Skip to content

Commit

Permalink
Merge branch 'master' into issue-2846
Browse files Browse the repository at this point in the history
  • Loading branch information
grandizzy committed Dec 2, 2024
2 parents 1536119 + b7a065f commit 422aa9e
Show file tree
Hide file tree
Showing 42 changed files with 959 additions and 697 deletions.
225 changes: 141 additions & 84 deletions Cargo.lock

Large diffs are not rendered by default.

66 changes: 33 additions & 33 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -170,63 +170,63 @@ foundry-linking = { path = "crates/linking" }
# solc & compilation utilities
foundry-block-explorers = { version = "0.9.0", default-features = false }
foundry-compilers = { version = "0.12.3", default-features = false }
foundry-fork-db = "0.7.0"
foundry-fork-db = "0.8.0"
solang-parser = "=0.3.3"
solar-ast = { version = "=0.1.0", default-features = false }
solar-parse = { version = "=0.1.0", default-features = false }

## revm
revm = { version = "18.0.0", default-features = false }
revm-primitives = { version = "14.0.0", default-features = false }
revm-inspectors = { version = "0.11.0", features = ["serde"] }
revm-inspectors = { version = "0.12.0", features = ["serde"] }

## ethers
ethers-contract-abigen = { version = "2.0.14", default-features = false }

## alloy
alloy-consensus = { version = "0.6.4", default-features = false }
alloy-contract = { version = "0.6.4", default-features = false }
alloy-eips = { version = "0.6.4", default-features = false }
alloy-genesis = { version = "0.6.4", default-features = false }
alloy-json-rpc = { version = "0.6.4", default-features = false }
alloy-network = { version = "0.6.4", default-features = false }
alloy-provider = { version = "0.6.4", default-features = false }
alloy-pubsub = { version = "0.6.4", default-features = false }
alloy-rpc-client = { version = "0.6.4", default-features = false }
alloy-rpc-types = { version = "0.6.4", default-features = true }
alloy-serde = { version = "0.6.4", default-features = false }
alloy-signer = { version = "0.6.4", default-features = false }
alloy-signer-aws = { version = "0.6.4", default-features = false }
alloy-signer-gcp = { version = "0.6.4", default-features = false }
alloy-signer-ledger = { version = "0.6.4", default-features = false }
alloy-signer-local = { version = "0.6.4", default-features = false }
alloy-signer-trezor = { version = "0.6.4", default-features = false }
alloy-transport = { version = "0.6.4", default-features = false }
alloy-transport-http = { version = "0.6.4", default-features = false }
alloy-transport-ipc = { version = "0.6.4", default-features = false }
alloy-transport-ws = { version = "0.6.4", default-features = false }
alloy-node-bindings = { version = "0.6.4", default-features = false }
alloy-consensus = { version = "0.7.0", default-features = false }
alloy-contract = { version = "0.7.0", default-features = false }
alloy-eips = { version = "0.7.0", default-features = false }
alloy-genesis = { version = "0.7.0", default-features = false }
alloy-json-rpc = { version = "0.7.0", default-features = false }
alloy-network = { version = "0.7.0", default-features = false }
alloy-provider = { version = "0.7.0", default-features = false }
alloy-pubsub = { version = "0.7.0", default-features = false }
alloy-rpc-client = { version = "0.7.0", default-features = false }
alloy-rpc-types = { version = "0.7.0", default-features = true }
alloy-serde = { version = "0.7.0", default-features = false }
alloy-signer = { version = "0.7.0", default-features = false }
alloy-signer-aws = { version = "0.7.0", default-features = false }
alloy-signer-gcp = { version = "0.7.0", default-features = false }
alloy-signer-ledger = { version = "0.7.0", default-features = false }
alloy-signer-local = { version = "0.7.0", default-features = false }
alloy-signer-trezor = { version = "0.7.0", default-features = false }
alloy-transport = { version = "0.7.0", default-features = false }
alloy-transport-http = { version = "0.7.0", default-features = false }
alloy-transport-ipc = { version = "0.7.0", default-features = false }
alloy-transport-ws = { version = "0.7.0", default-features = false }
alloy-node-bindings = { version = "0.7.0", default-features = false }

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

