From aa8f8f7dbfbca2788483ef61cb9aa48251a2bc78 Mon Sep 17 00:00:00 2001 From: pengin7384 Date: Fri, 17 Jan 2025 17:58:25 +0900 Subject: [PATCH] op-node: Add --l2.engine-rpc-timeout flag Add a new --l2.engine-rpc-timeout flag to configure the timeout duration for L2 Engine RPC calls. This allows for more flexible and explicit control over RPC call timeouts. --- op-node/flags/flags.go | 8 ++++++++ op-node/node/client.go | 5 +++++ op-node/service.go | 6 ++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/op-node/flags/flags.go b/op-node/flags/flags.go index 0107ee8c33f3..e8694e0476ce 100644 --- a/op-node/flags/flags.go +++ b/op-node/flags/flags.go @@ -209,6 +209,13 @@ var ( }(), Category: RollupCategory, } + L2EngineRpcTimeout = &cli.DurationFlag{ + Name: "l2.engine-rpc-timeout", + Usage: "L2 engine client rpc timeout", + EnvVars: prefixEnvVars("L2_ENGINE_RPC_TIMEOUT"), + Value: time.Second * 10, + Category: RollupCategory, + } VerifierL1Confs = &cli.Uint64Flag{ Name: "verifier.l1-confs", Usage: "Number of L1 blocks to keep distance from the L1 head before deriving L2 data from. Reorgs are supported, but may be slow to perform.", @@ -459,6 +466,7 @@ var optionalFlags = []cli.Flag{ ConductorRpcTimeoutFlag, SafeDBPath, L2EngineKind, + L2EngineRpcTimeout, InteropSupervisor, InteropRPCAddr, InteropRPCPort, diff --git a/op-node/node/client.go b/op-node/node/client.go index 3796bb98d051..9659f7da62b3 100644 --- a/op-node/node/client.go +++ b/op-node/node/client.go @@ -47,6 +47,10 @@ type L2EndpointConfig struct { // JWT secrets for L2 Engine API authentication during HTTP or initial Websocket communication. // Any value for an IPC connection. L2EngineJWTSecret [32]byte + + // L2EngineCallTimeout is the default timeout duration for L2 calls. + // Defines the maximum time a call to the L2 engine is allowed to take before timing out. + L2EngineCallTimeout time.Duration } var _ L2EndpointSetup = (*L2EndpointConfig)(nil) @@ -67,6 +71,7 @@ func (cfg *L2EndpointConfig) Setup(ctx context.Context, log log.Logger, rollupCf opts := []client.RPCOption{ client.WithGethRPCOptions(auth), client.WithDialAttempts(10), + client.WithCallTimeout(cfg.L2EngineCallTimeout), } l2Node, err := client.NewRPC(ctx, log, cfg.L2EngineAddr, opts...) if err != nil { diff --git a/op-node/service.go b/op-node/service.go index 7df2ab9a121e..9ed2e8392735 100644 --- a/op-node/service.go +++ b/op-node/service.go @@ -171,9 +171,11 @@ func NewL2EndpointConfig(ctx *cli.Context, logger log.Logger) (*node.L2EndpointC if err != nil { return nil, err } + l2RpcTimeout := ctx.Duration(flags.L2EngineRpcTimeout.Name) return &node.L2EndpointConfig{ - L2EngineAddr: l2Addr, - L2EngineJWTSecret: secret, + L2EngineAddr: l2Addr, + L2EngineJWTSecret: secret, + L2EngineCallTimeout: l2RpcTimeout, }, nil }