Skip to content

Commit 5bf0ca8

Browse files
authored
Add explanation to each line in the .env.example file (#387)
* add explanation to each line in the .env.example file remove SCR_CHAIN_TYPE * remove unused util * fix up e2e tests * add omitempty option to contract_versions_tag
1 parent 473f813 commit 5bf0ca8

File tree

10 files changed

+40
-61
lines changed

10 files changed

+40
-61
lines changed

.env.example

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,37 @@
1-
# Required for both Standard Chains and Frontier Chains
2-
SCR_CHAIN_NAME=awesomechain # L2 chain name
1+
# Your chain must be listed in https://github.com/ethereum-lists/chains
2+
# And you must use the exact same name in this field:
3+
SCR_CHAIN_NAME=awesomechain
34

45
# The superchain that this chain will belong to (mainnet or sepolia)
56
SCR_SUPERCHAIN_TARGET=mainnet
67

8+
# The short name will be used to identify the chain within the registry.
9+
# Ideally it does not contain spaces.
710
# Not that this is _NOT_ the short name from https://github.com/ethereum-lists/chains.
811
# It does not need to be globally unique, only unique within the particular superchain.
9-
# In this repository, the chain is identified by {SUPERCHAIN_TARGET}/{CHAIN_SHORT_NAME}
12+
# In this repository, the chain is identified by {SCR_SUPERCHAIN_TARGET}/{SCR_CHAIN_SHORT_NAME}
1013
# For example, mainnet/op and sepolia/op have the same chain short name.
1114
SCR_CHAIN_SHORT_NAME=awsm
1215

13-
SCR_CHAIN_TYPE=frontier # chain type (frontier or standard)
14-
1516
# Set to true to run most of the validation checks for standard chains
16-
# CHAIN_TYPE must be frontier
1717
SCR_STANDARD_CHAIN_CANDIDATE=false
1818

19+
# This is the path to your local fork of the github.com/ethereum-optimism/optimism monorepo
20+
# It is defined for convenience and reuse by other vars below
1921
SCR_MONOREPO_DIR=../optimism # path to local "ethereum-optimism/optimism" monorepo
22+
23+
# The following vars point to three input files required for adding a chain
24+
# Data will be scraped from these files in order to construct the required registry data
2025
SCR_DEPLOYMENTS_DIR=${SCR_MONOREPO_DIR}/packages/contracts-bedrock/deployments/getting-started
2126
SCR_ROLLUP_CONFIG=${SCR_MONOREPO_DIR}/op-node/rollup.json
2227
SCR_GENESIS=${SCR_MONOREPO_DIR}/op-node/genesis.json
28+
29+
# Your chain's endpoint for ETHEREUM JSON-RPC requests
2330
SCR_PUBLIC_RPC="http://awe.some.rpc" # new OP Stack L2 RPC URL
31+
32+
# Your chain's sequencer endpoint for eth_sendRawTransaction.
33+
# This can be set the same as SCR_PUBLIC_RPC if you don't have a separate endpoint.
2434
SCR_SEQUENCER_RPC="http://awe.some.seq.rpc" # new OP Stack L2 sequencer RPC URL
35+
36+
# Your chain's block explorer (e.g. Blockscout, Etherscan)
2537
SCR_EXPLORER="https://awesomescan.org" # new OP Stack L2 block explorer URL

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ You will need [`jq`](https://jqlang.github.io/jq/download/) and [`foundry`](http
4242

4343
To contribute a standard OP-Stack chain configuration, in addition to user-supplied metadata (chain name) the following data is required: contracts deployment, rollup config, L2 genesis. We provide a tool to scrape this information from your local [monorepo](https://github.com/ethereum-optimism/optimism) folder.
4444

45-
First, make a copy of `.env.example` named `.env`, and alter the variables to appropriate values.
45+
First, make a copy of `.env.example` named `.env`, and alter the variables to appropriate values. Each value is explained in a comment in `.env.example`.
46+
4647
#### Frontier chains
4748
To contribute a frontier OP-Stack chain configuration, you set the `SCR_CHAIN_TYPE=frontier` in the `.env` file. This will set `superchain_level = 1` in the registry's config file for this chain.
4849

add-chain/e2e_test.go

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,41 +32,38 @@ var tests = []struct {
3232
chainShortName: "testchain_b",
3333
rollupConfigFile: "./testdata/monorepo/op-node/rollup_baseline.json",
3434
deploymentsDir: "./testdata/monorepo/deployments",
35-
chainType: "standard",
3635
},
3736
{
3837
name: "zorasep",
3938
chainName: "testchain_zorasep",
4039
chainShortName: "testchain_zs",
4140
rollupConfigFile: "./testdata/monorepo/op-node/rollup_zorasep.json",
4241
deploymentsDir: "./testdata/monorepo/deployments",
43-
chainType: "frontier",
4442
standardChainCandidate: true,
4543
},
4644
{
47-
name: "plasma",
48-
chainName: "testchain_plasma",
49-
chainShortName: "testchain_p",
50-
rollupConfigFile: "./testdata/monorepo/op-node/rollup_plasma.json",
51-
deploymentsDir: "./testdata/monorepo/deployments",
52-
chainType: "standard",
45+
name: "plasma",
46+
chainName: "testchain_plasma",
47+
chainShortName: "testchain_p",
48+
rollupConfigFile: "./testdata/monorepo/op-node/rollup_plasma.json",
49+
deploymentsDir: "./testdata/monorepo/deployments",
50+
standardChainCandidate: true,
5351
},
5452
{
5553
name: "standard-candidate",
5654
chainName: "testchain_standard-candidate",
5755
chainShortName: "testchain_sc",
5856
rollupConfigFile: "./testdata/monorepo/op-node/rollup_standard-candidate.json",
59-
chainType: "frontier",
6057
deploymentsDir: "./testdata/monorepo/deployments",
6158
standardChainCandidate: true,
6259
},
6360
{
64-
name: "faultproofs",
65-
chainName: "testchain_faultproofs",
66-
chainShortName: "testchain_fp",
67-
rollupConfigFile: "./testdata/monorepo/op-node/rollup_faultproofs.json",
68-
chainType: "standard",
69-
deploymentsDir: "./testdata/monorepo/deployments-faultproofs",
61+
name: "faultproofs",
62+
chainName: "testchain_faultproofs",
63+
chainShortName: "testchain_fp",
64+
rollupConfigFile: "./testdata/monorepo/op-node/rollup_faultproofs.json",
65+
deploymentsDir: "./testdata/monorepo/deployments-faultproofs",
66+
standardChainCandidate: true,
7067
},
7168
}
7269

@@ -83,7 +80,6 @@ func TestAddChain_Main(t *testing.T) {
8380

8481
args := []string{
8582
"add-chain",
86-
"--chain-type=" + tt.chainType,
8783
"--chain-name=" + tt.chainName,
8884
"--chain-short-name=" + tt.chainShortName,
8985
"--rollup-config=" + tt.rollupConfigFile,

add-chain/flags/flags.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,6 @@ func prefixEnvVars(names ...string) []string {
1515
}
1616

1717
var (
18-
ChainTypeFlag = &cli.StringFlag{
19-
Name: "chain-type",
20-
Value: "frontier",
21-
EnvVars: prefixEnvVars("CHAIN_TYPE"),
22-
Usage: "Type of chain (either standard or frontier)",
23-
Required: false,
24-
}
2518
ChainNameFlag = &cli.StringFlag{
2619
Name: "chain-name",
2720
Value: "",

add-chain/main.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package main
22

33
import (
44
"encoding/json"
5-
"errors"
65
"fmt"
76
"os"
87
"path/filepath"
@@ -13,6 +12,7 @@ import (
1312
"github.com/ethereum-optimism/superchain-registry/add-chain/cmd"
1413
"github.com/ethereum-optimism/superchain-registry/add-chain/config"
1514
"github.com/ethereum-optimism/superchain-registry/add-chain/flags"
15+
"github.com/ethereum-optimism/superchain-registry/superchain"
1616
"github.com/joho/godotenv"
1717
"github.com/urfave/cli/v2"
1818
)
@@ -26,7 +26,6 @@ var app = &cli.App{
2626
flags.ExplorerFlag,
2727
flags.SuperchainTargetFlag,
2828
flags.MonorepoDirFlag,
29-
flags.ChainTypeFlag,
3029
flags.ChainNameFlag,
3130
flags.ChainShortNameFlag,
3231
flags.RollupConfigFlag,
@@ -72,16 +71,9 @@ func runApp(args []string) error {
7271
}
7372

7473
func entrypoint(ctx *cli.Context) error {
75-
chainType := ctx.String(flags.ChainTypeFlag.Name)
7674
standardChainCandidate := ctx.Bool(flags.StandardChainCandidateFlag.Name)
77-
if standardChainCandidate && chainType == "standard" {
78-
return errors.New("cannot set both chainType=standard and standard-chain-candidate=true")
79-
}
8075

81-
superchainLevel, err := getSuperchainLevel(chainType)
82-
if err != nil {
83-
return fmt.Errorf("failed to get superchain level: %w", err)
84-
}
76+
superchainLevel := superchain.Frontier // All chains enter as frontier chains
8577

8678
publicRPC := ctx.String(flags.PublicRpcFlag.Name)
8779
sequencerRPC := ctx.String(flags.SequencerRpcFlag.Name)

add-chain/testdata/superchain/configs/sepolia/expected_baseline.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ public_rpc: http://awe.some.rpc
44
sequencer_rpc: http://awe.some.seq.rpc
55
explorer: https://awesomescan.org
66

7-
superchain_level: 2
7+
superchain_level: 1
88
superchain_time: null # Missing hardfork times are NOT yet inherited from superchain.yaml
9-
contracts_version_tag: op-contracts/v1.3.0 # Multi-Chain Prep (MCP) https://github.com/ethereum-optimism/optimism/releases/tag/op-contracts%2Fv1.3.0
10-
119
batch_inbox_addr: "0xFf00000000000000000000000000000000042069"
1210

1311
genesis:

add-chain/testdata/superchain/configs/sepolia/expected_faultproofs.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ public_rpc: http://awe.some.rpc
44
sequencer_rpc: http://awe.some.seq.rpc
55
explorer: https://awesomescan.org
66

7-
superchain_level: 2
7+
superchain_level: 1
8+
standard_chain_candidate: true # This is a temporary field which causes most of the standard validation checks to run on this chain
89
superchain_time: null # Missing hardfork times are NOT yet inherited from superchain.yaml
910
contracts_version_tag: op-contracts/v1.4.0 # Fault Proofs https://github.com/ethereum-optimism/optimism/releases/tag/op-contracts%2Fv1.4.0
1011

add-chain/testdata/superchain/configs/sepolia/expected_plasma.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ public_rpc: http://awe.some.rpc
44
sequencer_rpc: http://awe.some.seq.rpc
55
explorer: https://awesomescan.org
66

7-
superchain_level: 2
7+
superchain_level: 1
8+
standard_chain_candidate: true # This is a temporary field which causes most of the standard validation checks to run on this chain
89
superchain_time: null # Missing hardfork times are NOT yet inherited from superchain.yaml
910
contracts_version_tag: op-contracts/v1.3.0 # Multi-Chain Prep (MCP) https://github.com/ethereum-optimism/optimism/releases/tag/op-contracts%2Fv1.3.0
1011

add-chain/utils.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import (
55
"fmt"
66
"os/exec"
77
"strings"
8-
9-
"github.com/ethereum-optimism/superchain-registry/superchain"
108
)
119

1210
func castCall(contractAddress, calldata, l1RpcUrl string) (string, error) {
@@ -26,16 +24,3 @@ func castCall(contractAddress, calldata, l1RpcUrl string) (string, error) {
2624

2725
return address, nil
2826
}
29-
30-
func getSuperchainLevel(chainType string) (superchain.SuperchainLevel, error) {
31-
switch chainType {
32-
case "standard":
33-
fmt.Printf("Adding standard chain to superchain-registry...\n\n")
34-
return superchain.Standard, nil
35-
case "frontier":
36-
fmt.Printf("Adding frontier chain to superchain-registry...\n\n")
37-
return superchain.Frontier, nil
38-
}
39-
40-
return 0, fmt.Errorf("invalid chain type: %s", chainType)
41-
}

superchain/superchain.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ type ChainConfig struct {
9595
// An op-contracts tag from github.com/ethereum-optimism/optimism
9696
// from which contracts were deployed. Example: "op-contracts/v1.4.0".
9797
// May be nil for frontier chains.
98-
ContractsVersionTag *string `yaml:"contracts_version_tag"`
98+
ContractsVersionTag *string `yaml:"contracts_version_tag,omitempty"`
9999

100100
BatchInboxAddr Address `yaml:"batch_inbox_addr"`
101101

0 commit comments

Comments
 (0)