Skip to content

Commit

Permalink
remove more randomness
Browse files Browse the repository at this point in the history
  • Loading branch information
joonazan committed Sep 25, 2024
1 parent 11d6294 commit dd425f9
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 33 deletions.
6 changes: 4 additions & 2 deletions core/lib/multivm/src/versions/testonly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use zksync_test_account::Account;
use zksync_types::{
block::L2BlockHasher, fee_model::BatchFeeInput, get_code_key, get_is_account_key,
utils::storage_key_for_eth_balance, Address, L1BatchNumber, L2BlockNumber, L2ChainId,
ProtocolVersionId, U256,
ProtocolVersionId, H160, U256,
};
use zksync_utils::{bytecode::hash_bytecode, u256_to_h256};

Expand Down Expand Up @@ -34,7 +34,9 @@ pub(super) fn default_l1_batch(number: L1BatchNumber) -> L1BatchEnv {
50_000_000_000, // 50 gwei
250_000_000, // 0.25 gwei
),
fee_account: Address::random(),
fee_account: Address::from(H160::from([
171, 255, 100, 126, 1, 76, 255, 237, 78, 76, 161, 0, 18, 6, 192, 49, 17, 18, 232, 29,
])),
enforced_base_fee: None,
first_l2_block: L2BlockEnv {
number: 1,
Expand Down
5 changes: 2 additions & 3 deletions core/lib/multivm/src/versions/vm_latest/tests/block_tip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@ use zksync_utils::{bytecode::hash_bytecode, bytes_to_be_words, h256_to_u256, u25
use super::utils::{get_complex_upgrade_abi, read_complex_upgrade};
use crate::{
interface::{L1BatchEnv, TxExecutionMode, VmExecutionMode, VmInterface, VmInterfaceExt},
versions::testonly::default_l1_batch,
vm_latest::{
constants::{
BOOTLOADER_BATCH_TIP_CIRCUIT_STATISTICS_OVERHEAD,
BOOTLOADER_BATCH_TIP_METRICS_SIZE_OVERHEAD, BOOTLOADER_BATCH_TIP_OVERHEAD,
MAX_VM_PUBDATA_PER_BATCH,
},
tests::tester::{
default_l1_batch, get_empty_storage, InMemoryStorageView, VmTesterBuilder,
},
tests::tester::{get_empty_storage, InMemoryStorageView, VmTesterBuilder},
tracers::PubdataTracer,
HistoryEnabled, TracerDispatcher,
},
Expand Down
3 changes: 2 additions & 1 deletion core/lib/multivm/src/versions/vm_latest/tests/l2_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ use crate::{
storage::WriteStorage, ExecutionResult, Halt, L2BlockEnv, TxExecutionMode, VmExecutionMode,
VmInterface, VmInterfaceExt,
},
versions::testonly::default_l1_batch,
vm_latest::{
constants::{
BOOTLOADER_HEAP_PAGE, TX_OPERATOR_L2_BLOCK_INFO_OFFSET,
TX_OPERATOR_SLOTS_PER_L2_BLOCK_INFO,
},
tests::tester::{default_l1_batch, VmTesterBuilder},
tests::tester::VmTesterBuilder,
utils::l2_blocks::get_l2_block_hash_key,
HistoryEnabled, Vm,
},
Expand Down
4 changes: 1 addition & 3 deletions core/lib/multivm/src/versions/vm_latest/tests/tester/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
pub(crate) use transaction_test_info::{ExpectedError, TransactionTestInfo, TxModifier};
pub(crate) use vm_tester::{
default_l1_batch, get_empty_storage, InMemoryStorageView, VmTester, VmTesterBuilder,
};
pub(crate) use vm_tester::{get_empty_storage, InMemoryStorageView, VmTester, VmTesterBuilder};
pub(crate) use zksync_test_account::{Account, DeployContractsTx, TxType};

mod inner_state;
Expand Down
34 changes: 10 additions & 24 deletions core/lib/multivm/src/versions/vm_latest/tests/tester/vm_tester.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ use std::marker::PhantomData;
use zksync_contracts::BaseSystemContracts;
use zksync_types::{
block::L2BlockHasher,
fee_model::BatchFeeInput,
get_code_key, get_is_account_key,
utils::{deployed_address_create, storage_key_for_eth_balance},
Address, L1BatchNumber, L2BlockNumber, L2ChainId, Nonce, ProtocolVersionId, U256,
Address, K256PrivateKey, L1BatchNumber, L2BlockNumber, L2ChainId, Nonce, ProtocolVersionId,
H256, U256,
};
use zksync_utils::{bytecode::hash_bytecode, u256_to_h256};

Expand All @@ -16,6 +16,7 @@ use crate::{
L1BatchEnv, L2Block, L2BlockEnv, SystemEnv, TxExecutionMode, VmExecutionMode, VmFactory,
VmInterface, VmInterfaceExt,
},
versions::testonly::default_l1_batch,
vm_latest::{
constants::BATCH_COMPUTATIONAL_GAS_LIMIT,
tests::{
Expand Down Expand Up @@ -205,7 +206,13 @@ impl<H: HistoryMode> VmTesterBuilder<H> {
}

pub(crate) fn with_deployer(mut self) -> Self {
let deployer = Account::random();
let deployer = Account::new(
K256PrivateKey::from_bytes(H256::from([
166, 213, 235, 115, 15, 141, 58, 10, 160, 63, 84, 199, 169, 24, 185, 226, 57, 199,
123, 116, 220, 99, 23, 83, 227, 247, 27, 37, 165, 2, 47, 222,
]))
.unwrap(),
);
self.deployer = Some(deployer);
self
}
Expand Down Expand Up @@ -246,27 +253,6 @@ impl<H: HistoryMode> VmTesterBuilder<H> {
}
}

pub(crate) fn default_l1_batch(number: L1BatchNumber) -> L1BatchEnv {
let timestamp = 0xdeedf00daaaabbbb;
L1BatchEnv {
previous_batch_hash: None,
number,
timestamp,
fee_input: BatchFeeInput::l1_pegged(
50_000_000_000, // 50 gwei
250_000_000, // 0.25 gwei
),
fee_account: Address::random(),
enforced_base_fee: None,
first_l2_block: L2BlockEnv {
number: 1,
timestamp,
prev_block_hash: L2BlockHasher::legacy_hash(L2BlockNumber(0)),
max_virtual_blocks_to_create: 100,
},
}
}

pub(crate) fn make_account_rich(storage: StoragePtr<InMemoryStorageView>, account: &Account) {
let key = storage_key_for_eth_balance(&account.address);
storage
Expand Down

0 comments on commit dd425f9

Please sign in to comment.