receipt decoder - handle both formats at read time#10079
Draft
macfarla wants to merge 1 commit intobesu-eth:mainfrom
Draft
receipt decoder - handle both formats at read time#10079macfarla wants to merge 1 commit intobesu-eth:mainfrom
macfarla wants to merge 1 commit intobesu-eth:mainfrom
Conversation
…d time Instead of converting sync receipts to canonical format at write time (which fails for wire-format typed receipts passed to TransactionReceiptDecoder), store raw wire bytes and handle both formats at read time: - putSyncTransactionReceipts: restored to store raw bytes with normalizeReceiptRlpElement wrapping raw type bytes (0x01-0x7F) as byte strings so the RLP list structure remains unambiguous. - rlpDecodeTransactionReceipts: now uses SyncTransactionReceiptDecoder + SyncTransactionReceiptConverter rather than TransactionReceiptDecoder directly, handling all 8 format combinations (legacy/typed × compacted/non-compacted × wire/canonical). - SyncTransactionReceiptDecoder.parseLogs: upgraded to handle both raw bytes32 topics (wire format) and [leadingZeros, shortData] lists (canonical compacted storage format) via per-item nextIsList() check and a new readTrimmedData helper mirroring Log.readFrom compacted logic. - SyncTransactionReceiptConverter.toTransactionReceipt: added storageFormatRlpInput helper to wrap wire-format typed receipts (first byte < 0x80) as byte strings before passing to TransactionReceiptDecoder, fixing the "Cannot enter a list, input is fully consumed (at bytes 0-0: [])" RLPException on fresh nodes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
Comment on lines
+145
to
+154
| final List<Bytes> topics = | ||
| logInput.readList( | ||
| topicIn -> | ||
| topicIn.nextIsList() | ||
| ? Bytes32.wrap(readTrimmedData(topicIn)) | ||
| : topicIn.readBytes32()); | ||
|
|
||
| // Data may also be compacted [leadingZeros, shortData] in canonical storage format. | ||
| final Bytes data = | ||
| logInput.nextIsList() ? readTrimmedData(logInput) : logInput.readBytes(); |
Contributor
There was a problem hiding this comment.
Isn't it possible to just do this change in the TransactionReceiptDecoder to avoid the need to use SyncTransactionReceiptDecoder and SyncTransactionReceiptConverter when loading from the DB?
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.
PR description
Fix receipt decode failure after snap sync
Problem
After snap syncing receipts from a peer (eth/69 or eth/70), subsequent reads of those receipts from local storage failed with:
RLPException: Cannot enter a lists, input is fully consumed (at bytes 0-0: [])
This manifested in two ways:
Root cause
Snap sync receives receipts in wire format. Compact receipts (eth/69/70, no bloom filter) encode log topics as raw bytes32. The read path used TransactionReceiptDecoder, which calls Log.readFrom(in, compacted=true) and expects canonical compacted storage format where topics are [leadingZeros, shortData] lists. This format mismatch caused the RLPException.
Additionally, for EIP-2718 typed receipts in wire format (type_byte || rlp_list, first byte 0x01–0x7F), TransactionReceiptDecoder reads the first byte as a 1-byte SHORT_ELEMENT, slices it off leaving Bytes.EMPTY, then fails on enterList() of the empty input - the "at bytes 0-0: []" error.
Changes:
Instead of converting sync receipts to canonical format at write time (which fails for wire-format typed receipts passed to TransactionReceiptDecoder), store raw wire bytes and handle both formats at read time:
putSyncTransactionReceipts: restored to store raw bytes with normalizeReceiptRlpElement wrapping raw type bytes (0x01-0x7F) as byte strings so the RLP list structure remains unambiguous.
rlpDecodeTransactionReceipts: now uses SyncTransactionReceiptDecoder + SyncTransactionReceiptConverter rather than TransactionReceiptDecoder directly, handling all 8 format combinations (legacy/typed × compacted/non-compacted × wire/canonical).
SyncTransactionReceiptDecoder.parseLogs: upgraded to handle both raw bytes32 topics (wire format) and [leadingZeros, shortData] lists (canonical compacted storage format) via per-item nextIsList() check and a new readTrimmedData helper mirroring Log.readFrom compacted logic.
SyncTransactionReceiptConverter.toTransactionReceipt: added storageFormatRlpInput helper to wrap wire-format typed receipts (first byte < 0x80) as byte strings before passing to TransactionReceiptDecoder, fixing the "Cannot enter a list, input is fully consumed (at bytes 0-0: [])" RLPException on fresh nodes.
Fixed Issue(s)
Thanks for sending a pull request! Have you done the following?
doc-change-requiredlabel to this PR if updates are required.Locally, you can run these tests to catch failures early:
./gradlew spotlessApply./gradlew build./gradlew acceptanceTest./gradlew integrationTest./gradlew ethereum:referenceTests:referenceTests