From a7adb9c813a9d68241183dc89c776b241107fe26 Mon Sep 17 00:00:00 2001 From: Shane Bammel Date: Fri, 3 Feb 2023 16:39:11 -0600 Subject: [PATCH] Fix proposer reward calculations Aggregate the value before applying the balance increase as done in Prysm. The previous incremental additions resulted in different reward burn behavior because of truncation in the math. --- .../src/per_block_processing/altair/sync_committee.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/consensus/state_processing/src/per_block_processing/altair/sync_committee.rs b/consensus/state_processing/src/per_block_processing/altair/sync_committee.rs index fb92bffc4..8e5280d04 100644 --- a/consensus/state_processing/src/per_block_processing/altair/sync_committee.rs +++ b/consensus/state_processing/src/per_block_processing/altair/sync_committee.rs @@ -47,18 +47,19 @@ pub fn process_sync_aggregate( // Apply participant and proposer rewards let committee_indices = state.get_sync_committee_indices(¤t_sync_committee)?; + let mut earned_proposer_reward = 0; for (participant_index, participation_bit) in committee_indices .into_iter() .zip(aggregate.sync_committee_bits.iter()) { if participation_bit { increase_balance(state, participant_index, participant_reward, spec, true)?; - increase_balance(state, proposer_index as usize, proposer_reward, spec, true)?; + earned_proposer_reward += proposer_reward; } else { decrease_balance(state, participant_index, participant_reward)?; } } - + increase_balance(state, proposer_index as usize, earned_proposer_reward, spec, true)?; Ok(()) }