lotus/cmd/lotus-bench/main.go

1056 lines
28 KiB
Go
Raw Normal View History

package main
import (
2023-09-21 15:37:02 +00:00
"bytes"
2019-11-28 01:43:36 +00:00
"context"
2023-09-29 16:56:10 +00:00
"crypto/rand"
2019-12-10 13:22:39 +00:00
"encoding/json"
"fmt"
"math/big"
"os"
"path/filepath"
2023-09-21 15:37:02 +00:00
"sync"
"time"
"github.com/docker/go-units"
2023-09-21 15:37:02 +00:00
"github.com/ipfs/boxo/blockservice"
"github.com/ipfs/boxo/ipld/merkledag"
"github.com/ipfs/go-cid"
offline "github.com/ipfs/go-ipfs-exchange-offline"
cbor "github.com/ipfs/go-ipld-cbor"
format "github.com/ipfs/go-ipld-format"
logging "github.com/ipfs/go-log/v2"
2020-05-07 23:44:12 +00:00
"github.com/minio/blake2b-simd"
"github.com/mitchellh/go-homedir"
"github.com/urfave/cli/v2"
2020-06-05 22:59:01 +00:00
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-paramfetch"
2020-09-07 03:49:10 +00:00
"github.com/filecoin-project/go-state-types/abi"
2023-09-21 15:37:02 +00:00
"github.com/filecoin-project/go-state-types/builtin/v9/verifreg"
2022-06-14 15:00:51 +00:00
prooftypes "github.com/filecoin-project/go-state-types/proof"
2023-09-21 15:37:02 +00:00
adt "github.com/filecoin-project/specs-actors/v6/actors/util/adt"
2020-02-28 18:06:59 +00:00
2020-02-27 22:23:05 +00:00
lapi "github.com/filecoin-project/lotus/api"
2023-09-21 15:37:02 +00:00
"github.com/filecoin-project/lotus/blockstore"
"github.com/filecoin-project/lotus/build"
2023-09-21 15:37:02 +00:00
"github.com/filecoin-project/lotus/chain/actors/builtin/market"
2020-11-05 12:43:05 +00:00
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/types"
2022-06-14 15:00:51 +00:00
lcli "github.com/filecoin-project/lotus/cli"
2019-12-10 13:22:39 +00:00
"github.com/filecoin-project/lotus/genesis"
"github.com/filecoin-project/lotus/storage/sealer/ffiwrapper"
"github.com/filecoin-project/lotus/storage/sealer/ffiwrapper/basicfs"
"github.com/filecoin-project/lotus/storage/sealer/storiface"
)
var log = logging.Logger("lotus-bench")
type BenchResults struct {
2021-01-06 04:20:33 +00:00
EnvVar map[string]string
2020-10-11 08:31:39 +00:00
SectorSize abi.SectorSize
2020-10-11 10:55:12 +00:00
SectorNumber int
2020-10-11 08:31:39 +00:00
SealingSum SealingResult
SealingResults []SealingResult
PostGenerateCandidates time.Duration
2020-04-13 22:13:34 +00:00
PostWinningProofCold time.Duration
PostWinningProofHot time.Duration
VerifyWinningPostCold time.Duration
VerifyWinningPostHot time.Duration
PostWindowProofCold time.Duration
PostWindowProofHot time.Duration
VerifyWindowPostCold time.Duration
VerifyWindowPostHot time.Duration
}
2020-10-11 08:31:39 +00:00
func (bo *BenchResults) SumSealingTime() error {
if len(bo.SealingResults) <= 0 {
return xerrors.Errorf("BenchResults SealingResults len <= 0")
}
2020-11-03 13:28:01 +00:00
if len(bo.SealingResults) != bo.SectorNumber {
return xerrors.Errorf("BenchResults SealingResults len(%d) != bo.SectorNumber(%d)", len(bo.SealingResults), bo.SectorNumber)
2020-10-11 08:31:39 +00:00
}
for _, sealing := range bo.SealingResults {
bo.SealingSum.AddPiece += sealing.AddPiece
bo.SealingSum.PreCommit1 += sealing.PreCommit1
bo.SealingSum.PreCommit2 += sealing.PreCommit2
bo.SealingSum.Commit1 += sealing.Commit1
bo.SealingSum.Commit2 += sealing.Commit2
bo.SealingSum.Verify += sealing.Verify
bo.SealingSum.Unseal += sealing.Unseal
}
return nil
}
type SealingResult struct {
2020-02-28 18:06:59 +00:00
AddPiece time.Duration
PreCommit1 time.Duration
PreCommit2 time.Duration
Commit1 time.Duration
Commit2 time.Duration
Verify time.Duration
Unseal time.Duration
}
2020-02-29 02:31:25 +00:00
type Commit2In struct {
2020-03-01 02:52:23 +00:00
SectorNum int64
Phase1Out []byte
SectorSize uint64
2020-02-29 02:31:25 +00:00
}
func main() {
logging.SetLogLevel("*", "INFO")
log.Info("Starting lotus-bench")
app := &cli.App{
Name: "lotus-bench",
Usage: "Benchmark performance of lotus on your hardware",
Version: build.UserVersion(),
DisableSliceFlagSeparator: true,
2020-03-01 02:52:23 +00:00
Commands: []*cli.Command{
proveCmd,
2023-09-21 15:37:02 +00:00
amtBenchCmd,
sealBenchCmd,
simpleCmd,
importBenchCmd,
Add new RPC stress testing tool (lotus-bench rpc) with rich reporting This benchmark is designed to stress test the rpc methods of a lotus node so that we can simulate real world usage and measure the performance of rpc methods on the node. This benchmark has the following features: * Can query each method both sequentially and concurrently * Supports rate limiting * Can query multiple different endpoints at once (supporting different concurrency level and rate limiting for each method) * Gives a nice reporting summary of the stress testing of each method (including latency distribution, histogram and more) * Easy to use To use this benchmark you must specify the rpc methods you want to test using the --method options, the format of it is: --method=NAME[:CONCURRENCY][:QPS][:PARAMS] where only METHOD is required. Here are some real examples: lotus-bench rpc --method='eth_chainId' // run eth_chainId with default concurrency and qps lotus-bench rpc --method='eth_chainId:3' // override concurrency to 3 lotus-bench rpc --method='eth_chainId::100' // override to 100 qps while using default concurrency lotus-bench rpc --method='eth_chainId:3:100' // run using 3 workers but limit to 100 qps lotus-bench rpc --method='eth_getTransactionCount:::["0xd4c70007F3F502f212c7e6794b94C06F36173B36", "latest"]' // run using optional params while using default concurrency and qps lotus-bench rpc --method='eth_chainId' --method='eth_getTransactionCount:10:0:["0xd4c70007F3F502f212c7e6794b94C06F36173B36", "latest"]' // run multiple methods at once`, Fixes: https://github.com/filecoin-project/lotus/issues/10752
2023-04-25 15:42:18 +00:00
rpcCmd,
2020-03-01 02:52:23 +00:00
},
}
if err := app.Run(os.Args); err != nil {
log.Warnf("%+v", err)
return
}
}
2023-09-21 15:37:02 +00:00
type amtStatCollector struct {
ds format.NodeGetter
walk func(format.Node) ([]*format.Link, error)
statsLk sync.Mutex
totalAMTLinks int
totalAMTValues int
totalAMTLinkNodes int
totalAMTValueNodes int
totalAMTLinkNodeSize int
totalAMTValueNodeSize int
}
func (asc *amtStatCollector) String() string {
asc.statsLk.Lock()
defer asc.statsLk.Unlock()
str := "\n------------\n"
str += fmt.Sprintf("Link Count: %d\n", asc.totalAMTLinks)
str += fmt.Sprintf("Value Count: %d\n", asc.totalAMTValues)
str += fmt.Sprintf("%d link nodes %d bytes\n", asc.totalAMTLinkNodes, asc.totalAMTLinkNodeSize)
str += fmt.Sprintf("%d value nodes %d bytes\n", asc.totalAMTValueNodes, asc.totalAMTValueNodeSize)
str += fmt.Sprintf("Total bytes: %d\n------------\n", asc.totalAMTLinkNodeSize+asc.totalAMTValueNodeSize)
return str
}
func (asc *amtStatCollector) record(ctx context.Context, nd format.Node) error {
size, err := nd.Size()
if err != nil {
return err
}
var node AMTNode
if err := node.UnmarshalCBOR(bytes.NewReader(nd.RawData())); err != nil {
// try to deserialize root
var root AMTRoot
if err := root.UnmarshalCBOR(bytes.NewReader(nd.RawData())); err != nil {
return err
}
node = root.AMTNode
}
asc.statsLk.Lock()
defer asc.statsLk.Unlock()
link := len(node.Links) > 0
value := len(node.Values) > 0
if link {
asc.totalAMTLinks += len(node.Links)
asc.totalAMTLinkNodes++
asc.totalAMTLinkNodeSize += int(size)
} else if value {
asc.totalAMTValues += len(node.Values)
asc.totalAMTValueNodes++
asc.totalAMTValueNodeSize += int(size)
} else {
return xerrors.Errorf("unexpected AMT node %x: neither link nor value", nd.RawData())
}
return nil
}
func (asc *amtStatCollector) walkLinks(ctx context.Context, c cid.Cid) ([]*format.Link, error) {
nd, err := asc.ds.Get(ctx, c)
if err != nil {
return nil, err
}
if err := asc.record(ctx, nd); err != nil {
return nil, err
}
return asc.walk(nd)
}
func carWalkFunc(nd format.Node) (out []*format.Link, err error) {
for _, link := range nd.Links() {
if link.Cid.Prefix().Codec == cid.FilCommitmentSealed || link.Cid.Prefix().Codec == cid.FilCommitmentUnsealed {
continue
}
out = append(out, link)
}
return out, nil
}
var amtBenchCmd = &cli.Command{
Name: "amt",
Usage: "Benchmark AMT churn",
Flags: []cli.Flag{
&cli.IntFlag{
Name: "rounds",
Usage: "rounds of churn to measure",
Value: 1,
},
&cli.IntFlag{
Name: "interval",
Usage: "AMT idx interval for churning values",
Value: 2880,
},
&cli.IntFlag{
Name: "bitwidth",
Usage: "AMT bitwidth",
Value: 6,
},
},
Action: func(c *cli.Context) error {
bs := blockstore.NewMemory()
ctx := c.Context
store := adt.WrapStore(ctx, cbor.NewCborStore(bs))
// Setup in memory blockstore
bitwidth := c.Int("bitwidth")
array, err := adt.MakeEmptyArray(store, bitwidth)
if err != nil {
return err
}
// Using motivating empirical example: market actor states AMT
// Create 40,000,000 states for realistic workload
fmt.Printf("Populating AMT\n")
for i := 0; i < 40000000; i++ {
if err := array.Set(uint64(i), &market.DealState{
SectorStartEpoch: abi.ChainEpoch(2000000 + i),
LastUpdatedEpoch: abi.ChainEpoch(-1),
SlashEpoch: -1,
VerifiedClaim: verifreg.AllocationId(i),
}); err != nil {
return err
}
}
r, err := array.Root()
if err != nil {
return err
}
// Measure ratio of internal / leaf nodes / sizes
dag := merkledag.NewDAGService(blockservice.New(bs, offline.Exchange(bs)))
asc := &amtStatCollector{
ds: dag,
walk: carWalkFunc,
}
fmt.Printf("Measuring AMT\n")
seen := cid.NewSet()
if err := merkledag.Walk(ctx, asc.walkLinks, r, seen.Visit, merkledag.Concurrent()); err != nil {
return err
}
fmt.Printf("%s\n", asc)
// Overwrite ids with idx % interval: one epoch of market cron
rounds := c.Int("rounds")
interval := c.Int("interval")
fmt.Printf("Overwrite 1 out of %d values for %d rounds\n", interval, rounds)
array, err = adt.AsArray(store, r, bitwidth)
if err != nil {
return err
}
roots := make([]cid.Cid, rounds)
for j := 0; j < rounds; j++ {
if j%10 == 0 {
fmt.Printf("round: %d\n", j)
}
for i := j; i < 40000000; i += interval {
if i%interval == j {
if err := array.Set(uint64(i), &market.DealState{
SectorStartEpoch: abi.ChainEpoch(2000000 + i),
LastUpdatedEpoch: abi.ChainEpoch(1),
SlashEpoch: -1,
VerifiedClaim: verifreg.AllocationId(i),
}); err != nil {
return err
}
}
}
roots[j], err = array.Root()
if err != nil {
return err
}
}
// Measure churn
dag = merkledag.NewDAGService(blockservice.New(bs, offline.Exchange(bs)))
asc = &amtStatCollector{
ds: dag,
walk: carWalkFunc,
}
fmt.Printf("Measuring %d rounds of churn\n", rounds)
for _, r := range roots {
if err := merkledag.Walk(ctx, asc.walkLinks, r, seen.Visit, merkledag.Concurrent()); err != nil {
return err
}
}
fmt.Printf("%s\n", asc)
return nil
},
}
var sealBenchCmd = &cli.Command{
2020-10-11 02:48:09 +00:00
Name: "sealing",
Usage: "Benchmark seal and winning post and window post",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "storage-dir",
Value: "~/.lotus-bench",
2020-10-11 09:20:55 +00:00
Usage: "path to the storage directory that will store sectors long term",
},
&cli.StringFlag{
Name: "sector-size",
Value: "512MiB",
Usage: "size of the sectors in bytes, i.e. 32GiB",
},
&cli.BoolFlag{
Name: "no-gpu",
Usage: "disable gpu usage for the benchmark run",
},
&cli.StringFlag{
Name: "miner-addr",
Usage: "pass miner address (only necessary if using existing sectorbuilder)",
Value: "t01000",
},
&cli.StringFlag{
Name: "benchmark-existing-sectorbuilder",
Usage: "pass a directory to run post timings on an existing sectorbuilder",
},
&cli.BoolFlag{
Name: "json-out",
Usage: "output results in json format",
},
&cli.BoolFlag{
Name: "skip-commit2",
Usage: "skip the commit2 (snark) portion of the benchmark",
},
&cli.BoolFlag{
Name: "skip-unseal",
Usage: "skip the unseal portion of the benchmark",
},
2020-10-11 09:20:55 +00:00
&cli.StringFlag{
Name: "ticket-preimage",
Usage: "ticket random",
},
&cli.StringFlag{
Name: "save-commit2-input",
2020-10-11 09:20:55 +00:00
Usage: "save commit2 input to a file",
},
2020-04-21 19:47:07 +00:00
&cli.IntFlag{
2020-04-21 21:38:26 +00:00
Name: "num-sectors",
2020-10-11 09:20:55 +00:00
Usage: "select number of sectors to seal",
2020-04-21 19:47:07 +00:00
Value: 1,
},
&cli.IntFlag{
Name: "parallel",
2020-10-11 09:20:55 +00:00
Usage: "num run in parallel",
Value: 1,
},
},
Action: func(c *cli.Context) error {
if c.Bool("no-gpu") {
err := os.Setenv("BELLMAN_NO_GPU", "1")
if err != nil {
return xerrors.Errorf("setting no-gpu flag: %w", err)
}
}
robench := c.String("benchmark-existing-sectorbuilder")
var sbdir string
if robench == "" {
sdir, err := homedir.Expand(c.String("storage-dir"))
if err != nil {
return err
}
err = os.MkdirAll(sdir, 0775) //nolint:gosec
if err != nil {
return xerrors.Errorf("creating sectorbuilder dir: %w", err)
}
tsdir, err := os.MkdirTemp(sdir, "bench")
if err != nil {
return err
}
defer func() {
if err := os.RemoveAll(tsdir); err != nil {
log.Warn("remove all: ", err)
}
}()
// TODO: pretty sure this isnt even needed?
if err := os.MkdirAll(tsdir, 0775); err != nil {
return err
}
sbdir = tsdir
} else {
exp, err := homedir.Expand(robench)
2020-02-27 22:23:05 +00:00
if err != nil {
return err
}
sbdir = exp
}
2020-02-27 22:23:05 +00:00
// miner address
maddr, err := address.NewFromString(c.String("miner-addr"))
if err != nil {
return err
}
amid, err := address.IDFromAddress(maddr)
if err != nil {
return err
}
mid := abi.ActorID(amid)
// sector size
sectorSizeInt, err := units.RAMInBytes(c.String("sector-size"))
if err != nil {
return err
}
sectorSize := abi.SectorSize(sectorSizeInt)
// Only fetch parameters if actually needed
2020-10-11 09:20:55 +00:00
skipc2 := c.Bool("skip-commit2")
if !skipc2 {
2021-03-10 15:16:44 +00:00
if err := paramfetch.GetParams(lcli.ReqContext(c), build.ParametersJSON(), build.SrsJSON(), uint64(sectorSize)); err != nil {
return xerrors.Errorf("getting params: %w", err)
2020-02-27 22:23:05 +00:00
}
}
sbfs := &basicfs.Provider{
Root: sbdir,
}
2020-02-27 22:23:05 +00:00
2020-11-05 12:43:05 +00:00
sb, err := ffiwrapper.New(sbfs)
if err != nil {
return err
}
2020-02-27 22:23:05 +00:00
2020-10-11 08:31:39 +00:00
sectorNumber := c.Int("num-sectors")
var sealTimings []SealingResult
2022-04-20 21:34:28 +00:00
var extendedSealedSectors []prooftypes.ExtendedSectorInfo
var sealedSectors []prooftypes.SectorInfo
if robench == "" {
var err error
parCfg := ParCfg{
PreCommit1: c.Int("parallel"),
PreCommit2: 1,
Commit: 1,
}
sealTimings, extendedSealedSectors, err = runSeals(sb, sbfs, sectorNumber, parCfg, mid, sectorSize, []byte(c.String("ticket-preimage")), c.String("save-commit2-input"), skipc2, c.Bool("skip-unseal"))
if err != nil {
return xerrors.Errorf("failed to run seals: %w", err)
}
for _, s := range extendedSealedSectors {
2022-04-20 21:34:28 +00:00
sealedSectors = append(sealedSectors, prooftypes.SectorInfo{
SealedCID: s.SealedCID,
SectorNumber: s.SectorNumber,
SealProof: s.SealProof,
})
}
2020-10-11 08:31:39 +00:00
} else {
// TODO: implement sbfs.List() and use that for all cases (preexisting sectorbuilder or not)
// TODO: this assumes we only ever benchmark a preseal
// sectorbuilder directory... we need a better way to handle
// this in other cases
fdata, err := os.ReadFile(filepath.Join(sbdir, "pre-seal-"+maddr.String()+".json"))
if err != nil {
return err
2019-12-10 13:22:39 +00:00
}
var genmm map[string]genesis.Miner
if err := json.Unmarshal(fdata, &genmm); err != nil {
return err
}
genm, ok := genmm[maddr.String()]
if !ok {
return xerrors.Errorf("preseal file didnt have expected miner in it")
}
2020-02-27 22:23:05 +00:00
for _, s := range genm.Sectors {
2022-04-20 21:34:28 +00:00
extendedSealedSectors = append(extendedSealedSectors, prooftypes.ExtendedSectorInfo{
SealedCID: s.CommR,
SectorNumber: s.SectorID,
SealProof: s.ProofType,
SectorKey: nil,
})
2022-04-20 21:34:28 +00:00
sealedSectors = append(sealedSectors, prooftypes.SectorInfo{
2020-06-15 16:30:49 +00:00
SealedCID: s.CommR,
SectorNumber: s.SectorID,
SealProof: s.ProofType,
})
}
}
bo := BenchResults{
SectorSize: sectorSize,
2020-10-11 10:55:12 +00:00
SectorNumber: sectorNumber,
SealingResults: sealTimings,
}
2020-10-11 08:31:39 +00:00
if err := bo.SumSealingTime(); err != nil {
return err
}
var challenge [32]byte
2023-09-29 16:56:10 +00:00
_, err = rand.Read(challenge[:])
if err != nil {
return err
}
2020-10-11 08:31:39 +00:00
beforePost := time.Now()
2019-11-29 18:48:07 +00:00
2020-10-11 09:20:55 +00:00
if !skipc2 {
2020-04-10 12:19:06 +00:00
log.Info("generating winning post candidates")
2020-11-05 12:43:05 +00:00
wipt, err := spt(sectorSize).RegisteredWinningPoStProof()
2020-06-15 16:30:49 +00:00
if err != nil {
return err
}
fcandidates, err := ffiwrapper.ProofVerifier.GenerateWinningPoStSectorChallenge(context.TODO(), wipt, mid, challenge[:], uint64(len(extendedSealedSectors)))
if err != nil {
return err
}
2019-11-29 18:48:07 +00:00
2022-04-20 21:34:28 +00:00
xcandidates := make([]prooftypes.ExtendedSectorInfo, len(fcandidates))
2020-04-10 12:19:06 +00:00
for i, fcandidate := range fcandidates {
xcandidates[i] = extendedSealedSectors[fcandidate]
}
gencandidates := time.Now()
2020-04-10 12:19:06 +00:00
log.Info("computing winning post snark (cold)")
proof1, err := sb.GenerateWinningPoSt(context.TODO(), mid, xcandidates, challenge[:])
if err != nil {
return err
}
2019-11-29 18:48:07 +00:00
winningpost1 := time.Now()
2019-11-28 01:43:36 +00:00
2020-04-10 12:19:06 +00:00
log.Info("computing winning post snark (hot)")
proof2, err := sb.GenerateWinningPoSt(context.TODO(), mid, xcandidates, challenge[:])
if err != nil {
return err
}
2019-11-29 18:48:07 +00:00
2022-04-20 21:34:28 +00:00
candidates := make([]prooftypes.SectorInfo, len(xcandidates))
for i, xsi := range xcandidates {
2022-04-20 21:34:28 +00:00
candidates[i] = prooftypes.SectorInfo{
SealedCID: xsi.SealedCID,
SectorNumber: xsi.SectorNumber,
SealProof: xsi.SealProof,
}
}
2020-04-13 22:13:34 +00:00
winnningpost2 := time.Now()
2020-02-27 22:23:05 +00:00
2022-04-20 21:34:28 +00:00
pvi1 := prooftypes.WinningPoStVerifyInfo{
2020-04-10 21:07:18 +00:00
Randomness: abi.PoStRandomness(challenge[:]),
Proofs: proof1,
2020-04-10 12:19:06 +00:00
ChallengedSectors: candidates,
2020-04-10 21:07:18 +00:00
Prover: mid,
}
ok, err := ffiwrapper.ProofVerifier.VerifyWinningPoSt(context.TODO(), pvi1)
if err != nil {
return err
}
if !ok {
log.Error("post verification failed")
}
2020-03-15 17:48:27 +00:00
verifyWinningPost1 := time.Now()
2022-04-20 21:34:28 +00:00
pvi2 := prooftypes.WinningPoStVerifyInfo{
2020-04-10 21:07:18 +00:00
Randomness: abi.PoStRandomness(challenge[:]),
Proofs: proof2,
2020-04-10 12:19:06 +00:00
ChallengedSectors: candidates,
2020-04-10 21:07:18 +00:00
Prover: mid,
2020-03-15 17:48:27 +00:00
}
ok, err = ffiwrapper.ProofVerifier.VerifyWinningPoSt(context.TODO(), pvi2)
if err != nil {
return err
}
if !ok {
log.Error("post verification failed")
}
2020-04-13 22:13:34 +00:00
verifyWinningPost2 := time.Now()
chore: build: Merge/v22 into 21 for 23 (#10702) * chore: update ffi to increase execution parallelism * Don't enforce walking receipt tree during compaction * fix: build: drop drand incentinet servers * chore: release lotus v1.20.4 * Apply suggestions from code review Co-authored-by: Jiaying Wang <42981373+jennijuju@users.noreply.github.com> * feat: Introduce nv19 skeleton Update to go-state-types v0.11.0-alpha-1 Introduce dummy v11 actor bundles Make new actors adapters Add upgrade to Upgrade Schedules make jen Update to go-state-types v0.11.0-alpha-2 * feat: vm: switch to the new exec trace format (#10372) This is now "FVM" native. Changes include: 1. Don't treat "trace" messages like off-chain messages. E.g., don't include CIDs, versions, etc. 2. Include IPLD codecs where applicable. 3. Remove fields that aren't filled by the FVM (timing, some errors, code locations, etc.). * feat: implement FIP-0061 * Address review * Add and test the FIP-0061 migration * Update actors bundles to fip/20230406 * Update to go-state-types master * Update to actors v11.0.0-rc1 * - Update go state types - Keep current expiration defaults on creation, extension some tests - Update ffi * ffi experiment * Integration nv19 migration - Open splitstore in migration shed tool - Update state root version * Post rebase fixup * Fix * gen * nv19 invariant checking * Try fixig blockstore so bundle is loaded * Debug * Fix * Make butterfly upgrades happen * Another ffi experiment * Fix copy paste error * Actually schedule migration (#10656) Co-authored-by: zenground0 <ZenGround0@users.noreply.github.com> * Butterfly artifacts * Set calibration net upgrade height * Review Response * Fix state tree version assert * Quick butterfly upgrade to sanity check (#10660) * Quick butterfly upgrade to sanity check * Update butterfly artifacts * Revert fake fix * Give butterfly net correct genesis * Butterfly artifacts * Give time before upgrade --------- Co-authored-by: zenground0 <ZenGround0@users.noreply.github.com> * chore:releasepolish v1.22 release (#10666) * Update butterfly artifacts * register actors v11 * Update calibration upgrade time * State inspection shed cmds * Fix * make gen * Fix swallowed errors * Lint fixup --------- Co-authored-by: zenground0 <ZenGround0@users.noreply.github.com> * v1.22.0-rc3 * bundle fix * Feat/expedite nv19 (#10681) * Update go-state-types * Modify upgrade schedule and params * Revert fip 0052 * Update gst * docsgen * fast butterfly migration to validate migration * Correct epoch to match specified date * Update actors v11 * Update changelog build version * Update butterfly artifacts * Fix lotus-miner init to work after upgrade --------- Co-authored-by: zenground0 <ZenGround0@users.noreply.github.com> * fix:deps:stable ffi for stable release (#10698) * Point to stable ffi for stable lotus release * go mod tidy --------- Co-authored-by: zenground0 <ZenGround0@users.noreply.github.com> * Update CHANGELOG.md Co-authored-by: Jiaying Wang <42981373+jennijuju@users.noreply.github.com> --------- Co-authored-by: Aayush Rajasekaran <arajasek94@gmail.com> Co-authored-by: zenground0 <ZenGround0@users.noreply.github.com> Co-authored-by: Jiaying Wang <42981373+jennijuju@users.noreply.github.com> Co-authored-by: Steven Allen <steven@stebalien.com> Co-authored-by: jennijuju <jiayingw703@gmail.com>
2023-04-19 22:40:18 +00:00
ppt, err := sealedSectors[0].SealProof.RegisteredWindowPoStProof()
if err != nil {
return err
}
ppt, err = ppt.ToV1_1PostProof()
if err != nil {
return err
}
2020-04-13 22:13:34 +00:00
log.Info("computing window post snark (cold)")
chore: build: Merge/v22 into 21 for 23 (#10702) * chore: update ffi to increase execution parallelism * Don't enforce walking receipt tree during compaction * fix: build: drop drand incentinet servers * chore: release lotus v1.20.4 * Apply suggestions from code review Co-authored-by: Jiaying Wang <42981373+jennijuju@users.noreply.github.com> * feat: Introduce nv19 skeleton Update to go-state-types v0.11.0-alpha-1 Introduce dummy v11 actor bundles Make new actors adapters Add upgrade to Upgrade Schedules make jen Update to go-state-types v0.11.0-alpha-2 * feat: vm: switch to the new exec trace format (#10372) This is now "FVM" native. Changes include: 1. Don't treat "trace" messages like off-chain messages. E.g., don't include CIDs, versions, etc. 2. Include IPLD codecs where applicable. 3. Remove fields that aren't filled by the FVM (timing, some errors, code locations, etc.). * feat: implement FIP-0061 * Address review * Add and test the FIP-0061 migration * Update actors bundles to fip/20230406 * Update to go-state-types master * Update to actors v11.0.0-rc1 * - Update go state types - Keep current expiration defaults on creation, extension some tests - Update ffi * ffi experiment * Integration nv19 migration - Open splitstore in migration shed tool - Update state root version * Post rebase fixup * Fix * gen * nv19 invariant checking * Try fixig blockstore so bundle is loaded * Debug * Fix * Make butterfly upgrades happen * Another ffi experiment * Fix copy paste error * Actually schedule migration (#10656) Co-authored-by: zenground0 <ZenGround0@users.noreply.github.com> * Butterfly artifacts * Set calibration net upgrade height * Review Response * Fix state tree version assert * Quick butterfly upgrade to sanity check (#10660) * Quick butterfly upgrade to sanity check * Update butterfly artifacts * Revert fake fix * Give butterfly net correct genesis * Butterfly artifacts * Give time before upgrade --------- Co-authored-by: zenground0 <ZenGround0@users.noreply.github.com> * chore:releasepolish v1.22 release (#10666) * Update butterfly artifacts * register actors v11 * Update calibration upgrade time * State inspection shed cmds * Fix * make gen * Fix swallowed errors * Lint fixup --------- Co-authored-by: zenground0 <ZenGround0@users.noreply.github.com> * v1.22.0-rc3 * bundle fix * Feat/expedite nv19 (#10681) * Update go-state-types * Modify upgrade schedule and params * Revert fip 0052 * Update gst * docsgen * fast butterfly migration to validate migration * Correct epoch to match specified date * Update actors v11 * Update changelog build version * Update butterfly artifacts * Fix lotus-miner init to work after upgrade --------- Co-authored-by: zenground0 <ZenGround0@users.noreply.github.com> * fix:deps:stable ffi for stable release (#10698) * Point to stable ffi for stable lotus release * go mod tidy --------- Co-authored-by: zenground0 <ZenGround0@users.noreply.github.com> * Update CHANGELOG.md Co-authored-by: Jiaying Wang <42981373+jennijuju@users.noreply.github.com> --------- Co-authored-by: Aayush Rajasekaran <arajasek94@gmail.com> Co-authored-by: zenground0 <ZenGround0@users.noreply.github.com> Co-authored-by: Jiaying Wang <42981373+jennijuju@users.noreply.github.com> Co-authored-by: Steven Allen <steven@stebalien.com> Co-authored-by: jennijuju <jiayingw703@gmail.com>
2023-04-19 22:40:18 +00:00
wproof1, _, err := sb.GenerateWindowPoSt(context.TODO(), mid, ppt, extendedSealedSectors, challenge[:])
2020-04-13 22:13:34 +00:00
if err != nil {
return err
}
windowpost1 := time.Now()
log.Info("computing window post snark (hot)")
chore: build: Merge/v22 into 21 for 23 (#10702) * chore: update ffi to increase execution parallelism * Don't enforce walking receipt tree during compaction * fix: build: drop drand incentinet servers * chore: release lotus v1.20.4 * Apply suggestions from code review Co-authored-by: Jiaying Wang <42981373+jennijuju@users.noreply.github.com> * feat: Introduce nv19 skeleton Update to go-state-types v0.11.0-alpha-1 Introduce dummy v11 actor bundles Make new actors adapters Add upgrade to Upgrade Schedules make jen Update to go-state-types v0.11.0-alpha-2 * feat: vm: switch to the new exec trace format (#10372) This is now "FVM" native. Changes include: 1. Don't treat "trace" messages like off-chain messages. E.g., don't include CIDs, versions, etc. 2. Include IPLD codecs where applicable. 3. Remove fields that aren't filled by the FVM (timing, some errors, code locations, etc.). * feat: implement FIP-0061 * Address review * Add and test the FIP-0061 migration * Update actors bundles to fip/20230406 * Update to go-state-types master * Update to actors v11.0.0-rc1 * - Update go state types - Keep current expiration defaults on creation, extension some tests - Update ffi * ffi experiment * Integration nv19 migration - Open splitstore in migration shed tool - Update state root version * Post rebase fixup * Fix * gen * nv19 invariant checking * Try fixig blockstore so bundle is loaded * Debug * Fix * Make butterfly upgrades happen * Another ffi experiment * Fix copy paste error * Actually schedule migration (#10656) Co-authored-by: zenground0 <ZenGround0@users.noreply.github.com> * Butterfly artifacts * Set calibration net upgrade height * Review Response * Fix state tree version assert * Quick butterfly upgrade to sanity check (#10660) * Quick butterfly upgrade to sanity check * Update butterfly artifacts * Revert fake fix * Give butterfly net correct genesis * Butterfly artifacts * Give time before upgrade --------- Co-authored-by: zenground0 <ZenGround0@users.noreply.github.com> * chore:releasepolish v1.22 release (#10666) * Update butterfly artifacts * register actors v11 * Update calibration upgrade time * State inspection shed cmds * Fix * make gen * Fix swallowed errors * Lint fixup --------- Co-authored-by: zenground0 <ZenGround0@users.noreply.github.com> * v1.22.0-rc3 * bundle fix * Feat/expedite nv19 (#10681) * Update go-state-types * Modify upgrade schedule and params * Revert fip 0052 * Update gst * docsgen * fast butterfly migration to validate migration * Correct epoch to match specified date * Update actors v11 * Update changelog build version * Update butterfly artifacts * Fix lotus-miner init to work after upgrade --------- Co-authored-by: zenground0 <ZenGround0@users.noreply.github.com> * fix:deps:stable ffi for stable release (#10698) * Point to stable ffi for stable lotus release * go mod tidy --------- Co-authored-by: zenground0 <ZenGround0@users.noreply.github.com> * Update CHANGELOG.md Co-authored-by: Jiaying Wang <42981373+jennijuju@users.noreply.github.com> --------- Co-authored-by: Aayush Rajasekaran <arajasek94@gmail.com> Co-authored-by: zenground0 <ZenGround0@users.noreply.github.com> Co-authored-by: Jiaying Wang <42981373+jennijuju@users.noreply.github.com> Co-authored-by: Steven Allen <steven@stebalien.com> Co-authored-by: jennijuju <jiayingw703@gmail.com>
2023-04-19 22:40:18 +00:00
wproof2, _, err := sb.GenerateWindowPoSt(context.TODO(), mid, ppt, extendedSealedSectors, challenge[:])
2020-04-13 22:13:34 +00:00
if err != nil {
return err
}
windowpost2 := time.Now()
2022-04-20 21:34:28 +00:00
wpvi1 := prooftypes.WindowPoStVerifyInfo{
2020-04-13 22:13:34 +00:00
Randomness: challenge[:],
Proofs: wproof1,
ChallengedSectors: sealedSectors,
Prover: mid,
}
ok, err = ffiwrapper.ProofVerifier.VerifyWindowPoSt(context.TODO(), wpvi1)
if err != nil {
return err
}
if !ok {
log.Error("window post verification failed")
2020-04-13 22:13:34 +00:00
}
verifyWindowpost1 := time.Now()
2022-04-20 21:34:28 +00:00
wpvi2 := prooftypes.WindowPoStVerifyInfo{
2020-04-13 22:13:34 +00:00
Randomness: challenge[:],
Proofs: wproof2,
ChallengedSectors: sealedSectors,
Prover: mid,
}
ok, err = ffiwrapper.ProofVerifier.VerifyWindowPoSt(context.TODO(), wpvi2)
if err != nil {
return err
}
if !ok {
log.Error("window post verification failed")
2020-04-13 22:13:34 +00:00
}
verifyWindowpost2 := time.Now()
2019-12-10 14:05:41 +00:00
bo.PostGenerateCandidates = gencandidates.Sub(beforePost)
bo.PostWinningProofCold = winningpost1.Sub(gencandidates)
bo.PostWinningProofHot = winnningpost2.Sub(winningpost1)
bo.VerifyWinningPostCold = verifyWinningPost1.Sub(winnningpost2)
bo.VerifyWinningPostHot = verifyWinningPost2.Sub(verifyWinningPost1)
2020-04-13 22:13:34 +00:00
bo.PostWindowProofCold = windowpost1.Sub(verifyWinningPost2)
bo.PostWindowProofHot = windowpost2.Sub(windowpost1)
bo.VerifyWindowPostCold = verifyWindowpost1.Sub(windowpost2)
bo.VerifyWindowPostHot = verifyWindowpost2.Sub(verifyWindowpost1)
}
2021-01-06 04:20:33 +00:00
bo.EnvVar = make(map[string]string)
for _, envKey := range []string{"BELLMAN_NO_GPU", "FIL_PROOFS_USE_GPU_COLUMN_BUILDER",
2020-12-18 09:46:49 +00:00
"FIL_PROOFS_USE_GPU_TREE_BUILDER", "FIL_PROOFS_USE_MULTICORE_SDR", "BELLMAN_CUSTOM_GPU"} {
envValue, found := os.LookupEnv(envKey)
if found {
2021-01-06 04:20:33 +00:00
bo.EnvVar[envKey] = envValue
2020-12-18 09:46:49 +00:00
}
}
if c.Bool("json-out") {
data, err := json.MarshalIndent(bo, "", " ")
if err != nil {
return err
}
fmt.Println(string(data))
} else {
2021-01-06 04:20:33 +00:00
fmt.Println("environment variable list:")
for envKey, envValue := range bo.EnvVar {
fmt.Printf("%s=%s\n", envKey, envValue)
}
2020-10-11 08:31:39 +00:00
fmt.Printf("----\nresults (v28) SectorSize:(%d), SectorNumber:(%d)\n", sectorSize, sectorNumber)
if robench == "" {
2020-10-11 10:55:12 +00:00
fmt.Printf("seal: addPiece: %s (%s)\n", bo.SealingSum.AddPiece, bps(bo.SectorSize, bo.SectorNumber, bo.SealingSum.AddPiece))
fmt.Printf("seal: preCommit phase 1: %s (%s)\n", bo.SealingSum.PreCommit1, bps(bo.SectorSize, bo.SectorNumber, bo.SealingSum.PreCommit1))
fmt.Printf("seal: preCommit phase 2: %s (%s)\n", bo.SealingSum.PreCommit2, bps(bo.SectorSize, bo.SectorNumber, bo.SealingSum.PreCommit2))
fmt.Printf("seal: commit phase 1: %s (%s)\n", bo.SealingSum.Commit1, bps(bo.SectorSize, bo.SectorNumber, bo.SealingSum.Commit1))
fmt.Printf("seal: commit phase 2: %s (%s)\n", bo.SealingSum.Commit2, bps(bo.SectorSize, bo.SectorNumber, bo.SealingSum.Commit2))
2020-10-11 08:31:39 +00:00
fmt.Printf("seal: verify: %s\n", bo.SealingSum.Verify)
if !c.Bool("skip-unseal") {
2020-10-11 10:55:12 +00:00
fmt.Printf("unseal: %s (%s)\n", bo.SealingSum.Unseal, bps(bo.SectorSize, bo.SectorNumber, bo.SealingSum.Unseal))
}
2020-04-13 22:13:34 +00:00
fmt.Println("")
}
2020-10-11 09:20:55 +00:00
if !skipc2 {
2020-10-11 10:55:12 +00:00
fmt.Printf("generate candidates: %s (%s)\n", bo.PostGenerateCandidates, bps(bo.SectorSize, len(bo.SealingResults), bo.PostGenerateCandidates))
fmt.Printf("compute winning post proof (cold): %s\n", bo.PostWinningProofCold)
fmt.Printf("compute winning post proof (hot): %s\n", bo.PostWinningProofHot)
fmt.Printf("verify winning post proof (cold): %s\n", bo.VerifyWinningPostCold)
fmt.Printf("verify winning post proof (hot): %s\n\n", bo.VerifyWinningPostHot)
2020-04-13 22:13:34 +00:00
fmt.Printf("compute window post proof (cold): %s\n", bo.PostWindowProofCold)
fmt.Printf("compute window post proof (hot): %s\n", bo.PostWindowProofHot)
fmt.Printf("verify window post proof (cold): %s\n", bo.VerifyWindowPostCold)
fmt.Printf("verify window post proof (hot): %s\n", bo.VerifyWindowPostHot)
}
}
return nil
},
}
2019-12-10 18:04:13 +00:00
type ParCfg struct {
PreCommit1 int
PreCommit2 int
Commit int
}
2022-04-20 21:34:28 +00:00
func runSeals(sb *ffiwrapper.Sealer, sbfs *basicfs.Provider, numSectors int, par ParCfg, mid abi.ActorID, sectorSize abi.SectorSize, ticketPreimage []byte, saveC2inp string, skipc2, skipunseal bool) ([]SealingResult, []prooftypes.ExtendedSectorInfo, error) {
var pieces []abi.PieceInfo
sealTimings := make([]SealingResult, numSectors)
2022-04-20 21:34:28 +00:00
sealedSectors := make([]prooftypes.ExtendedSectorInfo, numSectors)
preCommit2Sema := make(chan struct{}, par.PreCommit2)
commitSema := make(chan struct{}, par.Commit)
if numSectors%par.PreCommit1 != 0 {
return nil, nil, fmt.Errorf("parallelism factor must cleanly divide numSectors")
}
2020-11-20 15:20:26 +00:00
for i := abi.SectorNumber(0); i < abi.SectorNumber(numSectors); i++ {
sid := storiface.SectorRef{
2020-11-05 12:43:05 +00:00
ID: abi.SectorID{
Miner: mid,
Number: i,
},
ProofType: spt(sectorSize),
}
start := time.Now()
log.Infof("[%d] Writing piece into sector...", i)
2023-09-29 16:56:10 +00:00
pi, err := sb.AddPiece(context.TODO(), sid, nil, abi.PaddedPieceSize(sectorSize).Unpadded(), rand.Reader)
if err != nil {
return nil, nil, err
}
pieces = append(pieces, pi)
2020-10-11 03:39:27 +00:00
sealTimings[i].AddPiece = time.Since(start)
}
2020-05-07 23:44:12 +00:00
sectorsPerWorker := numSectors / par.PreCommit1
errs := make(chan error, par.PreCommit1)
for wid := 0; wid < par.PreCommit1; wid++ {
go func(worker int) {
sealerr := func() error {
2020-10-11 03:39:27 +00:00
start := worker * sectorsPerWorker
end := start + sectorsPerWorker
for i := abi.SectorNumber(start); i < abi.SectorNumber(end); i++ {
sid := storiface.SectorRef{
2020-11-05 12:43:05 +00:00
ID: abi.SectorID{
Miner: mid,
Number: i,
},
ProofType: spt(sectorSize),
}
start := time.Now()
trand := blake2b.Sum256(ticketPreimage)
ticket := abi.SealRandomness(trand[:])
log.Infof("[%d] Running replication(1)...", i)
2020-10-11 03:39:27 +00:00
piece := []abi.PieceInfo{pieces[i]}
pc1o, err := sb.SealPreCommit1(context.TODO(), sid, ticket, piece)
if err != nil {
return xerrors.Errorf("commit: %w", err)
}
precommit1 := time.Now()
preCommit2Sema <- struct{}{}
pc2Start := time.Now()
log.Infof("[%d] Running replication(2)...", i)
cids, err := sb.SealPreCommit2(context.TODO(), sid, pc1o)
if err != nil {
return xerrors.Errorf("commit: %w", err)
}
precommit2 := time.Now()
<-preCommit2Sema
2022-04-20 21:34:28 +00:00
sealedSectors[i] = prooftypes.ExtendedSectorInfo{
2020-11-05 12:43:05 +00:00
SealProof: sid.ProofType,
SectorNumber: i,
SealedCID: cids.Sealed,
SectorKey: nil,
}
seed := lapi.SealSeed{
Epoch: 101,
Value: []byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 255},
}
commitSema <- struct{}{}
commitStart := time.Now()
log.Infof("[%d] Generating PoRep for sector (1)", i)
2020-10-11 03:39:27 +00:00
c1o, err := sb.SealCommit1(context.TODO(), sid, ticket, seed.Value, piece, cids)
if err != nil {
return err
}
sealcommit1 := time.Now()
log.Infof("[%d] Generating PoRep for sector (2)", i)
if saveC2inp != "" {
c2in := Commit2In{
SectorNum: int64(i),
Phase1Out: c1o,
SectorSize: uint64(sectorSize),
}
b, err := json.Marshal(&c2in)
if err != nil {
return err
}
if err := os.WriteFile(saveC2inp, b, 0664); err != nil {
log.Warnf("%+v", err)
}
}
var proof storiface.Proof
if !skipc2 {
proof, err = sb.SealCommit2(context.TODO(), sid, c1o)
if err != nil {
return err
}
}
sealcommit2 := time.Now()
<-commitSema
if !skipc2 {
2022-04-20 21:34:28 +00:00
svi := prooftypes.SealVerifyInfo{
2020-11-20 15:20:26 +00:00
SectorID: abi.SectorID{Miner: mid, Number: i},
SealedCID: cids.Sealed,
2020-11-05 12:43:05 +00:00
SealProof: sid.ProofType,
Proof: proof,
DealIDs: nil,
Randomness: ticket,
InteractiveRandomness: seed.Value,
UnsealedCID: cids.Unsealed,
}
ok, err := ffiwrapper.ProofVerifier.VerifySeal(svi)
if err != nil {
return err
}
if !ok {
return xerrors.Errorf("porep proof for sector %d was invalid", i)
}
}
verifySeal := time.Now()
if !skipunseal {
log.Infof("[%d] Unsealing sector", i)
{
2020-11-03 11:56:04 +00:00
p, done, err := sbfs.AcquireSector(context.TODO(), sid, storiface.FTUnsealed, storiface.FTNone, storiface.PathSealing)
if err != nil {
return xerrors.Errorf("acquire unsealed sector for removing: %w", err)
}
done()
if err := os.Remove(p.Unsealed); err != nil {
return xerrors.Errorf("removing unsealed sector: %w", err)
}
}
err := sb.UnsealPiece(context.TODO(), sid, 0, abi.PaddedPieceSize(sectorSize).Unpadded(), ticket, cids.Unsealed)
if err != nil {
return err
}
}
unseal := time.Now()
2020-10-11 03:39:27 +00:00
sealTimings[i].PreCommit1 = precommit1.Sub(start)
sealTimings[i].PreCommit2 = precommit2.Sub(pc2Start)
sealTimings[i].Commit1 = sealcommit1.Sub(commitStart)
sealTimings[i].Commit2 = sealcommit2.Sub(sealcommit1)
sealTimings[i].Verify = verifySeal.Sub(sealcommit2)
sealTimings[i].Unseal = unseal.Sub(verifySeal)
2020-05-07 23:44:12 +00:00
}
return nil
}()
if sealerr != nil {
errs <- sealerr
return
2020-05-07 23:44:12 +00:00
}
errs <- nil
}(wid)
}
2020-05-07 23:44:12 +00:00
for i := 0; i < par.PreCommit1; i++ {
err := <-errs
if err != nil {
return nil, nil, err
}
}
return sealTimings, sealedSectors, nil
}
2020-03-01 02:52:23 +00:00
var proveCmd = &cli.Command{
2020-10-11 10:26:27 +00:00
Name: "prove",
Usage: "Benchmark a proof computation",
ArgsUsage: "[input.json]",
2020-03-01 02:52:23 +00:00
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "no-gpu",
Usage: "disable gpu usage for the benchmark run",
},
2020-06-11 08:35:46 +00:00
&cli.StringFlag{
Name: "miner-addr",
Usage: "pass miner address (only necessary if using existing sectorbuilder)",
Value: "t01000",
},
2020-03-01 02:52:23 +00:00
},
Action: func(c *cli.Context) error {
if c.Bool("no-gpu") {
err := os.Setenv("BELLMAN_NO_GPU", "1")
if err != nil {
return xerrors.Errorf("setting no-gpu flag: %w", err)
}
2020-03-01 02:52:23 +00:00
}
if !c.Args().Present() {
return xerrors.Errorf("Usage: lotus-bench prove [input.json]")
}
inb, err := os.ReadFile(c.Args().First())
2020-03-01 02:52:23 +00:00
if err != nil {
return xerrors.Errorf("reading input file: %w", err)
}
var c2in Commit2In
if err := json.Unmarshal(inb, &c2in); err != nil {
return xerrors.Errorf("unmarshalling input file: %w", err)
}
2021-03-10 15:16:44 +00:00
if err := paramfetch.GetParams(lcli.ReqContext(c), build.ParametersJSON(), build.SrsJSON(), c2in.SectorSize); err != nil {
2020-03-01 02:52:23 +00:00
return xerrors.Errorf("getting params: %w", err)
}
maddr, err := address.NewFromString(c.String("miner-addr"))
if err != nil {
return err
}
2020-03-18 01:08:11 +00:00
mid, err := address.IDFromAddress(maddr)
if err != nil {
return err
}
2020-03-01 02:52:23 +00:00
2020-11-05 12:43:05 +00:00
sb, err := ffiwrapper.New(nil)
2020-03-01 02:52:23 +00:00
if err != nil {
return err
}
ref := storiface.SectorRef{
2020-11-05 12:43:05 +00:00
ID: abi.SectorID{
Miner: abi.ActorID(mid),
Number: abi.SectorNumber(c2in.SectorNum),
},
ProofType: spt(abi.SectorSize(c2in.SectorSize)),
2020-03-01 02:52:23 +00:00
}
2020-10-11 10:26:27 +00:00
fmt.Printf("----\nstart proof computation\n")
2020-03-01 02:52:23 +00:00
start := time.Now()
2020-11-05 12:43:05 +00:00
proof, err := sb.SealCommit2(context.TODO(), ref, c2in.Phase1Out)
2020-03-01 02:52:23 +00:00
if err != nil {
return err
}
sealCommit2 := time.Now()
fmt.Printf("proof: %x\n", proof)
2020-10-11 02:48:09 +00:00
fmt.Printf("----\nresults (v28) (%d)\n", c2in.SectorSize)
2020-03-01 02:52:23 +00:00
dur := sealCommit2.Sub(start)
2020-10-11 10:55:12 +00:00
fmt.Printf("seal: commit phase 2: %s (%s)\n", dur, bps(abi.SectorSize(c2in.SectorSize), 1, dur))
2020-03-01 02:52:23 +00:00
return nil
},
}
2020-10-11 10:55:12 +00:00
func bps(sectorSize abi.SectorSize, sectorNum int, d time.Duration) string {
2020-10-11 08:31:39 +00:00
bdata := new(big.Int).SetUint64(uint64(sectorSize))
2020-10-11 10:55:12 +00:00
bdata = bdata.Mul(bdata, big.NewInt(int64(sectorNum)))
2020-10-11 08:31:39 +00:00
bdata = bdata.Mul(bdata, big.NewInt(time.Second.Nanoseconds()))
bps := bdata.Div(bdata, big.NewInt(d.Nanoseconds()))
return types.SizeStr(types.BigInt{Int: bps}) + "/s"
}
2020-11-05 12:43:05 +00:00
func spt(ssize abi.SectorSize) abi.RegisteredSealProof {
spt, err := miner.SealProofTypeFromSectorSize(ssize, build.TestNetworkVersion)
2020-11-05 12:43:05 +00:00
if err != nil {
panic(err)
}
return spt
}