-
Notifications
You must be signed in to change notification settings - Fork 6
Query caching #84
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
Query caching #84
Conversation
WalkthroughAdds Cap'n Proto caching: makes Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Server
rect rgb(220,235,255)
note over Client,Server: Two-stage cached query flow (when CapnProto.should_cache_queries = true)
Client->>Client: Check serialization_format.should_cache_queries
alt caching enabled
Client->>Client: Build QueryId cached request
Client->>Server: Send cached-query request (Query.body = queryId, cache headers)
Server->>Server: Lookup cache by QueryId
alt cache hit
Server-->>Client: CachedQueryResponse { queryResponse }
Client->>Client: read_query_response -> parse into ArrowResponse
Client-->>Client: return ArrowResponse
else cache miss
Server-->>Client: CachedQueryResponse { notCached }
Client->>Client: Fall back to full Query path
end
end
end
rect rgb(235,220,255)
note over Client,Server: Full query flow
Client->>Client: Build full Query request (body = query)
Client->>Server: Send full query
Server->>Server: Execute query
Server-->>Client: QueryResponse
Client->>Client: parse_query_response -> ArrowResponse
Client-->>Client: return ArrowResponse
end
Estimated code review effort🎯 5 (Critical) | ⏱️ ~120 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (4)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
hypersync-client/src/to_ethers.rs (2)
400-407: Fix incorrect error message.The error message says "Failed to convert field
value" but the field being converted isgas_price.Apply this diff to fix the error message:
gas_price: value .gas_price .map(|gas_price| { gas_price.try_into().map_err(|_| { - ConversionError::ConvertError("Failed to convert field `value`".into()) + ConversionError::ConvertError("Failed to convert field `gas_price`".into()) }) }) .transpose()?,
730-741: Fix incorrect error message.The error message says "Field
valueis null" but the field being checked isreward_type.Apply this diff to fix the error message:
reward_type: { let reward_type = reward_type.ok_or(ConversionError::MissingValue( - "Field `value` is null".into(), + "Field `reward_type` is null".into(), ))?;hypersync-net-types/src/transaction.rs (1)
351-354: Add the missing?when reading authorization items.
auth_list.get(i)returns aResult; without?the code won’t compile becauseAuthorizationSelection::from_readerexpects the reader, not the wrapper. Please propagate the result before invoking the reader.- let auth_reader = auth_list.get(i); - let auth_selection = AuthorizationSelection::from_reader(auth_reader)?; + let auth_reader = auth_list.get(i)?; + let auth_selection = AuthorizationSelection::from_reader(auth_reader)?;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
hypersync-net-types/src/__generated__/hypersync_net_types_capnp.rsis excluded by!**/__generated__/**
📒 Files selected for processing (14)
examples/all_erc20/src/main.rs(2 hunks)hypersync-client/src/config.rs(1 hunks)hypersync-client/src/lib.rs(6 hunks)hypersync-client/src/parse_response.rs(3 hunks)hypersync-client/src/to_ethers.rs(2 hunks)hypersync-client/tests/api_test.rs(1 hunks)hypersync-net-types/Cargo.toml(1 hunks)hypersync-net-types/hypersync_net_types.capnp(2 hunks)hypersync-net-types/src/block.rs(3 hunks)hypersync-net-types/src/lib.rs(2 hunks)hypersync-net-types/src/log.rs(3 hunks)hypersync-net-types/src/query.rs(6 hunks)hypersync-net-types/src/trace.rs(3 hunks)hypersync-net-types/src/transaction.rs(5 hunks)
🧰 Additional context used
🧬 Code graph analysis (6)
hypersync-net-types/src/block.rs (1)
hypersync-net-types/src/lib.rs (2)
populate_builder(52-52)populate_builder(66-81)
hypersync-client/src/parse_response.rs (2)
hypersync-client/src/lib.rs (3)
message(467-467)message(526-526)message_reader(496-497)hypersync-net-types/src/query.rs (8)
message(50-50)message(367-367)message(389-389)message(743-743)message(764-764)message_reader(84-84)message_reader(382-382)message_reader(404-404)
examples/all_erc20/src/main.rs (1)
hypersync-client/src/config.rs (2)
default(42-45)default(95-97)
hypersync-net-types/src/lib.rs (1)
hypersync-net-types/src/query.rs (4)
populate_builder(525-568)from_reader(90-117)from_reader(236-256)from_reader(572-613)
hypersync-client/src/lib.rs (1)
hypersync-client/src/parse_response.rs (2)
read_query_response(29-90)message_reader(98-99)
hypersync-net-types/src/query.rs (1)
hypersync-net-types/src/lib.rs (4)
from_reader(56-58)from_reader(89-99)populate_builder(52-52)populate_builder(66-81)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: test_release
- GitHub Check: test_dev
🔇 Additional comments (3)
hypersync-client/src/to_ethers.rs (3)
15-15: LGTM! Unused import removed.The removal of
Writefrom the import list is appropriate as it's not used in this module.
772-776: LGTM! Idiomatic Rust refactor.The simplified
filter_mapwithOption::mapis more concise and idiomatic than a manual unwrapping approach. It correctly filters outNonetopics while convertingSomevalues.
478-484: Verify silent defaulting to zero address.The
addressfield usesunwrap_or(ethers::types::Address::zero())instead of returning an error when the address is missing. This silently defaults to the zero address, which could mask missing data or cause unexpected behavior if the caller expects an error for missing addresses.Confirm whether this silent fallback is intentional for access list items.
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
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
hypersync-net-types/src/__generated__/hypersync_net_types_capnp.rsis excluded by!**/__generated__/**
📒 Files selected for processing (5)
hypersync-client/src/lib.rs(5 hunks)hypersync-net-types/Cargo.toml(2 hunks)hypersync-net-types/benches/compression.rs(2 hunks)hypersync-net-types/hypersync_net_types.capnp(2 hunks)hypersync-net-types/src/query.rs(4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- hypersync-net-types/Cargo.toml
🧰 Additional context used
🧬 Code graph analysis (3)
hypersync-client/src/lib.rs (1)
hypersync-client/src/parse_response.rs (2)
read_query_response(29-90)message_reader(98-99)
hypersync-net-types/benches/compression.rs (1)
hypersync-net-types/src/query.rs (12)
message(49-49)message(566-566)message(692-692)message(713-713)to_capnp_bytes(563-575)from_capnp_bytes(68-73)from_capnp_bytes(577-588)message_reader(71-71)message_reader(583-584)from_reader(77-109)from_reader(234-254)from_reader(499-540)
hypersync-net-types/src/query.rs (4)
hypersync-client/src/lib.rs (4)
message(449-449)message(508-508)message_reader(478-479)new(71-94)hypersync-net-types/benches/compression.rs (5)
message(329-329)from_capnp_bytes(348-354)message_reader(350-351)message_reader(359-360)to_capnp_bytes(336-340)hypersync-format/src/types/fixed_size_data.rs (1)
FixedSizeData(105-105)hypersync-net-types/src/lib.rs (4)
from_reader(56-58)from_reader(89-99)populate_builder(52-52)populate_builder(66-81)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: lint
- GitHub Check: test_dev
- GitHub Check: test_release
🔇 Additional comments (3)
hypersync-net-types/hypersync_net_types.capnp (1)
26-31: Schema updates LGTM
CachedQueryResponseand theQueryunion align cleanly with the caching flow; no issues spotted.hypersync-client/src/lib.rs (1)
425-503: Cap'n Proto caching flow looks solidThanks for threading the cached-query preflight and cleanly falling back—nothing concerning stood out in this segment.
hypersync-net-types/benches/compression.rs (1)
327-388: Benchmark helpers look goodThe shared helpers tidy up the Cap’n Proto setup without changing behavior—looks good to me.
Summary by CodeRabbit
New Features
Chores
Compatibility