Skip to content

Commit

Permalink
refactor: make zksync_utils thinner (#3568)
Browse files Browse the repository at this point in the history
## What ❔

This PR removes heavy transitive dependencies from `zksync_utils` by:
* Moving `ManagedTasks` into a separate crate (ideally needs to be
removed in favor of node_framework but unfortunately still used by
prover and contract-verifier)
* Deleting custom-written retry logic for reqwest. The only place that
was using was `RegionFetcher` from prover utils. I migrated it to
`reqwest-retry` instead (Cargo.lock diff looks bigger than it actually
is - almost every new crate is just some wasm-specific stuff that
doesn't matter).

## Why ❔

Depending on `zksync_contracts`, `zksync_multivm` and other seemingly
core crates pulls in a lot of transitive dependencies right now
(`reqwest`, `sentry`, `opentelemetry`, `openssl` etc)

## Checklist

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

- [x] 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.
- [x] Code has been formatted via `zkstack dev fmt` and `zkstack dev
lint`.
  • Loading branch information
itegulov authored Feb 6, 2025
1 parent a85d1f9 commit 8d8421c
Show file tree
Hide file tree
Showing 32 changed files with 230 additions and 691 deletions.
19 changes: 13 additions & 6 deletions core/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 core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ members = [
"lib/snapshots_applier",
"lib/crypto_primitives",
"lib/external_price_api",
"lib/task_management",
"lib/test_contracts",
# Test infrastructure
"tests/loadnext",
Expand Down Expand Up @@ -296,6 +297,7 @@ zksync_utils = { version = "26.2.1-non-semver-compat", path = "lib/utils" }
zksync_web3_decl = { version = "26.2.1-non-semver-compat", path = "lib/web3_decl" }
zksync_crypto_primitives = { version = "26.2.1-non-semver-compat", path = "lib/crypto_primitives" }
zksync_external_price_api = { version = "26.2.1-non-semver-compat", path = "lib/external_price_api" }
zksync_task_management = { version = "26.2.1-non-semver-compat", path = "lib/task_management" }

# Framework and components
zksync_node_framework = { version = "26.2.1-non-semver-compat", path = "node/node_framework" }
Expand Down
2 changes: 1 addition & 1 deletion core/bin/contract-verifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ zksync_dal.workspace = true
zksync_config = { workspace = true, features = ["observability_ext"] }
zksync_contract_verifier_lib.workspace = true
zksync_queued_job_processor.workspace = true
zksync_utils.workspace = true
zksync_task_management.workspace = true
zksync_vlog.workspace = true
zksync_core_leftovers.workspace = true

Expand Down
2 changes: 1 addition & 1 deletion core/bin/contract-verifier/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use zksync_contract_verifier_lib::ContractVerifier;
use zksync_core_leftovers::temp_config_store::{load_database_secrets, load_general_config};
use zksync_dal::{ConnectionPool, Core, CoreDal};
use zksync_queued_job_processor::JobProcessor;
use zksync_utils::wait_for_tasks::ManagedTasks;
use zksync_task_management::ManagedTasks;
use zksync_vlog::prometheus::PrometheusExporterConfig;

#[derive(Debug, Parser)]
Expand Down
20 changes: 20 additions & 0 deletions core/lib/task_management/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "zksync_task_management"
description = "ZKsync task management"
version.workspace = true
edition.workspace = true
authors.workspace = true
homepage.workspace = true
repository.workspace = true
license.workspace = true
keywords.workspace = true
categories.workspace = true

[dependencies]
zksync_utils.workspace = true
zksync_vlog.workspace = true

anyhow.workspace = true
futures.workspace = true
tokio = { workspace = true }
tracing.workspace = true
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// TODO: Migrate contract-verifier and provers to node_framework and get rid of this crate
use std::time::Duration;

use futures::future;
use tokio::task::JoinHandle;

use crate::panic_extractor::try_extract_panic_message;
use zksync_utils::panic_extractor::try_extract_panic_message;

/// Container for fallible Tokio tasks with ability to track their shutdown.
///
Expand Down
6 changes: 0 additions & 6 deletions core/lib/utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,10 @@ keywords.workspace = true
categories.workspace = true

[dependencies]
zksync_vlog.workspace = true

tokio = { workspace = true, features = ["time"] }
tracing.workspace = true
anyhow.workspace = true
futures.workspace = true
reqwest = { workspace = true, features = ["blocking"] }
serde_json.workspace = true
once_cell.workspace = true
sha2.workspace = true

[dev-dependencies]
tokio = { workspace = true, features = ["macros", "rt"] }
Expand Down
61 changes: 0 additions & 61 deletions core/lib/utils/src/http_with_retries.rs

This file was deleted.

2 changes: 0 additions & 2 deletions core/lib/utils/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
//! Various helpers used in the ZKsync stack.
pub mod env;
pub mod http_with_retries;
pub mod panic_extractor;
pub mod wait_for_tasks;
Loading

0 comments on commit 8d8421c

Please sign in to comment.