Skip to content

Commit 4561875

Browse files
committed
Merge branch 'master' into fix/cast-abi-strict-args
2 parents 4a6a07d + fbd7b1f commit 4561875

File tree

27 files changed

+693
-351
lines changed

27 files changed

+693
-351
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,8 @@ idna_adapter = "=1.1.0"
401401
# alloy-op-evm = { git = "https://github.com/alloy-rs/evm.git", rev = "7762adc" }
402402

403403
## revm
404-
# revm = { git = "https://github.com/bluealloy/revm.git", rev = "b5808253" }
405-
# op-revm = { git = "https://github.com/bluealloy/revm.git", rev = "b5808253" }
404+
revm = { git = "https://github.com/bluealloy/revm.git", rev = "d9cda3a" }
405+
op-revm = { git = "https://github.com/bluealloy/revm.git", rev = "d9cda3a" }
406406
# revm-inspectors = { git = "https://github.com/paradigmxyz/revm-inspectors.git", rev = "956bc98" }
407407

408408
## foundry

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,4 @@ dprint-check: ## Check formatting with dprint
150150
echo "Installing dprint..."; \
151151
cargo install dprint; \
152152
fi
153-
dprint check
153+
dprint check

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ impl TypedTransaction {
801801
input: t.tx().tx().input.clone(),
802802
nonce: t.tx().tx().nonce,
803803
gas_limit: t.tx().tx().gas_limit,
804-
gas_price: Some(t.tx().tx().max_fee_per_blob_gas),
804+
gas_price: None,
805805
max_fee_per_gas: Some(t.tx().tx().max_fee_per_gas),
806806
max_priority_fee_per_gas: Some(t.tx().tx().max_priority_fee_per_gas),
807807
max_fee_per_blob_gas: Some(t.tx().tx().max_fee_per_blob_gas),
@@ -815,7 +815,7 @@ impl TypedTransaction {
815815
input: t.tx().input.clone(),
816816
nonce: t.tx().nonce,
817817
gas_limit: t.tx().gas_limit,
818-
gas_price: Some(t.tx().max_fee_per_gas),
818+
gas_price: None,
819819
max_fee_per_gas: Some(t.tx().max_fee_per_gas),
820820
max_priority_fee_per_gas: Some(t.tx().max_priority_fee_per_gas),
821821
max_fee_per_blob_gas: None,

crates/anvil/src/eth/backend/mem/inspector.rs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use revm::{
1919
interpreter::EthInterpreter,
2020
},
2121
};
22+
use revm_inspectors::transfer::TransferInspector;
2223
use std::sync::Arc;
2324

2425
/// The [`revm::Inspector`] used when transacting in the evm
@@ -28,6 +29,8 @@ pub struct AnvilInspector {
2829
pub tracer: Option<TracingInspector>,
2930
/// Collects all `console.sol` logs
3031
pub log_collector: Option<LogCollector>,
32+
/// Collects all internal ETH transfers as ERC20 transfer events.
33+
pub transfer: Option<TransferInspector>,
3134
}
3235

3336
impl AnvilInspector {
@@ -79,6 +82,12 @@ impl AnvilInspector {
7982
self
8083
}
8184

85+
/// Configures the `Tracer` [`revm::Inspector`] with a transfer event collector
86+
pub fn with_transfers(mut self) -> Self {
87+
self.transfer = Some(TransferInspector::new(false).with_logs(true));
88+
self
89+
}
90+
8291
/// Configures the `Tracer` [`revm::Inspector`] with a trace printer
8392
pub fn with_trace_printer(mut self) -> Self {
8493
self.tracer = Some(TracingInspector::new(TracingInspectorConfig::all().with_state_diffs()));
@@ -139,7 +148,7 @@ where
139148
fn call(&mut self, ecx: &mut CTX, inputs: &mut CallInputs) -> Option<CallOutcome> {
140149
call_inspectors!(
141150
#[ret]
142-
[&mut self.tracer, &mut self.log_collector],
151+
[&mut self.tracer, &mut self.log_collector, &mut self.transfer],
143152
|inspector| inspector.call(ecx, inputs).map(Some),
144153
);
145154
None
@@ -152,11 +161,11 @@ where
152161
}
153162

154163
fn create(&mut self, ecx: &mut CTX, inputs: &mut CreateInputs) -> Option<CreateOutcome> {
155-
if let Some(tracer) = &mut self.tracer
156-
&& let Some(out) = tracer.create(ecx, inputs)
157-
{
158-
return Some(out);
159-
}
164+
call_inspectors!(
165+
#[ret]
166+
[&mut self.tracer, &mut self.transfer],
167+
|inspector| inspector.create(ecx, inputs).map(Some),
168+
);
160169
None
161170
}
162171

@@ -168,9 +177,9 @@ where
168177

169178
#[inline]
170179
fn selfdestruct(&mut self, contract: Address, target: Address, value: U256) {
171-
if let Some(tracer) = &mut self.tracer {
172-
<TracingInspector as Inspector<CTX>>::selfdestruct(tracer, contract, target, value);
173-
}
180+
call_inspectors!([&mut self.tracer, &mut self.transfer], |inspector| {
181+
Inspector::<CTX, EthInterpreter>::selfdestruct(inspector, contract, target, value)
182+
});
174183
}
175184
}
176185

crates/anvil/src/eth/backend/mem/mod.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ use revm::{
118118
primitives::{KECCAK_EMPTY, hardfork::SpecId},
119119
state::AccountInfo,
120120
};
121-
use revm_inspectors::transfer::TransferInspector;
122121
use std::{
123122
collections::BTreeMap,
124123
fmt::Debug,
@@ -1693,11 +1692,13 @@ impl Backend {
16931692
env.evm_env.block_env.basefee = 0;
16941693
}
16951694

1695+
let mut inspector = self.build_inspector();
1696+
16961697
// transact
16971698
let ResultAndState { result, state } = if trace_transfers {
16981699
// prepare inspector to capture transfer inside the evm so they are
16991700
// recorded and included in logs
1700-
let mut inspector = TransferInspector::new(false).with_logs(true);
1701+
inspector = inspector.with_transfers();
17011702
let mut evm= self.new_evm_with_inspector_ref(
17021703
&cache_db as &dyn DatabaseRef,
17031704
&env,
@@ -1707,7 +1708,6 @@ impl Backend {
17071708
trace!(target: "backend", env=?env.evm_env, spec=?env.evm_env.spec_id(),"simulate evm env");
17081709
evm.transact(env.tx)?
17091710
} else {
1710-
let mut inspector = self.build_inspector();
17111711
let mut evm = self.new_evm_with_inspector_ref(
17121712
&cache_db as &dyn DatabaseRef,
17131713
&env,
@@ -1718,6 +1718,11 @@ impl Backend {
17181718
};
17191719
trace!(target: "backend", ?result, ?request, "simulate call");
17201720

1721+
inspector.print_logs();
1722+
if self.print_traces {
1723+
inspector.into_print_traces(self.call_trace_decoder.clone());
1724+
}
1725+
17211726
// commit the transaction
17221727
cache_db.commit(state);
17231728
gas_used += result.gas_used();

crates/cast/src/cmd/access_list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub struct AccessListArgs {
2727
sig: Option<String>,
2828

2929
/// The arguments of the function to call.
30-
#[arg(value_name = "ARGS")]
30+
#[arg(value_name = "ARGS", allow_negative_numbers = true)]
3131
args: Vec<String>,
3232

3333
/// The block height to query at.

crates/cast/src/cmd/call.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ use foundry_evm::{
3030
opts::EvmOpts,
3131
traces::{InternalTraceMode, TraceMode},
3232
};
33+
use itertools::Either;
3334
use regex::Regex;
3435
use revm::context::TransactionType;
3536
use std::{str::FromStr, sync::LazyLock};
@@ -72,6 +73,7 @@ pub struct CallArgs {
7273
sig: Option<String>,
7374

7475
/// The arguments of the function to call.
76+
#[arg(allow_negative_numbers = true)]
7577
args: Vec<String>,
7678

7779
/// Raw hex-encoded data for the transaction. Used instead of \[SIG\] and \[ARGS\].
@@ -177,6 +179,7 @@ pub enum CallSubcommands {
177179
sig: Option<String>,
178180

179181
/// The arguments of the constructor.
182+
#[arg(allow_negative_numbers = true)]
180183
args: Vec<String>,
181184

182185
/// Ether to send in the transaction.
@@ -309,6 +312,12 @@ impl CallArgs {
309312
}
310313
}
311314

315+
if let Some(auth) = tx.inner.authorization_list {
316+
env_tx.authorization_list = auth.into_iter().map(Either::Left).collect();
317+
318+
env_tx.tx_type = TransactionType::Eip7702 as u8;
319+
}
320+
312321
let trace = match tx_kind {
313322
TxKind::Create => {
314323
let deploy_result = executor.deploy(from, input, value, None);
@@ -643,4 +652,21 @@ mod tests {
643652
Some(vec!["0x123:0x1:0x1234".to_string(), "0x456:0x2:0x5678".to_string()])
644653
);
645654
}
655+
656+
#[test]
657+
fn test_negative_args_with_flags() {
658+
// Test that negative args work with flags
659+
let args = CallArgs::parse_from([
660+
"foundry-cli",
661+
"--trace",
662+
"0xDeaDBeeFcAfEbAbEfAcEfEeDcBaDbEeFcAfEbAbE",
663+
"process(int256)",
664+
"-999999",
665+
"--debug",
666+
]);
667+
668+
assert!(args.trace);
669+
assert!(args.debug);
670+
assert_eq!(args.args, vec!["-999999"]);
671+
}
646672
}

crates/cast/src/cmd/estimate.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub struct EstimateArgs {
2222
sig: Option<String>,
2323

2424
/// The arguments of the function to call.
25+
#[arg(allow_negative_numbers = true)]
2526
args: Vec<String>,
2627

2728
/// The block height to query at.
@@ -58,6 +59,7 @@ pub enum EstimateSubcommands {
5859
sig: Option<String>,
5960

6061
/// Constructor arguments
62+
#[arg(allow_negative_numbers = true)]
6163
args: Vec<String>,
6264

6365
/// Ether to send in the transaction

crates/cast/src/cmd/mktx.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub struct MakeTxArgs {
2525
sig: Option<String>,
2626

2727
/// The arguments of the function to call.
28+
#[arg(allow_negative_numbers = true)]
2829
args: Vec<String>,
2930

3031
#[command(subcommand)]
@@ -69,6 +70,7 @@ pub enum MakeTxSubcommands {
6970
sig: Option<String>,
7071

7172
/// The constructor arguments.
73+
#[arg(allow_negative_numbers = true)]
7274
args: Vec<String>,
7375
},
7476
}

0 commit comments

Comments
 (0)