diff --git a/.github/workflows/release-relayer.yml b/.github/workflows/release-relayer.yml index 0fae3ff1ea..481bb0978b 100644 --- a/.github/workflows/release-relayer.yml +++ b/.github/workflows/release-relayer.yml @@ -4,7 +4,7 @@ on: push: branches: - main - - release-v1.0.0 + - populate-checkpoint-fix workflow_dispatch: env: diff --git a/relayer/relays/beacon/header/header.go b/relayer/relays/beacon/header/header.go index d65f75ebca..b1d8645553 100644 --- a/relayer/relays/beacon/header/header.go +++ b/relayer/relays/beacon/header/header.go @@ -523,12 +523,15 @@ func (h *Header) findLatestCheckPoint(slot uint64) (state.FinalizedHeader, error return beaconState, fmt.Errorf("GetLastFinalizedStateIndex error: %w", err) } startIndex := uint64(lastIndex) - endIndex := uint64(0) + 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 - for index := startIndex; index >= endIndex; index-- { + for index := startIndex; index != endIndex; index = (index - 1 + totalStates) % totalStates { + log.WithFields(log.Fields{"index": index}).Info("searching for checkpoint on-chain") beaconRoot, err := h.writer.GetFinalizedBeaconRootByIndex(uint32(index)) if err != nil { return beaconState, fmt.Errorf("GetFinalizedBeaconRootByIndex %d, error: %w", index, err) @@ -538,6 +541,7 @@ func (h *Header) findLatestCheckPoint(slot uint64) (state.FinalizedHeader, error return beaconState, fmt.Errorf("GetFinalizedHeaderStateByBlockRoot %s, error: %w", beaconRoot.Hex(), err) } statePeriodIndex := beaconState.BeaconSlot / syncCommitteePeriod + if beaconState.BeaconSlot < slot { break }