Skip to content

Commit b0608ed

Browse files
committed
manually add withdrawals
1 parent a015c72 commit b0608ed

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

crates/evm/src/eth/block.rs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ use alloy_consensus::{Header, Transaction, TxReceipt};
2020
use alloy_eips::{
2121
eip4895::Withdrawals,
2222
eip7685::Requests,
23-
eip7928::{AccountChanges, BlockAccessList},
23+
eip7928::{AccountChanges, BalanceChange, BlockAccessList},
2424
Encodable2718,
2525
};
2626
use alloy_hardforks::EthereumHardfork;
27-
use alloy_primitives::{Log, B256};
27+
use alloy_primitives::{Log, B256, U256};
2828
use revm::{
2929
context::Block, context_interface::result::ResultAndState, database::State, DatabaseCommit,
3030
Inspector,
@@ -262,7 +262,25 @@ where
262262
if let Some(mut alloy_bal) = self.evm.db_mut().take_built_alloy_bal() {
263263
if let Some(withdrawals) = self.ctx.withdrawals.as_deref() {
264264
for withdrawal in withdrawals.iter() {
265-
alloy_bal.push(AccountChanges::new(withdrawal.address));
265+
let initial = self
266+
.evm
267+
.db_mut()
268+
.database
269+
.basic(withdrawal.address)
270+
.unwrap()
271+
.unwrap()
272+
.balance;
273+
let final_balance = initial.saturating_add(U256::from(withdrawal.amount));
274+
if initial != final_balance {
275+
alloy_bal.push(
276+
AccountChanges::new(withdrawal.address).with_balance_change(
277+
BalanceChange::new(
278+
self.evm.db().bal_state.bal_index,
279+
U256::from(final_balance),
280+
),
281+
),
282+
);
283+
}
266284
}
267285
}
268286
alloy_bal.sort_by_key(|a| a.address);

0 commit comments

Comments
 (0)