From 8fae155cf61f03c43ecd2b347bae4009584fb49d Mon Sep 17 00:00:00 2001 From: whyrusleeping Date: Wed, 27 Nov 2019 19:43:36 -0600 Subject: [PATCH] Add timings for proof verification --- chain/stmgr/stmgr.go | 1 - cmd/lotus-bench/main.go | 29 +++++++++++++++++++++++++---- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/chain/stmgr/stmgr.go b/chain/stmgr/stmgr.go index c13a894a2..d2ef66327 100644 --- a/chain/stmgr/stmgr.go +++ b/chain/stmgr/stmgr.go @@ -84,7 +84,6 @@ func (sm *StateManager) TipSetState(ctx context.Context, ts *types.TipSet) (cid. func (sm *StateManager) computeTipSetState(ctx context.Context, blks []*types.BlockHeader, cb func(cid.Cid, *types.Message, *vm.ApplyRet) error) (cid.Cid, cid.Cid, error) { ctx, span := trace.StartSpan(ctx, "computeTipSetState") defer span.End() - fmt.Println("COMPUTE TIPSET STATE", len(blks)) for i := 0; i < len(blks); i++ { for j := i + 1; j < len(blks); j++ { diff --git a/cmd/lotus-bench/main.go b/cmd/lotus-bench/main.go index a4ed62fd1..03aa60658 100644 --- a/cmd/lotus-bench/main.go +++ b/cmd/lotus-bench/main.go @@ -1,6 +1,7 @@ package main import ( + "context" "crypto/sha256" "fmt" "io/ioutil" @@ -30,12 +31,14 @@ type BenchResults struct { PostGenerateCandidates time.Duration PostEProof time.Duration + VerifyEPost time.Duration } type SealingResult struct { AddPiece time.Duration PreCommit time.Duration Commit time.Duration + Verify time.Duration } func main() { @@ -81,10 +84,12 @@ func main() { return err } + sectorSize := c.Uint64("sector-size") + mds := datastore.NewMapDatastore() cfg := §orbuilder.Config{ Miner: maddr, - SectorSize: c.Uint64("sector-size"), + SectorSize: sectorSize, WorkerThreads: 2, CacheDir: filepath.Join(tsdir, "cache"), SealedDir: filepath.Join(tsdir, "sealed"), @@ -106,7 +111,7 @@ func main() { } r := rand.New(rand.NewSource(101)) - size := sectorbuilder.UserBytesForSectorSize(c.Uint64("sector-size")) + size := sectorbuilder.UserBytesForSectorSize(sectorSize) var sealTimings []SealingResult var sealedSectors []ffi.PublicSectorInfo @@ -150,14 +155,18 @@ func main() { if err != nil { return err } - _ = proof // todo verify sealcommit := time.Now() + commD := pi.CommP + sectorbuilder.VerifySeal(sectorSize, pco.CommR[:], commD[:], maddr, ticket.TicketBytes[:], seed.TicketBytes[:], i, proof) + + verifySeal := time.Now() sealTimings = append(sealTimings, SealingResult{ AddPiece: addpiece.Sub(start), PreCommit: precommit.Sub(addpiece), Commit: sealcommit.Sub(precommit), + Verify: verifySeal.Sub(sealcommit), }) } @@ -180,24 +189,36 @@ func main() { if err != nil { return err } - _ = proof // todo verify epost := time.Now() + ok, err := sectorbuilder.VerifyPost(context.TODO(), sectorSize, sinfos, challenge[:], proof, candidates[:1], maddr) + if err != nil { + return err + } + if !ok { + log.Error("post verification failed") + } + + verifypost := time.Now() + benchout := BenchResults{ SectorSize: cfg.SectorSize, SealingResults: sealTimings, PostGenerateCandidates: gencandidates.Sub(beforePost), PostEProof: epost.Sub(gencandidates), + VerifyEPost: verifypost.Sub(epost), } // TODO: optionally write this as json to a file fmt.Println("results") fmt.Printf("seal: addPiece: %s\n", benchout.SealingResults[0].AddPiece) // TODO: average across multiple sealings fmt.Printf("seal: preCommit: %s\n", benchout.SealingResults[0].PreCommit) fmt.Printf("seal: Commit: %s\n", benchout.SealingResults[0].Commit) + fmt.Printf("seal: Verify: %s\n", benchout.SealingResults[0].Verify) fmt.Printf("generate candidates: %s\n", benchout.PostGenerateCandidates) fmt.Printf("compute epost proof: %s\n", benchout.PostEProof) + fmt.Printf("verify epost proof: %s\n", benchout.VerifyEPost) return nil }, }