feat!: ni-porep for lotus-bench

This commit is contained in:
Rod Vagg 2024-05-28 18:37:02 +10:00
parent d9195c464b
commit 13cdf4b335
3 changed files with 75 additions and 29 deletions

View File

@ -9,6 +9,7 @@ import (
) )
var MinSyntheticPoRepVersion = network.Version21 var MinSyntheticPoRepVersion = network.Version21
var MinNonInteractivePoRepVersion = network.Version23
func AllPartSectors(mas State, sget func(Partition) (bitfield.BitField, error)) (bitfield.BitField, error) { func AllPartSectors(mas State, sget func(Partition) (bitfield.BitField, error)) (bitfield.BitField, error) {
var parts []bitfield.BitField var parts []bitfield.BitField
@ -33,7 +34,17 @@ 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) (abi.RegisteredSealProof, error) { 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")
}
switch { switch {
case nv < network.Version7: case nv < network.Version7:
switch ssize { switch ssize {
@ -67,11 +78,13 @@ 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 nv >= MinSyntheticPoRepVersion && synthetic { if synthetic {
return toSynthetic(v) return toSynthetic(v)
} else {
return v, nil
} }
if nonInteractive {
return toNonInteractive(v)
}
return v, nil
} }
return 0, xerrors.Errorf("unsupported network version") return 0, xerrors.Errorf("unsupported network version")
@ -94,6 +107,23 @@ func toSynthetic(in abi.RegisteredSealProof) (abi.RegisteredSealProof, error) {
} }
} }
func toNonInteractive(in abi.RegisteredSealProof) (abi.RegisteredSealProof, error) {
switch in {
case abi.RegisteredSealProof_StackedDrg2KiBV1_1:
return abi.RegisteredSealProof_StackedDrg2KiBV1_2_Feat_NiPoRep, nil
case abi.RegisteredSealProof_StackedDrg8MiBV1_1:
return abi.RegisteredSealProof_StackedDrg8MiBV1_2_Feat_NiPoRep, nil
case abi.RegisteredSealProof_StackedDrg512MiBV1_1:
return abi.RegisteredSealProof_StackedDrg512MiBV1_2_Feat_NiPoRep, nil
case abi.RegisteredSealProof_StackedDrg32GiBV1_1:
return abi.RegisteredSealProof_StackedDrg32GiBV1_2_Feat_NiPoRep, nil
case abi.RegisteredSealProof_StackedDrg64GiBV1_1:
return abi.RegisteredSealProof_StackedDrg64GiBV1_2_Feat_NiPoRep, nil
default:
return 0, xerrors.Errorf("unsupported conversion to non-interactive: %v", in)
}
}
// WindowPoStProofTypeFromSectorSize returns preferred post proof type for creating // WindowPoStProofTypeFromSectorSize returns preferred post proof type for creating
// new miner actors and new sectors // new miner actors and new sectors
func WindowPoStProofTypeFromSectorSize(ssize abi.SectorSize, nv network.Version) (abi.RegisteredPoStProof, error) { func WindowPoStProofTypeFromSectorSize(ssize abi.SectorSize, nv network.Version) (abi.RegisteredPoStProof, error) {

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).RegisteredWinningPoStProof() wipt, err := spt(sectorSize, false, false).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), ProofType: spt(sectorSize, false, false),
} }
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), ProofType: spt(sectorSize, false, false),
} }
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), ProofType: spt(abi.SectorSize(c2in.SectorSize), false, false),
} }
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) abi.RegisteredSealProof { func spt(ssize abi.SectorSize, synth bool, ni bool) abi.RegisteredSealProof {
spt, err := miner.SealProofTypeFromSectorSize(ssize, build.TestNetworkVersion, synth) spt, err := miner.SealProofTypeFromSectorSize(ssize, build.TestNetworkVersion, synth, ni)
if err != nil { if err != nil {
panic(err) panic(err)
} }

View File

@ -186,7 +186,7 @@ var simpleAddPiece = &cli.Command{
Miner: mid, Miner: mid,
Number: 1, Number: 1,
}, },
ProofType: spt(sectorSize, false), ProofType: spt(sectorSize, false, false),
} }
data, err := os.Open(cctx.Args().First()) data, err := os.Open(cctx.Args().First())
@ -201,7 +201,7 @@ var simpleAddPiece = &cli.Command{
return xerrors.Errorf("add piece: %w", err) return xerrors.Errorf("add piece: %w", err)
} }
took := time.Now().Sub(start) took := time.Since(start)
fmt.Printf("AddPiece %s (%s)\n", took, bps(abi.SectorSize(pi.Size), 1, took)) fmt.Printf("AddPiece %s (%s)\n", took, bps(abi.SectorSize(pi.Size), 1, took))
fmt.Printf("%s %d\n", pi.PieceCID, pi.Size) fmt.Printf("%s %d\n", pi.PieceCID, pi.Size)
@ -227,6 +227,10 @@ var simplePreCommit1 = &cli.Command{
Name: "synthetic", Name: "synthetic",
Usage: "generate synthetic PoRep proofs", Usage: "generate synthetic PoRep proofs",
}, },
&cli.BoolFlag{
Name: "non-interactive",
Usage: "generate NI-PoRep proofs",
},
}, },
ArgsUsage: "[unsealed] [sealed] [cache] [[piece cid] [piece size]]...", ArgsUsage: "[unsealed] [sealed] [cache] [[piece cid] [piece size]]...",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
@ -263,7 +267,7 @@ var simplePreCommit1 = &cli.Command{
Miner: mid, Miner: mid,
Number: 1, Number: 1,
}, },
ProofType: spt(sectorSize, cctx.Bool("synthetic")), ProofType: spt(sectorSize, cctx.Bool("synthetic"), cctx.Bool("non-interactive")),
} }
ticket := [32]byte{} ticket := [32]byte{}
@ -283,7 +287,7 @@ var simplePreCommit1 = &cli.Command{
return xerrors.Errorf("precommit1: %w", err) return xerrors.Errorf("precommit1: %w", err)
} }
took := time.Now().Sub(start) took := time.Since(start)
fmt.Printf("PreCommit1 %s (%s)\n", took, bps(sectorSize, 1, took)) fmt.Printf("PreCommit1 %s (%s)\n", took, bps(sectorSize, 1, took))
fmt.Println(base64.StdEncoding.EncodeToString(p1o)) fmt.Println(base64.StdEncoding.EncodeToString(p1o))
@ -308,6 +312,10 @@ var simplePreCommit2 = &cli.Command{
Name: "synthetic", Name: "synthetic",
Usage: "generate synthetic PoRep proofs", Usage: "generate synthetic PoRep proofs",
}, },
&cli.BoolFlag{
Name: "non-interactive",
Usage: "generate NI-PoRep proofs",
},
&cli.StringFlag{ &cli.StringFlag{
Name: "external-pc2", Name: "external-pc2",
Usage: "command for computing PC2 externally", Usage: "command for computing PC2 externally",
@ -388,7 +396,7 @@ Example invocation of lotus-bench as external executor:
Miner: mid, Miner: mid,
Number: 1, Number: 1,
}, },
ProofType: spt(sectorSize, cctx.Bool("synthetic")), ProofType: spt(sectorSize, cctx.Bool("synthetic"), cctx.Bool("non-interactive")),
} }
start := time.Now() start := time.Now()
@ -398,7 +406,7 @@ Example invocation of lotus-bench as external executor:
return xerrors.Errorf("precommit2: %w", err) return xerrors.Errorf("precommit2: %w", err)
} }
took := time.Now().Sub(start) took := time.Since(start)
fmt.Printf("PreCommit2 %s (%s)\n", took, bps(sectorSize, 1, took)) fmt.Printf("PreCommit2 %s (%s)\n", took, bps(sectorSize, 1, took))
fmt.Printf("d:%s r:%s\n", p2o.Unsealed, p2o.Sealed) fmt.Printf("d:%s r:%s\n", p2o.Unsealed, p2o.Sealed)
@ -423,6 +431,10 @@ var simpleCommit1 = &cli.Command{
Name: "synthetic", Name: "synthetic",
Usage: "generate synthetic PoRep proofs", Usage: "generate synthetic PoRep proofs",
}, },
&cli.BoolFlag{
Name: "non-interactive",
Usage: "generate NI-PoRep proofs",
},
}, },
ArgsUsage: "[sealed] [cache] [comm D] [comm R] [c1out.json]", ArgsUsage: "[sealed] [cache] [comm D] [comm R] [c1out.json]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
@ -458,7 +470,7 @@ var simpleCommit1 = &cli.Command{
Miner: mid, Miner: mid,
Number: 1, Number: 1,
}, },
ProofType: spt(sectorSize, cctx.Bool("synthetic")), ProofType: spt(sectorSize, cctx.Bool("synthetic"), cctx.Bool("non-interactive")),
} }
start := time.Now() start := time.Now()
@ -493,7 +505,7 @@ var simpleCommit1 = &cli.Command{
return xerrors.Errorf("commit1: %w", err) return xerrors.Errorf("commit1: %w", err)
} }
took := time.Now().Sub(start) took := time.Since(start)
fmt.Printf("Commit1 %s (%s)\n", took, bps(sectorSize, 1, took)) fmt.Printf("Commit1 %s (%s)\n", took, bps(sectorSize, 1, took))
@ -533,6 +545,10 @@ var simpleCommit2 = &cli.Command{
Name: "synthetic", Name: "synthetic",
Usage: "generate synthetic PoRep proofs", Usage: "generate synthetic PoRep proofs",
}, },
&cli.BoolFlag{
Name: "non-interactive",
Usage: "generate NI-PoRep proofs",
},
}, },
Action: func(c *cli.Context) error { Action: func(c *cli.Context) error {
if c.Bool("no-gpu") { if c.Bool("no-gpu") {
@ -579,7 +595,7 @@ var simpleCommit2 = &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), c.Bool("synthetic")), ProofType: spt(abi.SectorSize(c2in.SectorSize), c.Bool("synthetic"), c.Bool("non-interactive")),
} }
start := time.Now() start := time.Now()
@ -637,7 +653,7 @@ var simpleWindowPost = &cli.Command{
return xerrors.Errorf("parse commr: %w", err) return xerrors.Errorf("parse commr: %w", err)
} }
wpt, err := spt(sectorSize, false).RegisteredWindowPoStProof() wpt, err := spt(sectorSize, false, false).RegisteredWindowPoStProof()
if err != nil { if err != nil {
return err return err
} }
@ -657,7 +673,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), SealProof: spt(sectorSize, false, false),
SectorNumber: sn, SectorNumber: sn,
SealedCID: commr, SealedCID: commr,
}, },
@ -728,7 +744,7 @@ var simpleWinningPost = &cli.Command{
return xerrors.Errorf("parse commr: %w", err) return xerrors.Errorf("parse commr: %w", err)
} }
wpt, err := spt(sectorSize, false).RegisteredWinningPoStProof() wpt, err := spt(sectorSize, false, false).RegisteredWinningPoStProof()
if err != nil { if err != nil {
return err return err
} }
@ -748,7 +764,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), SealProof: spt(sectorSize, false, false),
SectorNumber: sn, SectorNumber: sn,
SealedCID: commr, SealedCID: commr,
}, },
@ -842,7 +858,7 @@ var simpleReplicaUpdate = &cli.Command{
Miner: mid, Miner: mid,
Number: 1, Number: 1,
}, },
ProofType: spt(sectorSize, false), ProofType: spt(sectorSize, false, false),
} }
start := time.Now() start := time.Now()
@ -852,7 +868,7 @@ var simpleReplicaUpdate = &cli.Command{
return xerrors.Errorf("replica update: %w", err) return xerrors.Errorf("replica update: %w", err)
} }
took := time.Now().Sub(start) took := time.Since(start)
fmt.Printf("ReplicaUpdate %s (%s)\n", took, bps(sectorSize, 1, took)) fmt.Printf("ReplicaUpdate %s (%s)\n", took, bps(sectorSize, 1, took))
fmt.Printf("d:%s r:%s\n", ruo.NewUnsealed, ruo.NewSealed) fmt.Printf("d:%s r:%s\n", ruo.NewUnsealed, ruo.NewSealed)
@ -910,7 +926,7 @@ var simpleProveReplicaUpdate1 = &cli.Command{
Miner: mid, Miner: mid,
Number: 1, Number: 1,
}, },
ProofType: spt(sectorSize, false), ProofType: spt(sectorSize, false, false),
} }
start := time.Now() start := time.Now()
@ -935,7 +951,7 @@ var simpleProveReplicaUpdate1 = &cli.Command{
return xerrors.Errorf("replica update: %w", err) return xerrors.Errorf("replica update: %w", err)
} }
took := time.Now().Sub(start) took := time.Since(start)
fmt.Printf("ProveReplicaUpdate1 %s (%s)\n", took, bps(sectorSize, 1, took)) fmt.Printf("ProveReplicaUpdate1 %s (%s)\n", took, bps(sectorSize, 1, took))
@ -997,7 +1013,7 @@ var simpleProveReplicaUpdate2 = &cli.Command{
Miner: mid, Miner: mid,
Number: 1, Number: 1,
}, },
ProofType: spt(sectorSize, false), ProofType: spt(sectorSize, false, false),
} }
start := time.Now() start := time.Now()
@ -1032,7 +1048,7 @@ var simpleProveReplicaUpdate2 = &cli.Command{
return xerrors.Errorf("prove replica update2: %w", err) return xerrors.Errorf("prove replica update2: %w", err)
} }
took := time.Now().Sub(start) took := time.Since(start)
fmt.Printf("ProveReplicaUpdate2 %s (%s)\n", took, bps(sectorSize, 1, took)) fmt.Printf("ProveReplicaUpdate2 %s (%s)\n", took, bps(sectorSize, 1, took))
fmt.Println("p:", base64.StdEncoding.EncodeToString(p)) fmt.Println("p:", base64.StdEncoding.EncodeToString(p))