-
Notifications
You must be signed in to change notification settings - Fork 23
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
Track uptimes for delegation period #520
Conversation
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.
I think we should also add an external updateUptime
function that can be called by anyone to update a validator's uptime.
I think we should also split the initializeEndDelegation
and initializeEndValidation
into two functions, one that expects the user to be reward eligible and one that doesn't. That way if a used calls the function expecting to be reward eligible, we can revert and not cause irreversible losses of rewards.
$._validatorUptimes[validationID] = uptime; | ||
emit ValidationUptimeUpdated(validationID, uptime); |
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 should only update the validator's uptime if the uptime provided is greater than the previously provided uptime. This way delegators may not have to provide an uptime proof to get their rewards, provided the validator has had a sufficiently high uptime.
uint64 uptime; | ||
if (includeUptimeProof) { | ||
uptime = _updateUptime(validationID, messageIndex); |
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 should read from state instead of using a return from _updateUptime
. That way if the validator's uptime has been updated recently, anyone ending their delegation won't have to submit another uptime proof, provided that the latest reported uptime up until now hits the 80% threshold.
Discussed both of these points in a call, and agreed that they would be optimizations that would potentially trade gas efficiency for usability. Requiring an uptime proof to be submitted when intializing validation/delegation end in order to be eligible for rewards is simple to reason about, and cheap assuming that fetching and verifying an uptime proof is cheap. On the other hand, decoupling uptime proof delivery from delegation/validation end could save gas in some circumstances, but would require the user to first check if they're eligible for rewards under the latest known proof, and would also require that proof be stored in the contract state. |
"PoSValidatorManager: invalid origin sender address" | ||
); | ||
|
||
(bytes32 uptimeValidationID, uint64 uptime) = |
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.
Just for my own understanding, does uptime return the absolute amount of time that the validator was up, or a percent of time that it was up during the staking period? I'm just thinking of whether other information is necessary to calculate rewards.
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.
It returns the absolute number of seconds the validator has been up
Why this should be merged
Modifies
initializeEndDelegation
to accept an uptime proof from the P-Chain to be used when calculating rewards incompleteEndDelegation
. If no uptime proof is provided, the uptime is assumed to be zero.This PR does not implement delegation rewards calculation or unlocks. That should be done in the same fashion as #489, or added as part of that work.
How this works
See above
How this was tested
CI. Skipped unit tests for now, since we are not doing anything interesting with the uptime proofs yet.
How is this documented
N/A