-
Notifications
You must be signed in to change notification settings - Fork 590
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
Use new port router for onchanupgradetry #7067
Merged
chatton
merged 6 commits into
feat/port-router
from
cian/issue#7027-use-new-port-router-for-onchanupgradetry
Aug 7, 2024
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a5521ab
chore: add fee implementation for OnChanOpenTry
chatton fae6122
chore: fix wiring in app.gos
chatton 61c4799
chore: updated callbacks tests to handle new OnChanOpenTry
chatton 824d62f
chore: lint, correct error string
chatton abcdb32
chore: remove commented code
chatton 50be8e1
chore: addressing PR feedback
chatton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,6 +74,50 @@ func (im *LegacyIBCModule) OnChanOpenInit( | |
return reconstructVersion(im.cbs, negotiatedVersions) | ||
} | ||
|
||
// OnChanOpenTry implements the IBCModule interface. | ||
func (im *LegacyIBCModule) OnChanOpenTry( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is almost an exact duplicate, I played around with trying to generalize the Init/Try functions, but it ended up looking even uglier, happy to revisit this idea, but I think it's fine as is for now unless someone has a suggestion for removing the duplication. |
||
ctx sdk.Context, | ||
order channeltypes.Order, | ||
connectionHops []string, | ||
portID, | ||
channelID string, | ||
counterparty channeltypes.Counterparty, | ||
counterpartyVersion string, | ||
) (string, error) { | ||
negotiatedVersions := make([]string, len(im.cbs)) | ||
|
||
for i := len(im.cbs) - 1; i >= 0; i-- { | ||
cbVersion := counterpartyVersion | ||
|
||
// To maintain backwards compatibility, we must handle two cases: | ||
// - relayer provides empty version (use default versions) | ||
// - relayer provides version which chooses to not enable a middleware | ||
// | ||
// If an application is a VersionWrapper which means it modifies the version string | ||
// and the version string is non-empty (don't use default), then the application must | ||
// attempt to unmarshal the version using the UnwrapVersionUnsafe interface function. | ||
// If it is unsuccessful, no callback will occur to this application as the version | ||
// indicates it should be disabled. | ||
if wrapper, ok := im.cbs[i].(VersionWrapper); ok && strings.TrimSpace(counterpartyVersion) != "" { | ||
appVersion, underlyingAppVersion, err := wrapper.UnwrapVersionUnsafe(counterpartyVersion) | ||
if err != nil { | ||
// middleware disabled | ||
negotiatedVersions[i] = "" | ||
continue | ||
} | ||
cbVersion, counterpartyVersion = appVersion, underlyingAppVersion | ||
} | ||
|
||
negotiatedVersion, err := im.cbs[i].OnChanOpenTry(ctx, order, connectionHops, portID, channelID, counterparty, cbVersion) | ||
if err != nil { | ||
return "", errorsmod.Wrapf(err, "channel open try callback failed for port ID: %s, channel ID: %s", portID, channelID) | ||
} | ||
negotiatedVersions[i] = negotiatedVersion | ||
} | ||
|
||
return reconstructVersion(im.cbs, negotiatedVersions) | ||
} | ||
|
||
// reconstructVersion will generate the channel version by applying any version wrapping as necessary. | ||
// Version wrapping will only occur if the negotiated version is non=empty and the application is a VersionWrapper. | ||
func reconstructVersion(cbs []ClassicIBCModule, negotiatedVersions []string) (string, error) { | ||
|
@@ -90,19 +134,6 @@ func reconstructVersion(cbs []ClassicIBCModule, negotiatedVersions []string) (st | |
return version, nil | ||
} | ||
|
||
// OnChanOpenTry implements the IBCModule interface. | ||
func (LegacyIBCModule) OnChanOpenTry( | ||
ctx sdk.Context, | ||
order channeltypes.Order, | ||
connectionHops []string, | ||
portID, | ||
channelID string, | ||
counterparty channeltypes.Counterparty, | ||
counterpartyVersion string, | ||
) (string, error) { | ||
return "", nil | ||
} | ||
|
||
// OnChanOpenAck implements the IBCModule interface | ||
func (LegacyIBCModule) OnChanOpenAck( | ||
ctx sdk.Context, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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 think on Try, the version must be set
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.
makes sense!