Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
claravanstaden committed Sep 26, 2024
1 parent 0a200df commit e756c18
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions relayer/relays/beacon/header/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,6 @@ func (h *Header) findLatestCheckPoint(slot uint64) (state.FinalizedHeader, error
endIndex := startIndex + 1

syncCommitteePeriod := h.protocol.Settings.SlotsInEpoch * h.protocol.Settings.EpochsPerSyncCommitteePeriod
slotPeriodIndex := slot / syncCommitteePeriod
totalStates := syncCommitteePeriod * 20 // Total size of the circular buffer,
// https://github.com/paritytech/polkadot-sdk/blob/master/bridges/snowbridge/pallets/ethereum-client/src/lib.rs#L75

Expand All @@ -538,16 +537,16 @@ func (h *Header) findLatestCheckPoint(slot uint64) (state.FinalizedHeader, error
}
beaconState, err = h.writer.GetFinalizedHeaderStateByBlockRoot(beaconRoot)
if err != nil {
// As soon as it can't find a block root, it means the circular wrap around array is empty.
log.WithFields(log.Fields{"index": index, "blockRoot": beaconRoot.Hex()}).WithError(err).Info("searching for checkpoint on-chain failed")
break
}
statePeriodIndex := beaconState.BeaconSlot / syncCommitteePeriod

if beaconState.BeaconSlot < slot {
break
}
// Found the beaconState
if beaconState.BeaconSlot > slot && beaconState.BeaconSlot < slot+syncCommitteePeriod && slotPeriodIndex == statePeriodIndex {
if beaconState.BeaconSlot > slot && beaconState.BeaconSlot < slot+syncCommitteePeriod {
log.WithFields(log.Fields{"index": index}).Info("found it!")
break
}
Expand Down

0 comments on commit e756c18

Please # to comment.