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: node can't shutdown by signal #1647

Merged
merged 7 commits into from
Oct 18, 2024

Conversation

yihuang
Copy link
Collaborator

@yihuang yihuang commented Oct 17, 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

  • Bug Fixes

    • Resolved an issue preventing the node from shutting down via signal.
    • Corrected query for address-by-account number and addressed multisig account issues.
  • Improvements

    • Enhanced transaction handling with parallel generation of test transactions.
    • Updated various dependencies for better compatibility and performance, including significant updates to the Ethermint module and PebbleDB support.
    • Improved logging clarity during application shutdown.
  • Documentation

    • Updated changelog to reflect ongoing development efforts and detailed changes across multiple versions.
  • Tests

    • Added new test for local state synchronization and enhanced existing tests for transaction handling and error management.

CHANGELOG.md Outdated Show resolved Hide resolved
Copy link

codecov bot commented Oct 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 34.94%. Comparing base (007077a) to head (7432f50).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1647   +/-   ##
=======================================
  Coverage   34.94%   34.94%           
=======================================
  Files         123      123           
  Lines       11803    11803           
=======================================
  Hits         4124     4124           
  Misses       7265     7265           
  Partials      414      414           

@yihuang yihuang marked this pull request as ready for review October 17, 2024 23:41
@yihuang yihuang requested a review from a team as a code owner October 17, 2024 23:41
@yihuang yihuang requested review from calvinaco and devashishdxt and removed request for a team October 17, 2024 23:41
Copy link
Contributor

coderabbitai bot commented Oct 17, 2024

Walkthrough

The pull request includes updates to the CHANGELOG.md, go.mod, and gomod2nix.toml files for the Cronos project. The changelog details bug fixes and improvements across multiple versions, including significant changes in the state machine and transaction handling. The go.mod file updates the Go version and various dependencies, while gomod2nix.toml reflects corresponding updates in module versions and hashes. These changes ensure compatibility with newer versions of dependencies and address identified issues.

Changes

File Change Summary
CHANGELOG.md Updated with bug fixes and improvements in the UNRELEASED, v1.4.0-rc1, v1.4.0-rc0, and earlier versions, including state machine changes, transaction handling improvements, and various bug fixes.
go.mod Updated Go version from 1.22.2 to 1.22.3. Modified dependencies: github.com/evmos/ethermint version updated, github.com/99designs/keyring replaced with github.com/cosmos/keyring, github.com/dgrijalva/jwt-go replaced with github.com/golang-jwt/jwt/v4, and updated github.com/ethereum/go-ethereum to a new version.
gomod2nix.toml Updated module versions and hashes for github.com/evmos/ethermint and github.com/ethereum/go-ethereum, marking the latter as replaced with github.com/crypto-org-chain/go-ethereum. Other modules also received version and hash updates, indicating a comprehensive refresh of dependencies.

Possibly related PRs

Suggested reviewers

  • yihuang

Poem

In the garden of code, where changes bloom,
Dependencies dance, dispelling the gloom.
With updates and fixes, our project takes flight,
Bugs are now banished, all feels just right.
So hop with delight, let the changelog sing,
For Cronos is thriving, and joy it will bring! 🐇✨


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.

@yihuang yihuang requested a review from mmsqe October 17, 2024 23:42
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 (3)
CHANGELOG.md (2)

5-7: Correct grammar in bug fix description

There's a minor grammatical issue in the bug fix description.

Consider changing:

-* (cli)[#1647](https://github.com/crypto-org-chain/cronos/pull/1647) Fix node can't shutdown by signal.
+* (cli)[#1647](https://github.com/crypto-org-chain/cronos/pull/1647) Fix node can't shut down by signal.

This change uses the correct verb form "shut down" instead of the noun "shutdown".

🧰 Tools
🪛 LanguageTool

[grammar] ~7-~7: The word ‘shutdown’ is a noun. Did you mean the verb “shut down”?
Context: ...-chain/cronos/pull/1647) Fix node can't shutdown by signal. ### Improvements * [#1645]...

(SHUTDOWN)


Line range hint 13-64: Significant state machine breaking change and comprehensive improvements

The v1.4.0-rc1 release includes a significant state machine breaking change in the memiavl module, along with numerous improvements and bug fixes.

The state machine breaking change in the memiavl module is crucial and may require careful consideration during upgrades. Ensure that all node operators are aware of this change and its implications.

The improvements and bug fixes address various aspects of the system, including:

  • Performance optimizations (e.g., changes to block-stm parallelism)
  • API enhancements (e.g., avoiding unnecessary block results in header-related API calls)
  • Bug fixes for account handling, transaction validation, and other critical areas

These changes appear to significantly enhance the system's functionality and reliability. However, due to the extensive nature of the changes, thorough testing is recommended before deployment to production environments.

🧰 Tools
🪛 LanguageTool

[grammar] ~7-~7: The word ‘shutdown’ is a noun. Did you mean the verb “shut down”?
Context: ...-chain/cronos/pull/1647) Fix node can't shutdown by signal. ### Improvements * [#1645]...

