Skip to content

Commit 6423b0d

Browse files
authored
feat: Proof manager watcher (#4241)
## What ❔ Basic implementation of ETH proof manager watcher part. This PR implements basic listening(with just logging received events) for event from proof manager contracts Parts of this PR are stubs, which should be filled in in coming changes. ## Why ❔ This is the part of proving networks integration ## Is this a breaking change? - [ ] Yes - [x] No ## Operational changes <!-- Any config changes? Any new flags? Any changes to any scripts? --> <!-- Please add anything that non-Matter Labs entities running their own ZK Chain may need to know --> ## 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 `zkstack dev fmt` and `zkstack dev lint`.
1 parent 23bfc94 commit 6423b0d

File tree

25 files changed

+820
-14
lines changed

25 files changed

+820
-14
lines changed

core/Cargo.lock

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ members = [
4242
"node/da_clients",
4343
"node/gateway_migrator",
4444
"node/zk_os_tree_manager",
45+
"node/eth_proof_manager",
4546
# Libraries
4647
"lib/db_connection",
4748
"lib/basic_types",
@@ -325,6 +326,7 @@ zksync_node_framework = { version = "28.9.0-non-semver-compat", path = "lib/node
325326
zksync_node_framework_derive = { version = "28.9.0-non-semver-compat", path = "lib/node_framework_derive" }
326327
zksync_shared_resources = { version = "28.9.0-non-semver-compat", path = "lib/shared_resources" }
327328
zksync_node_jemalloc = { version = "28.9.0-non-semver-compat", path = "node/jemalloc" }
329+
zksync_eth_proof_manager = { version = "28.9.0-non-semver-compat", path = "node/eth_proof_manager" }
328330
zksync_eth_watch = { version = "28.9.0-non-semver-compat", path = "node/eth_watch" }
329331
zksync_shared_metrics = { version = "28.9.0-non-semver-compat", path = "node/shared_metrics" }
330332
zksync_proof_data_handler = { version = "28.9.0-non-semver-compat", path = "node/proof_data_handler" }

core/bin/zksync_server/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ zksync_state_keeper.workspace = true
4747
zksync_shared_resources.workspace = true
4848
zksync_tee_proof_data_handler.workspace = true
4949
zksync_vm_runner.workspace = true
50+
zksync_eth_proof_manager.workspace = true
5051

5152
# Consensus dependenices
5253
zksync_consensus_crypto.workspace = true

core/bin/zksync_server/src/components.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ pub(crate) enum Component {
1212
Tree,
1313
/// Merkle tree API.
1414
TreeApi,
15+
/// Eth proof manager. Component for interacting with proof manager (proof distribution contracts)
16+
EthProofManager,
1517
EthWatcher,
1618
/// Eth tx generator.
1719
EthTxAggregator,
@@ -63,6 +65,7 @@ impl FromStr for Components {
6365
"tree_api" => Ok(Components(vec![Component::TreeApi])),
6466
"state_keeper" => Ok(Components(vec![Component::StateKeeper])),
6567
"housekeeper" => Ok(Components(vec![Component::Housekeeper])),
68+
"eth_proof_manager" => Ok(Components(vec![Component::EthProofManager])),
6669
"eth" => Ok(Components(vec![
6770
Component::EthWatcher,
6871
Component::EthTxAggregator,

core/bin/zksync_server/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ fn main() -> anyhow::Result<()> {
138138
// it'd be possible to get rid of settlement_layer_specific_contracts in our configs.
139139
// For easier refactoring in the future. We can mark it as Optional
140140
l1_sl_contracts: Some(contracts_config.settlement_layer_specific_contracts()),
141+
eth_proof_manager_contracts: Some(contracts_config.eth_proof_manager_contracts()),
141142
multicall3: Some(contracts_config.l1.multicall3_addr),
142143
};
143144

core/bin/zksync_server/src/node_builder.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ use zksync_config::{
1616
api::Namespace,
1717
consensus::ConsensusConfig,
1818
contracts::{
19-
chain::L2Contracts, ecosystem::L1SpecificContracts, SettlementLayerSpecificContracts,
19+
chain::{L2Contracts, ProofManagerContracts},
20+
ecosystem::L1SpecificContracts,
21+
SettlementLayerSpecificContracts,
2022
},
2123
da_client::DAClientConfig,
2224
secrets::DataAvailabilitySecrets,
@@ -37,6 +39,7 @@ use zksync_eth_client::{
3739
node::{BridgeAddressesUpdaterLayer, PKSigningEthClientLayer},
3840
web3_decl::node::QueryEthClientLayer,
3941
};
42+
use zksync_eth_proof_manager::node::EthProofManagerLayer;
4043
use zksync_eth_sender::node::{EthTxAggregatorLayer, EthTxManagerLayer};
4144
use zksync_eth_watch::node::EthWatchLayer;
4245
use zksync_external_proof_integration_api::node::ExternalProofIntegrationApiLayer;
@@ -102,6 +105,7 @@ pub(crate) struct MainNodeBuilder {
102105
// if use pre v26 contracts and not all functions are available for loading contracts
103106
pub l1_sl_contracts: Option<SettlementLayerSpecificContracts>,
104107
pub l2_contracts: L2Contracts,
108+
pub eth_proof_manager_contracts: Option<ProofManagerContracts>,
105109
pub multicall3: Option<Address>,
106110
}
107111

@@ -283,6 +287,16 @@ impl MainNodeBuilder {
283287
Ok(self)
284288
}
285289

290+
fn add_eth_proof_manager_layer(mut self) -> anyhow::Result<Self> {
291+
self.node.add_layer(EthProofManagerLayer::new(
292+
self.configs.eth_proof_manager.clone(),
293+
self.eth_proof_manager_contracts
294+
.clone()
295+
.expect("Eth proof manager contracts are required to run eth proof manager"),
296+
));
297+
Ok(self)
298+
}
299+
286300
fn add_eth_watch_layer(mut self) -> anyhow::Result<Self> {
287301
let eth_config = try_load_config!(self.configs.eth);
288302
self.node.add_layer(EthWatchLayer::new(
@@ -806,6 +820,9 @@ impl MainNodeBuilder {
806820
);
807821
// Do nothing, will be handled by the `Tree` component.
808822
}
823+
Component::EthProofManager => {
824+
self = self.add_eth_proof_manager_layer()?;
825+
}
809826
Component::EthWatcher => {
810827
self = self.add_eth_watch_layer()?;
811828
}

core/lib/config/src/configs/contracts/chain.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,10 @@ impl ContractsConfig {
241241
}
242242
}
243243

244+
pub fn eth_proof_manager_contracts(&self) -> ProofManagerContracts {
245+
self.proof_manager_contracts.clone()
246+
}
247+
244248
pub(crate) fn insert_into_schema(schema: &mut ConfigSchema) {
245249
schema.insert(&Self::DESCRIPTION, "contracts").unwrap();
246250
schema
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
use std::time::Duration;
2+
3+
use smart_config::{DescribeConfig, DeserializeConfig};
4+
5+
#[derive(Debug, Clone, PartialEq, DescribeConfig, DeserializeConfig)]
6+
pub struct EthProofManagerConfig {
7+
#[config(default_t = Duration::from_secs(10))]
8+
pub event_poll_interval: Duration,
9+
#[config(default_t = 1000)]
10+
pub event_expiration_blocks: u64,
11+
}
12+
13+
impl Default for EthProofManagerConfig {
14+
fn default() -> Self {
15+
Self {
16+
event_poll_interval: Duration::from_secs(10),
17+
event_expiration_blocks: 1000,
18+
}
19+
}
20+
}

core/lib/config/src/configs/general.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use crate::{
66
chain::{CircuitBreakerConfig, MempoolConfig, StateKeeperConfig, TimestampAsserterConfig},
77
consensus::ConsensusConfig,
88
da_dispatcher::DADispatcherConfig,
9+
eth_proof_manager::EthProofManagerConfig,
910
house_keeper::HouseKeeperConfig,
1011
prover_job_monitor::ProverJobMonitorConfig,
1112
pruning::PruningConfig,
@@ -58,6 +59,8 @@ pub struct GeneralConfig {
5859
pub db_config: DBConfig,
5960
#[config(nest)]
6061
pub eth: Option<EthConfig>,
62+
#[config(nest, default)]
63+
pub eth_proof_manager: EthProofManagerConfig,
6164
#[config(nest)]
6265
pub snapshot_creator: Option<SnapshotsCreatorConfig>,
6366
#[config(nest)]

core/lib/config/src/configs/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ pub mod contracts;
4848
pub mod da_client;
4949
pub mod da_dispatcher;
5050
pub mod database;
51+
pub mod eth_proof_manager;
5152
pub mod eth_sender;
5253
pub mod eth_watch;
5354
mod experimental;

0 commit comments

Comments
 (0)