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

add custom evm-version to abigen #1768

Merged
merged 1 commit into from
Jan 7, 2024
Merged

Conversation

trajan0x
Copy link
Contributor

@trajan0x trajan0x commented Jan 7, 2024

This was a feature that was needed for #1650 since our version of embedded geth is too old to support push0 (see #1767). It also allows us to target any evm for abigen by passing the param to the solc compiler.

Summary by CodeRabbit

  • New Features

    • Introduced new command-line flags to customize the ABI generation process.
    • Added functionality to specify the Ethereum Virtual Machine (EVM) version for Solidity compilation.
  • Improvements

    • Solidity files are now created in a specified directory, enhancing the organization of generated files.
  • Testing Enhancements

    • Expanded test coverage to include scenarios with explicit EVM version specification.

Copy link
Contributor

coderabbitai bot commented Jan 7, 2024

Walkthrough

The recent updates involve integrating a new package, adding flags to handle continuous integration and EVM versions, and updating functions for Solidity file handling and compilation. These changes are aimed at enhancing the abigen tool's capabilities in generating Ethereum contract binding code, with a focus on accommodating various EVM versions and improving CI compatibility.

Changes

Files Summary
tools/abigen/cmd/commands.go
tools/abigen/internal/generate.go
Imported new package, added disable-ci and evm-version flags, introduced strToPt function, updated GenerateCommand and EtherscanCommand, and modified BuildTemplates to include evmVersion.
tools/abigen/internal/export_test.go Updated CompileSolidity to accept an evmVersion *string parameter.
tools/abigen/internal/generate_test.go Added imports, renamed a test function for implicit EVM, and added a new test for explicit EVM version.

Poem

In the realm of code where smart contracts thrive,
🐇 CodeRabbit hopped in, making abigen alive.
With flags anew and EVM in sight,
It compiles with glee, through day and night.

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

@github-actions github-actions bot added go Pull requests that update Go code size/s labels Jan 7, 2024
Copy link

codecov bot commented Jan 7, 2024

Codecov Report

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

Comparison is base (26d1fae) 51.92478% compared to head (0e6f353) 52.29333%.

Files Patch % Lines
tools/abigen/internal/generate.go 55.55556% 4 Missing ⚠️
Additional details and impacted files
@@                 Coverage Diff                 @@
##              master       #1768         +/-   ##
===================================================
+ Coverage   51.92478%   52.29333%   +0.36854%     
===================================================
  Files            364         372          +8     
  Lines          24782       25596        +814     
  Branches         285         285                 
===================================================
+ Hits           12868       13385        +517     
- Misses         10667       10904        +237     
- Partials        1247        1307         +60     
Flag Coverage Δ
cctp-relayer 63.00863% <ø> (?)
explorer 24.80881% <ø> (ø)
promexporter 74.80916% <ø> (ø)
scribe 52.21130% <ø> (+0.18426%) ⬆️
sinner 64.60481% <ø> (ø)
tools 21.98661% <55.55556%> (+0.26209%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 26d1fae and 0e6f353.
Files selected for processing (4)
  • tools/abigen/cmd/commands.go (4 hunks)
  • tools/abigen/internal/export_test.go (1 hunks)
  • tools/abigen/internal/generate.go (4 hunks)
  • tools/abigen/internal/generate_test.go (3 hunks)
Additional comments: 12
tools/abigen/internal/export_test.go (1)
  • 14-15: The addition of the evmVersion parameter to the CompileSolidity function aligns with the PR's objectives to support custom EVM versions. Ensure that all calls to this function have been updated accordingly.
tools/abigen/internal/generate_test.go (3)
  • 4-7: The new imports for encoding/json, github.com/synapsecns/sanguine/core, and github.com/synapsecns/sanguine/ethergo/debug are necessary for the added test functionality.

  • 30-31: Renaming TestCompileSolidity to TestCompileSolidityImplicitEVM clarifies the intent of the test to cover the implicit EVM version scenario.

  • 41-60: The addition of TestCompileSolidityExplicitEVM is a good practice to ensure that the new functionality for setting an explicit EVM version is working as expected.

tools/abigen/cmd/commands.go (5)
  • 6-6: The import of github.com/synapsecns/sanguine/core is necessary for the strToPt utility function which is used to handle the new evm-version flag.

  • 37-57: The new flags disable-ci and evm-version are correctly defined and serve their intended purpose to control the regeneration on CI and to specify the EVM version.

  • 59-66: The strToPt function is a utility that correctly handles the conversion of a string to a pointer, which is useful for optional command-line flags.

  • 78-87: The GenerateCommand action has been updated to include the new evm-version flag and to handle the disable-ci flag, which is consistent with the PR's objectives.

  • 112-121: The EtherscanCommand action has been modified to handle the disableCIEtherscan flag and to pass the evmVersionFlags parameter, aligning with the new feature's requirements.

tools/abigen/internal/generate.go (3)
  • 32-38: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [35-54]

The GenerateABIFromEtherscan function now creates the Solidity file in a specific directory. Ensure that the file is properly cleaned up after its use to prevent any resource leaks.

  • 58-60: The BuildTemplates function has been updated to accept an evmVersion parameter, which is correctly passed to the compileSolidity function, aligning with the PR's objectives.

  • 183-193: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [126-190]

The compileSolidity function has been correctly updated to accept an evmVersion parameter and to include it in the compilation arguments when it is not nil.

@trajan0x trajan0x mentioned this pull request Jan 7, 2024
33 tasks
@trajan0x trajan0x merged commit 859697c into master Jan 7, 2024
43 of 44 checks passed
@trajan0x trajan0x deleted the feat/abigen-evm-version branch January 7, 2024 19:37
@trajan0x trajan0x mentioned this pull request Jan 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go Pull requests that update Go code size/s
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant