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

Upgrade Client #7367

Merged
merged 34 commits into from
Oct 1, 2020
Merged

Upgrade Client #7367

merged 34 commits into from
Oct 1, 2020

Conversation

AdityaSripal
Copy link
Member

Description

closes: #6378


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 Sep 23, 2020

Codecov Report

Merging #7367 into master will increase coverage by 0.14%.
The diff coverage is 80.27%.

@@            Coverage Diff             @@
##           master    #7367      +/-   ##
==========================================
+ Coverage   54.81%   54.96%   +0.14%     
==========================================
  Files         587      588       +1     
  Lines       36512    36630     +118     
==========================================
+ Hits        20014    20133     +119     
- Misses      14406    14408       +2     
+ Partials     2092     2089       -3     

proto/ibc/lightclients/solomachine/v1/solomachine.proto Outdated Show resolved Hide resolved
x/ibc/02-client/keeper/client.go Outdated Show resolved Hide resolved
x/ibc/02-client/keeper/client.go Outdated Show resolved Hide resolved
x/ibc/07-tendermint/client/cli/tx.go Show resolved Hide resolved
@AdityaSripal AdityaSripal marked this pull request as ready for review September 29, 2020 20:09
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.

Looks good! thanks for the additional tests. Pending lint and test fixes

proto/ibc/client/client.proto Outdated Show resolved Hide resolved
var height = clienttypes.NewHeight(0, 4)
var (
height = clienttypes.NewHeight(0, 4)
upgradeHeight = clienttypes.NewHeight(1, 1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we define these on ibctesting instead?

x/ibc/07-tendermint/types/upgrade.go Outdated Show resolved Hide resolved
x/upgrade/abci_test.go Show resolved Hide resolved
x/upgrade/keeper/keeper.go Outdated Show resolved Hide resolved
x/upgrade/keeper/keeper.go Outdated Show resolved Hide resolved
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.

Fantastic work!!! This is a solid feature and super neat that it is integrated with the upgrade module!

Left mostly comments on increasing code cov. LGTM though

proto/cosmos/upgrade/v1beta1/upgrade.proto Outdated Show resolved Hide resolved
x/ibc/02-client/handler.go Show resolved Hide resolved
x/ibc/02-client/keeper/client.go Outdated Show resolved Hide resolved
x/ibc/02-client/keeper/client.go Show resolved Hide resolved
x/ibc/02-client/types/client.go Outdated Show resolved Hide resolved
x/ibc/07-tendermint/types/upgrade.go Show resolved Hide resolved
x/ibc/07-tendermint/types/upgrade_test.go Outdated Show resolved Hide resolved
Name: "alt-good",
Info: "new text here",
Height: 543210000,
UpgradedClientState: altCs,
Copy link
Contributor

Choose a reason for hiding this comment

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

this should overwrite with non IBC plan so the upgrade client state should be nil right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct, as mentioned in test case name

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused? Why is UpgradedClientState: altCs set then?

func (p Plan) String() string {
due := p.DueAt()
dueUp := strings.ToUpper(due[0:1]) + due[1:]
var upgradedClientStr string
upgradedClient, err := clienttypes.UnpackClientState(p.UpgradedClientState)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest checking if p.UpgradedClientState != nil instead of allowing unpack with a nil client state. The err on unpacking could be return instead of no upgraded client provided

Copy link
Member Author

Choose a reason for hiding this comment

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

Can't return an error because that would break fmt.Stringer interface

Copy link
Contributor

Choose a reason for hiding this comment

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

why can't you set upgradedClientStr = err.Error()?

// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces
func (p Plan) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
// UpgradedClientState may be nil
if p.UpgradedClientState == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

see above comment, this seems unnecessary. I'm a little confused why unpack doesn't succeed if this returns nil as well

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.

ACK. Pending minor test cases. Great work!

x/ibc/02-client/types/msgs.go Show resolved Hide resolved
x/ibc/02-client/types/msgs.go Outdated Show resolved Hide resolved
x/ibc/02-client/types/msgs.go Outdated Show resolved Hide resolved
x/upgrade/keeper/keeper.go Show resolved Hide resolved
x/upgrade/keeper/keeper.go Show resolved Hide resolved
@fedekunze
Copy link
Collaborator

merging this to unblock #7408. @cwgoes's comments can be addressed on a follow-up

@fedekunze fedekunze merged commit 01fd22d into master Oct 1, 2020
@fedekunze fedekunze deleted the aditya-upgrade-client branch October 1, 2020 06:22
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.

Unless I'm missing something, we're not validating the non-zeroed-fields?


// counterparty chain must commit the upgraded client with all client-customizable fields zeroed out
// at the upgrade path specified by current client
committedClient := upgradedClient.ZeroCustomFields()
Copy link
Contributor

Choose a reason for hiding this comment

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

Where do we check that the non-zeroed-out fields correspond to the old (current) fields? The relayer shouldn't be choosing these

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not generally possible because the client state structure may have changed. I just check that the chosen fields are consistent with unchosen fields.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can't the relayer change the trusting ratio or something then? Are we preventing that somewhere?

Copy link
Contributor

@colin-axner colin-axner Oct 2, 2020

Choose a reason for hiding this comment

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

I think the issue here is the client state could change to something radically different (a solo machine client is used in testing) which may not have a trusting ratio?

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm, that would be alright, but we still can't let the relayer change these fields in e.g. a Tendermint to Tendermint upgrade

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade function for Tendermint light client
4 participants