Merge pull request #945 from filecoin-project/feat/parallel-bls-hash
parallelize bls message hashing for validation
This commit is contained in:
commit
61123d44a9
@ -6,6 +6,7 @@ import (
|
|||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Gurpartap/async"
|
"github.com/Gurpartap/async"
|
||||||
@ -409,6 +410,8 @@ func (syncer *Syncer) ValidateTipSet(ctx context.Context, fts *store.FullTipSet)
|
|||||||
ctx, span := trace.StartSpan(ctx, "validateTipSet")
|
ctx, span := trace.StartSpan(ctx, "validateTipSet")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
|
span.AddAttributes(trace.Int64Attribute("height", int64(fts.TipSet().Height())))
|
||||||
|
|
||||||
ts := fts.TipSet()
|
ts := fts.TipSet()
|
||||||
if ts.Equals(syncer.Genesis) {
|
if ts.Equals(syncer.Genesis) {
|
||||||
return nil
|
return nil
|
||||||
@ -794,10 +797,19 @@ func (syncer *Syncer) verifyBlsAggregate(ctx context.Context, sig types.Signatur
|
|||||||
trace.Int64Attribute("msgCount", int64(len(msgs))),
|
trace.Int64Attribute("msgCount", int64(len(msgs))),
|
||||||
)
|
)
|
||||||
|
|
||||||
var digests []bls.Digest
|
var wg sync.WaitGroup
|
||||||
for _, c := range msgs {
|
|
||||||
digests = append(digests, bls.Hash(bls.Message(c.Bytes())))
|
digests := make([]bls.Digest, len(msgs))
|
||||||
|
for i := 0; i < 10; i++ {
|
||||||
|
wg.Add(1)
|
||||||
|
go func(w int) {
|
||||||
|
defer wg.Done()
|
||||||
|
for j := 0; (j*10)+w < len(msgs); j++ {
|
||||||
|
digests[j*10+w] = bls.Hash(bls.Message(msgs[j*10+w].Bytes()))
|
||||||
|
}
|
||||||
|
}(i)
|
||||||
}
|
}
|
||||||
|
wg.Wait()
|
||||||
|
|
||||||
var bsig bls.Signature
|
var bsig bls.Signature
|
||||||
copy(bsig[:], sig.Data)
|
copy(bsig[:], sig.Data)
|
||||||
|
Loading…
Reference in New Issue
Block a user