fix: use hexutil.Uint64 for MorphTx version JSON encoding#293
Merged
fix: use hexutil.Uint64 for MorphTx version JSON encoding#293
Conversation
txJSON.Version was *uint8 (plain number) while RPCTransaction.Version uses *hexutil.Uint64 (hex string). This caused ethclient.BlockByNumber to fail with "cannot unmarshal string into Go struct field rpcBlock.transactions.version of type uint8" on non-sequencer nodes. Align txJSON.Version with the Ethereum JSON-RPC convention by using *hexutil.Uint64, consistent with all other numeric fields (FeeTokenID, QueueIndex, etc.).
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
tomatoishealthy
approved these changes
Mar 2, 2026
SegueII
pushed a commit
that referenced
this pull request
Mar 3, 2026
txJSON.Version was *uint8 (plain number) while RPCTransaction.Version uses *hexutil.Uint64 (hex string). This caused ethclient.BlockByNumber to fail with "cannot unmarshal string into Go struct field rpcBlock.transactions.version of type uint8" on non-sequencer nodes. Align txJSON.Version with the Ethereum JSON-RPC convention by using *hexutil.Uint64, consistent with all other numeric fields (FeeTokenID, QueueIndex, etc.).
FletcherMan
added a commit
that referenced
this pull request
Mar 6, 2026
* update morph tx * add reference * update * update * add test * fix sth * add check and test * add test * refactor: encode MorphTx version as prefix byte instead of RLP field (#284) Co-authored-by: fletcher.fan <fletcher.fan@bitget.com> * fix decode morphtx & receipt * fix get transaction hashes by reference * update args * fix args checks * fix version check * some improve * add args check * update * update * update to jade * active after jade fork time * check geth version * fix sth * fix reference validate * fix memo validate * fix tx filter * fix rpc and ref index * fix * fix version * add validate * update returns receipt & result * fix: use hexutil.Uint64 for MorphTx version JSON encoding (#293) txJSON.Version was *uint8 (plain number) while RPCTransaction.Version uses *hexutil.Uint64 (hex string). This caused ethclient.BlockByNumber to fail with "cannot unmarshal string into Go struct field rpcBlock.transactions.version of type uint8" on non-sequencer nodes. Align txJSON.Version with the Ethereum JSON-RPC convention by using *hexutil.Uint64, consistent with all other numeric fields (FeeTokenID, QueueIndex, etc.). * fix hash * add version check and test --------- Co-authored-by: segue <“huoda.china@gmail.com”> Co-authored-by: FletcherMan <fletcherman0709@gmail.com> Co-authored-by: fletcher.fan <fletcher.fan@bitget.com> Co-authored-by: panos <pan107104@outlook.com>
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
json: cannot unmarshal string into Go struct field rpcBlock.transactions.version of type uint8error on non-sequencer (syncing) nodestxJSON.Versionwas*uint8(plain number in JSON) whileRPCTransaction.Versioninapi.gouses*hexutil.Uint64(hex string like"0x1")txJSON.Versionwith the Ethereum JSON-RPC hex encoding convention, consistent with all other numeric fields (FeeTokenID,QueueIndex, etc.)Root Cause
Non-sequencer nodes call
eth_getBlockByNumberviaethclient.BlockByNumberto sync blocks. The RPC server serializesversionas"0x1"(hexutil.Uint64), buttypes.Transaction.UnmarshalJSONused*uint8which the standard JSON decoder cannot unmarshal from a hex string.Sequencers were unaffected because they never go through the JSON RPC path for block production — they operate directly on in-memory Go structs via the Engine API.
Changes
core/types/transaction_marshalling.go: changetxJSON.Versionfrom*uint8to*hexutil.Uint64, update marshal/unmarshal accordinglyTest plan
go test ./core/types/... -run "TestTransaction|TestMorph|TestMarshal|TestJSON"BlockByNumberon blocks containing MorphTx V1 transactions without error