-
Notifications
You must be signed in to change notification settings - Fork 4
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
fix(StakeManager): fix finalizeEpoch to use last epoch epochEnd #127
Merged
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
3esmit
force-pushed
the
fix-epochStartTime
branch
from
September 23, 2024 05:49
ae25e4d
to
f654fe4
Compare
0x-r4bbit
reviewed
Sep 23, 2024
3esmit
force-pushed
the
fix-epochStartTime
branch
from
September 23, 2024 09:21
f654fe4
to
59c1e6f
Compare
6 tasks
…dd tests to catch error
3esmit
force-pushed
the
fix-epochStartTime
branch
from
September 25, 2024 15:46
59c1e6f
to
057aee1
Compare
0x-r4bbit
approved these changes
Sep 26, 2024
…accounts and epochs This commit refactors the StakeManager contract to optimize the finalization and execution of epochs. It updates the function finalizeEpoch() to new function finalizeEpoch(uint256 _limitEpoch) that releases rewards for the current epoch and increases the epoch up to the specified limit. This allows for more efficient processing of epochs. The changes also include updates to the executeEpoch() and executeAccount() functions to utilize the new finalizeEpoch() function. Additionally, a new function newEpoch() is introduced to calculate the last epoch that can be processed based on the current time. Now the executeAccount(account,limit) will also process epochs up to the specified limit. Added a overload of the executeAccount to process the account up to the newEpoch() Added a overload of the executeEpoch to allow the process of epochs up to a certain limit. All methods now that finalizeEpoch will process the epochs up to the newEpoch(). These changes improve the overall performance, user expirience and reliability of the StakeManager contract. chore(StakeManagerStartMigration.spec): add new function executeEpoch(uint256) to blockedWhenMigrating fix(StakeManager.sol): Replace the check for pending migration in migrationInitialize with noPendingMigration modifier to avoid code duplication
As now all epochEnd() are multiples of EPOCH_SIZE, we can drop the startTime from the struct Epoch, and avoid storing an information that can be cheaply calculated on the fly. - Refactored the StakeManager contract to optimize the finalization of epochs and execution of accounts and epochs. - Replaced the Epoch.startTime with a new global variable startTime to keep track of the start time of the contract. - Modified the finalizeEpoch function to use a temporary variable for the current epoch and calculate the epoch reward only for the current epoch. - Updated the migrationInitialize function to set the start time using the new startTime variable. - Modified the epochEnd function to calculate the end time of the current epoch using the startTime variable. - Modified the newEpoch function to calculate the number of the next epoch based on the startTime variable. refactor(StakeManager): set startTime as immutable, load startTime from previousManager at constructor, verify startTime is correct on initializeMigration
3esmit
force-pushed
the
fix-epochStartTime
branch
from
September 26, 2024 18:37
6afa869
to
3dd2874
Compare
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.
Description
Fixes #124
Checklist
Ensure you completed all of the steps below before submitting your pull request:
forge snapshot
?pnpm gas-report
?pnpm lint
?forge test
?pnpm verify
?