Skip to content

Commit

Permalink
[Backport] poller: skip if no new block is polled (#333) (#336)
Browse files Browse the repository at this point in the history
Part of
babylonlabs-io/babylon-integration-deployment#32

`latestBlockHeight` can be the current height if there is no new block
during this polling iteration, but `blockToRetrieve` is set
`cp.NextHeight()` , meaning that `blockToRetrieve` can be bigger than
`latestBlockHeight` by `1`.

This PR adds a check on `blockToRetrieve > lastestBlockHeight`, and
skips with some logging if this occurs
  • Loading branch information
SebastianElvis authored Feb 17, 2025
1 parent 0847cdf commit 17c0ec2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

### Bug Fixes

* [#333](https://github.com/babylonlabs-io/finality-provider/pull/333) poller: skip if no new block is polled
* [#328](https://github.com/babylonlabs-io/finality-provider/pull/328) Fix small bias in EOTS private key generation
* [#327](https://github.com/babylonlabs-io/finality-provider/pull/327) fix: no add failed cycles count when chain poller no found new blocks

Expand Down
14 changes: 11 additions & 3 deletions finality-provider/service/chain_poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (cp *ChainPoller) blocksWithRetry(start, end uint64, limit uint32) ([]*type
// no need return error when just no found new blocks,
// the chain to poller may not produce new blocks.
if len(block) == 0 {
cp.logger.Warn(
cp.logger.Debug(
"no blocks found for range",
zap.Uint64("start_height", start),
zap.Uint64("end_height", end),
Expand Down Expand Up @@ -255,9 +255,17 @@ func (cp *ChainPoller) pollChain() {
func (cp *ChainPoller) tryPollChain(latestBlock *types.BlockInfo, blockToRetrieve uint64) error {
var blocks []*types.BlockInfo
var err error
if blockToRetrieve == latestBlock.Height {

switch {
case blockToRetrieve > latestBlock.Height:
cp.logger.Debug(
"skipping block query as there is no new block",
zap.Uint64("next_height", blockToRetrieve),
zap.Uint64("latest_height", latestBlock.Height),
)
case blockToRetrieve == latestBlock.Height:
blocks = []*types.BlockInfo{latestBlock}
} else {
default:
blocks, err = cp.blocksWithRetry(blockToRetrieve, latestBlock.Height, cp.cfg.PollSize)
}

Expand Down

0 comments on commit 17c0ec2

Please sign in to comment.