-
Notifications
You must be signed in to change notification settings - Fork 291
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
Rosetta Implementation - pt2 FIX2 (Stage 3.2 of Node API Overhaul) #3338
Merged
Daniel-VDM
merged 22 commits into
harmony-one:main
from
Daniel-VDM:rosetta-undelegation-fix
Sep 11, 2020
Merged
Rosetta Implementation - pt2 FIX2 (Stage 3.2 of Node API Overhaul) #3338
Daniel-VDM
merged 22 commits into
harmony-one:main
from
Daniel-VDM:rosetta-undelegation-fix
Sep 11, 2020
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov Report
@@ Coverage Diff @@
## main #3338 +/- ##
==========================================
- Coverage 34.38% 34.30% -0.08%
==========================================
Files 209 209
Lines 24906 25020 +114
==========================================
+ Hits 8564 8584 +20
- Misses 15685 15785 +100
+ Partials 657 651 -6
Continue to review full report at Codecov.
|
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
…dInEpoch Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* Fix GetUndelegationPayouts * Add GetDelegationsByValidatorAtBlock * Keep beaconchain usage at a minimum Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* Use refactored token lock period getter Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* Add UndelegationPayoutOperation * Rename PreStakingEraBlockRewardOperation to UndelegationPayoutOperation Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
* Refactor special case transaction handeling & add helper functions for determanining when payouts should be calculated * Make getBlockSignerInfo a method of BlockAPI * Rename constants for clarity * Add unit tests for formatting Undelegation payout special transaction Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
Daniel-VDM
force-pushed
the
rosetta-undelegation-fix
branch
from
September 11, 2020 06:18
15d8cc1
to
257041d
Compare
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
Daniel-VDM
force-pushed
the
rosetta-undelegation-fix
branch
from
September 11, 2020 08:44
23a0490
to
834e09b
Compare
rlan35
reviewed
Sep 11, 2020
rlan35
approved these changes
Sep 11, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Stage 3.2 FIX2 of Node API Overhaul
This PR is related to #3312 .
TLDR: This fixes the Undelegation reward operation as well as correctly accounts for the redelegation balance changes. This also adds an info dump for the last block that was garbage collected for non-archival DBs.
Details
Previously, the Undelegation transaction would result in a balance changing operation (other than gas). As this is not the case due to the locking period, the balance at a given block could be different than what it is on-chain. Therefore a 'special' transaction is added to the implementation to account for the Undelegation payouts at the last block of an epoch (similar to the pre-staking era block rewards).
Note that all nodes (archival & pruned) store the last block of an epoch, however, the Undelegations saved for the said block are after the Undelegations have been paid out. Since the unpaid Undelegations are needed to recompute the paid out amount for each delegator, the state of the second to the last block of an epoch is required. This means that the non-archival nodes/DBs will not be able to provide this data unless the state is still in memory. This is why I have added the 'oldest block identifier' on the
network
endpoint for nodes running in the non-archival mode.The oldest block number is computed from the biggest block number that has been garbage collected plus 1. Since the block garbage collection is done monotonically w.r.t. block number, this should always give a block number that is in memory.
Lastly, I used the transaction receipt to report how much of the redelegation took from the account's balance. As well as did some general refactoring/clean-up given the new functions & variables.
All logic was tested using localnet as well as testnet using the rosetta-cli.