@@ -14,16 +14,19 @@ import (
1414 "github.com/ethereum-optimism/optimism/op-service/logpipe"
1515 "github.com/ethereum-optimism/optimism/op-service/tasks"
1616 "github.com/ethereum-optimism/optimism/op-service/testutils/tcpproxy"
17+ gn "github.com/ethereum/go-ethereum/node"
18+ "github.com/ethereum/go-ethereum/rpc"
1719)
1820
1921type OpReth struct {
2022 mu sync.Mutex
2123
22- id stack.L2ELNodeID
23- l2Net * L2Network
24- jwtPath string
25- authRPC string
26- userRPC string
24+ id stack.L2ELNodeID
25+ l2Net * L2Network
26+ jwtPath string
27+ jwtSecret [32 ]byte
28+ authRPC string
29+ userRPC string
2730
2831 authProxy * tcpproxy.Proxy
2932 userProxy * tcpproxy.Proxy
@@ -46,6 +49,14 @@ func (n *OpReth) hydrate(system stack.ExtensibleSystem) {
4649 require .NoError (err )
4750 system .T ().Cleanup (rpcCl .Close )
4851
52+ // Do not have to check whether client is readOnly because
53+ // all external L2 Clients will be wrapped with op-geth sysgo devstack, supporting readOnly
54+ var engineCl client.RPC
55+ auth := rpc .WithHTTPAuth (gn .NewJWTAuth (n .jwtSecret ))
56+ engineCl , err = client .NewRPC (system .T ().Ctx (), system .Logger (), n .authRPC , client .WithGethRPCOptions (auth ))
57+ require .NoError (err )
58+ system .T ().Cleanup (engineCl .Close )
59+
4960 l2Net := system .L2Network (stack .L2NetworkID (n .id .ChainID ()))
5061 sysL2EL := shim .NewL2ELNode (shim.L2ELNodeConfig {
5162 RollupCfg : l2Net .RollupConfig (),
@@ -54,7 +65,8 @@ func (n *OpReth) hydrate(system stack.ExtensibleSystem) {
5465 Client : rpcCl ,
5566 ChainID : n .id .ChainID (),
5667 },
57- ID : n .id ,
68+ EngineClient : engineCl ,
69+ ID : n .id ,
5870 })
5971 sysL2EL .SetLabel (match .LabelVendor , string (match .OpReth ))
6072 l2Net .(stack.ExtensibleL2Network ).AddL2ELNode (sysL2EL )
@@ -157,7 +169,7 @@ func WithOpReth(id stack.L2ELNodeID, opts ...L2ELOption) stack.Option[*Orchestra
157169 orch .l2ELOptions .Apply (p , id , cfg ) // apply global options
158170 L2ELOptionBundle (opts ).Apply (p , id , cfg ) // apply specific options
159171
160- jwtPath , _ := orch .writeDefaultJWT ()
172+ jwtPath , jwtSecret := orch .writeDefaultJWT ()
161173
162174 useInterop := l2Net .genesis .Config .InteropTime != nil
163175
@@ -232,15 +244,16 @@ func WithOpReth(id stack.L2ELNodeID, opts ...L2ELOption) stack.Option[*Orchestra
232244 }
233245
234246 l2EL := & OpReth {
235- id : id ,
236- l2Net : l2Net ,
237- jwtPath : jwtPath ,
238- authRPC : "" ,
239- userRPC : "" ,
240- execPath : execPath ,
241- args : args ,
242- env : []string {},
243- p : p ,
247+ id : id ,
248+ l2Net : l2Net ,
249+ jwtPath : jwtPath ,
250+ jwtSecret : jwtSecret ,
251+ authRPC : "" ,
252+ userRPC : "" ,
253+ execPath : execPath ,
254+ args : args ,
255+ env : []string {},
256+ p : p ,
244257 }
245258
246259 p .Logger ().Info ("Starting op-reth" )
0 commit comments