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: revert restricted balances #4237

Merged
merged 3 commits into from
Nov 14, 2023
Merged

fix: revert restricted balances #4237

merged 3 commits into from
Nov 14, 2023

Conversation

dandanlen
Copy link
Collaborator

Pull Request

Closes: PRO-971

Checklist

Please conduct a thorough self-review before opening the PR.

  • I am confident that the code works.
  • I have updated documentation where appropriate.

Summary

This fixes two issues:

  1. If, after withdrawing restricted funds, the account didn't have enough remaining funds to pay the tax, the redemption would fail due to 'insufficient unrestricted funds'. -> The solution is to reduce the restricted balance by the gross withdrawal amount, rather than the net redeemed amount. This means that when withdrawing to a restricted address, the tax is paid from the restricted balance.
  2. If a withdrawal to a restricted address reverted, the restricted balance wasn't reverted (PRO-971) and the funds would thus lose their restriction. The solution was to store the amount and destination in the PendingRedemptions, and update the restricted balance if the redemption expires.

Copy link

linear bot commented Nov 13, 2023

PRO-971 Restrictions are lost if a redemption reverts

How to reproduce

Can the bug be reproduced? How? Ideally, provide a bouncer test or unit test that demonstrated the problem.

Redeem to a restricted address and let it expire.

Symptoms

How does the bug manifest? If it's not obvious, what behaviour did we expect?

The funds are credited back to the account but they are now unrestricted.

@dandanlen
Copy link
Collaborator Author

FYI @acdibble (thanks for raising this).

Copy link

codecov bot commented Nov 13, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (1de7247) 72% compared to head (a7f3a9e) 71%.
Report is 4 commits behind head on main.

Files Patch % Lines
state-chain/pallets/cf-funding/src/lib.rs 96% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@          Coverage Diff           @@
##            main   #4237    +/-   ##
======================================
- Coverage     72%     71%    -0%     
======================================
  Files        384     384            
  Lines      63015   63180   +165     
  Branches   63015   63180   +165     
======================================
+ Hits       45074   45122    +48     
- Misses     15609   15723   +114     
- Partials    2332    2335     +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dandanlen dandanlen changed the title Fix/funding-issues fix: revert restricted balances Nov 14, 2023
@dandanlen dandanlen enabled auto-merge (squash) November 14, 2023 14:14
@dandanlen dandanlen merged commit e4fbd0f into main Nov 14, 2023
40 checks passed
@dandanlen dandanlen deleted the fix/funding-issues branch November 14, 2023 14:51
dandanlen added a commit that referenced this pull request Nov 17, 2023
tomjohnburton pushed a commit that referenced this pull request Nov 20, 2023
Co-authored-by: dandanlen <3168260+dandanlen@users.noreply.github.com>
Co-authored-by: Alastair Holmes <42404303+AlastairHolmes@users.noreply.github.com>
Co-authored-by: Albert Llimos <53186777+albert-llimos@users.noreply.github.com>
Co-authored-by: Martin Rieke <121793148+martin-chainflip@users.noreply.github.com>
Co-authored-by: Maxim Shishmarev <msgmaxim@gmail.com>
Co-authored-by: Marcello <marcello@chainflip.io>
Co-authored-by: Roy Yang <roy@chainflip.io>
Co-authored-by: kylezs <kyle@chainflip.io>
Co-authored-by: Jamie Ford <jamie@chainflip.io>
fix naming of session keys (#4242)
fix: revert restricted balances (#4237)
fix: add missing spans in multisig logs (#4239)
fix cargo features (#4249)
fix: remove bound addresses on account deletion (#4244)
fix: remove existential deposit (#4243)
fix: egress id race condition (#4235)
fix: remove unwrap when getting tx receipt (#4231)
fix: protect against double witnessing after safe mode (#4254)
fix: runtime upgrade utils and migrations (#4258)
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.

None yet

3 participants