Skip to content

Per-epoch collateral record: database, gossip serve, sampled sync, retention off by default #387

Description

@MichaelTaylor3d

Task

Track the per-epoch collateral record in the node's database, serve it over gossip, and sync it from
peers with the specified confidence.

Parent epic: https://github.com/DIG-Network/dig_ecosystem/issues/3173
Depends on: dig-mirror-collateral (the math) and the census in dig-mirror-coin.

What to store

Per epoch: the epoch number, census height, store count, distinct owner count, total locked, multiplier,
handicap, and the derived required_per_storeplus the inputs needed to re-derive it, so a record
can be audited rather than merely trusted.

Serve and sync

Any node may request any historical epoch's record over gossip.

Syncing uses the sample plan from the decision, which is chain-derived rather than assumed:
N is the count of distinct collateralised owner puzzle hashes, k(N) plateaus at 9 for a population
of 20 or more, and the adoption threshold is 6 of 9 — 99.7% under the stated assumption that at most
20% of the population is dishonest. Print the assumption beside the number wherever the confidence
is reported; a confidence figure without its assumption is not a claim.

Below the minimum population the sample is advisory only and the node derives from chain. At N=3 one
adversary is 33% and it is the assumption, not the statistics, that fails. Say so rather than reporting a
confidence the mathematics does not support.

Sample independently and at random. A sample drawn from one DHT bucket, or from a peer's referrals,
lets an adversary supply the population instead of a sample of it.

Disagreement is a signal, not noise. If the sample does not converge, say so and fall back to
deriving from chain — never adopt a plurality answer quietly.

An unrepresentative sample is now detectable: if the node hears from more distinct owners than the
chain says exist, that is a provable lie, not noise. Reject it.

The rule that makes all of this safe

A node's own computation always beats a peer's answer. Every record is recomputable from chain, so
the sample buys the ability to skip an expensive historical re-derivation — it never buys the right to
be wrong. If a synced record disagrees with what this node computes, this node's value wins and the
disagreement is reported.

Retention

A one-year truncation option, off by default. Document the consequence honestly: a truncated node
can no longer answer historical queries, and cannot re-derive recent epochs without re-scanning the
chain, because the recurrence needs its predecessors.

A dependency to plan around

dig-gossip is not published to crates.io (the index returns 404) and is consumed by git pin —
tracked as https://github.com/DIG-Network/dig_ecosystem/issues/3172. Either wait on that or put the
message types in a published crate. Decide deliberately and say which.

Method

TDD, hostile cases first: a peer serving a record that disagrees with local computation; a peer claiming
an epoch that does not exist yet; more distinct responders than the chain's owner count; a sample that
does not converge; a truncated node asked for a truncated epoch.

§2.4b, SPEC.md, and §2.6 as usual.

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