-
Notifications
You must be signed in to change notification settings - Fork 839
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
apply_authorized_upgrade
: Implement feeless_if
#7812
base: master
Are you sure you want to change the base?
Conversation
This pr implements the `feeless_if` feature for `apply_authorized_upgrade`. The call would be feeless if the given code is authorized. Besides that the pr is doing some clean ups.
/cmd prdoc --audience runtime_user --bump major |
All GitHub workflows were cancelled due to failure one of the required jobs. |
All GitHub workflows were cancelled due to failure one of the required jobs. |
@@ -859,12 +860,25 @@ pub mod pallet { | |||
/// All origins are allowed. | |||
#[pallet::call_index(11)] | |||
#[pallet::weight((T::SystemWeightInfo::apply_authorized_upgrade(), DispatchClass::Operational))] | |||
#[pallet::feeless_if(|_: &OriginFor<T>, code: &Vec<u8>| -> bool { |
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.
Nice! Finally, a real usage example. I will also adjust my PR accordingly.
But iiuc, feeless_if
won't work unless we add SkipCheckIfFeeless
and pallet_skip_feeless_payment
to the runtimes, right? Please see my related questions here: #7592 (comment).
So, iiuc, feeless_if
won't have any effect without SkipCheckIfFeeless
, but in this case, execution will still be free because of pays_fee: Pays::No
, correct?
Next, if we add SkipCheckIfFeeless
and pallet_skip_feeless_payment
, and we change DispatchResultWithPostInfo
to DispatchResult
, then we no longer need the PostDispatchInfo { pays_fee: Pays::No, ... }
code, right? (Probably because of prevent further transactions
we want to keep it as it is here)
And lastly, when we make feeless_if
+ SkipCheckIfFeeless
work with TransactionExtensions
, how does it behave in the case of an extrinsic error? For example, if feeless_if
passes and returns true
, but fn apply_authorized_upgrade(..)
fails on Self::can_set_code(..)
, will the user still be charged, or will it remain free?
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.
But iiuc,
feeless_if
won't work unless we addSkipCheckIfFeeless
andpallet_skip_feeless_payment
to the runtimes, right? Please see my related questions here: #7592 (comment).
Yes feeless_if
is effective only if SkipCheckIfFeeless
is used, usually wrapping the transaction payment extension.
So, iiuc,
feeless_if
won't have any effect withoutSkipCheckIfFeeless
, but in this case, execution will still be free because ofpays_fee: Pays::No
, correct?
It would be free only if successful, people will have to pay for it, and they get refunded at the end of the transaction if is successful.
Next, if we add
SkipCheckIfFeeless
andpallet_skip_feeless_payment
, and we changeDispatchResultWithPostInfo
toDispatchResult
, then we no longer need thePostDispatchInfo { pays_fee: Pays::No, ... }
code, right? (Probably because ofprevent further transactions
we want to keep it as it is here)
Yes, but it doesn't harm.
And lastly, when we make
feeless_if
+SkipCheckIfFeeless
work withTransactionExtensions
, how does it behave in the case of an extrinsic error? For example, iffeeless_if
passes and returnstrue
, butfn apply_authorized_upgrade(..)
fails onSelf::can_set_code(..)
, will the user still be charged, or will it remain free?
if feeless_if
passes, the user is never charged, (the transaction payment happens in the transaction extension in prepare
phase, this payment will be skipped).
So if the transaction fails the changes in the call dispatch is reverted. So probably people will be able to spam a failing transaction for free.
Signer will not be charged after the failing of the transaction.
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.
@gui1117 Thank you :)
So if the transaction fails the changes in the call dispatch is reverted. So probably people will be able to spam a failing transaction for free.
Signer will not be charged after the failing of the transaction.
This is exactly what I was worried about :), but we probably just need to ensure that feeless_if
is correct and covers all the necessary validations, right?
Also, another thing, here we are using/expecting an unsigned call: ValidateUnsigned::validate_unsigned(Call::apply_authorized_upgrade(..))
. So, is this the spam protection mechanism that it doesn’t even add call to the transaction pool?
This pr implements the
feeless_if
feature forapply_authorized_upgrade
. The call would be feeless if the given code is authorized.Besides that the pr is doing some clean ups.