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

Revisit logic for ibc v3 gov updates #440

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 12 additions & 16 deletions x/twasm/contract/incoming_msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,9 @@ func (p ExecuteGovProposal) GetProposalContent(sender sdk.AccAddress) govtypes.C
p.Proposal.Text.Description = p.Description
return p.Proposal.Text
case p.Proposal.RegisterUpgrade != nil:
return &upgradetypes.SoftwareUpgradeProposal{
Title: p.Title,
Description: p.Description,
Plan: *p.Proposal.RegisterUpgrade,
}
p.Proposal.RegisterUpgrade.Title = p.Title
p.Proposal.RegisterUpgrade.Description = p.Description
return p.Proposal.RegisterUpgrade
case p.Proposal.CancelUpgrade != nil:
p.Proposal.CancelUpgrade.Title = p.Title
p.Proposal.CancelUpgrade.Description = p.Description
Expand Down Expand Up @@ -129,15 +127,11 @@ func (p ExecuteGovProposal) GetProposalContent(sender sdk.AccAddress) govtypes.C

// unpackInterfaces unpacks the Any type into the interface type in `Any.cachedValue`
func (p *ExecuteGovProposal) unpackInterfaces(unpacker codectypes.AnyUnpacker) error {
var err error
switch { //nolint:gocritic
case p.Proposal.RegisterUpgrade != nil:
// revisit with https://github.com/confio/tgrade/issues/364
if p.Proposal.RegisterUpgrade.UpgradedClientState != nil { //nolint:staticcheck
return sdkerrors.ErrInvalidRequest.Wrap("upgrade logic for IBC has been moved to the IBC module")
}
return p.Proposal.RegisterUpgrade.UnpackInterfaces(unpacker)
}
return err
return nil
}

// ProtoAny data type to map from json to cosmos-sdk Any type.
Expand Down Expand Up @@ -191,10 +185,12 @@ func (p *GovProposal) UnmarshalJSON(b []byte) error {
if err := json.Unmarshal(b, &proxy); err != nil {
return sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error())
}
result.RegisterUpgrade = &upgradetypes.Plan{
Name: proxy.Name,
Height: proxy.Height,
Info: proxy.Info,
result.RegisterUpgrade = &ibcclienttypes.UpgradeProposal{
Plan: upgradetypes.Plan{
Name: proxy.Name,
Height: proxy.Height,
Info: proxy.Info,
},
}
return nil
},
Expand Down Expand Up @@ -264,7 +260,7 @@ type proposalContent struct {

// Register an "live upgrade" on the x/upgrade module
// See https://github.com/cosmos/cosmos-sdk/blob/v0.42.3/proto/cosmos/upgrade/v1beta1/upgrade.proto#L12-L53
RegisterUpgrade *upgradetypes.Plan `json:"register_upgrade"`
RegisterUpgrade *ibcclienttypes.UpgradeProposal `json:"register_upgrade"`

// There can only be one pending upgrade at a given time. This cancels the pending upgrade, if any.
// See https://github.com/cosmos/cosmos-sdk/blob/v0.42.3/proto/cosmos/upgrade/v1beta1/upgrade.proto#L57-L62
Expand Down
4 changes: 1 addition & 3 deletions x/twasm/contract/incoming_msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package contract
import (
"encoding/json"
"testing"
"time"

wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
Expand Down Expand Up @@ -47,9 +46,8 @@ func TestGetProposalContent(t *testing.T) {
"height": 1,
"info": "any information"
}}}}`,
expGovProposal: &upgradetypes.SoftwareUpgradeProposal{Title: "myTitle", Description: "myDescription", Plan: upgradetypes.Plan{
expGovProposal: &ibcclienttypes.UpgradeProposal{Title: "myTitle", Description: "myDescription", Plan: upgradetypes.Plan{
Name: "myUpgradeName",
Time: time.Time{},
Height: 1,
Info: "any information",
}},
Expand Down