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

Some Superchain L2 Genesis Fixes #10231

Merged
merged 7 commits into from
May 16, 2024
Merged

Conversation

geoknee
Copy link
Contributor

@geoknee geoknee commented Apr 19, 2024

@geoknee geoknee marked this pull request as ready for review April 19, 2024 13:13
@geoknee geoknee requested review from a team as code owners April 19, 2024 13:13
Copy link
Contributor

coderabbitai bot commented Apr 19, 2024

Walkthrough

Walkthrough

The recent updates introduce new fields ExcessBlobGas and BlobGasUsed to the Genesis struct in the registry-data component, aligning with EIP-4844 requirements. Additionally, configuration adjustments have been made in the getting-started script for contracts-bedrock, including modifying gasPriceOracleOverhead and adding new time offset entries for L2 genesis settings.

Changes

File Path Change Summary
op-chain-ops/cmd/registry-data/main.go Added ExcessBlobGas and BlobGasUsed fields to the Genesis struct with JSON tags and updated the entrypoint function to initialize these fields.
.../contracts-bedrock/scripts/getting-started/config.sh Modified gasPriceOracleOverhead value, added l2GenesisEcotoneTimeOffset, and changed l2GenesisDeltaTimeOffset entries to "0x0".

Recent Review Details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 7d05ebe and 58a3fde.
Files selected for processing (1)
  • packages/contracts-bedrock/scripts/getting-started/config.sh (2 hunks)
Additional comments not posted (3)
packages/contracts-bedrock/scripts/getting-started/config.sh (3)

68-68: Verify the change of gasPriceOracleOverhead to 0.

Ensure that setting gasPriceOracleOverhead to 0 is intentional and does not affect the gas price calculations adversely.


84-84: LGTM! Ensure l2GenesisEcotoneTimeOffset is correctly used in the codebase.

Verification successful

The parameter l2GenesisEcotoneTimeOffset is correctly integrated and documented in the codebase.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of `l2GenesisEcotoneTimeOffset` in the codebase.

# Test: Search for the usage of the new parameter. Expect: Correct usage in relevant files.
rg --type json --type sh $'l2GenesisEcotoneTimeOffset'

Length of output: 153



Script:

#!/bin/bash
# Description: Verify the usage of `l2GenesisEcotoneTimeOffset` in the codebase across all file types.

# Test: Search for the usage of the new parameter in all file types. Expect: Correct usage in relevant files.
rg 'l2GenesisEcotoneTimeOffset'

Length of output: 252



Script:

#!/bin/bash
# Description: Verify the context and usage of `l2GenesisEcotoneTimeOffset` in the Go file.

# Test: Extract the relevant lines from the Go file to understand the usage of the new parameter.
rg --context 10 'l2GenesisEcotoneTimeOffset' op-chain-ops/genesis/config.go

Length of output: 1839


85-85: Verify the change of l2GenesisDeltaTimeOffset to "0x0".

Ensure that setting l2GenesisDeltaTimeOffset to "0x0" is intentional and does not affect the system configuration adversely.


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

codecov bot commented Apr 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 29.22%. Comparing base (4a3d3fb) to head (58a3fde).
Report is 229 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff              @@
##           develop   #10231       +/-   ##
============================================
- Coverage    42.40%   29.22%   -13.18%     
============================================
  Files           73       31       -42     
  Lines         4830     2898     -1932     
  Branches       766      614      -152     
============================================
- Hits          2048      847     -1201     
+ Misses        2676     1976      -700     
+ Partials       106       75       -31     
Flag Coverage Δ
cannon-go-tests ?
chain-mon-tests 27.14% <ø> (ø)
common-ts-tests ?
contracts-ts-tests 12.25% <ø> (ø)
core-utils-tests ?
sdk-tests 40.27% <ø> (ø)

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

see 42 files with indirect coverage changes

@geoknee geoknee enabled auto-merge April 22, 2024 21:32
Copy link
Contributor

semgrep-app bot commented Apr 24, 2024

Semgrep found 13 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 found 5 golang_fmt_errorf_no_params findings:

No fmt.Errorf invocations without fmt arguments allowed

Ignore this finding from golang_fmt_errorf_no_params.

Semgrep found 1 import-text-template finding:

  • op-bindings/bindgen/generator_local.go

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.

Semgrep found 1 dangerous-exec-command finding:

  • op-challenger/game/fault/trace/cannon/executor.go

