Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
feat!: add "is-genesis" check (#267)
Browse files Browse the repository at this point in the history
* is gen test

* my attempt at isGenesis

* logs and uncomment

* more changes

* comment out

* change init gen call loc

* further gen tests

* more tests

* another test

* revert unneeded changes

* remove extra

* reset to false

* Update x/auth/ante/sigverify.go

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

* changes from call with bez

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
  • Loading branch information
czarcas7ic and alexanderbez committed Jun 20, 2022
1 parent f59c62f commit 3e46ff7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,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) {
Expand Down
8 changes: 8 additions & 0 deletions types/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion x/auth/ante/sigverify.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 3e46ff7

Please sign in to comment.