Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(configs): Implement new format of configs and implement protobuf for it #1501

Merged
merged 78 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
6fc4798
add base path to constants
Deniallugo Feb 29, 2024
c5e33fc
Merge branch 'main' into deniallugo-fixes-for-zk-toolbox
Deniallugo Mar 4, 2024
63f8812
Use reth instead of geth
Deniallugo Mar 8, 2024
ce48143
Update private keys
Deniallugo Mar 11, 2024
a968dd6
Use reth instead of geth
Deniallugo Mar 11, 2024
72b0cf9
Merge branch 'main' into deniallugo-fixes-for-zk-toolbox
Deniallugo Mar 11, 2024
f9ef9b6
attempts to fix
Deniallugo Mar 11, 2024
bcf3168
Update contracts
Deniallugo Mar 11, 2024
807891c
Fix chain id
Deniallugo Mar 11, 2024
986ad71
Small fixes
Deniallugo Mar 11, 2024
8194a36
try approcah from en
Deniallugo Mar 11, 2024
410b9ae
Add genesis file
Deniallugo Mar 13, 2024
fc5a877
Genesis for EN
Deniallugo Mar 13, 2024
9aed6ad
Load genesis from env
Deniallugo Mar 13, 2024
f0f0845
Merge branch 'main' into deniallugo-genesis-config
Deniallugo Mar 14, 2024
03b838a
Update genesis
Deniallugo Mar 14, 2024
a9ade54
Create genesis
Deniallugo Mar 14, 2024
1695a35
Fix chain id
Deniallugo Mar 14, 2024
7f7cb8d
Add genesis protocol version
Deniallugo Mar 14, 2024
3842bd2
Fix tests for getting from env structs
Deniallugo Mar 15, 2024
d22e560
Merge branch 'main' into deniallugo-genesis-config
Deniallugo Mar 15, 2024
94bd47d
Merge
Deniallugo Mar 15, 2024
a73d73e
Merge
Deniallugo Mar 15, 2024
7c193c7
Introduce ensure_genesis_state_unchecked
Deniallugo Mar 15, 2024
ed785b6
Remove contracts from genesis
Deniallugo Mar 15, 2024
cac0716
Fix test
Deniallugo Mar 15, 2024
7447a2b
fix(protocol): Remove verifier address from protocol upgrade
Deniallugo Mar 15, 2024
1de2b29
Drop not null from the database
Deniallugo Mar 15, 2024
41ea1c6
Merge branch 'deniallugo-remove-verifier-address-from-protocol' into …
Deniallugo Mar 15, 2024
ea90b4f
add comments
Deniallugo Mar 15, 2024
5dc7efc
Merge branch 'main' into deniallugo-genesis-config
Deniallugo Mar 18, 2024
fb64d39
Remove genesis path
Deniallugo Mar 18, 2024
070f11c
feat(config): Split config to files
Deniallugo Mar 18, 2024
fa3b6b1
Use array
Deniallugo Mar 19, 2024
b461862
Apply suggestions
Deniallugo Mar 19, 2024
5d12a60
Merge branch 'deniallugo-genesis-config' into deniallugo-split-env-files
Deniallugo Mar 20, 2024
52535a8
feat(configs): Proto implementation
Deniallugo Mar 20, 2024
4c79e50
decode_yaml_repr
pompon0 Mar 20, 2024
cd99d90
zksync_server compiles
pompon0 Mar 20, 2024
44670ac
Add comments
Deniallugo Mar 20, 2024
85e1a81
Build config from server
Deniallugo Mar 20, 2024
a4e7ce7
Add wallets to protobuf config
Deniallugo Mar 25, 2024
425c7d8
Merge branch 'main' into deniallugo-implement-protobuf-for-new-configs
Deniallugo Mar 25, 2024
e696e3b
Move all configs to protobuf
Deniallugo Mar 26, 2024
7241741
Intialize everythin with proper config structs
Deniallugo Mar 26, 2024
5367cce
Use option for blob operator
Deniallugo Mar 26, 2024
91f42ee
Merge branch 'main' into deniallugo-implement-protobuf-for-new-configs
Deniallugo Mar 27, 2024
11ff010
Move crypto primitives from types
Deniallugo Mar 27, 2024
d2fcbf1
Fix node framework
Deniallugo Mar 27, 2024
afe3a3a
Remove full contracts env config
Deniallugo Mar 27, 2024
87c7803
Fix lints
Deniallugo Mar 27, 2024
1ca6ecd
Resolve some todos
Deniallugo Mar 27, 2024
04f1eb6
Return consensus config
Deniallugo Mar 27, 2024
3d8ef8b
Load configs from files
Deniallugo Mar 27, 2024
26a88b5
Fix configs
Deniallugo Mar 27, 2024
0d49e13
Merge branch 'main' into deniallugo-implement-protobuf-for-new-configs
Deniallugo Mar 27, 2024
d5d645f
Remove old crypto primitives
Deniallugo Mar 27, 2024
9e56a3b
Review suggestions
Deniallugo Mar 27, 2024
8245c2c
Fix tests
Deniallugo Mar 27, 2024
609807f
Use fee address from wallets
Deniallugo Mar 28, 2024
538c0fb
Load wallets correctly
Deniallugo Mar 28, 2024
5458fa4
Fix
Deniallugo Mar 28, 2024
ce615cc
Fix general config file only monitoring and snapshot creator
Deniallugo Mar 28, 2024
ccd0546
Add snapshot creator
Deniallugo Mar 28, 2024
bc99057
Add observability and snatpshot creator
Deniallugo Mar 29, 2024
5086645
make eth configs optional
Deniallugo Mar 29, 2024
ee88e97
Merge branch 'main' into deniallugo-implement-protobuf-for-new-configs
Deniallugo Mar 29, 2024
18a9517
Move l1_batch_commit_data_to_genesis
Deniallugo Mar 29, 2024
7bf9795
Add test for config verification
Deniallugo Mar 29, 2024
3755d9e
Fix review
Deniallugo Mar 29, 2024
f1e2cd8
Merge branch 'main' into deniallugo-implement-protobuf-for-new-configs
Deniallugo Apr 1, 2024
8d42925
fix tests
Deniallugo Apr 1, 2024
057de9a
Change prover to verifier
Deniallugo Apr 1, 2024
4b480ce
Fix encode decode
Deniallugo Apr 1, 2024
80b98c8
add deprecation note
Deniallugo Apr 1, 2024
1d199a0
Split address wallets and private key wallets
Deniallugo Apr 1, 2024
c753c93
Move sqlx back
Deniallugo Apr 1, 2024
3c2b3b6
Merge branch 'main' into deniallugo-implement-protobuf-for-new-configs
Deniallugo Apr 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Cargo.lock

