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
34 changes: 20 additions & 14 deletions x/ibc/core/02-client/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,27 @@ import (
func BeginBlocker(ctx sdk.Context, k keeper.Keeper) {
plan, found := k.GetUpgradePlan(ctx)
if found {
// Once we are at the last block this chain will commit, set the upgraded consensus state
// so that IBC clients can use the last NextValidatorsHash as a trusted kernel for verifying
// headers on the next version of the chain.
// Set the time to the last block time of the current chain.
// In order for a client to upgrade successfully, the first block of the new chain must be committed
// within the trusting period of the last block time on this chain.
_, exists := k.GetUpgradedClient(ctx, plan.Height)
if exists && ctx.BlockHeight() == plan.Height-1 {
upgradedConsState := &ibctmtypes.ConsensusState{
Timestamp: ctx.BlockTime(),
NextValidatorsHash: ctx.BlockHeader().NextValidatorsHash,
}
bz := k.MustMarshalConsensusState(upgradedConsState)
planHeight, found := k.GetUpgradePlanHeight(ctx)
if found {
// Once we are at the last block this chain will commit, set the upgraded consensus state
// so that IBC clients can use the last NextValidatorsHash as a trusted kernel for verifying
// headers on the next version of the chain.
// Set the time to the last block time of the current chain.
// In order for a client to upgrade successfully, the first block of the new chain must be committed
// within the trusting period of the last block time on this chain.
//
// The upgrade plan must exist in x/upgrade, the plan must be an IBC upgrade, and the current height
// must be one before the scheduled IBC upgrade.
_, exists := k.GetUpgradedClient(ctx, int64(planHeight))
if exists && ctx.BlockHeight() == int64(planHeight)-1 && ctx.BlockHeight() == plan.Height-1 {
upgradedConsState := &ibctmtypes.ConsensusState{
Timestamp: ctx.BlockTime(),
NextValidatorsHash: ctx.BlockHeader().NextValidatorsHash,
}
bz := k.MustMarshalConsensusState(upgradedConsState)

k.SetUpgradedConsensusState(ctx, plan.Height, bz)
k.SetUpgradedConsensusState(ctx, plan.Height, bz)
}
}
}

Expand Down
1 change: 1 addition & 0 deletions x/ibc/core/02-client/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func (suite *ClientTestSuite) TestBeginBlockerConsensusState() {
store := suite.chainA.GetContext().KVStore(suite.chainA.App.GetKey(upgradetypes.StoreKey))
bz := suite.chainA.App.AppCodec().MustMarshalBinaryBare(plan)
store.Set(upgradetypes.PlanKey(), bz)
suite.chainA.App.IBCKeeper.ClientKeeper.SetUpgradePlanHeight(suite.chainA.GetContext(), uint64(plan.Height))

nextValsHash := []byte("nextValsHash")
newCtx := suite.chainA.GetContext().WithBlockHeader(tmproto.Header{
Expand Down
8 changes: 4 additions & 4 deletions x/ibc/core/02-client/types/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,14 @@ func (up *UpgradeProposal) ValidateBasic() error {
return err
}

if up.Plan.Height <= 0 {
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")
}

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.UpgradedClientState == nil {
return sdkerrors.Wrap(ErrInvalidUpgradeProposal, "upgraded client state cannot be nil")
}
Expand Down
8 changes: 7 additions & 1 deletion x/ibc/core/02-client/types/proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,18 @@ func (suite *TypesTestSuite) TestUpgradeProposalValidateBasic() {
suite.Require().NoError(err)
}, false,
},
{
"plan height is zero", func() {
invalidPlan := upgradetypes.Plan{Name: "ibc upgrade", Height: 0}
proposal, err = types.NewUpgradeProposal(ibctesting.Title, ibctesting.Description, invalidPlan, cs)
suite.Require().NoError(err)
}, false,
},
{
"plan time is not set to 0", func() {
invalidPlan := upgradetypes.Plan{Name: "ibc upgrade", Time: time.Now()}
proposal, err = types.NewUpgradeProposal(ibctesting.Title, ibctesting.Description, invalidPlan, cs)
suite.Require().NoError(err)

}, false,
},
{
Expand Down