Change itemsTarget from float to int for query budgeting - #1395
Merged
DZakh merged 10 commits intoJul 9, 2026
Merged
Conversation
…ensity - Floor itemsTarget at 1 at creation (densityItemsTarget, water-fill chunk loop, probe) so a query's budget reservation always equals the maxNumLogs-style cap sent to the server; drop SourceManager's 2000-item fallback that let density-0 queries return up to 2000 unaccounted items. - Emit density-priced chunks only for a trusted positive density; density-0 and unknown-density partitions get a single open-ended probe sized at the even split of the tick's fresh budget (maxItemsTarget cap removed). This removes the chunkCost=0 path that flooded 10 free hard-bounded chunks per partition and froze the 1.8x range growth. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01McpcXkR3pPWfEcq4mCj9Sw
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01McpcXkR3pPWfEcq4mCj9Sw
The ceil-to-int conversion now happens once at query creation, so the reservation, the budget accounting, and the server cap all use the same integer value; SourceManager passes it through untouched. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01McpcXkR3pPWfEcq4mCj9Sw
Gap queries now use getTrustedDensity: chunks only on a trusted positive density (same rule as the water-fill); a trusted-zero density prices the whole gap as one open query, and a partition with no density signal prices it by available density — its equal-divide budget spread over the remaining range this tick — so a small gap reserves proportionally little instead of a noisy one-sample estimate or a NaN from dividing by a zero range. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01McpcXkR3pPWfEcq4mCj9Sw
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
Chains beyond the most-behind one in the budget waterfall are now capped at that leader's target progress, mapped onto their own block range (ChainState.progressAtBlock/blockAtProgress), so no chain runs further ahead than the chain the shared buffer pool is prioritizing. A chain visited after the pool is exhausted simply sits out the round — its reservations release as responses land, so the next tick redistributes. FetchState's dynamic-contract partition merge now inherits the sum of its parents' trusted densities (weighted onto the merged partition's min query range) instead of resetting to 0, so a merge with density history doesn't regress to an unpriced probe. Update E2E/rollback tests to the now-serialized cross-chain query dispatch (most-behind chain queries first; siblings follow once its response releases budget) and to give density-dependent chunking tests a nonzero item count to trust. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01McpcXkR3pPWfEcq4mCj9Sw
When a chain's target block is clamped (head, endBlock, or the cross-chain alignment cap), a known-density chain's fresh budget is now capped at density x clamped range (in-flight reservations stay on top so they don't crowd out new partitions). The unused remainder stays in the waterfall's pool and flows to the next chain in the same tick, instead of being held by an oversized probe until the response lands. This also removes the drain loop the infinite-reorg-loop test needed: the non-reorg chain's post-rollback refetch now reserves only its real range cost, so the reorg chain gets budget immediately. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01McpcXkR3pPWfEcq4mCj9Sw
A query clamped at the head sized exactly at density x range truncates at the server cap whenever the range is slightly denser than the estimate, forcing an immediate catch-up query for the last few blocks. Double the range cost for head-bound targets so one query usually suffices; the extra reservation releases as soon as the response lands. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01McpcXkR3pPWfEcq4mCj9Sw
…droom - targetBlock now clamps at endBlock (when below the head) via a shared fetchCeiling helper, so endBlock'd chains stop sizing and aligning against range they'll never fetch. - A chain with no positive density signal caps its fresh budget at 5k, so one unknown chain measuring its first responses no longer holds the whole cross-chain pool. - Head/endBlock-bound queries get 3x (was 2x) density headroom against truncating at the server cap and needing a catch-up query. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01McpcXkR3pPWfEcq4mCj9Sw
Remove redundant & references in format!/anyhow! arguments flagged by the CI-pinned clippy (rust 1.97). Pre-existing on the base branch, unrelated to the SourceManager/waterfall changes in this PR — fixed here since it was blocking cargo-test from going green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01McpcXkR3pPWfEcq4mCj9Sw
Removing the redundant & in anyhow!'s self.id.to_string() surfaced a second lint on the same line: ChainId (u64) already implements Display, so .to_string() inside the format arg is itself redundant. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01McpcXkR3pPWfEcq4mCj9Sw
DZakh
merged commit Jul 9, 2026
74ed18f
into
claude/multichain-indexer-query-control-kebggn
8 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refactors the query budget system to use integers instead of floats for
itemsTarget, improving precision and simplifying budget calculations throughout the fetch state management.Key Changes
itemsTargetfield inqueryandpendingQuerytypes changed fromfloattointdensityItemsTargetfunction now:densityas a parameter instead of deriving it from partition stateintinstead offloatMath.ceilto density-based calculations and enforces a minimum of 1getTrustedDensityhelper function extracts density calculation logic, requiring two responses before trusting the estimatepushGapFillQueriesrefactored to:partitionBudgetparameter for calculating "available density" when no trusted density existsprobeItemsTargetonce per round as an even split of fresh budgetintitemsTarget tofloatat the point of useitemsTargetdirectly without ceiling/validation logic (now handled upstream)itemsTargetNotable Implementation Details
Pervasives.max(1, ...)) rather than a named constant, ensuring queries never ask the backend for 0 itemspartitionBudget / remainingRange, spreading the budget proportionally over remaining workhttps://claude.ai/code/session_01McpcXkR3pPWfEcq4mCj9Sw