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

chore(anvil): use op-alloy types #9047

Merged
merged 7 commits into from
Oct 9, 2024
Merged
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
226 changes: 75 additions & 151 deletions Cargo.lock

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,9 @@ alloy-chains = "0.1"
alloy-rlp = "0.3"
alloy-trie = "0.6.0"

## op-alloy for tests in anvil
op-alloy-rpc-types = "0.2.9"
## op-alloy
op-alloy-rpc-types = "0.3.3"
op-alloy-consensus = "0.3.3"

## misc
async-trait = "0.1"
Expand Down Expand Up @@ -278,7 +279,7 @@ soldeer-commands = "=0.4.0"
proptest = "1"
comfy-table = "7"

# [patch.crates-io]
[patch.crates-io]
## alloy-core
# alloy-dyn-abi = { path = "../../alloy-rs/core/crates/dyn-abi" }
# alloy-json-abi = { path = "../../alloy-rs/core/crates/json-abi" }
Expand Down
3 changes: 3 additions & 0 deletions crates/anvil/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ alloy-transport.workspace = true
alloy-chains.workspace = true
alloy-genesis.workspace = true
alloy-trie.workspace = true
op-alloy-consensus.workspace = true

# axum related
axum.workspace = true
Expand Down Expand Up @@ -121,8 +122,10 @@ alloy-pubsub.workspace = true
foundry-test-utils.workspace = true
similar-asserts.workspace = true
tokio = { workspace = true, features = ["full"] }

op-alloy-rpc-types.workspace = true


[features]
default = ["cli", "jemalloc"]
cmd = ["clap", "clap_complete", "ctrlc", "anvil-server/clap"]
Expand Down
1 change: 1 addition & 0 deletions crates/anvil/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ alloy-eips.workspace = true
alloy-consensus = { workspace = true, features = ["k256", "kzg"] }
alloy-dyn-abi = { workspace = true, features = ["std", "eip712"] }
alloy-trie.workspace = true
op-alloy-consensus.workspace = true

serde = { workspace = true, optional = true }
serde_json.workspace = true
Expand Down
15 changes: 9 additions & 6 deletions crates/anvil/core/src/eth/transaction/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Transaction related types

use crate::eth::transaction::optimism::{DepositTransaction, DepositTransactionRequest};
use crate::eth::transaction::optimism::DepositTransaction;
use alloy_consensus::{
transaction::{
eip4844::{TxEip4844, TxEip4844Variant, TxEip4844WithSidecar},
Expand All @@ -21,6 +21,7 @@ use alloy_rpc_types::{
use alloy_serde::{OtherFields, WithOtherFields};
use bytes::BufMut;
use foundry_evm::traces::CallTraceNode;
use op_alloy_consensus::TxDeposit;
use revm::{
interpreter::InstructionResult,
primitives::{OptimismFields, TxEnv},
Expand Down Expand Up @@ -59,14 +60,16 @@ pub fn transaction_request_to_typed(

// Special case: OP-stack deposit tx
if transaction_type == Some(0x7E) || has_optimism_fields(&other) {
return Some(TypedTransactionRequest::Deposit(DepositTransactionRequest {
let mint = other.get_deserialized::<U256>("mint")?.map(|m| m.to::<u128>()).ok()?;

return Some(TypedTransactionRequest::Deposit(TxDeposit {
from: from.unwrap_or_default(),
source_hash: other.get_deserialized::<B256>("sourceHash")?.ok()?,
kind: to.unwrap_or_default(),
mint: other.get_deserialized::<U256>("mint")?.ok()?,
to: to.unwrap_or_default(),
mint: Some(mint),
value: value.unwrap_or_default(),
gas_limit: gas.unwrap_or_default(),
is_system_tx: other.get_deserialized::<bool>("isSystemTx")?.ok()?,
is_system_transaction: other.get_deserialized::<bool>("isSystemTx")?.ok()?,
input: input.into_input().unwrap_or_default(),
}));
}
Expand Down Expand Up @@ -165,7 +168,7 @@ pub enum TypedTransactionRequest {
EIP2930(TxEip2930),
EIP1559(TxEip1559),
EIP4844(TxEip4844Variant),
Deposit(DepositTransactionRequest),
Deposit(TxDeposit),
}

/// A wrapper for [TypedTransaction] that allows impersonating accounts.
Expand Down
Loading
Loading