Skip to content

Comments

L2 genesis generation updates#8285

Merged
Spacesai1or merged 1 commit intodevelopfrom
wyatt/bindgen/l2-genesis-generation
Dec 20, 2023
Merged

L2 genesis generation updates#8285
Spacesai1or merged 1 commit intodevelopfrom
wyatt/bindgen/l2-genesis-generation

Conversation

@Spacesai1or
Copy link
Contributor

@Spacesai1or Spacesai1or commented Nov 27, 2023

This PR adds the following predeploys at the following addresses to the genesis of new L2s (context on why these contracts were chosen):

MultiCall3                    = "0xcA11bde05977b3631167028862bE2a173976CA11"
Safe_v130                     = "0x69f4D1788e39c87893C980c06EdF4b7f686e2938"
SafeL2_v130                   = "0xfb1bffC9d739B8D520DaF37dF666da4C687191EA"
MultiSendCallOnly_v130        = "0xA1dabEF33b3B82c7814B6D82A79e50F4AC44102B"
SafeSingletonFactory          = "0x914d7Fec6aaC8cd542e72Bca78B30650d45643d7"
DeterministicDeploymentProxy  = "0x4e59b44847b379578588920cA78FbF26c0B4956C"
MultiSend_v130                = "0x998739BFdAAdde7C933B942a68053933098f9EDa"
Permit2                       = "0x000000000022D473030F116dDEE9F6B43aC78BA3"
SenderCreator                 = "0x7fc98430eaedbb6070b35b39d798725049088348"
EntryPoint                    = "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"

The bulk of the changes to the L2 genesis generation can be found in op-chain-ops/genesis/layer_two.go

Special treatment is given to Permit2 because it has two immutable Solidity variables that make use of block.chainid. In order to obtain the correct deployed bytecode to be used for the predeploy, a simulated Geth backend was created with the chain id sourced from config.L2ChainID, and Permit2 was deployed to it using create2deployer to mimic ETH deployment as closely as possible. The deployed bytecode was then obtained by calling backend.CodeAt and is what's used specifically for the new L2 chain. This code is responsible for creating the simulated backend with chain id, and this code deploys the contract using create2deployer

For all other added predeploys, the used deployed bytecode was sourced for Etherscan/RPC node using BindGen CLI (#8281) and is added to the genesis without modification


These tests were added to check if the code at each predeploy address of a created L2 matches what's expected from BindGen's output metadata files

Additionally, Permit2 and EntryPoint were manually tested to work on our devnet with this PR's modified genesis. The other predeploys were not manually tested other than checking if the deployed bytecode matches what's expected

@Spacesai1or
Copy link
Contributor Author

Spacesai1or commented Nov 27, 2023

@Spacesai1or Spacesai1or mentioned this pull request Nov 27, 2023
@semgrep-app
Copy link
Contributor

semgrep-app bot commented Nov 27, 2023

Semgrep found 2 import-text-template findings:

  • op-bindings/bindgen/remote_handlers.go: L11
  • 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.

@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/init-new-bindings branch from 70b096a to 480415f Compare November 27, 2023 06:16
@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/l2-genesis-generation branch 2 times, most recently from 7579e32 to 3ef9fdd Compare November 27, 2023 20:28
@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/init-new-bindings branch 2 times, most recently from 6758a75 to b8385d6 Compare November 27, 2023 20:29
@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/l2-genesis-generation branch 2 times, most recently from a6af78e to f1d5643 Compare November 27, 2023 20:32
@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/init-new-bindings branch from 625da98 to bfbf4a4 Compare November 27, 2023 21:02
@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/l2-genesis-generation branch from f1d5643 to 14161a1 Compare November 27, 2023 21:02
@tynes
Copy link
Contributor

tynes commented Nov 27, 2023

I would like to have #8269 merged before any modifications to the L2 genesis generation code are merged

@Spacesai1or Spacesai1or marked this pull request as draft November 27, 2023 21:32
@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/init-new-bindings branch from bfbf4a4 to d1fdd2b Compare November 27, 2023 22:29
@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/l2-genesis-generation branch from 14161a1 to 1b26dd9 Compare November 27, 2023 22:29
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 27, 2023

Warning

Rate Limit Exceeded

@spacesailor24 has exceeded the limit for the number of files or commits that can be reviewed per hour. Please wait 9 minutes and 18 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 c04cefe and 21dc425.

Walkthrough

The recent updates involve expanding the set of predeployed contracts within an Ethereum-based blockchain framework, likely Optimism. New contracts and constants are introduced, and the deployment and testing infrastructure has been updated to accommodate these changes. The codebase now includes additional checks for contract bytecode, error handling for backend creation, and expanded test cases to ensure proper address generation and contract deployment.

Changes

Files Change Summary
op-bindings/predeploys/addresses.go Addition of multiple constants and their corresponding variable declarations, along with the initialization of these variables in the init function. Introduces new predeployed contract addresses and modifies the initialization logic for the Predeploys map.
op-chain-ops/cmd/check-l2/main.go Extension of the checkPredeployConfig function to include multiple cases for different predeploy addresses. Addition of the checkPredeployBytecode function to compare deployed bytecode with expected bytecode.
op-chain-ops/deployer/deployer.go
op-chain-ops/deployer/deployer_test.go
Significant changes including addition of error handling for backend initialization functions, introduction of new backend configuration functions, modification of existing backend configuration functions, addition of a new function for deploying smart contracts, introduction of a helper function for computing Ethereum addresses, and introduction of a test function to test the functionality of creating Ethereum addresses using the create2 opcode.
op-chain-ops/genesis/layer_two.go
op-chain-ops/genesis/layer_two_test.go
Semantic changes including addition of packages, introduction of new functions and logic, conditional logic changes, and adjustments in account creation, state setting, and logging. Updated test cases to reflect the new expected length of gen.Alloc.
op-chain-ops/immutables/immutables.go
op-chain-ops/immutables/immutables_test.go
Addition of multiple new struct declarations within the PredeploysImmutableConfig type. Modification in the deployContractsWithImmutables function to introduce a new variable for error handling. Additions of multiple struct declarations within a test function, potentially affecting the control flow and behavior of the TestBuildOptimism function.
packages/contracts-bedrock/src/libraries/Predeploys.sol Additions of multiple constant addresses for various predeployed contracts.
packages/contracts-bedrock/test/Predeploys.t.sol Expansion of the conditional check within the PredeploysTest contract to include additional addresses, altering the logic flow within the contract.

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

@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/init-new-bindings branch from d1fdd2b to 4c7f238 Compare November 27, 2023 22:40
@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/l2-genesis-generation branch from 1b26dd9 to c17c1d5 Compare November 27, 2023 22:40
@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/init-new-bindings branch from 4c7f238 to 7699722 Compare November 27, 2023 22:44
@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/l2-genesis-generation branch from c17c1d5 to ee3fa77 Compare November 27, 2023 22:44
@Spacesai1or Spacesai1or marked this pull request as ready for review November 28, 2023 21:10
@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/l2-genesis-generation branch from 8301b59 to 613e08f Compare December 17, 2023 00:13
This was referenced Dec 17, 2023
@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/l2-genesis-generation branch from 613e08f to e2f2b2c Compare December 18, 2023 23:12
@Spacesai1or Spacesai1or requested a review from a team as a code owner December 18, 2023 23:12
@semgrep-app
Copy link
Contributor

semgrep-app bot commented Dec 18, 2023

Semgrep found 1 iterate-over-empty-map finding:

  • op-batcher/compressor/compressors.go: L12-23

Iteration over a possibly empty map Kinds. This is likely a bug or redundant code

Ignore this finding from iterate-over-empty-map.

@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/init-new-bindings branch from 3276fa8 to b6428aa Compare December 18, 2023 23:17
@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/l2-genesis-generation branch from e2f2b2c to 5a37ac8 Compare December 18, 2023 23:17
@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/init-new-bindings branch from b6428aa to d7f7658 Compare December 19, 2023 00:10
@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/l2-genesis-generation branch 2 times, most recently from 58c960d to 685aa4d Compare December 19, 2023 00:41
Base automatically changed from wyatt/bindgen/init-new-bindings to develop December 19, 2023 00:58
@codecov
Copy link

codecov bot commented Dec 19, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (f3da73d) 34.57% compared to head (21dc425) 25.69%.
Report is 2 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #8285      +/-   ##
===========================================
- Coverage    34.57%   25.69%   -8.88%     
===========================================
  Files          167      119      -48     
  Lines         7170     4888    -2282     
  Branches      1213     1062     -151     
===========================================
- Hits          2479     1256    -1223     
+ Misses        4539     3526    -1013     
+ Partials       152      106      -46     
Flag Coverage Δ
cannon-go-tests ?
chain-mon-tests 27.14% <ø> (ø)
common-ts-tests ?
contracts-bedrock-tests 20.24% <ø> (ø)
contracts-ts-tests 12.25% <ø> (ø)
core-utils-tests ?
sdk-next-tests 42.18% <ø> (ø)
sdk-tests 42.18% <ø> (ø)

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

see 48 files with indirect coverage changes

@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/l2-genesis-generation branch 3 times, most recently from 357b33a to 61af084 Compare December 20, 2023 01:34
@Spacesai1or Spacesai1or requested a review from tynes December 20, 2023 01:38
@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/l2-genesis-generation branch from 61af084 to 21dc425 Compare December 20, 2023 01:40
@Spacesai1or Spacesai1or added this pull request to the merge queue Dec 20, 2023
Merged via the queue into develop with commit 7103672 Dec 20, 2023
@Spacesai1or Spacesai1or deleted the wyatt/bindgen/l2-genesis-generation branch December 20, 2023 23:48
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