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 more