Conversation
…284) Co-authored-by: fletcher.fan <fletcher.fan@bitget.com>
MorphTx enhance & implement reference key
concensus: pbft to single sequencer, include P2P & block produce Co-authored-by: allen.wu <allen.wu@bitget.com>
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.).
|
Caution Review failedThe pull request is closed. ℹ️ Recent review infoConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (55)
📝 WalkthroughWalkthroughThis PR introduces MorphTx as a new versioned transaction type replacing AltFeeTx, adds a Reference metadata type for transaction indexing, renames MPTFork to JadeFork throughout, implements a reference index subsystem for transaction lookups, and extends receipts and RPC APIs to support versioned transaction metadata. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant TransactionArgs
participant BlockChain
participant TxPool
participant StateProcessor
participant ReferenceIndex
Note over Client,ReferenceIndex: MorphTx V1 with Reference Creation & Indexing
Client->>TransactionArgs: Submit TX with Version=V1, Reference=ref
TransactionArgs->>TransactionArgs: isMorphTxArgs() check
TransactionArgs->>TransactionArgs: validateMorphTxVersion()
TransactionArgs->>TransactionArgs: toTransaction() → MorphTx creation
TransactionArgs->>TxPool: Add MorphTx V1
TxPool->>TxPool: Check Jade fork active
TxPool->>TxPool: ValidateMorphTxVersion()
TxPool->>TxPool: Accept into pool
BlockChain->>BlockChain: InsertChain()
BlockChain->>StateProcessor: Process TX
StateProcessor->>StateProcessor: Populate receipt fields (Version, Reference, Memo)
StateProcessor->>BlockChain: Return receipt
BlockChain->>ReferenceIndex: WriteReferenceIndexEntriesForBlock()
ReferenceIndex->>ReferenceIndex: Extract MorphTx references
ReferenceIndex->>ReferenceIndex: Construct index keys (ref + timestamp + txIndex)
ReferenceIndex->>ReferenceIndex: Persist to database
BlockChain->>BlockChain: maintainReferenceIndex() background
BlockChain->>ReferenceIndex: Manage tail, prune old entries
sequenceDiagram
participant RPC Client
participant ethclient
participant PublicMorphAPI
participant rawdb
participant Database
Note over RPC Client,Database: Reference-Based Transaction Query Flow
RPC Client->>ethclient: GetTransactionHashesByReference(ref, offset, limit)
ethclient->>ethclient: Construct ReferenceQueryArgs
ethclient->>PublicMorphAPI: Call morph_getTransactionHashesByReference
PublicMorphAPI->>rawdb: ReadReferenceIndexEntries(reference)
rawdb->>Database: Iterate reference index by prefix
Database-->>rawdb: Return sorted entries (blockTimestamp, txIndex, txHash)
rawdb->>PublicMorphAPI: []ReferenceIndexEntry
PublicMorphAPI->>PublicMorphAPI: Apply offset/limit pagination
PublicMorphAPI-->>RPC Client: []ReferenceTransactionResult
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.5.0)Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions 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 |
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 errorSummary by CodeRabbit
Release Notes
New Features
Updates