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

Remove IBC logic from x/upgrade #8673

Merged
merged 47 commits into from
Mar 1, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
e65921b
add zeroed custom fields check to tm client
colin-axner Feb 23, 2021
64b59fd
remove custom fields function from x/upgrade and fix tests
colin-axner Feb 23, 2021
1234383
use []byte in x/upgrade, move abci to 02-client
colin-axner Feb 23, 2021
c5c0d26
remove x/ibc from types
colin-axner Feb 23, 2021
31ca56d
whoops, delete testing files
colin-axner Feb 23, 2021
9ea85b8
fix upgrade tests
colin-axner Feb 24, 2021
3449f66
fix tm tests
colin-axner Feb 24, 2021
01cc2d7
fix tests
colin-axner Feb 24, 2021
975133b
Merge branch 'master' of github.com:cosmos/cosmos-sdk into colin/rm-i…
colin-axner Feb 24, 2021
21fb511
update CHANGELOG
colin-axner Feb 24, 2021
862dc37
revert proto breakage, use reserved field cc @amaurym
colin-axner Feb 24, 2021
1d5bdd5
Merge branch 'master' into colin/rm-ibc-from-upgrade
colin-axner Feb 24, 2021
dd180e8
add IBC Upgrade Proposal type
colin-axner Feb 25, 2021
99f8a76
remove IBC from upgrade types
colin-axner Feb 25, 2021
973cef5
add IBC upgrade logic to 02-client
colin-axner Feb 25, 2021
c47f4ce
Merge branch 'colin/rm-ibc-from-upgrade' of github.com:cosmos/cosmos-…
colin-axner Feb 25, 2021
c9e515b
fix all tests for x/upgrade
colin-axner Feb 25, 2021
1590837
Add CLI for IBC Upgrade Proposal
colin-axner Feb 25, 2021
a2959f6
Merge branch 'master' of github.com:cosmos/cosmos-sdk into colin/rm-i…
colin-axner Feb 25, 2021
5295e58
Update x/ibc/core/02-client/types/proposal_test.go
colin-axner Feb 25, 2021
b136626
Merge branch 'colin/rm-ibc-from-upgrade' of github.com:cosmos/cosmos-…
colin-axner Feb 25, 2021
49924c8
add gRPC for upgraded client state
colin-axner Feb 25, 2021
d05fba1
test fixes
colin-axner Feb 25, 2021
d86f0b0
add HandleUpgradeProposal tests
colin-axner Feb 26, 2021
96bc1c8
update docs and remove unnecessary code
colin-axner Feb 26, 2021
28fb256
Merge branch 'master' into colin/rm-ibc-from-upgrade
colin-axner Feb 26, 2021
b1fc663
self review bug and test fixes
colin-axner Feb 26, 2021
715dd42
Merge branch 'colin/rm-ibc-from-upgrade' of github.com:cosmos/cosmos-…
colin-axner Feb 26, 2021
2b2e0b0
neatness
colin-axner Feb 26, 2021
a0ff9e3
Merge branch 'master' into colin/rm-ibc-from-upgrade
colin-axner Feb 26, 2021
7b281f4
construct empty rest handler
colin-axner Feb 26, 2021
75edb27
Merge branch 'master' into colin/rm-ibc-from-upgrade
colin-axner Feb 26, 2021
d771d4f
fix tests
colin-axner Feb 26, 2021
e9597c1
Merge branch 'colin/rm-ibc-from-upgrade' of github.com:cosmos/cosmos-…
colin-axner Feb 26, 2021
07670fc
fix stringer tests
colin-axner Feb 26, 2021
d3ecf9e
Update docs/core/proto-docs.md
colin-axner Mar 1, 2021
2a6adb0
add key in ibc store tracking ibc upgrade heights
colin-axner Mar 1, 2021
0b51095
Merge branch 'colin/rm-ibc-from-upgrade' of github.com:cosmos/cosmos-…
colin-axner Mar 1, 2021
d40e695
update abci and tests
colin-axner Mar 1, 2021
7906b28
Merge branch 'master' into colin/rm-ibc-from-upgrade
colin-axner Mar 1, 2021
0404d4e
Merge branch 'master' into colin/rm-ibc-from-upgrade
colin-axner Mar 1, 2021
9dbcbe1
Merge branch 'master' into colin/rm-ibc-from-upgrade
colin-axner Mar 1, 2021
73fefb9
Merge branch 'master' of github.com:cosmos/cosmos-sdk into colin/rm-i…
colin-axner Mar 1, 2021
abc4ebb
Merge branch 'colin/rm-ibc-from-upgrade' of github.com:cosmos/cosmos-…
colin-axner Mar 1, 2021
95cb360
revert key storage after discussion with @AdityaSripal
colin-axner Mar 1, 2021
5e20b2f
clear IBC states on cancelled upgrades
colin-axner Mar 1, 2021
57f2c8d
Merge branch 'master' into colin/rm-ibc-from-upgrade
colin-axner Mar 1, 2021
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
self review bug and test fixes
  • Loading branch information
colin-axner committed Feb 26, 2021
commit b1fc663ddbd3f9f8ebbc3b80494d2873c06729b5
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (x/distribution) [\#8473](https://github.com/cosmos/cosmos-sdk/pull/8473) On genesis init, if the distribution module account balance, coming from bank module state, does not match the one in distribution module state, the initialization will panic.
* (client/keys) [\#8500](https://github.com/cosmos/cosmos-sdk/pull/8500) `InfoImporter` interface is removed from legacy keybase.
* [\#8629](https://github.com/cosmos/cosmos-sdk/pull/8629) Deprecated `SetFullFundraiserPath` from `Config` in favor of `SetPurpose` and `SetCoinType`.
* (x/upgrade) [\#8673](https://github.com/cosmos/cosmos-sdk/pull/8673) Remove x/ibc imports from x/upgrade by replacing plan.UpgradedClient with a `[]byte` instead of using an `Any`. IBC upgrade begin blocker logic moved to the IBC module.
* (x/upgrade) [\#8673](https://github.com/cosmos/cosmos-sdk/pull/8673) Remove IBC logic from x/upgrade. Deprecates IBC fields in an Upgrade Plan. IBC upgrade logic moved to 02-client and an IBC UpgradeProposal is added.

### State Machine Breaking

Expand Down
2 changes: 1 addition & 1 deletion x/ibc/core/02-client/keeper/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (k Keeper) HandleUpgradeProposal(ctx sdk.Context, p *types.UpgradeProposal)
// clear any old IBC state stored by previous plan
oldPlan, found := k.GetUpgradePlan(ctx)
if found {
k.upgradeKeeper.ClearIBCState(ctx, oldPlan.Height-1)
k.upgradeKeeper.ClearIBCState(ctx, oldPlan.Height)
Copy link
Member

Choose a reason for hiding this comment

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

nit: Would be nice to implement this in ibc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

how do you mean by this? IBC would need the upgrade keeper store key to write to the upgrade store

}

clientState, err := types.UnpackClientState(p.UpgradedClientState)
Expand Down
8 changes: 8 additions & 0 deletions x/ibc/core/02-client/keeper/proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ func (suite *KeeperTestSuite) TestHandleUpgradeProposal() {
store := suite.chainA.GetContext().KVStore(suite.chainA.App.GetKey(upgradetypes.StoreKey))
bz := suite.chainA.App.AppCodec().MustMarshalBinaryBare(&oldPlan)
store.Set(upgradetypes.PlanKey(), bz)

bz, err := types.MarshalClientState(suite.chainA.App.AppCodec(), upgradedClientState)
suite.Require().NoError(err)
suite.chainA.App.UpgradeKeeper.SetUpgradedClient(suite.chainA.GetContext(), oldPlan.Height, bz)
}

upgradeProp, ok := content.(*types.UpgradeProposal)
Expand All @@ -225,6 +229,10 @@ func (suite *KeeperTestSuite) TestHandleUpgradeProposal() {
suite.Require().True(found)
suite.Require().Equal(plan, storedPlan)

// check that old upgraded client state is cleared
_, found = suite.chainA.App.UpgradeKeeper.GetUpgradedClient(suite.chainA.GetContext(), oldPlan.Height)
suite.Require().False(found)

// check that client state was set
storedClientState, found := suite.chainA.App.UpgradeKeeper.GetUpgradedClient(suite.chainA.GetContext(), plan.Height)
suite.Require().True(found)
Expand Down
21 changes: 12 additions & 9 deletions x/ibc/core/02-client/types/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ func NewUpgradeProposal(title, description string, plan upgradetypes.Plan, upgra
}, nil
}

// GetTitle returns the title of a client update proposal.
// GetTitle returns the title of a upgrade proposal.
func (up *UpgradeProposal) GetTitle() string { return up.Title }

// GetDescription returns the description of a client update proposal.
// GetDescription returns the description of a upgrade proposal.
func (up *UpgradeProposal) GetDescription() string { return up.Description }

// ProposalRoute returns the routing key of a client update proposal.
// ProposalRoute returns the routing key of a upgrade proposal.
func (up *UpgradeProposal) ProposalRoute() string { return RouterKey }

// ProposalType returns the upgrade proposal type.
Expand All @@ -115,6 +115,10 @@ func (up *UpgradeProposal) ValidateBasic() error {
return sdkerrors.Wrap(ErrInvalidUpgradeProposal, "IBC chain upgrades must only set height")
}

if up.UpgradedClientState == nil {
return sdkerrors.Wrap(ErrInvalidUpgradeProposal, "upgraded client state cannot be nil")
}

_, err := UnpackClientState(up.UpgradedClientState)
if err != nil {
return sdkerrors.Wrap(err, "failed to unpack upgraded client state")
Expand All @@ -133,12 +137,11 @@ func (up UpgradeProposal) String() string {
upgradedClientStr = upgradedClient.String()
}

return fmt.Sprintf(`IBC Upgrade Proposal:
Title: %s
Description: %s
Plan: %s
UpgradedClientState: %s
`, up.Title, up.Description, up.Plan, upgradedClientStr)
return fmt.Sprintf(`IBC Upgrade Proposal
colin-axner marked this conversation as resolved.
Show resolved Hide resolved
Title: %s
Description: %s
%s
Upgraded IBC Client: %s`, up.Title, up.Description, up.Plan, upgradedClientStr)
}

// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces
Expand Down
19 changes: 16 additions & 3 deletions x/ibc/core/02-client/types/proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ func (suite *TypesTestSuite) TestMarshalClientUpdateProposalProposal() {
cdc := codec.NewProtoCodec(ir)

// marshal message
bz, err := cdc.MarshalJSON(proposal)
content := proposal.(*types.ClientUpdateProposal)
bz, err := cdc.MarshalJSON(content)
suite.Require().NoError(err)

// unmarshal proposal
Expand Down Expand Up @@ -131,11 +132,21 @@ func (suite *TypesTestSuite) TestUpgradeProposalValidateBasic() {
{
"plan time is not set to 0", func() {
invalidPlan := upgradetypes.Plan{Name: "ibc upgrade", Time: time.Now()}
types.NewUpgradeProposal(ibctesting.Title, ibctesting.Description, invalidPlan, cs)
proposal, err = types.NewUpgradeProposal(ibctesting.Title, ibctesting.Description, invalidPlan, cs)
suite.Require().NoError(err)

}, false,
},
{
"client state is nil", func() {
proposal = &types.UpgradeProposal{
Title: ibctesting.Title,
Description: ibctesting.Description,
Plan: plan,
UpgradedClientState: nil,
}
}, false,
},
{
"failed to unpack client state", func() {
any, err := types.PackConsensusState(&ibctmtypes.ConsensusState{})
Expand All @@ -153,6 +164,8 @@ func (suite *TypesTestSuite) TestUpgradeProposalValidateBasic() {

for _, tc := range testCases {

tc.malleate()

err := proposal.ValidateBasic()

if tc.expPass {
Expand Down Expand Up @@ -209,7 +222,7 @@ func (suite *TypesTestSuite) TestUpgradeString() {
proposal, err := types.NewUpgradeProposal(ibctesting.Title, ibctesting.Description, plan, &ibctmtypes.ClientState{})
suite.Require().NoError(err)

expect := fmt.Sprintf("Upgrade Plan\n Name: ibc upgrade\n Height: 1000\n Info: https://foo.bar/baz.\n Upgraded IBC Client: %s", &ibctmtypes.ClientState{})
expect := fmt.Sprintf("IBC Upgrade Proposal\n Title: title\n Description: description\n Upgrade Plan\n Name: ibc upgrade\n Height: 1000\n Info: https://foo.bar/baz\n Upgraded IBC Client: %s", &ibctmtypes.ClientState{})

suite.Require().Equal(expect, proposal.String())
}
2 changes: 1 addition & 1 deletion x/upgrade/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func (k Keeper) ApplyUpgrade(ctx sdk.Context, plan types.Plan) {

// Must clear IBC state after upgrade is applied as it is stored separately from the upgrade plan.
// This will prevent resubmission of upgrade msg after upgrade is already completed.
k.ClearIBCState(ctx, plan.Height-1)
k.ClearIBCState(ctx, plan.Height)
k.ClearUpgradePlan(ctx)
k.setDone(ctx, plan.Name)
}
Expand Down