From 92c9f57227e54588744ed9153d8f7a7db6d01837 Mon Sep 17 00:00:00 2001 From: marukai67 Date: Mon, 12 Jan 2026 22:24:05 +0100 Subject: [PATCH] Update api.go --- internal/ethapi/api.go | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index d48bffd818..ffa9b82b61 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1638,6 +1638,19 @@ func (api *TransactionAPI) currentBlobSidecarVersion() byte { return types.BlobSidecarVersion0 } +// convertLegacyBlobSidecar upgrades legacy blob sidecar proofs to the currently +// expected version if needed. It returns the (possibly updated) transaction. +func convertLegacyBlobSidecar(tx *types.Transaction, expectedVersion byte) (*types.Transaction, error) { + sc := tx.BlobTxSidecar() + if sc == nil || sc.Version != types.BlobSidecarVersion0 || expectedVersion != types.BlobSidecarVersion1 { + return tx, nil + } + if err := sc.ToV1(); err != nil { + return nil, fmt.Errorf("blob sidecar conversion failed: %v", err) + } + return tx.WithBlobTxSidecar(sc), nil +} + // SendRawTransaction will add the signed transaction to the transaction pool. // The sender is responsible for signing the transaction and using the correct nonce. func (api *TransactionAPI) SendRawTransaction(ctx context.Context, input hexutil.Bytes) (common.Hash, error) { @@ -1648,14 +1661,10 @@ func (api *TransactionAPI) SendRawTransaction(ctx context.Context, input hexutil // Convert legacy blob transaction proofs. // TODO: remove in go-ethereum v1.17.x - if sc := tx.BlobTxSidecar(); sc != nil { - exp := api.currentBlobSidecarVersion() - if sc.Version == types.BlobSidecarVersion0 && exp == types.BlobSidecarVersion1 { - if err := sc.ToV1(); err != nil { - return common.Hash{}, fmt.Errorf("blob sidecar conversion failed: %v", err) - } - tx = tx.WithBlobTxSidecar(sc) - } + if updated, err := convertLegacyBlobSidecar(tx, api.currentBlobSidecarVersion()); err != nil { + return common.Hash{}, err + } else { + tx = updated } return SubmitTransaction(ctx, api.b, tx) @@ -1671,14 +1680,10 @@ func (api *TransactionAPI) SendRawTransactionSync(ctx context.Context, input hex // Convert legacy blob transaction proofs. // TODO: remove in go-ethereum v1.17.x - if sc := tx.BlobTxSidecar(); sc != nil { - exp := api.currentBlobSidecarVersion() - if sc.Version == types.BlobSidecarVersion0 && exp == types.BlobSidecarVersion1 { - if err := sc.ToV1(); err != nil { - return nil, fmt.Errorf("blob sidecar conversion failed: %v", err) - } - tx = tx.WithBlobTxSidecar(sc) - } + if updated, err := convertLegacyBlobSidecar(tx, api.currentBlobSidecarVersion()); err != nil { + return nil, err + } else { + tx = updated } ch := make(chan core.ChainEvent, 128)