refactor: remove consensus as a imported type in modules (backport #21480) (#21638)

Co-authored-by: Marko <marko@baricevic.me>
Co-authored-by: marbar3778 <marbar3778@yahoo.com>
This commit is contained in:
mergify[bot] 2024-09-10 19:10:37 +02:00 committed by GitHub
parent c9ae447ba7
commit df020efd00
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
71 changed files with 531 additions and 895 deletions

View File

@ -33,7 +33,6 @@ require (
cosmossdk.io/math v1.3.0
cosmossdk.io/schema v0.2.0 // indirect
cosmossdk.io/store v1.1.1-0.20240909133312-50288938d1b6 // indirect
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
@ -182,11 +181,6 @@ replace (
// pseudo version lower than the latest tag
cosmossdk.io/store => cosmossdk.io/store v1.0.0-rc.0.0.20240906090851-36d9b25e8981 // main
cosmossdk.io/x/bank => ./../../x/bank
cosmossdk.io/x/consensus => ./../../x/consensus
cosmossdk.io/x/distribution => ./../../x/distribution
cosmossdk.io/x/gov => ./../../x/gov
cosmossdk.io/x/mint => ./../../x/mint
cosmossdk.io/x/protocolpool => ./../../x/protocolpool
cosmossdk.io/x/slashing => ./../../x/slashing
cosmossdk.io/x/staking => ./../../x/staking
)

View File

@ -24,6 +24,8 @@ cosmossdk.io/schema v0.2.0 h1:UH5CR1DqUq8yP+5Np8PbvG4YX0zAUsTN2Qk6yThmfMk=
cosmossdk.io/schema v0.2.0/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
cosmossdk.io/store v1.0.0-rc.0.0.20240906090851-36d9b25e8981 h1:O510vQpVdyZgSlLm4NG2aQltDkKfoWcKrVCPPWQlNHs=
cosmossdk.io/store v1.0.0-rc.0.0.20240906090851-36d9b25e8981/go.mod h1:5lnCUSlWPWQYrUcNjpqBLTnlykyz1NeGQpMmZq1DCOg=
cosmossdk.io/x/protocolpool v0.0.0-20230925135524-a1bc045b3190 h1:XQJj9Dv9Gtze0l2TF79BU5lkP6MkUveTUuKICmxoz+o=
cosmossdk.io/x/protocolpool v0.0.0-20230925135524-a1bc045b3190/go.mod h1:7WUGupOvmlHJoIMBz1JbObQxeo6/TDiuDBxmtod8HRg=
cosmossdk.io/x/tx v0.13.4-0.20240909133312-50288938d1b6 h1:iOy4n9nKBKaLpPMLaxpzzfHbJKxFgpHc17noeK4dHec=
cosmossdk.io/x/tx v0.13.4-0.20240909133312-50288938d1b6/go.mod h1:D4mjFUYiNi1/r0p1kknsWhUnXxK9Y8RV1GQUdHEaBRw=
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=

2
go.mod
View File

@ -15,7 +15,6 @@ require (
cosmossdk.io/schema v0.2.0
cosmossdk.io/store v1.1.1-0.20240909133312-50288938d1b6
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000
cosmossdk.io/x/tx v0.13.4-0.20240909133312-50288938d1b6 // main
github.com/99designs/keyring v1.2.2
@ -186,7 +185,6 @@ replace (
// pseudo version lower than the latest tag
cosmossdk.io/store => cosmossdk.io/store v1.0.0-rc.0.0.20240906090851-36d9b25e8981 // main
cosmossdk.io/x/bank => ./x/bank
cosmossdk.io/x/consensus => ./x/consensus
cosmossdk.io/x/staking => ./x/staking
)

View File

@ -26,3 +26,4 @@ $mockgen_cmd -source=x/gov/testutil/expected_keepers.go -package testutil -desti
$mockgen_cmd -source=x/staking/types/expected_keepers.go -package testutil -destination x/staking/testutil/expected_keepers_mocks.go
# $mockgen_cmd -source=x/auth/vesting/types/expected_keepers.go -package testutil -destination x/auth/vesting/testutil/expected_keepers_mocks.go
$mockgen_cmd -source=x/protocolpool/types/expected_keepers.go -package testutil -destination x/protocolpool/testutil/expected_keepers_mocks.go
$mockgen_cmd -source=x/upgrade/types/expected_keepers.go -package testutil -destination x/upgrade/testutil/expected_keepers_mocks.go

View File

@ -3,11 +3,18 @@ package cometbft
import (
"context"
"crypto/sha256"
"encoding/json"
"io"
"strings"
"testing"
"time"
abciproto "github.com/cometbft/cometbft/api/cometbft/abci/v1"
v1 "github.com/cometbft/cometbft/api/cometbft/types/v1"
"github.com/cosmos/gogoproto/proto"
gogotypes "github.com/cosmos/gogoproto/types"
"github.com/stretchr/testify/require"
appmodulev2 "cosmossdk.io/core/appmodule/v2"
"cosmossdk.io/core/store"
"cosmossdk.io/core/transaction"
@ -20,16 +27,7 @@ import (
"cosmossdk.io/server/v2/stf"
"cosmossdk.io/server/v2/stf/branch"
"cosmossdk.io/server/v2/stf/mock"
abciproto "github.com/cometbft/cometbft/api/cometbft/abci/v1"
v1 "github.com/cometbft/cometbft/api/cometbft/types/v1"
"github.com/cosmos/gogoproto/proto"
"encoding/json"
consensustypes "cosmossdk.io/x/consensus/types"
gogotypes "github.com/cosmos/gogoproto/types"
"github.com/stretchr/testify/require"
)
var (

View File

@ -6,7 +6,6 @@ import (
"cosmossdk.io/core/log"
corestore "cosmossdk.io/core/store"
storev2 "cosmossdk.io/store/v2"
"cosmossdk.io/store/v2/commitment"
"cosmossdk.io/store/v2/commitment/iavl"
@ -17,7 +16,7 @@ import (
)
type MockStore struct {
Storage storev2.VersionedDatabase
Storage storev2.VersionedDatabase
Committer storev2.Committer
}

View File

@ -33,7 +33,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
}
anteDecorators := []sdk.AnteDecorator{
ante.NewSetUpContextDecorator(options.Environment), // outermost AnteDecorator. SetUpContext must be called first
ante.NewSetUpContextDecorator(options.Environment, options.ConsensusKeeper), // outermost AnteDecorator. SetUpContext must be called first
circuitante.NewCircuitBreakerDecorator(options.CircuitKeeper),
ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker),
ante.NewValidateBasicDecorator(options.Environment),

View File

@ -361,6 +361,7 @@ func NewSimApp(
runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())),
app.AuthKeeper,
app.BankKeeper,
app.ConsensusParamsKeeper,
govModuleAddr,
signingCtx.ValidatorAddressCodec(),
authcodec.NewBech32Codec(sdk.Bech32PrefixConsAddr),
@ -407,7 +408,7 @@ func NewSimApp(
}
homePath := cast.ToString(appOpts.Get(flags.FlagHome))
// set the governance module account as the authority for conducting upgrades
app.UpgradeKeeper = upgradekeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[upgradetypes.StoreKey]), logger.With(log.ModuleKey, "x/upgrade"), runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())), skipUpgradeHeights, appCodec, homePath, app.BaseApp, govModuleAddr)
app.UpgradeKeeper = upgradekeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[upgradetypes.StoreKey]), logger.With(log.ModuleKey, "x/upgrade"), runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())), skipUpgradeHeights, appCodec, homePath, app.BaseApp, govModuleAddr, app.ConsensusParamsKeeper)
// Register the proposal types
// Deprecated: Avoid adding new handlers, instead use the new proposal flow
@ -434,7 +435,7 @@ func NewSimApp(
// create evidence keeper with router
evidenceKeeper := evidencekeeper.NewKeeper(
appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[evidencetypes.StoreKey]), logger.With(log.ModuleKey, "x/evidence"), runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())), app.StakingKeeper, app.SlashingKeeper, app.AuthKeeper.AddressCodec(),
appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[evidencetypes.StoreKey]), logger.With(log.ModuleKey, "x/evidence"), runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())), app.StakingKeeper, app.SlashingKeeper, app.ConsensusParamsKeeper, app.AuthKeeper.AddressCodec(),
)
// If evidence needs to be handled for the app, set routes in router here and seal
app.EvidenceKeeper = *evidenceKeeper
@ -645,6 +646,7 @@ func (app *SimApp) setAnteHandler(txConfig client.TxConfig) {
AccountAbstractionKeeper: app.AccountsKeeper,
AccountKeeper: app.AuthKeeper,
BankKeeper: app.BankKeeper,
ConsensusKeeper: app.ConsensusParamsKeeper,
SignModeHandler: txConfig.SignModeHandler(),
FeegrantKeeper: app.FeeGrantKeeper,
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,

View File

@ -296,6 +296,7 @@ func (app *SimApp) setCustomAnteHandler() {
ante.HandlerOptions{
AccountKeeper: app.AuthKeeper,
BankKeeper: app.BankKeeper,
ConsensusKeeper: app.ConsensusParamsKeeper,
SignModeHandler: app.txConfig.SignModeHandler(),
FeegrantKeeper: app.FeeGrantKeeper,
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,

View File

@ -18,6 +18,8 @@ import (
"cosmossdk.io/x/bank"
bankkeeper "cosmossdk.io/x/bank/keeper"
banktypes "cosmossdk.io/x/bank/types"
"cosmossdk.io/x/consensus"
consensusparamkeeper "cosmossdk.io/x/consensus/keeper"
consensustypes "cosmossdk.io/x/consensus/types"
"cosmossdk.io/x/distribution"
distrkeeper "cosmossdk.io/x/distribution/keeper"
@ -132,7 +134,8 @@ func initFixture(t *testing.T) *fixture {
grpcRouter := baseapp.NewGRPCQueryRouter()
cometService := runtime.NewContextAwareCometInfoService()
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(grpcRouter), runtime.EnvWithMsgRouterService(msgRouter)), accountKeeper, bankKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), cometService)
consensusParamsKeeper := consensusparamkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[consensustypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(grpcRouter), runtime.EnvWithMsgRouterService(msgRouter)), authtypes.NewModuleAddress("gov").String())
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(grpcRouter), runtime.EnvWithMsgRouterService(msgRouter)), accountKeeper, bankKeeper, consensusParamsKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), cometService)
require.NoError(t, stakingKeeper.Params.Set(newCtx, stakingtypes.DefaultParams()))
poolKeeper := poolkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[pooltypes.StoreKey]), log.NewNopLogger()), accountKeeper, bankKeeper, stakingKeeper, authority.String())
@ -146,6 +149,7 @@ func initFixture(t *testing.T) *fixture {
stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper)
distrModule := distribution.NewAppModule(cdc, distrKeeper, accountKeeper, bankKeeper, stakingKeeper)
poolModule := protocolpool.NewAppModule(cdc, poolKeeper, accountKeeper, bankKeeper)
consensusModule := consensus.NewAppModule(cdc, consensusParamsKeeper)
addr := sdk.AccAddress(PKS[0].Address())
valAddr := sdk.ValAddress(addr)
@ -171,11 +175,12 @@ func initFixture(t *testing.T) *fixture {
encodingCfg.InterfaceRegistry.SigningContext().AddressCodec(),
encodingCfg.InterfaceRegistry.SigningContext().ValidatorAddressCodec(),
map[string]appmodule.AppModule{
authtypes.ModuleName: authModule,
banktypes.ModuleName: bankModule,
stakingtypes.ModuleName: stakingModule,
distrtypes.ModuleName: distrModule,
pooltypes.ModuleName: poolModule,
authtypes.ModuleName: authModule,
banktypes.ModuleName: bankModule,
stakingtypes.ModuleName: stakingModule,
distrtypes.ModuleName: distrModule,
pooltypes.ModuleName: poolModule,
consensustypes.ModuleName: consensusModule,
},
msgRouter,
grpcRouter,

View File

@ -1,4 +1,4 @@
package v4_test
package distribution_test
import (
"context"
@ -8,6 +8,7 @@ import (
"github.com/stretchr/testify/require"
"cosmossdk.io/core/comet"
coretesting "cosmossdk.io/core/testing"
"cosmossdk.io/log"
storetypes "cosmossdk.io/store/types"
"cosmossdk.io/x/bank"
@ -22,7 +23,9 @@ import (
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/integration"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
@ -32,6 +35,34 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
)
func TestMigration(t *testing.T) {
cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{}).Codec
storeKey := storetypes.NewKVStoreKey("distribution")
storeService := runtime.NewKVStoreService(storeKey)
tKey := storetypes.NewTransientStoreKey("transient_test")
ctx := testutil.DefaultContext(storeKey, tKey)
env := runtime.NewEnvironment(storeService, coretesting.NewNopLogger())
addr1 := secp256k1.GenPrivKey().PubKey().Address()
consAddr1 := sdk.ConsAddress(addr1)
// Set and check the previous proposer
err := v4.SetPreviousProposerConsAddr(ctx, storeService, cdc, consAddr1)
require.NoError(t, err)
gotAddr, err := v4.GetPreviousProposerConsAddr(ctx, storeService, cdc)
require.NoError(t, err)
require.Equal(t, consAddr1, gotAddr)
err = v4.MigrateStore(ctx, env, cdc)
require.NoError(t, err)
// Check that the previous proposer has been removed
_, err = v4.GetPreviousProposerConsAddr(ctx, storeService, cdc)
require.ErrorContains(t, err, "previous proposer not set")
}
type emptyCometService struct{}
// CometInfo implements comet.Service.

View File

@ -20,6 +20,8 @@ import (
"cosmossdk.io/x/bank"
bankkeeper "cosmossdk.io/x/bank/keeper"
banktypes "cosmossdk.io/x/bank/types"
"cosmossdk.io/x/consensus"
consensusparamkeeper "cosmossdk.io/x/consensus/keeper"
consensusparamtypes "cosmossdk.io/x/consensus/types"
"cosmossdk.io/x/evidence"
"cosmossdk.io/x/evidence/exported"
@ -144,13 +146,15 @@ func initFixture(tb testing.TB) *fixture {
assert.NilError(tb, bankKeeper.SetParams(newCtx, banktypes.DefaultParams()))
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(grpcQueryRouter), runtime.EnvWithMsgRouterService(msgRouter)), accountKeeper, bankKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), runtime.NewContextAwareCometInfoService())
consensusParamsKeeper := consensusparamkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(grpcQueryRouter), runtime.EnvWithMsgRouterService(msgRouter)), authtypes.NewModuleAddress("gov").String())
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(grpcQueryRouter), runtime.EnvWithMsgRouterService(msgRouter)), accountKeeper, bankKeeper, consensusParamsKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), runtime.NewContextAwareCometInfoService())
slashingKeeper := slashingkeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[slashingtypes.StoreKey]), log.NewNopLogger()), cdc, codec.NewLegacyAmino(), stakingKeeper, authority.String())
stakingKeeper.SetHooks(stakingtypes.NewMultiStakingHooks(slashingKeeper.Hooks()))
evidenceKeeper := keeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[evidencetypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(grpcQueryRouter), runtime.EnvWithMsgRouterService(msgRouter)), stakingKeeper, slashingKeeper, addresscodec.NewBech32Codec(sdk.Bech32PrefixAccAddr))
evidenceKeeper := keeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[evidencetypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(grpcQueryRouter), runtime.EnvWithMsgRouterService(msgRouter)), stakingKeeper, slashingKeeper, consensusParamsKeeper, addresscodec.NewBech32Codec(sdk.Bech32PrefixAccAddr))
router := evidencetypes.NewRouter()
router = router.AddRoute(evidencetypes.RouteEquivocation, testEquivocationHandler(evidenceKeeper))
evidenceKeeper.SetRouter(router)
@ -160,16 +164,18 @@ func initFixture(tb testing.TB) *fixture {
stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper)
slashingModule := slashing.NewAppModule(cdc, slashingKeeper, accountKeeper, bankKeeper, stakingKeeper, cdc.InterfaceRegistry(), cometInfoService)
evidenceModule := evidence.NewAppModule(cdc, *evidenceKeeper, cometInfoService)
consensusModule := consensus.NewAppModule(cdc, consensusParamsKeeper)
integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc,
encodingCfg.InterfaceRegistry.SigningContext().AddressCodec(),
encodingCfg.InterfaceRegistry.SigningContext().ValidatorAddressCodec(),
map[string]appmodule.AppModule{
authtypes.ModuleName: authModule,
banktypes.ModuleName: bankModule,
stakingtypes.ModuleName: stakingModule,
slashingtypes.ModuleName: slashingModule,
evidencetypes.ModuleName: evidenceModule,
authtypes.ModuleName: authModule,
banktypes.ModuleName: bankModule,
stakingtypes.ModuleName: stakingModule,
slashingtypes.ModuleName: slashingModule,
evidencetypes.ModuleName: evidenceModule,
consensusparamtypes.ModuleName: consensusModule,
},
msgRouter,
grpcQueryRouter,

