Repository navigation
fix(node): feed RegionAccountant on delivered node→node pulls (#858) - #886
Conversation
`RegionAccountant::record_pulled` had zero production callers: #831/#834 landed the node-to-node cache-miss pull orchestrator but never wired the accountant into it, so `bytes_in` stayed 0 in admin_v1_regionStats and the periodic region_bandwidth log even while paid pulls flowed — the surface operators use to reconcile pull spend by region (#750). Pass the runtime's existing Arc<RegionAccountant> into NodeOriginDeps and call record_pulled(&candidate.node_id, bytes.len()) in the delivered (Ok) arm of pull_from_candidate, mirroring the serve path's record_served. On a full delivery paid bytes == blob length; partially-paid failed pulls are intentionally not counted. Extends the headline pull test to assert bytes_in accumulates for the upstream peer's region, and refreshes the now-stale record_pulled doc. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request integrates the RegionAccountant into the node-to-node pull orchestrator (NodeOrigin). It adds region_accountant to NodeOriginDeps and records inbound bytes via record_pulled upon successful delivery from a candidate node. Additionally, the changes update relevant tests to assert that delivered pulls correctly increment the inbound byte count for the respective region. There are no review comments, so I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Coverage reportTotal: 86.17% (was 86.17%, ● 0.00%) — 35461/41152 lines
History
|
There was a problem hiding this comment.
Pull request overview
This PR fixes missing per-region inbound bandwidth accounting for node→node paid pull-through by wiring RegionAccountant::record_pulled into the NodeOrigin pull orchestrator, so bytes_in is correctly reflected in admin_v1_regionStats and periodic region bandwidth logs (fixes #858).
Changes:
- Add
region_accountant: Arc<RegionAccountant>toNodeOriginDepsand pass it from the runtime. - Record inbound bytes on successful (
Ok) node→node pulls viarecord_pulled(&candidate.node_id, bytes.len() as u64). - Extend the main node-origin pull integration test to assert
bytes_inis incremented for a resolvable upstream region.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/node/src/node_origin.rs | Adds region_accountant to deps and records inbound bytes on delivered pulls. |
| crates/node/src/runtime/mod.rs | Wires the runtime’s existing region_accountant into NodeOriginDeps. |
| crates/node/src/region_accounting.rs | Updates record_pulled doc comment to reflect the now-wired production call path. |
| crates/node/tests/node_origin_pull.rs | Adds a stub region resolver/accountant plumbing and asserts bytes_in updates after a delivered pull. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ng comment Follow-up to PR review of #858: - Extend node_origin_pull_falls_through_a_stalled_candidate to map the stalled (Err-arm) and delivered (Ok-arm) candidates to distinct regions and assert the snapshot counts only the delivered one — guarding the "partially-paid failed pulls are not counted" contract and multi-candidate attribution in a single assertion. - Tighten the record_pulled call-site comment: payment is incremental per voucher interval (the whole-blob hash check makes bytes.len() == paid cumulative on a full Ok delivery), and region bytes_in tracks delivered, not spent, bytes — so it diverges from the voucher watermark on failed pulls by design. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request integrates the RegionAccountant into the node-to-node pull path (NodeOrigin). Specifically, it adds region_accountant to NodeOriginDeps and records inbound bytes via record_pulled upon successful cache-miss pull-through deliveries. The tests in node_origin_pull.rs have been updated to inject stubbed region accountants and assert that inbound bytes are correctly attributed to the upstream node's region on successful deliveries, while failed or stalled pulls are excluded. There are no review comments to evaluate, and we have no further feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Summary
Fixes #858.
RegionAccountant::record_pulledhad zero production callers — #831/#834 landed the node-to-node cache-miss pull orchestrator (node_origin.rs) but never wired the accountant into it. Result:bytes_instayed0inadmin_v1_regionStatsand the periodicregion_bandwidthlog line even whilecache.node_to_node_pull_through_enabledpulls paid for inbound bytes — exactly the surface an operator uses to reconcile pull spend by region (#750).Change
region_accountant: Arc<RegionAccountant>toNodeOriginDeps(mirrors the requiredmetricsfield).record_pulled(&candidate.node_id, bytes.len())in the delivered (Ok) arm ofpull_from_candidate, right afterrecord_outcome(... Delivered ...)— the inbound counterpart of the serve path'srecord_served(handlers/client.rs). On a full delivery paid bytes == blob length. Partially-paid failed pulls (theErrarm) are intentionally not counted.region_accountantintoNodeOriginDepsinruntime/mod.rs.record_pulleddoc comment (it still claimed "the future pull orchestrator calls this; until then bytes_in reads 0").Tests
node_origin_pull_fills_and_records_reputationto map upstream A to regionDEand assertsnapshot()reportsbytes_in == total_bytesfor that region after a delivered pull. Sincerecord_pulledhas no other production caller, this fails without the wiring.StubRegionResolver+provisioned_origin_with_accountanttest helper; other tests use a default empty-region accountant.Verification
cargo build -p decdn-node✅cargo clippy -p decdn-node --all-targets✅ (anti-panic lints clean)cargo fmt -- --check✅cargo nextest run -p decdn-node— 486 lib tests + 11node_origin_pull+ 8 region tests all pass ✅No dependency changes (Cargo.lock untouched).
🤖 Generated with Claude Code