Struct fuel_gas_price_algorithm::v1::AlgorithmUpdaterV1

source ·
pub struct AlgorithmUpdaterV1 {
Show 18 fields pub new_exec_price: u64, pub last_da_gas_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, pub min_da_gas_price: u64, pub max_da_gas_price_change_percent: u8, pub total_da_rewards: u64, pub da_recorded_block_height: u32, pub latest_known_total_da_cost: u64, pub projected_total_da_cost: u64, pub da_p_component: i64, pub da_d_component: i64, pub profit_avg: i64, pub avg_window: u32, pub latest_da_cost_per_byte: u64, pub unrecorded_blocks: Vec<BlockBytes>,
}
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

§last_da_gas_price: u64

The gas price for the DA portion of the last block. This can be used to calculate the DA portion 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

§min_da_gas_price: u64

The lowest the algorithm allows the da gas price to go

§max_da_gas_price_change_percent: u8

The maximum percentage that the DA portion of the gas price can change in a single block

§total_da_rewards: u64

The cumulative reward from the DA portion of the gas price

§da_recorded_block_height: u32

The height of the las L2 block recorded on the DA chain

§latest_known_total_da_cost: u64

The cumulative cost of recording L2 blocks on the DA chain as of the last recorded block

§projected_total_da_cost: u64

The predicted cost of recording L2 blocks on the DA chain as of the last L2 block (This value is added on top of the latest_known_total_da_cost if the L2 height is higher)

§da_p_component: i64

The P component of the PID control for the DA gas price

§da_d_component: i64

The D component of the PID control for the DA gas price

§profit_avg: i64

The average profit over the last avg_window blocks

§avg_window: u32

The number of blocks to consider when calculating the average profit

§latest_da_cost_per_byte: u64

The latest known cost per byte for recording blocks on the DA chain

§unrecorded_blocks: Vec<BlockBytes>

The unrecorded blocks that are used to calculate the projected cost of recording blocks

Implementations§

source§

impl AlgorithmUpdaterV1

source

pub fn update_da_record_data( &mut self, blocks: Vec<RecordedBlock>, ) -> Result<(), Error>

source

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

source

pub fn algorithm(&self) -> AlgorithmV1

Trait Implementations§

source§

impl Clone for AlgorithmUpdaterV1

source§

fn clone(&self) -> AlgorithmUpdaterV1

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 AlgorithmUpdaterV1

source§

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

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

impl<'de> Deserialize<'de> for AlgorithmUpdaterV1

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 AlgorithmUpdaterV1

source§

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

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 AlgorithmUpdaterV1

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§

default 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,

§

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>,

§

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>,

§

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>,