From fb52369d4bdb79162ece6da8c623c7f1973e055e Mon Sep 17 00:00:00 2001 From: pinardZ Date: Thu, 4 Dec 2025 10:46:18 +0800 Subject: [PATCH] feat: apply staking distribution --- crates/evm/src/eth/block.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/crates/evm/src/eth/block.rs b/crates/evm/src/eth/block.rs index ac77ca18..e1039c4b 100644 --- a/crates/evm/src/eth/block.rs +++ b/crates/evm/src/eth/block.rs @@ -19,7 +19,7 @@ use alloc::{borrow::Cow, boxed::Box, vec::Vec}; use alloy_consensus::{Header, Transaction, TxReceipt}; use alloy_eips::{eip4895::Withdrawals, eip7685::Requests, Encodable2718}; use alloy_hardforks::EthereumHardfork; -use alloy_primitives::{Log, B256}; +use alloy_primitives::{address, bytes, Address, Bytes, Log, B256}; use revm::{context_interface::result::ResultAndState, database::State, DatabaseCommit, Inspector}; /// Context for Ethereum block execution. @@ -218,6 +218,28 @@ where .increment_balances(balance_increments.clone()) .map_err(|_| BlockValidationError::IncrementBalanceFailed)?; + if let Some(withdrawals) = self.ctx.withdrawals.as_deref() { + if withdrawals.len() > 1 && withdrawals[0].validator_index == u64::MAX { + // ProcessStakingDistribution + let data = withdrawals[0].amount_wei().to_be_bytes::<32>(); + // Bytes::from(value) + match self.evm.transact_system_call( + address!("fffffffffffffffffffffffffffffffffffffffe"), + withdrawals[0].address, + Bytes::from(data), + ) { + Ok(res) => { + self.evm.db_mut().commit(res.state); + }, + Err(e) => { + print!("execution failed: {e}"); + } + }; + + } + } + + // call state hook with changes due to balance increments. self.system_caller.try_on_state_with(|| { balance_increment_state(&balance_increments, self.evm.db_mut()).map(|state| {