Skip to content

Commit 28fb68f

Browse files
authored
Merge pull request #6184 from fdefelici/feat/tx-replay-handle-forks
test: tx replay handle forks
2 parents 2de8ade + f1e9f7b commit 28fb68f

File tree

5 files changed

+1716
-172
lines changed

5 files changed

+1716
-172
lines changed

stacks-signer/src/v0/signer.rs

Lines changed: 11 additions & 3 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, ReplayScopeOpt};
5656
use crate::Signer as SignerTrait;
5757

5858
/// A global variable that can be used to make signers repeat their proposal
@@ -125,6 +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+
/// Scope of Tx Replay in terms of Burn block boundaries
129+
pub tx_replay_scope: ReplayScopeOpt,
128130
}
129131

130132
impl std::fmt::Display for SignerMode {
@@ -241,6 +243,7 @@ impl SignerTrait<SignerMessage> for Signer {
241243
recently_processed: RecentlyProcessedBlocks::new(),
242244
global_state_evaluator,
243245
validate_with_replay_tx: signer_config.validate_with_replay_tx,
246+
tx_replay_scope: None,
244247
}
245248
}
246249

@@ -263,7 +266,9 @@ impl SignerTrait<SignerMessage> for Signer {
263266

264267
let mut prior_state = self.local_state_machine.clone();
265268
if self.reward_cycle <= current_reward_cycle {
266-
self.local_state_machine.handle_pending_update(&self.signer_db, stacks_client, &self.proposal_config)
269+
self.local_state_machine.handle_pending_update(&self.signer_db, stacks_client,
270+
&self.proposal_config,
271+
&mut self.tx_replay_scope)
267272
.unwrap_or_else(|e| error!("{self}: failed to update local state machine for pending update"; "err" => ?e));
268273
}
269274

@@ -532,11 +537,14 @@ impl Signer {
532537
);
533538
panic!("{self} Failed to write burn block event to signerdb: {e}");
534539
});
540+
535541
self.local_state_machine
536542
.bitcoin_block_arrival(&self.signer_db, stacks_client, &self.proposal_config, Some(NewBurnBlock {
537543
burn_block_height: *burn_height,
538544
consensus_hash: *consensus_hash,
539-
}))
545+
}),
546+
&mut self.tx_replay_scope
547+
)
540548
.unwrap_or_else(|e| error!("{self}: failed to update local state machine for latest bitcoin block arrival"; "err" => ?e));
541549
*sortition_state = None;
542550
}

0 commit comments

Comments
 (0)