mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-25 06:42:16 +00:00
mempool: make max_tx_bytes
configurable instead of max_msg_bytes
(#3877)
Fix #3868 (comment) Commits: * mempool: make `max_tx_bytes` configurable instead of `max_msg_bytes` * update CHANGELOG_PENDING * apply suggestions from code review
This commit is contained in:
parent
0cf8812b17
commit
e179787d40
@ -21,6 +21,7 @@ program](https://hackerone.com/tendermint).
|
||||
|
||||
- [privval] \#3370 Refactors and simplifies validator/kms connection handling. Please refer to thttps://github.com/tendermint/tendermint/pull/3370#issue-257360971
|
||||
- [consensus] \#3839 Reduce "Error attempting to add vote" message severity (Error -> Info)
|
||||
- [mempool] \#3877 Make `max_tx_bytes` configurable instead of `max_msg_bytes`
|
||||
|
||||
### BUG FIXES:
|
||||
|
||||
|
@ -637,7 +637,7 @@ type MempoolConfig struct {
|
||||
Size int `mapstructure:"size"`
|
||||
MaxTxsBytes int64 `mapstructure:"max_txs_bytes"`
|
||||
CacheSize int `mapstructure:"cache_size"`
|
||||
MaxMsgBytes int `mapstructure:"max_msg_bytes"`
|
||||
MaxTxBytes int `mapstructure:"max_tx_bytes"`
|
||||
}
|
||||
|
||||
// DefaultMempoolConfig returns a default configuration for the Tendermint mempool
|
||||
@ -651,7 +651,7 @@ func DefaultMempoolConfig() *MempoolConfig {
|
||||
Size: 5000,
|
||||
MaxTxsBytes: 1024 * 1024 * 1024, // 1GB
|
||||
CacheSize: 10000,
|
||||
MaxMsgBytes: 1024 * 1024, // 1MB
|
||||
MaxTxBytes: 1024 * 1024, // 1MB
|
||||
}
|
||||
}
|
||||
|
||||
@ -684,8 +684,8 @@ func (cfg *MempoolConfig) ValidateBasic() error {
|
||||
if cfg.CacheSize < 0 {
|
||||
return errors.New("cache_size can't be negative")
|
||||
}
|
||||
if cfg.MaxMsgBytes < 0 {
|
||||
return errors.New("max_msg_bytes can't be negative")
|
||||
if cfg.MaxTxBytes < 0 {
|
||||
return errors.New("max_tx_bytes can't be negative")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -294,8 +294,9 @@ max_txs_bytes = {{ .Mempool.MaxTxsBytes }}
|
||||
# Size of the cache (used to filter transactions we saw earlier) in transactions
|
||||
cache_size = {{ .Mempool.CacheSize }}
|
||||
|
||||
# Limit the size of TxMessage
|
||||
max_msg_bytes = {{ .Mempool.MaxMsgBytes }}
|
||||
# Maximum size of a single transaction.
|
||||
# NOTE: the max size of a tx transmitted over the network is {max_tx_bytes} + {amino overhead}.
|
||||
max_tx_bytes = {{ .Mempool.MaxTxBytes }}
|
||||
|
||||
##### fast sync configuration options #####
|
||||
[fastsync]
|
||||
|
@ -240,8 +240,9 @@ max_txs_bytes = 1073741824
|
||||
# Size of the cache (used to filter transactions we saw earlier) in transactions
|
||||
cache_size = 10000
|
||||
|
||||
# Limit the size of TxMessage
|
||||
max_msg_bytes = 1048576
|
||||
# Maximum size of a single transaction.
|
||||
# NOTE: the max size of a tx transmitted over the network is {max_tx_bytes} + {amino overhead}.
|
||||
max_tx_bytes = 1048576
|
||||
|
||||
##### fast sync configuration options #####
|
||||
[fastsync]
|
||||
|
@ -232,8 +232,8 @@ func (mem *CListMempool) CheckTxWithInfo(tx types.Tx, cb func(*abci.Response), t
|
||||
// The size of the corresponding amino-encoded TxMessage
|
||||
// can't be larger than the maxMsgSize, otherwise we can't
|
||||
// relay it to peers.
|
||||
if max := calcMaxTxSize(mem.config.MaxMsgBytes); txSize > max {
|
||||
return ErrTxTooLarge{max, txSize}
|
||||
if txSize > mem.config.MaxTxBytes {
|
||||
return ErrTxTooLarge{mem.config.MaxTxBytes, txSize}
|
||||
}
|
||||
|
||||
if mem.preCheck != nil {
|
||||
|
@ -426,8 +426,8 @@ func TestMempoolMaxMsgSize(t *testing.T) {
|
||||
mempl, cleanup := newMempoolWithApp(cc)
|
||||
defer cleanup()
|
||||
|
||||
maxMsgSize := mempl.config.MaxMsgBytes
|
||||
maxTxSize := calcMaxTxSize(mempl.config.MaxMsgBytes)
|
||||
maxTxSize := mempl.config.MaxTxBytes
|
||||
maxMsgSize := calcMaxMsgSize(maxTxSize)
|
||||
|
||||
testCases := []struct {
|
||||
len int
|
||||
|
@ -263,8 +263,9 @@ func RegisterMempoolMessages(cdc *amino.Codec) {
|
||||
}
|
||||
|
||||
func (memR *Reactor) decodeMsg(bz []byte) (msg MempoolMessage, err error) {
|
||||
if l := len(bz); l > memR.config.MaxMsgBytes {
|
||||
return msg, ErrTxTooLarge{memR.config.MaxMsgBytes, l}
|
||||
maxMsgSize := calcMaxMsgSize(memR.config.MaxTxBytes)
|
||||
if l := len(bz); l > maxMsgSize {
|
||||
return msg, ErrTxTooLarge{maxMsgSize, l}
|
||||
}
|
||||
err = cdc.UnmarshalBinaryBare(bz, &msg)
|
||||
return
|
||||
@ -282,8 +283,8 @@ func (m *TxMessage) String() string {
|
||||
return fmt.Sprintf("[TxMessage %v]", m.Tx)
|
||||
}
|
||||
|
||||
// calcMaxTxSize returns the max size of Tx
|
||||
// calcMaxMsgSize returns the max size of TxMessage
|
||||
// account for amino overhead of TxMessage
|
||||
func calcMaxTxSize(maxMsgSize int) int {
|
||||
return maxMsgSize - aminoOverheadForTxMessage
|
||||
func calcMaxMsgSize(maxTxSize int) int {
|
||||
return maxTxSize + aminoOverheadForTxMessage
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user