-
Notifications
You must be signed in to change notification settings - Fork 709
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
Refactor transaction storage pallet to use fungible traits #1800
Refactor transaction storage pallet to use fungible traits #1800
Conversation
4a72011
to
9aa58ea
Compare
Signed-off-by: Adrian Catangiu <adrian@parity.io>
9aa58ea
to
362e261
Compare
T::Currency::hold(&HoldReason::StorageFeeHold.into(), &sender, fee)?; | ||
let (credit, _) = T::Currency::slash(&HoldReason::StorageFeeHold.into(), &sender, fee); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems logically equivalent to just reducing the account balance by fee
if the balance is gt fee
(which seems way simpler)? Or am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if equivalent, the imbalance/credit does need to go to T::FeeDestination
, but maybe this can be changed too.
@paritytech/frame-coders may have a stronger opinion which way to go here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could very well use decrease_balance()
which returns the reduced balance. I don't see why that wouldn't work.
Though, I don't know why it was not used in the original code
Disregard my previous comment, I think @acatangiu you are right, we do want slash
to manage the imbalance and T::FeeDestination
to do whatever it needs to be done for us.
decrease_balance()
should not be used directly for that reason.
polkadot-sdk/substrate/frame/support/src/traits/tokens/fungible/regular.rs
Lines 122 to 127 in 21d36b7
/// **WARNING** | |
/// Do not use this directly unless you want trouble, since it allows you to alter account balances | |
/// without keeping the issuance up to date. It has no safeguards against accidentally creating | |
/// token imbalances in your system leading to accidental inflation or deflation. It's really just | |
/// for the underlying datatype to implement so the user gets the much safer `Balanced` trait to | |
/// use. |
…e-refactor-transaction-storage-pallet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM just a few optional nits
…e-refactor-transaction-storage-pallet
@liamaharon your comments are addressed, please take another look 🙏 |
The CI pipeline was cancelled due to failure one of the required jobs. |
Co-authored-by: georgepisaltu <52418509+georgepisaltu@users.noreply.github.com>
…e-refactor-transaction-storage-pallet
@acatangiu Any reason why |
I'm not familiar with |
This pull request has been mentioned on Polkadot Forum. There might be relevant details there: https://forum.polkadot.network/t/polkadot-release-analysis-v1-4-0/5152/1 |
…ch#1800) Partial paritytech#226 `frame/transaction-storage`: replace `Currency` with `fungible::*` traits --------- Signed-off-by: Adrian Catangiu <adrian@parity.io> Co-authored-by: georgepisaltu <52418509+georgepisaltu@users.noreply.github.com>
Partial #226
frame/transaction-storage
: replaceCurrency
withfungible::*
traits