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!: add check for the height of evidence #2007

Merged
merged 4 commits into from
Jul 3, 2024
Merged

Conversation

sainoe
Copy link
Contributor

@sainoe sainoe commented Jul 3, 2024

Please go to the Preview tab and select the appropriate sub-template:

  • Production code - for types fix, feat, and refactor.
  • Docs - for documentation changes.
  • Others - for changes that do not affect production code.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed an issue where the minimum height check for evidence in the consumer double-vote handler was missing, improving validation and error handling for double voting evidence.
  • Tests

    • Enhanced integration tests to better handle and validate scenarios involving double voting and misbehavior checks.
  • New Features

    • Added functionality to set and delete the minimum height for equivocation evidence related to a consumer chain.

Copy link
Contributor

coderabbitai bot commented Jul 3, 2024

Walkthrough

The recent changes introduce validation checks for equivocation evidence in the ICS consumer module to improve overall correctness and robustness. Enhancements include adding missing minimum height checks for evidence, updating related tests for better coverage, and ensuring proper validation and error handling during evidence processing and misbehavior checks.

Changes

File(s) Change Summary
.../provider/2007-evidence-min-height-filter.md Added missing checks for minimum evidence height in consumer double-vote handler.
tests/integration/double_vote.go, tests/integration/misbehaviour.go Updated tests to include cases for the minimum height check and proper evidence handling.
x/ccv/provider/keeper/consumer_equivocation.go Introduced error handling and validation logic for double voting evidence processing.
x/ccv/provider/keeper/proposal.go Added logic to set and delete the minimum height for equivocation evidence for consumer chains.

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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @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.

@sainoe sainoe enabled auto-merge July 3, 2024 13:25
@github-actions github-actions bot added C:Testing Assigned automatically by the PR labeler C:x/provider Assigned automatically by the PR labeler labels Jul 3, 2024
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: 2

@@ -4,6 +4,7 @@ import (
"bytes"
"encoding/binary"
"fmt"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
Copy link
Contributor

Choose a reason for hiding this comment

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

Sort imports according to the Uber Golang style guide.

The imports should be sorted according to the Uber Golang style guide.

- sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
+ "github.com/cosmos/cosmos-sdk/types/errors"
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/errors"
Tools
golangci-lint

7-7: File is not gci-ed with --skip-generated -s standard -s default -s blank -s dot -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) -s prefix(github.com/cometbft/cometbft) -s prefix(github.com/cosmos/interchain-security) --custom-order

(gci)

// the misbehaviour is for a light client attack and not a time violation,
// see ibc-go/modules/light-clients/07-tendermint/types/misbehaviour_handle.go
if !misbehaviour.Header1.GetHeight().EQ(misbehaviour.Header2.GetHeight()) {
return sdkerrors.Wrap(ibcclienttypes.ErrInvalidMisbehaviour, "headers are not at same height")
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace deprecated sdkerrors.Wrap.

sdkerrors.Wrap is deprecated. Use errorsmod.Wrap instead.

- return sdkerrors.Wrap(ibcclienttypes.ErrInvalidMisbehaviour, "headers are not at same height")
+ return errorsmod.Wrap(ibcclienttypes.ErrInvalidMisbehaviour, "headers are not at same height")
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return sdkerrors.Wrap(ibcclienttypes.ErrInvalidMisbehaviour, "headers are not at same height")
return errorsmod.Wrap(ibcclienttypes.ErrInvalidMisbehaviour, "headers are not at same height")
Tools
golangci-lint

314-314: SA1019: sdkerrors.Wrap is deprecated: functionality of this package has been moved to it's own module:

(staticcheck)

@sainoe sainoe added this pull request to the merge queue Jul 3, 2024
@sainoe sainoe removed this pull request from the merge queue due to a manual request Jul 3, 2024
@sainoe sainoe added this pull request to the merge queue Jul 3, 2024
@mpoke mpoke removed this pull request from the merge queue due to a manual request Jul 3, 2024
@mpoke mpoke added this pull request to the merge queue Jul 3, 2024
Merged via the queue into main with commit de9db96 Jul 3, 2024
17 of 18 checks passed
@mpoke mpoke deleted the sainoe/min-evidence-fix-3 branch July 3, 2024 14:53
sainoe added a commit that referenced this pull request Jul 3, 2024
* init commit

* added check, setting, and deleting of the equivocation min height

* update changelog entry

* remove unwwanted changelog entry

* update changelog entries

---------

Co-authored-by: insumity <karolos@informal.systems>
mergify bot pushed a commit that referenced this pull request Jul 3, 2024
* init commit

* added check, setting, and deleting of the equivocation min height

* update changelog entry

* remove unwwanted changelog entry

---------

Co-authored-by: insumity <karolos@informal.systems>
(cherry picked from commit de9db96)
mergify bot pushed a commit that referenced this pull request Jul 3, 2024
* init commit

* added check, setting, and deleting of the equivocation min height

* update changelog entry

* remove unwwanted changelog entry

---------

Co-authored-by: insumity <karolos@informal.systems>
(cherry picked from commit de9db96)
sainoe added a commit that referenced this pull request Jul 4, 2024
fix!: add check for the height of evidence (#2007)

* init commit

* added check, setting, and deleting of the equivocation min height

* update changelog entry

* remove unwwanted changelog entry

---------

Co-authored-by: insumity <karolos@informal.systems>
(cherry picked from commit de9db96)

Co-authored-by: Simon Noetzlin <simon.ntz@gmail.com>
sainoe added a commit that referenced this pull request Jul 4, 2024
fix!: add check for the height of evidence (#2007)

* init commit

* added check, setting, and deleting of the equivocation min height

* update changelog entry

* remove unwwanted changelog entry

---------

Co-authored-by: insumity <karolos@informal.systems>
(cherry picked from commit de9db96)

Co-authored-by: Simon Noetzlin <simon.ntz@gmail.com>
sainoe added a commit that referenced this pull request Jul 4, 2024
* init commit

* added check, setting, and deleting of the equivocation min height

* update changelog entry

* remove unwwanted changelog entry

* update changelog entries

---------

Co-authored-by: insumity <karolos@informal.systems>
sainoe added a commit that referenced this pull request Jul 4, 2024
* chore!: prepare changelog for v4.2.1 release

* update changelog

* revert changelog v4.2.0 removal

* fix changes

* update changelog

* clean unreleased folder

* fix!: add check for min height of evidence (backport #2007) (#2008)

* init commit

* added check, setting, and deleting of the equivocation min height

* update changelog entry

* remove unwwanted changelog entry

* update changelog entries

---------

Co-authored-by: insumity <karolos@informal.systems>

---------

Co-authored-by: insumity <karolos@informal.systems>
mergify bot pushed a commit that referenced this pull request Jul 9, 2024
* init commit

* added check, setting, and deleting of the equivocation min height

* update changelog entry

* remove unwwanted changelog entry

---------

Co-authored-by: insumity <karolos@informal.systems>
(cherry picked from commit de9db96)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:backport/v4.2.x A:backport/v4.3.x A:backport/v4.3.x-lsm A:backport/v5.1.x C:Testing Assigned automatically by the PR labeler C:x/provider Assigned automatically by the PR labeler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants