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: app hash mismatch occurs when upgrade to iavl v1.2.0 #1618

Merged
merged 17 commits into from
Oct 5, 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 !!!! 👮🏻👮🏻👮🏻

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

    • Updated CHANGELOG.md to include breaking changes and improvements for memiavl compatibility with iavl version 1.2.0.
    • Enhanced support for IBC channel upgrade methods.
  • Bug Fixes

    • Fixed issues with the ethermint API to prevent unnecessary block results.
    • Resolved bugs related to pebbledb support and multisig account transactions.
  • Dependency Updates

    • Upgraded cosmos-sdk to version 0.50.10 and other dependencies to their latest versions.
    • Updated Go toolchain and several module dependencies for improved performance and security.
  • Testing Improvements

    • Streamlined testing workflow in .github/workflows/build.yml for efficiency.
    • Added new tests for initial version handling in the IAVL tree to ensure integrity across states.
    • Enhanced clarity and maintainability of tests related to database operations.

Copy link
Contributor

coderabbitai bot commented Oct 4, 2024

Walkthrough

The pull request includes updates to the CHANGELOG.md, go.mod, gomod2nix.toml, and various files within the memiavl directory. Key changes involve updating dependencies, particularly the cosmos-sdk and iavl versions, as well as enhancements to error handling and version management in the memiavl component. The changelog documents breaking changes and improvements, while the memiavl files reflect modifications in versioning logic and testing enhancements.

Changes

File Change Summary
CHANGELOG.md Updated with entries for breaking changes in memiavl, improvements, bug fixes, and version upgrades.
go.mod Updated Go toolchain version and various module dependencies, including cosmos-sdk and ethermint.
gomod2nix.toml Updated github.com/cosmos/iavl version from v1.1.2 to v1.2.0 with hash change.
memiavl/db.go Modified reloadMultiTree method, refined error handling, and improved snapshot management.
memiavl/multitree.go Updated setInitialVersion method to use uint32, added overflow checks, and simplified tree management logic.
memiavl/tree.go Added cowVersion to Tree struct, simplified method signatures, and updated version handling logic.
.github/workflows/build.yml Streamlined testing commands and added conditional execution for relevant jobs.
Makefile Updated test target to depend on test-memiavl and test-store, added coverage options.

Possibly related PRs

Suggested reviewers

  • calvinaco
  • yihuang
  • devashishdxt

🐇 In the meadow, changes bloom,
With memiavl shedding gloom.
Versions rise, dependencies align,
Changelog notes the work divine.
Bugs are fixed, tests now sing,
A brighter code is what we bring! 🌼


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between af52366 and bb0913a.

📒 Files selected for processing (3)
  • memiavl/db.go (1 hunks)
  • memiavl/multitree.go (7 hunks)
  • memiavl/tree.go (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • memiavl/tree.go
🔇 Additional comments (11)
memiavl/multitree.go (10)

108-110: LGTM: Improved type safety and readability

The changes in the LoadMultiTree function look good. The explicit casting of initialVersion to uint32 ensures type safety, and the simplification of the empty check improves code readability.


137-142: LGTM: Enhanced safety in SetInitialVersion

The changes in the SetInitialVersion method are well-implemented. The additional check to ensure the tree is empty before setting the initial version prevents unintended modifications to non-empty trees. This, combined with the retained overflow check, significantly improves the method's robustness and safety.


146-151: LGTM: Improved version handling addresses PR objective

The changes in the setInitialVersion method are well-implemented and directly address the PR objective of resolving the app hash mismatch issue. The switch to uint32 improves type consistency, and the updated logic ensures correct initial version setting for each tree when the version is greater than 1. This should resolve the version-related issues during upgrades.


158-158: LGTM: Simplified SetZeroCopy method

The change in the SetZeroCopy method looks good. It reflects an update in the NamedTree struct and simplifies the method call, improving code readability.


167-167: LGTM: Improved Copy method ensures separate tree copies

The change in the Copy method is well-implemented. By creating a new NamedTree with a copied Tree, it ensures that each tree in the copied MultiTree is a separate copy. This is crucial for maintaining the integrity of the snapshot and preventing unintended modifications to the original tree.


253-253: LGTM: Simplified ApplyChangeSet method

The change in the ApplyChangeSet method is consistent with the updates seen in other methods. It simplifies the method call and improves code readability, reflecting the updated structure of the NamedTree struct.


277-277: LGTM: Simplified SaveVersion method

The change in the SaveVersion method is consistent with the updates seen in other methods. It simplifies the method call by directly invoking SaveVersion on the NamedTree entry, improving code readability and maintaining consistency with the updated NamedTree struct.


298-299: LGTM: Simplified buildCommitInfo method

The changes in the buildCommitInfo method are consistent with the updates seen in other methods. Directly accessing Version() and RootHash() on the NamedTree entry simplifies the code and improves readability, while maintaining consistency with the updated NamedTree struct.


416-416: LGTM: Simplified Close method

The change in the Close method is consistent with the updates seen in other methods. Directly calling Close() on the NamedTree entry simplifies the code and improves readability, while maintaining consistency with the updated NamedTree struct.


Line range hint 1-464: Overall assessment: Improved version handling and code consistency

The changes in this file consistently reflect an update in the NamedTree struct, making operations more direct and improving code readability. The modifications to version handling, particularly in the setInitialVersion method, directly address the PR objective of resolving the app hash mismatch issue during upgrades to iavl v1.2.0.

Key improvements include:

  1. Enhanced type safety with explicit casting to uint32 for version handling.
  2. Improved robustness in SetInitialVersion with additional checks.
  3. Consistent simplification of method calls across the MultiTree struct.
  4. Better handling of tree copies in the Copy method.

These changes should resolve the version-related issues and improve the overall reliability and maintainability of the code.

memiavl/db.go (1)

702-702: Pending WAL entries are now applied after reloading MultiTree

The addition of return db.applyWALEntry(db.pendingLog) ensures that any pending WAL entries are applied to the MultiTree after it has been reloaded. This change helps maintain the consistency of the database state by ensuring that no pending entries are lost during the reload process.


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 71.42857% with 10 lines in your changes missing coverage. Please review.

Project coverage is 35.86%. Comparing base (766af76) to head (bb0913a).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
memiavl/tree.go 64.70% 3 Missing and 3 partials ⚠️
memiavl/import.go 0.00% 2 Missing ⚠️
memiavl/multitree.go 86.66% 0 Missing and 2 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #1618       +/-   ##
===========================================
+ Coverage   17.72%   35.86%   +18.14%     
===========================================
  Files          72      123       +51     
  Lines        5208     9755     +4547     
===========================================
+ Hits          923     3499     +2576     
- Misses       4162     5845     +1683     
- Partials      123      411      +288     
Files with missing lines Coverage Δ
memiavl/db.go 64.11% <100.00%> (ø)
memiavl/import.go 74.83% <0.00%> (ø)
memiavl/multitree.go 76.11% <86.66%> (ø)
memiavl/tree.go 72.72% <64.70%> (ø)

... and 64 files with indirect coverage changes

@yihuang yihuang marked this pull request as ready for review October 4, 2024 08:28
@yihuang yihuang requested a review from a team as a code owner October 4, 2024 08:28
@yihuang yihuang requested review from leejw51crypto, thomas-nguy and yihuang and removed request for a team October 4, 2024 08:28
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: 8

🧹 Outside diff range and nitpick comments (2)
memiavl/import.go (1)

134-134: Summary: Improved error handling for version overflow scenarios

The changes in this file consistently enhance error reporting for version overflow scenarios in both the doImport function and the importer.Add method. These improvements align with Go's best practices for error handling and provide more context for debugging.

However, it's important to note that static analysis indicates these changed lines are not covered by tests. To ensure the robustness of these error handling improvements, consider adding specific test cases that trigger these version overflow scenarios for both doImport and importer.Add.

To improve the overall test coverage and maintainability of the codebase, consider the following:

  1. Implement unit tests that specifically target version overflow scenarios for both doImport and importer.Add.
  2. Consider extracting the version overflow check into a separate helper function, which can be easily tested and reused across the codebase.
  3. If version overflow is a critical concern, consider adding property-based tests that generate various input values to ensure these checks are always effective.

Would you like assistance in implementing these suggestions or creating GitHub issues to track these improvements?

Also applies to: 170-170

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 134-134: memiavl/import.go#L134
Added line #L134 was not covered by tests

memiavl/tree_test.go (1)

21-22: Consider unexporting variables not needed outside the package

The variables IAVLInitialVersion and RefHashesInitialVersion are exported due to their uppercase names. If these variables are intended for use only within this test package, consider renaming them to start with a lowercase letter to keep them unexported.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c96cdaf and 5df126d.

⛔ Files ignored due to path filters (2)
  • go.sum is excluded by !**/*.sum
  • memiavl/go.sum is excluded by !**/*.sum
📒 Files selected for processing (8)
  • CHANGELOG.md (1 hunks)
  • go.mod (0 hunks)
  • gomod2nix.toml (1 hunks)
  • memiavl/go.mod (1 hunks)
  • memiavl/import.go (2 hunks)
  • memiavl/multitree.go (1 hunks)
  • memiavl/tree.go (5 hunks)
  • memiavl/tree_test.go (4 hunks)
💤 Files with no reviewable changes (1)
  • go.mod
✅ Files skipped from review due to trivial changes (1)
  • memiavl/go.mod
🧰 Additional context used
🪛 GitHub Check: codecov/patch
memiavl/import.go

[warning] 134-134: memiavl/import.go#L134
Added line #L134 was not covered by tests


[warning] 170-170: memiavl/import.go#L170
Added line #L170 was not covered by tests

memiavl/tree.go

[warning] 96-97: memiavl/tree.go#L96-L97
Added lines #L96 - L97 were not covered by tests


[warning] 99-102: memiavl/tree.go#L99-L102
Added lines #L99 - L102 were not covered by tests


[warning] 152-152: memiavl/tree.go#L152
Added line #L152 was not covered by tests

🔇 Additional comments (11)
memiavl/import.go (2)

170-170: Consistent improvement in error message for version overflow.

This change is consistent with the previous modification in the doImport function. It enhances error reporting by including the actual version value in the error message, which aligns with Go's best practices for error handling and provides more context for debugging.

To ensure comprehensive test coverage, consider adding a test case for this scenario:

If no matching test is found, consider adding a test case to cover this scenario.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 170-170: memiavl/import.go#L170
Added line #L170 was not covered by tests


134-134: Improved error message for version overflow.

The change enhances error reporting by including the actual version value in the error message. This modification aligns with Go's best practices for error handling and provides more context for debugging.

To ensure comprehensive test coverage, consider adding a test case for this scenario:

If no matching test is found, consider adding a test case to cover this scenario.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 134-134: memiavl/import.go#L134
Added line #L134 was not covered by tests

CHANGELOG.md (4)

Line range hint 12-17: Multiple improvements and bug fixes noted

The changelog lists several improvements and bug fixes, including changes to the block-stm, ethermint API updates, and fixes for pebbledb support and multisig account transactions. These changes appear to enhance the overall functionality and stability of the system.


Line range hint 18-19: Cosmos-sdk upgrade to v0.50.10

Upgrading the cosmos-sdk to version 0.50.10 is a significant change that may introduce new features or bug fixes. It's important to ensure that this upgrade doesn't introduce any breaking changes or conflicts with existing functionality.

To verify the impact of this upgrade, please check for any breaking changes or deprecations in the cosmos-sdk changelog between the previous version and v0.50.10.


Line range hint 1-1186: Comprehensive changelog with clear version history

The CHANGELOG.md file provides a detailed history of changes across multiple versions of the Cronos project. It effectively categorizes changes into different types (e.g., State Machine Breaking, Bug Fixes, Improvements, Features) for each version, which is helpful for users and developers to understand the evolution of the project.

Some suggestions for improvement:

  1. Consider adding links to relevant pull requests or issues for each change, making it easier for readers to find more detailed information.
  2. Maintain consistency in formatting across all versions (e.g., use of bullet points, headings).
  3. For future updates, consider adding a "Deprecations" section if applicable, to highlight any features or APIs that are being phased out.

5-8: Breaking change: memiavl initial version logic update

The update to memiavl's initial version logic for compatibility with iavl 1.2.0 is a significant change. This could potentially affect the state machine and might require careful consideration during upgrades.

To verify the impact of this change, please run the following command to check for any references to the old memiavl logic:

memiavl/tree.go (1)

65-68: Verify correctness of initial version handling in NewWithInitialVersion

The logic subtracts 1 from initialVersion when it's greater than 1. Please verify that this correctly sets the initial tree version and doesn't introduce off-by-one errors when saving versions.

memiavl/tree_test.go (3)

4-4: Import statement approved

The addition of the "bytes" package is necessary for byte slice comparisons using bytes.Equal.


69-69: Type conversion to uint64 is appropriate

The explicit conversion of IAVLInitialVersion to uint64 ensures compatibility with the iavl.InitialVersionOption function, which expects a uint64 parameter.


181-187: Consistency check approved

The addition of require.Equal(t, hash, workingHash) ensures that the working hash matches the saved hash in TestRootHashes. This is a valuable consistency check.

memiavl/multitree.go (1)

147-150: Ensures correct versioning upon initialization.

The updated logic sets each tree's version to t.initialVersion - 1 when t.initialVersion > 1. This ensures that the first version saved after initialization will be t.initialVersion, maintaining consistency in version numbering across all trees.

gomod2nix.toml Show resolved Hide resolved
memiavl/tree.go Show resolved Hide resolved
memiavl/tree.go Show resolved Hide resolved
memiavl/tree.go Outdated Show resolved Hide resolved
memiavl/tree_test.go Show resolved Hide resolved
memiavl/tree_test.go Show resolved Hide resolved
memiavl/multitree.go Outdated Show resolved Hide resolved
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

🧹 Outside diff range and nitpick comments (2)
integration_tests/utils.py (2)

116-116: Improved debug output clarity.

The change enhances the readability of the debug output by providing a more descriptive message. This is a good improvement for debugging purposes.

Consider using an f-string for better readability and performance:

-            print("current block height", current_height)
+            print(f"current block height: {current_height}")

Line range hint 585-588: New utility function to retrieve send parameters.

The get_send_enable function is a useful addition for checking send enablement in the Cosmos bank module. It enhances the overall functionality of the test utilities.

Consider adding error handling to make the function more robust:

 def get_send_enable(port):
     url = f"http://127.0.0.1:{port}/cosmos/bank/v1beta1/params"
-    raw = requests.get(url).json()
-    return raw["params"]["send_enabled"]
+    try:
+        response = requests.get(url, timeout=10)
+        response.raise_for_status()
+        raw = response.json()
+        return raw["params"]["send_enabled"]
+    except requests.RequestException as e:
+        print(f"Error fetching send parameters: {e}")
+        return None

This change adds timeout, error checking, and exception handling to make the function more resilient to network issues or unexpected responses.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 5df126d and eb53b2c.

📒 Files selected for processing (1)
  • integration_tests/utils.py (1 hunks)
🔇 Additional comments (1)
integration_tests/utils.py (1)

Line range hint 1-588: Overall assessment of changes in integration_tests/utils.py

The changes made to this file are positive improvements:

  1. The debug output in the wait_for_block function has been clarified.
  2. A new get_send_enable function has been added to enhance the utility of the module.

These changes improve the readability and functionality of the test utilities without introducing any significant risks or issues. The suggestions provided in the review are minor and aimed at further enhancing code quality and robustness.

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

🧹 Outside diff range and nitpick comments (1)
versiondb/go.mod (1)

Custom cosmos-sdk tag v0.50.6-0.20240722033504-50f1fa0c49d1 not found

The replace directive for github.com/cosmos/cosmos-sdk points to a non-existent tag v0.50.6-0.20240722033504-50f1fa0c49d1 in github.com/crypto-org-chain/cosmos-sdk. This could lead to dependency resolution failures or build issues.

  • Action Required: Verify that the specified tag exists in the custom cosmos-sdk repository. If it does not, update the replace directive to reference a valid tag or ensure the tag is created in the custom fork.
🔗 Analysis chain

Line range hint 182-183: Clarify the need for custom cosmos-sdk fork

The addition of a replace directive for github.com/cosmos/cosmos-sdk pointing to a specific version of github.com/crypto-org-chain/cosmos-sdk indicates the use of a custom fork of the entire cosmos-sdk.

Could you please provide more information on:

  1. The reasons for using this custom fork of the entire cosmos-sdk?
  2. How this relates to resolving the app hash mismatch issue, if at all?
  3. Any plans to contribute these changes back to the main cosmos-sdk repository or to migrate away from the fork in the future?

To help understand the extent of the customizations, please run the following command:

Please review the output and provide a summary of the key differences, their implications, and how they relate to the app hash mismatch issue.


Please run the updated script below to gather the necessary information for verification.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Compare the custom cosmos-sdk fork with the original

# Test: Clone both repositories and compare the differences
git clone https://github.com/cosmos/cosmos-sdk.git original-cosmos-sdk
git clone https://github.com/crypto-org-chain/cosmos-sdk.git custom-cosmos-sdk

cd custom-cosmos-sdk
git checkout v0.50.6-0.20240722033504-50f1fa0c49d1
cd ../original-cosmos-sdk
git checkout v0.50.6

echo "Summary of differences:"
git diff --stat original-cosmos-sdk custom-cosmos-sdk

echo "\nDetailed diff of key files (limiting to 200 lines):"
git diff original-cosmos-sdk custom-cosmos-sdk | head -n 200

Length of output: 1631


Script:

#!/bin/bash
# Description: Compare the custom cosmos-sdk fork with the original

# Exit immediately if a command exits with a non-zero status
set -e

# Remove existing directories if they exist
rm -rf original-cosmos-sdk custom-cosmos-sdk

# Clone the original cosmos-sdk repository
git clone https://github.com/cosmos/cosmos-sdk.git original-cosmos-sdk

# Clone the custom cosmos-sdk repository
git clone https://github.com/crypto-org-chain/cosmos-sdk.git custom-cosmos-sdk

# List available tags in original cosmos-sdk
echo "Available tags in original cosmos-sdk:"
cd original-cosmos-sdk
git tag
cd ..

# List available tags in custom cosmos-sdk
echo "Available tags in custom cosmos-sdk:"
cd custom-cosmos-sdk
git tag
cd ..

# Attempt to check out the desired tags
cd custom-cosmos-sdk
if git rev-parse "v0.50.6-0.20240722033504-50f1fa0c49d1" >/dev/null 2>&1; then
  git checkout v0.50.6-0.20240722033504-50f1fa0c49d1
else
  echo "Tag v0.50.6-0.20240722033504-50f1fa0c49d1 not found in custom-cosmos-sdk."
  exit 1
fi
cd ../original-cosmos-sdk
# Remove any existing lock file
rm -f .git/index.lock
if git rev-parse "v0.50.6" >/dev/null 2>&1; then
  git checkout v0.50.6
else
  echo "Tag v0.50.6 not found in original-cosmos-sdk."
  exit 1
fi
cd ..

# Perform git diff
echo "Summary of differences:"
git diff --stat original-cosmos-sdk custom-cosmos-sdk

echo "\nDetailed diff of key files (limiting to 200 lines):"
git diff original-cosmos-sdk custom-cosmos-sdk | head -n 200

Length of output: 11470

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between eb53b2c and 409c781.

⛔ Files ignored due to path filters (2)
  • store/go.sum is excluded by !**/*.sum
  • versiondb/go.sum is excluded by !**/*.sum
📒 Files selected for processing (2)
  • store/go.mod (1 hunks)
  • versiondb/go.mod (1 hunks)
🔇 Additional comments (5)
store/go.mod (2)

51-51: LGTM: iavl dependency updated as intended.

The update of github.com/cosmos/iavl from v1.1.2 to v1.2.0 aligns with the PR objective to address the app hash mismatch issue. This change is likely the core update to resolve the problem.

To ensure compatibility, please verify that this update resolves the app hash mismatch issue without introducing new problems. Consider running integration tests that cover scenarios where the app hash is calculated and compared.


Line range hint 180-184: Please clarify the relationship between SDK fork changes and iavl update.

The replace directives have been updated to use a forked version of the Cosmos SDK (github.com/crypto-org-chain/cosmos-sdk) at a specific commit (50f1fa0c49d1). While this ensures consistency across the SDK components, it's not immediately clear how these changes relate to the iavl update and the app hash mismatch issue.

Could you please provide more context on:

  1. The relationship between these SDK fork changes and the iavl update?
  2. The specific reasons for using a forked version of the Cosmos SDK instead of the official release?

Additionally, consider adding documentation (e.g., in the PR description or a separate document) explaining the rationale behind these changes and any potential implications for the project's maintainability and compatibility with the broader Cosmos ecosystem.

To ensure these changes don't introduce unexpected behavior:

  1. Verify that the specified commit (50f1fa0c49d1) of the forked Cosmos SDK is stable and thoroughly tested.
  2. Run comprehensive integration tests to ensure compatibility between the updated iavl, the forked SDK, and your project.
  3. Check if there are any breaking changes in the forked SDK that might affect other parts of the Cronos project.
versiondb/go.mod (3)

Line range hint 1-184: Summary and request for comprehensive testing

The changes in this go.mod file appear to be addressing the app hash mismatch issue mentioned in the PR objectives. The key modifications include:

  1. Upgrading github.com/cosmos/iavl to v1.2.0
  2. Using custom forks for cosmossdk.io/store and github.com/cosmos/cosmos-sdk

While these changes seem appropriate for addressing the issue, it's crucial to ensure they don't introduce new problems or dependencies that could affect the project's stability or maintainability.

To ensure the changes resolve the app hash mismatch without introducing new issues, please conduct comprehensive testing, including:

  1. Run all existing unit and integration tests.
  2. Perform thorough upgrade tests, simulating the upgrade process from the previous version to this new version with the updated dependencies.
  3. Conduct performance benchmarks to ensure the changes don't negatively impact performance.
  4. Test for backwards compatibility, especially if this module interacts with other parts of the system that may not be upgraded simultaneously.

Please provide a summary of the test results, including any issues encountered and how they were resolved.


16-16: Approve iavl upgrade and suggest verification

The update of github.com/cosmos/iavl to v1.2.0 aligns with the PR objective to address the app hash mismatch issue. This change is likely the core solution to the problem.

To ensure this update resolves the issue without introducing new problems, please run the following verification steps:

Please review the output of these commands and ensure that:

  1. There are no breaking changes or known issues in iavl v1.2.0 that could affect this project.
  2. The app hash consistency tests pass, confirming that the mismatch issue is resolved.
  3. There are no new errors or warnings related to iavl after the upgrade.

Line range hint 180-181: Clarify the need for custom cosmos-sdk store fork

The addition of a replace directive for cosmossdk.io/store pointing to a specific commit of github.com/crypto-org-chain/cosmos-sdk/store suggests the use of a custom fork.

Could you please clarify:

  1. Why is this custom fork of the cosmos-sdk store necessary?
  2. Is this related to resolving the app hash mismatch issue?
  3. Are there any plans to contribute these changes back to the main cosmos-sdk repository?

To help understand the differences, please run the following command:

#!/bin/bash
# Description: Compare the custom fork with the original cosmos-sdk store

# Test: Clone both repositories and compare the differences
git clone https://github.com/cosmos/cosmos-sdk.git original-cosmos-sdk
git clone https://github.com/crypto-org-chain/cosmos-sdk.git custom-cosmos-sdk

cd custom-cosmos-sdk
git checkout 50f1fa0c49d1
cd ../original-cosmos-sdk
git checkout $(go list -m -f '{{.Version}}' cosmossdk.io/store)

echo "Differences in the store package:"
diff -r original-cosmos-sdk/store custom-cosmos-sdk/store

Please review the output and provide a summary of the key differences and their implications.

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: 3

🧹 Outside diff range and nitpick comments (5)
CHANGELOG.md (5)

5-9: Highlight state machine breaking change

The change in memiavl's initial version logic to be compatible with iavl 1.2.0 is a state machine breaking change. This is a critical update that needs to be communicated clearly to all node operators and developers.

Consider adding more details about the implications of this change and any necessary actions for node operators during the upgrade process.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~7-~7: This verb may not be in the correct tense. Consider changing the tense to fit the context better.
Context: ...pto-org-chain/cronos/pull/1618) memiavl change initial version logic to be compatibl...

(AI_EN_LECTOR_REPLACEMENT_VERB_TENSE)


Line range hint 11-24: Comprehensive improvements and bug fixes

This update includes several important improvements and bug fixes:

  1. Changes to block-stm parallelism
  2. Updates to ethermint to avoid unnecessary block results
  3. Fixes for pebbledb support and multisig account transactions
  4. Sync of e2ee module with v1.3.x branch
  5. Support for IBC channel upgrade methods
  6. Upgrade of cosmos-sdk to v0.50.10
  7. Various fixes related to API calls, transaction handling, and EVM operations

These changes appear to enhance performance, fix critical issues, and improve overall functionality.

Consider grouping related changes together in the changelog for better readability. Also, it might be helpful to provide brief explanations for some of the more technical changes to aid users in understanding their impact.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~7-~7: This verb may not be in the correct tense. Consider changing the tense to fit the context better.
Context: ...pto-org-chain/cronos/pull/1618) memiavl change initial version logic to be compatibl...

(AI_EN_LECTOR_REPLACEMENT_VERB_TENSE)


Line range hint 28-38: Critical state machine breaking changes in v1.4.0-rc0

This release contains several state machine breaking changes:

  1. Upgrade to SDK 0.50 and integration of block-stm parallel tx execution
  2. Addition of icahost wirings (disabled in parameters)
  3. Integration of new EVM tx format
  4. Adjustment of required gas for recvPacket when ReceiverChainIsSource
  5. Upgrade to ibc-go 8.3 and removal of icaauth module
  6. Changes to versiondb/memiavl compatibility
  7. Disabling of MsgCreatePermanentLockedAccount and MsgCreatePeriodicVestingAccount messages

