From b4b38788efcddceb87ee1677a5aa53a8380f2e6e Mon Sep 17 00:00:00 2001 From: whyrusleeping Date: Thu, 13 May 2021 11:00:42 -0700 Subject: [PATCH] add flags to control gateway lookback parameters --- cmd/lotus-gateway/main.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/cmd/lotus-gateway/main.go b/cmd/lotus-gateway/main.go index e2ef27dd9..60f45f283 100644 --- a/cmd/lotus-gateway/main.go +++ b/cmd/lotus-gateway/main.go @@ -8,6 +8,7 @@ import ( "contrib.go.opencensus.io/exporter/prometheus" "github.com/filecoin-project/go-jsonrpc" + "github.com/filecoin-project/go-state-types/abi" promclient "github.com/prometheus/client_golang/prometheus" "go.opencensus.io/tag" @@ -70,6 +71,16 @@ var runCmd = &cli.Command{ Name: "api-max-req-size", Usage: "maximum API request size accepted by the JSON RPC server", }, + &cli.DurationFlag{ + Name: "api-max-lookback", + Usage: "maximum duration allowable for tipset lookbacks", + Value: LookbackCap, + }, + &cli.Int64Flag{ + Name: "api-wait-lookback-limit", + Usage: "maximum number of blocks to search back through for message inclusion", + Value: int64(StateWaitLookbackLimit), + }, }, Action: func(cctx *cli.Context) error { log.Info("Starting lotus gateway") @@ -107,7 +118,11 @@ var runCmd = &cli.Command{ mux.Handle(path, rpcServer) } - ma := metrics.MetricedGatewayAPI(NewGatewayAPI(api)) + lookbackCap := cctx.Duration("api-max-lookback") + + waitLookback := abi.ChainEpoch(cctx.Int64("api-wait-lookback-limit")) + + ma := metrics.MetricedGatewayAPI(newGatewayAPI(api, lookbackCap, waitLookback)) serveRpc("/rpc/v1", ma) serveRpc("/rpc/v0", lapi.Wrap(new(v1api.FullNodeStruct), new(v0api.WrapperV1Full), ma))