Skip to content

fix(node): make payment.rate_per_mb restart-required, not hot-reloadable - #1684

Merged
alpergundogdu merged 1 commit into
mainfrom
claude/rate-per-mb-hot-reload-937f8b
Aug 14, 2026
Merged

alpergundogdu merged 1 commit into
mainfrom
claude/rate-per-mb-hot-reload-937f8b

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

Closes #1679.

Problem

payment.rate_per_mb was in the SIGHUP / admin_v1_reload hot-reload set, sharing one Arc<AtomicU64> between the probe and client handlers. Swapping the served price under a running node is a footgun:

  • Quote/charge skew — a client selects the node from a probe quote at the old rate (selection score is rate-weighted, ADR 001), then the serve leg charges the swapped-in rate against per-session quoted_rate_per_mb.
  • No cooldown / commitment window — repricing at will undercuts any expectation that a quoted rate holds.

The rate is an economic commitment on the wire, not an operational knob like a rate limit or log level. The correct way to reprice is: drain → close → cooldown → restart with the new rate.

Change

  • Delete PaymentSection from runtime::reload. The whole [payment] section is now restart-required and earns a presence-based "requires restart" notice, like network/blockchain/etc. (delivery_floor is governed on-chain via getRateBounds(); the other serve knobs are read once at handler construction.)
  • ProbeHandler / ClientHandler hold rate_per_mb: u64 fixed at startup (from cfg.payment.rate_per_mb) instead of a shared atomic.
  • Drop rate_per_mb from ReloadSnapshot / ReloadResponse and the decdn node reload plain output — a reload never changes it, so echoing it in a reload response was misleading.
  • e2e: NodeFixture::set_rate_per_mb now rewrites the config and restarts the daemon instead of hot-reloading. The G-GOV-03 rate-challenge evidence pair is unaffected — the SlashJudge only sees two operator-signed messages inside the 30s window and does not care how the rate moved between them; a restart is fast relative to that window.

Verification

  • cargo build / cargo clippy --all-targets (incl. -p decdn-e2e --features anvil-e2e) — clean
  • cargo fmt --check — clean
  • cargo nextest run -p decdn-node reload / sighup / probe / client_loopback suites — green (rewritten unit + integration tests assert the new "rate change ignored, notice emitted, log_level still applies" contract)
  • Pre-commit hooks (fmt, clippy, doc, deny) — passed

🤖 Generated with Claude Code

Copilot AI lite review requested due to automatic review settings August 14, 2026 09:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes payment.rate_per_mb restart-required rather than hot-reloadable, aligning the served price with the “economic commitment on the wire” model and avoiding quote/charge skew across probe vs serve legs.

Changes:

  • Remove [payment] from the hot-reloadable set and emit “requires restart” notices for [payment] presence on reload/SIGHUP.
  • Update probe/client handlers to hold a startup-fixed rate_per_mb: u64 (no shared Arc<AtomicU64>).
  • Remove rate_per_mb from reload snapshots / admin reload responses and adjust CLI + e2e/tests accordingly.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
