From 01ffedd4bf5f2380156312cd40a2a879a2933dfa Mon Sep 17 00:00:00 2001 From: Federico De Felici Date: Fri, 3 Oct 2025 12:11:24 +0200 Subject: [PATCH 1/7] feat: add marf input computation for test-harness, #6523 --- stackslib/src/chainstate/tests/consensus.rs | 107 +++++++++++++++++--- 1 file changed, 92 insertions(+), 15 deletions(-) diff --git a/stackslib/src/chainstate/tests/consensus.rs b/stackslib/src/chainstate/tests/consensus.rs index 2c5731e898..0193b87d3d 100644 --- a/stackslib/src/chainstate/tests/consensus.rs +++ b/stackslib/src/chainstate/tests/consensus.rs @@ -39,8 +39,11 @@ use crate::burnchains::PoxConstants; use crate::chainstate::burn::db::sortdb::SortitionDB; use crate::chainstate::nakamoto::{NakamotoBlock, NakamotoBlockHeader, NakamotoChainState}; use crate::chainstate::stacks::boot::{RewardSet, RewardSetData}; -use crate::chainstate::stacks::db::StacksEpochReceipt; -use crate::chainstate::stacks::{Error as ChainstateError, StacksTransaction, TenureChangeCause}; +use crate::chainstate::stacks::db::{StacksChainState, StacksEpochReceipt}; +use crate::chainstate::stacks::{ + Error as ChainstateError, StacksTransaction, TenureChangeCause, MINER_BLOCK_CONSENSUS_HASH, + MINER_BLOCK_HEADER_HASH, +}; use crate::chainstate::tests::TestChainstate; use crate::clarity_vm::clarity::{Error as ClarityError, PreCommitClarityBlock}; use crate::core::test_util::{make_contract_publish, make_stacks_transfer_tx}; @@ -170,6 +173,16 @@ pub enum ExpectedResult { Failure(String), } +impl ExpectedResult { + pub fn is_success(&self) -> bool { + matches!(&self, Self::Success(_)) + } + + pub fn is_failure(&self) -> bool { + matches!(&self, Self::Failure(_)) + } +} + /// Represents a block to be appended in a test and its expected result. #[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] pub struct TestBlock { @@ -181,6 +194,16 @@ pub struct TestBlock { pub expected_result: ExpectedResult, } +impl TestBlock { + pub fn is_success(&self) -> bool { + self.expected_result.is_success() + } + + pub fn is_failure(&self) -> bool { + self.expected_result.is_failure() + } +} + /// Defines a test vector for a consensus test, including chainstate setup and expected outcomes. #[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] pub struct ConsensusTestVector { @@ -459,10 +482,10 @@ impl ConsensusTest<'_> { self.test_vector.epoch_blocks[&epoch].len() ); self.advance_to_epoch(epoch); - for (i, block) in self.test_vector.epoch_blocks[&epoch].iter().enumerate() { + let epoch_blocks = self.test_vector.epoch_blocks[&epoch].clone(); + for (i, block) in epoch_blocks.iter().enumerate() { debug!("--------- Running block {i} for epoch {epoch:?} ---------"); - let (nakamoto_block, block_size) = - self.construct_nakamoto_block(&block.marf_hash, &block.transactions); + let (nakamoto_block, block_size) = self.construct_nakamoto_block(&block); let sortdb = self.chain.sortdb.take().unwrap(); let chain_tip = NakamotoChainState::get_canonical_block_header( self.chain.stacks_node().chainstate.db(), @@ -524,13 +547,8 @@ impl ConsensusTest<'_> { } } - /// Constructs a Nakamoto block with the given transactions and state index root. - fn construct_nakamoto_block( - &self, - marf_hash: &str, - transactions: &[StacksTransaction], - ) -> (NakamotoBlock, usize) { - let state_index_root = TrieHash::from_hex(marf_hash).unwrap(); + /// Constructs a Nakamoto block with the given [`TestBlock`] configuration. + fn construct_nakamoto_block(&mut self, test_block: &TestBlock) -> (NakamotoBlock, usize) { let chain_tip = NakamotoChainState::get_canonical_block_header( self.chain.stacks_node.as_ref().unwrap().chainstate.db(), self.chain.sortdb.as_ref().unwrap(), @@ -553,13 +571,13 @@ impl ConsensusTest<'_> { consensus_hash: chain_tip.consensus_hash.clone(), parent_block_id: chain_tip.index_block_hash(), tx_merkle_root: Sha512Trunc256Sum::from_data(&[]), - state_index_root, + state_index_root: TrieHash::from_empty_data(), timestamp: 1, miner_signature: MessageSignature::empty(), signer_signature: vec![], pox_treatment: BitVec::ones(1).unwrap(), }, - txs: transactions.to_vec(), + txs: test_block.transactions.to_vec(), }; let tx_merkle_root = { @@ -570,14 +588,73 @@ impl ConsensusTest<'_> { .collect(); MerkleTree::::new(&txid_vecs).root() }; - block.header.tx_merkle_root = tx_merkle_root; + + block.header.state_index_root = if test_block.is_success() { + self.compute_block_marf_index(block.header.timestamp, &block.txs) + } else { + //64 hex zeroes + TrieHash::from_bytes(&[0; 32]).unwrap() + }; + self.chain.miner.sign_nakamoto_block(&mut block); let mut signers = self.chain.config.test_signers.clone().unwrap_or_default(); signers.sign_nakamoto_block(&mut block, cycle); let block_len = block.serialize_to_vec().len(); (block, block_len) } + + fn compute_block_marf_index( + &mut self, + block_time: u64, + block_txs: &Vec, + ) -> TrieHash { + let node = self.chain.stacks_node.as_mut().unwrap(); + let sortdb = self.chain.sortdb.as_ref().unwrap(); + let burndb_conn = sortdb.index_handle_at_tip(); + let chainstate = &mut node.chainstate; + + let chain_tip = NakamotoChainState::get_canonical_block_header(chainstate.db(), &sortdb) + .unwrap() + .unwrap(); + + let (chainstate_tx, clarity_instance) = chainstate.chainstate_tx_begin().unwrap(); + let burndb_conn = sortdb.index_handle_at_tip(); + + let mut clarity_tx = StacksChainState::chainstate_block_begin( + &chainstate_tx, + clarity_instance, + &burndb_conn, + &chain_tip.consensus_hash, + &chain_tip.anchored_header.block_hash(), + &MINER_BLOCK_CONSENSUS_HASH, + &MINER_BLOCK_HEADER_HASH, + ); + + clarity_tx + .connection() + .as_free_transaction(|clarity_tx_conn| { + clarity_tx_conn.with_clarity_db(|db| { + db.setup_block_metadata(Some(block_time))?; + Ok(()) + }) + }) + .unwrap(); + + StacksChainState::process_block_transactions(&mut clarity_tx, block_txs, 0).unwrap(); + + NakamotoChainState::finish_block( + &mut clarity_tx, + None, + false, + chain_tip.burn_header_height, + ) + .unwrap(); + + let trie_hash = clarity_tx.seal(); + clarity_tx.rollback_block(); + return trie_hash; + } } #[test] From da5ab83727b569f8ed559a391e19d83f4e9fe5fa Mon Sep 17 00:00:00 2001 From: Federico De Felici Date: Fri, 3 Oct 2025 12:41:40 +0200 Subject: [PATCH 2/7] chore: add documentation for marf input computation, #6523 --- stackslib/src/chainstate/tests/consensus.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/stackslib/src/chainstate/tests/consensus.rs b/stackslib/src/chainstate/tests/consensus.rs index 0193b87d3d..b06d875f08 100644 --- a/stackslib/src/chainstate/tests/consensus.rs +++ b/stackslib/src/chainstate/tests/consensus.rs @@ -174,10 +174,11 @@ pub enum ExpectedResult { } impl ExpectedResult { + /// Returns `true` if this result represents a successful outcome. pub fn is_success(&self) -> bool { matches!(&self, Self::Success(_)) } - + /// Returns `true` if this result represents a failed outcome. pub fn is_failure(&self) -> bool { matches!(&self, Self::Failure(_)) } @@ -195,10 +196,12 @@ pub struct TestBlock { } impl TestBlock { + /// Returns `true` if the [`ExpectedResult`] variant represents a successful outcome. pub fn is_success(&self) -> bool { self.expected_result.is_success() } + /// Returns `true` if the [`ExpectedResult`] variant represents a failed outcome. pub fn is_failure(&self) -> bool { self.expected_result.is_failure() } @@ -590,10 +593,11 @@ impl ConsensusTest<'_> { }; block.header.tx_merkle_root = tx_merkle_root; + // Set the MARF root hash: compute it for success cases, + // or use an all-zero hash for failure cases. block.header.state_index_root = if test_block.is_success() { - self.compute_block_marf_index(block.header.timestamp, &block.txs) + self.compute_block_marf_root_hash(block.header.timestamp, &block.txs) } else { - //64 hex zeroes TrieHash::from_bytes(&[0; 32]).unwrap() }; @@ -604,7 +608,15 @@ impl ConsensusTest<'_> { (block, block_len) } - fn compute_block_marf_index( + /// Computes the MARF root hash for a block. + /// + /// This function is intended for use in success test cases only, where all + /// transactions are valid. In other scenarios, the computation may fail. + /// + /// The implementation is deliberately minimal: it does not cover every + /// possible situation (such as new tenure handling), but it should be + /// sufficient for the scope of our test cases. + fn compute_block_marf_root_hash( &mut self, block_time: u64, block_txs: &Vec, From b3bdc1de692a6f4a83db53a4a347a6f35db7e688 Mon Sep 17 00:00:00 2001 From: Federico De Felici Date: Fri, 3 Oct 2025 12:45:00 +0200 Subject: [PATCH 3/7] chore: improve marf computation failure message, #6523 --- stackslib/src/chainstate/tests/consensus.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/stackslib/src/chainstate/tests/consensus.rs b/stackslib/src/chainstate/tests/consensus.rs index b06d875f08..c227073a20 100644 --- a/stackslib/src/chainstate/tests/consensus.rs +++ b/stackslib/src/chainstate/tests/consensus.rs @@ -651,9 +651,10 @@ impl ConsensusTest<'_> { Ok(()) }) }) - .unwrap(); + .expect("MARF: Failure on block metadata setup!"); - StacksChainState::process_block_transactions(&mut clarity_tx, block_txs, 0).unwrap(); + StacksChainState::process_block_transactions(&mut clarity_tx, block_txs, 0) + .expect("MARF: Failure on processing block transactions!"); NakamotoChainState::finish_block( &mut clarity_tx, @@ -661,7 +662,7 @@ impl ConsensusTest<'_> { false, chain_tip.burn_header_height, ) - .unwrap(); + .expect("MARF: Failure on finishing block!"); let trie_hash = clarity_tx.seal(); clarity_tx.rollback_block(); From 32f353338014121d409e4a6bd04ca0ab50328862 Mon Sep 17 00:00:00 2001 From: Federico De Felici Date: Fri, 3 Oct 2025 13:17:03 +0200 Subject: [PATCH 4/7] chore: remove unused marf_hash field, #6523 --- stackslib/src/chainstate/tests/consensus.rs | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/stackslib/src/chainstate/tests/consensus.rs b/stackslib/src/chainstate/tests/consensus.rs index c227073a20..2d1e1be4e7 100644 --- a/stackslib/src/chainstate/tests/consensus.rs +++ b/stackslib/src/chainstate/tests/consensus.rs @@ -187,8 +187,6 @@ impl ExpectedResult { /// Represents a block to be appended in a test and its expected result. #[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] pub struct TestBlock { - /// Hex representation of the MARF hash for block construction. - pub marf_hash: String, /// Transactions to include in the block pub transactions: Vec, /// The expected result after appending the constructed block. @@ -680,7 +678,6 @@ fn test_append_empty_blocks() { epoch_blocks.insert( StacksEpochId::Epoch30, vec![TestBlock { - marf_hash: "f1934080b22ef0192cfb39710690e7cb0efa9cff950832b33544bde3aa1484a5".into(), transactions: vec![], expected_result: expected_result.clone(), }], @@ -688,7 +685,6 @@ fn test_append_empty_blocks() { epoch_blocks.insert( StacksEpochId::Epoch31, vec![TestBlock { - marf_hash: "a05f1383613215f5789eb977e4c62dfbb789d90964e14865d109375f7f6dc3cf".into(), transactions: vec![], expected_result: expected_result.clone(), }], @@ -696,7 +692,6 @@ fn test_append_empty_blocks() { epoch_blocks.insert( StacksEpochId::Epoch32, vec![TestBlock { - marf_hash: "c17829daff8746329c65ae658f4087519c6a8bd8c7f21e51644ddbc9c010390f".into(), transactions: vec![], expected_result: expected_result.clone(), }], @@ -704,7 +699,6 @@ fn test_append_empty_blocks() { epoch_blocks.insert( StacksEpochId::Epoch33, vec![TestBlock { - marf_hash: "23ecbcb91cac914ba3994a15f3ea7189bcab4e9762530cd0e6c7d237fcd6dc78".into(), transactions: vec![], expected_result: expected_result.clone(), }], @@ -723,7 +717,6 @@ fn test_append_state_index_root_mismatches() { epoch_blocks.insert( StacksEpochId::Epoch30, vec![TestBlock { - marf_hash: "0000000000000000000000000000000000000000000000000000000000000000".into(), transactions: vec![], expected_result: ExpectedResult::Failure( ChainstateError::InvalidStacksBlock( @@ -736,7 +729,6 @@ fn test_append_state_index_root_mismatches() { epoch_blocks.insert( StacksEpochId::Epoch31, vec![TestBlock { - marf_hash: "0000000000000000000000000000000000000000000000000000000000000000".into(), transactions: vec![], expected_result: ExpectedResult::Failure( ChainstateError::InvalidStacksBlock( @@ -749,7 +741,6 @@ fn test_append_state_index_root_mismatches() { epoch_blocks.insert( StacksEpochId::Epoch32, vec![TestBlock { - marf_hash: "0000000000000000000000000000000000000000000000000000000000000000".into(), transactions: vec![], expected_result: ExpectedResult::Failure( ChainstateError::InvalidStacksBlock( @@ -762,7 +753,6 @@ fn test_append_state_index_root_mismatches() { epoch_blocks.insert( StacksEpochId::Epoch33, vec![TestBlock { - marf_hash: "0000000000000000000000000000000000000000000000000000000000000000".into(), transactions: vec![], expected_result: ExpectedResult::Failure( ChainstateError::InvalidStacksBlock( @@ -833,7 +823,6 @@ fn test_append_stx_transfers_success() { epoch_blocks.insert( StacksEpochId::Epoch30, vec![TestBlock { - marf_hash: "63ea49669d2216ebc7e4f8b5e1cd2c99b8aff9806794adf87dcf709c0a244798".into(), transactions: transactions.clone(), expected_result: ExpectedResult::Success(outputs.clone()), }], @@ -841,7 +830,6 @@ fn test_append_stx_transfers_success() { epoch_blocks.insert( StacksEpochId::Epoch31, vec![TestBlock { - marf_hash: "7fc538e605a4a353871c4a655ae850fe9a70c3875b65f2bb42ea3bef5effed2c".into(), transactions: transactions.clone(), expected_result: ExpectedResult::Success(outputs.clone()), }], @@ -849,7 +837,6 @@ fn test_append_stx_transfers_success() { epoch_blocks.insert( StacksEpochId::Epoch32, vec![TestBlock { - marf_hash: "4d5c9a6d07806ac5006137de22b083de66fff7119143dd5cd92e4a457d66e028".into(), transactions: transactions.clone(), expected_result: ExpectedResult::Success(outputs.clone()), }], @@ -857,7 +844,6 @@ fn test_append_stx_transfers_success() { epoch_blocks.insert( StacksEpochId::Epoch33, vec![TestBlock { - marf_hash: "66eed8c0ab31db111a5adcc83d38a7004c6e464e3b9fb9f52ec589bc6d5f2d32".into(), transactions: transactions.clone(), expected_result: ExpectedResult::Success(outputs.clone()), }], @@ -900,7 +886,6 @@ fn test_append_chainstate_error_expression_stack_depth_too_deep() { epoch_blocks.insert( StacksEpochId::Epoch30, vec![TestBlock { - marf_hash: "0000000000000000000000000000000000000000000000000000000000000000".into(), transactions: vec![tx.clone()], expected_result: ExpectedResult::Failure( ChainstateError::InvalidStacksBlock(format!( @@ -913,7 +898,6 @@ fn test_append_chainstate_error_expression_stack_depth_too_deep() { epoch_blocks.insert( StacksEpochId::Epoch31, vec![TestBlock { - marf_hash: "0000000000000000000000000000000000000000000000000000000000000000".into(), transactions: vec![tx.clone()], expected_result: ExpectedResult::Failure( ChainstateError::InvalidStacksBlock(format!( @@ -926,7 +910,6 @@ fn test_append_chainstate_error_expression_stack_depth_too_deep() { epoch_blocks.insert( StacksEpochId::Epoch32, vec![TestBlock { - marf_hash: "0000000000000000000000000000000000000000000000000000000000000000".into(), transactions: vec![tx.clone()], expected_result: ExpectedResult::Failure( ChainstateError::InvalidStacksBlock(format!( @@ -939,7 +922,6 @@ fn test_append_chainstate_error_expression_stack_depth_too_deep() { epoch_blocks.insert( StacksEpochId::Epoch33, vec![TestBlock { - marf_hash: "0000000000000000000000000000000000000000000000000000000000000000".into(), transactions: vec![tx.clone()], expected_result: ExpectedResult::Failure( ChainstateError::InvalidStacksBlock(format!( From ef3aa827a32fce64df202d37cd0cf614b18dc222 Mon Sep 17 00:00:00 2001 From: Federico De Felici Date: Wed, 8 Oct 2025 12:08:06 +0200 Subject: [PATCH 5/7] chore: address test compile issue on windows requiring specify generic argument --- stacks-signer/src/client/mod.rs | 2 +- .../src/chainstate/nakamoto/test_signers.rs | 18 +++++++---- .../src/chainstate/nakamoto/tests/mod.rs | 30 +++++++++++++++---- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/stacks-signer/src/client/mod.rs b/stacks-signer/src/client/mod.rs index e518ff4a7b..11014a4a6c 100644 --- a/stacks-signer/src/client/mod.rs +++ b/stacks-signer/src/client/mod.rs @@ -224,7 +224,7 @@ pub(crate) mod tests { pub fn generate_random_consensus_hash() -> ConsensusHash { let rng = rand::thread_rng(); - let bytes: Vec = rng.sample_iter(Standard).take(20).collect(); + let bytes: Vec = rng.sample_iter::(Standard).take(20).collect(); let mut hash = [0u8; 20]; hash.copy_from_slice(&bytes); ConsensusHash(hash) diff --git a/stackslib/src/chainstate/nakamoto/test_signers.rs b/stackslib/src/chainstate/nakamoto/test_signers.rs index 1aab6b4467..c7a6cb72f8 100644 --- a/stackslib/src/chainstate/nakamoto/test_signers.rs +++ b/stackslib/src/chainstate/nakamoto/test_signers.rs @@ -44,8 +44,10 @@ pub struct TestSigners { impl Default for TestSigners { fn default() -> Self { - let aggregate_public_key: Vec = - rand::thread_rng().sample_iter(Standard).take(33).collect(); + let aggregate_public_key: Vec = rand::thread_rng() + .sample_iter::(Standard) + .take(33) + .collect(); let num_signers = 5; let threshold = 5 * 7 / 10; @@ -70,8 +72,10 @@ impl TestSigners { /// Internal function to generate aggregate key information fn default_with_signers(signer_keys: Vec) -> Self { - let aggregate_public_key: Vec = - rand::thread_rng().sample_iter(Standard).take(33).collect(); + let aggregate_public_key: Vec = rand::thread_rng() + .sample_iter::(Standard) + .take(33) + .collect(); let num_signers = signer_keys.len(); let threshold = u32::try_from(num_signers * 7 / 10).unwrap(); Self { @@ -227,8 +231,10 @@ impl TestSigners { return self.aggregate_public_key.clone(); } - let aggregate_public_key: Vec = - rand::thread_rng().sample_iter(Standard).take(33).collect(); + let aggregate_public_key: Vec = rand::thread_rng() + .sample_iter::(Standard) + .take(33) + .collect(); self.aggregate_public_key.clone_from(&aggregate_public_key); aggregate_public_key } diff --git a/stackslib/src/chainstate/nakamoto/tests/mod.rs b/stackslib/src/chainstate/nakamoto/tests/mod.rs index d734623333..6e59899a54 100644 --- a/stackslib/src/chainstate/nakamoto/tests/mod.rs +++ b/stackslib/src/chainstate/nakamoto/tests/mod.rs @@ -2270,7 +2270,10 @@ fn parse_vote_for_aggregate_public_key_valid() { let signer_index = thread_rng().next_u64(); let signer_index_arg = Value::UInt(signer_index as u128); - let aggregate_key: Vec = rand::thread_rng().sample_iter(Standard).take(33).collect(); + let aggregate_key: Vec = rand::thread_rng() + .sample_iter::(Standard) + .take(33) + .collect(); let aggregate_key_arg = Value::buff_from(aggregate_key.clone()).expect("Failed to create buff"); let round = thread_rng().next_u64(); let round_arg = Value::UInt(round as u128); @@ -2316,7 +2319,10 @@ fn parse_vote_for_aggregate_public_key_invalid() { let signer_index = thread_rng().next_u32(); let signer_index_arg = Value::UInt(signer_index as u128); - let aggregate_key: Vec = rand::thread_rng().sample_iter(Standard).take(33).collect(); + let aggregate_key: Vec = rand::thread_rng() + .sample_iter::(Standard) + .take(33) + .collect(); let aggregate_key_arg = Value::buff_from(aggregate_key).expect("Failed to create buff"); let round = thread_rng().next_u64(); let round_arg = Value::UInt(round as u128); @@ -2498,7 +2504,10 @@ fn valid_vote_transaction() { let signer_index = thread_rng().next_u32(); let signer_index_arg = Value::UInt(signer_index as u128); - let aggregate_key: Vec = rand::thread_rng().sample_iter(Standard).take(33).collect(); + let aggregate_key: Vec = rand::thread_rng() + .sample_iter::(Standard) + .take(33) + .collect(); let aggregate_key_arg = Value::buff_from(aggregate_key).expect("Failed to create buff"); let round = thread_rng().next_u64(); let round_arg = Value::UInt(round as u128); @@ -2548,7 +2557,10 @@ fn valid_vote_transaction_malformed_transactions() { let signer_index = thread_rng().next_u32(); let signer_index_arg = Value::UInt(signer_index as u128); - let aggregate_key: Vec = rand::thread_rng().sample_iter(Standard).take(33).collect(); + let aggregate_key: Vec = rand::thread_rng() + .sample_iter::(Standard) + .take(33) + .collect(); let aggregate_key_arg = Value::buff_from(aggregate_key).expect("Failed to create buff"); let round = thread_rng().next_u64(); let round_arg = Value::UInt(round as u128); @@ -2782,7 +2794,10 @@ fn filter_one_transaction_per_signer_multiple_addresses() { let signer_index = thread_rng().next_u32(); let signer_index_arg = Value::UInt(signer_index as u128); - let aggregate_key: Vec = rand::thread_rng().sample_iter(Standard).take(33).collect(); + let aggregate_key: Vec = rand::thread_rng() + .sample_iter::(Standard) + .take(33) + .collect(); let aggregate_key_arg = Value::buff_from(aggregate_key).expect("Failed to create buff"); let round = thread_rng().next_u64(); let round_arg = Value::UInt(round as u128); @@ -2910,7 +2925,10 @@ fn filter_one_transaction_per_signer_duplicate_nonces() { let signer_index = thread_rng().next_u32(); let signer_index_arg = Value::UInt(signer_index as u128); - let aggregate_key: Vec = rand::thread_rng().sample_iter(Standard).take(33).collect(); + let aggregate_key: Vec = rand::thread_rng() + .sample_iter::(Standard) + .take(33) + .collect(); let aggregate_key_arg = Value::buff_from(aggregate_key).expect("Failed to create buff"); let round = thread_rng().next_u64(); let round_arg = Value::UInt(round as u128); From 12521f01fbaba315b0d805d147c6c559e9f771c1 Mon Sep 17 00:00:00 2001 From: Federico De Felici Date: Wed, 8 Oct 2025 12:30:55 +0200 Subject: [PATCH 6/7] refactor: aac update test marf computation --- stackslib/src/chainstate/tests/consensus.rs | 86 ++++++++++----------- 1 file changed, 39 insertions(+), 47 deletions(-) diff --git a/stackslib/src/chainstate/tests/consensus.rs b/stackslib/src/chainstate/tests/consensus.rs index 3647caf64d..850f6891db 100644 --- a/stackslib/src/chainstate/tests/consensus.rs +++ b/stackslib/src/chainstate/tests/consensus.rs @@ -38,7 +38,7 @@ use crate::burnchains::PoxConstants; use crate::chainstate::burn::db::sortdb::SortitionDB; use crate::chainstate::nakamoto::{NakamotoBlock, NakamotoBlockHeader, NakamotoChainState}; use crate::chainstate::stacks::boot::RewardSet; -use crate::chainstate::stacks::db::{StacksChainState, StacksEpochReceipt}; +use crate::chainstate::stacks::db::{ClarityTx, StacksChainState, StacksEpochReceipt}; use crate::chainstate::stacks::{ Error as ChainstateError, StacksTransaction, TenureChangeCause, MINER_BLOCK_CONSENSUS_HASH, MINER_BLOCK_HEADER_HASH, @@ -209,8 +209,6 @@ impl From> for ExpectedResult { /// Represents a block to be appended in a test and its expected result. #[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] pub struct TestBlock { - /// Hex representation of the MARF hash for block construction. - pub marf_hash: String, /// Transactions to include in the block pub transactions: Vec, } @@ -430,13 +428,17 @@ impl ConsensusTest<'_> { }; block.header.tx_merkle_root = tx_merkle_root; - // Set the MARF root hash: compute it for success cases, - // or use an all-zero hash for failure cases. - block.header.state_index_root = if test_block.is_success() { - self.compute_block_marf_root_hash(block.header.timestamp, &block.txs) - } else { - TrieHash::from_bytes(&[0; 32]).unwrap() + // Set the MARF root hash or use an all-zero hash in case of failure. + // NOTE: It is expected to fail when trying computing the marf for invalid block/transactions. + /* + let marf_result = self.compute_block_marf_root_hash(block.header.timestamp, &block.txs); + block.header.state_index_root = match marf_result { + Ok(marf) => marf, + Err(_) => TrieHash::from_bytes(&[0; 32]).unwrap(), }; + */ + + block.header.state_index_root = TrieHash::from_bytes(&[0; 32]).unwrap(); self.chain.miner.sign_nakamoto_block(&mut block); let mut signers = self.chain.config.test_signers.clone().unwrap_or_default(); @@ -457,7 +459,7 @@ impl ConsensusTest<'_> { &mut self, block_time: u64, block_txs: &Vec, - ) -> TrieHash { + ) -> Result { let node = self.chain.stacks_node.as_mut().unwrap(); let sortdb = self.chain.sortdb.as_ref().unwrap(); let burndb_conn = sortdb.index_handle_at_tip(); @@ -479,7 +481,26 @@ impl ConsensusTest<'_> { &MINER_BLOCK_CONSENSUS_HASH, &MINER_BLOCK_HEADER_HASH, ); + let result = Self::inner_compute_block_marf_root_hash( + &mut clarity_tx, + block_time, + block_txs, + chain_tip.burn_header_height, + ); + clarity_tx.rollback_block(); + return result; + } + /// This is where the real MARF computation happens. + /// It is extrapolated into an _inner_ method to simplify rollback handling, + /// ensuring that rollback can be applied consistently on both success and failure + /// in the _outer_ method. + fn inner_compute_block_marf_root_hash( + clarity_tx: &mut ClarityTx, + block_time: u64, + block_txs: &Vec, + burn_header_height: u32, + ) -> Result { clarity_tx .connection() .as_free_transaction(|clarity_tx_conn| { @@ -488,22 +509,17 @@ impl ConsensusTest<'_> { Ok(()) }) }) - .expect("MARF: Failure on block metadata setup!"); + .map_err(|e| e.to_string())?; - StacksChainState::process_block_transactions(&mut clarity_tx, block_txs, 0) - .expect("MARF: Failure on processing block transactions!"); + StacksChainState::process_block_transactions(clarity_tx, block_txs, 0) + .map_err(|e| e.to_string())?; - NakamotoChainState::finish_block( - &mut clarity_tx, - None, - false, - chain_tip.burn_header_height, - ) - .expect("MARF: Failure on finishing block!"); + NakamotoChainState::finish_block(clarity_tx, None, false, burn_header_height) + .map_err(|e| e.to_string())?; let trie_hash = clarity_tx.seal(); - clarity_tx.rollback_block(); - return trie_hash; + //clarity_tx.rollback_block(); + Ok(trie_hash) } } @@ -513,28 +529,24 @@ fn test_append_empty_blocks() { epoch_blocks.insert( StacksEpochId::Epoch30, vec![TestBlock { - marf_hash: "f1934080b22ef0192cfb39710690e7cb0efa9cff950832b33544bde3aa1484a5".into(), transactions: vec![], }], ); epoch_blocks.insert( StacksEpochId::Epoch31, vec![TestBlock { - marf_hash: "a05f1383613215f5789eb977e4c62dfbb789d90964e14865d109375f7f6dc3cf".into(), transactions: vec![], }], ); epoch_blocks.insert( StacksEpochId::Epoch32, vec![TestBlock { - marf_hash: "c17829daff8746329c65ae658f4087519c6a8bd8c7f21e51644ddbc9c010390f".into(), transactions: vec![], }], ); epoch_blocks.insert( StacksEpochId::Epoch33, vec![TestBlock { - marf_hash: "23ecbcb91cac914ba3994a15f3ea7189bcab4e9762530cd0e6c7d237fcd6dc78".into(), transactions: vec![], }], ); @@ -547,34 +559,30 @@ fn test_append_empty_blocks() { insta::assert_ron_snapshot!(result); } -#[test] +//#[test] fn test_append_state_index_root_mismatches() { let mut epoch_blocks = HashMap::new(); epoch_blocks.insert( StacksEpochId::Epoch30, vec![TestBlock { - marf_hash: "0000000000000000000000000000000000000000000000000000000000000000".into(), transactions: vec![], }], ); epoch_blocks.insert( StacksEpochId::Epoch31, vec![TestBlock { - marf_hash: "0000000000000000000000000000000000000000000000000000000000000000".into(), transactions: vec![], }], ); epoch_blocks.insert( StacksEpochId::Epoch32, vec![TestBlock { - marf_hash: "0000000000000000000000000000000000000000000000000000000000000000".into(), transactions: vec![], }], ); epoch_blocks.insert( StacksEpochId::Epoch33, vec![TestBlock { - marf_hash: "0000000000000000000000000000000000000000000000000000000000000000".into(), transactions: vec![], }], ); @@ -620,28 +628,24 @@ fn test_append_stx_transfers_success() { epoch_blocks.insert( StacksEpochId::Epoch30, vec![TestBlock { - marf_hash: "63ea49669d2216ebc7e4f8b5e1cd2c99b8aff9806794adf87dcf709c0a244798".into(), transactions: transactions.clone(), }], ); epoch_blocks.insert( StacksEpochId::Epoch31, vec![TestBlock { - marf_hash: "7fc538e605a4a353871c4a655ae850fe9a70c3875b65f2bb42ea3bef5effed2c".into(), transactions: transactions.clone(), }], ); epoch_blocks.insert( StacksEpochId::Epoch32, vec![TestBlock { - marf_hash: "4d5c9a6d07806ac5006137de22b083de66fff7119143dd5cd92e4a457d66e028".into(), transactions: transactions.clone(), }], ); epoch_blocks.insert( StacksEpochId::Epoch33, vec![TestBlock { - marf_hash: "66eed8c0ab31db111a5adcc83d38a7004c6e464e3b9fb9f52ec589bc6d5f2d32".into(), transactions: transactions.clone(), }], ); @@ -678,28 +682,24 @@ fn test_append_chainstate_error_expression_stack_depth_too_deep() { epoch_blocks.insert( StacksEpochId::Epoch30, vec![TestBlock { - marf_hash: "0000000000000000000000000000000000000000000000000000000000000000".into(), transactions: vec![tx.clone()], }], ); epoch_blocks.insert( StacksEpochId::Epoch31, vec![TestBlock { - marf_hash: "0000000000000000000000000000000000000000000000000000000000000000".into(), transactions: vec![tx.clone()], }], ); epoch_blocks.insert( StacksEpochId::Epoch32, vec![TestBlock { - marf_hash: "0000000000000000000000000000000000000000000000000000000000000000".into(), transactions: vec![tx.clone()], }], ); epoch_blocks.insert( StacksEpochId::Epoch33, vec![TestBlock { - marf_hash: "0000000000000000000000000000000000000000000000000000000000000000".into(), transactions: vec![tx.clone()], }], ); @@ -732,28 +732,24 @@ fn test_append_block_with_contract_upload_success() { epoch_blocks.insert( StacksEpochId::Epoch30, vec![TestBlock { - marf_hash: "b45acd35f4c48a834a2f898ca8bb6c48416ac6bec9d8a3f3662b61ab97b1edde".into(), transactions: vec![tx.clone()], }], ); epoch_blocks.insert( StacksEpochId::Epoch31, vec![TestBlock { - marf_hash: "521d75234ec6c64f68648b6b0f6f385d89b58efb581211a411e0e88aa71f3371".into(), transactions: vec![tx.clone()], }], ); epoch_blocks.insert( StacksEpochId::Epoch32, vec![TestBlock { - marf_hash: "511e1cc37e83ef3de4ea56962574d6ddd2d8840d24d9238f19eee5a35127df6a".into(), transactions: vec![tx.clone()], }], ); epoch_blocks.insert( StacksEpochId::Epoch33, vec![TestBlock { - marf_hash: "3520c2dd96f7d91e179c4dcd00f3c49c16d6ec21434fb16921922558282eab26".into(), transactions: vec![tx.clone()], }], ); @@ -829,7 +825,6 @@ fn test_append_block_with_contract_call_success() { epoch_blocks.insert( StacksEpochId::Epoch30, vec![TestBlock { - marf_hash: "186c8e49bcfc59bb67ed22f031f009a44681f296392e0f92bed520918ba463ae".into(), transactions: vec![tx_contract_deploy.clone(), tx_contract_call.clone()], }], ); @@ -837,7 +832,6 @@ fn test_append_block_with_contract_call_success() { epoch_blocks.insert( StacksEpochId::Epoch31, vec![TestBlock { - marf_hash: "ad23713f072473cad6a32125ed5fa822bb62bbfae8ed2302209c12d2f1958128".into(), transactions: vec![tx_contract_deploy.clone(), tx_contract_call.clone()], }], ); @@ -845,7 +839,6 @@ fn test_append_block_with_contract_call_success() { epoch_blocks.insert( StacksEpochId::Epoch32, vec![TestBlock { - marf_hash: "021bd30b09b5ac6ff34abd11f05244a966af937b584b1752f272cd717bb25f1d".into(), transactions: vec![tx_contract_deploy.clone(), tx_contract_call.clone()], }], ); @@ -853,7 +846,6 @@ fn test_append_block_with_contract_call_success() { epoch_blocks.insert( StacksEpochId::Epoch33, vec![TestBlock { - marf_hash: "416e728daeec4de695c89d15eede8ddb7b85fb4af82daffb1e0d8166a3e93451".into(), transactions: vec![tx_contract_deploy, tx_contract_call], }], ); From 111595a9e2f9d2df65e9a4733975d381f97dc956 Mon Sep 17 00:00:00 2001 From: Federico De Felici Date: Wed, 8 Oct 2025 15:03:08 +0200 Subject: [PATCH 7/7] feat: add marf_hash to ExpectedBlockOutput --- stackslib/src/chainstate/tests/consensus.rs | 210 ++++++++++-------- ...pend_block_with_contract_call_success.snap | 185 ++++++++++++--- ...tests__consensus__append_empty_blocks.snap | 4 + ...s__append_state_index_root_mismatches.snap | 10 - ...nsensus__append_stx_transfers_success.snap | 4 + 5 files changed, 279 insertions(+), 134 deletions(-) delete mode 100644 stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__consensus__append_state_index_root_mismatches.snap diff --git a/stackslib/src/chainstate/tests/consensus.rs b/stackslib/src/chainstate/tests/consensus.rs index 850f6891db..f224f72646 100644 --- a/stackslib/src/chainstate/tests/consensus.rs +++ b/stackslib/src/chainstate/tests/consensus.rs @@ -166,6 +166,8 @@ pub struct ExpectedTransactionOutput { /// Represents the expected outputs for a block's execution. #[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] pub struct ExpectedBlockOutput { + /// The expected block marf + pub marf_hash: TrieHash, /// The expected outputs for each transaction, in input order. pub transactions: Vec, /// The total execution cost of the block. @@ -183,8 +185,11 @@ pub enum ExpectedResult { Failure(String), } -impl From> for ExpectedResult { - fn from(result: Result) -> Self { +impl ExpectedResult { + fn create_from( + result: Result, + marf_hash: TrieHash, + ) -> Self { match result { Ok(epoch_receipt) => { let transactions: Vec = epoch_receipt @@ -197,6 +202,7 @@ impl From> for ExpectedResult { .collect(); let total_block_cost = epoch_receipt.anchored_block_cost.clone(); ExpectedResult::Success(ExpectedBlockOutput { + marf_hash, transactions, total_block_cost, }) @@ -367,14 +373,12 @@ impl ConsensusTest<'_> { ); debug!("--------- Appended block: {} ---------", result.is_ok()); - results.push( - result - .map(|(receipt, clarity_commit, _, _)| { - clarity_commit.commit(); - receipt - }) - .into(), - ); + let remapped_result = result.map(|(receipt, clarity_commit, _, _)| { + clarity_commit.commit(); + receipt + }); + let expected_marf = nakamoto_block.header.state_index_root; + results.push(ExpectedResult::create_from(remapped_result, expected_marf)); chainstate_tx.commit().unwrap(); } @@ -430,15 +434,11 @@ impl ConsensusTest<'_> { // Set the MARF root hash or use an all-zero hash in case of failure. // NOTE: It is expected to fail when trying computing the marf for invalid block/transactions. - /* let marf_result = self.compute_block_marf_root_hash(block.header.timestamp, &block.txs); block.header.state_index_root = match marf_result { Ok(marf) => marf, Err(_) => TrieHash::from_bytes(&[0; 32]).unwrap(), }; - */ - - block.header.state_index_root = TrieHash::from_bytes(&[0; 32]).unwrap(); self.chain.miner.sign_nakamoto_block(&mut block); let mut signers = self.chain.config.test_signers.clone().unwrap_or_default(); @@ -517,9 +517,7 @@ impl ConsensusTest<'_> { NakamotoChainState::finish_block(clarity_tx, None, false, burn_header_height) .map_err(|e| e.to_string())?; - let trie_hash = clarity_tx.seal(); - //clarity_tx.rollback_block(); - Ok(trie_hash) + Ok(clarity_tx.seal()) } } @@ -559,42 +557,6 @@ fn test_append_empty_blocks() { insta::assert_ron_snapshot!(result); } -//#[test] -fn test_append_state_index_root_mismatches() { - let mut epoch_blocks = HashMap::new(); - epoch_blocks.insert( - StacksEpochId::Epoch30, - vec![TestBlock { - transactions: vec![], - }], - ); - epoch_blocks.insert( - StacksEpochId::Epoch31, - vec![TestBlock { - transactions: vec![], - }], - ); - epoch_blocks.insert( - StacksEpochId::Epoch32, - vec![TestBlock { - transactions: vec![], - }], - ); - epoch_blocks.insert( - StacksEpochId::Epoch33, - vec![TestBlock { - transactions: vec![], - }], - ); - - let test_vector = ConsensusTestVector { - initial_balances: vec![], - epoch_blocks, - }; - let result = ConsensusTest::new(function_name!(), test_vector).run(); - insta::assert_ron_snapshot!(result); -} - #[test] fn test_append_stx_transfers_success() { let sender_privks = [ @@ -759,38 +721,110 @@ fn test_append_block_with_contract_upload_success() { }; let result = ConsensusTest::new(function_name!(), test_vector).run(); - // Example of expecting the same result across all blocks - insta::allow_duplicates! { - for res in result { - // Example of inline snapshot - insta::assert_ron_snapshot!(res, @r" - Success(ExpectedBlockOutput( - transactions: [ - ExpectedTransactionOutput( - return_type: Response(ResponseData( - committed: true, - data: Bool(true), - )), - cost: ExecutionCost( - write_length: 13, - write_count: 2, - read_length: 1, - read_count: 1, - runtime: 8114, - ), - ), - ], - total_block_cost: ExecutionCost( - write_length: 13, - write_count: 2, - read_length: 1, - read_count: 1, - runtime: 8114, - ), - )) - "); - } - } + insta::assert_ron_snapshot!(result, @r#" + [ + Success(ExpectedBlockOutput( + marf_hash: "b45acd35f4c48a834a2f898ca8bb6c48416ac6bec9d8a3f3662b61ab97b1edde", + transactions: [ + ExpectedTransactionOutput( + return_type: Response(ResponseData( + committed: true, + data: Bool(true), + )), + cost: ExecutionCost( + write_length: 13, + write_count: 2, + read_length: 1, + read_count: 1, + runtime: 8114, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 13, + write_count: 2, + read_length: 1, + read_count: 1, + runtime: 8114, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "521d75234ec6c64f68648b6b0f6f385d89b58efb581211a411e0e88aa71f3371", + transactions: [ + ExpectedTransactionOutput( + return_type: Response(ResponseData( + committed: true, + data: Bool(true), + )), + cost: ExecutionCost( + write_length: 13, + write_count: 2, + read_length: 1, + read_count: 1, + runtime: 8114, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 13, + write_count: 2, + read_length: 1, + read_count: 1, + runtime: 8114, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "511e1cc37e83ef3de4ea56962574d6ddd2d8840d24d9238f19eee5a35127df6a", + transactions: [ + ExpectedTransactionOutput( + return_type: Response(ResponseData( + committed: true, + data: Bool(true), + )), + cost: ExecutionCost( + write_length: 13, + write_count: 2, + read_length: 1, + read_count: 1, + runtime: 8114, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 13, + write_count: 2, + read_length: 1, + read_count: 1, + runtime: 8114, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "3520c2dd96f7d91e179c4dcd00f3c49c16d6ec21434fb16921922558282eab26", + transactions: [ + ExpectedTransactionOutput( + return_type: Response(ResponseData( + committed: true, + data: Bool(true), + )), + cost: ExecutionCost( + write_length: 13, + write_count: 2, + read_length: 1, + read_count: 1, + runtime: 8114, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 13, + write_count: 2, + read_length: 1, + read_count: 1, + runtime: 8114, + ), + )), + ] + "#); } #[test] @@ -856,9 +890,5 @@ fn test_append_block_with_contract_call_success() { }; let result = ConsensusTest::new(function_name!(), test_vector).run(); - insta::allow_duplicates! { - for res in result { - insta::assert_ron_snapshot!(res); - } - } + insta::assert_ron_snapshot!(result); } diff --git a/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__consensus__append_block_with_contract_call_success.snap b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__consensus__append_block_with_contract_call_success.snap index f50380ee57..8aec4b5474 100644 --- a/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__consensus__append_block_with_contract_call_success.snap +++ b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__consensus__append_block_with_contract_call_success.snap @@ -1,41 +1,158 @@ --- source: stackslib/src/chainstate/tests/consensus.rs -expression: res +expression: result --- -Success(ExpectedBlockOutput( - transactions: [ - ExpectedTransactionOutput( - return_type: Response(ResponseData( - committed: true, - data: Bool(true), - )), - cost: ExecutionCost( - write_length: 121, - write_count: 2, - read_length: 1, - read_count: 1, - runtime: 11968, +[ + Success(ExpectedBlockOutput( + marf_hash: "186c8e49bcfc59bb67ed22f031f009a44681f296392e0f92bed520918ba463ae", + transactions: [ + ExpectedTransactionOutput( + return_type: Response(ResponseData( + committed: true, + data: Bool(true), + )), + cost: ExecutionCost( + write_length: 121, + write_count: 2, + read_length: 1, + read_count: 1, + runtime: 11968, + ), ), + ExpectedTransactionOutput( + return_type: Response(ResponseData( + committed: true, + data: UInt(1), + )), + cost: ExecutionCost( + write_length: 0, + write_count: 0, + read_length: 103, + read_count: 3, + runtime: 499, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 121, + write_count: 2, + read_length: 104, + read_count: 4, + runtime: 12467, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "ad23713f072473cad6a32125ed5fa822bb62bbfae8ed2302209c12d2f1958128", + transactions: [ + ExpectedTransactionOutput( + return_type: Response(ResponseData( + committed: true, + data: Bool(true), + )), + cost: ExecutionCost( + write_length: 121, + write_count: 2, + read_length: 1, + read_count: 1, + runtime: 11968, + ), + ), + ExpectedTransactionOutput( + return_type: Response(ResponseData( + committed: true, + data: UInt(1), + )), + cost: ExecutionCost( + write_length: 0, + write_count: 0, + read_length: 103, + read_count: 3, + runtime: 499, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 121, + write_count: 2, + read_length: 104, + read_count: 4, + runtime: 12467, ), - ExpectedTransactionOutput( - return_type: Response(ResponseData( - committed: true, - data: UInt(1), - )), - cost: ExecutionCost( - write_length: 0, - write_count: 0, - read_length: 103, - read_count: 3, - runtime: 499, + )), + Success(ExpectedBlockOutput( + marf_hash: "021bd30b09b5ac6ff34abd11f05244a966af937b584b1752f272cd717bb25f1d", + transactions: [ + ExpectedTransactionOutput( + return_type: Response(ResponseData( + committed: true, + data: Bool(true), + )), + cost: ExecutionCost( + write_length: 121, + write_count: 2, + read_length: 1, + read_count: 1, + runtime: 11968, + ), + ), + ExpectedTransactionOutput( + return_type: Response(ResponseData( + committed: true, + data: UInt(1), + )), + cost: ExecutionCost( + write_length: 0, + write_count: 0, + read_length: 103, + read_count: 3, + runtime: 499, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 121, + write_count: 2, + read_length: 104, + read_count: 4, + runtime: 12467, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "416e728daeec4de695c89d15eede8ddb7b85fb4af82daffb1e0d8166a3e93451", + transactions: [ + ExpectedTransactionOutput( + return_type: Response(ResponseData( + committed: true, + data: Bool(true), + )), + cost: ExecutionCost( + write_length: 121, + write_count: 2, + read_length: 1, + read_count: 1, + runtime: 11968, + ), + ), + ExpectedTransactionOutput( + return_type: Response(ResponseData( + committed: true, + data: UInt(1), + )), + cost: ExecutionCost( + write_length: 0, + write_count: 0, + read_length: 103, + read_count: 3, + runtime: 499, + ), ), + ], + total_block_cost: ExecutionCost( + write_length: 121, + write_count: 2, + read_length: 104, + read_count: 4, + runtime: 12467, ), - ], - total_block_cost: ExecutionCost( - write_length: 121, - write_count: 2, - read_length: 104, - read_count: 4, - runtime: 12467, - ), -)) + )), +] diff --git a/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__consensus__append_empty_blocks.snap b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__consensus__append_empty_blocks.snap index 017c5a91da..a1f13d92b8 100644 --- a/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__consensus__append_empty_blocks.snap +++ b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__consensus__append_empty_blocks.snap @@ -4,6 +4,7 @@ expression: result --- [ Success(ExpectedBlockOutput( + marf_hash: "f1934080b22ef0192cfb39710690e7cb0efa9cff950832b33544bde3aa1484a5", transactions: [], total_block_cost: ExecutionCost( write_length: 0, @@ -14,6 +15,7 @@ expression: result ), )), Success(ExpectedBlockOutput( + marf_hash: "a05f1383613215f5789eb977e4c62dfbb789d90964e14865d109375f7f6dc3cf", transactions: [], total_block_cost: ExecutionCost( write_length: 0, @@ -24,6 +26,7 @@ expression: result ), )), Success(ExpectedBlockOutput( + marf_hash: "c17829daff8746329c65ae658f4087519c6a8bd8c7f21e51644ddbc9c010390f", transactions: [], total_block_cost: ExecutionCost( write_length: 0, @@ -34,6 +37,7 @@ expression: result ), )), Success(ExpectedBlockOutput( + marf_hash: "23ecbcb91cac914ba3994a15f3ea7189bcab4e9762530cd0e6c7d237fcd6dc78", transactions: [], total_block_cost: ExecutionCost( write_length: 0, diff --git a/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__consensus__append_state_index_root_mismatches.snap b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__consensus__append_state_index_root_mismatches.snap deleted file mode 100644 index 1d73839536..0000000000 --- a/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__consensus__append_state_index_root_mismatches.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: stackslib/src/chainstate/tests/consensus.rs -expression: result ---- -[ - Failure("Block ef45bfa44231d9e7aff094b53cfd48df0456067312f169a499354c4273a66fe3 state root mismatch: expected 0000000000000000000000000000000000000000000000000000000000000000, got f1934080b22ef0192cfb39710690e7cb0efa9cff950832b33544bde3aa1484a5"), - Failure("Block a14d0b5c8d3c49554aeb462a8fe019718195789fa1dcd642059b75e41f0ce9cc state root mismatch: expected 0000000000000000000000000000000000000000000000000000000000000000, got a05f1383613215f5789eb977e4c62dfbb789d90964e14865d109375f7f6dc3cf"), - Failure("Block f8120b4a632ee1d49fbbde3e01289588389cd205cab459a4493a7d58d2dc18ed state root mismatch: expected 0000000000000000000000000000000000000000000000000000000000000000, got c17829daff8746329c65ae658f4087519c6a8bd8c7f21e51644ddbc9c010390f"), - Failure("Block 4dcb48b684d105ff0e0ab8becddd4a2d5623cc8b168aacf9c455e20b3e610e63 state root mismatch: expected 0000000000000000000000000000000000000000000000000000000000000000, got 23ecbcb91cac914ba3994a15f3ea7189bcab4e9762530cd0e6c7d237fcd6dc78"), -] diff --git a/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__consensus__append_stx_transfers_success.snap b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__consensus__append_stx_transfers_success.snap index dd47089fbb..c4be6d8a74 100644 --- a/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__consensus__append_stx_transfers_success.snap +++ b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__consensus__append_stx_transfers_success.snap @@ -4,6 +4,7 @@ expression: result --- [ Success(ExpectedBlockOutput( + marf_hash: "63ea49669d2216ebc7e4f8b5e1cd2c99b8aff9806794adf87dcf709c0a244798", transactions: [ ExpectedTransactionOutput( return_type: Response(ResponseData( @@ -54,6 +55,7 @@ expression: result ), )), Success(ExpectedBlockOutput( + marf_hash: "7fc538e605a4a353871c4a655ae850fe9a70c3875b65f2bb42ea3bef5effed2c", transactions: [ ExpectedTransactionOutput( return_type: Response(ResponseData( @@ -104,6 +106,7 @@ expression: result ), )), Success(ExpectedBlockOutput( + marf_hash: "4d5c9a6d07806ac5006137de22b083de66fff7119143dd5cd92e4a457d66e028", transactions: [ ExpectedTransactionOutput( return_type: Response(ResponseData( @@ -154,6 +157,7 @@ expression: result ), )), Success(ExpectedBlockOutput( + marf_hash: "66eed8c0ab31db111a5adcc83d38a7004c6e464e3b9fb9f52ec589bc6d5f2d32", transactions: [ ExpectedTransactionOutput( return_type: Response(ResponseData(