View File

@ -13,6 +13,9 @@ import (
"cosmossdk.io/x/bank"
bankkeeper "cosmossdk.io/x/bank/keeper"
banktypes "cosmossdk.io/x/bank/types"
"cosmossdk.io/x/consensus"
consensusparamkeeper "cosmossdk.io/x/consensus/keeper"
consensusparamtypes "cosmossdk.io/x/consensus/types"
"cosmossdk.io/x/gov"
"cosmossdk.io/x/gov/keeper"
"cosmossdk.io/x/gov/types"
@ -54,7 +57,7 @@ type fixture struct {
func initFixture(tb testing.TB) *fixture {
tb.Helper()
keys := storetypes.NewKVStoreKeys(
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, pooltypes.StoreKey, types.StoreKey,
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, pooltypes.StoreKey, types.StoreKey, consensusparamtypes.StoreKey,
)
encodingCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}, bank.AppModule{}, gov.AppModule{})
cdc := encodingCfg.Codec
@ -110,7 +113,11 @@ func initFixture(tb testing.TB) *fixture {
assert.NilError(tb, bankKeeper.SetParams(newCtx, banktypes.DefaultParams()))
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), log.NewNopLogger()), accountKeeper, bankKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), runtime.NewContextAwareCometInfoService())
router := baseapp.NewMsgServiceRouter()
queryRouter := baseapp.NewGRPCQueryRouter()
consensusParamsKeeper := consensusparamkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(queryRouter), runtime.EnvWithMsgRouterService(router)), authtypes.NewModuleAddress("gov").String())
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), log.NewNopLogger()), accountKeeper, bankKeeper, consensusParamsKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), runtime.NewContextAwareCometInfoService())
poolKeeper := poolkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[pooltypes.StoreKey]), log.NewNopLogger()), accountKeeper, bankKeeper, stakingKeeper, authority.String())
@ -120,9 +127,7 @@ func initFixture(tb testing.TB) *fixture {
// Create MsgServiceRouter, but don't populate it before creating the gov
// keeper.
router := baseapp.NewMsgServiceRouter()
router.SetInterfaceRegistry(cdc.InterfaceRegistry())
queryRouter := baseapp.NewGRPCQueryRouter()
queryRouter.SetInterfaceRegistry(cdc.InterfaceRegistry())
govKeeper := keeper.NewKeeper(
@ -146,15 +151,17 @@ func initFixture(tb testing.TB) *fixture {
bankModule := bank.NewAppModule(cdc, bankKeeper, accountKeeper)
stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper)
govModule := gov.NewAppModule(cdc, govKeeper, accountKeeper, bankKeeper, poolKeeper)
consensusModule := consensus.NewAppModule(cdc, consensusParamsKeeper)
integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc,
encodingCfg.InterfaceRegistry.SigningContext().AddressCodec(),
encodingCfg.InterfaceRegistry.SigningContext().ValidatorAddressCodec(),
map[string]appmodule.AppModule{
authtypes.ModuleName: authModule,
banktypes.ModuleName: bankModule,
stakingtypes.ModuleName: stakingModule,
types.ModuleName: govModule,
authtypes.ModuleName: authModule,
banktypes.ModuleName: bankModule,
stakingtypes.ModuleName: stakingModule,
types.ModuleName: govModule,
consensusparamtypes.ModuleName: consensusModule,
},
baseapp.NewMsgServiceRouter(),
baseapp.NewGRPCQueryRouter(),

View File

@ -17,6 +17,8 @@ import (
"cosmossdk.io/x/bank"
bankkeeper "cosmossdk.io/x/bank/keeper"
banktypes "cosmossdk.io/x/bank/types"
"cosmossdk.io/x/consensus"
consensusparamkeeper "cosmossdk.io/x/consensus/keeper"
consensustypes "cosmossdk.io/x/consensus/types"
minttypes "cosmossdk.io/x/mint/types"
"cosmossdk.io/x/slashing"
@ -117,21 +119,25 @@ func initFixture(tb testing.TB) *fixture {
cometInfoService := runtime.NewContextAwareCometInfoService()
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(queryRouter), runtime.EnvWithMsgRouterService(msgRouter)), accountKeeper, bankKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), cometInfoService)
consensusParamsKeeper := consensusparamkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[consensustypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(queryRouter), runtime.EnvWithMsgRouterService(msgRouter)), authtypes.NewModuleAddress("gov").String())
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(queryRouter), runtime.EnvWithMsgRouterService(msgRouter)), accountKeeper, bankKeeper, consensusParamsKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), cometInfoService)
slashingKeeper := slashingkeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[slashingtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(queryRouter), runtime.EnvWithMsgRouterService(msgRouter)), cdc, &codec.LegacyAmino{}, stakingKeeper, authority.String())
bankModule := bank.NewAppModule(cdc, bankKeeper, accountKeeper)
stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper)
slashingModule := slashing.NewAppModule(cdc, slashingKeeper, accountKeeper, bankKeeper, stakingKeeper, cdc.InterfaceRegistry(), cometInfoService)
consensusModule := consensus.NewAppModule(cdc, consensusParamsKeeper)
integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc,
encodingCfg.InterfaceRegistry.SigningContext().AddressCodec(),
encodingCfg.InterfaceRegistry.SigningContext().ValidatorAddressCodec(),
map[string]appmodule.AppModule{
banktypes.ModuleName: bankModule,
stakingtypes.ModuleName: stakingModule,
slashingtypes.ModuleName: slashingModule,
banktypes.ModuleName: bankModule,
stakingtypes.ModuleName: stakingModule,
slashingtypes.ModuleName: slashingModule,
consensustypes.ModuleName: consensusModule,
},
msgRouter,
queryRouter,

View File

@ -15,6 +15,8 @@ import (
"cosmossdk.io/x/bank"
bankkeeper "cosmossdk.io/x/bank/keeper"
banktypes "cosmossdk.io/x/bank/types"
"cosmossdk.io/x/consensus"
consensusparamkeeper "cosmossdk.io/x/consensus/keeper"
consensustypes "cosmossdk.io/x/consensus/types"
minttypes "cosmossdk.io/x/mint/types"
pooltypes "cosmossdk.io/x/protocolpool/types"
@ -162,19 +164,23 @@ func initFixture(tb testing.TB) *fixture {
assert.NilError(tb, bankKeeper.SetParams(newCtx, banktypes.DefaultParams()))
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[types.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(queryRouter), runtime.EnvWithMsgRouterService(msgRouter)), accountKeeper, bankKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), runtime.NewContextAwareCometInfoService())
consensusParamsKeeper := consensusparamkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[consensustypes.StoreKey]), log.NewNopLogger()), authtypes.NewModuleAddress("gov").String())
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[types.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(queryRouter), runtime.EnvWithMsgRouterService(msgRouter)), accountKeeper, bankKeeper, consensusParamsKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), runtime.NewContextAwareCometInfoService())
authModule := auth.NewAppModule(cdc, accountKeeper, acctsModKeeper, authsims.RandomGenesisAccounts, nil)
bankModule := bank.NewAppModule(cdc, bankKeeper, accountKeeper)
stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper)
consensusModule := consensus.NewAppModule(cdc, consensusParamsKeeper)
integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc,
encodingCfg.InterfaceRegistry.SigningContext().AddressCodec(),
encodingCfg.InterfaceRegistry.SigningContext().ValidatorAddressCodec(),
map[string]appmodule.AppModule{
authtypes.ModuleName: authModule,
banktypes.ModuleName: bankModule,
types.ModuleName: stakingModule,
authtypes.ModuleName: authModule,
banktypes.ModuleName: bankModule,
types.ModuleName: stakingModule,
consensustypes.ModuleName: consensusModule,
},
msgRouter,
queryRouter,

View File

@ -17,6 +17,9 @@ import (
bankkeeper "cosmossdk.io/x/bank/keeper"
banktestutil "cosmossdk.io/x/bank/testutil"
banktypes "cosmossdk.io/x/bank/types"
"cosmossdk.io/x/consensus"
consensusparamkeeper "cosmossdk.io/x/consensus/keeper"
consensusparamtypes "cosmossdk.io/x/consensus/types"
"cosmossdk.io/x/distribution"
minttypes "cosmossdk.io/x/mint/types"
"cosmossdk.io/x/staking"
@ -71,7 +74,7 @@ type deterministicFixture struct {
func initDeterministicFixture(t *testing.T) *deterministicFixture {
t.Helper()
keys := storetypes.NewKVStoreKeys(
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey,
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, consensusparamtypes.StoreKey,
)
encodingCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}, distribution.AppModule{})
cdc := encodingCfg.Codec
@ -124,19 +127,23 @@ func initDeterministicFixture(t *testing.T) *deterministicFixture {
assert.NilError(t, bankKeeper.SetParams(newCtx, banktypes.DefaultParams()))
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), log.NewNopLogger()), accountKeeper, bankKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), runtime.NewContextAwareCometInfoService())
consensusParamsKeeper := consensusparamkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), log.NewNopLogger()), authtypes.NewModuleAddress("gov").String())
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), log.NewNopLogger()), accountKeeper, bankKeeper, consensusParamsKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), runtime.NewContextAwareCometInfoService())
authModule := auth.NewAppModule(cdc, accountKeeper, acctsModKeeper, authsims.RandomGenesisAccounts, nil)
bankModule := bank.NewAppModule(cdc, bankKeeper, accountKeeper)
stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper)
consensusModule := consensus.NewAppModule(cdc, consensusParamsKeeper)
integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc,
encodingCfg.InterfaceRegistry.SigningContext().AddressCodec(),
encodingCfg.InterfaceRegistry.SigningContext().ValidatorAddressCodec(),
map[string]appmodule.AppModule{
authtypes.ModuleName: authModule,
banktypes.ModuleName: bankModule,
stakingtypes.ModuleName: stakingModule,
authtypes.ModuleName: authModule,
banktypes.ModuleName: bankModule,
stakingtypes.ModuleName: stakingModule,
consensusparamtypes.ModuleName: consensusModule,
},
baseapp.NewMsgServiceRouter(),
baseapp.NewGRPCQueryRouter(),

View File

