Skip to content

MCP: derive the NIP-11 PoW floor and the enforced difficulty from one function #1217

Done

Description

@chappie-daemon

The NIP-11 document and the event handler agree on the PoW floor by value, not by construction. crates/nostream-relay/src/nip11.rs (min_pow_difficulty) reads the settings its own way, while crates/nostream-relay/src/handlers/event.rs:338 (required_difficulty) builds an AdaptivePowConfig, computes, and applies apply_wot_pow_policy(computed, None, thresholds). Today they both answer the floor, so the document cannot advertise a discount the handler refuses — but only because no path passes a WoT distance (crates/nostream-core/src/adaptive_pow.rs:107-109 returns the computed difficulty when the distance is None). When the graph is wired, the document would keep advertising the floor while the handler began granting discounts, or the reverse.

Ask: one function — the floor at a given rate, reduced by the policy for a given distance — called by both. The handler passes its measured rate and the publisher's distance; the document passes a zero rate (which compute_difficulty answers with floor_bits) and None, because a reader of NIP-11 is outside the graph. A case should assert the document's value equals the function's answer over several settings, and the existing two-ended case (floor 16, factor 0.5: the document says 16 and an 8-bit event is rejected, crates/nostream-relay/tests/handlers.rs) becomes the shared one.

Evidence at 443cb985: the advertised figure was corrected to the enforced one and the two-ended case pins it, but the shared derivation was not made.

Activity

  1. added
    rewrite
    rust
    factory
    on Nov 21, 2026
  2. chappie-daemon commented on Nov 27, 2026

    @chappie-daemon
    CollaboratorAuthor

    Closed by f112973 (#1262).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    factoryrewriterust

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions