feat: niporep: introduce SealProofVariant

This commit is contained in:
Rod Vagg 2024-05-29 11:37:17 +10:00
parent 13cdf4b335
commit 0da6077f4d
8 changed files with 83 additions and 36 deletions

View File

@ -8,6 +8,14 @@ import (
"github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/go-state-types/network"
) )
type SealProofVariant int
const (
SealProofVariant_Standard SealProofVariant = iota
SealProofVariant_Synthetic
SealProofVariant_NonInteractive
)
var MinSyntheticPoRepVersion = network.Version21 var MinSyntheticPoRepVersion = network.Version21
var MinNonInteractivePoRepVersion = network.Version23 var MinNonInteractivePoRepVersion = network.Version23
@ -34,15 +42,16 @@ func AllPartSectors(mas State, sget func(Partition) (bitfield.BitField, error))
// SealProofTypeFromSectorSize returns preferred seal proof type for creating // SealProofTypeFromSectorSize returns preferred seal proof type for creating
// new miner actors and new sectors // new miner actors and new sectors
func SealProofTypeFromSectorSize(ssize abi.SectorSize, nv network.Version, synthetic bool, nonInteractive bool) (abi.RegisteredSealProof, error) { func SealProofTypeFromSectorSize(ssize abi.SectorSize, nv network.Version, variant SealProofVariant) (abi.RegisteredSealProof, error) {
if nv < MinSyntheticPoRepVersion && synthetic { switch variant {
case SealProofVariant_Synthetic:
if nv < MinSyntheticPoRepVersion {
return 0, xerrors.Errorf("synthetic proofs are not supported on network version %d", nv) return 0, xerrors.Errorf("synthetic proofs are not supported on network version %d", nv)
} }
if nv < MinNonInteractivePoRepVersion && nonInteractive { case SealProofVariant_NonInteractive:
if nv < MinNonInteractivePoRepVersion {
return 0, xerrors.Errorf("non-interactive proofs are not supported on network version %d", nv) return 0, xerrors.Errorf("non-interactive proofs are not supported on network version %d", nv)
} }
if synthetic && nonInteractive {
return 0, xerrors.Errorf("synthetic and non-interactive proofs are mutually exclusive")
} }
switch { switch {
@ -78,10 +87,10 @@ func SealProofTypeFromSectorSize(ssize abi.SectorSize, nv network.Version, synth
return 0, xerrors.Errorf("unsupported sector size for miner: %v", ssize) return 0, xerrors.Errorf("unsupported sector size for miner: %v", ssize)
} }
if synthetic { switch variant {
case SealProofVariant_Synthetic:
return toSynthetic(v) return toSynthetic(v)
} case SealProofVariant_NonInteractive:
if nonInteractive {
return toNonInteractive(v) return toNonInteractive(v)
} }
return v, nil return v, nil

View File

@ -138,7 +138,11 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sys vm.Syscal
i := i i := i
m := m m := m
spt, err := miner.SealProofTypeFromSectorSize(m.SectorSize, nv, synthetic) variant := miner.SealProofVariant_Standard
if synthetic {
variant = miner.SealProofVariant_Synthetic
}
spt, err := miner.SealProofTypeFromSectorSize(m.SectorSize, nv, variant)
if err != nil { if err != nil {
return cid.Undef, err return cid.Undef, err
} }

View File

@ -338,7 +338,7 @@ var sealBenchCmd = &cli.Command{
if !skipc2 { if !skipc2 {
log.Info("generating winning post candidates") log.Info("generating winning post candidates")
wipt, err := spt(sectorSize, false, false).RegisteredWinningPoStProof() wipt, err := spt(sectorSize, miner.SealProofVariant_Standard).RegisteredWinningPoStProof()
if err != nil { if err != nil {
return err return err
} }
@ -556,7 +556,7 @@ func runSeals(sb *ffiwrapper.Sealer, sbfs *basicfs.Provider, numSectors int, par
Miner: mid, Miner: mid,
Number: i, Number: i,
}, },
ProofType: spt(sectorSize, false, false), ProofType: spt(sectorSize, miner.SealProofVariant_Standard),
} }
start := time.Now() start := time.Now()
@ -586,7 +586,7 @@ func runSeals(sb *ffiwrapper.Sealer, sbfs *basicfs.Provider, numSectors int, par
Miner: mid, Miner: mid,
Number: i, Number: i,
}, },
ProofType: spt(sectorSize, false, false), ProofType: spt(sectorSize, miner.SealProofVariant_Standard),
} }
start := time.Now() start := time.Now()
@ -797,7 +797,7 @@ var proveCmd = &cli.Command{
Miner: abi.ActorID(mid), Miner: abi.ActorID(mid),
Number: abi.SectorNumber(c2in.SectorNum), Number: abi.SectorNumber(c2in.SectorNum),
}, },
ProofType: spt(abi.SectorSize(c2in.SectorSize), false, false), ProofType: spt(abi.SectorSize(c2in.SectorSize), miner.SealProofVariant_Standard),
} }
fmt.Printf("----\nstart proof computation\n") fmt.Printf("----\nstart proof computation\n")
@ -828,8 +828,8 @@ func bps(sectorSize abi.SectorSize, sectorNum int, d time.Duration) string {
return types.SizeStr(types.BigInt{Int: bps}) + "/s" return types.SizeStr(types.BigInt{Int: bps}) + "/s"
} }
func spt(ssize abi.SectorSize, synth bool, ni bool) abi.RegisteredSealProof { func spt(ssize abi.SectorSize, variant miner.SealProofVariant) abi.RegisteredSealProof {
spt, err := miner.SealProofTypeFromSectorSize(ssize, build.TestNetworkVersion, synth, ni) spt, err := miner.SealProofTypeFromSectorSize(ssize, build.TestNetworkVersion, variant)
if err != nil { if err != nil {
panic(err) panic(err)
} }

View File

@ -21,6 +21,7 @@ import (
prf "github.com/filecoin-project/specs-actors/actors/runtime/proof" prf "github.com/filecoin-project/specs-actors/actors/runtime/proof"
"github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
lcli "github.com/filecoin-project/lotus/cli" lcli "github.com/filecoin-project/lotus/cli"
"github.com/filecoin-project/lotus/storage/sealer/ffiwrapper" "github.com/filecoin-project/lotus/storage/sealer/ffiwrapper"
"github.com/filecoin-project/lotus/storage/sealer/storiface" "github.com/filecoin-project/lotus/storage/sealer/storiface"
@ -186,7 +187,7 @@ var simpleAddPiece = &cli.Command{
Miner: mid, Miner: mid,
Number: 1, Number: 1,
}, },
ProofType: spt(sectorSize, false, false), ProofType: spt(sectorSize, miner.SealProofVariant_Standard),
} }
data, err := os.Open(cctx.Args().First()) data, err := os.Open(cctx.Args().First())
@ -262,12 +263,17 @@ var simplePreCommit1 = &cli.Command{
return err return err
} }
variant, err := variantFromArgs(cctx)
if err != nil {
return err
}
sr := storiface.SectorRef{ sr := storiface.SectorRef{
ID: abi.SectorID{ ID: abi.SectorID{
Miner: mid, Miner: mid,
Number: 1, Number: 1,
}, },
ProofType: spt(sectorSize, cctx.Bool("synthetic"), cctx.Bool("non-interactive")), ProofType: spt(sectorSize, variant),
} }
ticket := [32]byte{} ticket := [32]byte{}
@ -391,12 +397,17 @@ Example invocation of lotus-bench as external executor:
return err return err
} }
variant, err := variantFromArgs(cctx)
if err != nil {
return err
}
sr := storiface.SectorRef{ sr := storiface.SectorRef{
ID: abi.SectorID{ ID: abi.SectorID{
Miner: mid, Miner: mid,
Number: 1, Number: 1,
}, },
ProofType: spt(sectorSize, cctx.Bool("synthetic"), cctx.Bool("non-interactive")), ProofType: spt(sectorSize, variant),
} }
start := time.Now() start := time.Now()
@ -465,12 +476,17 @@ var simpleCommit1 = &cli.Command{
return err return err
} }
variant, err := variantFromArgs(cctx)
if err != nil {
return err
}
sr := storiface.SectorRef{ sr := storiface.SectorRef{
ID: abi.SectorID{ ID: abi.SectorID{
Miner: mid, Miner: mid,
Number: 1, Number: 1,
}, },
ProofType: spt(sectorSize, cctx.Bool("synthetic"), cctx.Bool("non-interactive")), ProofType: spt(sectorSize, variant),
} }
start := time.Now() start := time.Now()
@ -590,12 +606,17 @@ var simpleCommit2 = &cli.Command{
return err return err
} }
variant, err := variantFromArgs(c)
if err != nil {
return err
}
ref := storiface.SectorRef{ ref := storiface.SectorRef{
ID: abi.SectorID{ ID: abi.SectorID{
Miner: abi.ActorID(mid), Miner: abi.ActorID(mid),
Number: abi.SectorNumber(c2in.SectorNum), Number: abi.SectorNumber(c2in.SectorNum),
}, },
ProofType: spt(abi.SectorSize(c2in.SectorSize), c.Bool("synthetic"), c.Bool("non-interactive")), ProofType: spt(abi.SectorSize(c2in.SectorSize), variant),
} }
start := time.Now() start := time.Now()
@ -653,7 +674,7 @@ var simpleWindowPost = &cli.Command{
return xerrors.Errorf("parse commr: %w", err) return xerrors.Errorf("parse commr: %w", err)
} }
wpt, err := spt(sectorSize, false, false).RegisteredWindowPoStProof() wpt, err := spt(sectorSize, miner.SealProofVariant_Standard).RegisteredWindowPoStProof()
if err != nil { if err != nil {
return err return err
} }
@ -673,7 +694,7 @@ var simpleWindowPost = &cli.Command{
vp, err := ffi.GenerateSingleVanillaProof(ffi.PrivateSectorInfo{ vp, err := ffi.GenerateSingleVanillaProof(ffi.PrivateSectorInfo{
SectorInfo: prf.SectorInfo{ SectorInfo: prf.SectorInfo{
SealProof: spt(sectorSize, false, false), SealProof: spt(sectorSize, miner.SealProofVariant_Standard),
SectorNumber: sn, SectorNumber: sn,
SealedCID: commr, SealedCID: commr,
}, },
@ -744,7 +765,7 @@ var simpleWinningPost = &cli.Command{
return xerrors.Errorf("parse commr: %w", err) return xerrors.Errorf("parse commr: %w", err)
} }
wpt, err := spt(sectorSize, false, false).RegisteredWinningPoStProof() wpt, err := spt(sectorSize, miner.SealProofVariant_Standard).RegisteredWinningPoStProof()
if err != nil { if err != nil {
return err return err
} }
@ -764,7 +785,7 @@ var simpleWinningPost = &cli.Command{
vp, err := ffi.GenerateSingleVanillaProof(ffi.PrivateSectorInfo{ vp, err := ffi.GenerateSingleVanillaProof(ffi.PrivateSectorInfo{
SectorInfo: prf.SectorInfo{ SectorInfo: prf.SectorInfo{
SealProof: spt(sectorSize, false, false), SealProof: spt(sectorSize, miner.SealProofVariant_Standard),
SectorNumber: sn, SectorNumber: sn,
SealedCID: commr, SealedCID: commr,
}, },
@ -858,7 +879,7 @@ var simpleReplicaUpdate = &cli.Command{
Miner: mid, Miner: mid,
Number: 1, Number: 1,
}, },
ProofType: spt(sectorSize, false, false), ProofType: spt(sectorSize, miner.SealProofVariant_Standard),
} }
start := time.Now() start := time.Now()
@ -926,7 +947,7 @@ var simpleProveReplicaUpdate1 = &cli.Command{
Miner: mid, Miner: mid,
Number: 1, Number: 1,
}, },
ProofType: spt(sectorSize, false, false), ProofType: spt(sectorSize, miner.SealProofVariant_Standard),
} }
start := time.Now() start := time.Now()
@ -1013,7 +1034,7 @@ var simpleProveReplicaUpdate2 = &cli.Command{
Miner: mid, Miner: mid,
Number: 1, Number: 1,
}, },
ProofType: spt(sectorSize, false, false), ProofType: spt(sectorSize, miner.SealProofVariant_Standard),
} }
start := time.Now() start := time.Now()
@ -1087,3 +1108,16 @@ func ParsePieceInfos(cctx *cli.Context, firstArg int) ([]abi.PieceInfo, error) {
return out, nil return out, nil
} }
func variantFromArgs(cctx *cli.Context) (miner.SealProofVariant, error) {
variant := miner.SealProofVariant_Standard
if cctx.Bool("synthetic") {
if cctx.Bool("non-interactive") {
return variant, xerrors.Errorf("can't use both synthetic and non-interactive")
}
variant = miner.SealProofVariant_Synthetic
} else if cctx.Bool("non-interactive") {
variant = miner.SealProofVariant_NonInteractive
}
return variant, nil
}

