-
Notifications
You must be signed in to change notification settings - Fork 639
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
Drop Pending Stakers 3 - persist stakers' StartTime #2306
Conversation
} | ||
|
||
func writeDelegatorMetadata(db database.KeyValueWriter, metadata *delegatorMetadata) error { | ||
return database.PutUInt64(db, metadata.txID[:], metadata.PotentialReward) | ||
metadataBytes, err := metadataCodec.Marshal(v1, metadata) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we store start time as soon as we deploy code, without waiting for fork activation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can people downgrade after updating to a version with this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The versioning should allow smooth handling of upgrades/downgrades
When reading from disk:
- If metadata have version zero, start time won't be loaded from disk and the default value AddStakerTx.StartTime() will be used.
- If metadata have version 1, start time will be read from disk.
This is why we don't need a data migration here, which may cause problems with downgrades.
The downside is that it'd be writing the StartTime to disk as soon as the code is deployed, even if Durango is not active. This is an extra int64 written for each staker promoted from pending to current among code deploy and code activation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens when I upgrade my node to this PR and write codec version v1 and then downgrade to a node that does not support parsing codec version v1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dhrubabasu right! I fixed it by reintroducing the config.Confg and by selecting codec version based on the fork activation. Code will be cleaned up as soon as fork is activated
0deb60a
to
8e8ab33
Compare
8e8ab33
to
b213740
Compare
Why this should be merged
Staking will start at a time different from the tx.StartTime specified in each AddStakerTx. Hence we need to explicitly store the start time of each staker to be able to duly rebuild it once we start a node and load data from disk
How this works
Slicing #2175 up
How this was tested
CI