Skip to content

Commit 1f9cc80

Browse files
authored
feat!: add "is-genesis" check (#267) (#269)
1 parent 8b021d2 commit 1f9cc80

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

baseapp/abci.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,12 @@ func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitC
8080

8181
// add block gas meter for any genesis transactions (allow infinite gas)
8282
app.deliverState.ctx = app.deliverState.ctx.WithBlockGasMeter(sdk.NewInfiniteGasMeter())
83+
app.deliverState.ctx = app.deliverState.ctx.WithIsGenesis(true)
8384

8485
res = app.initChainer(app.deliverState.ctx, req)
8586

87+
app.deliverState.ctx = app.deliverState.ctx.WithIsGenesis(false)
88+
8689
// sanity check
8790
if len(req.Validators) > 0 {
8891
if len(req.Validators) != len(res.Validators) {

types/context.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type Context struct {
2828
header tmproto.Header
2929
headerHash tmbytes.HexBytes
3030
chainID string
31+
isGenesis bool
3132
txBytes []byte
3233
logger log.Logger
3334
voteInfo []abci.VoteInfo
@@ -49,6 +50,7 @@ func (c Context) MultiStore() MultiStore { return c.ms }
4950
func (c Context) BlockHeight() int64 { return c.header.Height }
5051
func (c Context) BlockTime() time.Time { return c.header.Time }
5152
func (c Context) ChainID() string { return c.chainID }
53+
func (c Context) IsGenesis() bool { return c.isGenesis }
5254
func (c Context) TxBytes() []byte { return c.txBytes }
5355
func (c Context) Logger() log.Logger { return c.logger }
5456
func (c Context) VoteInfos() []abci.VoteInfo { return c.voteInfo }
@@ -196,6 +198,12 @@ func (c Context) WithIsReCheckTx(isRecheckTx bool) Context {
196198
return c
197199
}
198200

201+
// WithIsGenesis sets isGenesis
202+
func (c Context) WithIsGenesis(isGenesis bool) Context {
203+
c.isGenesis = isGenesis
204+
return c
205+
}
206+
199207
// WithMinGasPrices returns a Context with an updated minimum gas price value
200208
func (c Context) WithMinGasPrices(gasPrices DecCoins) Context {
201209
c.minGasPrice = gasPrices

x/auth/ante/sigverify.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ func (svd SigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simul
269269
}
270270

271271
// retrieve signer data
272-
genesis := ctx.BlockHeight() == 0
272+
genesis := ctx.IsGenesis() || ctx.BlockHeight() == 0
273273
chainID := ctx.ChainID()
274274
var accNum uint64
275275
if !genesis {

0 commit comments

Comments
 (0)