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: batch call precompile is not tested #1360

Merged
merged 4 commits into from
May 7, 2024

Conversation

mmsqe
Copy link
Collaborator

@mmsqe mmsqe commented Mar 22, 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
    • Introduced a new smart contract TestRelayer with batch transaction functionality.
  • Enhancements
    • Updated precompiled contract address in configuration for improved integration.
  • Bug Fixes
    • Adjusted iteration range in test configurations to refine test scope.
    • Modified a value in gas calculation test for enhanced accuracy.
  • Documentation
    • No visible changes.
  • Refactor
    • No visible changes.
  • Style
    • No visible changes.
  • Tests
    • Added new utility functions and constants to support integration testing.
  • Chores
    • Updated repository references in source configurations for maintenance.

Copy link
Contributor

coderabbitai bot commented Mar 22, 2024

Walkthrough

The recent updates span across various configuration and test files, primarily focusing on adjusting loop ranges, modifying contract addresses, and introducing new functionalities like batch transaction handling in Solidity contracts. Additionally, the updates include changes in constants, new utility functions, and revisions to dependencies, enhancing the system's flexibility and addressing specific needs like gas computations in tests.

Changes

File Path Change Summary
.../configs/ibc.jsonnet
.../configs/ibc_rly_evm.jsonnet
Modified loop ranges and updated contract addresses.
.../contracts/contracts/TestRelayer.sol
.../ibc_utils.py
.../utils.py
Introduced new Solidity contract and utility functions.
.../test_ibc_rly.py
.../test_ibc_rly_gas.py
Adjusted constants and test function parameters.
nix/sources.json Updated repository revision and checksum values.

🐰✨
In the land of code and wire,
Changes come as needs require.
Loops draw short, addresses shift,
New functions grow, our spirits lift.
Hopping through the code, we tweak,
A better system we do seek! 🌟
🐰✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@mmsqe mmsqe force-pushed the batch_call branch 2 times, most recently from 448f9c4 to a6a6fd4 Compare March 25, 2024 01:53
nix/sources.json Outdated Show resolved Hide resolved
Copy link

codecov bot commented May 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 17.78%. Comparing base (06c8345) to head (f80fa63).

❗ Current head f80fa63 differs from pull request most recent head 6ddba83. Consider uploading reports for the commit 6ddba83 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #1360       +/-   ##
===========================================
- Coverage   35.86%   17.78%   -18.09%     
===========================================
  Files         136       87       -49     
  Lines        9870     5337     -4533     
===========================================
- Hits         3540      949     -2591     
+ Misses       5934     4278     -1656     
+ Partials      396      110      -286     

see 72 files with indirect coverage changes

@mmsqe mmsqe marked this pull request as ready for review May 7, 2024 09:54
@mmsqe mmsqe requested a review from a team as a code owner May 7, 2024 09:54
@mmsqe mmsqe requested review from JayT106 and calvinaco and removed request for a team May 7, 2024 09:54
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

Out of diff range and nitpick comments (2)
integration_tests/ibc_utils.py (2)

17-17: Add a docstring to the derive_new_account function.

Providing a brief description of what the function does, its parameters, and its return value can greatly enhance the readability and maintainability of the code.


Line range hint 430-486: Add inline comments to clarify complex logic.

The function ibc_incentivized_transfer contains several complex operations related to handling balances and fees. Adding inline comments explaining each step can greatly improve the readability and maintainability of the code.

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 06c8345 and 6ddba83.
Files selected for processing (8)
  • integration_tests/configs/ibc.jsonnet (2 hunks)
  • integration_tests/configs/ibc_rly_evm.jsonnet (1 hunks)
  • integration_tests/contracts/contracts/TestRelayer.sol (1 hunks)
  • integration_tests/ibc_utils.py (6 hunks)
  • integration_tests/test_ibc_rly.py (2 hunks)
  • integration_tests/test_ibc_rly_gas.py (1 hunks)
  • integration_tests/utils.py (2 hunks)
  • nix/sources.json (1 hunks)
Files skipped from review due to trivial changes (1)
  • nix/sources.json
Additional comments not posted (8)
integration_tests/configs/ibc_rly_evm.jsonnet (1)

6-6: Update of precompiled_contract_address to '0x6F1805D56bF05b7be10857F376A5b1c160C8f72C' is noted.

