pub fn with_custom_system_contracts_and_chain_id(
        chain_id: L2ChainId,
        contracts: Vec<DeployedContract>,
    ) -> Self {
        let system_context_init_log = get_system_context_init_logs(chain_id);

        let state_without_indices: BTreeMap<_, _> = contracts
            .iter()
            .flat_map(|contract| {
                let bytecode_hash = BytecodeHash::for_bytecode(&contract.bytecode).value();

                let deployer_code_key = get_code_key(contract.account_id.address());
                let is_known_code_key = get_known_code_key(&bytecode_hash);

                [
                    StorageLog::new_write_log(deployer_code_key, bytecode_hash),
                    StorageLog::new_write_log(is_known_code_key, H256::from_low_u64_be(1)),
                ]
            })
            .chain(system_context_init_log)
            .filter_map(|log| (log.is_write()).then_some((log.key, log.value)))
            .collect();
        let state: HashMap<_, _> = state_without_indices
            .into_iter()
            .enumerate()
            .map(|(idx, (key, value))| (key.hashed_key(), (value, idx as u64 + 1)))
            .collect();

        let factory_deps = contracts
            .into_iter()
            .map(|contract| {
                (
                    BytecodeHash::for_bytecode(&contract.bytecode).value(),
                    contract.bytecode,
                )
            })
            .collect();

        let last_enum_index_set = state.len() as u64;
        Self {
            state,
            factory_deps,
            last_enum_index_set,
        }
    }
Constructs a storage that contains custom system contracts (provided in a vector).
core/lib/vm_interface/src/storage/in_memory.rs