Closed DefinitelyNotAGoat closed 5 years ago
Did some more testing here. The current calculation needs to be adjusted to use PreservedCycles constant so it works on multiple nets. Secondly, the data that is reported back from the first "old cycle" is typically inaccurate.
Consider this code that just loops over snapshots and prints the frozen balance. https://ghostbin.com/paste/f6f3m
Running this on mainnet as so ./cycles -cycle 57
produces this output https://ghostbin.com/paste/qtu3a
Notice the first cycle snapshot fetched (62, which is $cycle + preservedCycles) has no values, as does 63. Rewards appear in 64-69. Notice also that the rewards are different between 62 and the others.
Seems that the snapshot to fetch for the correct balance should be either the second one or the last: $cycle + (preservedCycles * 2) + 2
Ugh. Ok. There's two snapshots in mainnet that seem to be missing data. Cycle 62 and 63 both seem to be missing this frozen data when you use ($cycle + (preservedCycles * 2) + 2). All other snapshots are fine.
This calculation works in all my test cases, but I have no logic behind why +3 makes it all work.
diff := curCycle - cycle
if diff > this.Constants.PreservedCycles {
snap, err := this.GetSnapShot(cycle + this.Constants.PreservedCycles + 3)
Can only use this function with currently relevant data. Need to make it work historically.