Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions crates/evm/src/eth/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ pub struct EthBlockExecutionCtx<'a> {
pub ommers: &'a [Header],
/// Block withdrawals.
pub withdrawals: Option<Cow<'a, Withdrawals>>,
/// Block timestamp.
pub timestamp: u64,
}

/// Block executor for Ethereum.
Expand Down Expand Up @@ -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) => {
Expand All @@ -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}");
}
};

Expand Down
14 changes: 14 additions & 0 deletions crates/evm/src/eth/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ pub trait EthExecutorSpec: EthereumHardforks {
///
/// Used by [`super::eip6110::parse_deposits_from_receipts`].
fn deposit_contract_address(&self) -> Option<Address>;

/// Address of staking contract.
fn staking_contract_address(&self) -> Option<Address>;

/// 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.
Expand Down Expand Up @@ -56,4 +62,12 @@ impl EthExecutorSpec for EthSpec {
fn deposit_contract_address(&self) -> Option<Address> {
self.deposit_contract_address
}

fn staking_contract_address(&self) -> Option<Address> {
None
}

fn is_staking_activate_at_timestamp(&self, timestamp: u64) -> bool {
false
}
}
Loading