Skip to content

Commit 7b3877f

Browse files
authored
feat(node_framework): Document implementations (#2319)
## What ❔ Provides minimal documentation for the already present framework implementations. ## Why ❔ Accessibility. ## 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`.
1 parent c147b0c commit 7b3877f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+487
-86
lines changed

core/node/node_framework/src/implementations/layers/batch_status_updater.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ use crate::{
1111
wiring_layer::{WiringError, WiringLayer},
1212
};
1313

14+
/// Wiring layer for `BatchStatusUpdater`, part of the external node.
15+
///
16+
/// ## Requests resources
17+
///
18+
/// - `PoolResource<MasterPool>`
19+
/// - `MainNodeClientResource`
20+
/// - `AppHealthCheckResource` (adds a health check)
21+
///
22+
/// ## Adds tasks
23+
///
24+
/// - `BatchStatusUpdater`
1425
#[derive(Debug)]
1526
pub struct BatchStatusUpdaterLayer;
1627

core/node/node_framework/src/implementations/layers/circuit_breaker_checker.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ use crate::{
1414
/// [`zksync_circuit_breaker::CircuitBreakers`] collection using [`CircuitBreakersResource`].
1515
/// The added task periodically runs checks for all inserted circuit breakers.
1616
///
17-
/// ## Adds resources
18-
/// - [`CircuitBreakersResource`]
17+
/// ## Requests resources
18+
///
19+
/// - `CircuitBreakersResource`
1920
///
2021
/// ## Adds tasks
21-
/// - [`CircuitBreakerCheckerTask`] (as [`UnconstrainedTask`])
22+
///
23+
/// - `CircuitBreakerCheckerTask`
2224
#[derive(Debug)]
2325
pub struct CircuitBreakerCheckerLayer(pub CircuitBreakerConfig);
2426

core/node/node_framework/src/implementations/layers/commitment_generator.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ use crate::{
1818
/// Responsible for initialization and running [`CommitmentGenerator`].
1919
///
2020
/// ## Requests resources
21-
/// - [`PoolResource`] for [`MasterPool`]
22-
/// - [`AppHealthCheckResource`] (to add new health check)
21+
///
22+
/// - `PoolResource<MasterPool>`
23+
/// - `AppHealthCheckResource` (adds a health check)
2324
///
2425
/// ## Adds tasks
25-
/// - [`CommitmentGeneratorTask`] (as [`Task`])
26+
///
27+
/// - `CommitmentGeneratorTask`
2628
#[derive(Debug)]
2729
pub struct CommitmentGeneratorLayer {
2830
mode: L1BatchCommitmentMode,

core/node/node_framework/src/implementations/layers/consensus.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,20 @@ pub enum Mode {
2424
External,
2525
}
2626

27+
/// Wiring layer for consensus component.
28+
/// Can work in either "main" or "external" mode.
29+
///
30+
/// ## Requests resources
31+
///
32+
/// - `PoolResource<MasterPool>`
33+
/// - `MainNodeClientResource` (if `Mode::External`)
34+
/// - `SyncStateResource` (if `Mode::External`)
35+
/// - `ActionQueueSenderResource` (if `Mode::External`)
36+
///
37+
/// ## Adds tasks
38+
///
39+
/// - `MainNodeConsensusTask` (if `Mode::Main`)
40+
/// - `FetcherTask` (if `Mode::External`)
2741
#[derive(Debug)]
2842
pub struct ConsensusLayer {
2943
pub mode: Mode,

core/node/node_framework/src/implementations/layers/consistency_checker.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ use crate::{
1212
wiring_layer::{WiringError, WiringLayer},
1313
};
1414

15+
/// Wiring layer for the `ConsistencyChecker` (used by the external node).
16+
///
17+
/// ## Requests resources
18+
///
19+
/// - `EthInterfaceResource`
20+
/// - `PoolResource<MasterPool>`
21+
/// - `AppHealthCheckResource` (adds a health check)
22+
///
23+
/// ## Adds tasks
24+
///
25+
/// - `ConsistencyChecker`
1526
#[derive(Debug)]
1627
pub struct ConsistencyCheckerLayer {
1728
diamond_proxy_addr: Address,

core/node/node_framework/src/implementations/layers/contract_verification_api.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ use crate::{
1313
/// Responsible for initialization of the contract verification server.
1414
///
1515
/// ## Requests resources
16-
/// - [`PoolResource`] for [`MasterPool`]
17-
/// - [`PoolResource`] for [`ReplicaPool`]
16+
///
17+
/// - `PoolResource<MasterPool>`
18+
/// - `PoolResource<ReplicaPool>`
1819
///
1920
/// ## Adds tasks
20-
/// - [`ContractVerificationApiTask`] (as [`Task`])
21+
///
22+
/// - `ContractVerificationApiTask`
2123
#[derive(Debug)]
2224
pub struct ContractVerificationApiLayer(pub ContractVerifierConfig);
2325

core/node/node_framework/src/implementations/layers/eth_sender.rs

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,17 @@ use crate::{
2424
/// of `eth_txs`(such as `CommitBlocks`, `PublishProofBlocksOnchain` or `ExecuteBlock` ) to L1.
2525
///
2626
/// ## Requests resources
27-
/// - [`PoolResource`] for [`MasterPool`]
28-
/// - [`PoolResource`] for [`ReplicaPool`]
29-
/// - [`BoundEthInterfaceResource`]
30-
/// - [`BoundEthInterfaceForBlobsResource`]
31-
/// - [`L1TxParamsResource`]
32-
/// - [`CircuitBreakersResource`] (to add new circuit breaker)
27+
///
28+
/// - `PoolResource<MasterPool>`
29+
/// - `PoolResource<ReplicaPool>`
30+
/// - `BoundEthInterfaceResource`
31+
/// - `BoundEthInterfaceForBlobsResource` (optional)
32+
/// - `L1TxParamsResource`
33+
/// - `CircuitBreakersResource` (adds a circuit breaker)
3334
///
3435
/// ## Adds tasks
35-
/// - [`EthTxManagerTask`] (as [`Task`])
36+
///
37+
/// - `EthTxManager`
3638
#[derive(Debug)]
3739
pub struct EthTxManagerLayer {
3840
eth_sender_config: EthConfig,
@@ -79,9 +81,7 @@ impl WiringLayer for EthTxManagerLayer {
7981
eth_client_blobs,
8082
);
8183

82-
context.add_task(Box::new(EthTxManagerTask {
83-
eth_tx_manager_actor,
84-
}));
84+
context.add_task(Box::new(eth_tx_manager_actor));
8585

8686
// Insert circuit breaker.
8787
let CircuitBreakersResource { breakers } = context.get_resource_or_default().await;
@@ -100,15 +100,17 @@ impl WiringLayer for EthTxManagerLayer {
100100
/// These `eth_txs` will be used as a queue for generating signed txs and will be sent later on L1.
101101
///
102102
/// ## Requests resources
103-
/// - [`PoolResource`] for [`MasterPool`]
104-
/// - [`PoolResource`] for [`ReplicaPool`]
105-
/// - [`BoundEthInterfaceResource`]
106-
/// - [`BoundEthInterfaceForBlobsResource`]
107-
/// - [`ObjectStoreResource`]
108-
/// - [`CircuitBreakersResource`] (to add new circuit breaker)
103+
///
104+
/// - `PoolResource<MasterPool>`
105+
/// - `PoolResource<ReplicaPool>`
106+
/// - `BoundEthInterfaceResource`
107+
/// - `BoundEthInterfaceForBlobsResource` (optional)
108+
/// - `ObjectStoreResource`
109+
/// - `CircuitBreakersResource` (adds a circuit breaker)
109110
///
110111
/// ## Adds tasks
111-
/// - [`EthTxAggregatorTask`] (as [`Task`])
112+
///
113+
/// - `EthTxAggregator`
112114
#[derive(Debug)]
113115
pub struct EthTxAggregatorLayer {
114116
eth_sender_config: EthConfig,
@@ -183,9 +185,7 @@ impl WiringLayer for EthTxAggregatorLayer {
183185
)
184186
.await;
185187

186-
context.add_task(Box::new(EthTxAggregatorTask {
187-
eth_tx_aggregator_actor,
188-
}));
188+
context.add_task(Box::new(eth_tx_aggregator_actor));
189189

190190
// Insert circuit breaker.
191191
let CircuitBreakersResource { breakers } = context.get_resource_or_default().await;
@@ -197,34 +197,24 @@ impl WiringLayer for EthTxAggregatorLayer {
197197
}
198198
}
199199

200-
#[derive(Debug)]
201-
struct EthTxAggregatorTask {
202-
eth_tx_aggregator_actor: EthTxAggregator,
203-
}
204-
205200
#[async_trait::async_trait]
206-
impl Task for EthTxAggregatorTask {
201+
impl Task for EthTxAggregator {
207202
fn id(&self) -> TaskId {
208203
"eth_tx_aggregator".into()
209204
}
210205

211206
async fn run(self: Box<Self>, stop_receiver: StopReceiver) -> anyhow::Result<()> {
212-
self.eth_tx_aggregator_actor.run(stop_receiver.0).await
207+
(*self).run(stop_receiver.0).await
213208
}
214209
}
215210

216-
#[derive(Debug)]
217-
struct EthTxManagerTask {
218-
eth_tx_manager_actor: EthTxManager,
219-
}
220-
221211
#[async_trait::async_trait]
222-
impl Task for EthTxManagerTask {
212+
impl Task for EthTxManager {
223213
fn id(&self) -> TaskId {
224214
"eth_tx_manager".into()
225215
}
226216

227217
async fn run(self: Box<Self>, stop_receiver: StopReceiver) -> anyhow::Result<()> {
228-
self.eth_tx_manager_actor.run(stop_receiver.0).await
218+
(*self).run(stop_receiver.0).await
229219
}
230220
}

core/node/node_framework/src/implementations/layers/eth_watch.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ use crate::{
2222
/// such as priority operations (aka L1 transactions), protocol upgrades etc.
2323
///
2424
/// ## Requests resources
25-
/// - [`PoolResource`] for [`MasterPool`]
26-
/// - [`EthInterfaceResource`]
25+
///
26+
/// - `PoolResource<MasterPool>`
27+
/// - `EthInterfaceResource`
2728
///
2829
/// ## Adds tasks
29-
/// - [`EthWatchTask`] (as [`Task`])
30+
///
31+
/// - `EthWatchTask`
3032
#[derive(Debug)]
3133
pub struct EthWatchLayer {
3234
eth_watch_config: EthWatchConfig,

core/node/node_framework/src/implementations/layers/healtcheck_server.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ use crate::{
1717
/// into [`AppHealthCheck`] aggregating heath using [`AppHealthCheckResource`].
1818
/// The added task spawns a health check server that only exposes the state provided by other tasks.
1919
///
20-
/// ## Adds resources
21-
/// - [`AppHealthCheckResource`]
20+
/// ## Requests resources
21+
///
22+
/// - `AppHealthCheckResource`
2223
///
2324
/// ## Adds tasks
24-
/// - [`HealthCheckTask`] (as [`UnconstrainedTask`])
25+
///
26+
/// - `HealthCheckTask`
2527
#[derive(Debug)]
2628
pub struct HealthCheckLayer(pub HealthCheckConfig);
2729

core/node/node_framework/src/implementations/layers/house_keeper.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,26 @@ use crate::{
2020
wiring_layer::{WiringError, WiringLayer},
2121
};
2222

23+
/// Wiring layer for `HouseKeeper` - a component responsible for managing prover jobs
24+
/// and auxiliary server activities.
25+
///
26+
/// ## Requests resources
27+
///
28+
/// - `PoolResource<ReplicaPool>`
29+
/// - `PoolResource<ProverPool>`
30+
///
31+
/// ## Adds tasks
32+
///
33+
/// - `L1BatchMetricsReporterTask`
34+
/// - `FriProverJobRetryManagerTask`
35+
/// - `FriWitnessGeneratorJobRetryManagerTask`
36+
/// - `WaitingToQueuedFriWitnessJobMoverTask`
37+
/// - `FriProverJobArchiverTask`
38+
/// - `FriProverGpuArchiverTask`
39+
/// - `FriWitnessGeneratorStatsReporterTask`
40+
/// - `FriProverStatsReporterTask`
41+
/// - `FriProofCompressorStatsReporterTask`
42+
/// - `FriProofCompressorJobRetryManagerTask`
2343
#[derive(Debug)]
2444
pub struct HouseKeeperLayer {
2545
house_keeper_config: HouseKeeperConfig,
@@ -54,14 +74,14 @@ impl WiringLayer for HouseKeeperLayer {
5474
}
5575

5676
async fn wire(self: Box<Self>, mut context: ServiceContext<'_>) -> Result<(), WiringError> {
57-
// initialize resources
77+
// Initialize resources
5878
let replica_pool_resource = context.get_resource::<PoolResource<ReplicaPool>>().await?;
5979
let replica_pool = replica_pool_resource.get().await?;
6080

6181
let prover_pool_resource = context.get_resource::<PoolResource<ProverPool>>().await?;
6282
let prover_pool = prover_pool_resource.get().await?;
6383

64-
// initialize and add tasks
84+
// Initialize and add tasks
6585
let l1_batch_metrics_reporter = L1BatchMetricsReporter::new(
6686
self.house_keeper_config
6787
.l1_batch_metrics_reporting_interval_ms,

0 commit comments

Comments
 (0)