These changes significantly alter the state machine and require careful consideration during the upgrade process.

Consider providing a detailed upgrade guide for node operators, highlighting any necessary actions or potential risks associated with these breaking changes. It may also be beneficial to explain the rationale behind some of these changes, especially the disabling of certain message types.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~7-~7: This verb may not be in the correct tense. Consider changing the tense to fit the context better.
Context: ...pto-org-chain/cronos/pull/1618) memiavl change initial version logic to be compatibl...

(AI_EN_LECTOR_REPLACEMENT_VERB_TENSE)


Line range hint 40-61: Substantial improvements and bug fixes in v1.4.0-rc0

This release includes numerous improvements and bug fixes:

  1. Upgrade of rocksdb to v9.1.1
  2. Integration of testground for cluster benchmarking
  3. Update of cosmos-sdk to v0.50.7
  4. Optimization of gas handling in ante handlers
  5. Enabling of optimistic execution
  6. Update of cometbft to v0.38.8
  7. Various optimizations in versiondb and memiavl
  8. Configuration changes for mempool and rocksdb
  9. Performance improvements in block-stm
  10. Support for pinL0FilterAndIndexBlocksInCache
  11. Fix for mempool data race
  12. Integration of pre-estimate block-stm option

These changes appear to focus on performance enhancements, stability improvements, and resolving critical issues.

