Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions crates/chain-state/src/notifications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ mod tests {
block_receipts[0].0,
BlockReceipts {
block: block1.num_hash(),
timestamp: block1.timestamp,
tx_receipts: vec![(
// Transaction hash of a Transaction::default()
b256!("0x20b5378c6fe992c118b557d2f8e8bbe0b7567f6fe5483a8f0f1c51e93a9d91ab"),
Expand Down Expand Up @@ -443,6 +444,7 @@ mod tests {
block_receipts[0].0,
BlockReceipts {
block: old_block1.num_hash(),
timestamp: old_block1.timestamp,
tx_receipts: vec![(
// Transaction hash of a Transaction::default()
b256!("0x20b5378c6fe992c118b557d2f8e8bbe0b7567f6fe5483a8f0f1c51e93a9d91ab"),
Expand All @@ -459,6 +461,7 @@ mod tests {
block_receipts[1].0,
BlockReceipts {
block: new_block1.num_hash(),
timestamp: new_block1.timestamp,
tx_receipts: vec![(
// Transaction hash of a Transaction::default()
b256!("0x20b5378c6fe992c118b557d2f8e8bbe0b7567f6fe5483a8f0f1c51e93a9d91ab"),
Expand Down
31 changes: 21 additions & 10 deletions crates/evm/execution-types/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,16 +242,25 @@ impl<N: NodePrimitives> Chain<N> {
N::SignedTx: Encodable2718,
{
let mut receipt_attach = Vec::with_capacity(self.blocks().len());
for ((block_num, block), receipts) in
self.blocks().iter().zip(self.execution_outcome.receipts().iter())
{
let mut tx_receipts = Vec::with_capacity(receipts.len());
for (tx, receipt) in block.body().transactions().iter().zip(receipts.iter()) {
tx_receipts.push((tx.trie_hash(), receipt.clone()));
}
let block_num_hash = BlockNumHash::new(*block_num, block.hash());
receipt_attach.push(BlockReceipts { block: block_num_hash, tx_receipts });
}

self.blocks_and_receipts().for_each(|(block, receipts)| {
let block_num_hash = BlockNumHash::new(block.number(), block.hash());

let tx_receipts = block
.body()
.transactions()
.iter()
.zip(receipts)
.map(|(tx, receipt)| (tx.trie_hash(), receipt.clone()))
.collect();

receipt_attach.push(BlockReceipts {
block: block_num_hash,
tx_receipts,
timestamp: block.timestamp(),
});
});

receipt_attach
}

Expand Down Expand Up @@ -400,6 +409,8 @@ pub struct BlockReceipts<T = reth_ethereum_primitives::Receipt> {
pub block: BlockNumHash,
/// Transaction identifier and receipt.
pub tx_receipts: Vec<(TxHash, T)>,
/// Block timestamp
pub timestamp: u64,
}

/// Bincode-compatible [`Chain`] serde implementation.
Expand Down
3 changes: 2 additions & 1 deletion crates/rpc/rpc-eth-types/src/logs_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use std::sync::Arc;
pub fn matching_block_logs_with_tx_hashes<'a, I, R>(
filter: &Filter,
block_num_hash: BlockNumHash,
block_timestamp: u64,
tx_hashes_and_receipts: I,
removed: bool,
) -> Vec<Log>
Expand Down Expand Up @@ -44,7 +45,7 @@ where
transaction_index: Some(receipt_idx as u64),
log_index: Some(log_index),
removed,
block_timestamp: None,
block_timestamp: Some(block_timestamp),
};
all_logs.push(log);
}
Expand Down
1 change: 1 addition & 0 deletions crates/rpc/rpc/src/eth/pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ where
let all_logs = logs_utils::matching_block_logs_with_tx_hashes(
&filter,
block_receipts.block,
block_receipts.timestamp,
block_receipts.tx_receipts.iter().map(|(tx, receipt)| (*tx, receipt)),
removed,
);
Expand Down
Loading