Fix transaction proofs with duplicate witness ids - #2469
Open
a-shannon wants to merge 1 commit into
Open
Conversation
Contributor
Author
|
Added an explicit deterministic regression in 30d9c02. It creates three distinct transaction IDs with the same witness ID, first verifies that the proof is valid against the block root, and then verifies that the leaf is the requested transaction ID. On the parent commit the test fails only on the leaf-identity assertion; on this branch it passes. |
a-shannon
force-pushed
the
fix/transaction-membership-proof
branch
from
September 2, 2026 20:34
ca36ced to
202f762
Compare
Contributor
Author
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.
Summary
Root cause
For block versions after v1,
BlockTransactionscommits totxIds ++ witnessIds.The scrypto tree keeps every leaf in
topNode, but its hash-to-index map collapsesduplicate leaf hashes.
proofByElementthen traverses the real tree using the map'ssmaller size, so it can return a proof for another leaf that still validates against
the transaction root.
This change locates the requested transaction in
txIdsand traverses the existingtree with
nleaves for v1 or2nleaves for later versions. It also fails closed ifthe traversal does not terminate at the requested leaf.
Compatibility
The ordered leaves, Merkle-tree construction, transaction root, block serialization,
JSON schema, and consensus bytes are unchanged. Only membership-proof selection is
corrected. The transaction lookup is intentionally tx-only and uses a bounded linear
scan followed by logarithmic tree traversal.
The generic duplicate-leaf fix is already merged in scrypto #5. This
v6.0.6branchstill resolves scrypto 3.0.0, so the node-local fix remains necessary here.
Validation
v6.0.6base: the test-onlyBlockTransactionsSpecrun passed 1 test and failed the 2 new proof-identity casessbt "ergoCore/Test/testOnly org.ergoplatform.modifiers.history.BlockTransactionsSpec"— 3 passedsbt "ergoCore/Test/testOnly org.ergoplatform.serialization.SerializationCoreTests -- -z BlockTransactions"— 1 passedsbt "Test/testOnly org.ergoplatform.mining.ErgoMinerSpec"— 5 passedsbt "Test/testOnly org.ergoplatform.http.routes.BlocksApiRouteSpec"— 10 passed202f762cb38b6ac56c6cc9afdb9bf51aa5208dcaRelated work
Fixes #2463.
BlockTransactionsserializer parsing only; it does not change membership-proof selection.