Consider providing more context on the performance impacts of these changes, especially for the optimizations and new features like optimistic execution. It might be helpful to include some benchmarks or expected improvements to help users understand the benefits of upgrading.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~7-~7: This verb may not be in the correct tense. Consider changing the tense to fit the context better.
Context: ...pto-org-chain/cronos/pull/1618) memiavl change initial version logic to be compatibl...

(AI_EN_LECTOR_REPLACEMENT_VERB_TENSE)


Line range hint 63-1183: Comprehensive historical changelog

The changelog provides a detailed history of the project's evolution from v0.5.1 to the current version. It includes numerous features, improvements, and bug fixes across multiple releases. This historical record is valuable for understanding the project's development trajectory and the issues that have been addressed over time.

Key points:

  1. The project has undergone significant changes, including major version upgrades and consensus-breaking changes.
  2. There's a consistent focus on improving performance, security, and compatibility with other blockchain ecosystems (e.g., Ethereum, IBC).
  3. The changelog demonstrates active development and responsiveness to community needs and reported issues.

While the historical entries are informative, consider:

  1. Summarizing major themes or milestones across versions to highlight the project's overall progress.
  2. Removing or archiving very old entries to keep the main changelog focused on more recent and relevant changes.
  3. Ensuring that all mentioned issues or pull requests are properly linked and still accessible for reference.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~7-~7: This verb may not be in the correct tense. Consider changing the tense to fit the context better.