integration_tests/contracts/contracts/TestRelayer.sol (1)

4-12: Addition of TestRelayer contract with batchCall function is noted. Ensure that reentrancy guards are considered if applicable.

integration_tests/test_ibc_rly_gas.py (1)

26-26: Adjustment of diff value to 0.15 in gas-related tests is noted. Verify that this new threshold aligns with recent gas usage metrics.

integration_tests/configs/ibc.jsonnet (1)

15-15: Reduction of iteration range in for-loops is noted. Ensure that all necessary test cases are still adequately covered.

Also applies to: 90-90

integration_tests/test_ibc_rly.py (1)

10-10: Addition of RELAYER_CALLER constant is noted. Consider adding comments to clarify its usage in tests.

integration_tests/utils.py (2)

63-63: Addition of TestRelayer to TEST_CONTRACTS is noted. Ensure that this is correctly referenced in relevant tests.


401-406: Addition of derive_new_account function is noted. Verify the correctness of the account derivation logic and consider adding comments for clarity.

Verification successful

The output from the shell script provides the implementation details of the derive_new_account function as found in the integration_tests/utils.py file. The function constructs an account path using a derivation index n, retrieves a mnemonic from an environment variable, and then uses these to derive a new account using the Account.from_mnemonic method. This method is a standard approach for deriving blockchain accounts from mnemonics, suggesting that the function is implemented correctly given typical usage patterns in blockchain development.

However, the script output does not provide information on the correctness of the account derivation in terms of actual functionality (e.g., does it correctly handle different values of n, does it fail gracefully if the environment variable is not set, etc.). These aspects typically require running the function with various inputs or adding unit tests.

Since the basic implementation aligns with standard practices and no further specific issues were highlighted in the review comment, the function appears to be implemented correctly based on the information available.

Conclusion:
The derive_new_account function uses standard methods for account derivation from mnemonics and is implemented as expected in the Python code. No issues are found based on the review of the implementation details provided.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the correctness of the `derive_new_account` function.

# Test: Check the function's account derivation logic. Expect: Correctly derived accounts.
echo "Review the `derive_new_account` function to ensure it correctly derives new accounts as intended."

Length of output: 272



Script:

#!/bin/bash
# Description: Verify the correctness of the `derive_new_account` function by checking its implementation in Python.

# Use ripgrep to find the implementation details of `derive_new_account` in Python files.
rg "def derive_new_account" --context 10

Length of output: 1310

integration_tests/ibc_utils.py (1)

29-29: Ensure the RELAYER_CALLER address is validated.

Verification successful

The shell script provided in the review comment was executed to verify whether the RELAYER_CALLER address is a valid Ethereum address. The script uses a regular expression to check if the address matches the typical format of an Ethereum address, which is a 42-character string starting with 0x followed by 40 hexadecimal characters.

The output of the script confirms that the address 0x6F1805D56bF05b7be10857F376A5b1c160C8f72C matches this pattern, indicating that it is a valid Ethereum address format.

Given this information, the verification of the RELAYER_CALLER address format as a valid Ethereum address is successful.


The RELAYER_CALLER address format has been verified as valid.

  • The address 0x6F1805D56bF05b7be10857F376A5b1c160C8f72C correctly matches the Ethereum address format.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the RELAYER_CALLER address is a valid Ethereum address.

# Test: Check if the address is a valid Ethereum address. Expect: Address is valid.
echo "0x6F1805D56bF05b7be10857F376A5b1c160C8f72C" | grep -E '^0x[a-fA-F0-9]{40}$'

Length of output: 124

integration_tests/ibc_utils.py Show resolved Hide resolved
integration_tests/ibc_utils.py Show resolved Hide resolved
@mmsqe mmsqe added this pull request to the merge queue May 7, 2024
Merged via the queue into crypto-org-chain:main with commit 5b6f408 May 7, 2024
29 checks passed
mmsqe added a commit to mmsqe/cronos that referenced this pull request May 29, 2024
* cleanup

* Problem: batch call precompile is not tested

fix test

* update deps
alienc0der pushed a commit to alienc0der/supernova that referenced this pull request Jun 8, 2024
* cleanup

* Problem: batch call precompile is not tested

fix test

* update deps
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