mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-16 04:56:36 +00:00
eth, internal: add blob conversion for SendRawTransactionSync (#32930)
This commit is contained in:
parent
0a2c21acd5
commit
342285b139
1 changed files with 21 additions and 10 deletions
|
|
@ -1675,9 +1675,20 @@ func (api *TransactionAPI) SendRawTransactionSync(ctx context.Context, input hex
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ch := make(chan core.ChainEvent, 128)
|
ch := make(chan core.ChainEvent, 128)
|
||||||
sub := api.b.SubscribeChainEvent(ch)
|
sub := api.b.SubscribeChainEvent(ch)
|
||||||
subErrCh := sub.Err()
|
|
||||||
defer sub.Unsubscribe()
|
defer sub.Unsubscribe()
|
||||||
|
|
||||||
hash, err := SubmitTransaction(ctx, api.b, tx)
|
hash, err := SubmitTransaction(ctx, api.b, tx)
|
||||||
|
|
@ -1685,10 +1696,11 @@ func (api *TransactionAPI) SendRawTransactionSync(ctx context.Context, input hex
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
maxTimeout := api.b.RPCTxSyncMaxTimeout()
|
var (
|
||||||
defaultTimeout := api.b.RPCTxSyncDefaultTimeout()
|
maxTimeout = api.b.RPCTxSyncMaxTimeout()
|
||||||
|
defaultTimeout = api.b.RPCTxSyncDefaultTimeout()
|
||||||
timeout := defaultTimeout
|
timeout = defaultTimeout
|
||||||
|
)
|
||||||
if timeoutMs != nil && *timeoutMs > 0 {
|
if timeoutMs != nil && *timeoutMs > 0 {
|
||||||
req := time.Duration(*timeoutMs) * time.Millisecond
|
req := time.Duration(*timeoutMs) * time.Millisecond
|
||||||
if req > maxTimeout {
|
if req > maxTimeout {
|
||||||
|
|
@ -1697,7 +1709,6 @@ func (api *TransactionAPI) SendRawTransactionSync(ctx context.Context, input hex
|
||||||
timeout = req
|
timeout = req
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
receiptCtx, cancel := context.WithTimeout(ctx, timeout)
|
receiptCtx, cancel := context.WithTimeout(ctx, timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
|
|
@ -1706,19 +1717,20 @@ func (api *TransactionAPI) SendRawTransactionSync(ctx context.Context, input hex
|
||||||
return r, nil
|
return r, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Monitor the receipts
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-receiptCtx.Done():
|
case <-receiptCtx.Done():
|
||||||
// If server-side wait window elapsed, return the structured timeout.
|
// If server-side wait window elapsed, return the structured timeout.
|
||||||
if errors.Is(receiptCtx.Err(), context.DeadlineExceeded) {
|
if errors.Is(receiptCtx.Err(), context.DeadlineExceeded) {
|
||||||
return nil, &txSyncTimeoutError{
|
return nil, &txSyncTimeoutError{
|
||||||
msg: fmt.Sprintf("The transaction was added to the transaction pool but wasn't processed in %v.", timeout),
|
msg: fmt.Sprintf("The transaction was added to the transaction pool but wasn't processed in %v", timeout),
|
||||||
hash: hash,
|
hash: hash,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil, receiptCtx.Err()
|
return nil, receiptCtx.Err()
|
||||||
|
|
||||||
case err, ok := <-subErrCh:
|
case err, ok := <-sub.Err():
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, errSubClosed
|
return nil, errSubClosed
|
||||||
}
|
}
|
||||||
|
|
@ -1728,8 +1740,7 @@ func (api *TransactionAPI) SendRawTransactionSync(ctx context.Context, input hex
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, errSubClosed
|
return nil, errSubClosed
|
||||||
}
|
}
|
||||||
rs := ev.Receipts
|
rs, txs := ev.Receipts, ev.Transactions
|
||||||
txs := ev.Transactions
|
|
||||||
if len(rs) == 0 || len(rs) != len(txs) {
|
if len(rs) == 0 || len(rs) != len(txs) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue