Skip to content

Serve the current epoch collateral requirement, so a client can show what a margin costs #32

Description

@MichaelTaylor3d

Task

Expose the current epoch's collateral requirement over the node control plane, so a client can show
what a safety margin actually costs.

Parent epic: https://github.com/DIG-Network/dig_ecosystem/issues/3173
Blocks the useful half of: DIG-Network/dig-app#298 (PR #301) and
DIG-Network/dig-node#388

Why

The safety-margin setting shipped in dig-app PR #301. It saves and applies correctly — but it cannot
show the cost
, because nothing serves the requirement. Verified against
dig-node-control-interface 0.22: no epoch method and no collateral method exists.

A bare "+1%" tells an operator nothing actionable. The entire point of the setting is choosing between
safety and opportunity cost, and that choice cannot be made without the extra $DIG figure at the
current requirement and store count.

The app is honest about it today — it reports the requirement as unknown and confirms the choice
is still saved and applied, rather than computing a cost from an assumed value. That is the correct
behaviour and it should stay correct after this lands: a node that cannot determine the requirement
must still say so.

What to serve

At minimum, the current epoch and its required_per_store. Consider also the census inputs behind it
(store count, owner count, multiplier, handicap), since the per-epoch record already holds them and a
client that can show why the number moved is far more useful than one that shows only the number.

Serve, do not re-derive. The value comes from dig-mirror-collateral via the node's per-epoch
record (dig-node#387). A client must never recompute the requirement — a sibling lane already proved
that re-deriving the formula from spec text reintroduces holes the crate closes structurally.

Two design points that are already settled elsewhere — match them

  1. The protocol version belongs in the response. The model is versioned and upgradable, and the
    version that computed an epoch travels with the record. A client showing a requirement without
    knowing which ruleset produced it cannot detect a disagreement.
  2. Unknown must be representable. A node that has not yet censused the epoch, or that is behind the
    finality depth, must be able to say so. dig-app already has the pending/known/unknown shape and a
    guard test that exists because a confident zero shipped once before.

The single seam on the app side

collateral_requirement() in crates/dig-app-core/src/confirm/gui/window/pane/settings/mod.rs is the
one function that changes when this method exists. It was written as a seam deliberately — the app
needs no restructuring, only a real source.

Also

  • This is a catalog change first (dig-node-control-interface), then a dig-node implementation,
    then adoption — release-first per §4.1. Note that dig-node currently declares 0.21 and does not yet
    serve control.spends.list from 0.22 either (dig-node#385); these two adoptions may be worth doing
    together rather than as two separate version steps.
  • Check the error-code space before minting one — dig-node-control-interface#27 records that -32044
    already collides.

Acceptance

dign and the DIG App both show the same requirement for the same epoch, and both say unknown rather
than a number when the node cannot determine it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions