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

fix(tests): Fix estimate gas tests and linter #1394

Merged
merged 5 commits into from
Jan 9, 2024
Merged

Conversation

itsdevbear
Copy link
Member

@itsdevbear itsdevbear commented Jan 7, 2024

Summary by CodeRabbit

  • Bug Fixes

    • Updated gas estimation values for contract interactions and simple transfers to reflect more accurate calculations.
  • Refactor

    • Improved argument validation within the core precompile methods for enhanced readability and maintenance.

Copy link

coderabbitai bot commented Jan 7, 2024

Warning

Rate Limit Exceeded

@itsdevbear has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 9 minutes and 23 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between eaa3236 and 033c8aa.

Walkthrough

The updates involve changes to Ethereum's gas estimation for simple contracts and transfers, reducing the estimated gas required. Additionally, refactoring has been done in the Ethereum core precompile validation method to enhance code readability and modularity by introducing helper functions for argument validation.

Changes

File Path Change Summary
.../tests/eth_estimateGas/estimate-simple-contract.io
.../tests/eth_estimateGas/estimate-simple-transfer.io
Updated eth_estimateGas results.
eth/core/precompile/method_validation.go Refactored validateArg to use new helper functions for improved modularity and readability.

Poem

🐇✨

Code hops along, neat and fine,
Gas estimates drop, line by line.
Validation's dance, now so divine,
A rabbit's touch, in code, does shine.
🌟🐾

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's AI:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • 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 tests 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 from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @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.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

@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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 0ec98f5 and 561bd4d.
Files selected for processing (3)
  • e2e/hive/simulators/rpc-compat/tests/eth_estimateGas/estimate-simple-contract.io (1 hunks)
  • e2e/hive/simulators/rpc-compat/tests/eth_estimateGas/estimate-simple-transfer.io (1 hunks)
  • eth/core/precompile/method_validation.go (1 hunks)
Additional comments: 7
e2e/hive/simulators/rpc-compat/tests/eth_estimateGas/estimate-simple-contract.io (1)
  • 2-2: The gas estimate for a simple contract deployment has been updated. Please ensure this new value is consistent with the actual gas used for these operations across the codebase.
Verification successful

The new gas value 0x520b is found in two places within the e2e/hive/simulators/rpc-compat/tests directory: in the estimate-simple-contract.io file, which is part of the eth_estimateGas test, and in the create-al-simple-contract.io file, which is part of the eth_createAccessList test. This indicates that the new gas value is being used consistently in at least two tests related to Ethereum RPC compatibility.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for other occurrences of the old and new gas values to ensure consistency.
rg --type json '0x6273' e2e/hive/simulators/rpc-compat/tests/eth_estimateGas/
rg --type json '0x520b' e2e/hive/simulators/rpc-compat/tests/eth_estimateGas/

Length of output: 155



Script:

#!/bin/bash
# Search for occurrences of the new gas value '0x520b' across the entire codebase.
rg '0x520b'

Length of output: 299

e2e/hive/simulators/rpc-compat/tests/eth_estimateGas/estimate-simple-transfer.io (1)
  • 2-2: The gas estimate for a simple Ether transfer has been updated. Please ensure this new value is consistent with the actual gas used for these operations across the codebase.
Verification successful

The new gas estimate value '0x5208' is consistently used in at least two test files within the codebase, and there are no occurrences of the old value '0x6270'. This suggests that the update to the gas estimate is consistent with other parts of the codebase.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for other occurrences of the old and new gas values to ensure consistency.
rg --type json '0x6270' e2e/hive/simulators/rpc-compat/tests/eth_estimateGas/
rg --type json '0x5208' e2e/hive/simulators/rpc-compat/tests/eth_estimateGas/

Length of output: 155



Script:

#!/bin/bash
# Search for occurrences of the old and new gas values across the entire codebase.
rg '0x6270'
rg '0x5208'

Length of output: 311

eth/core/precompile/method_validation.go (5)
  • 43-55: The validateArg function has been refactored to delegate to new helper functions. Ensure that all cases are covered and that the switch statement is exhaustive.

  • 58-80: The new validateArrayOrSlice function checks for type mismatches and validates struct fields if necessary. Ensure that the logic correctly handles all array and slice types.

  • 82-91: The validateSameKind function checks for struct fields if the type is a struct. Confirm that this function is called correctly and that it handles all cases where the types should be the same.

  • 93-110: The validatePointer function ensures that pointer types are correctly matched and that struct fields are validated. Verify that the function is correctly used in all relevant cases.

  • 111-111: The validateStruct function is critical for ensuring that struct fields match between implementation and ABI. Confirm that it is robust and handles all struct comparisons correctly.

Copy link

codecov bot commented Jan 7, 2024

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Comparison is base (4be15ef) 48.19% compared to head (033c8aa) 48.36%.
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1394      +/-   ##
==========================================
+ Coverage   48.19%   48.36%   +0.16%     
==========================================
  Files          84       84              
  Lines        4959     4971      +12     
==========================================
+ Hits         2390     2404      +14     
+ Misses       2392     2391       -1     
+ Partials      177      176       -1     
Files Coverage Δ
eth/core/precompile/method_validation.go 93.80% <81.08%> (+2.71%) ⬆️

@itsdevbear
Copy link
Member Author

@archbear @calbera can you guys verify my reflect logic is maintaining the same behaviour

Copy link

@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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 561bd4d and e504ca6.
Files selected for processing (1)
  • e2e/hive/simulators/rpc-compat/tests/eth_estimateGas/estimate-simple-contract.io (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • e2e/hive/simulators/rpc-compat/tests/eth_estimateGas/estimate-simple-contract.io

Copy link

@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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between e504ca6 and eaa3236.
Files selected for processing (1)
  • e2e/hive/simulators/rpc-compat/tests/eth_estimateGas/estimate-simple-contract.io (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • e2e/hive/simulators/rpc-compat/tests/eth_estimateGas/estimate-simple-contract.io

@itsdevbear
Copy link
Member Author

removing eth_estimateGas tests for now, due to the reduced depth of the bin search introduced into geth, I think they are always going to be flakey.

Copy link
Contributor

@calbera calbera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

method validation refactor lgtm, utACK

@itsdevbear itsdevbear merged commit 0d874f0 into main Jan 9, 2024
11 of 13 checks passed
@itsdevbear itsdevbear deleted the lint-fix-gas branch January 9, 2024 04:58
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.

None yet

3 participants