anvil_zksync_l1_sidecar/zkstack_config/
mod.rs1use crate::zkstack_config::contracts::ContractsConfig;
2use crate::zkstack_config::genesis::GenesisConfig;
3use crate::zkstack_config::wallets::WalletsConfig;
4use once_cell::sync::Lazy;
5use std::collections::HashMap;
6use zksync_types::ProtocolVersionId;
7
8pub mod contracts;
9pub mod genesis;
10pub mod wallets;
11
12static BUILTIN_ZKSTACK_CONFIGS: Lazy<HashMap<ProtocolVersionId, ZkstackConfig>> = Lazy::new(|| {
13 let wallets: WalletsConfig =
14 serde_yaml::from_slice(include_bytes!("../../../../l1-setup/wallets.yaml")).unwrap();
15 HashMap::from_iter([
16 (
17 ProtocolVersionId::Version26,
18 ZkstackConfig {
19 contracts: serde_yaml::from_slice(include_bytes!(
20 "../../../../l1-setup/configs/v26-contracts.yaml"
21 ))
22 .unwrap(),
23 genesis: serde_yaml::from_slice(include_bytes!(
24 "../../../../l1-setup/configs/v26-genesis.yaml"
25 ))
26 .unwrap(),
27 wallets: wallets.clone(),
28 },
29 ),
30 (
31 ProtocolVersionId::Version27,
32 ZkstackConfig {
33 contracts: serde_yaml::from_slice(include_bytes!(
34 "../../../../l1-setup/configs/v27-contracts.yaml"
35 ))
36 .unwrap(),
37 genesis: serde_yaml::from_slice(include_bytes!(
38 "../../../../l1-setup/configs/v27-genesis.yaml"
39 ))
40 .unwrap(),
41 wallets: wallets.clone(),
42 },
43 ),
44 (
45 ProtocolVersionId::Version28,
46 ZkstackConfig {
47 contracts: serde_yaml::from_slice(include_bytes!(
48 "../../../../l1-setup/configs/v28-contracts.yaml"
49 ))
50 .unwrap(),
51 genesis: serde_yaml::from_slice(include_bytes!(
52 "../../../../l1-setup/configs/v28-genesis.yaml"
53 ))
54 .unwrap(),
55 wallets,
56 },
57 ),
58 ])
59});
60
61#[derive(Clone, Debug)]
62pub struct ZkstackConfig {
63 pub contracts: ContractsConfig,
64 pub genesis: GenesisConfig,
65 pub wallets: WalletsConfig,
66}
67
68impl ZkstackConfig {
69 pub fn builtin(protocol_version: ProtocolVersionId) -> Self {
70 BUILTIN_ZKSTACK_CONFIGS
71 .get(&protocol_version)
72 .expect("unsupported protocol version")
73 .clone()
74 }
75}