From 55e50a312f103461673b9ff620cf2add0a1993e7 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 11 Apr 2024 19:35:53 +0400 Subject: [PATCH] fix: use correct estimator --- Cargo.lock | 45 +++++++++++++------------ Cargo.toml | 44 ++++++++++++------------ crates/forge/tests/cli/script.rs | 58 ++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+), 44 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 28a029aa4844..6471888fd57d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,7 +79,7 @@ dependencies = [ [[package]] name = "alloy-consensus" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-eips", "alloy-primitives", @@ -94,7 +94,7 @@ dependencies = [ [[package]] name = "alloy-contract" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -133,7 +133,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -147,7 +147,7 @@ dependencies = [ [[package]] name = "alloy-genesis" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-primitives", "alloy-serde", @@ -169,18 +169,19 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-primitives", "serde", "serde_json", "thiserror", + "tracing", ] [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-consensus", "alloy-eips", @@ -223,7 +224,7 @@ dependencies = [ [[package]] name = "alloy-provider" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-eips", "alloy-json-rpc", @@ -249,7 +250,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -289,7 +290,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -309,7 +310,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-consensus", "alloy-eips", @@ -327,7 +328,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -339,7 +340,7 @@ dependencies = [ [[package]] name = "alloy-serde" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-primitives", "serde", @@ -349,7 +350,7 @@ dependencies = [ [[package]] name = "alloy-signer" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -364,7 +365,7 @@ dependencies = [ [[package]] name = "alloy-signer-aws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-consensus", "alloy-network", @@ -381,7 +382,7 @@ dependencies = [ [[package]] name = "alloy-signer-ledger" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-consensus", "alloy-network", @@ -398,7 +399,7 @@ dependencies = [ [[package]] name = "alloy-signer-trezor" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-consensus", "alloy-network", @@ -414,7 +415,7 @@ dependencies = [ [[package]] name = "alloy-signer-wallet" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-consensus", "alloy-network", @@ -491,7 +492,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-json-rpc", "base64 0.22.0", @@ -509,7 +510,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -522,7 +523,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -540,7 +541,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -6851,7 +6852,7 @@ dependencies = [ [[package]] name = "revm-inspectors" version = "0.1.0" -source = "git+https://github.com/paradigmxyz/evm-inspectors?rev=21f8f3d#21f8f3d266b05d1084e06f0c5331f2f1f4ed0905" +source = "git+https://github.com/paradigmxyz/evm-inspectors?rev=413b892#413b892dd936d117c52d47ba07d195b09a7f1216" dependencies = [ "alloy-primitives", "alloy-rpc-types", diff --git a/Cargo.toml b/Cargo.toml index 93a4f245509e..82e29e6f248d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -144,7 +144,7 @@ foundry-compilers = { version = "0.3.14", default-features = false } # no default features to avoid c-kzg revm = { version = "8", default-features = false } revm-primitives = { version = "3", default-features = false } -revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "21f8f3d", features = [ +revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "413b892", features = [ "serde", ] } @@ -158,27 +158,27 @@ ethers-signers = { version = "2.0.14", default-features = false } ethers-middleware = { version = "2.0.14", default-features = false } ## alloy -alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } +alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } alloy-primitives = { version = "0.7.0", features = ["getrandom"] } alloy-dyn-abi = "0.7.0" alloy-json-abi = "0.7.0" diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 8af676efd0dd..e56ae08ef51e 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -1231,3 +1231,61 @@ contract CustomErrorScript is Script { cmd.arg("script").arg(script).args(["--tc", "CustomErrorScript"]); assert!(cmd.stderr_lossy().contains("script failed: CustomError()")); }); + +// https://github.com/foundry-rs/foundry/issues/7620 +forgetest_async!(can_run_zero_base_fee, |prj, cmd| { + foundry_test_utils::util::initialize(prj.root()); + prj.add_script( + "Foo", + r#" +import "forge-std/Script.sol"; + +contract SimpleScript is Script { + function run() external { + vm.startBroadcast(); + address(0).call(""); + } +} + "#, + ) + .unwrap(); + + let node_config = NodeConfig::test().with_base_fee(Some(0)); + let (_api, handle) = spawn(node_config).await; + let dev = handle.dev_accounts().next().unwrap(); + + // Firstly run script with non-zero gas prices to ensure that eth_feeHistory contains non-zero + // values. + cmd.args([ + "script", + "SimpleScript", + "--fork-url", + &handle.http_endpoint(), + "--sender", + format!("{dev:?}").as_str(), + "--broadcast", + "--unlocked", + "--with-gas-price", + "2000000", + "--priority-gas-price", + "100000", + ]); + + let output = cmd.stdout_lossy(); + assert!(output.contains("ONCHAIN EXECUTION COMPLETE & SUCCESSFUL")); + + // Ensure that we can correctly estimate gas when base fee is zero but priority fee is not. + cmd.forge_fuse().args([ + "script", + "SimpleScript", + "--fork-url", + &handle.http_endpoint(), + "--sender", + format!("{dev:?}").as_str(), + "--broadcast", + "--unlocked", + ]); + + let output = cmd.stdout_lossy(); + assert!(output.contains("ONCHAIN EXECUTION COMPLETE & SUCCESSFUL")); +});