Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
more changes
Browse files Browse the repository at this point in the history
likhita-809 committed Sep 20, 2023
1 parent 5bf3ab6 commit 38fac38
Showing 5 changed files with 38 additions and 111 deletions.
8 changes: 4 additions & 4 deletions proto/cosmos/distribution/v1beta1/query.proto
Original file line number Diff line number Diff line change
@@ -68,8 +68,8 @@ service Query {

// CommunityPool queries the community pool coins.
//
// Deprecated: Prefer to use x/pool modules CommunityPool rpc method.
// Since 0.50
// Deprecated: Prefer to use x/pool module's CommunityPool rpc method.
// Since: cosmos-sdk 0.50
rpc CommunityPool(QueryCommunityPoolRequest) returns (QueryCommunityPoolResponse) {
option deprecated = true;
option (google.api.http).get = "/cosmos/distribution/v1beta1/community_pool";
@@ -247,7 +247,7 @@ message QueryDelegatorWithdrawAddressResponse {
// method.
//
// Deprecated
// Since 0.50
// Since: cosmos-sdk 0.50
message QueryCommunityPoolRequest {
option deprecated = true;
}
@@ -256,7 +256,7 @@ message QueryCommunityPoolRequest {
// RPC method.
//
// Deprecated
// Since 0.50
// Since: cosmos-sdk 0.50
message QueryCommunityPoolResponse {
option deprecated = true;
// pool defines community pool's coins.
16 changes: 8 additions & 8 deletions proto/cosmos/distribution/v1beta1/tx.proto
Original file line number Diff line number Diff line change
@@ -30,8 +30,8 @@ service Msg {
// FundCommunityPool defines a method to allow an account to directly
// fund the community pool.
//
// Deprecated: Use x/pool modules FundCommunityPool instead.
// Since 0.50
// Deprecated: Use x/pool module's FundCommunityPool instead.
// Since: cosmos-sdk 0.50
rpc FundCommunityPool(MsgFundCommunityPool) returns (MsgFundCommunityPoolResponse) {
option deprecated = true;
};
@@ -47,8 +47,8 @@ service Msg {
// could be the governance module itself. The authority is defined in the
// keeper.
//
// Deprecated: Use x/pool modules CommunityPoolSpend instead.
// Since: 0.50
// Deprecated: Use x/pool module's CommunityPoolSpend instead.
// Since: cosmos-sdk 0.50
rpc CommunityPoolSpend(MsgCommunityPoolSpend) returns (MsgCommunityPoolSpendResponse);

// DepositValidatorRewardsPool defines a method to provide additional rewards
@@ -127,8 +127,8 @@ message MsgWithdrawValidatorCommissionResponse {
// MsgFundCommunityPool allows an account to directly
// fund the community pool.
//
// Deprecated: Use x/pool modules MsgFundCommunityPool instead.
// Since 0.50
// Deprecated: Use x/pool module's MsgFundCommunityPool instead.
// Since: cosmos-sdk 0.50
message MsgFundCommunityPool {
option deprecated = true;
option (cosmos.msg.v1.signer) = "depositor";
@@ -149,7 +149,7 @@ message MsgFundCommunityPool {
// MsgFundCommunityPoolResponse defines the Msg/FundCommunityPool response type.
//
// Deprecated
// Since 0.50
// Since: cosmos-sdk 0.50
message MsgFundCommunityPoolResponse {
option deprecated = true;
}
@@ -180,7 +180,7 @@ message MsgUpdateParamsResponse {}
// pool to another account. This message is typically executed via a governance
// proposal with the governance module being the executing authority.

// Deprecated: Use x/pool modules MsgCommunityPoolSpend instead
// Deprecated: Use x/pool module's MsgCommunityPoolSpend instead
// Since: cosmos-sdk 0.50
message MsgCommunityPoolSpend {
option deprecated = true;
29 changes: 3 additions & 26 deletions x/distribution/keeper/allocation_test.go
Original file line number Diff line number Diff line change
@@ -10,11 +10,9 @@ import (

"cosmossdk.io/collections"
"cosmossdk.io/core/comet"
"cosmossdk.io/log"
"cosmossdk.io/math"
storetypes "cosmossdk.io/store/types"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec/address"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
@@ -45,14 +43,7 @@ func TestAllocateTokensToValidatorWithCommission(t *testing.T) {
accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress())
stakingKeeper.EXPECT().ValidatorAddressCodec().Return(valCodec).AnyTimes()

baseApp := baseapp.NewBaseApp(
"authz",
log.NewNopLogger(),
testCtx.DB,
encCfg.TxConfig.TxDecoder(),
)
baseApp.SetCMS(testCtx.CMS)
baseApp.SetInterfaceRegistry(encCfg.InterfaceRegistry)
baseApp := initBaseApp(testCtx, encCfg)

distrKeeper := keeper.NewKeeper(
encCfg.Codec,
@@ -113,14 +104,7 @@ func TestAllocateTokensToManyValidators(t *testing.T) {
accountKeeper.EXPECT().GetModuleAccount(gomock.Any(), "fee_collector").Return(feeCollectorAcc)
stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec("cosmosvaloper")).AnyTimes()

baseApp := baseapp.NewBaseApp(
"authz",
log.NewNopLogger(),
testCtx.DB,
encCfg.TxConfig.TxDecoder(),
)
baseApp.SetCMS(testCtx.CMS)
baseApp.SetInterfaceRegistry(encCfg.InterfaceRegistry)
baseApp := initBaseApp(testCtx, encCfg)

distrKeeper := keeper.NewKeeper(
encCfg.Codec,
@@ -252,14 +236,7 @@ func TestAllocateTokensTruncation(t *testing.T) {
accountKeeper.EXPECT().GetModuleAccount(gomock.Any(), "fee_collector").Return(feeCollectorAcc)
stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec("cosmosvaloper")).AnyTimes()

baseApp := baseapp.NewBaseApp(
"authz",
log.NewNopLogger(),
testCtx.DB,
encCfg.TxConfig.TxDecoder(),
)
baseApp.SetCMS(testCtx.CMS)
baseApp.SetInterfaceRegistry(encCfg.InterfaceRegistry)
baseApp := initBaseApp(testCtx, encCfg)

distrKeeper := keeper.NewKeeper(
encCfg.Codec,
94 changes: 22 additions & 72 deletions x/distribution/keeper/delegation_test.go
Original file line number Diff line number Diff line change
@@ -42,14 +42,7 @@ func TestCalculateRewardsBasic(t *testing.T) {
stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec(sdk.Bech32PrefixValAddr)).AnyTimes()
accountKeeper.EXPECT().AddressCodec().Return(address.NewBech32Codec(sdk.Bech32MainPrefix)).AnyTimes()

baseApp := baseapp.NewBaseApp(
"authz",
log.NewNopLogger(),
testCtx.DB,
encCfg.TxConfig.TxDecoder(),
)
baseApp.SetCMS(testCtx.CMS)
baseApp.SetInterfaceRegistry(encCfg.InterfaceRegistry)
baseApp := initBaseApp(testCtx, encCfg)

distrKeeper := keeper.NewKeeper(
encCfg.Codec,
@@ -154,14 +147,7 @@ func TestCalculateRewardsAfterSlash(t *testing.T) {
stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec(sdk.Bech32PrefixValAddr)).AnyTimes()
accountKeeper.EXPECT().AddressCodec().Return(address.NewBech32Codec(sdk.Bech32MainPrefix)).AnyTimes()

baseApp := baseapp.NewBaseApp(
"authz",
log.NewNopLogger(),
testCtx.DB,
encCfg.TxConfig.TxDecoder(),
)
baseApp.SetCMS(testCtx.CMS)
baseApp.SetInterfaceRegistry(encCfg.InterfaceRegistry)
baseApp := initBaseApp(testCtx, encCfg)

distrKeeper := keeper.NewKeeper(
encCfg.Codec,
@@ -268,14 +254,7 @@ func TestCalculateRewardsAfterManySlashes(t *testing.T) {
stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec(sdk.Bech32PrefixValAddr)).AnyTimes()
accountKeeper.EXPECT().AddressCodec().Return(address.NewBech32Codec(sdk.Bech32MainPrefix)).AnyTimes()

baseApp := baseapp.NewBaseApp(
"authz",
log.NewNopLogger(),
testCtx.DB,
encCfg.TxConfig.TxDecoder(),
)
baseApp.SetCMS(testCtx.CMS)
baseApp.SetInterfaceRegistry(encCfg.InterfaceRegistry)
baseApp := initBaseApp(testCtx, encCfg)

distrKeeper := keeper.NewKeeper(
encCfg.Codec,
@@ -403,14 +382,7 @@ func TestCalculateRewardsMultiDelegator(t *testing.T) {
stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec(sdk.Bech32PrefixValAddr)).AnyTimes()
accountKeeper.EXPECT().AddressCodec().Return(address.NewBech32Codec(sdk.Bech32MainPrefix)).AnyTimes()

baseApp := baseapp.NewBaseApp(
"authz",
log.NewNopLogger(),
testCtx.DB,
encCfg.TxConfig.TxDecoder(),
)
baseApp.SetCMS(testCtx.CMS)
baseApp.SetInterfaceRegistry(encCfg.InterfaceRegistry)
baseApp := initBaseApp(testCtx, encCfg)

distrKeeper := keeper.NewKeeper(
encCfg.Codec,
@@ -511,14 +483,7 @@ func TestWithdrawDelegationRewardsBasic(t *testing.T) {
stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec(sdk.Bech32PrefixValAddr)).AnyTimes()
accountKeeper.EXPECT().AddressCodec().Return(address.NewBech32Codec(sdk.Bech32MainPrefix)).AnyTimes()

baseApp := baseapp.NewBaseApp(
"authz",
log.NewNopLogger(),
testCtx.DB,
encCfg.TxConfig.TxDecoder(),
)
baseApp.SetCMS(testCtx.CMS)
baseApp.SetInterfaceRegistry(encCfg.InterfaceRegistry)
baseApp := initBaseApp(testCtx, encCfg)

distrKeeper := keeper.NewKeeper(
encCfg.Codec,
@@ -597,14 +562,7 @@ func TestCalculateRewardsAfterManySlashesInSameBlock(t *testing.T) {
stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec(sdk.Bech32PrefixValAddr)).AnyTimes()
accountKeeper.EXPECT().AddressCodec().Return(address.NewBech32Codec(sdk.Bech32MainPrefix)).AnyTimes()

baseApp := baseapp.NewBaseApp(
"authz",
log.NewNopLogger(),
testCtx.DB,
encCfg.TxConfig.TxDecoder(),
)
baseApp.SetCMS(testCtx.CMS)
baseApp.SetInterfaceRegistry(encCfg.InterfaceRegistry)
baseApp := initBaseApp(testCtx, encCfg)

distrKeeper := keeper.NewKeeper(
encCfg.Codec,
@@ -724,14 +682,7 @@ func TestCalculateRewardsMultiDelegatorMultiSlash(t *testing.T) {
stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec(sdk.Bech32PrefixValAddr)).AnyTimes()
accountKeeper.EXPECT().AddressCodec().Return(address.NewBech32Codec(sdk.Bech32MainPrefix)).AnyTimes()

baseApp := baseapp.NewBaseApp(
"authz",
log.NewNopLogger(),
testCtx.DB,
encCfg.TxConfig.TxDecoder(),
)
baseApp.SetCMS(testCtx.CMS)
baseApp.SetInterfaceRegistry(encCfg.InterfaceRegistry)
baseApp := initBaseApp(testCtx, encCfg)

distrKeeper := keeper.NewKeeper(
encCfg.Codec,
@@ -872,14 +823,7 @@ func TestCalculateRewardsMultiDelegatorMultWithdraw(t *testing.T) {
stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec(sdk.Bech32PrefixValAddr)).AnyTimes()
accountKeeper.EXPECT().AddressCodec().Return(address.NewBech32Codec(sdk.Bech32MainPrefix)).AnyTimes()

baseApp := baseapp.NewBaseApp(
"authz",
log.NewNopLogger(),
testCtx.DB,
encCfg.TxConfig.TxDecoder(),
)
baseApp.SetCMS(testCtx.CMS)
baseApp.SetInterfaceRegistry(encCfg.InterfaceRegistry)
baseApp := initBaseApp(testCtx, encCfg)

distrKeeper := keeper.NewKeeper(
encCfg.Codec,
@@ -1082,14 +1026,7 @@ func Test100PercentCommissionReward(t *testing.T) {
stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec(sdk.Bech32PrefixValAddr)).AnyTimes()
accountKeeper.EXPECT().AddressCodec().Return(address.NewBech32Codec(sdk.Bech32MainPrefix)).AnyTimes()

baseApp := baseapp.NewBaseApp(
"authz",
log.NewNopLogger(),
testCtx.DB,
encCfg.TxConfig.TxDecoder(),
)
baseApp.SetCMS(testCtx.CMS)
baseApp.SetInterfaceRegistry(encCfg.InterfaceRegistry)
baseApp := initBaseApp(testCtx, encCfg)

distrKeeper := keeper.NewKeeper(
encCfg.Codec,
@@ -1167,3 +1104,16 @@ func Test100PercentCommissionReward(t *testing.T) {
}
require.True(t, hasValue)
}

func initBaseApp(testCtx testutil.TestContext, encCfg moduletestutil.TestEncodingConfig) *baseapp.BaseApp {
baseApp := baseapp.NewBaseApp(
"distribution",
log.NewNopLogger(),
testCtx.DB,
encCfg.TxConfig.TxDecoder(),
)
baseApp.SetCMS(testCtx.CMS)
baseApp.SetInterfaceRegistry(encCfg.InterfaceRegistry)

return baseApp
}
2 changes: 1 addition & 1 deletion x/distribution/migrations/funds/migrate.go
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import (
)

// MigrateFunds migrates the distribution module funds to pool module
func MigrateFunds(ctx sdk.Context, bankKeeper types.BankKeeper, feePool types.FeePool, macc sdk.ModuleAccountI, poolMacc sdk.ModuleAccountI) error {
func MigrateFunds(ctx sdk.Context, bankKeeper types.BankKeeper, feePool types.FeePool, macc, poolMacc sdk.ModuleAccountI) error {
poolBal := sdk.NormalizeCoins(feePool.CommunityPool)
distrbalances := bankKeeper.GetAllBalances(ctx, macc.GetAddress())
if distrbalances.IsZero() || distrbalances.IsAllLT(poolBal) {

0 comments on commit 38fac38

Please sign in to comment.