Skip to content

Commit

Permalink
feat(config): Extract everything not related to the env config from z…
Browse files Browse the repository at this point in the history
…ksync_config crate (#245)

# What ❔

- Removes (unused) test_config from zksync_config crate
- Moves system constants from zksync_config crate to a separate one

## Why ❔

- Get rid of the dependency on the `zksync_config` in non-binary crates.
- Better logical separation

## 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 `zk fmt` and `zk lint`.
  • Loading branch information
popzxc committed Oct 18, 2023
1 parent 6cb8c2c commit 42c64e9
Show file tree
Hide file tree
Showing 112 changed files with 190 additions and 202 deletions.
39 changes: 29 additions & 10 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ members = [
"core/bin/merkle_tree_consistency_checker",
"core/bin/rocksdb_util",
"core/bin/storage_logs_dedup_migration",
"core/bin/system-constants-generator",
"core/bin/system-constants-generator",
"core/bin/verification_key_generator_and_server",
"core/bin/verified_sources_fetcher",
"core/bin/zksync_server",
# Libraries
"core/lib/zksync_core",
"core/lib/basic_types",
"core/lib/config",
"core/lib/constants",
"core/lib/contracts",
"core/lib/crypto",
"core/lib/circuit_breaker",
Expand Down
18 changes: 18 additions & 0 deletions core/lib/basic_types/src/basic_fri_types.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//! Basic types for FRI prover.

use serde::{Deserialize, Serialize};

#[derive(Debug, Deserialize, Serialize, Clone, Eq, Hash, PartialEq)]
pub struct CircuitIdRoundTuple {
pub circuit_id: u8,
pub aggregation_round: u8,
}

impl CircuitIdRoundTuple {
pub fn new(circuit_id: u8, aggregation_round: u8) -> Self {
Self {
circuit_id,
aggregation_round,
}
}
}
1 change: 1 addition & 0 deletions core/lib/basic_types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#[macro_use]
mod macros;

pub mod basic_fri_types;
pub mod network;

use serde::{de, Deserialize, Deserializer, Serialize};
Expand Down
18 changes: 2 additions & 16 deletions core/lib/config/src/configs/fri_prover_group.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
use serde::Deserialize;
use std::collections::{HashMap, HashSet};
use std::env;

use serde::{Deserialize, Serialize};

#[derive(Debug, Deserialize, Serialize, Clone, Eq, Hash, PartialEq)]
pub struct CircuitIdRoundTuple {
pub circuit_id: u8,
pub aggregation_round: u8,
}

impl CircuitIdRoundTuple {
pub fn new(circuit_id: u8, aggregation_round: u8) -> Self {
Self {
circuit_id,
aggregation_round,
}
}
}
use zksync_basic_types::basic_fri_types::CircuitIdRoundTuple;

fn load_from_env_variable() -> HashMap<String, HashSet<CircuitIdRoundTuple>> {
// Prepare a hash map to store the mapping of group to a vector of tuples
Expand Down
2 changes: 0 additions & 2 deletions core/lib/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@ pub use crate::configs::{
};

pub mod configs;
pub mod constants;
pub mod test_config;
63 changes: 0 additions & 63 deletions core/lib/config/src/test_config/mod.rs

This file was deleted.

24 changes: 24 additions & 0 deletions core/lib/constants/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[package]
name = "zksync_system_constants"
version = "0.1.0"
edition = "2018"
authors = ["The Matter Labs Team <hello@matterlabs.dev>"]
homepage = "https://zksync.io/"
repository = "https://github.com/matter-labs/zksync-era"
license = "MIT OR Apache-2.0"
keywords = ["blockchain", "zksync"]
categories = ["cryptography"]

[dependencies]
zksync_basic_types = { path = "../../lib/basic_types" }
zksync_utils = { path = "../../lib/utils" }
zksync_contracts = { path = "../../lib/contracts" }

anyhow = "1.0"
url = "2.1"
num = "0.3.1"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
once_cell = "1.13.0"
bigdecimal = "0.2.2"
hex = "0.4"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion core/lib/dal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ categories = ["cryptography"]
[dependencies]
vise = { git = "https://github.com/matter-labs/vise.git", version = "0.1.0", rev = "dd05139b76ab0843443ab3ff730174942c825dae" }
zksync_utils = { path = "../utils" }
zksync_config = { path = "../config" }
zksync_system_constants = { path = "../constants" }
zksync_contracts = { path = "../contracts" }
zksync_types = { path = "../types" }
zksync_health_check = { path = "../health_check" }
Expand Down
2 changes: 1 addition & 1 deletion core/lib/dal/src/blocks_web3_dal.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use bigdecimal::BigDecimal;
use sqlx::Row;

use zksync_config::constants::EMPTY_UNCLES_HASH;
use zksync_system_constants::EMPTY_UNCLES_HASH;
use zksync_types::{
api,
ethabi::Address,
Expand Down
4 changes: 2 additions & 2 deletions core/lib/dal/src/fri_prover_dal.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::{collections::HashMap, convert::TryFrom, time::Duration};

use zksync_config::configs::fri_prover_group::CircuitIdRoundTuple;
use zksync_types::protocol_version::FriProtocolVersionId;
use zksync_types::{
basic_fri_types::CircuitIdRoundTuple,
proofs::{AggregationRound, FriProverJobMetadata, JobCountStatistics, StuckJobs},
protocol_version::FriProtocolVersionId,
L1BatchNumber,
};

Expand Down
2 changes: 1 addition & 1 deletion core/lib/merkle_tree/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ thiserror = "1.0"
tracing = "0.1"

[dev-dependencies]
zksync_config = { path = "../config" }
zksync_system_constants = { path = "../constants" }

assert_matches = "1.5.0"
clap = { version = "4.2.2", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion core/lib/merkle_tree/tests/integration/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ use tempfile::TempDir;

use std::slice;

use zksync_config::constants::ACCOUNT_CODE_STORAGE_ADDRESS;
use zksync_crypto::hasher::blake2::Blake2Hasher;
use zksync_merkle_tree::{domain::ZkSyncTree, HashTree};
use zksync_storage::RocksDB;
use zksync_system_constants::ACCOUNT_CODE_STORAGE_ADDRESS;
use zksync_types::{
proofs::StorageLogMetadata, AccountTreeId, Address, L1BatchNumber, StorageKey, StorageLog, H256,
};
Expand Down
2 changes: 1 addition & 1 deletion core/lib/test_account/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ readme = "README.md"

[dependencies]
zksync_types = { path = "../types" }
zksync_config = { path = "../config" }
zksync_system_constants = { path = "../constants" }
zksync_utils = { path = "../utils" }
zksync_eth_signer = { path = "../eth_signer" }
zksync_contracts = { path = "../contracts" }
Expand Down
6 changes: 3 additions & 3 deletions core/lib/test_account/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use ethabi::Token;
use zksync_config::constants::{
CONTRACT_DEPLOYER_ADDRESS, MAX_GAS_PER_PUBDATA_BYTE, REQUIRED_L1_TO_L2_GAS_PER_PUBDATA_BYTE,
};
use zksync_contracts::test_contracts::LoadnextContractExecutionParams;
use zksync_contracts::{deployer_contract, load_contract};
use zksync_system_constants::{
CONTRACT_DEPLOYER_ADDRESS, MAX_GAS_PER_PUBDATA_BYTE, REQUIRED_L1_TO_L2_GAS_PER_PUBDATA_BYTE,
};
use zksync_types::fee::Fee;
use zksync_types::l2::L2Tx;
use zksync_types::utils::deployed_address_create;
Expand Down

0 comments on commit 42c64e9

Please sign in to comment.