Skip to content

Commit

Permalink
max block gas with -1
Browse files Browse the repository at this point in the history
  • Loading branch information
davidterpay committed Dec 28, 2023
1 parent c104919 commit 223c5ba
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions abci/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion abci/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 223c5ba

Please sign in to comment.