Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

Commit

Permalink
rid of retry broadcast in handler
Browse files Browse the repository at this point in the history
  • Loading branch information
calbera committed Jan 31, 2024
1 parent 6a8aa92 commit 3c50b5c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
7 changes: 5 additions & 2 deletions cosmos/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,11 @@ func (p *Polaris) SetupServices(clientCtx client.Context) error {
clientCtx.TxConfig, evmtypes.WrapPayload))

// Initialize the txpool with a new transaction serializer.
p.WrappedTxPool.Init(p.logger, clientCtx, libtx.NewSerializer[*ethtypes.Transaction](
clientCtx.TxConfig, evmtypes.WrapTx))
p.WrappedTxPool.Init(
p.logger, clientCtx,
libtx.NewSerializer[*ethtypes.Transaction](clientCtx.TxConfig, evmtypes.WrapTx),
clientCtx.Client,
)

// Register services with Polaris.
p.RegisterLifecycles([]node.Lifecycle{
Expand Down
21 changes: 18 additions & 3 deletions cosmos/runtime/txpool/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@
package txpool

import (
"context"
"errors"
"sync/atomic"
"time"

coretypes "github.com/cometbft/cometbft/rpc/core/types"

"cosmossdk.io/log"

"github.com/cosmos/cosmos-sdk/telemetry"
Expand All @@ -40,7 +43,7 @@ import (
// size of tx pool.
const (
txChanSize = 4096
maxRetries = 5
maxRetries = 0
retryDelay = 50 * time.Millisecond
statPeriod = 60 * time.Second
)
Expand All @@ -67,6 +70,16 @@ type TxBroadcaster interface {
BroadcastTxSync(txBytes []byte) (res *sdk.TxResponse, err error)
}

type TxSearcher interface {
TxSearch(
ctx context.Context,
query string,
prove bool,
page, perPage *int,
orderBy string,
) (*coretypes.ResultTxSearch, error)
}

// Subscription represents a subscription to the txpool.
type Subscription interface {
event.Subscription
Expand All @@ -85,6 +98,7 @@ type handler struct {
logger log.Logger
clientCtx TxBroadcaster
serializer TxSerializer
searcher TxSearcher
crc CometRemoteCache

// Ethereum
Expand All @@ -100,13 +114,14 @@ type handler struct {

// newHandler creates a new handler.
func newHandler(
clientCtx TxBroadcaster, txPool TxSubProvider, serializer TxSerializer,
clientCtx TxBroadcaster, txSearcher TxSearcher, txPool TxSubProvider, serializer TxSerializer,
crc CometRemoteCache, logger log.Logger,
) *handler {
h := &handler{
logger: logger,
clientCtx: clientCtx,
serializer: serializer,
searcher: txSearcher,
crc: crc,
txPool: txPool,
txsCh: make(chan core.NewTxsEvent, txChanSize),
Expand All @@ -122,7 +137,7 @@ func (h *handler) Start() error {
return errors.New("handler already started")
}
go h.mainLoop()
go h.failedLoop() // Start the retry policy
// go h.failedLoop() // Start the retry policy
go h.statLoop()
return nil
}
Expand Down
3 changes: 2 additions & 1 deletion cosmos/runtime/txpool/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ func (m *Mempool) Init(
logger log.Logger,
txBroadcaster TxBroadcaster,
txSerializer TxSerializer,
txSearcher TxSearcher,
) {
m.handler = newHandler(txBroadcaster, m.TxPool, txSerializer, m.crc, logger)
m.handler = newHandler(txBroadcaster, txSearcher, m.TxPool, txSerializer, m.crc, logger)
}

// Start starts the Mempool TxHandler.
Expand Down

0 comments on commit 3c50b5c

Please sign in to comment.