Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add test for migration #1765

Merged
merged 5 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions core/lib/multivm/src/versions/vm_latest/tests/migration.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
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,
},
};

/// 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() {
StanislavBreadless marked this conversation as resolved.
Show resolved Hide resolved
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 {:#?}",
result.result
);

let batch_result = vm.vm.execute(VmExecutionMode::Batch);
assert!(
!batch_result.result.is_failed(),
"Batch transaction wasn't successful {:#?}",
batch_result.result
);
}
1 change: 1 addition & 0 deletions core/lib/multivm/src/versions/vm_latest/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion etc/env/base/chain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ fee_model_version = "V1"
validation_computational_gas_limit = 300000
save_call_traces = true

bootloader_hash = "0x010008c5683b01d785f46d7a4237432c3898b0a2c421d362a0729e2ccaa1c076"
bootloader_hash = "0x010008e7e76ac18ea5e49634399ec7062152c224259c85f4fa88690e5447d2e7"
default_aa_hash = "0x01000563dc93ec6220498801ccef18c8e667fe26b7fdd9fb9a8d8e01796144ff"

[chain.operations_manager]
Expand Down
2 changes: 1 addition & 1 deletion etc/env/base/contracts.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading