Repository navigation
fix(node): start a source's warming allowance full, per ADR 041 - #2003
Merged
Merged
Conversation
A never-touched source's warming ledger started at zero, so a single speculative buy served once (net fee skim) cut the source off from every further market-price buy. ADR 041 gives each source an allowance capped at B that duds spend down, cutting the source off only once B is exhausted. At 0.5 USDC/MB one tiny warm-up blob drove the seeder negative in the node_pull_topup e2e, so the next node-to-node pull refused BelowMargin and the client saw a clean NotFound (#1893). The e2e now gets past that gate and stalls later on a separate, rate-independent fused serve-miss pull stall; its ignore reason and doc comment now describe that blocker. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013p4vAEc4scVHADBqA44K9j
Coverage reportTotal: 82.74% (was 82.74%, ● 0.00%) — 77147/93241 lines
History
|
With every source starting full, a budget-sized debit plus one serve credit already reads as available, so the vindication tests no longer told one serve from two. Each now spends the source down first so only the second credit flips it. credit_is_capped_at_budget asserts on the credited source, debt_is_floored_at_minus_budget pins the floor, and the blacklist-watcher fixture gets a real budget so its forget-the-tag assertion can fail. Docs: debit_speculative states the concurrent overshoot and what the floor bounds; the node_pull_topup doc and ignore reason name #1893 and drop one-off measurements; leftover "more negative" and plan-task wording goes. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013p4vAEc4scVHADBqA44K9j
There was a problem hiding this comment.
🟡 Changes recommended
A moderate concurrency race can discard early serve credits, and documentation follow-ups remain unresolved.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
This PR starts each source’s warming ledger at its full budget and updates related tests, documentation, and blocker notes.
Changes:
- Initializes first-use allowances at
budget. - Updates allowance, integration, and fixture tests.
- Revises terminology and documents the remaining node-pull stall.
File summaries
| File | Summary |
|---|---|
crates/node/tests/node_origin_pull.rs |
Updated dud-flood and vindication coverage. |
crates/node/tests/client_loopback.rs |
Updated asynchronous credit aggregation setup. |
crates/node/src/warming_allowance.rs |
Implements full-budget initialization. Moderate: tag publication can race with initial debit and discard early serve credits; add regression coverage. |
crates/node/src/serve_economics.rs |
Updated related documentation terminology. |
crates/node/src/metrics.rs |
Updated ledger terminology. Nit: align the observability appendix wording with positive initial allowances. |
crates/node/src/blacklist_watcher.rs |
Adjusted warming test fixtures. |
crates/e2e/tests/node_pull_topup.rs |
Revised documentation for the remaining ignored-test blocker. |
adr/041-refuse-to-serve.md |
Updated allowance wording. Nit: explicitly document full initial value and one-hit dud exhaustion semantics. |
Review details
Suppressed comments (2)
adr/041-refuse-to-serve.md:110
- The implementation and module docs now rely on the crucial invariant that a source's first ledger entry starts at
B, but this ADR edit does not state that invariant in the normative allowance section or acceptance criterion 4. A reader can still implement the ADR with a zero-centered first entry and recreate the miss this PR fixes; please specify the initial full value and that one-hit duds only reduce the allowance until it is exhausted.
the credit. A drop leaves the source's allowance lower than its true profit and
loss. It can only throttle warming from that source. It can never over-fund the
crates/node/src/metrics.rs:479
- The corresponding operator-facing description in
adr/appendix-observability.md:121still says a dropped credit leaves the ledger “more negative than its true profit and loss.” After the ledger now starts at a positive full allowance, that is not generally true; the remaining allowance can be positive while still lower than reality. Please update the appendix together with this terminology change so the observability contract matches the implementation.
/// is conservative — it leaves the source's ledger lower than reality,
/// never higher — so it can only block speculative warming,
- Files reviewed: 8/8 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
debit_speculative published the hash's source tag before taking the bucket lock. A serve that resolved the tag in that gap could apply its credit to the bucket this debit was about to create full, where the +budget cap discarded it. The tag is now published while the lock is held, ahead of the debit, so every credit the tag enables lands after the debit and no debit is ever committed without its tag. The serve path still never takes the lock. ADR 041 now states that a source's allowance starts full and that a dud does not cut it off until the duds exhaust B (allowance section and acceptance criterion 4); the observability appendix drops "more negative". Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013p4vAEc4scVHADBqA44K9j
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.
Refs #1893 (does not close it —
node_pull_topupstays ignored on a second, separate blocker described below).Root cause of #1893's clean miss
The issue's premise that the miss was a silent
PullMiss::Cleanfold was wrong: an instrumented run shows the SERVER'sdecdn_serve_economics_refused_totalticking — the ADR 041 buy-margin gate skipped the seeder (PullMiss::BelowMargin, wire-identicalNotFound).Why:
WarmingAllowancestarted a never-touched source's ledger at 0. The warm-up pull (a ~48 KiB speculative buy at 0.5 USDC/MB) debitedrate × mb_of(bytes)= 500_000 and its single serve credited0.9 × 500_000= 450_000, leaving the seeder at −50_000.available()went false, somax_buyfell to the amortized floor (450_000 < the 500_000 quote) and every further buy from that seeder was skipped. At the default rate the same skim is ~1 µUSDC and invisible.That contradicts ADR 041 §The per-source warming allowance: each source "carries an allowance capped at
B", is cut off only "after the sink has spent its allowanceBon duds", "each source's allowance resets to full" after a restart, and "a$5budget … covers a large volume of unrecovered one-hit warming per source before it cuts a source off".Change
crates/node/src/warming_allowance.rs: a source's first ledger entry holds the fullbudget(Bucket::full). Availability, the[-budget, +budget]clamp, credits and refill are unchanged. Docs updated.a_fresh_source_starts_with_the_full_budget,duds_spend_the_budget_then_block(replacesdud_drains_then_blocks, which encoded the one-dud cutoff);node_origin_pull::attack_b_dud_flood_is_bounded_and_vindication_works:B= one market buy; one served dud stays warm, a second dud spendsB, further buys refuseBelowMargin;client_loopback::a_completed_serve_credits_the_source_through_the_background_aggregator: debits the whole budget to reach "spent".crates/e2e/tests/node_pull_topup.rs: ignore reason + doc comment rewritten to the blocker that remains.Remaining blocker (separate bug, not fixed here)
With the gate fixed, the fetch is admitted and streams, then stalls: the client fails
upstream stalled: no progress for 30s. At the stall the SERVER showsdecdn_node_pull_through_window_paused_total 4, no outbound stream, and no top-up / stall / refusal / voucher-reject counter movement on either node. Upstream paid ≈ 4.5 MB vs client paid ≈ 3 MB — one ramped credit window — so the pull leg is parked onRampPacer::Waitfor a served-paid advance that never comes.It is rate- and top-up-independent: the same journey at the default rate with the default working deposit stalls at the same point. The warm-up completes because it fits inside
PULL_WINDOW_FLOOR. No existing e2e pulls a multi-MB blob node-to-node through the fused serve-miss path.DECDN_NODE_LOG="warn,decdn_node=debug"surfaces daemon debug logs through the harness (the issue noted they didn't;RUST_LOGcomes from that variable).Verification
cargo nextest run -p decdn-node: 1119/1119, including the review follow-ups (vindication tests now require the second serve; cap and-budgetfloor pinned).cargo nextest run -p decdn-e2e --features anvil-e2e -E 'binary(node_to_node_coalesce)': pass.node_pull_topup(run with the ignore removed): gets past the margin gate (noserve_economics_refused), then hits the stall above.🤖 Generated with Claude Code
https://claude.ai/code/session_013p4vAEc4scVHADBqA44K9j