Skip to content

Adopt dig-sex 0.4 and give tier-0 selection the residency it needs -- run_round knows nothing about what is held #287

Description

@MichaelTaylor3d

Task

Adopt dig-sex 0.4 in dig-node-core and thread residency into tier-0 selection.

This is not a mechanical version bump, and treating it as one silently defeats the change it adopts.

Why

dig-sex 0.4 makes the displacement margin reachable — SPEC 8.5's named primary defence against attacker-driven cache thrashing, previously implemented, tested, and unreachable through the only API a consumer calls.

It required two facts to reach selection, not one: the margin itself, and per-candidate incumbency. A margin alone cannot work, because hysteresis is a comparison between an incumbent and a challenger — a candidate set that cannot tell them apart cannot apply a margin whatever value it is handed.

The trap

tier0_prefetch::run_round has no residency information at all today. It samples from DHT probes, scores, selects and fetches with nothing consulting what is already held.

So resident: false would compile, would pass, and would reproduce exactly the churn the margin exists to stop — while the API now looks correct. That is the same defect one layer deeper and harder to see.

The call site

crates/dig-node-core/src/tier0_prefetch.rs, in run_round:

  • line ~410 gains resident: held.contains(&sc.content_id)
  • line ~420 becomes select_within_capacity(&selector_cands, SelectionPolicy::new(budget, SelectionSeed::from_peer_id(&node.peer_id)))

Thread the held-set in as an argument. run_round is deliberately pure — that purity is what fixed the #1991 parallel-runner env race — so the held-set joins the already-injected enabled / load / rate rather than being read from a global.

TieredPolicy::new is unchanged, so its two call sites need nothing.

Two minors, not one

Cargo.toml:348 still pins dig-sex = "0.2" while the crate is at 0.4.0. The 0.3.0 crate-root re-export work is also unadopted, so this covers both jumps.

Acceptance bar

A re-sampled already-held candidate is not re-fetched. That is the behaviour the margin buys and the only thing that proves the adoption is real rather than typed.

A test asserting resident is populated is not enough — it must assert the outcome, because a wrong-but-compiling resident: false passes any test that only checks the field exists.

Parent

Orchestrator epic: https://github.com/DIG-Network/dig_ecosystem/issues/3138

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind:businessa person can DO something new, or money moves, or a shipped surface stops lying to them

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions