Skip to content

test(e2e): cover fail-closed-on-RPC-loss for the authorized-origin gate #1374

Closed as not planned

Description

@yigitdot

Follow-up from the review of #1366.

ADR 037 §85 promises the authorized-origin gate has "the same fail-closed-on-RPC-unavailability behavior" as the rest of the chain-backed surface. ChainOriginDirectory documents per-namespace fail-close with a delta_remove_origin fallback and deferred re-read healing (crates/node/src/dht/chain_origin_directory.rs:72-82).

None of it is covered end to end. This is the one path where a bug means the node serves content nobody claimed — i.e. it fails open instead of closed — so it is worth an executable assertion rather than trust in the unit tests.

Sketch: bring up the G-NODE-08 shape, ratify, confirm a backend-only hash serves; then kill or stall the anvil RPC and assert a fresh backend-only hash in the same namespace is refused rather than served. Restoring the RPC should heal it.

Higher effort than the other e2e follow-ups because it needs RPC fault injection — ChainFixture currently has no way to pause or drop the anvil endpoint.

Activity

  1. added
    kind:test
    rust
    kind:security
    prio:medium
    on Jul 22, 2026
  2. self-assigned this
    on Jul 23, 2026
  3. thiras commented on Jul 24, 2026

    @thiras
    Contributor

    Investigated — this is a finding about the fail-close semantics, not a missing test

    While implementing the fail-closed-on-RPC-loss e2e I traced the actual gate behavior, and the sketched assertion ("stall the anvil RPC → a fresh backend-only hash in the same [already-authorized] namespace is refused") tests a behavior that does not exist.

    The gate's authorization check is entirely cache-backed, with no live RPC read:

    • pull_origin_gate_blocks → DirectoryCache::has_any → active_node_for reads only the cached origins_of_ns and operator_node maps (crates/node/src/dht/chain_origin_directory.rs:149-183).
    • Liveness is ChainStakerSet::is_active, which is self.proj.read(|s| s.contains(node_id)) (crates/node/src/dht/chain_staker_set.rs) — an in-memory projection, not a live read.
    • Neither cache is invalidated on a failed refresh.

    So a warm namespace — one the node already resolved before the RPC went away — keeps serving its cached authorization through a transient outage. It favors availability and serves stale, healing on the watcher's next successful read. Stalling the RPC does not flip a warm namespace to refused.

    The "fail-closed-on-RPC-loss" guarantee (ADR 022 §FIND_VALUE, ADR 037 §85) is the cold path: an empty or never-resolved directory resolves to "no authorized origin" → refused. That is already covered by unit tests — pull_origin_gate_decision and the EmptyOriginDirectory cases (the #1292 hazard) in crates/node/src/handlers/client/mod.rs and crates/node/src/dht/origin.rs.

    A deterministic e2e for the RPC-loss angle is also impractical: SIGSTOP/SIGCONT on the anvil child (the state-preserving way to model an outage) freezes anvil for the fixture too, so no new chain state can be established mid-stall.

    Resolution: documented the warm-vs-cold distinction in ADR 022 §FIND_VALUE (the fail-closed guarantee bounds what an unknown namespace resolves to, not how fast a known one reacts during an outage; the conservative direction is a lagging de-authorization, not an un-authorized origin admitted). Serving stale-authorized content during a transient blip is a defensible design for this gate.

    Closing as a finding. If strict warm-cache freshness is actually wanted, that's a code change (a last-successful-refresh staleness bound on the origin directory / staker cache) with an availability tradeoff — worth a separate, explicitly-scoped issue rather than this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind:securitykind:testprio:mediumrust

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions