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_network as network;
29pub use snarkos_node_rest as rest;
30pub use snarkos_node_router as router;
31pub use snarkos_node_sync as sync;
32pub use snarkos_node_tcp as tcp;
33pub use snarkvm;
34
35mod bootstrap_client;
36pub use bootstrap_client::*;
37
38mod client;
39pub use client::*;
40
41mod prover;
42pub use prover::*;
43
44mod validator;
45pub use validator::*;
46
47mod node;
48pub use node::*;
49
50mod traits;
51pub use traits::*;
52
53use aleo_std::StorageMode;
54
55/// A helper to log instructions to recover.
56pub fn log_clean_error(storage_mode: &StorageMode) {
57    match storage_mode {
58        StorageMode::Production => error!("Storage corruption detected! Run `snarkos clean` to reset storage"),
59        StorageMode::Development(id) => {
60            error!("Storage corruption detected! Run `snarkos clean --dev {id}` to reset storage")
61        }
62        StorageMode::Custom(path) => {
63            error!("Storage corruption detected! Run `snarkos clean --path {}` to reset storage", path.display())
64        }
65        StorageMode::Test(_) => {
66            // Ephemeral location - no need for cleanups.
67        }
68    }
69}
70
71/// Starts the notification message loop.
72pub fn start_notification_message_loop() -> tokio::task::JoinHandle<()> {
73    // let mut interval = tokio::time::interval(std::time::Duration::from_secs(180));
74    tokio::spawn(async move {
75        //     loop {
76        //         interval.tick().await;
77        //         // TODO (howardwu): Swap this with the official message for announcements.
78        //         // info!("{}", notification_message());
79        //     }
80    })
81}
82
83/// Returns the notification message as a string.
84pub fn notification_message() -> String {
85    use colored::Colorize;
86
87    let mut output = String::new();
88    output += &r#"
89
90 ==================================================================================================
91
92                     🚧 Welcome to Aleo - Calibration Period 🚧
93
94 ==================================================================================================
95
96     During the calibration period, the network will be running in limited capacity.
97
98     This calibration period is to ensure validators are stable and ready for mainnet launch.
99     During this period, the objective is to assess, adjust, and align validators' performance,
100     stability, and interoperability under varying network conditions.
101
102     Please expect several network resets. With each network reset, software updates will
103     be performed to address potential bottlenecks, vulnerabilities, and/or inefficiencies, which
104     will ensure optimal performance for the ecosystem of validators, provers, and developers.
105
106 ==================================================================================================
107
108    Duration:
109    - Start Date: September 27, 2023
110    - End Date: October 18, 2023 (subject to change)
111
112    Participation:
113    - Node operators are NOT REQUIRED to participate during this calibration period.
114
115    Network Resets:
116    - IMPORTANT: EXPECT MULTIPLE NETWORK RESETS.
117    - If participating, BE PREPARED TO RESET YOUR NODE AT ANY TIME.
118    - When a reset occurs, RUN THE FOLLOWING TO RESET YOUR NODE:
119        - git checkout mainnet && git pull
120        - cargo install --locked --path .
121        - snarkos clean
122        - snarkos start --nodisplay --client
123
124    Communication:
125    - Stay ONLINE and MONITOR our Discord and Twitter for community updates.
126
127    Purpose:
128    - This period is STRICTLY FOR NETWORK CALIBRATION.
129    - This period is NOT INTENDED for general-purpose usage by developers and provers.
130
131    Incentives:
132    - There are NO INCENTIVES during this calibration period.
133
134 ==================================================================================================
135"#
136    .white()
137    .bold();
138
139    output
140}