Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions crates/revmc-cli/src/benches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,14 @@ impl Bench {
}
}

pub fn fixture_from_bytecode(name: &'static str, bytecode: Vec<u8>, spec_id: SpecId) -> Bench {
pub fn fixture_from_bytecode(
name: &'static str,
bytecode: Vec<u8>,
spec_id: SpecId,
gas_limit: u64,
) -> Bench {
let bytecode = revmc::primitives::hex::encode(bytecode);
let gas_limit = format!("0x{gas_limit:x}");
Bench {
name,
fixture_json: Some(Cow::Owned(format!(
Expand All @@ -30,7 +36,7 @@ pub fn fixture_from_bytecode(name: &'static str, bytecode: Vec<u8>, spec_id: Spe
"env": {{
"currentBaseFee": "0x0",
"currentCoinbase": "0x0000000000000000000000000000000000000000",
"currentGasLimit": "0x7fffffffffffffff",
"currentGasLimit": "{gas_limit}",
"currentNumber": "0x1",
"currentTimestamp": "0x1"
}},
Expand All @@ -51,7 +57,7 @@ pub fn fixture_from_bytecode(name: &'static str, bytecode: Vec<u8>, spec_id: Spe
"transaction": [
{{
"data": "0x",
"gasLimit": "0x7fffffffffffffff",
"gasLimit": "{gas_limit}",
"gasPrice": "0x0",
"nonce": "0x0",
"sender": "0x1111111111111111111111111111111111111111",
Expand Down
9 changes: 7 additions & 2 deletions crates/revmc-cli/src/cmd/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,20 @@ impl RunArgs {
.to_string();
(stem, path.to_path_buf())
};
fixture_from_bytecode(name.leak(), read_code_path(&bytecode_path)?, spec_id)
fixture_from_bytecode(
name.leak(),
read_code_path(&bytecode_path)?,
spec_id,
self.gas_limit,
)
} else {
let bytecode = read_code_string(bench_name.trim().as_bytes(), None).map_err(|e| {
eyre!(
"{bench_name:?} is not a known benchmark, an existing path, \
or valid EVM hex/asm: {e}"
)
})?;
fixture_from_bytecode("custom", bytecode, spec_id)
fixture_from_bytecode("custom", bytecode, spec_id, self.gas_limit)
};

let name = bench_entry.name;
Expand Down