From 864acb8a76d2fb720a0e1b653303f6520e1a4c16 Mon Sep 17 00:00:00 2001 From: Bernd Mueller Date: Wed, 31 Jul 2024 11:44:13 +0200 Subject: [PATCH] Remove legacy-submit-proposal consumer-addition --- app/provider/app.go | 2 - .../ccv/provider/v1/provider.proto | 18 +-- .../ccv/provider/v1/tx.proto | 1 - tests/e2e/actions.go | 110 ++++++++++-------- tests/e2e/state.go | 4 +- tests/integration/provider_gov_hooks.go | 40 ++++--- testutil/integration/debug_test.go | 12 +- testutil/keeper/unit_test_helpers.go | 24 ++++ .../client/legacy_proposal_handler.go | 3 +- x/ccv/provider/keeper/hooks.go | 45 ++++--- x/ccv/provider/types/codec.go | 4 +- x/ccv/provider/types/tx.pb.go | 1 - 12 files changed, 156 insertions(+), 108 deletions(-) diff --git a/app/provider/app.go b/app/provider/app.go index 214d191b71..d0ecfb8c3b 100644 --- a/app/provider/app.go +++ b/app/provider/app.go @@ -144,7 +144,6 @@ var ( gov.NewAppModuleBasic( []govclient.ProposalHandler{ paramsclient.ProposalHandler, - ibcproviderclient.ConsumerAdditionProposalHandler, ibcproviderclient.ConsumerRemovalProposalHandler, ibcproviderclient.ConsumerModificationProposalHandler, ibcproviderclient.ChangeRewardDenomsProposalHandler, @@ -579,7 +578,6 @@ func New( govtypes.ModuleName: gov.NewAppModuleBasic( []govclient.ProposalHandler{ paramsclient.ProposalHandler, - ibcproviderclient.ConsumerAdditionProposalHandler, ibcproviderclient.ConsumerRemovalProposalHandler, ibcproviderclient.ConsumerModificationProposalHandler, ibcproviderclient.ChangeRewardDenomsProposalHandler, diff --git a/proto/interchain_security/ccv/provider/v1/provider.proto b/proto/interchain_security/ccv/provider/v1/provider.proto index 7e1836cf38..39ab8ebfd7 100644 --- a/proto/interchain_security/ccv/provider/v1/provider.proto +++ b/proto/interchain_security/ccv/provider/v1/provider.proto @@ -18,8 +18,8 @@ import "amino/amino.proto"; // // Note any type defined in this file is ONLY used internally to the provider CCV module. -// These schemas can change with proper consideration of compatibility or migration. -// +// These schemas can change with proper consideration of compatibility or migration. +// // ConsumerAdditionProposal is a governance proposal on the provider chain to // spawn a new consumer chain. If it passes, then all validators on the provider @@ -169,8 +169,8 @@ message ConsumerModificationProposal { // EquivocationProposal is a governance proposal on the provider chain to // punish a validator for equivocation on a consumer chain. -// -// This type is only used internally to the consumer CCV module. +// +// This type is only used internally to the consumer CCV module. // WARNING: This message is deprecated now that equivocations can be submitted // and verified automatically on the provider. (see SubmitConsumerDoubleVoting in proto/interchain-security/ccv/provider/v1/tx.proto). message EquivocationProposal { @@ -258,14 +258,14 @@ message Params { // The number of epochs a validator has to validate a consumer chain in order to start receiving rewards from that chain. int64 number_of_epochs_to_start_receiving_rewards = 11; - + // The maximal number of validators that will be passed // to the consensus engine on the provider. int64 max_provider_consensus_validators = 12; } // SlashAcks contains cons addresses of consumer chain validators -// successfully slashed on the provider chain. +// successfully slashed on the provider chain. message SlashAcks { repeated string addresses = 1; } // ConsumerAdditionProposals holds pending governance proposals on the provider @@ -335,9 +335,9 @@ message ConsumerAddrsToPruneV2 { } // ConsensusValidator is used to express a validator that -// should be validating on a chain. +// should be validating on a chain. // It contains relevant info for -// a validator that is expected to validate on +// a validator that is expected to validate on // either the provider or a consumer chain. message ConsensusValidator { // validator's consensus address on the provider chain @@ -353,7 +353,7 @@ message ConsensusValidator { int64 join_height = 4; } // ConsumerRewardsAllocation stores the rewards allocated by a consumer chain -// to the consumer rewards pool. It is used to allocate the tokens to the consumer +// to the consumer rewards pool. It is used to allocate the tokens to the consumer // opted-in validators and the community pool during BeginBlock. message ConsumerRewardsAllocation { repeated cosmos.base.v1beta1.DecCoin rewards = 1 [ diff --git a/proto/interchain_security/ccv/provider/v1/tx.proto b/proto/interchain_security/ccv/provider/v1/tx.proto index b0f3fc58c2..17f5cddf22 100644 --- a/proto/interchain_security/ccv/provider/v1/tx.proto +++ b/proto/interchain_security/ccv/provider/v1/tx.proto @@ -106,7 +106,6 @@ message MsgUpdateParamsResponse {} // If it passes, then all validators on the provider chain are expected to validate // the consumer chain at spawn time or get slashed. // It is recommended that spawn time occurs after the proposal end time. -// // Note: this replaces ConsumerAdditionProposal which is deprecated and will be removed soon message MsgConsumerAddition { option (cosmos.msg.v1.signer) = "authority"; diff --git a/tests/e2e/actions.go b/tests/e2e/actions.go index 2efd0b69e7..66fae75812 100644 --- a/tests/e2e/actions.go +++ b/tests/e2e/actions.go @@ -2,6 +2,7 @@ package main import ( "bufio" + "encoding/base64" "encoding/json" "fmt" "log" @@ -273,62 +274,79 @@ func (tr Chain) submitConsumerAdditionProposal( ) { spawnTime := tr.testConfig.containerConfig.Now.Add(time.Duration(action.SpawnTime) * time.Millisecond) params := ccvtypes.DefaultParams() - prop := client.ConsumerAdditionProposalJSON{ - Title: "Propose the addition of a new chain", - Summary: "Gonna be a great chain", - ChainId: string(tr.testConfig.chainConfigs[action.ConsumerChain].ChainId), - InitialHeight: action.InitialHeight, - GenesisHash: []byte("gen_hash"), - BinaryHash: []byte("bin_hash"), - SpawnTime: spawnTime, - ConsumerRedistributionFraction: params.ConsumerRedistributionFraction, - BlocksPerDistributionTransmission: params.BlocksPerDistributionTransmission, - HistoricalEntries: params.HistoricalEntries, - CcvTimeoutPeriod: params.CcvTimeoutPeriod, - TransferTimeoutPeriod: params.TransferTimeoutPeriod, - UnbondingPeriod: params.UnbondingPeriod, - Deposit: fmt.Sprint(action.Deposit) + `stake`, - DistributionTransmissionChannel: action.DistributionChannel, - TopN: action.TopN, - ValidatorsPowerCap: action.ValidatorsPowerCap, - ValidatorSetCap: action.ValidatorSetCap, - Allowlist: action.Allowlist, - Denylist: action.Denylist, - MinStake: action.MinStake, - AllowInactiveVals: action.AllowInactiveVals, - } - - bz, err := json.Marshal(prop) - if err != nil { - log.Fatal(err) - } - - jsonStr := string(bz) - if strings.Contains(jsonStr, "'") { - log.Fatal("prop json contains single quote") - } + template := ` + { + "messages": [ + { + "@type": "/interchain_security.ccv.provider.v1.MsgConsumerAddition", + "chain_id": "%s", + "initial_height": { + "revision_number": "%d", + "revision_height": "%d" + }, + "genesis_hash": "%s", + "binary_hash": "%s", + "spawn_time": "%s", + "unbonding_period": "%s", + "ccv_timeout_period": "%s", + "transfer_timeout_period": "%s", + "consumer_redistribution_fraction": "%s", + "blocks_per_distribution_transmission": "%d", + "historical_entries": "%d", + "distribution_transmission_channel": "%s", + "top_N": %d, + "validators_power_cap": %d, + "validator_set_cap": %d, + "allowlist": %s, + "denylist": %s, + "authority": "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn" + } + ], +"metadata": "ipfs://CID", +"deposit": "%dstake", +"title": "Propose the addition of a new chain", +"summary": "Gonna be a great chain", +"expedited": false +}` + jsonStr := fmt.Sprintf(template, + string(tr.testConfig.chainConfigs[action.ConsumerChain].ChainId), + action.InitialHeight.RevisionNumber, + action.InitialHeight.RevisionHeight, + base64.StdEncoding.EncodeToString([]byte("gen_hash")), + base64.StdEncoding.EncodeToString([]byte("bin_hash")), + spawnTime.Local().Format(time.RFC3339Nano), + params.UnbondingPeriod, + params.CcvTimeoutPeriod, + params.TransferTimeoutPeriod, + params.ConsumerRedistributionFraction, + params.BlocksPerDistributionTransmission, + params.HistoricalEntries, + action.DistributionChannel, + action.TopN, + action.ValidatorsPowerCap, + action.ValidatorSetCap, + action.Allowlist, + action.Denylist, + action.Deposit) //#nosec G204 -- bypass unsafe quoting warning (no production code) - cmd := tr.target.ExecCommand( - "/bin/bash", "-c", fmt.Sprintf(`echo '%s' > %s`, jsonStr, "/temp-proposal.json")) - bz, err = cmd.CombinedOutput() - if verbose { - log.Println("submitConsumerAdditionProposal cmd: ", cmd.String()) - } - + proposalFile := "/consumer-addition.proposal" + bz, err := tr.target.ExecCommand( + "/bin/bash", "-c", fmt.Sprintf(`echo '%s' > %s`, jsonStr, proposalFile), + ).CombinedOutput() if err != nil { log.Fatal(err, "\n", string(bz)) } // CONSUMER ADDITION PROPOSAL - cmd = tr.target.ExecCommand( + cmd := tr.target.ExecCommand( tr.testConfig.chainConfigs[action.Chain].BinaryName, - "tx", "gov", "submit-legacy-proposal", "consumer-addition", "/temp-proposal.json", + "tx", "gov", "submit-proposal", proposalFile, `--from`, `validator`+fmt.Sprint(action.From), `--chain-id`, string(tr.testConfig.chainConfigs[action.Chain].ChainId), `--home`, tr.getValidatorHome(action.Chain, action.From), - `--gas`, `900000`, `--node`, tr.getValidatorNode(action.Chain, action.From), + `--gas`, "900000", `--keyring-backend`, `test`, `-y`, ) @@ -339,7 +357,7 @@ func (tr Chain) submitConsumerAdditionProposal( } bz, err = cmd.CombinedOutput() if err != nil { - log.Fatal(err, "\n", string(bz)) + log.Fatal("submit-proposal failed:", err, "\n", string(bz)) } if verbose { @@ -347,7 +365,7 @@ func (tr Chain) submitConsumerAdditionProposal( } // wait for inclusion in a block -> '--broadcast-mode block' is deprecated - tr.waitBlocks(ChainID("provi"), 2, 10*time.Second) + tr.waitBlocks(action.Chain, 2, 10*time.Second) } type SubmitConsumerRemovalProposalAction struct { diff --git a/tests/e2e/state.go b/tests/e2e/state.go index fba5e36c3a..a9864123ac 100644 --- a/tests/e2e/state.go +++ b/tests/e2e/state.go @@ -465,7 +465,7 @@ func (tr Commands) GetProposal(chain ChainID, proposal uint) Proposal { Title: title, Description: description, } - case "/interchain_security.ccv.provider.v1.ConsumerAdditionProposal": + case "/interchain_security.ccv.provider.v1.MsgConsumerAddition": chainId := rawContent.Get("chain_id").String() spawnTime := rawContent.Get("spawn_time").Time().Sub(tr.containerConfig.Now) @@ -555,7 +555,7 @@ func (tr Commands) GetProposal(chain ChainID, proposal uint) Proposal { } } - log.Fatal("received unknown proposal type: ", propType, "proposal JSON:", propRaw) + log.Fatal("received unknown proposal type: '", propType, "', proposal JSON:", propRaw) return nil } diff --git a/tests/integration/provider_gov_hooks.go b/tests/integration/provider_gov_hooks.go index e3f9cc8ace..91f9447d87 100644 --- a/tests/integration/provider_gov_hooks.go +++ b/tests/integration/provider_gov_hooks.go @@ -21,15 +21,9 @@ func (s *CCVTestSuite) TestAfterPropSubmissionAndVotingPeriodEnded() { govKeeper := s.providerApp.GetTestGovKeeper() proposer := s.providerChain.SenderAccount - content := testkeeper.GetTestConsumerAdditionProp() - content.ChainId = "newchain-0" - legacyPropContent, err := v1.NewLegacyContent( - content, - authtypes.NewModuleAddress("gov").String(), - ) - s.Require().NoError(err) + addConsumerProp := testkeeper.GetTestMsgConsumerAddition() - proposal, err := v1.NewProposal([]sdk.Msg{legacyPropContent}, 1, time.Now(), time.Now().Add(1*time.Hour), "metadata", "title", "summary", proposer.GetAddress(), false) + proposal, err := v1.NewProposal([]sdk.Msg{&addConsumerProp}, 1, time.Now(), time.Now().Add(1*time.Hour), "metadata", "title", "summary", proposer.GetAddress(), false) s.Require().NoError(err) err = govKeeper.SetProposal(ctx, proposal) @@ -41,14 +35,14 @@ func (s *CCVTestSuite) TestAfterPropSubmissionAndVotingPeriodEnded() { proposalIdOnProvider, ok := providerKeeper.GetProposedConsumerChain(ctx, proposal.Id) s.Require().True(ok) s.Require().NotEmpty(proposalIdOnProvider) - s.Require().Equal(content.ChainId, proposalIdOnProvider) + s.Require().Equal(addConsumerProp.ChainId, proposalIdOnProvider) providerKeeper.Hooks().AfterProposalVotingPeriodEnded(ctx, proposal.Id) // verify that the proposal ID is deleted s.Require().Empty(providerKeeper.GetProposedConsumerChain(ctx, proposal.Id)) } -func (s *CCVTestSuite) TestGetConsumerAdditionLegacyPropFromProp() { +func (s *CCVTestSuite) TestGetConsumerAdditionFromProp() { ctx := s.providerChain.GetContext() proposer := s.providerChain.SenderAccount @@ -59,13 +53,19 @@ func (s *CCVTestSuite) TestGetConsumerAdditionLegacyPropFromProp() { Amount: sdk.NewCoins(sdk.NewCoin("stake", math.OneInt())), } + // create a legacy proposal textProp, err := v1.NewLegacyContent( v1beta1.NewTextProposal("a title", "a legacy text prop"), authtypes.NewModuleAddress("gov").String(), ) s.Require().NoError(err) - addConsumerProp, err := v1.NewLegacyContent( + // create a valid consumer addition proposal + addConsumerProp := testkeeper.GetTestMsgConsumerAddition() + + // create a legacy consumer addition proposal content + // (not supported anymore) + addConsumerPropLegacy, err := v1.NewLegacyContent( testkeeper.GetTestConsumerAdditionProp(), authtypes.NewModuleAddress("gov").String(), ) @@ -84,7 +84,7 @@ func (s *CCVTestSuite) TestGetConsumerAdditionLegacyPropFromProp() { expPanic: false, }, { - name: "msgs in prop contain no legacy props", + name: "msgs in prop contain no consumer addition props", propMsg: dummyMsg, expectConsumerPropFound: false, expPanic: false, @@ -98,11 +98,17 @@ func (s *CCVTestSuite) TestGetConsumerAdditionLegacyPropFromProp() { name: "msgs contain an invalid legacy prop", propMsg: &v1.MsgExecLegacyContent{}, expectConsumerPropFound: false, - expPanic: true, + expPanic: false, + }, + { + name: "msg contains a prop of legacy ConsumerAdditionProposal type - hook should NOT create a new proposed", + propMsg: addConsumerPropLegacy, + expectConsumerPropFound: false, + expPanic: false, }, { - name: "msg contains a prop of ConsumerAdditionProposal type - hook should create a new proposed chain", - propMsg: addConsumerProp, + name: "msg contains a prop of legacy ConsumerAdditionProposal type - hook should create a new proposed", + propMsg: &addConsumerProp, expectConsumerPropFound: true, expPanic: false, }, @@ -132,12 +138,12 @@ func (s *CCVTestSuite) TestGetConsumerAdditionLegacyPropFromProp() { if tc.expPanic { s.Require().Panics(func() { // this panics with a nil pointer dereference because the proposal is invalid and cannot be unmarshalled - providerKeeper.Hooks().GetConsumerAdditionLegacyPropFromProp(ctx, proposal.Id) + providerKeeper.Hooks().GetConsumerAdditionFromProp(ctx, proposal.Id) }) return } - savedProp, found := providerKeeper.Hooks().GetConsumerAdditionLegacyPropFromProp(ctx, proposal.Id) + savedProp, found := providerKeeper.Hooks().GetConsumerAdditionFromProp(ctx, proposal.Id) if tc.expectConsumerPropFound { s.Require().True(found) s.Require().NotEmpty(savedProp, savedProp) diff --git a/testutil/integration/debug_test.go b/testutil/integration/debug_test.go index 022cc71429..dedd937eaa 100644 --- a/testutil/integration/debug_test.go +++ b/testutil/integration/debug_test.go @@ -265,8 +265,8 @@ func TestAfterPropSubmissionAndVotingPeriodEnded(t *testing.T) { runCCVTestByName(t, "TestAfterPropSubmissionAndVotingPeriodEnded") } -func TestGetConsumerAdditionLegacyPropFromProp(t *testing.T) { - runCCVTestByName(t, "TestGetConsumerAdditionLegacyPropFromProp") +func TestGetConsumerAdditionFromProp(t *testing.T) { + runCCVTestByName(t, "TestGetConsumerAdditionFromProp") } func TestIBCTransferMiddleware(t *testing.T) { @@ -277,14 +277,6 @@ func TestAllocateTokens(t *testing.T) { runCCVTestByName(t, "TestAllocateTokens") } -func TestTransferConsumerRewardsToDistributionModule(t *testing.T) { - runCCVTestByName(t, "TransferConsumerRewardsToDistributionModule") -} - -func TestAllocateTokensToValidator(t *testing.T) { - runCCVTestByName(t, "TestAllocateTokensToValidator") -} - func TestMultiConsumerRewardsDistribution(t *testing.T) { runCCVTestByName(t, "TestMultiConsumerRewardsDistribution") } diff --git a/testutil/keeper/unit_test_helpers.go b/testutil/keeper/unit_test_helpers.go index 72a59a1207..0ac48f8e6c 100644 --- a/testutil/keeper/unit_test_helpers.go +++ b/testutil/keeper/unit_test_helpers.go @@ -2,6 +2,7 @@ package keeper import ( "crypto/rand" + "encoding/base64" "encoding/binary" "testing" "time" @@ -293,6 +294,29 @@ func GetTestConsumerAdditionProp() *providertypes.ConsumerAdditionProposal { return prop } +func GetTestMsgConsumerAddition() providertypes.MsgConsumerAddition { + return providertypes.MsgConsumerAddition{ + ChainId: "a ChainID", + InitialHeight: clienttypes.NewHeight(4, 5), + GenesisHash: []byte(base64.StdEncoding.EncodeToString([]byte("gen_hash"))), + BinaryHash: []byte(base64.StdEncoding.EncodeToString([]byte("bin_hash"))), + SpawnTime: time.Now(), + UnbondingPeriod: types.DefaultConsumerUnbondingPeriod, + CcvTimeoutPeriod: types.DefaultCCVTimeoutPeriod, + TransferTimeoutPeriod: types.DefaultTransferTimeoutPeriod, + ConsumerRedistributionFraction: types.DefaultConsumerRedistributeFrac, + BlocksPerDistributionTransmission: types.DefaultBlocksPerDistributionTransmission, + HistoricalEntries: types.DefaultHistoricalEntries, + DistributionTransmissionChannel: "", + Top_N: 10, + ValidatorsPowerCap: 0, + ValidatorSetCap: 0, + Allowlist: nil, + Denylist: nil, + Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), + } +} + // Obtains a CrossChainValidator with a newly generated key, and randomized field values func GetNewCrossChainValidator(t *testing.T) consumertypes.CrossChainValidator { t.Helper() diff --git a/x/ccv/provider/client/legacy_proposal_handler.go b/x/ccv/provider/client/legacy_proposal_handler.go index 6a792ef4b0..f52b7db172 100644 --- a/x/ccv/provider/client/legacy_proposal_handler.go +++ b/x/ccv/provider/client/legacy_proposal_handler.go @@ -15,7 +15,7 @@ import ( ) var ( - ConsumerAdditionProposalHandler = govclient.NewProposalHandler(SubmitConsumerAdditionPropTxCmd) + //ConsumerAdditionProposalHandler = govclient.NewProposalHandler(SubmitConsumerAdditionPropTxCmd) ConsumerRemovalProposalHandler = govclient.NewProposalHandler(SubmitConsumerRemovalProposalTxCmd) ChangeRewardDenomsProposalHandler = govclient.NewProposalHandler(SubmitChangeRewardDenomsProposalTxCmd) ConsumerModificationProposalHandler = govclient.NewProposalHandler(SubmitConsumerModificationProposalTxCmd) @@ -23,6 +23,7 @@ var ( // SubmitConsumerAdditionPropTxCmd returns a CLI command handler for submitting // a consumer addition proposal via a transaction. +// TODO BERND: remove this!!! func SubmitConsumerAdditionPropTxCmd() *cobra.Command { return &cobra.Command{ Use: "consumer-addition [proposal-file]", diff --git a/x/ccv/provider/keeper/hooks.go b/x/ccv/provider/keeper/hooks.go index 15d5d0e769..5005795166 100644 --- a/x/ccv/provider/keeper/hooks.go +++ b/x/ccv/provider/keeper/hooks.go @@ -2,12 +2,10 @@ package keeper import ( "context" - "fmt" "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" sdkgov "github.com/cosmos/cosmos-sdk/x/gov/types" - v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" @@ -112,8 +110,7 @@ func (h Hooks) BeforeTokenizeShareRecordRemoved(_ context.Context, _ uint64) err // that maps the proposal ID to the consumer chain ID. func (h Hooks) AfterProposalSubmission(goCtx context.Context, proposalID uint64) error { ctx := sdk.UnwrapSDKContext(goCtx) - - if p, ok := h.GetConsumerAdditionLegacyPropFromProp(ctx, proposalID); ok { + if p, ok := h.GetConsumerAdditionFromProp(ctx, proposalID); ok { h.k.SetProposedConsumerChain(ctx, p.ChainId, proposalID) } return nil @@ -126,7 +123,7 @@ func (h Hooks) AfterProposalSubmission(goCtx context.Context, proposalID uint64) func (h Hooks) AfterProposalVotingPeriodEnded(goCtx context.Context, proposalID uint64) error { ctx := sdk.UnwrapSDKContext(goCtx) - if _, ok := h.GetConsumerAdditionLegacyPropFromProp(ctx, proposalID); ok { + if _, ok := h.GetConsumerAdditionFromProp(ctx, proposalID); ok { h.k.DeleteProposedConsumerChainInStore(ctx, proposalID) } return nil @@ -144,9 +141,9 @@ func (h Hooks) AfterProposalFailedMinDeposit(ctx context.Context, proposalID uin return nil } -// GetConsumerAdditionLegacyPropFromProp extracts a consumer addition legacy proposal from +// GetConsumerAdditionFromProp extracts a consumer addition legacy proposal from // the proposal with the given ID -func (h Hooks) GetConsumerAdditionLegacyPropFromProp( +func (h Hooks) GetConsumerAdditionFromProp( ctx sdk.Context, proposalID uint64, ) (providertypes.ConsumerAdditionProposal, bool) { @@ -158,21 +155,33 @@ func (h Hooks) GetConsumerAdditionLegacyPropFromProp( // Iterate over the messages in the proposal // Note that it's assumed that at most ONE message can contain a consumer addition proposal for _, msg := range p.GetMessages() { - sdkMsg, isLegacyProposal := msg.GetCachedValue().(*v1.MsgExecLegacyContent) - if !isLegacyProposal { + sdkMsg, isConsumerAddition := msg.GetCachedValue().(*providertypes.MsgConsumerAddition) + if !isConsumerAddition { continue } - content, err := v1.LegacyContentFromMessage(sdkMsg) - if err != nil { - panic(fmt.Errorf("failed to get legacy proposal %d from prop message", proposalID)) - } - - // returns if legacy prop is of ConsumerAddition proposal type - prop, ok := content.(*providertypes.ConsumerAdditionProposal) - if ok { - return *prop, true + proposal := providertypes.ConsumerAdditionProposal{ + Title: p.Title, + Description: p.Summary, + ChainId: sdkMsg.ChainId, + InitialHeight: sdkMsg.InitialHeight, + GenesisHash: sdkMsg.GenesisHash, + BinaryHash: sdkMsg.BinaryHash, + SpawnTime: sdkMsg.SpawnTime, + UnbondingPeriod: sdkMsg.UnbondingPeriod, + CcvTimeoutPeriod: sdkMsg.CcvTimeoutPeriod, + TransferTimeoutPeriod: sdkMsg.TransferTimeoutPeriod, + ConsumerRedistributionFraction: sdkMsg.ConsumerRedistributionFraction, + BlocksPerDistributionTransmission: sdkMsg.BlocksPerDistributionTransmission, + HistoricalEntries: sdkMsg.HistoricalEntries, + DistributionTransmissionChannel: sdkMsg.DistributionTransmissionChannel, + Top_N: sdkMsg.Top_N, + ValidatorsPowerCap: sdkMsg.ValidatorsPowerCap, + ValidatorSetCap: sdkMsg.ValidatorSetCap, + Allowlist: sdkMsg.Allowlist, + Denylist: sdkMsg.Denylist, } + return proposal, true } return providertypes.ConsumerAdditionProposal{}, false } diff --git a/x/ccv/provider/types/codec.go b/x/ccv/provider/types/codec.go index a3593fb22f..17ccc0deba 100644 --- a/x/ccv/provider/types/codec.go +++ b/x/ccv/provider/types/codec.go @@ -31,7 +31,9 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { registry.RegisterImplementations( (*sdk.Msg)(nil), &MsgAssignConsumerKey{}, - &MsgConsumerAddition{}, + &MsgConsumerAddition{}, //TOOD @permissionless: replace with below + //&MsgInitializeConsumer{}, //TOOD @permissionless: uncomment once implemented + //&MsgUpdateConsumer{}, //TOOD @permissionless: uncomment once implemented &MsgConsumerRemoval{}, &MsgChangeRewardDenoms{}, &MsgUpdateParams{}, diff --git a/x/ccv/provider/types/tx.pb.go b/x/ccv/provider/types/tx.pb.go index 146475a32d..1b8dadf253 100644 --- a/x/ccv/provider/types/tx.pb.go +++ b/x/ccv/provider/types/tx.pb.go @@ -377,7 +377,6 @@ var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo // If it passes, then all validators on the provider chain are expected to validate // the consumer chain at spawn time or get slashed. // It is recommended that spawn time occurs after the proposal end time. -// // Note: this replaces ConsumerAdditionProposal which is deprecated and will be removed soon type MsgConsumerAddition struct { // the proposed chain-id of the new consumer chain, must be different from all