diff --git a/crates/consensus/src/pure/eip4844.rs b/crates/consensus/src/pure/eip4844.rs index de92abb825d..8d8c52514a9 100644 --- a/crates/consensus/src/pure/eip4844.rs +++ b/crates/consensus/src/pure/eip4844.rs @@ -7,7 +7,7 @@ use crate::constants::eip4844::{ /// See also [the EIP-4844 helpers](https://eips.ethereum.org/EIPS/eip-4844#helpers /// (`calc_excess_blob_gas`). #[inline] -pub fn calc_excess_blob_gas(parent_excess_blob_gas: u64, parent_blob_gas_used: u64) -> u64 { +pub const fn calc_excess_blob_gas(parent_excess_blob_gas: u64, parent_blob_gas_used: u64) -> u64 { (parent_excess_blob_gas + parent_blob_gas_used).saturating_sub(TARGET_DATA_GAS_PER_BLOCK) } diff --git a/crates/consensus/src/transaction/common.rs b/crates/consensus/src/transaction/common.rs index 532ff57f301..471faead6a6 100644 --- a/crates/consensus/src/transaction/common.rs +++ b/crates/consensus/src/transaction/common.rs @@ -14,7 +14,7 @@ pub enum TxKind { impl TxKind { /// Returns the address of the contract that will be called or will receive the transfer. - pub fn to(self) -> Option
{ + pub const fn to(self) -> Option
{ match self { TxKind::Create => None, TxKind::Call(to) => Some(to), @@ -23,19 +23,19 @@ impl TxKind { /// Returns true if the transaction is a contract creation. #[inline] - pub fn is_create(self) -> bool { + pub const fn is_create(self) -> bool { matches!(self, TxKind::Create) } /// Returns true if the transaction is a contract call. #[inline] - pub fn is_call(self) -> bool { + pub const fn is_call(self) -> bool { matches!(self, TxKind::Call(_)) } /// Calculates a heuristic for the in-memory size of the [TransactionKind]. #[inline] - pub(crate) fn size(self) -> usize { + pub(crate) const fn size(self) -> usize { std::mem::size_of::() } } diff --git a/crates/consensus/src/transaction/eip1559.rs b/crates/consensus/src/transaction/eip1559.rs index 5f01b97dd5d..94e57a44e86 100644 --- a/crates/consensus/src/transaction/eip1559.rs +++ b/crates/consensus/src/transaction/eip1559.rs @@ -62,7 +62,7 @@ pub struct TxEip1559 { impl TxEip1559 { /// Returns the effective gas price for the given `base_fee`. - pub fn effective_gas_price(&self, base_fee: Option) -> u128 { + pub const fn effective_gas_price(&self, base_fee: Option) -> u128 { match base_fee { None => self.max_fee_per_gas, Some(base_fee) => { @@ -163,7 +163,7 @@ impl TxEip1559 { } /// Get transaction type - pub(crate) fn tx_type(&self) -> TxType { + pub(crate) const fn tx_type(&self) -> TxType { TxType::Eip1559 } diff --git a/crates/consensus/src/transaction/eip2930.rs b/crates/consensus/src/transaction/eip2930.rs index ed14bfd84cf..a95d548f982 100644 --- a/crates/consensus/src/transaction/eip2930.rs +++ b/crates/consensus/src/transaction/eip2930.rs @@ -140,7 +140,7 @@ impl TxEip2930 { } /// Get transaction type. - pub fn tx_type(&self) -> TxType { + pub const fn tx_type(&self) -> TxType { TxType::Eip2930 } diff --git a/crates/consensus/src/transaction/envelope.rs b/crates/consensus/src/transaction/envelope.rs index d31f108089e..baf1f0ee3b1 100644 --- a/crates/consensus/src/transaction/envelope.rs +++ b/crates/consensus/src/transaction/envelope.rs @@ -75,7 +75,7 @@ impl From> for TxEnvelope { impl TxEnvelope { /// Return the [`TxType`] of the inner txn. - pub fn tx_type(&self) -> TxType { + pub const fn tx_type(&self) -> TxType { match self { TxEnvelope::Legacy(_) | TxEnvelope::TaggedLegacy(_) => TxType::Legacy, TxEnvelope::Eip2930(_) => TxType::Eip2930,