From 3f3ff1280c02abb157278c92aa124944852fb0c8 Mon Sep 17 00:00:00 2001 From: Aaron Blankstein Date: Thu, 28 Apr 2022 15:14:37 -0500 Subject: [PATCH] fix: duplicate event broadcasts in mocknet node --- testnet/stacks-node/src/node.rs | 50 ++------------------------------- 1 file changed, 3 insertions(+), 47 deletions(-) diff --git a/testnet/stacks-node/src/node.rs b/testnet/stacks-node/src/node.rs index 57dd0d9422..0af4e5c6e2 100644 --- a/testnet/stacks-node/src/node.rs +++ b/testnet/stacks-node/src/node.rs @@ -17,8 +17,8 @@ use stacks::chainstate::stacks::events::{ StacksTransactionEvent, StacksTransactionReceipt, TransactionOrigin, }; use stacks::chainstate::stacks::{ - CoinbasePayload, StacksBlock, StacksBlockHeader, StacksMicroblock, StacksTransaction, - StacksTransactionSigner, TransactionAnchorMode, TransactionPayload, TransactionVersion, + CoinbasePayload, StacksBlock, StacksMicroblock, StacksTransaction, StacksTransactionSigner, + TransactionAnchorMode, TransactionPayload, TransactionVersion, }; use stacks::chainstate::{burn::db::sortdb::SortitionDB, stacks::db::StacksEpochReceipt}; use stacks::core::mempool::MemPoolDB; @@ -766,7 +766,7 @@ impl Node { microblocks: Vec, db: &mut SortitionDB, ) -> ChainTip { - let parent_consensus_hash = { + let _parent_consensus_hash = { // look up parent consensus hash let ic = db.index_conn(); let parent_consensus_hash = StacksChainState::get_parent_consensus_hash( @@ -817,30 +817,6 @@ impl Node { parent_consensus_hash }; - // get previous burn block stats - let (parent_burn_block_hash, parent_burn_block_height, parent_burn_block_timestamp) = - if anchored_block.is_first_mined() { - (BurnchainHeaderHash([0; 32]), 0, 0) - } else { - match SortitionDB::get_block_snapshot_consensus(db.conn(), &parent_consensus_hash) - .unwrap() - { - Some(sn) => ( - sn.burn_header_hash, - sn.block_height as u32, - sn.burn_header_timestamp, - ), - None => { - // shouldn't happen - warn!( - "CORRUPTION: block {}/{} does not correspond to a burn block", - &parent_consensus_hash, &anchored_block.header.parent_block - ); - (BurnchainHeaderHash([0; 32]), 0, 0) - } - } - }; - let atlas_config = AtlasConfig::default(false); let mut processed_blocks = vec![]; loop { @@ -921,26 +897,6 @@ impl Node { StacksChainState::consensus_load(&block_path).unwrap() }; - let parent_index_hash = StacksBlockHeader::make_index_block_hash( - &parent_consensus_hash, - &block.header.parent_block, - ); - - self.event_dispatcher.process_chain_tip( - &block, - &metadata, - &receipts, - &parent_index_hash, - Txid([0; 32]), - &vec![], - None, - parent_burn_block_hash, - parent_burn_block_height, - parent_burn_block_timestamp, - &processed_block.anchored_block_cost, - &processed_block.parent_microblocks_cost, - ); - let chain_tip = ChainTip { metadata, block,