mirror of
https://github.com/XRPLF/rippled.git
synced 2026-08-21 22:30:57 +00:00
The `visitDifferences` guard said an inner node at leaf depth could be seeded by a peer through an earlier fetch-pack exchange, while the code marks the branch `UNREACHABLE`, which is documented as a line that must not be reached in normal use or under fuzzing. Both cannot hold: a peer-reachable assert is a peer-triggered abort. The code is the correct half. `addKnownNode` marks the map invalid instead of hooking such a node in, fetch-pack blobs are checked against their content hash in `LedgerMaster::getFetchPack`, and the parent child-hash slots they attach to chain up to a validated root, so provoking this needs a preimage rather than a crafted message. The comment now attributes the branch to a defect or a corrupt store, and records why the node is still reported into the pack before its children are skipped: the wire form of an inner node carries only child hashes, so the bad depth is never transmitted, and the recipient hooks blobs in by hash at positions its own traversal picks. Withholding it would instead surface as a peer that cannot complete a ledger, with nothing to diagnose locally. The `hasLeafNode` comment credited its caller with a bound that does not apply. That guard limits the depth of the caller's own traversal, whereas `hasLeafNode` runs on the map passed in and descends from that map's root, so the check here is the only thing between a malformed map and the throw in `getChildNodeID`, not a second line of defense. `hasInnerNode` is the one bounded by its caller. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>