node.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 use crate::common::test_peer::sample_genesis_block; 20 21 use alphaos_account::Account; 22 use alphaos_node::{Client, Prover, Validator}; 23 use alphaos_utilities::SignalHandler; 24 25 use alphavm::prelude::{store::helpers::memory::ConsensusMemory, MainnetV0 as CurrentNetwork}; 26 27 use alphastd::StorageMode; 28 use std::str::FromStr; 29 30 pub async fn client() -> Client<CurrentNetwork, ConsensusMemory<CurrentNetwork>> { 31 Client::new( 32 "127.0.0.1:0".parse().unwrap(), 33 None, 34 10, 35 Account::<CurrentNetwork>::from_str("APrivateKey1zkp2oVPTci9kKcUprnbzMwq95Di1MQERpYBhEeqvkrDirK1").unwrap(), 36 &[], 37 sample_genesis_block(), 38 None, // No CDN. 39 StorageMode::new_test(None), 40 false, // Connect to untrusted peers. 41 None, 42 SignalHandler::new(), 43 ) 44 .await 45 .expect("couldn't create client instance") 46 } 47 48 pub async fn prover() -> Prover<CurrentNetwork, ConsensusMemory<CurrentNetwork>> { 49 Prover::new( 50 "127.0.0.1:0".parse().unwrap(), 51 Account::<CurrentNetwork>::from_str("APrivateKey1zkp2oVPTci9kKcUprnbzMwq95Di1MQERpYBhEeqvkrDirK1").unwrap(), 52 &[], 53 sample_genesis_block(), 54 StorageMode::new_test(None), 55 false, 56 None, 57 SignalHandler::new(), 58 ) 59 .await 60 .expect("couldn't create prover instance") 61 } 62 63 pub async fn validator() -> Validator<CurrentNetwork, ConsensusMemory<CurrentNetwork>> { 64 Validator::new( 65 "127.0.0.1:0".parse().unwrap(), 66 None, 67 None, 68 10, 69 Account::<CurrentNetwork>::from_str("APrivateKey1zkp2oVPTci9kKcUprnbzMwq95Di1MQERpYBhEeqvkrDirK1").unwrap(), 70 &[], 71 &[], 72 sample_genesis_block(), // Should load the current network's genesis block. 73 None, // No CDN. 74 StorageMode::new_test(None), 75 false, // This test requires validators to connect to peers. 76 false, // No dev traffic in production mode. 77 None, 78 SignalHandler::new(), 79 ) 80 .await 81 .expect("couldn't create validator instance") 82 }