Skip to content

Commit 8a345d4

Browse files
committed
chore: formatting / clippy, #5971
1 parent 4effafb commit 8a345d4

File tree

3 files changed

+23
-26
lines changed

3 files changed

+23
-26
lines changed

stacks-signer/src/v0/signer.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ use crate::client::{ClientError, SignerSlotID, StackerDB, StacksClient};
5252
use crate::config::{SignerConfig, SignerConfigMode};
5353
use crate::runloop::SignerResult;
5454
use crate::signerdb::{BlockInfo, BlockState, SignerDb};
55-
use crate::v0::signer_state::NewBurnBlock;
55+
use crate::v0::signer_state::{NewBurnBlock, TxReplayScopeOpt};
5656
use crate::Signer as SignerTrait;
5757

5858
/// A global variable that can be used to make signers repeat their proposal
@@ -125,12 +125,8 @@ pub struct Signer {
125125
pub global_state_evaluator: GlobalStateEvaluator,
126126
/// Whether to validate blocks with replay transactions
127127
pub validate_with_replay_tx: bool,
128-
/// TODO: To understand if keep this as a "local" state
129-
/// or if add this to the State Machine update
130128
/// Scope of Tx Replay in terms of Burn block boundaries
131-
/// - .0 is the fork originating the tx replay,
132-
/// - .1 is the canonical burnchain tip when Tx Replay begun
133-
pub tx_replay_scope: Option<(NewBurnBlock, NewBurnBlock)>,
129+
pub tx_replay_scope: TxReplayScopeOpt,
134130
}
135131

