optimism
optimism copied to clipboard
Refactor L2 genesis generation - predeploy tests
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:
- The alloc should have a balance of
1. - The alloc should not have
codeset. - The alloc should have a
nonceof0. - The alloc should not have any storage slots set.
For predeploy proxies, the assertions are:
- The alloc should have a balance of
0. - The alloc should have
codesetProxy.soldeployed bytecode. - The alloc should have a
nonceof0. - The alloc should two storage slots set:
- L2GenesisHelpers.PROXY_ADMIN_ADDRESS
- L2GenesisHelpers.PROXY_IMPLEMENTATION_ADDRESS
For predeploy proxy implementations, the assertions are:
- The alloc should have a balance of
0. - The alloc should have
codeset to it's respective predeploy deployed bytecode. - The alloc should have a
nonceof0. - The alloc should have the storage slots set according to the specifc predeploy.
[!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
This stack of pull requests is managed by Graphite. Learn more about stacking.
Join @spacesailor24 and the rest of your teammates on
Graphite
Semgrep found 14 sol-style-notice-over-dev-natspec findings:
- packages/contracts-bedrock/scripts/libraries/L2GenesisHelpers.sol: L31, L17, L13
- packages/contracts-bedrock/scripts/L2Genesis.s.sol: L323, L315, L307, L291, L216, L151, L121, L90, L67, L51, L26
Prefer @notice over @dev in natspec comments
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
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?
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
@coderabbitaiin 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
@coderabbitaiin 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 pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger a review. This is useful when automatic reviews are disabled for the repository.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai helpto 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.yamlfile 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.
Semgrep found 2 sol-style-notice-over-dev-natspec findings:
Prefer @notice over @dev in natspec comments
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
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
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
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.
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.