mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-19 22:44:24 +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:
committed by
Anton Kaliaev
parent
0cf8812b17
commit
e179787d40
@@ -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
|
||||
|
||||
+6
-5
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user