From a071f96e5c930dde8d8d9467739fcd45a12951da Mon Sep 17 00:00:00 2001 From: Emiliano Bonassi Date: Mon, 23 Dec 2024 18:41:28 +0100 Subject: [PATCH] feat(proposer): op, support timeout witness gen config --- book/advanced/proposer.md | 1 + proposer/op/op_proposer.sh | 1 + proposer/op/proposer/config.go | 3 +++ proposer/op/proposer/flags/flags.go | 6 ++++++ proposer/op/proposer/prove.go | 8 ++++---- proposer/op/proposer/service.go | 2 ++ 6 files changed, 17 insertions(+), 4 deletions(-) diff --git a/book/advanced/proposer.md b/book/advanced/proposer.md index febf1ed1..e4b75195 100644 --- a/book/advanced/proposer.md +++ b/book/advanced/proposer.md @@ -56,6 +56,7 @@ The following environment variables are optional. |-----------|-------------| | `MAX_CONCURRENT_PROOF_REQUESTS` | Default: `10`. The maximum number of concurrent proof requests to send to the `op-succinct-server`. | | `MAX_CONCURRENT_WITNESS_GEN` | Default: `5`. The maximum number of concurrent witness generation processes to run on the `op-succinct-server`. | +| `WITNESS_GEN_TIMEOUT` | Default: `1200`. The maximum time in seconds to spend generating a witness for `op-succinct-server`. | | `MAX_BLOCK_RANGE_PER_SPAN_PROOF` | Default: `300`. The maximum number of blocks to include in each span proof. For chains with high throughput, you need to decrease this value. | | `OP_SUCCINCT_MOCK` | Default: `false`. Set to `true` to run in mock proof mode. The `OPSuccinctL2OutputOracle` contract must be configured to use an `SP1MockVerifier`. | | `OP_SUCCINCT_SERVER_URL` | Default: `http://op-succinct-server:3000`. The URL of the `op-succinct-server` service which the `op-succinct-proposer` will send proof requests to. | diff --git a/proposer/op/op_proposer.sh b/proposer/op/op_proposer.sh index 4ab592d4..78be0a01 100644 --- a/proposer/op/op_proposer.sh +++ b/proposer/op/op_proposer.sh @@ -14,6 +14,7 @@ --beacon-rpc=${L1_BEACON_RPC} \ --max-concurrent-proof-requests=${MAX_CONCURRENT_PROOF_REQUESTS:-10} \ --max-concurrent-witness-gen=${MAX_CONCURRENT_WITNESS_GEN:-5} \ + --witness-gen-timeout=${WITNESS_GEN_TIMEOUT:-1200} \ --db-path=${DB_PATH:-/usr/local/bin/dbdata} \ --op-succinct-server-url=${OP_SUCCINCT_SERVER_URL:-http://op-succinct-server:3000} \ --max-block-range-per-span-proof=${MAX_BLOCK_RANGE_PER_SPAN_PROOF:-300} \ diff --git a/proposer/op/proposer/config.go b/proposer/op/proposer/config.go index 7238f29a..fac48485 100644 --- a/proposer/op/proposer/config.go +++ b/proposer/op/proposer/config.go @@ -82,6 +82,8 @@ type CLIConfig struct { MaxBlockRangePerSpanProof uint64 // The max number of concurrent witness generation processes. MaxConcurrentWitnessGen uint64 + // The max time we will wait for a witness to be generated before giving up. + WitnessGenTimeout uint64 // The Chain ID of the L2 chain. L2ChainID uint64 // The maximum amount of time we will spend waiting for a proof before giving up and trying again. @@ -158,6 +160,7 @@ func NewConfig(ctx *cli.Context) *CLIConfig { SlackToken: ctx.String(flags.SlackTokenFlag.Name), MaxBlockRangePerSpanProof: ctx.Uint64(flags.MaxBlockRangePerSpanProofFlag.Name), MaxConcurrentWitnessGen: ctx.Uint64(flags.MaxConcurrentWitnessGenFlag.Name), + WitnessGenTimeout: ctx.Uint64(flags.WitnessGenTimeoutFlag.Name), ProofTimeout: ctx.Uint64(flags.ProofTimeoutFlag.Name), TxCacheOutDir: ctx.String(flags.TxCacheOutDirFlag.Name), OPSuccinctServerUrl: ctx.String(flags.OPSuccinctServerUrlFlag.Name), diff --git a/proposer/op/proposer/flags/flags.go b/proposer/op/proposer/flags/flags.go index f749e533..e3fd55f0 100644 --- a/proposer/op/proposer/flags/flags.go +++ b/proposer/op/proposer/flags/flags.go @@ -99,6 +99,12 @@ var ( Value: 5, EnvVars: prefixEnvVars("MAX_CONCURRENT_WITNESS_GEN"), } + WitnessGenTimeoutFlag = &cli.Uint64Flag{ + Name: "witness-gen-timeout", + Usage: "Maximum time in seconds to spend generating a witness before giving up", + Value: 20 * 60, + EnvVars: prefixEnvVars("WITNESS_GEN_TIMEOUT"), + } ProofTimeoutFlag = &cli.Uint64Flag{ Name: "proof-timeout", Usage: "Maximum time in seconds to spend generating a proof before giving up", diff --git a/proposer/op/proposer/prove.go b/proposer/op/proposer/prove.go index ae773ee7..00ba4278 100644 --- a/proposer/op/proposer/prove.go +++ b/proposer/op/proposer/prove.go @@ -17,7 +17,6 @@ import ( ) const PROOF_STATUS_TIMEOUT = 30 * time.Second -const WITNESSGEN_TIMEOUT = 20 * time.Minute // Process all of requests in PROVING state. func (l *L2OutputSubmitter) ProcessProvingRequests() error { @@ -71,7 +70,7 @@ func (l *L2OutputSubmitter) ProcessWitnessgenRequests() error { for _, req := range reqs { // If the request has been in the WITNESSGEN state for longer than the timeout, set status to FAILED. // This is a catch-all in case the witness generation state update failed. - if req.LastUpdatedTime+uint64(WITNESSGEN_TIMEOUT.Seconds()) < uint64(time.Now().Unix()) { + if req.LastUpdatedTime+uint64(l.Cfg.WitnessGenTimeout) < uint64(time.Now().Unix()) { // Retry the request if it timed out. l.RetryRequest(req, ProofStatusResponse{}) } @@ -327,13 +326,14 @@ func (l *L2OutputSubmitter) makeProofRequest(proofType proofrequest.Type, jsonBo } req.Header.Set("Content-Type", "application/json") - client := &http.Client{Timeout: WITNESSGEN_TIMEOUT} + timeout := time.Duration(l.Cfg.WitnessGenTimeout) * time.Second + client := &http.Client{Timeout: timeout} resp, err := client.Do(req) if err != nil { if netErr, ok := err.(net.Error); ok && netErr.Timeout() { l.Log.Error("Witness generation request timed out", "err", err) l.Metr.RecordWitnessGenFailure("Timeout") - return nil, fmt.Errorf("request timed out after %s: %w", WITNESSGEN_TIMEOUT, err) + return nil, fmt.Errorf("request timed out after %s: %w", timeout, err) } return nil, fmt.Errorf("failed to send request: %w", err) } diff --git a/proposer/op/proposer/service.go b/proposer/op/proposer/service.go index 6da74b92..837cd784 100644 --- a/proposer/op/proposer/service.go +++ b/proposer/op/proposer/service.go @@ -60,6 +60,7 @@ type ProposerConfig struct { TxCacheOutDir string MaxBlockRangePerSpanProof uint64 MaxConcurrentWitnessGen uint64 + WitnessGenTimeout uint64 L2ChainID uint64 ProofTimeout uint64 OPSuccinctServerUrl string @@ -124,6 +125,7 @@ func (ps *ProposerService) initFromCLIConfig(ctx context.Context, version string ps.TxCacheOutDir = cfg.TxCacheOutDir ps.MaxBlockRangePerSpanProof = cfg.MaxBlockRangePerSpanProof ps.MaxConcurrentWitnessGen = cfg.MaxConcurrentWitnessGen + ps.WitnessGenTimeout = cfg.WitnessGenTimeout ps.OPSuccinctServerUrl = cfg.OPSuccinctServerUrl ps.ProofTimeout = cfg.ProofTimeout ps.L2ChainID = cfg.L2ChainID