diff --git a/baseapp/abci.go b/baseapp/abci.go index 4ade1a9795d0..94a6a1362bb6 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -80,9 +80,12 @@ func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitC // add block gas meter for any genesis transactions (allow infinite gas) app.deliverState.ctx = app.deliverState.ctx.WithBlockGasMeter(sdk.NewInfiniteGasMeter()) + app.deliverState.ctx = app.deliverState.ctx.WithIsGenesis(true) res = app.initChainer(app.deliverState.ctx, req) + app.deliverState.ctx = app.deliverState.ctx.WithIsGenesis(false) + // sanity check if len(req.Validators) > 0 { if len(req.Validators) != len(res.Validators) { diff --git a/types/context.go b/types/context.go index 35030dad9a96..e3604df954ba 100644 --- a/types/context.go +++ b/types/context.go @@ -28,6 +28,7 @@ type Context struct { header tmproto.Header headerHash tmbytes.HexBytes chainID string + isGenesis bool txBytes []byte logger log.Logger voteInfo []abci.VoteInfo @@ -49,6 +50,7 @@ func (c Context) MultiStore() MultiStore { return c.ms } func (c Context) BlockHeight() int64 { return c.header.Height } func (c Context) BlockTime() time.Time { return c.header.Time } func (c Context) ChainID() string { return c.chainID } +func (c Context) IsGenesis() bool { return c.isGenesis } func (c Context) TxBytes() []byte { return c.txBytes } func (c Context) Logger() log.Logger { return c.logger } func (c Context) VoteInfos() []abci.VoteInfo { return c.voteInfo } @@ -196,6 +198,12 @@ func (c Context) WithIsReCheckTx(isRecheckTx bool) Context { return c } +// WithIsGenesis sets isGenesis +func (c Context) WithIsGenesis(isGenesis bool) Context { + c.isGenesis = isGenesis + return c +} + // WithMinGasPrices returns a Context with an updated minimum gas price value func (c Context) WithMinGasPrices(gasPrices DecCoins) Context { c.minGasPrice = gasPrices diff --git a/x/auth/ante/sigverify.go b/x/auth/ante/sigverify.go index dc2fedbc0772..9bb7d96f71f6 100644 --- a/x/auth/ante/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -269,7 +269,7 @@ func (svd SigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simul } // retrieve signer data - genesis := ctx.BlockHeight() == 0 + genesis := ctx.IsGenesis() || ctx.BlockHeight() == 0 chainID := ctx.ChainID() var accNum uint64 if !genesis {