-
Notifications
You must be signed in to change notification settings - Fork 93
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
Simplify data flow for epoch queues #2548
Simplify data flow for epoch queues #2548
Conversation
- Some renames to make it easier to read. - Mutate the state of the queue in place relying on EVM reverts to restore the state of the contract when the transactions revert. Would have to still update abstract contract and tests, so mainly pushing this for discussion. We would also have a new function for clients to determine available epochs, if that's actually required. I think for clients it might be fine if we just return the max of the registrationEpoch variable in the contract and currentEpoch() + 1. If the registration epoch gets bumped by one by the time their transaction is included that's just a race condition we can't avoid anyway. They can set a reasonable `validUntilEpoch` to avoid having to wait too long.
85ca13a
to
229b454
Compare
if (exitEpoch < currentEpoch() + 1) { | ||
// The exit epoch is outdated. | ||
exitEpoch = currentEpoch() + 1; | ||
numPendingExitsInEpoch = 0; |
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.
Probably better to call this queueIndex
to make it clearer that it goes from 0 to N - 1.
contracts/src/StakeTable.sol
Outdated
} else if (numPending >= maxChurnRate) { | ||
epoch = firstAvailableEpoch + 1; | ||
queueSize = 0; | ||
function pushToRegistrationQueue() internal override returns (uint64, uint64) { |
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.
previously i merged these into one function nextAvailableEpoch(...)
since the logic being performed was the same - just different queues (register and exit). pros of that are: smaller contract size, reusability and consistency, cons: reduced readability which can lead to errors if the function usage isn't clear.
Which do you think is best?
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 order for them to be general to work for both queues we can't directly operate on the state I think, so I prefer to have them separate.
…ridden again if need be, update parent contract
- Fix solhint. - Add a test for an epoch lenght greater than one. - Remove unnecessary return values from functions that push to queue.
Note this PR is from reviewing #2316 and into that branch.
Would have to still update abstract contract and tests, so mainly pushing this for discussion. We would also have a new function for clients to determine available epochs, if that's actually required.
I think for clients it might be fine if we just return the max of the registrationEpoch variable in the contract and currentEpoch() + 1. If the registration epoch gets bumped by one by the time their transaction is included that's just a race condition we can't avoid anyway. They can set a reasonable
validUntilEpoch
to avoid having to wait too long.