mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat(evm, root): pass state change source to state hook (#14494)
This commit is contained in:
@ -15,7 +15,7 @@ use reth_evm::{
|
||||
BlockExecutionStrategy, BlockExecutionStrategyFactory, BlockValidationError, ExecuteOutput,
|
||||
},
|
||||
state_change::post_block_balance_increments,
|
||||
system_calls::{OnStateHook, SystemCaller},
|
||||
system_calls::{OnStateHook, StateChangePostBlockSource, StateChangeSource, SystemCaller},
|
||||
ConfigureEvmFor, Database, Evm,
|
||||
};
|
||||
use reth_optimism_chainspec::OpChainSpec;
|
||||
@ -175,7 +175,7 @@ where
|
||||
|
||||
let mut cumulative_gas_used = 0;
|
||||
let mut receipts = Vec::with_capacity(block.body().transaction_count());
|
||||
for (sender, transaction) in block.transactions_with_sender() {
|
||||
for (tx_index, (sender, transaction)) in block.transactions_with_sender().enumerate() {
|
||||
// The sum of the transaction’s gas limit, Tg, and the gas utilized in this block prior,
|
||||
// must be no greater than the block’s gasLimit.
|
||||
let block_available_gas = block.gas_limit() - cumulative_gas_used;
|
||||
@ -219,7 +219,8 @@ where
|
||||
?transaction,
|
||||
"Executed transaction"
|
||||
);
|
||||
self.system_caller.on_state(&result_and_state.state);
|
||||
self.system_caller
|
||||
.on_state(StateChangeSource::Transaction(tx_index), &result_and_state.state);
|
||||
let ResultAndState { result, state } = result_and_state;
|
||||
evm.db_mut().commit(state);
|
||||
|
||||
@ -275,7 +276,10 @@ where
|
||||
.map_err(|_| BlockValidationError::IncrementBalanceFailed)?;
|
||||
// call state hook with changes due to balance increments.
|
||||
let balance_state = balance_increment_state(&balance_increments, &mut self.state)?;
|
||||
self.system_caller.on_state(&balance_state);
|
||||
self.system_caller.on_state(
|
||||
StateChangeSource::PostBlock(StateChangePostBlockSource::BalanceIncrements),
|
||||
&balance_state,
|
||||
);
|
||||
|
||||
Ok(Requests::default())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user