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

feat: include rotate keys logic in abci #18236

Merged
merged 115 commits into from
Dec 22, 2023
Merged

feat: include rotate keys logic in abci #18236

merged 115 commits into from
Dec 22, 2023

Conversation

atheeshp
Copy link
Contributor

@atheeshp atheeshp commented Oct 24, 2023

Description

follow-up: #18188
ref: #18141


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • run make lint and make test
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

Summary by CodeRabbit

  • New Features

    • Introduced a new function to update the community pool following a consensus public key rotation.
    • Added functionality to handle the correct consensus address when a validator rotates its key.
    • Implemented a new error type for handling invalid consensus public keys.
  • Enhancements

    • Updated the staking module to support validator public key rotation and associated hooks.
    • Improved handling of consensus public key rotation history and matured key rotations.
  • Bug Fixes

    • Fixed an issue to ensure the correct consensus address is used after a validator's key rotation.
  • Testing

    • Added new tests to verify the correct behavior of consensus public key updates.
  • Documentation

    • Updated comments and documentation to reflect changes related to consensus public key rotation.
  • Refactor

    • Renamed module constants to avoid cyclic dependencies and better reflect their purpose.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 24, 2023

Note

Reviews Paused

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Walkthrough

The changes across various files in the Cosmos SDK introduce functionality for updating validators' consensus public keys. This includes hooks and methods for handling the update process, error handling for invalid keys, and updating related data structures such as signing info and missed blocks. Additionally, there are updates to the staking module to manage the rotation history and matured keys, as well as changes to the distribution module to handle rotation fees. Tests are added to ensure the new functionality works as expected.

Changes

File Summary
x/distribution/keeper/hooks.go
x/slashing/keeper/hooks.go
x/staking/types/expected_keepers.go
x/staking/types/hooks.go
Introduced AfterConsensusPubKeyUpdate function to handle updates after a validator's consensus public key is rotated.
x/evidence/keeper/infraction.go Added code to handle the correct consensus address in case of a validator's key rotation.
x/slashing/keeper/signing_info.go Added PerformConsensusPubKeyUpdate function to update related data structures after a consensus public key change.
x/staking/keeper/cons_pubkey.go
x/staking/keeper/val_state_change.go
Implemented methods to manage validator public key updates and rotation history.
x/staking/keeper/hooks_test.go Added tests for the new AfterConsensusPubKeyUpdate hook.
x/staking/types/codec.go Registered new message type MsgRotateConsPubKey for handling public key rotations.
x/staking/keeper/msg_server.go Modified coin transfer logic to reflect changes in module names for handling fees.
x/staking/types/keys.go Renamed DistributionModuleName to PoolModuleName to avoid cyclic dependencies.

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 X ?


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • You can reply to a review comment made by CodeRabbit.
  • You can tag CodeRabbit on specific lines of code or files in the PR by tagging @coderabbitai in a comment.
  • You can tag @coderabbitai in a PR comment and ask one-off questions about the PR and the codebase. Use quoted replies to pass the context for follow-up questions.

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.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

x/distribution/keeper/hooks.go Fixed Show fixed Hide fixed
x/staking/keeper/cons_pubkey.go Fixed Show fixed Hide fixed
x/staking/keeper/cons_pubkey.go Fixed Show fixed Hide fixed
x/staking/keeper/cons_pubkey.go Fixed Show fixed Hide fixed
Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

Left a few minor comments, but overall I think this looks good enough to merge once addressed. Great work @atheeshp 👏

x/slashing/keeper/signing_info.go Outdated Show resolved Hide resolved
x/staking/keeper/val_state_change.go Outdated Show resolved Hide resolved
x/staking/keeper/val_state_change.go Outdated Show resolved Hide resolved
@atheeshp atheeshp requested a review from julienrbrt December 21, 2023 11:46
@@ -53,6 +53,10 @@ type StakingKeeper interface {

// IsValidatorJailed returns if the validator is jailed.
IsValidatorJailed(ctx context.Context, addr sdk.ConsAddress) (bool, error)

// ValidatorIdentifier maps the new cons key to previous cons key (which is the address before the rotation).
Copy link
Member

Choose a reason for hiding this comment

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

I don't necessary love this name, it doesn't accurately describe what it does

@atheeshp atheeshp added this pull request to the merge queue Dec 22, 2023
Merged via the queue into main with commit 19e66a9 Dec 22, 2023
59 of 63 checks passed
@atheeshp atheeshp deleted the ap/abci-and-hooks branch December 22, 2023 10:15
@coderabbitai coderabbitai bot mentioned this pull request Jan 17, 2024
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants