mempool: length prefix txs when getting them from mempool (#5483)

## Description

In protobuf `[]byte` is varint encoded. When adding txs to the block we were not taking this into account. 


Closes: #XXX
This commit is contained in:
Marko
2020-10-13 12:33:21 +02:00
committed by GitHub
parent 346aa14db5
commit e1644d00c5
12 changed files with 142 additions and 313 deletions

View File

@@ -104,6 +104,7 @@ func (blockExec *BlockExecutor) CreateProposalBlock(
// Fetch a limited amount of valid txs
maxDataBytes := types.MaxDataBytes(maxBytes, evSize, state.Validators.Size())
txs := blockExec.mempool.ReapMaxBytesMaxGas(maxDataBytes, maxGas)
return state.MakeBlock(height, txs, commit, evidence, proposerAddr)

View File

@@ -25,8 +25,8 @@ func TestTxFilter(t *testing.T) {
tx types.Tx
isErr bool
}{
{types.Tx(tmrand.Bytes(2154)), false},
{types.Tx(tmrand.Bytes(2155)), true},
{types.Tx(tmrand.Bytes(2151)), false},
{types.Tx(tmrand.Bytes(2152)), true},
{types.Tx(tmrand.Bytes(3000)), true},
}
@@ -37,7 +37,7 @@ func TestTxFilter(t *testing.T) {
state, err := stateStore.LoadFromDBOrGenesisDoc(genDoc)
require.NoError(t, err)
f := sm.TxPreCheck(state) // current max size of a tx 1850
f := sm.TxPreCheck(state)
if tc.isErr {
assert.NotNil(t, f(tc.tx), "#%v", i)
} else {