From 23853938d7e16c8e4e5e3c43d6202d28b6f3506d Mon Sep 17 00:00:00 2001 From: Julian Ventura Date: Fri, 16 Aug 2024 18:43:27 -0300 Subject: [PATCH 1/6] Modify sample size and duration on benchmarks --- core/tests/vm-benchmark/benches/criterion.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/tests/vm-benchmark/benches/criterion.rs b/core/tests/vm-benchmark/benches/criterion.rs index a02d6f308b33..7c216e0d453e 100644 --- a/core/tests/vm-benchmark/benches/criterion.rs +++ b/core/tests/vm-benchmark/benches/criterion.rs @@ -7,17 +7,17 @@ use criterion::{ use zksync_types::Transaction; use zksync_vm_benchmark_harness::{ cut_to_allowed_bytecode_size, get_deploy_tx, get_heavy_load_test_tx, get_load_test_deploy_tx, - get_load_test_tx, get_realistic_load_test_tx, BenchmarkingVm, BenchmarkingVmFactory, Fast, Lambda, - Legacy, LoadTestParams, + get_load_test_tx, get_realistic_load_test_tx, BenchmarkingVm, BenchmarkingVmFactory, Fast, + Lambda, Legacy, LoadTestParams, }; -const SAMPLE_SIZE: usize = 20; +const SAMPLE_SIZE: usize = 50; fn benches_in_folder(c: &mut Criterion) { let mut group = c.benchmark_group(VM::LABEL.as_str()); group .sample_size(SAMPLE_SIZE) - .measurement_time(Duration::from_secs(10)); + .measurement_time(Duration::from_secs(12)); for path in std::fs::read_dir("deployment_benchmarks").unwrap() { let path = path.unwrap().path(); @@ -51,7 +51,7 @@ fn bench_load_test(c: &mut Criterion) { let mut group = c.benchmark_group(VM::LABEL.as_str()); group .sample_size(SAMPLE_SIZE) - .measurement_time(Duration::from_secs(10)); + .measurement_time(Duration::from_secs(12)); // Nonce 0 is used for the deployment transaction let tx = get_load_test_tx(1, 10_000_000, LoadTestParams::default()); From 1db2b517d85ba3737c3aec69e3507bab12fdf301 Mon Sep 17 00:00:00 2001 From: Julian Ventura Date: Mon, 19 Aug 2024 11:50:58 -0300 Subject: [PATCH 2/6] Fix Execution instantiation --- core/lib/multivm/src/versions/era_vm/vm.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/core/lib/multivm/src/versions/era_vm/vm.rs b/core/lib/multivm/src/versions/era_vm/vm.rs index 9e02c7b93573..b79ea5ad2173 100644 --- a/core/lib/multivm/src/versions/era_vm/vm.rs +++ b/core/lib/multivm/src/versions/era_vm/vm.rs @@ -92,6 +92,7 @@ impl VmFactory for Vm { .to_fixed_bytes(), vm_hook_position, true, + 10_000_000, //TODO: Maybe we want to pass in a parameter ); let pre_contract_storage = Rc::new(RefCell::new(HashMap::new())); pre_contract_storage.borrow_mut().insert( From a37b2108c31a96f035145aeb035df23fdd19aee0 Mon Sep 17 00:00:00 2001 From: Julian Ventura Date: Mon, 19 Aug 2024 12:40:53 -0300 Subject: [PATCH 3/6] Update era_vm Execution gas initialization --- core/lib/multivm/src/versions/era_vm/vm.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/lib/multivm/src/versions/era_vm/vm.rs b/core/lib/multivm/src/versions/era_vm/vm.rs index b79ea5ad2173..9d1f16cf766e 100644 --- a/core/lib/multivm/src/versions/era_vm/vm.rs +++ b/core/lib/multivm/src/versions/era_vm/vm.rs @@ -92,7 +92,7 @@ impl VmFactory for Vm { .to_fixed_bytes(), vm_hook_position, true, - 10_000_000, //TODO: Maybe we want to pass in a parameter + u32::MAX - 0x80000000, //TODO: Maybe we want to pass in a parameter ); let pre_contract_storage = Rc::new(RefCell::new(HashMap::new())); pre_contract_storage.borrow_mut().insert( From 710a187694f05284af8497a3b6d0f2e2de319423 Mon Sep 17 00:00:00 2001 From: Julian Ventura Date: Mon, 19 Aug 2024 15:33:50 -0300 Subject: [PATCH 4/6] Add new hooks to era_vm --- core/lib/multivm/src/versions/era_vm/hook.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/lib/multivm/src/versions/era_vm/hook.rs b/core/lib/multivm/src/versions/era_vm/hook.rs index 8289331174d2..8d385f94f3e1 100644 --- a/core/lib/multivm/src/versions/era_vm/hook.rs +++ b/core/lib/multivm/src/versions/era_vm/hook.rs @@ -1,15 +1,18 @@ #[derive(Debug)] pub(crate) enum Hook { AccountValidationEntered, + PaymasterValidationEntered, AccountValidationExited, ValidationStepEnded, TxHasEnded, DebugLog, DebugReturnData, + NearCallCatch, AskOperatorForRefund, NotifyAboutRefund, PostResult, FinalBatchInfo, + PubdataRequested, } impl Hook { @@ -18,15 +21,18 @@ impl Hook { pub fn from_u32(hook: u32) -> Self { match hook { 0 => Hook::AccountValidationEntered, + 1 => Hook::PaymasterValidationEntered, 2 => Hook::AccountValidationExited, 3 => Hook::ValidationStepEnded, 4 => Hook::TxHasEnded, 5 => Hook::DebugLog, 6 => Hook::DebugReturnData, + 7 => Hook::NearCallCatch, 8 => Hook::AskOperatorForRefund, 9 => Hook::NotifyAboutRefund, 10 => Hook::PostResult, 11 => Hook::FinalBatchInfo, + 12 => Hook::PubdataRequested, _ => panic!("Unknown hook {}", hook), } } From d48698b3432f41074344c8faa6ae1bcdf19048ad Mon Sep 17 00:00:00 2001 From: Julian Ventura Date: Mon, 19 Aug 2024 15:57:25 -0300 Subject: [PATCH 5/6] Add hooks to vm match --- core/lib/multivm/src/versions/era_vm/vm.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/lib/multivm/src/versions/era_vm/vm.rs b/core/lib/multivm/src/versions/era_vm/vm.rs index 9d1f16cf766e..4ebcb909340f 100644 --- a/core/lib/multivm/src/versions/era_vm/vm.rs +++ b/core/lib/multivm/src/versions/era_vm/vm.rs @@ -189,6 +189,9 @@ impl Vm { Hook::ValidationStepEnded => { // println!("VALIDATION STEP ENDED"); } + Hook::PaymasterValidationEntered => {} + Hook::PubdataRequested => {} + Hook::NearCallCatch => {} Hook::AccountValidationExited => { // println!("ACCOUNT VALIDATION EXITED"); } From 66e8758c7ac87dee1a0a693dbe674d5c2c8d65f3 Mon Sep 17 00:00:00 2001 From: Julian Ventura Date: Mon, 19 Aug 2024 18:46:29 -0300 Subject: [PATCH 6/6] Modify benchmark sample size --- core/tests/vm-benchmark/benches/criterion.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/tests/vm-benchmark/benches/criterion.rs b/core/tests/vm-benchmark/benches/criterion.rs index 7c216e0d453e..88ec7dc6d210 100644 --- a/core/tests/vm-benchmark/benches/criterion.rs +++ b/core/tests/vm-benchmark/benches/criterion.rs @@ -11,7 +11,7 @@ use zksync_vm_benchmark_harness::{ Lambda, Legacy, LoadTestParams, }; -const SAMPLE_SIZE: usize = 50; +const SAMPLE_SIZE: usize = 30; fn benches_in_folder(c: &mut Criterion) { let mut group = c.benchmark_group(VM::LABEL.as_str());