-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix, refactor(sequencer): refactor ics20 logic (#1495)
## Summary Fixes incorrect addresses in ics20 refunds, and fixes/adds source vs sink zone detection of received/refunded asets. ## Background This PR started with the goal of using `Ics20WithdrawalFromRollup.rollup_return_address` when emitting ics20 deposit events instead of the rollup's bridge address (which for the rollup was quite meaningless). However, because the original logic was overly convoluted, this patch evolved into a refactor which subsequently revealed 2 more bugs. ## Changes - Refactor ics20 logic: split up `execute_ics20_transfer` into two functions `receive_tokens` and `refund_tokens` - Fix deposit events being emitted with the packet sender/bridge address as the receiving address on the rollup: instead use `Ics20WithdrawalFromRollup.rollup_return_address` which is the address originally supplied and understood by the rollup. - Fix bridge lock events of source tokens being emitted with an extra (port, channel) pair added (this resulting token is likely completely meaningless and not understood by the rollup): instead strip the leading (port, channel) pair to get the original token on sequencer. - Fix refunds to a rollup of failed ics20 transfers not checking if sequencer is their source or sink zone: instead perform the check and decrease the ibc escrow account is necessary. ## Testing Renamed and expanded tests to also check for sink vs source zone assets being received, the correct asset being emitted in bridge lock events, and the correct rollup return address being emitted in refunds. Specifically these tests were added or renamed: - `receive_source_zone_asset_on_sequencer_account` - `receive_sink_zone_asset_on_sequencer_account` - `receive_source_zone_asset_on_bridge_account_and_emit_to_rollup` - `receive_sink_zone_asset_on_bridge_account_and_emit_to_rollup` - `transfer_to_bridge_is_rejected_due_to_invalid_memo` - `transfer_to_bridge_account_is_rejected_due_to_not_permitted_token` - `refund_sequencer_account_with_source_zone_asset` - `refund_sequencer_account_with_sink_zone_asset` - `refund_rollup_with_sink_zone_asset` - `refund_rollup_with_source_zone_asset` - `refund_rollup_with_source_zone_asset_compat_prefix` ## Related Issues Closes #1439 Closes #1496 Closes #1514 --------- Co-authored-by: noot <[email protected]>
- Loading branch information
1 parent
eb466d9
commit c38ce8e
Showing
21 changed files
with
1,013 additions
and
946 deletions.
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
Oops, something went wrong.