| 244 | } |
| 245 | |
| 246 | func NewL1EndpointConfig(ctx *cli.Context, lg log.Logger) (*eth.L1EndpointConfig, *ethclient.Client, error) { |
| 247 | l1NodeAddr := ctx.GlobalString(flags.L1NodeAddr.Name) |
| 248 | client, err := ethclient.DialContext(context.Background(), l1NodeAddr) |
| 249 | if err != nil { |
| 250 | lg.Error("Failed to connect to the L1 RPC", "error", err, "l1Rpc", l1NodeAddr) |
| 251 | return nil, nil, err |
| 252 | } |
| 253 | chainid, err := client.ChainID(context.Background()) |
| 254 | if err != nil { |
| 255 | lg.Error("Failed to fetch chain id from the L1 RPC", "error", err, "l1Rpc", l1NodeAddr) |
| 256 | return nil, nil, err |
| 257 | } |
| 258 | return ð.L1EndpointConfig{ |
| 259 | L1ChainID: chainid.Uint64(), |
| 260 | L1NodeAddr: l1NodeAddr, |
| 261 | L1BlockTime: ctx.GlobalUint64(flags.L1BlockTime.Name), |
| 262 | L1BeaconURL: ctx.GlobalString(flags.L1BeaconAddr.Name), |
| 263 | L1BeaconSlotTime: ctx.GlobalUint64(flags.L1BeaconSlotTime.Name), |
| 264 | DAURL: ctx.GlobalString(flags.DAURL.Name), |
| 265 | L1MinDurationForBlobsRequest: ctx.GlobalUint64(flags.L1MinDurationForBlobsRequest.Name), |
| 266 | }, client, nil |
| 267 | } |
| 268 | |
| 269 | func NewDownloaderConfig(ctx *cli.Context) *downloader.Config { |
| 270 | return &downloader.Config{ |