Skip to content

Commit 97ce8c3

Browse files
authored
chore(anvil): use op-alloy types (#9047)
1 parent d847e0f commit 97ce8c3

File tree

8 files changed

+112
-448
lines changed

8 files changed

+112
-448
lines changed

Cargo.lock

Lines changed: 75 additions & 151 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,9 @@ alloy-chains = "0.1"
219219
alloy-rlp = "0.3"
220220
alloy-trie = "0.6.0"
221221

222-
## op-alloy for tests in anvil
223-
op-alloy-rpc-types = "0.2.9"
222+
## op-alloy
223+
op-alloy-rpc-types = "0.3.3"
224+
op-alloy-consensus = "0.3.3"
224225

225226
## misc
226227
async-trait = "0.1"
@@ -278,7 +279,7 @@ soldeer-commands = "=0.4.0"
278279
proptest = "1"
279280
comfy-table = "7"
280281

281-
# [patch.crates-io]
282+
[patch.crates-io]
282283
## alloy-core
283284
# alloy-dyn-abi = { path = "../../alloy-rs/core/crates/dyn-abi" }
284285
# alloy-json-abi = { path = "../../alloy-rs/core/crates/json-abi" }

crates/anvil/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ alloy-transport.workspace = true
6767
alloy-chains.workspace = true
6868
alloy-genesis.workspace = true
6969
alloy-trie.workspace = true
70+
op-alloy-consensus.workspace = true
7071

7172
# axum related
7273
axum.workspace = true
@@ -121,8 +122,10 @@ alloy-pubsub.workspace = true
121122
foundry-test-utils.workspace = true
122123
similar-asserts.workspace = true
123124
tokio = { workspace = true, features = ["full"] }
125+
124126
op-alloy-rpc-types.workspace = true
125127

128+
126129
[features]
127130
default = ["cli", "jemalloc"]
128131
cmd = ["clap", "clap_complete", "ctrlc", "anvil-server/clap"]

crates/anvil/core/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ alloy-eips.workspace = true
3030
alloy-consensus = { workspace = true, features = ["k256", "kzg"] }
3131
alloy-dyn-abi = { workspace = true, features = ["std", "eip712"] }
3232
alloy-trie.workspace = true
33+
op-alloy-consensus.workspace = true
3334

3435
serde = { workspace = true, optional = true }
3536
serde_json.workspace = true

crates/anvil/core/src/eth/transaction/mod.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Transaction related types
22
3-
use crate::eth::transaction::optimism::{DepositTransaction, DepositTransactionRequest};
3+
use crate::eth::transaction::optimism::DepositTransaction;
44
use alloy_consensus::{
55
transaction::{
66
eip4844::{TxEip4844, TxEip4844Variant, TxEip4844WithSidecar},
@@ -21,6 +21,7 @@ use alloy_rpc_types::{
2121
use alloy_serde::{OtherFields, WithOtherFields};
2222
use bytes::BufMut;
2323
use foundry_evm::traces::CallTraceNode;
24+
use op_alloy_consensus::TxDeposit;
2425
use revm::{
2526
interpreter::InstructionResult,
2627
primitives::{OptimismFields, TxEnv},
@@ -59,14 +60,16 @@ pub fn transaction_request_to_typed(
5960

6061
// Special case: OP-stack deposit tx
6162
if transaction_type == Some(0x7E) || has_optimism_fields(&other) {
62-
return Some(TypedTransactionRequest::Deposit(DepositTransactionRequest {
63+
let mint = other.get_deserialized::<U256>("mint")?.map(|m| m.to::<u128>()).ok()?;
64+
65+
return Some(TypedTransactionRequest::Deposit(TxDeposit {
6366
from: from.unwrap_or_default(),
6467
source_hash: other.get_deserialized::<B256>("sourceHash")?.ok()?,
65-
kind: to.unwrap_or_default(),
66-
mint: other.get_deserialized::<U256>("mint")?.ok()?,
68+
to: to.unwrap_or_default(),
69+
mint: Some(mint),
6770
value: value.unwrap_or_default(),
6871
gas_limit: gas.unwrap_or_default(),
69-
is_system_tx: other.get_deserialized::<bool>("isSystemTx")?.ok()?,
72+
is_system_transaction: other.get_deserialized::<bool>("isSystemTx")?.ok()?,
7073
input: input.into_input().unwrap_or_default(),
7174
}));
7275
}
@@ -165,7 +168,7 @@ pub enum TypedTransactionRequest {
165168
EIP2930(TxEip2930),
166169
EIP1559(TxEip1559),
167170
EIP4844(TxEip4844Variant),
168-
Deposit(DepositTransactionRequest),
171+
Deposit(TxDeposit),
169172
}
170173

171174
/// A wrapper for [TypedTransaction] that allows impersonating accounts.

0 commit comments

Comments
 (0)