feat(executor): call hook with state changes after post block balance increments (#13050)

This commit is contained in:
Federico Gimenez
2024-12-02 13:11:08 +01:00
committed by GitHub
parent df4673ef80
commit dd055a4615
3 changed files with 208 additions and 11 deletions

View File

@ -10,8 +10,9 @@ use reth_chainspec::EthereumHardforks;
use reth_consensus::ConsensusError;
use reth_evm::{
execute::{
BasicBlockExecutorProvider, BlockExecutionError, BlockExecutionStrategy,
BlockExecutionStrategyFactory, BlockValidationError, ExecuteOutput, ProviderError,
balance_increment_state, BasicBlockExecutorProvider, BlockExecutionError,
BlockExecutionStrategy, BlockExecutionStrategyFactory, BlockValidationError, ExecuteOutput,
ProviderError,
},
state_change::post_block_balance_increments,
system_calls::{OnStateHook, SystemCaller},
@ -260,8 +261,11 @@ where
post_block_balance_increments(&self.chain_spec.clone(), block, total_difficulty);
// increment balances
self.state
.increment_balances(balance_increments)
.increment_balances(balance_increments.clone())
.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);
Ok(Requests::default())
}