136132
impl std::fmt::Display for SignerMode {
@@ -270,7 +266,7 @@ impl SignerTrait<SignerMessage> for Signer {
270266

271267
let mut prior_state = self.local_state_machine.clone();
272268
if self.reward_cycle <= current_reward_cycle {
273-
self.local_state_machine.handle_pending_update(&self.signer_db, stacks_client,
269+
self.local_state_machine.handle_pending_update(&self.signer_db, stacks_client,
274270
&self.proposal_config,
275271
&mut self.tx_replay_scope)
276272
.unwrap_or_else(|e| error!("{self}: failed to update local state machine for pending update"; "err" => ?e));

stacks-signer/src/v0/signer_state.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ pub struct NewBurnBlock {
8888
pub consensus_hash: ConsensusHash,
8989
}
9090

91+
/// Scope of Tx Replay in terms of Burn block boundaries
92+
/// - tuple.0 is the fork originating the tx replay,
93+
/// - tuple.1 is the canonical burnchain tip when Tx Replay begun
94+
pub type TxReplayScopeOpt = Option<(NewBurnBlock, NewBurnBlock)>;
95+
9196
impl LocalStateMachine {
9297
/// Initialize a local state machine by querying the local stacks-node
9398
/// and signerdb for the current sortition information
@@ -192,7 +197,7 @@ impl LocalStateMachine {
192197
db: &SignerDb,
193198
client: &StacksClient,
194199
proposal_config: &ProposalEvalConfig,
195-
tx_replay_scope: &mut Option<(NewBurnBlock, NewBurnBlock)>,
200+
tx_replay_scope: &mut TxReplayScopeOpt,
196201
) -> Result<(), SignerChainstateError> {
197202
let LocalStateMachine::Pending { update, .. } = self else {
198203
return self.check_miner_inactivity(db, client, proposal_config);
@@ -502,7 +507,7 @@ impl LocalStateMachine {
502507
client: &StacksClient,
503508
proposal_config: &ProposalEvalConfig,
504509
mut expected_burn_block: Option<NewBurnBlock>,
505-
tx_replay_scope: &mut Option<(NewBurnBlock, NewBurnBlock)>,
510+
tx_replay_scope: &mut TxReplayScopeOpt,
506511
) -> Result<(), SignerChainstateError> {
507512
// set self to uninitialized so that if this function errors,
508513
// self is left as uninitialized.
@@ -913,11 +918,8 @@ impl LocalStateMachine {
913918
expected_burn_block: &NewBurnBlock,
914919
prior_state_machine: &SignerStateMachine,
915920
is_in_tx_replay_mode: bool,
916-
tx_replay_scope: &Option<(NewBurnBlock, NewBurnBlock)>,
917-
) -> Result<
918-
Option<(Vec<StacksTransaction>, Option<(NewBurnBlock, NewBurnBlock)>)>,
919-
SignerChainstateError,
920-
> {
921+
tx_replay_scope: &TxReplayScopeOpt,
922+
) -> Result<Option<(Vec<StacksTransaction>, TxReplayScopeOpt)>, SignerChainstateError> {
921923
if expected_burn_block.burn_block_height > prior_state_machine.burn_block_height {
922924
// no bitcoin fork, because we're advancing the burn block height
923925
return Ok(None);
@@ -953,7 +955,7 @@ impl LocalStateMachine {
953955
let updated_replay_set;
954956
let updated_scope_opt;
955957
if let Some(replay_set) =
956-
self.compute_forked_txs_set(db, client, expected_burn_block, &past_tip)?
958+
self.compute_forked_txs_set(db, client, expected_burn_block, past_tip)?
957959
{
958960
let scope = (expected_burn_block.clone(), past_tip.clone());
959961

@@ -1048,17 +1050,16 @@ impl LocalStateMachine {
10481050
))
10491051
.cloned()
10501052
.collect::<Vec<_>>();
1051-
let scope_opt;
1052-
if forked_txs.len() > 0 {
1053+
let scope_opt = if !forked_txs.is_empty() {
10531054
let scope = (expected_burn_block.clone(), potential_replay_tip);
10541055
info!("Tx Replay: replay set updated with {} tx(s)", forked_txs.len();
10551056
"tx_replay_set" => ?forked_txs,
10561057
"tx_replay_scope" => ?scope);
1057-
scope_opt = Some(scope);
1058+
Some(scope)
10581059
} else {
10591060
info!("Tx Replay: no transactions to be replayed.");
1060-
scope_opt = None;
1061-
}
1061+
None
1062+
};
10621063
Ok(Some((forked_txs, scope_opt)))
10631064
}
10641065

testnet/stacks-node/src/tests/signer/v0.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3732,7 +3732,7 @@ fn tx_replay_disagreement() {
37323732

37333733
#[test]
37343734
#[ignore]
3735-
/// Demostrate Tx Replay reject a proposal with partial replayed transactions,
3735+
/// Demonstrates Tx Replay reject a proposal with partial replayed transactions,
37363736
/// when not due to a Tenure Extend
37373737
///
37383738
/// The test flow is:
@@ -4149,7 +4149,7 @@ fn tx_replay_rejected_when_forking_across_reward_cycle() {
41494149

41504150
#[test]
41514151
#[ignore]
4152-
/// Demostrate Tx Replay state is kept by Signers after a fork
4152+
/// Demonstrates Tx Replay state is kept by Signers after a fork
41534153
/// occurred before the miner start replaying transactions
41544154
///
41554155
/// The test flow is:
@@ -4487,7 +4487,7 @@ fn tx_replay_with_fork_after_empty_tenures_before_starting_replaying_txs() {
44874487

44884488
#[test]
44894489
#[ignore]
4490-
/// Demostrate Tx Replay Set to be updated from a deepest fork
4490+
/// Demonstrates Tx Replay Set to be updated from a deepest fork
44914491
/// than the one that made Tx Replay to start
44924492
///
44934493
/// The test flow is:
@@ -4660,7 +4660,7 @@ fn tx_replay_with_fork_causing_replay_set_to_be_updated() {
46604660

46614661
#[test]
46624662
#[ignore]
4663-
/// Demostrate Tx Replay Set to be cleared from a deepest fork
4663+
/// Demonstrates Tx Replay Set to be cleared from a deepest fork
46644664
/// than the one that made Tx Replay to start, that led to
46654665
/// previous reward cylce
46664666
///
@@ -4809,7 +4809,7 @@ fn tx_replay_with_fork_causing_replay_to_be_cleared_due_to_cycle() {
48094809

48104810
#[test]
48114811
#[ignore]
4812-
/// Demostrate Tx Replay restart from scratch while it is in progress
4812+
/// Demonstrates Tx Replay restart from scratch while it is in progress
48134813
/// (partially replayed a subset of transaction) and a fork occurs.
48144814
/// In this case, partial replay is allowed because of tenure extend,
48154815
/// due to Tenure Budget exceeded.
@@ -5024,7 +5024,7 @@ fn tx_replay_with_fork_middle_replay_while_tenure_extending() {
50245024

50255025
#[test]
50265026
#[ignore]
5027-
/// Demostrate Tx Replay restart from scratch while it is in progress
5027+
/// Demonstrates Tx Replay restart from scratch while it is in progress
50285028
/// (partially replayed a subset of transaction), other transactions
50295029
/// are submitted, and then a fork occurs.
50305030
/// In this case, partial replay is allowed because of tenure extend,

0 commit comments

Comments
 (0)