Skip to content
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
1,185 changes: 603 additions & 582 deletions Cargo.lock

Large diffs are not rendered by default.

73 changes: 36 additions & 37 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -202,65 +202,64 @@ foundry-strategy-zksync = { path = "crates/strategy/zksync" }
# solc & compilation utilities
foundry-block-explorers = { version = "0.11.0", default-features = false }
foundry-compilers = { version = "0.13.3", default-features = false }
foundry-fork-db = "0.11.1"
foundry-fork-db = "0.12"
solang-parser = "=0.3.3"
solar-parse = { version = "=0.1.1", default-features = false }

## revm
revm = { version = "19.4.0", default-features = false }
revm-primitives = { version = "15.1.0", default-features = false }
revm-inspectors = { version = "0.15.0", features = ["serde"] }
revm-inspectors = { version = "0.16.0", features = ["serde"] }

## alloy
alloy-consensus = { version = "0.11.1", default-features = false }
alloy-contract = { version = "0.11.1", default-features = false }
alloy-eips = { version = "0.11.1", default-features = false }
alloy-genesis = { version = "0.11.1", default-features = false }
alloy-json-rpc = { version = "0.11.1", default-features = false }
alloy-network = { version = "0.11.1", default-features = false }
alloy-provider = { version = "0.11.1", default-features = false }
alloy-pubsub = { version = "0.11.1", default-features = false }
alloy-rpc-client = { version = "0.11.1", default-features = false }
alloy-rpc-types = { version = "0.11.1", default-features = true }
alloy-serde = { version = "0.11.1", default-features = false }
alloy-signer = { version = "0.11.1", default-features = false }
alloy-signer-aws = { version = "0.11.1", default-features = false }
alloy-signer-gcp = { version = "0.11.1", default-features = false }
alloy-signer-ledger = { version = "0.11.1", default-features = false }
alloy-signer-local = { version = "0.11.1", default-features = false }
alloy-signer-trezor = { version = "0.11.1", default-features = false }
alloy-transport = { version = "0.11.1", default-features = false }
alloy-transport-http = { version = "0.11.1", default-features = false }
alloy-transport-ipc = { version = "0.11.1", default-features = false }
alloy-transport-ws = { version = "0.11.1", default-features = false }
alloy-node-bindings = { version = "0.11.1", default-features = false }
alloy-network-primitives = { version = "0.11.1", default-features = false }
## Note(zk): alloy-zksync 0.12.1 is not compatible with latest alloy-consensus, this should be taken care of in the future release of alloy-zksync
alloy-consensus = { version = "=0.12.1", default-features = false }
alloy-contract = { version = "0.12.1", default-features = false }
alloy-eips = { version = "0.12.1", default-features = false }
alloy-genesis = { version = "0.12.1", default-features = false }
alloy-json-rpc = { version = "0.12.1", default-features = false }
alloy-network = { version = "0.12.1", default-features = false }
alloy-provider = { version = "0.12.1", default-features = false }
alloy-pubsub = { version = "0.12.1", default-features = false }
alloy-rpc-client = { version = "0.12.1", default-features = false }
alloy-rpc-types = { version = "0.12.1", default-features = true }
alloy-serde = { version = "0.12.1", default-features = false }
alloy-signer = { version = "0.12.1", default-features = false }
alloy-signer-aws = { version = "0.12.1", default-features = false }
alloy-signer-gcp = { version = "0.12.1", default-features = false }
alloy-signer-ledger = { version = "0.12.1", default-features = false }
alloy-signer-local = { version = "0.12.1", default-features = false }
alloy-signer-trezor = { version = "0.12.1", default-features = false }
alloy-transport = { version = "0.12.1", default-features = false }
alloy-transport-http = { version = "0.12.1", default-features = false }
alloy-transport-ipc = { version = "0.12.1", default-features = false }
alloy-transport-ws = { version = "0.12.1", default-features = false }
alloy-node-bindings = { version = "0.12.1", default-features = false }
alloy-network-primitives = { version = "0.12.1", default-features = false }

