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(sequencer): fix escrow channel check when receiving non-refund ics20 packet #851

Merged
merged 6 commits into from
Mar 26, 2024

Conversation

noot
Copy link
Collaborator

@noot noot commented Mar 20, 2024

Summary

fix escrow channel balance check by:

  1. when receiving non-refund ics20 packet, check dest_channel escrow balance
  2. remove prefix from denom when we're the token source

I had to put both the fixes in one PR to be able to add the unit tests (they would fail if only one issue was fixed)

Background

zellic audits + needs to match ics20 spec (https://github.com/cosmos/ibc/blob/0238989da88e790ec4daea7214ff3521cc264137/spec/app/ics-020-fungible-token-transfer/README.md)

Changes

  • when receiving non-refund ics20 packet, check dest_channel escrow balance
  • remove prefix from denom when we're the token source
  • on refund, use packet.sender as the recipient as per spec
  • add unit tests

Testing

unit tests

Related Issues

closes #848 and #849

@github-actions github-actions bot added the sequencer pertaining to the astria-sequencer crate label Mar 20, 2024
@noot noot merged commit b58b65e into main Mar 26, 2024
35 checks passed
@noot noot deleted the noot/ics20-escrow-fix branch March 26, 2024 00:33
github-merge-queue bot pushed a commit that referenced this pull request Jun 10, 2024
…1162)

## Summary
Rewrites the IBC denomation construction by parsing its prefix into
segments. This fixes the incorrect removal of prefxies for source
non-refund ics20 packets.

## Background
follow up to #851 which was an
audit fix - this fixes the fix by removing the source prefix correctly,
in the case assets we're the source of are transferred in. previously,
the entire prefix was removed, would would have been invalid if the
asset was prefixed by multiple hops, eg.
transfer/channel-1/transfer/channel-2/denom would have become just denom
when it should have become transfer/channel-2/denom.

## Changes
- refactor `astria_core::primitive::1::asset::Denom` to express its
prefix as a list of segments
- ensure that only full prefix segments are removed
- make `Denom` construction a fallible operation by parsing it
- removed a bunch of constructors as they were only used in tests and
not otherwise

## Testing
Provide exhaustive units.

## Related Issues
Replaces #1131
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sequencer pertaining to the astria-sequencer crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sequencer: fix escrow balance check in ICS20 transfer
2 participants