Skip to content

Commit

Permalink
feat: add MaxGossipDelay from CAT pool to the config (#1174)
Browse files Browse the repository at this point in the history
Closes: #1120

This is an additive change and is thus non-breaking.
  • Loading branch information
cmwaters authored Jan 16, 2024
1 parent 19f3c2b commit 4deeaa6
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
6 changes: 6 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,12 @@ type MempoolConfig struct {
// has existed in the mempool at least TTLNumBlocks number of blocks or if
// it's insertion time into the mempool is beyond TTLDuration.
TTLNumBlocks int64 `mapstructure:"ttl-num-blocks"`

// MaxGossipDelay is the maximum allotted time that the reactor expects a transaction to
// arrive before issuing a new request to a different peer
// Only applicable to the v2 / CAT mempool
// Default is 200ms
MaxGossipDelay time.Duration `mapstructure:"max-gossip-delay"`
}

// DefaultMempoolConfig returns a default configuration for the CometBFT mempool
Expand Down
6 changes: 6 additions & 0 deletions config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,12 @@ ttl-duration = "{{ .Mempool.TTLDuration }}"
# it's insertion time into the mempool is beyond ttl-duration.
ttl-num-blocks = {{ .Mempool.TTLNumBlocks }}
# max-gossip-delay is the maximum allotted time that the reactor expects a transaction to
# arrive before issuing a new request to a different peer
# Only applicable to the v2 / CAT mempool
# Default is 200ms
max-gossip-delay = "{{ .Mempool.MaxGossipDelay }}"
#######################################################
### State Sync Configuration Options ###
#######################################################
Expand Down
4 changes: 2 additions & 2 deletions mempool/cat/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
const (
// default duration to wait before considering a peer non-responsive
// and searching for the tx from a new peer
defaultGossipDelay = 200 * time.Millisecond
DefaultGossipDelay = 200 * time.Millisecond

// Content Addressable Tx Pool gossips state based messages (SeenTx and WantTx) on a separate channel
// for cross compatibility
Expand Down Expand Up @@ -66,7 +66,7 @@ func (opts *ReactorOptions) VerifyAndComplete() error {
}

if opts.MaxGossipDelay == 0 {
opts.MaxGossipDelay = defaultGossipDelay
opts.MaxGossipDelay = DefaultGossipDelay
}

if opts.MaxTxSize < 0 {
Expand Down
7 changes: 4 additions & 3 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,10 @@ func createMempoolAndMempoolReactor(
reactor, err := mempoolv2.NewReactor(
mp,
&mempoolv2.ReactorOptions{
ListenOnly: !config.Mempool.Broadcast,
MaxTxSize: config.Mempool.MaxTxBytes,
TraceClient: traceClient,
ListenOnly: !config.Mempool.Broadcast,
MaxTxSize: config.Mempool.MaxTxBytes,
TraceClient: traceClient,
MaxGossipDelay: config.Mempool.MaxGossipDelay,
},
)
if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions test/maverick/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,9 @@ func createMempoolAndMempoolReactor(config *cfg.Config, proxyApp proxy.AppConns,
reactor, err := mempoolv2.NewReactor(
mp,
&mempoolv2.ReactorOptions{
ListenOnly: !config.Mempool.Broadcast,
MaxTxSize: config.Mempool.MaxTxBytes,
ListenOnly: !config.Mempool.Broadcast,
MaxTxSize: config.Mempool.MaxTxBytes,
MaxGossipDelay: config.Mempool.MaxGossipDelay,
},
)
if err != nil {
Expand Down

0 comments on commit 4deeaa6

Please sign in to comment.