Skip to content

Commit

Permalink
remove democracy staking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
shaspitz committed Mar 10, 2023
1 parent a651abc commit 1269163
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 32 deletions.
4 changes: 2 additions & 2 deletions app/consumer-democracy/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ func New(
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper),
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.ConsumerKeeper),
ccvdistr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, authtypes.FeeCollectorName),
ccvstaking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.ConsumerKeeper),
ccvstaking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
upgrade.NewAppModule(app.UpgradeKeeper),
evidence.NewAppModule(app.EvidenceKeeper),
params.NewAppModule(app.ParamsKeeper),
Expand Down Expand Up @@ -587,7 +587,7 @@ func New(
feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
ccvgov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper, IsProposalWhitelisted),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper),
ccvstaking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.ConsumerKeeper),
ccvstaking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
ccvdistr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, authtypes.FeeCollectorName),
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
params.NewAppModule(app.ParamsKeeper),
Expand Down
12 changes: 0 additions & 12 deletions x/ccv/democracy/staking/expected_keepers.go

This file was deleted.

37 changes: 19 additions & 18 deletions x/ccv/democracy/staking/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,37 +29,35 @@ type AppModule struct {
// embed the Cosmos SDK's x/staking AppModule
staking.AppModule

keeper keeper.Keeper
accKeeper types.AccountKeeper
bankKeeper types.BankKeeper
consumerKeeper ConsumerKeeper
keeper keeper.Keeper
accKeeper types.AccountKeeper
bankKeeper types.BankKeeper
}

// NewAppModule creates a new AppModule object using the native x/staking module
// AppModule constructor.
func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak types.AccountKeeper, bk types.BankKeeper, ck ConsumerKeeper) AppModule {
func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak types.AccountKeeper, bk types.BankKeeper) AppModule {
stakingAppMod := staking.NewAppModule(cdc, keeper, ak, bk)
return AppModule{
AppModule: stakingAppMod,
keeper: keeper,
accKeeper: ak,
bankKeeper: bk,
consumerKeeper: ck,
AppModule: stakingAppMod,
keeper: keeper,
accKeeper: ak,
bankKeeper: bk,
}
}

// InitGenesis delegates the InitGenesis call to the underlying x/staking module,
// however, it returns no validator updates as validators are tracked via the
// consumer chain's x/cvv/consumer module and so this module is not responsible
// for returning the initial validator set.
//
// Note: InitGenesis is not called during the soft upgrade of a module (as a part of a migration from sovereign -> consumer chain),
// so there is no special handling needed in this method for a consumer being in the pre-CCV state.
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate {
var genesisState types.GenesisState

cdc.MustUnmarshalJSON(data, &genesisState)
valUpdates := staking.InitGenesis(ctx, am.keeper, am.accKeeper, am.bankKeeper, &genesisState)
if am.consumerKeeper.IsPreCCV(ctx) {
return valUpdates
}
_ = staking.InitGenesis(ctx, am.keeper, am.accKeeper, am.bankKeeper, &genesisState)

return []abci.ValidatorUpdate{}
}
Expand All @@ -68,10 +66,13 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.
// however, it returns no validator updates as validators are tracked via the
// consumer chain's x/cvv/consumer module and so this module is not responsible
// for returning the initial validator set.
//
// Note: This method does not require any special handling for PreCCV being true
// (as a part of the migration from sovereign -> consumer chain).
// The ccv consumer Endblocker is ordered to run before the staking Endblocker,
// so if PreCCV is true during one block, the ccv consumer Enblocker will return the proper validator updates,
// the PreCCV flag will be toggled to false, and no validator updates should be returned by this method.
func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
valUpdates := am.keeper.BlockValidatorUpdates(ctx)
if am.consumerKeeper.IsPreCCV(ctx) {
return valUpdates
}
_ = am.keeper.BlockValidatorUpdates(ctx)
return []abci.ValidatorUpdate{}
}

0 comments on commit 1269163

Please sign in to comment.