fix: node: bound the number of hops a forwarded request may take #11
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 311 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.344
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #11"
general
weight: 0.35
lichuang
Finding
P2 — a forwarded request has no hop limit, so two confused nodes can bounce it forever.
handle_forward_requestre-entersexecute_or_forward. If node A's metrics say the leader is B and node B's say it is A (stale metrics after a partition, or a leader that has not noticed its demotion), the request bounces between them.RETRY_TOTAL_BUDGETis per hop and the request carries no hop information, so client-visible latency is unbounded and every bounce holds a pooled connection.The fix
MAX_FORWARD_HOPS = 3; the hop count travels in the gRPCRaftRequestenvelope (uint32 hops = 2), not in the postcardForwardRequest.LeaderTransitionerror, so the origin re-resolves leadership instead of extending the chain.hops = 0, so the bound only applies to the forwarding chain.RaftNode::handle_forward_requestis nowpub(crate): the gRPC service is its only meaningful caller.NetworkConnection::forward, which hardcodedhops: 0and would have silently reset the counter.Why the envelope, not
ForwardRequestpostcard decodes structs by fixed field count: an old request (no
hops) fails on a new node withDeserializeUnexpectedEnd, and#[serde(default)]does not help there. The reverse direction ignores trailing bytes, so compatibility was asymmetric. The protobuf envelope is additive: old nodes ignore the unknown field and new nodes default tohops = 0, so mixed versions keep decoding in both directions.Rolling upgrades
An old node does not propagate the field, so it resets the count to 0. During a rolling upgrade the 3-hop bound is therefore enforced only between nodes that understand it; once every node is upgraded it is fully effective. There are no decode failures in either direction.
Tests
test_hop_budget_is_finitecoversmay_forward, includingu32::MAXfrom a peer.test_hop_count_roundtrips_in_the_envelopechecks the postcard body stays independently decodable and the protobuf envelope carrieshops.test_old_envelope_decodes_with_zero_hopsdecodes an envelope with only field 1 and verifieshops = 0.cargo fmt --check,cargo clippy --all-features --all-targets -- -D warningsandcargo testpass.