snarkos_node/
lib.rs

1// Copyright 2024 Aleo Network Foundation
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    }
62}
63
64/// Starts the notification message loop.
65pub fn start_notification_message_loop() -> tokio::task::JoinHandle<()> {
66    // let mut interval = tokio::time::interval(std::time::Duration::from_secs(180));
67    tokio::spawn(async move {
68        //     loop {
69        //         interval.tick().await;
70        //         // TODO (howardwu): Swap this with the official message for announcements.
71        //         // info!("{}", notification_message());
72        //     }
73    })
74}
75
76/// Returns the notification message as a string.
77pub fn notification_message() -> String {
78    use colored::Colorize;
79
80    let mut output = String::new();
81    output += &r#"
82
83 ==================================================================================================
84
85                     🚧 Welcome to Aleo - Calibration Period 🚧
86
87 ==================================================================================================
88
89     During the calibration period, the network will be running in limited capacity.
90
91     This calibration period is to ensure validators are stable and ready for mainnet launch.
92     During this period, the objective is to assess, adjust, and align validators' performance,
93     stability, and interoperability under varying network conditions.
94
95     Please expect several network resets. With each network reset, software updates will
96     be performed to address potential bottlenecks, vulnerabilities, and/or inefficiencies, which
97     will ensure optimal performance for the ecosystem of validators, provers, and developers.
98
99 ==================================================================================================
100
101    Duration:
102    - Start Date: September 27, 2023
103    - End Date: October 18, 2023 (subject to change)
104
105    Participation:
106    - Node operators are NOT REQUIRED to participate during this calibration period.
107
108    Network Resets:
109    - IMPORTANT: EXPECT MULTIPLE NETWORK RESETS.
110    - If participating, BE PREPARED TO RESET YOUR NODE AT ANY TIME.
111    - When a reset occurs, RUN THE FOLLOWING TO RESET YOUR NODE:
112        - git checkout mainnet && git pull
113        - cargo install --locked --path .
114        - snarkos clean
115        - snarkos start --nodisplay --client
116
117    Communication:
118    - Stay ONLINE and MONITOR our Discord and Twitter for community updates.
119
120    Purpose:
121    - This period is STRICTLY FOR NETWORK CALIBRATION.
122    - This period is NOT INTENDED for general-purpose usage by developers and provers.
123
124    Incentives:
125    - There are NO INCENTIVES during this calibration period.
126
127 ==================================================================================================
128"#
129    .white()
130    .bold();
131
132    output
133}