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

Flip the order of callback and actual channel closure on timeout #6039

Closed
3 tasks
Lockwarr opened this issue Mar 21, 2024 · 2 comments
Closed
3 tasks

Flip the order of callback and actual channel closure on timeout #6039

Lockwarr opened this issue Mar 21, 2024 · 2 comments
Labels
core type: refactor Architecture, code or CI improvements that may or may not tackle technical debt.

Comments

@Lockwarr
Copy link

Summary of Bug

When an ordered ics-27 channel (interchain accounts) receives a timeout, the channel gets closed. However, the current implementation invokes the callback reporting to the contract that the channel is closed before the actual channel closure. This leads to a discrepancy where the channel's state is changed to state_closed only after the callback, causing issues in subsequent operations like channel registration.

Details:

The current process for handling timeouts in interchain accounts follows this sequence:

  1. Timeout event triggers.
  2. Callback reporting channel closure is invoked.
  3. Channel closure is processed, changing the channel's state to state_closed.

Problem:

The order of operations poses a problem for processes relying on the accurate state of the channel. Specifically, when a new channel for the same interchain account needs to be registered. Due to the current implementation, the state transition to state_closed occurs after the callback, creating a timing issue and the contract must wait for the channel to be in state_closed before proceeding with a call to open a new interchain channel for the interchain account.

Expected Behaviour

To resolve this issue, we propose changing the order of calls in the timeout handling process. Specifically, the sequence should be adjusted to:

  1. Close the channel.
  2. Call the callback reporting channel closure.

Tested on ibc-go v7.3.1

We have tested the proposed solution locally and confirmed that it resolves the timing issue, allowing the contract to initiate a channel registration without waiting explicitly.

Changes:

moved ChannelKeeper.TimeoutExecuted before cbs.OnTimeoutPacket in both TimeoutOnClose() and Timeout() functions in modules/core/keeper/msg_server.go

This change is expected to positively impact processes reliant on accurate channel state, particularly in scenarios where subsequent actions depend on the channel being in the state_closed state.


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged/assigned
@crodriguezvega
Copy link
Contributor

Thanks for the detailed issue, @Lockwarr. I think this should be fine (in fact the ICS026 specifies the order you propose), but I would like to have a confirmation from @AdityaSripal.

@crodriguezvega crodriguezvega added core type: refactor Architecture, code or CI improvements that may or may not tackle technical debt. labels Mar 22, 2024
@crodriguezvega
Copy link
Contributor

The proposed change was implemented in GHSA-j496-crgh-34mx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core type: refactor Architecture, code or CI improvements that may or may not tackle technical debt.
Projects
Archived in project
Development

No branches or pull requests

2 participants