@@ -17,6 +17,7 @@ import (
1717 "github.com/ethereum-optimism/optimism/op-node/eth"
1818 "github.com/ethereum-optimism/optimism/op-node/metrics"
1919 "github.com/ethereum-optimism/optimism/op-node/p2p"
20+ "github.com/ethereum-optimism/optimism/op-node/rollup"
2021 "github.com/ethereum-optimism/optimism/op-node/rollup/driver"
2122 "github.com/ethereum-optimism/optimism/op-node/sources"
2223)
@@ -40,6 +41,8 @@ type OpNode struct {
4041 tracer Tracer // tracer to get events for testing/debugging
4142 runCfg * RuntimeConfig // runtime configurables
4243
44+ coordinatorClient * rollup.CoordinatorClient // Coordinator RPC
45+
4346 // some resources cannot be stopped directly, like the p2p gossipsub router (not our design),
4447 // and depend on this ctx to be closed.
4548 resourcesCtx context.Context
@@ -81,6 +84,9 @@ func (n *OpNode) init(ctx context.Context, cfg *Config, snapshotLog log.Logger)
8184 if err := n .initL1 (ctx , cfg ); err != nil {
8285 return err
8386 }
87+ if err := n .initOpCoordinator (ctx , cfg ); err != nil {
88+ return err
89+ }
8490 if err := n .initRuntimeConfig (ctx , cfg ); err != nil {
8591 return err
8692 }
@@ -115,6 +121,22 @@ func (n *OpNode) initTracer(ctx context.Context, cfg *Config) error {
115121 return nil
116122}
117123
124+ func (n * OpNode ) initOpCoordinator (ctx context.Context , cfg * Config ) error {
125+ if err := cfg .Coordinator .Check (); err != nil {
126+ return fmt .Errorf ("coordinator config is invalid: %w" , err )
127+ }
128+
129+ if cfg .Coordinator .Enabled {
130+ var err error
131+ n .coordinatorClient , err = rollup .NewCoordinatorClient (cfg .Coordinator .CoordinatorAddr , cfg .Coordinator .SequencerId )
132+ if err != nil {
133+ return fmt .Errorf ("failed to get Coordinator RPC client: %w" , err )
134+ }
135+ }
136+
137+ return nil
138+ }
139+
118140func (n * OpNode ) initL1 (ctx context.Context , cfg * Config ) error {
119141 l1Node , rpcCfg , err := cfg .L1 .Setup (ctx , n .log , & cfg .Rollup )
120142 if err != nil {
@@ -199,7 +221,7 @@ func (n *OpNode) initL2(ctx context.Context, cfg *Config, snapshotLog log.Logger
199221 return err
200222 }
201223
202- n .l2Driver = driver .NewDriver (& cfg .Driver , & cfg .Rollup , n .l2Source , n .l1Source , n , n , n .log , snapshotLog , n .metrics )
224+ n .l2Driver = driver .NewDriver (& cfg .Driver , & cfg .Rollup , n .l2Source , n .l1Source , n , n . coordinatorClient , n , n .log , snapshotLog , n .metrics )
203225
204226 return nil
205227}
0 commit comments