View File

@ -137,9 +137,8 @@ var preSealCmd = &cli.Command{
nv = network.Version(c.Uint64("network-version")) nv = network.Version(c.Uint64("network-version"))
} }
var synthetic = false // there's little reason to have this for a seed. var variant = miner.SealProofVariant_Standard // there's little reason to have this for a seed.
spt, err := miner.SealProofTypeFromSectorSize(sectorSize, nv, variant)
spt, err := miner.SealProofTypeFromSectorSize(sectorSize, nv, synthetic)
if err != nil { if err != nil {
return err return err
} }

View File

@ -260,7 +260,7 @@ func (n *Ensemble) MinerEnroll(minerNode *TestMiner, full *TestFullNode, opts ..
) )
// Will use 2KiB sectors by default (default value of sectorSize). // Will use 2KiB sectors by default (default value of sectorSize).
proofType, err := miner.SealProofTypeFromSectorSize(options.sectorSize, n.genesis.version, false) proofType, err := miner.SealProofTypeFromSectorSize(options.sectorSize, n.genesis.version, miner.SealProofVariant_Standard)
require.NoError(n.t, err) require.NoError(n.t, err)
// Create the preseal commitment. // Create the preseal commitment.

View File

@ -25,6 +25,7 @@ import (
const DefaultPresealsPerBootstrapMiner = 2 const DefaultPresealsPerBootstrapMiner = 2
const TestSpt = abi.RegisteredSealProof_StackedDrg2KiBV1_1 const TestSpt = abi.RegisteredSealProof_StackedDrg2KiBV1_1
const TestSptNi = abi.RegisteredSealProof_StackedDrg2KiBV1_2_Feat_NiPoRep
// nodeOpts is an options accumulating struct, where functional options are // nodeOpts is an options accumulating struct, where functional options are
// merged into. // merged into.

View File

@ -302,7 +302,7 @@ func TestMigrationNV17(t *testing.T) {
minerInfo, err := testClient.StateMinerInfo(ctx, testMiner.ActorAddr, types.EmptyTSK) minerInfo, err := testClient.StateMinerInfo(ctx, testMiner.ActorAddr, types.EmptyTSK)
require.NoError(t, err) require.NoError(t, err)
spt, err := miner.SealProofTypeFromSectorSize(minerInfo.SectorSize, network.Version17, false) spt, err := miner.SealProofTypeFromSectorSize(minerInfo.SectorSize, network.Version17, miner.SealProofVariant_Standard)
require.NoError(t, err) require.NoError(t, err)
preCommitParams := miner9.PreCommitSectorParams{ preCommitParams := miner9.PreCommitSectorParams{