-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: add more historic support for staking-payouts #1397
Conversation
Calls that I found need to be replaced that the runtimes before era 518 do not have:
|
sanitizedDepth = Math.min(Number(depth), currentEra - 518).toString(); | ||
} | ||
if (currentEra < 518) { | ||
// const edgeCase = currentEra === 519 || currentEra === 518; edgeCase ? earlyErasBlockInfo[518].start : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commented line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really great work on this! LGTM
This pull request has been mentioned on Polkadot Forum. There might be relevant details there: https://forum.polkadot.network/t/parity-tech-update-for-february/6630/1 |
Issue
We are unable to retrieve the payouts from era 0 until 518 in Kusama.
Example endpoint :
returns :
Root Cause
The available calls before era 518 were different or nonexistent compared to those after era 518. So we need to :
activeEra
, etc)Useful Resource
MIgration Commit that shows the replacement of some of the calls.
Suggested Solution
For the first 517 eras :
points
for an era, we reference theend
block of the previous era.rewards
for an era, we reference thestart
block of the current era.activeEra
was not available so we changed the logic on how we calculate it taking into account theSessionIndex
andcurrentEra
. Again, an exception case for era 0 was added in this check.historyDepth
was not available in that runtime so we disabled thedepth
query parameter for those eras.kusamaEarlyErasBlockInfo.json
) to track thestart
andend
block of each era.Important Note
Sample Test cases
Below are example test cases that refer to eras preceding 518 and now return payout results after implementing the suggested solution:
Example Request 1
We are querying block =
1341083
which according to our registry (kusamaEarlyErasBlockInfo.json
) is thestart
of era508
. Since Sidecar returns by default results with depthera - 1
, we expect to see results for era507
.Result for Request 1
We can verify this outcome (
totalEraPayout
=415081276367227
) by comparing it with the result obtained from Subscan event 1341083-2Example Request 2
We are querying block =
1057267
which according to our registry is thestart
of era427
. Since Sidecar returns by default results with depthera - 1
, we expect to see results for era426
.Result for Request 2
We can verify this outcome (
totalEraPayout
=349336487782285
) by comparing it with the result obtained from Polkadot JS Apps block 1057267 - Reward eventCredits & Thanks