diff --git a/abci/abci.go b/abci/abci.go index fa9e9115..521a1060 100644 --- a/abci/abci.go +++ b/abci/abci.go @@ -134,14 +134,14 @@ func (h *ProposalHandler) PrepareProposalHandler() sdk.PrepareProposalHandler { sdkTxBytes[index] = txBz } - if int64(gasLimit) > maxGasLimit { + if maxGasLimit > 0 && int64(gasLimit) > maxGasLimit { // The gas limit of the bundled transactions exceeds the maximum gas // limit of the block, so we remove the bid transaction and try the // next top bid. txsToRemove[tmpBidTx] = struct{}{} continue selectBidTxLoop } - totalGasLimit += int64(gasLimit) + totalGasLimit = int64(gasLimit) // At this point, both the bid transaction itself and all the bundled // transactions are valid. So we select the bid transaction along with @@ -219,7 +219,7 @@ func (h *ProposalHandler) PrepareProposalHandler() sdk.PrepareProposalHandler { continue selectTxLoop } gasLimit := feeTx.GetGas() - if totalGasLimit += int64(gasLimit); totalGasLimit > maxGasLimit { + if totalGasLimit += int64(gasLimit); maxGasLimit > 0 && totalGasLimit > maxGasLimit { // We've reached capacity per maxGasLimit so we cannot select any more // transactions. break selectTxLoop diff --git a/abci/abci_test.go b/abci/abci_test.go index 89f3e622..f0d51dab 100644 --- a/abci/abci_test.go +++ b/abci/abci_test.go @@ -892,7 +892,7 @@ func (suite *ABCITestSuite) TestPrepareProposalLimits() { suite.Run("rejects a tx that is too large but accepts a smaller one", func() { suite.SetupTest() // reset gasLimit := uint64(1000) - tx1, err := testutils.CreateTxWithLimit(suite.encodingConfig.TxConfig, suite.accounts[0], 0, 1000, testutils.CreateRandomMsgs(suite.accounts[0].Address, 1), gasLimit) + tx1, err := testutils.CreateTxWithLimit(suite.encodingConfig.TxConfig, suite.accounts[0], 1, 1000, testutils.CreateRandomMsgs(suite.accounts[0].Address, 1), gasLimit) suite.Require().NoError(err) tx2, err := testutils.CreateTxWithLimit(suite.encodingConfig.TxConfig, suite.accounts[0], 0, 1000, testutils.CreateRandomMsgs(suite.accounts[0].Address, 1), gasLimit-1)