Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 21 additions & 18 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1644,6 +1644,19 @@ func (api *TransactionAPI) currentBlobSidecarVersion() byte {
return types.BlobSidecarVersion0
}

// convertLegacyBlobSidecar upgrades the legacy blob sidecar if required.
// TODO: remove in go-ethereum v1.17.x
func convertLegacyBlobSidecar(tx *types.Transaction, expected byte) (*types.Transaction, error) {
sc := tx.BlobTxSidecar()
if sc == nil || sc.Version != types.BlobSidecarVersion0 || expected != 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) {
Expand All @@ -1653,15 +1666,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)
}
var err error
tx, err = convertLegacyBlobSidecar(tx, api.currentBlobSidecarVersion())
if err != nil {
return common.Hash{}, err
}

return SubmitTransaction(ctx, api.b, tx)
Expand All @@ -1676,15 +1684,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)
}
var err error
tx, err = convertLegacyBlobSidecar(tx, api.currentBlobSidecarVersion())
if err != nil {
return nil, err
}

ch := make(chan core.ChainEvent, 128)
Expand Down
Loading