From 2f38c67fd507eb2ff269a75cfb34e40233bc6b46 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Wed, 6 Nov 2024 14:55:10 +0700 Subject: [PATCH] feat(f3): allow to disable f3 passive testing using `LOTUS_DISABLE_F3_PASSIVE_TESTING=1` Signed-off-by: Jakub Sztandera --- build/params_shared_funcs.go | 21 +++++++++++++++++++++ chain/lf3/manifest.go | 3 ++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/build/params_shared_funcs.go b/build/params_shared_funcs.go index a0981cf4782..05dbe7817fa 100644 --- a/build/params_shared_funcs.go +++ b/build/params_shared_funcs.go @@ -55,3 +55,24 @@ func IsF3Enabled() bool { return false } } + +func IsF3PassiveTestingEnabled() bool { + if !IsF3Enabled() { + return false + } + const F3DisablePassiveTesting = "LOTUS_DISABLE_F3_PASSIVE_TESTING" + + v, disableEnvVarSet := os.LookupEnv(F3DisablePassiveTesting) + if !disableEnvVarSet { + // Environment variable to disable F3 passive testing is not set. + return true + } + switch strings.TrimSpace(strings.ToLower(v)) { + case "", "0", "false", "no": + // Consider these values as "do not disable". + return true + default: + // Consider any other value as disable. + return false + } +} diff --git a/chain/lf3/manifest.go b/chain/lf3/manifest.go index 2b64cc4b224..b242edb371d 100644 --- a/chain/lf3/manifest.go +++ b/chain/lf3/manifest.go @@ -13,6 +13,7 @@ import ( "github.com/filecoin-project/go-f3/ec" "github.com/filecoin-project/go-f3/manifest" + "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/node/modules/dtypes" "github.com/filecoin-project/lotus/node/modules/helpers" @@ -35,7 +36,7 @@ func (hg *headGetter) GetHead(context.Context) (ec.TipSet, error) { var MaxDynamicManifestChangesAllowed = 1000 func NewManifestProvider(mctx helpers.MetricsCtx, config *Config, cs *store.ChainStore, ps *pubsub.PubSub, mds dtypes.MetadataDS) (prov manifest.ManifestProvider, err error) { - if config.DynamicManifestProvider == "" { + if config.DynamicManifestProvider == "" || !build.IsF3PassiveTestingEnabled() { if config.StaticManifest == nil { return manifest.NoopManifestProvider{}, nil }