Skip to content

Commit

Permalink
fix: remove zero-amount withdrawals before incrementing balances (#4840)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rjected authored Sep 28, 2023
1 parent 5f9a917 commit c6ef9d7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions crates/revm/src/state_change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ where

/// Returns a map of addresses to their balance increments if the Shanghai hardfork is active at the
/// given timestamp.
///
/// Zero-valued withdrawals are filtered out.
#[inline]
pub fn post_block_withdrawals_balance_increments(
chain_spec: &ChainSpec,
Expand All @@ -129,6 +131,8 @@ pub fn post_block_withdrawals_balance_increments(

/// Applies all withdrawal balance increments if shanghai is active at the given timestamp to the
/// given `balance_increments` map.
///
/// Zero-valued withdrawals are filtered out.
#[inline]
pub fn insert_post_block_withdrawals_balance_increments(
chain_spec: &ChainSpec,
Expand All @@ -140,8 +144,10 @@ pub fn insert_post_block_withdrawals_balance_increments(
if chain_spec.is_shanghai_active_at_timestamp(block_timestamp) {
if let Some(withdrawals) = withdrawals {
for withdrawal in withdrawals {
*balance_increments.entry(withdrawal.address).or_default() +=
withdrawal.amount_wei();
if withdrawal.amount > 0 {
*balance_increments.entry(withdrawal.address).or_default() +=
withdrawal.amount_wei();
}
}
}
}
Expand Down

0 comments on commit c6ef9d7

Please sign in to comment.