diff --git a/zk_toolbox/crates/config/src/chain.rs b/zk_toolbox/crates/config/src/chain.rs index 02b72385d2a4..5795f7c22654 100644 --- a/zk_toolbox/crates/config/src/chain.rs +++ b/zk_toolbox/crates/config/src/chain.rs @@ -6,8 +6,6 @@ use std::{ use serde::{Deserialize, Serialize, Serializer}; use types::{BaseToken, ChainId, L1BatchCommitmentMode, L1Network, ProverMode, WalletCreation}; use xshell::Shell; -use zksync_config::configs::GeneralConfig as ZkSyncGeneralConfig; -use zksync_protobuf_config::encode_yaml_repr; use crate::{ consts::{ @@ -16,7 +14,7 @@ use crate::{ }, create_localhost_wallets, traits::{ - FileConfig, FileConfigWithDefaultName, ReadConfig, SaveConfig, SaveConfigWithBasePath, + FileConfigWithDefaultName, ReadConfig, SaveConfig, SaveConfigWithBasePath, ZkToolboxConfig, }, ContractsConfig, GeneralConfig, GenesisConfig, SecretsConfig, WalletsConfig, }; @@ -108,13 +106,8 @@ impl ChainConfig { self.configs.join(SECRETS_FILE) } - pub fn save_general_config(&self, general_config: &ZkSyncGeneralConfig) -> anyhow::Result<()> { - let path = self.configs.join(GENERAL_FILE); - let bytes = encode_yaml_repr::( - general_config, - )?; - self.get_shell().write_file(path, bytes)?; - Ok(()) + pub fn save_general_config(&self, general_config: &GeneralConfig) -> anyhow::Result<()> { + general_config.save_with_base_path(self.get_shell(), &self.configs) } pub fn path_to_foundry(&self) -> PathBuf { @@ -151,4 +144,4 @@ impl FileConfigWithDefaultName for ChainConfigInternal { const FILE_NAME: &'static str = CONFIG_NAME; } -impl FileConfig for ChainConfigInternal {} +impl ZkToolboxConfig for ChainConfigInternal {} diff --git a/zk_toolbox/crates/config/src/contracts.rs b/zk_toolbox/crates/config/src/contracts.rs index 03706d83cd10..0a0b3c22ab5b 100644 --- a/zk_toolbox/crates/config/src/contracts.rs +++ b/zk_toolbox/crates/config/src/contracts.rs @@ -8,7 +8,7 @@ use crate::{ initialize_bridges::output::InitializeBridgeOutput, register_chain::output::RegisterChainOutput, }, - traits::{FileConfig, FileConfigWithDefaultName}, + traits::{FileConfigWithDefaultName, ZkToolboxConfig}, }; #[derive(Debug, Deserialize, Serialize, Clone, Default)] @@ -89,7 +89,7 @@ impl FileConfigWithDefaultName for ContractsConfig { const FILE_NAME: &'static str = CONTRACTS_FILE; } -impl FileConfig for ContractsConfig {} +impl ZkToolboxConfig for ContractsConfig {} #[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)] pub struct EcosystemContracts { @@ -100,7 +100,7 @@ pub struct EcosystemContracts { pub diamond_cut_data: String, } -impl FileConfig for EcosystemContracts {} +impl ZkToolboxConfig for EcosystemContracts {} #[derive(Debug, Serialize, Deserialize, Clone, Default)] pub struct BridgesContracts { diff --git a/zk_toolbox/crates/config/src/ecosystem.rs b/zk_toolbox/crates/config/src/ecosystem.rs index 578a5909ebdf..c4c64cc14183 100644 --- a/zk_toolbox/crates/config/src/ecosystem.rs +++ b/zk_toolbox/crates/config/src/ecosystem.rs @@ -17,7 +17,7 @@ use crate::{ }, create_localhost_wallets, forge_interface::deploy_ecosystem::input::{Erc20DeploymentConfig, InitialDeploymentConfig}, - traits::{FileConfig, FileConfigWithDefaultName, ReadConfig, SaveConfig}, + traits::{FileConfigWithDefaultName, ReadConfig, SaveConfig, ZkToolboxConfig}, ChainConfig, ChainConfigInternal, ContractsConfig, WalletsConfig, }; @@ -90,9 +90,9 @@ impl FileConfigWithDefaultName for EcosystemConfig { const FILE_NAME: &'static str = CONFIG_NAME; } -impl FileConfig for EcosystemConfigInternal {} +impl ZkToolboxConfig for EcosystemConfigInternal {} -impl FileConfig for EcosystemConfig {} +impl ZkToolboxConfig for EcosystemConfig {} impl EcosystemConfig { fn get_shell(&self) -> &Shell { diff --git a/zk_toolbox/crates/config/src/external_node.rs b/zk_toolbox/crates/config/src/external_node.rs index cdeb4d0275bb..d75d5ad206ff 100644 --- a/zk_toolbox/crates/config/src/external_node.rs +++ b/zk_toolbox/crates/config/src/external_node.rs @@ -5,7 +5,7 @@ use types::{ChainId, L1BatchCommitmentMode}; use crate::{ consts::EN_CONFIG_FILE, - traits::{FileConfig, FileConfigWithDefaultName}, + traits::{FileConfigWithDefaultName, ZkToolboxConfig}, }; #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] @@ -25,4 +25,4 @@ impl FileConfigWithDefaultName for ENConfig { const FILE_NAME: &'static str = EN_CONFIG_FILE; } -impl FileConfig for ENConfig {} +impl ZkToolboxConfig for ENConfig {} diff --git a/zk_toolbox/crates/config/src/forge_interface/accept_ownership/mod.rs b/zk_toolbox/crates/config/src/forge_interface/accept_ownership/mod.rs index 58b5aa1f9d49..636cffc49f89 100644 --- a/zk_toolbox/crates/config/src/forge_interface/accept_ownership/mod.rs +++ b/zk_toolbox/crates/config/src/forge_interface/accept_ownership/mod.rs @@ -1,9 +1,9 @@ use ethers::types::Address; use serde::{Deserialize, Serialize}; -use crate::traits::FileConfig; +use crate::traits::ZkToolboxConfig; -impl FileConfig for AcceptOwnershipInput {} +impl ZkToolboxConfig for AcceptOwnershipInput {} #[derive(Debug, Deserialize, Serialize, Clone)] pub struct AcceptOwnershipInput { diff --git a/zk_toolbox/crates/config/src/forge_interface/deploy_ecosystem/input.rs b/zk_toolbox/crates/config/src/forge_interface/deploy_ecosystem/input.rs index 0ddca5d90cfb..91e6459fd780 100644 --- a/zk_toolbox/crates/config/src/forge_interface/deploy_ecosystem/input.rs +++ b/zk_toolbox/crates/config/src/forge_interface/deploy_ecosystem/input.rs @@ -10,7 +10,7 @@ use types::ChainId; use crate::{ consts::INITIAL_DEPLOYMENT_FILE, - traits::{FileConfig, FileConfigWithDefaultName}, + traits::{FileConfigWithDefaultName, ZkToolboxConfig}, ContractsConfig, GenesisConfig, WalletsConfig, }; @@ -61,7 +61,7 @@ impl FileConfigWithDefaultName for InitialDeploymentConfig { const FILE_NAME: &'static str = INITIAL_DEPLOYMENT_FILE; } -impl FileConfig for InitialDeploymentConfig {} +impl ZkToolboxConfig for InitialDeploymentConfig {} #[derive(Debug, Deserialize, Serialize, Clone)] pub struct Erc20DeploymentConfig { @@ -72,7 +72,7 @@ impl FileConfigWithDefaultName for Erc20DeploymentConfig { const FILE_NAME: &'static str = INITIAL_DEPLOYMENT_FILE; } -impl FileConfig for Erc20DeploymentConfig {} +impl ZkToolboxConfig for Erc20DeploymentConfig {} impl Default for Erc20DeploymentConfig { fn default() -> Self { @@ -122,7 +122,7 @@ pub struct DeployL1Config { pub tokens: TokensDeployL1Config, } -impl FileConfig for DeployL1Config {} +impl ZkToolboxConfig for DeployL1Config {} impl DeployL1Config { pub fn new( @@ -216,7 +216,7 @@ pub struct DeployErc20Config { pub additional_addresses_for_minting: Vec
, } -impl FileConfig for DeployErc20Config {} +impl ZkToolboxConfig for DeployErc20Config {} impl DeployErc20Config { pub fn new( diff --git a/zk_toolbox/crates/config/src/forge_interface/deploy_ecosystem/output.rs b/zk_toolbox/crates/config/src/forge_interface/deploy_ecosystem/output.rs index 9af7541ee1c1..77f212114916 100644 --- a/zk_toolbox/crates/config/src/forge_interface/deploy_ecosystem/output.rs +++ b/zk_toolbox/crates/config/src/forge_interface/deploy_ecosystem/output.rs @@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize}; use crate::{ consts::ERC20_CONFIGS_FILE, - traits::{FileConfig, FileConfigWithDefaultName}, + traits::{FileConfigWithDefaultName, ZkToolboxConfig}, }; #[derive(Debug, Deserialize, Serialize, Clone)] @@ -21,7 +21,7 @@ pub struct DeployL1Output { pub deployed_addresses: DeployL1DeployedAddressesOutput, } -impl FileConfig for DeployL1Output {} +impl ZkToolboxConfig for DeployL1Output {} #[derive(Debug, Deserialize, Serialize, Clone)] pub struct DeployL1ContractsConfigOutput { @@ -97,4 +97,4 @@ impl FileConfigWithDefaultName for DeployErc20Output { const FILE_NAME: &'static str = ERC20_CONFIGS_FILE; } -impl FileConfig for DeployErc20Output {} +impl ZkToolboxConfig for DeployErc20Output {} diff --git a/zk_toolbox/crates/config/src/forge_interface/initialize_bridges/input.rs b/zk_toolbox/crates/config/src/forge_interface/initialize_bridges/input.rs index e884c0a3a39e..7341eb1ad7fd 100644 --- a/zk_toolbox/crates/config/src/forge_interface/initialize_bridges/input.rs +++ b/zk_toolbox/crates/config/src/forge_interface/initialize_bridges/input.rs @@ -2,9 +2,9 @@ use ethers::types::Address; use serde::{Deserialize, Serialize}; use types::ChainId; -use crate::{traits::FileConfig, ChainConfig}; +use crate::{traits::ZkToolboxConfig, ChainConfig}; -impl FileConfig for InitializeBridgeInput {} +impl ZkToolboxConfig for InitializeBridgeInput {} #[derive(Debug, Clone, Serialize, Deserialize)] pub struct InitializeBridgeInput { diff --git a/zk_toolbox/crates/config/src/forge_interface/initialize_bridges/output.rs b/zk_toolbox/crates/config/src/forge_interface/initialize_bridges/output.rs index d03474a6a089..8da3707ed706 100644 --- a/zk_toolbox/crates/config/src/forge_interface/initialize_bridges/output.rs +++ b/zk_toolbox/crates/config/src/forge_interface/initialize_bridges/output.rs @@ -1,9 +1,9 @@ use ethers::types::Address; use serde::{Deserialize, Serialize}; -use crate::traits::FileConfig; +use crate::traits::ZkToolboxConfig; -impl FileConfig for InitializeBridgeOutput {} +impl ZkToolboxConfig for InitializeBridgeOutput {} #[derive(Debug, Clone, Serialize, Deserialize)] pub struct InitializeBridgeOutput { diff --git a/zk_toolbox/crates/config/src/forge_interface/paymaster/mod.rs b/zk_toolbox/crates/config/src/forge_interface/paymaster/mod.rs index e634f1eb3dab..fc43dd522103 100644 --- a/zk_toolbox/crates/config/src/forge_interface/paymaster/mod.rs +++ b/zk_toolbox/crates/config/src/forge_interface/paymaster/mod.rs @@ -2,7 +2,7 @@ use ethers::types::Address; use serde::{Deserialize, Serialize}; use types::ChainId; -use crate::{traits::FileConfig, ChainConfig}; +use crate::{traits::ZkToolboxConfig, ChainConfig}; #[derive(Debug, Serialize, Deserialize, Clone)] pub struct DeployPaymasterInput { @@ -21,11 +21,12 @@ impl DeployPaymasterInput { }) } } -impl FileConfig for DeployPaymasterInput {} + +impl ZkToolboxConfig for DeployPaymasterInput {} #[derive(Debug, Serialize, Deserialize, Clone)] pub struct DeployPaymasterOutput { pub paymaster: Address, } -impl FileConfig for DeployPaymasterOutput {} +impl ZkToolboxConfig for DeployPaymasterOutput {} diff --git a/zk_toolbox/crates/config/src/forge_interface/register_chain/input.rs b/zk_toolbox/crates/config/src/forge_interface/register_chain/input.rs index d6832b161533..6428e56625ce 100644 --- a/zk_toolbox/crates/config/src/forge_interface/register_chain/input.rs +++ b/zk_toolbox/crates/config/src/forge_interface/register_chain/input.rs @@ -3,7 +3,7 @@ use rand::Rng; use serde::{Deserialize, Serialize}; use types::{ChainId, L1BatchCommitmentMode}; -use crate::{traits::FileConfig, ChainConfig, ContractsConfig}; +use crate::{traits::ZkToolboxConfig, ChainConfig, ContractsConfig}; #[derive(Debug, Deserialize, Serialize, Clone)] struct Bridgehub { @@ -49,7 +49,7 @@ pub struct ChainL1Config { pub governance_min_delay: u64, } -impl FileConfig for RegisterChainL1Config {} +impl ZkToolboxConfig for RegisterChainL1Config {} impl RegisterChainL1Config { pub fn new(chain_config: &ChainConfig, contracts: &ContractsConfig) -> anyhow::Result { diff --git a/zk_toolbox/crates/config/src/forge_interface/register_chain/output.rs b/zk_toolbox/crates/config/src/forge_interface/register_chain/output.rs index 2f39b76c3933..f9521b16328f 100644 --- a/zk_toolbox/crates/config/src/forge_interface/register_chain/output.rs +++ b/zk_toolbox/crates/config/src/forge_interface/register_chain/output.rs @@ -1,7 +1,7 @@ use ethers::types::Address; use serde::{Deserialize, Serialize}; -use crate::traits::FileConfig; +use crate::traits::ZkToolboxConfig; #[derive(Debug, Deserialize, Serialize, Clone)] pub struct RegisterChainOutput { @@ -10,4 +10,4 @@ pub struct RegisterChainOutput { pub chain_admin_addr: Address, } -impl FileConfig for RegisterChainOutput {} +impl ZkToolboxConfig for RegisterChainOutput {} diff --git a/zk_toolbox/crates/config/src/traits.rs b/zk_toolbox/crates/config/src/traits.rs index a2ea52c17788..96522110fe6e 100644 --- a/zk_toolbox/crates/config/src/traits.rs +++ b/zk_toolbox/crates/config/src/traits.rs @@ -7,7 +7,8 @@ use common::files::{ use serde::{de::DeserializeOwned, Serialize}; use xshell::Shell; -pub trait FileConfig {} +// Configs that we use only inside zk toolbox, we don't have protobuf implementation for them. +pub trait ZkToolboxConfig {} pub trait FileConfigWithDefaultName { const FILE_NAME: &'static str; @@ -17,7 +18,7 @@ pub trait FileConfigWithDefaultName { } } -impl SaveConfig for T { +impl SaveConfig for T { fn save(&self, shell: &Shell, path: impl AsRef) -> anyhow::Result<()> { save_with_comment(shell, path, &self, "") } @@ -47,7 +48,7 @@ pub trait ReadConfig: Sized { impl ReadConfig for T where - T: DeserializeOwned + Clone + FileConfig, + T: DeserializeOwned + Clone + ZkToolboxConfig, { fn read(shell: &Shell, path: impl AsRef) -> anyhow::Result { let error_context = || format!("Failed to parse config file {:?}.", path.as_ref()); diff --git a/zk_toolbox/crates/config/src/wallets.rs b/zk_toolbox/crates/config/src/wallets.rs index cfa4741f5824..460c4e3574a3 100644 --- a/zk_toolbox/crates/config/src/wallets.rs +++ b/zk_toolbox/crates/config/src/wallets.rs @@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize}; use crate::{ consts::WALLETS_FILE, - traits::{FileConfig, FileConfigWithDefaultName}, + traits::{FileConfigWithDefaultName, ZkToolboxConfig}, }; #[derive(Debug, Clone, Serialize, Deserialize)] @@ -60,6 +60,6 @@ pub(crate) struct EthMnemonicConfig { pub(crate) base_path: String, } -impl FileConfig for EthMnemonicConfig {} +impl ZkToolboxConfig for EthMnemonicConfig {} -impl FileConfig for WalletsConfig {} +impl ZkToolboxConfig for WalletsConfig {} diff --git a/zk_toolbox/crates/types/Cargo.toml b/zk_toolbox/crates/types/Cargo.toml index 3c7b50622abb..7dc96cab768d 100644 --- a/zk_toolbox/crates/types/Cargo.toml +++ b/zk_toolbox/crates/types/Cargo.toml @@ -16,4 +16,4 @@ ethers.workspace = true serde.workspace = true strum.workspace = true thiserror.workspace = true -zksync_basic_types.workspace = true \ No newline at end of file +zksync_basic_types.workspace = true diff --git a/zk_toolbox/crates/zk_inception/Cargo.toml b/zk_toolbox/crates/zk_inception/Cargo.toml index 3c9be5e8eaa1..2626611376fe 100644 --- a/zk_toolbox/crates/zk_inception/Cargo.toml +++ b/zk_toolbox/crates/zk_inception/Cargo.toml @@ -32,4 +32,4 @@ url.workspace = true thiserror.workspace = true zksync_config.workspace = true slugify-rs.workspace = true -zksync_basic_types.workspace = true \ No newline at end of file +zksync_basic_types.workspace = true