11package eth
22
33import (
4+ "context"
5+ "encoding/json"
6+ "log/slog"
7+ "math/big"
8+ "net/http"
9+
10+ "github.com/ethereum-optimism/optimism/op-service/client"
411 "github.com/ethereum/go-ethereum/common"
12+ "github.com/ethereum/go-ethereum/log"
513 "github.com/ethereum/go-ethereum/params"
6- "math/big"
714)
815
916// L1ChainConfigByChainID returns the chain config for the given chain ID,
@@ -20,6 +27,7 @@ func L1ChainConfigByChainID(chainID ChainID) *params.ChainConfig {
2027 case ChainIDFromBig (params .HoodiChainConfig .ChainID ):
2128 return params .HoodiChainConfig
2229 default :
30+ genesisTimestamp := getGenesis ()
2331 return & params.ChainConfig {
2432 ChainID : chainID .ToBig (),
2533 HomesteadBlock : big .NewInt (0 ),
@@ -43,14 +51,36 @@ func L1ChainConfigByChainID(chainID ChainID) *params.ChainConfig {
4351 PragueTime : newUint64 (0 ),
4452 OsakaTime : newUint64 (0 ),
4553 BPO1Time : newUint64 (0 ),
46- DepositContractAddress : common .HexToAddress ("0x00000000219ab540356cbb839cbe05303d7705fa" ),
54+ // 2 epoch * 8 slot * 6 seconds
55+ BPO2Time : newUint64 (genesisTimestamp + 2 * 8 * 6 ),
56+ DepositContractAddress : common .HexToAddress ("0x00000000219ab540356cbb839cbe05303d7705fa" ),
4757 BlobScheduleConfig : & params.BlobScheduleConfig {
4858 Cancun : params .DefaultCancunBlobConfig ,
4959 Prague : params .DefaultPragueBlobConfig ,
5060 Osaka : params .DefaultOsakaBlobConfig ,
5161 BPO1 : params .DefaultBPO1BlobConfig ,
62+ BPO2 : params .DefaultBPO2BlobConfig ,
5263 },
5364 }
5465 }
5566}
67+
5668func newUint64 (val uint64 ) * uint64 { return & val }
69+
70+ func getGenesis () uint64 {
71+ logger := log .NewLogger (slog .Default ().Handler ())
72+ cl := client .NewBasicHTTPClient ("http://cl-1-lodestar-geth:4000" , logger )
73+ headers := http.Header {}
74+ headers .Add ("Accept" , "application/json" )
75+
76+ var genesisResp APIGenesisResponse
77+ resp , err := cl .Get (context .Background (), "eth/v1/beacon/genesis" , nil , headers )
78+ if err != nil {
79+ panic (err )
80+ }
81+ defer resp .Body .Close ()
82+ if err = json .NewDecoder (resp .Body ).Decode (& genesisResp ); err != nil {
83+ panic (err )
84+ }
85+ return uint64 (genesisResp .Data .GenesisTime )
86+ }
0 commit comments