fuel_gas_price_algorithm::v0

Struct AlgorithmUpdaterV0

source
pub struct AlgorithmUpdaterV0 {
    pub new_exec_price: u64,
    pub min_exec_gas_price: u64,
    pub exec_gas_price_change_percent: u64,
    pub l2_block_height: u32,
    pub l2_block_fullness_threshold_percent: u64,
}
Expand description

The state of the algorithm used to update the gas price algorithm for each block

Because there will always be a delay between blocks submitted to the L2 chain and the blocks being recorded on the DA chain, the updater needs to make “projections” about the cost of recording any given block to the DA chain. This is done by tracking the cost per byte of recording for the most recent blocks, and using the known bytes of the unrecorded blocks to estimate the cost for that block. Every time the DA recording is updated, the projections are recalculated.

This projection will inevitably lead to error in the gas price calculation. Special care should be taken to account for the worst case scenario when calculating the parameters of the algorithm.

Fields§

§new_exec_price: u64

The gas price to cover the execution of the next block

§min_exec_gas_price: u64

The lowest the algorithm allows the exec gas price to go

§exec_gas_price_change_percent: u64

The Percentage the execution gas price will change in a single block, either increase or decrease based on the fullness of the last L2 block

§l2_block_height: u32

The height of the next L2 block

§l2_block_fullness_threshold_percent: u64

The threshold of gas usage above and below which the gas price will increase or decrease This is a percentage of the total capacity of the L2 block

Implementations§

source§

impl AlgorithmUpdaterV0

source

pub fn new( new_exec_price: u64, min_exec_gas_price: u64, exec_gas_price_change_percent: u64, l2_block_height: u32, l2_block_fullness_threshold_percent: u64, ) -> Self

source

pub fn update_l2_block_data( &mut self, height: u32, used: u64, capacity: NonZeroU64, ) -> Result<(), Error>

source

pub fn algorithm(&self) -> AlgorithmV0

Trait Implementations§

source§

impl Clone for AlgorithmUpdaterV0

source§

fn clone(&self) -> AlgorithmUpdaterV0

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 AlgorithmUpdaterV0

source§

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

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

impl<'de> Deserialize<'de> for AlgorithmUpdaterV0

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 AlgorithmUpdaterV0

source§

fn eq(&self, other: &AlgorithmUpdaterV0) -> 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 AlgorithmUpdaterV0

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 AlgorithmUpdaterV0

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 T)

🔬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, 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,