fix(relay): fail closed when a batch cost exceeds the wire - #22
Closed
albertovincenzi wants to merge 1 commit into
Closed
fix(relay): fail closed when a batch cost exceeds the wire#22albertovincenzi wants to merge 1 commit into
albertovincenzi wants to merge 1 commit into
Conversation
Contributor
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.
Problem
Each item cost is a valid i64, but the relay summed all costs for a counter with unchecked addition. Two individually valid expensive items can exceed the i64 delta supported by kv.incr. Debug builds panic; optimized builds can wrap to a small or negative delta, which may let the batch through for free. The admitted-cost telemetry used the same unsafe accumulation and its lifetime atomic could wrap as well.
Fix
Dependency
This PR is intentionally based on #9 because the grouped-charge code first needs the shared-key deduplication implemented there. The review diff is one follow-up commit.
Review notes for Alice
The synthetic overflow charge uses delta i64::MAX and caps its max at i64::MAX - 1. That is deliberate: if the declared ceiling itself is i64::MAX, saturation alone would look like an exact fit and incorrectly apply. Once refused, prefix uses the original declared ceiling and admits the first item only.
Verification