Incentives: Use agreement round when estimating a node's proposal interval #6136
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is intended to fix some bugs in the block incentive scheme related to detecting when an account is absent.
If a node goes online with much more stake than the current total online stake, it could be immediately suspended because it appears to be "absent" in the very round in which it joins.
Because keyreg sets LastHeartbeat to fv, if a txn takes a while to get onto the chain, the account may already be absent.
After going online, a node can't vote for 320 rounds. So, if it joins with, say, 5% of stake, then after 200 rounds it is already absent.
This is a draft for now as it does not address everything yet.
Was caused because we were calculating the expected interval using the node's new online balance, as a fraction of the old total balance. Since we don't know the new total balance yet (because we are processing absentee and challenge kickoffs), the fix was to move to comparing balances in the agreement round rather than current round. This makes more sense anyway, since the interval in effect at round n is really based on the stake ratio at n-320 anyway.
Can be fixed by using the current round instead of FirstValid for the account's LastHeartbeat during keyreg, but see next point...
Is partially fixed because of change 1. All during the 320 rounds after keyreg, the account's online balance is 0, so it won't be absent after 200 rounds. But it would be considered absent as soon as it becomes truly eligible to vote (320 rounds after keyreg). The online balance would be high, it should have voted at least once in the last 200 rounds (but couldn't) so it would be marked absent then. Is completely fixed by adding the agreement round lookback to the LastHeartbeat that is put in place during keyreg. That is, if an account registers in round 1500, we write 1820 to the account's LastHeartbeat, thus making it immune from the 10x interval check until after it actually has a chance to start proposing. Furthermore, once it is truly ready to vote in round 1820, it needs to "last seen" in the last 200 rounds, and the heartbeat will count.