Skip to content

Commit e3217b9

Browse files
committed
Kasey's feedback
1 parent e1497c9 commit e3217b9

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

beacon-chain/core/signing/signing_root.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,9 @@ func ComputeDomain(domainType [DomainByteLength]byte, forkVersion, genesisValida
247247

248248
// This returns the bls domain given by the domain type and fork data root.
249249
func domain(domainType [DomainByteLength]byte, forkDataRoot []byte) []byte {
250-
b := make([]byte, 32)
251-
copy(b[0:4], domainType[:4])
252-
copy(b[4:], forkDataRoot[:28])
250+
b := make([]byte, 0, 32)
251+
b = append(b, domainType[:4]...)
252+
b = append(b, forkDataRoot[:28]...)
253253
return b
254254
}
255255

beacon-chain/sync/validate_aggregate_proof.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package sync
22

33
import (
44
"context"
5+
"encoding/binary"
56
"fmt"
67

78
"github.com/OffchainLabs/prysm/v6/beacon-chain/blockchain"
@@ -265,9 +266,10 @@ func (s *Service) hasSeenAggregatorIndexEpoch(epoch primitives.Epoch, aggregator
265266
func (s *Service) setAggregatorIndexEpochSeen(epoch primitives.Epoch, aggregatorIndex primitives.ValidatorIndex) {
266267
s.seenAggregatedAttestationLock.Lock()
267268
defer s.seenAggregatedAttestationLock.Unlock()
269+
268270
b := make([]byte, 64)
269-
copy(b[0:32], bytesutil.Bytes32(uint64(epoch)))
270-
copy(b[32:], bytesutil.Bytes32(uint64(aggregatorIndex)))
271+
binary.BigEndian.PutUint64(b[24:], uint64(epoch))
272+
binary.BigEndian.PutUint64(b[56:], uint64(aggregatorIndex))
271273
s.seenAggregatedAttestationCache.Add(string(b), true)
272274
}
273275

crypto/bls/signature_batch.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,13 @@ func NewSet() *SignatureBatch {
3232

3333
// Join merges the provided signature batch to out current one.
3434
func (s *SignatureBatch) Join(set *SignatureBatch) *SignatureBatch {
35+
if cap(s.Signatures)-len(s.Signatures) < len(set.Signatures) &&
36+
cap(set.Signatures)-len(set.Signatures) >= len(s.Signatures) {
37+
return set.Join(s)
38+
}
39+
3540
total := len(s.Signatures) + len(set.Signatures)
3641

37-
// Preallocate capacity if needed
3842
if cap(s.Signatures) < total {
3943
newSigs := make([][]byte, len(s.Signatures), total)
4044
copy(newSigs, s.Signatures)
@@ -60,6 +64,7 @@ func (s *SignatureBatch) Join(set *SignatureBatch) *SignatureBatch {
6064
s.PublicKeys = append(s.PublicKeys, set.PublicKeys...)
6165
s.Messages = append(s.Messages, set.Messages...)
6266
s.Descriptions = append(s.Descriptions, set.Descriptions...)
67+
6368
return s
6469
}
6570

0 commit comments

Comments
 (0)