primitives: use alloy Header struct (#10691)

This commit is contained in:
Thomas Coratger
2024-09-23 14:53:43 +02:00
committed by GitHub
parent 7529d36515
commit ed1de8996d
85 changed files with 826 additions and 991 deletions

View File

@ -569,9 +569,18 @@ impl CanonicalInMemoryState {
index: index as u64,
block_hash: block_state.hash(),
block_number: block_state.block().block.number,
base_fee: block_state.block().block().header.base_fee_per_gas,
base_fee: block_state
.block()
.block()
.header
.base_fee_per_gas
.map(|base_fee| base_fee as u64),
timestamp: block_state.block().block.timestamp,
excess_blob_gas: block_state.block().block.excess_blob_gas,
excess_blob_gas: block_state
.block()
.block
.excess_blob_gas
.map(|excess_blob| excess_blob as u64),
};
return Some((tx.clone(), meta))
}

View File

@ -9,10 +9,11 @@ use rand::{thread_rng, Rng};
use reth_chainspec::{ChainSpec, EthereumHardfork, MIN_TRANSACTION_GAS};
use reth_execution_types::{Chain, ExecutionOutcome};
use reth_primitives::{
alloy_primitives::Sealable,
constants::{EIP1559_INITIAL_BASE_FEE, EMPTY_ROOT_HASH},
proofs::{calculate_receipt_root, calculate_transaction_root, calculate_withdrawals_root},
Header, Receipt, Receipts, Requests, SealedBlock, SealedBlockWithSenders, Signature,
Transaction, TransactionSigned, TransactionSignedEcRecovered, TxEip1559,
Header, Receipt, Receipts, Requests, SealedBlock, SealedBlockWithSenders, SealedHeader,
Signature, Transaction, TransactionSigned, TransactionSignedEcRecovered, TxEip1559,
};
use reth_trie::{root::state_root_unhashed, updates::TrieUpdates, HashedPostState};
use revm::{db::BundleState, primitives::AccountInfo};
@ -138,10 +139,10 @@ impl TestBlockBuilder {
let header = Header {
number,
parent_hash,
gas_used: transactions.len() as u64 * MIN_TRANSACTION_GAS,
gas_limit: self.chain_spec.max_gas_limit,
gas_used: transactions.len() as u128 * MIN_TRANSACTION_GAS as u128,
gas_limit: self.chain_spec.max_gas_limit.into(),
mix_hash: B256::random(),
base_fee_per_gas: Some(EIP1559_INITIAL_BASE_FEE),
base_fee_per_gas: Some(EIP1559_INITIAL_BASE_FEE.into()),
transactions_root: calculate_transaction_root(&transactions),
receipts_root: calculate_receipt_root(&receipts),
beneficiary: Address::random(),
@ -166,8 +167,11 @@ impl TestBlockBuilder {
..Default::default()
};
let sealed = header.seal_slow();
let (header, seal) = sealed.into_parts();
let block = SealedBlock {
header: header.seal_slow(),
header: SealedHeader::new(header, seal),
body: transactions.into_iter().map(|tx| tx.into_signed()).collect(),
ommers: Vec::new(),
withdrawals: Some(vec![].into()),