Skip to content

Commit 324f866

Browse files
authored
Merge branch 'master' into adding_support_etherscan_v2
2 parents 8c09611 + b75625a commit 324f866

File tree

7 files changed

+147
-6
lines changed

7 files changed

+147
-6
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ env:
1414
CARGO_TERM_COLOR: always
1515
IS_NIGHTLY: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
1616
PROFILE: maxperf
17-
STABLE_VERSION: "v0.3.0"
17+
STABLE_VERSION: "v1.0.0"
1818

1919
jobs:
2020
prepare:

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ build-%:
4444

4545
.PHONY: docker-build-push
4646
docker-build-push: docker-build-prepare ## Build and push a cross-arch Docker image tagged with DOCKER_IMAGE_NAME.
47-
$(MAKE) build-x86_64-unknown-linux-gnu
47+
FEATURES="jemalloc aws-kms cli asm-keccak" $(MAKE) build-x86_64-unknown-linux-gnu
4848
mkdir -p $(BIN_DIR)/amd64
4949
for bin in anvil cast chisel forge; do \
5050
cp $(CARGO_TARGET_DIR)/x86_64-unknown-linux-gnu/$(PROFILE)/$$bin $(BIN_DIR)/amd64/; \
5151
done
5252

53-
$(MAKE) build-aarch64-unknown-linux-gnu
53+
FEATURES="aws-kms cli asm-keccak" $(MAKE) build-aarch64-unknown-linux-gnu
5454
mkdir -p $(BIN_DIR)/arm64
5555
for bin in anvil cast chisel forge; do \
5656
cp $(CARGO_TARGET_DIR)/aarch64-unknown-linux-gnu/$(PROFILE)/$$bin $(BIN_DIR)/arm64/; \

