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
impl AlgorithmUpdaterV0
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
pub fn update_l2_block_data( &mut self, height: u32, used: u64, capacity: NonZeroU64, ) -> Result<(), Error>
pub fn algorithm(&self) -> AlgorithmV0
Trait Implementations§
source§impl Clone for AlgorithmUpdaterV0
impl Clone for AlgorithmUpdaterV0
source§fn clone(&self) -> AlgorithmUpdaterV0
fn clone(&self) -> AlgorithmUpdaterV0
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for AlgorithmUpdaterV0
impl Debug for AlgorithmUpdaterV0
source§impl<'de> Deserialize<'de> for AlgorithmUpdaterV0
impl<'de> Deserialize<'de> for AlgorithmUpdaterV0
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl PartialEq for AlgorithmUpdaterV0
impl PartialEq for AlgorithmUpdaterV0
source§impl Serialize for AlgorithmUpdaterV0
impl Serialize for AlgorithmUpdaterV0
impl StructuralPartialEq for AlgorithmUpdaterV0
Auto Trait Implementations§
impl Freeze for AlgorithmUpdaterV0
impl RefUnwindSafe for AlgorithmUpdaterV0
impl Send for AlgorithmUpdaterV0
impl Sync for AlgorithmUpdaterV0
impl Unpin for AlgorithmUpdaterV0
impl UnwindSafe for AlgorithmUpdaterV0
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)