pub struct InitialAndFloorGas {
pub initial_regular_gas: u64,
pub initial_state_gas: u64,
pub state_refund: u64,
pub floor_gas: u64,
}Expand description
Init and floor gas from transaction
Fields§
§initial_regular_gas: u64Regular (non-state) portion of the initial intrinsic gas.
Under EIP-8037, this is the part constrained by TX_MAX_GAS_LIMIT;
state gas uses its own reservoir and is not subject to that cap.
initial_state_gas: u64State gas component of the initial intrinsic gas. Under EIP-8037, this includes:
- EIP-7702 auth list state gas (per-auth account creation + metadata costs)
- For CREATE transactions:
create_state_gas(account creation + contract metadata) - For CALL transactions: 0 (state gas is unpredictable at validation time)
state_refund: u64EIP-7702 refund for existing authorities. This is the refund given when an authorization is applied to an already existing account.
floor_gas: u64If transaction is a Call and Prague is enabled floor_gas is at least amount of gas that is going to be spent.
Implementations§
Source§impl InitialAndFloorGas
impl InitialAndFloorGas
Sourcepub const fn new(initial_regular_gas: u64, floor_gas: u64) -> Self
pub const fn new(initial_regular_gas: u64, floor_gas: u64) -> Self
Create a new InitialAndFloorGas instance.
Sourcepub const fn new_with_state_gas(
initial_regular_gas: u64,
initial_state_gas: u64,
floor_gas: u64,
) -> Self
pub const fn new_with_state_gas( initial_regular_gas: u64, initial_state_gas: u64, floor_gas: u64, ) -> Self
Create a new InitialAndFloorGas instance with state gas tracking.
Sourcepub const fn initial_regular_gas(&self) -> u64
pub const fn initial_regular_gas(&self) -> u64
Regular (non-state) portion of the initial intrinsic gas.
Under EIP-8037, this is the part constrained by TX_MAX_GAS_LIMIT;
state gas uses its own reservoir and is not subject to that cap.
Sourcepub const fn initial_state_gas_final(&self) -> u64
pub const fn initial_state_gas_final(&self) -> u64
State gas component of the initial intrinsic gas. This is the state gas component of the initial intrinsic gas minus the EIP-7702 refund.
Sourcepub const fn initial_total_gas(&self) -> u64
pub const fn initial_total_gas(&self) -> u64
Total initial intrinsic gas: initial_regular_gas + initial_state_gas.
Sourcepub const fn set_initial_regular_gas(&mut self, initial_regular_gas: u64)
pub const fn set_initial_regular_gas(&mut self, initial_regular_gas: u64)
Sets the initial_regular_gas field by mutable reference.
Sourcepub const fn set_initial_state_gas(&mut self, initial_state_gas: u64)
pub const fn set_initial_state_gas(&mut self, initial_state_gas: u64)
Sets the initial_state_gas field by mutable reference.
Sourcepub const fn set_floor_gas(&mut self, floor_gas: u64)
pub const fn set_floor_gas(&mut self, floor_gas: u64)
Sets the floor_gas field by mutable reference.
Sourcepub const fn with_initial_regular_gas(self, initial_regular_gas: u64) -> Self
pub const fn with_initial_regular_gas(self, initial_regular_gas: u64) -> Self
Sets the initial_regular_gas field.
Sourcepub const fn with_initial_state_gas(self, initial_state_gas: u64) -> Self
pub const fn with_initial_state_gas(self, initial_state_gas: u64) -> Self
Sets the initial_state_gas field.
Sourcepub const fn with_floor_gas(self, floor_gas: u64) -> Self
pub const fn with_floor_gas(self, floor_gas: u64) -> Self
Sets the floor_gas field.
Sourcepub fn initial_gas_and_reservoir(
&self,
tx_gas_limit: u64,
tx_gas_limit_cap: u64,
) -> (u64, u64)
pub fn initial_gas_and_reservoir( &self, tx_gas_limit: u64, tx_gas_limit_cap: u64, ) -> (u64, u64)
Computes the regular gas budget and reservoir for the initial call frame.
EIP-8037 reservoir model: execution_gas = tx.gas_limit - intrinsic_gas (= gas_limit parameter) regular_gas_budget = min(execution_gas, TX_MAX_GAS_LIMIT - intrinsic_gas) reservoir = execution_gas - regular_gas_budget
Initial state gas is then deducted from the reservoir (spilling into the regular budget when the reservoir is insufficient), and the EIP-7702 refund for existing authorities is added back to the reservoir.
On mainnet (state gas disabled), reservoir = 0 and gas_limit is unchanged.
Returns (gas_limit, reservoir).
Trait Implementations§
Source§impl Clone for InitialAndFloorGas
impl Clone for InitialAndFloorGas
Source§fn clone(&self) -> InitialAndFloorGas
fn clone(&self) -> InitialAndFloorGas
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for InitialAndFloorGas
impl Debug for InitialAndFloorGas
Source§impl Default for InitialAndFloorGas
impl Default for InitialAndFloorGas
Source§fn default() -> InitialAndFloorGas
fn default() -> InitialAndFloorGas
Source§impl<'de> Deserialize<'de> for InitialAndFloorGas
impl<'de> Deserialize<'de> for InitialAndFloorGas
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 InitialAndFloorGas
impl PartialEq for InitialAndFloorGas
Source§fn eq(&self, other: &InitialAndFloorGas) -> bool
fn eq(&self, other: &InitialAndFloorGas) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for InitialAndFloorGas
impl Serialize for InitialAndFloorGas
impl Copy for InitialAndFloorGas
impl Eq for InitialAndFloorGas
impl StructuralPartialEq for InitialAndFloorGas
Auto Trait Implementations§
impl Freeze for InitialAndFloorGas
impl RefUnwindSafe for InitialAndFloorGas
impl Send for InitialAndFloorGas
impl Sync for InitialAndFloorGas
impl Unpin for InitialAndFloorGas
impl UnsafeUnpin for InitialAndFloorGas
impl UnwindSafe for InitialAndFloorGas
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,
§impl<T> Conv for T
impl<T> Conv for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§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,
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> 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.