mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
primitives: rm redundant functions for Transaction (#11747)
This commit is contained in:
3
Cargo.lock
generated
3
Cargo.lock
generated
@ -7158,6 +7158,7 @@ dependencies = [
|
||||
name = "reth-engine-util"
|
||||
version = "1.1.0"
|
||||
dependencies = [
|
||||
"alloy-consensus",
|
||||
"alloy-primitives",
|
||||
"alloy-rpc-types-engine",
|
||||
"eyre",
|
||||
@ -8235,6 +8236,7 @@ dependencies = [
|
||||
name = "reth-optimism-rpc"
|
||||
version = "1.1.0"
|
||||
dependencies = [
|
||||
"alloy-consensus",
|
||||
"alloy-eips",
|
||||
"alloy-primitives",
|
||||
"alloy-rpc-types",
|
||||
@ -8726,6 +8728,7 @@ dependencies = [
|
||||
name = "reth-rpc-eth-api"
|
||||
version = "1.1.0"
|
||||
dependencies = [
|
||||
"alloy-consensus",
|
||||
"alloy-dyn-abi",
|
||||
"alloy-eips",
|
||||
"alloy-json-rpc",
|
||||
|
||||
@ -2,7 +2,7 @@ use crate::{
|
||||
in_memory::ExecutedBlock, CanonStateNotification, CanonStateNotifications,
|
||||
CanonStateSubscriptions,
|
||||
};
|
||||
use alloy_consensus::TxEip1559;
|
||||
use alloy_consensus::{Transaction as _, TxEip1559};
|
||||
use alloy_primitives::{Address, BlockNumber, Sealable, B256, U256};
|
||||
use alloy_signer::SignerSync;
|
||||
use alloy_signer_local::PrivateKeySigner;
|
||||
|
||||
@ -29,6 +29,7 @@ reth-trie.workspace = true
|
||||
# alloy
|
||||
alloy-primitives.workspace = true
|
||||
alloy-rpc-types-engine.workspace = true
|
||||
alloy-consensus.workspace = true
|
||||
|
||||
# async
|
||||
tokio = { workspace = true, default-features = false }
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
//! Stream wrapper that simulates reorgs.
|
||||
|
||||
use alloy_consensus::Transaction;
|
||||
use alloy_primitives::U256;
|
||||
use alloy_rpc_types_engine::{
|
||||
CancunPayloadFields, ExecutionPayload, ForkchoiceState, PayloadStatus,
|
||||
|
||||
@ -29,6 +29,7 @@ revm-primitives.workspace = true
|
||||
alloy-primitives.workspace = true
|
||||
alloy-eips.workspace = true
|
||||
alloy-sol-types.workspace = true
|
||||
alloy-consensus.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
reth-testing-utils.workspace = true
|
||||
@ -38,7 +39,6 @@ reth-primitives = { workspace = true, features = ["secp256k1"] }
|
||||
secp256k1.workspace = true
|
||||
serde_json.workspace = true
|
||||
alloy-genesis.workspace = true
|
||||
alloy-consensus.workspace = true
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
|
||||
@ -5,6 +5,7 @@ use crate::{
|
||||
EthEvmConfig,
|
||||
};
|
||||
use alloc::{boxed::Box, sync::Arc, vec, vec::Vec};
|
||||
use alloy_consensus::Transaction as _;
|
||||
use alloy_primitives::{BlockNumber, U256};
|
||||
use core::fmt::Display;
|
||||
use reth_chainspec::{ChainSpec, EthereumHardforks, MAINNET};
|
||||
|
||||
@ -5,6 +5,7 @@ use crate::{
|
||||
EthEvmConfig,
|
||||
};
|
||||
use alloc::sync::Arc;
|
||||
use alloy_consensus::Transaction as _;
|
||||
use core::fmt::Display;
|
||||
use reth_chainspec::{ChainSpec, EthereumHardfork, EthereumHardforks, MAINNET};
|
||||
use reth_consensus::ConsensusError;
|
||||
|
||||
@ -25,6 +25,7 @@ reth-consensus.workspace = true
|
||||
# ethereum
|
||||
alloy-primitives.workspace = true
|
||||
op-alloy-consensus.workspace = true
|
||||
alloy-consensus.workspace = true
|
||||
|
||||
# Optimism
|
||||
reth-optimism-consensus.workspace = true
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
use crate::{
|
||||
l1::ensure_create2_deployer, OpChainSpec, OptimismBlockExecutionError, OptimismEvmConfig,
|
||||
};
|
||||
use alloy_consensus::Transaction as _;
|
||||
use alloy_primitives::{BlockNumber, U256};
|
||||
use reth_chainspec::{ChainSpec, EthereumHardforks};
|
||||
use reth_evm::{
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
//! Optimism block execution strategy,
|
||||
|
||||
use crate::{l1::ensure_create2_deployer, OptimismBlockExecutionError, OptimismEvmConfig};
|
||||
use alloy_consensus::Transaction as _;
|
||||
use reth_chainspec::EthereumHardforks;
|
||||
use reth_consensus::ConsensusError;
|
||||
use reth_evm::{
|
||||
|
||||
@ -38,6 +38,7 @@ alloy-eips.workspace = true
|
||||
alloy-primitives.workspace = true
|
||||
alloy-rpc-types-eth.workspace = true
|
||||
alloy-rpc-types.workspace = true
|
||||
alloy-consensus.workspace = true
|
||||
op-alloy-network.workspace = true
|
||||
op-alloy-rpc-types.workspace = true
|
||||
op-alloy-consensus.workspace = true
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
//! Loads and formats OP transaction RPC response.
|
||||
|
||||
use alloy_consensus::Transaction as _;
|
||||
use alloy_primitives::{Bytes, B256};
|
||||
use alloy_rpc_types::TransactionInfo;
|
||||
use op_alloy_rpc_types::Transaction;
|
||||
|
||||
@ -249,33 +249,6 @@ impl Transaction {
|
||||
}
|
||||
}
|
||||
|
||||
/// Gets the transaction's value field.
|
||||
pub const fn value(&self) -> U256 {
|
||||
*match self {
|
||||
Self::Legacy(TxLegacy { value, .. }) |
|
||||
Self::Eip2930(TxEip2930 { value, .. }) |
|
||||
Self::Eip1559(TxEip1559 { value, .. }) |
|
||||
Self::Eip4844(TxEip4844 { value, .. }) |
|
||||
Self::Eip7702(TxEip7702 { value, .. }) => value,
|
||||
#[cfg(feature = "optimism")]
|
||||
Self::Deposit(TxDeposit { value, .. }) => value,
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the transaction's nonce.
|
||||
pub const fn nonce(&self) -> u64 {
|
||||
match self {
|
||||
Self::Legacy(TxLegacy { nonce, .. }) |
|
||||
Self::Eip2930(TxEip2930 { nonce, .. }) |
|
||||
Self::Eip1559(TxEip1559 { nonce, .. }) |
|
||||
Self::Eip4844(TxEip4844 { nonce, .. }) |
|
||||
Self::Eip7702(TxEip7702 { nonce, .. }) => *nonce,
|
||||
// Deposit transactions do not have nonces.
|
||||
#[cfg(feature = "optimism")]
|
||||
Self::Deposit(_) => 0,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the [`AccessList`] of the transaction.
|
||||
///
|
||||
/// Returns `None` for legacy transactions.
|
||||
@ -301,19 +274,6 @@ impl Transaction {
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the gas limit of the transaction.
|
||||
pub const fn gas_limit(&self) -> u64 {
|
||||
match self {
|
||||
Self::Legacy(TxLegacy { gas_limit, .. }) |
|
||||
Self::Eip1559(TxEip1559 { gas_limit, .. }) |
|
||||
Self::Eip4844(TxEip4844 { gas_limit, .. }) |
|
||||
Self::Eip7702(TxEip7702 { gas_limit, .. }) |
|
||||
Self::Eip2930(TxEip2930 { gas_limit, .. }) => *gas_limit,
|
||||
#[cfg(feature = "optimism")]
|
||||
Self::Deposit(TxDeposit { gas_limit, .. }) => *gas_limit,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns true if the tx supports dynamic fees
|
||||
pub const fn is_dynamic_fee(&self) -> bool {
|
||||
match self {
|
||||
@ -324,40 +284,6 @@ impl Transaction {
|
||||
}
|
||||
}
|
||||
|
||||
/// Max fee per gas for eip1559 transaction, for legacy transactions this is `gas_price`.
|
||||
///
|
||||
/// This is also commonly referred to as the "Gas Fee Cap" (`GasFeeCap`).
|
||||
pub const fn max_fee_per_gas(&self) -> u128 {
|
||||
match self {
|
||||
Self::Legacy(TxLegacy { gas_price, .. }) |
|
||||
Self::Eip2930(TxEip2930 { gas_price, .. }) => *gas_price,
|
||||
Self::Eip1559(TxEip1559 { max_fee_per_gas, .. }) |
|
||||
Self::Eip4844(TxEip4844 { max_fee_per_gas, .. }) |
|
||||
Self::Eip7702(TxEip7702 { max_fee_per_gas, .. }) => *max_fee_per_gas,
|
||||
// Deposit transactions buy their L2 gas on L1 and, as such, the L2 gas is not
|
||||
// refundable.
|
||||
#[cfg(feature = "optimism")]
|
||||
Self::Deposit(_) => 0,
|
||||
}
|
||||
}
|
||||
|
||||
/// Max priority fee per gas for eip1559 transaction, for legacy and eip2930 transactions this
|
||||
/// is `None`
|
||||
///
|
||||
/// This is also commonly referred to as the "Gas Tip Cap" (`GasTipCap`).
|
||||
pub const fn max_priority_fee_per_gas(&self) -> Option<u128> {
|
||||
match self {
|
||||
Self::Legacy(_) | Self::Eip2930(_) => None,
|
||||
Self::Eip1559(TxEip1559 { max_priority_fee_per_gas, .. }) |
|
||||
Self::Eip4844(TxEip4844 { max_priority_fee_per_gas, .. }) |
|
||||
Self::Eip7702(TxEip7702 { max_priority_fee_per_gas, .. }) => {
|
||||
Some(*max_priority_fee_per_gas)
|
||||
}
|
||||
#[cfg(feature = "optimism")]
|
||||
Self::Deposit(_) => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Blob versioned hashes for eip4844 transaction, for legacy, eip1559, eip2930 and eip7702
|
||||
/// transactions this is `None`
|
||||
///
|
||||
@ -373,18 +299,6 @@ impl Transaction {
|
||||
}
|
||||
}
|
||||
|
||||
/// Max fee per blob gas for eip4844 transaction [`TxEip4844`].
|
||||
///
|
||||
/// Returns `None` for non-eip4844 transactions.
|
||||
///
|
||||
/// This is also commonly referred to as the "Blob Gas Fee Cap" (`BlobGasFeeCap`).
|
||||
pub const fn max_fee_per_blob_gas(&self) -> Option<u128> {
|
||||
match self {
|
||||
Self::Eip4844(TxEip4844 { max_fee_per_blob_gas, .. }) => Some(*max_fee_per_blob_gas),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the blob gas used for all blobs of the EIP-4844 transaction if it is an EIP-4844
|
||||
/// transaction.
|
||||
///
|
||||
@ -394,25 +308,6 @@ impl Transaction {
|
||||
self.as_eip4844().map(TxEip4844::blob_gas)
|
||||
}
|
||||
|
||||
/// Return the max priority fee per gas if the transaction is an EIP-1559 transaction, and
|
||||
/// otherwise return the gas price.
|
||||
///
|
||||
/// # Warning
|
||||
///
|
||||
/// This is different than the `max_priority_fee_per_gas` method, which returns `None` for
|
||||
/// non-EIP-1559 transactions.
|
||||
pub const fn priority_fee_or_price(&self) -> u128 {
|
||||
match self {
|
||||
Self::Legacy(TxLegacy { gas_price, .. }) |
|
||||
Self::Eip2930(TxEip2930 { gas_price, .. }) => *gas_price,
|
||||
Self::Eip1559(TxEip1559 { max_priority_fee_per_gas, .. }) |
|
||||
Self::Eip4844(TxEip4844 { max_priority_fee_per_gas, .. }) |
|
||||
Self::Eip7702(TxEip7702 { max_priority_fee_per_gas, .. }) => *max_priority_fee_per_gas,
|
||||
#[cfg(feature = "optimism")]
|
||||
Self::Deposit(_) => 0,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the effective gas price for the given base fee.
|
||||
///
|
||||
/// If the transaction is a legacy or EIP2930 transaction, the gas price is returned.
|
||||
@ -923,7 +818,7 @@ impl AlloyTransaction for Transaction {
|
||||
}
|
||||
}
|
||||
|
||||
fn value(&self) -> alloy_primitives::U256 {
|
||||
fn value(&self) -> U256 {
|
||||
match self {
|
||||
Self::Legacy(tx) => tx.value(),
|
||||
Self::Eip2930(tx) => tx.value(),
|
||||
|
||||
@ -40,6 +40,7 @@ alloy-primitives.workspace = true
|
||||
alloy-rpc-types-eth.workspace = true
|
||||
alloy-rpc-types.workspace = true
|
||||
alloy-rpc-types-mev.workspace = true
|
||||
alloy-consensus.workspace = true
|
||||
|
||||
# rpc
|
||||
jsonrpsee = { workspace = true, features = ["server", "macros"] }
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
//! Database access for `eth_` transaction RPC methods. Loads transaction and receipt data w.r.t.
|
||||
//! network.
|
||||
|
||||
use alloy_consensus::Transaction;
|
||||
use alloy_dyn_abi::TypedData;
|
||||
use alloy_eips::eip2718::Encodable2718;
|
||||
use alloy_network::TransactionBuilder;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
//! RPC receipt response builder, extends a layer one receipt with layer two data.
|
||||
|
||||
use alloy_consensus::Transaction;
|
||||
use alloy_primitives::{Address, TxKind};
|
||||
use alloy_rpc_types::{
|
||||
AnyReceiptEnvelope, AnyTransactionReceipt, Log, ReceiptWithBloom, TransactionReceipt,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
//! Utilities for serving `eth_simulateV1`
|
||||
|
||||
use alloy_consensus::{TxEip4844Variant, TxType, TypedTransaction};
|
||||
use alloy_consensus::{Transaction as _, TxEip4844Variant, TxType, TypedTransaction};
|
||||
use alloy_primitives::Parity;
|
||||
use alloy_rpc_types::{
|
||||
simulate::{SimCallResult, SimulateError, SimulatedBlock},
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
use std::{collections::BTreeMap, marker::PhantomData};
|
||||
|
||||
use alloy_consensus::Transaction;
|
||||
use alloy_primitives::Address;
|
||||
use alloy_rpc_types_txpool::{
|
||||
TxpoolContent, TxpoolContentFrom, TxpoolInspect, TxpoolInspectSummary, TxpoolStatus,
|
||||
|
||||
@ -56,6 +56,7 @@ impl Deref for LoadedJar {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{test_utils::create_test_provider_factory, HeaderProvider};
|
||||
use alloy_consensus::Transaction;
|
||||
use alloy_primitives::{BlockHash, TxNumber, B256, U256};
|
||||
use rand::seq::SliceRandom;
|
||||
use reth_db::{
|
||||
|
||||
Reference in New Issue
Block a user