From 826df0acd5c2f4a08ce7c1251364fe2309d95a9c Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Sat, 18 Jun 2022 20:31:51 -0500 Subject: [PATCH 01/14] is gen test --- x/auth/ante/sigverify.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/x/auth/ante/sigverify.go b/x/auth/ante/sigverify.go index dc2fedbc0772..c311712e90c1 100644 --- a/x/auth/ante/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -269,12 +269,12 @@ func (svd SigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simul } // retrieve signer data - genesis := ctx.BlockHeight() == 0 + // genesis := ctx.BlockHeight() == 0 chainID := ctx.ChainID() var accNum uint64 - if !genesis { - accNum = acc.GetAccountNumber() - } + // if !genesis { + // accNum = acc.GetAccountNumber() + // } signerData := authsigning.SignerData{ ChainID: chainID, AccountNumber: accNum, From e5877acf09d0e4585befe9df56c31e375606d874 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Sat, 18 Jun 2022 22:05:43 -0500 Subject: [PATCH 02/14] my attempt at isGenesis --- baseapp/abci.go | 5 +++++ baseapp/baseapp.go | 8 ++++++++ types/context.go | 10 ++++++++++ x/auth/ante/sigverify.go | 7 ++++--- x/genutil/genesis.go | 2 ++ 5 files changed, 29 insertions(+), 3 deletions(-) diff --git a/baseapp/abci.go b/baseapp/abci.go index dcfe431ce0d7..1dc6d6c52ace 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -29,6 +29,7 @@ import ( func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitChain) { // On a new chain, we consider the init chain block height as 0, even though // req.InitialHeight is 1 by default. + // app.isGenesis = true initHeader := tmproto.Header{ChainID: req.ChainId, Time: req.Time} // If req.InitialHeight is > 1, then we set the initial version in the @@ -62,6 +63,7 @@ func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitC } // add block gas meter for any genesis transactions (allow infinite gas) + // app.deliverState.ctx.WithIsGenesis(true) app.deliverState.ctx = app.deliverState.ctx.WithBlockGasMeter(sdk.NewInfiniteGasMeter()) res = app.initChainer(app.deliverState.ctx, req) @@ -99,6 +101,9 @@ func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitC appHash = emptyHash[:] } + // app.isGenesis = false + // app.deliverState.ctx.WithIsGenesis(false) + // NOTE: We don't commit, but BeginBlock for block `initial_height` starts from this // deliverState. return abci.ResponseInitChain{ diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 177cb59801b6..94631ac9fe66 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -95,6 +95,9 @@ type BaseApp struct { // nolint: maligned // initialHeight is the initial height at which we start the baseapp initialHeight int64 + // isGenesis is used to determine if genesis logic should be run, despite whether or not the chain is at a non-zero height + isGenesis bool + // flag for sealing options and parameters to a BaseApp sealed bool @@ -177,6 +180,11 @@ func (app *BaseApp) Version() string { return app.version } +// IsGenesis returns the boolean value for genesis state. +func (app *BaseApp) IsGenesis() bool { + return app.isGenesis +} + // Logger returns the logger of the BaseApp. func (app *BaseApp) Logger() log.Logger { return app.logger diff --git a/types/context.go b/types/context.go index 35030dad9a96..f45f5b1bc196 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,14 @@ func (c Context) WithIsReCheckTx(isRecheckTx bool) Context { return c } +// WithIsGenesis sets isGenesis +func (c Context) WithIsGenesis(isGenesis bool) Context { + if isGenesis { + c.isGenesis = true + } + 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 c311712e90c1..424f664c4896 100644 --- a/x/auth/ante/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -270,11 +270,12 @@ func (svd SigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simul // retrieve signer data // genesis := ctx.BlockHeight() == 0 + genesis := ctx.IsGenesis() chainID := ctx.ChainID() var accNum uint64 - // if !genesis { - // accNum = acc.GetAccountNumber() - // } + if !genesis { + accNum = acc.GetAccountNumber() + } signerData := authsigning.SignerData{ ChainID: chainID, AccountNumber: accNum, diff --git a/x/genutil/genesis.go b/x/genutil/genesis.go index c6d17edb8da9..a76332d2c999 100644 --- a/x/genutil/genesis.go +++ b/x/genutil/genesis.go @@ -14,8 +14,10 @@ func InitGenesis( deliverTx deliverTxfn, genesisState types.GenesisState, txEncodingConfig client.TxEncodingConfig, ) (validators []abci.ValidatorUpdate, err error) { + ctx.WithIsGenesis(true) if len(genesisState.GenTxs) > 0 { validators, err = DeliverGenTxs(ctx, genesisState.GenTxs, stakingKeeper, deliverTx, txEncodingConfig) } + ctx.WithIsGenesis(false) return } From 3124de4f67e69eba3dc09e6bab395c1793103e85 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Sat, 18 Jun 2022 22:22:59 -0500 Subject: [PATCH 03/14] logs and uncomment --- baseapp/abci.go | 8 ++++---- x/auth/ante/sigverify.go | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/baseapp/abci.go b/baseapp/abci.go index 1dc6d6c52ace..53535034eec6 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -29,7 +29,7 @@ import ( func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitChain) { // On a new chain, we consider the init chain block height as 0, even though // req.InitialHeight is 1 by default. - // app.isGenesis = true + app.isGenesis = true initHeader := tmproto.Header{ChainID: req.ChainId, Time: req.Time} // If req.InitialHeight is > 1, then we set the initial version in the @@ -63,7 +63,7 @@ func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitC } // add block gas meter for any genesis transactions (allow infinite gas) - // app.deliverState.ctx.WithIsGenesis(true) + app.deliverState.ctx.WithIsGenesis(true) app.deliverState.ctx = app.deliverState.ctx.WithBlockGasMeter(sdk.NewInfiniteGasMeter()) res = app.initChainer(app.deliverState.ctx, req) @@ -101,8 +101,8 @@ func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitC appHash = emptyHash[:] } - // app.isGenesis = false - // app.deliverState.ctx.WithIsGenesis(false) + app.isGenesis = false + app.deliverState.ctx.WithIsGenesis(false) // NOTE: We don't commit, but BeginBlock for block `initial_height` starts from this // deliverState. diff --git a/x/auth/ante/sigverify.go b/x/auth/ante/sigverify.go index 424f664c4896..8869ecf3f964 100644 --- a/x/auth/ante/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -271,6 +271,7 @@ func (svd SigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simul // retrieve signer data // genesis := ctx.BlockHeight() == 0 genesis := ctx.IsGenesis() + fmt.Printf("GENESIS BOOL %v \n", genesis) chainID := ctx.ChainID() var accNum uint64 if !genesis { From 38a394c67ea015213934f85285821d3c28699dcf Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Sat, 18 Jun 2022 22:39:34 -0500 Subject: [PATCH 04/14] more changes --- baseapp/abci.go | 2 +- types/context.go | 4 +--- x/genutil/genesis.go | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/baseapp/abci.go b/baseapp/abci.go index 53535034eec6..32f24ce0cc02 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -30,6 +30,7 @@ func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitC // On a new chain, we consider the init chain block height as 0, even though // req.InitialHeight is 1 by default. app.isGenesis = true + app.deliverState.ctx.WithIsGenesis(true) initHeader := tmproto.Header{ChainID: req.ChainId, Time: req.Time} // If req.InitialHeight is > 1, then we set the initial version in the @@ -63,7 +64,6 @@ func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitC } // add block gas meter for any genesis transactions (allow infinite gas) - app.deliverState.ctx.WithIsGenesis(true) app.deliverState.ctx = app.deliverState.ctx.WithBlockGasMeter(sdk.NewInfiniteGasMeter()) res = app.initChainer(app.deliverState.ctx, req) diff --git a/types/context.go b/types/context.go index f45f5b1bc196..e3604df954ba 100644 --- a/types/context.go +++ b/types/context.go @@ -200,9 +200,7 @@ func (c Context) WithIsReCheckTx(isRecheckTx bool) Context { // WithIsGenesis sets isGenesis func (c Context) WithIsGenesis(isGenesis bool) Context { - if isGenesis { - c.isGenesis = true - } + c.isGenesis = isGenesis return c } diff --git a/x/genutil/genesis.go b/x/genutil/genesis.go index a76332d2c999..0f7e58876b3e 100644 --- a/x/genutil/genesis.go +++ b/x/genutil/genesis.go @@ -14,9 +14,8 @@ func InitGenesis( deliverTx deliverTxfn, genesisState types.GenesisState, txEncodingConfig client.TxEncodingConfig, ) (validators []abci.ValidatorUpdate, err error) { - ctx.WithIsGenesis(true) if len(genesisState.GenTxs) > 0 { - validators, err = DeliverGenTxs(ctx, genesisState.GenTxs, stakingKeeper, deliverTx, txEncodingConfig) + validators, err = DeliverGenTxs(ctx.WithIsGenesis(true), genesisState.GenTxs, stakingKeeper, deliverTx, txEncodingConfig) } ctx.WithIsGenesis(false) return From ce504ef56838b1d1d4796aa4d52ee14ff8a0cb46 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Sat, 18 Jun 2022 22:50:37 -0500 Subject: [PATCH 05/14] comment out --- baseapp/abci.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/baseapp/abci.go b/baseapp/abci.go index 32f24ce0cc02..7da385f4cab1 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -29,8 +29,8 @@ import ( func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitChain) { // On a new chain, we consider the init chain block height as 0, even though // req.InitialHeight is 1 by default. - app.isGenesis = true - app.deliverState.ctx.WithIsGenesis(true) + // app.isGenesis = true + // app.deliverState.ctx.WithIsGenesis(true) initHeader := tmproto.Header{ChainID: req.ChainId, Time: req.Time} // If req.InitialHeight is > 1, then we set the initial version in the @@ -101,8 +101,8 @@ func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitC appHash = emptyHash[:] } - app.isGenesis = false - app.deliverState.ctx.WithIsGenesis(false) + // app.isGenesis = false + // app.deliverState.ctx.WithIsGenesis(false) // NOTE: We don't commit, but BeginBlock for block `initial_height` starts from this // deliverState. From 3629d3f66fce19f2c29392eb03b8eed9ef69cd51 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Sat, 18 Jun 2022 23:03:05 -0500 Subject: [PATCH 06/14] change init gen call loc --- x/genutil/genesis.go | 3 +-- x/genutil/module.go | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/x/genutil/genesis.go b/x/genutil/genesis.go index 0f7e58876b3e..c6d17edb8da9 100644 --- a/x/genutil/genesis.go +++ b/x/genutil/genesis.go @@ -15,8 +15,7 @@ func InitGenesis( txEncodingConfig client.TxEncodingConfig, ) (validators []abci.ValidatorUpdate, err error) { if len(genesisState.GenTxs) > 0 { - validators, err = DeliverGenTxs(ctx.WithIsGenesis(true), genesisState.GenTxs, stakingKeeper, deliverTx, txEncodingConfig) + validators, err = DeliverGenTxs(ctx, genesisState.GenTxs, stakingKeeper, deliverTx, txEncodingConfig) } - ctx.WithIsGenesis(false) return } diff --git a/x/genutil/module.go b/x/genutil/module.go index 4b8bcc72e77d..2fa85fa8de0e 100644 --- a/x/genutil/module.go +++ b/x/genutil/module.go @@ -96,7 +96,7 @@ func NewAppModule(accountKeeper types.AccountKeeper, func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { var genesisState types.GenesisState cdc.MustUnmarshalJSON(data, &genesisState) - validators, err := InitGenesis(ctx, am.stakingKeeper, am.deliverTx, genesisState, am.txEncodingConfig) + validators, err := InitGenesis(ctx.WithIsGenesis(true), am.stakingKeeper, am.deliverTx, genesisState, am.txEncodingConfig) if err != nil { panic(err) } From d78425cf8071f48ea059a0939967393d3462f06b Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Sun, 19 Jun 2022 11:56:10 -0500 Subject: [PATCH 07/14] further gen tests --- types/module/module.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/module/module.go b/types/module/module.go index 2c4205f5e1f8..e4e920a8f657 100644 --- a/types/module/module.go +++ b/types/module/module.go @@ -319,8 +319,8 @@ func (m *Manager) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, genesisData } ctx.Logger().Info("running initialization for module", "module", moduleName) - moduleValUpdates := m.Modules[moduleName].InitGenesis(ctx, cdc, genesisData[moduleName]) - + moduleValUpdates := m.Modules[moduleName].InitGenesis(ctx.WithIsGenesis(true), cdc, genesisData[moduleName]) + fmt.Printf("IS GENESIS %v \n", ctx.IsGenesis()) // use these validator updates if provided, the module manager assumes // only one module will update the validator set if len(moduleValUpdates) > 0 { From 752ddd6854a67e641d28c82a0c82389b3a165b4a Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Sun, 19 Jun 2022 12:11:47 -0500 Subject: [PATCH 08/14] more tests --- simapp/app.go | 1 + types/module/module.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/simapp/app.go b/simapp/app.go index d30301c14c8d..ac31a6259f5f 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -445,6 +445,7 @@ func (app *SimApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci. panic(err) } app.UpgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap()) + ctx = ctx.WithIsGenesis(true) return app.mm.InitGenesis(ctx, app.appCodec, genesisState) } diff --git a/types/module/module.go b/types/module/module.go index e4e920a8f657..4c67fe400921 100644 --- a/types/module/module.go +++ b/types/module/module.go @@ -318,8 +318,8 @@ func (m *Manager) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, genesisData continue } ctx.Logger().Info("running initialization for module", "module", moduleName) - - moduleValUpdates := m.Modules[moduleName].InitGenesis(ctx.WithIsGenesis(true), cdc, genesisData[moduleName]) + ctx = ctx.WithIsGenesis(true) + moduleValUpdates := m.Modules[moduleName].InitGenesis(ctx, cdc, genesisData[moduleName]) fmt.Printf("IS GENESIS %v \n", ctx.IsGenesis()) // use these validator updates if provided, the module manager assumes // only one module will update the validator set From ddfe73167e83950d95457ed40fd295c5adbd37dc Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Sun, 19 Jun 2022 17:20:22 -0500 Subject: [PATCH 09/14] another test --- baseapp/abci.go | 1 + 1 file changed, 1 insertion(+) diff --git a/baseapp/abci.go b/baseapp/abci.go index 7da385f4cab1..3be854679452 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -65,6 +65,7 @@ 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) From 16a11bb560878eb7cd70e090e43d0429cdca425c Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Sun, 19 Jun 2022 18:32:51 -0500 Subject: [PATCH 10/14] revert unneeded changes --- baseapp/abci.go | 6 +----- simapp/app.go | 1 - types/module/module.go | 4 ++-- x/auth/ante/sigverify.go | 1 - x/genutil/module.go | 2 +- 5 files changed, 4 insertions(+), 10 deletions(-) diff --git a/baseapp/abci.go b/baseapp/abci.go index 3be854679452..f86bce4312b7 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -29,8 +29,7 @@ import ( func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitChain) { // On a new chain, we consider the init chain block height as 0, even though // req.InitialHeight is 1 by default. - // app.isGenesis = true - // app.deliverState.ctx.WithIsGenesis(true) + initHeader := tmproto.Header{ChainID: req.ChainId, Time: req.Time} // If req.InitialHeight is > 1, then we set the initial version in the @@ -102,9 +101,6 @@ func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitC appHash = emptyHash[:] } - // app.isGenesis = false - // app.deliverState.ctx.WithIsGenesis(false) - // NOTE: We don't commit, but BeginBlock for block `initial_height` starts from this // deliverState. return abci.ResponseInitChain{ diff --git a/simapp/app.go b/simapp/app.go index ac31a6259f5f..d30301c14c8d 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -445,7 +445,6 @@ func (app *SimApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci. panic(err) } app.UpgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap()) - ctx = ctx.WithIsGenesis(true) return app.mm.InitGenesis(ctx, app.appCodec, genesisState) } diff --git a/types/module/module.go b/types/module/module.go index 4c67fe400921..897550b90079 100644 --- a/types/module/module.go +++ b/types/module/module.go @@ -318,9 +318,9 @@ func (m *Manager) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, genesisData continue } ctx.Logger().Info("running initialization for module", "module", moduleName) - ctx = ctx.WithIsGenesis(true) + // ctx = ctx.WithIsGenesis(true) moduleValUpdates := m.Modules[moduleName].InitGenesis(ctx, cdc, genesisData[moduleName]) - fmt.Printf("IS GENESIS %v \n", ctx.IsGenesis()) + // fmt.Printf("IS GENESIS %v \n", ctx.IsGenesis()) // use these validator updates if provided, the module manager assumes // only one module will update the validator set if len(moduleValUpdates) > 0 { diff --git a/x/auth/ante/sigverify.go b/x/auth/ante/sigverify.go index 8869ecf3f964..a27fe741019d 100644 --- a/x/auth/ante/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -269,7 +269,6 @@ func (svd SigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simul } // retrieve signer data - // genesis := ctx.BlockHeight() == 0 genesis := ctx.IsGenesis() fmt.Printf("GENESIS BOOL %v \n", genesis) chainID := ctx.ChainID() diff --git a/x/genutil/module.go b/x/genutil/module.go index 2fa85fa8de0e..4b8bcc72e77d 100644 --- a/x/genutil/module.go +++ b/x/genutil/module.go @@ -96,7 +96,7 @@ func NewAppModule(accountKeeper types.AccountKeeper, func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { var genesisState types.GenesisState cdc.MustUnmarshalJSON(data, &genesisState) - validators, err := InitGenesis(ctx.WithIsGenesis(true), am.stakingKeeper, am.deliverTx, genesisState, am.txEncodingConfig) + validators, err := InitGenesis(ctx, am.stakingKeeper, am.deliverTx, genesisState, am.txEncodingConfig) if err != nil { panic(err) } From 692cbfc3e4d44335b822081029abb9aa1be1e0bc Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Sun, 19 Jun 2022 18:48:17 -0500 Subject: [PATCH 11/14] remove extra --- baseapp/abci.go | 1 - types/module/module.go | 2 -- x/auth/ante/sigverify.go | 1 - 3 files changed, 4 deletions(-) diff --git a/baseapp/abci.go b/baseapp/abci.go index f86bce4312b7..46ab0032d57b 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -29,7 +29,6 @@ import ( func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitChain) { // On a new chain, we consider the init chain block height as 0, even though // req.InitialHeight is 1 by default. - initHeader := tmproto.Header{ChainID: req.ChainId, Time: req.Time} // If req.InitialHeight is > 1, then we set the initial version in the diff --git a/types/module/module.go b/types/module/module.go index 897550b90079..7ce88ac8e6f5 100644 --- a/types/module/module.go +++ b/types/module/module.go @@ -318,9 +318,7 @@ func (m *Manager) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, genesisData continue } ctx.Logger().Info("running initialization for module", "module", moduleName) - // ctx = ctx.WithIsGenesis(true) moduleValUpdates := m.Modules[moduleName].InitGenesis(ctx, cdc, genesisData[moduleName]) - // fmt.Printf("IS GENESIS %v \n", ctx.IsGenesis()) // use these validator updates if provided, the module manager assumes // only one module will update the validator set if len(moduleValUpdates) > 0 { diff --git a/x/auth/ante/sigverify.go b/x/auth/ante/sigverify.go index a27fe741019d..9e52ff6c191f 100644 --- a/x/auth/ante/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -270,7 +270,6 @@ func (svd SigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simul // retrieve signer data genesis := ctx.IsGenesis() - fmt.Printf("GENESIS BOOL %v \n", genesis) chainID := ctx.ChainID() var accNum uint64 if !genesis { From f68986bfd8e17e307a86b1f63ac917924c9a247d Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Sun, 19 Jun 2022 20:20:41 -0500 Subject: [PATCH 12/14] reset to false --- baseapp/abci.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/baseapp/abci.go b/baseapp/abci.go index 46ab0032d57b..db4c659569b9 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -100,6 +100,8 @@ func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitC appHash = emptyHash[:] } + app.deliverState.ctx = app.deliverState.ctx.WithIsGenesis(false) + // NOTE: We don't commit, but BeginBlock for block `initial_height` starts from this // deliverState. return abci.ResponseInitChain{ From 6ba4bc3f7cf27f67d8f8596bc94a8c3cd67e887c Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Mon, 20 Jun 2022 09:26:11 -0500 Subject: [PATCH 13/14] Update x/auth/ante/sigverify.go Co-authored-by: Aleksandr Bezobchuk --- x/auth/ante/sigverify.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/auth/ante/sigverify.go b/x/auth/ante/sigverify.go index 9e52ff6c191f..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.IsGenesis() + genesis := ctx.IsGenesis() || ctx.BlockHeight() == 0 chainID := ctx.ChainID() var accNum uint64 if !genesis { From 7761bfbf1c49e5d8a2ecc00f1fb04b2ef507cd11 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Mon, 20 Jun 2022 09:28:34 -0500 Subject: [PATCH 14/14] changes from call with bez --- baseapp/abci.go | 4 ++-- baseapp/baseapp.go | 8 -------- types/module/module.go | 2 ++ 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/baseapp/abci.go b/baseapp/abci.go index db4c659569b9..12bf9ce5cea5 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -67,6 +67,8 @@ func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitC 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) { @@ -100,8 +102,6 @@ func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitC appHash = emptyHash[:] } - app.deliverState.ctx = app.deliverState.ctx.WithIsGenesis(false) - // NOTE: We don't commit, but BeginBlock for block `initial_height` starts from this // deliverState. return abci.ResponseInitChain{ diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 94631ac9fe66..177cb59801b6 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -95,9 +95,6 @@ type BaseApp struct { // nolint: maligned // initialHeight is the initial height at which we start the baseapp initialHeight int64 - // isGenesis is used to determine if genesis logic should be run, despite whether or not the chain is at a non-zero height - isGenesis bool - // flag for sealing options and parameters to a BaseApp sealed bool @@ -180,11 +177,6 @@ func (app *BaseApp) Version() string { return app.version } -// IsGenesis returns the boolean value for genesis state. -func (app *BaseApp) IsGenesis() bool { - return app.isGenesis -} - // Logger returns the logger of the BaseApp. func (app *BaseApp) Logger() log.Logger { return app.logger diff --git a/types/module/module.go b/types/module/module.go index 7ce88ac8e6f5..2c4205f5e1f8 100644 --- a/types/module/module.go +++ b/types/module/module.go @@ -318,7 +318,9 @@ func (m *Manager) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, genesisData continue } ctx.Logger().Info("running initialization for module", "module", moduleName) + moduleValUpdates := m.Modules[moduleName].InitGenesis(ctx, cdc, genesisData[moduleName]) + // use these validator updates if provided, the module manager assumes // only one module will update the validator set if len(moduleValUpdates) > 0 {