Skip to content

Commit

Permalink
[CLOB-914] Increase the mempool cache size to prevent replay attacks …
Browse files Browse the repository at this point in the history
…for short-term placements/cancellations. (dydxprotocol#486)
  • Loading branch information
lcwik committed Oct 5, 2023
1 parent fac10ef commit 0bac117
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion protocol/cmd/dydxprotocold/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
tmcfg "github.com/cometbft/cometbft/config"
serverconfig "github.com/cosmos/cosmos-sdk/server/config"
assettypes "github.com/dydxprotocol/v4-chain/protocol/x/assets/types"
clobtypes "github.com/dydxprotocol/v4-chain/protocol/x/clob/types"
)

const (
Expand Down Expand Up @@ -84,7 +85,11 @@ func initTendermintConfig() *tmcfg.Config {

// Mempool config.
cfg.Mempool.Version = "v1"
cfg.Mempool.CacheSize = 20000
// We specifically are using a number greater than max QPS (currently set at 5000) * ShortBlockWindow to prevent
// a replay attack that is possible with short-term order placements and cancellations. The attack would consume
// a users rate limit if the entry is evicted from the mempool cache as it would be possible for the transaction
// to go through `CheckTx` again causing it to hit rate limit code against the users account.
cfg.Mempool.CacheSize = 5000 * int(clobtypes.ShortBlockWindow)
cfg.Mempool.Size = 50000
cfg.Mempool.TTLNumBlocks = 20 //nolint:staticcheck
cfg.Mempool.KeepInvalidTxsInCache = true
Expand Down

0 comments on commit 0bac117

Please sign in to comment.