From 60f003024e9e866fe4b647bd16f159aed60adb19 Mon Sep 17 00:00:00 2001 From: "weixie.cui" Date: Sun, 17 May 2026 23:18:29 +0800 Subject: [PATCH] core/types: encode blob tx version decode blobtx sidecar --- core/types/transaction_marshalling.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/core/types/transaction_marshalling.go b/core/types/transaction_marshalling.go index f76d4b92e9..6c8c000931 100644 --- a/core/types/transaction_marshalling.go +++ b/core/types/transaction_marshalling.go @@ -50,6 +50,7 @@ type txJSON struct { YParity *hexutil.Uint64 `json:"yParity,omitempty"` // Blob transaction sidecar encoding: + Version *hexutil.Uint64 `json:"version,omitempty"` Blobs []kzg4844.Blob `json:"blobs,omitempty"` Commitments []kzg4844.Commitment `json:"commitments,omitempty"` Proofs []kzg4844.Proof `json:"proofs,omitempty"` @@ -150,6 +151,8 @@ func (tx *Transaction) MarshalJSON() ([]byte, error) { yparity := itx.V.Uint64() enc.YParity = (*hexutil.Uint64)(&yparity) if sidecar := itx.Sidecar; sidecar != nil { + version := uint64(sidecar.Version) + enc.Version = (*hexutil.Uint64)(&version) enc.Blobs = itx.Sidecar.Blobs enc.Commitments = itx.Sidecar.Commitments enc.Proofs = itx.Sidecar.Proofs @@ -429,6 +432,22 @@ func (tx *Transaction) UnmarshalJSON(input []byte) error { } } + if len(dec.Blobs) > 0 || len(dec.Commitments) > 0 || len(dec.Proofs) > 0 { + if len(dec.Blobs) != len(dec.Commitments) || len(dec.Blobs) != len(dec.Proofs) { + return errors.New("blob transaction sidecar fields 'blobs', 'commitments', and 'proofs' must all have the same length") + } + version := BlobSidecarVersion0 + if dec.Version != nil { + version = byte(*dec.Version) + } + itx.Sidecar = &BlobTxSidecar{ + Version: version, + Blobs: dec.Blobs, + Commitments: dec.Commitments, + Proofs: dec.Proofs, + } + } + case SetCodeTxType: var itx SetCodeTx inner = &itx