@ -9,14 +9,14 @@ import (
cmttypes "github.com/cometbft/cometbft/types"
dbm "github.com/cosmos/cosmos-db"
"cosmossdk.io/collections"
"cosmossdk.io/core/address"
"cosmossdk.io/core/appmodule"
corestore "cosmossdk.io/core/store"
"cosmossdk.io/log"
"cosmossdk.io/store"
"cosmossdk.io/store/metrics"
storetypes "cosmossdk.io/store/types"
consensusparamkeeper "cosmossdk.io/x/consensus/keeper"
consensusparamtypes "cosmossdk.io/x/consensus/types"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"
@ -26,10 +26,12 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
)
const appName = "integration-app"
const (
appName = "integration-app"
consensus = "consensus"
)
// App is a test application that can be used to test the integration of modules.
type App struct {
@ -88,14 +90,12 @@ func NewIntegrationApp(
grpcRouter.SetInterfaceRegistry(interfaceRegistry)
bApp.SetGRPCQueryRouter(grpcRouter)
if keys[consensusparamtypes.StoreKey] != nil {
// set baseApp param store
consensusParamsKeeper := consensusparamkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(grpcRouter), runtime.EnvWithMsgRouterService(msgRouter)), authtypes.NewModuleAddress("gov").String())
bApp.SetParamStore(consensusParamsKeeper.ParamsStore)
consensusparamtypes.RegisterQueryServer(grpcRouter, consensusParamsKeeper)
if keys[consensus] != nil {
cps := newParamStore(runtime.NewKVStoreService(keys[consensus]), appCodec)
bApp.SetParamStore(cps)
params := cmttypes.ConsensusParamsFromProto(*simtestutil.DefaultConsensusParams) // This fills up missing param sections
err := consensusParamsKeeper.ParamsStore.Set(sdkCtx, params.ToProto())
err := cps.Set(sdkCtx, params.ToProto())
if err != nil {
panic(fmt.Errorf("failed to set consensus params: %w", err))
}
@ -211,3 +211,26 @@ func CreateMultiStore(keys map[string]*storetypes.KVStoreKey, logger log.Logger)
_ = cms.LoadLatestVersion()
return cms
}
type paramStoreService struct {
ParamsStore collections.Item[cmtproto.ConsensusParams]
}
func newParamStore(storeService corestore.KVStoreService, cdc codec.Codec) paramStoreService {
sb := collections.NewSchemaBuilder(storeService)
return paramStoreService{
ParamsStore: collections.NewItem(sb, collections.NewPrefix("Consensus"), "params", codec.CollValue[cmtproto.ConsensusParams](cdc)),
}
}
func (pss paramStoreService) Get(ctx context.Context) (cmtproto.ConsensusParams, error) {
return pss.ParamsStore.Get(ctx)
}
func (pss paramStoreService) Has(ctx context.Context) (bool, error) {
return pss.ParamsStore.Has(ctx)
}
func (pss paramStoreService) Set(ctx context.Context, cp cmtproto.ConsensusParams) error {
return pss.ParamsStore.Set(ctx, cp)
}

View File

@ -28,8 +28,7 @@ require (
cosmossdk.io/log v1.4.1
cosmossdk.io/math v1.3.0
cosmossdk.io/store v1.1.1-0.20240909133312-50288938d1b6 // indirect
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/tx v0.13.4-0.20240909133312-50288938d1b6 // indirect; main
cosmossdk.io/x/tx v0.13.4-0.20240909133312-50288938d1b6 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.2 // indirect

View File

@ -25,7 +25,6 @@ require (
cosmossdk.io/log v1.4.1 // indirect
cosmossdk.io/schema v0.2.0 // indirect
cosmossdk.io/store v1.1.1-0.20240909133312-50288938d1b6 // indirect
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/tx v0.13.4-0.20240909133312-50288938d1b6 // indirect; main
filippo.io/edwards25519 v1.1.0 // indirect

View File

@ -34,7 +34,6 @@ require (
cosmossdk.io/schema v0.2.0 // indirect
cosmossdk.io/store v1.1.1-0.20240909133312-50288938d1b6 // indirect
cosmossdk.io/x/accounts/defaults/lockup v0.0.0-20240417181816-5e7aae0db1f5
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/distribution v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
@ -185,7 +184,6 @@ replace (
cosmossdk.io/x/accounts/defaults/lockup => ./defaults/lockup
cosmossdk.io/x/accounts/defaults/multisig => ./defaults/multisig
cosmossdk.io/x/bank => ../bank
cosmossdk.io/x/consensus => ../consensus
cosmossdk.io/x/distribution => ../distribution
cosmossdk.io/x/mint => ../mint
cosmossdk.io/x/slashing => ../slashing

View File

@ -53,6 +53,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [#19535](https://github.com/cosmos/cosmos-sdk/pull/19535) Remove vesting account creation when the chain is running. The accounts module is required for creating [#vesting accounts](../accounts/defaults/lockup/README.md) on a running chain.
* [#19600](https://github.com/cosmos/cosmos-sdk/pull/19600) add a consensus query method to the consensus module in order for modules to query consensus for the consensus params.
* [#19600](https://github.com/cosmos/cosmos-sdk/pull/21403) NewAppModule now takes in `ante.ExtensionOptionChecker`, but it's only used in server/v2 chains, so it's safe to pass in nil for the rest of the users.
* [#21480](https://github.com/cosmos/cosmos-sdk/pull/21480) ConsensusKeeper is a required keeper for ante handlers.
### Consensus Breaking Changes

View File

@ -19,6 +19,7 @@ type HandlerOptions struct {
AccountKeeper AccountKeeper
AccountAbstractionKeeper AccountAbstractionKeeper
BankKeeper types.BankKeeper
ConsensusKeeper ConsensusKeeper
ExtensionOptionChecker ExtensionOptionChecker
FeegrantKeeper FeegrantKeeper
SignModeHandler *txsigning.HandlerMap
@ -44,7 +45,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
}
anteDecorators := []sdk.AnteDecorator{
NewSetUpContextDecorator(options.Environment), // outermost AnteDecorator. SetUpContext must be called first
NewSetUpContextDecorator(options.Environment, options.ConsensusKeeper), // outermost AnteDecorator. SetUpContext must be called first
NewExtensionOptionsDecorator(options.ExtensionOptionChecker),
NewValidateBasicDecorator(options.Environment),
NewTxTimeoutHeightDecorator(options.Environment),

View File

@ -1249,6 +1249,7 @@ func TestCustomSignatureVerificationGasConsumer(t *testing.T) {
ante.HandlerOptions{
AccountKeeper: suite.accountKeeper,
BankKeeper: suite.bankKeeper,
ConsensusKeeper: suite.consensusKeeper,
FeegrantKeeper: suite.feeGrantKeeper,
SignModeHandler: suite.clientCtx.TxConfig.SignModeHandler(),
SigGasConsumer: func(meter gas.Meter, sig signing.SignatureV2, params authtypes.Params) error {

View File

@ -5,7 +5,6 @@ import (
"cosmossdk.io/core/address"
"cosmossdk.io/core/appmodule"
consensustypes "cosmossdk.io/x/consensus/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/types"
@ -29,5 +28,5 @@ type FeegrantKeeper interface {
}
type ConsensusKeeper interface {
Params(context.Context, *consensustypes.QueryParamsRequest) (*consensustypes.QueryParamsResponse, error)
BlockParams(context.Context) (uint64, uint64, error)
}

View File

@ -6,7 +6,6 @@ import (
"cosmossdk.io/core/appmodule"
errorsmod "cosmossdk.io/errors"
storetypes "cosmossdk.io/store/types"
consensusv1 "cosmossdk.io/x/consensus/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
@ -24,12 +23,14 @@ type GasTx interface {
// CONTRACT: Must be first decorator in the chain
// CONTRACT: Tx must implement GasTx interface
type SetUpContextDecorator struct {
env appmodule.Environment
env appmodule.Environment
consensusKeeper ConsensusKeeper
}
func NewSetUpContextDecorator(env appmodule.Environment) SetUpContextDecorator {
func NewSetUpContextDecorator(env appmodule.Environment, consensusKeeper ConsensusKeeper) SetUpContextDecorator {
return SetUpContextDecorator{
env: env,
env: env,
consensusKeeper: consensusKeeper,
}
}
@ -45,23 +46,13 @@ func (sud SetUpContextDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, _ bool,
newCtx = SetGasMeter(ctx, gasTx.GetGas())
// TODO: possibly cache the result of this query for other antehandlers to use
resp, err := sud.env.QueryRouterService.Invoke(ctx, &consensusv1.QueryParamsRequest{})
maxGas, _, err := sud.consensusKeeper.BlockParams(ctx)
if err != nil {
return newCtx, err
}
res, ok := resp.(*consensusv1.QueryParamsResponse)
if !ok {
return newCtx, fmt.Errorf("unexpected response type: %T", resp)
}
if res.Params.Block != nil {
// If there exists a maximum block gas limit, we must ensure that the tx
// does not exceed it.
if res.Params.Block.MaxGas > 0 && gasTx.GetGas() > uint64(res.Params.Block.MaxGas) {
return newCtx, errorsmod.Wrapf(sdkerrors.ErrInvalidGasLimit, "tx gas limit %d exceeds block max gas %d", gasTx.GetGas(), res.Params.Block.MaxGas)
}
if maxGas > 0 && gasTx.GetGas() > maxGas {
return newCtx, errorsmod.Wrapf(sdkerrors.ErrInvalidGasLimit, "tx gas limit %d exceeds block max gas %d", gasTx.GetGas(), maxGas)
}
// Decorator will catch an OutOfGasPanic caused in the next antehandler

View File

@ -33,7 +33,7 @@ func TestSetupDecorator_BlockMaxGas(t *testing.T) {
tx, err := suite.CreateTestTx(suite.ctx, privs, accNums, accSeqs, suite.ctx.ChainID(), signing.SignMode_SIGN_MODE_DIRECT)
require.NoError(t, err)
sud := ante.NewSetUpContextDecorator(suite.env)
sud := ante.NewSetUpContextDecorator(suite.env, suite.consensusKeeper)
antehandler := sdk.ChainAnteDecorators(sud)
suite.ctx = suite.ctx.
@ -63,7 +63,7 @@ func TestSetup(t *testing.T) {
tx, err := suite.CreateTestTx(suite.ctx, privs, accNums, accSeqs, suite.ctx.ChainID(), signing.SignMode_SIGN_MODE_DIRECT)
require.NoError(t, err)
sud := ante.NewSetUpContextDecorator(suite.env)
sud := ante.NewSetUpContextDecorator(suite.env, suite.consensusKeeper)
antehandler := sdk.ChainAnteDecorators(sud)
// Set height to non-zero value for GasMeter to be set
@ -98,7 +98,7 @@ func TestRecoverPanic(t *testing.T) {
tx, err := suite.CreateTestTx(suite.ctx, privs, accNums, accSeqs, suite.ctx.ChainID(), signing.SignMode_SIGN_MODE_DIRECT)
require.NoError(t, err)
sud := ante.NewSetUpContextDecorator(suite.env)
sud := ante.NewSetUpContextDecorator(suite.env, suite.consensusKeeper)
antehandler := sdk.ChainAnteDecorators(sud, OutOfGasDecorator{})
// Set height to non-zero value for GasMeter to be set

View File

@ -10,9 +10,8 @@ import (
address "cosmossdk.io/core/address"
appmodule "cosmossdk.io/core/appmodule"
types "cosmossdk.io/x/consensus/types"
types0 "github.com/cosmos/cosmos-sdk/types"
types1 "github.com/cosmos/cosmos-sdk/x/auth/types"
types "github.com/cosmos/cosmos-sdk/types"
types0 "github.com/cosmos/cosmos-sdk/x/auth/types"
gomock "github.com/golang/mock/gomock"
)
@ -54,10 +53,10 @@ func (mr *MockAccountKeeperMockRecorder) AddressCodec() *gomock.Call {
}
// GetAccount mocks base method.
func (m *MockAccountKeeper) GetAccount(ctx context.Context, addr types0.AccAddress) types0.AccountI {
func (m *MockAccountKeeper) GetAccount(ctx context.Context, addr types.AccAddress) types.AccountI {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetAccount", ctx, addr)
ret0, _ := ret[0].(types0.AccountI)
ret0, _ := ret[0].(types.AccountI)
return ret0
}
@ -82,10 +81,10 @@ func (mr *MockAccountKeeperMockRecorder) GetEnvironment() *gomock.Call {
}
// GetModuleAddress mocks base method.
func (m *MockAccountKeeper) GetModuleAddress(moduleName string) types0.AccAddress {
func (m *MockAccountKeeper) GetModuleAddress(moduleName string) types.AccAddress {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetModuleAddress", moduleName)
ret0, _ := ret[0].(types0.AccAddress)
ret0, _ := ret[0].(types.AccAddress)
return ret0
}
@ -96,10 +95,10 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(moduleName interface{}
}
// GetParams mocks base method.
func (m *MockAccountKeeper) GetParams(ctx context.Context) types1.Params {
func (m *MockAccountKeeper) GetParams(ctx context.Context) types0.Params {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetParams", ctx)
ret0, _ := ret[0].(types1.Params)
ret0, _ := ret[0].(types0.Params)
return ret0
}
@ -110,10 +109,10 @@ func (mr *MockAccountKeeperMockRecorder) GetParams(ctx interface{}) *gomock.Call
}
// NewAccountWithAddress mocks base method.
func (m *MockAccountKeeper) NewAccountWithAddress(ctx context.Context, addr types0.AccAddress) types0.AccountI {
func (m *MockAccountKeeper) NewAccountWithAddress(ctx context.Context, addr types.AccAddress) types.AccountI {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "NewAccountWithAddress", ctx, addr)
ret0, _ := ret[0].(types0.AccountI)
ret0, _ := ret[0].(types.AccountI)
return ret0
}
@ -124,7 +123,7 @@ func (mr *MockAccountKeeperMockRecorder) NewAccountWithAddress(ctx, addr interfa
}
// SetAccount mocks base method.
func (m *MockAccountKeeper) SetAccount(ctx context.Context, acc types0.AccountI) {
func (m *MockAccountKeeper) SetAccount(ctx context.Context, acc types.AccountI) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "SetAccount", ctx, acc)
}
@ -159,7 +158,7 @@ func (m *MockFeegrantKeeper) EXPECT() *MockFeegrantKeeperMockRecorder {
}
// UseGrantedFees mocks base method.
func (m *MockFeegrantKeeper) UseGrantedFees(ctx context.Context, granter, grantee types0.AccAddress, fee types0.Coins, msgs []types0.Msg) error {
func (m *MockFeegrantKeeper) UseGrantedFees(ctx context.Context, granter, grantee types.AccAddress, fee types.Coins, msgs []types.Msg) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "UseGrantedFees", ctx, granter, grantee, fee, msgs)
ret0, _ := ret[0].(error)
@ -195,17 +194,18 @@ func (m *MockConsensusKeeper) EXPECT() *MockConsensusKeeperMockRecorder {
return m.recorder
}
// Params mocks base method.
func (m *MockConsensusKeeper) Params(arg0 context.Context, arg1 *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
// BlockParams mocks base method.
func (m *MockConsensusKeeper) BlockParams(arg0 context.Context) (uint64, uint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Params", arg0, arg1)
ret0, _ := ret[0].(*types.QueryParamsResponse)
ret1, _ := ret[1].(error)
return ret0, ret1
ret := m.ctrl.Call(m, "BlockParams", arg0)
ret0, _ := ret[0].(uint64)
ret1, _ := ret[1].(uint64)
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
}
// Params indicates an expected call of Params.
func (mr *MockConsensusKeeperMockRecorder) Params(arg0, arg1 interface{}) *gomock.Call {
// BlockParams indicates an expected call of BlockParams.
func (mr *MockConsensusKeeperMockRecorder) BlockParams(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Params", reflect.TypeOf((*MockConsensusKeeper)(nil).Params), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BlockParams", reflect.TypeOf((*MockConsensusKeeper)(nil).BlockParams), arg0)
}

View File

@ -16,7 +16,6 @@ import (
"cosmossdk.io/core/header"
coretesting "cosmossdk.io/core/testing"
storetypes "cosmossdk.io/store/types"
consensustypes "cosmossdk.io/x/consensus/types"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
@ -101,10 +100,7 @@ func SetupTestSuite(t *testing.T, isCheckTx bool) *AnteTestSuite {
grpcQueryRouter.SetInterfaceRegistry(suite.encCfg.InterfaceRegistry)
suite.consensusKeeper = antetestutil.NewMockConsensusKeeper(ctrl)
suite.consensusKeeper.EXPECT().Params(gomock.Any(), gomock.Any()).Return(&consensustypes.QueryParamsResponse{
Params: simtestutil.DefaultConsensusParams,
}, nil).AnyTimes()
consensustypes.RegisterQueryServer(grpcQueryRouter, suite.consensusKeeper)
suite.consensusKeeper.EXPECT().BlockParams(gomock.Any()).Return(uint64(simtestutil.DefaultConsensusParams.Block.MaxGas), uint64(simtestutil.DefaultConsensusParams.Block.MaxBytes), nil).AnyTimes()
suite.env = runtime.NewEnvironment(runtime.NewKVStoreService(key), coretesting.NewNopLogger(), runtime.EnvWithQueryRouterService(grpcQueryRouter), runtime.EnvWithMsgRouterService(msgRouter))
suite.accountKeeper = keeper.NewAccountKeeper(
@ -127,6 +123,7 @@ func SetupTestSuite(t *testing.T, isCheckTx bool) *AnteTestSuite {
ante.HandlerOptions{
AccountKeeper: suite.accountKeeper,
BankKeeper: suite.bankKeeper,
ConsensusKeeper: suite.consensusKeeper,
FeegrantKeeper: suite.feeGrantKeeper,
SignModeHandler: suite.encCfg.TxConfig.SignModeHandler(),
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,

View File

@ -55,6 +55,7 @@ type ModuleInputs struct {
ProtoFileResolver txsigning.ProtoFileResolver
Environment appmodulev2.Environment
// BankKeeper is the expected bank keeper to be passed to AnteHandlers / Tx Validators
ConsensusKeeper ante.ConsensusKeeper
BankKeeper authtypes.BankKeeper `optional:"true"`
MetadataBankKeeper BankKeeper `optional:"true"`
AccountKeeper ante.AccountKeeper `optional:"true"`
@ -200,6 +201,7 @@ func newAnteHandler(txConfig client.TxConfig, in ModuleInputs) (sdk.AnteHandler,
ante.HandlerOptions{
Environment: in.Environment,
AccountKeeper: in.AccountKeeper,
ConsensusKeeper: in.ConsensusKeeper,
BankKeeper: in.BankKeeper,
SignModeHandler: txConfig.SignModeHandler(),
FeegrantKeeper: in.FeeGrantKeeper,

View File

@ -12,9 +12,7 @@ require (
cosmossdk.io/store v1.1.1-0.20240909133312-50288938d1b6 // main
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000
cosmossdk.io/x/tx v0.13.4-0.20240909133312-50288938d1b6 // main
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/cometbft/cometbft v1.0.0-rc1.0.20240908111210-ab0be101882f // indirect
cosmossdk.io/x/tx v0.13.4-0.20240909133312-50288938d1b6
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/cosmos/cosmos-sdk v0.52.0
github.com/cosmos/gogoproto v1.7.0
@ -28,13 +26,13 @@ require (
google.golang.org/protobuf v1.34.2
)
require cosmossdk.io/core/testing v0.0.0-20240909133312-50288938d1b6
require (
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab // indirect; main
cosmossdk.io/core/testing v0.0.0-20240909133312-50288938d1b6 // main
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab // indirect
cosmossdk.io/schema v0.2.0 // indirect
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.2 // indirect
@ -46,9 +44,12 @@ require (
github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cockroachdb/errors v1.11.3 // indirect
github.com/cockroachdb/fifo v0.0.0-20240816210425-c5d0cb0b6fc0 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/pebble v1.1.2 // indirect
github.com/cockroachdb/redact v1.1.5 // indirect
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/cometbft/cometbft v1.0.0-rc1.0.20240908111210-ab0be101882f // indirect
github.com/cometbft/cometbft-db v0.15.0 // indirect
github.com/cometbft/cometbft/api v1.0.0-rc.1 // indirect
github.com/cosmos/btcutil v1.0.5 // indirect
@ -83,6 +84,7 @@ require (
github.com/google/flatbuffers v24.3.25+incompatible // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/orderedcode v0.0.1 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/handlers v1.5.2 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
@ -166,11 +168,6 @@ require (
sigs.k8s.io/yaml v1.4.0 // indirect
)
require (
github.com/cockroachdb/fifo v0.0.0-20240816210425-c5d0cb0b6fc0 // indirect
github.com/google/uuid v1.6.0 // indirect
)
replace github.com/cosmos/cosmos-sdk => ../../.
// TODO remove post spinning out all modules
@ -180,6 +177,5 @@ replace (
// pseudo version lower than the latest tag
cosmossdk.io/store => cosmossdk.io/store v1.0.0-rc.0.0.20240906090851-36d9b25e8981 // main
cosmossdk.io/x/bank => ../bank
cosmossdk.io/x/consensus => ../consensus
cosmossdk.io/x/staking => ../staking
)

View File

@ -31,8 +31,6 @@ require (
require (
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
cosmossdk.io/schema v0.2.0 // indirect
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/tx v0.13.4-0.20240909133312-50288938d1b6 // indirect; main
filippo.io/edwards25519 v1.1.0 // indirect
@ -166,6 +164,7 @@ require (
)
require (
cosmossdk.io/schema v0.2.0 // indirect
github.com/cockroachdb/fifo v0.0.0-20240816210425-c5d0cb0b6fc0 // indirect
github.com/google/uuid v1.6.0 // indirect
)
@ -178,6 +177,5 @@ replace (
cosmossdk.io/api => cosmossdk.io/api v0.7.3-0.20240815194237-858ec2fcb897 // main
// pseudo version lower than the latest tag
cosmossdk.io/store => cosmossdk.io/store v1.0.0-rc.0.0.20240906090851-36d9b25e8981 // main
cosmossdk.io/x/consensus => ../consensus
cosmossdk.io/x/staking => ../staking
)

View File

@ -26,7 +26,6 @@ require (
cosmossdk.io/math v1.3.0 // indirect
cosmossdk.io/schema v0.2.0 // indirect
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/tx v0.13.4-0.20240909133312-50288938d1b6 // indirect; main
filippo.io/edwards25519 v1.1.0 // indirect
@ -177,6 +176,5 @@ replace (
// pseudo version lower than the latest tag
cosmossdk.io/store => cosmossdk.io/store v1.0.0-rc.0.0.20240906090851-36d9b25e8981 // main
cosmossdk.io/x/bank => ../bank
cosmossdk.io/x/consensus => ../consensus
cosmossdk.io/x/staking => ../staking
)

View File

@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"time"
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
cmttypes "github.com/cometbft/cometbft/types"
@ -143,3 +144,57 @@ func (k Keeper) paramCheck(ctx context.Context, consensusParams cmtproto.Consens
return &nextParams, nil
}
// BlockParams returns the maximum gas allowed in a block and the maximum bytes allowed in a block.
func (k Keeper) BlockParams(ctx context.Context) (uint64, uint64, error) {
params, err := k.ParamsStore.Get(ctx)
if err != nil {
return 0, 0, err
}
if params.Block == nil {
return 0, 0, errors.New("block gas is nil")
}
return uint64(params.Block.MaxGas), uint64(params.Block.MaxBytes), nil
}
// AppVersion returns the current application version.
func (k Keeper) AppVersion(ctx context.Context) (uint64, error) {
params, err := k.ParamsStore.Get(ctx)
if err != nil {
return 0, err
}
if params.Version == nil {
return 0, errors.New("app version is nil")
}
return params.Version.App, nil
}
// ValidatorPubKeyTypes returns the list of public key types that are allowed to be used for validators.
func (k Keeper) ValidatorPubKeyTypes(ctx context.Context) ([]string, error) {
params, err := k.ParamsStore.Get(ctx)
if err != nil {
return nil, err
}
fmt.Println("keyhere")
if params.Validator == nil {
return []string{}, errors.New("validator pub key types is nil")
}
return params.Validator.PubKeyTypes, nil
}
// EvidenceParams returns the maximum age of evidence, the time duration of the maximum age, and the maximum bytes.
func (k Keeper) EvidenceParams(ctx context.Context) (int64, time.Duration, uint64, error) {
params, err := k.ParamsStore.Get(ctx)
if err != nil {
return 0, 0, 0, err
}
if params.Evidence == nil {
return 0, 0, 0, errors.New("evidence age is nil")
}
return params.Evidence.MaxAgeNumBlocks, params.Evidence.MaxAgeDuration, uint64(params.Evidence.MaxBytes), nil
}

View File

@ -1,15 +0,0 @@
// Since: cosmos-sdk 0.52
syntax = "proto3";
package cosmos.consensus.v1;
import "cometbft/abci/v1/types.proto";
option go_package = "cosmossdk.io/x/consensus/types";
// CometInfo defines the structure of the x/consensus module's comet info.
message CometInfo {
repeated cometbft.abci.v1.Misbehavior evidence = 1;
bytes validators_hash = 2;
bytes proposer_address = 3;
cometbft.abci.v1.CommitInfo last_commit = 4;
}

View File

@ -1,503 +0,0 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: cosmos/consensus/v1/consensus.proto
package types
import (
fmt "fmt"
v1 "github.com/cometbft/cometbft/api/cometbft/abci/v1"
proto "github.com/cosmos/gogoproto/proto"
io "io"
math "math"
math_bits "math/bits"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
// CometInfo defines the structure of the x/consensus module's comet info.
type CometInfo struct {
Evidence []*v1.Misbehavior `protobuf:"bytes,1,rep,name=evidence,proto3" json:"evidence,omitempty"`
ValidatorsHash []byte `protobuf:"bytes,2,opt,name=validators_hash,json=validatorsHash,proto3" json:"validators_hash,omitempty"`
ProposerAddress []byte `protobuf:"bytes,3,opt,name=proposer_address,json=proposerAddress,proto3" json:"proposer_address,omitempty"`
LastCommit *v1.CommitInfo `protobuf:"bytes,4,opt,name=last_commit,json=lastCommit,proto3" json:"last_commit,omitempty"`
}
func (m *CometInfo) Reset() { *m = CometInfo{} }
func (m *CometInfo) String() string { return proto.CompactTextString(m) }
func (*CometInfo) ProtoMessage() {}
func (*CometInfo) Descriptor() ([]byte, []int) {
return fileDescriptor_7ed86dd7d42fb61b, []int{0}
}
func (m *CometInfo) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *CometInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_CometInfo.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *CometInfo) XXX_Merge(src proto.Message) {
xxx_messageInfo_CometInfo.Merge(m, src)
}
func (m *CometInfo) XXX_Size() int {
return m.Size()
}
func (m *CometInfo) XXX_DiscardUnknown() {
xxx_messageInfo_CometInfo.DiscardUnknown(m)
}
var xxx_messageInfo_CometInfo proto.InternalMessageInfo
func (m *CometInfo) GetEvidence() []*v1.Misbehavior {
if m != nil {
return m.Evidence
}
return nil
}
func (m *CometInfo) GetValidatorsHash() []byte {
if m != nil {
return m.ValidatorsHash
}
return nil
}
func (m *CometInfo) GetProposerAddress() []byte {
if m != nil {
return m.ProposerAddress
}
return nil
}
func (m *CometInfo) GetLastCommit() *v1.CommitInfo {
if m != nil {
return m.LastCommit
}
return nil
}
func init() {
proto.RegisterType((*CometInfo)(nil), "cosmos.consensus.v1.CometInfo")
}
func init() {
proto.RegisterFile("cosmos/consensus/v1/consensus.proto", fileDescriptor_7ed86dd7d42fb61b)
}
var fileDescriptor_7ed86dd7d42fb61b = []byte{
// 285 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x90, 0xb1, 0x4e, 0xf3, 0x30,
0x14, 0x85, 0xeb, 0xbf, 0xbf, 0x10, 0xb8, 0x88, 0xa2, 0xb0, 0x44, 0xa8, 0x58, 0x15, 0x0c, 0x94,
0xc5, 0x51, 0xca, 0x02, 0x03, 0x03, 0x74, 0x81, 0x81, 0x25, 0x23, 0x4b, 0xe4, 0x38, 0xae, 0x62,
0xd1, 0xe4, 0x46, 0xbe, 0xc6, 0x82, 0xb7, 0xe0, 0xb1, 0x18, 0x3b, 0xc2, 0x86, 0x92, 0x17, 0x41,
0x49, 0x28, 0x41, 0x62, 0x3c, 0xc7, 0xe7, 0x93, 0x7c, 0x3f, 0x7a, 0x22, 0x01, 0x73, 0xc0, 0x40,
0x42, 0x81, 0xaa, 0xc0, 0x27, 0x0c, 0x5c, 0xd8, 0x07, 0x5e, 0x1a, 0xb0, 0xe0, 0x1d, 0x74, 0x23,
0xde, 0xf7, 0x2e, 0x3c, 0x9c, 0x48, 0xc8, 0x95, 0x4d, 0x96, 0x36, 0x10, 0x89, 0xd4, 0x0d, 0x66,
0x5f, 0x4a, 0xf5, 0x8d, 0x1c, 0x7f, 0x10, 0xba, 0xb3, 0x68, 0x06, 0x77, 0xc5, 0x12, 0xbc, 0x4b,
0xba, 0xad, 0x9c, 0x4e, 0x55, 0x21, 0x95, 0x4f, 0xa6, 0xc3, 0xd9, 0x68, 0x7e, 0xc4, 0x37, 0x38,
0x6f, 0x70, 0xee, 0x42, 0x7e, 0xaf, 0x31, 0x51, 0x99, 0x70, 0x1a, 0x4c, 0xf4, 0x33, 0xf7, 0x4e,
0xe9, 0xd8, 0x89, 0x95, 0x4e, 0x85, 0x05, 0x83, 0x71, 0x26, 0x30, 0xf3, 0xff, 0x4d, 0xc9, 0x6c,
0x37, 0xda, 0xeb, 0xeb, 0x5b, 0x81, 0x99, 0x77, 0x46, 0xf7, 0x4b, 0x03, 0x25, 0xa0, 0x32, 0xb1,
0x48, 0x53, 0xa3, 0x10, 0xfd, 0x61, 0xbb, 0x1c, 0x6f, 0xfa, 0xeb, 0xae, 0xf6, 0xae, 0xe8, 0x68,
0x25, 0xd0, 0xc6, 0x12, 0xf2, 0x5c, 0x5b, 0xff, 0xff, 0x94, 0xcc, 0x46, 0xf3, 0xc9, 0xdf, 0x1f,
0x2d, 0xda, 0xf7, 0xe6, 0x82, 0x88, 0x36, 0x40, 0x97, 0x6f, 0x2e, 0xde, 0x2a, 0x46, 0xd6, 0x15,
0x23, 0x9f, 0x15, 0x23, 0xaf, 0x35, 0x1b, 0xac, 0x6b, 0x36, 0x78, 0xaf, 0xd9, 0xe0, 0x81, 0x75,
0xa2, 0x30, 0x7d, 0xe4, 0x1a, 0x82, 0xe7, 0x5f, 0x56, 0x5b, 0x37, 0xc9, 0x56, 0x2b, 0xe7, 0xfc,
0x2b, 0x00, 0x00, 0xff, 0xff, 0x7c, 0x63, 0x02, 0x4f, 0x76, 0x01, 0x00, 0x00,
}
func (m *CometInfo) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *CometInfo) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *CometInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if m.LastCommit != nil {
{
size, err := m.LastCommit.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintConsensus(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x22
}
if len(m.ProposerAddress) > 0 {
i -= len(m.ProposerAddress)
copy(dAtA[i:], m.ProposerAddress)
i = encodeVarintConsensus(dAtA, i, uint64(len(m.ProposerAddress)))
i--
dAtA[i] = 0x1a
}
if len(m.ValidatorsHash) > 0 {
i -= len(m.ValidatorsHash)
copy(dAtA[i:], m.ValidatorsHash)
i = encodeVarintConsensus(dAtA, i, uint64(len(m.ValidatorsHash)))
i--
dAtA[i] = 0x12
}
if len(m.Evidence) > 0 {
for iNdEx := len(m.Evidence) - 1; iNdEx >= 0; iNdEx-- {
{
size, err := m.Evidence[iNdEx].MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintConsensus(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0xa
}
}
return len(dAtA) - i, nil
}
func encodeVarintConsensus(dAtA []byte, offset int, v uint64) int {
offset -= sovConsensus(v)
base := offset
for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80)
v >>= 7
offset++
}
dAtA[offset] = uint8(v)
return base
}
func (m *CometInfo) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if len(m.Evidence) > 0 {
for _, e := range m.Evidence {
l = e.Size()
n += 1 + l + sovConsensus(uint64(l))
}
}
l = len(m.ValidatorsHash)
if l > 0 {
n += 1 + l + sovConsensus(uint64(l))
}
l = len(m.ProposerAddress)
if l > 0 {
n += 1 + l + sovConsensus(uint64(l))
}
if m.LastCommit != nil {
l = m.LastCommit.Size()
n += 1 + l + sovConsensus(uint64(l))
}
return n
}
func sovConsensus(x uint64) (n int) {
return (math_bits.Len64(x|1) + 6) / 7
}
func sozConsensus(x uint64) (n int) {
return sovConsensus(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (m *CometInfo) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowConsensus
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: CometInfo: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: CometInfo: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Evidence", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowConsensus
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthConsensus
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthConsensus
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Evidence = append(m.Evidence, &v1.Misbehavior{})
if err := m.Evidence[len(m.Evidence)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field ValidatorsHash", wireType)
}
var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowConsensus
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
byteLen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
return ErrInvalidLengthConsensus
}
postIndex := iNdEx + byteLen
if postIndex < 0 {
return ErrInvalidLengthConsensus
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.ValidatorsHash = append(m.ValidatorsHash[:0], dAtA[iNdEx:postIndex]...)
if m.ValidatorsHash == nil {
m.ValidatorsHash = []byte{}
}
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field ProposerAddress", wireType)
}
var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowConsensus
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
byteLen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
return ErrInvalidLengthConsensus
}
postIndex := iNdEx + byteLen
if postIndex < 0 {
return ErrInvalidLengthConsensus
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.ProposerAddress = append(m.ProposerAddress[:0], dAtA[iNdEx:postIndex]...)
if m.ProposerAddress == nil {
m.ProposerAddress = []byte{}
}
iNdEx = postIndex
case 4:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field LastCommit", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowConsensus
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthConsensus
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthConsensus
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.LastCommit == nil {
m.LastCommit = &v1.CommitInfo{}
}
if err := m.LastCommit.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipConsensus(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthConsensus
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipConsensus(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
depth := 0
for iNdEx < l {
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowConsensus
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
wireType := int(wire & 0x7)
switch wireType {
case 0:
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowConsensus
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
iNdEx++
if dAtA[iNdEx-1] < 0x80 {
break
}
}
case 1:
iNdEx += 8
case 2:
var length int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowConsensus
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
length |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if length < 0 {
return 0, ErrInvalidLengthConsensus
}
iNdEx += length
case 3:
depth++
case 4:
if depth == 0 {
return 0, ErrUnexpectedEndOfGroupConsensus
}
depth--
case 5:
iNdEx += 4
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
if iNdEx < 0 {
return 0, ErrInvalidLengthConsensus
}
if depth == 0 {
return iNdEx, nil
}
}
return 0, io.ErrUnexpectedEOF
}
var (
ErrInvalidLengthConsensus = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowConsensus = fmt.Errorf("proto: integer overflow")
ErrUnexpectedEndOfGroupConsensus = fmt.Errorf("proto: unexpected end of group")
)

View File

@ -9,11 +9,8 @@ require (
cosmossdk.io/core/testing v0.0.0-20240909133312-50288938d1b6 // main
cosmossdk.io/depinject v1.0.0
cosmossdk.io/errors v1.0.1
cosmossdk.io/log v1.4.1
cosmossdk.io/math v1.3.0
cosmossdk.io/store v1.1.1-0.20240909133312-50288938d1b6 // main
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91
cosmossdk.io/x/protocolpool v0.0.0-20230925135524-a1bc045b3190
cosmossdk.io/store v1.1.1-0.20240909133312-50288938d1b6
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/cosmos/cosmos-sdk v0.52.0
@ -33,9 +30,10 @@ require (
require (
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
cosmossdk.io/log v1.4.1 // indirect
cosmossdk.io/schema v0.2.0 // indirect
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/tx v0.13.4-0.20240909133312-50288938d1b6 // indirect; main
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
cosmossdk.io/x/tx v0.13.4-0.20240909133312-50288938d1b6 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.2 // indirect
@ -178,7 +176,6 @@ replace (
// pseudo version lower than the latest tag
cosmossdk.io/store => cosmossdk.io/store v1.0.0-rc.0.0.20240906090851-36d9b25e8981 // main
cosmossdk.io/x/bank => ../bank
cosmossdk.io/x/consensus => ../consensus
cosmossdk.io/x/protocolpool => ../protocolpool
cosmossdk.io/x/staking => ../staking
)

View File

@ -1,47 +0,0 @@
package v4_test
import (
"testing"
"github.com/stretchr/testify/require"
coretesting "cosmossdk.io/core/testing"
storetypes "cosmossdk.io/store/types"
"cosmossdk.io/x/distribution"
v4 "cosmossdk.io/x/distribution/migrations/v4"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
)
func TestMigration(t *testing.T) {
cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{}).Codec
storeKey := storetypes.NewKVStoreKey("distribution")
storeService := runtime.NewKVStoreService(storeKey)
tKey := storetypes.NewTransientStoreKey("transient_test")
ctx := testutil.DefaultContext(storeKey, tKey)
env := runtime.NewEnvironment(storeService, coretesting.NewNopLogger())
addr1 := secp256k1.GenPrivKey().PubKey().Address()
consAddr1 := sdk.ConsAddress(addr1)
// Set and check the previous proposer
err := v4.SetPreviousProposerConsAddr(ctx, storeService, cdc, consAddr1)
require.NoError(t, err)
gotAddr, err := v4.GetPreviousProposerConsAddr(ctx, storeService, cdc)
require.NoError(t, err)
require.Equal(t, consAddr1, gotAddr)
err = v4.MigrateStore(ctx, env, cdc)
require.NoError(t, err)
// Check that the previous proposer has been removed
_, err = v4.GetPreviousProposerConsAddr(ctx, storeService, cdc)
require.ErrorContains(t, err, "previous proposer not set")
}

View File

@ -20,14 +20,14 @@ require (
google.golang.org/grpc v1.66.0
)
require cosmossdk.io/schema v0.2.0 // indirect
require (
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
cosmossdk.io/log v1.4.1 // indirect
cosmossdk.io/math v1.3.0 // indirect
cosmossdk.io/schema v0.2.0 // indirect
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/tx v0.13.4-0.20240909133312-50288938d1b6 // indirect; main
filippo.io/edwards25519 v1.1.0 // indirect
@ -179,6 +179,5 @@ replace (
// pseudo version lower than the latest tag
cosmossdk.io/store => cosmossdk.io/store v1.0.0-rc.0.0.20240906090851-36d9b25e8981 // main
cosmossdk.io/x/bank => ../bank
cosmossdk.io/x/consensus => ../consensus
cosmossdk.io/x/staking => ../staking
)

View File

@ -31,6 +31,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [#20016](https://github.com/cosmos/cosmos-sdk/pull/20016) `NewMsgSubmitEvidence` now takes a string as argument instead of an `AccAddress`.
* [#19482](https://github.com/cosmos/cosmos-sdk/pull/19482) `appmodule.Environment` is passed to `NewKeeper` instead of individual services
* [#19627](https://github.com/cosmos/cosmos-sdk/pull/19627) `NewAppModule` now takes in a `codec.Codec` as its first argument
* [#21480](https://github.com/cosmos/cosmos-sdk/pull/21480) ConsensusKeeper is required to be passed to the keeper.
## [v0.1.1](https://github.com/cosmos/cosmos-sdk/releases/tag/x/evidence/v0.1.1) - 2024-04-22

View File

@ -33,9 +33,10 @@ type ModuleInputs struct {
EvidenceHandlers []eviclient.EvidenceHandler `optional:"true"`
CometService comet.Service
StakingKeeper types.StakingKeeper
SlashingKeeper types.SlashingKeeper
AddressCodec address.Codec
StakingKeeper types.StakingKeeper
SlashingKeeper types.SlashingKeeper
ConsensusKeeper types.ConsensusKeeper
AddressCodec address.Codec
}
type ModuleOutputs struct {
@ -46,7 +47,7 @@ type ModuleOutputs struct {
}
func ProvideModule(in ModuleInputs) ModuleOutputs {
k := keeper.NewKeeper(in.Cdc, in.Environment, in.StakingKeeper, in.SlashingKeeper, in.AddressCodec)
k := keeper.NewKeeper(in.Cdc, in.Environment, in.StakingKeeper, in.SlashingKeeper, in.ConsensusKeeper, in.AddressCodec)
m := NewAppModule(in.Cdc, *k, in.CometService, in.EvidenceHandlers...)
return ModuleOutputs{EvidenceKeeper: *k, Module: m}

View File

@ -10,8 +10,7 @@ require (
cosmossdk.io/depinject v1.0.0
cosmossdk.io/errors v1.0.1
cosmossdk.io/math v1.3.0
cosmossdk.io/store v1.1.1-0.20240909133312-50288938d1b6 // main
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000
cosmossdk.io/store v1.1.1-0.20240909133312-50288938d1b6
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/cosmos/cosmos-sdk v0.52.0
github.com/cosmos/gogoproto v1.7.0
@ -177,6 +176,5 @@ replace (
// pseudo version lower than the latest tag
cosmossdk.io/store => cosmossdk.io/store v1.0.0-rc.0.0.20240906090851-36d9b25e8981 // main
cosmossdk.io/x/bank => ../bank
cosmossdk.io/x/consensus => ../consensus
cosmossdk.io/x/staking => ../staking
)

View File

@ -5,7 +5,6 @@ import (
"fmt"
st "cosmossdk.io/api/cosmos/staking/v1beta1"
consensusv1 "cosmossdk.io/x/consensus/types"
"cosmossdk.io/x/evidence/types"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -73,27 +72,18 @@ func (k Keeper) handleEquivocationEvidence(ctx context.Context, evidence *types.
// Reject evidence if the double-sign is too old. Evidence is considered stale
// if the difference in time and number of blocks is greater than the allowed
// parameters defined.
resp, err := k.QueryRouterService.Invoke(ctx, &consensusv1.QueryParamsRequest{})
if err != nil {
return fmt.Errorf("failed to query consensus params: %w", err)
}
res, ok := resp.(*consensusv1.QueryParamsResponse)
if !ok {
return fmt.Errorf("unexpected response type: %T", resp)
}
if res.Params.Evidence != nil {
if ageDuration > res.Params.Evidence.MaxAgeDuration && ageBlocks > res.Params.Evidence.MaxAgeNumBlocks {
k.Logger.Info(
"ignored equivocation; evidence too old",
"validator", consAddr,
"infraction_height", infractionHeight,
"max_age_num_blocks", res.Params.Evidence.MaxAgeNumBlocks,
"infraction_time", infractionTime,
"max_age_duration", res.Params.Evidence.MaxAgeDuration,
)
return nil
}
eviAgeBlocks, eviAgeDuration, _, err := k.consensusKeeper.EvidenceParams(ctx)
if err == nil && ageDuration > eviAgeDuration && ageBlocks > eviAgeBlocks {
k.Logger.Info(
"ignored equivocation; evidence too old",
"validator", consAddr,
"infraction_height", infractionHeight,
"max_age_num_blocks", eviAgeBlocks,
"infraction_time", infractionTime,
"max_age_duration", eviAgeDuration,
)
return nil
}
if ok := k.slashingKeeper.HasValidatorSigningInfo(ctx, consAddr); !ok {

View File

@ -23,11 +23,12 @@ import (
type Keeper struct {
appmodule.Environment
cdc codec.BinaryCodec
router types.Router
stakingKeeper types.StakingKeeper
slashingKeeper types.SlashingKeeper
addressCodec address.Codec
cdc codec.BinaryCodec
router types.Router
stakingKeeper types.StakingKeeper
slashingKeeper types.SlashingKeeper
consensusKeeper types.ConsensusKeeper
addressCodec address.Codec
Schema collections.Schema
// Evidences key: evidence hash bytes | value: Evidence
@ -37,16 +38,17 @@ type Keeper struct {
// NewKeeper creates a new Keeper object.
func NewKeeper(
cdc codec.BinaryCodec, env appmodule.Environment, stakingKeeper types.StakingKeeper,
slashingKeeper types.SlashingKeeper, ac address.Codec,
slashingKeeper types.SlashingKeeper, ck types.ConsensusKeeper, ac address.Codec,
) *Keeper {
sb := collections.NewSchemaBuilder(env.KVStoreService)
k := &Keeper{
Environment: env,
cdc: cdc,
stakingKeeper: stakingKeeper,
slashingKeeper: slashingKeeper,
addressCodec: ac,
Evidences: collections.NewMap(sb, types.KeyPrefixEvidence, "evidences", collections.BytesKey, codec.CollInterfaceValue[exported.Evidence](cdc)),
Environment: env,
cdc: cdc,
stakingKeeper: stakingKeeper,
slashingKeeper: slashingKeeper,
consensusKeeper: ck,
addressCodec: ac,
Evidences: collections.NewMap(sb, types.KeyPrefixEvidence, "evidences", collections.BytesKey, codec.CollInterfaceValue[exported.Evidence](cdc)),
}
schema, err := sb.Build()
if err != nil {

View File

@ -102,12 +102,14 @@ func (suite *KeeperTestSuite) SetupTest() {
stakingKeeper := evidencetestutil.NewMockStakingKeeper(ctrl)
slashingKeeper := evidencetestutil.NewMockSlashingKeeper(ctrl)
accountKeeper := evidencetestutil.NewMockAccountKeeper(ctrl)
ck := evidencetestutil.NewMockConsensusKeeper(ctrl)
evidenceKeeper := keeper.NewKeeper(
encCfg.Codec,
env,
stakingKeeper,
slashingKeeper,
ck,
address.NewBech32Codec("cosmos"),
)

View File

@ -254,3 +254,43 @@ func (mr *MockAccountKeeperMockRecorder) SetAccount(ctx, acc interface{}) *gomoc
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetAccount", reflect.TypeOf((*MockAccountKeeper)(nil).SetAccount), ctx, acc)
}
// MockConsensusKeeper is a mock of ConsensusKeeper interface.
type MockConsensusKeeper struct {
ctrl *gomock.Controller
recorder *MockConsensusKeeperMockRecorder
}
// MockConsensusKeeperMockRecorder is the mock recorder for MockConsensusKeeper.
type MockConsensusKeeperMockRecorder struct {
mock *MockConsensusKeeper
}
// NewMockConsensusKeeper creates a new mock instance.
func NewMockConsensusKeeper(ctrl *gomock.Controller) *MockConsensusKeeper {
mock := &MockConsensusKeeper{ctrl: ctrl}
mock.recorder = &MockConsensusKeeperMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockConsensusKeeper) EXPECT() *MockConsensusKeeperMockRecorder {
return m.recorder
}
// EvidenceParams mocks base method.
func (m *MockConsensusKeeper) EvidenceParams(arg0 context.Context) (int64, time.Duration, uint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EvidenceParams", arg0)
ret0, _ := ret[0].(int64)
ret1, _ := ret[1].(time.Duration)
ret2, _ := ret[2].(uint64)
ret3, _ := ret[3].(error)
return ret0, ret1, ret2, ret3
}
// EvidenceParams indicates an expected call of EvidenceParams.
func (mr *MockConsensusKeeperMockRecorder) EvidenceParams(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EvidenceParams", reflect.TypeOf((*MockConsensusKeeper)(nil).EvidenceParams), arg0)
}

View File

@ -37,3 +37,7 @@ type SlashingKeeper interface {
type AccountKeeper interface {
SetAccount(ctx context.Context, acc sdk.AccountI)
}
type ConsensusKeeper interface {
EvidenceParams(context.Context) (maxAge int64, maxAgeDuration time.Duration, maxBytes uint64, err error)
}

View File

@ -38,7 +38,6 @@ require (
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
cosmossdk.io/log v1.4.1 // indirect
cosmossdk.io/schema v0.2.0 // indirect
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/protocolpool v0.0.0-20230925135524-a1bc045b3190 // indirect
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/tx v0.13.4-0.20240909133312-50288938d1b6 // indirect; main
@ -184,7 +183,6 @@ replace (
// pseudo version lower than the latest tag
cosmossdk.io/store => cosmossdk.io/store v1.0.0-rc.0.0.20240906090851-36d9b25e8981 // main
cosmossdk.io/x/bank => ../bank
cosmossdk.io/x/consensus => ../consensus
cosmossdk.io/x/gov => ../gov
cosmossdk.io/x/staking => ../staking
)

View File

@ -42,8 +42,7 @@ require (
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
cosmossdk.io/schema v0.2.0 // indirect
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/tx v0.13.4-0.20240909133312-50288938d1b6 // indirect; main
cosmossdk.io/x/tx v0.13.4-0.20240909133312-50288938d1b6 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.2 // indirect
@ -183,7 +182,6 @@ replace (
// pseudo version lower than the latest tag
cosmossdk.io/store => cosmossdk.io/store v1.0.0-rc.0.0.20240906090851-36d9b25e8981 // main
cosmossdk.io/x/bank => ../bank
cosmossdk.io/x/consensus => ../consensus
cosmossdk.io/x/protocolpool => ../protocolpool
cosmossdk.io/x/staking => ../staking
)

View File

@ -27,7 +27,9 @@ require (
)
require (
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
cosmossdk.io/schema v0.2.0 // indirect
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/tx v0.13.4-0.20240909133312-50288938d1b6 // indirect; main
@ -49,6 +51,7 @@ require (
github.com/cometbft/cometbft-db v0.15.0 // indirect
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/cosmos-db v1.0.3-0.20240829004618-717cba019b33 // indirect
github.com/cosmos/crypto v0.1.2 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cosmos/gogogateway v1.2.0 // indirect
github.com/cosmos/iavl v1.3.0 // indirect
@ -57,6 +60,7 @@ require (
github.com/danieljoos/wincred v1.2.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
github.com/dgraph-io/badger/v4 v4.3.0 // indirect
github.com/dgraph-io/ristretto v0.1.2-0.20240116140435-c67e07994f91 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/dvsekhvalnov/jose2go v1.6.0 // indirect
@ -71,8 +75,10 @@ require (
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/gogo/googleapis v1.4.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/btree v1.1.3 // indirect
github.com/google/flatbuffers v24.3.25+incompatible // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/orderedcode v0.0.1 // indirect
github.com/gorilla/handlers v1.5.2 // indirect
@ -85,6 +91,7 @@ require (
github.com/hashicorp/go-metrics v0.5.3 // indirect
github.com/hashicorp/go-plugin v1.6.1 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/hdevalence/ed25519consensus v0.2.0 // indirect
@ -104,6 +111,7 @@ require (
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mtibben/percent v0.2.1 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect
github.com/oklog/run v1.1.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
@ -128,6 +136,7 @@ require (
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.19.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/supranational/blst v0.3.13 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
github.com/tidwall/btree v1.7.0 // indirect
@ -136,6 +145,7 @@ require (
gitlab.com/yawning/secp256k1-voi v0.0.0-20230925100816-f2616030848b // indirect
gitlab.com/yawning/tuplehash v0.0.0-20230713102510-df83abbf9a02 // indirect
go.etcd.io/bbolt v1.4.0-alpha.1 // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect
@ -156,20 +166,9 @@ require (
)
require (
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
cosmossdk.io/schema v0.2.0 // indirect
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
github.com/cockroachdb/fifo v0.0.0-20240816210425-c5d0cb0b6fc0 // indirect
github.com/cometbft/cometbft/api v1.0.0-rc.1 // indirect
github.com/cosmos/crypto v0.1.2 // indirect
github.com/dgraph-io/badger/v4 v4.3.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/flatbuffers v24.3.25+incompatible // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/supranational/blst v0.3.13 // indirect
go.opencensus.io v0.24.0 // indirect
)
replace github.com/cosmos/cosmos-sdk => ../../.

View File

@ -27,7 +27,6 @@ require (
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab // indirect; main
cosmossdk.io/schema v0.2.0 // indirect
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/tx v0.13.4-0.20240909133312-50288938d1b6 // indirect; main
filippo.io/edwards25519 v1.1.0 // indirect
@ -176,6 +175,5 @@ replace (
// pseudo version lower than the latest tag
cosmossdk.io/store => cosmossdk.io/store v1.0.0-rc.0.0.20240906090851-36d9b25e8981 // main
cosmossdk.io/x/bank => ../bank
cosmossdk.io/x/consensus => ../consensus
cosmossdk.io/x/staking => ../staking
)

View File

@ -31,7 +31,6 @@ require (
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab // indirect; main
cosmossdk.io/schema v0.2.0 // indirect
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/tx v0.13.4-0.20240909133312-50288938d1b6 // indirect; main
filippo.io/edwards25519 v1.1.0 // indirect
@ -177,7 +176,6 @@ replace (
// pseudo version lower than the latest tag
cosmossdk.io/store => cosmossdk.io/store v1.0.0-rc.0.0.20240906090851-36d9b25e8981 // main
cosmossdk.io/x/bank => ../bank
cosmossdk.io/x/consensus => ../consensus
cosmossdk.io/x/distribution => ../distribution
cosmossdk.io/x/gov => ../gov
cosmossdk.io/x/mint => ../mint

View File

@ -30,7 +30,6 @@ require (
cosmossdk.io/log v1.4.1 // indirect
cosmossdk.io/schema v0.2.0 // indirect
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/tx v0.13.4-0.20240909133312-50288938d1b6 // indirect; main
filippo.io/edwards25519 v1.1.0 // indirect
@ -177,6 +176,5 @@ replace (
// pseudo version lower than the latest tag
cosmossdk.io/store => cosmossdk.io/store v1.0.0-rc.0.0.20240906090851-36d9b25e8981 // main
cosmossdk.io/x/bank => ../bank
cosmossdk.io/x/consensus => ../consensus
cosmossdk.io/x/staking => ../staking
)

View File

@ -32,8 +32,7 @@ require (
cosmossdk.io/log v1.4.1 // indirect
cosmossdk.io/schema v0.2.0 // indirect
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/tx v0.13.4-0.20240909133312-50288938d1b6 // indirect; main
cosmossdk.io/x/tx v0.13.4-0.20240909133312-50288938d1b6 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.2 // indirect
@ -178,6 +177,5 @@ replace (
// pseudo version lower than the latest tag
cosmossdk.io/store => cosmossdk.io/store v1.0.0-rc.0.0.20240906090851-36d9b25e8981 // main
cosmossdk.io/x/bank => ../bank
cosmossdk.io/x/consensus => ../consensus
cosmossdk.io/x/staking => ../staking
)

View File

@ -96,6 +96,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [#17335](https://github.com/cosmos/cosmos-sdk/pull/17335) Remove usage of `"cosmossdk.io/x/staking/types".Infraction_*` in favour of `"cosmossdk.io/api/cosmos/staking/v1beta1".Infraction_` in order to remove dependency between modules on staking
* [#20295](https://github.com/cosmos/cosmos-sdk/pull/20295) `GetValidatorByConsAddr` now returns the Cosmos SDK `cryptotypes.Pubkey` instead of `cometcrypto.Publickey`. The caller is responsible to translate the returned value to the expected type.
* Remove `CmtConsPublicKey()` and `TmConsPublicKey()` from `Validator` interface and as methods on the `Validator` struct.
* [#21480](https://github.com/cosmos/cosmos-sdk/pull/21480) ConsensusKeeper is required to be passed to the keeper.
### State Breaking changes

View File

@ -43,6 +43,7 @@ type ModuleInputs struct {
ConsensusAddressCodec address.ConsensusAddressCodec
AccountKeeper types.AccountKeeper
BankKeeper types.BankKeeper
ConsensusKeeper types.ConsensusKeeper
Cdc codec.Codec
Environment appmodule.Environment
CometInfoService comet.Service
@ -73,6 +74,7 @@ func ProvideModule(in ModuleInputs) ModuleOutputs {
in.Environment,
in.AccountKeeper,
in.BankKeeper,
in.ConsensusKeeper,
as,
in.ValidatorAddressCodec,
in.ConsensusAddressCodec,

View File

@ -35,7 +35,6 @@ require (
cosmossdk.io/log v1.4.1
cosmossdk.io/schema v0.2.0 // indirect
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000
cosmossdk.io/x/tx v0.13.4-0.20240909133312-50288938d1b6 // indirect; main
filippo.io/edwards25519 v1.1.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
@ -48,6 +47,7 @@ require (
github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cockroachdb/errors v1.11.3 // indirect
github.com/cockroachdb/fifo v0.0.0-20240816210425-c5d0cb0b6fc0 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/pebble v1.1.2 // indirect
github.com/cockroachdb/redact v1.1.5 // indirect
@ -85,6 +85,7 @@ require (
github.com/google/flatbuffers v24.3.25+incompatible // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/orderedcode v0.0.1 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/handlers v1.5.2 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
@ -165,11 +166,6 @@ require (
sigs.k8s.io/yaml v1.4.0 // indirect
)
require (
github.com/cockroachdb/fifo v0.0.0-20240816210425-c5d0cb0b6fc0 // indirect
github.com/google/uuid v1.6.0 // indirect
)
replace github.com/cosmos/cosmos-sdk => ../../.
// TODO remove post spinning out all modules
@ -179,5 +175,4 @@ replace (
// pseudo version lower than the latest tag
cosmossdk.io/store => cosmossdk.io/store v1.0.0-rc.0.0.20240906090851-36d9b25e8981 // main
cosmossdk.io/x/bank => ../bank
cosmossdk.io/x/consensus => ../consensus
)

View File

@ -57,6 +57,7 @@ type Keeper struct {
cdc codec.BinaryCodec
authKeeper types.AccountKeeper
bankKeeper types.BankKeeper
consensusKeeper types.ConsensusKeeper
hooks types.StakingHooks
authority string
validatorAddressCodec addresscodec.Codec
@ -119,6 +120,7 @@ func NewKeeper(
env appmodule.Environment,
ak types.AccountKeeper,
bk types.BankKeeper,
ck types.ConsensusKeeper,
authority string,
validatorAddressCodec addresscodec.Codec,
consensusAddressCodec addresscodec.Codec,
@ -148,6 +150,7 @@ func NewKeeper(
cdc: cdc,
authKeeper: ak,
bankKeeper: bk,
consensusKeeper: ck,
hooks: nil,
authority: authority,
validatorAddressCodec: validatorAddressCodec,

View File

@ -14,7 +14,6 @@ import (
"cosmossdk.io/log"
"cosmossdk.io/math"
storetypes "cosmossdk.io/store/types"
consensustypes "cosmossdk.io/x/consensus/types"
stakingkeeper "cosmossdk.io/x/staking/keeper"
stakingtestutil "cosmossdk.io/x/staking/testutil"
stakingtypes "cosmossdk.io/x/staking/types"
@ -81,14 +80,11 @@ func (s *KeeperTestSuite) SetupTest() {
// create consensus keeper
ck := stakingtestutil.NewMockConsensusKeeper(ctrl)
ck.EXPECT().Params(gomock.Any(), gomock.Any()).Return(&consensustypes.QueryParamsResponse{
Params: simtestutil.DefaultConsensusParams,
}, nil).AnyTimes()
ck.EXPECT().ValidatorPubKeyTypes(gomock.Any()).Return(simtestutil.DefaultConsensusParams.Validator.PubKeyTypes, nil).AnyTimes()
queryHelper := baseapp.NewQueryServerTestHelper(ctx, encCfg.InterfaceRegistry)
consensustypes.RegisterQueryServer(queryHelper, ck)
bankKeeper := stakingtestutil.NewMockBankKeeper(ctrl)
env := runtime.NewEnvironment(storeService, coretesting.NewNopLogger(), runtime.EnvWithQueryRouterService(queryHelper.GRPCQueryRouter), runtime.EnvWithMsgRouterService(s.baseApp.MsgServiceRouter()))
env := runtime.NewEnvironment(storeService, coretesting.NewNopLogger(), runtime.EnvWithMsgRouterService(s.baseApp.MsgServiceRouter()))
authority, err := accountKeeper.AddressCodec().BytesToString(authtypes.NewModuleAddress(stakingtypes.GovModuleName))
s.Require().NoError(err)
keeper := stakingkeeper.NewKeeper(
@ -96,6 +92,7 @@ func (s *KeeperTestSuite) SetupTest() {
env,
accountKeeper,
bankKeeper,
ck,
authority,
address.NewBech32Codec("cosmosvaloper"),
address.NewBech32Codec("cosmosvalcons"),

View File

@ -17,7 +17,6 @@ import (
"cosmossdk.io/core/event"
errorsmod "cosmossdk.io/errors"
"cosmossdk.io/math"
consensusv1 "cosmossdk.io/x/consensus/types"
"cosmossdk.io/x/staking/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
@ -75,20 +74,24 @@ func (k msgServer) CreateValidator(ctx context.Context, msg *types.MsgCreateVali
return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidType, "Expecting cryptotypes.PubKey, got %T", cv)
}
resp, err := k.QueryRouterService.Invoke(ctx, &consensusv1.QueryParamsRequest{})
pubkeyTypes, err := k.consensusKeeper.ValidatorPubKeyTypes(ctx)
if err != nil {
return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "failed to query consensus params: %s", err)
}
res, ok := resp.(*consensusv1.QueryParamsResponse)
if !ok {
return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "unexpected response type: %T", resp)
pkType := pk.Type()
if !slices.Contains(pubkeyTypes, pkType) {
return nil, errorsmod.Wrapf(
types.ErrValidatorPubKeyTypeNotSupported,
"got: %s, expected: %s", pk.Type(), pubkeyTypes,
)
}
if res.Params.Validator == nil {
if pubkeyTypes == nil {
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "validator params are not set")
}
if err = validatePubKey(pk, res.Params.Validator.PubKeyTypes); err != nil {
if err = validatePubKey(pk, pubkeyTypes); err != nil {
return nil, err
}
@ -660,21 +663,16 @@ func (k msgServer) RotateConsPubKey(ctx context.Context, msg *types.MsgRotateCon
return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidType, "expecting cryptotypes.PubKey, got %T", cv)
}
// check if the new public key type is valid
resp, err := k.QueryRouterService.Invoke(ctx, &consensusv1.QueryParamsRequest{})
pubkeyTypes, err := k.consensusKeeper.ValidatorPubKeyTypes(ctx)
if err != nil {
return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "failed to query consensus params: %s", err)
}
paramsRes, ok := resp.(*consensusv1.QueryParamsResponse)
if !ok {
return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "unexpected response type: %T", resp)
return nil, err
}
if paramsRes.Params.Validator == nil {
if pubkeyTypes == nil {
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "validator params are not set")
}
if err = validatePubKey(pk, paramsRes.Params.Validator.PubKeyTypes); err != nil {
if err = validatePubKey(pk, pubkeyTypes); err != nil {
return nil, err
}

View File

@ -11,10 +11,9 @@ import (
stakingv1beta1 "cosmossdk.io/api/cosmos/staking/v1beta1"
address "cosmossdk.io/core/address"
math "cosmossdk.io/math"
types "cosmossdk.io/x/consensus/types"
types0 "cosmossdk.io/x/staking/types"
types1 "github.com/cosmos/cosmos-sdk/crypto/types"
types2 "github.com/cosmos/cosmos-sdk/types"
types "cosmossdk.io/x/staking/types"
types0 "github.com/cosmos/cosmos-sdk/crypto/types"
types1 "github.com/cosmos/cosmos-sdk/types"
gomock "github.com/golang/mock/gomock"
)
@ -56,10 +55,10 @@ func (mr *MockAccountKeeperMockRecorder) AddressCodec() *gomock.Call {
}
// GetAccount mocks base method.
func (m *MockAccountKeeper) GetAccount(ctx context.Context, addr types2.AccAddress) types2.AccountI {
func (m *MockAccountKeeper) GetAccount(ctx context.Context, addr types1.AccAddress) types1.AccountI {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetAccount", ctx, addr)
ret0, _ := ret[0].(types2.AccountI)
ret0, _ := ret[0].(types1.AccountI)
return ret0
}
@ -70,10 +69,10 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomo
}
// GetModuleAccount mocks base method.
func (m *MockAccountKeeper) GetModuleAccount(ctx context.Context, moduleName string) types2.ModuleAccountI {
func (m *MockAccountKeeper) GetModuleAccount(ctx context.Context, moduleName string) types1.ModuleAccountI {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetModuleAccount", ctx, moduleName)
ret0, _ := ret[0].(types2.ModuleAccountI)
ret0, _ := ret[0].(types1.ModuleAccountI)
return ret0
}
@ -84,10 +83,10 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAccount(ctx, moduleName interf
}
// GetModuleAddress mocks base method.
func (m *MockAccountKeeper) GetModuleAddress(name string) types2.AccAddress {
func (m *MockAccountKeeper) GetModuleAddress(name string) types1.AccAddress {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetModuleAddress", name)
ret0, _ := ret[0].(types2.AccAddress)
ret0, _ := ret[0].(types1.AccAddress)
return ret0
}
@ -98,7 +97,7 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(name interface{}) *gom
}
// SetModuleAccount mocks base method.
func (m *MockAccountKeeper) SetModuleAccount(arg0 context.Context, arg1 types2.ModuleAccountI) {
func (m *MockAccountKeeper) SetModuleAccount(arg0 context.Context, arg1 types1.ModuleAccountI) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "SetModuleAccount", arg0, arg1)
}
@ -133,7 +132,7 @@ func (m *MockBankKeeper) EXPECT() *MockBankKeeperMockRecorder {
}
// BurnCoins mocks base method.
func (m *MockBankKeeper) BurnCoins(arg0 context.Context, arg1 []byte, arg2 types2.Coins) error {
func (m *MockBankKeeper) BurnCoins(arg0 context.Context, arg1 []byte, arg2 types1.Coins) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "BurnCoins", arg0, arg1, arg2)
ret0, _ := ret[0].(error)
@ -147,7 +146,7 @@ func (mr *MockBankKeeperMockRecorder) BurnCoins(arg0, arg1, arg2 interface{}) *g
}
// DelegateCoinsFromAccountToModule mocks base method.
func (m *MockBankKeeper) DelegateCoinsFromAccountToModule(ctx context.Context, senderAddr types2.AccAddress, recipientModule string, amt types2.Coins) error {
func (m *MockBankKeeper) DelegateCoinsFromAccountToModule(ctx context.Context, senderAddr types1.AccAddress, recipientModule string, amt types1.Coins) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "DelegateCoinsFromAccountToModule", ctx, senderAddr, recipientModule, amt)
ret0, _ := ret[0].(error)
@ -161,10 +160,10 @@ func (mr *MockBankKeeperMockRecorder) DelegateCoinsFromAccountToModule(ctx, send
}
// GetAllBalances mocks base method.
func (m *MockBankKeeper) GetAllBalances(ctx context.Context, addr types2.AccAddress) types2.Coins {
func (m *MockBankKeeper) GetAllBalances(ctx context.Context, addr types1.AccAddress) types1.Coins {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetAllBalances", ctx, addr)
ret0, _ := ret[0].(types2.Coins)
ret0, _ := ret[0].(types1.Coins)
return ret0
}
@ -175,10 +174,10 @@ func (mr *MockBankKeeperMockRecorder) GetAllBalances(ctx, addr interface{}) *gom
}
// GetBalance mocks base method.
func (m *MockBankKeeper) GetBalance(ctx context.Context, addr types2.AccAddress, denom string) types2.Coin {
func (m *MockBankKeeper) GetBalance(ctx context.Context, addr types1.AccAddress, denom string) types1.Coin {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetBalance", ctx, addr, denom)
ret0, _ := ret[0].(types2.Coin)
ret0, _ := ret[0].(types1.Coin)
return ret0
}
@ -189,10 +188,10 @@ func (mr *MockBankKeeperMockRecorder) GetBalance(ctx, addr, denom interface{}) *
}
// GetSupply mocks base method.
func (m *MockBankKeeper) GetSupply(ctx context.Context, denom string) types2.Coin {
func (m *MockBankKeeper) GetSupply(ctx context.Context, denom string) types1.Coin {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetSupply", ctx, denom)
ret0, _ := ret[0].(types2.Coin)
ret0, _ := ret[0].(types1.Coin)
return ret0
}
@ -217,10 +216,10 @@ func (mr *MockBankKeeperMockRecorder) IsSendEnabledDenom(ctx, denom interface{})
}
// LockedCoins mocks base method.
func (m *MockBankKeeper) LockedCoins(ctx context.Context, addr types2.AccAddress) types2.Coins {
func (m *MockBankKeeper) LockedCoins(ctx context.Context, addr types1.AccAddress) types1.Coins {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "LockedCoins", ctx, addr)
ret0, _ := ret[0].(types2.Coins)
ret0, _ := ret[0].(types1.Coins)
return ret0
}
@ -231,7 +230,7 @@ func (mr *MockBankKeeperMockRecorder) LockedCoins(ctx, addr interface{}) *gomock
}
// SendCoinsFromAccountToModule mocks base method.
func (m *MockBankKeeper) SendCoinsFromAccountToModule(ctx context.Context, senderAddr types2.AccAddress, recipientModule string, amt types2.Coins) error {
func (m *MockBankKeeper) SendCoinsFromAccountToModule(ctx context.Context, senderAddr types1.AccAddress, recipientModule string, amt types1.Coins) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "SendCoinsFromAccountToModule", ctx, senderAddr, recipientModule, amt)
ret0, _ := ret[0].(error)
@ -245,7 +244,7 @@ func (mr *MockBankKeeperMockRecorder) SendCoinsFromAccountToModule(ctx, senderAd
}
// SendCoinsFromModuleToModule mocks base method.
func (m *MockBankKeeper) SendCoinsFromModuleToModule(ctx context.Context, senderPool, recipientPool string, amt types2.Coins) error {
func (m *MockBankKeeper) SendCoinsFromModuleToModule(ctx context.Context, senderPool, recipientPool string, amt types1.Coins) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "SendCoinsFromModuleToModule", ctx, senderPool, recipientPool, amt)
ret0, _ := ret[0].(error)
@ -259,10 +258,10 @@ func (mr *MockBankKeeperMockRecorder) SendCoinsFromModuleToModule(ctx, senderPoo
}
// SpendableCoins mocks base method.
func (m *MockBankKeeper) SpendableCoins(ctx context.Context, addr types2.AccAddress) types2.Coins {
func (m *MockBankKeeper) SpendableCoins(ctx context.Context, addr types1.AccAddress) types1.Coins {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "SpendableCoins", ctx, addr)
ret0, _ := ret[0].(types2.Coins)
ret0, _ := ret[0].(types1.Coins)
return ret0
}
@ -273,7 +272,7 @@ func (mr *MockBankKeeperMockRecorder) SpendableCoins(ctx, addr interface{}) *gom
}
// UndelegateCoinsFromModuleToAccount mocks base method.
func (m *MockBankKeeper) UndelegateCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr types2.AccAddress, amt types2.Coins) error {
func (m *MockBankKeeper) UndelegateCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr types1.AccAddress, amt types1.Coins) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "UndelegateCoinsFromModuleToAccount", ctx, senderModule, recipientAddr, amt)
ret0, _ := ret[0].(error)
@ -310,10 +309,10 @@ func (m *MockValidatorSet) EXPECT() *MockValidatorSetMockRecorder {
}
// Delegation mocks base method.
func (m *MockValidatorSet) Delegation(arg0 context.Context, arg1 types2.AccAddress, arg2 types2.ValAddress) (types2.DelegationI, error) {
func (m *MockValidatorSet) Delegation(arg0 context.Context, arg1 types1.AccAddress, arg2 types1.ValAddress) (types1.DelegationI, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Delegation", arg0, arg1, arg2)
ret0, _ := ret[0].(types2.DelegationI)
ret0, _ := ret[0].(types1.DelegationI)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -325,10 +324,10 @@ func (mr *MockValidatorSetMockRecorder) Delegation(arg0, arg1, arg2 interface{})
}
// GetPubKeyByConsAddr mocks base method.
func (m *MockValidatorSet) GetPubKeyByConsAddr(arg0 context.Context, arg1 types2.ConsAddress) (types1.PubKey, error) {
func (m *MockValidatorSet) GetPubKeyByConsAddr(arg0 context.Context, arg1 types1.ConsAddress) (types0.PubKey, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetPubKeyByConsAddr", arg0, arg1)
ret0, _ := ret[0].(types1.PubKey)
ret0, _ := ret[0].(types0.PubKey)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -340,7 +339,7 @@ func (mr *MockValidatorSetMockRecorder) GetPubKeyByConsAddr(arg0, arg1 interface
}
// IterateBondedValidatorsByPower mocks base method.
func (m *MockValidatorSet) IterateBondedValidatorsByPower(arg0 context.Context, arg1 func(int64, types2.ValidatorI) bool) error {
func (m *MockValidatorSet) IterateBondedValidatorsByPower(arg0 context.Context, arg1 func(int64, types1.ValidatorI) bool) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "IterateBondedValidatorsByPower", arg0, arg1)
ret0, _ := ret[0].(error)
@ -354,7 +353,7 @@ func (mr *MockValidatorSetMockRecorder) IterateBondedValidatorsByPower(arg0, arg
}
// IterateValidators mocks base method.
func (m *MockValidatorSet) IterateValidators(arg0 context.Context, arg1 func(int64, types2.ValidatorI) bool) error {
func (m *MockValidatorSet) IterateValidators(arg0 context.Context, arg1 func(int64, types1.ValidatorI) bool) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "IterateValidators", arg0, arg1)
ret0, _ := ret[0].(error)
@ -368,7 +367,7 @@ func (mr *MockValidatorSetMockRecorder) IterateValidators(arg0, arg1 interface{}
}
// Jail mocks base method.
func (m *MockValidatorSet) Jail(arg0 context.Context, arg1 types2.ConsAddress) error {
func (m *MockValidatorSet) Jail(arg0 context.Context, arg1 types1.ConsAddress) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Jail", arg0, arg1)
ret0, _ := ret[0].(error)
@ -397,7 +396,7 @@ func (mr *MockValidatorSetMockRecorder) MaxValidators(arg0 interface{}) *gomock.
}
// Slash mocks base method.
func (m *MockValidatorSet) Slash(arg0 context.Context, arg1 types2.ConsAddress, arg2, arg3 int64, arg4 math.LegacyDec) (math.Int, error) {
func (m *MockValidatorSet) Slash(arg0 context.Context, arg1 types1.ConsAddress, arg2, arg3 int64, arg4 math.LegacyDec) (math.Int, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Slash", arg0, arg1, arg2, arg3, arg4)
ret0, _ := ret[0].(math.Int)
@ -412,7 +411,7 @@ func (mr *MockValidatorSetMockRecorder) Slash(arg0, arg1, arg2, arg3, arg4 inter
}
// SlashWithInfractionReason mocks base method.
func (m *MockValidatorSet) SlashWithInfractionReason(arg0 context.Context, arg1 types2.ConsAddress, arg2, arg3 int64, arg4 math.LegacyDec, arg5 stakingv1beta1.Infraction) (math.Int, error) {
func (m *MockValidatorSet) SlashWithInfractionReason(arg0 context.Context, arg1 types1.ConsAddress, arg2, arg3 int64, arg4 math.LegacyDec, arg5 stakingv1beta1.Infraction) (math.Int, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "SlashWithInfractionReason", arg0, arg1, arg2, arg3, arg4, arg5)
ret0, _ := ret[0].(math.Int)
@ -457,7 +456,7 @@ func (mr *MockValidatorSetMockRecorder) TotalBondedTokens(arg0 interface{}) *gom
}
// Unjail mocks base method.
func (m *MockValidatorSet) Unjail(arg0 context.Context, arg1 types2.ConsAddress) error {
func (m *MockValidatorSet) Unjail(arg0 context.Context, arg1 types1.ConsAddress) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Unjail", arg0, arg1)
ret0, _ := ret[0].(error)
@ -471,10 +470,10 @@ func (mr *MockValidatorSetMockRecorder) Unjail(arg0, arg1 interface{}) *gomock.C
}
// Validator mocks base method.
func (m *MockValidatorSet) Validator(arg0 context.Context, arg1 types2.ValAddress) (types2.ValidatorI, error) {
func (m *MockValidatorSet) Validator(arg0 context.Context, arg1 types1.ValAddress) (types1.ValidatorI, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Validator", arg0, arg1)
ret0, _ := ret[0].(types2.ValidatorI)
ret0, _ := ret[0].(types1.ValidatorI)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -486,10 +485,10 @@ func (mr *MockValidatorSetMockRecorder) Validator(arg0, arg1 interface{}) *gomoc
}
// ValidatorByConsAddr mocks base method.
func (m *MockValidatorSet) ValidatorByConsAddr(arg0 context.Context, arg1 types2.ConsAddress) (types2.ValidatorI, error) {
func (m *MockValidatorSet) ValidatorByConsAddr(arg0 context.Context, arg1 types1.ConsAddress) (types1.ValidatorI, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ValidatorByConsAddr", arg0, arg1)
ret0, _ := ret[0].(types2.ValidatorI)
ret0, _ := ret[0].(types1.ValidatorI)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -524,10 +523,10 @@ func (m *MockDelegationSet) EXPECT() *MockDelegationSetMockRecorder {
}
// GetValidatorSet mocks base method.
func (m *MockDelegationSet) GetValidatorSet() types0.ValidatorSet {
func (m *MockDelegationSet) GetValidatorSet() types.ValidatorSet {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetValidatorSet")
ret0, _ := ret[0].(types0.ValidatorSet)
ret0, _ := ret[0].(types.ValidatorSet)
return ret0
}
@ -538,7 +537,7 @@ func (mr *MockDelegationSetMockRecorder) GetValidatorSet() *gomock.Call {
}
// IterateDelegations mocks base method.
func (m *MockDelegationSet) IterateDelegations(ctx context.Context, delegator types2.AccAddress, fn func(int64, types2.DelegationI) bool) error {
func (m *MockDelegationSet) IterateDelegations(ctx context.Context, delegator types1.AccAddress, fn func(int64, types1.DelegationI) bool) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "IterateDelegations", ctx, delegator, fn)
ret0, _ := ret[0].(error)
@ -575,7 +574,7 @@ func (m *MockStakingHooks) EXPECT() *MockStakingHooksMockRecorder {
}
// AfterConsensusPubKeyUpdate mocks base method.
func (m *MockStakingHooks) AfterConsensusPubKeyUpdate(ctx context.Context, oldPubKey, newPubKey types1.PubKey, rotationFee types2.Coin) error {
func (m *MockStakingHooks) AfterConsensusPubKeyUpdate(ctx context.Context, oldPubKey, newPubKey types0.PubKey, rotationFee types1.Coin) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "AfterConsensusPubKeyUpdate", ctx, oldPubKey, newPubKey, rotationFee)
ret0, _ := ret[0].(error)
@ -589,7 +588,7 @@ func (mr *MockStakingHooksMockRecorder) AfterConsensusPubKeyUpdate(ctx, oldPubKe
}
// AfterDelegationModified mocks base method.
func (m *MockStakingHooks) AfterDelegationModified(ctx context.Context, delAddr types2.AccAddress, valAddr types2.ValAddress) error {
func (m *MockStakingHooks) AfterDelegationModified(ctx context.Context, delAddr types1.AccAddress, valAddr types1.ValAddress) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "AfterDelegationModified", ctx, delAddr, valAddr)
ret0, _ := ret[0].(error)
@ -617,7 +616,7 @@ func (mr *MockStakingHooksMockRecorder) AfterUnbondingInitiated(ctx, id interfac
}
// AfterValidatorBeginUnbonding mocks base method.
func (m *MockStakingHooks) AfterValidatorBeginUnbonding(ctx context.Context, consAddr types2.ConsAddress, valAddr types2.ValAddress) error {
func (m *MockStakingHooks) AfterValidatorBeginUnbonding(ctx context.Context, consAddr types1.ConsAddress, valAddr types1.ValAddress) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "AfterValidatorBeginUnbonding", ctx, consAddr, valAddr)
ret0, _ := ret[0].(error)
@ -631,7 +630,7 @@ func (mr *MockStakingHooksMockRecorder) AfterValidatorBeginUnbonding(ctx, consAd
}
// AfterValidatorBonded mocks base method.
func (m *MockStakingHooks) AfterValidatorBonded(ctx context.Context, consAddr types2.ConsAddress, valAddr types2.ValAddress) error {
func (m *MockStakingHooks) AfterValidatorBonded(ctx context.Context, consAddr types1.ConsAddress, valAddr types1.ValAddress) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "AfterValidatorBonded", ctx, consAddr, valAddr)
ret0, _ := ret[0].(error)
@ -645,7 +644,7 @@ func (mr *MockStakingHooksMockRecorder) AfterValidatorBonded(ctx, consAddr, valA
}
// AfterValidatorCreated mocks base method.
func (m *MockStakingHooks) AfterValidatorCreated(ctx context.Context, valAddr types2.ValAddress) error {
func (m *MockStakingHooks) AfterValidatorCreated(ctx context.Context, valAddr types1.ValAddress) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "AfterValidatorCreated", ctx, valAddr)
ret0, _ := ret[0].(error)
@ -659,7 +658,7 @@ func (mr *MockStakingHooksMockRecorder) AfterValidatorCreated(ctx, valAddr inter
}
// AfterValidatorRemoved mocks base method.
func (m *MockStakingHooks) AfterValidatorRemoved(ctx context.Context, consAddr types2.ConsAddress, valAddr types2.ValAddress) error {
func (m *MockStakingHooks) AfterValidatorRemoved(ctx context.Context, consAddr types1.ConsAddress, valAddr types1.ValAddress) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "AfterValidatorRemoved", ctx, consAddr, valAddr)
ret0, _ := ret[0].(error)
@ -673,7 +672,7 @@ func (mr *MockStakingHooksMockRecorder) AfterValidatorRemoved(ctx, consAddr, val
}
// BeforeDelegationCreated mocks base method.
func (m *MockStakingHooks) BeforeDelegationCreated(ctx context.Context, delAddr types2.AccAddress, valAddr types2.ValAddress) error {
func (m *MockStakingHooks) BeforeDelegationCreated(ctx context.Context, delAddr types1.AccAddress, valAddr types1.ValAddress) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "BeforeDelegationCreated", ctx, delAddr, valAddr)
ret0, _ := ret[0].(error)
@ -687,7 +686,7 @@ func (mr *MockStakingHooksMockRecorder) BeforeDelegationCreated(ctx, delAddr, va
}
// BeforeDelegationRemoved mocks base method.
func (m *MockStakingHooks) BeforeDelegationRemoved(ctx context.Context, delAddr types2.AccAddress, valAddr types2.ValAddress) error {
func (m *MockStakingHooks) BeforeDelegationRemoved(ctx context.Context, delAddr types1.AccAddress, valAddr types1.ValAddress) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "BeforeDelegationRemoved", ctx, delAddr, valAddr)
ret0, _ := ret[0].(error)
@ -701,7 +700,7 @@ func (mr *MockStakingHooksMockRecorder) BeforeDelegationRemoved(ctx, delAddr, va
}
// BeforeDelegationSharesModified mocks base method.
func (m *MockStakingHooks) BeforeDelegationSharesModified(ctx context.Context, delAddr types2.AccAddress, valAddr types2.ValAddress) error {
func (m *MockStakingHooks) BeforeDelegationSharesModified(ctx context.Context, delAddr types1.AccAddress, valAddr types1.ValAddress) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "BeforeDelegationSharesModified", ctx, delAddr, valAddr)
ret0, _ := ret[0].(error)
@ -715,7 +714,7 @@ func (mr *MockStakingHooksMockRecorder) BeforeDelegationSharesModified(ctx, delA
}
// BeforeValidatorModified mocks base method.
func (m *MockStakingHooks) BeforeValidatorModified(ctx context.Context, valAddr types2.ValAddress) error {
func (m *MockStakingHooks) BeforeValidatorModified(ctx context.Context, valAddr types1.ValAddress) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "BeforeValidatorModified", ctx, valAddr)
ret0, _ := ret[0].(error)
@ -729,7 +728,7 @@ func (mr *MockStakingHooksMockRecorder) BeforeValidatorModified(ctx, valAddr int
}
// BeforeValidatorSlashed mocks base method.
func (m *MockStakingHooks) BeforeValidatorSlashed(ctx context.Context, valAddr types2.ValAddress, fraction math.LegacyDec) error {
func (m *MockStakingHooks) BeforeValidatorSlashed(ctx context.Context, valAddr types1.ValAddress, fraction math.LegacyDec) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "BeforeValidatorSlashed", ctx, valAddr, fraction)
ret0, _ := ret[0].(error)
@ -765,17 +764,17 @@ func (m *MockConsensusKeeper) EXPECT() *MockConsensusKeeperMockRecorder {
return m.recorder
}
// Params mocks base method.
func (m *MockConsensusKeeper) Params(arg0 context.Context, arg1 *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
// ValidatorPubKeyTypes mocks base method.
func (m *MockConsensusKeeper) ValidatorPubKeyTypes(arg0 context.Context) ([]string, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Params", arg0, arg1)
ret0, _ := ret[0].(*types.QueryParamsResponse)
ret := m.ctrl.Call(m, "ValidatorPubKeyTypes", arg0)
ret0, _ := ret[0].([]string)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// Params indicates an expected call of Params.
func (mr *MockConsensusKeeperMockRecorder) Params(arg0, arg1 interface{}) *gomock.Call {
// ValidatorPubKeyTypes indicates an expected call of ValidatorPubKeyTypes.
func (mr *MockConsensusKeeperMockRecorder) ValidatorPubKeyTypes(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Params", reflect.TypeOf((*MockConsensusKeeper)(nil).Params), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidatorPubKeyTypes", reflect.TypeOf((*MockConsensusKeeper)(nil).ValidatorPubKeyTypes), arg0)
}

View File

@ -6,7 +6,6 @@ import (
st "cosmossdk.io/api/cosmos/staking/v1beta1"
"cosmossdk.io/core/address"
"cosmossdk.io/math"
consensustypes "cosmossdk.io/x/consensus/types"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -117,5 +116,5 @@ type StakingHooksWrapper struct{ StakingHooks }
func (StakingHooksWrapper) IsOnePerModuleType() {}
type ConsensusKeeper interface {
Params(context.Context, *consensustypes.QueryParamsRequest) (*consensustypes.QueryParamsResponse, error)
ValidatorPubKeyTypes(context.Context) ([]string, error)
}

View File

@ -33,6 +33,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [#19443](https://github.com/cosmos/cosmos-sdk/pull/19443) `NewKeeper` takes an `appmodule.Environment` instead of individual services.
* [#21259](https://github.com/cosmos/cosmos-sdk/pull/21259) Upgrade has been migrated to cosrestore.StoreUpgrades. Renaming keys support has been removed from the upgrade module.
* [#21480](https://github.com/cosmos/cosmos-sdk/pull/21480) ConsensusKeeper is required to be passed to the keeper.
### State Machine Breaking

View File

@ -41,6 +41,7 @@ type ModuleInputs struct {
Cdc codec.Codec
AddressCodec address.Codec
AppVersionModifier coreserver.VersionModifier
ConsensusKeeper types.ConsensusKeeper
AppOpts servertypes.AppOptions `optional:"true"` // server v0
Viper *viper.Viper `optional:"true"` // server v2
@ -85,7 +86,7 @@ func ProvideModule(in ModuleInputs) ModuleOutputs {
}
// set the governance module account as the authority for conducting upgrades
k := keeper.NewKeeper(in.Environment, skipUpgradeHeights, in.Cdc, homePath, in.AppVersionModifier, authorityStr)
k := keeper.NewKeeper(in.Environment, skipUpgradeHeights, in.Cdc, homePath, in.AppVersionModifier, authorityStr, in.ConsensusKeeper)
m := NewAppModule(k)
return ModuleOutputs{UpgradeKeeper: k, Module: m}

View File

@ -9,8 +9,7 @@ require (
cosmossdk.io/depinject v1.0.0
cosmossdk.io/errors v1.0.1
cosmossdk.io/log v1.4.1
cosmossdk.io/store v1.1.1-0.20240909133312-50288938d1b6 // main
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000
cosmossdk.io/store v1.1.1-0.20240909133312-50288938d1b6
cosmossdk.io/x/gov v0.0.0-20230925135524-a1bc045b3190
github.com/cometbft/cometbft v1.0.0-rc1.0.20240908111210-ab0be101882f
github.com/cometbft/cometbft/api v1.0.0-rc.1
@ -18,6 +17,7 @@ require (
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/cosmos/cosmos-sdk v0.52.0
github.com/cosmos/gogoproto v1.7.0
github.com/golang/mock v1.6.0
github.com/golang/protobuf v1.5.4
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/hashicorp/go-cleanhttp v0.5.2
@ -96,7 +96,6 @@ require (
github.com/gogo/googleapis v1.4.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/btree v1.1.3 // indirect
github.com/google/flatbuffers v24.3.25+incompatible // indirect
@ -207,7 +206,6 @@ replace (
// pseudo version lower than the latest tag
cosmossdk.io/store => cosmossdk.io/store v1.0.0-rc.0.0.20240906090851-36d9b25e8981 // main
cosmossdk.io/x/bank => ../bank
cosmossdk.io/x/consensus => ../consensus
cosmossdk.io/x/gov => ../gov
cosmossdk.io/x/staking => ../staking
)

View File

@ -5,7 +5,6 @@ import (
"errors"
"fmt"
consensusv1 "cosmossdk.io/x/consensus/types"
"cosmossdk.io/x/upgrade/types"
"github.com/cosmos/cosmos-sdk/telemetry"
@ -43,20 +42,9 @@ func (k Keeper) PreBlocker(ctx context.Context) error {
}
if lastAppliedPlan != "" && !k.HasHandler(lastAppliedPlan) {
var appVersion uint64
resp, err := k.QueryRouterService.Invoke(ctx, &consensusv1.QueryParamsRequest{})
appVersion, err := k.consensusKeeper.AppVersion(ctx)
if err != nil {
return errors.New("failed to query consensus params")
}
res, ok := resp.(*consensusv1.QueryParamsResponse)
if !ok {
return fmt.Errorf("unexpected response type: %T", resp)
}
if res.Params.Version != nil {
appVersion = res.Params.Version.App
return err
}
return fmt.Errorf("wrong app version %d, upgrade handler is missing for %s upgrade plan", appVersion, lastAppliedPlan)

View File

@ -8,6 +8,7 @@ import (
"time"
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"
"cosmossdk.io/core/appmodule"
@ -18,6 +19,7 @@ import (
storetypes "cosmossdk.io/store/types"
"cosmossdk.io/x/upgrade"
"cosmossdk.io/x/upgrade/keeper"
upgradetestutil "cosmossdk.io/x/upgrade/testutil"
"cosmossdk.io/x/upgrade/types"
"github.com/cosmos/cosmos-sdk/baseapp"
@ -138,7 +140,9 @@ func setupTest(t *testing.T, height int64, skip map[int64]bool) *TestSuite {
authority, err := addresscodec.NewBech32Codec("cosmos").BytesToString(authtypes.NewModuleAddress(govModuleName))
require.NoError(t, err)
s.keeper = keeper.NewKeeper(s.env, skip, s.encCfg.Codec, t.TempDir(), s.baseApp, authority)
ctrl := gomock.NewController(t)
ck := upgradetestutil.NewMockConsensusKeeper(ctrl)
s.keeper = keeper.NewKeeper(s.env, skip, s.encCfg.Codec, t.TempDir(), s.baseApp, authority, ck)
s.ctx = testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now(), Height: height})
@ -529,8 +533,11 @@ func TestDowngradeVerification(t *testing.T) {
authority, err := addresscodec.NewBech32Codec("cosmos").BytesToString(authtypes.NewModuleAddress(govModuleName))
require.NoError(t, err)
ctrl := gomock.NewController(t)
// downgrade. now keeper does not have the handler.
k := keeper.NewKeeper(s.env, map[int64]bool{}, s.encCfg.Codec, t.TempDir(), nil, authority)
ck := upgradetestutil.NewMockConsensusKeeper(ctrl)
ck.EXPECT().AppVersion(gomock.Any()).Return(uint64(0), nil).AnyTimes()
k := keeper.NewKeeper(s.env, map[int64]bool{}, s.encCfg.Codec, t.TempDir(), nil, authority, ck)
m := upgrade.NewAppModule(k)
// assertions

View File

@ -5,6 +5,7 @@ import (
"fmt"
"testing"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/suite"
"cosmossdk.io/core/appmodule"
@ -13,6 +14,7 @@ import (
storetypes "cosmossdk.io/store/types"
"cosmossdk.io/x/upgrade"
"cosmossdk.io/x/upgrade/keeper"
upgradetestutil "cosmossdk.io/x/upgrade/testutil"
"cosmossdk.io/x/upgrade/types"
"github.com/cosmos/cosmos-sdk/baseapp"
@ -47,7 +49,9 @@ func (suite *UpgradeTestSuite) SetupTest() {
authority, err := addresscodec.NewBech32Codec("cosmos").BytesToString(authtypes.NewModuleAddress(types.GovModuleName))
suite.Require().NoError(err)
suite.encodedAuthority = authority
suite.upgradeKeeper = keeper.NewKeeper(env, skipUpgradeHeights, suite.encCfg.Codec, suite.T().TempDir(), nil, authority)
ctrl := gomock.NewController(suite.T())
ck := upgradetestutil.NewMockConsensusKeeper(ctrl)
suite.upgradeKeeper = keeper.NewKeeper(env, skipUpgradeHeights, suite.encCfg.Codec, suite.T().TempDir(), nil, authority, ck)
err = suite.upgradeKeeper.SetModuleVersionMap(suite.ctx, appmodule.VersionMap{
"bank": 0,
})

View File

@ -38,6 +38,8 @@ type Keeper struct {
downgradeVerified bool // tells if we've already sanity checked that this binary version isn't being used against an old state.
authority string // the address capable of executing and canceling an upgrade. Usually the gov module account
initVersionMap appmodule.VersionMap // the module version map at init genesis
consensusKeeper types.ConsensusKeeper
}
// NewKeeper constructs an upgrade Keeper which requires the following arguments:
@ -53,6 +55,7 @@ func NewKeeper(
homePath string,
vs server.VersionModifier,
authority string,
ck types.ConsensusKeeper,
) *Keeper {
k := &Keeper{
Environment: env,
@ -62,6 +65,7 @@ func NewKeeper(
upgradeHandlers: map[string]types.UpgradeHandler{},
versionModifier: vs,
authority: authority,
consensusKeeper: ck,
}
if homePath == "" {

View File

@ -7,6 +7,7 @@ import (
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
cmttypes "github.com/cometbft/cometbft/types"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/suite"
"cosmossdk.io/core/appmodule"
@ -16,6 +17,7 @@ import (
storetypes "cosmossdk.io/store/types"
"cosmossdk.io/x/upgrade"
"cosmossdk.io/x/upgrade/keeper"
upgradetestutil "cosmossdk.io/x/upgrade/testutil"
"cosmossdk.io/x/upgrade/types"
"github.com/cosmos/cosmos-sdk/baseapp"
@ -73,7 +75,9 @@ func (s *KeeperTestSuite) SetupTest() {
authority, err := ac.BytesToString(authtypes.NewModuleAddress(types.GovModuleName))
s.Require().NoError(err)
s.encodedAuthority = authority
s.upgradeKeeper = keeper.NewKeeper(env, skipUpgradeHeights, s.encCfg.Codec, homeDir, s.baseApp, authority)
ctrl := gomock.NewController(s.T())
s.upgradeKeeper = keeper.NewKeeper(env, skipUpgradeHeights, s.encCfg.Codec, homeDir, s.baseApp, authority, upgradetestutil.NewMockConsensusKeeper(ctrl))
s.T().Log("home dir:", homeDir)
s.homeDir = homeDir
@ -257,7 +261,8 @@ func (s *KeeperTestSuite) TestIsSkipHeight() {
skip := map[int64]bool{skipOne: true}
storeService := runtime.NewKVStoreService(s.key)
env := runtime.NewEnvironment(storeService, coretesting.NewNopLogger())
upgradeKeeper := keeper.NewKeeper(env, skip, s.encCfg.Codec, s.T().TempDir(), s.baseApp, s.encodedAuthority)
ctrl := gomock.NewController(s.T())
upgradeKeeper := keeper.NewKeeper(env, skip, s.encCfg.Codec, s.T().TempDir(), s.baseApp, s.encodedAuthority, upgradetestutil.NewMockConsensusKeeper(ctrl))
s.Require().True(upgradeKeeper.IsSkipHeight(9))
s.Require().False(upgradeKeeper.IsSkipHeight(10))
}

View File

@ -0,0 +1,50 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: x/upgrade/types/expected_keepers.go
// Package testutil is a generated GoMock package.
package testutil
import (
context "context"
reflect "reflect"
gomock "github.com/golang/mock/gomock"
)
// MockConsensusKeeper is a mock of ConsensusKeeper interface.
type MockConsensusKeeper struct {
ctrl *gomock.Controller
recorder *MockConsensusKeeperMockRecorder
}
// MockConsensusKeeperMockRecorder is the mock recorder for MockConsensusKeeper.
type MockConsensusKeeperMockRecorder struct {
mock *MockConsensusKeeper
}
// NewMockConsensusKeeper creates a new mock instance.
func NewMockConsensusKeeper(ctrl *gomock.Controller) *MockConsensusKeeper {
mock := &MockConsensusKeeper{ctrl: ctrl}
mock.recorder = &MockConsensusKeeperMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockConsensusKeeper) EXPECT() *MockConsensusKeeperMockRecorder {
return m.recorder
}
// AppVersion mocks base method.
func (m *MockConsensusKeeper) AppVersion(ctx context.Context) (uint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "AppVersion", ctx)
ret0, _ := ret[0].(uint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// AppVersion indicates an expected call of AppVersion.
func (mr *MockConsensusKeeperMockRecorder) AppVersion(ctx interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AppVersion", reflect.TypeOf((*MockConsensusKeeper)(nil).AppVersion), ctx)
}

View File

@ -0,0 +1,7 @@
package types
import "context"
type ConsensusKeeper interface {
AppVersion(ctx context.Context) (uint64, error)
}