diff --git a/app/provider/app.go b/app/provider/app.go index e6876137b9..214d191b71 100644 --- a/app/provider/app.go +++ b/app/provider/app.go @@ -350,10 +350,7 @@ func New( authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) - // Remove the ConsumerRewardsPool from the group of blocked recipient addresses in bank - // this is required for the provider chain to be able to receive tokens from - // the consumer chain - bankBlockedAddrs := BankBlockedAddrs(app) + bankBlockedAddrs := ComputeBankBlockedAddrs(app) app.BankKeeper = bankkeeper.NewBaseKeeper( appCodec, @@ -802,7 +799,11 @@ func New( return app } -func BankBlockedAddrs(app *App) map[string]bool { +// Computes the addresses that should be blocked by the Bank module. +// We remove the ConsumerRewardsPool from the group of blocked recipient addresses in bank. +// This is required for the provider chain to be able to receive tokens from +// the consumer chain +func ComputeBankBlockedAddrs(app *App) map[string]bool { bankBlockedAddrs := app.ModuleAccountAddrs() delete(bankBlockedAddrs, authtypes.NewModuleAddress( providertypes.ConsumerRewardsPool).String()) diff --git a/docs/docs/adrs/adr-017-allowing-inactive-validators.md b/docs/docs/adrs/adr-017-allowing-inactive-validators.md index dd4ff1b10a..c75e34363a 100644 --- a/docs/docs/adrs/adr-017-allowing-inactive-validators.md +++ b/docs/docs/adrs/adr-017-allowing-inactive-validators.md @@ -58,7 +58,7 @@ achieved without further changes to staking or reward distributions, because sim The following changes to the state are required: -* Introduce the `MaxProviderConsensusValidators` parameter to the provider module, which is the number of validators that the provider module will send to consumer chains. +* Introduce the `MaxProviderConsensusValidators` parameter to the provider module, which is the number of validators that the provider module will send to the consensus engine. * Store the provider consensus validator set in the provider module state under the `LastProviderConsensusValsPrefix` key. This is the last set of validators that the provider sent to the consensus engine. This is needed to compute the ValUpdates to send to the consensus engine (by diffing the current set with this last sent set). * Increase the `MaxValidators` parameter of the staking module to the desired size of the potential validator set of consumer chains. diff --git a/x/ccv/provider/keeper/legacy_proposal.go b/x/ccv/provider/keeper/legacy_proposal.go index 49f5c0001e..d14773e5ed 100644 --- a/x/ccv/provider/keeper/legacy_proposal.go +++ b/x/ccv/provider/keeper/legacy_proposal.go @@ -125,7 +125,7 @@ func (k Keeper) HandleLegacyConsumerModificationProposal(ctx sdk.Context, p *typ if p.Top_N != oldTopN { if p.Top_N > 0 { // if the chain receives a non-zero top N value, store the minimum power in the top N - activeValidators, err := k.GetLastActiveBondedValidators(ctx) + activeValidators, err := k.GetLastProviderConsensusActiveValidators(ctx) if err != nil { return err } diff --git a/x/ccv/provider/keeper/proposal.go b/x/ccv/provider/keeper/proposal.go index 10aaf088e4..96d70b48a2 100644 --- a/x/ccv/provider/keeper/proposal.go +++ b/x/ccv/provider/keeper/proposal.go @@ -271,7 +271,7 @@ func (k Keeper) MakeConsumerGenesis( // we do not want to base the power calculation for the top N // on inactive validators, too, since the top N will be a percentage of the active set power // otherwise, it could be that inactive validators are forced to validate - activeValidators, err := k.GetLastActiveBondedValidators(ctx) + activeValidators, err := k.GetLastProviderConsensusActiveValidators(ctx) if err != nil { return gen, nil, errorsmod.Wrapf(stakingtypes.ErrNoValidatorFound, "error getting last active bonded validators: %s", err) } diff --git a/x/ccv/provider/keeper/relay.go b/x/ccv/provider/keeper/relay.go index 0a04b0bb6d..c95bd71079 100644 --- a/x/ccv/provider/keeper/relay.go +++ b/x/ccv/provider/keeper/relay.go @@ -60,9 +60,6 @@ func (k Keeper) OnTimeoutPacket(ctx sdk.Context, packet channeltypes.Packet) err // the Validator Set Update sub-protocol func (k Keeper) EndBlockVSU(ctx sdk.Context) ([]abci.ValidatorUpdate, error) { // logic to update the provider consensus validator set. - // Important: must be called before the rest of EndBlockVSU, because - // we need to know the updated provider validator set - // to compute the minimum power in the top N valUpdates := k.ProviderValidatorUpdates(ctx) if k.BlocksUntilNextEpoch(ctx) == 0 { @@ -205,7 +202,7 @@ func (k Keeper) QueueVSCPackets(ctx sdk.Context) { if topN > 0 { // in a Top-N chain, we automatically opt in all validators that belong to the top N // of the active validators - activeValidators, err := k.GetLastActiveBondedValidators(ctx) + activeValidators, err := k.GetLastProviderConsensusActiveValidators(ctx) if err != nil { // something must be broken in the bonded validators, so we have to panic since there is no realistic way to proceed panic(fmt.Errorf("failed to get active validators: %w", err)) diff --git a/x/ccv/provider/keeper/validator_set_update.go b/x/ccv/provider/keeper/validator_set_update.go index 26935a79e1..1c55f26553 100644 --- a/x/ccv/provider/keeper/validator_set_update.go +++ b/x/ccv/provider/keeper/validator_set_update.go @@ -203,7 +203,9 @@ func (k Keeper) GetLastBondedValidators(ctx sdk.Context) ([]stakingtypes.Validat return ccv.GetLastBondedValidatorsUtil(ctx, k.stakingKeeper, k.Logger(ctx), maxVals) } -func (k Keeper) GetLastActiveBondedValidators(ctx sdk.Context) ([]stakingtypes.Validator, error) { +// GetLastProviderConsensusActiveValidators returns the `MaxProviderConsensusValidators` many validators with the largest powers +// from the last bonded validators in the staking module. +func (k Keeper) GetLastProviderConsensusActiveValidators(ctx sdk.Context) ([]stakingtypes.Validator, error) { maxVals := k.GetMaxProviderConsensusValidators(ctx) return ccv.GetLastBondedValidatorsUtil(ctx, k.stakingKeeper, k.Logger(ctx), uint32(maxVals)) }