Struct L2ActivityTracker

Source
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

Source

pub fn new_full( normal_range_size: u16, capped_range_size: u16, decrease_range_size: u16, block_activity_threshold: ClampedPercentage, ) -> Self

Source

pub fn new( normal_range_size: u16, capped_range_size: u16, decrease_range_size: u16, activity: u16, block_activity_threshold: ClampedPercentage, ) -> Self

Source

pub fn new_always_normal() -> Self

Source

pub fn safety_mode(&self) -> DAGasPriceSafetyMode

Source

pub fn update(&mut self, block_usage: ClampedPercentage)

Source

pub fn current_activity(&self) -> u16

Source

pub fn max_activity(&self) -> u16

Source

pub fn capped_activity_threshold(&self) -> u16

Source

pub fn decrease_activity_threshold(&self) -> u16

Source

pub fn block_activity_threshold(&self) -> ClampedPercentage

Trait Implementations§

Source§

impl Clone for L2ActivityTracker

Source§

fn clone(&self) -> L2ActivityTracker

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for L2ActivityTracker

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for L2ActivityTracker

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for L2ActivityTracker

Source§

fn eq(&self, other: &L2ActivityTracker) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for L2ActivityTracker

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for L2ActivityTracker

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,