diff --git a/Cargo.lock b/Cargo.lock index cfe47a2a4b1e..a99150fe01c0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8282,23 +8282,38 @@ name = "zksync_contract_verifier" version = "0.1.0" dependencies = [ "anyhow", - "chrono", "ctrlc", - "ethabi", "futures 0.3.28", + "prometheus_exporter", + "structopt", + "tokio", + "tracing", + "vlog", + "zksync_config", + "zksync_contract_verifier_lib", + "zksync_dal", + "zksync_env_config", + "zksync_queued_job_processor", + "zksync_utils", +] + +[[package]] +name = "zksync_contract_verifier_lib" +version = "0.1.0" +dependencies = [ + "anyhow", + "chrono", + "ethabi", "hex", "lazy_static", - "prometheus_exporter", "regex", "serde", "serde_json", - "structopt", "tempfile", "thiserror", "tokio", "tracing", "vise", - "vlog", "zksync_config", "zksync_contracts", "zksync_dal", diff --git a/Cargo.toml b/Cargo.toml index de664288e150..5d9f6adf37ad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,6 +38,7 @@ members = [ "core/lib/basic_types", "core/lib/config", "core/lib/constants", + "core/lib/contract_verifier", "core/lib/contracts", "core/lib/crypto", "core/lib/circuit_breaker", @@ -212,6 +213,7 @@ zksync = { path = "sdk/zksync-rs" } zksync_basic_types = { path = "core/lib/basic_types" } zksync_circuit_breaker = { path = "core/lib/circuit_breaker" } zksync_config = { path = "core/lib/config" } +zksync_contract_verifier_lib = { path = "core/lib/contract_verifier" } zksync_contracts = { path = "core/lib/contracts" } zksync_core_leftovers = { path = "core/lib/zksync_core_leftovers" } zksync_crypto = { path = "core/lib/crypto" } diff --git a/core/bin/contract-verifier/Cargo.toml b/core/bin/contract-verifier/Cargo.toml index 49e5469998c8..3e9832f995f9 100644 --- a/core/bin/contract-verifier/Cargo.toml +++ b/core/bin/contract-verifier/Cargo.toml @@ -11,11 +11,10 @@ categories.workspace = true publish = false [dependencies] -zksync_types.workspace = true zksync_dal.workspace = true zksync_env_config.workspace = true zksync_config.workspace = true -zksync_contracts.workspace = true +zksync_contract_verifier_lib.workspace = true zksync_queued_job_processor.workspace = true zksync_utils.workspace = true prometheus_exporter.workspace = true @@ -25,15 +24,5 @@ anyhow.workspace = true tokio = { workspace = true, features = ["full"] } futures.workspace = true ctrlc.workspace = true -thiserror.workspace = true -chrono.workspace = true -serde_json.workspace = true -ethabi.workspace = true -vise.workspace = true -hex.workspace = true -serde = { workspace = true, features = ["derive"] } structopt.workspace = true -lazy_static.workspace = true -tempfile.workspace = true -regex.workspace = true tracing.workspace = true diff --git a/core/bin/contract-verifier/src/main.rs b/core/bin/contract-verifier/src/main.rs index 98b4a859d14d..5789422641c8 100644 --- a/core/bin/contract-verifier/src/main.rs +++ b/core/bin/contract-verifier/src/main.rs @@ -9,19 +9,12 @@ use zksync_config::{ configs::{ObservabilityConfig, PrometheusConfig}, ApiConfig, ContractVerifierConfig, }; +use zksync_contract_verifier_lib::ContractVerifier; use zksync_dal::{ConnectionPool, Core, CoreDal}; use zksync_env_config::FromEnv; use zksync_queued_job_processor::JobProcessor; use zksync_utils::{wait_for_tasks::ManagedTasks, workspace_dir_or_current_dir}; -use crate::verifier::ContractVerifier; - -pub mod error; -mod metrics; -pub mod verifier; -pub mod zksolc_utils; -pub mod zkvyper_utils; - async fn update_compiler_versions(connection_pool: &ConnectionPool) { let mut storage = connection_pool.connection().await.unwrap(); let mut transaction = storage.start_transaction().await.unwrap(); diff --git a/core/lib/contract_verifier/Cargo.toml b/core/lib/contract_verifier/Cargo.toml new file mode 100644 index 000000000000..5b5ab4b5e429 --- /dev/null +++ b/core/lib/contract_verifier/Cargo.toml @@ -0,0 +1,33 @@ +[package] +name = "zksync_contract_verifier_lib" +version = "0.1.0" +edition.workspace = true +authors.workspace = true +homepage.workspace = true +repository.workspace = true +license.workspace = true +keywords.workspace = true +categories.workspace = true + +[dependencies] +zksync_types.workspace = true +zksync_dal.workspace = true +zksync_env_config.workspace = true +zksync_config.workspace = true +zksync_contracts.workspace = true +zksync_queued_job_processor.workspace = true +zksync_utils.workspace = true + +anyhow.workspace = true +tokio = { workspace = true, features = ["full"] } +thiserror.workspace = true +chrono.workspace = true +serde_json.workspace = true +ethabi.workspace = true +vise.workspace = true +hex.workspace = true +serde = { workspace = true, features = ["derive"] } +lazy_static.workspace = true +tempfile.workspace = true +regex.workspace = true +tracing.workspace = true diff --git a/core/bin/contract-verifier/src/error.rs b/core/lib/contract_verifier/src/error.rs similarity index 100% rename from core/bin/contract-verifier/src/error.rs rename to core/lib/contract_verifier/src/error.rs diff --git a/core/bin/contract-verifier/src/verifier.rs b/core/lib/contract_verifier/src/lib.rs similarity index 99% rename from core/bin/contract-verifier/src/verifier.rs rename to core/lib/contract_verifier/src/lib.rs index 8d5ba9fccfe2..3ff4c2e18c77 100644 --- a/core/bin/contract-verifier/src/verifier.rs +++ b/core/lib/contract_verifier/src/lib.rs @@ -30,6 +30,11 @@ use crate::{ zkvyper_utils::{ZkVyper, ZkVyperInput}, }; +pub mod error; +mod metrics; +mod zksolc_utils; +mod zkvyper_utils; + lazy_static! { static ref DEPLOYER_CONTRACT: Contract = zksync_contracts::deployer_contract(); } @@ -274,7 +279,7 @@ impl ContractVerifier { Err(ContractVerifierError::MissingContract(contract_name)) } - async fn compile( + pub async fn compile( request: VerificationRequest, config: ContractVerifierConfig, ) -> Result { diff --git a/core/bin/contract-verifier/src/metrics.rs b/core/lib/contract_verifier/src/metrics.rs similarity index 100% rename from core/bin/contract-verifier/src/metrics.rs rename to core/lib/contract_verifier/src/metrics.rs diff --git a/core/bin/contract-verifier/src/zksolc_utils.rs b/core/lib/contract_verifier/src/zksolc_utils.rs similarity index 97% rename from core/bin/contract-verifier/src/zksolc_utils.rs rename to core/lib/contract_verifier/src/zksolc_utils.rs index 791d5ee5b6cc..4952c1e21d0d 100644 --- a/core/bin/contract-verifier/src/zksolc_utils.rs +++ b/core/lib/contract_verifier/src/zksolc_utils.rs @@ -74,18 +74,6 @@ impl Default for Optimizer { } } -impl Optimizer { - /// - /// A shortcut constructor. - /// - pub fn new(enabled: bool) -> Self { - Self { - enabled, - mode: None, - } - } -} - pub struct ZkSolc { zksolc_path: PathBuf, solc_path: PathBuf, diff --git a/core/bin/contract-verifier/src/zkvyper_utils.rs b/core/lib/contract_verifier/src/zkvyper_utils.rs similarity index 100% rename from core/bin/contract-verifier/src/zkvyper_utils.rs rename to core/lib/contract_verifier/src/zkvyper_utils.rs