Skip to content

Commit

Permalink
fix: use correct estimator (#7638)
Browse files Browse the repository at this point in the history
  • Loading branch information
klkvr authored Apr 11, 2024
1 parent 440ec52 commit a622e0f
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 44 deletions.
45 changes: 23 additions & 22 deletions Cargo.lock

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

44 changes: 22 additions & 22 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
] }

Expand All @@ -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"
Expand Down
58 changes: 58 additions & 0 deletions crates/forge/tests/cli/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
});

0 comments on commit a622e0f

Please sign in to comment.