Skip to content

Commit

Permalink
feat(relayer): pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sideninja committed Nov 4, 2024
1 parent cb96627 commit 627f518
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/cchain/provider/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ func newABCIFetchFunc(attCl atypes.QueryClient, cmtCl cmtservice.ServiceClient,
atts, ok, err := attsFromAtHeight(ctx, attCl, chainVer, fromOffset, 0)
if err != nil {
incQueryErr(endpoint)
return nil, cursor, errors.Wrap(err, "abci query attestations-from")
return nil, 0, errors.Wrap(err, "abci query attestations-from")
} else if ok {
binarySearchStepsMetric(chainName, 0)
lookbackStepsMetric(chainName, 0)
Expand All @@ -367,7 +367,7 @@ func newABCIFetchFunc(attCl atypes.QueryClient, cmtCl cmtservice.ServiceClient,
earliestAttestationAtLatestHeight, ok, err := queryEarliestAttestation(ctx, attCl, chainVer, 0)
if err != nil {
incQueryErr(endpoint)
return nil, cursor, errors.Wrap(err, "abci query earliest-attestation-in-state")
return nil, 0, errors.Wrap(err, "abci query earliest-attestation-in-state")
}

// Either no attestations have happened yet, or the queried fromOffset is in the "future"
Expand All @@ -379,7 +379,7 @@ func newABCIFetchFunc(attCl atypes.QueryClient, cmtCl cmtservice.ServiceClient,

latestBlockResp, err := cmtCl.GetLatestBlock(ctx, &cmtservice.GetLatestBlockRequest{})
if err != nil {
return []xchain.Attestation{}, cursor, errors.Wrap(err, "query latest block")
return []xchain.Attestation{}, 0, errors.Wrap(err, "query latest block")
}

latestHeight := uint64(latestBlockResp.SdkBlock.Header.Height)
Expand All @@ -391,22 +391,22 @@ func newABCIFetchFunc(attCl atypes.QueryClient, cmtCl cmtservice.ServiceClient,
searchStart, searchEnd, err = lookbackRange(ctx, attCl, chainVer, chainName, fromOffset, latestHeight)
if err != nil {
incQueryErr(endpoint)
return nil, cursor, errors.Wrap(err, "lookback search")
return nil, 0, errors.Wrap(err, "lookback search")
}
}

offsetHeight, err := binarySearch(ctx, attCl, chainVer, chainName, fromOffset, searchStart, searchEnd)
if err != nil {
incQueryErr(endpoint)
return nil, cursor, errors.Wrap(err, "binary search")
return nil, 0, errors.Wrap(err, "binary search")
}

atts, ok, err = attsFromAtHeight(ctx, attCl, chainVer, fromOffset, offsetHeight)
if err != nil {
incQueryErr(endpoint)
return nil, cursor, errors.Wrap(err, "abci query attestations-from")
return nil, 0, errors.Wrap(err, "abci query attestations-from")
} else if !ok {
return nil, cursor, errors.New("expected to find attestations [BUG]")
return nil, 0, errors.New("expected to find attestations [BUG]")
}

return atts, offsetHeight, nil
Expand Down

0 comments on commit 627f518

Please sign in to comment.