Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Introduce trait for OpTransaction #11745

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 54 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -461,10 +461,15 @@ alloy-transport-ipc = { version = "0.4.2", default-features = false }
alloy-transport-ws = { version = "0.4.2", default-features = false }

# op
op-alloy-rpc-types = "0.4"
op-alloy-rpc-types-engine = "0.4"
op-alloy-network = "0.4"
op-alloy-consensus = "0.4"
op-alloy-rpc-types = { git = "https://github.com/alloy-rs/op-alloy.git", branch = "main"}
op-alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/op-alloy.git", branch = "main"}
op-alloy-network = { git = "https://github.com/alloy-rs/op-alloy.git", branch = "main"}
op-alloy-consensus = { git = "https://github.com/alloy-rs/op-alloy.git", branch = "main"}
#op-alloy-rpc-types = "0.4.0"
#op-alloy-rpc-types-engine = "0.4.0"
#op-alloy-network = "0.4.0"
#op-alloy-consensus = "0.4.0"


# misc
aquamarine = "0.5"
Expand Down
1 change: 1 addition & 0 deletions crates/optimism/evm/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::{
l1::ensure_create2_deployer, OpChainSpec, OptimismBlockExecutionError, OptimismEvmConfig,
};
use alloy_primitives::{BlockNumber, U256};
use op_alloy_consensus::DepositTransaction;
use reth_chainspec::{ChainSpec, EthereumHardforks};
use reth_evm::{
execute::{
Expand Down
3 changes: 3 additions & 0 deletions crates/optimism/payload/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ alloy-eips.workspace = true
alloy-primitives.workspace = true
alloy-rlp.workspace = true
op-alloy-rpc-types-engine.workspace = true
op-alloy-consensus.workspace = true
revm-primitives.workspace = true
alloy-rpc-types-engine.workspace = true

Expand All @@ -54,3 +55,5 @@ optimism = [
"reth-optimism-evm/optimism",
"reth-revm/optimism",
]


1 change: 1 addition & 0 deletions crates/optimism/payload/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ use crate::{
error::OptimismPayloadBuilderError,
payload::{OptimismBuiltPayload, OptimismPayloadBuilderAttributes},
};
use op_alloy_consensus::DepositTransaction;

/// Optimism's payload builder
#[derive(Debug, Clone, PartialEq, Eq)]
Expand Down
4 changes: 3 additions & 1 deletion crates/optimism/rpc/src/eth/receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

use alloy_eips::eip2718::Encodable2718;
use alloy_rpc_types::{AnyReceiptEnvelope, Log, TransactionReceipt};
use op_alloy_consensus::{OpDepositReceipt, OpDepositReceiptWithBloom, OpReceiptEnvelope};
use op_alloy_consensus::{
DepositTransaction, OpDepositReceipt, OpDepositReceiptWithBloom, OpReceiptEnvelope,
};
use op_alloy_rpc_types::{receipt::L1BlockInfo, OpTransactionReceipt, OpTransactionReceiptFields};
use reth_node_api::{FullNodeComponents, NodeTypes};
use reth_optimism_chainspec::OpChainSpec;
Expand Down
1 change: 1 addition & 0 deletions crates/optimism/rpc/src/eth/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use alloy_primitives::{Bytes, B256};
use alloy_rpc_types::TransactionInfo;
use op_alloy_consensus::DepositTransaction;
use op_alloy_rpc_types::Transaction;
use reth_node_api::FullNodeComponents;
use reth_primitives::TransactionSignedEcRecovered;
Expand Down
2 changes: 2 additions & 0 deletions crates/primitives/src/transaction/compat.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::{Transaction, TransactionSigned};
use alloy_primitives::{Address, TxKind, U256};
#[cfg(feature = "optimism")]
use op_alloy_consensus::DepositTransaction;
use revm_primitives::{AuthorizationList, TxEnv};

/// Implements behaviour to fill a [`TxEnv`] from another transaction.
Expand Down
36 changes: 0 additions & 36 deletions crates/primitives/src/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,42 +472,6 @@ impl Transaction {
}
}

/// Returns the source hash of the transaction, which uniquely identifies its source.
/// If not a deposit transaction, this will always return `None`.
#[cfg(feature = "optimism")]
pub const fn source_hash(&self) -> Option<B256> {
match self {
Self::Deposit(TxDeposit { source_hash, .. }) => Some(*source_hash),
_ => None,
}
}

/// Returns the amount of ETH locked up on L1 that will be minted on L2. If the transaction
/// is not a deposit transaction, this will always return `None`.
#[cfg(feature = "optimism")]
pub const fn mint(&self) -> Option<u128> {
match self {
Self::Deposit(TxDeposit { mint, .. }) => *mint,
_ => None,
}
}

/// Returns whether or not the transaction is a system transaction. If the transaction
/// is not a deposit transaction, this will always return `false`.
#[cfg(feature = "optimism")]
pub const fn is_system_transaction(&self) -> bool {
match self {
Self::Deposit(TxDeposit { is_system_transaction, .. }) => *is_system_transaction,
_ => false,
}
}

/// Returns whether or not the transaction is an Optimism Deposited transaction.
#[cfg(feature = "optimism")]
pub const fn is_deposit(&self) -> bool {
matches!(self, Self::Deposit(_))
}

/// This encodes the transaction _without_ the signature, and is only suitable for creating a
/// hash intended for signing.
pub fn encode_without_signature(&self, out: &mut dyn bytes::BufMut) {
Expand Down
Loading