optimism
optimism copied to clipboard
feat: Remove contracts-ts in favor of @eth-optimism/constants
This pr is a simpler attempt at accomplishing the goal of the contracts-ts package. That package had goals of being the source of truth for JavaScript but had the following problems
- It only worked for op-mainnet
- The wagmi-cli generation tool used was complicated buggy and poorly maintained
Base and us came to conclusion that instead we want a simple package that has chain constants ready to be used in JavaScript packages. This generates that from the superchain registry in one go.
I am putting this in the monorepo for now based on:
- Conversation in office hours folks preferred keeping code out of the superchain registry if possible
- Later this may move to the ecopod repo or a base maintained repo but it's final home hasn't been decided as of now.
I wrote the code generation script in JavaScript to reduce dependencies. It depends on yaml parsing since JS doesn't have it natively. It depends on viem to get the rpc urls for a given chain.
This script will also let us know if any chains are missing from viem that need to be upstreamed
Walkthrough
Walkthrough
The changes encompass the integration of chain constants from a superchain registry into the project. This includes scripts for generating chain constants, managing genesis blocks, and integrating Optimistic Rollup contracts. A new script is introduced to create viem chains for each chain in the superchain registry. Additionally, a function to retrieve Layer 2 predeployed contracts is added. The build configuration is optimized, and the package now consolidates all functionalities through a single entry point.
Changes
| File | Change Summary |
|---|---|
packages/chains/README.md |
Introduces chain constants from the superchain registry with installation and usage instructions. |
packages/chains/scripts/chains/OP_GENESIS_BLOCK.js.../paths.js |
Imports a YAML file to extract specific values as OP_GENESIS_BLOCK and provides functionality for defining file paths. |
.../OpStackChain.ts |
Introduces OpStackChain type extending Chain to include OP contracts for L1 and L2 chains. |
.../generate.js |
Introduces a script to generate viem chain files from the superchain registry data. |
.../getL2Predeploys.js |
Introduces a function to return L2 predeployed contract information. |
.../index.ts |
Exports all functionality from chains.js. |
packages/chains/tsup.config.ts |
Modifies the build entry point to a single file and enables declaration file generation. |
.circleci/config.yml |
Removes the contracts-ts-tests job and associated configurations. |
.changeset/config.json |
Removes the linked field affecting linked dependencies configuration. |
.github/mergify.yml |
Updates label rules based on specific file conditions. |
op-bindings/README.md |
Removes the "See also" section. |
op-bindings/predeploys/addresses.go |
Refactors address constants in the predeploys package. |
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.
The generated objects look good to me!
Hey @roninjin10 this needs a rebase
Semgrep found 1 sol-style-return-arg-fmt finding:
- packages/contracts-bedrock/scripts/Artifacts.s.sol: L53
Named return arguments to functions must be appended with an underscore (_)
Semgrep found 1 missing-integrity finding:
- op-node/cmd/stateviz/assets/index.html: L8
This tag is missing an 'integrity' subresource integrity attribute. The 'integrity' attribute allows for the browser to verify that externally hosted files (for example from a CDN) are delivered without unexpected manipulation. Without this attribute, if an attacker can modify the externally hosted resource, this could lead to XSS and other types of attacks. To prevent this, include the base64-encoded cryptographic hash of the resource (file) you’re telling the browser to fetch in the 'integrity' attribute for all externally hosted files.
Ignore this finding from missing-integrity.Semgrep found 4 ifs-tampering findings:
The special variable IFS affects how splitting takes place when expanding unquoted variables. Don't set it globally. Prefer a dedicated utility such as 'cut' or 'awk' if you need to split input data. If you must use 'read', set IFS locally using e.g. 'IFS="," read -a my_array'.
Ignore this finding from ifs-tampering.Semgrep found 4 todos_require_linear findings:
Please create a GitHub ticket for this TODO.
Ignore this finding from todos_require_linear.
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.
It's back
Code gen has been implemented in the tevm/opstack package. The next TODO here is basically to just copy it in here https://github.com/evmts/tevm-monorepo/blob/main/extensions/opstack/scripts/generate.ts
Beyond what it's already doing it needs to get the addresses (code available in ecopod file) and use viem chains instead of tevm contracts (as this pr is already doing)
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.
@roninjin10 Huge fan of this PR- monitoring services will need to scale as other projects launch op-stack L2s as the chain monitoring services are crucial to secure operations.
I mention monitoring services specifically because I found this PR through a TODO: https://github.com/ethereum-optimism/optimism/blob/e30ccc041a8ed8854be724f54e3eb707dfa15789/packages/chain-mon/src/wd-mon/constants.ts#L3-L4
It would be helpful having monitoring services provided out-of-box for superchain-compatible chains. As the Superchain expands, we will need to monitor all connected chains.
Unfortunate I didn't get this pr over the finish line. @pegahcarter if you are interested in picking this up I'm happy to help advise you to getting this over finish line.
Also my project tevm has an @tevm/opstack package that also has these constants as well as contract objects.
