Skip to content

fix: use hexutil.Uint64 for MorphTx version JSON encoding#293

Merged
panos-xyz merged 1 commit intotest_3_13from
fix/morph-tx-version-json
Mar 2, 2026
Merged

fix: use hexutil.Uint64 for MorphTx version JSON encoding#293
panos-xyz merged 1 commit intotest_3_13from
fix/morph-tx-version-json

Conversation

@panos-xyz
Copy link
Copy Markdown
Contributor

Summary

  • Fix json: cannot unmarshal string into Go struct field rpcBlock.transactions.version of type uint8 error on non-sequencer (syncing) nodes
  • txJSON.Version was *uint8 (plain number in JSON) while RPCTransaction.Version in api.go uses *hexutil.Uint64 (hex string like "0x1")
  • Align txJSON.Version with the Ethereum JSON-RPC hex encoding convention, consistent with all other numeric fields (FeeTokenID, QueueIndex, etc.)

Root Cause

Non-sequencer nodes call eth_getBlockByNumber via ethclient.BlockByNumber to sync blocks. The RPC server serializes version as "0x1" (hexutil.Uint64), but types.Transaction.UnmarshalJSON used *uint8 which 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: change txJSON.Version from *uint8 to *hexutil.Uint64, update marshal/unmarshal accordingly

Test plan

  • Run go test ./core/types/... -run "TestTransaction|TestMorph|TestMarshal|TestJSON"
  • Verify syncing node can call BlockByNumber on blocks containing MorphTx V1 transactions without error

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.).
@panos-xyz panos-xyz requested a review from a team as a code owner March 2, 2026 10:59
@panos-xyz panos-xyz requested review from tomatoishealthy and removed request for a team March 2, 2026 10:59
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 2, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/morph-tx-version-json

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@panos-xyz panos-xyz merged commit 256292d into test_3_13 Mar 2, 2026
1 check passed
@panos-xyz panos-xyz deleted the fix/morph-tx-version-json branch March 2, 2026 11:23
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants