fix(jsonrpc): correct TransactionResult.nonce per JSON-RPC spec#6709
Merged
lvs0075 merged 1 commit intoMay 8, 2026
Merged
Conversation
bladehan1
reviewed
Apr 28, 2026
bladehan1
reviewed
Apr 28, 2026
bladehan1
reviewed
Apr 28, 2026
Per ethereum/execution-apis, TransactionInfo.nonce is `uint` (QUANTITY) and must match `^0x(0|[1-9a-f][0-9a-f]*)$`. java-tron emitted the field as `0x0000000000000000` via `ByteArray.toJsonHex(new byte[8])`, which violates the pattern. Both `TransactionResult` constructors now emit `"0x0"`. Block.nonce is intentionally left at `0x0000000000000000` because the Block schema defines it as `bytes8`, so that value is already compliant and shortening it would break conformance. Closes tronprotocol#6547
cc50549 to
ef27b6d
Compare
Collaborator
Author
|
After review discussion, the scope of this PR has been narrowed to only the The branch has been force-pushed to a single minimal commit. Earlier inline comments on the now-removed changes are no longer applicable; please re-review the latest state. |
0xbigapple
reviewed
Apr 30, 2026
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.
What this PR does
Corrects the
noncefield inTransactionResult, the response body shared byeth_getTransactionByHash,eth_getTransactionByBlockHashAndIndex,eth_getTransactionByBlockNumberAndIndex, and the full-tx mode ofeth_getBlockByHash/eth_getBlockByNumber.Closes #6547.
Why
Per
ethereum/execution-apis:TransactionInfo.nonceisuint(QUANTITY), pattern^0x(0|[1-9a-f][0-9a-f]*)$- no leading zeros; zero is0x0.java-tron's
TransactionResultpreviously emittedByteArray.toJsonHex(new byte[8])->"0x0000000000000000"(16 hex chars), which violates the pattern.What changes
nonceTransactionResultconstructors0x00000000000000000x0Why
Block.nonceis intentionally NOT changedBlock.nonceisbytes8per the spec (pattern^0x[0-9a-f]{16}$), so the existing0x0000000000000000is already compliant. Shortening it to0x0would break conformance with the bytes8 length requirement.BlockResult.nonceis therefore left untouched and existingJsonrpcServiceTestassertions on it ("0x0000000000000000") remain valid.Compatibility
This PR makes a minimal, surgical change: only the
nonceliteral value is modified. All other fields inTransactionResultretain their existing serialization, preserving byte-for-byte compatibility with current production responses.The numeric semantics of
nonceare unchanged (Long.parseLongof either value yields0); only the string representation tightens to the spec-compliant form.Tests
TransactionResultTestis updated to:nonce == "0x0"in both test methods (covering bothTransactionResultconstructors).nonceagainst the schema regex^0x(0|[1-9a-f][0-9a-f]*)$via a smallassertQuantityhelper, so any future regression that re-introduces a leading-zero form will fail the test.Pre-submit checklist
noncereturned byeth_getTransactionByHashis non-compliant #6547), 2 files changed