Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/evidence module implementation #5240

Merged
merged 76 commits into from
Nov 6, 2019
Merged
Show file tree
Hide file tree
Changes from 69 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
2d0b5fd
add stub files for evidence module
alexanderbez Oct 24, 2019
9e1a726
adr: update status and log
alexanderbez Oct 24, 2019
fff7429
adr: update router definition
alexanderbez Oct 24, 2019
9e92430
move IsAlphaNumeric to types/ and update gov usage
alexanderbez Oct 24, 2019
b3cd14e
types: add evidence type and router/handler
alexanderbez Oct 24, 2019
2d5b6a7
implement EvidenceHandler and related types
alexanderbez Oct 24, 2019
30af5af
rename file
alexanderbez Oct 24, 2019
45db95e
add module constants
alexanderbez Oct 24, 2019
eee71d2
add initial codec
alexanderbez Oct 24, 2019
6c102f4
update client package to be used by AppModuleBasic
alexanderbez Oct 24, 2019
e8851a6
update alias'
alexanderbez Oct 24, 2019
1f33d38
nolint alias file
alexanderbez Oct 24, 2019
5a27e5b
implement AppModuleBasic
alexanderbez Oct 24, 2019
46a1fb8
update AppModule
alexanderbez Oct 25, 2019
febbbf5
add unit tests for types
alexanderbez Oct 25, 2019
e589478
adr: update error return type
alexanderbez Oct 25, 2019
e51c9d2
implement initial keeper
alexanderbez Oct 25, 2019
9b76411
update adr
alexanderbez Oct 25, 2019
37ca15f
update evidence type to include hash
alexanderbez Oct 25, 2019
dbaba7a
add initial error handling
alexanderbez Oct 25, 2019
9e18744
add initial error types
alexanderbez Oct 25, 2019
793b1d4
exec evidence handler
alexanderbez Oct 25, 2019
f3dbc52
update godoc
alexanderbez Oct 25, 2019
50c72ef
implement and use setEvidence
alexanderbez Oct 25, 2019
79e8e28
restructure router usage and start keeper test harness
alexanderbez Oct 27, 2019
e1c0120
add tests
alexanderbez Oct 27, 2019
ce64ee6
use prefix stores instead of key comp.
alexanderbez Oct 28, 2019
10537e3
implement iterator with tests
alexanderbez Oct 28, 2019
39d1142
add new error types with converter
alexanderbez Oct 28, 2019
e638306
start querier types
alexanderbez Oct 28, 2019
a593d67
add ErrNoEvidenceExists
alexanderbez Oct 28, 2019
e90488f
implement querier with tests
alexanderbez Oct 28, 2019
674fc90
implement NewQuerierHandler and update alias'
alexanderbez Oct 28, 2019
9d4c1ea
godoc and misc.
alexanderbez Oct 28, 2019
add9d08
add message with test harness setup
alexanderbez Oct 28, 2019
fd3c6f2
register MsgSubmitEvidence with module cdc
alexanderbez Oct 29, 2019
129eb7e
change export genesis type
alexanderbez Oct 29, 2019
964b4ff
Merge branch 'master' into bez/evidence-module-impl
alexanderbez Oct 29, 2019
8aad1fb
redo type tests
alexanderbez Oct 29, 2019
6374cd6
add handler unit tests
alexanderbez Oct 29, 2019
4ef7797
add DONTCOVER to errors
alexanderbez Oct 29, 2019
25816dd
add genesis tpes along with import/export
alexanderbez Oct 29, 2019
371ca0b
add genesis test file (stub)
alexanderbez Oct 29, 2019
8aa1cbb
Merge branch 'master' into bez/evidence-module-impl
alexanderbez Oct 30, 2019
8c2413b
use simapp in test suites
alexanderbez Oct 30, 2019
fd9a484
add DONTCOVER to test utils
alexanderbez Oct 30, 2019
9b3976d
implement genesis types unit tests
alexanderbez Oct 30, 2019
8b21b3b
add genesis tests
alexanderbez Oct 30, 2019
8e8d382
add doc.go
alexanderbez Oct 30, 2019
2e1485f
remove TODO from module
alexanderbez Oct 30, 2019
f3c9d8b
implement CLI query command
alexanderbez Oct 30, 2019
5a727fd
remove TODO from module
alexanderbez Oct 30, 2019
ba048c6
implement rest handlers to query for evidence
alexanderbez Oct 31, 2019
2dfe2e5
update SubmitEvidenceCMD
alexanderbez Oct 31, 2019
615a3c0
add spec
alexanderbez Oct 31, 2019
946628d
add changelog entry
alexanderbez Oct 31, 2019
c829a3f
update adr
alexanderbez Oct 31, 2019
829c674
Update x/evidence/client/cli/query.go
alexanderbez Nov 5, 2019
2fc3737
Update x/evidence/client/cli/query.go
alexanderbez Nov 5, 2019
2d12a84
Update x/evidence/client/cli/query.go
alexanderbez Nov 5, 2019
bac71c0
Update x/evidence/client/cli/tx.go
alexanderbez Nov 5, 2019
ad7e945
Update x/evidence/client/cli/tx.go
alexanderbez Nov 5, 2019
4f9eb5d
Update x/evidence/client/cli/tx.go
alexanderbez Nov 5, 2019
0aebd95
Update x/evidence/client/rest/query.go
alexanderbez Nov 5, 2019
0737aa8
fix build
alexanderbez Nov 5, 2019
6991768
remove abci.go
alexanderbez Nov 5, 2019
0d5bd13
add to docs file
alexanderbez Nov 5, 2019
1b46150
move Evidence type to exported
alexanderbez Nov 5, 2019
ba5c236
Merge branch 'master' into bez/evidence-module-impl
alexanderbez Nov 5, 2019
709d5f5
emit events for evidence submission
alexanderbez Nov 5, 2019
4338e05
Merge branch 'bez/evidence-module-impl' of github.com:cosmos/cosmos-s…
alexanderbez Nov 5, 2019
cffa3b1
fix tests; goimports
alexanderbez Nov 5, 2019
177b5d3
Merge branch 'master' into bez/evidence-module-impl
alexanderbez Nov 6, 2019
3219e64
add GetEvidenceHandler
alexanderbez Nov 6, 2019
d07c383
Merge branch 'master' into bez/evidence-module-impl
alexanderbez Nov 6, 2019
9039963
Merge branch 'master' into bez/evidence-module-impl
alexanderbez Nov 6, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ increased significantly due to modular `AnteHandler` support. Increase GasLimit

