Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions node/cmd/node/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"morph-l2/node/flags"
"morph-l2/node/hakeeper"
"morph-l2/node/l1sequencer"
"morph-l2/node/rpcfailover"
"morph-l2/node/sequencer"
"morph-l2/node/sequencer/mock"
"morph-l2/node/sync"
Expand Down Expand Up @@ -106,15 +107,21 @@ func L2NodeMain(ctx *cli.Context) error {
}

// ========== Shared L1 client ==========
// One ethclient.Dial per process — all L1-touching components (syncer,
// derivation, l1sequencer Tracker/Verifier/Signer, rollup binding) share
// the same connection pool, retry policy, and metrics surface. Adding a
// new consumer means injecting this client, not opening a new one.
// One dial per process — all L1-touching components (syncer, derivation,
// l1sequencer Tracker/Verifier/Signer, rollup binding) share the same
// connection pool, retry policy, and metrics surface. Adding a new consumer
// means injecting this client, not opening a new one.
//
// --l1.rpc accepts a comma-separated list of endpoints, primary first. When
// more than one is given, failover happens inside the HTTP transport, so
// every consumer below keeps receiving a plain *ethclient.Client. See
// node/rpcfailover for what does and does not count as endpoint failure —
// notably, it assumes the caller only reads, which holds here.
l1RPC := ctx.GlobalString(flags.L1NodeAddr.Name)
if l1RPC == "" {
return fmt.Errorf("%s is required", flags.L1NodeAddr.Name)
}
l1Client, err := ethclient.Dial(l1RPC)
l1Client, err := rpcfailover.Dial(context.Background(), "L1", l1RPC, nodeConfig.Logger)
if err != nil {
return fmt.Errorf("dial l1 node error: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion node/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ var (

L1NodeAddr = cli.StringFlag{
Name: "l1.rpc",
Usage: "Address of L1 User JSON-RPC endpoint to use (eth namespace required)",
Usage: "Address of L1 User JSON-RPC endpoint to use (eth namespace required). Accepts a comma-separated list, primary first, to fail over when an endpoint stops answering; multiple endpoints must all be http(s)",
EnvVar: prefixEnvVar("L1_ETH_RPC"),
}

Expand Down
Loading
Loading