Context: ...pto-org-chain/cronos/pull/1618) memiavl change initial version logic to be compatibl...

(AI_EN_LECTOR_REPLACEMENT_VERB_TENSE)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 409c781 and 964a337.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (4)
  • CHANGELOG.md (1 hunks)
  • go.mod (0 hunks)
  • gomod2nix.toml (1 hunks)
  • memiavl/db_test.go (2 hunks)
💤 Files with no reviewable changes (1)
  • go.mod
🚧 Files skipped from review as they are similar to previous changes (1)
  • gomod2nix.toml
🧰 Additional context used
🪛 LanguageTool
CHANGELOG.md

[uncategorized] ~7-~7: This verb may not be in the correct tense. Consider changing the tense to fit the context better.
Context: ...pto-org-chain/cronos/pull/1618) memiavl change initial version logic to be compatibl...

(AI_EN_LECTOR_REPLACEMENT_VERB_TENSE)

🔇 Additional comments (3)
memiavl/db_test.go (3)

183-183: Variable value1 introduced for updating key

The variable value1 is introduced to update the value associated with the key in subsequent tests. This aids in testing the update functionality.


205-205: Verify version incrementation logic

The assertion require.Equal(t, realInitialVersion+1, v) assumes the version increments by 1 after the second commit. Confirm that this behavior is consistent and intended.

Ensure that no versions are skipped during commits and that the incrementation aligns with the database's versioning system.


214-214: Comparing commit hashes after reload

The comparison using hex.EncodeToString to verify that the commit hashes remain consistent after reloading the database is appropriate.

memiavl/db_test.go Show resolved Hide resolved
memiavl/db_test.go Show resolved Hide resolved
memiavl/db_test.go Show resolved Hide resolved
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: 1

🧹 Outside diff range and nitpick comments (5)
.github/workflows/build.yml (1)

77-77: Approved: Simplified test execution

The consolidation of test and test-versiondb into a single command is a good optimization. It simplifies the workflow and potentially reduces execution time.

However, consider the following:

  1. Ensure that error messages clearly distinguish between failures in test and test-versiondb.
  2. If separate execution of these tests is sometimes necessary, consider providing documentation on how to run them individually.
Makefile (2)

101-103: LGTM! Consider adding a comment explaining the test dependencies.

The changes to the test target look good. Adding test-memiavl and test-store as dependencies ensures these specific tests are run before the main test suite. The addition of -tags=objstore and coverage flags improves the testing process.

Consider adding a comment explaining why test-memiavl and test-store are run separately and before the main test suite. This would help other developers understand the testing strategy.


Line range hint 105-106: LGTM! Consider parameterizing common test flags.

