Skip to content

Commit 3469c50

Browse files
committed
Merge branch 'develop' of https://github.com/stacks-network/stacks-core into feat/miner-continues-tenure-if-tenure-empty
2 parents 4f5ecd9 + ea79fdc commit 3469c50

File tree

19 files changed

+614
-160
lines changed

19 files changed

+614
-160
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ and this project adheres to the versioning scheme outlined in the [README.md](RE
1313

1414
### Changed
1515

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

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

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);

stackslib/src/chainstate/stacks/tests/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -609,10 +609,7 @@ impl TestStacksNode {
609609
&miner_key.public_key,
610610
&burn_block.parent_snapshot.sortition_hash,
611611
)
612-
.expect(&format!(
613-
"FATAL: no private key for {}",
614-
miner_key.public_key.to_hex()
615-
));
612+
.unwrap_or_else(|| panic!("FATAL: no private key for {:?}", miner_key.public_key));
616613

617614
let (builder, parent_block_snapshot_opt) = match parent_stacks_block {
618615
None => {

stackslib/src/config/mod.rs

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,40 +1693,25 @@ pub struct NodeConfig {
16931693
pub stacker_dbs: Vec<QualifiedContractIdentifier>,
16941694
}
16951695

1696-
#[derive(Clone, Debug)]
1696+
#[derive(Clone, Debug, Default)]
16971697
pub enum CostEstimatorName {
1698+
#[default]
16981699
NaivePessimistic,
16991700
}
17001701

1701-
#[derive(Clone, Debug)]
1702+
#[derive(Clone, Debug, Default)]
17021703
pub enum FeeEstimatorName {
1704+
#[default]
17031705
ScalarFeeRate,
17041706
FuzzedWeightedMedianFeeRate,
17051707
}
17061708

1707-
#[derive(Clone, Debug)]
1709+
#[derive(Clone, Debug, Default)]
17081710
pub enum CostMetricName {
1711+
#[default]
17091712
ProportionDotProduct,
17101713
}
17111714

1712-
impl Default for CostEstimatorName {
1713-
fn default() -> Self {
1714-
CostEstimatorName::NaivePessimistic
1715-
}
1716-
}
1717-
1718-
impl Default for FeeEstimatorName {
1719-
fn default() -> Self {
1720-
FeeEstimatorName::ScalarFeeRate
1721-
}
1722-
}
1723-
1724-
impl Default for CostMetricName {
1725-
fn default() -> Self {
1726-
CostMetricName::ProportionDotProduct
1727-
}
1728-
}
1729-
17301715
impl CostEstimatorName {
17311716
fn panic_parse(s: String) -> CostEstimatorName {
17321717
if &s.to_lowercase() == "naive_pessimistic" {

stackslib/src/net/chat.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,12 @@ use crate::net::{
5252
use crate::util_lib::db::{DBConn, Error as db_error};
5353

5454
// did we or did we not successfully send a message?
55-
#[derive(Debug, Clone)]
55+
#[derive(Debug, Clone, Default)]
5656
pub struct NeighborHealthPoint {
5757
pub success: bool,
5858
pub time: u64,
5959
}
6060

61-
impl Default for NeighborHealthPoint {
62-
fn default() -> NeighborHealthPoint {
63-
NeighborHealthPoint {
64-
success: false,
65-
time: 0,
66-
}
67-
}
68-
}
69-
7061
pub const NUM_HEALTH_POINTS: usize = 32;
7162
pub const HEALTH_POINT_LIFETIME: u64 = 12 * 3600; // 12 hours
7263

0 commit comments

Comments
 (0)