github.com/ethereum-optimism/optimism@v1.7.2/op-node/rollup/superchain.go (about) 1 package rollup 2 3 import ( 4 "fmt" 5 "math/big" 6 7 "github.com/ethereum/go-ethereum/params" 8 9 "github.com/ethereum/go-ethereum/common" 10 11 "github.com/ethereum-optimism/optimism/op-service/eth" 12 "github.com/ethereum-optimism/superchain-registry/superchain" 13 ) 14 15 var OPStackSupport = params.ProtocolVersionV0{Build: [8]byte{}, Major: 6, Minor: 0, Patch: 0, PreRelease: 0}.Encode() 16 17 const ( 18 opMainnet = 10 19 opGoerli = 420 20 opSepolia = 11155420 21 22 labsGoerliDevnet = 997 23 labsGoerliChaosnet = 888 24 labsSepoliaDevnet0 = 11155421 25 26 baseGoerli = 84531 27 baseMainnet = 8453 28 29 pgnMainnet = 424 30 pgnSepolia = 58008 31 ) 32 33 // LoadOPStackRollupConfig loads the rollup configuration of the requested chain ID from the superchain-registry. 34 // Some chains may require a SystemConfigProvider to retrieve any values not part of the registry. 35 func LoadOPStackRollupConfig(chainID uint64) (*Config, error) { 36 chConfig, ok := superchain.OPChains[chainID] 37 if !ok { 38 return nil, fmt.Errorf("unknown chain ID: %d", chainID) 39 } 40 41 superChain, ok := superchain.Superchains[chConfig.Superchain] 42 if !ok { 43 return nil, fmt.Errorf("chain %d specifies unknown superchain: %q", chainID, chConfig.Superchain) 44 } 45 46 var genesisSysConfig eth.SystemConfig 47 if sysCfg, ok := superchain.GenesisSystemConfigs[chainID]; ok { 48 genesisSysConfig = eth.SystemConfig{ 49 BatcherAddr: common.Address(sysCfg.BatcherAddr), 50 Overhead: eth.Bytes32(sysCfg.Overhead), 51 Scalar: eth.Bytes32(sysCfg.Scalar), 52 GasLimit: sysCfg.GasLimit, 53 } 54 } else { 55 return nil, fmt.Errorf("unable to retrieve genesis SystemConfig of chain %d", chainID) 56 } 57 58 addrs, ok := superchain.Addresses[chainID] 59 if !ok { 60 return nil, fmt.Errorf("unable to retrieve deposit contract address") 61 } 62 63 regolithTime := uint64(0) 64 // three goerli testnets test-ran Bedrock and later upgraded to Regolith. 65 // All other OP-Stack chains have Regolith enabled from the start. 66 switch chainID { 67 case baseGoerli: 68 regolithTime = 1683219600 69 case opGoerli: 70 regolithTime = 1679079600 71 case labsGoerliDevnet: 72 regolithTime = 1677984480 73 case labsGoerliChaosnet: 74 regolithTime = 1692156862 75 } 76 77 cfg := &Config{ 78 Genesis: Genesis{ 79 L1: eth.BlockID{ 80 Hash: common.Hash(chConfig.Genesis.L1.Hash), 81 Number: chConfig.Genesis.L1.Number, 82 }, 83 L2: eth.BlockID{ 84 Hash: common.Hash(chConfig.Genesis.L2.Hash), 85 Number: chConfig.Genesis.L2.Number, 86 }, 87 L2Time: chConfig.Genesis.L2Time, 88 SystemConfig: genesisSysConfig, 89 }, 90 // The below chain parameters can be different per OP-Stack chain, 91 // but since none of the superchain chains differ, it's not represented in the superchain-registry yet. 92 // This restriction on superchain-chains may change in the future. 93 // Test/Alt configurations can still load custom rollup-configs when necessary. 94 BlockTime: 2, 95 MaxSequencerDrift: 600, 96 SeqWindowSize: 3600, 97 ChannelTimeout: 300, 98 L1ChainID: new(big.Int).SetUint64(superChain.Config.L1.ChainID), 99 L2ChainID: new(big.Int).SetUint64(chConfig.ChainID), 100 RegolithTime: ®olithTime, 101 CanyonTime: chConfig.CanyonTime, 102 DeltaTime: chConfig.DeltaTime, 103 EcotoneTime: chConfig.EcotoneTime, 104 FjordTime: chConfig.FjordTime, 105 BatchInboxAddress: common.Address(chConfig.BatchInboxAddr), 106 DepositContractAddress: common.Address(addrs.OptimismPortalProxy), 107 L1SystemConfigAddress: common.Address(addrs.SystemConfigProxy), 108 } 109 if superChain.Config.ProtocolVersionsAddr != nil { // Set optional protocol versions address 110 cfg.ProtocolVersionsAddress = common.Address(*superChain.Config.ProtocolVersionsAddr) 111 } 112 if chainID == labsGoerliDevnet || chainID == labsGoerliChaosnet { 113 cfg.ChannelTimeout = 120 114 cfg.MaxSequencerDrift = 1200 115 } 116 if chainID == pgnSepolia { 117 cfg.MaxSequencerDrift = 1000 118 cfg.SeqWindowSize = 7200 119 } 120 return cfg, nil 121 }