-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Timestamp inherent doesn't pay fees #9791
Timestamp inherent doesn't pay fees #9791
Conversation
This reverts commit 65c1aed04eaa50a501e3235df1d9ee98f0ec33da.
frame/timestamp/src/lib.rs
Outdated
@@ -189,7 +189,8 @@ pub mod pallet { | |||
/// # </weight> | |||
#[pallet::weight(( | |||
T::WeightInfo::set(), | |||
DispatchClass::Mandatory | |||
DispatchClass::Mandatory, | |||
Pays::No, |
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.
this makes sending a signed extrinsic with the call set
free, which is not good, even if it will fails directly it can still fill some block for free
if we want to use Pays::No then we need some validation code which makes the call invalid (invalid so it can't be included in a block). sidenote: Maybe we could improve on this using some
maybe the best is to make a more precise calculation ? |
I'm in favor of not putting pay fee to yes if there is no fee paid. |
if somebody send a signed extrinsic with the call EDIT: if we want to make the extrinsic free, then there should be code to ensure the extrinsic is invalid and can't go into a block. |
@thiolliere I understand this part and agree. Isn't there a way to change how the Extrinsic event reports if the fee are being paid in that case? |
What if we mark it as Would that help you @crystalin ? Could you tell us in more detail, why this would help you? |
The use case is simply to list all the collected fees of block. |
I've updated this PR to mark the extrinsic as |
How you are doing that currently? |
@bkchr I take all the extrinsics in the block, filter those with Pay::Yes and |
It seems we should fix transaction-payment instead. Instead it should return the correct fee depending on whereas the extrinsic is signed, so something roughly like this: diff --git a/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs
index e3a3bccc3d..5b85ad1f47 100644
--- a/frame/transaction-payment/src/lib.rs
+++ b/frame/transaction-payment/src/lib.rs
@@ -377,13 +377,16 @@ where
///
/// All dispatchables must be annotated with weight and will have some fee info. This function
/// always returns.
- pub fn query_info<Extrinsic: GetDispatchInfo>(
+ pub fn query_info<Extrinsic: GetDispatchInfo + sp_runtime::traits::Extrinsic>(
unchecked_extrinsic: Extrinsic,
len: u32,
) -> RuntimeDispatchInfo<BalanceOf<T>>
where
T::Call: Dispatchable<Info = DispatchInfo>,
{
+ if unchecked_extrinsic.is_signed().map_or(false, |is_signed| is_signed == false) {
+ return 0;
+ }
// NOTE: we can actually make it understand `ChargeTransactionPayment`, but would be some
// hassle for sure. We have to make it aware of the index of `ChargeTransactionPayment` in
// `Extra`. Alternatively, we could actually execute the tx's per-dispatch and record the
@@ -405,6 +408,9 @@ where
where
T::Call: Dispatchable<Info = DispatchInfo>,
{
+ if unchecked_extrinsic.is_signed().map_or(false, |is_signed| is_signed == false) {
+ return 0;
+ }
let dispatch_info = <Extrinsic as GetDispatchInfo>::get_dispatch_info(&unchecked_extrinsic);
Self::compute_fee_details(len, &dispatch_info, 0u32.into())
} |
@thiolliere looks like the correct way to do it. |
Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions. |
closed in favor of #10107 |
This PR marks pallet timestamp's
set
extrinsic asPays::No
. Inherents never pay fees because there is no origin and in general the block author is not associated with a runtime account. Therefore this makes no changes in terms of actual fee collection. Rather this just makes it easier to do offchain accounting work to track fees by block.Should this be handled somewhere deeper in FRAME so it applies to all inherents?
cc @crystalin