alloy-chains = "0.1"
alloy-rlp = "0.3"
alloy-trie = "0.6.0"

## op-alloy
op-alloy-rpc-types = "0.6.5"
op-alloy-consensus = "0.6.5"
op-alloy-rpc-types = "0.7.1"
op-alloy-consensus = "0.7.1"

## cli
anstream = "0.6"
Expand Down
5 changes: 5 additions & 0 deletions crates/anvil/core/src/eth/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ impl Block {
nonce: partial_header.nonce,
base_fee_per_gas: partial_header.base_fee,
requests_hash: partial_header.requests_hash,
target_blobs_per_block: None,
},
transactions,
ommers: vec![],
Expand Down Expand Up @@ -157,6 +158,7 @@ mod tests {
parent_beacon_block_root: Default::default(),
base_fee_per_gas: None,
requests_hash: None,
target_blobs_per_block: None,
};

let encoded = alloy_rlp::encode(&header);
Expand Down Expand Up @@ -198,6 +200,7 @@ mod tests {
nonce: B64::ZERO,
base_fee_per_gas: None,
requests_hash: None,
target_blobs_per_block: None,
};

header.encode(&mut data);
Expand Down Expand Up @@ -231,6 +234,7 @@ mod tests {
parent_beacon_block_root: None,
base_fee_per_gas: None,
requests_hash: None,
target_blobs_per_block: None,
};
let header = Header::decode(&mut data.as_slice()).unwrap();
assert_eq!(header, expected);
Expand Down Expand Up @@ -263,6 +267,7 @@ mod tests {
excess_blob_gas: None,
parent_beacon_block_root: None,
requests_hash: None,
target_blobs_per_block: None,
};
assert_eq!(header.hash_slow(), expected_hash);
}
Expand Down
28 changes: 14 additions & 14 deletions crates/anvil/core/src/eth/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ use alloy_consensus::{
eip4844::{TxEip4844, TxEip4844Variant, TxEip4844WithSidecar},
TxEip7702,
},
AnyReceiptEnvelope, Receipt, ReceiptEnvelope, ReceiptWithBloom, Signed, Transaction, TxEip1559,
TxEip2930, TxEnvelope, TxLegacy, TxReceipt,
Receipt, ReceiptEnvelope, ReceiptWithBloom, Signed, Transaction, TxEip1559, TxEip2930,
TxEnvelope, TxLegacy, TxReceipt,
};
use alloy_eips::eip2718::{Decodable2718, Eip2718Error, Encodable2718};
use alloy_network::{AnyRpcTransaction, AnyTxEnvelope};
use alloy_network::{AnyReceiptEnvelope, AnyRpcTransaction, AnyTransactionReceipt, AnyTxEnvelope};
use alloy_primitives::{
Address, Bloom, Bytes, Log, PrimitiveSignature, TxHash, TxKind, B256, U256, U64,
};
use alloy_rlp::{length_of_length, Decodable, Encodable, Header};
use alloy_rpc_types::{
request::TransactionRequest, trace::otterscan::OtsReceipt, AccessList, AnyTransactionReceipt,
ConversionError, Transaction as RpcTransaction, TransactionReceipt,
request::TransactionRequest, trace::otterscan::OtsReceipt, AccessList, ConversionError,
Transaction as RpcTransaction, TransactionReceipt,
};
use alloy_serde::{OtherFields, WithOtherFields};
use bytes::BufMut;
Expand Down Expand Up @@ -1109,7 +1109,7 @@ pub struct TransactionInfo {

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct DepositReceipt<T = alloy_primitives::Log> {
pub struct DepositReceipt<T = Receipt<alloy_primitives::Log>> {
#[serde(flatten)]
pub inner: ReceiptWithBloom<T>,
#[serde(default, with = "alloy_serde::quantity::opt")]
Expand All @@ -1136,7 +1136,7 @@ impl DepositReceipt {
/// Encodes the receipt data.
fn encode_fields(&self, out: &mut dyn BufMut) {
self.receipt_rlp_header().encode(out);
self.inner.receipt.status.encode(out);
self.inner.status().encode(out);
self.inner.receipt.cumulative_gas_used.encode(out);
self.inner.logs_bloom.encode(out);
self.inner.receipt.logs.encode(out);
Expand All @@ -1161,7 +1161,7 @@ impl DepositReceipt {
let status = Decodable::decode(b)?;
let cumulative_gas_used = Decodable::decode(b)?;
let logs_bloom = Decodable::decode(b)?;
let logs = Decodable::decode(b)?;
let logs: Vec<Log> = Decodable::decode(b)?;
let deposit_nonce = remaining(b).then(|| alloy_rlp::Decodable::decode(b)).transpose()?;
let deposit_nonce_version =
remaining(b).then(|| alloy_rlp::Decodable::decode(b)).transpose()?;
Expand Down Expand Up @@ -1207,7 +1207,7 @@ impl alloy_rlp::Decodable for DepositReceipt {

#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(tag = "type")]
pub enum TypedReceipt<T = alloy_primitives::Log> {
pub enum TypedReceipt<T = Receipt<alloy_primitives::Log>> {
#[serde(rename = "0x0", alias = "0x00")]
Legacy(ReceiptWithBloom<T>),
#[serde(rename = "0x1", alias = "0x01")]
Expand Down Expand Up @@ -1248,8 +1248,8 @@ impl<T> From<TypedReceipt<T>> for ReceiptWithBloom<T> {
}
}

impl From<TypedReceipt<alloy_rpc_types::Log>> for OtsReceipt {
fn from(value: TypedReceipt<alloy_rpc_types::Log>) -> Self {
impl From<TypedReceipt<Receipt<alloy_rpc_types::Log>>> for OtsReceipt {
fn from(value: TypedReceipt<Receipt<alloy_rpc_types::Log>>) -> Self {
let r#type = match value {
TypedReceipt::Legacy(_) => 0x00,
TypedReceipt::EIP2930(_) => 0x01,
Expand All @@ -1258,7 +1258,7 @@ impl From<TypedReceipt<alloy_rpc_types::Log>> for OtsReceipt {
TypedReceipt::EIP7702(_) => 0x04,
TypedReceipt::Deposit(_) => 0x7E,
} as u8;
let receipt = ReceiptWithBloom::<alloy_rpc_types::Log>::from(value);
let receipt = ReceiptWithBloom::<Receipt<alloy_rpc_types::Log>>::from(value);
let status = receipt.status();
let cumulative_gas_used = receipt.cumulative_gas_used() as u64;
let logs = receipt.logs().to_vec();
Expand All @@ -1282,7 +1282,7 @@ impl TypedReceipt {
}
}

impl From<ReceiptEnvelope<alloy_rpc_types::Log>> for TypedReceipt<alloy_rpc_types::Log> {
impl From<ReceiptEnvelope<alloy_rpc_types::Log>> for TypedReceipt<Receipt<alloy_rpc_types::Log>> {
fn from(value: ReceiptEnvelope<alloy_rpc_types::Log>) -> Self {
match value {
ReceiptEnvelope::Legacy(r) => Self::Legacy(r),
Expand Down Expand Up @@ -1439,7 +1439,7 @@ impl Decodable2718 for TypedReceipt {
}
}

pub type ReceiptResponse = TransactionReceipt<TypedReceipt<alloy_rpc_types::Log>>;
pub type ReceiptResponse = TransactionReceipt<TypedReceipt<Receipt<alloy_rpc_types::Log>>>;

pub fn convert_to_anvil_receipt(receipt: AnyTransactionReceipt) -> Option<ReceiptResponse> {
let WithOtherFields {
Expand Down
32 changes: 13 additions & 19 deletions crates/anvil/src/eth/backend/mem/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,15 +555,12 @@ impl MinedTransaction {
}
GethDebugBuiltInTracerType::CallTracer => {
return match tracer_config.into_call_config() {
Ok(call_config) => Ok(GethTraceBuilder::new(
self.info.traces.clone(),
TracingInspectorConfig::from_geth_config(&config),
)
.geth_call_traces(
call_config,
self.receipt.cumulative_gas_used() as u64,
)
.into()),
Ok(call_config) => Ok(GethTraceBuilder::new(self.info.traces.clone())
.geth_call_traces(
call_config,
self.receipt.cumulative_gas_used() as u64,
)
.into()),
Err(e) => Err(RpcError::invalid_params(e.to_string()).into()),
};
}
Expand All @@ -579,16 +576,13 @@ impl MinedTransaction {
}

// default structlog tracer
Ok(GethTraceBuilder::new(
self.info.traces.clone(),
TracingInspectorConfig::from_geth_config(&config),
)
.geth_traces(
self.receipt.cumulative_gas_used() as u64,
self.info.out.clone().unwrap_or_default(),
opts.config,
)
.into())
Ok(GethTraceBuilder::new(self.info.traces.clone())
.geth_traces(
self.receipt.cumulative_gas_used() as u64,
self.info.out.clone().unwrap_or_default(),
config,
)
.into())
}
}

Expand Down
1 change: 1 addition & 0 deletions crates/cast/tests/cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ totalDifficulty [..]
blobGasUsed [..]
excessBlobGas [..]
requestsHash [..]
targetBlobsPerBlock [..]
transactions: [
...
]
Expand Down
1 change: 1 addition & 0 deletions crates/cheatcodes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ alloy-signer-local = { workspace = true, features = [
] }
parking_lot.workspace = true
alloy-consensus = { workspace = true, features = ["k256"] }
alloy-network.workspace = true
alloy-rlp.workspace = true

base64.workspace = true
Expand Down
15 changes: 13 additions & 2 deletions crates/cheatcodes/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ impl CheatsConfig {
running_version: Option<Version>,
) -> Self {
let mut allowed_paths = vec![config.root.clone()];
allowed_paths.extend(config.libs.clone());
allowed_paths.extend(config.allow_paths.clone());
allowed_paths.extend(config.libs.iter().cloned());
allowed_paths.extend(config.allow_paths.iter().cloned());

let rpc_endpoints = config.rpc_endpoints.clone().resolved();
trace!(?rpc_endpoints, "using resolved rpc endpoints");
Expand Down Expand Up @@ -101,6 +101,17 @@ impl CheatsConfig {
}
}

/// Returns a new `CheatsConfig` configured with the given `Config` and `EvmOpts`.
pub fn clone_with(&self, config: &Config, evm_opts: EvmOpts) -> Self {
Self::new(
config,
evm_opts,
self.available_artifacts.clone(),
self.running_contract.clone(),
self.running_version.clone(),
)
}

/// Attempts to canonicalize (see [std::fs::canonicalize]) the path.
///
/// Canonicalization fails for non-existing paths, in which case we just normalize the path.
Expand Down
2 changes: 1 addition & 1 deletion crates/cheatcodes/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use super::string::parse;
use crate::{Cheatcode, Cheatcodes, CheatcodesExecutor, CheatsCtxt, Result, Vm::*};
use alloy_dyn_abi::DynSolType;
use alloy_json_abi::ContractObject;
use alloy_network::AnyTransactionReceipt;
use alloy_primitives::{hex, map::Entry, Bytes, U256};
use alloy_provider::network::ReceiptResponse;
use alloy_rpc_types::AnyTransactionReceipt;
use alloy_sol_types::SolValue;
use dialoguer::{Input, Password};
use forge_script_sequence::{BroadcastReader, TransactionWithMetadata};
Expand Down
4 changes: 2 additions & 2 deletions crates/cheatcodes/src/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ pub struct Cheatcodes {
/// Scripting based transactions
pub broadcastable_transactions: BroadcastableTransactions,

/// Additional, user configurable context this Inspector has access to when inspecting a call
/// Additional, user configurable context this Inspector has access to when inspecting a call.
pub config: Arc<CheatsConfig>,

/// Test-scoped context holding data that needs to be reset every test run
Expand Down Expand Up @@ -540,7 +540,7 @@ impl Cheatcodes {

/// Returns the configured wallets if available, else creates a new instance.
pub fn wallets(&mut self) -> &Wallets {
self.wallets.get_or_insert(Wallets::new(MultiWallet::default(), None))
self.wallets.get_or_insert_with(|| Wallets::new(MultiWallet::default(), None))
}

/// Sets the unlocked wallets.
Expand Down
Loading

0 comments on commit 422aa9e

Please sign in to comment.