mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 13:28:01 -05:00
removing redundant loop in computeOnChainAggregate (#15108)
* removing redundant loop * Update beacon-chain/rpc/prysm/v1alpha1/validator/proposer_attestations_electra.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * removing unused import * replacing with more used function * resolving Unsafe cast from uint64 to int error --------- Co-authored-by: Radosław Kapka <rkapka@wp.pl>
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
package validator
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
"slices"
|
||||
|
||||
"github.com/prysmaticlabs/go-bitfield"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v5/crypto/bls"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
@@ -58,11 +58,11 @@ func computeOnChainAggregate(aggregates []ethpb.Att) ([]ethpb.Att, error) {
|
||||
|
||||
for _, aggs := range aggsByDataRoot {
|
||||
slices.SortFunc(aggs, func(a, b ethpb.Att) int {
|
||||
return a.CommitteeBitsVal().BitIndices()[0] - b.CommitteeBitsVal().BitIndices()[0]
|
||||
return cmp.Compare(a.GetCommitteeIndex(), b.GetCommitteeIndex())
|
||||
})
|
||||
|
||||
sigs := make([]bls.Signature, len(aggs))
|
||||
committeeIndices := make([]primitives.CommitteeIndex, len(aggs))
|
||||
cb := primitives.NewAttestationCommitteeBits()
|
||||
aggBitsIndices := make([]uint64, 0)
|
||||
aggBitsOffset := uint64(0)
|
||||
var err error
|
||||
@@ -74,7 +74,7 @@ func computeOnChainAggregate(aggregates []ethpb.Att) ([]ethpb.Att, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
committeeIndices[i] = helpers.CommitteeIndices(a.CommitteeBitsVal())[0]
|
||||
cb.SetBitAt(uint64(a.GetCommitteeIndex()), true)
|
||||
|
||||
aggBitsOffset += a.GetAggregationBits().Len()
|
||||
}
|
||||
@@ -84,16 +84,12 @@ func computeOnChainAggregate(aggregates []ethpb.Att) ([]ethpb.Att, error) {
|
||||
aggregationBits.SetBitAt(bi, true)
|
||||
}
|
||||
|
||||
cb := primitives.NewAttestationCommitteeBits()
|
||||
att := ðpb.AttestationElectra{
|
||||
AggregationBits: aggregationBits,
|
||||
Data: aggs[0].GetData(),
|
||||
CommitteeBits: cb,
|
||||
Signature: bls.AggregateSignatures(sigs).Marshal(),
|
||||
}
|
||||
for _, ci := range committeeIndices {
|
||||
att.CommitteeBits.SetBitAt(uint64(ci), true)
|
||||
}
|
||||
result = append(result, att)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
### Ignored
|
||||
|
||||
- small optimization on the computeOnChainAggregate function
|
||||
Reference in New Issue
Block a user