anvil_zksync_l1_sidecar/zkstack_config/
mod.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
use crate::zkstack_config::contracts::ContractsConfig;
use crate::zkstack_config::genesis::GenesisConfig;
use crate::zkstack_config::wallets::WalletsConfig;
use once_cell::sync::Lazy;
use std::collections::HashMap;
use zksync_types::ProtocolVersionId;

pub mod contracts;
pub mod genesis;
pub mod wallets;

static BUILTIN_ZKSTACK_CONFIGS: Lazy<HashMap<ProtocolVersionId, ZkstackConfig>> = Lazy::new(|| {
    let wallets: WalletsConfig =
        serde_yaml::from_slice(include_bytes!("../../../../l1-setup/wallets.yaml")).unwrap();
    HashMap::from_iter([
        (
            ProtocolVersionId::Version26,
            ZkstackConfig {
                contracts: serde_yaml::from_slice(include_bytes!(
                    "../../../../l1-setup/configs/v26-contracts.yaml"
                ))
                .unwrap(),
                genesis: serde_yaml::from_slice(include_bytes!(
                    "../../../../l1-setup/configs/v26-genesis.yaml"
                ))
                .unwrap(),
                wallets: wallets.clone(),
            },
        ),
        (
            ProtocolVersionId::Version27,
            ZkstackConfig {
                contracts: serde_yaml::from_slice(include_bytes!(
                    "../../../../l1-setup/configs/v27-contracts.yaml"
                ))
                .unwrap(),
                genesis: serde_yaml::from_slice(include_bytes!(
                    "../../../../l1-setup/configs/v27-genesis.yaml"
                ))
                .unwrap(),
                wallets: wallets.clone(),
            },
        ),
        (
            ProtocolVersionId::Version28,
            ZkstackConfig {
                contracts: serde_yaml::from_slice(include_bytes!(
                    "../../../../l1-setup/configs/v28-contracts.yaml"
                ))
                .unwrap(),
                genesis: serde_yaml::from_slice(include_bytes!(
                    "../../../../l1-setup/configs/v28-genesis.yaml"
                ))
                .unwrap(),
                wallets,
            },
        ),
    ])
});

#[derive(Clone, Debug)]
pub struct ZkstackConfig {
    pub contracts: ContractsConfig,
    pub genesis: GenesisConfig,
    pub wallets: WalletsConfig,
}

impl ZkstackConfig {
    pub fn builtin(protocol_version: ProtocolVersionId) -> Self {
        BUILTIN_ZKSTACK_CONFIGS
            .get(&protocol_version)
            .expect("unsupported protocol version")
            .clone()
    }
}