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

Problem: fix of broken opBlockhash and tx validation are not included #1621

Merged
merged 2 commits into from
Oct 4, 2024

Conversation

mmsqe
Copy link
Collaborator

@mmsqe mmsqe commented Oct 4, 2024

👮🏻👮🏻👮🏻 !!!! REFERENCE THE PROBLEM YOUR ARE SOLVING IN THE PR TITLE AND DESCRIBE YOUR SOLUTION HERE !!!! DO NOT FORGET !!!! 👮🏻👮🏻👮🏻

For more info

PR Checklist:

  • Have you read the CONTRIBUTING.md?
  • Does your PR follow the C4 patch requirements?
  • Have you rebased your work on top of the latest master?
  • Have you checked your code compiles? (make)
  • Have you included tests for any non-trivial functionality?
  • Have you checked your code passes the unit tests? (make test)
  • Have you checked your code formatting is correct? (go fmt)
  • Have you checked your basic code style is fine? (golangci-lint run)
  • If you added any dependencies, have you checked they do not contain any known vulnerabilities? (go list -json -m all | nancy sleuth)
  • If your changes affect the client infrastructure, have you run the integration test?
  • If your changes affect public APIs, does your PR follow the C4 evolution of public contracts?
  • If your code changes public APIs, have you incremented the crate version numbers and documented your changes in the CHANGELOG.md?
  • If you are contributing for the first time, please read the agreement in CONTRIBUTING.md now and add a comment to this pull request stating that your PR is in accordance with the Developer's Certificate of Origin.

Thank you for your code, it's appreciated! :)

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a new parameter, header_hash_num, to enhance EVM module functionality and API documentation.
    • Added support for IBC channel upgrade methods.
  • Improvements

    • Optimized performance by adjusting default parallelism settings.
    • Updated Ethermint to improve API call efficiency and transaction validation.
  • Bug Fixes

    • Resolved issues with multisig accounts and incorrect address queries.
    • Fixed unsupported sign mode for bank transfers.
  • Documentation

    • Updated changelog to reflect new versioning and significant changes.

@mmsqe mmsqe requested a review from a team as a code owner October 4, 2024 08:03
@mmsqe mmsqe requested review from yihuang and JayT106 and removed request for a team October 4, 2024 08:03
Copy link
Contributor

coderabbitai bot commented Oct 4, 2024

Walkthrough

The pull request includes updates across several files, primarily focusing on enhancements and bug fixes. Key changes involve modifications to the CHANGELOG.md to document improvements, including performance optimizations and bug resolutions. The app/upgrades.go file has been updated to handle EVM parameters during upgrades. Additionally, the Swagger documentation has been enhanced with a new field, header_hash_num. Dependency management has been updated in go.mod and gomod2nix.toml, while the integration tests have been refined for better clarity and organization. A new field has also been added to the EVM parameters in the protocol buffer definition.

Changes

File Change Summary
CHANGELOG.md Updated to reflect improvements, bug fixes, and new version v1.4.0-rc0.
app/upgrades.go Modified RegisterUpgradeHandlers to handle EVM parameters and added error handling.
client/docs/swagger-ui/swagger.yaml Added header_hash_num field in paths and definitions for EVM module.
go.mod Updated Go toolchain and various module dependencies, including github.com/evmos/ethermint.
gomod2nix.toml Updated module versions and hashes for dependencies, particularly github.com/evmos/ethermint.
integration_tests/test_upgrade.py Introduced assert_evm_params function and refined assertions related to EVM parameters.
third_party/proto/ethermint/evm/v1/params.proto Added header_hash_num field to Params message in EVM package.

Possibly related PRs

Suggested reviewers

  • devashishdxt
  • calvinaco
  • yihuang

Poem

Hop hop, the changes are here,
With upgrades and fixes, we cheer!
A new field to guide,
In EVM we confide,
For smoother paths, let’s persevere! 🐇✨


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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

codecov bot commented Oct 4, 2024

Codecov Report

