Skip to content

Commit

Permalink
optimism: use op-alloy TxDeposit
Browse files Browse the repository at this point in the history
  • Loading branch information
tcoratger committed Sep 2, 2024
1 parent 659375d commit 88e7135
Show file tree
Hide file tree
Showing 9 changed files with 345 additions and 262 deletions.
47 changes: 25 additions & 22 deletions Cargo.lock

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

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

# op
op-alloy-rpc-types = "0.2.5"
op-alloy-rpc-types-engine = "0.2"
op-alloy-network = "0.2"
op-alloy-rpc-types = "0.2.7"
op-alloy-rpc-types-engine = "0.2.7"
op-alloy-network = "0.2.7"
op-alloy-consensus = "0.2.7"

# misc
aquamarine = "0.5"
Expand Down
3 changes: 3 additions & 0 deletions crates/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ alloy-eips = { workspace = true, features = ["serde"] }

# optimism
op-alloy-rpc-types = { workspace = true, optional = true }
op-alloy-consensus = { workspace = true, optional = true }

# crypto
secp256k1 = { workspace = true, features = [
Expand Down Expand Up @@ -98,6 +99,7 @@ arbitrary = [
"dep:arbitrary",
"dep:proptest",
"reth-codec",
"op-alloy-consensus/arbitrary",
]
secp256k1 = ["dep:secp256k1"]
c-kzg = ["dep:c-kzg", "revm-primitives/c-kzg", "dep:tempfile", "alloy-eips/kzg", "alloy-consensus/kzg"]
Expand All @@ -106,6 +108,7 @@ optimism = [
"reth-ethereum-forks/optimism",
"revm-primitives/optimism",
"dep:reth-optimism-chainspec",
"dep:op-alloy-consensus",
]
alloy-compat = ["reth-primitives-traits/alloy-compat", "dep:alloy-rpc-types", "dep:alloy-serde", "dep:op-alloy-rpc-types"]
test-utils = ["reth-primitives-traits/test-utils"]
Expand Down
2 changes: 1 addition & 1 deletion crates/primitives/src/transaction/compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl FillTxEnv for TransactionSigned {
#[cfg(feature = "optimism")]
Transaction::Deposit(tx) => {
tx_env.access_list.clear();
tx_env.gas_limit = tx.gas_limit;
tx_env.gas_limit = tx.gas_limit as u64;
tx_env.gas_price = U256::ZERO;
tx_env.gas_priority_fee = None;
tx_env.transact_to = tx.to;
Expand Down
13 changes: 8 additions & 5 deletions crates/primitives/src/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ impl Transaction {
Self::Eip4844(_) => TxType::Eip4844,
Self::Eip7702(_) => TxType::Eip7702,
#[cfg(feature = "optimism")]
Self::Deposit(deposit_tx) => deposit_tx.tx_type(),
Self::Deposit(_) => TxType::Deposit,
}
}

Expand Down Expand Up @@ -315,7 +315,7 @@ impl Transaction {
Self::Eip7702(TxEip7702 { gas_limit, .. }) => *gas_limit as u64,
Self::Eip2930(TxEip2930 { gas_limit, .. }) => *gas_limit as u64,
#[cfg(feature = "optimism")]
Self::Deposit(TxDeposit { gas_limit, .. }) => *gas_limit,
Self::Deposit(TxDeposit { gas_limit, .. }) => *gas_limit as u64,
}
}

Expand Down Expand Up @@ -569,7 +569,7 @@ impl Transaction {
Self::Eip4844(tx) => tx.gas_limit = gas_limit.into(),
Self::Eip7702(tx) => tx.gas_limit = gas_limit.into(),
#[cfg(feature = "optimism")]
Self::Deposit(tx) => tx.gas_limit = gas_limit,
Self::Deposit(tx) => tx.gas_limit = gas_limit.into(),
}
}

Expand Down Expand Up @@ -1243,7 +1243,10 @@ impl TransactionSigned {
true,
),
#[cfg(feature = "optimism")]
Transaction::Deposit(deposit_tx) => deposit_tx.payload_len(),
Transaction::Deposit(deposit_tx) => deposit_tx.encoded_len_with_signature(
&self.signature.as_signature_with_boolean_parity(),
true,
),
}
}

Expand Down Expand Up @@ -1370,7 +1373,7 @@ impl TransactionSigned {
TxType::Eip4844 => Transaction::Eip4844(TxEip4844::decode_fields(data)?),
TxType::Eip7702 => Transaction::Eip7702(TxEip7702::decode_fields(data)?),
#[cfg(feature = "optimism")]
TxType::Deposit => Transaction::Deposit(TxDeposit::decode_inner(data)?),
TxType::Deposit => Transaction::Deposit(TxDeposit::decode_fields(data)?),
TxType::Legacy => return Err(RlpError::Custom("unexpected legacy tx type")),
};

Expand Down
Loading

0 comments on commit 88e7135

Please sign in to comment.