Skip to content

Commit b5e586d

Browse files
Fix division by zero in fee estimation
1 parent f19f4f2 commit b5e586d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

vm/rust/src/execution.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,11 @@ where
386386
if balance > max_fee_without_l2_gas.0.into() {
387387
// Calculate the maximum amount of L2 gas that can be bought with the balance.
388388
let max_l2_gas = (balance - max_fee_without_l2_gas.0)
389-
/ initial_resource_bounds.l2_gas.max_price_per_unit.0;
389+
/ initial_resource_bounds
390+
.l2_gas
391+
.max_price_per_unit
392+
.0
393+
.max(1u64.into());
390394
Ok(u64::try_from(max_l2_gas).unwrap_or(u64::MAX).into())
391395
} else {
392396
// Balance is less than committed L1 gas and L1 data gas, transaction will fail.

0 commit comments

Comments
 (0)