/ node / src / lib.rs
lib.rs
  1  // Copyright (c) 2025-2026 ACDC Network
  2  // This file is part of the alphaos library.
  3  //
  4  // Alpha Chain | Delta Chain Protocol
  5  // International Monetary Graphite.
  6  //
  7  // Derived from Aleo (https://aleo.org) and ProvableHQ (https://provable.com).
  8  // They built world-class ZK infrastructure. We installed the EASY button.
  9  // Their cryptography: elegant. Our modifications: bureaucracy-compatible.
 10  // Original brilliance: theirs. Robert's Rules: ours. Bugs: definitely ours.
 11  //
 12  // Original Aleo/ProvableHQ code subject to Apache 2.0 https://www.apache.org/licenses/LICENSE-2.0
 13  // All modifications and new work: CC0 1.0 Universal Public Domain Dedication.
 14  // No rights reserved. No permission required. No warranty. No refunds.
 15  //
 16  // https://creativecommons.org/publicdomain/zero/1.0/
 17  // SPDX-License-Identifier: CC0-1.0
 18  
 19  #![forbid(unsafe_code)]
 20  #![allow(clippy::too_many_arguments)]
 21  #![recursion_limit = "256"]
 22  
 23  #[macro_use]
 24  extern crate async_trait;
 25  #[macro_use]
 26  extern crate tracing;
 27  
 28  pub use alphaos_node_bft as bft;
 29  pub use alphaos_node_cdn as cdn;
 30  pub use alphaos_node_consensus as consensus;
 31  pub use alphaos_node_network as network;
 32  pub use alphaos_node_rest as rest;
 33  pub use alphaos_node_router as router;
 34  pub use alphaos_node_sync as sync;
 35  pub use alphaos_node_tcp as tcp;
 36  pub use alphavm;
 37  
 38  mod bootstrap_client;
 39  pub use bootstrap_client::*;
 40  
 41  mod client;
 42  pub use client::*;
 43  
 44  mod prover;
 45  pub use prover::*;
 46  
 47  mod validator;
 48  pub use validator::*;
 49  
 50  mod node;
 51  pub use node::*;
 52  
 53  mod traits;
 54  pub use traits::*;
 55  
 56  use alphastd::StorageMode;
 57  
 58  /// A helper to log instructions to recover.
 59  pub fn log_clean_error(storage_mode: &StorageMode) {
 60      match storage_mode {
 61          StorageMode::Production => error!("Storage corruption detected! Run `alphaos clean` to reset storage"),
 62          StorageMode::Development(id) => {
 63              error!("Storage corruption detected! Run `alphaos clean --dev {id}` to reset storage")
 64          }
 65          StorageMode::Custom(path, _) => {
 66              error!("Storage corruption detected! Run `alphaos clean --path {}` to reset storage", path.display())
 67          }
 68          StorageMode::Test(_) => {
 69              // Ephemeral location - no need for cleanups.
 70          }
 71      }
 72  }
 73  
 74  /// Starts the notification message loop.
 75  pub fn start_notification_message_loop() -> tokio::task::JoinHandle<()> {
 76      // let mut interval = tokio::time::interval(std::time::Duration::from_secs(180));
 77      tokio::spawn(async move {
 78          //     loop {
 79          //         interval.tick().await;
 80          //         // TODO (howardwu): Swap this with the official message for announcements.
 81          //         // info!("{}", notification_message());
 82          //     }
 83      })
 84  }
 85  
 86  /// Returns the notification message as a string.
 87  pub fn notification_message() -> String {
 88      use colored::Colorize;
 89  
 90      let mut output = String::new();
 91      output += &r#"
 92  
 93   ==================================================================================================
 94  
 95                       🚧 Welcome to Alpha - Calibration Period 🚧
 96  
 97   ==================================================================================================
 98  
 99       During the calibration period, the network will be running in limited capacity.
100  
101       This calibration period is to ensure validators are stable and ready for mainnet launch.
102       During this period, the objective is to assess, adjust, and align validators' performance,
103       stability, and interoperability under varying network conditions.
104  
105       Please expect several network resets. With each network reset, software updates will
106       be performed to address potential bottlenecks, vulnerabilities, and/or inefficiencies, which
107       will ensure optimal performance for the ecosystem of validators, provers, and developers.
108  
109   ==================================================================================================
110  
111      Duration:
112      - Start Date: September 27, 2023
113      - End Date: October 18, 2023 (subject to change)
114  
115      Participation:
116      - Node operators are NOT REQUIRED to participate during this calibration period.
117  
118      Network Resets:
119      - IMPORTANT: EXPECT MULTIPLE NETWORK RESETS.
120      - If participating, BE PREPARED TO RESET YOUR NODE AT ANY TIME.
121      - When a reset occurs, RUN THE FOLLOWING TO RESET YOUR NODE:
122          - git checkout mainnet && git pull
123          - cargo install --locked --path .
124          - alphaos clean
125          - alphaos start --nodisplay --client
126  
127      Communication:
128      - Stay ONLINE and MONITOR our Discord and Twitter for community updates.
129  
130      Purpose:
131      - This period is STRICTLY FOR NETWORK CALIBRATION.
132      - This period is NOT INTENDED for general-purpose usage by developers and provers.
133  
134      Incentives:
135      - There are NO INCENTIVES during this calibration period.
136  
137   ==================================================================================================
138  "#
139      .white()
140      .bold();
141  
142      output
143  }