diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 7cd4d4857..34780cfbb 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -68,7 +68,7 @@ type BaseApp struct { // spam prevention minimumFees sdk.Coins - maximumBlockGas int64 + maximumBlockGas uint64 // flag for sealing sealed bool @@ -185,7 +185,7 @@ func (app *BaseApp) initFromStore(mainKey sdk.StoreKey) error { func (app *BaseApp) SetMinimumFees(fees sdk.Coins) { app.minimumFees = fees } // SetMaximumBlockGas sets the maximum gas allowable per block. -func (app *BaseApp) SetMaximumBlockGas(gas int64) { app.maximumBlockGas = gas } +func (app *BaseApp) SetMaximumBlockGas(gas uint64) { app.maximumBlockGas = gas } // NewContext returns a new Context with the correct store, the given header, and nil txBytes. func (app *BaseApp) NewContext(isCheckTx bool, header abci.Header) sdk.Context { diff --git a/baseapp/baseapp_test.go b/baseapp/baseapp_test.go index 27e5f8280..8ea5cbb89 100644 --- a/baseapp/baseapp_test.go +++ b/baseapp/baseapp_test.go @@ -855,7 +855,7 @@ func TestTxGasLimits(t *testing.T) { // Test that transactions exceeding gas limits fail func TestMaxBlockGasLimits(t *testing.T) { - gasGranted := int64(10) + gasGranted := uint64(10) anteOpt := func(bapp *BaseApp) { bapp.SetAnteHandler(func(ctx sdk.Context, tx sdk.Tx, simulate bool) (newCtx sdk.Context, res sdk.Result, abort bool) { newCtx = ctx.WithGasMeter(sdk.NewGasMeter(gasGranted)) @@ -880,7 +880,7 @@ func TestMaxBlockGasLimits(t *testing.T) { }() count := tx.(*txTest).Counter - newCtx.GasMeter().ConsumeGas(count, "counter-ante") + newCtx.GasMeter().ConsumeGas(uint64(count), "counter-ante") res = sdk.Result{ GasWanted: gasGranted, } @@ -892,7 +892,7 @@ func TestMaxBlockGasLimits(t *testing.T) { routerOpt := func(bapp *BaseApp) { bapp.Router().AddRoute(routeMsgCounter, func(ctx sdk.Context, msg sdk.Msg) sdk.Result { count := msg.(msgCounter).Counter - ctx.GasMeter().ConsumeGas(count, "counter-handler") + ctx.GasMeter().ConsumeGas(uint64(count), "counter-handler") return sdk.Result{} }) } @@ -903,7 +903,7 @@ func TestMaxBlockGasLimits(t *testing.T) { testCases := []struct { tx *txTest numDelivers int - gasUsedPerDeliver int64 + gasUsedPerDeliver uint64 fail bool failAfterDeliver int }{ @@ -933,12 +933,13 @@ func TestMaxBlockGasLimits(t *testing.T) { // check for failed transactions if tc.fail && (j+1) > tc.failAfterDeliver { - require.Equal(t, res.Code, sdk.ToABCICode(sdk.CodespaceRoot, sdk.CodeOutOfGas), fmt.Sprintf("%d: %v, %v", i, tc, res)) + require.Equal(t, res.Code, sdk.CodeOutOfGas, fmt.Sprintf("%d: %v, %v", i, tc, res)) + require.Equal(t, res.Codespace, sdk.CodespaceRoot, fmt.Sprintf("%d: %v, %v", i, tc, res)) require.True(t, ctx.BlockGasMeter().PastLimit()) } else { // check gas used and wanted - expBlockGasUsed := tc.gasUsedPerDeliver * int64(j+1) + expBlockGasUsed := tc.gasUsedPerDeliver * uint64(j+1) require.Equal(t, expBlockGasUsed, blockGasUsed, fmt.Sprintf("%d,%d: %v, %v, %v, %v", i, j, tc, expBlockGasUsed, blockGasUsed, res)) diff --git a/baseapp/options.go b/baseapp/options.go index 8d6131314..7fd95aec8 100644 --- a/baseapp/options.go +++ b/baseapp/options.go @@ -40,7 +40,7 @@ func SetMinimumFees(minFees string) func(*BaseApp) { } // SetMinimumFees returns an option that sets the minimum fees on the app. -func SetMaximumBlockGas(gas int64) func(*BaseApp) { +func SetMaximumBlockGas(gas uint64) func(*BaseApp) { return func(bap *BaseApp) { bap.SetMaximumBlockGas(gas) } } diff --git a/cmd/gaia/cmd/gaiad/main.go b/cmd/gaia/cmd/gaiad/main.go index 4ae6f57d5..ecb906bc7 100644 --- a/cmd/gaia/cmd/gaiad/main.go +++ b/cmd/gaia/cmd/gaiad/main.go @@ -63,7 +63,7 @@ func newApp(logger log.Logger, db dbm.DB, if err != nil { panic(err) } - maxBlockGas := genDoc.ConsensusParams.BlockSize.MaxGas + maxBlockGas := uint64(genDoc.ConsensusParams.BlockSize.MaxGas) return app.NewGaiaApp(logger, db, traceStore, baseapp.SetPruning(viper.GetString("pruning")),