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: unsuppored sign mode SIGN_MODE_TEXTUAL in bank transfer #1617

Merged
merged 2 commits into from
Oct 4, 2024

Conversation

mmsqe
Copy link
Collaborator

@mmsqe mmsqe commented Oct 3, 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

  • New Features

    • Enhanced transaction signing options, including support for a new textual signing mode.
    • Added support for IBC channel upgrade-related methods.
    • Improved slice manipulation capabilities.
  • Bug Fixes

    • Resolved issues with multisig accounts and transaction encoding.
    • Fixed the query for address-by-acc-num to use the correct identifier.
    • Addressed unsupported sign mode for bank transfers.
  • Documentation

    • Updated the changelog to reflect recent improvements and bug fixes.

Copy link
Contributor

coderabbitai bot commented Oct 3, 2024

Walkthrough

The pull request includes updates to the CHANGELOG.md, app/app.go, and integration_tests/test_basic.py files. The CHANGELOG.md reflects various improvements and bug fixes, including changes to transaction signing modes and updates to the cosmos-sdk. The app/app.go file introduces new signing modes and modifies transaction configuration handling. Additionally, new tests are added in integration_tests/test_basic.py to validate the functionality of the new signing modes and multisig accounts.

Changes

File Change Summary
CHANGELOG.md Updated to include improvements and bug fixes, including updates to ethermint, cosmos-sdk, and IBC methods.
app/app.go Imported slices and sigtypes, updated New function for transaction signing modes, modified setAnteHandler.
integration_tests/test_basic.py Added test_textual and test_multi_acc functions for testing new signing modes and multisig accounts.

Possibly related PRs

Suggested reviewers

  • yihuang
  • calvinaco

Poem

🐇 In the meadow, changes bloom,
New modes of signing, dispel the gloom.
With tests for multisig, all in line,
In the world of code, our efforts shine!
Hops and skips, we celebrate,
For every fix, we elevate! 🌼


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 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 36.88%. Comparing base (2685ed7) to head (b7d2a87).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #1617       +/-   ##
===========================================
+ Coverage   17.73%   36.88%   +19.14%     
===========================================
  Files          72      102       +30     
  Lines        5204     8055     +2851     
===========================================
+ Hits          923     2971     +2048     
- Misses       4158     4706      +548     
- Partials      123      378      +255     

see 47 files with indirect coverage changes

@mmsqe mmsqe marked this pull request as ready for review October 3, 2024 13:04
@mmsqe mmsqe requested a review from a team as a code owner October 3, 2024 13:04
@mmsqe mmsqe requested review from JayT106 and thomas-nguy and removed request for a team October 3, 2024 13:04
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/test_basic.py (1)

990-998: LGTM: Good test for textual sign mode, with room for enhancement.

The test_textual function effectively tests the basic functionality of the "textual" sign mode for transactions. It performs a transfer and checks for a successful response.

Consider enhancing this test by:

  1. Verifying the balance changes of both the sender and receiver after the transfer.
  2. Testing with different amounts and multiple transfers to ensure consistency.
  3. Adding a negative test case where the transaction should fail (e.g., insufficient funds).

Example of balance verification:

def test_textual(cronos):
    cli = cronos.cosmos_cli()
    sender = cli.address("validator")
    receiver = cli.address("signer2")
    amount = "1basetcro"

    # Check initial balances
    sender_initial = cli.balance(sender)
    receiver_initial = cli.balance(receiver)

    rsp = cli.transfer(sender, receiver, amount, sign_mode="textual")
    assert rsp["code"] == 0, rsp["raw_log"]

    # Verify balance changes
    sender_final = cli.balance(sender)
    receiver_final = cli.balance(receiver)
    assert sender_final == sender_initial - int(amount)
    assert receiver_final == receiver_initial + int(amount)
app/app.go (1)

Line range hint 1143-1160: Adjust log levels in 'setAnteHandler' for clarity

In the setAnteHandler function, app.Logger().Error is used to log messages about setting the ante handler, even when there is no error. Using the Error log level for normal operations can be misleading.

Recommend changing the log level to Info for normal operation messages.

Apply this diff to adjust the log levels:

 if len(blacklist) > 0 {
-    app.Logger().Error("Setting ante handler with blacklist", "size", len(blacklist), "hash", hex.EncodeToString(h.Sum(nil)))
+    app.Logger().Info("Setting ante handler with blacklist", "size", len(blacklist), "hash", hex.EncodeToString(h.Sum(nil)))
     for _, addr := range blacklist {
-        app.Logger().Error("Blacklisted address", "address", addr)
+        app.Logger().Info("Blacklisted address", "address", addr)
     }
 } else {
-    app.Logger().Error("Setting ante handler without blacklist")
+    app.Logger().Info("Setting ante handler without blacklist")
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 3766e6a and f6fa3b7.

📒 Files selected for processing (3)
  • CHANGELOG.md (1 hunks)
  • app/app.go (4 hunks)
  • integration_tests/test_basic.py (1 hunks)
🔇 Additional comments (11)
integration_tests/test_basic.py (2)

988-997: LGTM: Well-structured test for multisig account functionality.

The test_multi_acc function effectively tests the creation and basic operations of a multisig account. It covers creating the account, transferring funds, and verifying the account details, which are essential aspects of multisig functionality.


988-998: Summary: Valuable additions to the test suite.

The new test functions test_multi_acc and test_textual are valuable additions to the integration test suite. They cover important functionalities:

  1. test_multi_acc: Tests the creation and basic operations of multisig accounts.
  2. test_textual: Verifies the functionality of the "textual" sign mode for transactions.

These additions enhance the overall test coverage of the system. While both tests are well-implemented for basic functionality, there's potential for further enhancement, particularly in the test_textual function, to cover more edge cases and verify the results more thoroughly.

CHANGELOG.md (4)

18-18: Fix for unsupported sign mode in bank transfer

This fix addresses an issue with the unsupported sign mode SIGN_MODE_TEXTUAL for bank transfers. It's important to ensure that all supported sign modes are properly handled to maintain compatibility and prevent transaction failures.


Line range hint 20-24: Multiple improvements and bug fixes in v1.0.7

This release includes several improvements and bug fixes:

  1. Performance optimization by reusing recovered sender addresses.
  2. Addition of static-linked binaries for Linux platforms.
  3. Introduction of PebbleDB backend.
  4. Bug fixes related to JSON-RPC APIs for legacy blocks and third-party fixes.

These changes should enhance performance, expand platform support, and resolve several issues. The addition of PebbleDB as a backend option could provide performance benefits depending on the use case.

🧰 Tools
🪛 Markdownlint

20-20: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


Line range hint 28-32: Bug fix for JSON-RPC APIs in v1.0.6

This release focuses on backporting multiple JSON-RPC bug fixes from Ethermint. Ensuring the stability and correctness of JSON-RPC APIs is crucial for maintaining compatibility with Ethereum tooling and dApps.

🧰 Tools
🪛 Markdownlint

20-20: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


Line range hint 1-1185: Overall assessment of recent changes

The recent releases of Cronos (v1.0.6, v1.0.7, and the upcoming unreleased version) show a focus on:

  1. Improving compatibility and stability of Ethereum-related features (JSON-RPC APIs, EVM execution).
  2. Enhancing performance through optimizations and new backend options.
  3. Expanding platform support (e.g., static-linked binaries for Linux).
  4. Fixing critical issues related to transaction processing and state management.

These changes indicate an active development process with a strong emphasis on maintaining compatibility with the Ethereum ecosystem while improving the overall performance and stability of the Cronos blockchain.

For future releases, consider:

  1. Providing more detailed explanations of state machine breaking changes and their potential impact on users and developers.
  2. Including upgrade instructions or migration guides for significant changes.
  3. Grouping related changes together for better readability.
🧰 Tools
🪛 Markdownlint

20-20: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

app/app.go (5)

16-16: Approved: Import of 'slices' package

The slices package is imported and used appropriately when cloning the default sign modes.


66-66: Approved: Import of 'sigtypes' package

The sigtypes package is imported and used correctly to include the SIGN_MODE_TEXTUAL sign mode.


74-74: Approved: Import of 'txmodule' package

The txmodule package is imported and used appropriately for the coin metadata query function.


520-534: Enable 'SIGN_MODE_TEXTUAL' in transaction configuration

The code correctly enables the SIGN_MODE_TEXTUAL sign mode by cloning the default sign modes and appending the new sign mode. It then creates a new transaction configuration using authtx.NewTxConfigWithOptions with the updated sign modes and the coin metadata query function.

The error handling with panic(err) is appropriate in this initialization context.


Line range hint 1002-1007: Updated 'setAnteHandler' to use the new 'txConfig'

The code correctly passes the updated txConfig with the enabled SIGN_MODE_TEXTUAL sign mode to setAnteHandler. This ensures that the ante handler is aware of the new signing modes.

@mmsqe mmsqe added this pull request to the merge queue Oct 4, 2024
Merged via the queue into crypto-org-chain:main with commit dfcf478 Oct 4, 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