mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 21:56:43 +00:00
refactor: make tx forwarding to sequencer non-blocking if tx pool is enabled (#1227)
* make sequencer forwarding non-blocking if tx pool is enabled * chore: auto version bump [bot] * address review comments * chore: auto version bump [bot] * fix: blob client beacon node do http request with context (#1228) * fix: beacon node client request with context * chore: auto version bump [bot] --------- Co-authored-by: Morty <70688412+yiweichi@users.noreply.github.com>
This commit is contained in:
parent
4c967ae4c2
commit
35bc5a9b0f
2 changed files with 28 additions and 8 deletions
|
|
@ -19,6 +19,7 @@ package eth
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -277,16 +278,35 @@ func (b *EthAPIBackend) SendTx(ctx context.Context, signedTx *types.Transaction)
|
||||||
|
|
||||||
// Forward to remote sequencer RPC
|
// Forward to remote sequencer RPC
|
||||||
if b.eth.sequencerRPCService != nil {
|
if b.eth.sequencerRPCService != nil {
|
||||||
signedTxData, err := signedTx.MarshalBinary()
|
// If the transaction pool is disabled, then we need to make sure that we send the transaction to the sequencer RPC synchronously.
|
||||||
if err != nil {
|
if b.disableTxPool {
|
||||||
|
err = b.sendToSequencer(ctx, signedTx)
|
||||||
|
if err != nil {
|
||||||
|
log.Warn("failed to forward tx to sequencer", "tx", signedTx.Hash(), "err", err)
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err = b.eth.sequencerRPCService.CallContext(ctx, nil, "eth_sendRawTransaction", hexutil.Encode(signedTxData)); err != nil {
|
|
||||||
log.Warn("failed to forward tx to sequencer", "tx", signedTx.Hash(), "err", err)
|
// If the transaction pool is enabled, we send the transaction to the sequencer RPC asynchronously as this is
|
||||||
if b.disableTxPool {
|
// additional to the public mempool.
|
||||||
return err
|
go func() {
|
||||||
|
err := b.sendToSequencer(ctx, signedTx)
|
||||||
|
if err != nil {
|
||||||
|
log.Warn("failed to forward tx to sequencer", "tx", signedTx.Hash(), "err", err)
|
||||||
}
|
}
|
||||||
}
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *EthAPIBackend) sendToSequencer(ctx context.Context, signedTx *types.Transaction) error {
|
||||||
|
signedTxData, err := signedTx.MarshalBinary()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to marshal signed tx: %w", err)
|
||||||
|
}
|
||||||
|
if err = b.eth.sequencerRPCService.CallContext(ctx, nil, "eth_sendRawTransaction", hexutil.Encode(signedTxData)); err != nil {
|
||||||
|
return fmt.Errorf("eth_sendRawTransaction to sequencer RPC failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import (
|
||||||
const (
|
const (
|
||||||
VersionMajor = 5 // Major version component of the current release
|
VersionMajor = 5 // Major version component of the current release
|
||||||
VersionMinor = 8 // Minor version component of the current release
|
VersionMinor = 8 // Minor version component of the current release
|
||||||
VersionPatch = 75 // Patch version component of the current release
|
VersionPatch = 76 // Patch version component of the current release
|
||||||
VersionMeta = "mainnet" // Version metadata to append to the version string
|
VersionMeta = "mainnet" // Version metadata to append to the version string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue