fix(provider): post state get didn't get receipts (#2360)

This commit is contained in:
rakita
2023-04-23 17:30:39 +02:00
committed by GitHub
parent 07efa2db45
commit ad77de49f0
2 changed files with 26 additions and 7 deletions

View File

@ -3,8 +3,8 @@
use crate::{post_state::PostState, Transaction}; use crate::{post_state::PostState, Transaction};
use reth_db::{database::Database, models::StoredBlockBodyIndices, tables}; use reth_db::{database::Database, models::StoredBlockBodyIndices, tables};
use reth_primitives::{ use reth_primitives::{
hex_literal::hex, Account, BlockNumber, Header, SealedBlock, SealedBlockWithSenders, hex_literal::hex, Account, BlockNumber, Bytes, Header, Log, Receipt, SealedBlock,
Withdrawal, H160, H256, U256, SealedBlockWithSenders, TxType, Withdrawal, H160, H256, U256,
}; };
use reth_rlp::Decodable; use reth_rlp::Decodable;
use std::collections::BTreeMap; use std::collections::BTreeMap;
@ -112,6 +112,17 @@ fn block1(number: BlockNumber) -> (SealedBlockWithSenders, PostState) {
BTreeMap::from([(U256::from(5), (U256::ZERO, U256::from(10)))]), BTreeMap::from([(U256::from(5), (U256::ZERO, U256::from(10)))]),
); );
post_state.add_receipt(Receipt {
tx_type: TxType::EIP2930,
success: true,
cumulative_gas_used: 300,
logs: vec![Log {
address: H160([0x60; 20]),
topics: vec![H256::from_low_u64_be(1), H256::from_low_u64_be(2)],
data: Bytes::default(),
}],
});
(SealedBlockWithSenders { block, senders: vec![H160([0x30; 20])] }, post_state) (SealedBlockWithSenders { block, senders: vec![H160([0x30; 20])] }, post_state)
} }
@ -141,6 +152,16 @@ fn block2(number: BlockNumber, parent_hash: H256) -> (SealedBlockWithSenders, Po
H160([0x60; 20]), H160([0x60; 20]),
BTreeMap::from([(U256::from(5), (U256::from(10), U256::from(15)))]), BTreeMap::from([(U256::from(5), (U256::from(10), U256::from(15)))]),
); );
post_state.add_receipt(Receipt {
tx_type: TxType::EIP1559,
success: false,
cumulative_gas_used: 400,
logs: vec![Log {
address: H160([0x61; 20]),
topics: vec![H256::from_low_u64_be(3), H256::from_low_u64_be(4)],
data: Bytes::default(),
}],
});
(SealedBlockWithSenders { block, senders: vec![H160([0x31; 20])] }, post_state) (SealedBlockWithSenders { block, senders: vec![H160([0x31; 20])] }, post_state)
} }

View File

@ -959,11 +959,9 @@ where
// loop break if we are at the end of the blocks. // loop break if we are at the end of the blocks.
for (block_number, block_body) in block_bodies.into_iter() { for (block_number, block_body) in block_bodies.into_iter() {
for tx_num in block_body.tx_num_range() { for _ in block_body.tx_num_range() {
if let Some((receipt_tx_num, receipt)) = receipt_iter.next() { if let Some((_, receipt)) = receipt_iter.next() {
if tx_num != receipt_tx_num { block_states.entry(block_number).or_default().add_receipt(receipt);
block_states.entry(block_number).or_default().add_receipt(receipt);
}
} }
} }
} }