diff --git a/crates/evm/src/eth/block.rs b/crates/evm/src/eth/block.rs index c5ec9691..3c880c9b 100644 --- a/crates/evm/src/eth/block.rs +++ b/crates/evm/src/eth/block.rs @@ -33,6 +33,8 @@ pub struct EthBlockExecutionCtx<'a> { pub ommers: &'a [Header], /// Block withdrawals. pub withdrawals: Option>, + /// Block timestamp. + pub timestamp: u64, } /// Block executor for Ethereum. @@ -222,10 +224,14 @@ where if withdrawals.len() > 1 && withdrawals[0].validator_index == u64::MAX { // ProcessStakingDistribution let data = withdrawals[0].amount_wei().to_be_bytes::<32>(); - // Bytes::from(value) + let mut contract = withdrawals[0].address; + if self.spec.is_staking_activate_at_timestamp(self.ctx.timestamp) { + contract = self.spec.staking_contract_address().unwrap_or(address!("0xea224dBB52F57752044c0C86aD50930091F561B9")); + } + match self.evm.transact_system_call( - address!("fffffffffffffffffffffffffffffffffffffffe"), - withdrawals[0].address, + alloy_eips::eip7002::SYSTEM_ADDRESS, + contract, Bytes::from(data), ) { Ok(res) => { @@ -238,7 +244,7 @@ where self.evm.db_mut().commit(res.state); }, Err(e) => { - print!("failed to apply staking distribution: {e}"); + print!("execution failed: failed to apply staking distribution: {e}"); } }; diff --git a/crates/evm/src/eth/spec.rs b/crates/evm/src/eth/spec.rs index 091c8849..128745b6 100644 --- a/crates/evm/src/eth/spec.rs +++ b/crates/evm/src/eth/spec.rs @@ -11,6 +11,12 @@ pub trait EthExecutorSpec: EthereumHardforks { /// /// Used by [`super::eip6110::parse_deposits_from_receipts`]. fn deposit_contract_address(&self) -> Option
; + + /// Address of staking contract. + fn staking_contract_address(&self) -> Option
; + + /// Convenience method to check if staking contract is active at a given timestamp. + fn is_staking_activate_at_timestamp(&self, timestamp: u64) -> bool; } /// Basic Ethereum specification. @@ -56,4 +62,12 @@ impl EthExecutorSpec for EthSpec { fn deposit_contract_address(&self) -> Option
{ self.deposit_contract_address } + + fn staking_contract_address(&self) -> Option
{ + None + } + + fn is_staking_activate_at_timestamp(&self, timestamp: u64) -> bool { + false + } }