From 08038540e4d4811d702256d45e4ace08f1b3453b Mon Sep 17 00:00:00 2001 From: "Andrew Jackson (Ajax)" Date: Wed, 31 May 2023 23:03:52 -0500 Subject: [PATCH] Impl synthPoRep --- chain/actors/builtin/miner/miner.go | 3 +- chain/actors/builtin/miner/utils.go | 2 +- cmd/lotus-miner/sectors.go | 2 +- .../en/default-lotus-miner-config.toml | 8 ++++ node/config/doc_gen.go | 8 ++++ node/modules/storageminer.go | 4 +- storage/sealer/ffiwrapper/sealer_cgo.go | 39 +++++++++++++++++++ 7 files changed, 61 insertions(+), 5 deletions(-) diff --git a/chain/actors/builtin/miner/miner.go b/chain/actors/builtin/miner/miner.go index 8582f7ee5..e13ac6dd0 100644 --- a/chain/actors/builtin/miner/miner.go +++ b/chain/actors/builtin/miner/miner.go @@ -234,7 +234,7 @@ func PreferredSealProofTypeFromWindowPoStType(nver network.Version, proof abi.Re } } - if !configWantSynthetic { + if nver < network.SyntheticVersion || !configWantSynthetic { switch proof { case abi.RegisteredPoStProof_StackedDrgWindow2KiBV1, abi.RegisteredPoStProof_StackedDrgWindow2KiBV1_1: return abi.RegisteredSealProof_StackedDrg2KiBV1_1, nil @@ -250,6 +250,7 @@ func PreferredSealProofTypeFromWindowPoStType(nver network.Version, proof abi.Re return -1, xerrors.Errorf("unrecognized window post type: %d", proof) } } + switch proof { case abi.RegisteredPoStProof_StackedDrgWindow2KiBV1, abi.RegisteredPoStProof_StackedDrgWindow2KiBV1_1: return abi.RegisteredSealProof_StackedDrg2KiBV1_1_Feat_SyntheticPoRep, nil diff --git a/chain/actors/builtin/miner/utils.go b/chain/actors/builtin/miner/utils.go index 24806b320..80fbb8762 100644 --- a/chain/actors/builtin/miner/utils.go +++ b/chain/actors/builtin/miner/utils.go @@ -65,7 +65,7 @@ func SealProofTypeFromSectorSize(ssize abi.SectorSize, nv network.Version, synth return 0, xerrors.Errorf("unsupported sector size for miner: %v", ssize) } - if synthetic { + if nv >= network.SyntheticVersion && synthetic { return toSynthetic(v) } else { return v, nil diff --git a/cmd/lotus-miner/sectors.go b/cmd/lotus-miner/sectors.go index 3993ecf75..4c00aeb81 100644 --- a/cmd/lotus-miner/sectors.go +++ b/cmd/lotus-miner/sectors.go @@ -1741,7 +1741,7 @@ var sectorsCapacityCollateralCmd = &cli.Command{ return err } - spt, err := lminer.PreferredSealProofTypeFromWindowPoStType(nv, mi.WindowPoStProofType) + spt, err := lminer.PreferredSealProofTypeFromWindowPoStType(nv, mi.WindowPoStProofType, false) if err != nil { return err } diff --git a/documentation/en/default-lotus-miner-config.toml b/documentation/en/default-lotus-miner-config.toml index c0a204bf1..c32cd30ad 100644 --- a/documentation/en/default-lotus-miner-config.toml +++ b/documentation/en/default-lotus-miner-config.toml @@ -671,6 +671,14 @@ # env var: LOTUS_SEALING_TERMINATEBATCHWAIT #TerminateBatchWait = "5m0s" + # SealWithSyntheticPoRep will reduce data holdings after PC1 by storing the precomputed responses + # to any challenge. This proof's PC1 step uses a cheaper-to-compute algorithm for the responses, + # but still must do more computation during PC1 in order to create this oracle. + # + # type: bool + # env var: LOTUS_SEALING_SEALWITHSYNTHETICPOREP + #SealWithSyntheticPoRep = false + [Storage] # type: int diff --git a/node/config/doc_gen.go b/node/config/doc_gen.go index 5361b2d6c..33dc4af96 100644 --- a/node/config/doc_gen.go +++ b/node/config/doc_gen.go @@ -1265,6 +1265,14 @@ Submitting a smaller number of prove commits per epoch would reduce the possibil Comment: ``, }, + { + Name: "SealWithSyntheticPoRep", + Type: "bool", + + Comment: `SealWithSyntheticPoRep will reduce data holdings after PC1 by storing the precomputed responses +to any challenge. This proof's PC1 step uses a cheaper-to-compute algorithm for the responses, +but still must do more computation during PC1 in order to create this oracle.`, + }, }, "Splitstore": []DocField{ { diff --git a/node/modules/storageminer.go b/node/modules/storageminer.go index ee70d9322..fba916a52 100644 --- a/node/modules/storageminer.go +++ b/node/modules/storageminer.go @@ -147,7 +147,7 @@ func StorageNetworkName(ctx helpers.MetricsCtx, a v1api.FullNode) (dtypes.Networ return a.StateNetworkName(ctx) } -func SealProofType(maddr dtypes.MinerAddress, fnapi v1api.FullNode) (abi.RegisteredSealProof, error) { +func SealProofType(maddr dtypes.MinerAddress, fnapi v1api.FullNode, configSyntheticPoRep bool) (abi.RegisteredSealProof, error) { mi, err := fnapi.StateMinerInfo(context.TODO(), address.Address(maddr), types.EmptyTSK) if err != nil { return 0, err @@ -157,7 +157,7 @@ func SealProofType(maddr dtypes.MinerAddress, fnapi v1api.FullNode) (abi.Registe return 0, err } - return miner.PreferredSealProofTypeFromWindowPoStType(networkVersion, mi.WindowPoStProofType) + return miner.PreferredSealProofTypeFromWindowPoStType(networkVersion, mi.WindowPoStProofType, configSyntheticPoRep) } func AddressSelector(addrConf *config.MinerAddressConfig) func() (*ctladdr.AddressSelector, error) { diff --git a/storage/sealer/ffiwrapper/sealer_cgo.go b/storage/sealer/ffiwrapper/sealer_cgo.go index 871012d0b..a9dce73a8 100644 --- a/storage/sealer/ffiwrapper/sealer_cgo.go +++ b/storage/sealer/ffiwrapper/sealer_cgo.go @@ -859,6 +859,33 @@ func (sb *Sealer) SealPreCommit2(ctx context.Context, sector storiface.SectorRef } } + if abi.Synthetic[sector.ProofType] { + err = ffi.GenerateSynthProofs( + sector.ProofType, + sealedCID, + unsealedCID, + paths.Cache, + paths.Sealed, + sector.ID.Number, + sector.ID.Miner, ticket, + []abi.PieceInfo{{Size: abi.PaddedPieceSize(ssize), PieceCID: unsealedCID}}) + if err != nil { + log.Warn("GenerateSynthProofs() failed: ", err) + log.Warnf("num:%d tkt:%v seed:%v sealedCID:%v, unsealedCID:%v", sector.ID.Number, ticket, sealedCID, unsealedCID) + return storiface.SectorCids{}, xerrors.Errorf("checking PreCommit failed: %w", err) + } + + if err = ffi.ClearLayerData(ssize, paths.Cache); err != nil { + log.Warn("failed to GenerateSynthProofs(): ", err) + log.Warnf("num:%d tkt:%v seed:%v sealedCID:%v, unsealedCID:%v", sector.ID.Number, ticket, sealedCID, unsealedCID) + return storiface.SectorCids{ + Unsealed: unsealedCID, + Sealed: sealedCID, + }, nil + // Note: non-fatal error. + } + } + return storiface.SectorCids{ Unsealed: unsealedCID, Sealed: sealedCID, @@ -889,6 +916,18 @@ func (sb *Sealer) SealCommit1(ctx context.Context, sector storiface.SectorRef, t return nil, xerrors.Errorf("StandaloneSealCommit: %w", err) } + + ssize, err := sector.ProofType.SectorSize() + if err != nil { + log.Warn("Unable to delete Synth cache: Could not read sector size:", err) + return output, nil // Non-fatal error. + } + + ffi.ClearCache(uint64(ssize), paths.Cache) + if err != nil { + log.Warn("Unable to delete Synth cache:", err) + return output, nil // Non-fatal error. + } return output, nil }