From d240b1219637ad4d3fd3f6218d12b07e994c97b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Thu, 29 Sep 2022 12:08:05 +0000 Subject: [PATCH] feat: miner paramfetch: Don't fetch param files when not needed --- node/builder_miner.go | 7 ++++--- node/modules/storageminer.go | 37 +++++++++++++++++++++--------------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/node/builder_miner.go b/node/builder_miner.go index a3eb9a7ec..cd7b4ec8d 100644 --- a/node/builder_miner.go +++ b/node/builder_miner.go @@ -94,6 +94,10 @@ func ConfigStorageMiner(c interface{}) Option { Override(new(paths.Store), From(new(*paths.Remote))), Override(new(dtypes.RetrievalPricingFunc), modules.RetrievalPricingFunc(cfg.Dealmaking)), + If(cfg.Subsystems.EnableMining || cfg.Subsystems.EnableSealing, + Override(GetParamsKey, modules.GetParams(!cfg.Proving.DisableBuiltinWindowPoSt || !cfg.Proving.DisableBuiltinWinningPoSt || cfg.Storage.AllowCommit || cfg.Storage.AllowProveReplicaUpdate2)), + ), + If(!cfg.Subsystems.EnableMining, If(cfg.Subsystems.EnableSealing, Error(xerrors.Errorf("sealing can only be enabled on a mining node"))), If(cfg.Subsystems.EnableSectorStorage, Error(xerrors.Errorf("sealing can only be enabled on a mining node"))), @@ -107,9 +111,6 @@ func ConfigStorageMiner(c interface{}) Option { Override(new(storiface.Prover), ffiwrapper.ProofProver), Override(new(storiface.ProverPoSt), From(new(sectorstorage.SectorManager))), - // Sealing (todo should be under EnableSealing, but storagefsm is currently bundled with storage.Miner) - Override(GetParamsKey, modules.GetParams), - Override(new(dtypes.SetSealingConfigFunc), modules.NewSetSealConfigFunc), Override(new(dtypes.GetSealingConfigFunc), modules.NewGetSealConfigFunc), diff --git a/node/modules/storageminer.go b/node/modules/storageminer.go index 0d85cd168..4497271ed 100644 --- a/node/modules/storageminer.go +++ b/node/modules/storageminer.go @@ -110,24 +110,31 @@ func minerAddrFromDS(ds dtypes.MetadataDS) (address.Address, error) { return address.NewFromBytes(maddrb) } -func GetParams(spt abi.RegisteredSealProof) error { - ssize, err := spt.SectorSize() - if err != nil { - return err - } +func GetParams(prover bool) func(spt abi.RegisteredSealProof) error { + return func(spt abi.RegisteredSealProof) error { + ssize, err := spt.SectorSize() + if err != nil { + return err + } + + // If built-in assets are disabled, we expect the user to have placed the right + // parameters in the right location on the filesystem (/var/tmp/filecoin-proof-parameters). + if build.DisableBuiltinAssets { + return nil + } + + var provingSize uint64 + if prover { + provingSize = uint64(ssize) + } + + // TODO: We should fetch the params for the actual proof type, not just based on the size. + if err := paramfetch.GetParams(context.TODO(), build.ParametersJSON(), build.SrsJSON(), provingSize); err != nil { + return xerrors.Errorf("fetching proof parameters: %w", err) + } - // If built-in assets are disabled, we expect the user to have placed the right - // parameters in the right location on the filesystem (/var/tmp/filecoin-proof-parameters). - if build.DisableBuiltinAssets { return nil } - - // TODO: We should fetch the params for the actual proof type, not just based on the size. - if err := paramfetch.GetParams(context.TODO(), build.ParametersJSON(), build.SrsJSON(), uint64(ssize)); err != nil { - return xerrors.Errorf("fetching proof parameters: %w", err) - } - - return nil } func MinerAddress(ds dtypes.MetadataDS) (dtypes.MinerAddress, error) {