diff --git a/arbnode/parent/chain_config.json b/arbnode/parent/chain_config.json new file mode 100644 index 0000000000..0637a088a0 --- /dev/null +++ b/arbnode/parent/chain_config.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/arbnode/parent/parent.go b/arbnode/parent/parent.go index 2fa46704f1..6dc8376340 100644 --- a/arbnode/parent/parent.go +++ b/arbnode/parent/parent.go @@ -6,6 +6,9 @@ package parent import ( "context" + _ "embed" + "encoding/json" + "fmt" "math/big" "github.com/ethereum/go-ethereum/consensus/misc/eip4844" @@ -15,6 +18,10 @@ import ( "github.com/offchainlabs/nitro/util/headerreader" ) +// knownConfigs maps known Ethereum chain IDs to their chain configurations. +// Note that this is not exhaustive; users can add more configurations via +// chain_config.json files or can even override existing known configurations by providing +// the same chain ID. var ( knownConfigs = map[uint64]*params.ChainConfig{ params.MainnetChainConfig.ChainID.Uint64(): params.MainnetChainConfig, @@ -24,6 +31,20 @@ var ( } ) +//go:embed chain_config.json +var DefaultChainsConfigBytes []byte + +func init() { + var chainsConfig []*params.ChainConfig + err := json.Unmarshal(DefaultChainsConfigBytes, &chainsConfig) + if err != nil { + panic(fmt.Errorf("error marshalling default chainsConfig: %w", err)) + } + for _, chainConfig := range chainsConfig { + knownConfigs[chainConfig.ChainID.Uint64()] = chainConfig + } +} + type ParentChain struct { ChainID *big.Int L1Reader *headerreader.HeaderReader