-
Notifications
You must be signed in to change notification settings - Fork 626
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
refactor: use explicit checks in ica controller upgrade handlers #5472
Conversation
@@ -162,30 +187,49 @@ func (k Keeper) OnChanUpgradeInit(ctx sdk.Context, portID, channelID string, ord | |||
return "", err | |||
} | |||
|
|||
if err := icatypes.ValidateControllerMetadata(ctx, k.channelKeeper, connectionHops, metadata); err != nil { | |||
return "", errorsmod.Wrap(err, "invalid metadata") | |||
// ValidateControllerMetadata will ensure the interchain account version has not changed and that the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could pull here down into a helper func ValidateUpgradeMetadata
, pulling out the relevant checks from ValidateControllerMetadata
, but left as duplication between upgrade init and upgrade ack for now
…troller Updated UpgradeInit logic Updated UpgradeAck logic Refactored UpgradeInit tests
33769a6
to
6fe19e1
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #5472 +/- ##
==========================================
+ Coverage 80.96% 81.09% +0.13%
==========================================
Files 197 197
Lines 15221 15234 +13
==========================================
+ Hits 12323 12354 +31
+ Misses 2427 2412 -15
+ Partials 471 468 -3
|
order channeltypes.Order | ||
) | ||
|
||
// updateMetadata is a helper function which modifies the metadata stored in the channel version | ||
// and marshals it into a string to pass to OnChanUpgradeInit as the counterpartyVersion string. | ||
updateMetadata := func(modificationFn func(*icatypes.Metadata)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated to match upgrade ack
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, very nice test coverage ❤️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, @colin-axner
if currentMetadata.ControllerConnectionId != proposedMetadata.ControllerConnectionId { | ||
return "", errorsmod.Wrap(connectiontypes.ErrInvalidConnection, "proposed controller connection ID must not change") | ||
} | ||
|
||
if currentMetadata.HostConnectionId != proposedMetadata.HostConnectionId { | ||
return "", errorsmod.Wrap(connectiontypes.ErrInvalidConnection, "proposed host connection ID must not change") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't feel too strongly about it, but if these checks are not reachable in either OnChanUpgradeInit
and OnChanUpgradeAck
, couldn't we just remove them and add a comment above the call to ValidateControllerMetadata
to explain that this function protects against these changes?
* refactor: explicit checks in upgrade init and upgrade ack for ica controller Updated UpgradeInit logic Updated UpgradeAck logic Refactored UpgradeInit tests * test: complete upgrade ack tests * test: add code cov * lint appease * nit: use correct error type * nit comment change * fix typo --------- Co-authored-by: Cian Hatton <cian@interchain.io> Co-authored-by: Carlos Rodriguez <carlos@interchain.io> (cherry picked from commit 4a021a3)
…) (#5518) * refactor: explicit checks in upgrade init and upgrade ack for ica controller Updated UpgradeInit logic Updated UpgradeAck logic Refactored UpgradeInit tests * test: complete upgrade ack tests * test: add code cov * lint appease * nit: use correct error type * nit comment change * fix typo --------- Co-authored-by: Cian Hatton <cian@interchain.io> Co-authored-by: Carlos Rodriguez <carlos@interchain.io> (cherry picked from commit 4a021a3) Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com>
Description
ref: #5462
Commit Message / Changelog Entry
see the guidelines for commit messages. (view raw markdown for examples)
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.
docs/
) or specification (x/<module>/spec/
).godoc
comments.Files changed
in the Github PR explorer.Codecov Report
in the comment section below once CI passes.