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 cw20 ics20 packets #684

Merged
merged 6 commits into from
Mar 24, 2022
Merged

Fix cw20 ics20 packets #684

merged 6 commits into from
Mar 24, 2022

Conversation

ethanfrey
Copy link
Member

Closes #662

We change the logic to always be the "v2" style, and no longer add a flag in the packet (which is rejected by the transfer module), but rather migrate current state to new format if possible (for 1 open channel, we can assign all current balance to inflight for this channel).

If there are production versions that have multiple open channels and need migration, please comment here, and we could possibly support that migration in the future (but it is much trickier).

cc: @giansalex

TODO: add a test for the migration code

for (denom, mut state) in states.into_iter() {
// this checks if we have received some coins that are "in flight" and not yet accounted in the state
let Coin { amount, .. } = deps.querier.query_balance(addr, &denom)?;
let diff = state.outstanding - amount;
Copy link
Contributor

@giansalex giansalex Mar 24, 2022

Choose a reason for hiding this comment

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

Suggested change
let diff = state.outstanding - amount;
let diff = amount - state.outstanding;

should be: cw-balance > state.outstanding ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch! This is why I need tests (to panic here), or good reviewers

Copy link
Member Author

Choose a reason for hiding this comment

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

still missing the handling for cw20 tokens...

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in 9ad5fef but not sure how to test

@ethanfrey ethanfrey merged commit f9a69ff into main Mar 24, 2022
@ethanfrey ethanfrey deleted the fix-cw20-ics20-packets branch March 24, 2022 18:23
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.

ICS20, invalid packet data
2 participants