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