pub struct TargetedFeeAdjustment<T, S, V, M, X>(_);
Expand description
A struct to update the weight multiplier per block. It implements Convert<Multiplier, Multiplier>
, meaning that it can convert the previous multiplier to the next one. This should
be called on on_finalize
of a block, prior to potentially cleaning the weight data from the
system pallet.
given: s = previous block weight s’= ideal block weight m = maximum block weight diff = (s - s’)/m v = 0.00001 t1 = (v * diff) t2 = (v * diff)^2 / 2 then: next_multiplier = prev_multiplier * (1 + t1 + t2)
Where (s', v)
must be given as the Get
implementation of the T
generic type. Moreover, M
must provide the minimum allowed value for the multiplier. Note that a runtime should ensure
with tests that the combination of this M
and V
is not such that the multiplier can drop to
zero and never recover.
Note that s'
is interpreted as a portion in the normal transaction capacity of the block.
For example, given s' == 0.25
and AvailableBlockRatio = 0.75
, then the target fullness is
0.25 of the normal capacity and 0.1875 of the entire block.
Since block weight is multi-dimension, we use the scarcer resource, referred as limiting
dimension, for calculation of fees. We determine the limiting dimension by comparing the
dimensions using the ratio of dimension_value / max_dimension_value
and selecting the largest
ratio. For instance, if a block is 30% full based on ref_time
and 25% full based on
proof_size
, we identify ref_time
as the limiting dimension, indicating that the block is 30%
full.
This implementation implies the bound:
v ≤ p / k * (s − s')
- or, solving for
p
:p >= v * k * (s - s')
where p
is the amount of change over k
blocks.
Hence:
- in a fully congested chain:
p >= v * k * (1 - s')
. - in an empty chain:
p >= v * k * (-s')
.
For example, when all blocks are full and there are 28800 blocks per day (default in
substrate-node
) and v == 0.00001, s’ == 0.1875, we’d have:
p >= 0.00001 * 28800 * 0.8125 p >= 0.234
Meaning that fees can change by around ~23% per day, given extreme congestion.
More info can be found at: https://research.web3.foundation/en/latest/polkadot/overview/2-token-economics.html
Trait Implementations§
source§impl<T, S, V, M, X> Convert<FixedU128, FixedU128> for TargetedFeeAdjustment<T, S, V, M, X>where
T: Config,
S: Get<Perquintill>,
V: Get<FixedU128>,
M: Get<FixedU128>,
X: Get<FixedU128>,
impl<T, S, V, M, X> Convert<FixedU128, FixedU128> for TargetedFeeAdjustment<T, S, V, M, X>where T: Config, S: Get<Perquintill>, V: Get<FixedU128>, M: Get<FixedU128>, X: Get<FixedU128>,
source§impl<T, S, V, M, X> MultiplierUpdate for TargetedFeeAdjustment<T, S, V, M, X>where
T: Config,
S: Get<Perquintill>,
V: Get<FixedU128>,
M: Get<FixedU128>,
X: Get<FixedU128>,
impl<T, S, V, M, X> MultiplierUpdate for TargetedFeeAdjustment<T, S, V, M, X>where T: Config, S: Get<Perquintill>, V: Get<FixedU128>, M: Get<FixedU128>, X: Get<FixedU128>,
source§fn min() -> FixedU128
fn min() -> FixedU128
convert
function should be at least this.source§fn max() -> FixedU128
fn max() -> FixedU128
convert
function should be less or equal this.source§fn target() -> Perquintill
fn target() -> Perquintill
source§fn variability() -> FixedU128
fn variability() -> FixedU128
Auto Trait Implementations§
impl<T, S, V, M, X> RefUnwindSafe for TargetedFeeAdjustment<T, S, V, M, X>where M: RefUnwindSafe, S: RefUnwindSafe, T: RefUnwindSafe, V: RefUnwindSafe, X: RefUnwindSafe,
impl<T, S, V, M, X> Send for TargetedFeeAdjustment<T, S, V, M, X>where M: Send, S: Send, T: Send, V: Send, X: Send,
impl<T, S, V, M, X> Sync for TargetedFeeAdjustment<T, S, V, M, X>where M: Sync, S: Sync, T: Sync, V: Sync, X: Sync,
impl<T, S, V, M, X> Unpin for TargetedFeeAdjustment<T, S, V, M, X>where M: Unpin, S: Unpin, T: Unpin, V: Unpin, X: Unpin,
impl<T, S, V, M, X> UnwindSafe for TargetedFeeAdjustment<T, S, V, M, X>where M: UnwindSafe, S: UnwindSafe, T: UnwindSafe, V: UnwindSafe, X: UnwindSafe,
Blanket Implementations§
source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T, Outer> IsWrappedBy<Outer> for Twhere
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for Twhere Outer: AsRef<T> + AsMut<T> + From<T>, T: From<Outer>,
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere Self: UniqueSaturatedFrom<T>,
source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere Self: UniqueSaturatedInto<T>,
T
. Read more§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.source§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere T: UncheckedFrom<S>,
source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.source§impl<T, S> UniqueSaturatedInto<T> for Swhere
T: Bounded,
S: TryInto<T>,
impl<T, S> UniqueSaturatedInto<T> for Swhere T: Bounded, S: TryInto<T>,
source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.