Skip to content

Commit 5a76b47

Browse files
committed
Merge remote-tracking branch 'origin/develop' into feat/add-version-to-block-proposal
2 parents 4572469 + ea79fdc commit 5a76b47

File tree

26 files changed

+1181
-159
lines changed

26 files changed

+1181
-159
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ and this project adheres to the versioning scheme outlined in the [README.md](RE
1010
### Added
1111

1212
- The `BlockProposal` StackerDB message serialization struct now includes a `server_version` string, which represents the version of the node that the miner is using. ([#5803](https://github.com/stacks-network/stacks-core/pull/5803))
13+
- Add `vrf_seed` to the `/v3/sortitions` rpc endpoint
1314

1415
### Changed
1516

17+
- Miner will stop waiting for signatures on a block if the Stacks tip advances (causing the block it had proposed to be invalid).
18+
1619
### Fixed
1720

1821
- Error responses to /v2/transactions/fees are once again expressed as JSON ([#4145](https://github.com/stacks-network/stacks-core/issues/4145)).

contrib/tools/block-replay.sh

Lines changed: 471 additions & 0 deletions
Large diffs are not rendered by default.

docs/rpc/api/core-node/get_sortitions.example.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"miner_pk_hash160": "0x6bc51b33e9f3626944eb879147e18111581f8f9b",
1111
"stacks_parent_ch": "0x697357c72da55b759b1d6b721676c92c69f0b490",
1212
"last_sortition_ch": "0x697357c72da55b759b1d6b721676c92c69f0b490",
13-
"committed_block_hash": "0xeea47d6d639c565027110e192e308fb11656183d5c077bcd718d830652800183"
13+
"committed_block_hash": "0xeea47d6d639c565027110e192e308fb11656183d5c077bcd718d830652800183",
14+
"vrf_seed": "0x48b754acc291a5bfad1354ee19bbc471f14af2b21dc7eccc0f929bd16798defe"
1415
}
1516
]

stacks-signer/src/tests/chainstate.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,7 @@ fn check_proposal_refresh() {
559559
stacks_parent_ch: Some(view.cur_sortition.parent_tenure_id),
560560
last_sortition_ch: Some(view.cur_sortition.parent_tenure_id),
561561
committed_block_hash: None,
562+
vrf_seed: None,
562563
},
563564
SortitionInfo {
564565
burn_block_hash: BurnchainHeaderHash([128; 32]),
@@ -572,6 +573,7 @@ fn check_proposal_refresh() {
572573
stacks_parent_ch: Some(view.cur_sortition.parent_tenure_id),
573574
last_sortition_ch: Some(view.cur_sortition.parent_tenure_id),
574575
committed_block_hash: None,
576+
vrf_seed: None,
575577
},
576578
];
577579

stacks-signer/src/v0/signer.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,10 @@ impl SignerTrait<SignerMessage> for Signer {
207207
"block_height" => b.header.chain_length,
208208
"signer_sighash" => %b.header.signer_signature_hash(),
209209
);
210+
#[cfg(any(test, feature = "testing"))]
211+
if self.test_skip_block_broadcast(b) {
212+
return;
213+
}
210214
stacks_client.post_block_until_ok(self, b);
211215
}
212216
SignerMessage::MockProposal(mock_proposal) => {

stackslib/src/burnchains/bitcoin/indexer.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,7 @@ impl BitcoinIndexer {
234234
true,
235235
false,
236236
)
237-
.expect(&format!(
238-
"Failed to open {:?}",
239-
working_dir_path.to_str().unwrap()
240-
));
237+
.unwrap_or_else(|_| panic!("Failed to open {working_dir_path:?}"));
241238

242239
BitcoinIndexer {
243240
config: BitcoinIndexerConfig::default_regtest(

stackslib/src/burnchains/tests/mod.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -439,10 +439,7 @@ impl TestBurnchainBlock {
439439
// prove on the last-ever sortition's hash to produce the new seed
440440
let proof = miner
441441
.make_proof(&leader_key.public_key, &last_snapshot.sortition_hash)
442-
.expect(&format!(
443-
"FATAL: no private key for {}",
444-
leader_key.public_key.to_hex()
445-
));
442+
.unwrap_or_else(|| panic!("FATAL: no private key for {:?}", leader_key.public_key));
446443

447444
VRFSeed::from_proof(&proof)
448445
});
@@ -655,10 +652,12 @@ impl TestBurnchainBlock {
655652
let parent_hdr = indexer
656653
.read_burnchain_header(self.block_height.saturating_sub(1))
657654
.unwrap()
658-
.expect(&format!(
659-
"BUG: could not read block at height {}",
660-
self.block_height.saturating_sub(1)
661-
));
655+
.unwrap_or_else(|| {
656+
panic!(
657+
"BUG: could not read block at height {}",
658+
self.block_height.saturating_sub(1)
659+
)
660+
});
662661

663662
let now = BURNCHAIN_TEST_BLOCK_TIME;
664663
let block_hash = BurnchainHeaderHash::from_bitcoin_hash(

stackslib/src/chainstate/nakamoto/tests/node.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,7 +1344,7 @@ impl TestPeer<'_> {
13441344
);
13451345
}
13461346
Err(e) => {
1347-
panic!("Failure fetching recipient set: {:?}", e);
1347+
panic!("Failure fetching recipient set: {e:?}");
13481348
}
13491349
};
13501350

@@ -1368,16 +1368,11 @@ impl TestPeer<'_> {
13681368
let proof = self
13691369
.miner
13701370
.make_proof(&miner_key.public_key, &tip.sortition_hash)
1371-
.expect(&format!(
1372-
"FATAL: no private key for {}",
1373-
miner_key.public_key.to_hex()
1374-
));
1371+
.unwrap_or_else(|| panic!("FATAL: no private key for {:?}", miner_key.public_key));
13751372
self.sortdb = Some(sortdb);
13761373
debug!(
1377-
"VRF proof made from {} over {}: {}",
1378-
&miner_key.public_key.to_hex(),
1379-
&tip.sortition_hash,
1380-
&proof.to_hex()
1374+
"VRF proof made from {:?} over {}: {proof:?}",
1375+
miner_key.public_key, &tip.sortition_hash
13811376
);
13821377
proof
13831378
}

stackslib/src/chainstate/stacks/boot/pox_2_tests.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,10 +334,7 @@ pub fn check_stacking_state_invariants(
334334
.burn_header_height;
335335

336336
let stacking_state_entry = get_stacking_state_pox(peer, tip, stacker, active_pox_contract)
337-
.expect(&format!(
338-
"Invariant violated: reward-cycle entry has stacker field set, but not present in stacker-state (pox_contract = {})",
339-
active_pox_contract,
340-
))
337+
.unwrap_or_else(|| panic!("Invariant violated: reward-cycle entry has stacker field set, but not present in stacker-state (pox_contract = {active_pox_contract})"))
341338
.expect_tuple().unwrap();
342339
let first_cycle = stacking_state_entry
343340
.get("first-reward-cycle")

stackslib/src/chainstate/stacks/boot/pox_4_tests.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8353,9 +8353,9 @@ fn test_scenario_three(use_nakamoto: bool) {
83538353
assert_eq!(amount_locked_actual, amount_locked_expected);
83548354

83558355
// Check Bob signer key
8356-
let signer_key_expected = Value::buff_from(bob.public_key.to_bytes_compressed());
8356+
let signer_key_expected = Value::buff_from(bob.public_key.to_bytes_compressed()).unwrap();
83578357
let signer_key_actual = bob_stack_tx_ok.data_map.get("signer-key").unwrap().clone();
8358-
assert_eq!(signer_key_actual, signer_key_actual);
8358+
assert_eq!(signer_key_actual, signer_key_expected);
83598359

83608360
// 5. Check that David can't delegate-stack-stx Eve if delegation expires during lock period
83618361
let eve_delegate_stx_to_david_err = receipts
@@ -10262,7 +10262,7 @@ fn test_scenario_five(use_nakamoto: bool) {
1026210262
for (idx, (stacker, stacker_lock_period)) in davids_stackers.iter().enumerate() {
1026310263
let (pox_address, first_reward_cycle, lock_period, _indices) =
1026410264
get_stacker_info_pox_4(&mut peer, &stacker.principal)
10265-
.expect(format!("Failed to find stacker {}", idx).as_str());
10265+
.unwrap_or_else(|| panic!("Failed to find stacker {idx}"));
1026610266
assert_eq!(first_reward_cycle, reward_cycle);
1026710267
assert_eq!(pox_address, david.pox_address);
1026810268
assert_eq!(lock_period, *stacker_lock_period);
@@ -10271,7 +10271,7 @@ fn test_scenario_five(use_nakamoto: bool) {
1027110271
for (idx, (stacker, stacker_lock_period)) in eves_stackers.iter().enumerate() {
1027210272
let (pox_address, first_reward_cycle, lock_period, _indices) =
1027310273
get_stacker_info_pox_4(&mut peer, &stacker.principal)
10274-
.expect(format!("Failed to find stacker {}", idx).as_str());
10274+
.unwrap_or_else(|| panic!("Failed to find stacker {idx}"));
1027510275
assert_eq!(first_reward_cycle, reward_cycle);
1027610276
assert_eq!(pox_address, eve.pox_address);
1027710277
assert_eq!(lock_period, *stacker_lock_period);

0 commit comments

Comments
 (0)