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!: provider proposal for changing reward denoms (backport #1280) #1291

Merged
merged 5 commits into from
Sep 12, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix conflicts
  • Loading branch information
shaspitz committed Sep 12, 2023
commit cba7f913662571f9424cb8c879542149816b6281
14 changes: 4 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -4,17 +4,11 @@

Add an entry to the unreleased section whenever merging a PR to main that is not targeted at a specific release. These entries will eventually be included in a release.

<<<<<<< HEAD
## v2.0.0-lsm
=======
## v2.1.0-provider

* (feature!) [#1280](https://github.com/cosmos/interchain-security/pull/1280) provider proposal for changing reward denoms
* (feature!) [#1244](https://github.com/cosmos/interchain-security/pull/1244) Update the default consumer unbonding period to 2 weeks.
* (deps) [#1259](https://github.com/cosmos/interchain-security/pull/1259) Bump [cosmos-sdk](https://github.com/cosmos/cosmos-sdk) to [v0.47.5](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.5).
* (deps!) [#1258](https://github.com/cosmos/interchain-security/pull/1258) Bump [ibc-go](https://github.com/cosmos/ibc-go) to [v7.3.0](https://github.com/cosmos/ibc-go/releases/tag/v7.3.0).
* (deps) [#1258](https://github.com/cosmos/interchain-security/pull/1258) Bump [cosmos-sdk](https://github.com/cosmos/cosmos-sdk) to [v0.47.4](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.4).
* (deps!) [#1196](https://github.com/cosmos/interchain-security/pull/1196) Bump [ibc-go](https://github.com/cosmos/ibc-go) to [v7.2.0](https://github.com/cosmos/ibc-go/releases/tag/v7.2.0).
* `[x/ccv/provider]` (fix) [#1076](https://github.com/cosmos/interchain-security/pull/1076) Add `InitTimeoutTimestamps` and `ExportedVscSendTimestamps` to exported genesis.
>>>>>>> 48a2186 (feat!: provider proposal for changing reward denoms (#1280))

## v2.0.0-lsm

Date: August 18th, 2023

15 changes: 1 addition & 14 deletions app/provider/app.go
Original file line number Diff line number Diff line change
@@ -131,7 +131,6 @@ var (
mint.AppModuleBasic{},
distr.AppModuleBasic{},
gov.NewAppModuleBasic(
<<<<<<< HEAD
paramsclient.ProposalHandler,
distrclient.ProposalHandler,
upgradeclient.ProposalHandler,
@@ -141,19 +140,7 @@ var (
ibcproviderclient.ConsumerAdditionProposalHandler,
ibcproviderclient.ConsumerRemovalProposalHandler,
ibcproviderclient.EquivocationProposalHandler,
=======
[]govclient.ProposalHandler{
paramsclient.ProposalHandler,
upgradeclient.LegacyProposalHandler,
upgradeclient.LegacyCancelProposalHandler,
ibcclientclient.UpdateClientProposalHandler,
ibcclientclient.UpgradeProposalHandler,
ibcproviderclient.ConsumerAdditionProposalHandler,
ibcproviderclient.ConsumerRemovalProposalHandler,
ibcproviderclient.EquivocationProposalHandler,
ibcproviderclient.ChangeRewardDenomsProposalHandler,
},
>>>>>>> 48a2186 (feat!: provider proposal for changing reward denoms (#1280))
ibcproviderclient.ChangeRewardDenomsProposalHandler,
),
params.AppModuleBasic{},
crisis.AppModuleBasic{},
10 changes: 2 additions & 8 deletions proto/interchain_security/ccv/provider/v1/provider.proto
Original file line number Diff line number Diff line change
@@ -95,10 +95,6 @@ message EquivocationProposal {
repeated cosmos.evidence.v1beta1.Equivocation equivocations = 3;
}

<<<<<<< HEAD
// A persisted queue entry indicating that a slash packet data instance needs to be handled.
// This type belongs in the "global" queue, to coordinate slash packet handling times between consumers.
=======
// ChangeRewardDenomsProposal is a governance proposal on the provider chain to
// mutate the set of denoms accepted by the provider as rewards.
message ChangeRewardDenomsProposal {
@@ -112,10 +108,8 @@ message ChangeRewardDenomsProposal {
repeated string denoms_to_remove = 4;
}

// A persisted queue entry indicating that a slash packet data instance needs to
// be handled. This type belongs in the "global" queue, to coordinate slash
// packet handling times between consumers.
>>>>>>> 48a2186 (feat!: provider proposal for changing reward denoms (#1280))
// A persisted queue entry indicating that a slash packet data instance needs to be handled.
// This type belongs in the "global" queue, to coordinate slash packet handling times between consumers.
message GlobalSlashEntry {
// Block time that slash packet was received by provider chain.
// This field is used for store key iteration ordering.
9 changes: 0 additions & 9 deletions proto/interchain_security/ccv/provider/v1/tx.proto
Original file line number Diff line number Diff line change
@@ -10,13 +10,7 @@ import "google/protobuf/any.proto";

// Msg defines the Msg service.
service Msg {
<<<<<<< HEAD
rpc AssignConsumerKey(MsgAssignConsumerKey) returns (MsgAssignConsumerKeyResponse);
rpc RegisterConsumerRewardDenom(MsgRegisterConsumerRewardDenom) returns (MsgRegisterConsumerRewardDenomResponse);
=======
rpc AssignConsumerKey(MsgAssignConsumerKey)
returns (MsgAssignConsumerKeyResponse);
>>>>>>> 48a2186 (feat!: provider proposal for changing reward denoms (#1280))
}

message MsgAssignConsumerKey {
@@ -34,7 +28,6 @@ message MsgAssignConsumerKey {
}

message MsgAssignConsumerKeyResponse {}
<<<<<<< HEAD

// MsgRegisterConsumerRewardDenom allows an account to register
// a consumer reward denom, i.e., add it to the list of denoms
@@ -49,5 +42,3 @@ message MsgRegisterConsumerRewardDenom {

// MsgRegisterConsumerRewardDenomResponse defines the Msg/RegisterConsumerRewardDenom response type.
message MsgRegisterConsumerRewardDenomResponse {}
=======
>>>>>>> 48a2186 (feat!: provider proposal for changing reward denoms (#1280))
18 changes: 0 additions & 18 deletions tests/e2e/actions.go
Original file line number Diff line number Diff line change
@@ -1684,20 +1684,6 @@ type submitChangeRewardDenomsProposalAction struct {
func (tr TestRun) submitChangeRewardDenomsProposal(action submitChangeRewardDenomsProposalAction, verbose bool) {
providerChain := tr.chainConfigs[chainID("provi")]

<<<<<<< HEAD
`--from`, `validator`+fmt.Sprint(action.from),
`--chain-id`, string(action.chain),
`--home`, tr.getValidatorHome(action.chain, action.from),
`--node`, tr.getValidatorNode(action.chain, action.from),
`--gas`, "9000000",
`--keyring-backend`, `test`,
`-b`, `block`,
`-y`,
).CombinedOutput()

if verbose {
fmt.Println("redelegate cmd:", string(bz))
=======
prop := client.ChangeRewardDenomsProposalJSON{
Summary: "Change reward denoms",
ChangeRewardDenomsProposal: types.ChangeRewardDenomsProposal{
@@ -1707,7 +1693,6 @@ func (tr TestRun) submitChangeRewardDenomsProposal(action submitChangeRewardDeno
DenomsToRemove: []string{"stake"},
},
Deposit: fmt.Sprint(action.deposit) + `stake`,
>>>>>>> 48a2186 (feat!: provider proposal for changing reward denoms (#1280))
}

bz, err := json.Marshal(prop)
@@ -1727,8 +1712,6 @@ func (tr TestRun) submitChangeRewardDenomsProposal(action submitChangeRewardDeno
if err != nil {
log.Fatal(err, "\n", string(bz))
}
<<<<<<< HEAD
=======

//#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments.
// CHANGE REWARDS DENOM PROPOSAL
@@ -1749,7 +1732,6 @@ func (tr TestRun) submitChangeRewardDenomsProposal(action submitChangeRewardDeno

// wait for inclusion in a block -> '--broadcast-mode block' is deprecated
tr.waitBlocks(chainID("provi"), 2, 30*time.Second)
>>>>>>> 48a2186 (feat!: provider proposal for changing reward denoms (#1280))
}

// Creates an additional node on selected chain
31 changes: 1 addition & 30 deletions tests/integration/distribution.go
Original file line number Diff line number Diff line change
@@ -5,20 +5,11 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
<<<<<<< HEAD
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
transfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types"

consumertypes "github.com/cosmos/interchain-security/v2/x/ccv/consumer/types"
providertypes "github.com/cosmos/interchain-security/v2/x/ccv/provider/types"
ccv "github.com/cosmos/interchain-security/v2/x/ccv/types"
=======

icstestingutils "github.com/cosmos/interchain-security/v3/testutil/integration"
consumerkeeper "github.com/cosmos/interchain-security/v3/x/ccv/consumer/keeper"
consumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types"
providertypes "github.com/cosmos/interchain-security/v3/x/ccv/provider/types"
ccv "github.com/cosmos/interchain-security/v3/x/ccv/types"
>>>>>>> 48a2186 (feat!: provider proposal for changing reward denoms (#1280))
)

// This test is valid for minimal viable consumer chain
@@ -106,28 +97,8 @@ func (s *CCVTestSuite) TestRewardsDistribution() {
rewardCoins = providerBankKeeper.GetAllBalances(s.providerCtx(), rewardPool)
s.Require().True(rewardCoins[ibcCoinIndex].Amount.Equal(providerExpectedRewards[0].Amount))

<<<<<<< HEAD
// Successfully register the consumer reward denom this time

// Send the coins back to the delAddr
err = providerBankKeeper.SendCoinsFromModuleToAccount(s.providerCtx(), govtypes.ModuleName, delAddr, senderCoins)
s.Require().NoError(err)

// log the sender's coins
senderCoins1 := providerBankKeeper.GetAllBalances(s.providerCtx(), delAddr)

// Register the consumer reward denom
err = s.providerApp.GetProviderKeeper().RegisterConsumerRewardDenom(s.providerCtx(), rewardCoins[ibcCoinIndex].Denom, delAddr)
s.Require().NoError(err)

// Check that the delAddr has the right amount less money in it after paying the fee
senderCoins2 := providerBankKeeper.GetAllBalances(s.providerCtx(), delAddr)
consumerRewardDenomRegistrationFee := s.providerApp.GetProviderKeeper().GetConsumerRewardDenomRegistrationFee(s.providerCtx())
s.Require().Equal(senderCoins1.Sub(senderCoins2), sdk.NewCoins(consumerRewardDenomRegistrationFee))
=======
// Set the consumer reward denom. This would be done by a governance proposal in prod
s.providerApp.GetProviderKeeper().SetConsumerRewardDenom(s.providerCtx(), rewardCoins[ibcCoinIndex].Denom)
>>>>>>> 48a2186 (feat!: provider proposal for changing reward denoms (#1280))

s.providerChain.NextBlock()

6 changes: 0 additions & 6 deletions x/ccv/provider/client/cli/tx.go
Original file line number Diff line number Diff line change
@@ -8,12 +8,6 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
<<<<<<< HEAD
"github.com/cosmos/cosmos-sdk/version"
=======
sdk "github.com/cosmos/cosmos-sdk/types"
>>>>>>> 48a2186 (feat!: provider proposal for changing reward denoms (#1280))

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/interchain-security/v2/x/ccv/provider/types"
)
62 changes: 41 additions & 21 deletions x/ccv/provider/client/proposal_handler.go
Original file line number Diff line number Diff line change
@@ -23,16 +23,10 @@
)

var (
<<<<<<< HEAD
ConsumerAdditionProposalHandler = govclient.NewProposalHandler(SubmitConsumerAdditionPropTxCmd, ConsumerAdditionProposalRESTHandler)
ConsumerRemovalProposalHandler = govclient.NewProposalHandler(SubmitConsumerRemovalProposalTxCmd, ConsumerRemovalProposalRESTHandler)
EquivocationProposalHandler = govclient.NewProposalHandler(SubmitEquivocationProposalTxCmd, EquivocationProposalRESTHandler)
=======
ConsumerAdditionProposalHandler = govclient.NewProposalHandler(SubmitConsumerAdditionPropTxCmd)
ConsumerRemovalProposalHandler = govclient.NewProposalHandler(SubmitConsumerRemovalProposalTxCmd)
EquivocationProposalHandler = govclient.NewProposalHandler(SubmitEquivocationProposalTxCmd)
ChangeRewardDenomsProposalHandler = govclient.NewProposalHandler(SubmitChangeRewardDenomsProposalTxCmd)
>>>>>>> 48a2186 (feat!: provider proposal for changing reward denoms (#1280))
ConsumerAdditionProposalHandler = govclient.NewProposalHandler(SubmitConsumerAdditionPropTxCmd, ConsumerAdditionProposalRESTHandler)
ConsumerRemovalProposalHandler = govclient.NewProposalHandler(SubmitConsumerRemovalProposalTxCmd, ConsumerRemovalProposalRESTHandler)
EquivocationProposalHandler = govclient.NewProposalHandler(SubmitEquivocationProposalTxCmd, EquivocationProposalRESTHandler)
ChangeRewardDenomsProposalHandler = govclient.NewProposalHandler(SubmitChangeRewardDenomsProposalTxCmd, ChangeRewardDenomsProposalRESTHandler)
)

// SubmitConsumerAdditionPropTxCmd returns a CLI command handler for submitting
@@ -259,17 +253,12 @@

from := clientCtx.GetFromAddress()

msgContent, err := govv1.NewLegacyContent(content, authtypes.NewModuleAddress(govtypes.ModuleName).String())
if err != nil {
return err
}

deposit, err := sdk.ParseCoinsNormalized(proposal.Deposit)
if err != nil {
return err
}

msg, err := govv1.NewMsgSubmitProposal([]sdk.Msg{msgContent}, deposit, from.String(), "", content.GetTitle(), proposal.Summary)
msg, err := govtypes.NewMsgSubmitProposal(content, deposit, from)
if err != nil {
return err
}
@@ -404,7 +393,6 @@
return proposal, nil
}

<<<<<<< HEAD
// EquivocationProposalRESTHandler returns a ProposalRESTHandler that exposes the equivocation rest handler.
func EquivocationProposalRESTHandler(clientCtx client.Context) govrest.ProposalRESTHandler {
return govrest.ProposalRESTHandler{
@@ -413,24 +401,21 @@
}
}

func ParseConsumerRemovalProposalJSON(proposalFile string) (ConsumerRemovalProposalJSON, error) {
proposal := ConsumerRemovalProposalJSON{}
=======
type ChangeRewardDenomsProposalJSON struct {
Summary string `json:"summary"`
types.ChangeRewardDenomsProposal
Deposit string `json:"deposit"`
}

type ChangeRewardDenomsProposalReq struct {
BaseReq rest.BaseReq `json:"base_req"`
Proposer sdk.AccAddress `json:"proposer"`
types.ChangeRewardDenomsProposal
Deposit sdk.Coins `json:"deposit"`
}

func ParseChangeRewardDenomsProposalJSON(proposalFile string) (ChangeRewardDenomsProposalJSON, error) {
proposal := ChangeRewardDenomsProposalJSON{}
>>>>>>> 48a2186 (feat!: provider proposal for changing reward denoms (#1280))

contents, err := os.ReadFile(filepath.Clean(proposalFile))
if err != nil {
@@ -442,6 +427,13 @@
return proposal, nil
}

func ChangeRewardDenomsProposalRESTHandler(clientCtx client.Context) govrest.ProposalRESTHandler {
return govrest.ProposalRESTHandler{
SubRoute: "change_reward_denoms",
Handler: postEquivocationProposalHandlerFn(clientCtx),
}
}

// ConsumerAdditionProposalRESTHandler returns a ProposalRESTHandler that exposes the consumer addition rest handler.
func ConsumerAdditionProposalRESTHandler(clientCtx client.Context) govrest.ProposalRESTHandler {
return govrest.ProposalRESTHandler{
@@ -567,3 +559,31 @@
providerUnbondingTime)
}
}

func postChangeRewardDenomsProposalHandlerFn(clientCtx client.Context) http.HandlerFunc {

Check failure on line 563 in x/ccv/provider/client/proposal_handler.go

GitHub Actions / lint

func `postChangeRewardDenomsProposalHandlerFn` is unused (unused)
return func(w http.ResponseWriter, r *http.Request) {
var req ChangeRewardDenomsProposalReq
if !rest.ReadRESTReq(w, r, clientCtx.LegacyAmino, &req) {
return
}

req.BaseReq = req.BaseReq.Sanitize()
if !req.BaseReq.ValidateBasic(w) {
return
}

content := types.NewChangeRewardDenomsProposal(
req.Title, req.Description, req.DenomsToAdd, req.DenomsToRemove)

msg, err := govtypes.NewMsgSubmitProposal(content, req.Deposit, req.Proposer)
if rest.CheckBadRequestError(w, err) {
return
}

if rest.CheckBadRequestError(w, msg.ValidateBasic()) {
return
}

tx.WriteGeneratedTxResponse(clientCtx, w, req.BaseReq, msg)
}
}
6 changes: 0 additions & 6 deletions x/ccv/provider/keeper/distribution.go
Original file line number Diff line number Diff line change
@@ -2,13 +2,7 @@ package keeper

import (
sdk "github.com/cosmos/cosmos-sdk/types"
<<<<<<< HEAD
consumertypes "github.com/cosmos/interchain-security/v2/x/ccv/consumer/types"
"github.com/cosmos/interchain-security/v2/x/ccv/provider/types"
=======

"github.com/cosmos/interchain-security/v3/x/ccv/provider/types"
>>>>>>> 48a2186 (feat!: provider proposal for changing reward denoms (#1280))
)

// EndBlockRD executes EndBlock logic for the Reward Distribution sub-protocol.
48 changes: 0 additions & 48 deletions x/ccv/provider/keeper/distribution_test.go

This file was deleted.

Loading
Loading