crates/node/tests/support/mod.rs Update test wiring to pass rate_per_mb by value into handler deps.
crates/node/tests/sighup_signal.rs Adjust SIGHUP/reload integration tests to treat [payment] as restart-required and stop asserting atomic rate swaps.
crates/node/tests/self_hosted_discovery.rs Update ProbeHandler::new call sites for by-value rate_per_mb.
crates/node/tests/probe_warm_reconnect.rs Remove atomic rate plumbing in probe server helper.
crates/node/tests/probe_loopback.rs Remove atomic rate plumbing in probe loopback helpers.
crates/node/src/runtime/reload.rs Delete PaymentSection, drop rate from snapshot, and make [payment] restart-required with presence-based notices.
crates/node/src/runtime/mod.rs Wire handlers with cfg.payment.rate_per_mb directly instead of a reload-state atomic.
crates/node/src/handlers/probe.rs Store rate_per_mb as a startup-fixed u64 and remove atomic loads.
crates/node/src/handlers/client/wire.rs Clamp against startup-fixed rate_per_mb rather than loading from an atomic.
crates/node/src/handlers/client/mod.rs Change ClientHandlerDeps/ClientHandler to hold rate_per_mb: u64 with updated docs/tests.
crates/node/src/commands/mod.rs Stop passing PaymentArgs into RuntimeReloadState::new.
crates/node/src/admin.rs Remove rate_per_mb from admin reload response path and update tests.
crates/e2e/tests/g_gov_03_real_evidence.rs Update evidence narrative and flow to restart daemon to apply repricing.
crates/e2e/src/node.rs Change NodeFixture::set_rate_per_mb to rewrite config and restart instead of hot-reload.
crates/common/src/cli/node.rs Update CLI docs to reflect current reloadable set (excluding payment rate).
crates/common/src/admin.rs Remove rate_per_mb from ReloadResponse and update RPC docs.
crates/cli/src/commands/rotate_key/mod.rs Update docs to reflect reload set no longer includes payment rate.
crates/cli/src/commands/node.rs Remove plain-text rate_per_mb= output from decdn node reload; keep log_level= only.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread crates/node/src/runtime/reload.rs Resolved
@alpergundogdu
alpergundogdu force-pushed the claude/rate-per-mb-hot-reload-937f8b branch from 116c988 to a60e926 Compare August 14, 2026 09:21
…ble (#1679)

The served per-MB rate was in the SIGHUP / admin_v1_reload hot-reload set,
sharing one Arc<AtomicU64> between the probe and client handlers. Swapping it
under a running node is a footgun: a client selects the node from a probe quote
at the old rate, then the serve leg charges the swapped-in rate — skewing
already-quoted probes against in-flight vouchers — with no cooldown or
commitment window. The rate is an economic commitment on the wire, not an
operational knob.

Move it off the reload path entirely:

- Delete PaymentSection; the whole [payment] section is now restart-required and
  earns a presence-based "requires restart" notice like network/blockchain/etc.
- ProbeHandler and ClientHandler hold rate_per_mb as a plain u64 fixed at
  startup (read from cfg.payment.rate_per_mb) instead of a shared atomic.
- Drop rate_per_mb from ReloadSnapshot / ReloadResponse and the `decdn node
  reload` plain output — a reload never changes it, so reporting it misled.
- e2e: NodeFixture::set_rate_per_mb now rewrites the config and restarts the
  daemon (drain→stop→restart is the reprice path); the G-GOV-03 rate-challenge
  evidence pair is unaffected since the judge only sees two signed messages in
  the 30s window.

Repricing is now: drain, close, cooldown, restart with the new rate.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@alpergundogdu
alpergundogdu force-pushed the claude/rate-per-mb-hot-reload-937f8b branch from a60e926 to f241ece Compare August 14, 2026 09:25
@github-actions

Copy link
Copy Markdown

Coverage report

Total: 80.79% (was 80.83%, ▼ 0.04%) — 59400/73525 lines

File Coverage Lines Δ
crates/cli/src/commands/node.rs 77.52% 1176/1517 ▲ +0.05%
crates/cli/src/commands/rotate_key/mod.rs 35.14% 13/37 ● 0.00%
crates/common/src/admin.rs 94.74% 126/133 ● 0.00%
crates/common/src/cli/node.rs 100.00% 5/5 ● 0.00%
crates/e2e/src/node.rs 24.79% 120/484 ▲ +0.20%
crates/node/src/admin.rs 95.51% 1169/1224 ▼ 0.04%
crates/node/src/commands/mod.rs 0.00% 0/58 ● 0.00%
crates/node/src/handlers/client/mod.rs 88.55% 696/786 ▼ 0.04%
crates/node/src/handlers/client/wire.rs 97.62% 123/126 ● 0.00%
crates/node/src/handlers/probe.rs 86.36% 266/308 ● 0.00%
crates/node/src/runtime/mod.rs 46.72% 1091/2335 ● 0.00%
crates/node/src/runtime/reload.rs 96.80% 1421/1468 ▲ +0.41%
History
Commit Total Δ vs base
f241ece (HEAD) 80.79% ▼ 0.04%

@alpergundogdu
alpergundogdu merged commit ad40da7 into main Aug 14, 2026
26 checks passed
@alpergundogdu
alpergundogdu deleted the claude/rate-per-mb-hot-reload-937f8b branch August 17, 2026 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rate_per_mb should not be hot-reloadable; require drain + cooldown + restart to reprice

2 participants