You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
poll new blocks in the committer when in live mode (#226)
### TL;DR
Added support for real-time block committing in addition to backfill mode.
### What changed?
- Added a new `getBlockToCommitUntil` function that determines the end block for committing based on work mode
- In real-time mode, the committer now checks the latest block from RPC and uses that as the upper bound if it's less than the calculated end block
- Created a `fetchBlockDataToCommit` function that handles different data retrieval strategies based on work mode:
- In backfill mode: retrieves data from staging storage
- In real-time mode: uses a `BoundlessPoller` to fetch data directly without saving to staging first
- Updated the `getBlockNumbersToCommit` function to accept a context parameter
- Refactored `getSequentialBlockDataToCommit` to use the new functions
### How to test?
1. Run the application in real-time mode and verify it correctly commits blocks up to the latest block from RPC
2. Run the application in backfill mode and verify it commits blocks in batches of `blocksPerCommit`
3. Verify that when switching between modes, the committer correctly adjusts its behavior
### Why make this change?
This change enables the committer to operate in two distinct modes:
1. Backfill mode: for historical data processing where blocks are first staged then committed
2. Real-time mode: for processing current blocks directly from the RPC without staging
This dual-mode approach improves efficiency by allowing real-time processing to skip the staging step when immediate data is needed, while maintaining the ability to process historical data in batches.
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
- **New Features**
- Improved block data fetching logic to dynamically adjust commit ranges based on current mode and blockchain state.
- **Bug Fixes**
- Updated gap handling to skip unnecessary operations in live mode, reducing redundant processing.
- **Tests**
- Enhanced test coverage to reflect new context-based method signatures and work mode handling.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
returnnil, fmt.Errorf("error fetching blocks to commit: %v", err)
201
+
returnnil, err
159
202
}
160
203
iflen(blocksData) ==0 {
161
-
log.Warn().Msgf("Committer didn't find the following range in staging: %v - %v", blocksToCommit[0].Int64(), blocksToCommit[len(blocksToCommit)-1].Int64())
log.Debug().Msgf("Skipping gap handling in live mode. Expected block %s, actual first block %s", expectedStartBlockNumber.String(), actualFirstBlock.Number.String())
0 commit comments