-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Weight annotation. #3157
Weight annotation. #3157
Changes from 1 commit
b042a93
37f6ae0
2e5b1f4
b7646ec
a871c9f
8e7c803
a824b56
5de080f
a8789b9
7d96429
30b4ba7
2a9c9df
342efb5
b8f564e
07fdfe2
7f33006
36063fe
7a0fbc9
84fa279
f4d4579
def6425
d12713a
3350f9c
b788507
b9b6b53
045681e
bfcfa36
107801f
c100df9
f5d33c6
0c1c268
6a0a1d4
b06ef82
c3e0ee3
5b0c715
e683829
ce11fc5
0b592e2
ee970d1
58191a3
67b268a
0d9133f
ec6554f
a25e4be
5724771
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -161,10 +161,10 @@ use srml_support::traits::{ | |
| use srml_support::dispatch::Result; | ||
| use primitives::traits::{ | ||
| Zero, SimpleArithmetic, StaticLookup, Member, CheckedAdd, CheckedSub, MaybeSerializeDebug, | ||
| Saturating, Bounded, SignedExtension, SaturatedConversion, DispatchError | ||
| Saturating, Bounded, SignedExtension, SaturatedConversion, DispatchError, Convert, | ||
| }; | ||
| use primitives::transaction_validity::{TransactionPriority, ValidTransaction}; | ||
| use primitives::weights::{DispatchInfo, SimpleDispatchInfo}; | ||
| use primitives::weights::{DispatchInfo, SimpleDispatchInfo, Weight}; | ||
| use system::{IsDeadAccount, OnNewAccount, ensure_signed, ensure_root}; | ||
|
|
||
| mod mock; | ||
|
|
@@ -207,8 +207,8 @@ pub trait Subtrait<I: Instance = DefaultInstance>: system::Trait { | |
| /// The fee to be paid for making a transaction; the per-byte portion. | ||
| type TransactionByteFee: Get<Self::Balance>; | ||
|
|
||
| /// The amount of fee deducted oer unit of weight. | ||
| type TransactionWeightFee: Get<Self::Balance>; | ||
| /// Convert a weight value into a deductible fee based on the currency type. | ||
| type WeightToFee: Convert<Weight, Self::Balance>; | ||
| } | ||
|
|
||
| pub trait Trait<I: Instance = DefaultInstance>: system::Trait { | ||
|
|
@@ -253,8 +253,8 @@ pub trait Trait<I: Instance = DefaultInstance>: system::Trait { | |
| /// The fee to be paid for making a transaction; the per-byte portion. | ||
| type TransactionByteFee: Get<Self::Balance>; | ||
|
|
||
| /// The amount of fee deducted oer unit of weight. | ||
| type TransactionWeightFee: Get<Self::Balance>; | ||
| /// Convert a weight value into a deductible fee based on the currency type. | ||
| type WeightToFee: Convert<Weight, Self::Balance>; | ||
| } | ||
|
|
||
| impl<T: Trait<I>, I: Instance> Subtrait<I> for T { | ||
|
|
@@ -266,7 +266,7 @@ impl<T: Trait<I>, I: Instance> Subtrait<I> for T { | |
| type CreationFee = T::CreationFee; | ||
| type TransactionBaseFee = T::TransactionBaseFee; | ||
| type TransactionByteFee = T::TransactionByteFee; | ||
| type TransactionWeightFee = T::TransactionWeightFee; | ||
| type WeightToFee = T::WeightToFee; | ||
| } | ||
|
|
||
| decl_event!( | ||
|
|
@@ -790,7 +790,7 @@ impl<T: Subtrait<I>, I: Instance> Trait<I> for ElevatedTrait<T, I> { | |
| type CreationFee = T::CreationFee; | ||
| type TransactionBaseFee = T::TransactionBaseFee; | ||
| type TransactionByteFee = T::TransactionByteFee; | ||
| type TransactionWeightFee = T::TransactionWeightFee; | ||
| type WeightToFee = T::WeightToFee; | ||
| } | ||
|
|
||
| impl<T: Trait<I>, I: Instance> Currency<T::AccountId> for Module<T, I> | ||
|
|
@@ -1195,10 +1195,9 @@ impl<T: Trait<I>, I: Instance> TakeFees<T, I> { | |
| // cap the weight to the maximum defined in runtime, otherwise it will be the `Bounded` | ||
| // maximum of its data type, which is not desired. | ||
| let capped_weight = info.weight.min(<T as system::Trait>::MaximumBlockWeight::get()); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this kinda sucks that every signed extension using weight must cap it itself if they want to. This is because in the details of the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also do the same in system I had the assumption that the weight fo one individual tx cannot go beyond the weight of the entire block. Even if thee annotationa sets the weight to infinity the runtime checks interpret it as whatever If this does not exist, then |
||
| let weight_fee: T::Balance = <system::Module<T>>::next_weight_multiplier() | ||
| .apply_to(capped_weight).saturated_into(); | ||
| let per_weight = T::TransactionWeightFee::get(); | ||
| weight_fee.saturating_mul(per_weight) | ||
| let weight_update = <system::Module<T>>::next_weight_multiplier(); | ||
| let adjusted_weight = weight_update.apply_to(capped_weight); | ||
| T::WeightToFee::convert(adjusted_weight) | ||
| }; | ||
|
|
||
| len_fee.saturating_add(weight_fee).saturating_add(tip) | ||
|
|
||
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.
@gavofyork do you know why this keeps happening? even though Bob has some initial balance, the creation fee is deducted from alice upon sending the transfer. It is also the same for some other tests.
At some point I put a log here and this was
false. no clue what's going on.https://github.com/paritytech/substrate/blob/master/srml/balances/src/lib.rs#L870
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.
more prints needed, then. shouldn't be hard to track down.
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.
false alarm. It is just
transfer_fee.let fee = if would_create { T::CreationFee::get() } else { T::TransferFee::get() };.