Skip to content

harden(dig-wallet): chain.rs:111 with_sources is dead code that builds a single-source peak_height path #360

Description

@MichaelTaylor3d

Task

chain.rs:111 with_sources is dead code that constructs peer_reads: None — a ChainTransport
whose peak_height therefore takes the oracle-first router path instead of the peer round.

Either delete it, or make it take the peer reads, before anyone calls it.

Why this is worth a ticket rather than a comment

The NC-12 property being enforced elsewhere in this crate is that a chain fact is agreed across several
concurrently-queried, independently-held peer sessions — never determined by a single source.

service.rs:173 is the only production ChainTransport construction, and it attaches
with_peer_reads, so chain.rs:200 always short-circuits into the peer round; an empty draw returns
None rather than falling back to an oracle read. That is the property, and it holds today only
because the other constructor is unused.

with_sources is a loaded gun with the safety off. The first caller who reaches for it gets a
transport that silently answers peak_height from one endpoint, with nothing in its name or signature
saying so — and it will look like the obvious constructor to use.

This is the same shape as the defect the NC-12 work just fixed one layer up: two "independence groups"
that both resolved to api.coinset.org, so a 2-of-2 quorum was satisfiable by one endpoint with zero
peers
. A guard is only as good as the paths that cannot route around it.

Context

Done condition

Either with_sources no longer exists, or it cannot produce a transport with peer_reads: None
plus a test that fails if a future edit reintroduces a single-source peak_height path.

Prefer deletion. A constructor kept "in case someone needs it" is exactly how this returns.

Scope

Only this constructor. Do not widen into the rest of chain.rs.

Effort

Low — but the decision (delete vs. require peer reads) is worth a moment, because deleting is only
correct if genuinely nothing needs a source-only transport. Grep before deciding.

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