Add timings for proof verification
This commit is contained in:
parent
99b9dfe18d
commit
8fae155cf6
@ -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) {
|
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")
|
ctx, span := trace.StartSpan(ctx, "computeTipSetState")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
fmt.Println("COMPUTE TIPSET STATE", len(blks))
|
|
||||||
|
|
||||||
for i := 0; i < len(blks); i++ {
|
for i := 0; i < len(blks); i++ {
|
||||||
for j := i + 1; j < len(blks); j++ {
|
for j := i + 1; j < len(blks); j++ {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@ -30,12 +31,14 @@ type BenchResults struct {
|
|||||||
|
|
||||||
PostGenerateCandidates time.Duration
|
PostGenerateCandidates time.Duration
|
||||||
PostEProof time.Duration
|
PostEProof time.Duration
|
||||||
|
VerifyEPost time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
type SealingResult struct {
|
type SealingResult struct {
|
||||||
AddPiece time.Duration
|
AddPiece time.Duration
|
||||||
PreCommit time.Duration
|
PreCommit time.Duration
|
||||||
Commit time.Duration
|
Commit time.Duration
|
||||||
|
Verify time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -81,10 +84,12 @@ func main() {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sectorSize := c.Uint64("sector-size")
|
||||||
|
|
||||||
mds := datastore.NewMapDatastore()
|
mds := datastore.NewMapDatastore()
|
||||||
cfg := §orbuilder.Config{
|
cfg := §orbuilder.Config{
|
||||||
Miner: maddr,
|
Miner: maddr,
|
||||||
SectorSize: c.Uint64("sector-size"),
|
SectorSize: sectorSize,
|
||||||
WorkerThreads: 2,
|
WorkerThreads: 2,
|
||||||
CacheDir: filepath.Join(tsdir, "cache"),
|
CacheDir: filepath.Join(tsdir, "cache"),
|
||||||
SealedDir: filepath.Join(tsdir, "sealed"),
|
SealedDir: filepath.Join(tsdir, "sealed"),
|
||||||
@ -106,7 +111,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
r := rand.New(rand.NewSource(101))
|
r := rand.New(rand.NewSource(101))
|
||||||
size := sectorbuilder.UserBytesForSectorSize(c.Uint64("sector-size"))
|
size := sectorbuilder.UserBytesForSectorSize(sectorSize)
|
||||||
|
|
||||||
var sealTimings []SealingResult
|
var sealTimings []SealingResult
|
||||||
var sealedSectors []ffi.PublicSectorInfo
|
var sealedSectors []ffi.PublicSectorInfo
|
||||||
@ -150,14 +155,18 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
_ = proof // todo verify
|
|
||||||
|
|
||||||
sealcommit := time.Now()
|
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{
|
sealTimings = append(sealTimings, SealingResult{
|
||||||
AddPiece: addpiece.Sub(start),
|
AddPiece: addpiece.Sub(start),
|
||||||
PreCommit: precommit.Sub(addpiece),
|
PreCommit: precommit.Sub(addpiece),
|
||||||
Commit: sealcommit.Sub(precommit),
|
Commit: sealcommit.Sub(precommit),
|
||||||
|
Verify: verifySeal.Sub(sealcommit),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,24 +189,36 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
_ = proof // todo verify
|
|
||||||
|
|
||||||
epost := time.Now()
|
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{
|
benchout := BenchResults{
|
||||||
SectorSize: cfg.SectorSize,
|
SectorSize: cfg.SectorSize,
|
||||||
SealingResults: sealTimings,
|
SealingResults: sealTimings,
|
||||||
|
|
||||||
PostGenerateCandidates: gencandidates.Sub(beforePost),
|
PostGenerateCandidates: gencandidates.Sub(beforePost),
|
||||||
PostEProof: epost.Sub(gencandidates),
|
PostEProof: epost.Sub(gencandidates),
|
||||||
|
VerifyEPost: verifypost.Sub(epost),
|
||||||
} // TODO: optionally write this as json to a file
|
} // TODO: optionally write this as json to a file
|
||||||
|
|
||||||
fmt.Println("results")
|
fmt.Println("results")
|
||||||
fmt.Printf("seal: addPiece: %s\n", benchout.SealingResults[0].AddPiece) // TODO: average across multiple sealings
|
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: preCommit: %s\n", benchout.SealingResults[0].PreCommit)
|
||||||
fmt.Printf("seal: Commit: %s\n", benchout.SealingResults[0].Commit)
|
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("generate candidates: %s\n", benchout.PostGenerateCandidates)
|
||||||
fmt.Printf("compute epost proof: %s\n", benchout.PostEProof)
|
fmt.Printf("compute epost proof: %s\n", benchout.PostEProof)
|
||||||
|
fmt.Printf("verify epost proof: %s\n", benchout.VerifyEPost)
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user