Detected non-static command inside Command. Audit the input to 'exec.Command'. If unverified user data can reach this call site, this is a code injection vulnerability. A malicious actor can inject a malicious script to execute arbitrary code.

Ignore this finding from dangerous-exec-command.

Co-authored-by: George C. Knee <georgeknee@googlemail.com>
Copy link
Contributor

semgrep-app bot commented May 16, 2024

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

  • packages/contracts-bedrock/scripts/Deployer.sol
  • packages/contracts-bedrock/scripts/DeployPeriphery.s.sol
  • packages/contracts-bedrock/scripts/Config.sol

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

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

Semgrep found 3 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 found 3 sol-style-input-arg-fmt findings:

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

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

Semgrep found 10 golang_fmt_errorf_no_params findings:

No fmt.Errorf invocations without fmt arguments allowed

Ignore this finding from golang_fmt_errorf_no_params.

Semgrep found 1 writable-filesystem-service finding:

  • ops-bedrock/docker-compose.yml

Service 'op_stack_go_builder' is running with a writable root filesystem. This may allow malicious applications to download and run additional payloads, or modify container files. If an application inside a container has to save something temporarily consider using a tmpfs. Add 'read_only: true' to this service to prevent this.

Ignore this finding from writable-filesystem-service.

Semgrep found 1 no-new-privileges finding:

  • ops-bedrock/docker-compose.yml

Service 'op_stack_go_builder' allows for privilege escalation via setuid or setgid binaries. Add 'no-new-privileges:true' in 'security_opt' to prevent this.

Ignore this finding from no-new-privileges.

Semgrep found 1 import-text-template finding:

  • op-bindings/bindgen/remote_handlers.go

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.

Semgrep found 1 avoid-bind-to-all-interfaces finding:

Detected a network listener listening on 0.0.0.0 or an empty string. This could unexpectedly expose the server publicly as it binds to all available interfaces. Instead, specify another IP address that is not 0.0.0.0 nor the empty string.

Ignore this finding from avoid-bind-to-all-interfaces.

Semgrep found 1 math-random-used finding:

  • op-chain-ops/state/memory_db_test.go

Do not use math/rand. Use crypto/rand instead.

Ignore this finding from math-random-used.

Semgrep found 1 err-nil-check finding:

superfluous nil err check before return

Ignore this finding from err-nil-check.

@geoknee geoknee added this pull request to the merge queue May 16, 2024
Merged via the queue into develop with commit 13d6146 May 16, 2024
75 checks passed
@geoknee geoknee deleted the gk/getting-started-missing-fields branch May 16, 2024 20:29
@@ -65,7 +65,7 @@ config=$(cat << EOL
"l1FeeVaultWithdrawalNetwork": 0,
"sequencerFeeVaultWithdrawalNetwork": 0,

"gasPriceOracleOverhead": 2100,
"gasPriceOracleOverhead": 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

wouldn't this break?

if cfg.Genesis.SystemConfig.Overhead == (eth.Bytes32{}) {
return ErrMissingOverhead
}
if cfg.Genesis.SystemConfig.Scalar == (eth.Bytes32{}) {
return ErrMissingScalar
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Overhead: eth.Bytes32(common.BigToHash(new(big.Int).SetUint64(d.GasPriceOracleOverhead))),

a 0 Overhead will turn into:

SystemConfig: eth.SystemConfig{
				BatcherAddr: d.BatchSenderAddress,
				Overhead:    eth.Bytes32(common.BigToHash(new(big.Int).SetUint64(d.GasPriceOracleOverhead))),
				Scalar:      eth.Bytes32(d.FeeScalar()),
				GasLimit:    uint64(d.L2GenesisBlockGasLimit),
			},

empty 32 bytes.

After which op-node validation fails:

if cfg.Genesis.SystemConfig.Overhead == (eth.Bytes32{}) {
return ErrMissingOverhead
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for highlighting. This will be addressed here #10226

rdovgan pushed a commit to rdovgan/optimism that referenced this pull request Jun 24, 2024
* add l2GenesisEcotoneTimeOffset to getting-started/config.sh

* set l2GenesisDeltaTimeOffset to 0

* remove unecessary line

* parse 4844 params in registry-data tool

* update overhead and scalar

* add 4844 fields to the other Genesis literal

* scalar: revert

Co-authored-by: George C. Knee <georgeknee@googlemail.com>

---------

Co-authored-by: Mark Tyneway <mark.tyneway@gmail.com>
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.

5 participants