Skip to content

Commit

Permalink
chore: move contract verifier logic to lib (#2240)
Browse files Browse the repository at this point in the history
## What ❔

Move the contract verifier struct to the separate lib crate.

## Why ❔

This logic can be used as a library. At lest, for example, now it's
needed for some compiler analysis tool.

## Checklist

<!-- Check your PR fulfills the following items. -->
<!-- For draft PRs check the boxes as you complete them. -->

- [ ] PR title corresponds to the body of PR (we generate changelog
entries from PRs).
- [ ] Tests for the changes have been added / updated.
- [ ] Documentation comments have been added / updated.
- [ ] Code has been formatted via `zk fmt` and `zk lint`.
- [ ] Spellcheck has been run via `zk spellcheck`.
  • Loading branch information
AntonD3 authored Jun 17, 2024
1 parent 6c49a50 commit 63be1f3
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 38 deletions.
25 changes: 20 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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" }
Expand Down
13 changes: 1 addition & 12 deletions core/bin/contract-verifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
9 changes: 1 addition & 8 deletions core/bin/contract-verifier/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Core>) {
let mut storage = connection_pool.connection().await.unwrap();
let mut transaction = storage.start_transaction().await.unwrap();
Expand Down
33 changes: 33 additions & 0 deletions core/lib/contract_verifier/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -274,7 +279,7 @@ impl ContractVerifier {
Err(ContractVerifierError::MissingContract(contract_name))
}

async fn compile(
pub async fn compile(
request: VerificationRequest,
config: ContractVerifierConfig,
) -> Result<CompilationArtifacts, ContractVerifierError> {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 63be1f3

Please sign in to comment.