feat!: consensus module (#12905)

This commit is contained in:
Marko 2022-10-05 20:06:24 +02:00 committed by GitHub
parent 87e46b2f51
commit 306a9a7170
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
54 changed files with 541 additions and 308 deletions

View File

@ -51,6 +51,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (x/bank) [#11981](https://github.com/cosmos/cosmos-sdk/pull/11981) Create the `SetSendEnabled` endpoint for managing the bank's SendEnabled settings.
* (x/auth) [#13210](https://github.com/cosmos/cosmos-sdk/pull/13210) Add `Query/AccountInfo` endpoint for simplified access to basic account info.
* (cli) [#13147](https://github.com/cosmos/cosmos-sdk/pull/13147) Add the `--append` flag to the `sign-batch` CLI cmd to combine the messages and sign those txs which are created with `--generate-only`.
* (x/consensus) [#12905](https://github.com/cosmos/cosmos-sdk/pull/12905) Create a new `x/consensus` module that is now responsible for maintaining Tendermint consensus parameters instead of `x/param`. Legacy types remain in order to facilitate parameter migration from the deprecated `x/params`. App developers should ensure that they execute `baseapp.MigrateParams` during their chain upgrade. These legacy types will be removed in a future release.
### Improvements

View File

@ -52,8 +52,10 @@ Please use the `ghcr.io/cosmos/proto-builder` image (version >= `0.11.0`) for ge
#### Broadcast Mode
Broadcast mode `block` was deprecated and has been removed. Please use `sync` mode instead.
When upgrading your tests from `block` to `sync` and checking for a transaction code, you need to query the transaction first (with its hash) to get the correct code.
Broadcast mode `block` was deprecated and has been removed. Please use `sync` mode
instead. When upgrading your tests from `block` to `sync` and checking for a
transaction code, you need to query the transaction first (with its hash) to get
the correct code.
### Modules
@ -69,6 +71,53 @@ By default, the new `MinInitialDepositRatio` parameter is set to zero during mig
feature is disabled. If chains wish to utilize the minimum proposal deposits at time of submission, the migration logic needs to be
modified to set the new parameter to the desired value.
#### `x/consensus`
Introducing a new `x/consensus` module to handle managing Tendermint consensus
parameters. For migration it is required to call a specific migration to migrate
existing parameters from the deprecated `x/params` to `x/consensus` module. App
developers should ensure to call `baseapp.MigrateParams` in their upgrade handler.
Example:
```go
func (app SimApp) RegisterUpgradeHandlers() {
----> baseAppLegacySS := app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable()) <----
app.UpgradeKeeper.SetUpgradeHandler(
UpgradeName,
func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// Migrate Tendermint consensus parameters from x/params module to a
// dedicated x/consensus module.
----> baseapp.MigrateParams(ctx, baseAppLegacySS, &app.ConsensusParamsKeeper) <----
// ...
return app.ModuleManager.RunMigrations(ctx, app.Configurator(), fromVM)
},
)
// ...
}
```
The old params module is required to still be imported in your app.go in order to handle this migration.
##### App.go Changes
Previous:
```go
bApp.SetParamStore(app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable()))
```
After:
```go
app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, keys[upgradetypes.StoreKey], authtypes.NewModuleAddress(govtypes.ModuleName).String())
bApp.SetParamStore(&app.ConsensusParamsKeeper)
```
### Ledger
Ledger support has been generalized to enable use of different apps and keytypes that use `secp256k1`. The Ledger interface remains the same, but it can now be provided through the Keyring `Options`, allowing higher-level chains to connect to different Ledger apps or use custom implementations. In addition, higher-level chains can provide custom key implementations around the Ledger public key, to enable greater flexibility with address generation and signing.

View File

@ -2,6 +2,7 @@ package baseapp
import (
"encoding/json"
"errors"
"os"
"testing"
@ -177,17 +178,19 @@ type paramStore struct {
db *dbm.MemDB
}
func (ps *paramStore) Set(_ sdk.Context, key []byte, value interface{}) {
var ParamstoreKey = []byte("paramstore")
func (ps *paramStore) Set(_ sdk.Context, value *tmproto.ConsensusParams) {
bz, err := json.Marshal(value)
if err != nil {
panic(err)
}
ps.db.Set(key, bz)
ps.db.Set(ParamstoreKey, bz)
}
func (ps *paramStore) Has(_ sdk.Context, key []byte) bool {
ok, err := ps.db.Has(key)
func (ps *paramStore) Has(_ sdk.Context) bool {
ok, err := ps.db.Has(ParamstoreKey)
if err != nil {
panic(err)
}
@ -195,17 +198,21 @@ func (ps *paramStore) Has(_ sdk.Context, key []byte) bool {
return ok
}
func (ps *paramStore) Get(_ sdk.Context, key []byte, ptr interface{}) {
bz, err := ps.db.Get(key)
func (ps paramStore) Get(_ sdk.Context) (*tmproto.ConsensusParams, error) {
bz, err := ps.db.Get(ParamstoreKey)
if err != nil {
panic(err)
return nil, err
}
if len(bz) == 0 {
return
return nil, errors.New("no consensus params")
}
if err := json.Unmarshal(bz, ptr); err != nil {
var params tmproto.ConsensusParams
if err := json.Unmarshal(bz, &params); err != nil {
panic(err)
}
return &params, nil
}

View File

@ -5,6 +5,7 @@ import (
"sort"
"strings"
"github.com/cosmos/gogoproto/proto"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto/tmhash"
"github.com/tendermint/tendermint/libs/log"
@ -12,8 +13,6 @@ import (
dbm "github.com/tendermint/tm-db"
"golang.org/x/exp/maps"
"github.com/cosmos/gogoproto/proto"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/snapshots"
"github.com/cosmos/cosmos-sdk/store"
@ -407,39 +406,14 @@ func (app *BaseApp) GetConsensusParams(ctx sdk.Context) *tmproto.ConsensusParams
return nil
}
cp := new(tmproto.ConsensusParams)
if app.paramStore.Has(ctx, ParamStoreKeyBlockParams) {
var bp tmproto.BlockParams
app.paramStore.Get(ctx, ParamStoreKeyBlockParams, &bp)
cp.Block = &bp
}
if app.paramStore.Has(ctx, ParamStoreKeyEvidenceParams) {
var ep tmproto.EvidenceParams
app.paramStore.Get(ctx, ParamStoreKeyEvidenceParams, &ep)
cp.Evidence = &ep
}
if app.paramStore.Has(ctx, ParamStoreKeyValidatorParams) {
var vp tmproto.ValidatorParams
app.paramStore.Get(ctx, ParamStoreKeyValidatorParams, &vp)
cp.Validator = &vp
cp, err := app.paramStore.Get(ctx)
if err != nil {
panic(err)
}
return cp
}
// AddRunTxRecoveryHandler adds custom app.runTx method panic handlers.
func (app *BaseApp) AddRunTxRecoveryHandler(handlers ...RecoveryHandler) {
for _, h := range handlers {
app.runTxRecoveryMiddleware = newRecoveryMiddleware(h, app.runTxRecoveryMiddleware)
}
}
// StoreConsensusParams sets the consensus parameters to the baseapp's param store.
func (app *BaseApp) StoreConsensusParams(ctx sdk.Context, cp *tmproto.ConsensusParams) {
if app.paramStore == nil {
@ -450,13 +424,18 @@ func (app *BaseApp) StoreConsensusParams(ctx sdk.Context, cp *tmproto.ConsensusP
return
}
app.paramStore.Set(ctx, ParamStoreKeyBlockParams, cp.Block)
app.paramStore.Set(ctx, ParamStoreKeyEvidenceParams, cp.Evidence)
app.paramStore.Set(ctx, ParamStoreKeyValidatorParams, cp.Validator)
app.paramStore.Set(ctx, cp)
// We're explicitly not storing the Tendermint app_version in the param store. It's
// stored instead in the x/upgrade store, with its own bump logic.
}
// AddRunTxRecoveryHandler adds custom app.runTx method panic handlers.
func (app *BaseApp) AddRunTxRecoveryHandler(handlers ...RecoveryHandler) {
for _, h := range handlers {
app.runTxRecoveryMiddleware = newRecoveryMiddleware(h, app.runTxRecoveryMiddleware)
}
}
// getMaximumBlockGas gets the maximum gas from the consensus params. It panics
// if maximum block gas is less than negative one and returns zero if negative
// one.

View File

@ -32,8 +32,6 @@ import (
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
)
var blockMaxGas = uint64(simtestutil.DefaultConsensusParams.Block.MaxGas)
@ -73,8 +71,6 @@ func TestBaseApp_BlockGas(t *testing.T) {
var (
bankKeeper bankkeeper.Keeper
accountKeeper authkeeper.AccountKeeper
paramsKeeper paramskeeper.Keeper
stakingKeeper *stakingkeeper.Keeper
appBuilder *runtime.AppBuilder
txConfig client.TxConfig
cdc codec.Codec
@ -88,8 +84,6 @@ func TestBaseApp_BlockGas(t *testing.T) {
err = depinject.Inject(appConfig,
&bankKeeper,
&accountKeeper,
&paramsKeeper,
&stakingKeeper,
&interfaceRegistry,
&txConfig,
&cdc,

View File

@ -5,6 +5,7 @@ import (
"context"
"encoding/binary"
"encoding/json"
"errors"
"fmt"
"math/rand"
"net/url"
@ -17,6 +18,14 @@ import (
"unsafe"
"cosmossdk.io/depinject"
"github.com/cosmos/gogoproto/jsonpb"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
dbm "github.com/tendermint/tm-db"
"github.com/cosmos/cosmos-sdk/baseapp"
baseapptestutil "github.com/cosmos/cosmos-sdk/baseapp/testutil"
"github.com/cosmos/cosmos-sdk/client"
@ -34,13 +43,6 @@ import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/signing"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
"github.com/cosmos/gogoproto/jsonpb"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
dbm "github.com/tendermint/tm-db"
)
var (
@ -102,10 +104,13 @@ func setupBaseAppWithSnapshots(t *testing.T, config *setupConfig) (*baseapp.Base
// patch in TxConfig instead of using an output from x/auth/tx
txConfig := authtx.NewTxConfig(cdc, authtx.DefaultSignModes)
// set the TxDecoder in the BaseApp for minimal tx simulations
app.SetTxDecoder(txConfig.TxDecoder())
app.InitChain(abci.RequestInitChain{})
app.InitChain(abci.RequestInitChain{
ConsensusParams: &tmproto.ConsensusParams{},
})
r := rand.New(rand.NewSource(3920758213583))
keyCounter := 0
@ -571,9 +576,13 @@ func TestGRPCQuery(t *testing.T) {
app := setupBaseApp(t, grpcQueryOpt)
app.GRPCQueryRouter().SetInterfaceRegistry(codectypes.NewInterfaceRegistry())
app.InitChain(abci.RequestInitChain{})
app.InitChain(abci.RequestInitChain{
ConsensusParams: &tmproto.ConsensusParams{},
})
header := tmproto.Header{Height: app.LastBlockHeight() + 1}
app.BeginBlock(abci.RequestBeginBlock{Header: header})
app.Commit()
req := testdata.SayHelloRequest{Name: "foo"}
@ -1886,7 +1895,9 @@ func TestQuery(t *testing.T) {
app.SetTxDecoder(txConfig.TxDecoder())
app.SetParamStore(&paramStore{db: dbm.NewMemDB()})
app.InitChain(abci.RequestInitChain{})
app.InitChain(abci.RequestInitChain{
ConsensusParams: &tmproto.ConsensusParams{},
})
// NOTE: "/store/key1" tells us KVStore
// and the final "/key" says to use the data as the
@ -2152,17 +2163,19 @@ type paramStore struct {
db *dbm.MemDB
}
func (ps *paramStore) Set(_ sdk.Context, key []byte, value interface{}) {
var ParamstoreKey = []byte("paramstore")
func (ps *paramStore) Set(_ sdk.Context, value *tmproto.ConsensusParams) {
bz, err := json.Marshal(value)
if err != nil {
panic(err)
}
ps.db.Set(key, bz)
ps.db.Set(ParamstoreKey, bz)
}
func (ps *paramStore) Has(_ sdk.Context, key []byte) bool {
ok, err := ps.db.Has(key)
func (ps *paramStore) Has(_ sdk.Context) bool {
ok, err := ps.db.Has(ParamstoreKey)
if err != nil {
panic(err)
}
@ -2170,17 +2183,21 @@ func (ps *paramStore) Has(_ sdk.Context, key []byte) bool {
return ok
}
func (ps *paramStore) Get(_ sdk.Context, key []byte, ptr interface{}) {
bz, err := ps.db.Get(key)
func (ps paramStore) Get(ctx sdk.Context) (*tmproto.ConsensusParams, error) {
bz, err := ps.db.Get(ParamstoreKey)
if err != nil {
panic(err)
}
if len(bz) == 0 {
return
return nil, errors.New("params not found")
}
if err := json.Unmarshal(bz, ptr); err != nil {
var params tmproto.ConsensusParams
if err := json.Unmarshal(bz, &params); err != nil {
panic(err)
}
return &params, nil
}

View File

@ -114,8 +114,5 @@ func (qrt *GRPCQueryRouter) SetInterfaceRegistry(interfaceRegistry codectypes.In
qrt.cdc = codec.NewProtoCodec(interfaceRegistry).GRPCCodec()
// Once we have an interface registry, we can register the interface
// registry reflection gRPC service.
reflection.RegisterReflectionServiceServer(
qrt,
reflection.NewReflectionServiceServer(interfaceRegistry),
)
reflection.RegisterReflectionServiceServer(qrt, reflection.NewReflectionServiceServer(interfaceRegistry))
}

View File

@ -1,85 +1,15 @@
package baseapp
import (
"errors"
"fmt"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// Paramspace defines the parameter subspace to be used for the paramstore.
const Paramspace = "baseapp"
// Parameter store keys for all the consensus parameter types.
var (
ParamStoreKeyBlockParams = []byte("BlockParams")
ParamStoreKeyEvidenceParams = []byte("EvidenceParams")
ParamStoreKeyValidatorParams = []byte("ValidatorParams")
)
// ParamStore defines the interface the parameter store used by the BaseApp must
// fulfill.
type ParamStore interface {
Get(ctx sdk.Context, key []byte, ptr interface{})
Has(ctx sdk.Context, key []byte) bool
Set(ctx sdk.Context, key []byte, param interface{})
}
// ValidateBlockParams defines a stateless validation on BlockParams. This function
// is called whenever the parameters are updated or stored.
func ValidateBlockParams(i interface{}) error {
v, ok := i.(tmproto.BlockParams)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}
if v.MaxBytes <= 0 {
return fmt.Errorf("block maximum bytes must be positive: %d", v.MaxBytes)
}
if v.MaxGas < -1 {
return fmt.Errorf("block maximum gas must be greater than or equal to -1: %d", v.MaxGas)
}
return nil
}
// ValidateEvidenceParams defines a stateless validation on EvidenceParams. This
// function is called whenever the parameters are updated or stored.
func ValidateEvidenceParams(i interface{}) error {
v, ok := i.(tmproto.EvidenceParams)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}
if v.MaxAgeNumBlocks <= 0 {
return fmt.Errorf("evidence maximum age in blocks must be positive: %d", v.MaxAgeNumBlocks)
}
if v.MaxAgeDuration <= 0 {
return fmt.Errorf("evidence maximum age time duration must be positive: %v", v.MaxAgeDuration)
}
if v.MaxBytes < 0 {
return fmt.Errorf("maximum evidence bytes must be non-negative: %v", v.MaxBytes)
}
return nil
}
// ValidateValidatorParams defines a stateless validation on ValidatorParams. This
// function is called whenever the parameters are updated or stored.
func ValidateValidatorParams(i interface{}) error {
v, ok := i.(tmproto.ValidatorParams)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}
if len(v.PubKeyTypes) == 0 {
return errors.New("validator allowed pubkey types must not be empty")
}
return nil
Get(ctx sdk.Context) (*tmproto.ConsensusParams, error)
Has(ctx sdk.Context) bool
Set(ctx sdk.Context, cp *tmproto.ConsensusParams)
}

147
baseapp/params_legacy.go Normal file
View File

@ -0,0 +1,147 @@
/*
Deprecated.
Legacy types are defined below to aid in the migration of Tendermint consensus
parameters from use of the now deprecated x/params modules to a new dedicated
x/consensus module.
Application developers should ensure that they implement their upgrade handler
correctly such that app.ConsensusParamsKeeper.Set() is called with the values
returned by GetConsensusParams().
Example:
baseAppLegacySS := app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable())
app.UpgradeKeeper.SetUpgradeHandler(
UpgradeName,
func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
if cp := baseapp.GetConsensusParams(ctx, baseAppLegacySS); cp != nil {
app.ConsensusParamsKeeper.Set(ctx, cp)
} else {
ctx.Logger().Info("warning: consensus parameters are undefined; skipping migration", "upgrade", UpgradeName)
}
return app.ModuleManager.RunMigrations(ctx, app.Configurator(), fromVM)
},
)
Developers can also bypass the use of the legacy Params subspace and set the
values to app.ConsensusParamsKeeper.Set() explicitly.
Note, for new chains this is not necessary as Tendermint's consensus parameters
will automatically be set for you in InitChain.
*/
package baseapp
import (
"errors"
"fmt"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
const Paramspace = "baseapp"
var (
ParamStoreKeyBlockParams = []byte("BlockParams")
ParamStoreKeyEvidenceParams = []byte("EvidenceParams")
ParamStoreKeyValidatorParams = []byte("ValidatorParams")
)
type LegacyParamStore interface {
Get(ctx sdk.Context, key []byte, ptr interface{})
Has(ctx sdk.Context, key []byte) bool
}
func ValidateBlockParams(i interface{}) error {
v, ok := i.(tmproto.BlockParams)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}
if v.MaxBytes <= 0 {
return fmt.Errorf("block maximum bytes must be positive: %d", v.MaxBytes)
}
if v.MaxGas < -1 {
return fmt.Errorf("block maximum gas must be greater than or equal to -1: %d", v.MaxGas)
}
return nil
}
func ValidateEvidenceParams(i interface{}) error {
v, ok := i.(tmproto.EvidenceParams)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}
if v.MaxAgeNumBlocks <= 0 {
return fmt.Errorf("evidence maximum age in blocks must be positive: %d", v.MaxAgeNumBlocks)
}
if v.MaxAgeDuration <= 0 {
return fmt.Errorf("evidence maximum age time duration must be positive: %v", v.MaxAgeDuration)
}
if v.MaxBytes < 0 {
return fmt.Errorf("maximum evidence bytes must be non-negative: %v", v.MaxBytes)
}
return nil
}
func ValidateValidatorParams(i interface{}) error {
v, ok := i.(tmproto.ValidatorParams)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}
if len(v.PubKeyTypes) == 0 {
return errors.New("validator allowed pubkey types must not be empty")
}
return nil
}
func GetConsensusParams(ctx sdk.Context, paramStore LegacyParamStore) *tmproto.ConsensusParams {
if paramStore == nil {
return nil
}
cp := new(tmproto.ConsensusParams)
if paramStore.Has(ctx, ParamStoreKeyBlockParams) {
var bp tmproto.BlockParams
paramStore.Get(ctx, ParamStoreKeyBlockParams, &bp)
cp.Block = &bp
}
if paramStore.Has(ctx, ParamStoreKeyEvidenceParams) {
var ep tmproto.EvidenceParams
paramStore.Get(ctx, ParamStoreKeyEvidenceParams, &ep)
cp.Evidence = &ep
}
if paramStore.Has(ctx, ParamStoreKeyValidatorParams) {
var vp tmproto.ValidatorParams
paramStore.Get(ctx, ParamStoreKeyValidatorParams, &vp)
cp.Validator = &vp
}
return cp
}
func MigrateParams(ctx sdk.Context, lps LegacyParamStore, ps ParamStore) {
if cp := GetConsensusParams(ctx, lps); cp != nil {
ps.Set(ctx, cp)
} else {
ctx.Logger().Info("warning: consensus parameters are undefined; skipping migration")
}
}

View File

@ -1,65 +0,0 @@
package baseapp_test
import (
"testing"
"github.com/stretchr/testify/require"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
"github.com/cosmos/cosmos-sdk/baseapp"
)
func TestValidateBlockParams(t *testing.T) {
testCases := []struct {
arg interface{}
expectErr bool
}{
{nil, true},
{&tmproto.BlockParams{}, true},
{tmproto.BlockParams{}, true},
{tmproto.BlockParams{MaxBytes: -1, MaxGas: -1}, true},
{tmproto.BlockParams{MaxBytes: 2000000, MaxGas: -5}, true},
{tmproto.BlockParams{MaxBytes: 2000000, MaxGas: 300000}, false},
}
for _, tc := range testCases {
require.Equal(t, tc.expectErr, baseapp.ValidateBlockParams(tc.arg) != nil)
}
}
func TestValidateEvidenceParams(t *testing.T) {
testCases := []struct {
arg interface{}
expectErr bool
}{
{nil, true},
{&tmproto.EvidenceParams{}, true},
{tmproto.EvidenceParams{}, true},
{tmproto.EvidenceParams{MaxAgeNumBlocks: -1, MaxAgeDuration: 18004000, MaxBytes: 5000000}, true},
{tmproto.EvidenceParams{MaxAgeNumBlocks: 360000, MaxAgeDuration: -1, MaxBytes: 5000000}, true},
{tmproto.EvidenceParams{MaxAgeNumBlocks: 360000, MaxAgeDuration: 18004000, MaxBytes: -1}, true},
{tmproto.EvidenceParams{MaxAgeNumBlocks: 360000, MaxAgeDuration: 18004000, MaxBytes: 5000000}, false},
{tmproto.EvidenceParams{MaxAgeNumBlocks: 360000, MaxAgeDuration: 18004000, MaxBytes: 0}, false},
}
for _, tc := range testCases {
require.Equal(t, tc.expectErr, baseapp.ValidateEvidenceParams(tc.arg) != nil)
}
}
func TestValidateValidatorParams(t *testing.T) {
testCases := []struct {
arg interface{}
expectErr bool
}{
{nil, true},
{&tmproto.ValidatorParams{}, true},
{tmproto.ValidatorParams{}, true},
{tmproto.ValidatorParams{PubKeyTypes: []string{}}, true},
{tmproto.ValidatorParams{PubKeyTypes: []string{"secp256k1"}}, false},
}
for _, tc := range testCases {
require.Equal(t, tc.expectErr, baseapp.ValidateValidatorParams(tc.arg) != nil)
}
}

View File

@ -11,6 +11,7 @@ import (
appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1"
authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1"
bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1"
consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1"
mintmodulev1 "cosmossdk.io/api/cosmos/mint/module/v1"
paramsmodulev1 "cosmossdk.io/api/cosmos/params/module/v1"
stakingmodulev1 "cosmossdk.io/api/cosmos/staking/module/v1"
@ -28,6 +29,7 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
_ "github.com/cosmos/cosmos-sdk/x/bank"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
_ "github.com/cosmos/cosmos-sdk/x/consensus"
_ "github.com/cosmos/cosmos-sdk/x/mint"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
_ "github.com/cosmos/cosmos-sdk/x/params"
@ -79,6 +81,7 @@ func makeTestConfig() depinject.Config {
"auth",
"bank",
"params",
"consensus",
},
EndBlockers: []string{
"staking",
@ -86,6 +89,7 @@ func makeTestConfig() depinject.Config {
"bank",
"mint",
"params",
"consensus",
},
OverrideStoreKeys: []*runtimev1alpha1.StoreKeyConfig{
{
@ -99,6 +103,7 @@ func makeTestConfig() depinject.Config {
"staking",
"mint",
"params",
"consensus",
},
}),
},
@ -130,6 +135,10 @@ func makeTestConfig() depinject.Config {
Name: "mint",
Config: appconfig.WrapAny(&mintmodulev1.Module{}),
},
{
Name: "consensus",
Config: appconfig.WrapAny(&consensusmodulev1.Module{}),
},
{
Name: "tx",
Config: appconfig.WrapAny(&txmodulev1.Module{}),

View File

@ -45,7 +45,7 @@ sleep 10
# send transaction to deterministic address
echo sending transaction with addr $addr
simd tx bank send "$addr" cosmos19g9cm8ymzchq2qkcdv3zgqtwayj9asv3hjv5u5 100stake --yes --keyring-backend=test --broadcast-mode=block --chain-id=testing
simd tx bank send "$addr" cosmos19g9cm8ymzchq2qkcdv3zgqtwayj9asv3hjv5u5 100stake --yes --keyring-backend=test --chain-id=testing
sleep 10

View File

@ -45,6 +45,9 @@ import (
"github.com/cosmos/cosmos-sdk/x/capability"
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
consensus "github.com/cosmos/cosmos-sdk/x/consensus"
consensuskeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
"github.com/cosmos/cosmos-sdk/x/crisis"
crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
@ -120,6 +123,7 @@ var (
groupmodule.AppModuleBasic{},
vesting.AppModuleBasic{},
nftmodule.AppModuleBasic{},
consensus.AppModuleBasic{},
)
)
@ -142,22 +146,23 @@ type SimApp struct {
keys map[string]*storetypes.KVStoreKey
// keepers
AccountKeeper authkeeper.AccountKeeper
BankKeeper bankkeeper.Keeper
CapabilityKeeper *capabilitykeeper.Keeper
StakingKeeper *stakingkeeper.Keeper
SlashingKeeper slashingkeeper.Keeper
MintKeeper mintkeeper.Keeper
DistrKeeper distrkeeper.Keeper
GovKeeper *govkeeper.Keeper
CrisisKeeper *crisiskeeper.Keeper
UpgradeKeeper upgradekeeper.Keeper
ParamsKeeper paramskeeper.Keeper
AuthzKeeper authzkeeper.Keeper
EvidenceKeeper evidencekeeper.Keeper
FeeGrantKeeper feegrantkeeper.Keeper
GroupKeeper groupkeeper.Keeper
NFTKeeper nftkeeper.Keeper
AccountKeeper authkeeper.AccountKeeper
BankKeeper bankkeeper.Keeper
CapabilityKeeper *capabilitykeeper.Keeper
StakingKeeper *stakingkeeper.Keeper
SlashingKeeper slashingkeeper.Keeper
MintKeeper mintkeeper.Keeper
DistrKeeper distrkeeper.Keeper
GovKeeper *govkeeper.Keeper
CrisisKeeper *crisiskeeper.Keeper
UpgradeKeeper upgradekeeper.Keeper
ParamsKeeper paramskeeper.Keeper
AuthzKeeper authzkeeper.Keeper
EvidenceKeeper evidencekeeper.Keeper
FeeGrantKeeper feegrantkeeper.Keeper
GroupKeeper groupkeeper.Keeper
NFTKeeper nftkeeper.Keeper
ConsensusParamsKeeper consensuskeeper.Keeper
// simulation manager
sm *module.SimulationManager
@ -192,10 +197,13 @@ func NewSimApp(
// supply the application options
appOpts,
// for providing a custom inflaction function for x/mint
// add here your custom function that implements the minttypes.InflationCalculationFn interface.
// For providing a custom inflation function for x/mint add here your
// custom function that implements the minttypes.InflationCalculationFn
// interface.
// for providing a custom authority to a module simply add it below. By default the governance module is the default authority.
// For providing a custom authority to a module simply add it below. By
// default the governance module is the default authority.
//
// map[string]sdk.AccAddress{
// minttypes.ModuleName: authtypes.NewModuleAddress(authtypes.ModuleName),
// },
@ -225,6 +233,7 @@ func NewSimApp(
&app.FeeGrantKeeper,
&app.GroupKeeper,
&app.NFTKeeper,
&app.ConsensusParamsKeeper,
); err != nil {
panic(err)
}
@ -254,7 +263,7 @@ func NewSimApp(
distrtypes.ModuleName, stakingtypes.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName,
minttypes.ModuleName, crisistypes.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName,
feegrant.ModuleName, nft.ModuleName, group.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName,
vestingtypes.ModuleName,
vestingtypes.ModuleName, consensustypes.ModuleName,
}
app.ModuleManager.SetOrderInitGenesis(genesisModuleOrder...)
app.ModuleManager.SetOrderExportGenesis(genesisModuleOrder...)

View File

@ -9,6 +9,7 @@ import (
authzmodulev1 "cosmossdk.io/api/cosmos/authz/module/v1"
bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1"
capabilitymodulev1 "cosmossdk.io/api/cosmos/capability/module/v1"
consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1"
crisismodulev1 "cosmossdk.io/api/cosmos/crisis/module/v1"
distrmodulev1 "cosmossdk.io/api/cosmos/distribution/module/v1"
evidencemodulev1 "cosmossdk.io/api/cosmos/evidence/module/v1"
@ -32,6 +33,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/authz"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
@ -102,6 +104,7 @@ var (
group.ModuleName,
paramstypes.ModuleName,
vestingtypes.ModuleName,
consensustypes.ModuleName,
},
EndBlockers: []string{
crisistypes.ModuleName,
@ -120,6 +123,7 @@ var (
nft.ModuleName,
group.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
},
@ -217,6 +221,10 @@ var (
Name: crisistypes.ModuleName,
Config: appconfig.WrapAny(&crisismodulev1.Module{}),
},
{
Name: consensustypes.ModuleName,
Config: appconfig.WrapAny(&consensusmodulev1.Module{}),
},
},
})
)

View File

@ -51,6 +51,8 @@ import (
"github.com/cosmos/cosmos-sdk/x/capability"
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
"github.com/cosmos/cosmos-sdk/x/crisis"
crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
@ -166,22 +168,23 @@ type SimApp struct {
memKeys map[string]*storetypes.MemoryStoreKey
// keepers
AccountKeeper authkeeper.AccountKeeper
BankKeeper bankkeeper.Keeper
CapabilityKeeper *capabilitykeeper.Keeper
StakingKeeper *stakingkeeper.Keeper
SlashingKeeper slashingkeeper.Keeper
MintKeeper mintkeeper.Keeper
DistrKeeper distrkeeper.Keeper
GovKeeper govkeeper.Keeper
CrisisKeeper *crisiskeeper.Keeper
UpgradeKeeper upgradekeeper.Keeper
ParamsKeeper paramskeeper.Keeper
AuthzKeeper authzkeeper.Keeper
EvidenceKeeper evidencekeeper.Keeper
FeeGrantKeeper feegrantkeeper.Keeper
GroupKeeper groupkeeper.Keeper
NFTKeeper nftkeeper.Keeper
AccountKeeper authkeeper.AccountKeeper
BankKeeper bankkeeper.Keeper
CapabilityKeeper *capabilitykeeper.Keeper
StakingKeeper *stakingkeeper.Keeper
SlashingKeeper slashingkeeper.Keeper
MintKeeper mintkeeper.Keeper
DistrKeeper distrkeeper.Keeper
GovKeeper govkeeper.Keeper
CrisisKeeper *crisiskeeper.Keeper
UpgradeKeeper upgradekeeper.Keeper
ParamsKeeper paramskeeper.Keeper
AuthzKeeper authzkeeper.Keeper
EvidenceKeeper evidencekeeper.Keeper
FeeGrantKeeper feegrantkeeper.Keeper
GroupKeeper groupkeeper.Keeper
NFTKeeper nftkeeper.Keeper
ConsensusParamsKeeper consensusparamkeeper.Keeper
// the module manager
ModuleManager *module.Manager
@ -226,7 +229,7 @@ func NewSimApp(
keys := sdk.NewKVStoreKeys(
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, crisistypes.StoreKey,
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, consensusparamtypes.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey,
evidencetypes.StoreKey, capabilitytypes.StoreKey,
authzkeeper.StoreKey, nftkeeper.StoreKey, group.StoreKey,
)
@ -257,7 +260,8 @@ func NewSimApp(
app.ParamsKeeper = initParamsKeeper(appCodec, legacyAmino, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey])
// set the BaseApp's parameter store
bApp.SetParamStore(app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable()))
app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, keys[upgradetypes.StoreKey], authtypes.NewModuleAddress(govtypes.ModuleName).String())
bApp.SetParamStore(&app.ConsensusParamsKeeper)
app.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey])
// Applications that wish to enforce statically created ScopedKeepers should call `Seal` after creating
@ -339,7 +343,7 @@ func NewSimApp(
),
)
// RegisterUpgradeHandlers is used for registering any on-chain upgrades
// RegisterUpgradeHandlers is used for registering any on-chain upgrades.
app.RegisterUpgradeHandlers()
app.NFTKeeper = nftkeeper.NewKeeper(keys[nftkeeper.StoreKey], appCodec, app.AccountKeeper, app.BankKeeper)

View File

@ -1,25 +1,35 @@
package simapp
import (
"github.com/cosmos/cosmos-sdk/baseapp"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/group"
"github.com/cosmos/cosmos-sdk/x/nft"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)
// UpgradeName defines the on-chain upgrade name for the sample simap upgrade from v045 to v046.
// UpgradeName defines the on-chain upgrade name for the sample SimApp upgrade
// from v046 to v047.
//
// NOTE: This upgrade defines a reference implementation of what an upgrade could look like
// when an application is migrating from Cosmos SDK version v0.45.x to v0.46.x.
const UpgradeName = "v045-to-v046"
// NOTE: This upgrade defines a reference implementation of what an upgrade
// could look like when an application is migrating from Cosmos SDK version
// v0.46.x to v0.47.x.
const UpgradeName = "v046-to-v047"
func (app SimApp) RegisterUpgradeHandlers() {
app.UpgradeKeeper.SetUpgradeHandler(UpgradeName,
func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
baseAppLegacySS := app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable())
app.UpgradeKeeper.SetUpgradeHandler(
UpgradeName,
func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// Migrate Tendermint consensus parameters from x/params module to a
// dedicated x/consensus module.
baseapp.MigrateParams(ctx, baseAppLegacySS, &app.ConsensusParamsKeeper)
return app.ModuleManager.RunMigrations(ctx, app.Configurator(), fromVM)
})
},
)
upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
@ -27,12 +37,7 @@ func (app SimApp) RegisterUpgradeHandlers() {
}
if upgradeInfo.Name == UpgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := storetypes.StoreUpgrades{
Added: []string{
group.ModuleName,
nft.ModuleName,
},
}
storeUpgrades := storetypes.StoreUpgrades{}
// configure store loader that checks if version == upgradeHeight and applies store upgrades
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))

View File

@ -44,6 +44,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
configurator.GenutilModule(),
configurator.StakingModule(),
configurator.GovModule(),
configurator.ConsensusModule(),
configurator.TxModule())
cfg, err := network.DefaultConfigWithAppConfig(appConfig)

View File

@ -130,6 +130,7 @@ func (suite *IntegrationTestSuite) SetupTest() {
configurator.BankModule(),
configurator.StakingModule(),
configurator.ParamsModule(),
configurator.ConsensusModule(),
configurator.VestingModule()),
&suite.accountKeeper, &suite.bankKeeper, &suite.stakingKeeper,
&interfaceRegistry, &suite.appCodec, &suite.authConfig)

View File

@ -26,6 +26,7 @@ import (
_ "github.com/cosmos/cosmos-sdk/x/bank"
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
_ "github.com/cosmos/cosmos-sdk/x/consensus"
"github.com/cosmos/cosmos-sdk/x/genutil"
"github.com/cosmos/cosmos-sdk/x/genutil/types"
_ "github.com/cosmos/cosmos-sdk/x/params"
@ -67,6 +68,7 @@ func (suite *GenTxTestSuite) SetupTest() {
configurator.TxModule(),
configurator.StakingModule(),
configurator.ParamsModule(),
configurator.ConsensusModule(),
configurator.AuthModule()),
simtestutil.DefaultStartUpConfig(),
&encCfg.InterfaceRegistry, &encCfg.Codec, &encCfg.TxConfig, &encCfg.Amino,

View File

@ -19,6 +19,7 @@ import (
_ "github.com/cosmos/cosmos-sdk/x/bank"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
_ "github.com/cosmos/cosmos-sdk/x/consensus"
_ "github.com/cosmos/cosmos-sdk/x/distribution"
distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
@ -51,6 +52,7 @@ var appConfig = configurator.NewAppConfig(
configurator.GovModule(),
configurator.DistributionModule(),
configurator.MintModule(),
configurator.ConsensusModule(),
)
func TestImportExportQueues(t *testing.T) {

View File

@ -5,6 +5,7 @@ import (
appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1"
authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1"
bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1"
consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1"
distrmodulev1 "cosmossdk.io/api/cosmos/distribution/module/v1"
feegrantmodulev1 "cosmossdk.io/api/cosmos/feegrant/module/v1"
genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1"
@ -37,6 +38,7 @@ var beginBlockOrder = []string{
"nft",
"group",
"params",
"consensus",
"vesting",
}
@ -57,6 +59,7 @@ var endBlockersOrder = []string{
"nft",
"group",
"params",
"consensus",
"upgrade",
"vesting",
}
@ -78,6 +81,7 @@ var initGenesisOrder = []string{
"nft",
"group",
"params",
"consensus",
"upgrade",
"vesting",
}
@ -198,6 +202,15 @@ func GovModule() ModuleOption {
}
}
func ConsensusModule() ModuleOption {
return func(config *appConfig) {
config.moduleConfigs["consensus"] = &appv1alpha1.ModuleConfig{
Name: "consensus",
Config: appconfig.WrapAny(&consensusmodulev1.Module{}),
}
}
}
func MintModule() ModuleOption {
return func(config *appConfig) {
config.moduleConfigs["mint"] = &appv1alpha1.ModuleConfig{

View File

@ -50,6 +50,7 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
_ "github.com/cosmos/cosmos-sdk/x/bank"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
_ "github.com/cosmos/cosmos-sdk/x/consensus"
"github.com/cosmos/cosmos-sdk/x/genutil"
_ "github.com/cosmos/cosmos-sdk/x/params"
_ "github.com/cosmos/cosmos-sdk/x/staking"
@ -140,6 +141,7 @@ func MinimumAppConfig() depinject.Config {
configurator.BankModule(),
configurator.GenutilModule(),
configurator.StakingModule(),
configurator.ConsensusModule(),
configurator.TxModule())
}

View File

@ -26,6 +26,7 @@ import (
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
"github.com/cosmos/cosmos-sdk/x/bank/types"
_ "github.com/cosmos/cosmos-sdk/x/consensus"
_ "github.com/cosmos/cosmos-sdk/x/params"
)
@ -67,6 +68,7 @@ func (s *paginationTestSuite) SetupTest() {
configurator.AuthModule(),
configurator.BankModule(),
configurator.ParamsModule(),
configurator.ConsensusModule(),
configurator.OmitInitGenesis(),
),
&bankKeeper, &accountKeeper, &reg, &cdc)

View File

@ -5,6 +5,7 @@ import (
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/module"
_ "github.com/cosmos/cosmos-sdk/x/auth/vesting"
_ "github.com/cosmos/cosmos-sdk/x/bank"
_ "github.com/cosmos/cosmos-sdk/x/consensus"
_ "github.com/cosmos/cosmos-sdk/x/feegrant/module"
_ "github.com/cosmos/cosmos-sdk/x/genutil"
_ "github.com/cosmos/cosmos-sdk/x/params"
@ -14,6 +15,7 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
"github.com/cosmos/cosmos-sdk/x/feegrant"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
@ -24,6 +26,7 @@ import (
appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1"
authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1"
bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1"
consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1"
feegrantmodulev1 "cosmossdk.io/api/cosmos/feegrant/module/v1"
genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1"
paramsmodulev1 "cosmossdk.io/api/cosmos/params/module/v1"
@ -45,6 +48,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
genutiltypes.ModuleName,
feegrant.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
vestingtypes.ModuleName,
},
EndBlockers: []string{
@ -54,6 +58,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
genutiltypes.ModuleName,
feegrant.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
vestingtypes.ModuleName,
},
InitGenesis: []string{
@ -63,6 +68,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
genutiltypes.ModuleName,
feegrant.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
vestingtypes.ModuleName,
},
}),
@ -97,6 +103,10 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
Name: paramstypes.ModuleName,
Config: appconfig.WrapAny(&paramsmodulev1.Module{}),
},
{
Name: consensustypes.ModuleName,
Config: appconfig.WrapAny(&consensusmodulev1.Module{}),
},
{
Name: "tx",
Config: appconfig.WrapAny(&txmodulev1.Module{}),

View File

@ -5,6 +5,7 @@ import (
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/module"
_ "github.com/cosmos/cosmos-sdk/x/authz/module"
_ "github.com/cosmos/cosmos-sdk/x/bank"
_ "github.com/cosmos/cosmos-sdk/x/consensus"
_ "github.com/cosmos/cosmos-sdk/x/genutil"
_ "github.com/cosmos/cosmos-sdk/x/gov"
_ "github.com/cosmos/cosmos-sdk/x/mint"
@ -15,6 +16,7 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/authz"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
@ -26,6 +28,7 @@ import (
authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1"
authzmodulev1 "cosmossdk.io/api/cosmos/authz/module/v1"
bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1"
consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1"
genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1"
mintmodulev1 "cosmossdk.io/api/cosmos/mint/module/v1"
paramsmodulev1 "cosmossdk.io/api/cosmos/params/module/v1"
@ -47,6 +50,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
genutiltypes.ModuleName,
authz.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
},
EndBlockers: []string{
minttypes.ModuleName,
@ -56,6 +60,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
genutiltypes.ModuleName,
authz.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
},
InitGenesis: []string{
authtypes.ModuleName,
@ -65,6 +70,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
genutiltypes.ModuleName,
authz.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
},
}),
},
@ -101,6 +107,10 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
Name: genutiltypes.ModuleName,
Config: appconfig.WrapAny(&genutilmodulev1.Module{}),
},
{
Name: consensustypes.ModuleName,
Config: appconfig.WrapAny(&consensusmodulev1.Module{}),
},
{
Name: authz.ModuleName,
Config: appconfig.WrapAny(&authzmodulev1.Module{}),

View File

@ -21,6 +21,7 @@ import (
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
"github.com/cosmos/cosmos-sdk/x/bank/types"
_ "github.com/cosmos/cosmos-sdk/x/consensus"
_ "github.com/cosmos/cosmos-sdk/x/gov"
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
_ "github.com/cosmos/cosmos-sdk/x/params"
@ -109,6 +110,7 @@ func createTestSuite(t *testing.T, genesisAccounts []authtypes.GenesisAccount) s
configurator.AuthModule(),
configurator.StakingModule(),
configurator.TxModule(),
configurator.ConsensusModule(),
configurator.BankModule(),
configurator.GovModule(),
),

View File

@ -21,6 +21,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/bank/simulation"
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
"github.com/cosmos/cosmos-sdk/x/bank/types"
_ "github.com/cosmos/cosmos-sdk/x/consensus"
_ "github.com/cosmos/cosmos-sdk/x/params"
_ "github.com/cosmos/cosmos-sdk/x/staking"
)
@ -45,6 +46,7 @@ func (suite *SimTestSuite) SetupTest() {
configurator.ParamsModule(),
configurator.BankModule(),
configurator.StakingModule(),
configurator.ConsensusModule(),
configurator.TxModule(),
), &suite.accountKeeper, &suite.bankKeeper, &suite.cdc, &appBuilder)

View File

@ -5,6 +5,7 @@ import (
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/module"
_ "github.com/cosmos/cosmos-sdk/x/bank"
_ "github.com/cosmos/cosmos-sdk/x/capability"
_ "github.com/cosmos/cosmos-sdk/x/consensus"
_ "github.com/cosmos/cosmos-sdk/x/genutil"
_ "github.com/cosmos/cosmos-sdk/x/params"
_ "github.com/cosmos/cosmos-sdk/x/staking"
@ -13,6 +14,7 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
@ -22,6 +24,7 @@ import (
authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1"
bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1"
capabilitymodulev1 "cosmossdk.io/api/cosmos/capability/module/v1"
consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1"
genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1"
paramsmodulev1 "cosmossdk.io/api/cosmos/params/module/v1"
stakingmodulev1 "cosmossdk.io/api/cosmos/staking/module/v1"
@ -41,6 +44,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
banktypes.ModuleName,
genutiltypes.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
},
EndBlockers: []string{
stakingtypes.ModuleName,
@ -49,6 +53,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
banktypes.ModuleName,
genutiltypes.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
},
InitGenesis: []string{
capabilitytypes.ModuleName,
@ -57,6 +62,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
stakingtypes.ModuleName,
genutiltypes.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
},
}),
},
@ -91,6 +97,10 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
Name: genutiltypes.ModuleName,
Config: appconfig.WrapAny(&genutilmodulev1.Module{}),
},
{
Name: consensustypes.ModuleName,
Config: appconfig.WrapAny(&consensusmodulev1.Module{}),
},
{
Name: capabilitytypes.ModuleName,
Config: appconfig.WrapAny(&capabilitymodulev1.Module{

View File

@ -1,10 +1,11 @@
package keeper_test
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/consensus/types"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmtypes "github.com/tendermint/tendermint/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/consensus/types"
)
func (s *KeeperTestSuite) TestGRPCQueryConsensusParams() {

View File

@ -3,6 +3,9 @@ package keeper_test
import (
"testing"
"github.com/stretchr/testify/suite"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -11,9 +14,6 @@ import (
consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
"github.com/stretchr/testify/suite"
)
type KeeperTestSuite struct {

View File

@ -34,6 +34,7 @@ func (k msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParam
if err := types.Validate(tmtypes.ConsensusParamsFromProto(consensusParams)); err != nil {
return nil, err
}
k.Set(ctx, &consensusParams)
ctx.EventManager().EmitEvent(

View File

@ -4,14 +4,14 @@ import (
"context"
"encoding/json"
modulev1 "cosmossdk.io/api/cosmos/consensus/module/v1"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/depinject"
gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"
abci "github.com/tendermint/tendermint/abci/types"
modulev1 "cosmossdk.io/api/cosmos/consensus/module/v1"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
@ -20,7 +20,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/consensus/exported"
"github.com/cosmos/cosmos-sdk/x/consensus/keeper"
"github.com/cosmos/cosmos-sdk/x/consensus/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
@ -84,9 +83,6 @@ type AppModule struct {
AppModuleBasic
keeper keeper.Keeper
// legacySubspace is used solely for migration of x/params managed parameters
legacySubspace exported.ParamStore
}
// RegisterServices registers module services.
@ -96,11 +92,10 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
}
// NewAppModule creates a new AppModule object
func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ss exported.ParamStore) AppModule {
func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule {
return AppModule{
AppModuleBasic: AppModuleBasic{cdc: cdc},
keeper: keeper,
legacySubspace: ss,
}
}
@ -143,9 +138,6 @@ type consensusParamInputs struct {
Key *store.KVStoreKey
ModuleKey depinject.OwnModuleKey
Authority map[string]sdk.AccAddress `optional:"true"`
// LegacySubspace is used solely for migration of x/params managed parameters
LegacySubspace exported.ParamStore
}
type consensusParamOutputs struct {
@ -164,14 +156,14 @@ func provideModule(in consensusParamInputs) consensusParamOutputs {
}
k := keeper.NewKeeper(in.Cdc, in.Key, authority.String())
m := NewAppModule(in.Cdc, k, in.LegacySubspace)
// baseappOpt := func(app *baseapp.BaseApp) {
// app.SetParamStore(&k)
// }
m := NewAppModule(in.Cdc, k)
baseappOpt := func(app *baseapp.BaseApp) {
app.SetParamStore(&k)
}
return consensusParamOutputs{
Keeper: k,
Module: runtime.WrapAppModule(m),
// BaseAppOption: baseappOpt,
Keeper: k,
Module: runtime.WrapAppModule(m),
BaseAppOption: baseappOpt,
}
}

View File

@ -1,8 +1,10 @@
package types
const (
// ModuleName defines the name of the x/consensus module.
ModuleName = "consensus"
// StoreKey defines the module's store key.
StoreKey = ModuleName
)

View File

@ -1,9 +1,10 @@
package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmtypes "github.com/tendermint/tendermint/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// bank message types

View File

@ -4,7 +4,8 @@ import (
tmtypes "github.com/tendermint/tendermint/types"
)
// Validate all module parameters
// Validate performs basic validation of ConsensusParams returning an error upon
// failure.
func Validate(p tmtypes.ConsensusParams) error {
return p.ValidateBasic()
}

View File

@ -4,7 +4,7 @@ import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
// x/consensus_param module sentinel errors
// Sentinel errors for the x/consensus module.
var (
ErrUnauthorized = sdkerrors.Register(ModuleName, 2, "unauthorized action")
)

View File

@ -245,6 +245,7 @@ func (suite *SimTestSuite) SetupTest() {
configurator.BankModule(),
configurator.StakingModule(),
configurator.TxModule(),
configurator.ConsensusModule(),
configurator.DistributionModule(),
), &suite.accountKeeper,
&suite.bankKeeper,

View File

@ -4,6 +4,7 @@ import (
_ "github.com/cosmos/cosmos-sdk/x/auth"
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/module"
_ "github.com/cosmos/cosmos-sdk/x/bank"
_ "github.com/cosmos/cosmos-sdk/x/consensus"
_ "github.com/cosmos/cosmos-sdk/x/distribution"
_ "github.com/cosmos/cosmos-sdk/x/genutil"
_ "github.com/cosmos/cosmos-sdk/x/mint"
@ -13,6 +14,7 @@ import (
"cosmossdk.io/core/appconfig"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
@ -23,6 +25,7 @@ import (
appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1"
authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1"
bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1"
consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1"
distrmodulev1 "cosmossdk.io/api/cosmos/distribution/module/v1"
genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1"
mintmodulev1 "cosmossdk.io/api/cosmos/mint/module/v1"
@ -45,6 +48,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
banktypes.ModuleName,
genutiltypes.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
},
EndBlockers: []string{
stakingtypes.ModuleName,
@ -54,6 +58,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
minttypes.ModuleName,
genutiltypes.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
},
InitGenesis: []string{
authtypes.ModuleName,
@ -63,6 +68,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
minttypes.ModuleName,
genutiltypes.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
},
}),
},
@ -91,6 +97,10 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
Name: paramstypes.ModuleName,
Config: appconfig.WrapAny(&paramsmodulev1.Module{}),
},
{
Name: consensustypes.ModuleName,
Config: appconfig.WrapAny(&consensusmodulev1.Module{}),
},
{
Name: "tx",
Config: appconfig.WrapAny(&txmodulev1.Module{}),

View File

@ -4,6 +4,7 @@ import (
_ "github.com/cosmos/cosmos-sdk/x/auth"
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/module"
_ "github.com/cosmos/cosmos-sdk/x/bank"
_ "github.com/cosmos/cosmos-sdk/x/consensus"
_ "github.com/cosmos/cosmos-sdk/x/evidence"
_ "github.com/cosmos/cosmos-sdk/x/genutil"
_ "github.com/cosmos/cosmos-sdk/x/params"
@ -13,6 +14,7 @@ import (
"cosmossdk.io/core/appconfig"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
@ -24,6 +26,7 @@ import (
appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1"
authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1"
bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1"
consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1"
evidencemodulev1 "cosmossdk.io/api/cosmos/evidence/module/v1"
genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1"
paramsmodulev1 "cosmossdk.io/api/cosmos/params/module/v1"
@ -46,6 +49,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
banktypes.ModuleName,
genutiltypes.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
},
EndBlockers: []string{
stakingtypes.ModuleName,
@ -55,6 +59,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
genutiltypes.ModuleName,
evidencetypes.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
},
InitGenesis: []string{
authtypes.ModuleName,
@ -64,6 +69,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
genutiltypes.ModuleName,
evidencetypes.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
},
}),
},
@ -95,6 +101,10 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
Name: paramstypes.ModuleName,
Config: appconfig.WrapAny(&paramsmodulev1.Module{}),
},
{
Name: consensustypes.ModuleName,
Config: appconfig.WrapAny(&consensusmodulev1.Module{}),
},
{
Name: "tx",
Config: appconfig.WrapAny(&txmodulev1.Module{}),

View File

@ -5,6 +5,7 @@ import (
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/module"
_ "github.com/cosmos/cosmos-sdk/x/auth/vesting"
_ "github.com/cosmos/cosmos-sdk/x/bank"
_ "github.com/cosmos/cosmos-sdk/x/consensus"
_ "github.com/cosmos/cosmos-sdk/x/feegrant/module"
_ "github.com/cosmos/cosmos-sdk/x/genutil"
_ "github.com/cosmos/cosmos-sdk/x/mint"
@ -15,6 +16,7 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
"github.com/cosmos/cosmos-sdk/x/feegrant"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
@ -25,6 +27,7 @@ import (
appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1"
authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1"
bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1"
consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1"
feegrantmodulev1 "cosmossdk.io/api/cosmos/feegrant/module/v1"
genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1"
paramsmodulev1 "cosmossdk.io/api/cosmos/params/module/v1"
@ -47,6 +50,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
feegrant.ModuleName,
paramstypes.ModuleName,
vestingtypes.ModuleName,
consensustypes.ModuleName,
},
EndBlockers: []string{
stakingtypes.ModuleName,
@ -56,6 +60,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
feegrant.ModuleName,
paramstypes.ModuleName,
vestingtypes.ModuleName,
consensustypes.ModuleName,
},
InitGenesis: []string{
authtypes.ModuleName,
@ -65,6 +70,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
feegrant.ModuleName,
paramstypes.ModuleName,
vestingtypes.ModuleName,
consensustypes.ModuleName,
},
}),
},
@ -96,6 +102,10 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
Name: paramstypes.ModuleName,
Config: appconfig.WrapAny(&paramsmodulev1.Module{}),
},
{
Name: consensustypes.ModuleName,
Config: appconfig.WrapAny(&consensusmodulev1.Module{}),
},
{
Name: "tx",
Config: appconfig.WrapAny(&txmodulev1.Module{}),

View File

@ -18,6 +18,7 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
_ "github.com/cosmos/cosmos-sdk/x/bank"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
_ "github.com/cosmos/cosmos-sdk/x/consensus"
"github.com/cosmos/cosmos-sdk/x/gov/keeper"
"github.com/cosmos/cosmos-sdk/x/gov/types"
v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
@ -116,6 +117,7 @@ func createTestSuite(t *testing.T) suite {
configurator.StakingModule(),
configurator.BankModule(),
configurator.GovModule(),
configurator.ConsensusModule(),
),
simtestutil.DefaultStartUpConfig(),
&res.AccountKeeper, &res.BankKeeper, &res.GovKeeper, &res.StakingKeeper,

View File

@ -22,6 +22,7 @@ import (
_ "github.com/cosmos/cosmos-sdk/x/bank"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
_ "github.com/cosmos/cosmos-sdk/x/consensus"
govcodec "github.com/cosmos/cosmos-sdk/x/gov/codec"
"github.com/cosmos/cosmos-sdk/x/gov/keeper"
"github.com/cosmos/cosmos-sdk/x/gov/simulation"
@ -297,6 +298,7 @@ func createTestSuite(t *testing.T, isCheckTx bool) (suite, sdk.Context) {
configurator.ParamsModule(),
configurator.BankModule(),
configurator.StakingModule(),
configurator.ConsensusModule(),
configurator.GovModule(),
), &res.AccountKeeper, &res.BankKeeper, &res.GovKeeper, &res.StakingKeeper, &res.cdc)
require.NoError(t, err)

View File

@ -9,6 +9,7 @@ import (
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/module"
_ "github.com/cosmos/cosmos-sdk/x/authz"
_ "github.com/cosmos/cosmos-sdk/x/bank"
_ "github.com/cosmos/cosmos-sdk/x/consensus"
_ "github.com/cosmos/cosmos-sdk/x/genutil"
_ "github.com/cosmos/cosmos-sdk/x/group/module"
_ "github.com/cosmos/cosmos-sdk/x/mint"
@ -18,6 +19,7 @@ import (
"cosmossdk.io/core/appconfig"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
"github.com/cosmos/cosmos-sdk/x/group"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
@ -28,6 +30,7 @@ import (
appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1"
authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1"
bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1"
consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1"
genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1"
groupmodulev1 "cosmossdk.io/api/cosmos/group/module/v1"
paramsmodulev1 "cosmossdk.io/api/cosmos/params/module/v1"
@ -49,6 +52,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
genutiltypes.ModuleName,
group.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
},
EndBlockers: []string{
stakingtypes.ModuleName,
@ -58,6 +62,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
genutiltypes.ModuleName,
group.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
},
InitGenesis: []string{
authtypes.ModuleName,
@ -67,6 +72,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
genutiltypes.ModuleName,
group.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
},
}),
},
@ -94,6 +100,10 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
Name: paramstypes.ModuleName,
Config: appconfig.WrapAny(&paramsmodulev1.Module{}),
},
{
Name: consensustypes.ModuleName,
Config: appconfig.WrapAny(&consensusmodulev1.Module{}),
},
{
Name: "tx",
Config: appconfig.WrapAny(&txmodulev1.Module{}),

View File

@ -5,6 +5,7 @@ import (
_ "github.com/cosmos/cosmos-sdk/x/auth"
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/module"
_ "github.com/cosmos/cosmos-sdk/x/bank"
_ "github.com/cosmos/cosmos-sdk/x/consensus"
_ "github.com/cosmos/cosmos-sdk/x/genutil"
_ "github.com/cosmos/cosmos-sdk/x/mint"
_ "github.com/cosmos/cosmos-sdk/x/params"
@ -12,6 +13,7 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
@ -21,6 +23,7 @@ import (
appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1"
authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1"
bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1"
consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1"
genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1"
mintmodulev1 "cosmossdk.io/api/cosmos/mint/module/v1"
paramsmodulev1 "cosmossdk.io/api/cosmos/params/module/v1"
@ -41,6 +44,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
banktypes.ModuleName,
genutiltypes.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
},
EndBlockers: []string{
stakingtypes.ModuleName,
@ -49,6 +53,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
minttypes.ModuleName,
genutiltypes.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
},
InitGenesis: []string{
authtypes.ModuleName,
@ -57,6 +62,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
minttypes.ModuleName,
genutiltypes.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
},
}),
},
@ -84,6 +90,10 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
Name: paramstypes.ModuleName,
Config: appconfig.WrapAny(&paramsmodulev1.Module{}),
},
{
Name: consensustypes.ModuleName,
Config: appconfig.WrapAny(&consensusmodulev1.Module{}),
},
{
Name: "tx",
Config: appconfig.WrapAny(&txmodulev1.Module{}),

View File

@ -5,6 +5,7 @@ import (
_ "github.com/cosmos/cosmos-sdk/x/auth"
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/module"
_ "github.com/cosmos/cosmos-sdk/x/bank"
_ "github.com/cosmos/cosmos-sdk/x/consensus"
_ "github.com/cosmos/cosmos-sdk/x/genutil"
_ "github.com/cosmos/cosmos-sdk/x/mint"
_ "github.com/cosmos/cosmos-sdk/x/nft/module"
@ -13,6 +14,7 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
"github.com/cosmos/cosmos-sdk/x/nft"
@ -23,6 +25,7 @@ import (
appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1"
authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1"
bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1"
consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1"
genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1"
mintmodulev1 "cosmossdk.io/api/cosmos/mint/module/v1"
nftmodulev1 "cosmossdk.io/api/cosmos/nft/module/v1"
@ -45,6 +48,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
genutiltypes.ModuleName,
nft.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
},
EndBlockers: []string{
stakingtypes.ModuleName,
@ -54,6 +58,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
genutiltypes.ModuleName,
nft.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
},
InitGenesis: []string{
authtypes.ModuleName,
@ -63,6 +68,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
genutiltypes.ModuleName,
nft.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
},
}),
},
@ -91,6 +97,10 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
Name: paramstypes.ModuleName,
Config: appconfig.WrapAny(&paramsmodulev1.Module{}),
},
{
Name: consensustypes.ModuleName,
Config: appconfig.WrapAny(&consensusmodulev1.Module{}),
},
{
Name: "tx",
Config: appconfig.WrapAny(&txmodulev1.Module{}),

View File

@ -15,7 +15,6 @@ import (
"cosmossdk.io/depinject"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
@ -158,21 +157,18 @@ type paramsInputs struct {
type paramsOutputs struct {
depinject.Out
ParamsKeeper keeper.Keeper
BaseAppOption runtime.BaseAppOption
Module runtime.AppModuleWrapper
GovHandler govv1beta1.HandlerRoute
ParamsKeeper keeper.Keeper
Module runtime.AppModuleWrapper
GovHandler govv1beta1.HandlerRoute
}
func provideModule(in paramsInputs) paramsOutputs {
k := keeper.NewKeeper(in.Cdc, in.LegacyAmino, in.KvStoreKey, in.TransientStoreKey)
baseappOpt := func(app *baseapp.BaseApp) {
app.SetParamStore(k.Subspace(baseapp.Paramspace).WithKeyTable(types.ConsensusParamsKeyTable()))
}
m := runtime.WrapAppModule(NewAppModule(k))
govHandler := govv1beta1.HandlerRoute{RouteKey: proposal.RouterKey, Handler: NewParamChangeProposalHandler(k)}
return paramsOutputs{ParamsKeeper: k, BaseAppOption: baseappOpt, Module: m, GovHandler: govHandler}
return paramsOutputs{ParamsKeeper: k, Module: m, GovHandler: govHandler}
}
type subspaceInputs struct {

View File

@ -4,6 +4,7 @@ import (
_ "github.com/cosmos/cosmos-sdk/x/auth"
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/module"
_ "github.com/cosmos/cosmos-sdk/x/bank"
_ "github.com/cosmos/cosmos-sdk/x/consensus"
_ "github.com/cosmos/cosmos-sdk/x/genutil"
_ "github.com/cosmos/cosmos-sdk/x/params"
_ "github.com/cosmos/cosmos-sdk/x/staking"
@ -11,6 +12,7 @@ import (
"cosmossdk.io/core/appconfig"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
@ -19,6 +21,7 @@ import (
appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1"
authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1"
bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1"
consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1"
genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1"
paramsmodulev1 "cosmossdk.io/api/cosmos/params/module/v1"
stakingmodulev1 "cosmossdk.io/api/cosmos/staking/module/v1"
@ -37,6 +40,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
banktypes.ModuleName,
genutiltypes.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
},
EndBlockers: []string{
stakingtypes.ModuleName,
@ -44,6 +48,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
banktypes.ModuleName,
genutiltypes.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
},
InitGenesis: []string{
authtypes.ModuleName,
@ -51,6 +56,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
stakingtypes.ModuleName,
genutiltypes.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
},
}),
},
@ -77,6 +83,10 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
Name: paramstypes.ModuleName,
Config: appconfig.WrapAny(&paramsmodulev1.Module{}),
},
{
Name: consensustypes.ModuleName,
Config: appconfig.WrapAny(&consensusmodulev1.Module{}),
},
{
Name: "tx",
Config: appconfig.WrapAny(&txmodulev1.Module{}),

View File

@ -6,11 +6,7 @@ import (
"github.com/cosmos/cosmos-sdk/baseapp"
)
// ConsensusParamsKeyTable returns an x/params module keyTable to be used in
// the BaseApp's ParamStore. The KeyTable registers the types along with the
// standard validation functions. Applications can choose to adopt this KeyTable
// or provider their own when the existing validation functions do not suite their
// needs.
// Deprecated.
func ConsensusParamsKeyTable() KeyTable {
return NewKeyTable(
NewParamSetPair(

View File

@ -57,6 +57,7 @@ func TestSlashingMsgs(t *testing.T) {
configurator.StakingModule(),
configurator.SlashingModule(),
configurator.TxModule(),
configurator.ConsensusModule(),
configurator.BankModule()),
startupCfg, &stakingKeeper, &bankKeeper, &slashingKeeper)

View File

@ -4,6 +4,7 @@ import (
_ "github.com/cosmos/cosmos-sdk/x/auth"
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/module"
_ "github.com/cosmos/cosmos-sdk/x/bank"
_ "github.com/cosmos/cosmos-sdk/x/consensus"
_ "github.com/cosmos/cosmos-sdk/x/distribution"
_ "github.com/cosmos/cosmos-sdk/x/genutil"
_ "github.com/cosmos/cosmos-sdk/x/mint"
@ -14,6 +15,7 @@ import (
"cosmossdk.io/core/appconfig"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
@ -25,6 +27,7 @@ import (
appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1"
authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1"
bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1"
consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1"
distrmodulev1 "cosmossdk.io/api/cosmos/distribution/module/v1"
genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1"
mintmodulev1 "cosmossdk.io/api/cosmos/mint/module/v1"
@ -49,6 +52,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
genutiltypes.ModuleName,
slashingtypes.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
},
EndBlockers: []string{
stakingtypes.ModuleName,
@ -59,6 +63,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
minttypes.ModuleName,
slashingtypes.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
},
InitGenesis: []string{
authtypes.ModuleName,
@ -69,6 +74,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
slashingtypes.ModuleName,
genutiltypes.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
},
}),
},
@ -102,6 +108,10 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
Name: paramstypes.ModuleName,
Config: appconfig.WrapAny(&paramsmodulev1.Module{}),
},
{
Name: consensustypes.ModuleName,
Config: appconfig.WrapAny(&consensusmodulev1.Module{}),
},
{
Name: "tx",
Config: appconfig.WrapAny(&txmodulev1.Module{}),

View File

@ -4,6 +4,7 @@ import (
_ "github.com/cosmos/cosmos-sdk/x/auth"
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/module"
_ "github.com/cosmos/cosmos-sdk/x/bank"
_ "github.com/cosmos/cosmos-sdk/x/consensus"
_ "github.com/cosmos/cosmos-sdk/x/distribution"
_ "github.com/cosmos/cosmos-sdk/x/genutil"
_ "github.com/cosmos/cosmos-sdk/x/mint"
@ -14,6 +15,7 @@ import (
"cosmossdk.io/core/appconfig"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
@ -25,6 +27,7 @@ import (
appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1"
authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1"
bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1"
consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1"
distrmodulev1 "cosmossdk.io/api/cosmos/distribution/module/v1"
genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1"
mintmodulev1 "cosmossdk.io/api/cosmos/mint/module/v1"
@ -49,6 +52,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
genutiltypes.ModuleName,
slashingtypes.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
},
EndBlockers: []string{
stakingtypes.ModuleName,
@ -59,6 +63,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
minttypes.ModuleName,
slashingtypes.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
},
InitGenesis: []string{
authtypes.ModuleName,
@ -69,6 +74,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
slashingtypes.ModuleName,
genutiltypes.ModuleName,
paramstypes.ModuleName,
consensustypes.ModuleName,
},
}),
},
@ -102,6 +108,10 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
Name: paramstypes.ModuleName,
Config: appconfig.WrapAny(&paramsmodulev1.Module{}),
},
{
Name: consensustypes.ModuleName,
Config: appconfig.WrapAny(&consensusmodulev1.Module{}),
},
{
Name: "tx",
Config: appconfig.WrapAny(&txmodulev1.Module{}),

View File

@ -14,7 +14,7 @@ var (
var _ paramtypes.ParamSet = (*Params)(nil)
// ParamTable for staking module
// Deprecated: now params can be accesed on key `0x51` on the staking store.
// Deprecated: now params can be accessed on key `0x51` on the staking store.
func ParamKeyTable() paramtypes.KeyTable {
return paramtypes.NewKeyTable().RegisterParamSet(&Params{})
}

View File

@ -11,10 +11,9 @@ import (
"github.com/tendermint/tendermint/libs/log"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/store/prefix"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/kv"