Repository navigation
perf(node): read each signer's authorization once at admission - #2333
Conversation
The admit-path signer confirm kept a getAuthorization read for 60 s, so a repeat client paid one synchronous eth_call a minute and concurrent confirms each sent their own. Testnet admission p99 (391 ms) sat at eth_call p95-p99. A Registered read now stays cached: cap and expiry are write-once, and spent is the read's value plus what the event projection folded for the signer since. An Unregistered read is re-read after a minute, or once the projection folds a redemption by the signer. Confirms of one (pool, signer) share one in-flight read, through the single-flight that getPool already used, now generic over its key. A full cache prunes lapsed Unregistered reads, then evicts the oldest. Three sibling counters split admission signer checks by cache outcome (cached, first read, unregistered re-read), charted in a new delivery dashboard panel. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Code Coverage OverviewLanguages: Rust Rust / code-coverage/cargo-llvm-covThe overall line coverage in commit 78da23b in the Show a line coverage summary of the most impacted files.
Updated |
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The change reworks on-chain admission/authorization caching and single-flight concurrency semantics with subtle correctness/economic tradeoffs, which warrants final human review despite only one minor documentation nit found.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
This PR cuts admission-path tail latency by changing how ResolvingPoolView reads a voucher signer's on-chain authorization. Testnet metrics tied the 4.5% of >100 ms admissions to repeated getAuthorization eth_calls (one per (pool, signer) every 60 s, with no coalescing). The fix makes a Registered read write-once-cached forever (with spent kept current from the projection's fold), re-reads only Unregistered signers (1-minute TTL or once a redemption folds), coalesces concurrent reads through a now-generic single-flight slot shared with getPool, bounds the cache at 4096 entries, and drops the stale-registration fallback so a read fault simply refuses the signer. New sibling counters and a dashboard panel make the remaining chain-read tail observable.
Changes:
- Rework signer-auth caching: permanent
Registeredreads, TTL/fold-based re-reads forUnregistered, bounded eviction, and fault-refuses-signer semantics. - Generalize the single-flight read slot over key/value so
getAuthorizationreads coalesce likegetPool. - Add
decdn_serve_signer_auth_{cached,first_read,reread}_totalcounters, observability registry rows, and a stacked dashboard panel; wireArc<Metrics>intoResolvingPoolView.
| File | Description |
|---|---|
crates/node/src/payment_settlement.rs |
Core refactor: AuthRead/CachedAuth, cached_auth/remember_auth, generic single-flight, read_authorization, metrics, tests. |
crates/node/src/metrics.rs |
Three new admit signer-auth counters and their recorder methods. |
crates/node/src/runtime/mod.rs |
Pass node_metrics into ResolvingPoolView::new. |
crates/node/src/pool_view.rs |
Doc update for the new permanent-registered / fault-refuses semantics. |
crates/node/src/chain_events/mod.rs |
Doc update: admission reads refuse rather than fall back. |
adr/appendix-observability.md |
Registry rows for the three new counters. |
monitoring/dashboard-delivery.json |
New stacked "Admission signer checks by cache outcome" panel. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…n tests Co-Authored-By: Claude Opus 5.5 <[email protected]>
The delegated clamp journey retried its fetch until the fetch succeeded or the lane's outstanding amount rose above zero. In this flow the lane's last signed amount stays zero while the node redeems, so only a successful fetch ended the loop. The node now refuses the drained signer at admission, so later fetches cannot succeed; the loop ends on the first accepted voucher instead. Co-Authored-By: Claude Opus 5.5 <[email protected]>

Why
Testnet phase metrics (3 days, 7 nodes): admission is 4 ms at p50 but 391 ms at p99, and 4.5% of admissions take over 100 ms. That tail matches
eth_calllatency (p95 491 ms, p99 900 ms).getPoolalready reads from the event projection, with single-flight. The repeat cost wasgetAuthorization: one synchronous read per(pool, signer)every 60 s, and no coalescing of concurrent reads.What
capandexpiryare write-once.spentis the read's value plus what the projection has folded for the signer since the read. The fold covers every provider'sPoolRedeemed. The baseline is taken before the read is sent, so any error makesspenthigh and refuses near the cap, never over-admits.getAuthorization. ThegetPoolin-flight slot is now generic over its key and value, and both reads use it.decdn_serve_signer_auth_{cached,first_read,reread}_total, sibling counters that sum to all admission signer checks. They have registry rows inadr/appendix-observability.mdand a stacked panel, "Admission signer checks by cache outcome", indashboard-delivery.json.Testing
cargo nextest run -p decdn-node: 1606 passed. New tests cover the freshness rules, cache eviction, coalesced reads against a hung RPC, re-read triggered by a projection fold, spent-delta accounting and counter values.cargo clippy --workspace --all-targets --all-features,cargo docwith-D warnings,cargo test --no-run -p decdn-e2e --features anvil-e2e: clean.After deploy, the new panel shows how much admission still waits on a chain read (first read + re-read).
🤖 Generated with Claude Code