Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: add InitOptions to x/distribution keeper for protocol pool enabling #23936

Draft
wants to merge 6 commits into
base: chore/pp
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 92 additions & 25 deletions api/cosmos/distribution/module/v1/module.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion proto/cosmos/distribution/module/v1/module.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ message Module {

// authority defines the custom module authority. If not set, defaults to the governance module.
string authority = 2;
}

// ProtocolPoolEnabled determines whether the protocol pool is to be enabled, meaning community pool funds
// will be directed to x/protocolpool.
bool protocol_pool_enabled = 3;
}
15 changes: 12 additions & 3 deletions simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,16 @@ func NewSimApp(
)
app.MintKeeper = mintkeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[minttypes.StoreKey]), app.StakingKeeper, app.AccountKeeper, app.BankKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String())

app.DistrKeeper = distrkeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[distrtypes.StoreKey]), app.AccountKeeper, app.BankKeeper, app.StakingKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String())
app.DistrKeeper = distrkeeper.NewKeeper(
appCodec,
runtime.NewKVStoreService(keys[distrtypes.StoreKey]),
app.AccountKeeper,
app.BankKeeper,
app.StakingKeeper,
authtypes.FeeCollectorName,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
distrkeeper.WithProtocolPoolEnabled(),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding this option

)

app.SlashingKeeper = slashingkeeper.NewKeeper(
appCodec, legacyAmino, runtime.NewKVStoreService(keys[slashingtypes.StoreKey]), app.StakingKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
Expand Down Expand Up @@ -387,7 +396,7 @@ func NewSimApp(

app.GovKeeper = *govKeeper.SetHooks(
govtypes.NewMultiGovHooks(
// register the governance hooks
// register the governance hooks
),
)

Expand All @@ -407,7 +416,7 @@ func NewSimApp(

app.EpochsKeeper.SetHooks(
epochstypes.NewMultiEpochHooks(
// insert epoch hooks receivers here
// insert epoch hooks receivers here
),
)

Expand Down
6 changes: 4 additions & 2 deletions simapp/app_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,10 @@ var (
Config: appconfig.WrapAny(&upgrademodulev1.Module{}),
},
{
Name: distrtypes.ModuleName,
Config: appconfig.WrapAny(&distrmodulev1.Module{}),
Name: distrtypes.ModuleName,
Config: appconfig.WrapAny(&distrmodulev1.Module{
ProtocolPoolEnabled: true,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

di option

}),
},
{
Name: evidencetypes.ModuleName,
Expand Down
11 changes: 8 additions & 3 deletions x/distribution/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/cosmos/cosmos-sdk/runtime"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/query"
"github.com/cosmos/cosmos-sdk/x/distribution/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
Expand All @@ -27,7 +28,7 @@ func NewQuerier(keeper Keeper) Querier {
}

// Params queries params of distribution module
func (k Querier) Params(ctx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
func (k Querier) Params(ctx context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
params, err := k.Keeper.Params.Get(ctx)
if err != nil {
return nil, err
Expand Down Expand Up @@ -255,7 +256,7 @@ func (k Querier) DelegationRewards(ctx context.Context, req *types.QueryDelegati
return &types.QueryDelegationRewardsResponse{Rewards: rewards}, nil
}

// DelegationTotalRewards the total rewards accrued by a each validator
// DelegationTotalRewards the total rewards accrued by each validator
func (k Querier) DelegationTotalRewards(ctx context.Context, req *types.QueryDelegationTotalRewardsRequest) (*types.QueryDelegationTotalRewardsResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
Expand Down Expand Up @@ -362,7 +363,11 @@ func (k Querier) DelegatorWithdrawAddress(ctx context.Context, req *types.QueryD
}

// CommunityPool queries the community pool coins
func (k Querier) CommunityPool(ctx context.Context, req *types.QueryCommunityPoolRequest) (*types.QueryCommunityPoolResponse, error) {
func (k Querier) CommunityPool(ctx context.Context, _ *types.QueryCommunityPoolRequest) (*types.QueryCommunityPoolResponse, error) {
if k.protocolPoolEnabled {
return nil, errors.Wrapf(sdkerrors.ErrInvalidRequest, "protocol pool is enabled - to query CommunityPool use the query exposed by x/protocolpool")
}

pool, err := k.FeePool.Get(ctx)
if err != nil {
return nil, err
Expand Down
Loading
Loading