Skip to content

Commit 7a15f92

Browse files
authored
Merge branch 'develop' into feat/signer-indexes
2 parents 5f0bf92 + ea79fdc commit 7a15f92

File tree

13 files changed

+58
-114
lines changed

13 files changed

+58
-114
lines changed

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
@@ -1691,40 +1691,25 @@ pub struct NodeConfig {
16911691
pub stacker_dbs: Vec<QualifiedContractIdentifier>,
16921692
}
16931693

1694-
#[derive(Clone, Debug)]
1694+
#[derive(Clone, Debug, Default)]
16951695
pub enum CostEstimatorName {
1696+
#[default]
16961697
NaivePessimistic,
16971698
}
16981699

1699-
#[derive(Clone, Debug)]
1700+
#[derive(Clone, Debug, Default)]
17001701
pub enum FeeEstimatorName {
1702+
#[default]
17011703
ScalarFeeRate,
17021704
FuzzedWeightedMedianFeeRate,
17031705
}
17041706

1705-
#[derive(Clone, Debug)]
1707+
#[derive(Clone, Debug, Default)]
17061708
pub enum CostMetricName {
1709+
#[default]
17071710
ProportionDotProduct,
17081711
}
17091712

1710-
impl Default for CostEstimatorName {
1711-
fn default() -> Self {
1712-
CostEstimatorName::NaivePessimistic
1713-
}
1714-
}
1715-
1716-
impl Default for FeeEstimatorName {
1717-
fn default() -> Self {
1718-
FeeEstimatorName::ScalarFeeRate
1719-
}
1720-
}
1721-
1722-
impl Default for CostMetricName {
1723-
fn default() -> Self {
1724-
CostMetricName::ProportionDotProduct
1725-
}
1726-
}
1727-
17281713
impl CostEstimatorName {
17291714
fn panic_parse(s: String) -> CostEstimatorName {
17301715
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

stackslib/src/net/download/nakamoto/tenure.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,10 +345,12 @@ impl TenureStartEnd {
345345
rc,
346346
pox_constants
347347
.block_height_to_reward_cycle(first_burn_height, wt_start.burn_height)
348-
.expect(&format!(
349-
"FATAL: tenure from before system start ({} <= {})",
350-
wt_start.burn_height, first_burn_height
351-
)),
348+
.unwrap_or_else(|| {
349+
panic!(
350+
"FATAL: tenure from before system start ({} <= {first_burn_height})",
351+
wt_start.burn_height
352+
)
353+
}),
352354
wt.processed,
353355
);
354356
tenure_start_end.fetch_end_block = true;

stackslib/src/net/httpcore.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,10 +1014,9 @@ impl StacksHttp {
10141014
pub fn set_response_handler(&mut self, request_verb: &str, request_path: &str) {
10151015
let handler_index = self
10161016
.find_response_handler(request_verb, request_path)
1017-
.expect(&format!(
1018-
"FATAL: could not find handler for '{}' '{}'",
1019-
request_verb, request_path
1020-
));
1017+
.unwrap_or_else(|| {
1018+
panic!("FATAL: could not find handler for '{request_verb}' '{request_path}'")
1019+
});
10211020
self.request_handler_index = Some(handler_index);
10221021
}
10231022

0 commit comments

Comments
 (0)