Skip to content

Prove older ledgers with externalize ancestry - #20

Merged
samjay8 merged 1 commit into
mainfrom
feat/ancestry
Oct 26, 2026
Merged

samjay8 merged 1 commit into
mainfrom
feat/ancestry

Conversation

@samjay8

@samjay8 samjay8 commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Closes #3.

externalize ancestry proves a ledger older than a certified one. It certifies the bundle's ledger (claims included, as verify does), then follows previous-ledger hashes back through archived ledger-*.xdr.gz files to the requested ledger.

$ externalize ancestry --bundle bundle-64791359.json \
    --headers ledger-03dca33f.xdr.gz ledger-03dca2ff.xdr.gz --ledger 64791250
VERIFIED  ledger 64791250
  hash      …af4d3b5c797fbd05b8434
  closed    2026-10-05T23:13:52Z
  via       ledger 64791359, certified by 30 trusted validators (10 orgs agree), 109 links back

--json prints report::ancestry: the proven ledger, the certifying ledger (the same shape as a verified bundle's), and the number of links. Exit codes match verify: 0 proven, 1 rejected, 2 could not run.

The library side is prove_ancestor. It accepts whole archive files and uses only the headers from the target up to the certified ledger. It fails closed:

  • a missing header is Error::MissingHeader(seq), naming the ledger whose archive file to add;
  • a target that isn't older is Error::NotAnAncestor;
  • two different headers for one ledger, or a header that doesn't chain, is Error::BrokenChain.

Done-when from the issue

  • A test proves a ledger at least one checkpoint older than the fixture's, using archived headers. This adds ledger-03dca2ff.xdr.gz, the previous mainnet checkpoint's headers (15 KB, from SDF's archive), and proves 64,791,250 from 64,791,359.
  • A broken link is rejected with a clear error. The test edits a header and also recomputes its own hash; the chain still breaks at that ledger.
  • The README command table lists ancestry. The trust model, CONTRIBUTING (fixtures) and the CHANGELOG are updated too.

Checked

cargo fmt --check, cargo clippy --workspace --all-targets, cargo doc, cargo test --workspace (4 new library tests, 3 new CLI tests), and the wasm32 build of externalize-core.

A certified ledger vouches for its ancestors, but the CLI could only
certify ledgers that come with their own SCP messages. externalize ancestry
certifies a bundle's ledger, then follows previous-ledger hashes back
through archived ledger-*.xdr.gz files to the requested ledger, printing
its hash and close time (or --json via report::ancestry).

The library side is prove_ancestor: it takes whole archive files, uses only
the headers from the target up to the certified ledger, and fails closed:
a missing header is Error::MissingHeader naming the ledger, a target that
is not older is Error::NotAnAncestor, and a forged header breaks the chain
even with its own hash recomputed.

Tests use the previous mainnet checkpoint's headers (ledger-03dca2ff,
from SDF's archive) to prove ledger 64791250 from 64791359.

Closes #3.
@samjay8
samjay8 merged commit dfff275 into main Oct 26, 2026
8 checks passed
@samjay8
samjay8 deleted the feat/ancestry branch October 26, 2026 00:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[enhancement]: prove older ledgers from a certified one with externalize ancestry

1 participant