## alloy-core
alloy-dyn-abi = "0.8.18"
alloy-json-abi = "0.8.18"
alloy-primitives = { version = "0.8.18", features = [
alloy-dyn-abi = "0.8.22"
alloy-json-abi = "0.8.22"
alloy-primitives = { version = "0.8.22", features = [
"getrandom",
"rand",
"map-fxhash",
"map-foldhash",
] }
alloy-sol-macro-expander = "0.8.18"
alloy-sol-macro-input = "0.8.18"
alloy-sol-types = "0.8.18"
syn-solidity = "0.8.18"
alloy-sol-macro-expander = "0.8.22"
alloy-sol-macro-input = "0.8.22"
alloy-sol-types = "0.8.22"
syn-solidity = "0.8.22"

alloy-chains = "0.1"
alloy-rlp = "0.3"
alloy-zksync = "0.11.0"
alloy-zksync = "0.12.1"

alloy-trie = "0.7.0"

## op-alloy
## Note(zk): Foundry upstream change to maili-consensus but we need to keep
Comment thread
Jrigada marked this conversation as resolved.
## it for zksync for now until era-solc updates the pinned version of serde
op-alloy-consensus = "0.10.0"
op-alloy-rpc-types = "0.10.0"
op-alloy-consensus = "0.11.0"
op-alloy-rpc-types = "0.11.0"

## cli
anstream = "0.6"
Expand Down
38 changes: 24 additions & 14 deletions crates/anvil/core/src/eth/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::eth::transaction::optimism::DepositTransaction;
use alloy_consensus::{
transaction::{
eip4844::{TxEip4844, TxEip4844Variant, TxEip4844WithSidecar},
TxEip7702,
Recovered, TxEip7702,
},
Receipt, ReceiptEnvelope, ReceiptWithBloom, Signed, TxEip1559, TxEip2930, TxEnvelope, TxLegacy,
TxReceipt, Typed2718,
Expand Down Expand Up @@ -285,9 +285,11 @@ pub fn to_alloy_transaction_with_hash_and_sender(
block_hash: None,
block_number: None,
transaction_index: None,
from,
effective_gas_price: None,
inner: TxEnvelope::Legacy(Signed::new_unchecked(tx, sig, hash)),
inner: Recovered::new_unchecked(
TxEnvelope::Legacy(Signed::new_unchecked(tx, sig, hash)),
from,
),
}
}
TypedTransaction::EIP2930(t) => {
Expand All @@ -296,9 +298,11 @@ pub fn to_alloy_transaction_with_hash_and_sender(
block_hash: None,
block_number: None,
transaction_index: None,
from,
effective_gas_price: None,
inner: TxEnvelope::Eip2930(Signed::new_unchecked(tx, sig, hash)),
inner: Recovered::new_unchecked(
TxEnvelope::Eip2930(Signed::new_unchecked(tx, sig, hash)),
from,
),
}
}
TypedTransaction::EIP1559(t) => {
Expand All @@ -307,9 +311,11 @@ pub fn to_alloy_transaction_with_hash_and_sender(
block_hash: None,
block_number: None,
transaction_index: None,
from,
effective_gas_price: None,
inner: TxEnvelope::Eip1559(Signed::new_unchecked(tx, sig, hash)),
inner: Recovered::new_unchecked(
TxEnvelope::Eip1559(Signed::new_unchecked(tx, sig, hash)),
from,
),
}
}
TypedTransaction::EIP4844(t) => {
Expand All @@ -318,9 +324,11 @@ pub fn to_alloy_transaction_with_hash_and_sender(
block_hash: None,
block_number: None,
transaction_index: None,
from,
effective_gas_price: None,
inner: TxEnvelope::Eip4844(Signed::new_unchecked(tx, sig, hash)),
inner: Recovered::new_unchecked(
TxEnvelope::Eip4844(Signed::new_unchecked(tx, sig, hash)),
from,
),
}
}
TypedTransaction::EIP7702(t) => {
Expand All @@ -329,9 +337,11 @@ pub fn to_alloy_transaction_with_hash_and_sender(
block_hash: None,
block_number: None,
transaction_index: None,
from,
effective_gas_price: None,
inner: TxEnvelope::Eip7702(Signed::new_unchecked(tx, sig, hash)),
inner: Recovered::new_unchecked(
TxEnvelope::Eip7702(Signed::new_unchecked(tx, sig, hash)),
from,
),
}
}
TypedTransaction::Deposit(_t) => {
Expand Down Expand Up @@ -610,9 +620,9 @@ impl TryFrom<AnyRpcTransaction> for TypedTransaction {
type Error = ConversionError;

fn try_from(value: AnyRpcTransaction) -> Result<Self, Self::Error> {
let AnyRpcTransaction { inner, .. } = value;
let from = inner.from;
match inner.inner {
let WithOtherFields { inner, .. } = value.0;
let from = inner.inner.signer();
match inner.inner.into_inner() {
AnyTxEnvelope::Ethereum(tx) => match tx {
TxEnvelope::Legacy(tx) => Ok(Self::Legacy(tx)),
TxEnvelope::Eip2930(tx) => Ok(Self::EIP2930(tx)),
Expand Down
10 changes: 4 additions & 6 deletions crates/anvil/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,7 @@ impl NodeConfig {
};

let block = provider
.get_block(BlockNumberOrTag::Number(fork_block_number).into(), false.into())
.get_block(BlockNumberOrTag::Number(fork_block_number).into())
.await
.wrap_err("failed to get fork block")?;

Expand Down Expand Up @@ -1340,10 +1340,8 @@ async fn derive_block_and_transactions(

// Get the block pertaining to the fork transaction
let transaction_block = provider
.get_block_by_number(
transaction_block_number.into(),
alloy_rpc_types::BlockTransactionsKind::Full,
)
.get_block_by_number(transaction_block_number.into())
.full()
.await?
.ok_or_else(|| eyre::eyre!("failed to get fork block by number"))?;

Expand Down Expand Up @@ -1520,7 +1518,7 @@ async fn find_latest_fork_block<P: Provider<AnyNetwork>>(
// walk back from the head of the chain, but at most 2 blocks, which should be more than enough
// leeway
for _ in 0..2 {
if let Some(block) = provider.get_block(num.into(), false.into()).await? {
if let Some(block) = provider.get_block(num.into()).await? {
if !block.header.hash.is_zero() {
break;
}
Expand Down
22 changes: 16 additions & 6 deletions crates/anvil/src/eth/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ use crate::{
revm::primitives::{BlobExcessGasAndPrice, Output},
ClientFork, LoggingManager, Miner, MiningMode, StorageInfo,
};
use alloy_consensus::{transaction::eip4844::TxEip4844Variant, Account};
use alloy_consensus::{
transaction::{eip4844::TxEip4844Variant, Recovered},
Account,
};
use alloy_dyn_abi::TypedData;
use alloy_eips::eip2718::Encodable2718;
use alloy_network::{
Expand Down Expand Up @@ -1189,17 +1192,20 @@ impl EthApi {
node_info!("eth_getTransactionByHash");
let mut tx = self.pool.get_transaction(hash).map(|pending| {
let from = *pending.sender();
let mut tx = transaction_build(
let tx = transaction_build(
Some(*pending.hash()),
pending.transaction,
None,
None,
Some(self.backend.base_fee()),
);

let WithOtherFields { inner: mut tx, other } = tx.0;
// we set the from field here explicitly to the set sender of the pending transaction,
// in case the transaction is impersonated.
tx.from = from;
tx
tx.inner = Recovered::new_unchecked(tx.inner.into_inner(), from);

AnyRpcTransaction(WithOtherFields { inner: tx, other })
});
if tx.is_none() {
tx = self.backend.transaction_by_hash(hash).await?
Expand Down Expand Up @@ -2388,17 +2394,21 @@ impl EthApi {
let mut content = TxpoolContent::<AnyRpcTransaction>::default();
fn convert(tx: Arc<PoolTransaction>) -> Result<AnyRpcTransaction> {
let from = *tx.pending_transaction.sender();
let mut tx = transaction_build(
let tx = transaction_build(
Some(tx.hash()),
tx.pending_transaction.transaction.clone(),
None,
None,
None,
);

let WithOtherFields { inner: mut tx, other } = tx.0;

// we set the from field here explicitly to the set sender of the pending transaction,
// in case the transaction is impersonated.
tx.from = from;
tx.inner = Recovered::new_unchecked(tx.inner.into_inner(), from);

let tx = AnyRpcTransaction(WithOtherFields { inner: tx, other });

Ok(tx)
}
Expand Down
12 changes: 5 additions & 7 deletions crates/anvil/src/eth/backend/fork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,8 @@ impl ClientFork {
}

let provider = self.provider();
let block = provider
.get_block(block_number, false.into())
.await?
.ok_or(BlockchainError::BlockNotFound)?;
let block =
provider.get_block(block_number).await?.ok_or(BlockchainError::BlockNotFound)?;
let block_hash = block.header.hash;
let timestamp = block.header.timestamp;
let base_fee = block.header.base_fee_per_gas;
Expand Down Expand Up @@ -194,7 +192,7 @@ impl ClientFork {
block: Option<BlockNumber>,
) -> Result<Bytes, TransportError> {
let block = block.unwrap_or(BlockNumber::Latest);
let res = self.provider().call(request).block(block.into()).await?;
let res = self.provider().call(request.clone()).block(block.into()).await?;

Ok(res)
}
Expand All @@ -206,7 +204,7 @@ impl ClientFork {
block: Option<BlockNumber>,
) -> Result<u128, TransportError> {
let block = block.unwrap_or_default();
let res = self.provider().estimate_gas(request).block(block.into()).await?;
let res = self.provider().estimate_gas(request.clone()).block(block.into()).await?;

Ok(res as u128)
}
Expand Down Expand Up @@ -514,7 +512,7 @@ impl ClientFork {
&self,
block_id: impl Into<BlockId>,
) -> Result<Option<AnyRpcBlock>, TransportError> {
if let Some(block) = self.provider().get_block(block_id.into(), true.into()).await? {
if let Some(block) = self.provider().get_block(block_id.into()).full().await? {
let hash = block.header.hash;
let block_number = block.header.number;
let mut storage = self.storage_write();
Expand Down
Loading