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

Init remote contract generation #8281

Merged
merged 1 commit into from
Dec 15, 2023

Conversation

spacesailor24
Copy link
Contributor

@spacesailor24 spacesailor24 commented Nov 27, 2023

This PR makes use of #8280 to fetch needed details about deployed contracts (on both ETH mainnet and OP mainnet) to generate Go bidings and metadata files (these files contain deployed bytecode and other data used to deploy the contract i.e. create2 salts)

op-bindings/artifacts.json contains the list of contracts bindings are being generated for, and the addresses of which their deployed bytecode and other details are being fetched at

Copy link
Contributor

semgrep-app bot commented Nov 27, 2023

Semgrep found 1 import-text-template finding:

  • op-bindings/bindgen/generator_local.go: L12

When working with web applications that involve rendering user-generated content, it's important to properly escape any HTML content to prevent Cross-Site Scripting (XSS) attacks. In Go, the text/template package does not automatically escape HTML content, which can leave your application vulnerable to these types of attacks. To mitigate this risk, it's recommended to use the html/template package instead, which provides built-in functionality for HTML escaping. By using html/template to render your HTML content, you can help to ensure that your web application is more secure and less susceptible to XSS vulnerabilities.

Ignore this finding from import-text-template.

@spacesailor24 spacesailor24 force-pushed the wyatt/bindgen/init-etherscan-client branch from f183f17 to 0e04b92 Compare November 27, 2023 20:27
@spacesailor24 spacesailor24 force-pushed the wyatt/bindgen/init-remote-contract-gen branch 2 times, most recently from d8b1bfd to 5441f06 Compare November 27, 2023 20:33
@spacesailor24 spacesailor24 marked this pull request as draft November 27, 2023 21:33
@spacesailor24 spacesailor24 force-pushed the wyatt/bindgen/init-etherscan-client branch 2 times, most recently from e858407 to e30e909 Compare November 27, 2023 22:28
@spacesailor24 spacesailor24 force-pushed the wyatt/bindgen/init-remote-contract-gen branch from 5441f06 to 713b79e Compare November 27, 2023 22:28
Copy link
Contributor

coderabbitai bot commented Nov 27, 2023

Walkthrough

Walkthrough

The project has made significant enhancements to facilitate the handling of Ethereum and Optimism smart contracts. The changes include the addition of new environment variables for Etherscan API keys to aid in generating bindings for all contracts and specifically for remote contracts. A new Go file has been introduced for remote contract generation, along with associated types and methods. The main.go file has been updated to incorporate import statements, flags, and subcommands for remote generation. Additionally, functions for fetching and processing remote contract data have been added, and existing contract handling logic has been updated.

Changes

File Path Change Summary
op-bindings/Makefile Added environment variables ETHERSCAN_APIKEY_ETH and ETHERSCAN_APIKEY_OP; introduced new targets bindgen-generate-all and bindgen-remote for generating bindings.
op-bindings/bindgen/generator_remote.go Added new Go file with bindGenGeneratorRemote struct, contractDataClient interface, and methods for generating and processing bindings.
op-bindings/bindgen/main.go Included import statement for the etherscan package, flags, subcommands, and a function for parsing remote contract generation configuration.
op-bindings/bindgen/remote_handlers.go Added and modified functions for handling remote contract metadata, including logic for fetching, comparing, and writing data.
op-bindings/bindgen/utils.go Modified the contractsList struct to include a new Remote field of type remoteContract.

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 X ?


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • You can reply to a review comment made by CodeRabbit.
  • You can tag CodeRabbit on specific lines of code or files in the PR by tagging @coderabbitai in a comment.
  • You can tag @coderabbitai in a PR comment and ask one-off questions about the PR and the codebase. Use quoted replies to pass the context for follow-up questions.

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

@spacesailor24 spacesailor24 force-pushed the wyatt/bindgen/init-etherscan-client branch from e30e909 to 7dbf9c5 Compare November 27, 2023 22:40
@spacesailor24 spacesailor24 force-pushed the wyatt/bindgen/init-remote-contract-gen branch 2 times, most recently from 1df8707 to 45375b2 Compare November 27, 2023 22:44
@spacesailor24 spacesailor24 marked this pull request as ready for review November 28, 2023 21:10
Copy link
Contributor

@hamdiallam hamdiallam left a comment

Choose a reason for hiding this comment

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

Looks good! few comments

op-bindings/bindgen/generator_remote.go Outdated Show resolved Hide resolved
op-bindings/bindgen/main.go Outdated Show resolved Hide resolved
op-bindings/bindgen/main.go Outdated Show resolved Hide resolved
op-bindings/bindgen/main.go Outdated Show resolved Hide resolved
op-bindings/bindgen/remote_handlers.go Outdated Show resolved Hide resolved
op-bindings/bindgen/remote_handlers.go Outdated Show resolved Hide resolved
op-bindings/bindgen/main.go Outdated Show resolved Hide resolved
op-bindings/bindgen/generator_remote.go Outdated Show resolved Hide resolved
op-bindings/bindgen/main.go Outdated Show resolved Hide resolved
op-bindings/bindgen/remote_handlers.go Outdated Show resolved Hide resolved
Copy link
Contributor

semgrep-app bot commented Dec 1, 2023

Semgrep found 6 sol-style-return-arg-fmt findings:

Named return arguments to functions must be appended with an underscore (_)

Ignore this finding from sol-style-return-arg-fmt.

Semgrep found 1 sol-style-input-arg-fmt finding:

  • packages/contracts-bedrock/scripts/Deployer.sol: L373

Inputs to functions must be prepended with an underscore (_)

Ignore this finding from sol-style-input-arg-fmt.

@spacesailor24 spacesailor24 marked this pull request as draft December 1, 2023 19:29
@spacesailor24 spacesailor24 force-pushed the wyatt/bindgen/init-etherscan-client branch from 7dbf9c5 to 42d11e0 Compare December 2, 2023 01:29
@spacesailor24 spacesailor24 force-pushed the wyatt/bindgen/init-remote-contract-gen branch from 08c5c83 to 6b3ec28 Compare December 2, 2023 01:29
@spacesailor24 spacesailor24 force-pushed the wyatt/bindgen/init-etherscan-client branch from 42d11e0 to a9c7e2a Compare December 2, 2023 02:20
@spacesailor24 spacesailor24 force-pushed the wyatt/bindgen/init-remote-contract-gen branch from 6b3ec28 to d46de62 Compare December 2, 2023 02:20
@spacesailor24 spacesailor24 force-pushed the wyatt/bindgen/init-etherscan-client branch from f203a03 to b4629be Compare December 14, 2023 07:11
@spacesailor24 spacesailor24 force-pushed the wyatt/bindgen/init-remote-contract-gen branch from 5a9e6a4 to 387d992 Compare December 14, 2023 07:11
Base automatically changed from wyatt/bindgen/init-etherscan-client to develop December 14, 2023 16:47
op-bindings/artifacts.json Outdated Show resolved Hide resolved
@spacesailor24 spacesailor24 force-pushed the wyatt/bindgen/init-remote-contract-gen branch from 387d992 to 68a0655 Compare December 14, 2023 21:16
op-bindings/bindgen/generator_remote.go Outdated Show resolved Hide resolved
op-bindings/bindgen/generator_remote.go Outdated Show resolved Hide resolved
op-bindings/etherscan/client.go Show resolved Hide resolved
op-bindings/bindgen/generator_remote.go Show resolved Hide resolved
op-bindings/bindgen/generator_remote.go Outdated Show resolved Hide resolved
@spacesailor24 spacesailor24 force-pushed the wyatt/bindgen/init-remote-contract-gen branch from c549d3d to dba53cc Compare December 14, 2023 22:20
@spacesailor24 spacesailor24 force-pushed the wyatt/bindgen/init-remote-contract-gen branch from dba53cc to 725ad1a Compare December 14, 2023 23:38
@mslipper mslipper added this pull request to the merge queue Dec 15, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 15, 2023
@spacesailor24 spacesailor24 added this pull request to the merge queue Dec 15, 2023
Merged via the queue into develop with commit 816e425 Dec 15, 2023
59 checks passed
@spacesailor24 spacesailor24 deleted the wyatt/bindgen/init-remote-contract-gen branch December 15, 2023 19:38
This was referenced Dec 17, 2023
roberto-bayardo pushed a commit to roberto-bayardo/optimism that referenced this pull request Dec 19, 2023
roberto-bayardo pushed a commit to roberto-bayardo/optimism that referenced this pull request Dec 21, 2023
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.

4 participants