Skip to content

Commit 08d3a4a

Browse files
grandizzyDaniPopeszerosnacks
authored
More v1.3.1 backports (#11256)
* fix(fmt): don't panic on stdin read failure (#11226) * fix(`forge script`): repeated `vm.createSelectFork` with same RPC causes segfault (#11250) --------- Co-authored-by: DaniPopes <[email protected]> Co-authored-by: zerosnacks <[email protected]>
1 parent bcc78eb commit 08d3a4a

File tree

5 files changed

+112
-30
lines changed

5 files changed

+112
-30
lines changed

Cargo.lock

Lines changed: 13 additions & 26 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
@@ -403,8 +403,8 @@ idna_adapter = "=1.1.0"
403403
# alloy-op-evm = { git = "https://github.com/alloy-rs/evm.git", rev = "7762adc" }
404404

405405
## revm
406-
# revm = { git = "https://github.com/bluealloy/revm.git", rev = "b5808253" }
407-
# op-revm = { git = "https://github.com/bluealloy/revm.git", rev = "b5808253" }
406+
revm = { git = "https://github.com/bluealloy/revm.git", rev = "d9cda3a" }
407+
op-revm = { git = "https://github.com/bluealloy/revm.git", rev = "d9cda3a" }
408408
# revm-inspectors = { git = "https://github.com/paradigmxyz/revm-inspectors.git", rev = "956bc98" }
409409

410410
## 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/forge/src/cmd/fmt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl FmtArgs {
7070
}
7171
[one] if one == Path::new("-") => {
7272
let mut s = String::new();
73-
io::stdin().read_to_string(&mut s).expect("Failed to read from stdin");
73+
io::stdin().read_to_string(&mut s).wrap_err("failed to read from stdin")?;
7474
Input::Stdin(s)
7575
}
7676
paths => {

crates/forge/tests/cli/script.rs

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3009,3 +3009,98 @@ ONCHAIN EXECUTION COMPLETE & SUCCESSFUL.
30093009
assert_eq!(receiver2.nonce, 0);
30103010
assert_eq!(receiver2.balance.to_string(), "101000000000000000000");
30113011
});
3012+
3013+
// <https://github.com/foundry-rs/foundry/issues/11213>
3014+
forgetest_async!(call_to_non_contract_address_does_not_panic, |prj, cmd| {
3015+
foundry_test_utils::util::initialize(prj.root());
3016+
3017+
let endpoint = rpc::next_http_archive_rpc_url();
3018+
3019+
prj.add_source(
3020+
"Counter.sol",
3021+
r#"
3022+
contract Counter {
3023+
uint256 public number;
3024+
function setNumber(uint256 newNumber) public {
3025+
number = newNumber;
3026+
}
3027+
function increment() public {
3028+
number++;
3029+
}
3030+
}
3031+
"#,
3032+
)
3033+
.unwrap();
3034+
3035+
let deploy_script = prj
3036+
.add_script(
3037+
"Counter.s.sol",
3038+
&r#"
3039+
import "forge-std/Script.sol";
3040+
import {Counter} from "../src/Counter.sol";
3041+
contract CounterScript is Script {
3042+
Counter public counter;
3043+
function setUp() public {}
3044+
function run() public {
3045+
vm.createSelectFork("<url>");
3046+
vm.startBroadcast();
3047+
counter = new Counter();
3048+
vm.stopBroadcast();
3049+
vm.createSelectFork("<url>");
3050+
vm.startBroadcast();
3051+
counter.increment();
3052+
vm.stopBroadcast();
3053+
}
3054+
}
3055+
"#
3056+
.replace("<url>", &endpoint),
3057+
)
3058+
.unwrap();
3059+
3060+
let (_api, handle) = spawn(NodeConfig::test()).await;
3061+
cmd.args([
3062+
"script",
3063+
&deploy_script.display().to_string(),
3064+
"--root",
3065+
prj.root().to_str().unwrap(),
3066+
"--fork-url",
3067+
&handle.http_endpoint(),
3068+
"--slow",
3069+
"--broadcast",
3070+
"--private-key",
3071+
"ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",
3072+
])
3073+
.assert_failure()
3074+
.stdout_eq(str![[r#"
3075+
[COMPILING_FILES] with [SOLC_VERSION]
3076+
[SOLC_VERSION] [ELAPSED]
3077+
Compiler run successful!
3078+
Traces:
3079+
[..] → new CounterScript@[..]
3080+
└─ ← [Return] 2200 bytes of code
3081+
3082+
[..] CounterScript::setUp()
3083+
└─ ← [Stop]
3084+
3085+
[..] CounterScript::run()
3086+
├─ [..] VM::createSelectFork("<rpc url>")
3087+
│ └─ ← [Return] 1
3088+
├─ [..] VM::startBroadcast()
3089+
│ └─ ← [Return]
3090+
├─ [..] → new Counter@[..]
3091+
│ └─ ← [Return] 481 bytes of code
3092+
├─ [..] VM::stopBroadcast()
3093+
│ └─ ← [Return]
3094+
├─ [..] VM::createSelectFork("<rpc url>")
3095+
│ └─ ← [Return] 2
3096+
├─ [..] VM::startBroadcast()
3097+
│ └─ ← [Return]
3098+
└─ ← [Revert] call to non-contract address [..]
3099+
3100+
3101+
3102+
"#]])
3103+
.stderr_eq(str![[r#"
3104+
Error: script failed: call to non-contract address [..]
3105+
"#]]);
3106+
});

0 commit comments

Comments
 (0)