/etc/env/*
!/etc/env/base
!/etc/env/file_based
!/etc/env/dev.toml
!/etc/env/dev_validium.toml
!/etc/env/dev_validium_docker.toml
Expand Down
41 changes: 30 additions & 11 deletions Cargo.lock

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

24 changes: 12 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,12 @@ members = [
"core/lib/vm_utils",
"core/lib/web3_decl",
"core/lib/snapshots_applier",

"core/lib/crypto_primitives",
# Test infrastructure
"core/tests/test_account",
"core/tests/loadnext",
"core/tests/vm-benchmark",
"core/tests/vm-benchmark/harness",

# SDK section
"sdk/zksync-rs",
]
Expand Down Expand Up @@ -167,16 +166,16 @@ zk_evm_1_3_1 = { package = "zk_evm", git = "https://github.com/matter-labs/era-z
zk_evm_1_3_3 = { package = "zk_evm", git = "https://github.com/matter-labs/era-zk_evm.git", tag = "v1.3.3-rc2" }
zk_evm_1_4_0 = { package = "zk_evm", git = "https://github.com/matter-labs/era-zk_evm.git", branch = "v1.4.0" }
zk_evm_1_4_1 = { package = "zk_evm", git = "https://github.com/matter-labs/era-zk_evm.git", branch = "v1.4.1" }
zksync_concurrency = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "ce9279566ae9653c6da61b499e89c0779d601484" }
zksync_consensus_bft = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "ce9279566ae9653c6da61b499e89c0779d601484" }
zksync_consensus_crypto = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "ce9279566ae9653c6da61b499e89c0779d601484" }
zksync_consensus_executor = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "ce9279566ae9653c6da61b499e89c0779d601484" }
zksync_consensus_network = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "ce9279566ae9653c6da61b499e89c0779d601484" }
zksync_consensus_roles = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "ce9279566ae9653c6da61b499e89c0779d601484" }
zksync_consensus_storage = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "ce9279566ae9653c6da61b499e89c0779d601484" }
zksync_consensus_utils = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "ce9279566ae9653c6da61b499e89c0779d601484" }
zksync_protobuf = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "ce9279566ae9653c6da61b499e89c0779d601484" }
zksync_protobuf_build = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "ce9279566ae9653c6da61b499e89c0779d601484" }
zksync_concurrency = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "8833a9b7fef89d1ffc5c08d53a3560164bc1c694" }
zksync_consensus_bft = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "8833a9b7fef89d1ffc5c08d53a3560164bc1c694" }
zksync_consensus_crypto = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "8833a9b7fef89d1ffc5c08d53a3560164bc1c694" }
zksync_consensus_executor = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "8833a9b7fef89d1ffc5c08d53a3560164bc1c694" }
zksync_consensus_network = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "8833a9b7fef89d1ffc5c08d53a3560164bc1c694" }
zksync_consensus_roles = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "8833a9b7fef89d1ffc5c08d53a3560164bc1c694" }
zksync_consensus_storage = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "8833a9b7fef89d1ffc5c08d53a3560164bc1c694" }
zksync_consensus_utils = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "8833a9b7fef89d1ffc5c08d53a3560164bc1c694" }
zksync_protobuf = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "8833a9b7fef89d1ffc5c08d53a3560164bc1c694" }
zksync_protobuf_build = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "8833a9b7fef89d1ffc5c08d53a3560164bc1c694" }

# "Local" dependencies
multivm = { path = "core/lib/multivm" }
Expand Down Expand Up @@ -215,3 +214,4 @@ zksync_test_account = { path = "core/tests/test_account" }
zksync_types = { path = "core/lib/types" }
zksync_utils = { path = "core/lib/utils" }
zksync_web3_decl = { path = "core/lib/web3_decl" }
zksync_crypto_primitives = { path = "core/lib/crypto_primitives" }
16 changes: 9 additions & 7 deletions core/bin/block_reverter/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use anyhow::Context as _;
use clap::{Parser, Subcommand};
use tokio::io::{self, AsyncReadExt};
use zksync_config::{
configs::ObservabilityConfig, ContractsConfig, DBConfig, ETHClientConfig, ETHSenderConfig,
PostgresConfig,
configs::ObservabilityConfig, ContractsConfig, DBConfig, ETHConfig, PostgresConfig,
};
use zksync_core::block_reverter::{
BlockReverter, BlockReverterEthConfig, BlockReverterFlags, L1ExecutedBatchesRevert, NodeRole,
Expand Down Expand Up @@ -87,14 +86,17 @@ async fn main() -> anyhow::Result<()> {
}
let _guard = builder.build();

let eth_sender = ETHSenderConfig::from_env().context("ETHSenderConfig::from_env()")?;
let eth_sender = ETHConfig::from_env().context("ETHSenderConfig::from_env()")?;
let db_config = DBConfig::from_env().context("DBConfig::from_env()")?;
let eth_client = ETHClientConfig::from_env().context("ETHClientConfig::from_env()")?;
let default_priority_fee_per_gas =
U256::from(eth_sender.gas_adjuster.default_priority_fee_per_gas);
let default_priority_fee_per_gas = U256::from(
eth_sender
.gas_adjuster
.context("gas_adjuster")?
.default_priority_fee_per_gas,
);
let contracts = ContractsConfig::from_env().context("ContractsConfig::from_env()")?;
let postgres_config = PostgresConfig::from_env().context("PostgresConfig::from_env()")?;
let config = BlockReverterEthConfig::new(eth_sender, contracts, eth_client.web3_url.clone());
let config = BlockReverterEthConfig::new(eth_sender, contracts);

let connection_pool = ConnectionPool::<Core>::builder(
postgres_config.master_url()?,
Expand Down
30 changes: 26 additions & 4 deletions core/bin/external_node/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use zksync_types::{api::BridgeAddresses, fee_model::FeeParams};
use zksync_web3_decl::{
error::ClientRpcContext,
jsonrpsee::http_client::{HttpClient, HttpClientBuilder},
namespaces::{EthNamespaceClient, ZksNamespaceClient},
namespaces::{EnNamespaceClient, EthNamespaceClient, ZksNamespaceClient},
};

pub(crate) mod observability;
Expand All @@ -30,6 +30,8 @@ const BYTES_IN_MEGABYTE: usize = 1_024 * 1_024;
#[derive(Debug, Deserialize, Clone, PartialEq)]
pub struct RemoteENConfig {
pub bridgehub_proxy_addr: Option<Address>,
pub state_transition_proxy_addr: Option<Address>,
pub transparent_proxy_admin_addr: Option<Address>,
pub diamond_proxy_addr: Address,
pub l1_erc20_bridge_proxy_addr: Address,
pub l2_erc20_bridge_addr: Address,
Expand All @@ -39,6 +41,8 @@ pub struct RemoteENConfig {
pub l2_chain_id: L2ChainId,
pub l1_chain_id: L1ChainId,
pub max_pubdata_per_batch: u64,
pub l1_batch_commit_data_generator_mode: L1BatchCommitDataGeneratorMode,
pub dummy_verifier: bool,
}

impl RemoteENConfig {
Expand All @@ -51,8 +55,8 @@ impl RemoteENConfig {
.get_testnet_paymaster()
.rpc_context("get_testnet_paymaster")
.await?;
// In case EN is connected to the old server version without `get_bridgehub_contract` method.
let bridgehub_proxy_addr = client.get_bridgehub_contract().await.ok().flatten();
let genesis = client.genesis_config().rpc_context("genesis").await.ok();
let shared_bridge = genesis.as_ref().and_then(|a| a.shared_bridge.clone());
let diamond_proxy_addr = client
.get_main_contract()
.rpc_context("get_main_contract")
Expand All @@ -77,7 +81,13 @@ impl RemoteENConfig {
};

Ok(Self {
bridgehub_proxy_addr,
bridgehub_proxy_addr: shared_bridge.as_ref().map(|a| a.bridgehub_proxy_addr),
state_transition_proxy_addr: shared_bridge
.as_ref()
.map(|a| a.state_transition_proxy_addr),
transparent_proxy_admin_addr: shared_bridge
.as_ref()
.map(|a| a.transparent_proxy_admin_addr),
diamond_proxy_addr,
l2_testnet_paymaster_addr,
l1_erc20_bridge_proxy_addr: bridges.l1_erc20_default_bridge,
Expand All @@ -87,6 +97,14 @@ impl RemoteENConfig {
l2_chain_id,
l1_chain_id,
max_pubdata_per_batch,
l1_batch_commit_data_generator_mode: genesis
.as_ref()
.map(|a| a.l1_batch_commit_data_generator_mode)
.unwrap_or_default(),
dummy_verifier: genesis
.as_ref()
.map(|a| a.dummy_verifier)
.unwrap_or_default(),
})
}
}
Expand Down Expand Up @@ -676,13 +694,17 @@ impl From<ExternalNodeConfig> for InternalApiConfig {
l2_weth_bridge: config.remote.l2_weth_bridge_addr,
},
bridgehub_proxy_addr: config.remote.bridgehub_proxy_addr,
state_transition_proxy_addr: config.remote.state_transition_proxy_addr,
transparent_proxy_admin_addr: config.remote.transparent_proxy_admin_addr,
diamond_proxy_addr: config.remote.diamond_proxy_addr,
l2_testnet_paymaster_addr: config.remote.l2_testnet_paymaster_addr,
req_entities_limit: config.optional.req_entities_limit,
fee_history_limit: config.optional.fee_history_limit,
filters_disabled: config.optional.filters_disabled,
mempool_cache_update_interval: config.optional.mempool_cache_update_interval(),
mempool_cache_size: config.optional.mempool_cache_size,
dummy_verifier: config.remote.dummy_verifier,
l1_batch_commit_data_generator_mode: config.remote.l1_batch_commit_data_generator_mode,
}
}
}
Expand Down
1 change: 1 addition & 0 deletions core/bin/external_node/src/config/observability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ pub fn observability_config_from_env() -> anyhow::Result<ObservabilityConfig> {
sentry_environment,
log_format,
opentelemetry: None,
sporadic_crypto_errors_substrs: vec![],
})
}
2 changes: 2 additions & 0 deletions core/bin/snapshots_creator/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ use super::*;
const TEST_CONFIG: SnapshotsCreatorConfig = SnapshotsCreatorConfig {
storage_logs_chunk_size: 1_000_000,
concurrent_queries_count: 10,
object_store: None,
};
const SEQUENTIAL_TEST_CONFIG: SnapshotsCreatorConfig = SnapshotsCreatorConfig {
storage_logs_chunk_size: 1_000_000,
concurrent_queries_count: 1,
object_store: None,
};

#[derive(Debug)]
Expand Down
1 change: 1 addition & 0 deletions core/bin/zksync_server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ publish = false
[dependencies]
zksync_config.workspace = true
zksync_env_config.workspace = true
zksync_protobuf_config.workspace = true
zksync_storage.workspace = true
zksync_utils.workspace = true
zksync_types.workspace = true
Expand Down