-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pass down priority and max fee per gas for broadcasting script txs
- Loading branch information
Showing
7 changed files
with
114 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import {Script} from "forge-std/Script.sol"; | ||
import {Greeter} from "src/Greeter.sol"; | ||
|
||
contract GasScript is Script { | ||
function run() public { | ||
vm.startBroadcast(); | ||
Greeter greeter = new Greeter(); | ||
vm.stopBroadcast(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
use foundry_test_utils::{forgetest_async, util, TestProject}; | ||
|
||
use foundry_test_utils::{util::OutputExt, ZkSyncNode}; | ||
|
||
forgetest_async!(script_execution_with_gas_price, |prj, cmd| { | ||
setup_gas_prj(&mut prj); | ||
|
||
let node = ZkSyncNode::start().await; | ||
let url = node.url(); | ||
|
||
cmd.forge_fuse(); | ||
|
||
let private_key = | ||
ZkSyncNode::rich_wallets().next().map(|(_, pk, _)| pk).expect("No rich wallets available"); | ||
|
||
let script_args = vec![ | ||
"--zk-startup", | ||
"./script/Gas.s.sol", | ||
"--private-key", | ||
&private_key, | ||
"--chain", | ||
"260", | ||
"--rpc-url", | ||
url.as_str(), | ||
"--slow", | ||
"--evm-version", | ||
"shanghai", | ||
"-vvvvv", | ||
"--broadcast", | ||
"--with-gas-price", | ||
"370000037", | ||
"--priority-gas-price", | ||
"123123", | ||
]; | ||
|
||
cmd.arg("script").args(&script_args); | ||
|
||
let stdout = cmd.assert_success().get_output().stdout_lossy(); | ||
assert!(stdout.contains("ONCHAIN EXECUTION COMPLETE & SUCCESSFUL")); | ||
|
||
let run_latest = foundry_common::fs::json_files(prj.root().join("broadcast").as_path()) | ||
.find(|file| file.ends_with("run-latest.json")) | ||
.expect("No broadcast artifacts"); | ||
|
||
let json: serde_json::Value = | ||
serde_json::from_str(&foundry_common::fs::read_to_string(run_latest).unwrap()).unwrap(); | ||
|
||
assert_eq!(json["transactions"].as_array().expect("broadcastable txs").len(), 1); | ||
|
||
let transaction_hash = json["receipts"][0]["transactionHash"].as_str().unwrap(); | ||
let stdout = cmd | ||
.cast_fuse() | ||
.arg("tx") | ||
.arg(transaction_hash) | ||
.arg("--rpc-url") | ||
.arg(url.as_str()) | ||
.assert_success() | ||
.get_output() | ||
.stdout_lossy(); | ||
|
||
assert!(stdout.contains("maxFeePerGas 370000037")); | ||
assert!(stdout.contains("maxPriorityFeePerGas 123123")); | ||
}); | ||
|
||
fn setup_gas_prj(prj: &mut TestProject) { | ||
util::initialize(prj.root()); | ||
prj.add_script("Gas.s.sol", include_str!("../../fixtures/zk/Gas.s.sol")).unwrap(); | ||
prj.add_source("Greeter.sol", include_str!("../../../../../testdata/zk/Greeter.sol")).unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ mod factory; | |
mod factory_deps; | ||
mod fork; | ||
mod fuzz; | ||
mod gas; | ||
mod invariant; | ||
mod linking; | ||
mod logs; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters