feat: niporep: introduce SealProofVariant
This commit is contained in:
parent
13cdf4b335
commit
0da6077f4d
@ -8,6 +8,14 @@ import (
|
||||
"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 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
|
||||
// new miner actors and new sectors
|
||||
func SealProofTypeFromSectorSize(ssize abi.SectorSize, nv network.Version, synthetic bool, nonInteractive bool) (abi.RegisteredSealProof, error) {
|
||||
if nv < MinSyntheticPoRepVersion && synthetic {
|
||||
return 0, xerrors.Errorf("synthetic proofs are not supported on network version %d", nv)
|
||||
}
|
||||
if nv < MinNonInteractivePoRepVersion && nonInteractive {
|
||||
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")
|
||||
func SealProofTypeFromSectorSize(ssize abi.SectorSize, nv network.Version, variant SealProofVariant) (abi.RegisteredSealProof, error) {
|
||||
switch variant {
|
||||
case SealProofVariant_Synthetic:
|
||||
if nv < MinSyntheticPoRepVersion {
|
||||
return 0, xerrors.Errorf("synthetic proofs are not supported on network version %d", nv)
|
||||
}
|
||||
case SealProofVariant_NonInteractive:
|
||||
if nv < MinNonInteractivePoRepVersion {
|
||||
return 0, xerrors.Errorf("non-interactive proofs are not supported on network version %d", nv)
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
if synthetic {
|
||||
switch variant {
|
||||
case SealProofVariant_Synthetic:
|
||||
return toSynthetic(v)
|
||||
}
|
||||
if nonInteractive {
|
||||
case SealProofVariant_NonInteractive:
|
||||
return toNonInteractive(v)
|
||||
}
|
||||
return v, nil
|
||||
|
@ -138,7 +138,11 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sys vm.Syscal
|
||||
i := i
|
||||
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 {
|
||||
return cid.Undef, err
|
||||
}
|
||||
|
@ -338,7 +338,7 @@ var sealBenchCmd = &cli.Command{
|
||||
|
||||
if !skipc2 {
|
||||
log.Info("generating winning post candidates")
|
||||
wipt, err := spt(sectorSize, false, false).RegisteredWinningPoStProof()
|
||||
wipt, err := spt(sectorSize, miner.SealProofVariant_Standard).RegisteredWinningPoStProof()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -556,7 +556,7 @@ func runSeals(sb *ffiwrapper.Sealer, sbfs *basicfs.Provider, numSectors int, par
|
||||
Miner: mid,
|
||||
Number: i,
|
||||
},
|
||||
ProofType: spt(sectorSize, false, false),
|
||||
ProofType: spt(sectorSize, miner.SealProofVariant_Standard),
|
||||
}
|
||||
|
||||
start := time.Now()
|
||||
@ -586,7 +586,7 @@ func runSeals(sb *ffiwrapper.Sealer, sbfs *basicfs.Provider, numSectors int, par
|
||||
Miner: mid,
|
||||
Number: i,
|
||||
},
|
||||
ProofType: spt(sectorSize, false, false),
|
||||
ProofType: spt(sectorSize, miner.SealProofVariant_Standard),
|
||||
}
|
||||
|
||||
start := time.Now()
|
||||
@ -797,7 +797,7 @@ var proveCmd = &cli.Command{
|
||||
Miner: abi.ActorID(mid),
|
||||
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")
|
||||
@ -828,8 +828,8 @@ func bps(sectorSize abi.SectorSize, sectorNum int, d time.Duration) string {
|
||||
return types.SizeStr(types.BigInt{Int: bps}) + "/s"
|
||||
}
|
||||
|
||||
func spt(ssize abi.SectorSize, synth bool, ni bool) abi.RegisteredSealProof {
|
||||
spt, err := miner.SealProofTypeFromSectorSize(ssize, build.TestNetworkVersion, synth, ni)
|
||||
func spt(ssize abi.SectorSize, variant miner.SealProofVariant) abi.RegisteredSealProof {
|
||||
spt, err := miner.SealProofTypeFromSectorSize(ssize, build.TestNetworkVersion, variant)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import (
|
||||
prf "github.com/filecoin-project/specs-actors/actors/runtime/proof"
|
||||
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
||||
lcli "github.com/filecoin-project/lotus/cli"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/ffiwrapper"
|
||||
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
||||
@ -186,7 +187,7 @@ var simpleAddPiece = &cli.Command{
|
||||
Miner: mid,
|
||||
Number: 1,
|
||||
},
|
||||
ProofType: spt(sectorSize, false, false),
|
||||
ProofType: spt(sectorSize, miner.SealProofVariant_Standard),
|
||||
}
|
||||
|
||||
data, err := os.Open(cctx.Args().First())
|
||||
@ -262,12 +263,17 @@ var simplePreCommit1 = &cli.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
variant, err := variantFromArgs(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
sr := storiface.SectorRef{
|
||||
ID: abi.SectorID{
|
||||
Miner: mid,
|
||||
Number: 1,
|
||||
},
|
||||
ProofType: spt(sectorSize, cctx.Bool("synthetic"), cctx.Bool("non-interactive")),
|
||||
ProofType: spt(sectorSize, variant),
|
||||
}
|
||||
|
||||
ticket := [32]byte{}
|
||||
@ -391,12 +397,17 @@ Example invocation of lotus-bench as external executor:
|
||||
return err
|
||||
}
|
||||
|
||||
variant, err := variantFromArgs(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
sr := storiface.SectorRef{
|
||||
ID: abi.SectorID{
|
||||
Miner: mid,
|
||||
Number: 1,
|
||||
},
|
||||
ProofType: spt(sectorSize, cctx.Bool("synthetic"), cctx.Bool("non-interactive")),
|
||||
ProofType: spt(sectorSize, variant),
|
||||
}
|
||||
|
||||
start := time.Now()
|
||||
@ -465,12 +476,17 @@ var simpleCommit1 = &cli.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
variant, err := variantFromArgs(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
sr := storiface.SectorRef{
|
||||
ID: abi.SectorID{
|
||||
Miner: mid,
|
||||
Number: 1,
|
||||
},
|
||||
ProofType: spt(sectorSize, cctx.Bool("synthetic"), cctx.Bool("non-interactive")),
|
||||
ProofType: spt(sectorSize, variant),
|
||||
}
|
||||
|
||||
start := time.Now()
|
||||
@ -590,12 +606,17 @@ var simpleCommit2 = &cli.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
variant, err := variantFromArgs(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ref := storiface.SectorRef{
|
||||
ID: abi.SectorID{
|
||||
Miner: abi.ActorID(mid),
|
||||
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()
|
||||
@ -653,7 +674,7 @@ var simpleWindowPost = &cli.Command{
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
@ -673,7 +694,7 @@ var simpleWindowPost = &cli.Command{
|
||||
|
||||
vp, err := ffi.GenerateSingleVanillaProof(ffi.PrivateSectorInfo{
|
||||
SectorInfo: prf.SectorInfo{
|
||||
SealProof: spt(sectorSize, false, false),
|
||||
SealProof: spt(sectorSize, miner.SealProofVariant_Standard),
|
||||
SectorNumber: sn,
|
||||
SealedCID: commr,
|
||||
},
|
||||
@ -744,7 +765,7 @@ var simpleWinningPost = &cli.Command{
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
@ -764,7 +785,7 @@ var simpleWinningPost = &cli.Command{
|
||||
|
||||
vp, err := ffi.GenerateSingleVanillaProof(ffi.PrivateSectorInfo{
|
||||
SectorInfo: prf.SectorInfo{
|
||||
SealProof: spt(sectorSize, false, false),
|
||||
SealProof: spt(sectorSize, miner.SealProofVariant_Standard),
|
||||
SectorNumber: sn,
|
||||
SealedCID: commr,
|
||||
},
|
||||
@ -858,7 +879,7 @@ var simpleReplicaUpdate = &cli.Command{
|
||||
Miner: mid,
|
||||
Number: 1,
|
||||
},
|
||||
ProofType: spt(sectorSize, false, false),
|
||||
ProofType: spt(sectorSize, miner.SealProofVariant_Standard),
|
||||
}
|
||||
|
||||
start := time.Now()
|
||||
@ -926,7 +947,7 @@ var simpleProveReplicaUpdate1 = &cli.Command{
|
||||
Miner: mid,
|
||||
Number: 1,
|
||||
},
|
||||
ProofType: spt(sectorSize, false, false),
|
||||
ProofType: spt(sectorSize, miner.SealProofVariant_Standard),
|
||||
}
|
||||
|
||||
start := time.Now()
|
||||
@ -1013,7 +1034,7 @@ var simpleProveReplicaUpdate2 = &cli.Command{
|
||||
Miner: mid,
|
||||
Number: 1,
|
||||
},
|
||||
ProofType: spt(sectorSize, false, false),
|
||||
ProofType: spt(sectorSize, miner.SealProofVariant_Standard),
|
||||
}
|
||||
|
||||
start := time.Now()
|
||||
@ -1087,3 +1108,16 @@ func ParsePieceInfos(cctx *cli.Context, firstArg int) ([]abi.PieceInfo, error) {
|
||||
|
||||
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
|
||||
}
|
||||
|
@ -137,9 +137,8 @@ var preSealCmd = &cli.Command{
|
||||
nv = network.Version(c.Uint64("network-version"))
|
||||
}
|
||||
|
||||
var synthetic = false // there's little reason to have this for a seed.
|
||||
|
||||
spt, err := miner.SealProofTypeFromSectorSize(sectorSize, nv, synthetic)
|
||||
var variant = miner.SealProofVariant_Standard // there's little reason to have this for a seed.
|
||||
spt, err := miner.SealProofTypeFromSectorSize(sectorSize, nv, variant)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ func (n *Ensemble) MinerEnroll(minerNode *TestMiner, full *TestFullNode, opts ..
|
||||
)
|
||||
|
||||
// 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)
|
||||
|
||||
// Create the preseal commitment.
|
||||
|
@ -25,6 +25,7 @@ import (
|
||||
const DefaultPresealsPerBootstrapMiner = 2
|
||||
|
||||
const TestSpt = abi.RegisteredSealProof_StackedDrg2KiBV1_1
|
||||
const TestSptNi = abi.RegisteredSealProof_StackedDrg2KiBV1_2_Feat_NiPoRep
|
||||
|
||||
// nodeOpts is an options accumulating struct, where functional options are
|
||||
// merged into.
|
||||
|
@ -302,7 +302,7 @@ func TestMigrationNV17(t *testing.T) {
|
||||
minerInfo, err := testClient.StateMinerInfo(ctx, testMiner.ActorAddr, types.EmptyTSK)
|
||||
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)
|
||||
|
||||
preCommitParams := miner9.PreCommitSectorParams{
|
||||
|
Loading…
Reference in New Issue
Block a user