Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
domiwei committed Nov 9, 2024
1 parent 10dbf1d commit b0adf3f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
4 changes: 4 additions & 0 deletions cl/cltypes/solid/attestation.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ func (s *SingleAttestation) Clone() clonable.Clonable {
return &SingleAttestation{}
}

func (s *SingleAttestation) Static() bool {
return true
}

func (s *SingleAttestation) ToAttestation(memberIndexInCommittee int) *Attestation {
committeeBits := NewBitVector(maxCommitteesPerSlot)
aggregationBits := NewBitList(0, aggregationBitsSizeElectra)
Expand Down
32 changes: 19 additions & 13 deletions cl/cltypes/solid/bitlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,27 +128,17 @@ func (u *BitList) Set(index int, v byte) {
u.u[index] = v
}

func (u *BitList) SetOnBit(bitIndex int) {
if bitIndex >= u.c {
return
}
// remove the last on bit if nessary
func (u *BitList) removeMsb() {
for i := len(u.u) - 1; i >= 0; i-- {
if u.u[i] != 0 {
// find last bit, make a mask and clear it
u.u[i] &= ^(1 << uint(bits.Len8(u.u[i])-1))
break
}
}
// expand the bitlist if necessary
for len(u.u)*8 <= bitIndex {
u.u = append(u.u, 0)
}

// set the bit
u.u[bitIndex/8] |= 1 << uint(bitIndex%8)
}

// set last bit
func (u *BitList) addMsb() {
for i := len(u.u) - 1; i >= 0; i-- {
if u.u[i] != 0 {
msb := bits.Len8(u.u[i])
Expand All @@ -163,6 +153,22 @@ func (u *BitList) SetOnBit(bitIndex int) {
break
}
}
}

func (u *BitList) SetOnBit(bitIndex int) {
if bitIndex >= u.c {
return
}
// remove the last on bit if necessary
u.removeMsb()
// expand the bitlist if necessary
for len(u.u)*8 <= bitIndex {
u.u = append(u.u, 0)
}
// set the bit
u.u[bitIndex/8] |= 1 << uint(bitIndex%8)
// set last bit
u.addMsb()
u.l = len(u.u)
}

Expand Down
4 changes: 2 additions & 2 deletions cl/phase1/network/services/attestation_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ func (s *attestationService) ProcessMessage(ctx context.Context, subnet *uint64,
}
attestation = att.SingleAttestation.ToAttestation(memberIndexInCommittee)
} else {
// deneb and before case
root = att.Attestation.Data.BeaconBlockRoot
slot = att.Attestation.Data.Slot
committeeIndex = att.Attestation.Data.CommitteeIndex
Expand Down Expand Up @@ -350,8 +351,7 @@ func (a *attestationService) loop(ctx context.Context) {
return true
}

root := v.att.Attestation.Data.BeaconBlockRoot
if _, ok := a.forkchoiceStore.GetHeader(root); !ok {
if _, ok := a.forkchoiceStore.GetHeader(v.beaconRoot); !ok {
return true
}
a.ProcessMessage(ctx, &v.subnet, v.att)
Expand Down

0 comments on commit b0adf3f

Please sign in to comment.