-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Weight Refunds mechanism RFC #5032
Conversation
frame/transaction-payment/src/lib.rs
Outdated
| ) -> Result<Self::Pre, TransactionValidityError> { | ||
| let tip = self.0; | ||
| let fee = Self::compute_fee(len as u32, info, tip); | ||
| Self::withdraw_fee(who, tip, fee).map_err(|()| InvalidTransaction::Payment.into()) |
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.
Let see if this is safe:
- If I panic within the code of the call itself, we have already charged the fee. That is good.
- But for example if the fee was meant to go to authors and treasury, we don't use the imbalance and it is just dropped, so we burn it. Is this desired? Or maybe it is addressed further down in the code. But we should def. discuss this scenario.
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.
@thiolliere actually, you are also changing this code so pinging you
| /// Dispatch a given `T::Call` with a given origin. | ||
| /// | ||
| /// Returns how much weight was unspent. | ||
| pub fn dispatch_call( |
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.
| pub fn dispatch_call( | |
| pub fn note_dispatch_call( |
There should really be an emphasis on the fact that this some bookkeeping for you. Chose some other name if you want, but dispatch_call is too simple.
kianenigma
left a comment
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.
I like this idea all in all.
- What we need to make sure is that it is safe regards to fees.
- The only potential huge change to it is some refactors; This logic (specially the function
note_dispatch_call) can live in either system, transaction-payment, or a new pseudo-executive module. But that is not a huge concern for now.
| /// Total weight for all extrinsics put together, for the current block. | ||
| AllExtrinsicsWeight: Option<Weight>; | ||
|
|
||
| /// The weight taken by the current executing disptachable. |
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.
typo: disptachable
| fn post_dispatch(_pre: Self::Pre, info: Self::DispatchInfo, _len: usize) { | ||
| let spent = CurrentDispatchableWeight::get().unwrap_or(info.weight); | ||
| let reserved = info.weight; | ||
| let unspent = spent - reserved; |
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.
I think a comment why unchecked math is OK here is in order.
|
As a status update on this, there is a problem with how to introduce a global central dispatch point. |
af10334 to
9a2ceef
Compare
|
Rebased onto current master and resolved conflicts with it. Removed some unrelated style changes that added to the noise of this PR. Next steps will be to integrate it with the changes in #5130 as soon as there is some confidence on how the GCD will manifest. |
|
Closed in favor of #5584 |
This PR is a draft of the changes for weight refunds (aka dynamic weights, so fixes #3730 if merged).
This is not yet ready for the code related discussion, although design related feedback is welcome.