Skip to content

Commit

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

This is an automatic backport of pull request #1174 done by
[Mergify](https://mergify.com).


---


<details>
<summary>Mergify commands and options</summary>

<br />

More conditions and actions can be found in the
[documentation](https://docs.mergify.com/).

You can also trigger Mergify actions by commenting on this pull request:

- `@Mergifyio refresh` will re-evaluate the rules
- `@Mergifyio rebase` will rebase this PR on its base branch
- `@Mergifyio update` will merge the base branch into this PR
- `@Mergifyio backport <destination>` will backport this PR on
`<destination>` branch

Additionally, on Mergify [dashboard](https://dashboard.mergify.com) you
can:

- look at your merge queues
- generate the Mergify configuration with the config editor.

Finally, you can contact us on https://mergify.com
</details>

Co-authored-by: Callum Waters <cmwaters19@gmail.com>
  • Loading branch information
mergify[bot] and cmwaters authored Jan 20, 2024
1 parent b761147 commit 5a5e689
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 @@ -752,6 +752,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 @@ -395,9 +395,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 5a5e689

Please sign in to comment.