Skip to content

TrieProofResponse's documentation says an empty path means absence; the server means it could not walk the path #391

Open

Description

@SDL-A1

crates/networking/src/protocol/rsk.rs:183-186, against
crates/sync/src/snap/server.rs:678-695.

The TrieProofResponse doc comment says:

An empty path means the trie does not hold the key. It is never a truncated
path -- proving absence in a radix trie needs the divergence point and its
siblings, a different structure, and a shortened inclusion path would look
like one without being one.

The server that produces those paths says the opposite:

nodes_to_divergence rather than nodes_on_path [...] Answering an absent
key with an empty array would let any peer deny any account by sending
nothing.

An empty array now means only one thing: this node could not walk the path
at all, because its store is missing something.

The server is right and the comment is stale. Absence is proved by the
divergence nodes; empty now signals incompleteness.

Why it is worth an issue despite being a comment

The two readings differ by exactly the conflation this message pair exists to
prevent. A client implemented from the wire documentation treats an empty
array as a proved absence, and therefore reports a zero balance for an account
a peer simply declined to serve. That is the omission attack working as
designed, and the documentation is what an implementer reads first --
especially one writing a client in another language against rsk/64.

It is also the direction that fails silently. A client that wrongly treats
absence as incompleteness shows an error; one that wrongly treats
incompleteness as absence shows a confident wrong number.

What would settle it

Replace the comment with the server's semantics: the path runs root-to-leaf
for a key that is present and root-to-divergence for one that is not, a
verifier confirms the terminal node's relevant child reference is empty, and
an empty array means the responder could not walk the path and is not an
answer about the key.

No wire change; the encoding already carries what the server sends.

Found while comparing this protocol with the SNAP range proofs in
NethermindEth/nethermind#14457, whose light client gets absence for free from
range boundaries and so never faces this ambiguity.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions