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

UpgradeClient Followup #1 #7457

Merged
merged 19 commits into from
Oct 8, 2020
Merged

UpgradeClient Followup #1 #7457

merged 19 commits into from
Oct 8, 2020

Conversation

AdityaSripal
Copy link
Member

@AdityaSripal AdityaSripal commented Oct 5, 2020

Description

The current UpgradeClient followup logic does not take into account at what point the upgrade is going to occur on the old chain. This is an issue because multiple upgrade plans might be voted on and stored, with the latest one taking precedence. This becomes a problem since outdated plans are still provable by IBC light clients. Clients need some way to know what the latest planned upgrade is.

In order to accomplish this, I set the upgraded client at the height the planned upgrade will occur. This upgrade height must then be passed into the MsgUpgradeClient struct. The upgrade client logic will use this upgrade height as the proof height to ensure that the passed in upgrade client is the latest agreed upon client at the time of the upgrade height.


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

@codecov
Copy link

codecov bot commented Oct 5, 2020

Codecov Report

Merging #7457 into master will increase coverage by 0.02%.
The diff coverage is 85.33%.

@@            Coverage Diff             @@
##           master    #7457      +/-   ##
==========================================
+ Coverage   55.25%   55.28%   +0.02%     
==========================================
  Files         591      591              
  Lines       36951    36998      +47     
==========================================
+ Hits        20416    20453      +37     
- Misses      14427    14432       +5     
- Partials     2108     2113       +5     

proto/ibc/core/client/v1/client.proto Outdated Show resolved Hide resolved
x/upgrade/keeper/keeper.go Show resolved Hide resolved
x/upgrade/keeper/keeper.go Show resolved Hide resolved
x/ibc/light-clients/07-tendermint/types/upgrade.go Outdated Show resolved Hide resolved
x/ibc/light-clients/07-tendermint/types/upgrade.go Outdated Show resolved Hide resolved
x/ibc/light-clients/07-tendermint/types/errors.go Outdated Show resolved Hide resolved
Comment on lines 116 to 120
keys := strings.Split(cs.UpgradePath, "/")
for _, k := range keys {
if strings.TrimSpace(k) == "" {
return sdkerrors.Wrapf(ErrInvalidUpgradePath, "upgrade path invalid: %s", cs.UpgradePath)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto, can we move this to a ValidateUpgradePath function?

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
@AdityaSripal AdityaSripal added this to the IBC 1.0 [Implementation] milestone Oct 5, 2020
@cwgoes
Copy link
Contributor

cwgoes commented Oct 6, 2020

In order to accomplish this, I set the upgraded client at the height the planned upgrade will occur. This upgrade height must then be passed into the MsgUpgradeClient struct. The upgrade client logic will use this upgrade height as the proof height to ensure that the passed in upgrade client is the latest agreed upon client at the time of the upgrade height.

In principle this seems alright but we need to be careful that off-by-one errors won't cause problems here - in particular, transactions processed in the last block need an extra block to be committed-to and proved - will that work here?

x/ibc/core/02-client/types/msgs_test.go Show resolved Hide resolved
x/ibc/light-clients/07-tendermint/types/errors.go Outdated Show resolved Hide resolved
x/upgrade/keeper/keeper.go Outdated Show resolved Hide resolved
x/upgrade/keeper/keeper.go Show resolved Hide resolved
x/upgrade/keeper/keeper.go Show resolved Hide resolved
x/upgrade/keeper/keeper.go Show resolved Hide resolved
x/ibc/light-clients/07-tendermint/types/client_state.go Outdated Show resolved Hide resolved
x/ibc/light-clients/07-tendermint/types/upgrade.go Outdated Show resolved Hide resolved
x/ibc/light-clients/07-tendermint/types/upgrade.go Outdated Show resolved Hide resolved
AdityaSripal and others added 3 commits October 6, 2020 09:59
Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com>
@AdityaSripal
Copy link
Member Author

AdityaSripal commented Oct 6, 2020

In principle this seems alright but we need to be careful that off-by-one errors won't cause problems here - in particular, transactions processed in the last block need an extra block to be committed-to and proved - will that work here?

Yes this is an excellent point. This will work because it isn't as if the upgrade client is committed at the last block. It should be committed much earlier. It's just that we use the last block height to prove it since it the latest upgraded client is what will still remain in store by that point.

Although I think it is crucial that we see a live test of this feature in stargate testnets

cc: @cwgoes

@lgtm-com
Copy link

lgtm-com bot commented Oct 6, 2020

This pull request introduces 1 alert when merging 85817e5 into 3e6089d - view on LGTM.com

new alerts:

  • 1 for Useless assignment to local variable

x/ibc/light-clients/07-tendermint/types/upgrade.go Outdated Show resolved Hide resolved
@@ -112,6 +112,14 @@ func (cs ClientState) Validate() error {
return sdkerrors.Wrap(ErrInvalidProofSpecs, "proof spec cannot be nil")
}
}
if cs.UpgradePath != "" {
keys := strings.Split(cs.UpgradePath, "/")
Copy link
Contributor

Choose a reason for hiding this comment

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

should we move this to a utility function or is there one we could already use?

Copy link
Contributor

@colin-axner colin-axner left a comment

Choose a reason for hiding this comment

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

I'm still uncertain about the handling on Get/SetUpgradeClient. It feels like something someone will try to rewrite. Can you add sufficient godoc as to why it is constructed the way it is

x/ibc/core/02-client/types/msgs_test.go Show resolved Hide resolved
x/ibc/light-clients/07-tendermint/types/upgrade.go Outdated Show resolved Hide resolved
x/upgrade/keeper/keeper.go Show resolved Hide resolved
x/upgrade/keeper/keeper.go Show resolved Hide resolved
x/upgrade/keeper/keeper_test.go Outdated Show resolved Hide resolved
x/upgrade/keeper/keeper.go Show resolved Hide resolved
Copy link
Collaborator

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

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

Changes LGTM. Pending previous comments from reviews

x/upgrade/keeper/keeper.go Show resolved Hide resolved
x/upgrade/keeper/keeper.go Show resolved Hide resolved
@AdityaSripal AdityaSripal added the A:automerge Automatically merge PR once all prerequisites pass. label Oct 7, 2020
Copy link
Contributor

@colin-axner colin-axner left a comment

Choose a reason for hiding this comment

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

ACK for most recent changes

Copy link
Contributor

@cwgoes cwgoes left a comment

Choose a reason for hiding this comment

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

utACK

@mergify mergify bot merged commit 31ab35a into master Oct 8, 2020
@mergify mergify bot deleted the aditya/upgrade-followups branch October 8, 2020 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge Automatically merge PR once all prerequisites pass.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants