Skip to content

Commit 763bbd3

Browse files
authored
fix: Cap gas limit by balance in gas_params (#1192)
* zksync: cap gas limit by balance in gas_params; drop debug logs * chore: update anvil-zksync repository URL and bump release tag to v0.6.10 in workflows * chore: update zksync-telemetry repository URL from nbaztec to matter-labs * chore: add RUSTSEC-2025-0098 to deny list for unmaintained unic-ucd-version * chore: add RUSTSEC-2025-0104 to deny list for unmaintained unic-ucd-segment * chore: update deny list with new RUSTSEC advisories for unmaintained unic crates * fix(cli): update function names and improve logging in main.rs for test passing * Debug * bring back change after debug * Fix tests * Rust format * fix(tests): remove ignore flag from osaka_can_run_p256_precompile test and update emit parameters * Format
1 parent b9f3efc commit 763bbd3

File tree

8 files changed

+49
-43
lines changed

8 files changed

+49
-43
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ jobs:
130130
log: info
131131
logFilePath: anvil_zksync.log
132132
target: x86_64-unknown-linux-gnu
133-
releaseTag: v0.6.1
133+
releaseTag: v0.6.10
134134

135135
- name: Setup Git config
136136
run: |

.github/workflows/zk-aave-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
log: info
3737
logFilePath: anvil_zksync.log
3838
target: x86_64-unknown-linux-gnu
39-
releaseTag: v0.6.1
39+
releaseTag: v0.6.10
4040

4141
- name: Setup Git config
4242
run: |

crates/cast/tests/cli/main.rs

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3402,7 +3402,7 @@ Traces:
34023402
│ ├─ [2553] 0x2Ce6311ddAE708829bc0784C967b7d77D19FD779::balanceOf(0xA12384c5E52fD646E7BC7F6B3b33A605651F566E) [delegatecall]
34033403
│ │ └─ ← [Return] 0x000000000000000000000000000000000000000000000000000000000000f3b9
34043404
│ └─ ← [Return] 0x000000000000000000000000000000000000000000000000000000000000f3b9
3405-
├─ [65442] 0xc2FF493F28e894742b968A7DB5D3F21F0aD80C6c::00000000(00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000a12384c5e52fd646e7bc7f6b3b33a605651f566e000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000000000000000000000000000000000000000060f000000000000000000000000000000000000000000000000000000000000060f0000000000000000000000000000000000000000000000000000000000036cd000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000320000000000000000000000000000000000000000000000000000000000000060f000000000000000000000000000000000000000000000000000000000000060f000000000000000000000000327a25ad5cfe5c4d4339c1a4267d4a83e8c93312000000000000000000000000000000000000000000000000000000000000034000000000000000000000000000000000000000000000000000000000000005a00000000000000000000000000b55b053230e4effb6609de652fca73fd1c2980400000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000221000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006cdd519280ec730727f07aa36550bde31a1d5f3097818f3425c2f083ed33a91f080fa2afac0071f6e1af9a0e9c09b851bf01e68bc8a1c1f89f686c48205762f92500000000000000000000000000000000000000000000000000000000000000244242424242424242424242424242424242424242424242424242424242424242010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000827b226368616c6c656e6765223a224b51704d51446e7841757a726f68522d483878472d5a536b625249702d76515f5f5f4a714259357a655038222c2263726f73734f726967696e223a66616c73652c226f726967696e223a2268747470732f2f6974686163612e78797a222c2274797065223a22776562617574686e2e676574227d0000000000000000000000000000000000000000000000000000000000001bde17b8de18819c9eb86cefc3920ddb5d3d4254de276e3d6e18dd2b399f732b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000)
3405+
├─ [65442] 0xc2FF493F28e894742b968A7DB5D3F21F0aD80C6c::fulfillBasicOrder_efficient_6GL6yc()
34063406
│ ├─ [25070] 0xA12384c5E52fD646E7BC7F6B3b33A605651F566E::unwrapAndValidateSignature(0x290a4c4039f102eceba2147e1fcc46f994a46d1229faf43ffff26a058e7378ff, 0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006cdd519280ec730727f07aa36550bde31a1d5f3097818f3425c2f083ed33a91f080fa2afac0071f6e1af9a0e9c09b851bf01e68bc8a1c1f89f686c48205762f92500000000000000000000000000000000000000000000000000000000000000244242424242424242424242424242424242424242424242424242424242424242010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000827b226368616c6c656e6765223a224b51704d51446e7841757a726f68522d483878472d5a536b625249702d76515f5f5f4a714259357a655038222c2263726f73734f726967696e223a66616c73652c226f726967696e223a2268747470732f2f6974686163612e78797a222c2274797065223a22776562617574686e2e676574227d0000000000000000000000000000000000000000000000000000000000001bde17b8de18819c9eb86cefc3920ddb5d3d4254de276e3d6e18dd2b399f732b00) [staticcall]
34073407
│ │ ├─ [22067] 0x0B55b053230E4EFFb6609de652fCa73Fd1C29804::unwrapAndValidateSignature(0x290a4c4039f102eceba2147e1fcc46f994a46d1229faf43ffff26a058e7378ff, 0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006cdd519280ec730727f07aa36550bde31a1d5f3097818f3425c2f083ed33a91f080fa2afac0071f6e1af9a0e9c09b851bf01e68bc8a1c1f89f686c48205762f92500000000000000000000000000000000000000000000000000000000000000244242424242424242424242424242424242424242424242424242424242424242010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000827b226368616c6c656e6765223a224b51704d51446e7841757a726f68522d483878472d5a536b625249702d76515f5f5f4a714259357a655038222c2263726f73734f726967696e223a66616c73652c226f726967696e223a2268747470732f2f6974686163612e78797a222c2274797065223a22776562617574686e2e676574227d0000000000000000000000000000000000000000000000000000000000001bde17b8de18819c9eb86cefc3920ddb5d3d4254de276e3d6e18dd2b399f732b00) [delegatecall]
34083408
│ │ │ ├─ [2369] 0xc2FF493F28e894742b968A7DB5D3F21F0aD80C6c::pauseFlag() [staticcall]
@@ -3436,7 +3436,7 @@ Traces:
34363436
│ │ ├─ [553] 0x2Ce6311ddAE708829bc0784C967b7d77D19FD779::balanceOf(0x327a25aD5Cfe5c4D4339C1A4267D4a83E8c93312) [delegatecall]
34373437
│ │ │ └─ ← [Return] 0x0000000000000000000000000000000000000000000000000000000000009c9a
34383438
│ │ └─ ← [Return] 0x0000000000000000000000000000000000000000000000000000000000009c9a
3439-
│ ├─ [5675] 0xc2FF493F28e894742b968A7DB5D3F21F0aD80C6c::00000001(00000000000000000000000000000000000000000000000000000000000000001bde17b8de18819c9eb86cefc3920ddb5d3d4254de276e3d6e18dd2b399f732b290a4c4039f102eceba2147e1fcc46f994a46d1229faf43ffff26a058e7378ff0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000a12384c5e52fd646e7bc7f6b3b33a605651f566e000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000000000000000000000000000000000000000060f000000000000000000000000000000000000000000000000000000000000060f0000000000000000000000000000000000000000000000000000000000036cd000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000320000000000000000000000000000000000000000000000000000000000000060f000000000000000000000000000000000000000000000000000000000000060f000000000000000000000000327a25ad5cfe5c4d4339c1a4267d4a83e8c93312000000000000000000000000000000000000000000000000000000000000034000000000000000000000000000000000000000000000000000000000000005a00000000000000000000000000b55b053230e4effb6609de652fca73fd1c2980400000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000221000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006cdd519280ec730727f07aa36550bde31a1d5f3097818f3425c2f083ed33a91f080fa2afac0071f6e1af9a0e9c09b851bf01e68bc8a1c1f89f686c48205762f92500000000000000000000000000000000000000000000000000000000000000244242424242424242424242424242424242424242424242424242424242424242010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000827b226368616c6c656e6765223a224b51704d51446e7841757a726f68522d483878472d5a536b625249702d76515f5f5f4a714259357a655038222c2263726f73734f726967696e223a66616c73652c226f726967696e223a2268747470732f2f6974686163612e78797a222c2274797065223a22776562617574686e2e676574227d0000000000000000000000000000000000000000000000000000000000001bde17b8de18819c9eb86cefc3920ddb5d3d4254de276e3d6e18dd2b399f732b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000)
3439+
│ ├─ [5675] 0xc2FF493F28e894742b968A7DB5D3F21F0aD80C6c::multicallN2M_001Taw5z()
34403440
│ │ ├─ [4148] 0xA12384c5E52fD646E7BC7F6B3b33A605651F566E::execute(0x0100000000007821000100000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000201bde17b8de18819c9eb86cefc3920ddb5d3d4254de276e3d6e18dd2b399f732b)
34413441
│ │ │ ├─ [3693] 0x0B55b053230E4EFFb6609de652fCa73Fd1C29804::execute(0x0100000000007821000100000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000201bde17b8de18819c9eb86cefc3920ddb5d3d4254de276e3d6e18dd2b399f732b) [delegatecall]
34423442
│ │ │ │ ├─ [435] 0xA12384c5E52fD646E7BC7F6B3b33A605651F566E::fallback()
@@ -4035,18 +4035,23 @@ casttest!(cast_mktx_negative_numbers, |_prj, cmd| {
40354035
});
40364036

40374037
// Test cast access-list with negative numbers
4038-
casttest!(cast_access_list_negative_numbers, |_prj, cmd| {
4039-
let rpc = next_rpc_endpoint(NamedChain::Sepolia);
4040-
cmd.args([
4041-
"access-list",
4042-
"0x9999999999999999999999999999999999999999",
4043-
"adjustPosition(int128)",
4044-
"-33333",
4045-
"--rpc-url",
4046-
rpc.as_str(),
4047-
])
4048-
.assert_success();
4049-
});
4038+
// Note(zk): Ignored - this test is also failing in upstream
4039+
casttest!(
4040+
#[ignore]
4041+
cast_access_list_negative_numbers,
4042+
|_prj, cmd| {
4043+
let rpc = next_rpc_endpoint(NamedChain::Sepolia);
4044+
cmd.args([
4045+
"access-list",
4046+
"0x9999999999999999999999999999999999999999",
4047+
"adjustPosition(int128)",
4048+
"-33333",
4049+
"--rpc-url",
4050+
rpc.as_str(),
4051+
])
4052+
.assert_success();
4053+
}
4054+
);
40504055

40514056
// tests that cast call properly applies multiple state diff overrides
40524057
// <https://github.com/foundry-rs/foundry/issues/11551>

crates/forge/tests/cli/cmd.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2984,6 +2984,7 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests)
29842984
});
29852985

29862986
// <https://github.com/foundry-rs/foundry/issues/9300>
2987+
// NOTE(zk): gas values differ slightly from upstream due to fork-specific differences
29872988
forgetest_init!(gas_report_size_for_nested_create, |prj, cmd| {
29882989
prj.add_test(
29892990
"NestedDeployTest.sol",
@@ -3053,7 +3054,7 @@ contract NestedDeploy is Test {
30533054
+============================================================================================+
30543055
| Deployment Cost | Deployment Size | | | | |
30553056
|-------------------------------------------+-----------------+-----+--------+-----+---------|
3056-
| 328949 | 1163 | | | | |
3057+
| 328961 | 1163 | | | | |
30573058
|-------------------------------------------+-----------------+-----+--------+-----+---------|
30583059
| | | | | | |
30593060
|-------------------------------------------+-----------------+-----+--------+-----+---------|
@@ -3108,7 +3109,7 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests)
31083109
{
31093110
"contract": "test/NestedDeployTest.sol:Parent",
31103111
"deployment": {
3111-
"gas": 328949,
3112+
"gas": 328961,
31123113
"size": 1163
31133114
},
31143115
"functions": {

crates/forge/tests/it/invariant.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,7 @@ contract AssumeTest is Test {
762762

763763
// Test too many inputs rejected for `assumePrecompile`/`assumeForgeAddress`.
764764
// <https://github.com/foundry-rs/foundry/issues/9054>
765+
// NOTE(zk): runs and calls values differ from upstream due to gas limit being capped by balance
765766
forgetest_init!(should_revert_with_assume_code, |prj, cmd| {
766767
prj.update_config(|config| {
767768
config.invariant.fail_on_revert = true;
@@ -806,7 +807,7 @@ contract BalanceAssumeTest is Test {
806807

807808
cmd.args(["test", "--mt", "invariant_balance"]).assert_failure().stdout_eq(str![[r#"
808809
...
809-
[FAIL: `vm.assume` rejected too many inputs (10 allowed)] invariant_balance() (runs: 5, calls: 2500, reverts: 0)
810+
[FAIL: `vm.assume` rejected too many inputs (10 allowed)] invariant_balance() (runs: 2, calls: 1000, reverts: 0)
810811
...
811812
"#]]);
812813
});

crates/zksync/core/src/vm/inspect.rs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use zksync_types::{
4646
use zksync_vm_interface::storage::{ReadStorage, StoragePtr, WriteStorage};
4747

4848
use crate::{
49-
DEFAULT_PROTOCOL_VERSION, MAX_L2_GAS_LIMIT,
49+
DEFAULT_PROTOCOL_VERSION,
5050
convert::{ConvertAddress, ConvertH160, ConvertH256, ConvertRU256},
5151
fix_l2_gas_limit, fix_l2_gas_price, increment_tx_nonce, is_system_address,
5252
state::{FullNonce, new_full_nonce, parse_full_nonce},
@@ -413,27 +413,17 @@ where
413413
let value = ecx.tx.value.to_u256();
414414
let gas_price = U256::from(ecx.tx.gas_price);
415415
let gas_limit = U256::from(ecx.tx.gas_limit);
416-
417-
let dev_mode = gas_price.is_zero();
418-
if !dev_mode {
419-
// return the original gas limit (subject to max tx gas limit in zkEVM) and gas price. If
420-
// not limited, causes not enough funds error in bootloader.
421-
let gas_limit = gas_limit.min(MAX_L2_GAS_LIMIT.into());
422-
return (gas_limit, gas_price);
423-
}
424-
425416
let use_paymaster = !paymaster_params.paymaster.is_zero();
426417
let payer = if use_paymaster {
427418
Address::from_slice(paymaster_params.paymaster.as_bytes())
428419
} else {
429420
caller
430421
};
431422
let balance = ZKVMData::new(ecx).get_balance(payer);
432-
433-
let max_fee_per_gas = fix_l2_gas_price(gas_price);
434-
let gas_limit = fix_l2_gas_limit(gas_limit, max_fee_per_gas, value, balance);
435-
436-
(gas_limit, max_fee_per_gas)
423+
let dev_mode = gas_price.is_zero();
424+
let effective_gas_price = if dev_mode { fix_l2_gas_price(gas_price) } else { gas_price };
425+
let gas_limit = fix_l2_gas_limit(gas_limit, effective_gas_price, value, balance);
426+
(gas_limit, effective_gas_price)
437427
}
438428

439429
#[allow(dead_code)]

deny.toml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,21 @@ ignore = [
1212
"RUSTSEC-2024-0436",
1313
# protobuf in trezor_client
1414
"RUSTSEC-2024-0437",
15-
# https://rustsec.org/advisories/RUSTSEC-2025-0055 logging user input may result in poisoning logs with ANSI escape sequences
16-
"RUSTSEC-2025-0055",
17-
# https://rustsec.org/advisories/RUSTSEC-2025-0021 gitoxide uses SHA-1 hash implementations without any collision detection, leaving it vulnerable to hash collision attacks.
18-
"RUSTSEC-2025-0021",
19-
# https://rustsec.org/advisories/RUSTSEC-2025-0047 Out-of-bounds access in `get_disjoint_mut` due to incorrect bounds check
20-
"RUSTSEC-2025-0047",
15+
# https://rustsec.org/advisories/RUSTSEC-2025-0073 DoS vulnerability on alloy_dyn_abi::TypedData hashing
16+
"RUSTSEC-2025-0073",
17+
# All unic-* crates are unmaintained (from anvil-zksync -> zksync-error -> tera)
18+
# https://rustsec.org/advisories/RUSTSEC-2025-0074 unic-segment
19+
"RUSTSEC-2025-0074",
20+
# https://rustsec.org/advisories/RUSTSEC-2025-0075 unic-char-range
21+
"RUSTSEC-2025-0075",
22+
# https://rustsec.org/advisories/RUSTSEC-2025-0080 unic-common
23+
"RUSTSEC-2025-0080",
24+
# https://rustsec.org/advisories/RUSTSEC-2025-0081 unic-char-property
25+
"RUSTSEC-2025-0081",
26+
# https://rustsec.org/advisories/RUSTSEC-2025-0098 unic-ucd-version
27+
"RUSTSEC-2025-0098",
28+
# https://rustsec.org/advisories/RUSTSEC-2025-0104 unic-ucd-segment
29+
"RUSTSEC-2025-0104",
2130
]
2231

2332
# This section is considered when running `cargo deny check bans`.
@@ -126,8 +135,8 @@ allow-git = [
126135
"https://github.com/alloy-rs/alloy",
127136
"https://github.com/foundry-rs/compilers",
128137
"https://github.com/foundry-rs/foundry-fork-db",
129-
"https://github.com/nbaztec/zksync-telemetry",
130-
"https://github.com/nbaztec/anvil-zksync",
138+
"https://github.com/matter-labs/zksync-telemetry",
139+
"https://github.com/matter-labs/anvil-zksync",
131140
"https://github.com/Romsters/posthog-rs",
132141
"https://github.com/paradigmxyz/revm-inspectors",
133142
"https://github.com/paradigmxyz/solar",

testdata/forge-std-rev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8bbcf6e3f8f62f419e5429a0bd89331c85c37824
1+
8e40513d678f392f398620b3ef2b418648b33e89

0 commit comments

Comments
 (0)