Proto: do not use snapshot to compute rights
Context
To compute rights, instead of using snapshots of stakes which makes things hard to reason with, we can use:
- for staked tez, the value at the end of the cycle; those tez are going to stay frozen for at least 7 more cycles;
- for delegated tez, the minimum over the cycle; if you switched delegate or if you staked during the cycle, then those tez do not bring rights in that cycle.
I think it has the good properties:
- not counting twice the same tez,
- not bringing rights to people moving tez, hence preventing people buying and selling tez right before the snapshot to gather the rights.
What we lose is the consistency that the sum of rights correspond to the sum of delegated+frozen stake at some point in time.
The MR is made based on !10413 (merged), !11086 (merged), !11197 (merged), and made of:
-
refactoring of-> moved to !11086 (merged)Full_staking_balance_repr - enriching
Full_staking_balance_reprto lazily maintain the minimum over the last cycle (probably requires more comments) - using it instead of the snapshot
-
getting rid of the snapshots-> moved to !11374 (merged) -
cleaning up dead stuff-> moved to !11369 (merged), !11370 (merged), !11374 (merged)
Manually testing the MR
See updated tests.
Some AI tests are still broken, they make assumptions on what the snapshot contains. Leaving the fix to @lrand
Checklist
-
Document the interface of any function added or modified (see the coding guidelines) -
Document any change to the user interface, including configuration parameters (see node configuration) -
Provide automatic testing (see the testing guide). -
For new features and bug fixes, add an item in the appropriate changelog ( docs/protocols/alpha.rstfor the protocol and the environment,CHANGES.rstat the root of the repository for everything else). -
Select suitable reviewers using the Reviewersfield below. -
Select as Assigneethe next person who should take action on that MR
Edited by Mehdi Bouaziz