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.

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§

Make conversion.
Minimum multiplier. Any outcome of the convert function should be at least this.
Maximum multiplier. Any outcome of the convert function should be less or equal this.
Target block saturation level
Variability factor

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Convert from a value of T into an equivalent instance of Option<Self>. Read more
Consume self to return Some equivalent value of Option<T>. Read more
Convert 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. Read more
Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more
Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more
Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more
Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Cast reference.
Cast reference.
Cast mutable reference.
Cast mutable reference.

Get a reference to the inner from the outer.

Get a mutable reference to the inner from the outer.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
Convert from a value of T into an equivalent instance of Self. Read more
Consume self to return an equivalent value of T. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
The counterpart to unchecked_from.
Consume self to return an equivalent value of T.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more