### Features

* (x/evidence) [\#5240](https://github.com/cosmos/cosmos-sdk/pull/5240) Initial implementation of the `x/evidence` module.
* (cli) [\#5212](https://github.com/cosmos/cosmos-sdk/issues/5212) The `q gov proposals` command now supports pagination.
* (store) [\#4724](https://github.com/cosmos/cosmos-sdk/issues/4724) Multistore supports substore migrations upon load. New `rootmulti.Store.LoadLatestVersionAndUpgrade` method in
`Baseapp` supports `StoreLoader` to enable various upgrade strategies. It no
Expand Down
13 changes: 8 additions & 5 deletions docs/architecture/adr-009-evidence-module.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
## Changelog

- 2019 July 31: Initial draft
- 2019 October 24: Initial implementation

## Status

Proposed
Accepted

## Context

Expand Down Expand Up @@ -55,7 +56,8 @@ type Evidence interface {
Route() string
Type() string
String() string
ValidateBasic() Error
Hash() HexBytes
ValidateBasic() error

// The consensus address of the malicious validator at time of infraction
GetConsensusAddress() ConsAddress
Expand All @@ -78,7 +80,7 @@ the `x/evidence` module. It accomplishes this through the `Router` implementatio

```go
type Router interface {
AddRoute(r string, h Handler)
AddRoute(r string, h Handler) Router
HasRoute(r string) bool
GetRoute(path string) Handler
Seal()
Expand All @@ -97,7 +99,7 @@ necessary in order for the `Handler` to make the necessary state transitions.
If no error is returned, the `Evidence` is considered valid.

```go
type Handler func(Context, Evidence) Error
type Handler func(Context, Evidence) error
```

### Submission
Expand Down Expand Up @@ -128,7 +130,7 @@ the module's router and invoking the corresponding `Handler` which may include
slashing and jailing the validator. Upon success, the submitted evidence is persisted.

```go
func (k Keeper) SubmitEvidence(ctx Context, evidence Evidence) Error {
func (k Keeper) SubmitEvidence(ctx Context, evidence Evidence) error {
handler := keeper.router.GetRoute(evidence.Route())
if err := handler(ctx, evidence); err != nil {
return ErrInvalidEvidence(keeper.codespace, err)
Expand Down Expand Up @@ -177,3 +179,4 @@ due to the inability to introduce the new evidence type's corresponding handler

- [ICS](https://github.com/cosmos/ics)
- [IBC Architecture](https://github.com/cosmos/ics/blob/master/ibc/1_IBC_ARCHITECTURE.md)
- [Tendermint Fork Accountability](https://github.com/tendermint/tendermint/blob/master/docs/spec/consensus/fork-accountability.md)
75 changes: 36 additions & 39 deletions docs/building-modules/README.md
Original file line number Diff line number Diff line change
@@ -1,78 +1,75 @@
# Auth
# Modules

The `x/auth` modules is used for accounts
## Auth

See the [API docs](https://godoc.org/github.com/cosmos/cosmos-sdk/x/auth)
The `x/auth` modules is used for accounts

See the [specification](https://github.com/cosmos/cosmos-sdk/tree/master/docs/spec/auth)
- [API docs](https://godoc.org/github.com/cosmos/cosmos-sdk/x/auth)
- [Specification](https://github.com/cosmos/cosmos-sdk/tree/master/docs/spec/auth)

# Bank
## Bank

The `x/bank` module is for transferring coins between accounts.

See the [API docs](https://godoc.org/github.com/cosmos/cosmos-sdk/x/bank).

See the [specification](https://github.com/cosmos/cosmos-sdk/tree/master/docs/spec/bank)
- [API docs](https://godoc.org/github.com/cosmos/cosmos-sdk/x/bank)
- [Specification](https://github.com/cosmos/cosmos-sdk/tree/master/docs/spec/bank)

# Stake
## Staking

The `x/staking` module is for Cosmos Delegated-Proof-of-Stake.

See the [API docs](https://godoc.org/github.com/cosmos/cosmos-sdk/x/staking).
- [API docs](https://godoc.org/github.com/cosmos/cosmos-sdk/x/staking)
- [Specification](https://github.com/cosmos/cosmos-sdk/tree/master/docs/spec/staking)

See the
[specification](https://github.com/cosmos/cosmos-sdk/tree/master/docs/spec/staking)

# Slashing
## Slashing

The `x/slashing` module is for Cosmos Delegated-Proof-of-Stake.

See the [API docs](https://godoc.org/github.com/cosmos/cosmos-sdk/x/slashing)

See the
[specification](https://github.com/cosmos/cosmos-sdk/tree/master/docs/spec/slashing)
- [API docs](https://godoc.org/github.com/cosmos/cosmos-sdk/x/slashing)
- [Specification](https://github.com/cosmos/cosmos-sdk/tree/master/docs/spec/slashing)

# Distribution
## Distribution

The `x/distribution` module is for distributing fees and inflation across bonded
stakeholders.

See the [API docs](https://godoc.org/github.com/cosmos/cosmos-sdk/x/distribution)

See the
[specification](https://github.com/cosmos/cosmos-sdk/tree/master/docs/spec/distribution)
- [API docs](https://godoc.org/github.com/cosmos/cosmos-sdk/x/distribution)
- [Specification](https://github.com/cosmos/cosmos-sdk/tree/master/docs/spec/distribution)

# Governance
## Governance

The `x/gov` module is for bonded stakeholders to make proposals and vote on them.

See the [API docs](https://godoc.org/github.com/cosmos/cosmos-sdk/x/gov)

See the
[specification](https://github.com/cosmos/cosmos-sdk/tree/master/docs/spec/governance)
- [API docs](https://godoc.org/github.com/cosmos/cosmos-sdk/x/gov)
- [Specification](https://github.com/cosmos/cosmos-sdk/tree/master/docs/spec/governance)

To keep up with the current status of IBC, follow and contribute to [ICS](https://github.com/cosmos/ics)

# Crisis
## Crisis

The `x/crisis` module is for halting the blockchain under certain circumstances.

See the [API Docs](https://godoc.org/github.com/cosmos/cosmos-sdk/x/crisis)

See the [specification](https://github.com/cosmos/cosmos-sdk/blob/master/docs/spec/crisis)
- [API Docs](https://godoc.org/github.com/cosmos/cosmos-sdk/x/crisis)
- [Specification](https://github.com/cosmos/cosmos-sdk/blob/master/docs/spec/crisis)

# Mint
## Mint

The `x/mint` module is for flexible inflation rates and effect a balance between market liquidity and staked supply.

See the [API Docs](https://godoc.org/github.com/cosmos/cosmos-sdk/x/mint)

See the [specification](https://github.com/cosmos/cosmos-sdk/blob/master/docs/spec/mint)
- [API Docs](https://godoc.org/github.com/cosmos/cosmos-sdk/x/mint)
- [Specification](https://github.com/cosmos/cosmos-sdk/blob/master/docs/spec/mint)

# Params
## Params

The `x/params` module provides a globally available parameter store.

See the [API Docs](https://godoc.org/github.com/cosmos/cosmos-sdk/x/params)
- [API Docs](https://godoc.org/github.com/cosmos/cosmos-sdk/x/params)
- [Specification](https://github.com/cosmos/cosmos-sdk/blob/master/docs/spec/params)

## Evidence

The `x/evidence` modules provides a mechanism for defining and submitting arbitrary
events of misbehavior and a means to execute custom business logic for such misbehavior.

See the [specification](https://github.com/cosmos/cosmos-sdk/blob/master/docs/spec/params)
- [API Docs](https://godoc.org/github.com/cosmos/cosmos-sdk/x/evidence)
- [Specification](https://github.com/cosmos/cosmos-sdk/blob/master/docs/spec/evidence)
114 changes: 82 additions & 32 deletions simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/bank"
"github.com/cosmos/cosmos-sdk/x/crisis"
distr "github.com/cosmos/cosmos-sdk/x/distribution"
"github.com/cosmos/cosmos-sdk/x/evidence"
"github.com/cosmos/cosmos-sdk/x/genutil"
"github.com/cosmos/cosmos-sdk/x/gov"
"github.com/cosmos/cosmos-sdk/x/mint"
Expand Down Expand Up @@ -54,6 +55,7 @@ var (
params.AppModuleBasic{},
crisis.AppModuleBasic{},
slashing.AppModuleBasic{},
evidence.AppModuleBasic{},
)

// module account permissions
Expand Down Expand Up @@ -90,6 +92,9 @@ type SimApp struct {
keys map[string]*sdk.KVStoreKey
tkeys map[string]*sdk.TransientStoreKey

// subspaces
subspaces map[string]params.Subspace

// keepers
AccountKeeper auth.AccountKeeper
BankKeeper bank.Keeper
Expand All @@ -101,6 +106,7 @@ type SimApp struct {
GovKeeper gov.Keeper
CrisisKeeper crisis.Keeper
ParamsKeeper params.Keeper
EvidenceKeeper evidence.Keeper

// the module manager
mm *module.Manager
Expand All @@ -121,9 +127,10 @@ func NewSimApp(
bApp.SetCommitMultiStoreTracer(traceStore)
bApp.SetAppVersion(version.Version)

keys := sdk.NewKVStoreKeys(bam.MainStoreKey, auth.StoreKey, staking.StoreKey,
supply.StoreKey, mint.StoreKey, distr.StoreKey, slashing.StoreKey,
gov.StoreKey, params.StoreKey)
keys := sdk.NewKVStoreKeys(
bam.MainStoreKey, auth.StoreKey, staking.StoreKey, supply.StoreKey, mint.StoreKey,
distr.StoreKey, slashing.StoreKey, gov.StoreKey, params.StoreKey, evidence.StoreKey,
)
tkeys := sdk.NewTransientStoreKeys(params.TStoreKey)

app := &SimApp{
Expand All @@ -132,39 +139,68 @@ func NewSimApp(
invCheckPeriod: invCheckPeriod,
keys: keys,
tkeys: tkeys,
subspaces: make(map[string]params.Subspace),
}

// init params keeper and subspaces
app.ParamsKeeper = params.NewKeeper(app.cdc, keys[params.StoreKey], tkeys[params.TStoreKey], params.DefaultCodespace)
authSubspace := app.ParamsKeeper.Subspace(auth.DefaultParamspace)
bankSubspace := app.ParamsKeeper.Subspace(bank.DefaultParamspace)
stakingSubspace := app.ParamsKeeper.Subspace(staking.DefaultParamspace)
mintSubspace := app.ParamsKeeper.Subspace(mint.DefaultParamspace)
distrSubspace := app.ParamsKeeper.Subspace(distr.DefaultParamspace)
slashingSubspace := app.ParamsKeeper.Subspace(slashing.DefaultParamspace)
govSubspace := app.ParamsKeeper.Subspace(gov.DefaultParamspace).WithKeyTable(gov.ParamKeyTable())
crisisSubspace := app.ParamsKeeper.Subspace(crisis.DefaultParamspace)
app.subspaces[auth.ModuleName] = app.ParamsKeeper.Subspace(auth.DefaultParamspace)
app.subspaces[bank.ModuleName] = app.ParamsKeeper.Subspace(bank.DefaultParamspace)
app.subspaces[staking.ModuleName] = app.ParamsKeeper.Subspace(staking.DefaultParamspace)
app.subspaces[mint.ModuleName] = app.ParamsKeeper.Subspace(mint.DefaultParamspace)
app.subspaces[distr.ModuleName] = app.ParamsKeeper.Subspace(distr.DefaultParamspace)
app.subspaces[slashing.ModuleName] = app.ParamsKeeper.Subspace(slashing.DefaultParamspace)
app.subspaces[gov.ModuleName] = app.ParamsKeeper.Subspace(gov.DefaultParamspace).WithKeyTable(gov.ParamKeyTable())
app.subspaces[crisis.ModuleName] = app.ParamsKeeper.Subspace(crisis.DefaultParamspace)
app.subspaces[evidence.ModuleName] = app.ParamsKeeper.Subspace(evidence.DefaultParamspace)

// add keepers
app.AccountKeeper = auth.NewAccountKeeper(app.cdc, keys[auth.StoreKey], authSubspace, auth.ProtoBaseAccount)
app.BankKeeper = bank.NewBaseKeeper(app.AccountKeeper, bankSubspace, bank.DefaultCodespace, app.ModuleAccountAddrs())
app.SupplyKeeper = supply.NewKeeper(app.cdc, keys[supply.StoreKey], app.AccountKeeper, app.BankKeeper, maccPerms)
stakingKeeper := staking.NewKeeper(app.cdc, keys[staking.StoreKey],
app.SupplyKeeper, stakingSubspace, staking.DefaultCodespace)
app.MintKeeper = mint.NewKeeper(app.cdc, keys[mint.StoreKey], mintSubspace, &stakingKeeper, app.SupplyKeeper, auth.FeeCollectorName)
app.DistrKeeper = distr.NewKeeper(app.cdc, keys[distr.StoreKey], distrSubspace, &stakingKeeper,
app.SupplyKeeper, distr.DefaultCodespace, auth.FeeCollectorName, app.ModuleAccountAddrs())
app.SlashingKeeper = slashing.NewKeeper(app.cdc, keys[slashing.StoreKey], &stakingKeeper,
slashingSubspace, slashing.DefaultCodespace)
app.CrisisKeeper = crisis.NewKeeper(crisisSubspace, invCheckPeriod, app.SupplyKeeper, auth.FeeCollectorName)
app.AccountKeeper = auth.NewAccountKeeper(
app.cdc, keys[auth.StoreKey], app.subspaces[auth.ModuleName], auth.ProtoBaseAccount,
)
app.BankKeeper = bank.NewBaseKeeper(
app.AccountKeeper, app.subspaces[bank.ModuleName], bank.DefaultCodespace,
app.ModuleAccountAddrs(),
)
app.SupplyKeeper = supply.NewKeeper(
app.cdc, keys[supply.StoreKey], app.AccountKeeper, app.BankKeeper, maccPerms,
)
stakingKeeper := staking.NewKeeper(
app.cdc, keys[staking.StoreKey], app.SupplyKeeper, app.subspaces[staking.ModuleName],
staking.DefaultCodespace)
app.MintKeeper = mint.NewKeeper(
app.cdc, keys[mint.StoreKey], app.subspaces[mint.ModuleName], &stakingKeeper,
app.SupplyKeeper, auth.FeeCollectorName,
)
app.DistrKeeper = distr.NewKeeper(
app.cdc, keys[distr.StoreKey], app.subspaces[distr.ModuleName], &stakingKeeper,
app.SupplyKeeper, distr.DefaultCodespace, auth.FeeCollectorName, app.ModuleAccountAddrs(),
)
app.SlashingKeeper = slashing.NewKeeper(
app.cdc, keys[slashing.StoreKey], &stakingKeeper, app.subspaces[slashing.ModuleName], slashing.DefaultCodespace,
)
app.CrisisKeeper = crisis.NewKeeper(
app.subspaces[crisis.ModuleName], invCheckPeriod, app.SupplyKeeper, auth.FeeCollectorName,
)

// create evidence keeper with router
evidenceKeeper := evidence.NewKeeper(
app.cdc, keys[evidence.StoreKey], app.subspaces[evidence.ModuleName], evidence.DefaultCodespace,
)
evidenceRouter := evidence.NewRouter()
// TODO: Register evidence routes.
evidenceKeeper.SetRouter(evidenceRouter)
app.EvidenceKeeper = *evidenceKeeper

// register the proposal types
govRouter := gov.NewRouter()
govRouter.AddRoute(gov.RouterKey, gov.ProposalHandler).
AddRoute(params.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).
AddRoute(distr.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper))
app.GovKeeper = gov.NewKeeper(app.cdc, keys[gov.StoreKey], govSubspace,
app.SupplyKeeper, &stakingKeeper, gov.DefaultCodespace, govRouter)
app.GovKeeper = gov.NewKeeper(
app.cdc, keys[gov.StoreKey], app.subspaces[gov.ModuleName], app.SupplyKeeper,
&stakingKeeper, gov.DefaultCodespace, govRouter,
)

// register the staking hooks
// NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks
Expand All @@ -185,22 +221,21 @@ func NewSimApp(
distr.NewAppModule(app.DistrKeeper, app.SupplyKeeper),
slashing.NewAppModule(app.SlashingKeeper, app.StakingKeeper),
staking.NewAppModule(app.StakingKeeper, app.AccountKeeper, app.SupplyKeeper),
evidence.NewAppModule(app.EvidenceKeeper),
)

// During begin block slashing happens after distr.BeginBlocker so that
// there is nothing left over in the validator fee pool, so as to keep the
// CanWithdrawInvariant invariant.
app.mm.SetOrderBeginBlockers(mint.ModuleName, distr.ModuleName, slashing.ModuleName)

app.mm.SetOrderEndBlockers(crisis.ModuleName, gov.ModuleName, staking.ModuleName)

// NOTE: The genutils moodule must occur after staking so that pools are
// properly initialized with tokens from genesis accounts.
app.mm.SetOrderInitGenesis(
auth.ModuleName, distr.ModuleName, staking.ModuleName,
bank.ModuleName, slashing.ModuleName, gov.ModuleName,
mint.ModuleName, supply.ModuleName, crisis.ModuleName,
genutil.ModuleName,
auth.ModuleName, distr.ModuleName, staking.ModuleName, bank.ModuleName,
slashing.ModuleName, gov.ModuleName, mint.ModuleName, supply.ModuleName,
crisis.ModuleName, genutil.ModuleName, evidence.ModuleName,
)

app.mm.RegisterInvariants(&app.CrisisKeeper)
Expand Down Expand Up @@ -239,6 +274,7 @@ func NewSimApp(
cmn.Exit(err.Error())
}
}

return app
}

Expand Down Expand Up @@ -274,21 +310,35 @@ func (app *SimApp) ModuleAccountAddrs() map[string]bool {
return modAccAddrs
}

// Codec returns simapp's codec
// Codec returns SimApp's codec.
//
// NOTE: This is solely to be used for testing purposes as it may be desirable
// for modules to register their own custom testing types.
func (app *SimApp) Codec() *codec.Codec {
return app.cdc
}

// GetKey returns the KVStoreKey for the provided store key
// GetKey returns the KVStoreKey for the provided store key.
//
// NOTE: This is solely to be used for testing purposes.
func (app *SimApp) GetKey(storeKey string) *sdk.KVStoreKey {
return app.keys[storeKey]
}

// GetTKey returns the TransientStoreKey for the provided store key
// GetTKey returns the TransientStoreKey for the provided store key.
//
// NOTE: This is solely to be used for testing purposes.
func (app *SimApp) GetTKey(storeKey string) *sdk.TransientStoreKey {
return app.tkeys[storeKey]
}

// GetSubspace returns a param subspace for a given module name.
//
// NOTE: This is solely to be used for testing purposes.
func (app *SimApp) GetSubspace(moduleName string) params.Subspace {
return app.subspaces[moduleName]
}

// GetMaccPerms returns a copy of the module account permissions
func GetMaccPerms() map[string][]string {
dupMaccPerms := make(map[string][]string)
Expand Down
Loading