Skip to content

Commit

Permalink
Fix caplin RPC attestation rewards being off by one epoch (#12073)
Browse files Browse the repository at this point in the history
Checked against beaconcha.in, against a synced prysm, and against
ethereum-beacon-api.publicnode.com.

Catlin is consistently off-by-one (one has to ask for the next numbered
epoch to get calculation for the one that one wanted).

@Giulio2002
  • Loading branch information
errge authored Oct 1, 2024
1 parent 9c10433 commit dcf7bca
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions cl/beacon/handler/attestation_rewards.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ func (a *ApiHandler) PostEthV1BeaconRewardsAttestations(w http.ResponseWriter, r
defer tx.Rollback()

epoch, err := beaconhttp.EpochFromRequest(r)

// attestation rewards are always delayed by 1 extra epoch compared to other rewards
epoch += 1

if err != nil {
return nil, beaconhttp.NewEndpointError(http.StatusBadRequest, err)
}
Expand Down
2 changes: 1 addition & 1 deletion cl/beacon/handler/test_data/attestations_1.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cl/beacon/handler/test_data/attestations_2.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"data":{"ideal_rewards":[{"effective_balance":"32000000000","head":"0","target":"290680","source":"0","inclusion_delay":"0","inactivity":"0"},{"effective_balance":"32000000000","head":"0","target":"290680","source":"0","inclusion_delay":"0","inactivity":"0"}],"total_rewards":[{"validator_index":"1","head":"0","target":"290680","source":"-156520","inclusion_delay":"0","inactivity":"0"},{"validator_index":"4","head":"0","target":"290680","source":"-156520","inclusion_delay":"0","inactivity":"0"}]},"execution_optimistic":false,"finalized":true}
{"data":{"ideal_rewards":[{"effective_balance":"32000000000","head":"0","target":"9083","source":"0","inclusion_delay":"0","inactivity":"0"},{"effective_balance":"32000000000","head":"0","target":"9083","source":"0","inclusion_delay":"0","inactivity":"0"}],"total_rewards":[{"validator_index":"1","head":"0","target":"-290680","source":"-156520","inclusion_delay":"0","inactivity":"0"},{"validator_index":"4","head":"0","target":"-290680","source":"-156520","inclusion_delay":"0","inactivity":"0"}]},"execution_optimistic":false,"finalized":true}

0 comments on commit dcf7bca

Please sign in to comment.