(SHUTDOWN)

go.mod (1)

276-276: Add a comment explaining the ethermint replacement

Including a comment to explain why github.com/evmos/ethermint is replaced with github.com/crypto-org-chain/ethermint helps future maintainers understand the rationale behind this change and maintain the codebase more effectively.

Apply this diff to add the explanatory comment:

+	// Replace ethermint with a custom version to fix node shutdown issue
	github.com/evmos/ethermint => github.com/crypto-org-chain/ethermint v0.6.1-0.20241017130935-816389c76eac
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between f3746f6 and cce96f3.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (3)
  • CHANGELOG.md (1 hunks)
  • go.mod (1 hunks)
  • gomod2nix.toml (1 hunks)
🧰 Additional context used
🪛 LanguageTool
CHANGELOG.md

[grammar] ~7-~7: The word ‘shutdown’ is a noun. Did you mean the verb “shut down”?
Context: ...-chain/cronos/pull/1647) Fix node can't shutdown by signal. ### Improvements * [#1645]...

(SHUTDOWN)

🔇 Additional comments (2)
gomod2nix.toml (1)

265-266: Version update and module replacement for ethermint

The github.com/evmos/ethermint module has been updated to a newer commit (v0.6.1-0.20241017130935-816389c76eac) and is now replaced with github.com/crypto-org-chain/ethermint.

Please ensure that the changes in the forked repository (github.com/crypto-org-chain/ethermint) are reviewed and aligned with the project's requirements. Run the following script to compare the differences between the original and forked repositories:

CHANGELOG.md (1)

8-11: LGTM: Improvements enhance system functionality

The improvements listed here seem to enhance the system's functionality by optimizing test transaction generation and improving the load generator's error handling.

@mmsqe
Copy link
Collaborator

mmsqe commented Oct 18, 2024

test_local_statesync seems flaky now

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 (1)
app/app.go (1)

1457-1462: Improved shutdown logging, but consider enhancing error handling

The changes to the Close method improve the logging behavior during application shutdown. The separation of message construction and error handling provides clearer and more consistent logging. However, there's room for a minor improvement in error handling.

Consider modifying the error handling to provide more detailed information when multiple errors occur. Here's a suggested improvement:

-	err := stderrors.Join(errs...)
-	msg := "Application gracefully shutdown"
-	if err == nil {
-		app.Logger().Info(msg)
-	} else {
-		app.Logger().Error(msg, "error", err)
-	}
+	err := stderrors.Join(errs...)
+	if err == nil {
+		app.Logger().Info("Application gracefully shutdown")
+	} else {
+		app.Logger().Error("Application shutdown with errors", "error", err)
+		// Log individual errors for more detailed debugging
+		for i, e := range errs {
+			if e != nil {
+				app.Logger().Error(fmt.Sprintf("Shutdown error %d", i+1), "error", e)
+			}
+		}
+	}

This modification will provide more detailed error information when multiple errors occur during shutdown, aiding in debugging and troubleshooting.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between cce96f3 and df34a67.

📒 Files selected for processing (2)
  • app/app.go (1 hunks)
  • integration_tests/test_basic.py (1 hunks)
🧰 Additional context used

integration_tests/test_basic.py 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 (3)
integration_tests/test_basic.py (3)

380-383: LGTM! Consider extracting port configuration to a separate function.

The JSON-RPC configuration looks good. It correctly uses dynamic port allocation to avoid conflicts.

For improved readability and maintainability, consider extracting the port configuration to a separate function:

def get_json_rpc_config(base_port):
    return {
        "address": f"127.0.0.1:{ports.evmrpc_port(base_port)}",
        "ws-address": f"127.0.0.1:{ports.evmrpc_ws_port(base_port)}",
    }

# Usage
cluster.edit_app_cfg(
    Path(home) / "config/app.toml",
    base_port,
    {
        "json-rpc": get_json_rpc_config(base_port),
        # ... other configurations ...
    },
)

This refactoring would make the code more modular and easier to maintain.


384-386: LGTM! Consider adding a comment explaining versiondb.

The addition of the versiondb configuration is appropriate for this test.

To improve code clarity, consider adding a brief comment explaining the purpose of enabling versiondb in this context:

"versiondb": {
    "enable": True,  # Enable versiondb for efficient state management during statesync
},

This comment would help other developers understand the significance of this configuration.


Line range hint 329-452: LGTM! Consider enhancing error handling in the subprocess call.

The test_local_statesync function is a well-structured and comprehensive test for local state synchronization. It covers all the necessary steps from setting up a new node to verifying the synced state.

To improve error handling and resource management, consider using a context manager for the subprocess call:

import contextlib

# ... (rest of the code)

with contextlib.closing(subprocess.Popen(
    [cronos.chain_binary, "start", "--home", home],
    stdout=subprocess.PIPE,
    stderr=subprocess.STDOUT,
)) as process:
    try:
        wait_for_port(ports.rpc_port(base_port))
        # check the node sync normally
        wait_for_new_blocks(cli, 2)
        # check grpc works
        print("distribution", cli.distribution_community(height=height))
        with pytest.raises(Exception) as exc_info:
            cli.distribution_community(height=height - 1)

        assert "collections: not found" in exc_info.value.args[0]
    finally:
        process.terminate()
        process.wait(timeout=10)

This approach ensures that the subprocess is properly terminated even if an exception occurs during the test execution.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between df34a67 and ab1df58.

📒 Files selected for processing (1)
  • integration_tests/test_basic.py (1 hunks)
🧰 Additional context used
🔇 Additional comments (1)
integration_tests/test_basic.py (1)

Line range hint 1-452: Overall, the changes in this file are well-implemented and valuable.

The addition of the test_local_statesync function significantly improves the test coverage for state synchronization in the Cronos blockchain. The test is comprehensive and well-structured, covering all necessary steps of the statesync process.

The suggestions provided in the review comments aim to further enhance the code quality by:

  1. Improving modularity with the extraction of the JSON-RPC configuration.
  2. Adding clarifying comments for the versiondb configuration.
  3. Enhancing error handling in the subprocess call.

These improvements will contribute to better maintainability and robustness of the test suite.

@yihuang yihuang added this pull request to the merge queue Oct 18, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Oct 18, 2024
@mmsqe mmsqe enabled auto-merge October 18, 2024 03:43
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)
CHANGELOG.md (1)

5-7: Correct grammar in bug fix description.

There's a minor grammatical issue in the bug fix description.

Consider changing:

-* (cli)[#1647](https://github.com/crypto-org-chain/cronos/pull/1647) Fix node can't shutdown by signal.
+* (cli)[#1647](https://github.com/crypto-org-chain/cronos/pull/1647) Fix node can't shut down by signal.

This change uses the correct verb form "shut down" instead of the noun "shutdown".

🧰 Tools
🪛 LanguageTool

[grammar] ~7-~7: The word ‘shutdown’ is a noun. Did you mean the verb “shut down”?
Context: ...-chain/cronos/pull/1647) Fix node can't shutdown by signal. ### Improvements * [#1645]...

(SHUTDOWN)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ab1df58 and 7432f50.

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

[grammar] ~7-~7: The word ‘shutdown’ is a noun. Did you mean the verb “shut down”?
Context: ...-chain/cronos/pull/1647) Fix node can't shutdown by signal. ### Improvements * [#1645]...

(SHUTDOWN)

🔇 Additional comments (6)
gomod2nix.toml (2)

Line range hint 1-266: Overall dependency updates look good

The changes in this file primarily consist of version updates for various dependencies. These updates likely include bug fixes, security patches, and potentially new features. Some key points to note:

  1. Most changes are minor version updates or commit hash changes, suggesting they are likely compatible with the existing codebase.
  2. Several modules are marked as replaced (e.g., github.com/ethereum/go-ethereum, github.com/syndtr/goleveldb), indicating the use of custom forks or versions. Ensure these custom versions are maintained and kept up-to-date with their upstream counterparts.
  3. There are no new dependencies added or existing ones removed, which is good for maintaining stability.

These updates should improve the overall stability and security of the project. However, it's recommended to thoroughly test the application to ensure these updates don't introduce any unexpected behavior or compatibility issues.

To verify the impact of these dependency updates, run the following command to check for any breaking changes or significant updates in the most critical dependencies:

