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:
Jun Kimura
2019-08-05 20:01:30 +04:00
committed by Anton Kaliaev
parent 0cf8812b17
commit e179787d40
7 changed files with 21 additions and 17 deletions
+2 -2
View File
@@ -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 {
+2 -2
View File
@@ -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
View File
@@ -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
}