optimism icon indicating copy to clipboard operation
optimism copied to clipboard

Refactor L2 genesis generation - predeploy tests

Open spacesailor24 opened this issue 1 year ago • 8 comments

This PR adds tests to #9292 to assert that the outputted genesis allocs match what's expected

The test split the assertions based on whether each alloc address is detected to be either a precompile, predeploy proxy, or predeploy proxy implementation.

For precompiles, the assertions are:

  1. The alloc should have a balance of 1.
  2. The alloc should not have code set.
  3. The alloc should have a nonce of 0.
  4. The alloc should not have any storage slots set.

For predeploy proxies, the assertions are:

  1. The alloc should have a balance of 0.
  2. The alloc should have code set Proxy.sol deployed bytecode.
  3. The alloc should have a nonce of 0.
  4. The alloc should two storage slots set:
    1. L2GenesisHelpers.PROXY_ADMIN_ADDRESS
    2. L2GenesisHelpers.PROXY_IMPLEMENTATION_ADDRESS

For predeploy proxy implementations, the assertions are:

  1. The alloc should have a balance of 0.
  2. The alloc should have code set to it's respective predeploy deployed bytecode.
  3. The alloc should have a nonce of 0.
  4. The alloc should have the storage slots set according to the specifc predeploy.

spacesailor24 avatar Feb 07 '24 04:02 spacesailor24

[!WARNING] This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite. Learn more

  • #9328 Graphite
  • #9317 Graphite
  • #9410 Graphite 👈
  • #9557 Graphite
  • #9558 Graphite
  • develop

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @spacesailor24 and the rest of your teammates on Graphite Graphite

spacesailor24 avatar Feb 07 '24 04:02 spacesailor24

Semgrep found 14 sol-style-notice-over-dev-natspec findings:

Prefer @notice over @dev in natspec comments

Ignore this finding from sol-style-notice-over-dev-natspec.

semgrep-app[bot] avatar Feb 07 '24 04:02 semgrep-app[bot]

Where there is code, the nonce really should be 1 in the genesis. I think we should stick with it being 0 though as to not create issues between old and new states. I think this was an oversight in the original implementation

tynes avatar Feb 07 '24 17:02 tynes

Walkthrough

The update enhances the L2Genesis script by integrating the L2GenesisHelpers library for improved proxy and precompile management, refining deployment configurations, and enhancing developer account handling. These changes aim to streamline the Layer 2 genesis generation process, making it more modular and easier to maintain.

Changes

File Path Change Summary
packages/contracts-bedrock/scripts/L2Genesis.s.sol Integrated L2GenesisHelpers for efficient proxy and precompile management, updated inheritance to DeployConfig, and refactored functions for better performance.
.../scripts/libraries/L2GenesisHelpers.sol Introduced helper methods for L2 genesis generation and testing.
.../test/scripts/L2Genesis.t.sol Improved tests for genesis allocations using the new L2GenesisHelpers library.

Related issues

  • ethereum-optimism/optimism#8616: This PR aims to optimize genesis generation by enhancing proxy and precompile management, potentially addressing the issue of excessive unused proxies through script refactoring and method utilization.

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.

coderabbitai[bot] avatar Feb 12 '24 18:02 coderabbitai[bot]

Semgrep found 2 sol-style-notice-over-dev-natspec findings:

  • packages/contracts-bedrock/scripts/L2Genesis.s.sol: L54, L50

Prefer @notice over @dev in natspec comments

Ignore this finding from sol-style-notice-over-dev-natspec.

semgrep-app[bot] avatar Feb 14 '24 07:02 semgrep-app[bot]

Semgrep found 1 sol-style-notice-over-dev-natspec finding:

  • packages/contracts-bedrock/scripts/L2Genesis.s.sol: L59

Prefer @notice over @dev in natspec comments

Ignore this finding from sol-style-notice-over-dev-natspec.

semgrep-app[bot] avatar Feb 14 '24 08:02 semgrep-app[bot]

Semgrep found 1 sol-style-notice-over-dev-natspec finding:

  • packages/contracts-bedrock/scripts/L2Genesis.s.sol: L253

Prefer @notice over @dev in natspec comments

Ignore this finding from sol-style-notice-over-dev-natspec.

semgrep-app[bot] avatar Feb 15 '24 05:02 semgrep-app[bot]

Semgrep found 1 sol-style-notice-over-dev-natspec finding:

  • packages/contracts-bedrock/scripts/L2Genesis.s.sol: L406

Prefer @notice over @dev in natspec comments

Ignore this finding from sol-style-notice-over-dev-natspec.

semgrep-app[bot] avatar Feb 15 '24 05:02 semgrep-app[bot]

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Mar 17 '24 01:03 github-actions[bot]

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Apr 21 '24 01:04 github-actions[bot]