diff --git a/src/chainstate/stacks/db/unconfirmed.rs b/src/chainstate/stacks/db/unconfirmed.rs index dfa4536cd..a54bb9455 100644 --- a/src/chainstate/stacks/db/unconfirmed.rs +++ b/src/chainstate/stacks/db/unconfirmed.rs @@ -45,8 +45,9 @@ pub struct ProcessedUnconfirmedState { pub total_burns: u128, pub total_fees: u128, // each element of this vector is a tuple, where each tuple contains a microblock - // sequence number, and a vector of transaction receipts for that microblock - pub receipts: Vec<(u16, Vec)>, + // sequence number, microblock header hash, and a vector of transaction receipts + // for that microblock + pub receipts: Vec<(u16, BlockHeaderHash, Vec)>, } impl Default for ProcessedUnconfirmedState { @@ -229,7 +230,7 @@ impl UnconfirmedState { total_fees += stx_fees; total_burns += stx_burns; num_new_mblocks += 1; - all_receipts.push((seq, receipts)); + all_receipts.push((seq, mblock_hash, receipts)); last_mblock = Some(mblock_header); last_mblock_seq = seq; diff --git a/testnet/stacks-node/src/event_dispatcher.rs b/testnet/stacks-node/src/event_dispatcher.rs index c85bacc78..ae672eeaf 100644 --- a/testnet/stacks-node/src/event_dispatcher.rs +++ b/testnet/stacks-node/src/event_dispatcher.rs @@ -28,7 +28,9 @@ use stacks::chainstate::stacks::{ use stacks::codec::StacksMessageCodec; use stacks::core::mempool::{MemPoolDropReason, MemPoolEventDispatcher}; use stacks::net::atlas::{Attachment, AttachmentInstance}; -use stacks::types::chainstate::{BurnchainHeaderHash, StacksAddress, StacksBlockId}; +use stacks::types::chainstate::{ + BlockHeaderHash, BurnchainHeaderHash, StacksAddress, StacksBlockId, +}; use stacks::util::hash::bytes_to_hex; use stacks::vm::analysis::contract_interface_builder::build_contract_interface; use stacks::vm::types::{AssetIdentifier, QualifiedContractIdentifier, Value}; @@ -239,6 +241,7 @@ impl EventObserver { fn make_new_microblock_txs_payload( receipt: &StacksTransactionReceipt, tx_index: u32, + header_hash: &BlockHeaderHash, sequence: u16, ) -> serde_json::Value { let receipt_payload_info = EventObserver::generate_payload_info_for_receipt(receipt); @@ -251,7 +254,8 @@ impl EventObserver { "raw_tx": format!("0x{}", &receipt_payload_info.raw_tx), "contract_abi": receipt_payload_info.contract_interface_json, "execution_cost": receipt.execution_cost, - "sequence": sequence, + "microblock_sequence": sequence, + "microblock_header_hash": format!("0x{}", header_hash), }) } @@ -348,6 +352,7 @@ impl EventObserver { "parent_block_hash": format!("0x{}", chain_tip.block.header.parent_block), "parent_index_block_hash": format!("0x{}", parent_index_hash), "parent_microblock": format!("0x{}", chain_tip.block.header.parent_microblock), + "parent_microblock_sequence": chain_tip.block.header.parent_microblock_sequence, "matured_miner_rewards": mature_rewards.clone(), "events": serialized_events, "transactions": serialized_txs, @@ -670,7 +675,7 @@ impl EventDispatcher { let flattened_receipts = processed_unconfirmed_state .receipts .iter() - .flat_map(|(_, r)| r.clone()) + .flat_map(|(_, _, r)| r.clone()) .collect(); let (dispatch_matrix, events) = self.create_dispatch_matrix_and_event_vector(&flattened_receipts); @@ -679,12 +684,15 @@ impl EventDispatcher { let mut tx_index; let mut serialized_txs = Vec::new(); - for (curr_sequence_number, receipts) in processed_unconfirmed_state.receipts.iter() { + for (curr_sequence_number, header_hash, receipts) in + processed_unconfirmed_state.receipts.iter() + { tx_index = 0; for receipt in receipts.iter() { let payload = EventObserver::make_new_microblock_txs_payload( receipt, tx_index, + header_hash, *curr_sequence_number, ); serialized_txs.push(payload);