Skip to content

Commit 342285b

Browse files
authored
eth, internal: add blob conversion for SendRawTransactionSync (#32930)
1 parent 0a2c21a commit 342285b

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

internal/ethapi/api.go

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1675,20 +1675,32 @@ func (api *TransactionAPI) SendRawTransactionSync(ctx context.Context, input hex
16751675
return nil, err
16761676
}
16771677

1678+
// Convert legacy blob transaction proofs.
1679+
// TODO: remove in go-ethereum v1.17.x
1680+
if sc := tx.BlobTxSidecar(); sc != nil {
1681+
exp := api.currentBlobSidecarVersion()
1682+
if sc.Version == types.BlobSidecarVersion0 && exp == types.BlobSidecarVersion1 {
1683+
if err := sc.ToV1(); err != nil {
1684+
return nil, fmt.Errorf("blob sidecar conversion failed: %v", err)
1685+
}
1686+
tx = tx.WithBlobTxSidecar(sc)
1687+
}
1688+
}
1689+
16781690
ch := make(chan core.ChainEvent, 128)
16791691
sub := api.b.SubscribeChainEvent(ch)
1680-
subErrCh := sub.Err()
16811692
defer sub.Unsubscribe()
16821693

16831694
hash, err := SubmitTransaction(ctx, api.b, tx)
16841695
if err != nil {
16851696
return nil, err
16861697
}
16871698

1688-
maxTimeout := api.b.RPCTxSyncMaxTimeout()
1689-
defaultTimeout := api.b.RPCTxSyncDefaultTimeout()
1690-
1691-
timeout := defaultTimeout
1699+
var (
1700+
maxTimeout = api.b.RPCTxSyncMaxTimeout()
1701+
defaultTimeout = api.b.RPCTxSyncDefaultTimeout()
1702+
timeout = defaultTimeout
1703+
)
16921704
if timeoutMs != nil && *timeoutMs > 0 {
16931705
req := time.Duration(*timeoutMs) * time.Millisecond
16941706
if req > maxTimeout {
@@ -1697,7 +1709,6 @@ func (api *TransactionAPI) SendRawTransactionSync(ctx context.Context, input hex
16971709
timeout = req
16981710
}
16991711
}
1700-
17011712
receiptCtx, cancel := context.WithTimeout(ctx, timeout)
17021713
defer cancel()
17031714

@@ -1706,19 +1717,20 @@ func (api *TransactionAPI) SendRawTransactionSync(ctx context.Context, input hex
17061717
return r, nil
17071718
}
17081719

1720+
// Monitor the receipts
17091721
for {
17101722
select {
17111723
case <-receiptCtx.Done():
17121724
// If server-side wait window elapsed, return the structured timeout.
17131725
if errors.Is(receiptCtx.Err(), context.DeadlineExceeded) {
17141726
return nil, &txSyncTimeoutError{
1715-
msg: fmt.Sprintf("The transaction was added to the transaction pool but wasn't processed in %v.", timeout),
1727+
msg: fmt.Sprintf("The transaction was added to the transaction pool but wasn't processed in %v", timeout),
17161728
hash: hash,
17171729
}
17181730
}
17191731
return nil, receiptCtx.Err()
17201732

1721-
case err, ok := <-subErrCh:
1733+
case err, ok := <-sub.Err():
17221734
if !ok {
17231735
return nil, errSubClosed
17241736
}
@@ -1728,8 +1740,7 @@ func (api *TransactionAPI) SendRawTransactionSync(ctx context.Context, input hex
17281740
if !ok {
17291741
return nil, errSubClosed
17301742
}
1731-
rs := ev.Receipts
1732-
txs := ev.Transactions
1743+
rs, txs := ev.Receipts, ev.Transactions
17331744
if len(rs) == 0 || len(rs) != len(txs) {
17341745
continue
17351746
}

0 commit comments

Comments
 (0)