Skip to content

Fix: Use NextState.ConsolidatedAmounts instead of CurrentState in EpochReward#218

Open
kamoallebabot-blip wants to merge 1 commit intomigalabs:masterfrom
kamoallebabot-blip:fix/electra-consolidated-amounts
Open

Fix: Use NextState.ConsolidatedAmounts instead of CurrentState in EpochReward#218
kamoallebabot-blip wants to merge 1 commit intomigalabs:masterfrom
kamoallebabot-blip:fix/electra-consolidated-amounts

Conversation

@kamoallebabot-blip
Copy link

Fixes #215

Problem

Validators that are targets of consolidations (post-Electra) have their f_reward values inflated by exactly the consolidated amount (~32 ETH) due to incorrect timing when subtracting ConsolidatedAmounts from the epoch reward calculation.

Root Cause

The EpochReward() function in pkg/spec/metrics/standard.go was using CurrentState.ConsolidatedAmounts instead of NextState.ConsolidatedAmounts. This caused the subtraction to fail because the consolidated amount is only available in NextState during consolidation events.

The Fix

Changed line 31 in pkg/spec/metrics/standard.go from:

consolidatedAmount, ok := p.CurrentState.ConsolidatedAmounts[valIdx]

To:

consolidatedAmount, ok := p.NextState.ConsolidatedAmounts[valIdx]

This aligns with how Deposits are handled (line 42 uses p.NextState.Deposits).

Impact

  • Fixes inflated f_reward values for validators receiving consolidations
  • Resolves cascading errors in pool summaries and APR calculations
  • Allows proper historical data cleanup for epochs >= 411389 (post-Electra)

Testing

The fix resolves the symptoms where validators show f_reward >> f_max_reward for consolidated amounts, bringing f_reward back to expected ranges.

…chReward

Fixes migalabs#215

## Problem
Validators that are targets of consolidations (post-Electra) have their
f_reward values inflated by exactly the consolidated amount (~32 ETH) due to
incorrect timing when subtracting ConsolidatedAmounts from the epoch reward
calculation.

## Root Cause
EpochReward() function was using CurrentState.ConsolidatedAmounts which
doesn't contain the consolidated amount until NextState. This caused the
subtraction to fail and resulted in inflated f_reward values.

## Solution
Changed line 31 in pkg/spec/metrics/standard.go to use NextState.ConsolidatedAmounts
instead of CurrentState.ConsolidatedAmounts, aligning with how Deposits are
handled on line 42.

Before fix:
  consolidatedAmount, ok := p.CurrentState.ConsolidatedAmounts[valIdx]

After fix:
  consolidatedAmount, ok := p.NextState.ConsolidatedAmounts[valIdx]

This ensures consolidated amounts are properly subtracted from the reward
calculation for target validators.

## Testing
The fix resolves the symptoms where validators show f_reward >> f_max_reward
for consolidated amounts, bringing f_reward back to expected ranges.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

f_reward Inflated by Consolidated Amounts (Post-Electra Validators)

1 participant