pub struct L2PricingState<'a, D> {
pub backing_storage: Storage<'a, D>,
pub arbos_version: u64,
/* private fields */
}Expand description
L2 pricing state manages gas pricing for L2 execution.
Fields§
§backing_storage: Storage<'a, D>§arbos_version: u64Implementations§
Source§impl<D: Database> L2PricingState<'_, D>
impl<D: Database> L2PricingState<'_, D>
Sourcepub fn gas_model_to_use<B: SystemStateBackend>(
&self,
backend: &mut B,
) -> Result<GasModel, L2PricingError>
pub fn gas_model_to_use<B: SystemStateBackend>( &self, backend: &mut B, ) -> Result<GasModel, L2PricingError>
Determine which gas model to use based on ArbOS version and stored constraints.
Sourcepub fn grow_backlog<B: StorageBackend>(
&self,
backend: &mut B,
used_gas: u64,
used_multi_gas: MultiGas,
) -> Result<(), L2PricingError>
pub fn grow_backlog<B: StorageBackend>( &self, backend: &mut B, used_gas: u64, used_multi_gas: MultiGas, ) -> Result<(), L2PricingError>
Grow the gas backlog for the active pricing model.
Sourcepub fn shrink_backlog<B: StorageBackend>(
&self,
backend: &mut B,
used_gas: u64,
used_multi_gas: MultiGas,
) -> Result<(), L2PricingError>
pub fn shrink_backlog<B: StorageBackend>( &self, backend: &mut B, used_gas: u64, used_multi_gas: MultiGas, ) -> Result<(), L2PricingError>
Shrink the gas backlog for the active pricing model.
Sourcepub fn update_pricing_model<B: StorageBackend>(
&self,
backend: &mut B,
time_passed: u64,
arbos_version: u64,
) -> Result<(), L2PricingError>
pub fn update_pricing_model<B: StorageBackend>( &self, backend: &mut B, time_passed: u64, arbos_version: u64, ) -> Result<(), L2PricingError>
Update the pricing model for a new block.
Sourcepub fn calc_multi_gas_constraints_exponents<B: StorageBackend>(
&self,
backend: &mut B,
) -> Result<[u64; 9], L2PricingError>
pub fn calc_multi_gas_constraints_exponents<B: StorageBackend>( &self, backend: &mut B, ) -> Result<[u64; 9], L2PricingError>
Calculate exponent (in basis points) per resource kind across all constraints.
Sourcepub fn calc_base_fee_from_exponent<B: StorageBackend>(
&self,
backend: &mut B,
exponent_bips: u64,
) -> Result<U256, L2PricingError>
pub fn calc_base_fee_from_exponent<B: StorageBackend>( &self, backend: &mut B, exponent_bips: u64, ) -> Result<U256, L2PricingError>
Calculate base fee from an exponent in basis points. base_fee = min_base_fee * exp(exponent_bips / 10000)
pub fn get_multi_gas_base_fee_per_resource<B: SystemStateBackend>( &self, backend: &mut B, ) -> Result<[U256; 9], L2PricingError>
Sourcepub fn get_current_multi_gas_fees<B: SystemStateBackend>(
&self,
backend: &mut B,
) -> Result<[U256; 9], L2PricingError>
pub fn get_current_multi_gas_fees<B: SystemStateBackend>( &self, backend: &mut B, ) -> Result<[U256; 9], L2PricingError>
Reads the 8 current-block multi-gas fees (non-SingleDim). Intended for
block-level caching by the executor: these values are only written by
commit_next_to_current, which runs before any tx in the block.
Zero is kept (not substituted to base_fee_wei) so the caller can do the
substitution with a fresh base_fee read on every use.
Sourcepub fn commit_multi_gas_fees<B: StorageBackend>(
&self,
backend: &mut B,
) -> Result<(), L2PricingError>
pub fn commit_multi_gas_fees<B: StorageBackend>( &self, backend: &mut B, ) -> Result<(), L2PricingError>
Rotate next-block multi-gas fees into current-block fees.
Sourcepub fn backlog_update_cost<B: SystemStateBackend>(
&self,
backend: &mut B,
) -> Result<u64, L2PricingError>
pub fn backlog_update_cost<B: SystemStateBackend>( &self, backend: &mut B, ) -> Result<u64, L2PricingError>
Calculate the cost for a backlog update operation.
Sourcepub fn set_gas_constraints_from_legacy<B: StorageBackend>(
&self,
backend: &mut B,
) -> Result<(), L2PricingError>
pub fn set_gas_constraints_from_legacy<B: StorageBackend>( &self, backend: &mut B, ) -> Result<(), L2PricingError>
Set gas constraints from legacy parameters (for upgrades).
Sourcepub fn set_multi_gas_constraints_from_single_gas_constraints<B: StorageBackend>(
&self,
backend: &mut B,
) -> Result<(), L2PricingError>
pub fn set_multi_gas_constraints_from_single_gas_constraints<B: StorageBackend>( &self, backend: &mut B, ) -> Result<(), L2PricingError>
Convert single-gas constraints to multi-gas constraints (for upgrades).
Sourcepub fn multi_dimensional_price_for_refund<B: SystemStateBackend>(
&self,
backend: &mut B,
gas_used: MultiGas,
) -> Result<U256, L2PricingError>
pub fn multi_dimensional_price_for_refund<B: SystemStateBackend>( &self, backend: &mut B, gas_used: MultiGas, ) -> Result<U256, L2PricingError>
Compute total cost for a multi-gas usage, for refund calculations.
Returns sum(gas_used[kind] * base_fee[kind]) across all resource kinds.
Sourcepub fn multi_dimensional_price_for_refund_with_fees<B: SystemStateBackend>(
&self,
backend: &mut B,
gas_used: MultiGas,
cached_fees: &[U256; 9],
) -> Result<U256, L2PricingError>
pub fn multi_dimensional_price_for_refund_with_fees<B: SystemStateBackend>( &self, backend: &mut B, gas_used: MultiGas, cached_fees: &[U256; 9], ) -> Result<U256, L2PricingError>
Variant of multi_dimensional_price_for_refund that uses precomputed
current-block multi-gas fees (as returned by get_current_multi_gas_fees).
Single-dimensional gas and any resource whose current-block fee is zero
are valued at the live base_fee_wei (the per-block floor), matching
get_multi_gas_base_fee_per_resource. The refund reconciles the
single-gas cost the sender paid (base_fee × gasUsed) against this
multi-dimensional cost over the raw, pre-refund resource usage.
Source§impl<'a, D> L2PricingState<'a, D>
impl<'a, D> L2PricingState<'a, D>
pub fn open(sto: Storage<'a, D>, arbos_version: u64) -> Self
pub fn initialize<B: StorageBackend>( sto: &Storage<'_, D>, backend: &mut B, ) -> Result<(), L2PricingError>
pub fn base_fee_wei<B: SystemStateBackend>( &self, backend: &mut B, ) -> Result<U256, L2PricingError>
pub fn set_base_fee_wei<B: StorageBackend>( &self, backend: &mut B, val: U256, ) -> Result<(), L2PricingError>
pub fn min_base_fee_wei<B: SystemStateBackend>( &self, backend: &mut B, ) -> Result<U256, L2PricingError>
pub fn set_min_base_fee_wei<B: StorageBackend>( &self, backend: &mut B, val: U256, ) -> Result<(), L2PricingError>
pub fn speed_limit_per_second<B: SystemStateBackend>( &self, backend: &mut B, ) -> Result<u64, L2PricingError>
pub fn set_speed_limit_per_second<B: StorageBackend>( &self, backend: &mut B, limit: u64, ) -> Result<(), L2PricingError>
pub fn per_block_gas_limit<B: SystemStateBackend>( &self, backend: &mut B, ) -> Result<u64, L2PricingError>
pub fn set_max_per_block_gas_limit<B: StorageBackend>( &self, backend: &mut B, limit: u64, ) -> Result<(), L2PricingError>
pub fn per_tx_gas_limit<B: SystemStateBackend>( &self, backend: &mut B, ) -> Result<u64, L2PricingError>
pub fn set_max_per_tx_gas_limit<B: StorageBackend>( &self, backend: &mut B, limit: u64, ) -> Result<(), L2PricingError>
pub fn gas_backlog<B: SystemStateBackend>( &self, backend: &mut B, ) -> Result<u64, L2PricingError>
pub fn set_gas_backlog<B: StorageBackend>( &self, backend: &mut B, backlog: u64, ) -> Result<(), L2PricingError>
pub fn pricing_inertia<B: SystemStateBackend>( &self, backend: &mut B, ) -> Result<u64, L2PricingError>
pub fn set_pricing_inertia<B: StorageBackend>( &self, backend: &mut B, val: u64, ) -> Result<(), L2PricingError>
pub fn backlog_tolerance<B: SystemStateBackend>( &self, backend: &mut B, ) -> Result<u64, L2PricingError>
pub fn set_backlog_tolerance<B: StorageBackend>( &self, backend: &mut B, val: u64, ) -> Result<(), L2PricingError>
pub fn gas_constraints_length<B: SystemStateBackend>( &self, backend: &mut B, ) -> Result<u64, L2PricingError>
pub fn open_gas_constraint_at(&self, index: u64) -> GasConstraint
pub fn add_gas_constraint<B: StorageBackend>( &self, backend: &mut B, target: u64, adjustment_window: u64, backlog: u64, ) -> Result<(), L2PricingError>
pub fn clear_gas_constraints<B: StorageBackend>( &self, backend: &mut B, ) -> Result<(), L2PricingError>
pub fn multi_gas_constraints_length<B: SystemStateBackend>( &self, backend: &mut B, ) -> Result<u64, L2PricingError>
pub fn open_multi_gas_constraint_at(&self, index: u64) -> MultiGasConstraint
pub fn add_multi_gas_constraint<B: StorageBackend>( &self, backend: &mut B, target: u64, adjustment_window: u32, backlog: u64, weights: &[u64; 9], ) -> Result<(), L2PricingError>
pub fn clear_multi_gas_constraints<B: StorageBackend>( &self, backend: &mut B, ) -> Result<(), L2PricingError>
pub fn restrict(&self, _err: ())
Sourcepub fn multi_gas_fees(&self) -> MultiGasFees<'a, D>
pub fn multi_gas_fees(&self) -> MultiGasFees<'a, D>
Per-resource-kind base fee accessor for the current/next block.
Auto Trait Implementations§
impl<'a, D> Freeze for L2PricingState<'a, D>
impl<'a, D> RefUnwindSafe for L2PricingState<'a, D>where
D: RefUnwindSafe,
impl<'a, D> Send for L2PricingState<'a, D>where
D: Send,
impl<'a, D> Sync for L2PricingState<'a, D>where
D: Sync,
impl<'a, D> Unpin for L2PricingState<'a, D>
impl<'a, D> !UnwindSafe for L2PricingState<'a, D>
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
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<TxEnv, T> FromRecoveredTx<&T> for TxEnvwhere
TxEnv: FromRecoveredTx<T>,
impl<TxEnv, T> FromRecoveredTx<&T> for TxEnvwhere
TxEnv: FromRecoveredTx<T>,
§fn from_recovered_tx(tx: &&T, sender: Address) -> TxEnv
fn from_recovered_tx(tx: &&T, sender: Address) -> TxEnv
TxEnv] from a transaction and a sender address.§impl<TxEnv, T> FromTxWithEncoded<&T> for TxEnvwhere
TxEnv: FromTxWithEncoded<T>,
impl<TxEnv, T> FromTxWithEncoded<&T> for TxEnvwhere
TxEnv: FromTxWithEncoded<T>,
§fn from_encoded_tx(tx: &&T, sender: Address, encoded: Bytes) -> TxEnv
fn from_encoded_tx(tx: &&T, sender: Address, encoded: Bytes) -> TxEnv
TxEnv] from a transaction, its sender, and encoded transaction bytes.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.