Skip to content

Commit e206db9

Browse files
authored
Fix meta_tx_v0 panic with use of SierraGas (#3851)
<!-- Reference any GitHub issues resolved by this PR --> Closes # ## Introduced changes <!-- A brief description of the changes --> - Fix panic that occur with use of `meta_tx_v0` syscall and `SierraGas` as tracked resources ## Checklist <!-- Make sure all of these are complete --> - [ ] Linked relevant issue - [ ] Updated relevant documentation - [ ] Added relevant tests - [x] Performed self-review of the code - [x] Added changes to `CHANGELOG.md`
1 parent 84c65d9 commit e206db9

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313

1414
- Gas values in fuzzing test output are now displayed as whole numbers without fractional parts
1515

16+
#### Fixed
17+
18+
- A bug that caused `meta_tx_v0` to panic when tracked resources are Sierra gas.
19+
1620
## [0.51.0] - 2025-10-21
1721

1822
### Forge

crates/cheatnet/src/runtime_extensions/common.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,15 @@ pub fn get_syscalls_gas_consumed(
3535
panic!("Failed to get syscall gas cost for selector {selector:?}")
3636
});
3737

38-
// `linear_factor` is relevant only for `deploy` syscall, for other syscalls it is 0
38+
// `linear_factor` is relevant only for `deploy` and `meta_tx_v0` syscalls, for other syscalls it is 0
3939
// `base_syscall_cost` makes an assert that `linear_factor` is 0
4040
// Hence to get base cost for `deploy` we use `get_syscall_cost` with 0 as `linear_length`
4141
// For other syscalls we use `base_syscall_cost`, which is also an additional check that `linear_factor` is always 0 then
42-
let base_cost = if let SyscallSelector::Deploy = selector {
43-
syscall_gas_cost.get_syscall_cost(0)
44-
} else {
45-
syscall_gas_cost.base_syscall_cost()
42+
let base_cost = match selector {
43+
SyscallSelector::Deploy | SyscallSelector::MetaTxV0 => {
44+
syscall_gas_cost.get_syscall_cost(0)
45+
}
46+
_ => syscall_gas_cost.base_syscall_cost(),
4647
};
4748

4849
// We want to calculate `base_cost * call_count + linear_cost * linear_factor`

crates/forge/tests/integration/meta_tx_v0.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ fn meta_tx_v0_with_cheat_block_hash() {
165165
.unwrap()
166166
);
167167

168-
let result = run_test_case(&test, ForgeTrackedResource::CairoSteps);
168+
let result = run_test_case(&test, ForgeTrackedResource::SierraGas);
169169
assert_passed(&result);
170170
}
171171

@@ -236,6 +236,6 @@ fn meta_tx_v0_verify_tx_context_modification() {
236236
.unwrap()
237237
);
238238

239-
let result = run_test_case(&test, ForgeTrackedResource::CairoSteps);
239+
let result = run_test_case(&test, ForgeTrackedResource::SierraGas);
240240
assert_passed(&result);
241241
}

0 commit comments

Comments
 (0)