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

feat(forge): allow --verifier custom option (#9311) #6

Merged
merged 68 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
36cbce7
feat(forge): allow `--verifier custom` option (#9311)
grandizzy Nov 14, 2024
c526cab
feat(`cheatcodes`): add `delegatecall` to `prank`ing (#8863)
tsnewnami Nov 15, 2024
9d7557f
feat(forge build): err if no source file in specified paths (#9329)
grandizzy Nov 15, 2024
a79dfae
feat(`forge build`): add `--sizes` and `--names` JSON compatibility (…
zerosnacks Nov 15, 2024
3eb47ea
chore: fix clippy (#9333)
grandizzy Nov 16, 2024
d14c09f
test: enhance tests (#9334)
mattsse Nov 16, 2024
e649e62
chore(deps): weekly `cargo update` (#9336)
github-actions[bot] Nov 17, 2024
44c86e7
chore: fix getArtifactPath flaky test (#9339)
grandizzy Nov 18, 2024
d275a49
fix(cast storage): respect `--json` for layout (#9332)
MaxMustermann2 Nov 18, 2024
60dd1d7
feat(`config`): set default evm version to cancun (#9131)
grandizzy Nov 18, 2024
550ebd8
chore: update test values to cancun (#9344)
grandizzy Nov 18, 2024
7e323c2
feat(`forge build -vvvvv`): If verbosity level is 5 or higher show fi…
mgiagante Nov 18, 2024
6625e16
chore: add some more debugging to forge bind (#9345)
DaniPopes Nov 18, 2024
547d8a5
feat: compilation restrictions (#8668)
klkvr Nov 18, 2024
c13d42e
fix: identification of contracts in scripts (#9346)
klkvr Nov 18, 2024
dacf341
fix(`coverage`): allow `ir-minimum` for versions < 0.8.5 (#9341)
grandizzy Nov 19, 2024
25b317a
chore: don't color error message in red (#9352)
DaniPopes Nov 19, 2024
19249c3
chore: remove redundant 'setup failed' in setup errors (#9354)
DaniPopes Nov 19, 2024
9b49082
chore: make environment variable error nicer (#9353)
DaniPopes Nov 19, 2024
9f0c26d
test: update external forge-std (#9356)
DaniPopes Nov 19, 2024
7538c4e
chore(ci): archive endpoints config (#9348)
grandizzy Nov 19, 2024
4648d5c
chore: pick provider urls by next index (#9359)
grandizzy Nov 20, 2024
d20c142
fix: correct shell substitution in installer (#9351)
mdqst Nov 20, 2024
e577693
chore: TestSetup cleanup (#9355)
DaniPopes Nov 20, 2024
3a95440
chore(ci): proper read of archive nodes (#9362)
grandizzy Nov 20, 2024
999cc1b
chore(test-utils): simplify next calls (#9361)
DaniPopes Nov 20, 2024
2a194bd
Support EIP-7702 Delegations in Forge (#9236)
evchip Nov 20, 2024
b9ee7de
chore(deps): bump foundry-compilers 0.12.2 (#9364)
DaniPopes Nov 20, 2024
622f922
feat: rename `ShellOtps` to `GlobalOpts` (#9313)
zerosnacks Nov 20, 2024
fb5f0e1
chore(deps): bump foundry-compilers 0.12.3 (#9368)
grandizzy Nov 20, 2024
25cc1ac
chore(deps): bump alloy 0.6.4 (#9280)
yash-atreya Nov 20, 2024
057c8ac
feat(`anvil`): `--cache-path` (#9343)
yash-atreya Nov 21, 2024
9504f78
chore: rm flaky cache-path test (#9372)
yash-atreya Nov 21, 2024
fef2098
feat: add global -j, --threads (#9367)
DaniPopes Nov 21, 2024
41b4359
feat: Update to soldeer 0.5.2 (#9373)
mario-eth Nov 21, 2024
2bc7125
fix: `vm.broadcastRawTransaction` (#9378)
klkvr Nov 22, 2024
76a2cb0
fix(forge test): install missing dependencies before creating `Projec…
klkvr Nov 22, 2024
1332b6d
chore(chisel): replace solang with solar in SolidityHelper (#9376)
DaniPopes Nov 22, 2024
cf66dea
fix(chisel): uint/int full word print (#9381)
grandizzy Nov 22, 2024
37cc284
fix: flaky test_broadcast_raw_create2_deployer (#9383)
yash-atreya Nov 22, 2024
8b7d5df
refactor(forge): rewrite `geiger` with Solar (#9382)
DaniPopes Nov 22, 2024
398ef4a
feat(forge, cast): add `cast --with_local_artifacts`/`forge selectors…
byteshijinn Nov 22, 2024
e5412ad
chore: use has_library_ancestor (#9387)
DaniPopes Nov 23, 2024
d14a7b4
chore(evm/traces): replace solang with Solar (#9386)
DaniPopes Nov 23, 2024
4923529
chore(deps): weekly `cargo update` (#9392)
github-actions[bot] Nov 24, 2024
cca72ab
fix: bail incomplete bytecode sequence disassemble (#9390)
publicqi Nov 25, 2024
66228e4
fix(forge create): install missing deps if any (#9401)
grandizzy Nov 25, 2024
eae5fb4
feat(forge): show additional details of contract to verify (#9403)
grandizzy Nov 25, 2024
de5e89c
fix: remove duplicate `gas_limit` / `block_gas_limit` field, declare …
zerosnacks Nov 25, 2024
672bdf6
fix(cheatcodes): use calldata in attachDelegation (#9407)
grandizzy Nov 25, 2024
995fd9e
chore(cheatcodes): enforce `calldata` in declaration (#9408)
DaniPopes Nov 25, 2024
d739704
feat: remove ethers (#8826)
DaniPopes Nov 26, 2024
958c713
Revert "feat: remove ethers" (#9411)
grandizzy Nov 26, 2024
0045384
fix: forge script should adhere to `--json` flag (#9404)
zerosnacks Nov 26, 2024
31dd1f7
feat(cast): add decode-event sig data (#9413)
grandizzy Nov 26, 2024
735b5eb
chore: fix 404 status URL (#9417)
wangjingcun Nov 27, 2024
2c3114c
feat: add `--broadcast` flag to forge create, default to dry run mode…
zerosnacks Nov 27, 2024
c63aba8
feat(`traces`): show state changes in `cast run` and `forge test` on …
cassc Nov 27, 2024
16a013f
feat(cast): decode external lib sigs from cached selectors (#9399)
grandizzy Nov 28, 2024
56d0dd8
feat: rewrite inline config using figment (#9414)
DaniPopes Nov 28, 2024
20905ef
chore: rename the arg name of EvmOpts from evm_opts to evm_args (#9424)
jsvisa Nov 28, 2024
27cabbd
Fix conditional syntax issue in macOS libusb check (#9384)
voronor Nov 28, 2024
2e9f536
feat: add timeouts to fuzz testing (#9394)
smartcontracts Nov 29, 2024
0d76df5
feat(`cast`): `decode-error` with sig, local cache and openchain api …
grandizzy Nov 29, 2024
0f7268f
feat(`cast`): `decode-event` with local and openchain API (#9431)
grandizzy Nov 29, 2024
fbbcc8c
chore: use alloy-chains' `is_arbitrum` (#9432)
zerosnacks Nov 29, 2024
af0fee2
feat: rpc_headers in cast and config (#9429)
yash-atreya Nov 29, 2024
4527475
fix: set user-agent header in runtime transport (#9434)
yash-atreya Nov 29, 2024
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
416 changes: 228 additions & 188 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion crates/cast/bin/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ where
};

if self.state.to.is_none() && code.is_none() {
let has_value = self.tx.value.map_or(false, |v| !v.is_zero());
let has_value = self.tx.value.is_some_and(|v| !v.is_zero());
let has_auth = self.auth.is_some();
// We only allow user to omit the recipient address if transaction is an EIP-7702 tx
// without a value.
Expand Down
9 changes: 3 additions & 6 deletions crates/cast/tests/cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -650,8 +650,7 @@ casttest!(rpc_with_args, |_prj, cmd| {

// Call `cast rpc eth_getBlockByNumber 0x123 false`
cmd.args(["rpc", "--rpc-url", eth_rpc_url.as_str(), "eth_getBlockByNumber", "0x123", "false"])
.assert_success()
.stdout_eq(str![[r#"
.assert_json_stdout(str![[r#"
{"number":"0x123","hash":"0xc5dab4e189004a1312e9db43a40abb2de91ad7dd25e75880bf36016d8e9df524","transactions":[],"totalDifficulty":"0x4dea420908b","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","extraData":"0x476574682f4c5649562f76312e302e302f6c696e75782f676f312e342e32","nonce":"0x29d6547c196e00e0","miner":"0xbb7b8287f3f0a933474a79eae42cbca977791171","difficulty":"0x494433b31","gasLimit":"0x1388","gasUsed":"0x0","uncles":[],"sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","size":"0x220","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","stateRoot":"0x3fe6bd17aa85376c7d566df97d9f2e536f37f7a87abb3a6f9e2891cf9442f2e4","mixHash":"0x943056aa305aa6d22a3c06110942980342d1f4d4b11c17711961436a0f963ea0","parentHash":"0x7abfd11e862ccde76d6ea8ee20978aac26f4bcb55de1188cc0335be13e817017","timestamp":"0x55ba4564"}

"#]]);
Expand All @@ -670,8 +669,7 @@ casttest!(rpc_raw_params, |_prj, cmd| {
"--raw",
r#"["0x123", false]"#,
])
.assert_success()
.stdout_eq(str![[r#"
.assert_json_stdout(str![[r#"
{"number":"0x123","hash":"0xc5dab4e189004a1312e9db43a40abb2de91ad7dd25e75880bf36016d8e9df524","transactions":[],"totalDifficulty":"0x4dea420908b","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","extraData":"0x476574682f4c5649562f76312e302e302f6c696e75782f676f312e342e32","nonce":"0x29d6547c196e00e0","miner":"0xbb7b8287f3f0a933474a79eae42cbca977791171","difficulty":"0x494433b31","gasLimit":"0x1388","gasUsed":"0x0","uncles":[],"sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","size":"0x220","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","stateRoot":"0x3fe6bd17aa85376c7d566df97d9f2e536f37f7a87abb3a6f9e2891cf9442f2e4","mixHash":"0x943056aa305aa6d22a3c06110942980342d1f4d4b11c17711961436a0f963ea0","parentHash":"0x7abfd11e862ccde76d6ea8ee20978aac26f4bcb55de1188cc0335be13e817017","timestamp":"0x55ba4564"}

"#]]);
Expand All @@ -687,8 +685,7 @@ casttest!(rpc_raw_params_stdin, |_prj, cmd| {
stdin.write_all(b"\n[\n\"0x123\",\nfalse\n]\n").unwrap();
},
)
.assert_success()
.stdout_eq(str![[r#"
.assert_json_stdout(str![[r#"
{"number":"0x123","hash":"0xc5dab4e189004a1312e9db43a40abb2de91ad7dd25e75880bf36016d8e9df524","transactions":[],"totalDifficulty":"0x4dea420908b","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","extraData":"0x476574682f4c5649562f76312e302e302f6c696e75782f676f312e342e32","nonce":"0x29d6547c196e00e0","miner":"0xbb7b8287f3f0a933474a79eae42cbca977791171","difficulty":"0x494433b31","gasLimit":"0x1388","gasUsed":"0x0","uncles":[],"sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","size":"0x220","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","stateRoot":"0x3fe6bd17aa85376c7d566df97d9f2e536f37f7a87abb3a6f9e2891cf9442f2e4","mixHash":"0x943056aa305aa6d22a3c06110942980342d1f4d4b11c17711961436a0f963ea0","parentHash":"0x7abfd11e862ccde76d6ea8ee20978aac26f4bcb55de1188cc0335be13e817017","timestamp":"0x55ba4564"}

"#]]);
Expand Down
80 changes: 80 additions & 0 deletions crates/cheatcodes/assets/cheatcodes.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions crates/cheatcodes/spec/src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,22 @@ interface Vm {
#[cheatcode(group = Evm, safety = Unsafe)]
function startPrank(address msgSender, address txOrigin) external;

/// Sets the *next* delegate call's `msg.sender` to be the input address.
#[cheatcode(group = Evm, safety = Unsafe)]
function prank(address msgSender, bool delegateCall) external;

/// Sets all subsequent delegate calls' `msg.sender` to be the input address until `stopPrank` is called.
#[cheatcode(group = Evm, safety = Unsafe)]
function startPrank(address msgSender, bool delegateCall) external;

/// Sets the *next* delegate call's `msg.sender` to be the input address, and the `tx.origin` to be the second input.
#[cheatcode(group = Evm, safety = Unsafe)]
function prank(address msgSender, address txOrigin, bool delegateCall) external;

/// Sets all subsequent delegate calls' `msg.sender` to be the input address until `stopPrank` is called, and the `tx.origin` to be the second input.
#[cheatcode(group = Evm, safety = Unsafe)]
function startPrank(address msgSender, address txOrigin, bool delegateCall) external;

/// Resets subsequent calls' `msg.sender` to be `address(this)`.
#[cheatcode(group = Evm, safety = Unsafe)]
function stopPrank() external;
Expand Down
58 changes: 53 additions & 5 deletions crates/cheatcodes/src/evm/prank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ pub struct Prank {
pub depth: u64,
/// Whether the prank stops by itself after the next call
pub single_call: bool,
/// Whether the prank should be be applied to delegate call
pub delegate_call: bool,
/// Whether the prank has been used yet (false if unused)
pub used: bool,
}
Expand All @@ -29,8 +31,18 @@ impl Prank {
new_origin: Option<Address>,
depth: u64,
single_call: bool,
delegate_call: bool,
) -> Self {
Self { prank_caller, prank_origin, new_caller, new_origin, depth, single_call, used: false }
Self {
prank_caller,
prank_origin,
new_caller,
new_origin,
depth,
single_call,
delegate_call,
used: false,
}
}

/// Apply the prank by setting `used` to true iff it is false
Expand All @@ -47,28 +59,56 @@ impl Prank {
impl Cheatcode for prank_0Call {
fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result {
let Self { msgSender } = self;
prank(ccx, msgSender, None, true)
prank(ccx, msgSender, None, true, false)
}
}

impl Cheatcode for startPrank_0Call {
fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result {
let Self { msgSender } = self;
prank(ccx, msgSender, None, false)
prank(ccx, msgSender, None, false, false)
}
}

impl Cheatcode for prank_1Call {
fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result {
let Self { msgSender, txOrigin } = self;
prank(ccx, msgSender, Some(txOrigin), true)
prank(ccx, msgSender, Some(txOrigin), true, false)
}
}

impl Cheatcode for startPrank_1Call {
fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result {
let Self { msgSender, txOrigin } = self;
prank(ccx, msgSender, Some(txOrigin), false)
prank(ccx, msgSender, Some(txOrigin), false, false)
}
}

impl Cheatcode for prank_2Call {
fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result {
let Self { msgSender, delegateCall } = self;
prank(ccx, msgSender, None, true, *delegateCall)
}
}

impl Cheatcode for startPrank_2Call {
fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result {
let Self { msgSender, delegateCall } = self;
prank(ccx, msgSender, None, false, *delegateCall)
}
}

impl Cheatcode for prank_3Call {
fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result {
let Self { msgSender, txOrigin, delegateCall } = self;
prank(ccx, msgSender, Some(txOrigin), true, *delegateCall)
}
}

impl Cheatcode for startPrank_3Call {
fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result {
let Self { msgSender, txOrigin, delegateCall } = self;
prank(ccx, msgSender, Some(txOrigin), false, *delegateCall)
}
}

Expand All @@ -85,6 +125,7 @@ fn prank(
new_caller: &Address,
new_origin: Option<&Address>,
single_call: bool,
delegate_call: bool,
) -> Result {
let prank = Prank::new(
ccx.caller,
Expand All @@ -93,8 +134,15 @@ fn prank(
new_origin.copied(),
ccx.ecx.journaled_state.depth(),
single_call,
delegate_call,
);

// Ensure that code exists at `msg.sender` if delegate calling.
if delegate_call {
let code = ccx.code(*new_caller)?;
ensure!(!code.is_empty(), "cannot `prank` delegate call from an EOA");
}

if let Some(Prank { used, single_call: current_single_call, .. }) = ccx.state.prank {
ensure!(used, "cannot overwrite a prank until it is applied at least once");
// This case can only fail if the user calls `vm.startPrank` and then `vm.prank` later on.
Expand Down
15 changes: 14 additions & 1 deletion crates/cheatcodes/src/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use proptest::test_runner::{RngAlgorithm, TestRng, TestRunner};
use rand::Rng;
use revm::{
interpreter::{
opcode as op, CallInputs, CallOutcome, CallScheme, CreateInputs, CreateOutcome,
opcode as op, CallInputs, CallOutcome, CallScheme, CallValue, CreateInputs, CreateOutcome,
EOFCreateInputs, EOFCreateKind, Gas, InstructionResult, Interpreter, InterpreterAction,
InterpreterResult,
},
Expand Down Expand Up @@ -941,6 +941,19 @@ where {

// Apply our prank
if let Some(prank) = &self.prank {
// Apply delegate call, `call.caller`` will not equal `prank.prank_caller`
if let CallScheme::DelegateCall | CallScheme::ExtDelegateCall = call.scheme {
if prank.delegate_call {
call.target_address = prank.new_caller;
call.caller = prank.new_caller;
let acc = ecx.journaled_state.account(prank.new_caller);
call.value = CallValue::Apparent(acc.info.balance);
if let Some(new_origin) = prank.new_origin {
ecx.env.tx.caller = new_origin;
}
}
}

if ecx.journaled_state.depth() >= prank.depth && call.caller == prank.prank_caller {
let mut prank_applied = false;

Expand Down
2 changes: 1 addition & 1 deletion crates/cheatcodes/src/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ mod tests {
match value {
DynSolValue::Tuple(_) | DynSolValue::CustomStruct { .. } => true,
DynSolValue::Array(v) | DynSolValue::FixedArray(v) => {
v.first().map_or(false, contains_tuple)
v.first().is_some_and(contains_tuple)
}
_ => false,
}
Expand Down
2 changes: 1 addition & 1 deletion crates/cheatcodes/src/test/expect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ pub(crate) fn handle_expect_emit(
return false
}
// Maybe match source address.
if event_to_fill_or_check.address.map_or(false, |addr| addr != log.address) {
if event_to_fill_or_check.address.is_some_and(|addr| addr != log.address) {
return false;
}
// Maybe match data.
Expand Down
2 changes: 1 addition & 1 deletion crates/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ num-format.workspace = true
reqwest.workspace = true
semver.workspace = true
serde_json.workspace = true
serde.workspace = true
serde = { workspace = true, features = ["derive"] }
thiserror.workspace = true
tokio.workspace = true
tracing.workspace = true
Expand Down
Loading
Loading