From 1e8ceb96d33849f0d1dac2960b7a49abd77d2e9b Mon Sep 17 00:00:00 2001 From: Stanislav Breadless Date: Mon, 22 Apr 2024 22:06:34 +0200 Subject: [PATCH 1/5] add test for migration --- contracts | 2 +- .../src/versions/vm_latest/tests/migration.rs | 44 +++++++++++++++++++ .../src/versions/vm_latest/tests/mod.rs | 1 + 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 core/lib/multivm/src/versions/vm_latest/tests/migration.rs diff --git a/contracts b/contracts index 06d4311dda56..4c791976dc3c 160000 --- a/contracts +++ b/contracts @@ -1 +1 @@ -Subproject commit 06d4311dda56d0b0b7284bb045b2c80fa9b8f0aa +Subproject commit 4c791976dc3ca133784ee5253b9418e3f299f809 diff --git a/core/lib/multivm/src/versions/vm_latest/tests/migration.rs b/core/lib/multivm/src/versions/vm_latest/tests/migration.rs new file mode 100644 index 000000000000..fe12c2e1cf3f --- /dev/null +++ b/core/lib/multivm/src/versions/vm_latest/tests/migration.rs @@ -0,0 +1,44 @@ +use zksync_types::{get_code_key, H256, SYSTEM_CONTEXT_ADDRESS}; + +use crate::{ + interface::{TxExecutionMode, VmExecutionMode, VmInterface}, + vm_latest::{ + tests::{ + tester::{get_empty_storage, DeployContractsTx, TxType, VmTesterBuilder}, + utils::read_test_contract, + }, + HistoryEnabled, + }, +}; + +#[test] +fn test_migration_for_system_context_aa_interaction() { + let mut storage = get_empty_storage(); + // We will set the system context bytecode to zero. + storage.set_value(get_code_key(&SYSTEM_CONTEXT_ADDRESS), H256::zero()); + + // In this test, we aim to test whether a simple account interaction (without any fee logic) + // will work. The account will try to deploy a simple contract from integration tests. + let mut vm = VmTesterBuilder::new(HistoryEnabled) + .with_storage(storage) + .with_execution_mode(TxExecutionMode::VerifyExecute) + .with_random_rich_accounts(1) + .build(); + + // Now, we will just proceed with standard transaction execution. + // The bootloader should be able to update system context regardless of whether + // the upgrade transaction is there or not. + let account = &mut vm.rich_accounts[0]; + let counter = read_test_contract(); + let DeployContractsTx { tx, .. } = account.get_deploy_tx(&counter, None, TxType::L2); + + vm.vm.push_transaction(tx); + let result = vm.vm.execute(VmExecutionMode::OneTx); + assert!(!result.result.is_failed(), "Transaction wasn't successful"); + + let batch_result = vm.vm.execute(VmExecutionMode::Batch); + assert!( + !batch_result.result.is_failed(), + "Batch transaction wasn't successful" + ); +} diff --git a/core/lib/multivm/src/versions/vm_latest/tests/mod.rs b/core/lib/multivm/src/versions/vm_latest/tests/mod.rs index d416e2107b85..409b67ce9e06 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/mod.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/mod.rs @@ -12,6 +12,7 @@ mod get_used_contracts; mod is_write_initial; mod l1_tx_execution; mod l2_blocks; +mod migration; mod nonce_holder; mod precompiles; mod prestate_tracer; From 0603e8b95f7f0073821fc7f944a93a0253903f1a Mon Sep 17 00:00:00 2001 From: Stanislav Breadless Date: Tue, 23 Apr 2024 10:15:38 +0200 Subject: [PATCH 2/5] fixed hash --- contracts | 2 +- etc/env/base/chain.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts b/contracts index 4c791976dc3c..c20d5d644d5e 160000 --- a/contracts +++ b/contracts @@ -1 +1 @@ -Subproject commit 4c791976dc3ca133784ee5253b9418e3f299f809 +Subproject commit c20d5d644d5e14ab81bca7a0b1e908072701f80e diff --git a/etc/env/base/chain.toml b/etc/env/base/chain.toml index 998e91faf5e1..9161015a627c 100644 --- a/etc/env/base/chain.toml +++ b/etc/env/base/chain.toml @@ -90,7 +90,7 @@ fee_model_version = "V1" validation_computational_gas_limit = 300000 save_call_traces = true -bootloader_hash = "0x010008c5683b01d785f46d7a4237432c3898b0a2c421d362a0729e2ccaa1c076" +bootloader_hash = "0x010008e7a98d718e09d563f96d42c7dc0e10ec767cf2d4bfa652fc3707190d19" default_aa_hash = "0x01000563dc93ec6220498801ccef18c8e667fe26b7fdd9fb9a8d8e01796144ff" [chain.operations_manager] From 9d6659d68fcde49087c93eadb4ecf54fb1e84ec5 Mon Sep 17 00:00:00 2001 From: Stanislav Breadless Date: Tue, 23 Apr 2024 10:35:44 +0200 Subject: [PATCH 3/5] use dev branch for contracts + address comments --- contracts | 2 +- .../multivm/src/versions/vm_latest/tests/migration.rs | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/contracts b/contracts index c20d5d644d5e..9cf72821dc08 160000 --- a/contracts +++ b/contracts @@ -1 +1 @@ -Subproject commit c20d5d644d5e14ab81bca7a0b1e908072701f80e +Subproject commit 9cf72821dc08cd0304964ea822ff95de930f8b6e diff --git a/core/lib/multivm/src/versions/vm_latest/tests/migration.rs b/core/lib/multivm/src/versions/vm_latest/tests/migration.rs index fe12c2e1cf3f..6bd0e87615ed 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/migration.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/migration.rs @@ -11,6 +11,8 @@ use crate::{ }, }; +/// This test checks that the new bootloader will work fine even if the previous system context contract is not +/// compatible with it, i.e. the bootloader will upgrade it before starting any transaction. #[test] fn test_migration_for_system_context_aa_interaction() { let mut storage = get_empty_storage(); @@ -34,11 +36,16 @@ fn test_migration_for_system_context_aa_interaction() { vm.vm.push_transaction(tx); let result = vm.vm.execute(VmExecutionMode::OneTx); - assert!(!result.result.is_failed(), "Transaction wasn't successful"); + assert!( + !result.result.is_failed(), + "Transaction wasn't successful {:#?}", + result.result + ); let batch_result = vm.vm.execute(VmExecutionMode::Batch); assert!( !batch_result.result.is_failed(), - "Batch transaction wasn't successful" + "Batch transaction wasn't successful {:#?}", + batch_result.result ); } From 7d1fd7b7855afa21208984b1dd393533de3c39a9 Mon Sep 17 00:00:00 2001 From: Stanislav Breadless Date: Tue, 23 Apr 2024 11:44:18 +0200 Subject: [PATCH 4/5] update hash in config --- etc/env/base/chain.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/env/base/chain.toml b/etc/env/base/chain.toml index 9161015a627c..c87b2e14b99b 100644 --- a/etc/env/base/chain.toml +++ b/etc/env/base/chain.toml @@ -90,7 +90,7 @@ fee_model_version = "V1" validation_computational_gas_limit = 300000 save_call_traces = true -bootloader_hash = "0x010008e7a98d718e09d563f96d42c7dc0e10ec767cf2d4bfa652fc3707190d19" +bootloader_hash = "0x010008e7e76ac18ea5e49634399ec7062152c224259c85f4fa88690e5447d2e7" default_aa_hash = "0x01000563dc93ec6220498801ccef18c8e667fe26b7fdd9fb9a8d8e01796144ff" [chain.operations_manager] From 72fb231d2421b7cf3e4085c76803118b8d3ae773 Mon Sep 17 00:00:00 2001 From: Stanislav Breadless Date: Tue, 23 Apr 2024 12:16:25 +0200 Subject: [PATCH 5/5] fix commitment --- etc/env/base/contracts.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/env/base/contracts.toml b/etc/env/base/contracts.toml index 09ac0e52d470..cbf3b104912e 100644 --- a/etc/env/base/contracts.toml +++ b/etc/env/base/contracts.toml @@ -27,7 +27,7 @@ RECURSION_LEAF_LEVEL_VK_HASH = "0x101e08b00193e529145ee09823378ef51a3bc896650406 RECURSION_CIRCUITS_SET_VKS_HASH = "0x18c1639094f58177409186e8c48d9f577c9410901d2f1d486b3e7d6cf553ae4c" GENESIS_TX_HASH = "0xb99ebfea46cbe05a21cd80fe5597d97b204befc52a16303f579c607dc1ac2e2e" GENESIS_ROOT = "0x7fe280b1c2209f4b34a15db4cc74568f59db98d400c8e3f3282163acb74d4b14" -GENESIS_BATCH_COMMITMENT = "0x600c2128b67ebf9b5e7c46a5dca5f47b4805baefe483951c26f7404c0f0f92e3" +GENESIS_BATCH_COMMITMENT = "0x62a99e2685b08bd81eef940a3698ffba6289ec77882d7ac6d5e7bcdbbe6351cd" PRIORITY_TX_MAX_GAS_LIMIT = 72000000 DEPLOY_L2_BRIDGE_COUNTERPART_GAS_LIMIT = 10000000 GENESIS_ROLLUP_LEAF_INDEX = "50"