Add module invariants and input validations (#14)

Reviewed-on: deep-stack/laconic2d#14
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
This commit is contained in:
2024-03-06 09:24:15 +00:00
committed by nabarun
parent d346b95234
commit ec147272e6
15 changed files with 400 additions and 10 deletions
+6 -1
View File
@@ -29,6 +29,7 @@ import (
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
consensuskeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper"
distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
@@ -42,6 +43,7 @@ import (
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import for side-effects
_ "github.com/cosmos/cosmos-sdk/x/bank" // import for side-effects
_ "github.com/cosmos/cosmos-sdk/x/consensus" // import for side-effects
_ "github.com/cosmos/cosmos-sdk/x/crisis" // import for side-effects
_ "github.com/cosmos/cosmos-sdk/x/distribution" // import for side-effects
_ "github.com/cosmos/cosmos-sdk/x/mint" // import for side-effects
_ "github.com/cosmos/cosmos-sdk/x/staking" // import for side-effects
@@ -73,6 +75,7 @@ type LaconicApp struct {
BankKeeper bankkeeper.Keeper
StakingKeeper *stakingkeeper.Keeper
DistrKeeper distrkeeper.Keeper
CrisisKeeper *crisiskeeper.Keeper
ConsensusParamsKeeper consensuskeeper.Keeper
// laconic keepers
@@ -137,6 +140,7 @@ func NewLaconicApp(
&app.BankKeeper,
&app.StakingKeeper,
&app.DistrKeeper,
&app.CrisisKeeper,
&app.ConsensusParamsKeeper,
&app.AuctionKeeper,
&app.BondKeeper,
@@ -154,7 +158,8 @@ func NewLaconicApp(
/**** Module Options ****/
// TOOD: Required?
app.ModuleManager.RegisterInvariants(app.CrisisKeeper)
// create the simulation manager and define the order of the modules for deterministic simulations
// NOTE: this is not required apps that don't use the simulator for fuzz testing transactions
app.sm = module.NewSimulationManagerFromAppModules(app.ModuleManager.Modules, make(map[string]module.AppModuleSimulation, 0))
+5 -2
View File
@@ -7,10 +7,10 @@ modules:
# there is nothing left over in the validator fee pool, so as to keep the CanWithdrawInvariant invariant.
# NOTE: staking module is required if HistoricalEntries param > 0
begin_blockers: [distribution, staking]
end_blockers: [staking, auction, registry]
end_blockers: [crisis, staking, auction, registry]
# NOTE: The genutils module must occur after staking so that pools are properly initialized with tokens from genesis accounts.
# NOTE: The genutils module must also occur after auth so that it can access the params from auth.
init_genesis: [auth, bank, distribution, staking, genutil, auction, bond, registry]
init_genesis: [auth, bank, distribution, staking, crisis, genutil, auction, bond, registry]
override_store_keys:
- module_name: auth
kv_store_key: acc
@@ -51,6 +51,9 @@ modules:
- name: tx
config:
"@type": cosmos.tx.config.v1.Config
- name: crisis
config:
"@type": cosmos.crisis.module.v1.Module
- name: bond
config:
"@type": cerc.bond.module.v1.Module