pub struct ResultGas { /* private fields */ }Expand description
Gas accounting result from transaction execution.
Self-contained gas snapshot with all values needed for downstream consumers.
§Stored values
| Getter | Source | Description |
|---|---|---|
total_gas_spent() | Gas::spent() = limit − remaining | Total gas consumed before refund |
inner_refunded() | Gas::refunded() as u64 | Gas refunded (capped per EIP-3529) |
floor_gas() | InitialAndFloorGas::floor_gas | EIP-7623 floor gas (0 if not applicable) |
state_gas_spent() | Gas::state_gas_spent | State gas consumed during execution (EIP-8037) |
§Derived values
tx_gas_used()=max(total_gas_spent − refunded, floor_gas)(the value that goes into receipts)block_regular_gas_used()=max(total_gas_spent − state_gas_spent, floor_gas)block_state_gas_used()=state_gas_spentspent_sub_refunded()=total_gas_spent − refunded(before floor gas check)final_refunded()=refundedwhen floor gas is inactive,0when floor gas kicks in
Implementations§
Source§impl ResultGas
impl ResultGas
Sourcepub const fn new(total_gas_spent: u64, refunded: u64, floor_gas: u64) -> Self
👎Deprecated since 32.0.0: It can be a footgun as gas limit is removed, use ResultGas::with_* functions instead
pub const fn new(total_gas_spent: u64, refunded: u64, floor_gas: u64) -> Self
It can be a footgun as gas limit is removed, use ResultGas::with_* functions instead
Creates a new ResultGas.
Sourcepub const fn new_with_state_gas(
total_gas_spent: u64,
refunded: u64,
floor_gas: u64,
state_gas_spent: u64,
) -> Self
pub const fn new_with_state_gas( total_gas_spent: u64, refunded: u64, floor_gas: u64, state_gas_spent: u64, ) -> Self
Creates a new ResultGas with state gas tracking.
Sourcepub const fn total_gas_spent(&self) -> u64
pub const fn total_gas_spent(&self) -> u64
Returns the total gas spent inside execution before any refund.
If you want final gas used, use used().
Sourcepub const fn state_gas_spent(&self) -> u64
pub const fn state_gas_spent(&self) -> u64
Returns the state gas spent during execution (EIP-8037).
This is same as ResultGas::block_state_gas_used for the transaction.
Sourcepub const fn inner_refunded(&self) -> u64
pub const fn inner_refunded(&self) -> u64
Returns the raw refund from EVM execution, before EIP-7623 floor gas adjustment.
This is the refunded field value (capped per EIP-3529 but not adjusted for floor gas).
See final_refunded() for the effective refund.
Sourcepub const fn spent(&self) -> u64
👎Deprecated since 32.0.0: After EIP-8037 gas is split on
regular and state gas, this method is no longer valid.
Use ResultGas::total_gas_spent instead
pub const fn spent(&self) -> u64
After EIP-8037 gas is split on
regular and state gas, this method is no longer valid.
Use ResultGas::total_gas_spent instead
Returns the total gas spent.
Sourcepub fn set_total_gas_spent(&mut self, total_gas_spent: u64)
pub fn set_total_gas_spent(&mut self, total_gas_spent: u64)
Sets the total_gas_spent field by mutable reference.
Sourcepub fn set_refunded(&mut self, refunded: u64)
pub fn set_refunded(&mut self, refunded: u64)
Sets the refunded field by mutable reference.
Sourcepub fn set_floor_gas(&mut self, floor_gas: u64)
pub fn set_floor_gas(&mut self, floor_gas: u64)
Sets the floor_gas field by mutable reference.
Sourcepub fn set_state_gas_spent(&mut self, state_gas_spent: u64)
pub fn set_state_gas_spent(&mut self, state_gas_spent: u64)
Sets the state_gas_spent field by mutable reference.
Sourcepub fn set_spent(&mut self, spent: u64)
👎Deprecated since 32.0.0: After EIP-8037 gas is split on
regular and state gas, this method is no longer valid.
Use ResultGas::set_total_gas_spent instead
pub fn set_spent(&mut self, spent: u64)
After EIP-8037 gas is split on
regular and state gas, this method is no longer valid.
Use ResultGas::set_total_gas_spent instead
Sets the spent field by mutable reference.
Sourcepub const fn with_total_gas_spent(self, total_gas_spent: u64) -> Self
pub const fn with_total_gas_spent(self, total_gas_spent: u64) -> Self
Sets the total_gas_spent field.
Sourcepub const fn with_refunded(self, refunded: u64) -> Self
pub const fn with_refunded(self, refunded: u64) -> Self
Sets the refunded 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 const fn with_state_gas_spent(self, state_gas_spent: u64) -> Self
pub const fn with_state_gas_spent(self, state_gas_spent: u64) -> Self
Sets the state_gas_spent field.
Sourcepub const fn with_spent(self, spent: u64) -> Self
👎Deprecated since 32.0.0: After EIP-8037 gas is split on
regular and state gas, this method is no longer valid.
Use ResultGas::with_total_gas_spent instead
pub const fn with_spent(self, spent: u64) -> Self
After EIP-8037 gas is split on
regular and state gas, this method is no longer valid.
Use ResultGas::with_total_gas_spent instead
Sets the spent field.
Sourcepub const fn tx_gas_used(&self) -> u64
pub const fn tx_gas_used(&self) -> u64
Returns the total gas used by the transaction.
This value is set inside Receipt.
Sourcepub const fn block_regular_gas_used(&self) -> u64
pub const fn block_regular_gas_used(&self) -> u64
Returns the regular gas used by the block.
Sourcepub const fn block_state_gas_used(&self) -> u64
pub const fn block_state_gas_used(&self) -> u64
Returns the state gas used by the block.
This is same as ResultGas::state_gas_spent for the block.
Sourcepub const fn used(&self) -> u64
👎Deprecated since 32.0.0: Used is not descriptive enough, use ResultGas::tx_gas_used instead
pub const fn used(&self) -> u64
Used is not descriptive enough, use ResultGas::tx_gas_used instead
Returns the final gas used: max(spent - refunded, floor_gas).
This is the value used for receipt cumulative_gas_used accumulation
and the per-transaction gas charge.
Sourcepub const fn spent_sub_refunded(&self) -> u64
pub const fn spent_sub_refunded(&self) -> u64
Returns the gas spent minus the refunded gas.
This does not take into account EIP-7623 floor gas. If you want to get the gas used in
receipt, use used() instead.
Sourcepub const fn final_refunded(&self) -> u64
pub const fn final_refunded(&self) -> u64
Returns the effective refund after EIP-7623 floor gas adjustment.
When floor gas kicks in (spent - refunded < floor_gas), the refund is zero
because the floor gas charge absorbs it entirely. Otherwise returns the raw refund.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ResultGas
impl<'de> Deserialize<'de> for ResultGas
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>,
impl Copy for ResultGas
impl Eq for ResultGas
impl StructuralPartialEq for ResultGas
Auto Trait Implementations§
impl Freeze for ResultGas
impl RefUnwindSafe for ResultGas
impl Send for ResultGas
impl Sync for ResultGas
impl Unpin for ResultGas
impl UnsafeUnpin for ResultGas
impl UnwindSafe for ResultGas
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.