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

feat: handler for ChanUpgradeTry #3628

Merged
merged 114 commits into from
Jun 7, 2023

Conversation

charleenfei
Copy link
Contributor

@charleenfei charleenfei commented May 22, 2023

This PR introduces the ChanUpgradeTry handler.

closes: #3739


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 and Go style guide.
  • Wrote unit and integration tests.
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/).
  • Added relevant godoc comments.
  • Provide a commit message to be used for the changelog entry in the PR description for review.
  • Re-reviewed Files changed in the Github PR explorer.
  • Review Codecov Report in the comment section below once CI passes.

colin-axner and others added 30 commits April 13, 2023 10:50
…e-basic-functions' into cian/issue#3451-add-verifiable-upgrade-type-and-validate-basic-functions
…it-to-use-new-upgrade-type' into charly/#3448-modify-upgrade-try
…init-to-use-new-upgrade-type' into charly/#3448-modify-upgrade-try
…init-to-use-new-upgrade-type' into charly/#3448-modify-upgrade-try
…ype' of https://github.com/cosmos/ibc-go into cian/issue#3447-modify-upgradeinit-to-use-new-upgrade-type
@charleenfei charleenfei marked this pull request as draft June 5, 2023 12:50
@charleenfei charleenfei marked this pull request as ready for review June 6, 2023 12:02
Copy link
Contributor

@chatton chatton left a comment

Choose a reason for hiding this comment

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

LGTM! Excited to get this merged, thanks for all the hard work on this one, this should make all the follow up PRs more manageable to review 👍

Comment on lines +613 to +615
if !found {
return fmt.Errorf("could not find upgrade for channel %s", endpoint.ChannelID)
}
Copy link
Contributor

@colin-axner colin-axner Jun 7, 2023

Choose a reason for hiding this comment

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

This is unreachable since it will fail on line 611, maybe you can add the error string to line 611

Copy link
Member

@damiannolan damiannolan left a comment

Choose a reason for hiding this comment

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

Nice, happy to get this merged asap! Just left some comments on test setup.

Is the intention to have follow up PRs addressing all of the inline code comments and testcases?

Comment on lines +232 to +239
proposedConnectionHops = []string{path.EndpointB.ConnectionID}
upgrade := types.NewUpgrade(
types.NewUpgradeFields(
types.UNORDERED, proposedConnectionHops, fmt.Sprintf("%s-v2", mock.Version),
),
types.NewTimeout(path.EndpointA.Chain.GetTimeoutHeight(), 0),
0,
)
Copy link
Member

Choose a reason for hiding this comment

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

is it possible to use path.EndpointB.GetProposedUpgrade()?

Comment on lines +339 to +346
proposedConnectionHops := []string{path.EndpointB.ConnectionID}
upgrade = types.NewUpgrade(
types.NewUpgradeFields(
types.UNORDERED, proposedConnectionHops, fmt.Sprintf("%s-v2", mock.Version),
),
types.NewTimeout(path.EndpointA.Chain.GetTimeoutHeight(), 0),
0,
)
Copy link
Member

Choose a reason for hiding this comment

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

ditto

path = ibctesting.NewPath(suite.chainA, suite.chainB)
suite.coordinator.Setup(path)

path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = fmt.Sprintf("%s-v2", mock.Version)
Copy link
Member

Choose a reason for hiding this comment

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

if we use path.EndpointB.GetProposedUpgrade() below then here we can assign the upgrade version for both endpoints instead of just endpointA

Copy link
Member

Choose a reason for hiding this comment

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

fmt.Sprintf("%s-v2", mock.Version" can be replaced with mock.UpgradeVersion

Copy link
Contributor

Choose a reason for hiding this comment

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

haha we are on the same page #3628 (comment)

return types.Upgrade{}, errorsmod.Wrap(err, "failed to retrieve connection using the channel connection hops")
}

// make sure connection is OPEN
Copy link
Member

Choose a reason for hiding this comment

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

nit: I feel like this comment doesn't really add much value, I prefer to avoid inline comments which are self explanatory, this part of the code is self documenting and pretty obvious whats happening

)
}

// check if packet is timed out on the receiving chain
Copy link
Member

Choose a reason for hiding this comment

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

ditto re. this comment - this is also incorrect as it mentions packet but I understand this piece of timeout code will change later with the new Timeout API

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.

LGTM! I left a lot of small nits/suggestions/removing unnecessary code. Happy to address a lot of the issues in followups if needed. Maybe we can address the code removal suggestions here?

modules/core/04-channel/types/timeout.go Show resolved Hide resolved
modules/core/04-channel/keeper/upgrade.go Show resolved Hide resolved
true,
},
// {
// "success with later upgrade sequence",
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 not sure I follow. If I uncomment the test it passes

@@ -67,21 +68,69 @@ func (k Keeper) WriteUpgradeInitChannel(ctx sdk.Context, portID, channelID strin
emitChannelUpgradeInitEvent(ctx, portID, channelID, currentChannel, upgrade)
}

// upgradeTry
// ChanUpgradeTry is called by a module to accept the first step of a channel upgrade handshake initiated by
// a module on another chain. If this function is successful, the proposed upgrade will be returned. If the upgrade fails, the upgrade sequence will still be incremented but an error will be returned.
func (k Keeper) ChanUpgradeTry(
ctx sdk.Context,
portID,
channelID string,
proposedConnectionHops []string,
Copy link
Contributor

Choose a reason for hiding this comment

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

@AdityaSripal is it intentional that the TRY step must use the same version as the counterparty? I don't see a mention in the spec for this reasoning. There's no check in startFlushUpgradeHandshake for this (potentially because we automatically use the counterparty upgrade version, but there is a check for the ordering being the same (despite the fact we also use the counterparty upgrade ordering), so there's an inconsistency in construction

@colin-axner
Copy link
Contributor

Is the intention to have follow up PRs addressing all of the inline code comments and testcases?

yup!

Copy link
Member

@damiannolan damiannolan left a comment

Choose a reason for hiding this comment

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

ACK lets follow up with addressing comments from this PR

@colin-axner colin-axner enabled auto-merge (squash) June 7, 2023 11:11
@colin-axner
Copy link
Contributor

I will do followup testing nits. In parallel we can start work on the rest of this handler, but lets open a pr immediately once work is started on it, so we can work together on it (since it is blocking the next set of prs)

@colin-axner colin-axner merged commit 1d47967 into 04-channel-upgrades Jun 7, 2023
@colin-axner colin-axner deleted the charly/#3448-modify-upgrade-try branch June 7, 2023 11:18
colin-axner added a commit that referenced this pull request Jun 7, 2023
* chore: apply review nits to clean up testing code

* chore: continued nits addressed
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.

5 participants