The addition of the test-memiavl target is good. It allows for separate testing of the memiavl package, which is likely crucial for the project.

Consider parameterizing the common test flags (like -tags=objstore, -coverprofile=$(COVERAGE), -covermode=atomic) into a variable. This would make it easier to maintain consistent flags across all test targets. For example:

TEST_FLAGS := -tags=objstore -v -mod=readonly -coverprofile=$(COVERAGE) -covermode=atomic

test-memiavl:
	@cd memiavl; go test $(TEST_FLAGS) ./...
memiavl/tree.go (2)

96-102: Clarify the version decrement logic in SetInitialVersion

In the SetInitialVersion method, t.version is set to uint32(initialVersion - 1) when initialVersion is valid. Adding a comment to explain why initialVersion is decremented by 1 would improve code readability and help future maintainers understand the reasoning.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 96-97: memiavl/tree.go#L96-L97
Added lines #L96 - L97 were not covered by tests


[warning] 99-102: memiavl/tree.go#L99-L102
Added lines #L99 - L102 were not covered by tests


65-68: Explain the decrement of initialVersion in NewWithInitialVersion

In NewWithInitialVersion, when initialVersion > 1, you decrement it by 1 before passing it to NewEmptyTree. Including a comment to clarify the purpose of this decrement will enhance code clarity.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 964a337 and af52366.

📒 Files selected for processing (3)
  • .github/workflows/build.yml (1 hunks)
  • Makefile (1 hunks)
  • memiavl/tree.go (5 hunks)
🧰 Additional context used
🪛 GitHub Check: codecov/patch
memiavl/tree.go

[warning] 96-97: memiavl/tree.go#L96-L97
Added lines #L96 - L97 were not covered by tests


[warning] 99-102: memiavl/tree.go#L99-L102
Added lines #L99 - L102 were not covered by tests


[warning] 152-152: memiavl/tree.go#L152
Added line #L152 was not covered by tests

🔇 Additional comments (2)
Makefile (2)

Line range hint 108-109: LGTM! Reiterate parameterization of test flags.

The addition of the test-store target is good. It allows for separate testing of the store package, which is likely important for data storage in the project.

As mentioned in the previous comment, consider parameterizing the common test flags to maintain consistency and ease of maintenance across all test targets.


Line range hint 101-109: Summary: Enhanced testing strategy aligns with PR objective

The changes to the Makefile improve the testing process by adding specific targets for memiavl and store, and enhancing the main test target. This aligns well with the PR objective of addressing the app hash mismatch issue during the upgrade to iavl v1.2.0.

The separate test targets for memiavl and store suggest that these components are crucial in the upgrade process and may be related to the hash mismatch issue. This granular approach to testing can help isolate and identify issues more effectively, potentially aiding in resolving the app hash mismatch problem.

To ensure these changes effectively address the app hash mismatch issue, consider running the following verification script:

This script will help verify that the new test targets are executed successfully and that the app hash mismatch issue is resolved.

memiavl/tree.go Show resolved Hide resolved
@yihuang yihuang added this pull request to the merge queue Oct 5, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 5, 2024
@yihuang yihuang added this pull request to the merge queue Oct 5, 2024
Merged via the queue into crypto-org-chain:main with commit f10363c Oct 5, 2024
38 checks passed
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