refactor(network): validate aligned header range payloads#298
Conversation
|
Note Complete: Audit complete. V12 did not find any issues that need review. Open the full results here. Analyzed 13 files, diff |
Make request geometry and delivered per-height data structurally checked before overlap and root-authentication scheduling reuse them.
Keep checked range failures fallible through the optional suffix path and satisfy the strict unwrap-in-result lint.
004361b to
975730a
Compare
evan-forbes
left a comment
There was a problem hiding this comment.
we're free to make breaks atm
therefore if its easier to just stick everything in a struct and have a single vector then I'm down
we can even include the request ids in the message
generally not against so I don't want to block, but I think we could also still find a better solution
| #[error( | ||
| "Zakura header-sync range starting at {start:?} has invalid or overflowing count {count}" | ||
| )] | ||
| InvalidRangeGeometry { |
There was a problem hiding this comment.
personally find the name geometry here unconventional and not intuitive
perhaps we could just say, invalid range
There was a problem hiding this comment.
Ah, this was an initial AI choice. I thought I renamed everything, but it looks like this one remained. Changing
|
I am making a follow-up PR to address the comments |
Motivation
Header-sync range geometry is currently represented by loose
start_heightandcountfields, while headers, body-size hints, and tree-aux roots cross asynchronous boundaries as independent vectors. The upcoming root-authentication lane will reuse one response for operations with different prefixes, making unchecked arithmetic and independent slicing unsafe.PR #246 answered: “Which request and operation produced this completion?”
This PR answers: “Exactly which heights and per-height data belong to that operation?”
Why this matters:
[F+1 … E+1]but authenticates only[F+1 … E]; the last header is a successor witness.HeaderRangePayload binds headers, body-size hints, and optional roots together. Trimming a prefix now slices all three atomically, preventing roots or counts from becoming associated with the wrong header.
This is prerequisite scaffolding only. It does not yet:
The next design step can therefore implement state-owned root persistence knowing that network responses have exact identities, checked heights, and structurally aligned data.
Solution
CheckedHeaderRangefor non-empty, overflow-safe inclusive geometry and checked prefix/suffix operationsHeaderRangePayloadto validate and atomically slice headers, body sizes, and optional all-or-nothing rootsSpecifications & References