snarkos_node/
lib.rs

1// Copyright (c) 2019-2025 Provable Inc.
2// This file is part of the snarkOS library.
3
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at:
7
8// http://www.apache.org/licenses/LICENSE-2.0
9
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16#![forbid(unsafe_code)]
17#![allow(clippy::too_many_arguments)]
18#![recursion_limit = "256"]
19
20#[macro_use]
21extern crate async_trait;
22#[macro_use]
23extern crate tracing;
24
25pub use snarkos_node_bft as bft;
26pub use snarkos_node_cdn as cdn;
27pub use snarkos_node_consensus as consensus;
28pub use snarkos_node_rest as rest;
29pub use snarkos_node_router as router;
30pub use snarkos_node_sync as sync;
31pub use snarkos_node_tcp as tcp;
32pub use snarkvm;
33
34mod client;
35pub use client::*;
36
37mod prover;
38pub use prover::*;
39
40mod validator;
41pub use validator::*;
42
43mod node;
44pub use node::*;
45
46mod traits;
47pub use traits::*;
48
49use aleo_std::StorageMode;
50
51/// A helper to log instructions to recover.
52pub fn log_clean_error(storage_mode: &StorageMode) {
53    match storage_mode {
54        StorageMode::Production => error!("Storage corruption detected! Run `snarkos clean` to reset storage"),
55        StorageMode::Development(id) => {
56            error!("Storage corruption detected! Run `snarkos clean --dev {id}` to reset storage")
57        }
58        StorageMode::Custom(path) => {
59            error!("Storage corruption detected! Run `snarkos clean --path {}` to reset storage", path.display())
60        }
61        StorageMode::Test(_) => {
62            // Ephemeral location - no need for cleanups.
63        }
64    }
65}
66
67/// Starts the notification message loop.
68pub fn start_notification_message_loop() -> tokio::task::JoinHandle<()> {
69    // let mut interval = tokio::time::interval(std::time::Duration::from_secs(180));
70    tokio::spawn(async move {
71        //     loop {
72        //         interval.tick().await;
73        //         // TODO (howardwu): Swap this with the official message for announcements.
74        //         // info!("{}", notification_message());
75        //     }
76    })
77}
78
79/// Returns the notification message as a string.
80pub fn notification_message() -> String {
81    use colored::Colorize;
82
83    let mut output = String::new();
84    output += &r#"
85
86 ==================================================================================================
87
88                     🚧 Welcome to Aleo - Calibration Period 🚧
89
90 ==================================================================================================
91
92     During the calibration period, the network will be running in limited capacity.
93
94     This calibration period is to ensure validators are stable and ready for mainnet launch.
95     During this period, the objective is to assess, adjust, and align validators' performance,
96     stability, and interoperability under varying network conditions.
97
98     Please expect several network resets. With each network reset, software updates will
99     be performed to address potential bottlenecks, vulnerabilities, and/or inefficiencies, which
100     will ensure optimal performance for the ecosystem of validators, provers, and developers.
101
102 ==================================================================================================
103
104    Duration:
105    - Start Date: September 27, 2023
106    - End Date: October 18, 2023 (subject to change)
107
108    Participation:
109    - Node operators are NOT REQUIRED to participate during this calibration period.
110
111    Network Resets:
112    - IMPORTANT: EXPECT MULTIPLE NETWORK RESETS.
113    - If participating, BE PREPARED TO RESET YOUR NODE AT ANY TIME.
114    - When a reset occurs, RUN THE FOLLOWING TO RESET YOUR NODE:
115        - git checkout mainnet && git pull
116        - cargo install --locked --path .
117        - snarkos clean
118        - snarkos start --nodisplay --client
119
120    Communication:
121    - Stay ONLINE and MONITOR our Discord and Twitter for community updates.
122
123    Purpose:
124    - This period is STRICTLY FOR NETWORK CALIBRATION.
125    - This period is NOT INTENDED for general-purpose usage by developers and provers.
126
127    Incentives:
128    - There are NO INCENTIVES during this calibration period.
129
130 ==================================================================================================
131"#
132    .white()
133    .bold();
134
135    output
136}