pub struct L2ActivityTracker { /* private fields */ }
Expand description
The L2ActivityTracker
tracks the chain activity to determine a safety mode for setting the DA price.
Because the DA gas price can increase even when no-one is using the network, there is a potential
for a negative feedback loop to occur where the gas price increases, further decreasing activity
and increasing the gas price. The L2ActivityTracker
is used to moderate changes to the DA
gas price based on the activity of the L2 chain.
The chain activity is a cumulative measure, updated whenever a new block is processed. For each L2 block, the block usage is a percentage of the block capacity used. If the block usage is below a certain threshold, the chain activity is decreased, if above the threshold, the activity is increased The chain activity exists on a scale between 0 and the sum of the normal, capped, and decrease buffers.
e.g. if the decrease activity threshold is 20, the capped activity threshold is 80, and the max activity is 120, we’d have the following ranges:
0 <– decrease range –>20<– capped range –>80<– normal range –>120
The current chain activity determines the behavior of the DA gas price.
For healthy behavior, the activity should be in the normal
range.
Implementations§
Source§impl L2ActivityTracker
impl L2ActivityTracker
pub fn new_full( normal_range_size: u16, capped_range_size: u16, decrease_range_size: u16, block_activity_threshold: ClampedPercentage, ) -> Self
pub fn new( normal_range_size: u16, capped_range_size: u16, decrease_range_size: u16, activity: u16, block_activity_threshold: ClampedPercentage, ) -> Self
pub fn new_always_normal() -> Self
pub fn safety_mode(&self) -> DAGasPriceSafetyMode
pub fn update(&mut self, block_usage: ClampedPercentage)
pub fn current_activity(&self) -> u16
pub fn max_activity(&self) -> u16
pub fn capped_activity_threshold(&self) -> u16
pub fn decrease_activity_threshold(&self) -> u16
pub fn block_activity_threshold(&self) -> ClampedPercentage
Trait Implementations§
Source§impl Clone for L2ActivityTracker
impl Clone for L2ActivityTracker
Source§fn clone(&self) -> L2ActivityTracker
fn clone(&self) -> L2ActivityTracker
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more