Skip to content

Commit

Permalink
Fix compile
Browse files Browse the repository at this point in the history
  • Loading branch information
jaekwon committed Nov 20, 2018
1 parent 56dc236 commit d911565
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ type BaseApp struct {

// spam prevention
minimumFees sdk.Coins
maximumBlockGas int64
maximumBlockGas uint64

// flag for sealing
sealed bool
Expand Down Expand Up @@ -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 {
Expand Down
13 changes: 7 additions & 6 deletions baseapp/baseapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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,
}
Expand All @@ -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{}
})
}
Expand All @@ -903,7 +903,7 @@ func TestMaxBlockGasLimits(t *testing.T) {
testCases := []struct {
tx *txTest
numDelivers int
gasUsedPerDeliver int64
gasUsedPerDeliver uint64
fail bool
failAfterDeliver int
}{
Expand Down Expand Up @@ -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))

Expand Down
2 changes: 1 addition & 1 deletion baseapp/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/gaia/cmd/gaiad/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")),
Expand Down

0 comments on commit d911565

Please sign in to comment.