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

L2 genesis - refactor to use solidity script #10106

Merged
merged 7 commits into from
Apr 23, 2024
Merged

L2 genesis - refactor to use solidity script #10106

merged 7 commits into from
Apr 23, 2024

Conversation

protolambda
Copy link
Contributor

@protolambda protolambda commented Apr 10, 2024

Description

Rebased version of #9792

Taking ownership over this PR to add ProxyAdmin, Preinstalls, and integrate into op-e2e / devnet testing.

TODO:

  • Work from Mark to revive and improve changes from Wyatt to add missing predeploys to the script.
  • Insert ProxyAdmin into L2 predeploys
  • Support Preinstalls in solidity script
    • Permit2
    • Create2Deployer
    • DeterministicDeploymentProxy
    • EntryPoint (4337)
    • Safe_v130
    • SenderCreator
    • SafeSingletonFactory
    • MultiSend_v130
    • MultiCall3
    • SafeL2_v130
    • MultiSendCallOnly_v130
  • Apply ecotone
  • Update Setup solidity contract to use this, rather than Go FFI
  • Re-use superchain-registry code path to build full genesis.json and `rollup.json`` Minimized op-chain-ops a lot already, reusing registry requires more diff, probably better for a different PR.
  • Integrate into op-e2e
  • Integrate into devnet (running in CI, verifying results still)

Metadata

Fix https://github.com/ethereum-optimism/protocol-quest/issues/151

@protolambda protolambda requested a review from tynes April 10, 2024 18:19
@protolambda protolambda self-assigned this Apr 10, 2024
Copy link
Contributor

coderabbitai bot commented Apr 10, 2024

Walkthrough

Walkthrough

The updates encompass significant improvements across blockchain contract deployment, configuration, and testing processes. These enhancements include refined L2 genesis allocations, streamlined proxy setups, enhanced predeploy management, and advancements in the testing framework. The changes aim to enhance operational transparency, deployment efficiency, and overall system robustness.

Changes

File or Directory Summary of Changes
packages/contracts-bedrock/scripts/Deploy.s.sol, DeployConfig.s.sol Updated deployment scripts with enhanced logging and configuration settings for fee vault networks.
packages/contracts-bedrock/scripts/L2Genesis.s.sol, test/L2Genesis.t.sol Major overhaul in L2Genesis functionality and testing, introducing new entities and improving initialization processes.
packages/contracts-bedrock/src/libraries/Predeploys.sol, test/Preinstalls.t.sol Significant changes in handling predeploys and testing preinstalled contracts.
packages/contracts-bedrock/test/... Updated various test scripts, including new assertions, import adjustments, and removal of redundant code.
op-chain-ops/genesis/..., op-e2e/... Changes in genesis block construction, testing, and E2E setup reflecting new L2 allocations and operational adjustments.
.circleci/config.yml, op-node/cmd/genesis/cmd.go Configuration updates in CI and command-line interfaces to support new network setups and parameters.
bedrock-devnet/devnet/__init__.py, packages/contracts-bedrock/.gas-snapshot Devnet initialization enhancements and updated gas cost snapshots for benchmarking.
packages/contracts-bedrock/scripts/Config.sol Modified state dump path generation logic to include new parameters and extended chain enums.

These changes collectively aim to refine the system's efficiency and clarity in operations, particularly focusing on L2 functionalities and testing rigor.


Recent Review Details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 53afefd and 1d9bc3c.
Files ignored due to path filters (2)
  • op-chain-ops/genesis/testdata/test-deploy-config-devnet-l1.json is excluded by !**/*.json
  • packages/contracts-bedrock/snapshots/state-diff/Kontrol-Deploy.json is excluded by !**/*.json
Files selected for processing (29)
  • .circleci/config.yml (3 hunks)
  • bedrock-devnet/devnet/init.py (7 hunks)
  • op-chain-ops/genesis/config.go (3 hunks)
  • op-chain-ops/genesis/helpers.go (1 hunks)
  • op-chain-ops/genesis/layer_two.go (1 hunks)
  • op-chain-ops/genesis/setters.go (3 hunks)
  • op-e2e/actions/ecotone_fork_test.go (4 hunks)
  • op-e2e/actions/span_batch_test.go (2 hunks)
  • op-e2e/config/init.go (5 hunks)
  • op-e2e/e2eutils/setup.go (1 hunks)
  • op-e2e/op_geth.go (1 hunks)
  • op-e2e/op_geth_test.go (3 hunks)
  • op-e2e/sequencer_failover_setup.go (1 hunks)
  • op-e2e/setup.go (1 hunks)
  • op-e2e/system_test.go (1 hunks)
  • op-node/cmd/genesis/cmd.go (4 hunks)
  • packages/contracts-bedrock/.gas-snapshot (1 hunks)
  • packages/contracts-bedrock/scripts/Config.sol (2 hunks)
  • packages/contracts-bedrock/scripts/Deploy.s.sol (2 hunks)
  • packages/contracts-bedrock/scripts/DeployConfig.s.sol (3 hunks)
  • packages/contracts-bedrock/scripts/ForgeArtifacts.sol (2 hunks)
  • packages/contracts-bedrock/scripts/L2Genesis.s.sol (4 hunks)
  • packages/contracts-bedrock/src/libraries/Predeploys.sol (3 hunks)
  • packages/contracts-bedrock/test/L2/GasPriceOracle.t.sol (4 hunks)
  • packages/contracts-bedrock/test/L2/L2StandardBridge.t.sol (1 hunks)
  • packages/contracts-bedrock/test/L2Genesis.t.sol (1 hunks)
  • packages/contracts-bedrock/test/Preinstalls.t.sol (1 hunks)
  • packages/contracts-bedrock/test/mocks/EIP1967Helper.sol (1 hunks)
  • packages/contracts-bedrock/test/setup/Setup.sol (5 hunks)
Files not reviewed due to errors (1)
  • packages/contracts-bedrock/scripts/L2Genesis.s.sol (no review received)
Files skipped from review as they are similar to previous changes (24)
  • .circleci/config.yml
  • op-chain-ops/genesis/config.go
  • op-chain-ops/genesis/helpers.go
  • op-chain-ops/genesis/layer_two.go
  • op-e2e/actions/ecotone_fork_test.go
  • op-e2e/actions/span_batch_test.go
  • op-e2e/config/init.go
  • op-e2e/e2eutils/setup.go
  • op-e2e/op_geth.go
  • op-e2e/op_geth_test.go
  • op-e2e/sequencer_failover_setup.go
  • op-e2e/setup.go
  • op-e2e/system_test.go
  • op-node/cmd/genesis/cmd.go
  • packages/contracts-bedrock/.gas-snapshot
  • packages/contracts-bedrock/scripts/Config.sol
  • packages/contracts-bedrock/scripts/Deploy.s.sol
  • packages/contracts-bedrock/scripts/DeployConfig.s.sol
  • packages/contracts-bedrock/test/L2/GasPriceOracle.t.sol
  • packages/contracts-bedrock/test/L2/L2StandardBridge.t.sol
  • packages/contracts-bedrock/test/L2Genesis.t.sol
  • packages/contracts-bedrock/test/Preinstalls.t.sol
  • packages/contracts-bedrock/test/mocks/EIP1967Helper.sol
  • packages/contracts-bedrock/test/setup/Setup.sol
Additional Context Used
Ruff (6)
bedrock-devnet/devnet/__init__.py (6)

7-7: calendar imported but unused; consider removing, adding to __all__, or using a redundant alias


12-12: gzip imported but unused; consider removing, adding to __all__, or using a redundant alias


18-18: devnet.log_setup imported but unused; consider removing, adding to __all__, or using a redundant alias


220-220: Avoid equality comparisons to False; use if not os.path.exists(l2_allocs_path): for false checks


220-220: Avoid equality comparisons to True; use if DEVNET_FPAC: for truth checks


309-309: Local variable e is assigned to but never used

Learnings (1)
packages/contracts-bedrock/src/libraries/Predeploys.sol (1)
User: tynes
PR: ethereum-optimism/optimism#8377
File: packages/contracts-bedrock/scripts/Deployer.sol:210-263
Timestamp: 2023-11-30T22:39:28.561Z
Learning: The user explained that populating a mapping for predeployed contracts in Solidity would require initialization earlier in the execution, which is not ideal. They also mentioned the lack of capability to iterate over all predeploys in Solidity. The current approach in the code uses hashed contract names for identification, which is a practical solution given the constraints.
Additional comments not posted (8)
op-chain-ops/genesis/setters.go (2)

22-27: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [14-27]

LGTM! The function FundDevAccounts correctly checks for the existence of accounts before creating and funding them.


31-33: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [29-37]

LGTM! The function SetPrecompileBalances efficiently sets balances for precompile addresses, which is a good optimization for contract calls.

packages/contracts-bedrock/src/libraries/Predeploys.sol (4)

5-9: The documentation and the constant PREDEPLOY_COUNT are clearly defined, enhancing the readability and maintainability of the code.


86-111: The function getName efficiently retrieves names for predeploy addresses using conditional checks. Ensure that all addresses are correctly mapped to their names.


113-126: The function isSupportedPredeploy correctly identifies if a predeploy is supported in new OP-Stack chains. This function is crucial for maintaining compatibility and should be thoroughly tested.


128-141: The function predeployToCodeNamespace uses bitwise operations to derive code-namespace addresses for predeploys. This is a critical function for address management and should be reviewed for accuracy in address computation.

packages/contracts-bedrock/scripts/ForgeArtifacts.sol (2)

146-152: The function isInitialized correctly checks if a contract is initialized by accessing the storage slot. This is a crucial function for contract management and should be tested to ensure it handles various contract states correctly.


204-210: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [207-213]

The refactored ensurePath function uses vm.split to handle file paths more robustly. This change improves the reliability of directory handling in script operations.


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.

Copy link
Contributor

semgrep-app bot commented Apr 10, 2024

Semgrep found 2 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.

op-node/cmd/genesis/cmd.go Outdated Show resolved Hide resolved
@protolambda
Copy link
Contributor Author

rebased on develop, fixed an ugly few solidity test integration issues, devnet should work (will watch for CI) and going to work on op-e2e now

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: 3

op-chain-ops/genesis/layer_two.go Show resolved Hide resolved
bedrock-devnet/devnet/__init__.py Show resolved Hide resolved
spacesailor24 and others added 6 commits April 22, 2024 18:20
Commits:
- Tmp change for Graphite
- Add Missing Predeploys to L2 Genesis Script
- contracts-bedrock: refactor L2 genesis generation
- wip
- temp
- l2 genesis generation wip
- updates

Co-authored-by: Mark Tyneway <[email protected]>
Co-authored-by: Wyatt Barnes <[email protected]>
Squashed commits:

todo

add ProxyAdmin predeploy, clean up test assertions

order predeploy setters

split Predeploys and Preinstalls

L2 genesis script: bytes32(0) style suggestion

move predeploy utils to predeploy library

preinstalls bytecode

fix typos

permit2 bytecode immutable patching

activate ecotone

cleanup tests, fixes, ecotone

work in progress GenesisL2 addition to Setup()

fixes

devnet allocs

fix go lint

more fixes

fix predeploys proxy impl checking test

fix solady

continue Go integration

l2 genesis Go integration stuff

fix lint

fix go lint

lint fixes

fixes for some PR review comments

Predeploys test clean up

go test superseded by solidity testing

fix lint

cleanup and review fixes

minor fixes

test fixes

op-e2e l2 allocs filepath fix

more devnet test funds

improve logging

fix devnet allocs-l2 path naming and output file moving to .devnet

devnet allocs CI fixes

circle ci workspace allocs-l2 fixes

op-e2e: fix alloc npe

fix

enforce genesis allocs copy

op-e2e fix

go test fixes, 4788 nonce edge case, dev accounts fix, misc fixes

fix test, fix flake

fix tests

Proxy artifact workaround

update gas snapshot

undo workaround, apply config change to fix

undo failed workarounds
@tynes tynes enabled auto-merge April 23, 2024 02:39
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: 1

Out of diff range and nitpick comments (3)
bedrock-devnet/devnet/__init__.py (3)

Line range hint 7-7: The calendar module is imported but not used in the file. Consider removing it to clean up the imports.

- import calendar

Line range hint 12-12: The gzip module is imported but not used in the file. Consider removing it to clean up the imports.

- import gzip

Line range hint 18-18: The devnet.log_setup module is imported but not used in the file. Consider removing it to clean up the imports.

- import devnet.log_setup

bedrock-devnet/devnet/__init__.py Show resolved Hide resolved
@tynes tynes added this pull request to the merge queue Apr 23, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 23, 2024
@tynes tynes added this pull request to the merge queue Apr 23, 2024
Merged via the queue into develop with commit c956771 Apr 23, 2024
74 of 75 checks passed
@tynes tynes deleted the l2-genesis branch April 23, 2024 04:53
tynes added a commit that referenced this pull request Apr 23, 2024
Now that #10106
has been merged, this script is dead code and can be deleted.
It was previously the cause of many race conditions and flakes
in CI. Now all genesis generation is done directly in solidity,
simplifying the process as a whole.
tynes added a commit that referenced this pull request Apr 23, 2024
This commit includes the deletion of a bunch of dead code
after #10106
has been merged. There is no need to maintain a bunch of custom
go code to generate the L2 genesis anymore, all of that is handled
directly in solidity.
github-merge-queue bot pushed a commit that referenced this pull request Apr 23, 2024
Now that #10106
has been merged, this script is dead code and can be deleted.
It was previously the cause of many race conditions and flakes
in CI. Now all genesis generation is done directly in solidity,
simplifying the process as a whole.
github-merge-queue bot pushed a commit that referenced this pull request Apr 23, 2024
* op-chain-ops: delete dead code

This commit includes the deletion of a bunch of dead code
after #10106
has been merged. There is no need to maintain a bunch of custom
go code to generate the L2 genesis anymore, all of that is handled
directly in solidity.

* op-chain-ops: delete more dead code

* op-chain-ops: more cleanup

* cleanup: remove old references

* op-chain-ops: cleanup abstractions

Co-authored-by: refcell <[email protected]>

---------

Co-authored-by: refcell <[email protected]>
pcw109550 added a commit to ethereum-optimism/asterisc that referenced this pull request Apr 23, 2024
pcw109550 added a commit to ethereum-optimism/asterisc that referenced this pull request Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants