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
add key in ibc store tracking ibc upgrade heights
Add a new Key to the IBC client store to track the IBC Upgrade Height. This allows IBC upgrades to correctly remove old IBC upgrade states
  • Loading branch information
colin-axner committed Mar 1, 2021
commit 2a6adb0d6036abae46be050171b4e9020ef6fcf2
18 changes: 18 additions & 0 deletions x/ibc/core/02-client/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,24 @@ func (k Keeper) SetNextClientSequence(ctx sdk.Context, sequence uint64) {
store.Set([]byte(types.KeyNextClientSequence), bz)
}

// GetUpgradePlanHeight gets the IBC upgrade plan height.
func (k Keeper) GetUpgradePlanHeight(ctx sdk.Context) (uint64, bool) {
store := ctx.KVStore(k.storeKey)
colin-axner marked this conversation as resolved.
Show resolved Hide resolved
bz := store.Get([]byte(types.KeyUpgradePlanHeight))
if bz == nil {
return 0, false
}

return sdk.BigEndianToUint64(bz), true
}

// SetUpgradePlanHeight sets the IBC upgrade plan height to the store.
func (k Keeper) SetUpgradePlanHeight(ctx sdk.Context, height uint64) {
store := ctx.KVStore(k.storeKey)
bz := sdk.Uint64ToBigEndian(height)
store.Set([]byte(types.KeyUpgradePlanHeight), bz)
}

// IterateConsensusStates provides an iterator over all stored consensus states.
// objects. For each State object, cb will be called. If the cb returns true,
// the iterator will close and stop.
Expand Down
7 changes: 5 additions & 2 deletions x/ibc/core/02-client/keeper/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ func (k Keeper) ClientUpdateProposal(ctx sdk.Context, p *types.ClientUpdatePropo
// store.
func (k Keeper) HandleUpgradeProposal(ctx sdk.Context, p *types.UpgradeProposal) error {
// clear any old IBC state stored by previous plan
oldPlan, found := k.GetUpgradePlan(ctx)
planHeight, found := k.GetUpgradePlanHeight(ctx)
if found {
k.upgradeKeeper.ClearIBCState(ctx, oldPlan.Height)
k.upgradeKeeper.ClearIBCState(ctx, int64(planHeight))
}

clientState, err := types.UnpackClientState(p.UpgradedClientState)
Expand All @@ -98,6 +98,9 @@ func (k Keeper) HandleUpgradeProposal(ctx sdk.Context, p *types.UpgradeProposal)
return err
}

// set the new IBC upgrade plan height
k.SetUpgradePlanHeight(ctx, uint64(p.Plan.Height))

// sets the new upgraded client in last height committed on this chain is at plan.Height,
// since the chain will panic at plan.Height and new chain will resume at plan.Height
return k.upgradeKeeper.SetUpgradedClient(ctx, p.Plan.Height, bz)
Expand Down
1 change: 1 addition & 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,7 @@ 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)
suite.chainA.App.IBCKeeper.ClientKeeper.SetUpgradePlanHeight(suite.chainA.GetContext(), uint64(oldPlan.Height))

bz, err := types.MarshalClientState(suite.chainA.App.AppCodec(), upgradedClientState)
suite.Require().NoError(err)
Expand Down
4 changes: 4 additions & 0 deletions x/ibc/core/02-client/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ const (
// KeyNextClientSequence is the key used to store the next client sequence in
// the keeper.
KeyNextClientSequence = "nextClientSequence"

// KeyUpgradePlanHeight is the key used to store the IBC upgrade plan
// height in the keeper.
KeyUpgradePlanHeight = "upgradePlanHeight"
)

// FormatClientIdentifier returns the client identifier with the sequence appended.
Expand Down
4 changes: 4 additions & 0 deletions x/ibc/core/02-client/types/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ func (up *UpgradeProposal) ValidateBasic() error {
return err
}

if up.Plan.Height <= 0 {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is unreachable but safe to have. plan.ValidateBasic won't allow not setting time and height and it won't allow setting both time and height

return sdkerrors.Wrap(ErrInvalidUpgradeProposal, "IBC chain upgrades must set a positive height")
}

if up.Plan.Time.Unix() > 0 {
return sdkerrors.Wrap(ErrInvalidUpgradeProposal, "IBC chain upgrades must only set height")
}
Expand Down