Trait PoolTransaction
pub trait PoolTransaction:
Debug
+ Send
+ Sync
+ Clone
+ TryFrom<RecoveredTx<Self::Consensus>, Error = Self::TryFromConsensusError>
+ Into<RecoveredTx<Self::Consensus>>
+ From<RecoveredTx<Self::Pooled>> {
type TryFromConsensusError: Display;
type Consensus: From<Self::Pooled>;
type Pooled: SignedTransaction;
Show 31 methods
// Required methods
fn try_consensus_into_pooled(
tx: RecoveredTx<Self::Consensus>,
) -> Result<RecoveredTx<Self::Pooled>, Self::TryFromConsensusError>;
fn hash(&self) -> &FixedBytes<32>;
fn sender(&self) -> Address;
fn sender_ref(&self) -> &Address;
fn nonce(&self) -> u64;
fn cost(&self) -> &Uint<256, 4>;
fn gas_limit(&self) -> u64;
fn max_fee_per_gas(&self) -> u128;
fn access_list(&self) -> Option<&AccessList>;
fn max_priority_fee_per_gas(&self) -> Option<u128>;
fn max_fee_per_blob_gas(&self) -> Option<u128>;
fn effective_tip_per_gas(&self, base_fee: u64) -> Option<u128>;
fn priority_fee_or_price(&self) -> u128;
fn kind(&self) -> TxKind;
fn is_create(&self) -> bool;
fn input(&self) -> &[u8] ⓘ;
fn size(&self) -> usize;
fn tx_type(&self) -> u8;
fn encoded_length(&self) -> usize;
fn chain_id(&self) -> Option<u64>;
// Provided methods
fn try_from_consensus(
tx: RecoveredTx<Self::Consensus>,
) -> Result<Self, Self::TryFromConsensusError> { ... }
fn clone_into_consensus(&self) -> RecoveredTx<Self::Consensus> { ... }
fn into_consensus(self) -> RecoveredTx<Self::Consensus> { ... }
fn from_pooled(pooled: RecoveredTx<Self::Pooled>) -> Self { ... }
fn try_into_pooled(
self,
) -> Result<RecoveredTx<Self::Pooled>, Self::TryFromConsensusError> { ... }
fn pooled_into_consensus(tx: Self::Pooled) -> Self::Consensus { ... }
fn to(&self) -> Option<Address> { ... }
fn is_eip1559(&self) -> bool { ... }
fn is_eip4844(&self) -> bool { ... }
fn is_eip7702(&self) -> bool { ... }
fn ensure_max_init_code_size(
&self,
max_init_code_size: usize,
) -> Result<(), InvalidPoolTransactionError> { ... }
}
Expand description
Trait for transaction types used inside the pool.
This supports two transaction formats
- Consensus format: the form the transaction takes when it is included in a block.
- Pooled format: the form the transaction takes when it is gossiping around the network.
This distinction is necessary for the EIP-4844 blob transactions, which require an additional
sidecar when they are gossiped around the network. It is expected that the Consensus
format is
a subset of the Pooled
format.
Required Associated Types§
type TryFromConsensusError: Display
type TryFromConsensusError: Display
Associated error type for the try_from_consensus
method.
type Consensus: From<Self::Pooled>
type Consensus: From<Self::Pooled>
Associated type representing the raw consensus variant of the transaction.
type Pooled: SignedTransaction
type Pooled: SignedTransaction
Associated type representing the recovered pooled variant of the transaction.
Required Methods§
fn try_consensus_into_pooled(
tx: RecoveredTx<Self::Consensus>,
) -> Result<RecoveredTx<Self::Pooled>, Self::TryFromConsensusError>
fn try_consensus_into_pooled( tx: RecoveredTx<Self::Consensus>, ) -> Result<RecoveredTx<Self::Pooled>, Self::TryFromConsensusError>
Tries to convert the Consensus
type into the Pooled
type.
fn hash(&self) -> &FixedBytes<32>
fn hash(&self) -> &FixedBytes<32>
Hash of the transaction.
fn sender_ref(&self) -> &Address
fn sender_ref(&self) -> &Address
Reference to the Sender of the transaction.
fn cost(&self) -> &Uint<256, 4>
fn cost(&self) -> &Uint<256, 4>
Returns the cost that this transaction is allowed to consume:
For EIP-1559 transactions: max_fee_per_gas * gas_limit + tx_value
.
For legacy transactions: gas_price * gas_limit + tx_value
.
For EIP-4844 blob transactions: max_fee_per_gas * gas_limit + tx_value + max_blob_fee_per_gas * blob_gas_used
.
fn gas_limit(&self) -> u64
fn gas_limit(&self) -> u64
Amount of gas that should be used in executing this transaction. This is paid up-front.
fn max_fee_per_gas(&self) -> u128
fn max_fee_per_gas(&self) -> u128
Returns the EIP-1559 the maximum fee per gas the caller is willing to pay.
For legacy transactions this is gas_price
.
This is also commonly referred to as the “Gas Fee Cap” (GasFeeCap
).
fn access_list(&self) -> Option<&AccessList>
fn access_list(&self) -> Option<&AccessList>
Returns the access_list
for the particular transaction type.
For Legacy transactions, returns default.
fn max_priority_fee_per_gas(&self) -> Option<u128>
fn max_priority_fee_per_gas(&self) -> Option<u128>
Returns the EIP-1559 Priority fee the caller is paying to the block author.
This will return None
for non-EIP1559 transactions
fn max_fee_per_blob_gas(&self) -> Option<u128>
fn max_fee_per_blob_gas(&self) -> Option<u128>
Returns the EIP-4844 max fee per data gas
This will return None
for non-EIP4844 transactions
fn effective_tip_per_gas(&self, base_fee: u64) -> Option<u128>
fn effective_tip_per_gas(&self, base_fee: u64) -> Option<u128>
Returns the effective tip for this transaction.
For EIP-1559 transactions: min(max_fee_per_gas - base_fee, max_priority_fee_per_gas)
.
For legacy transactions: gas_price - base_fee
.
fn priority_fee_or_price(&self) -> u128
fn priority_fee_or_price(&self) -> u128
Returns the max priority fee per gas if the transaction is an EIP-1559 transaction, and otherwise returns the gas price.
fn kind(&self) -> TxKind
fn kind(&self) -> TxKind
Returns the transaction’s TxKind
, which is the address of the recipient or
TxKind::Create
if the transaction is a contract creation.
fn is_create(&self) -> bool
fn is_create(&self) -> bool
Returns true if the transaction is a contract creation.
We don’t provide a default implementation via kind
as it copies the 21-byte
TxKind
for this simple check. A proper implementation shouldn’t allocate.
fn encoded_length(&self) -> usize
fn encoded_length(&self) -> usize
Returns the length of the rlp encoded transaction object
Note: Implementations should cache this value.
Provided Methods§
fn try_from_consensus(
tx: RecoveredTx<Self::Consensus>,
) -> Result<Self, Self::TryFromConsensusError>
fn try_from_consensus( tx: RecoveredTx<Self::Consensus>, ) -> Result<Self, Self::TryFromConsensusError>
Define a method to convert from the Consensus
type to Self
fn clone_into_consensus(&self) -> RecoveredTx<Self::Consensus>
fn clone_into_consensus(&self) -> RecoveredTx<Self::Consensus>
Clone the transaction into a consensus variant.
This method is preferred when the PoolTransaction
already wraps the consensus variant.
fn into_consensus(self) -> RecoveredTx<Self::Consensus>
fn into_consensus(self) -> RecoveredTx<Self::Consensus>
Define a method to convert from the Self
type to Consensus
fn from_pooled(pooled: RecoveredTx<Self::Pooled>) -> Self
fn from_pooled(pooled: RecoveredTx<Self::Pooled>) -> Self
Define a method to convert from the Pooled
type to Self
fn try_into_pooled(
self,
) -> Result<RecoveredTx<Self::Pooled>, Self::TryFromConsensusError>
fn try_into_pooled( self, ) -> Result<RecoveredTx<Self::Pooled>, Self::TryFromConsensusError>
Tries to convert the Consensus
type into the Pooled
type.
fn pooled_into_consensus(tx: Self::Pooled) -> Self::Consensus
fn pooled_into_consensus(tx: Self::Pooled) -> Self::Consensus
Converts the Pooled
type into the Consensus
type.
fn to(&self) -> Option<Address>
fn to(&self) -> Option<Address>
Returns the recipient of the transaction if it is not a TxKind::Create
transaction.
fn is_eip1559(&self) -> bool
fn is_eip1559(&self) -> bool
Returns true if the transaction is an EIP-1559 transaction.
fn is_eip4844(&self) -> bool
fn is_eip4844(&self) -> bool
Returns true if the transaction is an EIP-4844 transaction.
fn is_eip7702(&self) -> bool
fn is_eip7702(&self) -> bool
Returns true if the transaction is an EIP-7702 transaction.
fn ensure_max_init_code_size(
&self,
max_init_code_size: usize,
) -> Result<(), InvalidPoolTransactionError>
fn ensure_max_init_code_size( &self, max_init_code_size: usize, ) -> Result<(), InvalidPoolTransactionError>
Ensures that the transaction’s code size does not exceed the provided max_init_code_size
.
This is specifically relevant for contract creation transactions (TxKind::Create
),
where the input data contains the initialization code. If the input code size exceeds
the configured limit, an InvalidPoolTransactionError::ExceedsMaxInitCodeSize
error is
returned.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.