Skip to content
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: reset validator signing info missed blocks counter #8053

Merged
merged 5 commits into from
Apr 19, 2024

Conversation

czarcas7ic
Copy link
Member

@czarcas7ic czarcas7ic commented Apr 15, 2024

Closes: #XXX

What is the purpose of the change

In v24, we upgraded to the sdk v0.50 slashing logic. When timing the migration, we realized that a non-negligible period of time was spent copying over the missed blocks, so we decided it was fine to clear these missed blocks. We, however, forgot to also reset the missed block counter. Therefore, a validator's missed block counter floor is stuck at the value it was at the time of upgrade.

Testing and Verifying

Go test added to demonstrate the counter is reset.

Summary by CodeRabbit

  • New Features
    • Introduced functionality to reset validator signing info missed blocks counter.
    • Implemented operations speedup and various optimizations.
  • Bug Fixes
    • Removed legacy behavior preventing unbonding lockups at very small block heights on testnets.
  • Tests
    • Added test cases for new upgrade functionalities in the slashing module.
  • Documentation
    • Updated CHANGELOG.md with recent changes and improvements.

@czarcas7ic czarcas7ic added the V:state/breaking State machine breaking PR label Apr 15, 2024
@github-actions github-actions bot added the C:app-wiring Changes to the app folder label Apr 15, 2024
@@ -62,20 +63,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* [#7472](https://github.com/osmosis-labs/osmosis/pull/7472) Refactor TWAP keys to only require a single key format. Significantly lowers TWAP-caused writes
* [#7499](https://github.com/osmosis-labs/osmosis/pull/7499) Slight speed/gas improvements to CL CreatePosition and AddToPosition
* [#7564](https://github.com/osmosis-labs/osmosis/pull/7564) Move protorev dev account bank sends from every backrun to once per epoch
* [#7508](https://github.com/osmosis-labs/osmosis/pull/7508) Improve protorev performance by removing iterator and storing base denoms as a single object rather than an array.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, drive by change, periods at the end of some but not all changelog entries was bothering me.

@czarcas7ic czarcas7ic marked this pull request as ready for review April 15, 2024 20:53
Copy link
Contributor

coderabbitai bot commented Apr 15, 2024

Warning

Rate Limit Exceeded

@czarcas7ic has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 31 minutes and 47 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between fbcd43c and 74a95bc.

Walkthrough

The recent updates to the Osmosis project focus on enhancing validator operations and pruning obsolete data. Changes include resetting the missed blocks counter for validators, removing outdated behaviors in lockups, and speeding up various operations. Additionally, the v25 upgrade introduces necessary tests and functions for these adjustments, ensuring robustness and efficiency in the network's performance.

Changes

Files Change Summary
CHANGELOG.md Updated with details on resetting validators' missed blocks counter, removal of legacy lockup behavior, speedup operations, and various improvements.
app/upgrades/v25/upgrades.go Introduces new imports for slashing-related packages, adds resetMissedBlocksCounter function, and includes logic for handling deprecated TWAPs pruning and missed blocks counter reset.
app/upgrades/v25/upgrades_test.go Introduces test cases for the v25 upgrade functionality in the slashing module and includes tests for upgrading validator signing information during the v25 upgrade process.

🐇🌟
In the code's garden, changes bloom anew,
Validators rejoice, missed blocks reset true.
Speed and strength, in lines we thread,
With every pull, old bugs shed.
Hop, hop, hurray, to v25 we zoom! 🚀🌌


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Actionable comments outside the diff hunks (9)
CHANGELOG.md (9)

Line range hint 983-983: Adjust heading level from h4 to h3 for consistency.

- #### [v6.4.0]
+ ### [v6.4.0]

Line range hint 995-995: Adjust heading level from h4 to h3 for consistency.

- #### [v6.3.1]
+ ### [v6.3.1]

Line range hint 1004-1004: Adjust heading level from h4 to h3 for consistency.

- #### [v6.3.0]
+ ### [v6.3.0]

Line range hint 1009-1009: Adjust heading level from h4 to h3 for consistency.

- #### [v6.2.0]
+ ### [v6.2.0]

Line range hint 1061-1061: Adjust heading level from h4 to h3 for consistency.

- #### [v6.1.0]
+ ### [v6.1.0]

Line range hint 322-322: Remove the period at the end of the heading for consistency.

- ## [v4.0.0]
+ ## [v4.0.0]

Line range hint 585-585: Convert the bare URL to a markdown link for better readability.

- See: [SDK v0.43.0 Release Notes](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.43.0) For more details
+ See: [SDK v0.43.0 Release Notes](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.43.0) for more details.

Line range hint 643-643: Convert the bare URL to a markdown link for better readability.

- [wasmd-v.022.0-osmo-v7.2](https://github.com/osmosis-labs/wasmd/releases/tag/v0.22.0-osmo-v7.2) Upgrade SDK and IAVL dependencies to use fast storage
+ [wasmd-v.022.0-osmo-v7.2](https://github.com/osmosis-labs/wasmd/releases/tag/v0.22.0-osmo-v7.2) Upgrade SDK and IAVL dependencies to use fast storage.

Line range hint 1224-1224: Ensure that all links are properly formatted and not empty.

- * [Commit db450f0](https://github.com/osmosis-labs/osmosis/commit/db450f0dce8c595211d920f9bca7ed0f3a136e43) - Revert back to passing in the correct staking keeper into the IBC keeper constructor.
+ * [Commit db450f0](https://github.com/osmosis-labs/osmosis/commit/db450f0dce8c595211d920f9bca7ed0f3a136e43) - Revert back to passing in the correct staking keeper into the IBC keeper constructor.

Comment on lines 45 to 46
info.MissedBlocksCounter = 0
slashingKeeper.SetValidatorSigningInfo(ctx, address, info)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't right -- this will have the opposite of problem of setting a Ceil / potentially leading to negative missed blocks.

You have to re-compute the missed blocks by loading all the bit arrays.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see, couldn't we just reset the bit array to zero again for simplicity @ValarDragon

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By bit array to zero I mean, just deleting them and start from where we did in the migration

Copy link
Member

@ValarDragon ValarDragon Apr 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that would work! (But they would have to be deleted)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch btw, my bad for overlooking

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe I did it correctly here, and added a test that replicates mainnet better: fbcd43c

Copy link
Member

@ValarDragon ValarDragon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm+

Copy link
Collaborator

@PaddyMc PaddyMc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GG!

@PaddyMc PaddyMc merged commit 6b0ac5a into main Apr 19, 2024
1 check passed
@PaddyMc PaddyMc deleted the adam/reset-signing-info branch April 19, 2024 09:12
@github-actions github-actions bot mentioned this pull request May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:app-wiring Changes to the app folder V:state/breaking State machine breaking PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants