From 7af0a11b493a9a462c29dd894aaf9e6844f9bf2e Mon Sep 17 00:00:00 2001 From: Jude Nelson Date: Tue, 26 Nov 2024 22:07:00 -0500 Subject: [PATCH] hotfix: load the BurnStateDB implementation from the block's header's consensus_hash field, not the canonical tip --- stackslib/src/net/api/postblock_proposal.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/stackslib/src/net/api/postblock_proposal.rs b/stackslib/src/net/api/postblock_proposal.rs index 517105515c..cb009d0621 100644 --- a/stackslib/src/net/api/postblock_proposal.rs +++ b/stackslib/src/net/api/postblock_proposal.rs @@ -363,9 +363,17 @@ impl NakamotoBlockProposal { }); } - let sort_tip = SortitionDB::get_canonical_sortition_tip(sortdb.conn())?; - let burn_dbconn: SortitionHandleConn = sortdb.index_handle(&sort_tip); - let mut db_handle = sortdb.index_handle(&sort_tip); + let sort_tip = SortitionDB::get_block_snapshot_consensus( + sortdb.conn(), + &self.block.header.consensus_hash, + )? + .ok_or_else(|| BlockValidateRejectReason { + reason_code: ValidateRejectCode::NoSuchTenure, + reason: "Failed to find sortition for block tenure".to_string(), + })?; + + let burn_dbconn: SortitionHandleConn = sortdb.index_handle(&sort_tip.sortition_id); + let mut db_handle = sortdb.index_handle(&sort_tip.sortition_id); // (For the signer) // Verify that the block's tenure is on the canonical sortition history