fix: remove zero-amount withdrawals before incrementing balances (#4840)

This commit is contained in:
Dan Cline
2023-09-28 12:32:30 -04:00
committed by GitHub
parent 5f9a917fb1
commit c6ef9d7c34

View File

@ -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,
@ -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,
@ -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();
}
}
}
}