Skip to content

Commit 32461ef

Browse files
authored
Merge pull request #6287 from jferrant/cleanup/exit-early-from-block-eval-if-global-accepted
Do not evaluate globally accepted block proposals
2 parents 3cafbfd + 07fa4fa commit 32461ef

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

stacks-signer/src/v0/signer.rs

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -938,19 +938,25 @@ impl Signer {
938938
// TODO: should add a check to ignore an old burn block height if we know its outdated. Would require us to store the burn block height we last saw on the side.
939939
// the signer needs to be able to determine whether or not the block they're about to sign would conflict with an already-signed Stacks block
940940
let signer_signature_hash = block_proposal.block.header.signer_signature_hash();
941-
let prior_evaluation = self
942-
.block_lookup_by_reward_cycle(&signer_signature_hash)
943-
.and_then(|block_info| if should_reevaluate_block(&block_info) {
944-
debug!("Received a proposal for this block before, but our rejection reason allows us to reconsider";
945-
"reject_reason" => ?block_info.reject_reason);
946-
None
947-
} else {
948-
Some(block_info)
949-
});
950-
951-
// we previously considered this proposal, handle the status here
952-
if let Some(block_info) = prior_evaluation {
953-
return self.handle_prior_proposal_eval(&block_info);
941+
if let Some(block_info) = self.block_lookup_by_reward_cycle(&signer_signature_hash) {
942+
if block_info.state == BlockState::GloballyAccepted {
943+
info!("{self}: Received a block proposal for a block that is already globally accepted. Ignoring...";
944+
"signer_signature_hash" => %signer_signature_hash,
945+
"block_id" => %block_proposal.block.block_id(),
946+
"block_height" => block_proposal.block.header.chain_length,
947+
"burn_height" => block_proposal.burn_height,
948+
"consensus_hash" => %block_proposal.block.header.consensus_hash,
949+
"timestamp" => block_proposal.block.header.timestamp,
950+
"signed_group" => block_info.signed_group,
951+
"signed_self" => block_info.signed_self
952+
);
953+
return;
954+
}
955+
if !should_reevaluate_block(&block_info) {
956+
return self.handle_prior_proposal_eval(&block_info);
957+
}
958+
debug!("Received a proposal for this block before, but our rejection reason allows us to reconsider";
959+
"reject_reason" => ?block_info.reject_reason);
954960
}
955961

956962
info!(

0 commit comments

Comments
 (0)