Skip to content

Commit

Permalink
feat: update default mempool config
Browse files Browse the repository at this point in the history
  • Loading branch information
rootulp committed Oct 10, 2024
1 parent a7476c6 commit 751782e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
19 changes: 7 additions & 12 deletions app/default_overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/celestiaorg/celestia-app/v3/pkg/appconsts"
"github.com/celestiaorg/celestia-app/v3/x/mint"
minttypes "github.com/celestiaorg/celestia-app/v3/x/mint/types"
"github.com/celestiaorg/go-square/v2/share"
"github.com/cosmos/cosmos-sdk/codec"
serverconfig "github.com/cosmos/cosmos-sdk/server/config"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -37,6 +36,8 @@ import (
coretypes "github.com/tendermint/tendermint/types"
)

const mebibyte = 1024 * 1024

// bankModule defines a custom wrapper around the x/bank module's AppModuleBasic
// implementation to provide custom default genesis state.
type bankModule struct {
Expand Down Expand Up @@ -259,20 +260,14 @@ func DefaultEvidenceParams() tmproto.EvidenceParams {
func DefaultConsensusConfig() *tmcfg.Config {
cfg := tmcfg.DefaultConfig()
// Set broadcast timeout to be 50 seconds in order to avoid timeouts for long block times
// TODO: make TimeoutBroadcastTx configurable per https://github.com/celestiaorg/celestia-app/issues/1034
cfg.RPC.TimeoutBroadcastTxCommit = 50 * time.Second
cfg.RPC.MaxBodyBytes = int64(8388608) // 8 MiB

cfg.Mempool.TTLNumBlocks = 5
cfg.Mempool.TTLDuration = time.Duration(cfg.Mempool.TTLNumBlocks) * appconsts.GoalBlockTime
// Given that there is a stateful transaction size check in CheckTx,
// We set a loose upper bound on what we expect the transaction to
// be based on the upper bound size of the entire block for the given
// version. This acts as a first line of DoS protection
upperBoundBytes := appconsts.DefaultSquareSizeUpperBound * appconsts.DefaultSquareSizeUpperBound * share.ContinuationSparseShareContentSize
cfg.Mempool.MaxTxBytes = upperBoundBytes
cfg.Mempool.MaxTxsBytes = int64(upperBoundBytes) * cfg.Mempool.TTLNumBlocks
cfg.Mempool.Version = "v1" // prioritized mempool
cfg.Mempool.TTLNumBlocks = 12
cfg.Mempool.TTLDuration = time.Duration(75 * time.Second)

Check failure on line 267 in app/default_overrides.go

View workflow job for this annotation

GitHub Actions / lint / golangci-lint

unnecessary conversion (unconvert)
cfg.Mempool.MaxTxBytes = 8 * mebibyte // 8 MiB
cfg.Mempool.MaxTxsBytes = 40 * mebibyte // 40 MiB
cfg.Mempool.Version = "v1" // prioritized mempool

cfg.Consensus.TimeoutPropose = appconsts.TimeoutPropose
cfg.Consensus.TimeoutCommit = appconsts.TimeoutCommit
Expand Down
8 changes: 4 additions & 4 deletions app/default_overrides_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ func TestDefaultConsensusConfig(t *testing.T) {
Size: tmcfg.DefaultMempoolConfig().Size,
WalPath: tmcfg.DefaultMempoolConfig().WalPath,

// overrides
MaxTxBytes: 7_897_088,
MaxTxsBytes: 39_485_440,
// Overrides
TTLNumBlocks: 12,
TTLDuration: 75 * time.Second,
TTLNumBlocks: 5,
MaxTxBytes: 8 * mebibyte,
MaxTxsBytes: 40 * mebibyte,
Version: "v1",
}
assert.Equal(t, want, *got.Mempool)
Expand Down

0 comments on commit 751782e

Please sign in to comment.