Skip to content

Commit f6e5f66

Browse files
committed
Merge branch 'develop' of https://github.com/stacks-network/stacks-core into chore/add-clippy-stacks
2 parents b851d0f + a077937 commit f6e5f66

File tree

26 files changed

+97
-174
lines changed

26 files changed

+97
-174
lines changed

stacks-common/src/types/mod.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -700,12 +700,7 @@ impl Address for StacksAddress {
700700
}
701701

702702
fn from_string(s: &str) -> Option<StacksAddress> {
703-
let (version, bytes) = match c32_address_decode(s) {
704-
Ok((v, b)) => (v, b),
705-
Err(_) => {
706-
return None;
707-
}
708-
};
703+
let (version, bytes) = c32_address_decode(s).ok()?;
709704

710705
if bytes.len() != 20 {
711706
return None;

stackslib/src/burnchains/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1620,7 +1620,7 @@ impl BurnchainDB {
16201620
conn,
16211621
"SELECT affirmation_map FROM overrides WHERE reward_cycle = ?1",
16221622
params![u64_to_sql(reward_cycle)?],
1623-
|| format!("BUG: more than one override affirmation map for the same reward cycle"),
1623+
|| "BUG: more than one override affirmation map for the same reward cycle".to_string(),
16241624
)?;
16251625
if let Some(am) = &am_opt {
16261626
assert_eq!((am.len() + 1) as u64, reward_cycle);

stackslib/src/chainstate/burn/db/sortdb.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ impl db_keys {
940940
}
941941

942942
pub fn pox_reward_set_payouts_key() -> String {
943-
format!("sortition_db::reward_set::payouts")
943+
"sortition_db::reward_set::payouts".to_string()
944944
}
945945

946946
pub fn pox_reward_set_payouts_value(addrs: Vec<PoxAddress>, payout_per_addr: u128) -> String {

stackslib/src/chainstate/stacks/auth.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,9 +383,7 @@ impl StacksMessageCodec for OrderIndependentMultisigSpendingCondition {
383383

384384
// must all be compressed if we're using P2WSH
385385
if have_uncompressed && hash_mode == OrderIndependentMultisigHashMode::P2WSH {
386-
let msg = format!(
387-
"Failed to deserialize order independent multisig spending condition: expected compressed keys only"
388-
);
386+
let msg = "Failed to deserialize order independent multisig spending condition: expected compressed keys only".to_string();
389387
test_debug!("{msg}");
390388
return Err(codec_error::DeserializeError(msg));
391389
}

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,7 @@ pub fn make_json_boot_contracts_reference() -> String {
160160
&contract_supporting_docs,
161161
ClarityVersion::Clarity1,
162162
);
163-
format!(
164-
"{}",
165-
serde_json::to_string(&api_out).expect("Failed to serialize documentation")
166-
)
163+
serde_json::to_string(&api_out).expect("Failed to serialize documentation")
167164
}
168165

169166
#[cfg(test)]

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

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,7 @@ impl RewardSet {
280280
/// If there are no reward set signers, a ChainstateError is returned.
281281
pub fn total_signing_weight(&self) -> Result<u32, String> {
282282
let Some(ref reward_set_signers) = self.signers else {
283-
return Err(format!(
284-
"Unable to calculate total weight - No signers in reward set"
285-
));
283+
return Err("Unable to calculate total weight - No signers in reward set".to_string());
286284
};
287285
Ok(reward_set_signers
288286
.iter()
@@ -630,17 +628,12 @@ impl StacksChainState {
630628
sortdb: &SortitionDB,
631629
stacks_block_id: &StacksBlockId,
632630
) -> Result<u128, Error> {
633-
self.eval_boot_code_read_only(
634-
sortdb,
635-
stacks_block_id,
636-
"pox",
637-
&format!("(get-stacking-minimum)"),
638-
)
639-
.map(|value| {
640-
value
641-
.expect_u128()
642-
.expect("FATAL: unexpected PoX structure")
643-
})
631+
self.eval_boot_code_read_only(sortdb, stacks_block_id, "pox", "(get-stacking-minimum)")
632+
.map(|value| {
633+
value
634+
.expect_u128()
635+
.expect("FATAL: unexpected PoX structure")
636+
})
644637
}
645638

646639
pub fn get_total_ustx_stacked(
@@ -1743,11 +1736,7 @@ pub mod test {
17431736
}
17441737

17451738
pub fn get_balance(peer: &mut TestPeer, addr: &PrincipalData) -> u128 {
1746-
let value = eval_at_tip(
1747-
peer,
1748-
"pox",
1749-
&format!("(stx-get-balance '{})", addr.to_string()),
1750-
);
1739+
let value = eval_at_tip(peer, "pox", &format!("(stx-get-balance '{addr})"));
17511740
if let Value::UInt(balance) = value {
17521741
return balance;
17531742
} else {
@@ -1759,11 +1748,7 @@ pub mod test {
17591748
peer: &mut TestPeer,
17601749
addr: &PrincipalData,
17611750
) -> Option<(PoxAddress, u128, u128, Vec<u128>)> {
1762-
let value_opt = eval_at_tip(
1763-
peer,
1764-
"pox-4",
1765-
&format!("(get-stacker-info '{})", addr.to_string()),
1766-
);
1751+
let value_opt = eval_at_tip(peer, "pox-4", &format!("(get-stacker-info '{addr})"));
17671752
let data = if let Some(d) = value_opt.expect_optional().unwrap() {
17681753
d
17691754
} else {
@@ -1812,11 +1797,7 @@ pub mod test {
18121797
peer: &mut TestPeer,
18131798
addr: &PrincipalData,
18141799
) -> Option<(u128, PoxAddress, u128, u128)> {
1815-
let value_opt = eval_at_tip(
1816-
peer,
1817-
"pox",
1818-
&format!("(get-stacker-info '{})", addr.to_string()),
1819-
);
1800+
let value_opt = eval_at_tip(peer, "pox", &format!("(get-stacker-info '{addr})"));
18201801
let data = if let Some(d) = value_opt.expect_optional().unwrap() {
18211802
d
18221803
} else {
@@ -4267,7 +4248,7 @@ pub mod test {
42674248
(var-set test-result
42684249
(match result ok_value -1 err_value err_value))
42694250
(var-set test-run true))
4270-
", boot_code_test_addr().to_string()));
4251+
", boot_code_test_addr()));
42714252

42724253
block_txs.push(bob_test_tx);
42734254

@@ -4281,7 +4262,7 @@ pub mod test {
42814262
(var-set test-result
42824263
(match result ok_value -1 err_value err_value))
42834264
(var-set test-run true))
4284-
", boot_code_test_addr().to_string()));
4265+
", boot_code_test_addr()));
42854266

42864267
block_txs.push(alice_test_tx);
42874268

@@ -4295,7 +4276,7 @@ pub mod test {
42954276
(var-set test-result
42964277
(match result ok_value -1 err_value err_value))
42974278
(var-set test-run true))
4298-
", boot_code_test_addr().to_string()));
4279+
", boot_code_test_addr()));
42994280

43004281
block_txs.push(charlie_test_tx);
43014282
}

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

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -281,26 +281,22 @@ pub fn check_pox_print_event(
281281
match inner_tuple.data_map.get(inner_key) {
282282
Some(v) => {
283283
if v != &inner_val {
284-
wrong.push((
285-
format!("{}", &inner_key),
286-
format!("{}", v),
287-
format!("{}", &inner_val),
288-
));
284+
wrong.push((inner_key.to_string(), v.to_string(), inner_val.to_string()));
289285
}
290286
}
291287
None => {
292-
missing.push(format!("{}", &inner_key));
288+
missing.push(inner_key.to_string());
293289
}
294290
}
295291
// assert_eq!(inner_tuple.data_map.get(inner_key), Some(&inner_val));
296292
}
297293
if !missing.is_empty() || !wrong.is_empty() {
298-
eprintln!("missing:\n{:#?}", &missing);
299-
eprintln!("wrong:\n{:#?}", &wrong);
294+
eprintln!("missing:\n{missing:#?}");
295+
eprintln!("wrong:\n{wrong:#?}");
300296
assert!(false);
301297
}
302298
} else {
303-
error!("unexpected event type: {:?}", event);
299+
error!("unexpected event type: {event:?}");
304300
panic!("Unexpected transaction event type.")
305301
}
306302
}
@@ -1466,15 +1462,15 @@ fn delegate_stack_increase() {
14661462

14671463
assert_eq!(first_v2_cycle, EXPECTED_FIRST_V2_CYCLE);
14681464

1469-
eprintln!("First v2 cycle = {}", first_v2_cycle);
1465+
eprintln!("First v2 cycle = {first_v2_cycle}");
14701466

14711467
let epochs = StacksEpoch::all(0, 0, EMPTY_SORTITIONS as u64 + 10);
14721468

14731469
let observer = TestEventObserver::new();
14741470

14751471
let (mut peer, mut keys) = instantiate_pox_peer_with_epoch(
14761472
&burnchain,
1477-
&format!("pox_2_delegate_stack_increase"),
1473+
"pox_2_delegate_stack_increase",
14781474
Some(epochs.clone()),
14791475
Some(&observer),
14801476
);
@@ -1830,7 +1826,7 @@ fn stack_increase() {
18301826

18311827
let (mut peer, mut keys) = instantiate_pox_peer_with_epoch(
18321828
&burnchain,
1833-
&format!("test_simple_pox_2_increase"),
1829+
"test_simple_pox_2_increase",
18341830
Some(epochs.clone()),
18351831
Some(&observer),
18361832
);
@@ -4509,7 +4505,7 @@ fn stack_aggregation_increase() {
45094505

45104506
let (mut peer, mut keys) = instantiate_pox_peer_with_epoch(
45114507
&burnchain,
4512-
&format!("pox_2_stack_aggregation_increase"),
4508+
"pox_2_stack_aggregation_increase",
45134509
Some(epochs.clone()),
45144510
Some(&observer),
45154511
);
@@ -4959,7 +4955,7 @@ fn stack_in_both_pox1_and_pox2() {
49594955

49604956
let (mut peer, mut keys) = instantiate_pox_peer_with_epoch(
49614957
&burnchain,
4962-
&format!("stack_in_both_pox1_and_pox2"),
4958+
"stack_in_both_pox1_and_pox2",
49634959
Some(epochs.clone()),
49644960
Some(&observer),
49654961
);

stackslib/src/chainstate/stacks/db/blocks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ impl StacksChainState {
475475

476476
let _ = StacksChainState::mkdirs(&block_path)?;
477477

478-
block_path.push(format!("{}", to_hex(block_hash_bytes)));
478+
block_path.push(to_hex(block_hash_bytes).to_string());
479479
let blocks_path_str = block_path
480480
.to_str()
481481
.ok_or_else(|| Error::DBError(db_error::ParseError))?

stackslib/src/chainstate/stacks/db/transactions.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ impl StacksTransactionReceipt {
212212
span.start_line, span.start_column, check_error.diagnostic.message
213213
)
214214
} else {
215-
format!("{}", check_error.diagnostic.message)
215+
check_error.diagnostic.message.to_string()
216216
}
217217
}
218218
clarity_error::Parse(ref parse_error) => {
@@ -222,7 +222,7 @@ impl StacksTransactionReceipt {
222222
span.start_line, span.start_column, parse_error.diagnostic.message
223223
)
224224
} else {
225-
format!("{}", parse_error.diagnostic.message)
225+
parse_error.diagnostic.message.to_string()
226226
}
227227
}
228228
_ => error.to_string(),
@@ -980,14 +980,14 @@ impl StacksChainState {
980980
// post-conditions are not allowed for this variant, since they're non-sensical.
981981
// Their presence in this variant makes the transaction invalid.
982982
if !tx.post_conditions.is_empty() {
983-
let msg = format!("Invalid Stacks transaction: TokenTransfer transactions do not support post-conditions");
983+
let msg = "Invalid Stacks transaction: TokenTransfer transactions do not support post-conditions".to_string();
984984
info!("{}", &msg; "txid" => %tx.txid());
985985

986986
return Err(Error::InvalidStacksTransaction(msg, false));
987987
}
988988

989989
if *addr == origin_account.principal {
990-
let msg = format!("Invalid TokenTransfer: address tried to send to itself");
990+
let msg = "Invalid TokenTransfer: address tried to send to itself".to_string();
991991
info!("{}", &msg; "txid" => %tx.txid());
992992
return Err(Error::InvalidStacksTransaction(msg, false));
993993
}
@@ -1392,7 +1392,7 @@ impl StacksChainState {
13921392
// post-conditions are not allowed for this variant, since they're non-sensical.
13931393
// Their presence in this variant makes the transaction invalid.
13941394
if !tx.post_conditions.is_empty() {
1395-
let msg = format!("Invalid Stacks transaction: PoisonMicroblock transactions do not support post-conditions");
1395+
let msg = "Invalid Stacks transaction: PoisonMicroblock transactions do not support post-conditions".to_string();
13961396
info!("{}", &msg);
13971397

13981398
return Err(Error::InvalidStacksTransaction(msg, false));
@@ -1424,7 +1424,7 @@ impl StacksChainState {
14241424
// post-conditions are not allowed for this variant, since they're non-sensical.
14251425
// Their presence in this variant makes the transaction invalid.
14261426
if !tx.post_conditions.is_empty() {
1427-
let msg = format!("Invalid Stacks transaction: TenureChange transactions do not support post-conditions");
1427+
let msg = "Invalid Stacks transaction: TenureChange transactions do not support post-conditions".to_string();
14281428
info!("{msg}");
14291429

14301430
return Err(Error::InvalidStacksTransaction(msg, false));

stackslib/src/chainstate/stacks/miner.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2585,8 +2585,7 @@ impl StacksBlockBuilder {
25852585
event_observer: Option<&dyn MemPoolEventDispatcher>,
25862586
burnchain: &Burnchain,
25872587
) -> Result<(StacksBlock, ExecutionCost, u64), Error> {
2588-
if let TransactionPayload::Coinbase(..) = coinbase_tx.payload {
2589-
} else {
2588+
if !matches!(coinbase_tx.payload, TransactionPayload::Coinbase(..)) {
25902589
return Err(Error::MemPoolError(
25912590
"Not a coinbase transaction".to_string(),
25922591
));

0 commit comments

Comments
 (0)