Better Parameterisation for Fee system#3823
Conversation
|
This change one invariant that all types declared through now some type define there are actually being implemented some trait in node/runtime/src/impl.rs using their values. That can be ok, but I feel like it can start confusing some ppl, Though I'm ok with this. |
|
My argument was that seeing all of these numbers, regardless of how they are interpreted, on one place is much better. Before, the 25% used to be somewhere else in |
|
I can also get rid of the weight in the interface of CC @4meta5 you might be interested in these changes as I recall exactly that I mis-guided you when you also asked if it is possible to directly read a storage in the fee update implementation. |
| } | ||
|
|
||
| /// Return the inner value. Only for testing. | ||
| #[cfg(any(feature = "std", test))] |
There was a problem hiding this comment.
if this is only for testing, then why not ?
| #[cfg(any(feature = "std", test))] | |
| #[cfg(test)] |
There was a problem hiding this comment.
Fair point and I (naively) used the gating feature that I used here https://github.com/paritytech/substrate/pull/3823/files#diff-24bd3cac4cae1c620f82f7aa79ef28ceR707
Declaring the function with just #[cfg(test)] was not enough and it cannot be found in tests though 🤔 and I had to make it test or std. Do you know the reason of the difference
There was a problem hiding this comment.
I agree that logically it should be just cfg[test]. Something is wrong maybe in cargo files
There was a problem hiding this comment.
oh actually this is because the test configure is only set for the tested crate.
if you test the runtime then sr-arithmetic isn't compiled with test.
I don't know what is the prefered way to solve this
There was a problem hiding this comment.
(won't work as discussed on off-band. will leave the comment open)
|
code is OK but wonder about API again maybe we would prefer not having this code in runtime/impl.rs as probably quite some other runtime will implement the same. In contracts it is organized a bit differently and maybe we should inspiration from it: type ComputeDispatchFee: ComputeDispatchFee<<Self as Trait>::Call, BalanceOf<Self>>;and then in contracts crate there is : /// The default dispatch fee computor computes the fee in the same way that
/// the implementation of `ChargeTransactionPayment` for the Balances module does. Note that this only takes a fixed
/// fee based on size. Unlike the balances module, weight-fee is applied.
pub struct DefaultDispatchFeeComputor<T: Trait>(PhantomData<T>);
impl<T: Trait> ComputeDispatchFee<<T as Trait>::Call, BalanceOf<T>> for DefaultDispatchFeeComputor<T> {
fn compute_dispatch_fee(call: &<T as Trait>::Call) -> BalanceOf<T> {
...
}
}EDIT: maybe we would want to have some default struct with an unnamed field like struct OneWayToComputeStuffUsingPerbill(pub Perbill) |
|
So the dilemma is to leave it in In practice, I am fine with both. We are providing a default behaviour for something which at the end of the day the user should define. But what I don't like about putting this I am even tempted to wipe this ting from substrate node and only leave it in polkadot repo. Substrate node can just use |
Agreed, I am pro putting this logic in Polkadot and using I can expand on this, but I basically don't expect most developers building with Substrate to adopt the same fee structure as a relay chain. The economics of parachains/sovereign chains should and will be very different. Personally, I think something like BRAQ (section 4.2, page 9) or some similar model for subsidizing actions within a defined period of blocks might be more appropriate than charging per method call. |
* Price to Weight ration as type parameter * Kian feedback * Some renames. * Fix executor tests * Getting Closer. * Phantom Data * Actually fix executor tests.
| iterations += 1; | ||
| } | ||
| println!("iteration {}, new fm = {:?}. Weight fee is now zero", iterations, fm); | ||
| let block_weight = 0; |
There was a problem hiding this comment.
is it on purpose that block weight changed from 1000 to 0 ?
There was a problem hiding this comment.
yeah just makes a bit more sense: the test is supposed to simulate an empty chain. Nonetheless the test is not that important as you see and just runs a simulation.
As I see A1-onice, maybe I should review once finished
|
@thiolliere we are writing a doc about weights and I thought I would keep this Iced to apply very small changes to docs and prevent opening new PRs every day. |
Makes is slightly more substrate-style by using
Getinstead of floating constant or hardcoded values.