#!/bin/bash
# Check for major version changes or significant updates in key dependencies
grep -E "github.com/(cosmos|ethereum|tendermint|cometbft)/" gomod2nix.toml | while read -r line; do
  if [[ $line =~ version[[:space:]]*=[[:space:]]*\"([^\"]*)\" ]]; then
    version="${BASH_REMATCH[1]}"
    module=$(echo "$line" | awk -F'"' '{print $2}')
    echo "Checking $module at version $version"
    gh repo view "$module" --json url -q .url | xargs -I {} gh api {}/releases/tags/"$version"
  fi
done

265-266: Ethermint module updated to latest version

The github.com/evmos/ethermint module has been updated to the latest version (v0.6.1-0.20241017130935-816389c76eac). This update likely includes new features, improvements, or bug fixes.

Note that this module is replaced with github.com/crypto-org-chain/ethermint, indicating the use of a custom fork. Ensure that this fork is up-to-date with the latest changes from the original repository and that it doesn't introduce any incompatibilities with other dependencies.

To verify the changes in this update, you can run the following command:

CHANGELOG.md (4)

Line range hint 8-12: LGTM: Improvements look good.

The improvements in this section appear to enhance performance and functionality:

  1. Generating test transactions in parallel even on a single node.
  2. Implementing a load generator with error retry and backoff.
  3. Adding an abort option in the PrepareProposal process.

These changes should contribute to better system efficiency and reliability.

🧰 Tools
🪛 LanguageTool

[grammar] ~7-~7: The word ‘shutdown’ is a noun. Did you mean the verb “shut down”?
Context: ...-chain/cronos/pull/1647) Fix node can't shutdown by signal. ### Improvements * [#1645]...

(SHUTDOWN)


[uncategorized] ~11-~11: Possible missing comma found.
Context: ...-chain/cronos/pull/1645) Gen test tx in parallel even in single node. * (testground)[#16...

(AI_HYDRA_LEO_MISSING_COMMA)


Line range hint 21-28: LGTM: Improvements and bug fixes look comprehensive.

The improvements and bug fixes in this section address various aspects of the system:

  1. Changes to block state machine parallelism.
  2. Updates to the Ethermint module for better API performance.
  3. Enhancements to PebbleDB support.
  4. Multiple bug fixes for critical issues like query failures, multisig account problems, and unsupported sign modes.

These changes should significantly improve the system's stability and performance.

🧰 Tools
🪛 LanguageTool

[grammar] ~7-~7: The word ‘shutdown’ is a noun. Did you mean the verb “shut down”?
Context: ...-chain/cronos/pull/1647) Fix node can't shutdown by signal. ### Improvements * [#1645]...

(SHUTDOWN)


[uncategorized] ~11-~11: Possible missing comma found.
Context: ...-chain/cronos/pull/1645) Gen test tx in parallel even in single node. * (testground)[#16...

(AI_HYDRA_LEO_MISSING_COMMA)


Line range hint 30-34: Noted: Previous version entries

The changelog includes entries for older versions (v1.4.0-rc0, v1.3.0-rc2, v1.3.0-rc1, and earlier). These entries provide valuable context for the project's development history and demonstrate ongoing improvements and bug fixes across multiple releases.

🧰 Tools
🪛 LanguageTool

[grammar] ~7-~7: The word ‘shutdown’ is a noun. Did you mean the verb “shut down”?
Context: ...-chain/cronos/pull/1647) Fix node can't shutdown by signal. ### Improvements * [#1645]...

(SHUTDOWN)


[uncategorized] ~11-~11: Possible missing comma found.
Context: ...-chain/cronos/pull/1645) Gen test tx in parallel even in single node. * (testground)[#16...

(AI_HYDRA_LEO_MISSING_COMMA)


Line range hint 16-19: Important: State Machine Breaking Change

The change in the memiavl module alters the initial version logic to ensure compatibility with iavl 1.2.0. This is a state machine breaking change and requires careful consideration during the upgrade process.

To verify the impact of this change, you can run the following script:

🧰 Tools
🪛 LanguageTool

[grammar] ~7-~7: The word ‘shutdown’ is a noun. Did you mean the verb “shut down”?
Context: ...-chain/cronos/pull/1647) Fix node can't shutdown by signal. ### Improvements * [#1645]...

(SHUTDOWN)


[uncategorized] ~11-~11: Possible missing comma found.
Context: ...-chain/cronos/pull/1645) Gen test tx in parallel even in single node. * (testground)[#16...

(AI_HYDRA_LEO_MISSING_COMMA)

@mmsqe mmsqe added this pull request to the merge queue Oct 18, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 18, 2024
@mmsqe mmsqe added this pull request to the merge queue Oct 18, 2024
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