Skip to content

fix: use ClaimedRewards storage for staking-payouts claimed status post-AHM#1922

Merged
eugypalu merged 1 commit intomasterfrom
fix/staking-payouts-claimed-status
Mar 23, 2026
Merged

fix: use ClaimedRewards storage for staking-payouts claimed status post-AHM#1922
eugypalu merged 1 commit intomasterfrom
fix/staking-payouts-claimed-status

Conversation

@eugypalu
Copy link
Collaborator

Summary

Fix accounts/{address}/staking-payouts returning already-claimed payouts as unclaimed on Asset Hub (post-AHM).

Root cause: After the Asset Hub Migration, pallet-staking-async records claimed rewards in the Staking.ClaimedRewards(era, validator) storage map. The legacy legacyClaimedRewards field in the staking ledger is no longer updated. Sidecar was only reading the legacy field, so it always saw claimed: false for post-AHM eras.

Fix: In deriveEraPayouts, check ClaimedRewards storage first, comparing claimed pages against pageCount from ErasStakersOverview. Fall back to the legacy ledger fields only when the new storage doesn't exist in the runtime (pre-AHM). This matches the approach used by polkadot-rest-api and already present in sidecar's own AccountsStakingInfoService.

Changes:

  • deriveEraPayouts made async, receives historicApi (required) to query storage at the correct block
  • All three call sites updated (fetchAccountStakingPayout, fetchErasFromRelayChain, fetchErasFromAssetHub)
  • Added tests covering the new ClaimedRewards storage path

Before (sidecar): era 2101 returned with claimed: false and payout data, even though the reward was already claimed.
After (sidecar): era 2101 correctly returns "payouts": [] with unclaimedOnly=true, matching polkadot-rest-api.

@eugypalu eugypalu requested a review from a team as a code owner March 18, 2026 17:17
Copy link
Member

@TarikGul TarikGul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍 Thanks for the fix.

@eugypalu eugypalu merged commit 90cfeee into master Mar 23, 2026
10 checks passed
@eugypalu eugypalu deleted the fix/staking-payouts-claimed-status branch March 23, 2026 11:57
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.

2 participants