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

Refactor transaction storage pallet to use fungible traits #1800

Merged

Conversation

acatangiu
Copy link
Contributor

@acatangiu acatangiu commented Oct 5, 2023

Partial #226

frame/transaction-storage: replace Currency with fungible::* traits

@acatangiu acatangiu self-assigned this Oct 5, 2023
@acatangiu acatangiu force-pushed the frame-refactor-transaction-storage-pallet branch 2 times, most recently from 4a72011 to 9aa58ea Compare October 7, 2023 14:33
@acatangiu acatangiu marked this pull request as ready for review October 7, 2023 14:33
@acatangiu acatangiu requested review from a team October 7, 2023 14:33
@acatangiu acatangiu added the T2-pallets This PR/Issue is related to a particular pallet. label Oct 7, 2023
@acatangiu acatangiu force-pushed the frame-refactor-transaction-storage-pallet branch from 9aa58ea to 362e261 Compare October 7, 2023 15:18
substrate/frame/transaction-storage/src/lib.rs Outdated Show resolved Hide resolved
Comment on lines 447 to 448
T::Currency::hold(&HoldReason::StorageFeeHold.into(), &sender, fee)?;
let (credit, _) = T::Currency::slash(&HoldReason::StorageFeeHold.into(), &sender, fee);
Copy link
Contributor

@liamaharon liamaharon Oct 7, 2023

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?

Copy link
Contributor Author

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.

Copy link
Contributor

@juangirini juangirini Oct 26, 2023

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.

/// **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.

@paritytech-ci paritytech-ci requested a review from a team October 7, 2023 21:16
Copy link
Contributor

@juangirini juangirini left a 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

@acatangiu
Copy link
Contributor Author

@liamaharon your comments are addressed, please take another look 🙏

@paritytech-cicd-pr
Copy link

The CI pipeline was cancelled due to failure one of the required jobs.
Job name: test-linux-stable 1/3
Logs: https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/4124271

@acatangiu acatangiu merged commit 30f3ad2 into paritytech:master Oct 30, 2023
109 of 110 checks passed
@acatangiu acatangiu deleted the frame-refactor-transaction-storage-pallet branch October 30, 2023 13:15
@gupnik
Copy link
Contributor

gupnik commented Oct 31, 2023

@acatangiu Any reason why Consideration was not used here? Seems perfectly suitable to this use-case.

@acatangiu
Copy link
Contributor Author

@acatangiu Any reason why Consideration was not used here? Seems perfectly suitable to this use-case.

I'm not familiar with Consideration so that answers your question :) also goes to say I can't tell if it's better/worse.
Feel free to open a follow-up PR for it if you think it's more suited.

@Polkadot-Forum
Copy link

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

bgallois pushed a commit to duniter/duniter-polkadot-sdk that referenced this pull request Mar 25, 2024
…ch#1800)

Partial paritytech#226

`frame/transaction-storage`: replace `Currency` with `fungible::*`
traits

---------

Signed-off-by: Adrian Catangiu <[email protected]>
Co-authored-by: georgepisaltu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T2-pallets This PR/Issue is related to a particular pallet.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants