Repository navigation
fix: harden voucher rate, pointer budget, attestation and metrics checks - #3031
Open
alpergundogdu wants to merge 1 commit into
Open
alpergundogdu wants to merge 1 commit into
alpergundogdu wants to merge 1 commit into
Conversation
- incentive: the voucher rate check is exact. The tolerance is gone: the client prices every span with div_ceil, so an honest voucher never pays less than the quote, and a 1%-short voucher is now refused. - gateway: the known-signer lookup budget is per (namespace, signer), in a map cleared each minute and capped at 1024 keys, so a former owner's key cannot spend the current owner's budget. - node: an origin attestation is valid only while its signer is in the registered set (bound to a NodeId the staker set reports active). A seat outlives its operator's registration until someone prunes it. - node: a loopback /metrics listener answers only a loopback Host, so a DNS-rebinding page cannot read the scrape. ADR 003 and ADR 022 state the exact rate check and the registration rule. Refs #2851 Co-Authored-By: Claude Opus 5.5 <[email protected]>
10 tasks
Code coverage overviewLanguages: Rust Rust / code-coverage/cargo-llvm-cov
View coverage of the 8 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. |
This branch has not been deployed
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 #2851
Covers the four items of #2851 still open on
main, and reports on a fifth.Voucher rate tolerance
verify_rateis exact, and the tolerance parameter is gone (DEFAULT_TOLERANCE_BPSremoved, no config knob). Every client pricing path rounds up (ledger::next_voucher,driver,credentialall usediv_ceil, and a chunk prices to exactlyrate_per_mbbecauseCHUNK_BYTES == BYTES_PER_MB), so an honest voucher always clears the check. New testone_percent_short_rejected;min_payment_clears_rate_checkcovers honest round-up pricing at odd byte counts. ADR 003 § Voucher withholding now says the check is exact.Gateway known-signer budget
PUT /_pointerkeys the known-signer lookup budget by (namespace, signer). A former owner's key that is still inhigh_waterspends only its own budget. The map is cleared when the minute turns and holds at most 1,024 keys; past that cap, a known signer uses the shared budget. New testa_former_owner_cannot_spend_the_current_owners_lookup_budget.Attestation verifier requires registration
AttestationVerifier::admitsalso requires the signer to be in the registered set (RegisteredOperators). That means the registry snapshot'soperator → NodeIdbinding exists and the staker set reports that NodeId active. This is the same checkChainOriginDirectoryalready applies and the one ADR 011 § Interaction with CapacityBond describes. ADR 022 § Origin Attestation gains validity rule 4 and the matching conformance text. New testa_seated_signer_outside_the_registered_set_attests_nothingcovers both an unbound signer and a signer bound to an inactive NodeId.Note: a newly registered origin's attestations become valid at each verifier's next registry read (5 min, or sooner when a lookup meets an unknown node). A seat already requires an active operator, so in practice registration lands before seating.
Metrics server
The timer, the 10 s header timeout and the 60 s connection lifetime were already on
main. The lifetime bounds keep-alive, since it caps the whole connection. This PR adds the loopbackHostcheck. On a loopback listener,/metricsanswers only aHostoflocalhostor a loopback IP (any port), and anything else gets 403. A listener the operator bound to a non-loopback address (container scrapes) accepts anyHost, because scrapers there name the host by its own address. New tests:loopback_hosts_are_the_loopback_names_on_any_portanda_loopback_metrics_listener_refuses_a_foreign_host.Attestation persisted before the pull lands: not changed
Persisting on commit is not a small change. The attestation has to be in the store from the handshake on, because it gates the pull and lets the node serve downstream while the pull is in flight. A pull lands through several paths (progressive miss pull, buffered fill, ranged legs, the timed source) inside the cache crate's
CacheStore, which has no attestation hook. To persist on commit, a completion callback would have to run through each of those paths. #2921 already covers the effect: an attestation for a blob the node never landed serves nothing (serving needs the blob) and is dropped at its first refresh.Checks
cargo nextest run -p decdn-incentive -p decdn-node -p decdn-cli: 3,232 passed.node_origin_pull::concurrent_pulls_resume_at_their_own_frontier_not_the_lanesfailed once under full-suite load and passed on retry and in 8 of 8 isolated runs.cargo clippy --workspace --all-targets --all-features: cleancargo test --no-run -p decdn-e2e --features anvil-e2e: buildsCARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-items: clean🤖 Generated with Claude Code