-
Notifications
You must be signed in to change notification settings - Fork 34
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
Add average uptime calculation #97
Conversation
thaarok
commented
Nov 7, 2024
•
edited
Loading
edited
- Updated and refactored version of Add average uptime for validators #83
- Use Q1.30 number representation for the normalised uptime (fits into uint32)
- Used math lemma for the average
- Used unsigned integers only to simplify checks/verification
- Disabled too inactive validators included but disabled by default. (I would prefer to include it into the audit.)
f660764
to
d215bbb
Compare
contracts/sfc/ConstantsManager.sol
Outdated
// Is also the minimum number of epochs necessary for deactivation of offline validators. | ||
uint32 public averageUptimeEpochsThreshold; | ||
|
||
// Minimum average uptime in Q1.30 format; acceptable bounds [0,0.9] |
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.
Changing from int32 to uint32 means we have UQ1.31 (and not Q1.30). Perhaps, you want to replace any occurrence in the comments/source code from Q1.30 to UQ1.31. Also, the constant 1 << 30 needs to change to 1 << 31. Ideally, you don't want to have the number 1 << 31 in the source code - perhaps you can define a constant with the value 1 << 31.
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.
Actually we have already Decimal.unit() in the SFC for this purpose.
Reworked to use Decimal.unit() instead.
|
||
function updateAverageUptimeEpochsThreshold(uint32 v) external virtual onlyOwner { | ||
if (v < 10) { | ||
revert ValueTooSmall(); |
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.
In the comment, you may want to mention that an epoch lasts approximately 6 minutes, and the duration 6-minute * threshold must exceed the permissible downtime with a safety margin so that validators going through a maintenance cycle are not automatically culled.
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 don't think we should fix and mention the epoch duration in SFC source, as it depends on the network configuration. We may use very different epochs configuration in the future.
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.
ok.
Rewritten to use Unit.decimal() (1e18) instead of (1<<30) to keep fixed-point representation consistent across usages in the SFC. |
|
||
function updateAverageUptimeEpochsThreshold(uint32 v) external virtual onlyOwner { | ||
if (v < 10) { | ||
revert ValueTooSmall(); |
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.
ok.
2d223b3
to
e75db56
Compare
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.
LGTM
Thank you.