Skip to content

Commit f6064f3

Browse files
authored
internal/ethapi: convert legacy blobtx proofs in sendRawTransaction (#32849)
This adds a temporary conversion path for blob transactions with legacy proof sidecar. This feature will activate after Fusaka. We will phase this out when the fork has sufficiently settled and client side libraries have been upgraded to send the new proofs.
1 parent 55a5320 commit f6064f3

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

internal/ethapi/api.go

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,16 +1619,9 @@ func (api *TransactionAPI) SendTransaction(ctx context.Context, args Transaction
16191619
// processing (signing + broadcast).
16201620
func (api *TransactionAPI) FillTransaction(ctx context.Context, args TransactionArgs) (*SignTransactionResult, error) {
16211621
// Set some sanity defaults and terminate on failure
1622-
sidecarVersion := types.BlobSidecarVersion0
1623-
if len(args.Blobs) > 0 {
1624-
h := api.b.CurrentHeader()
1625-
if api.b.ChainConfig().IsOsaka(h.Number, h.Time) {
1626-
sidecarVersion = types.BlobSidecarVersion1
1627-
}
1628-
}
16291622
config := sidecarConfig{
16301623
blobSidecarAllowed: true,
1631-
blobSidecarVersion: sidecarVersion,
1624+
blobSidecarVersion: api.currentBlobSidecarVersion(),
16321625
}
16331626
if err := args.setDefaults(ctx, api.b, config); err != nil {
16341627
return nil, err
@@ -1642,13 +1635,34 @@ func (api *TransactionAPI) FillTransaction(ctx context.Context, args Transaction
16421635
return &SignTransactionResult{data, tx}, nil
16431636
}
16441637

1638+
func (api *TransactionAPI) currentBlobSidecarVersion() byte {
1639+
h := api.b.CurrentHeader()
1640+
if api.b.ChainConfig().IsOsaka(h.Number, h.Time) {
1641+
return types.BlobSidecarVersion1
1642+
}
1643+
return types.BlobSidecarVersion0
1644+
}
1645+
16451646
// SendRawTransaction will add the signed transaction to the transaction pool.
16461647
// The sender is responsible for signing the transaction and using the correct nonce.
16471648
func (api *TransactionAPI) SendRawTransaction(ctx context.Context, input hexutil.Bytes) (common.Hash, error) {
16481649
tx := new(types.Transaction)
16491650
if err := tx.UnmarshalBinary(input); err != nil {
16501651
return common.Hash{}, err
16511652
}
1653+
1654+
// Convert legacy blob transaction proofs.
1655+
// TODO: remove in go-ethereum v1.17.x
1656+
if sc := tx.BlobTxSidecar(); sc != nil {
1657+
exp := api.currentBlobSidecarVersion()
1658+
if sc.Version == types.BlobSidecarVersion0 && exp == types.BlobSidecarVersion1 {
1659+
if err := sc.ToV1(); err != nil {
1660+
return common.Hash{}, fmt.Errorf("blob sidecar conversion failed: %v", err)
1661+
}
1662+
tx = tx.WithBlobTxSidecar(sc)
1663+
}
1664+
}
1665+
16521666
return SubmitTransaction(ctx, api.b, tx)
16531667
}
16541668

0 commit comments

Comments
 (0)