crates/cheatcodes/src/inspector.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use proptest::test_runner::{RngAlgorithm, TestRng, TestRunner};
4646
use rand::Rng;
4747
use revm::{
4848
interpreter::{
49-
opcode as op, CallInputs, CallOutcome, CallScheme, CallValue, CreateInputs, CreateOutcome,
49+
opcode as op, CallInputs, CallOutcome, CallScheme, CreateInputs, CreateOutcome,
5050
EOFCreateInputs, EOFCreateKind, Gas, InstructionResult, Interpreter, InterpreterAction,
5151
InterpreterResult,
5252
},
@@ -1047,8 +1047,6 @@ where {
10471047
if let CallScheme::DelegateCall | CallScheme::ExtDelegateCall = call.scheme {
10481048
call.target_address = prank.new_caller;
10491049
call.caller = prank.new_caller;
1050-
let acc = ecx.journaled_state.account(prank.new_caller);
1051-
call.value = CallValue::Apparent(acc.info.balance);
10521050
if let Some(new_origin) = prank.new_origin {
10531051
ecx.env.tx.caller = new_origin;
10541052
}

crates/evm/core/src/backend/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,14 @@ impl DatabaseExt for Backend {
11021102
// update the shared state and track
11031103
let mut fork = self.inner.take_fork(idx);
11041104

1105+
// Make sure all persistent accounts on the newly selected fork starts from the init
1106+
// state (from setup).
1107+
for addr in &self.inner.persistent_accounts {
1108+
if let Some(account) = self.fork_init_journaled_state.state.get(addr) {
1109+
fork.journaled_state.state.insert(*addr, account.clone());
1110+
}
1111+
}
1112+
11051113
// since all forks handle their state separately, the depth can drift
11061114
// this is a handover where the target fork starts at the same depth where it was
11071115
// selected. This ensures that there are no gaps in depth which would

crates/forge/tests/cli/test_cmd.rs

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3521,3 +3521,82 @@ contract InterceptInitcodeTest is DSTest {
35213521
.unwrap();
35223522
cmd.args(["test", "-vvvvv"]).assert_success();
35233523
});
3524+
3525+
// <https://github.com/foundry-rs/foundry/issues/10296>
3526+
forgetest_init!(should_preserve_fork_state_setup, |prj, cmd| {
3527+
prj.wipe_contracts();
3528+
prj.add_test(
3529+
"Counter.t.sol",
3530+
r#"
3531+
import "forge-std/Test.sol";
3532+
import {StdChains} from "forge-std/StdChains.sol";
3533+
3534+
contract CounterTest is Test {
3535+
struct Domain {
3536+
StdChains.Chain chain;
3537+
uint256 forkId;
3538+
}
3539+
3540+
struct Bridge {
3541+
Domain source;
3542+
Domain destination;
3543+
uint256 someVal;
3544+
}
3545+
3546+
struct SomeStruct {
3547+
Domain domain;
3548+
Bridge[] bridges;
3549+
}
3550+
3551+
mapping(uint256 => SomeStruct) internal data;
3552+
3553+
function setUp() public {
3554+
StdChains.Chain memory chain1 = getChain("mainnet");
3555+
StdChains.Chain memory chain2 = getChain("base");
3556+
Domain memory domain1 = Domain(chain1, vm.createFork(chain1.rpcUrl, 22253716));
3557+
Domain memory domain2 = Domain(chain2, vm.createFork(chain2.rpcUrl, 28839981));
3558+
data[1].domain = domain1;
3559+
data[2].domain = domain2;
3560+
3561+
vm.selectFork(domain1.forkId);
3562+
3563+
data[2].bridges.push(Bridge(domain1, domain2, 123));
3564+
vm.selectFork(data[2].domain.forkId);
3565+
vm.selectFork(data[1].domain.forkId);
3566+
data[2].bridges.push(Bridge(domain1, domain2, 456));
3567+
3568+
assertEq(data[2].bridges.length, 2);
3569+
}
3570+
3571+
function test_assert_storage() public {
3572+
vm.selectFork(data[2].domain.forkId);
3573+
assertEq(data[2].bridges.length, 2);
3574+
}
3575+
3576+
function test_modify_and_storage() public {
3577+
data[3].domain = Domain(getChain("base"), vm.createFork(getChain("base").rpcUrl, 28839981));
3578+
data[3].bridges.push(Bridge(data[1].domain, data[2].domain, 123));
3579+
data[3].bridges.push(Bridge(data[1].domain, data[2].domain, 456));
3580+
3581+
vm.selectFork(data[2].domain.forkId);
3582+
assertEq(data[3].bridges.length, 2);
3583+
}
3584+
}
3585+
"#,
3586+
)
3587+
.unwrap();
3588+
3589+
cmd.args(["test", "--mc", "CounterTest"]).assert_success().stdout_eq(str![[r#"
3590+
[COMPILING_FILES] with [SOLC_VERSION]
3591+
[SOLC_VERSION] [ELAPSED]
3592+
Compiler run successful!
3593+
3594+
Ran 2 tests for test/Counter.t.sol:CounterTest
3595+
[PASS] test_assert_storage() ([GAS])
3596+
[PASS] test_modify_and_storage() ([GAS])
3597+
Suite result: ok. 2 passed; 0 failed; 0 skipped; [ELAPSED]
3598+
3599+
Ran 1 test suite [ELAPSED]: 2 tests passed, 0 failed, 0 skipped (2 total tests)
3600+
3601+
"#]]);
3602+
});

crates/forge/tests/it/repros.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,3 +398,6 @@ test_repro!(9643);
398398

399399
// https://github.com/foundry-rs/foundry/issues/7238
400400
test_repro!(7238);
401+
402+
// https://github.com/foundry-rs/foundry/issues/10302
403+
test_repro!(10302);
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// SPDX-License-Identifier: MIT OR Apache-2.0
2+
pragma solidity ^0.8.18;
3+
4+
import "ds-test/test.sol";
5+
import "cheats/Vm.sol";
6+
7+
contract A {
8+
function foo() public pure returns (bool) {
9+
return true;
10+
}
11+
}
12+
13+
contract Issue10302Test is DSTest {
14+
Vm constant vm = Vm(HEVM_ADDRESS);
15+
16+
function testDelegateFails() external {
17+
vm.createSelectFork("sepolia");
18+
A a = new A();
19+
vm.startPrank(0x0fe884546476dDd290eC46318785046ef68a0BA9, true);
20+
(bool success,) = address(a).delegatecall(abi.encodeWithSelector(A.foo.selector));
21+
vm.stopPrank();
22+
require(success, "Delegate call should succeed");
23+
}
24+
25+
function testDelegatePassesWhenBalanceSetToZero() external {
26+
vm.createSelectFork("sepolia");
27+
A a = new A();
28+
vm.startPrank(0x0fe884546476dDd290eC46318785046ef68a0BA9, true);
29+
vm.deal(0x0fe884546476dDd290eC46318785046ef68a0BA9, 0 ether);
30+
(bool success,) = address(a).delegatecall(abi.encodeWithSelector(A.foo.selector));
31+
vm.stopPrank();
32+
require(success, "Delegate call should succeed");
33+
}
34+
35+
function testDelegateCallSucceeds() external {
36+
vm.createSelectFork("sepolia");
37+
A a = new A();
38+
vm.startPrank(0xd363339eE47775888Df411A163c586a8BdEA9dbf, true);
39+
(bool success,) = address(a).delegatecall(abi.encodeWithSelector(A.foo.selector));
40+
vm.stopPrank();
41+
require(success, "Delegate call should succeed");
42+
}
43+
44+
function testDelegateFailsWhenBalanceGtZero() external {
45+
vm.createSelectFork("sepolia");
46+
A a = new A();
47+
vm.startPrank(0xd363339eE47775888Df411A163c586a8BdEA9dbf, true);
48+
vm.deal(0xd363339eE47775888Df411A163c586a8BdEA9dbf, 1 ether);
49+
(bool success,) = address(a).delegatecall(abi.encodeWithSelector(A.foo.selector));
50+
vm.stopPrank();
51+
require(success, "Delegate call should succeed");
52+
}
53+
}

0 commit comments

Comments
 (0)