Skip to content

Commit

Permalink
Caplin: fix validatorSet's CopyTo (#13818) (#13819)
Browse files Browse the repository at this point in the history
  • Loading branch information
Giulio2002 authored Feb 14, 2025
1 parent 1d14262 commit 0eb0ad8
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions cl/cltypes/solid/validator_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,17 @@ func (v *ValidatorSet) expandBuffer(newValidatorSetLength int) {
func (v *ValidatorSet) Append(val Validator) {
offset := v.EncodingSizeSSZ()
// we are overflowing the buffer? append.
if offset+validatorSize >= len(v.buffer) {
v.expandBuffer(v.l + 1)
v.phase0Data = append(v.phase0Data, Phase0Data{})
//if offset+validatorSize >= len(v.buffer) {
v.expandBuffer(v.l + 1)
v.phase0Data = append(v.phase0Data, Phase0Data{})
//}

if v.MerkleTree != nil {
v.MerkleTree.AppendLeaf()
}
v.zeroTreeHash(v.l)
copy(v.buffer[offset:], val)
copy(v.buffer[offset:], val)
if v.MerkleTree != nil {
v.MerkleTree.AppendLeaf()
}
v.zeroTreeHash(v.l)

if v.l >= len(v.phase0Data) {
for i := len(v.phase0Data); i < v.l+1; i++ {
v.phase0Data = append(v.phase0Data, Phase0Data{})
Expand Down Expand Up @@ -171,6 +172,7 @@ func (v *ValidatorSet) CopyTo(t *ValidatorSet) {
t.phase0Data = make([]Phase0Data, v.l)
copy(t.buffer, v.buffer)
copy(t.attesterBits, v.attesterBits)
t.buffer = t.buffer[:v.l*validatorSize]
t.attesterBits = t.attesterBits[:v.l]
}

Expand Down

0 comments on commit 0eb0ad8

Please sign in to comment.