Attention: Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Project coverage is 36.86%. Comparing base (c96cdaf) to head (04b239b).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
app/upgrades.go 0.00% 4 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1621      +/-   ##
==========================================
- Coverage   36.88%   36.86%   -0.02%     
==========================================
  Files         102      102              
  Lines        8055     8059       +4     
==========================================
  Hits         2971     2971              
- Misses       4706     4710       +4     
  Partials      378      378              
Files with missing lines Coverage Δ
app/upgrades.go 15.38% <0.00%> (-2.80%) ⬇️

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

🧹 Outside diff range and nitpick comments (5)
client/docs/swagger-ui/swagger.yaml (1)

49087-49090: LGTM. Consistent definition, but consider DRY principle.

The addition of the header_hash_num field here maintains consistency with its earlier definitions, which is crucial for accurate API documentation.

However, the repetition of this definition in multiple places might make future updates more error-prone. Consider if it's possible to use Swagger's reference feature ($ref) to define this parameter once and reference it in multiple places. This would adhere to the DRY (Don't Repeat Yourself) principle and make future updates easier.

Example:

components:
  parameters:
    HeaderHashNum:
      name: header_hash_num
      in: query
      schema:
        type: string
        format: uint64
      description: header_hash_num is the number of header hash to persist.

paths:
  /your/path:
    get:
      parameters:
        - $ref: '#/components/parameters/HeaderHashNum'

This is just a suggestion for potential future refactoring, not a blocking issue for this PR.

integration_tests/test_upgrade.py (2)

297-297: LGTM: Important assertion for header_hash_num, but consider using a constant

This assertion is crucial for verifying the header_hash_num parameter after the upgrade. It aligns well with the PR objective of fixing broken opBlockhash.

Consider defining "10000" as a named constant at the module level for better maintainability. For example:

EXPECTED_HEADER_HASH_NUM = "10000"

# Then use it in the assertion:
assert cli.query_params("evm")["params"]["header_hash_num"] == EXPECTED_HEADER_HASH_NUM, p

This makes it easier to update the expected value in the future if needed.


299-300: Approved, but consider adding a comment for clarity

The change to expect an AssertionError when querying icaauth parameters is likely correct given the upgrades. However, the reason for this change is not immediately clear from the code.

Consider adding a comment explaining why we expect an AssertionError here after the upgrade. This will help future maintainers understand the intention behind this test. For example:

# After the upgrade, icaauth parameters should no longer be available
with pytest.raises(AssertionError):
    cli.query_params("icaauth")
go.mod (1)

Line range hint 280-293: Carefully manage replace directives and custom forks

The replace directives are used to override default module versions or use custom forks. While this can be necessary for compatibility or specific features, it also introduces maintenance challenges. Pay special attention to:

  1. The replacement of github.com/ethereum/go-ethereum with a custom fork.
  2. The use of a custom ethermint fork.
  3. The replacement of github.com/99designs/keyring with github.com/cosmos/keyring.

Ensure that:

  1. Custom forks are regularly updated with upstream changes to maintain security and compatibility.
  2. The reasons for using custom forks are well-documented.
  3. There's a plan to migrate away from custom forks if/when the necessary features are incorporated upstream.

Consider creating a document that tracks all custom forks, their purposes, and plans for future maintenance or migration.

CHANGELOG.md (1)

19-19: Consider clarifying the ethermint update description.

The description "Update ethermint to the fix of broken opBlockhash and tx validation" could be more precise. Consider rephrasing it to something like "Update ethermint to include fixes for broken opBlockhash and tx validation issues."

-* [#1621](https://github.com/crypto-org-chain/cronos/pull/1621) Update ethermint to the fix of broken opBlockhash and tx validation.
+* [#1621](https://github.com/crypto-org-chain/cronos/pull/1621) Update ethermint to include fixes for broken opBlockhash and tx validation issues.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~19-~19: “to the” seems less likely than “to”.
Context: ...hain/cronos/pull/1621) Update ethermint to the fix of broken opBlockhash and tx valida...

(AI_HYDRA_LEO_CP_TO_THE_TO)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between a87e03b and 0389b35.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (7)
  • CHANGELOG.md (1 hunks)
  • app/upgrades.go (2 hunks)
  • client/docs/swagger-ui/swagger.yaml (3 hunks)
  • go.mod (1 hunks)
  • gomod2nix.toml (1 hunks)
  • integration_tests/test_upgrade.py (1 hunks)
  • third_party/proto/ethermint/evm/v1/params.proto (1 hunks)
🧰 Additional context used
🪛 LanguageTool
CHANGELOG.md

[uncategorized] ~19-~19: “to the” seems less likely than “to”.
Context: ...hain/cronos/pull/1621) Update ethermint to the fix of broken opBlockhash and tx valida...

(AI_HYDRA_LEO_CP_TO_THE_TO)

🪛 GitHub Check: codecov/patch
app/upgrades.go

[warning] 30-33: app/upgrades.go#L30-L33
Added lines #L30 - L33 were not covered by tests

🔇 Additional comments (13)
client/docs/swagger-ui/swagger.yaml (3)

48887-48890: LGTM. Consistent with previous definition.

The addition of the header_hash_num field here is consistent with its earlier definition. This repetition is often necessary in Swagger YAML files to ensure the field is properly documented in all relevant contexts.


3047-3050: Request for clarification on PR objectives

The changes in this file consistently add a new header_hash_num parameter to the EVM module parameters in the Swagger YAML file. These additions are well-documented and maintain consistency throughout the file.

However, there seems to be a disconnect between these changes and the stated PR objectives of fixing broken opBlockhash and tx validation. Could you please provide more context on how the addition of this header_hash_num parameter relates to these objectives? This information would help reviewers better understand the purpose and impact of these changes in the broader context of the PR.

Additionally, it would be helpful to know if there are other files changed in this PR that more directly address the opBlockhash and tx validation issues mentioned in the PR description.

To help understand the context, let's search for related terms in the codebase:

Also applies to: 48887-48890, 49087-49090


3047-3050: LGTM. Please clarify the relation to PR objectives.

The addition of the header_hash_num field to the EVM module parameters is well-documented and follows good API design practices. The description is clear and the use of uint64 as a string format is appropriate for cross-system compatibility.

However, could you please clarify how this change relates to fixing the broken opBlockhash and tx validation mentioned in the PR objectives? This context would help reviewers better understand the purpose and impact of this addition.

To ensure consistency, let's check if this new field is used elsewhere in the codebase:

✅ Verification successful

Verified.

The header_hash_num field is utilized in app/upgrades.go to set evmParams.HeaderHashNum, which supports the PR objectives of fixing broken opBlockhash and transaction validation by enhancing header hash persistence.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for usage of header_hash_num in the codebase

# Test: Search for header_hash_num in Go files
rg --type go 'header_hash_num'

# Test: Search for HeaderHashNum in Go files (in case of camelCase usage)
rg --type go 'HeaderHashNum'

Length of output: 134

third_party/proto/ethermint/evm/v1/params.proto (1)

25-26: New field added to Params message: Verify alignment with PR objectives

The addition of the header_hash_num field to the Params message is a significant change that may relate to the PR's objective of fixing opBlockhash issues. However, there are some points to consider:

  1. The field's purpose is not immediately clear from its name alone. Consider adding a more detailed comment explaining its specific use and impact on the EVM module.

  2. The type uint64 suggests this is a numeric value, but it's not clear what the acceptable range or default value should be.

  3. This change might require updates to other parts of the codebase that interact with the Params message, such as parameter initialization, API endpoints, or state management.

To ensure this change is properly integrated, please run the following script to check for other occurrences of the Params message in the codebase:

Would you like assistance in drafting more detailed documentation for this new field or in identifying other areas of the codebase that might need updates due to this change?

✅ Verification successful

Addition of header_hash_num Verified

The introduction of the header_hash_num field in third_party/proto/ethermint/evm/v1/params.proto has been thoroughly reviewed. No additional usages or dependencies were found that require updates, ensuring that this change aligns with the PR objectives without introducing conflicts.

  • Consider enhancing the comment for header_hash_num to provide more context on its usage and default values, improving clarity for future maintenance.
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find other occurrences of the Params message that might need updating

# Search for Params message usage in Go files
echo "Searching for Params usage in Go files:"
rg --type go -A 5 'Params\s*{' 

# Search for Params message usage in Protobuf files
echo "Searching for Params usage in Protobuf files:"
rg --type proto -A 5 'Params\s*{' 

Length of output: 426


Script:

#!/bin/bash
# Description: Find other occurrences of the Params message that might need updating

# Search for Params message usage in Go files
echo "Searching for Params usage in Go files:"
rg --type go -A 5 'Params\s*\{'

# Search for Params message usage in Protobuf files
echo "Searching for Params usage in Protobuf files:"
rg --type proto -A 5 'Params\s*\{'

Length of output: 11243


Script:

#!/bin/bash
# Description: Find other occurrences of the Params message that might need updating

# Search for Params message usage in Go files
echo "Searching for Params usage in Go files:"
rg --type go -A 5 'Params\s*\{'

# Search for Params message usage in Protobuf files using a glob pattern
echo "Searching for Params usage in Protobuf files:"
rg -g "*.proto" -A 5 'Params\s*\{'

Length of output: 22058

integration_tests/test_upgrade.py (3)

287-291: LGTM: New helper function improves code maintainability

The addition of the assert_evm_params function is a good refactoring step. It encapsulates the logic for asserting EVM parameters, which improves code readability and maintainability. The removal of header_hash_num before comparison is noteworthy and suggests this value might change between upgrades.


292-293: LGTM: Effective use of the new helper function

The usage of the assert_evm_params function here simplifies the assertions for EVM parameters at different upgrade heights. This change makes the code more readable and maintainable.


286-300: Overall assessment: Improvements enhance upgrade testing robustness

The changes in this file significantly improve the upgrade testing process for the Cronos blockchain. The addition of the assert_evm_params helper function and the new assertions for specific EVM parameters align well with the PR objectives of fixing broken opBlockhash and tx validation.

Key improvements:

  1. Enhanced readability and maintainability through the assert_evm_params function.
  2. Specific assertion for header_hash_num, crucial for opBlockhash functionality.
  3. Updated expectations for icaauth parameters post-upgrade.

These changes collectively strengthen the upgrade testing suite, providing more comprehensive validation of the upgrade process. The code is well-structured, though minor enhancements in documentation and constant usage could further improve its quality.

go.mod (3)

Line range hint 3-5: Go toolchain update approved

The update from Go 1.22.2 to 1.22.3 is a minor version change, which typically includes bug fixes and security improvements. This update is a good practice to maintain the latest stable version.


Line range hint 1-293: Overall changes look good, with some recommendations

The updates to go.mod include:

  1. An update to the Go toolchain version.
  2. Several dependency updates and additions.
  3. Modifications to replace directives, including the use of custom forks.

These changes generally follow good practices for dependency management. However, please ensure to:

  1. Verify the changes in the custom ethermint fork for compatibility.
  2. Carefully manage the custom forks, especially for critical dependencies like go-ethereum.
  3. Keep documentation up-to-date regarding the use of custom forks and replace directives.
  4. Regularly review and update dependencies to maintain security and compatibility with upstream projects.

Line range hint 7-278: Dependency updates approved, verify ethermint changes

The dependency updates, including the addition of new dependencies and version changes for existing ones, are generally good for security and bug fixes. However, special attention should be given to the update of github.com/evmos/ethermint to the custom fork github.com/crypto-org-chain/ethermint v0.6.1-0.20241004074623-853e1e5b3475.

Please ensure that the changes in the custom ethermint fork are compatible with the current codebase and don't introduce breaking changes. Run the following script to check for any major changes in the ethermint dependency:

gomod2nix.toml (1)

266-267: Dependency update for github.com/evmos/ethermint

The version of github.com/evmos/ethermint has been updated from v0.6.1-0.20240927061036-33e3cc6ed365 to v0.6.1-0.20241004074623-853e1e5b3475. This change also includes an update to the corresponding hash.

To ensure this update aligns with the PR objectives and doesn't introduce any unintended changes, please run the following verification:

This script will help identify any changes in the ethermint dependency that might be relevant to the PR objectives, specifically regarding opBlockhash and tx validation.

✅ Verification successful

To identify the correct versions of the github.com/evmos/ethermint dependency, please run the following script to list all available tags in the repository:


To accurately compare the changes between the specified versions of github.com/evmos/ethermint, please run the following script using the commit hashes extracted from the pseudo-versions:


Dependency update for github.com/evmos/ethermint verified

The update to github.com/evmos/ethermint includes the intended fix for opBlockhash as per PR #534. No issues were found related to tx validation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for changes in the ethermint dependency that might affect opBlockhash and tx validation

# Fetch the diff between the old and new versions
git clone https://github.com/crypto-org-chain/ethermint.git
cd ethermint
git diff v0.6.1-0.20240927061036-33e3cc6ed365 v0.6.1-0.20241004074623-853e1e5b3475 > ethermint_diff.patch

# Search for relevant changes
echo "Changes related to opBlockhash:"
grep -i "opblockhash" ethermint_diff.patch

echo "Changes related to tx validation:"
grep -i "tx.*validat" ethermint_diff.patch

# Clean up
cd ..
rm -rf ethermint

Length of output: 733


Script:

#!/bin/bash
# Description: List all tags in the ethermint repository to verify the specified versions

git clone https://github.com/crypto-org-chain/ethermint.git
cd ethermint
git fetch --tags
echo "Available tags:"
git tag

Length of output: 1146


Script:

#!/bin/bash
# Description: Compare changes between two specific commits in the ethermint repository related to opBlockhash and tx validation

# Clone the ethermint repository
git clone https://github.com/crypto-org-chain/ethermint.git
cd ethermint

# Define commit hashes from the pseudo-versions
OLD_COMMIT="33e3cc6ed365"
NEW_COMMIT="853e1e5b3475"

# Fetch all commits to ensure the specified commits are available
git fetch --all

# Perform git diff between the two commits
git diff ${OLD_COMMIT} ${NEW_COMMIT} > ethermint_diff.patch

# Search for relevant changes
echo "Changes related to opBlockhash:"
grep -i "opblockhash" ethermint_diff.patch

echo "Changes related to tx validation:"
grep -i "tx.*validat" ethermint_diff.patch

# Clean up
cd ..
rm -rf ethermint

Length of output: 814

app/upgrades.go (2)

14-14: Importing evmtypes for EVM parameter handling

The addition of evmtypes import is appropriate for managing EVM parameters in the upgrade handler.


30-34: ⚠️ Potential issue

Ensure resetting HeaderHashNum does not overwrite custom configurations

Setting evmParams.HeaderHashNum to evmtypes.DefaultHeaderHashNum may overwrite any existing custom configurations of HeaderHashNum. Verify if this is the intended behavior, or if the upgrade should preserve the current value to avoid unintended side effects.

To check for any custom configurations of HeaderHashNum in the codebase, you can run the following script:

✅ Verification successful

Confirmed: Resetting HeaderHashNum does not overwrite any custom configurations

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for any custom settings of HeaderHashNum in the codebase.

# Find assignments to HeaderHashNum in Go files.
rg --type go "HeaderHashNum" -A 5 -B 5

Length of output: 7766

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 30-33: app/upgrades.go#L30-L33
Added lines #L30 - L33 were not covered by tests

CHANGELOG.md Show resolved Hide resolved
app/upgrades.go Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants