This repository has been archived by the owner on Mar 5, 2024. It is now read-only.
HIP-28 consensus reward calc grace period #922
Merged
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.
As described in HIP-28, this update adds a grace period in the consensus epoch reward calculation. Instead of always basing the calculation on election_interval number of block epochs, allow for up to election_interval + election_retry_interval blocks to be used in an epoch for calculating consensus rewards in order to provide time for the election itself. Change is protected behind reward_version chain var and is active when the value is >=6.
This PR does not address the other suggested changes in the HIP, specifically reallocating unearned consensus rewards to PoC as evanmcc and others have some alternative suggestions.
Lastly, this fixes the epoch reward calc for other reward types as well which was off by one block. Start and End are inclusive but epoch length was calculated as End - Start. Changed to End - Start + 1.
To-Do: add some test cases. I have verified it compiles and all existing EUnit tests execute successfully. However, I have not added any tests specific to the new code.