Skip to content

fix(core): certify ledger headers through the next ledger's consensus - #42

Merged
samjay8 merged 5 commits into
mainfrom
fix/certify-header
Nov 8, 2026
Merged

samjay8 merged 5 commits into
mainfrom
fix/certify-header

Conversation

@samjay8

@samjay8 samjay8 commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Certificate::verify certified only a header's scpValue, which is all that slot N's signatures cover, and checked that header.hash == sha256(header). Every other field (txSetResultHash, previousLedgerHash, the bucket list hash) could be rewritten and the hash recomputed. Results, success flags, Soroban return values and events, and ancestry were therefore forgeable. Affected: v0.1.x to v0.2.0.

Header N is now certified through ledger N+1:

  1. Slot N: a quorum of trusted validators EXTERNALIZEs exactly header.scpValue. This step and its equivocation check are unchanged.
  2. Slot N+1: a quorum of trusted validators EXTERNALIZEs one value V, decoded as StellarValue. Any other value from a trusted validator is Equivocation.
  3. next_transactions.ledgerSeq == N+1, and its set hashes to V.txSetHash. A generalized set (ext v1) hashes as SHA-256(XDR(GeneralizedTransactionSet)). A legacy set hashes as SHA-256(previousLedgerHash ‖ XDR(tx)…). Both follow stellar-core src/herder/TxSetFrame.cpp.
  4. The set's previousLedgerHash == SHA-256(XDR(header N)).

Changes:

  • Bundle format externalize/bundle/v2, with required next_scp and next_transactions. v1 is refused with Error::V1Bundle.
  • Certificate gains next_scp and next_transactions. archive::certificates takes transaction entries and returns Error::MissingSuccessor when they are missing.
  • externalize certify takes --transactions, and --scp and --transactions take several files. Without the next checkpoint's files, a checkpoint's last ledger is reported as NOT CERTIFIED.
  • New errors: MissingSuccessor, SuccessorTxSetMismatch, HeaderNotCommitted, V1Bundle.
  • The conformance fixture is regenerated as v2. It is byte-identical to testdata/bundle-64791359.json on externalize-node's feat/bundle-v2 branch.
  • New fixtures from SDF's archives, with sources listed in tests/fixtures/README.md:
    • mainnet scp-03dca37f and ledger 64791360's transactions;
    • testnet transactions-004d19ff, scp-004d1a3f and ledger 5052928's transactions;
    • mainnet ledgers 50000000 and 50000001 (protocol 19), for the legacy set hash.
  • The wasm crate and site/app.js handle v2. The site explains v1 rejections and waits for ledger N+1 to be archived.
  • Docs, README and CHANGELOG are updated. There is no version bump.

Forgery tests (all rejected):

  • A rewritten result set with recomputed hashes: once with a success flipped to a failure, once with a nonexistent transaction.
  • A forged previousLedgerHash used for ancestry.
  • A next_transactions that doesn't match V: relabeled, with an edited fee, or for the wrong ledger.
  • A next_transactions with another previousLedgerHash: on real data, and with synthetic validators agreeing on it.
  • next_scp for the wrong slot.
  • next_scp without a quorum.
  • An equivocating validator in next_scp, using synthetic keys.
  • v1 input.

The legacy set hash is checked against real protocol 19 data. That checkpoint's archived SCP holds only one trusted signature per ledger, so the full legacy certificate is tested with synthetic validators re-signing the genuine values.

Validators sign only a ledger's StellarValue, so every other header field
(txSetResultHash, previousLedgerHash, bucket list hash) could be rewritten
with the header hash recomputed. Header N is now certified only when slot
N+1's externalized value names a transaction set whose previousLedgerHash
is SHA-256(header N). Bundle format externalize/bundle/v2 adds next_scp and
next_transactions; v1 bundles are refused.
@samjay8
samjay8 marked this pull request as ready for review November 8, 2026 20:29
@samjay8
samjay8 merged commit 1c0af32 into main Nov 8, 2026
15 checks passed
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.

1 participant