Skip to content

Commit 58ab8df

Browse files
edobrygeoknee
andauthored
refactor(ops): rename add-chain to ops (#725)
* rename add-chain dir to scr-ops * update justfile * update doc * more justfile updates * update tests * update module name * update more docs * update code comments * update ci pipeline * update go.work * fix justfile typo * rename to ops * update tests * update addnewchain test method name * Update justfile --------- Co-authored-by: George Knee <[email protected]>
1 parent 09661bf commit 58ab8df

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+92
-79
lines changed

.circleci/main_config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ commands:
3535
install-foundry:
3636
steps:
3737
- run:
38-
# need foundry to execute 'cast call' within add-chain script
38+
# need foundry to execute 'cast call' within ops script
3939
name: Install foundry
4040
command: |
4141
echo "SHELL=$SHELL"
@@ -116,8 +116,8 @@ jobs:
116116
name: run validation module unit tests
117117
command: just test-validation
118118
- run:
119-
name: run add-chain module unit tests
120-
command: just test-add-chain
119+
name: run ops module unit tests
120+
command: just test-ops
121121
- notify-failures-on-main:
122122
channel: C03N11M0BBN # to slack channel `notify-ci-failures`
123123
# TODO this should also be filtered on modified chains

CONTRIBUTING.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,28 @@
33
> [!WARNING]
44
> `CONTRIBUTING.md` contains guidelines for modifying or working with the code in the Superchain Registry, including the validation checks and exported modules.
55
>
6-
> For guidelines on how to add a chain to the Registry, see the documentation for [adding a new chain](docs/add-chain.md).
6+
> For guidelines on how to add a chain to the Registry, see the documentation for [adding a new chain](docs/ops.md#adding-a-chain).
77
88
The Superchain Registry repository contains:
9-
* raw ["per-chain" config data](./README.md#3-understand-output) in `toml` and `json/json.gz` files arranged in a semantically meaningful directory structure
10-
* [superchain-wide config data](#superchain-wide-config-data)
11-
* a Go workspace with
9+
10+
- raw ["per-chain" config data](./README.md#3-understand-output) in `toml` and `json/json.gz` files arranged in a semantically meaningful directory structure
11+
- [superchain-wide config data](#superchain-wide-config-data)
12+
- a Go workspace with
1213
- a [`superchain`](#superchain-go-module) module
1314
- a [`validation`](#validation-go-module) module
14-
- an [`add-chain`](#add-chain-go-module) module
15+
- an [`ops`](#ops-go-module) module
1516
- The modules are tracked by a top level `go.work` file. The associated `go.work.sum` file is gitignored and not important to typical workflows, which should mirror those of the [CI configuration](.circleci/config.yml).
16-
* Automatically generated summary `chainList.json` and `chainList.toml` files.
17-
17+
- Automatically generated summary `chainList.json` and `chainList.toml` files.
1818

1919
## Superchain-wide config data
20-
A superchain target defines a set of layer 2 chains which share a `SuperchainConfig` and `ProtocolVersions` contract deployment on layer 1. It is usually named after the layer 1 chain, possibly with an extra identifier to distinguish devnets.
2120

21+
A superchain target defines a set of layer 2 chains which share a `SuperchainConfig` and `ProtocolVersions` contract deployment on layer 1. It is usually named after the layer 1 chain, possibly with an extra identifier to distinguish devnets.
2222

2323
> **Note**
2424
> Example: `sepolia` and `sepolia-dev-0` are distinct superchain targets, although they are on the same layer 1 chain.
2525
2626
### Adding a superchain target
27+
2728
A new Superchain Target can be added by creating a new superchain config directory,
2829
with a `superchain.yaml` config file.
2930

@@ -49,25 +50,25 @@ protocol_versions_addr: null # todo
4950
superchain_config_addr: null # todo
5051
EOF
5152
```
52-
Superchain-wide configuration, like the `ProtocolVersions` contract address, should be configured here when available.
53-
54-
5553

54+
Superchain-wide configuration, like the `ProtocolVersions` contract address, should be configured here when available.
5655

5756
## `superchain` Go Module
5857

5958
Per chain and superchain-wide configs and extra data are embedded into the `superchain` go module, which can be imported like so:
6059

61-
```
60+
```shell
6261
go get github.com/ethereum-optimism/superchain-registry/superchain@latest
6362
```
64-
The configs are consumed by downstream OP Stack software, i.e. `op-geth` and `op-node`.
6563

64+
The configs are consumed by downstream OP Stack software, i.e. `op-geth` and `op-node`.
6665

6766
## `validation` Go Module
67+
6868
A second module exists in this repo whose purpose is to validate the config exported by the `superchain` module. It is a separate module to avoid import cycles and polluting downstream dependencies with things like `go-ethereum` (which is used in the validation tests).
6969

70-
## `add-chain` Go module
70+
## `ops` Go module
71+
7172
This module contains the CLI tool for generating `superchain` compliant configs and extra data to the registry.
7273

7374
## CheckSecurityConfigs
@@ -158,6 +159,7 @@ graph TD
158159
```
159160

160161
## Setting up your editor for formatting and linting
162+
161163
If you use VSCode, you can place the following in a `settings.json` file in the gitignored `.vscode` directory:
162164

163165
```json
@@ -171,8 +173,8 @@ If you use VSCode, you can place the following in a `settings.json` file in the
171173
}
172174
```
173175

174-
175176
## Links
177+
176178
See [Superchain Upgrades] OP Stack specifications.
177179

178180
[Superchain Upgrades]: https://specs.optimism.io/protocol/superchain-upgrades.html

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ The Superchain Registry is an index of chains which serves as the source of trut
77

88
## Quickstart
99

10-
* ### [👀 See who's in the Superchain Ecosystem](chainList.json)
11-
* ### [⚙️ View detailed config information for each chain](superchain/configs)
12-
* ### [📝 Add a new chain to the Superchain Registry](docs/add-chain.md)
10+
- ### [👀 See who's in the Superchain Ecosystem](chainList.json)
11+
- ### [⚙️ View detailed config information for each chain](superchain/configs)
12+
- ### [📝 Add a new chain to the Superchain Registry](docs/ops.md#adding-a-chain)
1313

1414
## More about the Superchain Registry
1515

docs/add-chain.md renamed to docs/ops.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# Adding a Chain
1+
# Superchain Registry Operations (ops)
2+
3+
## Adding a Chain
24

35
The following are the steps you need to take to add a chain to the registry:
46

@@ -9,6 +11,7 @@ The following are the steps you need to take to add a chain to the registry:
911
> added to the registry.
1012
1113
### 0. Fork this repository
14+
1215
You will be raising a Pull Request from your fork to the upstream repo.
1316

1417
We recommend only adding one chain at a time, and starting with a fresh branch of this repo for every chain.
@@ -46,7 +49,9 @@ just add-chain
4649
The remaining steps should then be followed to merge the config data into the registry -- a prerequisite for [promoting the chain](#promote-a-chain-to-standard) to a standard chain.
4750

4851
### 4. Understand output
52+
4953
The tool will write the following data:
54+
5055
- The main configuration source, with genesis data, and address of onchain system configuration. These are written to `superchain/configs/<superchain-target>/<chain-short-name>.toml`.
5156
- Hardfork override times, where they have been set, will be included. If and when a chain becomes a standard chain, a `superchain_time` is set in the chain config. From that time on, future hardfork activation times which are missing from the chain config will be inherited from superchain-wide values in the neighboring `superchain.toml` file.
5257
- Genesis system config data
@@ -56,13 +61,15 @@ The genesis largely consists of contracts common with other chains:
5661
all contract bytecode is deduplicated and hosted in the `extra/bytecodes` directory.
5762

5863
The format is a gzipped JSON `genesis.json` file, with either:
64+
5965
- a `alloc` attribute, structured like a standard `genesis.json`, but with `codeHash` (bytes32, `keccak256` hash of contract code) attribute per account, instead of the `code` attribute seen in standard Ethereum genesis definitions.
6066
- a `stateHash` attribute: to omit a large state (e.g. for networks with a re-genesis or migration history). Nodes can load the genesis block header, and state-sync to complete the node initialization.
6167

6268
### 5. Run tests locally
6369

6470
Run the following commands to run the Go validation checks, for only the chain you added (replace the `<chain-id>` accordingly):
65-
```
71+
72+
```shell
6673
just validate <chain-id>
6774
just validate-genesis-allocs <chain-id>
6875
```
@@ -78,7 +85,7 @@ The [`validation_test.go`](./validation/validation_test.go) test declaration fil
7885

7986
This tool will add your chain to the `chainList.toml` and `addresses.json` files, which contain summaries of all chains in the registry.
8087

81-
```
88+
```shell
8289
just codegen
8390
```
8491

@@ -88,23 +95,27 @@ just codegen
8895
> If anything looks incorrect, please get in touch.
8996
9097
### 7. Open Your Pull Request
98+
9199
When opening a PR:
100+
92101
- Open it from a non-protected branch in your fork (e.g. avoid the `main` branch). This allows maintainers to push to your branch if needed, which streamlines the review and merge process.
93102
- Open one PR per chain you would like to add. This ensures the merge of one chain is not blocked by unexpected issues.
94103
- Once the PR is opened, please check the box to [allow edits from maintainers](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork).
95104

96105
Once the PR is opened, the same automated checks you've run locally will then run on your PR, and your PR will be reviewed in due course. Once these checks pass, the PR will be merged.
97106

98-
99107
## Promote a chain to standard
108+
100109
This process is only possible for chains already in the registry.
101110

102111
Run this command (replace the `<chain-id>` accordingly):
103-
```
112+
113+
```shell
104114
just promote-to-standard <chain-id>
105115
```
106116

107117
This command will:
108-
* declare the chain as a standard chain
109-
* set the `superchain_time`, so that the chain receives future hardforks with the rest of the superchain (baked into downstream OPStack software, selected with [network flags](https://docs.optimism.io/builders/node-operators/configuration/base-config#initialization-via-network-flags)).
110-
* activate the full suite of validation checks for standard chains, including checks on the `ProxyAdminOwner`
118+
119+
- declare the chain as a standard chain
120+
- set the `superchain_time`, so that the chain receives future hardforks with the rest of the superchain (baked into downstream OPStack software, selected with [network flags](https://docs.optimism.io/builders/node-operators/configuration/base-config#initialization-via-network-flags)).
121+
- activate the full suite of validation checks for standard chains, including checks on the `ProxyAdminOwner`

go.work

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
go 1.22.0
22

33
use (
4-
./add-chain
4+
./ops
55
./superchain
66
./validation
77
)

justfile

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,41 @@ alias l := lint-all
44

55
# Adding a chain
66
add-chain:
7-
go run ./add-chain add-new-chain
8-
go run ./add-chain check-rollup-config
9-
go run ./add-chain compress-genesis
10-
go run ./add-chain check-genesis
7+
go run ./ops add-new-chain
8+
go run ./ops check-rollup-config
9+
go run ./ops compress-genesis
10+
go run ./ops check-genesis
1111
just codegen
1212

1313
# Promote a standard candidate chain to a standard chain, example: just promote-to-standard 10
1414
promote-to-standard CHAIN:
15-
go run ./add-chain promote-to-standard --chain-id={{CHAIN}}
15+
go run ./ops promote-to-standard --chain-id={{CHAIN}}
1616
just codegen
1717

1818
# Generate auto-generated files
19-
codegen: clean-add-chain
19+
codegen: clean-ops
2020
CODEGEN=true go run superchain/internal/codegen/main.go
2121

2222
# Lint all Go code
2323
lint-all:
24-
golangci-lint run superchain/... validation/... add-chain/... --fix
24+
golangci-lint run superchain/... validation/... ops/... --fix
2525

2626
# Test all Go code
27-
test-all: test-add-chain test-superchain test-validation
27+
test-all: test-ops test-superchain test-validation
2828

29-
# Test all Go code in the add-chain module
30-
test-add-chain:
29+
# Test all Go code in the ops module
30+
test-ops:
3131
# We separate the first test from the rest because it generates artifacts
3232
# Which need to exist before the remaining tests run.
33-
TEST_DIRECTORY=./add-chain go run gotest.tools/gotestsum@latest --format testname -- -count=1 -run TestAddChain_Main
34-
TEST_DIRECTORY=./add-chain/... go run gotest.tools/gotestsum@latest --format testname -- -count=1 -run '[^TestAddChain_Main]'
33+
TEST_DIRECTORY=./ops go run gotest.tools/gotestsum@latest --format testname -- -count=1 -run TestOps_AddNewChain
34+
TEST_DIRECTORY=./ops/... go run gotest.tools/gotestsum@latest --format testname -- -count=1 -run '[^TestOps_AddNewChain]'
3535

3636
# Test all Go code in the superchain module
37-
test-superchain: clean-add-chain
37+
test-superchain: clean-ops
3838
TEST_DIRECTORY=./superchain go run gotest.tools/gotestsum@latest --format testname
3939

4040
# Unit test all Go code in the validation module, and do not run validation checks themselves
41-
test-validation: clean-add-chain
41+
test-validation: clean-ops
4242
TEST_DIRECTORY=./validation/... go run gotest.tools/gotestsum@latest --format testname -- -run '[^TestValidation|^TestPromotion|^TestGenesisAllocs]'
4343

4444
# Runs validation checks for any chain whose config changed
@@ -65,18 +65,18 @@ promotion-test:
6565
validate-standard-candidate CHAIN_ID:
6666
TEST_DIRECTORY=./validation go run gotest.tools/gotestsum@latest --format testname -- -run='Promotion/.+\({{CHAIN_ID}}\)$' -count=1
6767

68-
# Clean test files generated by the add-chain tooling
69-
clean-add-chain:
68+
# Clean test files generated by the ops tooling
69+
clean-ops:
7070
rm -f superchain/configs/sepolia/testchain_*.toml
7171
rm -f superchain/extra/sepolia/testchain_*.json.gz
7272
rm -rf -- validation/genesis/validation-inputs/*-test/
7373

7474
# Tidying all go.mod files
75-
tidy-all: tidy-add-chain tidy-superchain tidy-validation
75+
tidy-all: tidy-ops tidy-superchain tidy-validation
7676

77-
# Tidy the add-chain go.mod file
78-
tidy-add-chain:
79-
cd add-chain && go mod tidy
77+
# Tidy the ops go.mod file
78+
tidy-ops:
79+
cd ops && go mod tidy
8080

8181
# Tidy the superchain go.mod file
8282
tidy-superchain:
File renamed without changes.

add-chain/cmd/add-new-chain.go renamed to ops/cmd/add-new-chain.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import (
1313
"github.com/BurntSushi/toml"
1414
"github.com/ethereum-optimism/optimism/op-e2e/bindings"
1515
"github.com/ethereum-optimism/optimism/op-service/retry"
16-
"github.com/ethereum-optimism/superchain-registry/add-chain/config"
17-
"github.com/ethereum-optimism/superchain-registry/add-chain/flags"
18-
"github.com/ethereum-optimism/superchain-registry/add-chain/utils"
16+
"github.com/ethereum-optimism/superchain-registry/ops/config"
17+
"github.com/ethereum-optimism/superchain-registry/ops/flags"
18+
"github.com/ethereum-optimism/superchain-registry/ops/utils"
1919
"github.com/ethereum-optimism/superchain-registry/superchain"
2020
"github.com/ethereum-optimism/superchain-registry/validation"
2121
"github.com/ethereum-optimism/superchain-registry/validation/genesis"
@@ -271,7 +271,7 @@ func writeGenesisValidationMetadata(commit string, targetDir string) error {
271271
// Define default metadata params:
272272
// These may not be sufficient to make the genesis validation work,
273273
// but we address that with some manual trial-and-error intervention
274-
// involving OPLabs engineers after the add-chain command runs.
274+
// involving OPLabs engineers after the add-new-chain command runs.
275275
const defaultNodeVersion = "18.12.1"
276276
const defaultMonorepoBuildCommand = "pnpm"
277277
const defaultGenesisCreationCommand = "forge1" // See validation/genesis/commands.go

add-chain/cmd/check-genesis.go renamed to ops/cmd/check-genesis.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"math/big"
77
"os"
88

9-
"github.com/ethereum-optimism/superchain-registry/add-chain/flags"
9+
"github.com/ethereum-optimism/superchain-registry/ops/flags"
1010
"github.com/ethereum/go-ethereum/core"
1111
"github.com/google/go-cmp/cmp"
1212
"github.com/google/go-cmp/cmp/cmpopts"

add-chain/cmd/check-rollup-config.go renamed to ops/cmd/check-rollup-config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"os"
88

99
"github.com/ethereum-optimism/optimism/op-node/rollup"
10-
"github.com/ethereum-optimism/superchain-registry/add-chain/flags"
10+
"github.com/ethereum-optimism/superchain-registry/ops/flags"
1111
"github.com/ethereum/go-ethereum/common"
1212
"github.com/google/go-cmp/cmp"
1313
"github.com/google/go-cmp/cmp/cmpopts"

0 commit comments

Comments
 (0)