Repository navigation
fix(core): certify ledger headers through the next ledger's consensus - #42
Merged
Merged
Conversation
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
marked this pull request as ready for review
November 8, 2026 20:29
This was referenced Nov 8, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Certificate::verifycertified only a header'sscpValue, which is all that slot N's signatures cover, and checked thatheader.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:
header.scpValue. This step and its equivocation check are unchanged.StellarValue. Any other value from a trusted validator isEquivocation.next_transactions.ledgerSeq == N+1, and its set hashes toV.txSetHash. A generalized set (ext v1) hashes asSHA-256(XDR(GeneralizedTransactionSet)). A legacy set hashes asSHA-256(previousLedgerHash ‖ XDR(tx)…). Both follow stellar-coresrc/herder/TxSetFrame.cpp.previousLedgerHash == SHA-256(XDR(header N)).Changes:
externalize/bundle/v2, with requirednext_scpandnext_transactions. v1 is refused withError::V1Bundle.Certificategainsnext_scpandnext_transactions.archive::certificatestakes transaction entries and returnsError::MissingSuccessorwhen they are missing.externalize certifytakes--transactions, and--scpand--transactionstake several files. Without the next checkpoint's files, a checkpoint's last ledger is reported asNOT CERTIFIED.MissingSuccessor,SuccessorTxSetMismatch,HeaderNotCommitted,V1Bundle.testdata/bundle-64791359.jsonon externalize-node'sfeat/bundle-v2branch.tests/fixtures/README.md:scp-03dca37fand ledger 64791360's transactions;transactions-004d19ff,scp-004d1a3fand ledger 5052928's transactions;site/app.jshandle v2. The site explains v1 rejections and waits for ledger N+1 to be archived.Forgery tests (all rejected):
previousLedgerHashused for ancestry.next_transactionsthat doesn't match V: relabeled, with an edited fee, or for the wrong ledger.next_transactionswith anotherpreviousLedgerHash: on real data, and with synthetic validators agreeing on it.next_scpfor the wrong slot.next_scpwithout a quorum.next_scp, using synthetic keys.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.