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

fix: avoid race conditions in ics27 handshakes (backport #2682) #2698

Merged
merged 2 commits into from
Nov 8, 2022

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Nov 7, 2022

This is an automatic backport of pull request #2682 done by Mergify.


Mergify commands and options

More conditions and actions can be found in the documentation.

You can also trigger Mergify actions by commenting on this pull request:

  • @Mergifyio refresh will re-evaluate the rules
  • @Mergifyio rebase will rebase this PR on its base branch
  • @Mergifyio update will merge the base branch into this PR
  • @Mergifyio backport <destination> will backport this PR on <destination> branch

Additionally, on Mergify dashboard you can:

  • look at your merge queues
  • generate the Mergify configuration with the config editor.

Finally, you can contact us on https://mergify.com

* wip adding conditional to msg server and go apis, adding tests

* cleanup

* cleanup middleware enabled code

* adding additional test case for reopening channel via msg server

* Update modules/apps/27-interchain-accounts/controller/keeper/keeper.go

Co-authored-by: Cian Hatton <[email protected]>

* updating error msgs and test case assertion

* updating InitGenesis to set middleware disabled

Co-authored-by: Cian Hatton <[email protected]>
(cherry picked from commit c9b8064)
store.Set(icatypes.KeyIsMiddlewareEnabled(portID, connectionID), icatypes.MiddlewareEnabled)
}

// SetMiddlewareDisabled stores a flag to indicate that the underlying application callbacks should be disabled for the given port and connection identifier pair
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, but I didn't have time to review the original PR, so I am just mentioning this as a suggestion that could be taken up in a follow up PR if you think it's useful. It's more of a code hygiene thing, anyway...

Instead of having two separate functions (SetMiddlewareEnabled and SetMiddlewareDisabled), would it be possible instead to have just one (e.g. SetMiddlewareStatus) and pass as third argument either icatypes.MiddlewareEnabledoricatypes.MiddlewareDisabled? The key could be also icatypes.KeyIsMiddlewareStatusinsteadicatypes.KeyIsMiddlewareEnabled`.

Copy link
Member

Choose a reason for hiding this comment

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

I thought about this and originally when I was working on the issue I had one IsMiddlewareEnabled() func which retruned a true/false boolean value.

The problem with this is you need to handle more than just two cases cases. Middleware is either enabled, disabled or hasn't been set. In the case of it not being set it would be the first time a handshake is initiated for that connection/owner tuple and we need to allow it proceed these checks.

I think with your suggestion of SetMiddlewareStatus you'd also need a CheckMiddlewareStatus(enabled/disabled) which takes an arg and returns true/false in the appropriate cases. I'm sure there's a few different approachs you could take here. I think the current code and logic is pretty readable when you consider all the scenarios.

@colin-axner colin-axner enabled auto-merge (squash) November 8, 2022 12:08
@colin-axner colin-axner merged commit 2eb5217 into release/v6.0.x Nov 8, 2022
@colin-axner colin-axner deleted the mergify/bp/release/v6.0.x/pr-2682 branch November 8, 2022 12:16
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.

4 participants