-
Notifications
You must be signed in to change notification settings - Fork 19
poll new blocks in the committer when in live mode #226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
poll new blocks in the committer when in live mode #226
Conversation
Caution Review failedThe pull request is closed. """ WalkthroughThe pull request refactors the Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant Committer
participant Storage
participant RPC
participant Poller
Caller->>Committer: getSequentialBlockDataToCommit(ctx)
Committer->>Committer: getBlockNumbersToCommit(ctx)
Committer->>Committer: getBlockToCommitUntil(ctx, latestCommittedBlockNumber)
alt Backfill mode
Committer->>Storage: GetStagingBlockData(blockNumbers)
alt Data missing
Committer->>Committer: handleMissingStagingData()
end
else Live mode
Committer->>Poller: PollWithoutSaving(ctx, blockNumbers)
end
Committer-->>Caller: BlockData or nil
Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
This stack of pull requests is managed by Graphite. Learn more about stacking. |
6d7bf93
to
055b412
Compare
055b412
to
66f3a66
Compare
c3d9b2b
to
fdf67f3
Compare
66f3a66
to
4fafda1
Compare
fdf67f3
to
05ef01c
Compare
4fafda1
to
c3ca0b9
Compare
05ef01c
to
4450a45
Compare
c3ca0b9
to
30d792b
Compare
4450a45
to
ec67258
Compare
30d792b
to
55d5c67
Compare
c35218d
to
ca1698e
Compare
103b15d
to
e238656
Compare
ca1698e
to
4139a04
Compare
e238656
to
95bc3d5
Compare
95bc3d5
to
cc624f5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
internal/orchestrator/committer.go (1)
131-143
:⚠️ Potential issueGuard against
endBlock
precedingstartBlock
When the node is in live mode and the RPC’s latest block equals (or is less than) the last-committed block,
endBlock
can be ≤startBlock
.
The current code will compute a negativeblockCount
, panicking when creating the slice.+ if endBlock.Cmp(startBlock) < 0 { + return []*big.Int{}, nil + }Insert this short-circuit right before
blockCount
is calculated.
🧹 Nitpick comments (2)
internal/orchestrator/committer_test.go (1)
28-29
: Avoid reaching into unexported state from testsEvery test tweaks
committer.workMode
directly. That couples the test-suite to internal implementation details and will break as soon as the field becomes private/removed.
Prefer exercising the public surface instead, e.g.committer := NewCommitter(mockRPC, mockStorage, WithCommitterWorkModeChan(nil)) setWorkMode(committer, WorkModeBackfill) // helper that sends on the channelor expose a small setter used only in tests.
This keeps behaviour contracts intact while allowing the struct layout to evolve.Also applies to: 44-45, 68-69, 95-96, 122-123, 146-147, 173-174, 200-201, 225-226, 251-252, 286-287, 325-326, 351-352, 475-476, 522-523
internal/orchestrator/committer.go (1)
146-162
: Consider caching latest RPC block in live mode
getBlockToCommitUntil
hits the RPC every commit cycle.
On high-frequency triggers this becomes needless load. A lightweight cache with TTL (e.g. 1-2 s) would cut traffic while staying fresh enough for live committing.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
internal/orchestrator/committer.go
(4 hunks)internal/orchestrator/committer_test.go
(15 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
internal/orchestrator/committer_test.go (1)
internal/orchestrator/work_mode_monitor.go (1)
WorkModeBackfill
(21-21)
🔇 Additional comments (1)
internal/orchestrator/committer.go (1)
291-294
: Double-check metric semantics when skipping gap handling in live modeThe function increments
GapCounter
/MissedBlockNumbers
even when live mode intentionally ignores gaps.
If gaps are expected in live streaming this will inflate the metrics and trigger alerts.Verify the desired behaviour; otherwise move the increment after the live-mode early-return.
cc624f5
to
abb607d
Compare
TL;DR
Added support for real-time block committing in addition to backfill mode.
What changed?
getBlockToCommitUntil
function that determines the end block for committing based on work modefetchBlockDataToCommit
function that handles different data retrieval strategies based on work mode:BoundlessPoller
to fetch data directly without saving to staging firstgetBlockNumbersToCommit
function to accept a context parametergetSequentialBlockDataToCommit
to use the new functionsHow to test?
blocksPerCommit
Why make this change?
This change enables the committer to operate in two distinct modes:
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.
Summary by CodeRabbit