diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index de7e36d72a..b0e7645d48 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -136,6 +136,7 @@ func (app *BaseApp) MountStore(key sdk.StoreKey, typ sdk.StoreType) { } // load latest application version +// panics if called more than once on a running baseapp func (app *BaseApp) LoadLatestVersion(mainKey *sdk.KVStoreKey) error { err := app.cms.LoadLatestVersion() if err != nil { @@ -145,6 +146,7 @@ func (app *BaseApp) LoadLatestVersion(mainKey *sdk.KVStoreKey) error { } // load application version +// panics if called more than once on a running baseapp func (app *BaseApp) LoadVersion(version int64, mainKey *sdk.KVStoreKey) error { err := app.cms.LoadVersion(version) if err != nil { @@ -702,7 +704,9 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte, tx sdk.Tx) (result sdk } } - // consume block gas whether panic or not. + // If BlockGasMeter() panics it will be caught by the above recover and + // return an error - in any case BlockGasMeter will consume gas past + // the limit. if mode == runTxModeDeliver { ctx.BlockGasMeter().ConsumeGas( ctx.GasMeter().GasConsumedToLimit(), "block gas meter") diff --git a/types/gas.go b/types/gas.go index 90c9da3ec8..100b004305 100644 --- a/types/gas.go +++ b/types/gas.go @@ -63,7 +63,7 @@ func (g *basicGasMeter) Limit() Gas { } func (g *basicGasMeter) GasConsumedToLimit() Gas { - if g.consumed > g.limit { + if g.IsPastLimit() { return g.limit } return g.consumed