Drop server item cap for bounded chunk queries - #1490
Merged
Conversation
A chunk query with a specific end block already has its toBlock as a hard bound on the response range, so the itemsTarget/maxNumLogs cap only exists to guard against a denser-than-expected range. With client-side address filtering the server counts filtered-out items toward that cap, so it can truncate the range short and open a gap that then needs a gap-fill roundtrip. Stop sending a server cap for bounded chunk queries: SourceManager forwards None to the source when the query is a chunk with a set toBlock, and the maxNumLogs / maxNumInstructions inputs become optional through the HyperSync clients and the napi boundary. A bounded chunk's partial response is now always treated as genuine source-capacity evidence. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GqyCTGE239bpYGZ9UvfJDn
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (9)
📝 WalkthroughWalkthroughHyperSync log, instruction, and source item caps now accept optional values. Bounded fetch queries omit server-side caps, open-ended probes retain caps, and partial chunk responses update capacity evidence. Query sizing and related tests now use estimated item counts. ChangesOptional cap contracts and payloads
Fetch scheduling and dispatch
Validation updates
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant CrossChainState
participant FetchState
participant HyperSyncSource
participant HyperSyncClient
CrossChainState->>FetchState: request next query
FetchState->>HyperSyncSource: getItemsOrThrow(itemsTarget)
HyperSyncSource->>HyperSyncClient: send optional max cap
HyperSyncClient-->>HyperSyncSource: items response
HyperSyncSource-->>FetchState: query response
FetchState->>FetchState: update capacity from bounded partial response
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
Follow-up to dropping the server cap for bounded chunk queries. Every chunk/gap-fill query is bounded (its toBlock is sized to the source's range capacity), so it now carries itemsTarget None and sends no server cap; only open-ended probes, whose range isn't otherwise bounded, keep a cap (itemsTarget Some(itemsEst)). query.itemsTarget becomes option<int> and SourceManager forwards it straight through. itemsEst is now the sole query-sizing and budget-reservation unit. This retires the chunkItemsMultiplier headroom and the itemsTargetFloor: both only ever sized a bounded query's server cap, never the itemsEst-based reservation, so with bounded queries uncapped they no longer do anything. Drops the params from FetchState.getNextQuery, ChainState.getNextQuery, and CrossChainState's 1.5x/3x realtime headroom. Tests updated to the option representation and to assert itemsEst where they previously asserted the (now-absent) cap. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GqyCTGE239bpYGZ9UvfJDn
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.
What
Stop sending a server-side item cap (
maxNumLogs/maxNumInstructions) for chunk queries that have a specific end block.Why
A bounded chunk query already has its
toBlockas a hard bound on the response range, so theitemsTargetcap only ever existed to guard against a denser-than-expected range. With the recently added client-side address filtering (#1483), the server counts filtered-out items toward that cap, so it can truncate the range short — returning fewer blocks thantoBlock— and open a gap that then needs an extra gap-fill roundtrip. For bounded chunks the cap buys nothing and actively causes gaps.How
SourceManagerforwardsNoneas the item target to the source when the query is a chunk with a settoBlock; everything else keeps its cap.itemsTargetat theSource.getItemsOrThrowboundary becomesoption<int>(None= no cap).maxNumLogs(EVM) andmaxNumInstructions(SVM) become optional through the HyperSync ReScript clients and the Rust napi boundary (Option<i64>), mapping to the underlying HyperSync query's already-optional field.FetchStatecapacity heuristic: a bounded chunk's partial response is now always treated as genuine source-capacity evidence, since no self-inflicted cap could have truncated it. The old "cap hit preserves capacity" protection still applies to non-chunk bounded queries.query.itemsTargetstaysintinFetchState, so query sizing, budget reservation (itemsEst), and the cross-chain headroom accounting are unchanged — only the decision to forward it as a server cap moved to the dispatch boundary.Testing
cargo check(EVM + SVM napi)pnpm rescriptcompilesenvio,envio-tests,test_codegenFetchState_test99/99,SourceManager_test56/56,SvmHyperSyncSource_test3/3🤖 Generated with Claude Code
Generated by Claude Code
Summary by CodeRabbit
New Features
Bug Fixes