mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
Refactor Block (#10913)
Co-authored-by: Arsenii Kulikov <klkvrr@gmail.com>
This commit is contained in:
@ -8,7 +8,7 @@ use alloy_primitives::BlockNumber;
|
||||
use reth_evm::execute::{
|
||||
BatchExecutor, BlockExecutionError, BlockExecutionOutput, BlockExecutorProvider, Executor,
|
||||
};
|
||||
use reth_primitives::{Block, BlockWithSenders, Receipt};
|
||||
use reth_primitives::{Block, BlockBody, BlockWithSenders, Receipt};
|
||||
use reth_primitives_traits::format_gas_throughput;
|
||||
use reth_provider::{
|
||||
BlockReader, Chain, HeaderProvider, ProviderError, StateProviderFactory, TransactionVariant,
|
||||
@ -95,7 +95,7 @@ where
|
||||
cumulative_gas += block.gas_used;
|
||||
|
||||
// Configure the executor to use the current state.
|
||||
trace!(target: "exex::backfill", number = block_number, txs = block.body.len(), "Executing block");
|
||||
trace!(target: "exex::backfill", number = block_number, txs = block.body.transactions.len(), "Executing block");
|
||||
|
||||
// Execute the block
|
||||
let execute_start = Instant::now();
|
||||
@ -105,10 +105,12 @@ where
|
||||
let (unsealed_header, hash) = block.header.split();
|
||||
let block = Block {
|
||||
header: unsealed_header,
|
||||
body: block.body,
|
||||
ommers: block.ommers,
|
||||
withdrawals: block.withdrawals,
|
||||
requests: block.requests,
|
||||
body: BlockBody {
|
||||
transactions: block.body.transactions,
|
||||
ommers: block.body.ommers,
|
||||
withdrawals: block.body.withdrawals,
|
||||
requests: block.body.requests,
|
||||
},
|
||||
}
|
||||
.with_senders_unchecked(senders);
|
||||
|
||||
@ -204,7 +206,7 @@ where
|
||||
self.provider.history_by_block_number(block_number.saturating_sub(1))?,
|
||||
));
|
||||
|
||||
trace!(target: "exex::backfill", number = block_number, txs = block_with_senders.block.body.len(), "Executing block");
|
||||
trace!(target: "exex::backfill", number = block_number, txs = block_with_senders.block.body.transactions.len(), "Executing block");
|
||||
|
||||
let block_execution_output = executor.execute((&block_with_senders, td).into())?;
|
||||
|
||||
|
||||
@ -8,8 +8,8 @@ use reth_evm::execute::{
|
||||
};
|
||||
use reth_evm_ethereum::execute::EthExecutorProvider;
|
||||
use reth_primitives::{
|
||||
constants::ETH_TO_WEI, Block, BlockWithSenders, Genesis, GenesisAccount, Header, Receipt,
|
||||
Requests, SealedBlockWithSenders, Transaction, TxEip2930,
|
||||
constants::ETH_TO_WEI, Block, BlockBody, BlockWithSenders, Genesis, GenesisAccount, Header,
|
||||
Receipt, Requests, SealedBlockWithSenders, Transaction, TxEip2930,
|
||||
};
|
||||
use reth_provider::{
|
||||
providers::ProviderNodeTypes, BlockWriter as _, ExecutionOutcome, LatestStateProviderRef,
|
||||
@ -103,19 +103,21 @@ fn blocks(
|
||||
gas_used: MIN_TRANSACTION_GAS.into(),
|
||||
..Default::default()
|
||||
},
|
||||
body: vec![sign_tx_with_key_pair(
|
||||
key_pair,
|
||||
Transaction::Eip2930(TxEip2930 {
|
||||
chain_id: chain_spec.chain.id(),
|
||||
nonce: 0,
|
||||
gas_limit: MIN_TRANSACTION_GAS as u128,
|
||||
gas_price: 1_500_000_000,
|
||||
to: TxKind::Call(Address::ZERO),
|
||||
value: U256::from(0.1 * ETH_TO_WEI as f64),
|
||||
..Default::default()
|
||||
}),
|
||||
)],
|
||||
..Default::default()
|
||||
body: BlockBody {
|
||||
transactions: vec![sign_tx_with_key_pair(
|
||||
key_pair,
|
||||
Transaction::Eip2930(TxEip2930 {
|
||||
chain_id: chain_spec.chain.id(),
|
||||
nonce: 0,
|
||||
gas_limit: MIN_TRANSACTION_GAS as u128,
|
||||
gas_price: 1_500_000_000,
|
||||
to: TxKind::Call(Address::ZERO),
|
||||
value: U256::from(0.1 * ETH_TO_WEI as f64),
|
||||
..Default::default()
|
||||
}),
|
||||
)],
|
||||
..Default::default()
|
||||
},
|
||||
}
|
||||
.with_recovered_senders()
|
||||
.ok_or_eyre("failed to recover senders")?;
|
||||
@ -133,19 +135,21 @@ fn blocks(
|
||||
gas_used: MIN_TRANSACTION_GAS.into(),
|
||||
..Default::default()
|
||||
},
|
||||
body: vec![sign_tx_with_key_pair(
|
||||
key_pair,
|
||||
Transaction::Eip2930(TxEip2930 {
|
||||
chain_id: chain_spec.chain.id(),
|
||||
nonce: 1,
|
||||
gas_limit: MIN_TRANSACTION_GAS as u128,
|
||||
gas_price: 1_500_000_000,
|
||||
to: TxKind::Call(Address::ZERO),
|
||||
value: U256::from(0.1 * ETH_TO_WEI as f64),
|
||||
..Default::default()
|
||||
}),
|
||||
)],
|
||||
..Default::default()
|
||||
body: BlockBody {
|
||||
transactions: vec![sign_tx_with_key_pair(
|
||||
key_pair,
|
||||
Transaction::Eip2930(TxEip2930 {
|
||||
chain_id: chain_spec.chain.id(),
|
||||
nonce: 1,
|
||||
gas_limit: MIN_TRANSACTION_GAS as u128,
|
||||
gas_price: 1_500_000_000,
|
||||
to: TxKind::Call(Address::ZERO),
|
||||
value: U256::from(0.1 * ETH_TO_WEI as f64),
|
||||
..Default::default()
|
||||
}),
|
||||
)],
|
||||
..Default::default()
|
||||
},
|
||||
}
|
||||
.with_recovered_senders()
|
||||
.ok_or_eyre("failed to recover senders")?;
|
||||
|
||||
Reference in New Issue
Block a user