mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-21 19:20:39 +00:00
Added concurrent bls (#7709)
This commit is contained in:
parent
4d35e776da
commit
63006611ec
@ -160,6 +160,8 @@ func (b *Eth1Block) DecodeSSZ(buf []byte, version int) error {
|
||||
b.Extra = solid.NewExtraData()
|
||||
b.Transactions = &solid.TransactionsSSZ{}
|
||||
b.Withdrawals = solid.NewStaticListSSZ[*types.Withdrawal](16, 44)
|
||||
b.DataGasUsed = new(uint64)
|
||||
b.ExcessDataGas = new(uint64)
|
||||
b.version = clparams.StateVersion(version)
|
||||
return ssz2.UnmarshalSSZ(buf, version, b.getSchema()...)
|
||||
}
|
||||
@ -181,7 +183,7 @@ func (b *Eth1Block) getSchema() []interface{} {
|
||||
s = append(s, b.Withdrawals)
|
||||
}
|
||||
if b.version >= clparams.DenebVersion {
|
||||
s = append(s, &b.DataGasUsed, &b.ExcessDataGas)
|
||||
s = append(s, b.DataGasUsed, b.ExcessDataGas)
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
@ -1,14 +1,11 @@
|
||||
//go:build spectest
|
||||
|
||||
// once all tests are implemented, we can allow this test in the ci build path
|
||||
|
||||
package spectest
|
||||
|
||||
import (
|
||||
"github.com/ledgerwatch/erigon/cl/transition"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/ledgerwatch/erigon/cl/transition"
|
||||
|
||||
"github.com/ledgerwatch/erigon/cl/spectest/consensus_tests"
|
||||
|
||||
"github.com/ledgerwatch/erigon/spectest"
|
||||
|
@ -4,11 +4,12 @@ import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"github.com/ledgerwatch/erigon/cl/transition/impl/eth2/statechange"
|
||||
"github.com/ledgerwatch/erigon/metrics/methelp"
|
||||
"golang.org/x/exp/slices"
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/common"
|
||||
"github.com/ledgerwatch/erigon/cl/cltypes/solid"
|
||||
@ -704,21 +705,43 @@ func processAttestation(s *state.BeaconState, attestation *solid.Attestation, ba
|
||||
}
|
||||
|
||||
func verifyAttestations(s *state.BeaconState, attestations *solid.ListSSZ[*solid.Attestation], attestingIndicies [][]uint64) (bool, error) {
|
||||
var err error
|
||||
valid := true
|
||||
indexedAttestations := make([]*cltypes.IndexedAttestation, 0, attestations.Len())
|
||||
attestations.Range(func(idx int, a *solid.Attestation, _ int) bool {
|
||||
indexedAttestation := state.GetIndexedAttestation(a, attestingIndicies[idx])
|
||||
valid, err = state.IsValidIndexedAttestation(s.BeaconState, indexedAttestation)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
if !valid {
|
||||
return false
|
||||
}
|
||||
indexedAttestations = append(indexedAttestations, state.GetIndexedAttestation(a, attestingIndicies[idx]))
|
||||
return true
|
||||
})
|
||||
|
||||
return valid, err
|
||||
return batchVerifyAttestations(s, indexedAttestations)
|
||||
}
|
||||
|
||||
type indexedAttestationVerificationResult struct {
|
||||
valid bool
|
||||
err error
|
||||
}
|
||||
|
||||
// Concurrent verification of BLS.
|
||||
func batchVerifyAttestations(s *state.BeaconState, indexedAttestations []*cltypes.IndexedAttestation) (valid bool, err error) {
|
||||
c := make(chan indexedAttestationVerificationResult, 1)
|
||||
|
||||
for idx := range indexedAttestations {
|
||||
go func(idx int) {
|
||||
valid, err := state.IsValidIndexedAttestation(s.BeaconState, indexedAttestations[idx])
|
||||
c <- indexedAttestationVerificationResult{
|
||||
valid: valid,
|
||||
err: err,
|
||||
}
|
||||
}(idx)
|
||||
}
|
||||
for i := 0; i < len(indexedAttestations); i++ {
|
||||
result := <-c
|
||||
if result.err != nil {
|
||||
return false, err
|
||||
}
|
||||
if !result.valid {
|
||||
return false, nil
|
||||
}
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (I *impl) ProcessBlockHeader(s *state.BeaconState, block *cltypes.BeaconBlock) error {
|
||||
|
@ -2,7 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"net/http"
|
||||
|
||||
"github.com/ledgerwatch/erigon/turbo/debug"
|
||||
|
||||
"github.com/ledgerwatch/erigon/cl/cltypes"
|
||||
"github.com/ledgerwatch/erigon/cl/phase1/forkchoice"
|
||||
@ -41,13 +42,7 @@ func main() {
|
||||
)
|
||||
if *pprof {
|
||||
// Server for pprof
|
||||
go func() {
|
||||
log.Info("Serving pprof on localhost:6060")
|
||||
if err := http.ListenAndServe("localhost:6060", nil); err != nil { //nolint:gosec
|
||||
log.Error("Could not serve pprof", "err", err)
|
||||
}
|
||||
|
||||
}()
|
||||
debug.StartPProf("localhost:6060", true)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
2
go.mod
2
go.mod
@ -14,7 +14,7 @@ require (
|
||||
require (
|
||||
gfx.cafe/util/go/generic v0.0.0-20230502013805-237fcc25d586
|
||||
github.com/99designs/gqlgen v0.17.32
|
||||
github.com/Giulio2002/bls v0.0.0-20230507111335-fa36c339a11f
|
||||
github.com/Giulio2002/bls v0.0.0-20230611172327-c0b9800e7b57
|
||||
github.com/RoaringBitmap/roaring v1.2.3
|
||||
github.com/VictoriaMetrics/fastcache v1.12.1
|
||||
github.com/VictoriaMetrics/metrics v1.23.1
|
||||
|
4
go.sum
4
go.sum
@ -18,8 +18,8 @@ git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGy
|
||||
github.com/99designs/gqlgen v0.17.32 h1:yX5On31oZ8I4dAfgZeeR/A8L9SWk+nD+cF8Aao4vmHs=
|
||||
github.com/99designs/gqlgen v0.17.32/go.mod h1:5j5Ak84e9FTYtH3aaNhK+FoYzXdUAY9CahQcWDqOwR8=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/Giulio2002/bls v0.0.0-20230507111335-fa36c339a11f h1:7H8fhLJwlYAzzVUE1bQsQZjJBg8Rw+x5IZyb3i7PfZw=
|
||||
github.com/Giulio2002/bls v0.0.0-20230507111335-fa36c339a11f/go.mod h1:o6qWofeW8A1XImbo3eHbC/wXnw/dasu0YuHEtdrjYzw=
|
||||
github.com/Giulio2002/bls v0.0.0-20230611172327-c0b9800e7b57 h1:583GFQgWYOAz3dKqHqARVY3KkgebRcJtU4tzy+87gzc=
|
||||
github.com/Giulio2002/bls v0.0.0-20230611172327-c0b9800e7b57/go.mod h1:vwm1rY/WKYdwv5Ii5US2bZ3MQVcHadnev+1Ml2QYWFk=
|
||||
github.com/RoaringBitmap/roaring v0.4.7/go.mod h1:8khRDP4HmeXns4xIj9oGrKSz7XTQiJx2zgh7AcNke4w=
|
||||
github.com/RoaringBitmap/roaring v0.4.17/go.mod h1:D3qVegWTmfCaX4Bl5CrBE9hfrSrrXIr8KVNvRsDi1NI=
|
||||
github.com/RoaringBitmap/roaring v0.4.23/go.mod h1:D0gp8kJQgE1A4LQ5wFLggQEyvDi06Mq5mKs52e1TwOo=
|
||||
|
Loading…
Reference in New Issue
Block a user