From 76dea2285c3ddfa0c2f4160fb08fedaf2751fd4b Mon Sep 17 00:00:00 2001 From: Hank Stoever Date: Fri, 15 Nov 2024 11:29:46 -0800 Subject: [PATCH] fix: dont exit if block marked as globally accepted/rejected --- stacks-signer/src/signerdb.rs | 8 ++++++++ stacks-signer/src/v0/signer.rs | 13 +++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/stacks-signer/src/signerdb.rs b/stacks-signer/src/signerdb.rs index 1d2e650207..df83eee5f8 100644 --- a/stacks-signer/src/signerdb.rs +++ b/stacks-signer/src/signerdb.rs @@ -258,6 +258,14 @@ impl BlockInfo { self.state = state; Ok(()) } + + /// Check if the block is globally accepted or rejected + pub fn has_reached_consensus(&self) -> bool { + matches!( + self.state, + BlockState::GloballyAccepted | BlockState::GloballyRejected + ) + } } /// This struct manages a SQLite database connection diff --git a/stacks-signer/src/v0/signer.rs b/stacks-signer/src/v0/signer.rs index 424fe423b8..c2589ddf06 100644 --- a/stacks-signer/src/v0/signer.rs +++ b/stacks-signer/src/v0/signer.rs @@ -550,8 +550,11 @@ impl Signer { } }; if let Err(e) = block_info.mark_locally_accepted(false) { - warn!("{self}: Failed to mark block as locally accepted: {e:?}",); - return None; + if !block_info.has_reached_consensus() { + warn!("{self}: Failed to mark block as locally accepted: {e:?}",); + return None; + } + block_info.signed_self.get_or_insert(get_epoch_time_secs()); } let signature = self .private_key @@ -600,8 +603,10 @@ impl Signer { } }; if let Err(e) = block_info.mark_locally_rejected() { - warn!("{self}: Failed to mark block as locally rejected: {e:?}",); - return None; + if !block_info.has_reached_consensus() { + warn!("{self}: Failed to mark block as locally rejected: {e:?}",); + return None; + } } let block_rejection = BlockRejection::from_validate_rejection( block_validate_reject.clone(),