From f793ae0b8e80928a3cdf4588acd0331746708167 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Tue, 31 Oct 2023 13:01:23 +0100 Subject: [PATCH 001/551] perf: use a blocking task for check_batch_header Signed-off-by: ljedrz --- node/bft/src/primary.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 1c3cf3aedf..68770b2dc6 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -520,7 +520,9 @@ impl Primary { self.ensure_is_signing_round(batch_round)?; // Ensure the batch header from the peer is valid. - let missing_transmissions = self.storage.check_batch_header(&batch_header, transmissions)?; + let storage = self.storage.clone(); + let header = batch_header.clone(); + let missing_transmissions = spawn_blocking!(storage.check_batch_header(&header, transmissions))?; // Inserts the missing transmissions into the workers. self.insert_missing_transmissions_into_workers(peer_ip, missing_transmissions.into_iter())?; From 04b9526b49906f278b715473ddf6b021444b66a1 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Tue, 31 Oct 2023 13:02:46 +0100 Subject: [PATCH 002/551] perf: use a blocking task for insert_certificate Signed-off-by: ljedrz --- node/bft/src/primary.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 68770b2dc6..cd26664501 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -1097,7 +1097,9 @@ impl Primary { // Note: Do not change the `Proposal` to use a HashMap. The ordering there is necessary for safety. let transmissions = transmissions.into_iter().collect::>(); // Store the certified batch. - self.storage.insert_certificate(certificate.clone(), transmissions)?; + let storage = self.storage.clone(); + let certificate_clone = certificate.clone(); + spawn_blocking!(storage.insert_certificate(certificate_clone, transmissions))?; debug!("Stored a batch certificate for round {}", certificate.round()); // If a BFT sender was provided, send the certificate to the BFT. if let Some(bft_sender) = self.bft_sender.get() { @@ -1176,7 +1178,9 @@ impl Primary { // Check if the certificate needs to be stored. if !self.storage.contains_certificate(certificate.certificate_id()) { // Store the batch certificate. - self.storage.insert_certificate(certificate.clone(), missing_transmissions)?; + let storage = self.storage.clone(); + let certificate_clone = certificate.clone(); + spawn_blocking!(storage.insert_certificate(certificate_clone, missing_transmissions))?; debug!("Stored a batch certificate for round {batch_round} from '{peer_ip}'"); // If a BFT sender was provided, send the round and certificate to the BFT. if let Some(bft_sender) = self.bft_sender.get() { From 46d6afcbd7047122d9e1c862578955ddb2c8553f Mon Sep 17 00:00:00 2001 From: ljedrz Date: Tue, 31 Oct 2023 13:22:17 +0100 Subject: [PATCH 003/551] perf: use a blocking task for sync_certificate_with_block Signed-off-by: ljedrz --- node/bft/src/sync/mod.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index a43e7963f6..53826060ad 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -14,6 +14,7 @@ use crate::{ helpers::{BFTSender, Pending, Storage, SyncReceiver}, + spawn_blocking, Gateway, Transport, MAX_BATCH_DELAY, @@ -202,9 +203,11 @@ impl Sync { // If the block authority is a subdag, then sync the batch certificates with the block. if let Authority::Quorum(subdag) = block.authority() { // Iterate over the certificates. - for certificate in subdag.values().flatten() { + for certificate in subdag.values().flatten().cloned() { // Sync the batch certificate with the block. - self.storage.sync_certificate_with_block(block, certificate); + let storage = self.storage.clone(); + let block = block.clone(); + let _ = spawn_blocking!(Ok(storage.sync_certificate_with_block(&block, &certificate))); } } } @@ -276,7 +279,10 @@ impl Sync { // Iterate over the certificates. for certificate in subdag.values().flatten() { // Sync the batch certificate with the block. - self.storage.sync_certificate_with_block(&block, certificate); + let storage = self.storage.clone(); + let block_clone = block.clone(); + let certificate_clone = certificate.clone(); + let _ = spawn_blocking!(Ok(storage.sync_certificate_with_block(&block_clone, &certificate_clone))); // If a BFT sender was provided, send the certificate to the BFT. if let Some(bft_sender) = self.bft_sender.get() { // Await the callback to continue. From 83721459d46981bb276011c85db1defc58dec231 Mon Sep 17 00:00:00 2001 From: Jos Dehaes Date: Tue, 17 Oct 2023 15:27:20 +0200 Subject: [PATCH 004/551] fix: update simple_node --- node/bft/examples/simple_node.rs | 101 ++++++++++++++++++++++++++++--- 1 file changed, 92 insertions(+), 9 deletions(-) diff --git a/node/bft/examples/simple_node.rs b/node/bft/examples/simple_node.rs index 528293cc53..edb7d8a323 100644 --- a/node/bft/examples/simple_node.rs +++ b/node/bft/examples/simple_node.rs @@ -23,20 +23,32 @@ use snarkos_node_bft::{ MAX_GC_ROUNDS, MEMORY_POOL_PORT, }; -use snarkos_node_bft_ledger_service::MockLedgerService; +use snarkos_node_bft_ledger_service::TranslucentLedgerService; use snarkos_node_bft_storage_service::BFTMemoryService; use snarkvm::{ + console::algorithms::BHP256, ledger::{ committee::{Committee, MIN_VALIDATOR_STAKE}, narwhal::Data, }, prelude::{ - block::Transaction, + block::{Block, Transaction}, coinbase::{ProverSolution, PuzzleCommitment}, + store::{helpers::memory::ConsensusMemory, ConsensusStore}, + Address, Field, + FromBytes, + Hash, + Ledger, Network, + PrivateKey, + TestRng, + ToBits, + ToBytes, Uniform, + VM, }, + utilities::to_bytes_le, }; use ::bytes::Bytes; @@ -51,8 +63,15 @@ use axum::{ use axum_extra::response::ErasedJson; use clap::{Parser, ValueEnum}; use indexmap::IndexMap; -use rand::{Rng, SeedableRng}; -use std::{collections::HashMap, net::SocketAddr, path::PathBuf, str::FromStr, sync::Arc}; +use parking_lot::Mutex; +use rand::{CryptoRng, Rng, SeedableRng}; +use std::{ + collections::HashMap, + net::SocketAddr, + path::PathBuf, + str::FromStr, + sync::{Arc, OnceLock}, +}; use tokio::sync::oneshot; use tracing_subscriber::{ layer::{Layer, SubscriberExt}, @@ -113,8 +132,17 @@ pub async fn start_bft( let (sender, receiver) = init_primary_channels(); // Initialize the components. let (committee, account) = initialize_components(node_id, num_nodes)?; - // Initialize the mock ledger service. - let ledger = Arc::new(MockLedgerService::new(committee)); + // Initialize the translucent ledger service. + let gen_key = account.private_key(); + let public_balance_per_validator = + (1_500_000_000_000_000 - (num_nodes as u64) * 1_000_000_000_000) / (num_nodes as u64); + let mut balances = IndexMap::, u64>::new(); + for address in committee.members().keys() { + balances.insert(*address, public_balance_per_validator); + } + let mut rng = TestRng::default(); + let gen_ledger = genesis_ledger(*gen_key, committee.clone(), balances.clone(), &mut rng); + let ledger = Arc::new(TranslucentLedgerService::new(gen_ledger)); // Initialize the storage. let storage = Storage::new(ledger.clone(), Arc::new(BFTMemoryService::new()), MAX_GC_ROUNDS); // Initialize the gateway IP and dev mode. @@ -142,10 +170,11 @@ pub async fn start_bft( /// Starts the primary instance. pub async fn start_primary( - node_id: u16, - num_nodes: u16, - peers: HashMap, + _node_id: u16, + _num_nodes: u16, + _peers: HashMap, ) -> Result<(Primary, PrimarySender)> { + /* // Initialize the primary channels. let (sender, receiver) = init_primary_channels(); // Initialize the components. @@ -169,6 +198,60 @@ pub async fn start_primary( handle_signals(&primary); // Return the primary instance. Ok((primary, sender)) + */ + todo!() +} + +pub type CurrentLedger = Ledger>; + +fn genesis_cache() -> &'static Mutex, Block>> { + static CACHE: OnceLock, Block>>> = OnceLock::new(); + CACHE.get_or_init(|| Mutex::new(HashMap::new())) +} + +fn genesis_block( + genesis_private_key: PrivateKey, + committee: Committee, + public_balances: IndexMap, u64>, + rng: &mut (impl Rng + CryptoRng), +) -> Block { + // Initialize the store. + let store = ConsensusStore::<_, ConsensusMemory<_>>::open(None).unwrap(); + // Initialize a new VM. + let vm = VM::from(store).unwrap(); + // Initialize the genesis block. + vm.genesis_quorum(&genesis_private_key, committee, public_balances, rng).unwrap() +} + +fn genesis_ledger( + genesis_private_key: PrivateKey, + committee: Committee, + public_balances: IndexMap, u64>, + rng: &mut (impl Rng + CryptoRng), +) -> CurrentLedger { + let cache_key = + to_bytes_le![genesis_private_key, committee, public_balances.iter().collect::>()].unwrap(); + // Initialize the genesis block on the first call; other callers + // will wait for it on the mutex. + let block = genesis_cache() + .lock() + .entry(cache_key.clone()) + .or_insert_with(|| { + let hasher = BHP256::::setup("aleo.dev.block").unwrap(); + let file_name = hasher.hash(&cache_key.to_bits_le()).unwrap().to_string() + ".genesis"; + let file_path = std::env::temp_dir().join(file_name); + if file_path.exists() { + let buffer = std::fs::read(file_path).unwrap(); + return Block::from_bytes_le(&buffer).unwrap(); + } + + let block = genesis_block(genesis_private_key, committee, public_balances, rng); + std::fs::write(&file_path, block.to_bytes_le().unwrap()).unwrap(); + block + }) + .clone(); + // Initialize the ledger with the genesis block. + CurrentLedger::load(block, None).unwrap() } /// Initializes the components of the node. From d4122b07baab41eeea28bf3a22995971876be861 Mon Sep 17 00:00:00 2001 From: Jos Dehaes Date: Mon, 23 Oct 2023 09:17:04 +0200 Subject: [PATCH 005/551] fix: start_primary --- node/bft/examples/simple_node.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/node/bft/examples/simple_node.rs b/node/bft/examples/simple_node.rs index edb7d8a323..225c692ac2 100644 --- a/node/bft/examples/simple_node.rs +++ b/node/bft/examples/simple_node.rs @@ -170,17 +170,24 @@ pub async fn start_bft( /// Starts the primary instance. pub async fn start_primary( - _node_id: u16, - _num_nodes: u16, - _peers: HashMap, + node_id: u16, + num_nodes: u16, + peers: HashMap, ) -> Result<(Primary, PrimarySender)> { - /* // Initialize the primary channels. let (sender, receiver) = init_primary_channels(); // Initialize the components. let (committee, account) = initialize_components(node_id, num_nodes)?; - // Initialize the mock ledger service. - let ledger = Arc::new(MockLedgerService::new(committee)); + let gen_key = account.private_key(); + let public_balance_per_validator = + (1_500_000_000_000_000 - (num_nodes as u64) * 1_000_000_000_000) / (num_nodes as u64); + let mut balances = IndexMap::, u64>::new(); + for address in committee.members().keys() { + balances.insert(*address, public_balance_per_validator); + } + let mut rng = TestRng::default(); + let gen_ledger = genesis_ledger(*gen_key, committee.clone(), balances.clone(), &mut rng); + let ledger = Arc::new(TranslucentLedgerService::new(gen_ledger)); // Initialize the storage. let storage = Storage::new(ledger.clone(), Arc::new(BFTMemoryService::new()), MAX_GC_ROUNDS); // Initialize the gateway IP and dev mode. @@ -198,8 +205,6 @@ pub async fn start_primary( handle_signals(&primary); // Return the primary instance. Ok((primary, sender)) - */ - todo!() } pub type CurrentLedger = Ledger>; From ba5e3fb616cae1e04b5ec231e015fe6975a4431b Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sat, 25 Nov 2023 16:50:48 -0800 Subject: [PATCH 006/551] Switches transmissions configs to snarkVM --- Cargo.lock | 172 +++++++++++-------------------- Cargo.toml | 6 +- node/bft/examples/simple_node.rs | 17 ++- node/bft/src/gateway.rs | 27 +++-- node/bft/src/helpers/storage.rs | 11 +- node/bft/src/lib.rs | 18 +--- node/bft/src/primary.rs | 3 +- node/bft/src/worker.rs | 26 +++-- node/bft/tests/common/primary.rs | 28 +++-- node/consensus/src/lib.rs | 12 +-- 10 files changed, 124 insertions(+), 196 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ba5816f31b..66e9968938 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3387,8 +3387,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4d6fb48420e229bc1249d228fcccc06ac3b0f19898b614f41d53b6f38b01b73" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "anstyle", "anyhow", @@ -3418,8 +3417,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcfbd2290969a801c1bafd23f51c7a8d8acef84c07e7599124aa3004328d341" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "aleo-std", "anyhow", @@ -3449,8 +3447,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d8072bc6ca7ae052c7e6f4e516aef2c9039c72affac9d6e663f5aa1dfa938b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3464,8 +3461,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9cacf35ad888287d323d34883fa9903ac92cca6a276ff7242afd4e2dc5c8a5c" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3476,8 +3472,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a431f3009222e1ae45a71f4e2774546ca5a61ecc59effb4857b3d206966ad3b2" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3487,8 +3482,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b9e454cb7edce9ada862a394e95081c4b82cb4426d6d266ee8302341f87c318" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3498,8 +3492,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55fc33c5c12d0e028ab825e4a3fe9ed6974551b4b0d382eee37d365e34537e74" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "indexmap 2.1.0", "itertools 0.11.0", @@ -3517,14 +3510,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39ba2b291e079e225db125ecf95d5e8e3f1895336abcefb2b36b0cb203a5e5a7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" [[package]] name = "snarkvm-circuit-network" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d547ed70ed9a1a5f2f9ad78a4a2ba4df6d64712fb656f3df8ad54b0682425c76" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3535,8 +3526,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14a7940f71ad60fb7b66b4bf7fc23e7253b2df3bd49b923314ade8de66c8e4d0" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3551,8 +3541,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "210d41a4c452f0b6025b4da2360a437b30a81e6f9eac203ac004a180e4fb6a04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3567,8 +3556,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "228cf239e1868534d5b682a4487c089094ba00ad27a641335aa77d38972fbe74" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3581,8 +3569,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a33a90e2594f783ee830e06c77243686ddd9755e8b5828c717311ea37bec756" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3591,8 +3578,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bcae4432523640af834a3050621ced7d7515e713b23b1eb12b39c4599f2fb45" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3602,8 +3588,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a102cc9183d9fbd4e2cb35eb125dd66d078054052f7035eff49118e099cd7397" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3615,8 +3600,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebb0276d8b42d3549f9057981665d1b4c9567b3e9e27438b7d2f041dadf7a7d3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3628,8 +3612,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2278626673e5a9f60633635650bb713048b0cb773c0fe4a12dec1e6769fa1274" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3640,8 +3623,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e55021ba40e4322066fbfbf5eabf312dc3dbe8c24218ef1f3849b6c86a616143" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3653,8 +3635,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92258c38e9ae49eea356e3d3757b11d20601124da34a9b0ebda4d05fc57a1f7c" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3667,8 +3648,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d76ae77cacaa39504c9dcbd9f4db7b69103760f83cbd0125c4b4a817fcbe4f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "bs58", "snarkvm-console-network", @@ -3679,8 +3659,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e85657d9451cd262444b017e47f404e2fba890185beead5257027550077a7eb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "blake2s_simd", "smallvec", @@ -3693,8 +3672,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa64d2937bfb0b2c2b40cef1f716326054bb1968095bb278f6d766fe57ffea90" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "aleo-std", "rayon", @@ -3705,8 +3683,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce01c1ba23552a75721ff27f4aa0eb3c124698f32b6772d094bcdabaa28ede80" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "anyhow", "indexmap 2.1.0", @@ -3729,8 +3706,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef8af3eb2f888221e34346336e4b39b216c125f044ff347794bdce5808aff1df" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "anyhow", "bech32", @@ -3748,8 +3724,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de9eec44d25a034f14fc0317dea02e7d3c3e3025d04a4bd3799d67f66ad4770e" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "enum_index", "enum_index_derive", @@ -3770,8 +3745,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d51894fac468fff5eff12180309435b252246640ac602b540aee87cfc5e95a42" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3786,8 +3760,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed406e9776033f0c0357778a5e29eb96c47e832935c52b3af88e656dd16d034a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3798,8 +3771,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46f1de71d361b611589b45106002307aeab85d27bfa87e0a73367d9b96c04b9d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "snarkvm-console-network-environment", ] @@ -3807,8 +3779,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96887e3a16f0d806c8536abff8beb7eb8e39f5ff0e845d52d8586b3b16657ca" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3818,8 +3789,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00bcfeacecfdb3fc153c114d429ac6fd73d8e4cb0e731bb8bc0ed7d1c9fe6170" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3830,8 +3800,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b447282f6cdb4afc87bb587f6774eb75a84708817b04225713025cc75a9e491b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3842,8 +3811,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba9a4ad3b4ff94bfe02f5e928d42f4cf0d62ca91dee4c700c6a5a560d5a787a5" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3854,8 +3822,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "919104eed891a72c790778370ddd98dc7161a4867968ec0dfeaa8dd7e017be90" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3866,8 +3833,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14f138c0addd4e0dfcf811f4cf55874adde783324aace2904afd8a924b14fc9c" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "rand", "rayon", @@ -3881,8 +3847,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ac467a6a1d28dd9090061138f7f97f2f63d271c63251452bfca067c6eef3fdb" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "aleo-std", "anyhow", @@ -3900,8 +3865,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3877c2e9002e91892b4d5ef00474ef098d060bf9dc86dfc74adb75f10de9b2ad" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "aleo-std", "anyhow", @@ -3926,8 +3890,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b1188fcd9cc90bc0778e43ea00a5afebb22d7f8c2426d51452057cfd7c7143" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "anyhow", "rand", @@ -3939,8 +3902,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d582de04f43e01d01309bdb8dbd92421ac80db7ecdff42992113c4fe4ecea6a2" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "indexmap 2.1.0", "rayon", @@ -3958,8 +3920,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-coinbase" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b08086e8d201a50202b9238f4bfa286cad9ecdc205b365b73af713e289b7216a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "aleo-std", "anyhow", @@ -3979,8 +3940,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7734f963717fe491c0166c90f35d83babd5e504c6e3078cf30b53558ec35e6f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "anyhow", "indexmap 2.1.0", @@ -3990,14 +3950,14 @@ dependencies = [ "rand_distr", "serde_json", "snarkvm-console", + "snarkvm-ledger-narwhal-batch-header", "test-strategy", ] [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76ca021280bce8d17c1a9212d133566dacb6b41479e47c7c9d552902bef2c39f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -4010,8 +3970,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b5288c6e8e7e269be3c9b7a60d46c46d65af4590b83221070b74b489aa36a8d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "indexmap 2.1.0", "serde_json", @@ -4023,8 +3982,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53c15a409169b1a0d30e55277124044c6337240e70aca6c8bfccd91adf0034da" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "indexmap 2.1.0", "serde_json", @@ -4036,8 +3994,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8aff2a9a3039a531af55908d3b45bf1057ec5c8680b065bd7c215e8270931d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "bytes", "serde_json", @@ -4048,8 +4005,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "926e9a69c930ac514e434e8de5999f96296388595d63fbda32994b2a7e3e0243" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "indexmap 2.1.0", "rayon", @@ -4063,8 +4019,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce67bcf479d6c38e81701a1c37bf3efd6c7b02684d607e36ed329c896b71e5d8" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "bytes", "serde_json", @@ -4077,8 +4032,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcd14ba1dd8d8b37d14f002f1870a0517596f37caf9cadce01af4d76e761b299" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "snarkvm-console", "snarkvm-ledger-coinbase", @@ -4087,8 +4041,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11b52cea9bdd1b1c482a36d450f6433de00eda2f2a94b8b0affa35b136150066" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "async-trait", "reqwest", @@ -4101,8 +4054,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0806b7f132ee20ef8c87ff050c15ee17babbcdb3f77b6bcfae9991e34ce8860e" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "aleo-std", "anyhow", @@ -4127,8 +4079,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "372af153300b8302392fb2bb655b7721922ad867c6472bd0ba64010891b9a1b5" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4143,8 +4094,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f140d9692a9c6ebd0f4709172bdc9cfd713257fe41a8c9a38fdb4cbb7a88fa8" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "aleo-std", "anyhow", @@ -4168,8 +4118,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e0c79f7b3688d70499c595c415c1655853f53058f5edc689c2d7b4c9646d191" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "aleo-std", "anyhow", @@ -4194,8 +4143,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80ee94a4c319ac00c6dd44a89929e9c8c1bbd55a0ae7fdecf4251fca7965b302" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "aleo-std", "colored", @@ -4218,8 +4166,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9edf432edeebdb2545f2038ea60d676a0c35121558d39bae130b17fb59770fef" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "indexmap 2.1.0", "paste", @@ -4233,8 +4180,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3b9276323ec77c7bf1236b5158eca94f81587e57b1bb4801cb6a694acf22db0" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "bincode", "once_cell", @@ -4247,8 +4193,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bb1dc49e03d5a4c11d10fe52c9afae70e665206962b1cba9d2b3317cae991e2" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "aleo-std", "anyhow", @@ -4269,8 +4214,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3fd5c8981c25670659b8ddddc0c35db989a00a70cefaadc9af4c8ce47094aff" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=811d738#811d7381aa29c6aef84b40b18018fe4dd33a7940" dependencies = [ "proc-macro2", "quote 1.0.33", diff --git a/Cargo.toml b/Cargo.toml index babc50fcee..ba37fa6497 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,9 +41,9 @@ members = [ ] [workspace.dependencies.snarkvm] -#git = "https://github.com/AleoHQ/snarkVM.git" -#rev = "9124c31" -version = "=0.16.11" +git = "https://github.com/AleoHQ/snarkVM.git" +rev = "811d738" +#version = "=0.16.11" features = [ "circuit", "console", "rocks" ] [[bin]] diff --git a/node/bft/examples/simple_node.rs b/node/bft/examples/simple_node.rs index 528293cc53..7486a311ff 100644 --- a/node/bft/examples/simple_node.rs +++ b/node/bft/examples/simple_node.rs @@ -20,23 +20,18 @@ use snarkos_node_bft::{ helpers::{init_consensus_channels, init_primary_channels, ConsensusReceiver, PrimarySender, Storage}, Primary, BFT, - MAX_GC_ROUNDS, MEMORY_POOL_PORT, }; use snarkos_node_bft_ledger_service::MockLedgerService; use snarkos_node_bft_storage_service::BFTMemoryService; use snarkvm::{ ledger::{ - committee::{Committee, MIN_VALIDATOR_STAKE}, - narwhal::Data, - }, - prelude::{ block::Transaction, coinbase::{ProverSolution, PuzzleCommitment}, - Field, - Network, - Uniform, + committee::{Committee, MIN_VALIDATOR_STAKE}, + narwhal::{BatchHeader, Data}, }, + prelude::{Field, Network, Uniform}, }; use ::bytes::Bytes; @@ -116,7 +111,8 @@ pub async fn start_bft( // Initialize the mock ledger service. let ledger = Arc::new(MockLedgerService::new(committee)); // Initialize the storage. - let storage = Storage::new(ledger.clone(), Arc::new(BFTMemoryService::new()), MAX_GC_ROUNDS); + let storage = + Storage::new(ledger.clone(), Arc::new(BFTMemoryService::new()), BatchHeader::::MAX_GC_ROUNDS); // Initialize the gateway IP and dev mode. let (ip, dev) = match peers.get(&node_id) { Some(ip) => (Some(*ip), None), @@ -153,7 +149,8 @@ pub async fn start_primary( // Initialize the mock ledger service. let ledger = Arc::new(MockLedgerService::new(committee)); // Initialize the storage. - let storage = Storage::new(ledger.clone(), Arc::new(BFTMemoryService::new()), MAX_GC_ROUNDS); + let storage = + Storage::new(ledger.clone(), Arc::new(BFTMemoryService::new()), BatchHeader::::MAX_GC_ROUNDS); // Initialize the gateway IP and dev mode. let (ip, dev) = match peers.get(&node_id) { Some(ip) => (Some(*ip), None), diff --git a/node/bft/src/gateway.rs b/node/bft/src/gateway.rs index 8e54c8badb..8f458a4a48 100644 --- a/node/bft/src/gateway.rs +++ b/node/bft/src/gateway.rs @@ -16,11 +16,9 @@ use crate::{ events::{EventCodec, PrimaryPing}, helpers::{assign_to_worker, Cache, PrimarySender, Resolver, SyncSender, WorkerSender}, spawn_blocking, + Worker, CONTEXT, MAX_BATCH_DELAY_IN_MS, - MAX_GC_ROUNDS, - MAX_TRANSMISSIONS_PER_BATCH, - MAX_TRANSMISSIONS_PER_WORKER_PING, MEMORY_POOL_PORT, }; use snarkos_account::Account; @@ -54,7 +52,10 @@ use snarkos_node_tcp::{ }; use snarkvm::{ console::prelude::*, - ledger::{committee::Committee, narwhal::Data}, + ledger::{ + committee::Committee, + narwhal::{BatchHeader, Data}, + }, prelude::Address, }; @@ -212,12 +213,12 @@ impl Gateway { /// The maximum number of certificate requests to cache. fn max_cache_certificates(&self) -> usize { - 2 * MAX_GC_ROUNDS as usize * self.max_committee_size() + 2 * BatchHeader::::MAX_GC_ROUNDS as usize * self.max_committee_size() } /// Thne maximum number of transmission requests to cache. fn max_cache_transmissions(&self) -> usize { - self.max_cache_certificates() * MAX_TRANSMISSIONS_PER_BATCH + self.max_cache_certificates() * BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH } /// The maximum number of duplicates for any particular request. @@ -743,7 +744,7 @@ impl Gateway { Event::WorkerPing(ping) => { // Ensure the number of transmissions is not too large. ensure!( - ping.transmission_ids.len() <= MAX_TRANSMISSIONS_PER_WORKER_PING, + ping.transmission_ids.len() <= Worker::::MAX_TRANSMISSIONS_PER_WORKER_PING, "{CONTEXT} Received too many transmissions" ); // Retrieve the number of workers. @@ -977,8 +978,10 @@ impl Reading for Gateway { type Message = Event; /// The maximum queue depth of incoming messages for a single peer. - const MESSAGE_QUEUE_DEPTH: usize = - 2 * MAX_GC_ROUNDS as usize * Committee::::MAX_COMMITTEE_SIZE as usize * MAX_TRANSMISSIONS_PER_BATCH; + const MESSAGE_QUEUE_DEPTH: usize = 2 + * BatchHeader::::MAX_GC_ROUNDS as usize + * Committee::::MAX_COMMITTEE_SIZE as usize + * BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH; /// Creates a [`Decoder`] used to interpret messages from the network. /// The `side` param indicates the connection side **from the node's perspective**. @@ -1010,8 +1013,10 @@ impl Writing for Gateway { type Message = Event; /// The maximum queue depth of outgoing messages for a single peer. - const MESSAGE_QUEUE_DEPTH: usize = - 2 * MAX_GC_ROUNDS as usize * Committee::::MAX_COMMITTEE_SIZE as usize * MAX_TRANSMISSIONS_PER_BATCH; + const MESSAGE_QUEUE_DEPTH: usize = 2 + * BatchHeader::::MAX_GC_ROUNDS as usize + * Committee::::MAX_COMMITTEE_SIZE as usize + * BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH; /// Creates an [`Encoder`] used to write the outbound messages to the target stream. /// The `side` parameter indicates the connection side **from the node's perspective**. diff --git a/node/bft/src/helpers/storage.rs b/node/bft/src/helpers/storage.rs index 739a3cb37c..4bd21d0988 100644 --- a/node/bft/src/helpers/storage.rs +++ b/node/bft/src/helpers/storage.rs @@ -935,17 +935,14 @@ mod tests { #[cfg(test)] pub mod prop_tests { use super::*; - use crate::{ - helpers::{now, storage::tests::assert_storage}, - MAX_GC_ROUNDS, - }; + use crate::helpers::{now, storage::tests::assert_storage}; use snarkos_node_bft_ledger_service::MockLedgerService; use snarkos_node_bft_storage_service::BFTMemoryService; use snarkvm::{ ledger::{ coinbase::PuzzleCommitment, committee::prop_tests::{CommitteeContext, ValidatorSet}, - narwhal::Data, + narwhal::{BatchHeader, Data}, }, prelude::{Signature, Uniform}, }; @@ -970,7 +967,7 @@ pub mod prop_tests { type Strategy = BoxedStrategy>; fn arbitrary() -> Self::Strategy { - (any::(), 0..MAX_GC_ROUNDS) + (any::(), 0..BatchHeader::::MAX_GC_ROUNDS) .prop_map(|(CommitteeContext(committee, _), gc_rounds)| { let ledger = Arc::new(MockLedgerService::new(committee)); Storage::::new(ledger, Arc::new(BFTMemoryService::new()), gc_rounds) @@ -979,7 +976,7 @@ pub mod prop_tests { } fn arbitrary_with(context: Self::Parameters) -> Self::Strategy { - (Just(context), 0..MAX_GC_ROUNDS) + (Just(context), 0..BatchHeader::::MAX_GC_ROUNDS) .prop_map(|(CommitteeContext(committee, _), gc_rounds)| { let ledger = Arc::new(MockLedgerService::new(committee)); Storage::::new(ledger, Arc::new(BFTMemoryService::new()), gc_rounds) diff --git a/node/bft/src/lib.rs b/node/bft/src/lib.rs index 60aa00ee6b..9ea14b821e 100644 --- a/node/bft/src/lib.rs +++ b/node/bft/src/lib.rs @@ -54,12 +54,8 @@ pub const MAX_GC_ROUNDS: u64 = 50; // rounds pub const MAX_LEADER_CERTIFICATE_DELAY_IN_SECS: i64 = 2 * MAX_BATCH_DELAY_IN_MS as i64 / 1000; // seconds /// The maximum number of seconds before the timestamp is considered expired. pub const MAX_TIMESTAMP_DELTA_IN_SECS: i64 = 10; // seconds -/// The maximum number of transmissions allowed in a batch. -pub const MAX_TRANSMISSIONS_PER_BATCH: usize = 250; // transmissions -/// The maximum number of transmissions allowed in a worker ping. -pub const MAX_TRANSMISSIONS_PER_WORKER_PING: usize = MAX_TRANSMISSIONS_PER_BATCH / 10; // transmissions /// The maximum number of workers that can be spawned. -pub const MAX_WORKERS: u8 = 1; // workers +pub const MAX_WORKERS: u8 = 1; // worker(s) /// The frequency at which each primary broadcasts a ping to every other node. pub const PRIMARY_PING_IN_MS: u64 = 2 * MAX_BATCH_DELAY_IN_MS; // ms @@ -76,15 +72,3 @@ macro_rules! spawn_blocking { } }; } - -#[cfg(test)] -mod tests { - use super::*; - - type CurrentNetwork = snarkvm::console::network::Testnet3; - - #[test] - fn test_max_gc_rounds() { - assert_eq!(MAX_GC_ROUNDS as usize, snarkvm::ledger::narwhal::Subdag::::MAX_ROUNDS); - } -} diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 38f9f99c2e..082d83b3f5 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -33,7 +33,6 @@ use crate::{ Transport, Worker, MAX_BATCH_DELAY_IN_MS, - MAX_TRANSMISSIONS_PER_BATCH, MAX_WORKERS, PRIMARY_PING_IN_MS, WORKER_PING_IN_MS, @@ -379,7 +378,7 @@ impl Primary { } // Determined the required number of transmissions per worker. - let num_transmissions_per_worker = MAX_TRANSMISSIONS_PER_BATCH / self.num_workers() as usize; + let num_transmissions_per_worker = BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH / self.num_workers() as usize; // Initialize the map of transmissions. let mut transmissions: IndexMap<_, _> = Default::default(); // Initialize a tracker for the number of transactions. diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index 47f486083c..a46568d86f 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -18,17 +18,15 @@ use crate::{ ProposedBatch, Transport, MAX_BATCH_DELAY_IN_MS, - MAX_TRANSMISSIONS_PER_BATCH, - MAX_TRANSMISSIONS_PER_WORKER_PING, MAX_WORKERS, }; use snarkos_node_bft_ledger_service::LedgerService; use snarkvm::{ console::prelude::*, - ledger::narwhal::{Data, Transmission, TransmissionID}, - prelude::{ + ledger::{ block::Transaction, coinbase::{ProverSolution, PuzzleCommitment}, + narwhal::{BatchHeader, Data, Transmission, TransmissionID}, }, }; @@ -37,8 +35,6 @@ use parking_lot::Mutex; use std::{future::Future, net::SocketAddr, sync::Arc, time::Duration}; use tokio::{sync::oneshot, task::JoinHandle, time::timeout}; -const MAX_TRANSMISSIONS_PER_WORKER: usize = MAX_TRANSMISSIONS_PER_BATCH / MAX_WORKERS as usize; - #[derive(Clone)] pub struct Worker { /// The worker ID. @@ -97,6 +93,14 @@ impl Worker { } impl Worker { + /// The maximum number of transmissions allowed in a worker. + pub const MAX_TRANSMISSIONS_PER_WORKER: usize = + BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH / MAX_WORKERS as usize; + /// The maximum number of transmissions allowed in a worker ping. + pub const MAX_TRANSMISSIONS_PER_WORKER_PING: usize = BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH / 10; + + // transmissions + /// Returns the number of transmissions in the ready queue. pub fn num_transmissions(&self) -> usize { self.ready.num_transmissions() @@ -209,8 +213,12 @@ impl Worker { /// Broadcasts a worker ping event. pub(crate) fn broadcast_ping(&self) { // Retrieve the transmission IDs. - let transmission_ids = - self.ready.transmission_ids().into_iter().take(MAX_TRANSMISSIONS_PER_WORKER_PING).collect::>(); + let transmission_ids = self + .ready + .transmission_ids() + .into_iter() + .take(Self::MAX_TRANSMISSIONS_PER_WORKER_PING) + .collect::>(); // Broadcast the ping event. if !transmission_ids.is_empty() { @@ -228,7 +236,7 @@ impl Worker { } // If the ready queue is full, then skip this transmission. // Note: We must prioritize the unconfirmed solutions and unconfirmed transactions, not transmissions. - if self.ready.num_transmissions() > MAX_TRANSMISSIONS_PER_WORKER { + if self.ready.num_transmissions() > Self::MAX_TRANSMISSIONS_PER_WORKER { return; } // Attempt to fetch the transmission from the peer. diff --git a/node/bft/tests/common/primary.rs b/node/bft/tests/common/primary.rs index 2d81fd45a8..7186f0cee2 100644 --- a/node/bft/tests/common/primary.rs +++ b/node/bft/tests/common/primary.rs @@ -23,29 +23,21 @@ use snarkos_node_bft::{ Primary, BFT, MAX_BATCH_DELAY_IN_MS, - MAX_GC_ROUNDS, }; use snarkos_node_bft_storage_service::BFTMemoryService; use snarkvm::{ - console::algorithms::BHP256, + console::{ + account::{Address, PrivateKey}, + algorithms::{Hash, BHP256}, + }, ledger::{ block::Block, committee::{Committee, MIN_VALIDATOR_STAKE}, - Ledger, - }, - prelude::{ + narwhal::BatchHeader, store::{helpers::memory::ConsensusMemory, ConsensusStore}, - Address, - CryptoRng, - FromBytes, - Hash, - PrivateKey, - Rng, - TestRng, - ToBits, - ToBytes, - VM, + Ledger, }, + prelude::{CryptoRng, FromBytes, Rng, TestRng, ToBits, ToBytes, VM}, utilities::to_bytes_le, }; @@ -152,7 +144,11 @@ impl TestNetwork { let mut rng = TestRng::fixed(id as u64); let gen_ledger = genesis_ledger(gen_key, committee.clone(), balances.clone(), &mut rng); let ledger = Arc::new(TranslucentLedgerService::new(gen_ledger)); - let storage = Storage::new(ledger.clone(), Arc::new(BFTMemoryService::new()), MAX_GC_ROUNDS); + let storage = Storage::new( + ledger.clone(), + Arc::new(BFTMemoryService::new()), + BatchHeader::::MAX_GC_ROUNDS, + ); let (primary, bft) = if config.bft { let bft = BFT::::new(account, storage, ledger, None, &[], Some(id as u16)).unwrap(); diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 570e3856c2..270e6402af 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -29,8 +29,6 @@ use snarkos_node_bft::{ }, spawn_blocking, BFT, - MAX_GC_ROUNDS, - MAX_TRANSMISSIONS_PER_BATCH, }; use snarkos_node_bft_ledger_service::LedgerService; use snarkos_node_bft_storage_service::BFTPersistentStorage; @@ -38,7 +36,7 @@ use snarkvm::{ ledger::{ block::Transaction, coinbase::{ProverSolution, PuzzleCommitment}, - narwhal::{Data, Subdag, Transmission, TransmissionID}, + narwhal::{BatchHeader, Data, Subdag, Transmission, TransmissionID}, }, prelude::*, }; @@ -86,7 +84,7 @@ impl Consensus { // Initialize the Narwhal transmissions. let transmissions = Arc::new(BFTPersistentStorage::open(dev)?); // Initialize the Narwhal storage. - let storage = NarwhalStorage::new(ledger.clone(), transmissions, MAX_GC_ROUNDS); + let storage = NarwhalStorage::new(ledger.clone(), transmissions, BatchHeader::::MAX_GC_ROUNDS); // Initialize the BFT. let bft = BFT::new(account, storage, ledger.clone(), ip, trusted_validators, dev)?; // Return the consensus. @@ -202,7 +200,7 @@ impl Consensus { // If the memory pool of this node is full, return early. let num_unconfirmed = self.num_unconfirmed_transmissions(); - if num_unconfirmed > N::MAX_SOLUTIONS || num_unconfirmed > MAX_TRANSMISSIONS_PER_BATCH { + if num_unconfirmed > N::MAX_SOLUTIONS || num_unconfirmed > BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH { return Ok(()); } // Retrieve the solutions. @@ -256,13 +254,13 @@ impl Consensus { // If the memory pool of this node is full, return early. let num_unconfirmed = self.num_unconfirmed_transmissions(); - if num_unconfirmed > MAX_TRANSMISSIONS_PER_BATCH { + if num_unconfirmed > BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH { return Ok(()); } // Retrieve the transactions. let transactions = { // Determine the available capacity. - let capacity = MAX_TRANSMISSIONS_PER_BATCH.saturating_sub(num_unconfirmed); + let capacity = BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH.saturating_sub(num_unconfirmed); // Acquire the lock on the queue. let mut queue = self.transactions_queue.lock(); // Determine the number of transactions to send. From 93ac510d025e3d0e3a89a499e88988bab7222600 Mon Sep 17 00:00:00 2001 From: Niklas Date: Wed, 17 Jan 2024 11:26:43 -0800 Subject: [PATCH 007/551] fix: prevent handshake based sig forgery --- node/bft/events/src/challenge_response.rs | 11 ++++++++--- node/bft/src/gateway.rs | 16 ++++++++++------ node/router/messages/src/challenge_response.rs | 18 ++++++++++++++---- node/router/src/handshake.rs | 18 ++++++++++++------ node/tests/common/test_peer.rs | 14 ++++++++++---- 5 files changed, 54 insertions(+), 23 deletions(-) diff --git a/node/bft/events/src/challenge_response.rs b/node/bft/events/src/challenge_response.rs index 0fc678a86d..aad59f760f 100644 --- a/node/bft/events/src/challenge_response.rs +++ b/node/bft/events/src/challenge_response.rs @@ -17,6 +17,7 @@ use super::*; #[derive(Clone, Debug, PartialEq, Eq)] pub struct ChallengeResponse { pub signature: Data>, + pub nonce: u64, } impl EventTrait for ChallengeResponse { @@ -30,6 +31,7 @@ impl EventTrait for ChallengeResponse { impl ToBytes for ChallengeResponse { fn write_le(&self, mut writer: W) -> IoResult<()> { self.signature.write_le(&mut writer)?; + self.nonce.write_le(&mut writer)?; Ok(()) } } @@ -37,8 +39,9 @@ impl ToBytes for ChallengeResponse { impl FromBytes for ChallengeResponse { fn read_le(mut reader: R) -> IoResult { let signature = Data::read_le(&mut reader)?; + let nonce = u64::read_le(&mut reader)?; - Ok(Self { signature }) + Ok(Self { signature, nonce }) } } @@ -53,7 +56,7 @@ pub mod prop_tests { }; use bytes::{Buf, BufMut, BytesMut}; - use proptest::prelude::{BoxedStrategy, Strategy}; + use proptest::prelude::{any, BoxedStrategy, Strategy}; use test_strategy::proptest; type CurrentNetwork = snarkvm::prelude::Testnet3; @@ -70,7 +73,9 @@ pub mod prop_tests { } pub fn any_challenge_response() -> BoxedStrategy> { - any_signature().prop_map(|sig| ChallengeResponse { signature: Data::Object(sig) }).boxed() + (any_signature(), any::()) + .prop_map(|(sig, nonce)| ChallengeResponse { signature: Data::Object(sig), nonce }) + .boxed() } #[proptest] diff --git a/node/bft/src/gateway.rs b/node/bft/src/gateway.rs index d6b8c000d4..ecbfdb110a 100644 --- a/node/bft/src/gateway.rs +++ b/node/bft/src/gateway.rs @@ -1176,11 +1176,13 @@ impl Gateway { /* Step 3: Send the challenge response. */ // Sign the counterparty nonce. - let Ok(our_signature) = self.account.sign_bytes(&peer_request.nonce.to_le_bytes(), rng) else { + let response_nonce: u64 = rng.gen(); + let data = [peer_request.nonce.to_le_bytes(), response_nonce.to_le_bytes()].concat(); + let Ok(our_signature) = self.account.sign_bytes(&data, rng) else { return Err(error(format!("Failed to sign the challenge request nonce from '{peer_addr}'"))); }; // Send the challenge response. - let our_response = ChallengeResponse { signature: Data::Object(our_signature) }; + let our_response = ChallengeResponse { signature: Data::Object(our_signature), nonce: response_nonce }; send_event(&mut framed, peer_addr, Event::ChallengeResponse(our_response)).await?; // Add the peer to the gateway. @@ -1229,11 +1231,13 @@ impl Gateway { let rng = &mut rand::rngs::OsRng; // Sign the counterparty nonce. - let Ok(our_signature) = self.account.sign_bytes(&peer_request.nonce.to_le_bytes(), rng) else { + let response_nonce: u64 = rng.gen(); + let data = [peer_request.nonce.to_le_bytes(), response_nonce.to_le_bytes()].concat(); + let Ok(our_signature) = self.account.sign_bytes(&data, rng) else { return Err(error(format!("Failed to sign the challenge request nonce from '{peer_addr}'"))); }; // Send the challenge response. - let our_response = ChallengeResponse { signature: Data::Object(our_signature) }; + let our_response = ChallengeResponse { signature: Data::Object(our_signature), nonce: response_nonce }; send_event(&mut framed, peer_addr, Event::ChallengeResponse(our_response)).await?; // Sample a random nonce. @@ -1290,14 +1294,14 @@ impl Gateway { expected_nonce: u64, ) -> Option { // Retrieve the components of the challenge response. - let ChallengeResponse { signature } = response; + let ChallengeResponse { signature, nonce } = response; // Perform the deferred non-blocking deserialization of the signature. let Ok(signature) = spawn_blocking!(signature.deserialize_blocking()) else { warn!("{CONTEXT} Gateway handshake with '{peer_addr}' failed (cannot deserialize the signature)"); return Some(DisconnectReason::InvalidChallengeResponse); }; // Verify the signature. - if !signature.verify_bytes(&peer_address, &expected_nonce.to_le_bytes()) { + if !signature.verify_bytes(&peer_address, &[expected_nonce.to_le_bytes(), nonce.to_le_bytes()].concat()) { warn!("{CONTEXT} Gateway handshake with '{peer_addr}' failed (invalid signature)"); return Some(DisconnectReason::InvalidChallengeResponse); } diff --git a/node/router/messages/src/challenge_response.rs b/node/router/messages/src/challenge_response.rs index 3c75d4db19..d51c5bb717 100644 --- a/node/router/messages/src/challenge_response.rs +++ b/node/router/messages/src/challenge_response.rs @@ -25,6 +25,7 @@ use std::borrow::Cow; pub struct ChallengeResponse { pub genesis_header: Header, pub signature: Data>, + pub nonce: u64, } impl MessageTrait for ChallengeResponse { @@ -38,13 +39,18 @@ impl MessageTrait for ChallengeResponse { impl ToBytes for ChallengeResponse { fn write_le(&self, mut writer: W) -> io::Result<()> { self.genesis_header.write_le(&mut writer)?; - self.signature.write_le(&mut writer) + self.signature.write_le(&mut writer)?; + self.nonce.write_le(&mut writer) } } impl FromBytes for ChallengeResponse { fn read_le(mut reader: R) -> io::Result { - Ok(Self { genesis_header: Header::read_le(&mut reader)?, signature: Data::read_le(reader)? }) + Ok(Self { + genesis_header: Header::read_le(&mut reader)?, + signature: Data::read_le(&mut reader)?, + nonce: u64::read_le(reader)?, + }) } } @@ -80,8 +86,12 @@ pub mod prop_tests { } pub fn any_challenge_response() -> BoxedStrategy> { - (any_signature(), any_genesis_header()) - .prop_map(|(sig, genesis_header)| ChallengeResponse { signature: Data::Object(sig), genesis_header }) + (any_signature(), any_genesis_header(), any::()) + .prop_map(|(sig, genesis_header, nonce)| ChallengeResponse { + signature: Data::Object(sig), + genesis_header, + nonce, + }) .boxed() } diff --git a/node/router/src/handshake.rs b/node/router/src/handshake.rs index 7ccb67fa89..195298eaea 100644 --- a/node/router/src/handshake.rs +++ b/node/router/src/handshake.rs @@ -164,12 +164,15 @@ impl Router { } /* Step 3: Send the challenge response. */ + let response_nonce: u64 = rng.gen(); + let data = [peer_request.nonce.to_le_bytes(), response_nonce.to_le_bytes()].concat(); // Sign the counterparty nonce. - let Ok(our_signature) = self.account.sign_bytes(&peer_request.nonce.to_le_bytes(), rng) else { + let Ok(our_signature) = self.account.sign_bytes(&data, rng) else { return Err(error(format!("Failed to sign the challenge request nonce from '{peer_addr}'"))); }; // Send the challenge response. - let our_response = ChallengeResponse { genesis_header, signature: Data::Object(our_signature) }; + let our_response = + ChallengeResponse { genesis_header, signature: Data::Object(our_signature), nonce: response_nonce }; send(&mut framed, peer_addr, Message::ChallengeResponse(our_response)).await?; // Add the peer to the router. @@ -213,11 +216,14 @@ impl Router { let rng = &mut OsRng; // Sign the counterparty nonce. - let Ok(our_signature) = self.account.sign_bytes(&peer_request.nonce.to_le_bytes(), rng) else { + let response_nonce: u64 = rng.gen(); + let data = [peer_request.nonce.to_le_bytes(), response_nonce.to_le_bytes()].concat(); + let Ok(our_signature) = self.account.sign_bytes(&data, rng) else { return Err(error(format!("Failed to sign the challenge request nonce from '{peer_addr}'"))); }; // Send the challenge response. - let our_response = ChallengeResponse { genesis_header, signature: Data::Object(our_signature) }; + let our_response = + ChallengeResponse { genesis_header, signature: Data::Object(our_signature), nonce: response_nonce }; send(&mut framed, peer_addr, Message::ChallengeResponse(our_response)).await?; // Sample a random nonce. @@ -303,7 +309,7 @@ impl Router { expected_nonce: u64, ) -> Option { // Retrieve the components of the challenge response. - let ChallengeResponse { genesis_header, signature } = response; + let ChallengeResponse { genesis_header, signature, nonce } = response; // Verify the challenge response, by checking that the block header matches. if genesis_header != expected_genesis_header { @@ -316,7 +322,7 @@ impl Router { return Some(DisconnectReason::InvalidChallengeResponse); }; // Verify the signature. - if !signature.verify_bytes(&peer_address, &expected_nonce.to_le_bytes()) { + if !signature.verify_bytes(&peer_address, &[expected_nonce.to_le_bytes(), nonce.to_le_bytes()].concat()) { warn!("Handshake with '{peer_addr}' failed (invalid signature)"); return Some(DisconnectReason::InvalidChallengeResponse); } diff --git a/node/tests/common/test_peer.rs b/node/tests/common/test_peer.rs index d480c6a3e1..8d9d5e39bb 100644 --- a/node/tests/common/test_peer.rs +++ b/node/tests/common/test_peer.rs @@ -140,10 +140,13 @@ impl Handshake for TestPeer { let peer_request = expect_message!(Message::ChallengeRequest, framed, peer_addr); // Sign the nonce. - let signature = self.account().sign_bytes(&peer_request.nonce.to_le_bytes(), rng).unwrap(); + let response_nonce: u64 = rng.gen(); + let data = [peer_request.nonce.to_le_bytes(), response_nonce.to_le_bytes()].concat(); + let signature = self.account().sign_bytes(&data, rng).unwrap(); // Send the challenge response. - let our_response = ChallengeResponse { genesis_header, signature: Data::Object(signature) }; + let our_response = + ChallengeResponse { genesis_header, signature: Data::Object(signature), nonce: response_nonce }; framed.send(Message::ChallengeResponse(our_response)).await?; } ConnectionSide::Responder => { @@ -151,10 +154,13 @@ impl Handshake for TestPeer { let peer_request = expect_message!(Message::ChallengeRequest, framed, peer_addr); // Sign the nonce. - let signature = self.account().sign_bytes(&peer_request.nonce.to_le_bytes(), rng).unwrap(); + let response_nonce: u64 = rng.gen(); + let data = [peer_request.nonce.to_le_bytes(), response_nonce.to_le_bytes()].concat(); + let signature = self.account().sign_bytes(&data, rng).unwrap(); // Send our challenge bundle. - let our_response = ChallengeResponse { genesis_header, signature: Data::Object(signature) }; + let our_response = + ChallengeResponse { genesis_header, signature: Data::Object(signature), nonce: response_nonce }; framed.send(Message::ChallengeResponse(our_response)).await?; let our_request = ChallengeRequest::new(local_ip.port(), self.node_type(), self.address(), rng.gen()); framed.send(Message::ChallengeRequest(our_request)).await?; From 3c7b9e0f8e3068c3bb2cadfccf8b4e89d82de45c Mon Sep 17 00:00:00 2001 From: Niklas Date: Fri, 19 Jan 2024 07:59:15 -0800 Subject: [PATCH 008/551] feat: bump `Event` and `Message` versions --- node/bft/events/src/lib.rs | 2 +- node/router/messages/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/node/bft/events/src/lib.rs b/node/bft/events/src/lib.rs index d49073b1c5..7a3c6d30ef 100644 --- a/node/bft/events/src/lib.rs +++ b/node/bft/events/src/lib.rs @@ -118,7 +118,7 @@ impl From for Event { impl Event { /// The version of the event protocol; it can be incremented in order to force users to update. - pub const VERSION: u32 = 5; + pub const VERSION: u32 = 6; /// Returns the event name. #[inline] diff --git a/node/router/messages/src/lib.rs b/node/router/messages/src/lib.rs index baa512b5b4..09b065a49d 100644 --- a/node/router/messages/src/lib.rs +++ b/node/router/messages/src/lib.rs @@ -111,7 +111,7 @@ impl From for Message { impl Message { /// The version of the network protocol; it can be incremented in order to force users to update. - pub const VERSION: u32 = 13; + pub const VERSION: u32 = 14; /// Returns the message name. #[inline] From db46db2146d0b0dc50ecd4a929212bdc18593083 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 7 Feb 2024 15:18:39 -0800 Subject: [PATCH 009/551] Update rev - 1e4c188 feat/committee-round-lag --- Cargo.lock | 116 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 2 +- 2 files changed, 59 insertions(+), 59 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bf937e0469..bdf7d02834 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3523,7 +3523,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "anstyle", "anyhow", @@ -3554,7 +3554,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "aleo-std", "anyhow", @@ -3584,7 +3584,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3598,7 +3598,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3609,7 +3609,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3619,7 +3619,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3629,7 +3629,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "indexmap 2.2.2", "itertools 0.11.0", @@ -3647,12 +3647,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" [[package]] name = "snarkvm-circuit-network" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3663,7 +3663,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3678,7 +3678,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3693,7 +3693,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3706,7 +3706,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3715,7 +3715,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3725,7 +3725,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3737,7 +3737,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3749,7 +3749,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3760,7 +3760,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3772,7 +3772,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3785,7 +3785,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "bs58", "snarkvm-console-network", @@ -3796,7 +3796,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "blake2s_simd", "smallvec", @@ -3809,7 +3809,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "aleo-std", "rayon", @@ -3820,7 +3820,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "anyhow", "indexmap 2.2.2", @@ -3843,7 +3843,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "anyhow", "bech32", @@ -3861,7 +3861,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "enum_index", "enum_index_derive", @@ -3882,7 +3882,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3897,7 +3897,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3908,7 +3908,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "snarkvm-console-network-environment", ] @@ -3916,7 +3916,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3926,7 +3926,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3937,7 +3937,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3948,7 +3948,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3959,7 +3959,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3970,7 +3970,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "rand", "rayon", @@ -3984,7 +3984,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "aleo-std", "anyhow", @@ -4001,7 +4001,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "aleo-std", "anyhow", @@ -4026,7 +4026,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "anyhow", "rand", @@ -4038,7 +4038,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4057,7 +4057,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-coinbase" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "aleo-std", "anyhow", @@ -4077,7 +4077,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "anyhow", "indexmap 2.2.2", @@ -4095,7 +4095,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -4108,7 +4108,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4121,7 +4121,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "indexmap 2.2.2", "serde_json", @@ -4133,7 +4133,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "bytes", "serde_json", @@ -4144,7 +4144,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4159,7 +4159,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "bytes", "serde_json", @@ -4172,7 +4172,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "snarkvm-console", "snarkvm-ledger-coinbase", @@ -4181,7 +4181,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "async-trait", "reqwest", @@ -4194,7 +4194,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "aleo-std-storage", "anyhow", @@ -4219,7 +4219,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4234,7 +4234,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4243,7 +4243,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "aleo-std", "anyhow", @@ -4268,7 +4268,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "aleo-std", "anyhow", @@ -4292,7 +4292,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "aleo-std", "colored", @@ -4315,7 +4315,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "indexmap 2.2.2", "paste", @@ -4329,7 +4329,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "bincode", "once_cell", @@ -4342,7 +4342,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "aleo-std", "anyhow", @@ -4363,7 +4363,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=963555a#963555a3c5b22dcaa9439d553fcc102ed104d596" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" dependencies = [ "proc-macro2", "quote 1.0.35", diff --git a/Cargo.toml b/Cargo.toml index 2d58e6b789..b32c66f84b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,7 +42,7 @@ members = [ [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "963555a" +rev = "1e4c188" # feat/committee-round-lag #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From c319cafe65e20e0eb2d0ab089a4fd8e02691b39a Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 7 Feb 2024 15:19:01 -0800 Subject: [PATCH 010/551] Introduce get_previous_committee_with_lag_for_round --- node/bft/ledger-service/src/ledger.rs | 13 ++++++++----- node/bft/ledger-service/src/mock.rs | 4 ++-- node/bft/ledger-service/src/prover.rs | 6 +++--- node/bft/ledger-service/src/traits.rs | 6 +++--- node/bft/ledger-service/src/translucent.rs | 4 ++-- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/node/bft/ledger-service/src/ledger.rs b/node/bft/ledger-service/src/ledger.rs index a34a7f2a08..9955a485a8 100644 --- a/node/bft/ledger-service/src/ledger.rs +++ b/node/bft/ledger-service/src/ledger.rs @@ -143,9 +143,9 @@ impl> LedgerService for CoreLedgerService< } } - /// Returns the previous committee for the given round. - /// If the previous round is in the future, then the current committee is returned. - fn get_previous_committee_for_round(&self, round: u64) -> Result> { + /// Returns the previous committee with lag for the given round. + /// If the previous round with lag is in the future, then the current committee is returned. + fn get_previous_committee_with_lag_for_round(&self, round: u64) -> Result> { // Get the round number for the previous committee. Note, we subtract 2 from odd rounds, // because committees are updated in even rounds. let previous_round = match round % 2 == 0 { @@ -153,8 +153,11 @@ impl> LedgerService for CoreLedgerService< false => round.saturating_sub(2), }; - // Retrieve the committee for the previous round. - self.get_committee_for_round(previous_round) + // Get the previous round with lag. + let previous_round_with_lag = previous_round.saturating_sub(N::COMMITTEE_ROUND_LAG); + + // Retrieve the committee for the previous round with lag. + self.get_committee_for_round(previous_round_with_lag) } /// Returns `true` if the ledger contains the given certificate ID in block history. diff --git a/node/bft/ledger-service/src/mock.rs b/node/bft/ledger-service/src/mock.rs index 5b2732370a..21d49ff55a 100644 --- a/node/bft/ledger-service/src/mock.rs +++ b/node/bft/ledger-service/src/mock.rs @@ -126,8 +126,8 @@ impl LedgerService for MockLedgerService { Ok(self.committee.clone()) } - /// Returns the previous committee for the given round. - fn get_previous_committee_for_round(&self, _round: u64) -> Result> { + /// Returns the previous committee with lag for the given round. + fn get_previous_committee_with_lag_for_round(&self, _round: u64) -> Result> { Ok(self.committee.clone()) } diff --git a/node/bft/ledger-service/src/prover.rs b/node/bft/ledger-service/src/prover.rs index 8677f9c3d9..57c0074fbf 100644 --- a/node/bft/ledger-service/src/prover.rs +++ b/node/bft/ledger-service/src/prover.rs @@ -108,9 +108,9 @@ impl LedgerService for ProverLedgerService { bail!("Committee for round {round} does not exist in prover") } - /// Returns the previous committee for the given round. - /// If the previous round is in the future, then the current committee is returned. - fn get_previous_committee_for_round(&self, round: u64) -> Result> { + /// Returns the previous committee with lag for the given round. + /// If the previous round with lag is in the future, then the current committee is returned. + fn get_previous_committee_with_lag_for_round(&self, round: u64) -> Result> { bail!("Previous committee for round {round} does not exist in prover") } diff --git a/node/bft/ledger-service/src/traits.rs b/node/bft/ledger-service/src/traits.rs index 82a546d1ba..2d41570152 100644 --- a/node/bft/ledger-service/src/traits.rs +++ b/node/bft/ledger-service/src/traits.rs @@ -68,9 +68,9 @@ pub trait LedgerService: Debug + Send + Sync { /// If the given round is in the future, then the current committee is returned. fn get_committee_for_round(&self, round: u64) -> Result>; - /// Returns the previous committee for the given round. - /// If the previous round is in the future, then the current committee is returned. - fn get_previous_committee_for_round(&self, round: u64) -> Result>; + /// Returns the previous committee with lag for the given round. + /// If the previous round with lag is in the future, then the current committee is returned. + fn get_previous_committee_with_lag_for_round(&self, round: u64) -> Result>; /// Returns `true` if the ledger contains the given certificate ID. fn contains_certificate(&self, certificate_id: &Field) -> Result; diff --git a/node/bft/ledger-service/src/translucent.rs b/node/bft/ledger-service/src/translucent.rs index cf327a173f..83b3793b02 100644 --- a/node/bft/ledger-service/src/translucent.rs +++ b/node/bft/ledger-service/src/translucent.rs @@ -119,8 +119,8 @@ impl> LedgerService for TranslucentLedgerS self.inner.get_committee_for_round(round) } - fn get_previous_committee_for_round(&self, round: u64) -> Result> { - self.inner.get_previous_committee_for_round(round) + fn get_previous_committee_with_lag_for_round(&self, round: u64) -> Result> { + self.inner.get_previous_committee_with_lag_for_round(round) } /// Returns `true` if the ledger contains the given certificate ID in block history. From c1bfb272ae815999d2667613b4c93a251fc4bd2e Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 7 Feb 2024 15:19:32 -0800 Subject: [PATCH 011/551] Use get_previous_committee_with_lag_for_round in consensus --- node/bft/src/bft.rs | 42 ++++++++++++++++------------ node/bft/src/gateway.rs | 3 +- node/bft/src/helpers/storage.rs | 25 +++++++++-------- node/bft/src/primary.rs | 49 +++++++++++++++++++-------------- node/bft/src/worker.rs | 2 +- 5 files changed, 69 insertions(+), 52 deletions(-) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 5637ddfd3e..e643978e62 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -291,16 +291,18 @@ impl BFT { return false; } - // Retrieve the previous committee of the current round. - let previous_committee = match self.ledger().get_previous_committee_for_round(current_round) { + // Retrieve the previous committee with lag of the current round. + let previous_committee_with_lag = match self.ledger().get_previous_committee_with_lag_for_round(current_round) { Ok(committee) => committee, Err(e) => { - error!("BFT failed to retrieve the previous committee for the even round {current_round} - {e}"); + error!( + "BFT failed to retrieve the previous committee with lag for the even round {current_round} - {e}" + ); return false; } }; // Determine the leader of the current round. - let leader = match previous_committee.get_leader(current_round) { + let leader = match previous_committee_with_lag.get_leader(current_round) { Ok(leader) => leader, Err(e) => { error!("BFT failed to compute the leader for the even round {current_round} - {e}"); @@ -311,7 +313,7 @@ impl BFT { let leader_certificate = current_certificates.iter().find(|certificate| certificate.author() == leader); *self.leader_certificate.write() = leader_certificate.cloned(); - self.is_even_round_ready_for_next_round(current_certificates, previous_committee, current_round) + self.is_even_round_ready_for_next_round(current_certificates, previous_committee_with_lag, current_round) } /// Returns 'true' under one of the following conditions: @@ -375,21 +377,26 @@ impl BFT { let leader_certificate_id = leader_certificate.id(); // Retrieve the certificates for the current round. let current_certificates = self.storage().get_certificates_for_round(current_round); - // Retrieve the previous committee of the current round. - let previous_committee = match self.ledger().get_previous_committee_for_round(current_round) { + // Retrieve the previous committee with lag for the current round. + let previous_committee_with_lag = match self.ledger().get_previous_committee_with_lag_for_round(current_round) { Ok(committee) => committee, Err(e) => { - error!("BFT failed to retrieve the previous committee for the odd round {current_round} - {e}"); + error!( + "BFT failed to retrieve the previous committee with lag for the odd round {current_round} - {e}" + ); return false; } }; // Compute the stake for the leader certificate. - let (stake_with_leader, stake_without_leader) = - self.compute_stake_for_leader_certificate(leader_certificate_id, current_certificates, &previous_committee); + let (stake_with_leader, stake_without_leader) = self.compute_stake_for_leader_certificate( + leader_certificate_id, + current_certificates, + &previous_committee_with_lag, + ); // Return 'true' if any of the following conditions hold: - stake_with_leader >= previous_committee.availability_threshold() - || stake_without_leader >= previous_committee.quorum_threshold() + stake_with_leader >= previous_committee_with_lag.availability_threshold() + || stake_without_leader >= previous_committee_with_lag.quorum_threshold() || self.is_timer_expired() } @@ -448,12 +455,13 @@ impl BFT { return Ok(()); } - // Retrieve the previous committee for the commit round. - let Ok(previous_committee) = self.ledger().get_previous_committee_for_round(commit_round) else { - bail!("BFT failed to retrieve the committee for commit round {commit_round}"); + // Retrieve the previous committee with lag for the commit round. + let Ok(previous_committee_with_lag) = self.ledger().get_previous_committee_with_lag_for_round(commit_round) + else { + bail!("BFT failed to retrieve the committee with lag for commit round {commit_round}"); }; // Compute the leader for the commit round. - let Ok(leader) = previous_committee.get_leader(commit_round) else { + let Ok(leader) = previous_committee_with_lag.get_leader(commit_round) else { bail!("BFT failed to compute the leader for commit round {commit_round}"); }; // Retrieve the leader certificate for the commit round. @@ -476,7 +484,7 @@ impl BFT { }) .collect(); // Check if the leader is ready to be committed. - if !previous_committee.is_availability_threshold_reached(&authors) { + if !previous_committee_with_lag.is_availability_threshold_reached(&authors) { // If the leader is not ready to be committed, return early. trace!("BFT is not ready to commit {commit_round}"); return Ok(()); diff --git a/node/bft/src/gateway.rs b/node/bft/src/gateway.rs index 733b4ea3a2..9d15c22dc9 100644 --- a/node/bft/src/gateway.rs +++ b/node/bft/src/gateway.rs @@ -327,13 +327,14 @@ impl Gateway { /// Returns `true` if the given address is an authorized validator. pub fn is_authorized_validator_address(&self, validator_address: Address) -> bool { + // TODO (raychu86): How should we address the authorized validators now that we have committee lags. // Determine if the validator address is a member of the previous or current committee. // We allow leniency in this validation check in order to accommodate these two scenarios: // 1. New validators should be able to connect immediately once bonded as a committee member. // 2. Existing validators must remain connected until they are no longer bonded as a committee member. // (i.e. meaning they must stay online until the next block has been produced) self.ledger - .get_previous_committee_for_round(self.ledger.latest_round()) + .get_previous_committee_with_lag_for_round(self.ledger.latest_round()) .map_or(false, |committee| committee.is_committee_member(validator_address)) || self .ledger diff --git a/node/bft/src/helpers/storage.rs b/node/bft/src/helpers/storage.rs index 3ebbd0cad8..5578c1aa7e 100644 --- a/node/bft/src/helpers/storage.rs +++ b/node/bft/src/helpers/storage.rs @@ -340,12 +340,12 @@ impl Storage { bail!("Batch for round {round} already exists in storage {gc_log}") } - // Retrieve the previous committee for the batch round. - let Ok(previous_committee) = self.ledger.get_previous_committee_for_round(round) else { - bail!("Storage failed to retrieve the committee for round {round} {gc_log}") + // Retrieve the previous committee with lag for the batch round. + let Ok(previous_committee_with_lag) = self.ledger.get_previous_committee_with_lag_for_round(round) else { + bail!("Storage failed to retrieve the committee with lag for round {round} {gc_log}") }; // Ensure the author is in the committee. - if !previous_committee.is_committee_member(batch_header.author()) { + if !previous_committee_with_lag.is_committee_member(batch_header.author()) { bail!("Author {} is not in the committee for round {round} {gc_log}", batch_header.author()) } @@ -362,8 +362,9 @@ impl Storage { let previous_round = round.saturating_sub(1); // Check if the previous round is within range of the GC round. if previous_round > gc_round { - // Retrieve the committee for the previous round. - let Ok(previous_committee) = self.ledger.get_previous_committee_for_round(previous_round) else { + // Retrieve the committee with lag for the previous round. + let Ok(previous_committee_with_lag) = self.ledger.get_previous_committee_with_lag_for_round(previous_round) + else { bail!("Missing committee for the previous round {previous_round} in storage {gc_log}") }; // Ensure the previous round certificates exists in storage. @@ -371,7 +372,7 @@ impl Storage { bail!("Missing certificates for the previous round {previous_round} in storage {gc_log}") } // Ensure the number of previous certificate IDs is at or below the number of committee members. - if batch_header.previous_certificate_ids().len() > previous_committee.num_members() { + if batch_header.previous_certificate_ids().len() > previous_committee_with_lag.num_members() { bail!("Too many previous certificates for round {round} {gc_log}") } // Initialize a set of the previous authors. @@ -397,7 +398,7 @@ impl Storage { previous_authors.insert(previous_certificate.author()); } // Ensure the previous certificates have reached the quorum threshold. - if !previous_committee.is_quorum_threshold_reached(&previous_authors) { + if !previous_committee_with_lag.is_quorum_threshold_reached(&previous_authors) { bail!("Previous certificates for a batch in round {round} did not reach quorum threshold {gc_log}") } } @@ -447,8 +448,8 @@ impl Storage { // Check the timestamp for liveness. check_timestamp_for_liveness(certificate.timestamp())?; - // Retrieve the previous committee for the batch round. - let Ok(previous_committee) = self.ledger.get_previous_committee_for_round(round) else { + // Retrieve the previous committee with lag for the batch round. + let Ok(previous_committee_with_lag) = self.ledger.get_previous_committee_with_lag_for_round(round) else { bail!("Storage failed to retrieve the committee for round {round} {gc_log}") }; @@ -462,7 +463,7 @@ impl Storage { // Retrieve the signer. let signer = signature.to_address(); // Ensure the signer is in the committee. - if !previous_committee.is_committee_member(signer) { + if !previous_committee_with_lag.is_committee_member(signer) { bail!("Signer {signer} is not in the committee for round {round} {gc_log}") } // Append the signer. @@ -470,7 +471,7 @@ impl Storage { } // Ensure the signatures have reached the quorum threshold. - if !previous_committee.is_quorum_threshold_reached(&signers) { + if !previous_committee_with_lag.is_quorum_threshold_reached(&signers) { bail!("Signatures for a batch in round {round} did not reach quorum threshold {gc_log}") } Ok(missing_transmissions) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 419894877a..b01b05b4df 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -285,7 +285,9 @@ impl Primary { // TODO(ljedrz): the BatchHeader should be serialized only once in advance before being sent to non-signers. let event = Event::BatchPropose(proposal.batch_header().clone().into()); // Iterate through the non-signers. - for address in proposal.nonsigners(&self.ledger.get_previous_committee_for_round(proposal.round())?) { + for address in + proposal.nonsigners(&self.ledger.get_previous_committee_with_lag_for_round(proposal.round())?) + { // Resolve the address to the peer IP. match self.gateway.resolver().get_peer_ip_for_address(address) { // Resend the batch proposal to the validator for signing. @@ -334,13 +336,13 @@ impl Primary { // Check if the primary is connected to enough validators to reach quorum threshold. { // Retrieve the committee to check against. - let committee = self.ledger.get_previous_committee_for_round(round)?; + let committee_with_lag = self.ledger.get_previous_committee_with_lag_for_round(round)?; // Retrieve the connected validator addresses. let mut connected_validators = self.gateway.connected_addresses(); // Append the primary to the set. connected_validators.insert(self.gateway.account().address()); // If quorum threshold is not reached, return early. - if !committee.is_quorum_threshold_reached(&connected_validators) { + if !committee_with_lag.is_quorum_threshold_reached(&connected_validators) { debug!( "Primary is safely skipping a batch proposal {}", "(please connect to more validators)".dimmed() @@ -360,14 +362,15 @@ impl Primary { let mut is_ready = previous_round == 0; // If the previous round is not 0, check if the previous certificates have reached the quorum threshold. if previous_round > 0 { - // Retrieve the previous committee for the round. - let Ok(previous_committee) = self.ledger.get_previous_committee_for_round(previous_round) else { - bail!("Cannot propose a batch for round {round}: the previous committee is not known yet") + // Retrieve the previous committee with lag for the round. + let Ok(previous_committee_with_lag) = self.ledger.get_previous_committee_with_lag_for_round(previous_round) + else { + bail!("Cannot propose a batch for round {round}: the previous committee with lag is not known yet") }; // Construct a set over the authors. let authors = previous_certificates.iter().map(BatchCertificate::author).collect(); // Check if the previous certificates have reached the quorum threshold. - if previous_committee.is_quorum_threshold_reached(&authors) { + if previous_committee_with_lag.is_quorum_threshold_reached(&authors) { is_ready = true; } } @@ -466,8 +469,11 @@ impl Primary { &mut rand::thread_rng() ))?; // Construct the proposal. - let proposal = - Proposal::new(self.ledger.get_previous_committee_for_round(round)?, batch_header.clone(), transmissions)?; + let proposal = Proposal::new( + self.ledger.get_previous_committee_with_lag_for_round(round)?, + batch_header.clone(), + transmissions, + )?; // Broadcast the batch to all validators for signing. self.gateway.broadcast(Event::BatchPropose(batch_header.into())); // Set the proposed batch. @@ -656,17 +662,18 @@ impl Primary { ), } } - // Retrieve the previous committee for the round. - let previous_committee = self.ledger.get_previous_committee_for_round(proposal.round())?; + // Retrieve the previous committee with lag for the round. + let previous_committee_with_lag = + self.ledger.get_previous_committee_with_lag_for_round(proposal.round())?; // Retrieve the address of the validator. let Some(signer) = self.gateway.resolver().get_address(peer_ip) else { bail!("Signature is from a disconnected validator"); }; // Add the signature to the batch. - proposal.add_signature(signer, signature, &previous_committee)?; + proposal.add_signature(signer, signature, &previous_committee_with_lag)?; info!("Received a batch signature for round {} from '{peer_ip}'", proposal.round()); // Check if the batch is ready to be certified. - if !proposal.is_quorum_threshold_reached(&previous_committee) { + if !proposal.is_quorum_threshold_reached(&previous_committee_with_lag) { // If the batch is not ready to be certified, return early. return Ok(()); } @@ -685,11 +692,11 @@ impl Primary { info!("Quorum threshold reached - Preparing to certify our batch for round {}...", proposal.round()); - // Retrieve the previous committee for the round. - let previous_committee = self.ledger.get_previous_committee_for_round(proposal.round())?; + // Retrieve the previous committee with lag for the round. + let previous_committee_with_lag = self.ledger.get_previous_committee_with_lag_for_round(proposal.round())?; // Store the certified batch and broadcast it to all validators. // If there was an error storing the certificate, reinsert the transmissions back into the ready queue. - if let Err(e) = self.store_and_broadcast_certificate(&proposal, &previous_committee).await { + if let Err(e) = self.store_and_broadcast_certificate(&proposal, &previous_committee_with_lag).await { // Reinsert the transmissions back into the ready queue for the next proposal. self.reinsert_transmissions_into_workers(proposal)?; return Err(e); @@ -747,14 +754,14 @@ impl Primary { // Retrieve the current round. let current_round = self.current_round(); - // Retrieve the previous committee. - let previous_committee = self.ledger.get_previous_committee_for_round(current_round)?; + // Retrieve the previous committee with lag. + let previous_committee_with_lag = self.ledger.get_previous_committee_with_lag_for_round(current_round)?; // Retrieve the certificates. let certificates = self.storage.get_certificates_for_round(current_round); // Construct a set over the authors. let authors = certificates.iter().map(BatchCertificate::author).collect(); // Check if the certificates have reached the quorum threshold. - let is_quorum = previous_committee.is_quorum_threshold_reached(&authors); + let is_quorum = previous_committee_with_lag.is_quorum_threshold_reached(&authors); // Determine if we are currently proposing a round. // Note: This is important, because while our peers have advanced, @@ -1309,8 +1316,8 @@ impl Primary { let is_quorum_threshold_reached = { let certificates = self.storage.get_certificates_for_round(batch_round); let authors = certificates.iter().map(BatchCertificate::author).collect(); - let previous_committee = self.ledger.get_previous_committee_for_round(batch_round)?; - previous_committee.is_quorum_threshold_reached(&authors) + let previous_committee_with_lag = self.ledger.get_previous_committee_with_lag_for_round(batch_round)?; + previous_committee_with_lag.is_quorum_threshold_reached(&authors) }; // Check if our primary should move to the next round. diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index eba416a955..eb63774342 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -492,7 +492,7 @@ mod tests { fn get_batch_certificate(&self, certificate_id: &Field) -> Result>; fn current_committee(&self) -> Result>; fn get_committee_for_round(&self, round: u64) -> Result>; - fn get_previous_committee_for_round(&self, round: u64) -> Result>; + fn get_previous_committee_with_lag_for_round(&self, round: u64) -> Result>; fn contains_certificate(&self, certificate_id: &Field) -> Result; fn contains_transmission(&self, transmission_id: &TransmissionID) -> Result; fn ensure_transmission_id_matches( From 1f2dfc0d3903bc80aade8f870454afb35fa9dc82 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 7 Feb 2024 15:19:58 -0800 Subject: [PATCH 012/551] Add test to enforce MAX_GC_ROUNDS is equivalent to the COMMITTEE_ROUND_LAG --- node/bft/src/lib.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/node/bft/src/lib.rs b/node/bft/src/lib.rs index 839843011e..bb6cdfbd99 100644 --- a/node/bft/src/lib.rs +++ b/node/bft/src/lib.rs @@ -72,3 +72,17 @@ macro_rules! spawn_blocking { } }; } + +#[cfg(test)] +mod tests { + use super::*; + + type CurrentNetwork = snarkvm::console::network::Testnet3; + + #[test] + fn test_max_gc_rounds() { + assert_eq!(MAX_GC_ROUNDS, snarkvm::ledger::narwhal::BatchHeader::::MAX_GC_ROUNDS as u64); + assert_eq!(MAX_GC_ROUNDS, snarkvm::ledger::narwhal::Subdag::::MAX_ROUNDS); + assert_eq!(MAX_GC_ROUNDS, ::COMMITTEE_ROUND_LAG); + } +} From 4416bc241f752e928702a572248f48314d2670f0 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 7 Feb 2024 15:22:16 -0800 Subject: [PATCH 013/551] Update comment --- node/bft/src/gateway.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/node/bft/src/gateway.rs b/node/bft/src/gateway.rs index 9d15c22dc9..7f0c799b15 100644 --- a/node/bft/src/gateway.rs +++ b/node/bft/src/gateway.rs @@ -327,8 +327,7 @@ impl Gateway { /// Returns `true` if the given address is an authorized validator. pub fn is_authorized_validator_address(&self, validator_address: Address) -> bool { - // TODO (raychu86): How should we address the authorized validators now that we have committee lags. - // Determine if the validator address is a member of the previous or current committee. + // Determine if the validator address is a member of the previous committee with lag or the current committee. // We allow leniency in this validation check in order to accommodate these two scenarios: // 1. New validators should be able to connect immediately once bonded as a committee member. // 2. Existing validators must remain connected until they are no longer bonded as a committee member. From 2612d64ec711f293f09e3e26458f76b65f49c3b3 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 7 Feb 2024 15:42:57 -0800 Subject: [PATCH 014/551] Update rev - 5b5c559 feat/committee-round-lag --- Cargo.lock | 116 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 2 +- 2 files changed, 59 insertions(+), 59 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bdf7d02834..2a8925b025 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3523,7 +3523,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "anstyle", "anyhow", @@ -3554,7 +3554,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "aleo-std", "anyhow", @@ -3584,7 +3584,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3598,7 +3598,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3609,7 +3609,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3619,7 +3619,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3629,7 +3629,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "indexmap 2.2.2", "itertools 0.11.0", @@ -3647,12 +3647,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" [[package]] name = "snarkvm-circuit-network" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3663,7 +3663,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3678,7 +3678,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3693,7 +3693,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3706,7 +3706,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3715,7 +3715,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3725,7 +3725,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3737,7 +3737,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3749,7 +3749,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3760,7 +3760,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3772,7 +3772,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3785,7 +3785,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "bs58", "snarkvm-console-network", @@ -3796,7 +3796,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "blake2s_simd", "smallvec", @@ -3809,7 +3809,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "aleo-std", "rayon", @@ -3820,7 +3820,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "anyhow", "indexmap 2.2.2", @@ -3843,7 +3843,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "anyhow", "bech32", @@ -3861,7 +3861,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "enum_index", "enum_index_derive", @@ -3882,7 +3882,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3897,7 +3897,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3908,7 +3908,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "snarkvm-console-network-environment", ] @@ -3916,7 +3916,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3926,7 +3926,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3937,7 +3937,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3948,7 +3948,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3959,7 +3959,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3970,7 +3970,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "rand", "rayon", @@ -3984,7 +3984,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "aleo-std", "anyhow", @@ -4001,7 +4001,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "aleo-std", "anyhow", @@ -4026,7 +4026,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "anyhow", "rand", @@ -4038,7 +4038,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4057,7 +4057,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-coinbase" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "aleo-std", "anyhow", @@ -4077,7 +4077,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "anyhow", "indexmap 2.2.2", @@ -4095,7 +4095,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -4108,7 +4108,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4121,7 +4121,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "indexmap 2.2.2", "serde_json", @@ -4133,7 +4133,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "bytes", "serde_json", @@ -4144,7 +4144,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4159,7 +4159,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "bytes", "serde_json", @@ -4172,7 +4172,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "snarkvm-console", "snarkvm-ledger-coinbase", @@ -4181,7 +4181,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "async-trait", "reqwest", @@ -4194,7 +4194,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "aleo-std-storage", "anyhow", @@ -4219,7 +4219,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4234,7 +4234,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4243,7 +4243,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "aleo-std", "anyhow", @@ -4268,7 +4268,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "aleo-std", "anyhow", @@ -4292,7 +4292,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "aleo-std", "colored", @@ -4315,7 +4315,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "indexmap 2.2.2", "paste", @@ -4329,7 +4329,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "bincode", "once_cell", @@ -4342,7 +4342,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "aleo-std", "anyhow", @@ -4363,7 +4363,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1e4c188#1e4c1881303b2f2461e4aace75516bbbe1abd0b7" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" dependencies = [ "proc-macro2", "quote 1.0.35", diff --git a/Cargo.toml b/Cargo.toml index b32c66f84b..df1e04ee80 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,7 +42,7 @@ members = [ [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "1e4c188" # feat/committee-round-lag +rev = "5b5c559" # feat/committee-round-lag #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From 1ec9145bb3d45fb75d910aa9b6bcd012b9c8d68e Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 7 Feb 2024 16:17:12 -0800 Subject: [PATCH 015/551] Update rev - bef915a feat/committee-round-lag --- Cargo.lock | 116 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 2 +- 2 files changed, 59 insertions(+), 59 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2a8925b025..560176b99c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3523,7 +3523,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "anstyle", "anyhow", @@ -3554,7 +3554,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "aleo-std", "anyhow", @@ -3584,7 +3584,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3598,7 +3598,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3609,7 +3609,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3619,7 +3619,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3629,7 +3629,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "indexmap 2.2.2", "itertools 0.11.0", @@ -3647,12 +3647,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" [[package]] name = "snarkvm-circuit-network" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3663,7 +3663,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3678,7 +3678,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3693,7 +3693,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3706,7 +3706,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3715,7 +3715,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3725,7 +3725,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3737,7 +3737,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3749,7 +3749,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3760,7 +3760,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3772,7 +3772,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3785,7 +3785,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "bs58", "snarkvm-console-network", @@ -3796,7 +3796,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "blake2s_simd", "smallvec", @@ -3809,7 +3809,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "aleo-std", "rayon", @@ -3820,7 +3820,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "anyhow", "indexmap 2.2.2", @@ -3843,7 +3843,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "anyhow", "bech32", @@ -3861,7 +3861,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "enum_index", "enum_index_derive", @@ -3882,7 +3882,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3897,7 +3897,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3908,7 +3908,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "snarkvm-console-network-environment", ] @@ -3916,7 +3916,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3926,7 +3926,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3937,7 +3937,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3948,7 +3948,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3959,7 +3959,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3970,7 +3970,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "rand", "rayon", @@ -3984,7 +3984,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "aleo-std", "anyhow", @@ -4001,7 +4001,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "aleo-std", "anyhow", @@ -4026,7 +4026,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "anyhow", "rand", @@ -4038,7 +4038,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4057,7 +4057,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-coinbase" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "aleo-std", "anyhow", @@ -4077,7 +4077,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "anyhow", "indexmap 2.2.2", @@ -4095,7 +4095,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -4108,7 +4108,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4121,7 +4121,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "indexmap 2.2.2", "serde_json", @@ -4133,7 +4133,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "bytes", "serde_json", @@ -4144,7 +4144,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4159,7 +4159,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "bytes", "serde_json", @@ -4172,7 +4172,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "snarkvm-console", "snarkvm-ledger-coinbase", @@ -4181,7 +4181,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "async-trait", "reqwest", @@ -4194,7 +4194,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "aleo-std-storage", "anyhow", @@ -4219,7 +4219,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4234,7 +4234,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4243,7 +4243,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "aleo-std", "anyhow", @@ -4268,7 +4268,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "aleo-std", "anyhow", @@ -4292,7 +4292,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "aleo-std", "colored", @@ -4315,7 +4315,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "indexmap 2.2.2", "paste", @@ -4329,7 +4329,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "bincode", "once_cell", @@ -4342,7 +4342,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "aleo-std", "anyhow", @@ -4363,7 +4363,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5b5c559#5b5c5593f5dd20817c6bb1e5e924ad684491be9a" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" dependencies = [ "proc-macro2", "quote 1.0.35", diff --git a/Cargo.toml b/Cargo.toml index df1e04ee80..41fe2e5aad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,7 +42,7 @@ members = [ [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "5b5c559" # feat/committee-round-lag +rev = "bef915a" # feat/committee-round-lag #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From 0cfd9d32327d4a9f075bc2f95a70574a8a587329 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Tue, 30 Jan 2024 16:38:20 -0500 Subject: [PATCH 016/551] Adds support for multiple committed dags --- node/bft/src/bft.rs | 214 ++++++++++++++++++++++++++++---------------- 1 file changed, 137 insertions(+), 77 deletions(-) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 5637ddfd3e..30004ce008 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -497,94 +497,129 @@ impl BFT { leader_certificate: BatchCertificate, election_certificate_ids: IndexSet>, ) -> Result<()> { - // Retrieve the leader certificate round. - let leader_round = leader_certificate.round(); - // Compute the commit subdag. - let commit_subdag = match self.order_dag_with_dfs::(leader_certificate) { - Ok(subdag) => subdag, - Err(e) => bail!("BFT failed to order the DAG with DFS - {e}"), - }; - // Initialize a map for the deduped transmissions. - let mut transmissions = IndexMap::new(); - // Start from the oldest leader certificate. - for certificate in commit_subdag.values().flatten() { - // Update the DAG. - if IS_SYNCING { - self.dag.write().commit(certificate, self.storage().max_gc_rounds()); - } - // Retrieve the transmissions. - for transmission_id in certificate.transmission_ids() { - // If the transmission already exists in the map, skip it. - if transmissions.contains_key(transmission_id) { - continue; - } - // If the transmission already exists in the ledger, skip it. - // Note: On failure to read from the ledger, we skip including this transmission, out of safety. - if self.ledger().contains_transmission(transmission_id).unwrap_or(true) { + // Determine the list of all previous leader certificates since the last committed round. + // The order of the leader certificates is from **newest** to **oldest**. + let mut leader_certificates = vec![leader_certificate.clone()]; + { + // Retrieve the leader round. + let leader_round = leader_certificate.round(); + // Retrieve the leader for the round. + // TODO (howardwu): This is a static leader. Change it to fetch the actual leader for the specified round. + let leader = leader_certificate.author(); + + let mut current_certificate = leader_certificate; + for round in (self.dag.read().last_committed_round() + 2..=leader_round.saturating_sub(2)).rev().step_by(2) + { + // Retrieve the previous leader certificate. + let Some(previous_certificate) = self.dag.read().get_certificate_for_round_with_author(round, leader) + else { continue; - } - // Retrieve the transmission. - let Some(transmission) = self.storage().get_transmission(*transmission_id) else { - bail!( - "BFT failed to retrieve transmission '{}' from round {}", - fmt_id(transmission_id), - certificate.round() - ); }; - // Add the transmission to the set. - transmissions.insert(*transmission_id, transmission); + // Determine if there is a path between the previous certificate and the current certificate. + if self.is_linked(previous_certificate.clone(), current_certificate.clone())? { + // Add the previous leader certificate to the list of certificates to commit. + leader_certificates.push(previous_certificate.clone()); + // Update the current certificate to the previous leader certificate. + current_certificate = previous_certificate; + } } } - // If the node is not syncing, trigger consensus, as this will build a new block for the ledger. - if !IS_SYNCING { - // Construct the subdag. - let subdag = Subdag::from(commit_subdag.clone(), election_certificate_ids.clone())?; - // Retrieve the anchor round. - let anchor_round = subdag.anchor_round(); - // Retrieve the number of transmissions. - let num_transmissions = transmissions.len(); - // Retrieve metadata about the subdag. - let subdag_metadata = subdag.iter().map(|(round, c)| (*round, c.len())).collect::>(); - - // Ensure the subdag anchor round matches the leader round. - ensure!( - anchor_round == leader_round, - "BFT failed to commit - the subdag anchor round {anchor_round} does not match the leader round {leader_round}", - ); - // Trigger consensus. - if let Some(consensus_sender) = self.consensus_sender.get() { - // Initialize a callback sender and receiver. - let (callback_sender, callback_receiver) = oneshot::channel(); - // Send the subdag and transmissions to consensus. - consensus_sender.tx_consensus_subdag.send((subdag, transmissions, callback_sender)).await?; - // Await the callback to continue. - match callback_receiver.await { - Ok(Ok(())) => (), // continue - Ok(Err(e)) => { - error!("BFT failed to advance the subdag for round {anchor_round} - {e}"); - return Ok(()); + // Iterate over the leader certificates to commit. + for leader_certificate in leader_certificates.into_iter().rev() { + // Retrieve the leader certificate round. + let leader_round = leader_certificate.round(); + // Compute the commit subdag. + let commit_subdag = match self.order_dag_with_dfs::(leader_certificate) { + Ok(subdag) => subdag, + Err(e) => bail!("BFT failed to order the DAG with DFS - {e}"), + }; + // Initialize a map for the deduped transmissions. + let mut transmissions = IndexMap::new(); + // Start from the oldest leader certificate. + for certificate in commit_subdag.values().flatten() { + // Update the DAG. + if IS_SYNCING { + self.dag.write().commit(certificate, self.storage().max_gc_rounds()); + } + // Retrieve the transmissions. + for transmission_id in certificate.transmission_ids() { + // If the transmission already exists in the map, skip it. + if transmissions.contains_key(transmission_id) { + continue; } - Err(e) => { - error!("BFT failed to receive the callback for round {anchor_round} - {e}"); - return Ok(()); + // If the transmission already exists in the ledger, skip it. + // Note: On failure to read from the ledger, we skip including this transmission, out of safety. + if self.ledger().contains_transmission(transmission_id).unwrap_or(true) { + continue; } + // Retrieve the transmission. + let Some(transmission) = self.storage().get_transmission(*transmission_id) else { + bail!( + "BFT failed to retrieve transmission '{}' from round {}", + fmt_id(transmission_id), + certificate.round() + ); + }; + // Add the transmission to the set. + transmissions.insert(*transmission_id, transmission); } } + // If the node is not syncing, trigger consensus, as this will build a new block for the ledger. + if !IS_SYNCING { + // Construct the subdag. + let subdag = Subdag::from(commit_subdag.clone(), election_certificate_ids.clone())?; + // Retrieve the anchor round. + let anchor_round = subdag.anchor_round(); + // Retrieve the number of transmissions. + let num_transmissions = transmissions.len(); + // Retrieve metadata about the subdag. + let subdag_metadata = subdag.iter().map(|(round, c)| (*round, c.len())).collect::>(); + + // Ensure the subdag anchor round matches the leader round. + ensure!( + anchor_round == leader_round, + "BFT failed to commit - the subdag anchor round {anchor_round} does not match the leader round {leader_round}", + ); + + // Trigger consensus. + if let Some(consensus_sender) = self.consensus_sender.get() { + // Initialize a callback sender and receiver. + let (callback_sender, callback_receiver) = oneshot::channel(); + // Send the subdag and transmissions to consensus. + consensus_sender.tx_consensus_subdag.send((subdag, transmissions, callback_sender)).await?; + // Await the callback to continue. + match callback_receiver.await { + Ok(Ok(())) => (), // continue + Ok(Err(e)) => { + error!("BFT failed to advance the subdag for round {anchor_round} - {e}"); + return Ok(()); + } + Err(e) => { + error!("BFT failed to receive the callback for round {anchor_round} - {e}"); + return Ok(()); + } + } + } - info!( - "\n\nCommitting a subdag from round {anchor_round} with {num_transmissions} transmissions: {subdag_metadata:?}\n" - ); - // Update the DAG, as the subdag was successfully included into a block. - let mut dag_write = self.dag.write(); - for certificate in commit_subdag.values().flatten() { - dag_write.commit(certificate, self.storage().max_gc_rounds()); + info!( + "\n\nCommitting a subdag from round {anchor_round} with {num_transmissions} transmissions: {subdag_metadata:?}\n" + ); + // Update the DAG, as the subdag was successfully included into a block. + let mut dag_write = self.dag.write(); + for certificate in commit_subdag.values().flatten() { + dag_write.commit(certificate, self.storage().max_gc_rounds()); + } + } + // Update the last election certificate IDs. + // TODO (howardwu): This is currently writing the *latest* election certificate IDs, + // however this needs to be dynamically retrieving the election certificate IDs for the + // leader round (technically the `leader_round+1` round to get the election round) + // that it is currently committing. + { + let mut last_election_certificate_ids = self.last_election_certificate_ids.write(); + *last_election_certificate_ids = election_certificate_ids.clone(); } - } - // Update the last election certificate IDs. - { - let mut last_election_certificate_ids = self.last_election_certificate_ids.write(); - *last_election_certificate_ids = election_certificate_ids; } Ok(()) } @@ -668,6 +703,31 @@ impl BFT { // Return the certificates to commit. Ok(commit) } + + /// Returns `true` if there is a path from the previous certificate to the current certificate. + fn is_linked( + &self, + previous_certificate: BatchCertificate, + current_certificate: BatchCertificate, + ) -> Result { + // Initialize the list containing the traversal. + let mut traversal = vec![current_certificate.clone()]; + // Iterate over the rounds from the current certificate to the previous certificate. + for round in (previous_certificate.round()..current_certificate.round()).rev() { + // Retrieve all of the certificates for this past round. + let Some(certificates) = self.dag.read().get_certificates_for_round(round) else { + // This is a critical error, as the traversal should have these certificates. + // If this error is hit, it is likely that the maximum GC rounds should be increased. + bail!("BFT failed to retrieve the certificates for past round {round}"); + }; + // Filter the certificates to only include those that are in the traversal. + traversal = certificates + .into_values() + .filter(|c| traversal.iter().any(|p| p.previous_certificate_ids().contains(&c.id()))) + .collect(); + } + Ok(traversal.contains(&previous_certificate)) + } } impl BFT { From 0e47d74d6b9e7fcfa8bc4d19f1881bfadcbfe023 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 7 Feb 2024 21:42:24 -0800 Subject: [PATCH 017/551] Clarify filtering in is_linked --- node/bft/src/bft.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 30004ce008..498a1ab0c1 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -723,7 +723,7 @@ impl BFT { // Filter the certificates to only include those that are in the traversal. traversal = certificates .into_values() - .filter(|c| traversal.iter().any(|p| p.previous_certificate_ids().contains(&c.id()))) + .filter(|p| traversal.iter().any(|c| c.previous_certificate_ids().contains(&p.id()))) .collect(); } Ok(traversal.contains(&previous_certificate)) From b158fd4f32b10bdf0ab2dba02b799feeeffd3514 Mon Sep 17 00:00:00 2001 From: Michel D <108158289+mdelle1@users.noreply.github.com> Date: Fri, 2 Feb 2024 15:17:45 -0500 Subject: [PATCH 018/551] Adds support for dynamic leaders --- node/bft/src/bft.rs | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 498a1ab0c1..33e3222649 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -494,33 +494,44 @@ impl BFT { /// Commits the leader certificate, and all previous leader certificates since the last committed round. async fn commit_leader_certificate( &self, - leader_certificate: BatchCertificate, + root_leader_certificate: BatchCertificate, election_certificate_ids: IndexSet>, ) -> Result<()> { // Determine the list of all previous leader certificates since the last committed round. // The order of the leader certificates is from **newest** to **oldest**. - let mut leader_certificates = vec![leader_certificate.clone()]; + let mut leader_certificates = vec![root_leader_certificate.clone()]; { - // Retrieve the leader round. - let leader_round = leader_certificate.round(); - // Retrieve the leader for the round. - // TODO (howardwu): This is a static leader. Change it to fetch the actual leader for the specified round. - let leader = leader_certificate.author(); - - let mut current_certificate = leader_certificate; - for round in (self.dag.read().last_committed_round() + 2..=leader_round.saturating_sub(2)).rev().step_by(2) + // Retrieve the root leader round. + let root_leader_round = root_leader_certificate.round(); + // Initialize the current leader certificate to the root leader certificate. This will be updated as we recurse through the root leader subDAG. + let mut current_leader_certificate = root_leader_certificate; + for round in (self.dag.read().last_committed_round() + 2..=root_leader_round.saturating_sub(2)).rev().step_by(2) { + // Retrieve the previous committee for the leader round. + let previous_committee = match self.ledger().get_previous_committee_for_round(round) { + Ok(committee) => committee, + Err(e) => { + bail!("BFT failed to retrieve the previous committee for the even round {round} - {e}"); + } + }; + // Compute the leader address for the leader round. + let previous_leader = match previous_committee.get_leader(round) { + Ok(leader) => leader, + Err(e) => { + bail!("BFT failed to compute the leader for the even round {round} - {e}"); + } + }; // Retrieve the previous leader certificate. - let Some(previous_certificate) = self.dag.read().get_certificate_for_round_with_author(round, leader) + let Some(previous_leader_certificate) = self.dag.read().get_certificate_for_round_with_author(round, previous_leader) else { continue; }; - // Determine if there is a path between the previous certificate and the current certificate. - if self.is_linked(previous_certificate.clone(), current_certificate.clone())? { + // Determine if there is a path between the previous certificate and the current leader certificate. + if self.is_linked(previous_leader_certificate.clone(), current_leader_certificate.clone())? { // Add the previous leader certificate to the list of certificates to commit. - leader_certificates.push(previous_certificate.clone()); - // Update the current certificate to the previous leader certificate. - current_certificate = previous_certificate; + leader_certificates.push(previous_leader_certificate.clone()); + // Update the current leader certificate to the previous leader certificate. + current_leader_certificate = previous_leader_certificate; } } } @@ -721,7 +732,7 @@ impl BFT { bail!("BFT failed to retrieve the certificates for past round {round}"); }; // Filter the certificates to only include those that are in the traversal. - traversal = certificates + traversal = certificates .into_values() .filter(|p| traversal.iter().any(|c| c.previous_certificate_ids().contains(&p.id()))) .collect(); From 05375ef6d2482dbcca4b50724e4025912f66f073 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 7 Feb 2024 21:59:45 -0800 Subject: [PATCH 019/551] Cleanup recursive leader selection in commit_leader_certificate --- node/bft/src/bft.rs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 33e3222649..a032fb3b5a 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -494,44 +494,44 @@ impl BFT { /// Commits the leader certificate, and all previous leader certificates since the last committed round. async fn commit_leader_certificate( &self, - root_leader_certificate: BatchCertificate, + leader_certificate: BatchCertificate, election_certificate_ids: IndexSet>, ) -> Result<()> { // Determine the list of all previous leader certificates since the last committed round. // The order of the leader certificates is from **newest** to **oldest**. - let mut leader_certificates = vec![root_leader_certificate.clone()]; + let mut leader_certificates = vec![leader_certificate.clone()]; { - // Retrieve the root leader round. - let root_leader_round = root_leader_certificate.round(); - // Initialize the current leader certificate to the root leader certificate. This will be updated as we recurse through the root leader subDAG. - let mut current_leader_certificate = root_leader_certificate; - for round in (self.dag.read().last_committed_round() + 2..=root_leader_round.saturating_sub(2)).rev().step_by(2) + // Retrieve the leader round. + let leader_round = leader_certificate.round(); + + let mut current_leader_certificate = leader_certificate; + for round in (self.dag.read().last_committed_round() + 2..=leader_round.saturating_sub(2)).rev().step_by(2) { - // Retrieve the previous committee for the leader round. + // Retrieve the previous committee for the leader round. let previous_committee = match self.ledger().get_previous_committee_for_round(round) { Ok(committee) => committee, Err(e) => { bail!("BFT failed to retrieve the previous committee for the even round {round} - {e}"); } }; - // Compute the leader address for the leader round. - let previous_leader = match previous_committee.get_leader(round) { + // Compute the leader address for the leader round. + let leader = match previous_committee.get_leader(round) { Ok(leader) => leader, Err(e) => { bail!("BFT failed to compute the leader for the even round {round} - {e}"); } }; // Retrieve the previous leader certificate. - let Some(previous_leader_certificate) = self.dag.read().get_certificate_for_round_with_author(round, previous_leader) + let Some(previous_certificate) = self.dag.read().get_certificate_for_round_with_author(round, leader) else { continue; }; // Determine if there is a path between the previous certificate and the current leader certificate. - if self.is_linked(previous_leader_certificate.clone(), current_leader_certificate.clone())? { + if self.is_linked(previous_certificate.clone(), current_leader_certificate.clone())? { // Add the previous leader certificate to the list of certificates to commit. - leader_certificates.push(previous_leader_certificate.clone()); + leader_certificates.push(previous_certificate.clone()); // Update the current leader certificate to the previous leader certificate. - current_leader_certificate = previous_leader_certificate; + current_leader_certificate = previous_certificate; } } } @@ -732,7 +732,7 @@ impl BFT { bail!("BFT failed to retrieve the certificates for past round {round}"); }; // Filter the certificates to only include those that are in the traversal. - traversal = certificates + traversal = certificates .into_values() .filter(|p| traversal.iter().any(|c| c.previous_certificate_ids().contains(&p.id()))) .collect(); From e20a5c10d9e203c8277b57431b11dcc53d11a0b1 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 7 Feb 2024 22:12:48 -0800 Subject: [PATCH 020/551] Remove unused MAX_GC_ROUNDS variable in favor of snarkVM variant --- node/bft/src/lib.rs | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/node/bft/src/lib.rs b/node/bft/src/lib.rs index bb6cdfbd99..85d06b2088 100644 --- a/node/bft/src/lib.rs +++ b/node/bft/src/lib.rs @@ -48,8 +48,6 @@ pub const MEMORY_POOL_PORT: u16 = 5000; // port /// The maximum number of milliseconds to wait before proposing a batch. pub const MAX_BATCH_DELAY_IN_MS: u64 = 2500; // ms -/// The maximum number of rounds to store before garbage collecting. -pub const MAX_GC_ROUNDS: u64 = 50; // rounds /// The maximum number of seconds allowed for the leader to send their certificate. pub const MAX_LEADER_CERTIFICATE_DELAY_IN_SECS: i64 = 2 * MAX_BATCH_DELAY_IN_MS as i64 / 1000; // seconds /// The maximum number of seconds before the timestamp is considered expired. @@ -72,17 +70,3 @@ macro_rules! spawn_blocking { } }; } - -#[cfg(test)] -mod tests { - use super::*; - - type CurrentNetwork = snarkvm::console::network::Testnet3; - - #[test] - fn test_max_gc_rounds() { - assert_eq!(MAX_GC_ROUNDS, snarkvm::ledger::narwhal::BatchHeader::::MAX_GC_ROUNDS as u64); - assert_eq!(MAX_GC_ROUNDS, snarkvm::ledger::narwhal::Subdag::::MAX_ROUNDS); - assert_eq!(MAX_GC_ROUNDS, ::COMMITTEE_ROUND_LAG); - } -} From 50b08347f8b09c8056cae9a816cfe20f48dd7a4e Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Fri, 9 Feb 2024 14:01:17 -0800 Subject: [PATCH 021/551] Update constant --- node/consensus/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index a5d8dd086c..dd21abf312 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -93,10 +93,10 @@ impl Consensus { bft, primary_sender: Default::default(), solutions_queue: Arc::new(Mutex::new(LruCache::new( - NonZeroUsize::new(MAX_TRANSMISSIONS_PER_BATCH).unwrap(), + NonZeroUsize::new(BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH).unwrap(), ))), transactions_queue: Arc::new(Mutex::new(LruCache::new( - NonZeroUsize::new(MAX_TRANSMISSIONS_PER_BATCH).unwrap(), + NonZeroUsize::new(BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH).unwrap(), ))), seen_solutions: Arc::new(Mutex::new(LruCache::new(NonZeroUsize::new(1 << 16).unwrap()))), seen_transactions: Arc::new(Mutex::new(LruCache::new(NonZeroUsize::new(1 << 16).unwrap()))), From fc991071d86b2b30ff8ea874a7b0a6d45b4d17ab Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Fri, 9 Feb 2024 17:06:29 -0800 Subject: [PATCH 022/551] nit: variable name --- node/bft/src/bft.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index a032fb3b5a..23ef94327f 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -504,7 +504,7 @@ impl BFT { // Retrieve the leader round. let leader_round = leader_certificate.round(); - let mut current_leader_certificate = leader_certificate; + let mut current_certificate = leader_certificate; for round in (self.dag.read().last_committed_round() + 2..=leader_round.saturating_sub(2)).rev().step_by(2) { // Retrieve the previous committee for the leader round. @@ -526,12 +526,12 @@ impl BFT { else { continue; }; - // Determine if there is a path between the previous certificate and the current leader certificate. - if self.is_linked(previous_certificate.clone(), current_leader_certificate.clone())? { + // Determine if there is a path between the previous certificate and the current certificate. + if self.is_linked(previous_certificate.clone(), current_certificate.clone())? { // Add the previous leader certificate to the list of certificates to commit. leader_certificates.push(previous_certificate.clone()); - // Update the current leader certificate to the previous leader certificate. - current_leader_certificate = previous_certificate; + // Update the current certificate to the previous leader certificate. + current_certificate = previous_certificate; } } } From f161c7aedbeb28709ff41ab3424f4e58d87b39e0 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 9 Feb 2024 17:32:11 -0800 Subject: [PATCH 023/551] Update rev - 2d062ce --- Cargo.lock | 232 +++++++++++++------------- Cargo.toml | 2 +- node/bft/ledger-service/src/ledger.rs | 2 +- 3 files changed, 118 insertions(+), 118 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2b4fa6b1d4..d7925027db 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3525,8 +3525,8 @@ dependencies = [ [[package]] name = "snarkvm" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "anstyle", "anyhow", @@ -3556,8 +3556,8 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "aleo-std", "anyhow", @@ -3586,8 +3586,8 @@ dependencies = [ [[package]] name = "snarkvm-circuit" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3600,8 +3600,8 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3611,8 +3611,8 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3621,8 +3621,8 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3631,8 +3631,8 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "indexmap 2.2.2", "itertools 0.11.0", @@ -3649,13 +3649,13 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" [[package]] name = "snarkvm-circuit-network" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3665,8 +3665,8 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3680,8 +3680,8 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3695,8 +3695,8 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3708,8 +3708,8 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3717,8 +3717,8 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3727,8 +3727,8 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3739,8 +3739,8 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3751,8 +3751,8 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3762,8 +3762,8 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3774,8 +3774,8 @@ dependencies = [ [[package]] name = "snarkvm-console" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3787,8 +3787,8 @@ dependencies = [ [[package]] name = "snarkvm-console-account" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "bs58", "snarkvm-console-network", @@ -3798,8 +3798,8 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "blake2s_simd", "smallvec", @@ -3811,8 +3811,8 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "aleo-std", "rayon", @@ -3822,8 +3822,8 @@ dependencies = [ [[package]] name = "snarkvm-console-network" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "anyhow", "indexmap 2.2.2", @@ -3845,8 +3845,8 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "anyhow", "bech32", @@ -3863,8 +3863,8 @@ dependencies = [ [[package]] name = "snarkvm-console-program" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "enum_index", "enum_index_derive", @@ -3884,8 +3884,8 @@ dependencies = [ [[package]] name = "snarkvm-console-types" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3899,8 +3899,8 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3910,16 +3910,16 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "snarkvm-console-network-environment", ] [[package]] name = "snarkvm-console-types-field" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3928,8 +3928,8 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3939,8 +3939,8 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3950,8 +3950,8 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3961,8 +3961,8 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3972,8 +3972,8 @@ dependencies = [ [[package]] name = "snarkvm-curves" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "rand", "rayon", @@ -3986,8 +3986,8 @@ dependencies = [ [[package]] name = "snarkvm-fields" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "aleo-std", "anyhow", @@ -4003,8 +4003,8 @@ dependencies = [ [[package]] name = "snarkvm-ledger" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "aleo-std", "anyhow", @@ -4028,8 +4028,8 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "anyhow", "rand", @@ -4040,8 +4040,8 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4059,8 +4059,8 @@ dependencies = [ [[package]] name = "snarkvm-ledger-coinbase" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "aleo-std", "anyhow", @@ -4079,8 +4079,8 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "anyhow", "indexmap 2.2.2", @@ -4097,8 +4097,8 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -4110,8 +4110,8 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4123,8 +4123,8 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "indexmap 2.2.2", "serde_json", @@ -4135,8 +4135,8 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "bytes", "serde_json", @@ -4146,8 +4146,8 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4161,8 +4161,8 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "bytes", "serde_json", @@ -4174,8 +4174,8 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "snarkvm-console", "snarkvm-ledger-coinbase", @@ -4183,8 +4183,8 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "async-trait", "reqwest", @@ -4196,8 +4196,8 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "aleo-std-storage", "anyhow", @@ -4221,8 +4221,8 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4236,8 +4236,8 @@ dependencies = [ [[package]] name = "snarkvm-metrics" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4245,8 +4245,8 @@ dependencies = [ [[package]] name = "snarkvm-parameters" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "aleo-std", "anyhow", @@ -4270,8 +4270,8 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "aleo-std", "anyhow", @@ -4294,8 +4294,8 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "aleo-std", "colored", @@ -4317,8 +4317,8 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "indexmap 2.2.2", "paste", @@ -4331,8 +4331,8 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "bincode", "once_cell", @@ -4344,8 +4344,8 @@ dependencies = [ [[package]] name = "snarkvm-utilities" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "aleo-std", "anyhow", @@ -4365,8 +4365,8 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" -version = "0.16.17" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=bef915a#bef915a9e72583f1b57b265b7382b18abb73a4d8" +version = "0.16.18" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" dependencies = [ "proc-macro2", "quote 1.0.35", diff --git a/Cargo.toml b/Cargo.toml index a517316a0f..c698e61fe8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "bef915a" # feat/committee-round-lag +rev = "2d062ce" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] diff --git a/node/bft/ledger-service/src/ledger.rs b/node/bft/ledger-service/src/ledger.rs index 9955a485a8..fa9a0a2a9a 100644 --- a/node/bft/ledger-service/src/ledger.rs +++ b/node/bft/ledger-service/src/ledger.rs @@ -154,7 +154,7 @@ impl> LedgerService for CoreLedgerService< }; // Get the previous round with lag. - let previous_round_with_lag = previous_round.saturating_sub(N::COMMITTEE_ROUND_LAG); + let previous_round_with_lag = previous_round.saturating_sub(Committee::::COMMITTEE_LOOKBACK_RANGE); // Retrieve the committee for the previous round with lag. self.get_committee_for_round(previous_round_with_lag) From 92e5bb5c60811ba826114be92a63565f793e3a39 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Fri, 9 Feb 2024 17:44:36 -0800 Subject: [PATCH 024/551] nit: first pass of using committee lookback --- node/bft/ledger-service/src/ledger.rs | 10 +++---- node/bft/ledger-service/src/mock.rs | 4 +-- node/bft/ledger-service/src/prover.rs | 6 ++-- node/bft/ledger-service/src/traits.rs | 6 ++-- node/bft/ledger-service/src/translucent.rs | 4 +-- node/bft/src/bft.rs | 23 ++++++-------- node/bft/src/gateway.rs | 4 +-- node/bft/src/helpers/storage.rs | 11 ++++--- node/bft/src/primary.rs | 35 +++++++++------------- node/bft/src/worker.rs | 2 +- 10 files changed, 46 insertions(+), 59 deletions(-) diff --git a/node/bft/ledger-service/src/ledger.rs b/node/bft/ledger-service/src/ledger.rs index fa9a0a2a9a..b95edca854 100644 --- a/node/bft/ledger-service/src/ledger.rs +++ b/node/bft/ledger-service/src/ledger.rs @@ -143,9 +143,9 @@ impl> LedgerService for CoreLedgerService< } } - /// Returns the previous committee with lag for the given round. - /// If the previous round with lag is in the future, then the current committee is returned. - fn get_previous_committee_with_lag_for_round(&self, round: u64) -> Result> { + /// Returns the committee lookback for the given round. + /// If the committee lookback round is in the future, then the current committee is returned. + fn get_committee_lookback_for_round(&self, round: u64) -> Result> { // Get the round number for the previous committee. Note, we subtract 2 from odd rounds, // because committees are updated in even rounds. let previous_round = match round % 2 == 0 { @@ -153,10 +153,10 @@ impl> LedgerService for CoreLedgerService< false => round.saturating_sub(2), }; - // Get the previous round with lag. + // Get the committee lookback round. let previous_round_with_lag = previous_round.saturating_sub(Committee::::COMMITTEE_LOOKBACK_RANGE); - // Retrieve the committee for the previous round with lag. + // Retrieve the committee for the committee lookback round. self.get_committee_for_round(previous_round_with_lag) } diff --git a/node/bft/ledger-service/src/mock.rs b/node/bft/ledger-service/src/mock.rs index 21d49ff55a..c36679a40e 100644 --- a/node/bft/ledger-service/src/mock.rs +++ b/node/bft/ledger-service/src/mock.rs @@ -126,8 +126,8 @@ impl LedgerService for MockLedgerService { Ok(self.committee.clone()) } - /// Returns the previous committee with lag for the given round. - fn get_previous_committee_with_lag_for_round(&self, _round: u64) -> Result> { + /// Returns the committee lookback for the given round. + fn get_committee_lookback_for_round(&self, _round: u64) -> Result> { Ok(self.committee.clone()) } diff --git a/node/bft/ledger-service/src/prover.rs b/node/bft/ledger-service/src/prover.rs index 57c0074fbf..6edfbafd4c 100644 --- a/node/bft/ledger-service/src/prover.rs +++ b/node/bft/ledger-service/src/prover.rs @@ -108,9 +108,9 @@ impl LedgerService for ProverLedgerService { bail!("Committee for round {round} does not exist in prover") } - /// Returns the previous committee with lag for the given round. - /// If the previous round with lag is in the future, then the current committee is returned. - fn get_previous_committee_with_lag_for_round(&self, round: u64) -> Result> { + /// Returns the committee lookback for the given round. + /// If the committee lookback round is in the future, then the current committee is returned. + fn get_committee_lookback_for_round(&self, round: u64) -> Result> { bail!("Previous committee for round {round} does not exist in prover") } diff --git a/node/bft/ledger-service/src/traits.rs b/node/bft/ledger-service/src/traits.rs index 2d41570152..a97fdeb373 100644 --- a/node/bft/ledger-service/src/traits.rs +++ b/node/bft/ledger-service/src/traits.rs @@ -68,9 +68,9 @@ pub trait LedgerService: Debug + Send + Sync { /// If the given round is in the future, then the current committee is returned. fn get_committee_for_round(&self, round: u64) -> Result>; - /// Returns the previous committee with lag for the given round. - /// If the previous round with lag is in the future, then the current committee is returned. - fn get_previous_committee_with_lag_for_round(&self, round: u64) -> Result>; + /// Returns the committee lookback for the given round. + /// If the committee lookback round is in the future, then the current committee is returned. + fn get_committee_lookback_for_round(&self, round: u64) -> Result>; /// Returns `true` if the ledger contains the given certificate ID. fn contains_certificate(&self, certificate_id: &Field) -> Result; diff --git a/node/bft/ledger-service/src/translucent.rs b/node/bft/ledger-service/src/translucent.rs index 83b3793b02..e53cb5a573 100644 --- a/node/bft/ledger-service/src/translucent.rs +++ b/node/bft/ledger-service/src/translucent.rs @@ -119,8 +119,8 @@ impl> LedgerService for TranslucentLedgerS self.inner.get_committee_for_round(round) } - fn get_previous_committee_with_lag_for_round(&self, round: u64) -> Result> { - self.inner.get_previous_committee_with_lag_for_round(round) + fn get_committee_lookback_for_round(&self, round: u64) -> Result> { + self.inner.get_committee_lookback_for_round(round) } /// Returns `true` if the ledger contains the given certificate ID in block history. diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index e216e7e0c8..7378495087 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -291,13 +291,11 @@ impl BFT { return false; } - // Retrieve the previous committee with lag of the current round. - let previous_committee_with_lag = match self.ledger().get_previous_committee_with_lag_for_round(current_round) { + // Retrieve the committee lookback of the current round. + let previous_committee_with_lag = match self.ledger().get_committee_lookback_for_round(current_round) { Ok(committee) => committee, Err(e) => { - error!( - "BFT failed to retrieve the previous committee with lag for the even round {current_round} - {e}" - ); + error!("BFT failed to retrieve the committee lookback for the even round {current_round} - {e}"); return false; } }; @@ -377,13 +375,11 @@ impl BFT { let leader_certificate_id = leader_certificate.id(); // Retrieve the certificates for the current round. let current_certificates = self.storage().get_certificates_for_round(current_round); - // Retrieve the previous committee with lag for the current round. - let previous_committee_with_lag = match self.ledger().get_previous_committee_with_lag_for_round(current_round) { + // Retrieve the committee lookback for the current round. + let previous_committee_with_lag = match self.ledger().get_committee_lookback_for_round(current_round) { Ok(committee) => committee, Err(e) => { - error!( - "BFT failed to retrieve the previous committee with lag for the odd round {current_round} - {e}" - ); + error!("BFT failed to retrieve the committee lookback for the odd round {current_round} - {e}"); return false; } }; @@ -455,9 +451,8 @@ impl BFT { return Ok(()); } - // Retrieve the previous committee with lag for the commit round. - let Ok(previous_committee_with_lag) = self.ledger().get_previous_committee_with_lag_for_round(commit_round) - else { + // Retrieve the committee lookback for the commit round. + let Ok(previous_committee_with_lag) = self.ledger().get_committee_lookback_for_round(commit_round) else { bail!("BFT failed to retrieve the committee with lag for commit round {commit_round}"); }; // Compute the leader for the commit round. @@ -516,7 +511,7 @@ impl BFT { for round in (self.dag.read().last_committed_round() + 2..=leader_round.saturating_sub(2)).rev().step_by(2) { // Retrieve the previous committee for the leader round. - let previous_committee = match self.ledger().get_previous_committee_with_lag_for_round(round) { + let previous_committee = match self.ledger().get_committee_lookback_for_round(round) { Ok(committee) => committee, Err(e) => { bail!("BFT failed to retrieve the previous committee for the even round {round} - {e}"); diff --git a/node/bft/src/gateway.rs b/node/bft/src/gateway.rs index 4a4a8ecbf2..11f2dd3ebe 100644 --- a/node/bft/src/gateway.rs +++ b/node/bft/src/gateway.rs @@ -327,13 +327,13 @@ impl Gateway { /// Returns `true` if the given address is an authorized validator. pub fn is_authorized_validator_address(&self, validator_address: Address) -> bool { - // Determine if the validator address is a member of the previous committee with lag or the current committee. + // Determine if the validator address is a member of the committee lookback or the current committee. // We allow leniency in this validation check in order to accommodate these two scenarios: // 1. New validators should be able to connect immediately once bonded as a committee member. // 2. Existing validators must remain connected until they are no longer bonded as a committee member. // (i.e. meaning they must stay online until the next block has been produced) self.ledger - .get_previous_committee_with_lag_for_round(self.ledger.latest_round()) + .get_committee_lookback_for_round(self.ledger.latest_round()) .map_or(false, |committee| committee.is_committee_member(validator_address)) || self .ledger diff --git a/node/bft/src/helpers/storage.rs b/node/bft/src/helpers/storage.rs index 5578c1aa7e..30ceb78e90 100644 --- a/node/bft/src/helpers/storage.rs +++ b/node/bft/src/helpers/storage.rs @@ -340,8 +340,8 @@ impl Storage { bail!("Batch for round {round} already exists in storage {gc_log}") } - // Retrieve the previous committee with lag for the batch round. - let Ok(previous_committee_with_lag) = self.ledger.get_previous_committee_with_lag_for_round(round) else { + // Retrieve the committee lookback for the batch round. + let Ok(previous_committee_with_lag) = self.ledger.get_committee_lookback_for_round(round) else { bail!("Storage failed to retrieve the committee with lag for round {round} {gc_log}") }; // Ensure the author is in the committee. @@ -363,8 +363,7 @@ impl Storage { // Check if the previous round is within range of the GC round. if previous_round > gc_round { // Retrieve the committee with lag for the previous round. - let Ok(previous_committee_with_lag) = self.ledger.get_previous_committee_with_lag_for_round(previous_round) - else { + let Ok(previous_committee_with_lag) = self.ledger.get_committee_lookback_for_round(previous_round) else { bail!("Missing committee for the previous round {previous_round} in storage {gc_log}") }; // Ensure the previous round certificates exists in storage. @@ -448,8 +447,8 @@ impl Storage { // Check the timestamp for liveness. check_timestamp_for_liveness(certificate.timestamp())?; - // Retrieve the previous committee with lag for the batch round. - let Ok(previous_committee_with_lag) = self.ledger.get_previous_committee_with_lag_for_round(round) else { + // Retrieve the committee lookback for the batch round. + let Ok(previous_committee_with_lag) = self.ledger.get_committee_lookback_for_round(round) else { bail!("Storage failed to retrieve the committee for round {round} {gc_log}") }; diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index dea6fc44cf..d8d155cde2 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -285,9 +285,7 @@ impl Primary { // TODO(ljedrz): the BatchHeader should be serialized only once in advance before being sent to non-signers. let event = Event::BatchPropose(proposal.batch_header().clone().into()); // Iterate through the non-signers. - for address in - proposal.nonsigners(&self.ledger.get_previous_committee_with_lag_for_round(proposal.round())?) - { + for address in proposal.nonsigners(&self.ledger.get_committee_lookback_for_round(proposal.round())?) { // Resolve the address to the peer IP. match self.gateway.resolver().get_peer_ip_for_address(address) { // Resend the batch proposal to the validator for signing. @@ -336,7 +334,7 @@ impl Primary { // Check if the primary is connected to enough validators to reach quorum threshold. { // Retrieve the committee to check against. - let committee_with_lag = self.ledger.get_previous_committee_with_lag_for_round(round)?; + let committee_with_lag = self.ledger.get_committee_lookback_for_round(round)?; // Retrieve the connected validator addresses. let mut connected_validators = self.gateway.connected_addresses(); // Append the primary to the set. @@ -362,10 +360,9 @@ impl Primary { let mut is_ready = previous_round == 0; // If the previous round is not 0, check if the previous certificates have reached the quorum threshold. if previous_round > 0 { - // Retrieve the previous committee with lag for the round. - let Ok(previous_committee_with_lag) = self.ledger.get_previous_committee_with_lag_for_round(previous_round) - else { - bail!("Cannot propose a batch for round {round}: the previous committee with lag is not known yet") + // Retrieve the committee lookback for the round. + let Ok(previous_committee_with_lag) = self.ledger.get_committee_lookback_for_round(previous_round) else { + bail!("Cannot propose a batch for round {round}: the committee lookback is not known yet") }; // Construct a set over the authors. let authors = previous_certificates.iter().map(BatchCertificate::author).collect(); @@ -469,11 +466,8 @@ impl Primary { &mut rand::thread_rng() ))?; // Construct the proposal. - let proposal = Proposal::new( - self.ledger.get_previous_committee_with_lag_for_round(round)?, - batch_header.clone(), - transmissions, - )?; + let proposal = + Proposal::new(self.ledger.get_committee_lookback_for_round(round)?, batch_header.clone(), transmissions)?; // Broadcast the batch to all validators for signing. self.gateway.broadcast(Event::BatchPropose(batch_header.into())); // Set the proposed batch. @@ -662,9 +656,8 @@ impl Primary { ), } } - // Retrieve the previous committee with lag for the round. - let previous_committee_with_lag = - self.ledger.get_previous_committee_with_lag_for_round(proposal.round())?; + // Retrieve the committee lookback for the round. + let previous_committee_with_lag = self.ledger.get_committee_lookback_for_round(proposal.round())?; // Retrieve the address of the validator. let Some(signer) = self.gateway.resolver().get_address(peer_ip) else { bail!("Signature is from a disconnected validator"); @@ -692,8 +685,8 @@ impl Primary { info!("Quorum threshold reached - Preparing to certify our batch for round {}...", proposal.round()); - // Retrieve the previous committee with lag for the round. - let previous_committee_with_lag = self.ledger.get_previous_committee_with_lag_for_round(proposal.round())?; + // Retrieve the committee lookback for the round. + let previous_committee_with_lag = self.ledger.get_committee_lookback_for_round(proposal.round())?; // Store the certified batch and broadcast it to all validators. // If there was an error storing the certificate, reinsert the transmissions back into the ready queue. if let Err(e) = self.store_and_broadcast_certificate(&proposal, &previous_committee_with_lag).await { @@ -742,8 +735,8 @@ impl Primary { // Retrieve the current round. let current_round = self.current_round(); - // Retrieve the previous committee with lag. - let previous_committee_with_lag = self.ledger.get_previous_committee_with_lag_for_round(current_round)?; + // Retrieve the committee lookback. + let previous_committee_with_lag = self.ledger.get_committee_lookback_for_round(current_round)?; // Retrieve the certificates. let certificates = self.storage.get_certificates_for_round(current_round); // Construct a set over the authors. @@ -1301,7 +1294,7 @@ impl Primary { let is_quorum_threshold_reached = { let certificates = self.storage.get_certificates_for_round(batch_round); let authors = certificates.iter().map(BatchCertificate::author).collect(); - let previous_committee_with_lag = self.ledger.get_previous_committee_with_lag_for_round(batch_round)?; + let previous_committee_with_lag = self.ledger.get_committee_lookback_for_round(batch_round)?; previous_committee_with_lag.is_quorum_threshold_reached(&authors) }; diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index eb63774342..f9af2f68a5 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -492,7 +492,7 @@ mod tests { fn get_batch_certificate(&self, certificate_id: &Field) -> Result>; fn current_committee(&self) -> Result>; fn get_committee_for_round(&self, round: u64) -> Result>; - fn get_previous_committee_with_lag_for_round(&self, round: u64) -> Result>; + fn get_committee_lookback_for_round(&self, round: u64) -> Result>; fn contains_certificate(&self, certificate_id: &Field) -> Result; fn contains_transmission(&self, transmission_id: &TransmissionID) -> Result; fn ensure_transmission_id_matches( From 26ae0a98f0b94adca2dfd1c863e730343a1fbe5b Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Fri, 9 Feb 2024 17:59:51 -0800 Subject: [PATCH 025/551] nit: second pass of using committee lookback --- node/bft/ledger-service/src/ledger.rs | 4 +-- node/bft/ledger-service/src/translucent.rs | 1 + node/bft/src/bft.rs | 31 ++++++++++------------ node/bft/src/helpers/storage.rs | 20 +++++++------- node/bft/src/primary.rs | 26 +++++++++--------- 5 files changed, 40 insertions(+), 42 deletions(-) diff --git a/node/bft/ledger-service/src/ledger.rs b/node/bft/ledger-service/src/ledger.rs index b95edca854..1f42f909b0 100644 --- a/node/bft/ledger-service/src/ledger.rs +++ b/node/bft/ledger-service/src/ledger.rs @@ -154,10 +154,10 @@ impl> LedgerService for CoreLedgerService< }; // Get the committee lookback round. - let previous_round_with_lag = previous_round.saturating_sub(Committee::::COMMITTEE_LOOKBACK_RANGE); + let committee_lookback_round = previous_round.saturating_sub(Committee::::COMMITTEE_LOOKBACK_RANGE); // Retrieve the committee for the committee lookback round. - self.get_committee_for_round(previous_round_with_lag) + self.get_committee_for_round(committee_lookback_round) } /// Returns `true` if the ledger contains the given certificate ID in block history. diff --git a/node/bft/ledger-service/src/translucent.rs b/node/bft/ledger-service/src/translucent.rs index e53cb5a573..34afa15667 100644 --- a/node/bft/ledger-service/src/translucent.rs +++ b/node/bft/ledger-service/src/translucent.rs @@ -119,6 +119,7 @@ impl> LedgerService for TranslucentLedgerS self.inner.get_committee_for_round(round) } + /// Returns the committee lookback for the given round. fn get_committee_lookback_for_round(&self, round: u64) -> Result> { self.inner.get_committee_lookback_for_round(round) } diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 7378495087..163e2c5bc7 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -292,7 +292,7 @@ impl BFT { } // Retrieve the committee lookback of the current round. - let previous_committee_with_lag = match self.ledger().get_committee_lookback_for_round(current_round) { + let committee_lookback = match self.ledger().get_committee_lookback_for_round(current_round) { Ok(committee) => committee, Err(e) => { error!("BFT failed to retrieve the committee lookback for the even round {current_round} - {e}"); @@ -300,7 +300,7 @@ impl BFT { } }; // Determine the leader of the current round. - let leader = match previous_committee_with_lag.get_leader(current_round) { + let leader = match committee_lookback.get_leader(current_round) { Ok(leader) => leader, Err(e) => { error!("BFT failed to compute the leader for the even round {current_round} - {e}"); @@ -311,7 +311,7 @@ impl BFT { let leader_certificate = current_certificates.iter().find(|certificate| certificate.author() == leader); *self.leader_certificate.write() = leader_certificate.cloned(); - self.is_even_round_ready_for_next_round(current_certificates, previous_committee_with_lag, current_round) + self.is_even_round_ready_for_next_round(current_certificates, committee_lookback, current_round) } /// Returns 'true' under one of the following conditions: @@ -376,7 +376,7 @@ impl BFT { // Retrieve the certificates for the current round. let current_certificates = self.storage().get_certificates_for_round(current_round); // Retrieve the committee lookback for the current round. - let previous_committee_with_lag = match self.ledger().get_committee_lookback_for_round(current_round) { + let committee_lookback = match self.ledger().get_committee_lookback_for_round(current_round) { Ok(committee) => committee, Err(e) => { error!("BFT failed to retrieve the committee lookback for the odd round {current_round} - {e}"); @@ -385,14 +385,11 @@ impl BFT { }; // Compute the stake for the leader certificate. - let (stake_with_leader, stake_without_leader) = self.compute_stake_for_leader_certificate( - leader_certificate_id, - current_certificates, - &previous_committee_with_lag, - ); + let (stake_with_leader, stake_without_leader) = + self.compute_stake_for_leader_certificate(leader_certificate_id, current_certificates, &committee_lookback); // Return 'true' if any of the following conditions hold: - stake_with_leader >= previous_committee_with_lag.availability_threshold() - || stake_without_leader >= previous_committee_with_lag.quorum_threshold() + stake_with_leader >= committee_lookback.availability_threshold() + || stake_without_leader >= committee_lookback.quorum_threshold() || self.is_timer_expired() } @@ -452,11 +449,11 @@ impl BFT { } // Retrieve the committee lookback for the commit round. - let Ok(previous_committee_with_lag) = self.ledger().get_committee_lookback_for_round(commit_round) else { + let Ok(committee_lookback) = self.ledger().get_committee_lookback_for_round(commit_round) else { bail!("BFT failed to retrieve the committee with lag for commit round {commit_round}"); }; // Compute the leader for the commit round. - let Ok(leader) = previous_committee_with_lag.get_leader(commit_round) else { + let Ok(leader) = committee_lookback.get_leader(commit_round) else { bail!("BFT failed to compute the leader for commit round {commit_round}"); }; // Retrieve the leader certificate for the commit round. @@ -479,7 +476,7 @@ impl BFT { }) .collect(); // Check if the leader is ready to be committed. - if !previous_committee_with_lag.is_availability_threshold_reached(&authors) { + if !committee_lookback.is_availability_threshold_reached(&authors) { // If the leader is not ready to be committed, return early. trace!("BFT is not ready to commit {commit_round}"); return Ok(()); @@ -511,14 +508,14 @@ impl BFT { for round in (self.dag.read().last_committed_round() + 2..=leader_round.saturating_sub(2)).rev().step_by(2) { // Retrieve the previous committee for the leader round. - let previous_committee = match self.ledger().get_committee_lookback_for_round(round) { + let previous_committee_lookback = match self.ledger().get_committee_lookback_for_round(round) { Ok(committee) => committee, Err(e) => { - bail!("BFT failed to retrieve the previous committee for the even round {round} - {e}"); + bail!("BFT failed to retrieve a previous committee lookback for the even round {round} - {e}"); } }; // Compute the leader address for the leader round. - let leader = match previous_committee.get_leader(round) { + let leader = match previous_committee_lookback.get_leader(round) { Ok(leader) => leader, Err(e) => { bail!("BFT failed to compute the leader for the even round {round} - {e}"); diff --git a/node/bft/src/helpers/storage.rs b/node/bft/src/helpers/storage.rs index 30ceb78e90..bd5febb574 100644 --- a/node/bft/src/helpers/storage.rs +++ b/node/bft/src/helpers/storage.rs @@ -341,11 +341,11 @@ impl Storage { } // Retrieve the committee lookback for the batch round. - let Ok(previous_committee_with_lag) = self.ledger.get_committee_lookback_for_round(round) else { - bail!("Storage failed to retrieve the committee with lag for round {round} {gc_log}") + let Ok(committee_lookback) = self.ledger.get_committee_lookback_for_round(round) else { + bail!("Storage failed to retrieve the committee lookback for round {round} {gc_log}") }; // Ensure the author is in the committee. - if !previous_committee_with_lag.is_committee_member(batch_header.author()) { + if !committee_lookback.is_committee_member(batch_header.author()) { bail!("Author {} is not in the committee for round {round} {gc_log}", batch_header.author()) } @@ -362,8 +362,8 @@ impl Storage { let previous_round = round.saturating_sub(1); // Check if the previous round is within range of the GC round. if previous_round > gc_round { - // Retrieve the committee with lag for the previous round. - let Ok(previous_committee_with_lag) = self.ledger.get_committee_lookback_for_round(previous_round) else { + // Retrieve the committee lookback for the previous round. + let Ok(previous_committee_lookback) = self.ledger.get_committee_lookback_for_round(previous_round) else { bail!("Missing committee for the previous round {previous_round} in storage {gc_log}") }; // Ensure the previous round certificates exists in storage. @@ -371,7 +371,7 @@ impl Storage { bail!("Missing certificates for the previous round {previous_round} in storage {gc_log}") } // Ensure the number of previous certificate IDs is at or below the number of committee members. - if batch_header.previous_certificate_ids().len() > previous_committee_with_lag.num_members() { + if batch_header.previous_certificate_ids().len() > previous_committee_lookback.num_members() { bail!("Too many previous certificates for round {round} {gc_log}") } // Initialize a set of the previous authors. @@ -397,7 +397,7 @@ impl Storage { previous_authors.insert(previous_certificate.author()); } // Ensure the previous certificates have reached the quorum threshold. - if !previous_committee_with_lag.is_quorum_threshold_reached(&previous_authors) { + if !previous_committee_lookback.is_quorum_threshold_reached(&previous_authors) { bail!("Previous certificates for a batch in round {round} did not reach quorum threshold {gc_log}") } } @@ -448,7 +448,7 @@ impl Storage { check_timestamp_for_liveness(certificate.timestamp())?; // Retrieve the committee lookback for the batch round. - let Ok(previous_committee_with_lag) = self.ledger.get_committee_lookback_for_round(round) else { + let Ok(previous_committee_lookback) = self.ledger.get_committee_lookback_for_round(round) else { bail!("Storage failed to retrieve the committee for round {round} {gc_log}") }; @@ -462,7 +462,7 @@ impl Storage { // Retrieve the signer. let signer = signature.to_address(); // Ensure the signer is in the committee. - if !previous_committee_with_lag.is_committee_member(signer) { + if !previous_committee_lookback.is_committee_member(signer) { bail!("Signer {signer} is not in the committee for round {round} {gc_log}") } // Append the signer. @@ -470,7 +470,7 @@ impl Storage { } // Ensure the signatures have reached the quorum threshold. - if !previous_committee_with_lag.is_quorum_threshold_reached(&signers) { + if !previous_committee_lookback.is_quorum_threshold_reached(&signers) { bail!("Signatures for a batch in round {round} did not reach quorum threshold {gc_log}") } Ok(missing_transmissions) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index d8d155cde2..aa876a2254 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -334,13 +334,13 @@ impl Primary { // Check if the primary is connected to enough validators to reach quorum threshold. { // Retrieve the committee to check against. - let committee_with_lag = self.ledger.get_committee_lookback_for_round(round)?; + let committee_lookback = self.ledger.get_committee_lookback_for_round(round)?; // Retrieve the connected validator addresses. let mut connected_validators = self.gateway.connected_addresses(); // Append the primary to the set. connected_validators.insert(self.gateway.account().address()); // If quorum threshold is not reached, return early. - if !committee_with_lag.is_quorum_threshold_reached(&connected_validators) { + if !committee_lookback.is_quorum_threshold_reached(&connected_validators) { debug!( "Primary is safely skipping a batch proposal {}", "(please connect to more validators)".dimmed() @@ -361,13 +361,13 @@ impl Primary { // If the previous round is not 0, check if the previous certificates have reached the quorum threshold. if previous_round > 0 { // Retrieve the committee lookback for the round. - let Ok(previous_committee_with_lag) = self.ledger.get_committee_lookback_for_round(previous_round) else { + let Ok(previous_committee_lookback) = self.ledger.get_committee_lookback_for_round(previous_round) else { bail!("Cannot propose a batch for round {round}: the committee lookback is not known yet") }; // Construct a set over the authors. let authors = previous_certificates.iter().map(BatchCertificate::author).collect(); // Check if the previous certificates have reached the quorum threshold. - if previous_committee_with_lag.is_quorum_threshold_reached(&authors) { + if previous_committee_lookback.is_quorum_threshold_reached(&authors) { is_ready = true; } } @@ -657,16 +657,16 @@ impl Primary { } } // Retrieve the committee lookback for the round. - let previous_committee_with_lag = self.ledger.get_committee_lookback_for_round(proposal.round())?; + let previous_committee_lookback = self.ledger.get_committee_lookback_for_round(proposal.round())?; // Retrieve the address of the validator. let Some(signer) = self.gateway.resolver().get_address(peer_ip) else { bail!("Signature is from a disconnected validator"); }; // Add the signature to the batch. - proposal.add_signature(signer, signature, &previous_committee_with_lag)?; + proposal.add_signature(signer, signature, &previous_committee_lookback)?; info!("Received a batch signature for round {} from '{peer_ip}'", proposal.round()); // Check if the batch is ready to be certified. - if !proposal.is_quorum_threshold_reached(&previous_committee_with_lag) { + if !proposal.is_quorum_threshold_reached(&previous_committee_lookback) { // If the batch is not ready to be certified, return early. return Ok(()); } @@ -686,10 +686,10 @@ impl Primary { info!("Quorum threshold reached - Preparing to certify our batch for round {}...", proposal.round()); // Retrieve the committee lookback for the round. - let previous_committee_with_lag = self.ledger.get_committee_lookback_for_round(proposal.round())?; + let previous_committee_lookback = self.ledger.get_committee_lookback_for_round(proposal.round())?; // Store the certified batch and broadcast it to all validators. // If there was an error storing the certificate, reinsert the transmissions back into the ready queue. - if let Err(e) = self.store_and_broadcast_certificate(&proposal, &previous_committee_with_lag).await { + if let Err(e) = self.store_and_broadcast_certificate(&proposal, &previous_committee_lookback).await { // Reinsert the transmissions back into the ready queue for the next proposal. self.reinsert_transmissions_into_workers(proposal)?; return Err(e); @@ -736,13 +736,13 @@ impl Primary { // Retrieve the current round. let current_round = self.current_round(); // Retrieve the committee lookback. - let previous_committee_with_lag = self.ledger.get_committee_lookback_for_round(current_round)?; + let previous_committee_lookback = self.ledger.get_committee_lookback_for_round(current_round)?; // Retrieve the certificates. let certificates = self.storage.get_certificates_for_round(current_round); // Construct a set over the authors. let authors = certificates.iter().map(BatchCertificate::author).collect(); // Check if the certificates have reached the quorum threshold. - let is_quorum = previous_committee_with_lag.is_quorum_threshold_reached(&authors); + let is_quorum = previous_committee_lookback.is_quorum_threshold_reached(&authors); // Determine if we are currently proposing a round. // Note: This is important, because while our peers have advanced, @@ -1294,8 +1294,8 @@ impl Primary { let is_quorum_threshold_reached = { let certificates = self.storage.get_certificates_for_round(batch_round); let authors = certificates.iter().map(BatchCertificate::author).collect(); - let previous_committee_with_lag = self.ledger.get_committee_lookback_for_round(batch_round)?; - previous_committee_with_lag.is_quorum_threshold_reached(&authors) + let previous_committee_lookback = self.ledger.get_committee_lookback_for_round(batch_round)?; + previous_committee_lookback.is_quorum_threshold_reached(&authors) }; // Check if our primary should move to the next round. From afa2597e186494a22086f9918ca75de672650f60 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Fri, 9 Feb 2024 18:04:28 -0800 Subject: [PATCH 026/551] nit: third pass of using committee lookback --- node/bft/src/helpers/storage.rs | 6 +++--- node/bft/src/primary.rs | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/node/bft/src/helpers/storage.rs b/node/bft/src/helpers/storage.rs index bd5febb574..4f10c4438a 100644 --- a/node/bft/src/helpers/storage.rs +++ b/node/bft/src/helpers/storage.rs @@ -448,7 +448,7 @@ impl Storage { check_timestamp_for_liveness(certificate.timestamp())?; // Retrieve the committee lookback for the batch round. - let Ok(previous_committee_lookback) = self.ledger.get_committee_lookback_for_round(round) else { + let Ok(committee_lookback) = self.ledger.get_committee_lookback_for_round(round) else { bail!("Storage failed to retrieve the committee for round {round} {gc_log}") }; @@ -462,7 +462,7 @@ impl Storage { // Retrieve the signer. let signer = signature.to_address(); // Ensure the signer is in the committee. - if !previous_committee_lookback.is_committee_member(signer) { + if !committee_lookback.is_committee_member(signer) { bail!("Signer {signer} is not in the committee for round {round} {gc_log}") } // Append the signer. @@ -470,7 +470,7 @@ impl Storage { } // Ensure the signatures have reached the quorum threshold. - if !previous_committee_lookback.is_quorum_threshold_reached(&signers) { + if !committee_lookback.is_quorum_threshold_reached(&signers) { bail!("Signatures for a batch in round {round} did not reach quorum threshold {gc_log}") } Ok(missing_transmissions) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index aa876a2254..b926f893a8 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -657,16 +657,16 @@ impl Primary { } } // Retrieve the committee lookback for the round. - let previous_committee_lookback = self.ledger.get_committee_lookback_for_round(proposal.round())?; + let committee_lookback = self.ledger.get_committee_lookback_for_round(proposal.round())?; // Retrieve the address of the validator. let Some(signer) = self.gateway.resolver().get_address(peer_ip) else { bail!("Signature is from a disconnected validator"); }; // Add the signature to the batch. - proposal.add_signature(signer, signature, &previous_committee_lookback)?; + proposal.add_signature(signer, signature, &committee_lookback)?; info!("Received a batch signature for round {} from '{peer_ip}'", proposal.round()); // Check if the batch is ready to be certified. - if !proposal.is_quorum_threshold_reached(&previous_committee_lookback) { + if !proposal.is_quorum_threshold_reached(&committee_lookback) { // If the batch is not ready to be certified, return early. return Ok(()); } @@ -686,10 +686,10 @@ impl Primary { info!("Quorum threshold reached - Preparing to certify our batch for round {}...", proposal.round()); // Retrieve the committee lookback for the round. - let previous_committee_lookback = self.ledger.get_committee_lookback_for_round(proposal.round())?; + let committee_lookback = self.ledger.get_committee_lookback_for_round(proposal.round())?; // Store the certified batch and broadcast it to all validators. // If there was an error storing the certificate, reinsert the transmissions back into the ready queue. - if let Err(e) = self.store_and_broadcast_certificate(&proposal, &previous_committee_lookback).await { + if let Err(e) = self.store_and_broadcast_certificate(&proposal, &committee_lookback).await { // Reinsert the transmissions back into the ready queue for the next proposal. self.reinsert_transmissions_into_workers(proposal)?; return Err(e); @@ -736,13 +736,13 @@ impl Primary { // Retrieve the current round. let current_round = self.current_round(); // Retrieve the committee lookback. - let previous_committee_lookback = self.ledger.get_committee_lookback_for_round(current_round)?; + let committee_lookback = self.ledger.get_committee_lookback_for_round(current_round)?; // Retrieve the certificates. let certificates = self.storage.get_certificates_for_round(current_round); // Construct a set over the authors. let authors = certificates.iter().map(BatchCertificate::author).collect(); // Check if the certificates have reached the quorum threshold. - let is_quorum = previous_committee_lookback.is_quorum_threshold_reached(&authors); + let is_quorum = committee_lookback.is_quorum_threshold_reached(&authors); // Determine if we are currently proposing a round. // Note: This is important, because while our peers have advanced, @@ -1294,8 +1294,8 @@ impl Primary { let is_quorum_threshold_reached = { let certificates = self.storage.get_certificates_for_round(batch_round); let authors = certificates.iter().map(BatchCertificate::author).collect(); - let previous_committee_lookback = self.ledger.get_committee_lookback_for_round(batch_round)?; - previous_committee_lookback.is_quorum_threshold_reached(&authors) + let committee_lookback = self.ledger.get_committee_lookback_for_round(batch_round)?; + committee_lookback.is_quorum_threshold_reached(&authors) }; // Check if our primary should move to the next round. From ce873652d41cc911ee453a7022e46a881c084689 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Fri, 9 Feb 2024 19:38:40 -0800 Subject: [PATCH 027/551] Reverts election certificates --- Cargo.lock | 116 ++++++++++---------- Cargo.toml | 2 +- node/bft/events/src/certificate_response.rs | 11 +- node/bft/src/bft.rs | 57 ++-------- node/bft/src/helpers/channels.rs | 35 +----- node/bft/src/helpers/proposal.rs | 1 - node/bft/src/helpers/storage.rs | 1 - node/bft/src/primary.rs | 74 +------------ node/bft/src/sync/mod.rs | 4 +- 9 files changed, 78 insertions(+), 223 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d7925027db..45a462955a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3526,7 +3526,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "anstyle", "anyhow", @@ -3557,7 +3557,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "aleo-std", "anyhow", @@ -3587,7 +3587,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3601,7 +3601,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3612,7 +3612,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3622,7 +3622,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3632,7 +3632,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "indexmap 2.2.2", "itertools 0.11.0", @@ -3650,12 +3650,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" [[package]] name = "snarkvm-circuit-network" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3666,7 +3666,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3681,7 +3681,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3696,7 +3696,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3709,7 +3709,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3718,7 +3718,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3728,7 +3728,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3740,7 +3740,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3752,7 +3752,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3763,7 +3763,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3775,7 +3775,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3788,7 +3788,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "bs58", "snarkvm-console-network", @@ -3799,7 +3799,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "blake2s_simd", "smallvec", @@ -3812,7 +3812,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "aleo-std", "rayon", @@ -3823,7 +3823,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "anyhow", "indexmap 2.2.2", @@ -3846,7 +3846,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "anyhow", "bech32", @@ -3864,7 +3864,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "enum_index", "enum_index_derive", @@ -3885,7 +3885,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3900,7 +3900,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3911,7 +3911,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "snarkvm-console-network-environment", ] @@ -3919,7 +3919,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3929,7 +3929,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3940,7 +3940,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3951,7 +3951,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3962,7 +3962,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3973,7 +3973,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "rand", "rayon", @@ -3987,7 +3987,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "aleo-std", "anyhow", @@ -4004,7 +4004,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "aleo-std", "anyhow", @@ -4029,7 +4029,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "anyhow", "rand", @@ -4041,7 +4041,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4060,7 +4060,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-coinbase" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "aleo-std", "anyhow", @@ -4080,7 +4080,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "anyhow", "indexmap 2.2.2", @@ -4098,7 +4098,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -4111,7 +4111,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4124,7 +4124,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "indexmap 2.2.2", "serde_json", @@ -4136,7 +4136,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "bytes", "serde_json", @@ -4147,7 +4147,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4162,7 +4162,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "bytes", "serde_json", @@ -4175,7 +4175,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "snarkvm-console", "snarkvm-ledger-coinbase", @@ -4184,7 +4184,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "async-trait", "reqwest", @@ -4197,7 +4197,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "aleo-std-storage", "anyhow", @@ -4222,7 +4222,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4237,7 +4237,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4246,7 +4246,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "aleo-std", "anyhow", @@ -4271,7 +4271,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "aleo-std", "anyhow", @@ -4295,7 +4295,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "aleo-std", "colored", @@ -4318,7 +4318,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "indexmap 2.2.2", "paste", @@ -4332,7 +4332,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "bincode", "once_cell", @@ -4345,7 +4345,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "aleo-std", "anyhow", @@ -4366,7 +4366,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2d062ce#2d062ceba8c570fcfd784106c89320a8cdd229a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" dependencies = [ "proc-macro2", "quote 1.0.35", diff --git a/Cargo.toml b/Cargo.toml index c698e61fe8..4b98594481 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "2d062ce" +rev = "d1255de" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] diff --git a/node/bft/events/src/certificate_response.rs b/node/bft/events/src/certificate_response.rs index f0942dfc32..4b14e17ecf 100644 --- a/node/bft/events/src/certificate_response.rs +++ b/node/bft/events/src/certificate_response.rs @@ -90,16 +90,7 @@ pub mod prop_tests { let signer = selector.select(validators); let transmission_ids = transmissions.into_iter().map(|(id, _)| id).collect(); - BatchHeader::new( - &signer.private_key, - 0, - now(), - transmission_ids, - Default::default(), - Default::default(), - &mut rng, - ) - .unwrap() + BatchHeader::new(&signer.private_key, 0, now(), transmission_ids, Default::default(), &mut rng).unwrap() }) .boxed() } diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 163e2c5bc7..e333772881 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -67,8 +67,6 @@ pub struct BFT { leader_certificate: Arc>>>, /// The timer for the leader certificate to be received. leader_certificate_timer: Arc, - /// The last election certificate IDs. - last_election_certificate_ids: Arc>>>, /// The consensus sender. consensus_sender: Arc>>, /// The spawned handles. @@ -92,7 +90,6 @@ impl BFT { dag: Default::default(), leader_certificate: Default::default(), leader_certificate_timer: Default::default(), - last_election_certificate_ids: Default::default(), consensus_sender: Default::default(), handles: Default::default(), lock: Default::default(), @@ -145,11 +142,6 @@ impl BFT { pub const fn leader_certificate(&self) -> &Arc>>> { &self.leader_certificate } - - /// Returns the last election certificate IDs. - pub fn last_election_certificate_ids(&self) -> IndexSet> { - self.last_election_certificate_ids.read().clone() - } } impl BFT { @@ -485,17 +477,14 @@ impl BFT { /* Proceeding to commit the leader. */ info!("Proceeding to commit round {commit_round} with leader {leader}..."); - // Prepare the election certificate IDs. - let election_certificate_ids = certificates.values().map(|c| c.id()).collect::>(); // Commit the leader certificate, and all previous leader certificates since the last committed round. - self.commit_leader_certificate::(leader_certificate, election_certificate_ids).await + self.commit_leader_certificate::(leader_certificate).await } /// Commits the leader certificate, and all previous leader certificates since the last committed round. async fn commit_leader_certificate( &self, leader_certificate: BatchCertificate, - election_certificate_ids: IndexSet>, ) -> Result<()> { // Determine the list of all previous leader certificates since the last committed round. // The order of the leader certificates is from **newest** to **oldest**. @@ -579,7 +568,7 @@ impl BFT { // If the node is not syncing, trigger consensus, as this will build a new block for the ledger. if !IS_SYNCING { // Construct the subdag. - let subdag = Subdag::from(commit_subdag.clone(), election_certificate_ids.clone())?; + let subdag = Subdag::from(commit_subdag.clone())?; // Retrieve the anchor round. let anchor_round = subdag.anchor_round(); // Retrieve the number of transmissions. @@ -622,15 +611,6 @@ impl BFT { dag_write.commit(certificate, self.storage().max_gc_rounds()); } } - // Update the last election certificate IDs. - // TODO (howardwu): This is currently writing the *latest* election certificate IDs, - // however this needs to be dynamically retrieving the election certificate IDs for the - // leader round (technically the `leader_round+1` round to get the election round) - // that it is currently committing. - { - let mut last_election_certificate_ids = self.last_election_certificate_ids.write(); - *last_election_certificate_ids = election_certificate_ids.clone(); - } } Ok(()) } @@ -745,22 +725,12 @@ impl BFT { /// Starts the BFT handlers. fn start_handlers(&self, bft_receiver: BFTReceiver) { let BFTReceiver { - mut rx_last_election_certificate_ids, mut rx_primary_round, mut rx_primary_certificate, mut rx_sync_bft_dag_at_bootup, mut rx_sync_bft, } = bft_receiver; - // Process the request for the last election certificate IDs. - let self_ = self.clone(); - self.spawn(async move { - while let Some(callback) = rx_last_election_certificate_ids.recv().await { - // Retrieve the last election certificate IDs, and send them to the callback. - callback.send(self_.last_election_certificate_ids()).ok(); - } - }); - // Process the current round from the primary. let self_ = self.clone(); self.spawn(async move { @@ -809,11 +779,11 @@ impl BFT { /// Finally, it updates the DAG with the latest leader certificate. async fn sync_bft_dag_at_bootup( &self, - leader_certificates: Vec<(BatchCertificate, IndexSet>)>, + leader_certificates: Vec>, certificates: Vec>, ) { - // Split the leader certificates into past leader certificates, the latest leader certificate, and the election certificate IDs. - let (past_leader_certificates, leader_certificate, election_certificate_ids) = { + // Split the leader certificates into past leader certificates and the latest leader certificate. + let (past_leader_certificates, leader_certificate) = { // Compute the penultimate index. let index = leader_certificates.len().saturating_sub(1); // Split the leader certificates. @@ -821,9 +791,7 @@ impl BFT { debug_assert!(latest.len() == 1, "There should only be one latest leader certificate"); // Retrieve the latest leader certificate. match latest.first() { - Some((leader_certificate, election_certificate_ids)) => { - (past, leader_certificate.clone(), election_certificate_ids.clone()) - } + Some(leader_certificate) => (past, leader_certificate.clone()), // If there is no latest leader certificate, return early. None => return, } @@ -840,23 +808,14 @@ impl BFT { } } - // Acquire the last election certificate IDs. - let mut last_election_certificate_ids = self.last_election_certificate_ids.write(); // Iterate over the leader certificates. - for (leader_certificate, election_certificate_ids) in past_leader_certificates { + for leader_certificate in past_leader_certificates { // Commit the leader certificate. dag.commit(leader_certificate, self.storage().max_gc_rounds()); - // Update the last election certificate IDs. - // - // Note: Because we will be committing the latest leader certificate after this, - // technically we do not need to be updating the last election certificate IDs - // for intermediate leader certificates. However, this is a safety mechanic to ensure completeness. - *last_election_certificate_ids = election_certificate_ids.clone(); } } // Commit the latest leader certificate. - if let Err(e) = self.commit_leader_certificate::(leader_certificate, election_certificate_ids).await - { + if let Err(e) = self.commit_leader_certificate::(leader_certificate).await { error!("BFT failed to update the DAG with the latest leader certificate - {e}"); } } diff --git a/node/bft/src/helpers/channels.rs b/node/bft/src/helpers/channels.rs index 8881b1f0ca..0857d6a1ed 100644 --- a/node/bft/src/helpers/channels.rs +++ b/node/bft/src/helpers/channels.rs @@ -61,25 +61,13 @@ pub fn init_consensus_channels() -> (ConsensusSender, ConsensusRe #[derive(Clone, Debug)] pub struct BFTSender { - pub tx_last_election_certificate_ids: mpsc::Sender>>>, pub tx_primary_round: mpsc::Sender<(u64, oneshot::Sender)>, pub tx_primary_certificate: mpsc::Sender<(BatchCertificate, oneshot::Sender>)>, - pub tx_sync_bft_dag_at_bootup: - mpsc::Sender<(Vec<(BatchCertificate, IndexSet>)>, Vec>)>, + pub tx_sync_bft_dag_at_bootup: mpsc::Sender<(Vec>, Vec>)>, pub tx_sync_bft: mpsc::Sender<(BatchCertificate, oneshot::Sender>)>, } impl BFTSender { - /// Retrieves the last election certificate IDs. - pub async fn get_last_election_certificate_ids(&self) -> Result>> { - // Initialize a callback sender and receiver. - let (callback_sender, callback_receiver) = oneshot::channel(); - // Send the request to get the last election certificate IDs. - self.tx_last_election_certificate_ids.send(callback_sender).await?; - // Await the callback to continue. - Ok(callback_receiver.await?) - } - /// Sends the current round to the BFT. pub async fn send_primary_round_to_bft(&self, current_round: u64) -> Result { // Initialize a callback sender and receiver. @@ -113,36 +101,21 @@ impl BFTSender { #[derive(Debug)] pub struct BFTReceiver { - pub rx_last_election_certificate_ids: mpsc::Receiver>>>, pub rx_primary_round: mpsc::Receiver<(u64, oneshot::Sender)>, pub rx_primary_certificate: mpsc::Receiver<(BatchCertificate, oneshot::Sender>)>, - pub rx_sync_bft_dag_at_bootup: - mpsc::Receiver<(Vec<(BatchCertificate, IndexSet>)>, Vec>)>, + pub rx_sync_bft_dag_at_bootup: mpsc::Receiver<(Vec>, Vec>)>, pub rx_sync_bft: mpsc::Receiver<(BatchCertificate, oneshot::Sender>)>, } /// Initializes the BFT channels. pub fn init_bft_channels() -> (BFTSender, BFTReceiver) { - let (tx_last_election_certificate_ids, rx_last_election_certificate_ids) = mpsc::channel(MAX_CHANNEL_SIZE); let (tx_primary_round, rx_primary_round) = mpsc::channel(MAX_CHANNEL_SIZE); let (tx_primary_certificate, rx_primary_certificate) = mpsc::channel(MAX_CHANNEL_SIZE); let (tx_sync_bft_dag_at_bootup, rx_sync_bft_dag_at_bootup) = mpsc::channel(MAX_CHANNEL_SIZE); let (tx_sync_bft, rx_sync_bft) = mpsc::channel(MAX_CHANNEL_SIZE); - let sender = BFTSender { - tx_last_election_certificate_ids, - tx_primary_round, - tx_primary_certificate, - tx_sync_bft_dag_at_bootup, - tx_sync_bft, - }; - let receiver = BFTReceiver { - rx_last_election_certificate_ids, - rx_primary_round, - rx_primary_certificate, - rx_sync_bft_dag_at_bootup, - rx_sync_bft, - }; + let sender = BFTSender { tx_primary_round, tx_primary_certificate, tx_sync_bft_dag_at_bootup, tx_sync_bft }; + let receiver = BFTReceiver { rx_primary_round, rx_primary_certificate, rx_sync_bft_dag_at_bootup, rx_sync_bft }; (sender, receiver) } diff --git a/node/bft/src/helpers/proposal.rs b/node/bft/src/helpers/proposal.rs index 8e904435a2..7b26e0f9fe 100644 --- a/node/bft/src/helpers/proposal.rs +++ b/node/bft/src/helpers/proposal.rs @@ -207,7 +207,6 @@ mod prop_tests { now(), transmission_map.keys().cloned().collect(), Default::default(), - Default::default(), &mut rng, ) .unwrap(); diff --git a/node/bft/src/helpers/storage.rs b/node/bft/src/helpers/storage.rs index 4f10c4438a..3ccbd56a57 100644 --- a/node/bft/src/helpers/storage.rs +++ b/node/bft/src/helpers/storage.rs @@ -1118,7 +1118,6 @@ pub mod prop_tests { now(), transmission_map.keys().cloned().collect(), Default::default(), - Default::default(), &mut rng, ) .unwrap(); diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index b926f893a8..927a0448d8 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -450,11 +450,6 @@ impl Primary { let transmission_ids = transmissions.keys().copied().collect(); // Prepare the previous batch certificate IDs. let previous_certificate_ids = previous_certificates.into_iter().map(|c| c.id()).collect(); - // Prepare the last election certificate IDs. - let last_election_certificate_ids = match self.bft_sender.get() { - Some(bft_sender) => bft_sender.get_last_election_certificate_ids().await?, - None => Default::default(), - }; // Sign the batch header. let batch_header = spawn_blocking!(BatchHeader::new( &private_key, @@ -462,7 +457,6 @@ impl Primary { now(), transmission_ids, previous_certificate_ids, - last_election_certificate_ids, &mut rand::thread_rng() ))?; // Construct the proposal. @@ -1316,18 +1310,7 @@ impl Primary { self.fetch_missing_previous_certificates(peer_ip, batch_header).await.map_err(|e| { anyhow!("Failed to fetch missing previous certificates for round {batch_round} from '{peer_ip}' - {e}") })?; - // Ensure the primary has all of the election certificates. - let missing_election_certificates = match self.fetch_missing_election_certificates(peer_ip, batch_header).await - { - Ok(missing_election_certificates) => missing_election_certificates, - Err(e) => { - // TODO (howardwu): Change this to return early, once we have persistence on the election certificates. - error!("Failed to fetch missing election certificates for round {batch_round} from '{peer_ip}' - {e}"); - // Note: We do not return early on error, because we can still proceed without the election certificates, - // albeit with reduced safety guarantees for commits. This is not a long-term solution. - Default::default() - } - }; + // Ensure the primary has all of the transmissions. let missing_transmissions = self.fetch_missing_transmissions(peer_ip, batch_header).await.map_err(|e| { anyhow!("Failed to fetch missing transmissions for round {batch_round} from '{peer_ip}' - {e}") @@ -1338,11 +1321,6 @@ impl Primary { // Store the batch certificate (recursively fetching any missing previous certificates). self.sync_with_certificate_from_peer(peer_ip, batch_certificate).await?; } - // Iterate through the missing election certificates. - for batch_certificate in missing_election_certificates { - // Store the batch certificate (recursively fetching any missing previous certificates). - self.sync_with_certificate_from_peer(peer_ip, batch_certificate).await?; - } Ok(missing_transmissions) } @@ -1425,32 +1403,6 @@ impl Primary { Ok(missing_previous_certificates) } - /// Fetches any missing election certificates for the specified batch header from the specified peer. - async fn fetch_missing_election_certificates( - &self, - peer_ip: SocketAddr, - batch_header: &BatchHeader, - ) -> Result>> { - // Retrieve the round. - let round = batch_header.round(); - // If the previous round is 0, or is <= the GC round, return early. - if round == 1 || round <= self.storage.gc_round() + 1 { - return Ok(Default::default()); - } - - // Fetch the missing election certificates. - let missing_election_certificates = - self.fetch_missing_certificates(peer_ip, round, batch_header.last_election_certificate_ids()).await?; - if !missing_election_certificates.is_empty() { - debug!( - "Fetched {} missing election certificates for round {round} from '{peer_ip}'", - missing_election_certificates.len(), - ); - } - // Return the missing election certificates. - Ok(missing_election_certificates) - } - /// Fetches any missing certificates for the specified batch header from the specified peer. async fn fetch_missing_certificates( &self, @@ -1628,16 +1580,8 @@ mod tests { ] .into(); // Sign the batch header. - let batch_header = BatchHeader::new( - private_key, - round, - timestamp, - transmission_ids, - previous_certificate_ids, - Default::default(), - rng, - ) - .unwrap(); + let batch_header = + BatchHeader::new(private_key, round, timestamp, transmission_ids, previous_certificate_ids, rng).unwrap(); // Construct the proposal. Proposal::new(committee, batch_header, transmissions).unwrap() } @@ -1704,16 +1648,8 @@ mod tests { ] .into(); - let batch_header = BatchHeader::new( - private_key, - round, - timestamp, - transmission_ids, - previous_certificate_ids, - Default::default(), - rng, - ) - .unwrap(); + let batch_header = + BatchHeader::new(private_key, round, timestamp, transmission_ids, previous_certificate_ids, rng).unwrap(); let signatures = peer_signatures_for_batch(primary_address, accounts, batch_header.batch_id(), rng); let certificate = BatchCertificate::::from(batch_header, signatures).unwrap(); (certificate, transmissions) diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index 517dbca5eb..f56fc8c9e5 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -222,9 +222,7 @@ impl Sync { // If the block authority is a beacon, then skip the block. Authority::Beacon(_) => None, // If the block authority is a subdag, then retrieve the certificates. - Authority::Quorum(subdag) => { - Some((subdag.leader_certificate().clone(), subdag.election_certificate_ids().clone())) - } + Authority::Quorum(subdag) => Some(subdag.leader_certificate().clone()), } }) .collect::>(); From c180372dbce6604a91862d2cc7781303f001020e Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Fri, 9 Feb 2024 19:41:25 -0800 Subject: [PATCH 028/551] Cargo.lock --- Cargo.lock | 116 ++++++++++++++++++++++++++--------------------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 45a462955a..473d2d77fc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3526,7 +3526,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "anstyle", "anyhow", @@ -3557,7 +3557,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "aleo-std", "anyhow", @@ -3587,7 +3587,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3601,7 +3601,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3612,7 +3612,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3622,7 +3622,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3632,7 +3632,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "indexmap 2.2.2", "itertools 0.11.0", @@ -3650,12 +3650,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" [[package]] name = "snarkvm-circuit-network" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3666,7 +3666,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3681,7 +3681,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3696,7 +3696,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3709,7 +3709,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3718,7 +3718,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3728,7 +3728,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3740,7 +3740,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3752,7 +3752,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3763,7 +3763,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3775,7 +3775,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3788,7 +3788,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "bs58", "snarkvm-console-network", @@ -3799,7 +3799,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "blake2s_simd", "smallvec", @@ -3812,7 +3812,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "aleo-std", "rayon", @@ -3823,7 +3823,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "anyhow", "indexmap 2.2.2", @@ -3846,7 +3846,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "anyhow", "bech32", @@ -3864,7 +3864,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "enum_index", "enum_index_derive", @@ -3885,7 +3885,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3900,7 +3900,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3911,7 +3911,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "snarkvm-console-network-environment", ] @@ -3919,7 +3919,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3929,7 +3929,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3940,7 +3940,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3951,7 +3951,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3962,7 +3962,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3973,7 +3973,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "rand", "rayon", @@ -3987,7 +3987,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "aleo-std", "anyhow", @@ -4004,7 +4004,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "aleo-std", "anyhow", @@ -4029,7 +4029,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "anyhow", "rand", @@ -4041,7 +4041,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4060,7 +4060,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-coinbase" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "aleo-std", "anyhow", @@ -4080,7 +4080,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "anyhow", "indexmap 2.2.2", @@ -4098,7 +4098,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -4111,7 +4111,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4124,7 +4124,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "indexmap 2.2.2", "serde_json", @@ -4136,7 +4136,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "bytes", "serde_json", @@ -4147,7 +4147,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4162,7 +4162,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "bytes", "serde_json", @@ -4175,7 +4175,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "snarkvm-console", "snarkvm-ledger-coinbase", @@ -4184,7 +4184,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "async-trait", "reqwest", @@ -4197,7 +4197,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "aleo-std-storage", "anyhow", @@ -4222,7 +4222,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4237,7 +4237,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4246,7 +4246,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "aleo-std", "anyhow", @@ -4271,7 +4271,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "aleo-std", "anyhow", @@ -4295,7 +4295,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "aleo-std", "colored", @@ -4318,7 +4318,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "indexmap 2.2.2", "paste", @@ -4332,7 +4332,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "bincode", "once_cell", @@ -4345,7 +4345,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "aleo-std", "anyhow", @@ -4366,7 +4366,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7faebdd#7faebdd323d847abc89a81f142ee1081837f075b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" dependencies = [ "proc-macro2", "quote 1.0.35", From d1960b0db2c56bc1280c8139ac3d4e8ba31618c6 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Fri, 9 Feb 2024 20:09:35 -0800 Subject: [PATCH 029/551] Reduce the primary ping --- node/bft/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/bft/src/lib.rs b/node/bft/src/lib.rs index 85d06b2088..04edf8acf5 100644 --- a/node/bft/src/lib.rs +++ b/node/bft/src/lib.rs @@ -56,7 +56,7 @@ pub const MAX_TIMESTAMP_DELTA_IN_SECS: i64 = 10; // seconds pub const MAX_WORKERS: u8 = 1; // worker(s) /// The frequency at which each primary broadcasts a ping to every other node. -pub const PRIMARY_PING_IN_MS: u64 = 4 * MAX_BATCH_DELAY_IN_MS; // ms +pub const PRIMARY_PING_IN_MS: u64 = 8 * MAX_BATCH_DELAY_IN_MS; // ms /// The frequency at which each worker broadcasts a ping to every other node. pub const WORKER_PING_IN_MS: u64 = 4 * MAX_BATCH_DELAY_IN_MS; // ms From 279b3291ba23ebf99fecabd6759178fbef6ec3b7 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Fri, 9 Feb 2024 20:25:21 -0800 Subject: [PATCH 030/551] Remove the batch certificates from primary ping --- node/bft/src/primary.rs | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 927a0448d8..6327dbc9d7 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -842,21 +842,22 @@ impl Primary { }; // Retrieve the batch certificates. - let batch_certificates = { - // Retrieve the current round. - let current_round = self_.current_round(); - // Retrieve the batch certificates for the current round. - let mut current_certificates = self_.storage.get_certificates_for_round(current_round); - // If there are no batch certificates for the current round, - // then retrieve the batch certificates for the previous round. - if current_certificates.is_empty() { - // Retrieve the previous round. - let previous_round = current_round.saturating_sub(1); - // Retrieve the batch certificates for the previous round. - current_certificates = self_.storage.get_certificates_for_round(previous_round); - } - current_certificates - }; + // let batch_certificates = { + // // Retrieve the current round. + // let current_round = self_.current_round(); + // // Retrieve the batch certificates for the current round. + // let mut current_certificates = self_.storage.get_certificates_for_round(current_round); + // // If there are no batch certificates for the current round, + // // then retrieve the batch certificates for the previous round. + // if current_certificates.is_empty() { + // // Retrieve the previous round. + // let previous_round = current_round.saturating_sub(1); + // // Retrieve the batch certificates for the previous round. + // current_certificates = self_.storage.get_certificates_for_round(previous_round); + // } + // current_certificates + // }; + let batch_certificates = IndexSet::default(); // Construct the primary ping. let primary_ping = PrimaryPing::from(( From 7477acbcec2cbbe0df9d80ad08e088db486ea543 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Fri, 9 Feb 2024 20:40:37 -0800 Subject: [PATCH 031/551] Remove batch certificates from primary ping --- node/bft/events/src/primary_ping.rs | 64 +++------------------- node/bft/src/gateway.rs | 8 +-- node/bft/src/helpers/channels.rs | 6 +-- node/bft/src/primary.rs | 83 +---------------------------- 4 files changed, 12 insertions(+), 149 deletions(-) diff --git a/node/bft/events/src/primary_ping.rs b/node/bft/events/src/primary_ping.rs index 8f2fe67da7..d8eae4267b 100644 --- a/node/bft/events/src/primary_ping.rs +++ b/node/bft/events/src/primary_ping.rs @@ -19,7 +19,6 @@ pub struct PrimaryPing { pub version: u32, pub block_locators: BlockLocators, pub primary_certificate: Data>, - pub batch_certificates: IndexMap, Data>>, } impl PrimaryPing { @@ -28,28 +27,15 @@ impl PrimaryPing { version: u32, block_locators: BlockLocators, primary_certificate: Data>, - batch_certificates: IndexMap, Data>>, ) -> Self { - Self { version, block_locators, primary_certificate, batch_certificates } + Self { version, block_locators, primary_certificate } } } -impl From<(u32, BlockLocators, BatchCertificate, IndexSet>)> for PrimaryPing { +impl From<(u32, BlockLocators, BatchCertificate)> for PrimaryPing { /// Initializes a new ping event. - fn from( - (version, block_locators, primary_certificate, batch_certificates): ( - u32, - BlockLocators, - BatchCertificate, - IndexSet>, - ), - ) -> Self { - Self::new( - version, - block_locators, - Data::Object(primary_certificate), - batch_certificates.into_iter().map(|c| (c.id(), Data::Object(c))).collect(), - ) + fn from((version, block_locators, primary_certificate): (u32, BlockLocators, BatchCertificate)) -> Self { + Self::new(version, block_locators, Data::Object(primary_certificate)) } } @@ -70,17 +56,6 @@ impl ToBytes for PrimaryPing { // Write the primary certificate. self.primary_certificate.write_le(&mut writer)?; - // Determine the number of batch certificates. - let num_certificates = - u16::try_from(self.batch_certificates.len()).map_err(error)?.min(Committee::::MAX_COMMITTEE_SIZE); - - // Write the number of batch certificates. - num_certificates.write_le(&mut writer)?; - // Write the batch certificates. - for (certificate_id, certificate) in self.batch_certificates.iter().take(usize::from(num_certificates)) { - certificate_id.write_le(&mut writer)?; - certificate.write_le(&mut writer)?; - } Ok(()) } } @@ -94,27 +69,8 @@ impl FromBytes for PrimaryPing { // Read the primary certificate. let primary_certificate = Data::read_le(&mut reader)?; - // Read the number of batch certificates. - let num_certificates = u16::read_le(&mut reader)?; - // Ensure the number of batch certificates is not greater than the maximum committee size. - // Note: We allow there to be 0 batch certificates. This is necessary to ensure primary pings are sent. - if num_certificates > Committee::::MAX_COMMITTEE_SIZE { - return Err(error("The number of batch certificates is greater than the maximum committee size")); - } - - // Read the batch certificates. - let mut batch_certificates = IndexMap::with_capacity(usize::from(num_certificates)); - for _ in 0..num_certificates { - // Read the certificate ID. - let certificate_id = Field::read_le(&mut reader)?; - // Read the certificate. - let certificate = Data::read_le(&mut reader)?; - // Insert the certificate. - batch_certificates.insert(certificate_id, certificate); - } - // Return the ping event. - Ok(Self::new(version, block_locators, primary_certificate, batch_certificates)) + Ok(Self::new(version, block_locators, primary_certificate)) } } @@ -138,7 +94,7 @@ pub mod prop_tests { pub fn any_primary_ping() -> BoxedStrategy> { (any::(), any_block_locators(), any_batch_certificate()) .prop_map(|(version, block_locators, batch_certificate)| { - PrimaryPing::from((version, block_locators, batch_certificate.clone(), indexset![batch_certificate])) + PrimaryPing::from((version, block_locators, batch_certificate.clone())) }) .boxed() } @@ -154,13 +110,5 @@ pub mod prop_tests { primary_ping.primary_certificate.deserialize_blocking().unwrap(), decoded.primary_certificate.deserialize_blocking().unwrap(), ); - assert!( - primary_ping - .batch_certificates - .into_iter() - .map(|(a, bc)| (a, bc.deserialize_blocking().unwrap())) - .zip(decoded.batch_certificates.into_iter().map(|(a, bc)| (a, bc.deserialize_blocking().unwrap()))) - .all(|(a, b)| a == b) - ) } } diff --git a/node/bft/src/gateway.rs b/node/bft/src/gateway.rs index 11f2dd3ebe..d1420c50a5 100644 --- a/node/bft/src/gateway.rs +++ b/node/bft/src/gateway.rs @@ -632,7 +632,7 @@ impl Gateway { bail!("{CONTEXT} {:?}", disconnect.reason) } Event::PrimaryPing(ping) => { - let PrimaryPing { version, block_locators, primary_certificate, batch_certificates } = ping; + let PrimaryPing { version, block_locators, primary_certificate } = ping; // Ensure the event version is not outdated. if version < Event::::VERSION { @@ -648,11 +648,7 @@ impl Gateway { } // Send the batch certificates to the primary. - let _ = self - .primary_sender() - .tx_primary_ping - .send((peer_ip, primary_certificate, batch_certificates)) - .await; + let _ = self.primary_sender().tx_primary_ping.send((peer_ip, primary_certificate)).await; Ok(()) } Event::TransmissionRequest(request) => { diff --git a/node/bft/src/helpers/channels.rs b/node/bft/src/helpers/channels.rs index 0857d6a1ed..159d7f3e79 100644 --- a/node/bft/src/helpers/channels.rs +++ b/node/bft/src/helpers/channels.rs @@ -125,8 +125,7 @@ pub struct PrimarySender { pub tx_batch_propose: mpsc::Sender<(SocketAddr, BatchPropose)>, pub tx_batch_signature: mpsc::Sender<(SocketAddr, BatchSignature)>, pub tx_batch_certified: mpsc::Sender<(SocketAddr, Data>)>, - pub tx_primary_ping: - mpsc::Sender<(SocketAddr, Data>, IndexMap, Data>>)>, + pub tx_primary_ping: mpsc::Sender<(SocketAddr, Data>)>, pub tx_unconfirmed_solution: mpsc::Sender<(PuzzleCommitment, Data>, oneshot::Sender>)>, pub tx_unconfirmed_transaction: mpsc::Sender<(N::TransactionID, Data>, oneshot::Sender>)>, @@ -167,8 +166,7 @@ pub struct PrimaryReceiver { pub rx_batch_propose: mpsc::Receiver<(SocketAddr, BatchPropose)>, pub rx_batch_signature: mpsc::Receiver<(SocketAddr, BatchSignature)>, pub rx_batch_certified: mpsc::Receiver<(SocketAddr, Data>)>, - pub rx_primary_ping: - mpsc::Receiver<(SocketAddr, Data>, IndexMap, Data>>)>, + pub rx_primary_ping: mpsc::Receiver<(SocketAddr, Data>)>, pub rx_unconfirmed_solution: mpsc::Receiver<(PuzzleCommitment, Data>, oneshot::Sender>)>, pub rx_unconfirmed_transaction: diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 6327dbc9d7..44e26ef814 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -750,34 +750,6 @@ impl Primary { } Ok(()) } - - /// Processes a batch certificate from a primary ping. - /// - /// This method performs the following steps: - /// 1. Stores the given batch certificate, after ensuring it is valid. - /// 2. If there are enough certificates to reach quorum threshold for the current round, - /// then proceed to advance to the next round. - async fn process_batch_certificate_from_ping( - &self, - peer_ip: SocketAddr, - certificate: BatchCertificate, - ) -> Result<()> { - // Ensure storage does not already contain the certificate. - if self.storage.contains_certificate(certificate.id()) { - return Ok(()); - } - - // Ensure the batch certificate is from an authorized validator. - if !self.gateway.is_authorized_validator_ip(peer_ip) { - // Proceed to disconnect the validator. - self.gateway.disconnect(peer_ip); - bail!("Malicious peer - Received a batch certificate from an unauthorized validator IP ({peer_ip})"); - } - - // Store the certificate, after ensuring it is valid. - self.sync_with_certificate_from_peer(peer_ip, certificate).await?; - Ok(()) - } } impl Primary { @@ -841,31 +813,8 @@ impl Primary { } }; - // Retrieve the batch certificates. - // let batch_certificates = { - // // Retrieve the current round. - // let current_round = self_.current_round(); - // // Retrieve the batch certificates for the current round. - // let mut current_certificates = self_.storage.get_certificates_for_round(current_round); - // // If there are no batch certificates for the current round, - // // then retrieve the batch certificates for the previous round. - // if current_certificates.is_empty() { - // // Retrieve the previous round. - // let previous_round = current_round.saturating_sub(1); - // // Retrieve the batch certificates for the previous round. - // current_certificates = self_.storage.get_certificates_for_round(previous_round); - // } - // current_certificates - // }; - let batch_certificates = IndexSet::default(); - // Construct the primary ping. - let primary_ping = PrimaryPing::from(( - >::VERSION, - block_locators, - primary_certificate, - batch_certificates, - )); + let primary_ping = PrimaryPing::from((>::VERSION, block_locators, primary_certificate)); // Broadcast the event. self_.gateway.broadcast(Event::PrimaryPing(primary_ping)); } @@ -875,7 +824,7 @@ impl Primary { // Start the primary ping handler. let self_ = self.clone(); self.spawn(async move { - while let Some((peer_ip, primary_certificate, batch_certificates)) = rx_primary_ping.recv().await { + while let Some((peer_ip, primary_certificate)) = rx_primary_ping.recv().await { // If the primary is not synced, then do not process the primary ping. if !self_.sync.is_synced() { trace!("Skipping a primary ping from '{peer_ip}' {}", "(node is syncing)".dimmed()); @@ -898,34 +847,6 @@ impl Primary { } }); } - - // Iterate through the batch certificates. - for (certificate_id, certificate) in batch_certificates { - // Ensure storage does not already contain the certificate. - if self_.storage.contains_certificate(certificate_id) { - continue; - } - // Spawn a task to process the batch certificate. - let self_ = self_.clone(); - tokio::spawn(async move { - // Deserialize the batch certificate in the primary ping. - let Ok(batch_certificate) = spawn_blocking!(certificate.deserialize_blocking()) else { - warn!("Failed to deserialize batch certificate in a 'PrimaryPing' from '{peer_ip}'"); - return; - }; - // Ensure the batch certificate ID matches. - if batch_certificate.id() != certificate_id { - warn!("Batch certificate ID mismatch in a 'PrimaryPing' from '{peer_ip}'"); - // Proceed to disconnect the validator. - self_.gateway.disconnect(peer_ip); - return; - } - // Process the batch certificate. - if let Err(e) = self_.process_batch_certificate_from_ping(peer_ip, batch_certificate).await { - warn!("Cannot process a batch certificate in a 'PrimaryPing' from '{peer_ip}' - {e}"); - } - }); - } } }); From 0898240e70696a81e0e91fdb7d071703d63f8b80 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Fri, 9 Feb 2024 20:50:31 -0800 Subject: [PATCH 032/551] Update the ping back to 4x --- node/bft/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/node/bft/src/lib.rs b/node/bft/src/lib.rs index 04edf8acf5..c975241a67 100644 --- a/node/bft/src/lib.rs +++ b/node/bft/src/lib.rs @@ -56,7 +56,8 @@ pub const MAX_TIMESTAMP_DELTA_IN_SECS: i64 = 10; // seconds pub const MAX_WORKERS: u8 = 1; // worker(s) /// The frequency at which each primary broadcasts a ping to every other node. -pub const PRIMARY_PING_IN_MS: u64 = 8 * MAX_BATCH_DELAY_IN_MS; // ms +/// Note: If this is updated, be sure to update `MAX_BLOCKS_BEHIND` to correspond properly. +pub const PRIMARY_PING_IN_MS: u64 = 4 * MAX_BATCH_DELAY_IN_MS; // ms /// The frequency at which each worker broadcasts a ping to every other node. pub const WORKER_PING_IN_MS: u64 = 4 * MAX_BATCH_DELAY_IN_MS; // ms From bfd7dfcc252f3bc4f25a433c992952f04c6c4318 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Fri, 9 Feb 2024 21:06:12 -0800 Subject: [PATCH 033/551] Increase fetch timeouts --- node/bft/src/lib.rs | 2 ++ node/bft/src/sync/mod.rs | 5 +++-- node/bft/src/worker.rs | 4 ++-- node/bft/tests/bft_e2e.rs | 6 +++--- node/bft/tests/narwhal_e2e.rs | 6 +++--- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/node/bft/src/lib.rs b/node/bft/src/lib.rs index c975241a67..a041c3869b 100644 --- a/node/bft/src/lib.rs +++ b/node/bft/src/lib.rs @@ -48,6 +48,8 @@ pub const MEMORY_POOL_PORT: u16 = 5000; // port /// The maximum number of milliseconds to wait before proposing a batch. pub const MAX_BATCH_DELAY_IN_MS: u64 = 2500; // ms +/// The maximum number of milliseconds to wait before timing out on a fetch. +pub const MAX_FETCH_TIMEOUT_IN_MS: u64 = 2 * MAX_BATCH_DELAY_IN_MS; // ms /// The maximum number of seconds allowed for the leader to send their certificate. pub const MAX_LEADER_CERTIFICATE_DELAY_IN_SECS: i64 = 2 * MAX_BATCH_DELAY_IN_MS as i64 / 1000; // seconds /// The maximum number of seconds before the timestamp is considered expired. diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index f56fc8c9e5..685219f1c1 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -16,7 +16,7 @@ use crate::{ helpers::{BFTSender, Pending, Storage, SyncReceiver}, Gateway, Transport, - MAX_BATCH_DELAY_IN_MS, + MAX_FETCH_TIMEOUT_IN_MS, PRIMARY_PING_IN_MS, }; use snarkos_node_bft_events::{CertificateRequest, CertificateResponse, Event}; @@ -339,7 +339,8 @@ impl Sync { } } // Wait for the certificate to be fetched. - match tokio::time::timeout(core::time::Duration::from_millis(MAX_BATCH_DELAY_IN_MS), callback_receiver).await { + match tokio::time::timeout(core::time::Duration::from_millis(MAX_FETCH_TIMEOUT_IN_MS), callback_receiver).await + { // If the certificate was fetched, return it. Ok(result) => Ok(result?), // If the certificate was not fetched, return an error. diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index f9af2f68a5..c061f7c0d9 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -17,7 +17,7 @@ use crate::{ helpers::{fmt_id, Pending, Ready, Storage, WorkerReceiver}, ProposedBatch, Transport, - MAX_BATCH_DELAY_IN_MS, + MAX_FETCH_TIMEOUT_IN_MS, MAX_WORKERS, }; use snarkos_node_bft_ledger_service::LedgerService; @@ -391,7 +391,7 @@ impl Worker { bail!("Unable to fetch transmission - failed to send request") } // Wait for the transmission to be fetched. - match timeout(Duration::from_millis(MAX_BATCH_DELAY_IN_MS), callback_receiver).await { + match timeout(Duration::from_millis(MAX_FETCH_TIMEOUT_IN_MS), callback_receiver).await { // If the transmission was fetched, return it. Ok(result) => Ok((transmission_id, result?)), // If the transmission was not fetched, return an error. diff --git a/node/bft/tests/bft_e2e.rs b/node/bft/tests/bft_e2e.rs index 796cd50d4e..cd2a442f52 100644 --- a/node/bft/tests/bft_e2e.rs +++ b/node/bft/tests/bft_e2e.rs @@ -18,7 +18,7 @@ mod common; use crate::common::primary::{TestNetwork, TestNetworkConfig}; use deadline::deadline; use itertools::Itertools; -use snarkos_node_bft::MAX_BATCH_DELAY_IN_MS; +use snarkos_node_bft::MAX_FETCH_TIMEOUT_IN_MS; use std::time::Duration; use tokio::time::sleep; @@ -114,7 +114,7 @@ async fn test_quorum_threshold() { // Start the cannons for node 0. network.fire_transmissions_at(0, TRANSMISSION_INTERVAL_MS); - sleep(Duration::from_millis(MAX_BATCH_DELAY_IN_MS * 2)).await; + sleep(Duration::from_millis(MAX_FETCH_TIMEOUT_IN_MS)).await; // Check each node is still at round 1. for validator in network.validators.values() { @@ -125,7 +125,7 @@ async fn test_quorum_threshold() { network.connect_validators(0, 1).await; network.fire_transmissions_at(1, TRANSMISSION_INTERVAL_MS); - sleep(Duration::from_millis(MAX_BATCH_DELAY_IN_MS * 2)).await; + sleep(Duration::from_millis(MAX_FETCH_TIMEOUT_IN_MS)).await; // Check each node is still at round 1. for validator in network.validators.values() { diff --git a/node/bft/tests/narwhal_e2e.rs b/node/bft/tests/narwhal_e2e.rs index b2783b1d90..ebf4c47eb6 100644 --- a/node/bft/tests/narwhal_e2e.rs +++ b/node/bft/tests/narwhal_e2e.rs @@ -16,7 +16,7 @@ mod common; use crate::common::primary::{TestNetwork, TestNetworkConfig}; -use snarkos_node_bft::MAX_BATCH_DELAY_IN_MS; +use snarkos_node_bft::MAX_FETCH_TIMEOUT_IN_MS; use std::time::Duration; @@ -72,7 +72,7 @@ async fn test_quorum_threshold() { // Start the cannons for node 0. network.fire_transmissions_at(0, TRANSMISSION_INTERVAL_MS); - sleep(Duration::from_millis(MAX_BATCH_DELAY_IN_MS * 2)).await; + sleep(Duration::from_millis(MAX_FETCH_TIMEOUT_IN_MS)).await; // Check each node is still at round 1. for validator in network.validators.values() { @@ -83,7 +83,7 @@ async fn test_quorum_threshold() { network.connect_validators(0, 1).await; network.fire_transmissions_at(1, TRANSMISSION_INTERVAL_MS); - sleep(Duration::from_millis(MAX_BATCH_DELAY_IN_MS * 2)).await; + sleep(Duration::from_millis(MAX_FETCH_TIMEOUT_IN_MS)).await; // Check each node is still at round 1. for validator in network.validators.values() { From dc03a03421c776f03ca6079fdd12c157c0d4703c Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Fri, 9 Feb 2024 21:19:31 -0800 Subject: [PATCH 034/551] Try 0 block behind --- node/sync/src/block_sync.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/sync/src/block_sync.rs b/node/sync/src/block_sync.rs index 413da66198..ae8e93d774 100644 --- a/node/sync/src/block_sync.rs +++ b/node/sync/src/block_sync.rs @@ -45,7 +45,7 @@ const MAX_BLOCK_REQUESTS: usize = 50; // 50 requests const MAX_BLOCK_REQUEST_TIMEOUTS: usize = 5; // 5 timeouts /// The maximum number of blocks tolerated before the primary is considered behind its peers. -pub const MAX_BLOCKS_BEHIND: u32 = 2; // blocks +pub const MAX_BLOCKS_BEHIND: u32 = 0; // blocks /// This is a dummy IP address that is used to represent the local node. /// Note: This here does not need to be a real IP address, but it must be unique/distinct from all other connections. From b9aa45ea84d87660235a929b5d56e34d1832ad89 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Fri, 9 Feb 2024 21:31:04 -0800 Subject: [PATCH 035/551] Switch to 2x and 1 block --- node/bft/src/lib.rs | 2 +- node/sync/src/block_sync.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/node/bft/src/lib.rs b/node/bft/src/lib.rs index a041c3869b..0b2f2a53ea 100644 --- a/node/bft/src/lib.rs +++ b/node/bft/src/lib.rs @@ -59,7 +59,7 @@ pub const MAX_WORKERS: u8 = 1; // worker(s) /// The frequency at which each primary broadcasts a ping to every other node. /// Note: If this is updated, be sure to update `MAX_BLOCKS_BEHIND` to correspond properly. -pub const PRIMARY_PING_IN_MS: u64 = 4 * MAX_BATCH_DELAY_IN_MS; // ms +pub const PRIMARY_PING_IN_MS: u64 = 2 * MAX_BATCH_DELAY_IN_MS; // ms /// The frequency at which each worker broadcasts a ping to every other node. pub const WORKER_PING_IN_MS: u64 = 4 * MAX_BATCH_DELAY_IN_MS; // ms diff --git a/node/sync/src/block_sync.rs b/node/sync/src/block_sync.rs index ae8e93d774..52abf55030 100644 --- a/node/sync/src/block_sync.rs +++ b/node/sync/src/block_sync.rs @@ -45,7 +45,7 @@ const MAX_BLOCK_REQUESTS: usize = 50; // 50 requests const MAX_BLOCK_REQUEST_TIMEOUTS: usize = 5; // 5 timeouts /// The maximum number of blocks tolerated before the primary is considered behind its peers. -pub const MAX_BLOCKS_BEHIND: u32 = 0; // blocks +pub const MAX_BLOCKS_BEHIND: u32 = 1; // blocks /// This is a dummy IP address that is used to represent the local node. /// Note: This here does not need to be a real IP address, but it must be unique/distinct from all other connections. From c7e3912d301e4a4ca2c22744e7eabf236bc4c710 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Fri, 9 Feb 2024 23:01:12 -0800 Subject: [PATCH 036/551] Clippy --- node/bft/events/src/lib.rs | 1 - node/bft/events/src/primary_ping.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/node/bft/events/src/lib.rs b/node/bft/events/src/lib.rs index 7a3c6d30ef..c3a1833d07 100644 --- a/node/bft/events/src/lib.rs +++ b/node/bft/events/src/lib.rs @@ -70,7 +70,6 @@ use snarkvm::{ console::prelude::{error, FromBytes, Network, Read, ToBytes, Write}, ledger::{ block::Block, - committee::Committee, narwhal::{BatchCertificate, BatchHeader, Data, Transmission, TransmissionID}, }, prelude::{Address, Field, Signature}, diff --git a/node/bft/events/src/primary_ping.rs b/node/bft/events/src/primary_ping.rs index d8eae4267b..fca808bda8 100644 --- a/node/bft/events/src/primary_ping.rs +++ b/node/bft/events/src/primary_ping.rs @@ -81,7 +81,6 @@ pub mod prop_tests { use snarkvm::utilities::{FromBytes, ToBytes}; use bytes::{Buf, BufMut, BytesMut}; - use indexmap::indexset; use proptest::prelude::{any, BoxedStrategy, Strategy}; use test_strategy::proptest; From b7728ea1a02505cbd357e671f36449d78c923537 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sat, 10 Feb 2024 17:39:13 -0800 Subject: [PATCH 037/551] Update rev --- Cargo.lock | 232 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 2 +- 2 files changed, 117 insertions(+), 117 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 473d2d77fc..5a163b7100 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3525,8 +3525,8 @@ dependencies = [ [[package]] name = "snarkvm" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "anstyle", "anyhow", @@ -3556,8 +3556,8 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "aleo-std", "anyhow", @@ -3586,8 +3586,8 @@ dependencies = [ [[package]] name = "snarkvm-circuit" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3600,8 +3600,8 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3611,8 +3611,8 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3621,8 +3621,8 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3631,8 +3631,8 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "indexmap 2.2.2", "itertools 0.11.0", @@ -3649,13 +3649,13 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" [[package]] name = "snarkvm-circuit-network" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3665,8 +3665,8 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3680,8 +3680,8 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3695,8 +3695,8 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3708,8 +3708,8 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3717,8 +3717,8 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3727,8 +3727,8 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3739,8 +3739,8 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3751,8 +3751,8 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3762,8 +3762,8 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3774,8 +3774,8 @@ dependencies = [ [[package]] name = "snarkvm-console" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3787,8 +3787,8 @@ dependencies = [ [[package]] name = "snarkvm-console-account" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "bs58", "snarkvm-console-network", @@ -3798,8 +3798,8 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "blake2s_simd", "smallvec", @@ -3811,8 +3811,8 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "aleo-std", "rayon", @@ -3822,8 +3822,8 @@ dependencies = [ [[package]] name = "snarkvm-console-network" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "anyhow", "indexmap 2.2.2", @@ -3845,8 +3845,8 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "anyhow", "bech32", @@ -3863,8 +3863,8 @@ dependencies = [ [[package]] name = "snarkvm-console-program" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "enum_index", "enum_index_derive", @@ -3884,8 +3884,8 @@ dependencies = [ [[package]] name = "snarkvm-console-types" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3899,8 +3899,8 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3910,16 +3910,16 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "snarkvm-console-network-environment", ] [[package]] name = "snarkvm-console-types-field" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3928,8 +3928,8 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3939,8 +3939,8 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3950,8 +3950,8 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3961,8 +3961,8 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3972,8 +3972,8 @@ dependencies = [ [[package]] name = "snarkvm-curves" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "rand", "rayon", @@ -3986,8 +3986,8 @@ dependencies = [ [[package]] name = "snarkvm-fields" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "aleo-std", "anyhow", @@ -4003,8 +4003,8 @@ dependencies = [ [[package]] name = "snarkvm-ledger" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "aleo-std", "anyhow", @@ -4028,8 +4028,8 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "anyhow", "rand", @@ -4040,8 +4040,8 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4059,8 +4059,8 @@ dependencies = [ [[package]] name = "snarkvm-ledger-coinbase" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "aleo-std", "anyhow", @@ -4079,8 +4079,8 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "anyhow", "indexmap 2.2.2", @@ -4097,8 +4097,8 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -4110,8 +4110,8 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4123,8 +4123,8 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "indexmap 2.2.2", "serde_json", @@ -4135,8 +4135,8 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "bytes", "serde_json", @@ -4146,8 +4146,8 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4161,8 +4161,8 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "bytes", "serde_json", @@ -4174,8 +4174,8 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "snarkvm-console", "snarkvm-ledger-coinbase", @@ -4183,8 +4183,8 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "async-trait", "reqwest", @@ -4196,8 +4196,8 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "aleo-std-storage", "anyhow", @@ -4221,8 +4221,8 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4236,8 +4236,8 @@ dependencies = [ [[package]] name = "snarkvm-metrics" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4245,8 +4245,8 @@ dependencies = [ [[package]] name = "snarkvm-parameters" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "aleo-std", "anyhow", @@ -4270,8 +4270,8 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "aleo-std", "anyhow", @@ -4294,8 +4294,8 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "aleo-std", "colored", @@ -4317,8 +4317,8 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "indexmap 2.2.2", "paste", @@ -4331,8 +4331,8 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "bincode", "once_cell", @@ -4344,8 +4344,8 @@ dependencies = [ [[package]] name = "snarkvm-utilities" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "aleo-std", "anyhow", @@ -4365,8 +4365,8 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" -version = "0.16.18" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d1255de#d1255de834af6bcf1827515b6670480c63c7f74d" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" dependencies = [ "proc-macro2", "quote 1.0.35", diff --git a/Cargo.toml b/Cargo.toml index 4b98594481..c7a7f33979 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "d1255de" +rev = "ca2efa9" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From 62ca01b88407e611ccc0789ea8a1dbd5dda62c3a Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sat, 10 Feb 2024 18:01:42 -0800 Subject: [PATCH 038/551] Update Testnet3 to MainnetV0 --- .circleci/config.yml | 2 +- .devnet/.analytics/analytics.js | 2 +- .devnet/README.md | 2 +- .devnet/config.sh | 8 +- .devnet/install.sh | 6 +- .devnet/reinstall.sh | 6 +- .github/dependabot.yml | 2 +- .integration/src/lib.rs | 4 +- Cargo.lock | 116 +++++++++--------- Cargo.toml | 2 +- account/src/lib.rs | 4 +- cli/src/commands/account.rs | 2 +- cli/src/commands/developer/mod.rs | 6 +- cli/src/commands/developer/scan.rs | 10 +- cli/src/commands/start.rs | 32 ++--- node/bft/events/src/batch_certified.rs | 2 +- node/bft/events/src/batch_propose.rs | 2 +- node/bft/events/src/batch_signature.rs | 2 +- node/bft/events/src/block_response.rs | 2 +- node/bft/events/src/certificate_request.rs | 2 +- node/bft/events/src/certificate_response.rs | 2 +- node/bft/events/src/challenge_request.rs | 2 +- node/bft/events/src/challenge_response.rs | 2 +- node/bft/events/src/helpers/codec.rs | 2 +- node/bft/events/src/lib.rs | 4 +- node/bft/events/src/primary_ping.rs | 2 +- node/bft/events/src/transmission_request.rs | 2 +- node/bft/events/src/transmission_response.rs | 2 +- node/bft/events/src/validators_response.rs | 2 +- node/bft/events/src/worker_ping.rs | 2 +- node/bft/examples/simple_node.rs | 2 +- node/bft/src/bft.rs | 2 +- node/bft/src/gateway.rs | 4 +- node/bft/src/helpers/cache.rs | 4 +- node/bft/src/helpers/dag.rs | 10 +- node/bft/src/helpers/partition.rs | 2 +- node/bft/src/helpers/pending.rs | 2 +- node/bft/src/helpers/ready.rs | 2 +- node/bft/src/helpers/resolver.rs | 2 +- node/bft/src/helpers/storage.rs | 4 +- node/bft/src/primary.rs | 2 +- node/bft/src/worker.rs | 4 +- node/bft/tests/common/mod.rs | 2 +- node/cdn/src/blocks.rs | 4 +- node/rest/src/lib.rs | 76 ++++++------ node/rest/src/routes.rs | 70 +++++------ node/router/messages/src/block_response.rs | 2 +- node/router/messages/src/challenge_request.rs | 2 +- .../router/messages/src/challenge_response.rs | 2 +- node/router/messages/src/ping.rs | 2 +- node/router/messages/src/puzzle_response.rs | 2 +- .../messages/src/unconfirmed_solution.rs | 2 +- .../messages/src/unconfirmed_transaction.rs | 2 +- node/router/src/helpers/cache.rs | 4 +- node/router/tests/common/mod.rs | 2 +- node/src/lib.rs | 2 +- node/src/validator/mod.rs | 4 +- node/sync/locators/src/block_locators.rs | 4 +- node/sync/src/block_sync.rs | 2 +- node/tests/common/mod.rs | 2 +- node/tests/common/node.rs | 2 +- node/tests/common/test_peer.rs | 2 +- node/tests/handshake.rs | 2 +- 63 files changed, 234 insertions(+), 234 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 47b63f2eb4..984e1e4c70 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -420,6 +420,6 @@ workflows: filters: branches: only: - - testnet3 + - mainnet jobs: - integration diff --git a/.devnet/.analytics/analytics.js b/.devnet/.analytics/analytics.js index 32fc0e0abd..30f551b6c0 100644 --- a/.devnet/.analytics/analytics.js +++ b/.devnet/.analytics/analytics.js @@ -134,7 +134,7 @@ async function main() { if (match && match[1]) { const ipAddress = match[1]; - const baseUrl = `http://${ipAddress}:3033/testnet3/block`; + const baseUrl = `http://${ipAddress}:3033/mainnet/block`; console.log(`${dimStart}IP Address: ${ipAddress}${dimEnd}`); console.log(`${dimStart}Base URL: ${baseUrl}${dimEnd}`); diff --git a/.devnet/README.md b/.devnet/README.md index 559e8984de..a6b51f69ef 100644 --- a/.devnet/README.md +++ b/.devnet/README.md @@ -10,7 +10,7 @@ Start by creating EC2 instances in the AWS console. - Custom TCP - Port 4133 - 0.0.0.0/0 - Custom TCP - Port 5000 - 0.0.0.0/0 -Be sure the give the EC2 instances a name tag, i.e. `testnet3`. +Be sure the give the EC2 instances a name tag, i.e. `devnet`. Make sure you set the correct SSH `.pem` and have the `.pem` in your `~/.ssh` directory. diff --git a/.devnet/config.sh b/.devnet/config.sh index 130e21740f..8c791ed6b2 100755 --- a/.devnet/config.sh +++ b/.devnet/config.sh @@ -1,12 +1,12 @@ #!/bin/bash # Read the EC2 instance name from the user -read -p "Enter the EC2 instance name to filter by (e.g. Name) (default: testnet3): " INSTANCE_NAME -INSTANCE_NAME="${INSTANCE_NAME:-testnet3}" +read -p "Enter the EC2 instance name to filter by (e.g. Name) (default: devnet): " INSTANCE_NAME +INSTANCE_NAME="${INSTANCE_NAME:-devnet}" # Read the PEM file path from the user or use the default in ~/.ssh -read -p "Enter the PEM file path (default: ~/.ssh/s3-testnet3.pem): " PEM_FILE -PEM_FILE="${PEM_FILE:-~/.ssh/s3-testnet3.pem}" +read -p "Enter the PEM file path (default: ~/.ssh/s3-devnet.pem): " PEM_FILE +PEM_FILE="${PEM_FILE:-~/.ssh/s3-devnet.pem}" # Use the AWS CLI to describe running EC2 instances, filter by the provided name, and store the JSON output in a variable instance_info=$(aws ec2 describe-instances \ diff --git a/.devnet/install.sh b/.devnet/install.sh index a903c83072..4c585f2761 100755 --- a/.devnet/install.sh +++ b/.devnet/install.sh @@ -1,8 +1,8 @@ #!/bin/bash -# Prompt the user for the branch to install (default is "testnet3") -read -p "Enter the branch to install (default: testnet3): " BRANCH -BRANCH=${BRANCH:-testnet3} +# Prompt the user for the branch to install (default is "mainnet") +read -p "Enter the branch to install (default: mainnet): " BRANCH +BRANCH=${BRANCH:-mainnet} # Determine the number of AWS EC2 instances by checking ~/.ssh/config NODE_ID=0 diff --git a/.devnet/reinstall.sh b/.devnet/reinstall.sh index 3db5b4f533..126fa38b1a 100755 --- a/.devnet/reinstall.sh +++ b/.devnet/reinstall.sh @@ -1,8 +1,8 @@ #!/bin/bash -# Prompt the user for the branch to install (default is "testnet3") -read -p "Enter the branch to install (default: testnet3): " BRANCH -BRANCH=${BRANCH:-testnet3} +# Prompt the user for the branch to install (default is "mainnet") +read -p "Enter the branch to install (default: mainnet): " BRANCH +BRANCH=${BRANCH:-mainnet} # Determine the number of AWS EC2 instances by checking ~/.ssh/config NODE_ID=0 diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 8ab1084ea6..85dabf229b 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,5 +5,5 @@ updates: schedule: interval: daily time: "10:00" - target-branch: "testnet3" + target-branch: "mainnet" open-pull-requests-limit: 10 diff --git a/.integration/src/lib.rs b/.integration/src/lib.rs index cddebc32cb..02e18ed396 100644 --- a/.integration/src/lib.rs +++ b/.integration/src/lib.rs @@ -23,13 +23,13 @@ mod tests { store::helpers::memory::ConsensusMemory, FromBytes, Ledger, + MainnetV0, Network, - Testnet3, }; use tracing_test::traced_test; - type CurrentNetwork = Testnet3; + type CurrentNetwork = MainnetV0; const TEST_BASE_URL: &str = "https://testnet3.blocks.aleo.org/phase3"; diff --git a/Cargo.lock b/Cargo.lock index 5a163b7100..71982e4c7a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3526,7 +3526,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "anstyle", "anyhow", @@ -3557,7 +3557,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "aleo-std", "anyhow", @@ -3587,7 +3587,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3601,7 +3601,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3612,7 +3612,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3622,7 +3622,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3632,7 +3632,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "indexmap 2.2.2", "itertools 0.11.0", @@ -3650,12 +3650,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3666,7 +3666,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3681,7 +3681,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3696,7 +3696,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3709,7 +3709,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3718,7 +3718,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3728,7 +3728,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3740,7 +3740,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3752,7 +3752,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3763,7 +3763,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3775,7 +3775,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3788,7 +3788,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "bs58", "snarkvm-console-network", @@ -3799,7 +3799,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "blake2s_simd", "smallvec", @@ -3812,7 +3812,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "aleo-std", "rayon", @@ -3823,7 +3823,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "anyhow", "indexmap 2.2.2", @@ -3846,7 +3846,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "anyhow", "bech32", @@ -3864,7 +3864,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "enum_index", "enum_index_derive", @@ -3885,7 +3885,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3900,7 +3900,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3911,7 +3911,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "snarkvm-console-network-environment", ] @@ -3919,7 +3919,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3929,7 +3929,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3940,7 +3940,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3951,7 +3951,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3962,7 +3962,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3973,7 +3973,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "rand", "rayon", @@ -3987,7 +3987,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "aleo-std", "anyhow", @@ -4004,7 +4004,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "aleo-std", "anyhow", @@ -4029,7 +4029,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "anyhow", "rand", @@ -4041,7 +4041,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4060,7 +4060,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-coinbase" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "aleo-std", "anyhow", @@ -4080,7 +4080,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "anyhow", "indexmap 2.2.2", @@ -4098,7 +4098,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -4111,7 +4111,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4124,7 +4124,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "indexmap 2.2.2", "serde_json", @@ -4136,7 +4136,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "bytes", "serde_json", @@ -4147,7 +4147,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4162,7 +4162,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "bytes", "serde_json", @@ -4175,7 +4175,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "snarkvm-console", "snarkvm-ledger-coinbase", @@ -4184,7 +4184,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "async-trait", "reqwest", @@ -4197,7 +4197,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "aleo-std-storage", "anyhow", @@ -4222,7 +4222,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4237,7 +4237,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4246,7 +4246,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "aleo-std", "anyhow", @@ -4271,7 +4271,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "aleo-std", "anyhow", @@ -4295,7 +4295,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "aleo-std", "colored", @@ -4318,7 +4318,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "indexmap 2.2.2", "paste", @@ -4332,7 +4332,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "bincode", "once_cell", @@ -4345,7 +4345,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "aleo-std", "anyhow", @@ -4366,7 +4366,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ca2efa9#ca2efa99bde3fe9c85eba0110eeff33f4fad4bde" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" dependencies = [ "proc-macro2", "quote 1.0.35", diff --git a/Cargo.toml b/Cargo.toml index c7a7f33979..b59c8cdef4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "ca2efa9" +rev = "fa5f425" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] diff --git a/account/src/lib.rs b/account/src/lib.rs index 11270fe443..684db130ed 100644 --- a/account/src/lib.rs +++ b/account/src/lib.rs @@ -162,9 +162,9 @@ impl Display for Account { #[cfg(test)] mod tests { use super::*; - use snarkvm::prelude::Testnet3; + use snarkvm::prelude::MainnetV0; - type CurrentNetwork = Testnet3; + type CurrentNetwork = MainnetV0; #[test] fn test_sign() { diff --git a/cli/src/commands/account.rs b/cli/src/commands/account.rs index 8ec15e688d..ee0cc3550e 100644 --- a/cli/src/commands/account.rs +++ b/cli/src/commands/account.rs @@ -29,7 +29,7 @@ use rayon::prelude::*; use std::io::{Read, Write}; use zeroize::Zeroize; -type Network = snarkvm::prelude::Testnet3; +type Network = snarkvm::prelude::MainnetV0; /// Commands to manage Aleo accounts. #[derive(Debug, Parser, Zeroize)] diff --git a/cli/src/commands/developer/mod.rs b/cli/src/commands/developer/mod.rs index 5eac33aad0..d5e2767742 100644 --- a/cli/src/commands/developer/mod.rs +++ b/cli/src/commands/developer/mod.rs @@ -52,7 +52,7 @@ use colored::Colorize; use std::{path::PathBuf, str::FromStr}; type CurrentAleo = snarkvm::circuit::AleoV0; -type CurrentNetwork = snarkvm::prelude::Testnet3; +type CurrentNetwork = snarkvm::prelude::MainnetV0; /// Commands to deploy and execute transactions #[derive(Debug, Parser)] @@ -121,7 +121,7 @@ impl Developer { /// Fetch the program from the given endpoint. fn fetch_program(program_id: &ProgramID, endpoint: &str) -> Result> { // Send a request to the query node. - let response = ureq::get(&format!("{endpoint}/testnet3/program/{program_id}")).call(); + let response = ureq::get(&format!("{endpoint}/mainnet/program/{program_id}")).call(); // Deserialize the program. match response { @@ -143,7 +143,7 @@ impl Developer { // Send a request to the query node. let response = - ureq::get(&format!("{endpoint}/testnet3/program/{credits}/mapping/{account_mapping}/{address}")).call(); + ureq::get(&format!("{endpoint}/mainnet/program/{credits}/mapping/{account_mapping}/{address}")).call(); // Deserialize the balance. let balance: Result>> = match response { diff --git a/cli/src/commands/developer/scan.rs b/cli/src/commands/developer/scan.rs index 69643126d4..1652fe9808 100644 --- a/cli/src/commands/developer/scan.rs +++ b/cli/src/commands/developer/scan.rs @@ -173,7 +173,7 @@ impl Scan { // Fetch the genesis block from the endpoint. let genesis_block: Block = - ureq::get(&format!("{endpoint}/testnet3/block/0")).call()?.into_json()?; + ureq::get(&format!("{endpoint}/mainnet/block/0")).call()?.into_json()?; // Determine if the endpoint is on a development network. let is_development_network = genesis_block != Block::from_bytes_le(CurrentNetwork::genesis_bytes())?; @@ -210,7 +210,7 @@ impl Scan { let request_end = request_start.saturating_add(num_blocks_to_request); // Establish the endpoint. - let blocks_endpoint = format!("{endpoint}/testnet3/blocks?start={request_start}&end={request_end}"); + let blocks_endpoint = format!("{endpoint}/mainnet/blocks?start={request_start}&end={request_end}"); // Fetch blocks let blocks: Vec> = ureq::get(&blocks_endpoint).call()?.into_json()?; @@ -332,7 +332,7 @@ impl Scan { Record::>::serial_number(private_key, commitment)?; // Establish the endpoint. - let endpoint = format!("{endpoint}/testnet3/find/transitionID/{serial_number}"); + let endpoint = format!("{endpoint}/mainnet/find/transitionID/{serial_number}"); // Check if the record is spent. match ureq::get(&endpoint).call() { @@ -357,9 +357,9 @@ impl Scan { #[cfg(test)] mod tests { use super::*; - use snarkvm::prelude::{TestRng, Testnet3}; + use snarkvm::prelude::{MainnetV0, TestRng}; - type CurrentNetwork = Testnet3; + type CurrentNetwork = MainnetV0; #[test] fn test_parse_account() { diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index fdaec4ed58..a6d30e99c3 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -19,7 +19,7 @@ use snarkvm::{ console::{ account::{Address, PrivateKey}, algorithms::Hash, - network::{Network, Testnet3}, + network::{MainnetV0, Network}, }, ledger::{ block::Block, @@ -142,7 +142,7 @@ impl Start { match cli.network { 3 => { // Parse the node from the configurations. - let node = cli.parse_node::().await.expect("Failed to parse the node"); + let node = cli.parse_node::().await.expect("Failed to parse the node"); // If the display is enabled, render the display. if !cli.nodisplay { // Initialize the display. @@ -537,18 +537,18 @@ fn load_or_compute_genesis( preimage.extend(&to_bytes_le![public_balances.iter().collect::>()]?); // Input the parameters' metadata. - preimage.extend(snarkvm::parameters::testnet3::BondPublicVerifier::METADATA.as_bytes()); - preimage.extend(snarkvm::parameters::testnet3::UnbondPublicVerifier::METADATA.as_bytes()); - preimage.extend(snarkvm::parameters::testnet3::UnbondDelegatorAsValidatorVerifier::METADATA.as_bytes()); - preimage.extend(snarkvm::parameters::testnet3::ClaimUnbondPublicVerifier::METADATA.as_bytes()); - preimage.extend(snarkvm::parameters::testnet3::SetValidatorStateVerifier::METADATA.as_bytes()); - preimage.extend(snarkvm::parameters::testnet3::TransferPrivateVerifier::METADATA.as_bytes()); - preimage.extend(snarkvm::parameters::testnet3::TransferPublicVerifier::METADATA.as_bytes()); - preimage.extend(snarkvm::parameters::testnet3::TransferPrivateToPublicVerifier::METADATA.as_bytes()); - preimage.extend(snarkvm::parameters::testnet3::TransferPublicToPrivateVerifier::METADATA.as_bytes()); - preimage.extend(snarkvm::parameters::testnet3::FeePrivateVerifier::METADATA.as_bytes()); - preimage.extend(snarkvm::parameters::testnet3::FeePublicVerifier::METADATA.as_bytes()); - preimage.extend(snarkvm::parameters::testnet3::InclusionVerifier::METADATA.as_bytes()); + preimage.extend(snarkvm::parameters::mainnet::BondPublicVerifier::METADATA.as_bytes()); + preimage.extend(snarkvm::parameters::mainnet::UnbondPublicVerifier::METADATA.as_bytes()); + preimage.extend(snarkvm::parameters::mainnet::UnbondDelegatorAsValidatorVerifier::METADATA.as_bytes()); + preimage.extend(snarkvm::parameters::mainnet::ClaimUnbondPublicVerifier::METADATA.as_bytes()); + preimage.extend(snarkvm::parameters::mainnet::SetValidatorStateVerifier::METADATA.as_bytes()); + preimage.extend(snarkvm::parameters::mainnet::TransferPrivateVerifier::METADATA.as_bytes()); + preimage.extend(snarkvm::parameters::mainnet::TransferPublicVerifier::METADATA.as_bytes()); + preimage.extend(snarkvm::parameters::mainnet::TransferPrivateToPublicVerifier::METADATA.as_bytes()); + preimage.extend(snarkvm::parameters::mainnet::TransferPublicToPrivateVerifier::METADATA.as_bytes()); + preimage.extend(snarkvm::parameters::mainnet::FeePrivateVerifier::METADATA.as_bytes()); + preimage.extend(snarkvm::parameters::mainnet::FeePublicVerifier::METADATA.as_bytes()); + preimage.extend(snarkvm::parameters::mainnet::InclusionVerifier::METADATA.as_bytes()); // Initialize the hasher. let hasher = snarkvm::console::algorithms::BHP256::::setup("aleo.dev.block")?; @@ -589,9 +589,9 @@ fn load_or_compute_genesis( mod tests { use super::*; use crate::commands::{Command, CLI}; - use snarkvm::prelude::Testnet3; + use snarkvm::prelude::MainnetV0; - type CurrentNetwork = Testnet3; + type CurrentNetwork = MainnetV0; #[test] fn test_parse_trusted_peers() { diff --git a/node/bft/events/src/batch_certified.rs b/node/bft/events/src/batch_certified.rs index 615a200c28..03898af68f 100644 --- a/node/bft/events/src/batch_certified.rs +++ b/node/bft/events/src/batch_certified.rs @@ -65,7 +65,7 @@ pub mod prop_tests { use proptest::prelude::{BoxedStrategy, Strategy}; use test_strategy::proptest; - type CurrentNetwork = snarkvm::prelude::Testnet3; + type CurrentNetwork = snarkvm::prelude::MainnetV0; pub fn any_batch_certified() -> BoxedStrategy> { any_batch_certificate().prop_map(BatchCertified::from).boxed() diff --git a/node/bft/events/src/batch_propose.rs b/node/bft/events/src/batch_propose.rs index 54b48d6905..a1c180247e 100644 --- a/node/bft/events/src/batch_propose.rs +++ b/node/bft/events/src/batch_propose.rs @@ -72,7 +72,7 @@ pub mod prop_tests { use proptest::prelude::{any, BoxedStrategy, Strategy}; use test_strategy::proptest; - type CurrentNetwork = snarkvm::prelude::Testnet3; + type CurrentNetwork = snarkvm::prelude::MainnetV0; pub fn any_batch_propose() -> BoxedStrategy> { any::() diff --git a/node/bft/events/src/batch_signature.rs b/node/bft/events/src/batch_signature.rs index 0785c96a7f..c6ab199424 100644 --- a/node/bft/events/src/batch_signature.rs +++ b/node/bft/events/src/batch_signature.rs @@ -65,7 +65,7 @@ pub mod prop_tests { use proptest::prelude::{BoxedStrategy, Strategy}; use test_strategy::proptest; - type CurrentNetwork = snarkvm::prelude::Testnet3; + type CurrentNetwork = snarkvm::prelude::MainnetV0; pub fn any_batch_signature() -> BoxedStrategy> { (any_field(), any_signature()) diff --git a/node/bft/events/src/block_response.rs b/node/bft/events/src/block_response.rs index 15e1db2254..1ca7ab86ef 100644 --- a/node/bft/events/src/block_response.rs +++ b/node/bft/events/src/block_response.rs @@ -148,7 +148,7 @@ pub mod prop_tests { }; use test_strategy::proptest; - type CurrentNetwork = snarkvm::prelude::Testnet3; + type CurrentNetwork = snarkvm::prelude::MainnetV0; pub fn any_block() -> BoxedStrategy> { any::().prop_map(|seed| sample_genesis_block(&mut TestRng::fixed(seed))).boxed() diff --git a/node/bft/events/src/certificate_request.rs b/node/bft/events/src/certificate_request.rs index 9190186f65..525112fd7f 100644 --- a/node/bft/events/src/certificate_request.rs +++ b/node/bft/events/src/certificate_request.rs @@ -68,7 +68,7 @@ pub mod prop_tests { use proptest::prelude::{any, BoxedStrategy, Strategy}; use test_strategy::proptest; - type CurrentNetwork = snarkvm::prelude::Testnet3; + type CurrentNetwork = snarkvm::prelude::MainnetV0; pub fn any_field() -> BoxedStrategy> { any::().prop_map(|_| Field::rand(&mut TestRng::default())).boxed() diff --git a/node/bft/events/src/certificate_response.rs b/node/bft/events/src/certificate_response.rs index 4b14e17ecf..d81f28f1bc 100644 --- a/node/bft/events/src/certificate_response.rs +++ b/node/bft/events/src/certificate_response.rs @@ -80,7 +80,7 @@ pub mod prop_tests { }; use test_strategy::proptest; - type CurrentNetwork = snarkvm::prelude::Testnet3; + type CurrentNetwork = snarkvm::prelude::MainnetV0; pub fn any_batch_header(committee: &CommitteeContext) -> BoxedStrategy> { (Just(committee.clone()), any::(), vec(any_transmission(), 0..16)) diff --git a/node/bft/events/src/challenge_request.rs b/node/bft/events/src/challenge_request.rs index 2ce3236bec..30e7321e1b 100644 --- a/node/bft/events/src/challenge_request.rs +++ b/node/bft/events/src/challenge_request.rs @@ -70,7 +70,7 @@ pub mod prop_tests { use proptest::prelude::{any, BoxedStrategy, Strategy}; use test_strategy::proptest; - type CurrentNetwork = snarkvm::prelude::Testnet3; + type CurrentNetwork = snarkvm::prelude::MainnetV0; pub fn any_valid_address() -> BoxedStrategy> { any::().prop_map(|seed| Address::rand(&mut TestRng::fixed(seed))).boxed() diff --git a/node/bft/events/src/challenge_response.rs b/node/bft/events/src/challenge_response.rs index aad59f760f..c75953c4ec 100644 --- a/node/bft/events/src/challenge_response.rs +++ b/node/bft/events/src/challenge_response.rs @@ -59,7 +59,7 @@ pub mod prop_tests { use proptest::prelude::{any, BoxedStrategy, Strategy}; use test_strategy::proptest; - type CurrentNetwork = snarkvm::prelude::Testnet3; + type CurrentNetwork = snarkvm::prelude::MainnetV0; pub fn any_signature() -> BoxedStrategy> { (0..64) diff --git a/node/bft/events/src/helpers/codec.rs b/node/bft/events/src/helpers/codec.rs index 1de8bcf694..0d0c273d18 100644 --- a/node/bft/events/src/helpers/codec.rs +++ b/node/bft/events/src/helpers/codec.rs @@ -335,7 +335,7 @@ mod tests { use snow::{params::NoiseParams, Builder}; use test_strategy::proptest; - type CurrentNetwork = snarkvm::prelude::Testnet3; + type CurrentNetwork = snarkvm::prelude::MainnetV0; fn handshake_xx() -> (NoiseCodec, NoiseCodec) { let params: NoiseParams = NOISE_HANDSHAKE_TYPE.parse().unwrap(); diff --git a/node/bft/events/src/lib.rs b/node/bft/events/src/lib.rs index c3a1833d07..33ba85c4a0 100644 --- a/node/bft/events/src/lib.rs +++ b/node/bft/events/src/lib.rs @@ -231,7 +231,7 @@ mod tests { use crate::Event; use bytes::{Buf, BufMut, BytesMut}; use snarkvm::console::prelude::{FromBytes, ToBytes}; - type CurrentNetwork = snarkvm::prelude::Testnet3; + type CurrentNetwork = snarkvm::prelude::MainnetV0; #[test] fn deserializing_invalid_data_panics() { @@ -275,7 +275,7 @@ pub mod prop_tests { }; use test_strategy::proptest; - type CurrentNetwork = snarkvm::prelude::Testnet3; + type CurrentNetwork = snarkvm::prelude::MainnetV0; /// Returns the current UTC epoch timestamp. pub fn now() -> i64 { diff --git a/node/bft/events/src/primary_ping.rs b/node/bft/events/src/primary_ping.rs index fca808bda8..23dd85a926 100644 --- a/node/bft/events/src/primary_ping.rs +++ b/node/bft/events/src/primary_ping.rs @@ -84,7 +84,7 @@ pub mod prop_tests { use proptest::prelude::{any, BoxedStrategy, Strategy}; use test_strategy::proptest; - type CurrentNetwork = snarkvm::prelude::Testnet3; + type CurrentNetwork = snarkvm::prelude::MainnetV0; pub fn any_block_locators() -> BoxedStrategy> { any::().prop_map(sample_block_locators).boxed() diff --git a/node/bft/events/src/transmission_request.rs b/node/bft/events/src/transmission_request.rs index 7b1ec442cd..ec59c764c4 100644 --- a/node/bft/events/src/transmission_request.rs +++ b/node/bft/events/src/transmission_request.rs @@ -74,7 +74,7 @@ pub mod prop_tests { }; use test_strategy::proptest; - type CurrentNetwork = snarkvm::prelude::Testnet3; + type CurrentNetwork = snarkvm::prelude::MainnetV0; fn any_transmission_id() -> BoxedStrategy> { prop_oneof![ diff --git a/node/bft/events/src/transmission_response.rs b/node/bft/events/src/transmission_response.rs index c08f729a3f..45c55a7edc 100644 --- a/node/bft/events/src/transmission_response.rs +++ b/node/bft/events/src/transmission_response.rs @@ -78,7 +78,7 @@ pub mod prop_tests { }; use test_strategy::proptest; - type CurrentNetwork = snarkvm::prelude::Testnet3; + type CurrentNetwork = snarkvm::prelude::MainnetV0; pub fn any_transmission() -> BoxedStrategy<(TransmissionID, Transmission)> { prop_oneof![ diff --git a/node/bft/events/src/validators_response.rs b/node/bft/events/src/validators_response.rs index 2299763060..f7dfeaad14 100644 --- a/node/bft/events/src/validators_response.rs +++ b/node/bft/events/src/validators_response.rs @@ -72,7 +72,7 @@ pub mod prop_tests { use std::net::{IpAddr, SocketAddr}; use test_strategy::proptest; - type CurrentNetwork = snarkvm::prelude::Testnet3; + type CurrentNetwork = snarkvm::prelude::MainnetV0; pub fn any_valid_socket_addr() -> BoxedStrategy { any::<(IpAddr, u16)>().prop_map(|(ip_addr, port)| SocketAddr::new(ip_addr, port)).boxed() diff --git a/node/bft/events/src/worker_ping.rs b/node/bft/events/src/worker_ping.rs index 98a7f3ad95..1bb578d0f0 100644 --- a/node/bft/events/src/worker_ping.rs +++ b/node/bft/events/src/worker_ping.rs @@ -74,7 +74,7 @@ pub mod prop_tests { }; use test_strategy::proptest; - type CurrentNetwork = snarkvm::prelude::Testnet3; + type CurrentNetwork = snarkvm::prelude::MainnetV0; pub fn any_worker_ping() -> BoxedStrategy> { hash_set(any_transmission_id(), 1..16).prop_map(|ids| WorkerPing::new(ids.into_iter().collect())).boxed() diff --git a/node/bft/examples/simple_node.rs b/node/bft/examples/simple_node.rs index e15208beb7..a7328c877e 100644 --- a/node/bft/examples/simple_node.rs +++ b/node/bft/examples/simple_node.rs @@ -54,7 +54,7 @@ use tracing_subscriber::{ util::SubscriberInitExt, }; -type CurrentNetwork = snarkvm::prelude::Testnet3; +type CurrentNetwork = snarkvm::prelude::MainnetV0; /**************************************************************************************************/ diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index e333772881..7affd30b6a 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -858,7 +858,7 @@ mod tests { use indexmap::IndexSet; use std::sync::{atomic::Ordering, Arc}; - type CurrentNetwork = snarkvm::console::network::Testnet3; + type CurrentNetwork = snarkvm::console::network::MainnetV0; /// Samples a new test instance, with an optional committee round and the given maximum GC rounds. fn sample_test_instance( diff --git a/node/bft/src/gateway.rs b/node/bft/src/gateway.rs index 0f9b87bbbd..71562ed068 100644 --- a/node/bft/src/gateway.rs +++ b/node/bft/src/gateway.rs @@ -1345,7 +1345,7 @@ mod prop_tests { prop_tests::{CommitteeContext, ValidatorSet}, Committee, }, - prelude::{PrivateKey, Testnet3}, + prelude::{MainnetV0, PrivateKey}, }; use indexmap::IndexMap; @@ -1360,7 +1360,7 @@ mod prop_tests { }; use test_strategy::proptest; - type CurrentNetwork = Testnet3; + type CurrentNetwork = MainnetV0; impl Debug for Gateway { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { diff --git a/node/bft/src/helpers/cache.rs b/node/bft/src/helpers/cache.rs index d3b7b4504f..7e6bafc0a9 100644 --- a/node/bft/src/helpers/cache.rs +++ b/node/bft/src/helpers/cache.rs @@ -191,11 +191,11 @@ impl Cache { #[cfg(test)] mod tests { use super::*; - use snarkvm::prelude::Testnet3; + use snarkvm::prelude::MainnetV0; use std::{net::Ipv4Addr, thread, time::Duration}; - type CurrentNetwork = Testnet3; + type CurrentNetwork = MainnetV0; trait Input { fn input() -> Self; diff --git a/node/bft/src/helpers/dag.rs b/node/bft/src/helpers/dag.rs index a97b31689a..2d64ded988 100644 --- a/node/bft/src/helpers/dag.rs +++ b/node/bft/src/helpers/dag.rs @@ -152,13 +152,13 @@ pub(crate) mod test_helpers { mod tests { use super::*; use snarkvm::{ - prelude::{narwhal::batch_certificate::test_helpers::sample_batch_certificate_for_round, Testnet3}, + prelude::{narwhal::batch_certificate::test_helpers::sample_batch_certificate_for_round, MainnetV0}, utilities::TestRng, }; #[test] fn test_dag_empty() { - let dag = DAG::::new(); + let dag = DAG::::new(); assert_eq!(dag.get_certificates_for_round(0), None); assert_eq!(dag.last_committed_round(), 0); @@ -167,7 +167,7 @@ mod tests { #[test] fn test_dag_insert() { let rng = &mut TestRng::default(); - let mut dag = DAG::::new(); + let mut dag = DAG::::new(); const ROUND: u64 = 2; @@ -187,7 +187,7 @@ mod tests { #[test] fn test_dag_commit() { let rng = &mut TestRng::default(); - let mut dag = DAG::::new(); + let mut dag = DAG::::new(); // Sample a certificate for round 2 and 3 with the same author. let certificate_2 = sample_batch_certificate_for_round(2, &mut TestRng::fixed(123456789)); @@ -234,7 +234,7 @@ mod tests { #[test] fn test_is_recently_committed() { - let mut dag = DAG::::new(); + let mut dag = DAG::::new(); // Sample a certificate for round 2, 3, and 4 with the same author. let certificate_2 = sample_batch_certificate_for_round(2, &mut TestRng::fixed(123456789)); diff --git a/node/bft/src/helpers/partition.rs b/node/bft/src/helpers/partition.rs index 4281e749f3..e668eb8c35 100644 --- a/node/bft/src/helpers/partition.rs +++ b/node/bft/src/helpers/partition.rs @@ -78,7 +78,7 @@ mod tests { use super::*; use snarkvm::prelude::coinbase::PuzzleCommitment; - type CurrentNetwork = snarkvm::prelude::Testnet3; + type CurrentNetwork = snarkvm::prelude::MainnetV0; #[test] fn test_assign_to_worker() { diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index 7ffbda469b..033d59408b 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -114,7 +114,7 @@ mod tests { prelude::{Rng, TestRng}, }; - type CurrentNetwork = snarkvm::prelude::Testnet3; + type CurrentNetwork = snarkvm::prelude::MainnetV0; #[test] fn test_pending() { diff --git a/node/bft/src/helpers/ready.rs b/node/bft/src/helpers/ready.rs index 09bff73dab..70ad087224 100644 --- a/node/bft/src/helpers/ready.rs +++ b/node/bft/src/helpers/ready.rs @@ -135,7 +135,7 @@ mod tests { use ::bytes::Bytes; - type CurrentNetwork = snarkvm::prelude::Testnet3; + type CurrentNetwork = snarkvm::prelude::MainnetV0; #[test] fn test_ready() { diff --git a/node/bft/src/helpers/resolver.rs b/node/bft/src/helpers/resolver.rs index 89a98b3c87..fa0d1d53b2 100644 --- a/node/bft/src/helpers/resolver.rs +++ b/node/bft/src/helpers/resolver.rs @@ -95,7 +95,7 @@ mod tests { use super::*; use snarkvm::{prelude::Rng, utilities::TestRng}; - type CurrentNetwork = snarkvm::prelude::Testnet3; + type CurrentNetwork = snarkvm::prelude::MainnetV0; #[test] fn test_resolver() { diff --git a/node/bft/src/helpers/storage.rs b/node/bft/src/helpers/storage.rs index 329297282e..e1ea607805 100644 --- a/node/bft/src/helpers/storage.rs +++ b/node/bft/src/helpers/storage.rs @@ -754,7 +754,7 @@ mod tests { use ::bytes::Bytes; use indexmap::indexset; - type CurrentNetwork = snarkvm::prelude::Testnet3; + type CurrentNetwork = snarkvm::prelude::MainnetV0; /// Asserts that the storage matches the expected layout. pub fn assert_storage( @@ -968,7 +968,7 @@ pub mod prop_tests { use std::fmt::Debug; use test_strategy::proptest; - type CurrentNetwork = snarkvm::prelude::Testnet3; + type CurrentNetwork = snarkvm::prelude::MainnetV0; impl Arbitrary for Storage { type Parameters = CommitteeContext; diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 44e26ef814..cf9ef53a50 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -1402,7 +1402,7 @@ mod tests { use indexmap::IndexSet; use rand::RngCore; - type CurrentNetwork = snarkvm::prelude::Testnet3; + type CurrentNetwork = snarkvm::prelude::MainnetV0; // Returns a primary and a list of accounts in the configured committee. async fn primary_without_handlers( diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index c061f7c0d9..7dc0bfc1b8 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -463,7 +463,7 @@ mod tests { use mockall::mock; use std::{io, ops::Range}; - type CurrentNetwork = snarkvm::prelude::Testnet3; + type CurrentNetwork = snarkvm::prelude::MainnetV0; mock! { Gateway {} @@ -753,7 +753,7 @@ mod prop_tests { use test_strategy::proptest; - type CurrentNetwork = snarkvm::prelude::Testnet3; + type CurrentNetwork = snarkvm::prelude::MainnetV0; // Initializes a new test committee. fn new_test_committee(n: u16) -> Committee { diff --git a/node/bft/tests/common/mod.rs b/node/bft/tests/common/mod.rs index e81ccc3d74..2505f6add7 100644 --- a/node/bft/tests/common/mod.rs +++ b/node/bft/tests/common/mod.rs @@ -15,6 +15,6 @@ pub mod primary; pub mod utils; -pub type CurrentNetwork = snarkvm::prelude::Testnet3; +pub type CurrentNetwork = snarkvm::prelude::MainnetV0; pub type TranslucentLedgerService = snarkos_node_bft_ledger_service::TranslucentLedgerService; diff --git a/node/cdn/src/blocks.rs b/node/cdn/src/blocks.rs index 8373101579..2de4c63812 100644 --- a/node/cdn/src/blocks.rs +++ b/node/cdn/src/blocks.rs @@ -438,12 +438,12 @@ mod tests { blocks::{cdn_get, cdn_height, log_progress, BLOCKS_PER_FILE}, load_blocks, }; - use snarkvm::prelude::{block::Block, Testnet3}; + use snarkvm::prelude::{block::Block, MainnetV0}; use parking_lot::RwLock; use std::{sync::Arc, time::Instant}; - type CurrentNetwork = Testnet3; + type CurrentNetwork = MainnetV0; const TEST_BASE_URL: &str = "https://s3.us-west-1.amazonaws.com/testnet3.blocks/phase3"; diff --git a/node/rest/src/lib.rs b/node/rest/src/lib.rs index f076023c19..360dc5fd4e 100644 --- a/node/rest/src/lib.rs +++ b/node/rest/src/lib.rs @@ -121,67 +121,67 @@ impl, R: Routing> Rest { axum::Router::new() // All the endpoints before the call to `route_layer` are protected with JWT auth. - .route("/testnet3/node/address", get(Self::get_node_address)) + .route("/mainnet/node/address", get(Self::get_node_address)) .route_layer(middleware::from_fn(auth_middleware)) // ----------------- DEPRECATED ROUTES ----------------- // The following `GET ../latest/..` routes will be removed before mainnet. // Please refer to the recommended routes for each endpoint: - // Deprecated: use `/testnet3/block/height/latest` instead. - .route("/testnet3/latest/height", get(Self::latest_height)) - // Deprecated: use `/testnet3/block/hash/latest` instead. - .route("/testnet3/latest/hash", get(Self::latest_hash)) - // Deprecated: use `/testnet3/latest/block/height` instead. - .route("/testnet3/latest/block", get(Self::latest_block)) - // Deprecated: use `/testnet3/stateRoot/latest` instead. - .route("/testnet3/latest/stateRoot", get(Self::latest_state_root)) - // Deprecated: use `/testnet3/committee/latest` instead. - .route("/testnet3/latest/committee", get(Self::latest_committee)) + // Deprecated: use `/mainnet/block/height/latest` instead. + .route("/mainnet/latest/height", get(Self::latest_height)) + // Deprecated: use `/mainnet/block/hash/latest` instead. + .route("/mainnet/latest/hash", get(Self::latest_hash)) + // Deprecated: use `/mainnet/latest/block/height` instead. + .route("/mainnet/latest/block", get(Self::latest_block)) + // Deprecated: use `/mainnet/stateRoot/latest` instead. + .route("/mainnet/latest/stateRoot", get(Self::latest_state_root)) + // Deprecated: use `/mainnet/committee/latest` instead. + .route("/mainnet/latest/committee", get(Self::latest_committee)) // ------------------------------------------------------ // GET ../block/.. - .route("/testnet3/block/height/latest", get(Self::get_block_height_latest)) - .route("/testnet3/block/hash/latest", get(Self::get_block_hash_latest)) - .route("/testnet3/block/latest", get(Self::get_block_latest)) - .route("/testnet3/block/:height_or_hash", get(Self::get_block)) + .route("/mainnet/block/height/latest", get(Self::get_block_height_latest)) + .route("/mainnet/block/hash/latest", get(Self::get_block_hash_latest)) + .route("/mainnet/block/latest", get(Self::get_block_latest)) + .route("/mainnet/block/:height_or_hash", get(Self::get_block)) // The path param here is actually only the height, but the name must match the route // above, otherwise there'll be a conflict at runtime. - .route("/testnet3/block/:height_or_hash/transactions", get(Self::get_block_transactions)) + .route("/mainnet/block/:height_or_hash/transactions", get(Self::get_block_transactions)) // GET and POST ../transaction/.. - .route("/testnet3/transaction/:id", get(Self::get_transaction)) - .route("/testnet3/transaction/confirmed/:id", get(Self::get_confirmed_transaction)) - .route("/testnet3/transaction/broadcast", post(Self::transaction_broadcast)) + .route("/mainnet/transaction/:id", get(Self::get_transaction)) + .route("/mainnet/transaction/confirmed/:id", get(Self::get_confirmed_transaction)) + .route("/mainnet/transaction/broadcast", post(Self::transaction_broadcast)) // POST ../solution/broadcast - .route("/testnet3/solution/broadcast", post(Self::solution_broadcast)) + .route("/mainnet/solution/broadcast", post(Self::solution_broadcast)) // GET ../find/.. - .route("/testnet3/find/blockHash/:tx_id", get(Self::find_block_hash)) - .route("/testnet3/find/transactionID/deployment/:program_id", get(Self::find_transaction_id_from_program_id)) - .route("/testnet3/find/transactionID/:transition_id", get(Self::find_transaction_id_from_transition_id)) - .route("/testnet3/find/transitionID/:input_or_output_id", get(Self::find_transition_id)) + .route("/mainnet/find/blockHash/:tx_id", get(Self::find_block_hash)) + .route("/mainnet/find/transactionID/deployment/:program_id", get(Self::find_transaction_id_from_program_id)) + .route("/mainnet/find/transactionID/:transition_id", get(Self::find_transaction_id_from_transition_id)) + .route("/mainnet/find/transitionID/:input_or_output_id", get(Self::find_transition_id)) // GET ../peers/.. - .route("/testnet3/peers/count", get(Self::get_peers_count)) - .route("/testnet3/peers/all", get(Self::get_peers_all)) - .route("/testnet3/peers/all/metrics", get(Self::get_peers_all_metrics)) + .route("/mainnet/peers/count", get(Self::get_peers_count)) + .route("/mainnet/peers/all", get(Self::get_peers_all)) + .route("/mainnet/peers/all/metrics", get(Self::get_peers_all_metrics)) // GET ../program/.. - .route("/testnet3/program/:id", get(Self::get_program)) - .route("/testnet3/program/:id/mappings", get(Self::get_mapping_names)) - .route("/testnet3/program/:id/mapping/:name/:key", get(Self::get_mapping_value)) + .route("/mainnet/program/:id", get(Self::get_program)) + .route("/mainnet/program/:id/mappings", get(Self::get_mapping_names)) + .route("/mainnet/program/:id/mapping/:name/:key", get(Self::get_mapping_value)) // GET misc endpoints. - .route("/testnet3/blocks", get(Self::get_blocks)) - .route("/testnet3/height/:hash", get(Self::get_height)) - .route("/testnet3/memoryPool/transmissions", get(Self::get_memory_pool_transmissions)) - .route("/testnet3/memoryPool/solutions", get(Self::get_memory_pool_solutions)) - .route("/testnet3/memoryPool/transactions", get(Self::get_memory_pool_transactions)) - .route("/testnet3/statePath/:commitment", get(Self::get_state_path_for_commitment)) - .route("/testnet3/stateRoot/latest", get(Self::get_state_root_latest)) - .route("/testnet3/committee/latest", get(Self::get_committee_latest)) + .route("/mainnet/blocks", get(Self::get_blocks)) + .route("/mainnet/height/:hash", get(Self::get_height)) + .route("/mainnet/memoryPool/transmissions", get(Self::get_memory_pool_transmissions)) + .route("/mainnet/memoryPool/solutions", get(Self::get_memory_pool_solutions)) + .route("/mainnet/memoryPool/transactions", get(Self::get_memory_pool_transactions)) + .route("/mainnet/statePath/:commitment", get(Self::get_state_path_for_commitment)) + .route("/mainnet/stateRoot/latest", get(Self::get_state_root_latest)) + .route("/mainnet/committee/latest", get(Self::get_committee_latest)) // Pass in `Rest` to make things convenient. .with_state(self.clone()) diff --git a/node/rest/src/routes.rs b/node/rest/src/routes.rs index ed28b52496..b8a5f4c3bd 100644 --- a/node/rest/src/routes.rs +++ b/node/rest/src/routes.rs @@ -45,54 +45,54 @@ impl, R: Routing> Rest { // Please use the recommended alternatives when implementing new features or refactoring. // Deprecated: Use `get_block_height_latest` instead. - // GET /testnet3/latest/height + // GET /mainnet/latest/height pub(crate) async fn latest_height(State(rest): State) -> ErasedJson { ErasedJson::pretty(rest.ledger.latest_height()) } // Deprecated: Use `get_block_hash_latest` instead. - // GET /testnet3/latest/hash + // GET /mainnet/latest/hash pub(crate) async fn latest_hash(State(rest): State) -> ErasedJson { ErasedJson::pretty(rest.ledger.latest_hash()) } // Deprecated: Use `get_block_latest` instead. - // GET /testnet3/latest/block + // GET /mainnet/latest/block pub(crate) async fn latest_block(State(rest): State) -> ErasedJson { ErasedJson::pretty(rest.ledger.latest_block()) } // Deprecated: Use `get_state_root_latest` instead. - // GET /testnet3/latest/stateRoot + // GET /mainnet/latest/stateRoot pub(crate) async fn latest_state_root(State(rest): State) -> ErasedJson { ErasedJson::pretty(rest.ledger.latest_state_root()) } // Deprecated: Use `get_committee_latest` instead. - // GET /testnet3/latest/committee + // GET /mainnet/latest/committee pub(crate) async fn latest_committee(State(rest): State) -> Result { Ok(ErasedJson::pretty(rest.ledger.latest_committee()?)) } // --------------------------------------------------------- - // GET /testnet3/block/height/latest + // GET /mainnet/block/height/latest pub(crate) async fn get_block_height_latest(State(rest): State) -> ErasedJson { ErasedJson::pretty(rest.ledger.latest_height()) } - // GET /testnet3/block/hash/latest + // GET /mainnet/block/hash/latest pub(crate) async fn get_block_hash_latest(State(rest): State) -> ErasedJson { ErasedJson::pretty(rest.ledger.latest_hash()) } - // GET /testnet3/block/latest + // GET /mainnet/block/latest pub(crate) async fn get_block_latest(State(rest): State) -> ErasedJson { ErasedJson::pretty(rest.ledger.latest_block()) } - // GET /testnet3/block/{height} - // GET /testnet3/block/{blockHash} + // GET /mainnet/block/{height} + // GET /mainnet/block/{blockHash} pub(crate) async fn get_block( State(rest): State, Path(height_or_hash): Path, @@ -112,7 +112,7 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(block)) } - // GET /testnet3/blocks?start={start_height}&end={end_height} + // GET /mainnet/blocks?start={start_height}&end={end_height} pub(crate) async fn get_blocks( State(rest): State, Query(block_range): Query, @@ -142,7 +142,7 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(blocks)) } - // GET /testnet3/height/{blockHash} + // GET /mainnet/height/{blockHash} pub(crate) async fn get_height( State(rest): State, Path(hash): Path, @@ -150,7 +150,7 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(rest.ledger.get_height(&hash)?)) } - // GET /testnet3/block/{height}/transactions + // GET /mainnet/block/{height}/transactions pub(crate) async fn get_block_transactions( State(rest): State, Path(height): Path, @@ -158,7 +158,7 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(rest.ledger.get_transactions(height)?)) } - // GET /testnet3/transaction/{transactionID} + // GET /mainnet/transaction/{transactionID} pub(crate) async fn get_transaction( State(rest): State, Path(tx_id): Path, @@ -166,7 +166,7 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(rest.ledger.get_transaction(tx_id)?)) } - // GET /testnet3/transaction/confirmed/{transactionID} + // GET /mainnet/transaction/confirmed/{transactionID} pub(crate) async fn get_confirmed_transaction( State(rest): State, Path(tx_id): Path, @@ -174,7 +174,7 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(rest.ledger.get_confirmed_transaction(tx_id)?)) } - // GET /testnet3/memoryPool/transmissions + // GET /mainnet/memoryPool/transmissions pub(crate) async fn get_memory_pool_transmissions(State(rest): State) -> Result { match rest.consensus { Some(consensus) => { @@ -184,7 +184,7 @@ impl, R: Routing> Rest { } } - // GET /testnet3/memoryPool/solutions + // GET /mainnet/memoryPool/solutions pub(crate) async fn get_memory_pool_solutions(State(rest): State) -> Result { match rest.consensus { Some(consensus) => Ok(ErasedJson::pretty(consensus.unconfirmed_solutions().collect::>())), @@ -192,7 +192,7 @@ impl, R: Routing> Rest { } } - // GET /testnet3/memoryPool/transactions + // GET /mainnet/memoryPool/transactions pub(crate) async fn get_memory_pool_transactions(State(rest): State) -> Result { match rest.consensus { Some(consensus) => Ok(ErasedJson::pretty(consensus.unconfirmed_transactions().collect::>())), @@ -200,7 +200,7 @@ impl, R: Routing> Rest { } } - // GET /testnet3/program/{programID} + // GET /mainnet/program/{programID} pub(crate) async fn get_program( State(rest): State, Path(id): Path>, @@ -208,7 +208,7 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(rest.ledger.get_program(id)?)) } - // GET /testnet3/program/{programID}/mappings + // GET /mainnet/program/{programID}/mappings pub(crate) async fn get_mapping_names( State(rest): State, Path(id): Path>, @@ -216,8 +216,8 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(rest.ledger.vm().finalize_store().get_mapping_names_confirmed(&id)?)) } - // GET /testnet3/program/{programID}/mapping/{mappingName}/{mappingKey} - // GET /testnet3/program/{programID}/mapping/{mappingName}/{mappingKey}?metadata={true} + // GET /mainnet/program/{programID}/mapping/{mappingName}/{mappingKey} + // GET /mainnet/program/{programID}/mapping/{mappingName}/{mappingKey}?metadata={true} pub(crate) async fn get_mapping_value( State(rest): State, Path((id, name, key)): Path<(ProgramID, Identifier, Plaintext)>, @@ -238,7 +238,7 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(mapping_value)) } - // GET /testnet3/statePath/{commitment} + // GET /mainnet/statePath/{commitment} pub(crate) async fn get_state_path_for_commitment( State(rest): State, Path(commitment): Path>, @@ -246,37 +246,37 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(rest.ledger.get_state_path_for_commitment(&commitment)?)) } - // GET /testnet3/stateRoot/latest + // GET /mainnet/stateRoot/latest pub(crate) async fn get_state_root_latest(State(rest): State) -> ErasedJson { ErasedJson::pretty(rest.ledger.latest_state_root()) } - // GET /testnet3/committee/latest + // GET /mainnet/committee/latest pub(crate) async fn get_committee_latest(State(rest): State) -> Result { Ok(ErasedJson::pretty(rest.ledger.latest_committee()?)) } - // GET /testnet3/peers/count + // GET /mainnet/peers/count pub(crate) async fn get_peers_count(State(rest): State) -> ErasedJson { ErasedJson::pretty(rest.routing.router().number_of_connected_peers()) } - // GET /testnet3/peers/all + // GET /mainnet/peers/all pub(crate) async fn get_peers_all(State(rest): State) -> ErasedJson { ErasedJson::pretty(rest.routing.router().connected_peers()) } - // GET /testnet3/peers/all/metrics + // GET /mainnet/peers/all/metrics pub(crate) async fn get_peers_all_metrics(State(rest): State) -> ErasedJson { ErasedJson::pretty(rest.routing.router().connected_metrics()) } - // GET /testnet3/node/address + // GET /mainnet/node/address pub(crate) async fn get_node_address(State(rest): State) -> ErasedJson { ErasedJson::pretty(rest.routing.router().address()) } - // GET /testnet3/find/blockHash/{transactionID} + // GET /mainnet/find/blockHash/{transactionID} pub(crate) async fn find_block_hash( State(rest): State, Path(tx_id): Path, @@ -284,7 +284,7 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(rest.ledger.find_block_hash(&tx_id)?)) } - // GET /testnet3/find/transactionID/deployment/{programID} + // GET /mainnet/find/transactionID/deployment/{programID} pub(crate) async fn find_transaction_id_from_program_id( State(rest): State, Path(program_id): Path>, @@ -292,7 +292,7 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(rest.ledger.find_transaction_id_from_program_id(&program_id)?)) } - // GET /testnet3/find/transactionID/{transitionID} + // GET /mainnet/find/transactionID/{transitionID} pub(crate) async fn find_transaction_id_from_transition_id( State(rest): State, Path(transition_id): Path, @@ -300,7 +300,7 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(rest.ledger.find_transaction_id_from_transition_id(&transition_id)?)) } - // GET /testnet3/find/transitionID/{inputOrOutputID} + // GET /mainnet/find/transitionID/{inputOrOutputID} pub(crate) async fn find_transition_id( State(rest): State, Path(input_or_output_id): Path>, @@ -308,7 +308,7 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(rest.ledger.find_transition_id(&input_or_output_id)?)) } - // POST /testnet3/transaction/broadcast + // POST /mainnet/transaction/broadcast pub(crate) async fn transaction_broadcast( State(rest): State, Json(tx): Json>, @@ -332,7 +332,7 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(tx_id)) } - // POST /testnet3/solution/broadcast + // POST /mainnet/solution/broadcast pub(crate) async fn solution_broadcast( State(rest): State, Json(prover_solution): Json>, diff --git a/node/router/messages/src/block_response.rs b/node/router/messages/src/block_response.rs index d7da6b93cf..75a4135dd6 100644 --- a/node/router/messages/src/block_response.rs +++ b/node/router/messages/src/block_response.rs @@ -74,7 +74,7 @@ pub mod prop_tests { }; use test_strategy::proptest; - type CurrentNetwork = snarkvm::prelude::Testnet3; + type CurrentNetwork = snarkvm::prelude::MainnetV0; pub fn any_block() -> BoxedStrategy> { any::().prop_map(|seed| sample_genesis_block(&mut TestRng::fixed(seed))).boxed() diff --git a/node/router/messages/src/challenge_request.rs b/node/router/messages/src/challenge_request.rs index b1bafedb8e..cdcc3638ff 100644 --- a/node/router/messages/src/challenge_request.rs +++ b/node/router/messages/src/challenge_request.rs @@ -76,7 +76,7 @@ pub mod prop_tests { use proptest::prelude::{any, BoxedStrategy, Strategy}; use test_strategy::proptest; - type CurrentNetwork = snarkvm::prelude::Testnet3; + type CurrentNetwork = snarkvm::prelude::MainnetV0; pub fn any_valid_address() -> BoxedStrategy> { any::().prop_map(|seed| Address::rand(&mut TestRng::fixed(seed))).boxed() diff --git a/node/router/messages/src/challenge_response.rs b/node/router/messages/src/challenge_response.rs index d51c5bb717..190001837e 100644 --- a/node/router/messages/src/challenge_response.rs +++ b/node/router/messages/src/challenge_response.rs @@ -68,7 +68,7 @@ pub mod prop_tests { use proptest::prelude::{any, BoxedStrategy, Strategy}; use test_strategy::proptest; - type CurrentNetwork = snarkvm::prelude::Testnet3; + type CurrentNetwork = snarkvm::prelude::MainnetV0; pub fn any_signature() -> BoxedStrategy> { (0..64) diff --git a/node/router/messages/src/ping.rs b/node/router/messages/src/ping.rs index bf439ec781..c0e982b6ef 100644 --- a/node/router/messages/src/ping.rs +++ b/node/router/messages/src/ping.rs @@ -111,7 +111,7 @@ pub mod prop_tests { use proptest::prelude::{any, BoxedStrategy, Strategy}; use test_strategy::proptest; - type CurrentNetwork = snarkvm::prelude::Testnet3; + type CurrentNetwork = snarkvm::prelude::MainnetV0; pub fn any_block_locators() -> BoxedStrategy> { any::().prop_map(sample_block_locators).boxed() diff --git a/node/router/messages/src/puzzle_response.rs b/node/router/messages/src/puzzle_response.rs index 1523d17cb4..dcc1aa803c 100644 --- a/node/router/messages/src/puzzle_response.rs +++ b/node/router/messages/src/puzzle_response.rs @@ -61,7 +61,7 @@ pub mod prop_tests { use proptest::prelude::{any, BoxedStrategy, Strategy}; use test_strategy::proptest; - type CurrentNetwork = snarkvm::prelude::Testnet3; + type CurrentNetwork = snarkvm::prelude::MainnetV0; pub fn any_epoch_challenge() -> BoxedStrategy> { any::() diff --git a/node/router/messages/src/unconfirmed_solution.rs b/node/router/messages/src/unconfirmed_solution.rs index eb8554a76f..43edaf948d 100644 --- a/node/router/messages/src/unconfirmed_solution.rs +++ b/node/router/messages/src/unconfirmed_solution.rs @@ -61,7 +61,7 @@ pub mod prop_tests { use proptest::prelude::{any, BoxedStrategy, Strategy}; use test_strategy::proptest; - type CurrentNetwork = snarkvm::prelude::Testnet3; + type CurrentNetwork = snarkvm::prelude::MainnetV0; pub fn any_solution_id() -> BoxedStrategy> { any::() diff --git a/node/router/messages/src/unconfirmed_transaction.rs b/node/router/messages/src/unconfirmed_transaction.rs index d6565eaeb4..ae24a9ff21 100644 --- a/node/router/messages/src/unconfirmed_transaction.rs +++ b/node/router/messages/src/unconfirmed_transaction.rs @@ -68,7 +68,7 @@ pub mod prop_tests { use proptest::prelude::{any, BoxedStrategy, Strategy}; use test_strategy::proptest; - type CurrentNetwork = snarkvm::prelude::Testnet3; + type CurrentNetwork = snarkvm::prelude::MainnetV0; pub fn any_transaction() -> BoxedStrategy> { any::() diff --git a/node/router/src/helpers/cache.rs b/node/router/src/helpers/cache.rs index 5233cfb5a3..20c958b9ae 100644 --- a/node/router/src/helpers/cache.rs +++ b/node/router/src/helpers/cache.rs @@ -260,11 +260,11 @@ impl Cache { #[cfg(test)] mod tests { use super::*; - use snarkvm::prelude::Testnet3; + use snarkvm::prelude::MainnetV0; use std::net::Ipv4Addr; - type CurrentNetwork = Testnet3; + type CurrentNetwork = MainnetV0; #[test] fn test_inbound_solution() { diff --git a/node/router/tests/common/mod.rs b/node/router/tests/common/mod.rs index 9807dc4100..c173d43772 100644 --- a/node/router/tests/common/mod.rs +++ b/node/router/tests/common/mod.rs @@ -24,7 +24,7 @@ use std::{ use snarkos_account::Account; use snarkos_node_router::{messages::NodeType, Router}; -use snarkvm::prelude::{block::Block, FromBytes, Network, Testnet3 as CurrentNetwork}; +use snarkvm::prelude::{block::Block, FromBytes, MainnetV0 as CurrentNetwork, Network}; /// A helper macro to print the TCP listening address, along with the connected and connecting peers. #[macro_export] diff --git a/node/src/lib.rs b/node/src/lib.rs index aa84031492..e2dec54367 100644 --- a/node/src/lib.rs +++ b/node/src/lib.rs @@ -249,7 +249,7 @@ pub fn notification_message() -> String { - IMPORTANT: EXPECT MULTIPLE NETWORK RESETS. - If participating, BE PREPARED TO RESET YOUR NODE AT ANY TIME. - When a reset occurs, RUN THE FOLLOWING TO RESET YOUR NODE: - - git checkout testnet3 && git pull + - git checkout mainnet && git pull - cargo install --locked --path . - snarkos clean - snarkos start --nodisplay --client diff --git a/node/src/validator/mod.rs b/node/src/validator/mod.rs index 3d9846b27f..fc0c277371 100644 --- a/node/src/validator/mod.rs +++ b/node/src/validator/mod.rs @@ -454,7 +454,7 @@ mod tests { use super::*; use snarkvm::prelude::{ store::{helpers::memory::ConsensusMemory, ConsensusStore}, - Testnet3, + MainnetV0, VM, }; @@ -463,7 +463,7 @@ mod tests { use rand_chacha::ChaChaRng; use std::str::FromStr; - type CurrentNetwork = Testnet3; + type CurrentNetwork = MainnetV0; /// Use `RUST_MIN_STACK=67108864 cargo test --release profiler --features timer` to run this test. #[ignore] diff --git a/node/sync/locators/src/block_locators.rs b/node/sync/locators/src/block_locators.rs index de85c498e9..38bfe4c479 100644 --- a/node/sync/locators/src/block_locators.rs +++ b/node/sync/locators/src/block_locators.rs @@ -311,7 +311,7 @@ pub mod test_helpers { use super::*; use snarkvm::prelude::Field; - type CurrentNetwork = snarkvm::prelude::Testnet3; + type CurrentNetwork = snarkvm::prelude::MainnetV0; /// Simulates a block locator at the given height. pub fn sample_block_locators(height: u32) -> BlockLocators { @@ -392,7 +392,7 @@ mod tests { use core::ops::Range; - type CurrentNetwork = snarkvm::prelude::Testnet3; + type CurrentNetwork = snarkvm::prelude::MainnetV0; /// Simulates block locators for a ledger within the given `heights` range. fn check_is_valid(checkpoints: IndexMap::BlockHash>, heights: Range) { diff --git a/node/sync/src/block_sync.rs b/node/sync/src/block_sync.rs index 47b90d9ac2..0bc46e10bf 100644 --- a/node/sync/src/block_sync.rs +++ b/node/sync/src/block_sync.rs @@ -891,7 +891,7 @@ mod tests { use snarkvm::ledger::committee::Committee; use std::net::{IpAddr, Ipv4Addr}; - type CurrentNetwork = snarkvm::prelude::Testnet3; + type CurrentNetwork = snarkvm::prelude::MainnetV0; /// Returns the peer IP for the sync pool. fn sample_peer_ip(id: u16) -> SocketAddr { diff --git a/node/tests/common/mod.rs b/node/tests/common/mod.rs index 71d48c4900..7e5f65f68a 100644 --- a/node/tests/common/mod.rs +++ b/node/tests/common/mod.rs @@ -18,7 +18,7 @@ pub mod test_peer; use std::{env, str::FromStr}; use snarkos_account::Account; -use snarkvm::prelude::{block::Block, FromBytes, Network, Testnet3 as CurrentNetwork}; +use snarkvm::prelude::{block::Block, FromBytes, MainnetV0 as CurrentNetwork, Network}; /// Returns a fixed account. pub fn sample_account() -> Account { diff --git a/node/tests/common/node.rs b/node/tests/common/node.rs index 7a9c0bc110..80c0262903 100644 --- a/node/tests/common/node.rs +++ b/node/tests/common/node.rs @@ -15,7 +15,7 @@ use crate::common::test_peer::sample_genesis_block; use snarkos_account::Account; use snarkos_node::{Client, Prover, Validator}; -use snarkvm::prelude::{store::helpers::memory::ConsensusMemory, Testnet3 as CurrentNetwork}; +use snarkvm::prelude::{store::helpers::memory::ConsensusMemory, MainnetV0 as CurrentNetwork}; use aleo_std::StorageMode; use std::str::FromStr; diff --git a/node/tests/common/test_peer.rs b/node/tests/common/test_peer.rs index 8d9d5e39bb..4c7cfc037a 100644 --- a/node/tests/common/test_peer.rs +++ b/node/tests/common/test_peer.rs @@ -19,7 +19,7 @@ use snarkos_node_router::{ }; use snarkvm::{ ledger::narwhal::Data, - prelude::{block::Block, error, Address, FromBytes, Network, TestRng, Testnet3 as CurrentNetwork}, + prelude::{block::Block, error, Address, FromBytes, MainnetV0 as CurrentNetwork, Network, TestRng}, }; use std::{ diff --git a/node/tests/handshake.rs b/node/tests/handshake.rs index e513ba705f..3c4c214269 100644 --- a/node/tests/handshake.rs +++ b/node/tests/handshake.rs @@ -21,7 +21,7 @@ use common::{node::*, test_peer::TestPeer}; use snarkos_node::{Client, Prover, Validator}; use snarkos_node_router::Outbound; use snarkos_node_tcp::P2P; -use snarkvm::prelude::{store::helpers::memory::ConsensusMemory, Testnet3 as CurrentNetwork}; +use snarkvm::prelude::{store::helpers::memory::ConsensusMemory, MainnetV0 as CurrentNetwork}; use pea2pea::Pea2Pea; From ea4f1bbfe1022c61aaa6e7c9342849ea4c70c6e1 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sat, 10 Feb 2024 18:07:06 -0800 Subject: [PATCH 039/551] Update rev --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index b59c8cdef4..cc6a5d99e9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "fa5f425" +rev = "62bce04" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From 7eb4a0fde91bb0c68d9b47509a75ac5ec4235b94 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sat, 10 Feb 2024 18:59:04 -0800 Subject: [PATCH 040/551] Update rev --- Cargo.lock | 116 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 2 +- 2 files changed, 59 insertions(+), 59 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 71982e4c7a..398f40ac23 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3526,7 +3526,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "anstyle", "anyhow", @@ -3557,7 +3557,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "aleo-std", "anyhow", @@ -3587,7 +3587,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3601,7 +3601,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3612,7 +3612,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3622,7 +3622,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3632,7 +3632,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "indexmap 2.2.2", "itertools 0.11.0", @@ -3650,12 +3650,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3666,7 +3666,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3681,7 +3681,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3696,7 +3696,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3709,7 +3709,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3718,7 +3718,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3728,7 +3728,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3740,7 +3740,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3752,7 +3752,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3763,7 +3763,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3775,7 +3775,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3788,7 +3788,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "bs58", "snarkvm-console-network", @@ -3799,7 +3799,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "blake2s_simd", "smallvec", @@ -3812,7 +3812,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "aleo-std", "rayon", @@ -3823,7 +3823,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "anyhow", "indexmap 2.2.2", @@ -3846,7 +3846,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "anyhow", "bech32", @@ -3864,7 +3864,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "enum_index", "enum_index_derive", @@ -3885,7 +3885,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3900,7 +3900,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3911,7 +3911,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "snarkvm-console-network-environment", ] @@ -3919,7 +3919,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3929,7 +3929,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3940,7 +3940,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3951,7 +3951,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3962,7 +3962,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3973,7 +3973,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "rand", "rayon", @@ -3987,7 +3987,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "aleo-std", "anyhow", @@ -4004,7 +4004,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "aleo-std", "anyhow", @@ -4029,7 +4029,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "anyhow", "rand", @@ -4041,7 +4041,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4060,7 +4060,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-coinbase" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "aleo-std", "anyhow", @@ -4080,7 +4080,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "anyhow", "indexmap 2.2.2", @@ -4098,7 +4098,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -4111,7 +4111,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4124,7 +4124,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "indexmap 2.2.2", "serde_json", @@ -4136,7 +4136,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "bytes", "serde_json", @@ -4147,7 +4147,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4162,7 +4162,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "bytes", "serde_json", @@ -4175,7 +4175,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "snarkvm-console", "snarkvm-ledger-coinbase", @@ -4184,7 +4184,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "async-trait", "reqwest", @@ -4197,7 +4197,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "aleo-std-storage", "anyhow", @@ -4222,7 +4222,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4237,7 +4237,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4246,7 +4246,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "aleo-std", "anyhow", @@ -4271,7 +4271,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "aleo-std", "anyhow", @@ -4295,7 +4295,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "aleo-std", "colored", @@ -4318,7 +4318,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "indexmap 2.2.2", "paste", @@ -4332,7 +4332,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "bincode", "once_cell", @@ -4345,7 +4345,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "aleo-std", "anyhow", @@ -4366,7 +4366,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=fa5f425#fa5f4250874203af80ebc461b0a3d659b3c32f04" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" dependencies = [ "proc-macro2", "quote 1.0.35", diff --git a/Cargo.toml b/Cargo.toml index cc6a5d99e9..f635a13fa0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "62bce04" +rev = "b08c6fc" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From ef983440dce732c2015605e643ad11e56a564288 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sat, 10 Feb 2024 19:17:50 -0800 Subject: [PATCH 041/551] Update rev --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index c7a7f33979..dad7cd55bc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "ca2efa9" +rev = "0987894" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From 0215f8b60df0e80e4fedbf117d300eb002d5a036 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sat, 10 Feb 2024 20:46:26 -0800 Subject: [PATCH 042/551] Clippy --- node/bft/src/helpers/channels.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node/bft/src/helpers/channels.rs b/node/bft/src/helpers/channels.rs index 159d7f3e79..8981883522 100644 --- a/node/bft/src/helpers/channels.rs +++ b/node/bft/src/helpers/channels.rs @@ -22,7 +22,7 @@ use crate::events::{ }; use snarkos_node_sync::locators::BlockLocators; use snarkvm::{ - console::{network::*, types::Field}, + console::network::*, ledger::{ block::{Block, Transaction}, coinbase::{ProverSolution, PuzzleCommitment}, @@ -31,7 +31,7 @@ use snarkvm::{ prelude::Result, }; -use indexmap::{IndexMap, IndexSet}; +use indexmap::IndexMap; use std::net::SocketAddr; use tokio::sync::{mpsc, oneshot}; From f4e8bc26e258b735ca312005c75dcda7b4e2624a Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sat, 10 Feb 2024 20:50:13 -0800 Subject: [PATCH 043/551] Fix path references --- .github/workflows/release.yml | 16 ++++++++-------- cli/src/commands/developer/scan.rs | 4 ++-- node/cdn/src/blocks.rs | 2 +- node/router/src/routing.rs | 2 +- node/src/lib.rs | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f0c9ccbdba..03ca1330c3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,16 +35,16 @@ jobs: mkdir tempdir mv target/release/snarkos tempdir cd tempdir - zip -r aleo-testnet1-${{ steps.get_version.outputs.version }}-x86_64-unknown-linux-gnu.zip snarkos + zip -r aleo-${{ steps.get_version.outputs.version }}-x86_64-unknown-linux-gnu.zip snarkos cd .. - mv tempdir/aleo-testnet1-${{ steps.get_version.outputs.version }}-x86_64-unknown-linux-gnu.zip . + mv tempdir/aleo-${{ steps.get_version.outputs.version }}-x86_64-unknown-linux-gnu.zip . - name: Release uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') with: files: | - aleo-testnet1-${{ steps.get_version.outputs.version }}-x86_64-unknown-linux-gnu.zip + aleo-${{ steps.get_version.outputs.version }}-x86_64-unknown-linux-gnu.zip env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -75,16 +75,16 @@ jobs: mkdir tempdir mv target/release/snarkos tempdir cd tempdir - zip -r aleo-testnet1-${{ steps.get_version.outputs.version }}-x86_64-apple-darwin.zip snarkos + zip -r aleo-${{ steps.get_version.outputs.version }}-x86_64-apple-darwin.zip snarkos cd .. - mv tempdir/aleo-testnet1-${{ steps.get_version.outputs.version }}-x86_64-apple-darwin.zip . + mv tempdir/aleo-${{ steps.get_version.outputs.version }}-x86_64-apple-darwin.zip . - name: Release uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') with: files: | - aleo-testnet1-${{ steps.get_version.outputs.version }}-x86_64-apple-darwin.zip + aleo-${{ steps.get_version.outputs.version }}-x86_64-apple-darwin.zip env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -122,13 +122,13 @@ jobs: - name: Zip run: | - Compress-Archive target/release/snarkos.exe aleo-testnet1-${{ steps.get_version.outputs.version }}-x86_64-pc-windows-msvc.zip + Compress-Archive target/release/snarkos.exe aleo-${{ steps.get_version.outputs.version }}-x86_64-pc-windows-msvc.zip - name: Release uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') with: files: | - aleo-testnet1-${{ steps.get_version.outputs.version }}-x86_64-pc-windows-msvc.zip + aleo-${{ steps.get_version.outputs.version }}-x86_64-pc-windows-msvc.zip env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/cli/src/commands/developer/scan.rs b/cli/src/commands/developer/scan.rs index 1652fe9808..21be11d4d3 100644 --- a/cli/src/commands/developer/scan.rs +++ b/cli/src/commands/developer/scan.rs @@ -122,7 +122,7 @@ impl Scan { } (Some(start), None, None) => { // Request the latest block height from the endpoint. - let endpoint = format!("{}/testnet3/latest/height", self.endpoint); + let endpoint = format!("{}/mainnet/latest/height", self.endpoint); let latest_height = u32::from_str(&ureq::get(&endpoint).call()?.into_string()?)?; // Print a warning message if the user is attempting to scan the whole chain. @@ -135,7 +135,7 @@ impl Scan { (None, Some(end), None) => Ok((0, end)), (None, None, Some(last)) => { // Request the latest block height from the endpoint. - let endpoint = format!("{}/testnet3/latest/height", self.endpoint); + let endpoint = format!("{}/mainnet/latest/height", self.endpoint); let latest_height = u32::from_str(&ureq::get(&endpoint).call()?.into_string()?)?; Ok((latest_height.saturating_sub(last), latest_height)) diff --git a/node/cdn/src/blocks.rs b/node/cdn/src/blocks.rs index 2de4c63812..8772b43ec3 100644 --- a/node/cdn/src/blocks.rs +++ b/node/cdn/src/blocks.rs @@ -513,7 +513,7 @@ mod tests { rt.block_on(async { let client = reqwest::Client::new(); let height = - cdn_get::(client, &format!("{TEST_BASE_URL}/testnet3/latest/height"), "height").await.unwrap(); + cdn_get::(client, &format!("{TEST_BASE_URL}/mainnet/latest/height"), "height").await.unwrap(); assert!(height > 0); }); } diff --git a/node/router/src/routing.rs b/node/router/src/routing.rs index 63715124f9..1fdc9c7ca2 100644 --- a/node/router/src/routing.rs +++ b/node/router/src/routing.rs @@ -72,7 +72,7 @@ pub trait Routing: report.insert("node_type".to_string(), self_clone.router().node_type().to_string()); report.insert("is_dev".to_string(), self_clone.router().is_dev().to_string()); // Transmit the report. - let url = "https://vm.aleo.org/testnet3/report"; + let url = "https://vm.aleo.org/mainnet/report"; let _ = reqwest::Client::new().post(url).json(&report).send().await; // Sleep for a fixed duration in seconds. tokio::time::sleep(Duration::from_secs(6 * 60 * 60)).await; diff --git a/node/src/lib.rs b/node/src/lib.rs index e2dec54367..d50a5ad9de 100644 --- a/node/src/lib.rs +++ b/node/src/lib.rs @@ -207,7 +207,7 @@ pub fn start_notification_message_loop() -> tokio::task::JoinHandle<()> { tokio::spawn(async move { loop { interval.tick().await; - // TODO (howardwu): Swap this with the official message for Testnet 3 announcements. + // TODO (howardwu): Swap this with the official message for announcements. // info!("{}", notification_message()); } }) @@ -222,7 +222,7 @@ pub fn notification_message() -> String { ================================================================================================== - 🚧 Welcome to Aleo Testnet 3 Phase 3 - Calibration Period 🚧 + 🚧 Welcome to Aleo - Calibration Period 🚧 ================================================================================================== From 058b37a5f3b9226994bb201f047d6e58dac65f53 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sat, 10 Feb 2024 20:57:40 -0800 Subject: [PATCH 044/551] Update port usage to match ID derivation --- .devnet/.analytics/analytics.js | 2 +- .devnet/README.md | 4 +- .devnet/start.sh | 2 +- Cargo.lock | 116 ++++++++++++++++---------------- README.md | 8 +-- build_ubuntu.sh | 6 +- cli/src/commands/start.rs | 12 ++-- node/router/src/lib.rs | 8 +-- node/src/validator/mod.rs | 4 +- 9 files changed, 81 insertions(+), 81 deletions(-) diff --git a/.devnet/.analytics/analytics.js b/.devnet/.analytics/analytics.js index 30f551b6c0..897eb1cb10 100644 --- a/.devnet/.analytics/analytics.js +++ b/.devnet/.analytics/analytics.js @@ -134,7 +134,7 @@ async function main() { if (match && match[1]) { const ipAddress = match[1]; - const baseUrl = `http://${ipAddress}:3033/mainnet/block`; + const baseUrl = `http://${ipAddress}:3030/mainnet/block`; console.log(`${dimStart}IP Address: ${ipAddress}${dimEnd}`); console.log(`${dimStart}Base URL: ${baseUrl}${dimEnd}`); diff --git a/.devnet/README.md b/.devnet/README.md index a6b51f69ef..57610c5ef3 100644 --- a/.devnet/README.md +++ b/.devnet/README.md @@ -6,8 +6,8 @@ Start by creating EC2 instances in the AWS console. - Ubuntu 22.04 LTS (not Amazon Linux) - Security Group - Inbound Policy - SSH - Port 22 - 0.0.0.0/0 (or your IP) - - Custom TCP - Port 3033 - 0.0.0.0/0 (or your IP) - - Custom TCP - Port 4133 - 0.0.0.0/0 + - Custom TCP - Port 3030 - 0.0.0.0/0 (or your IP) + - Custom TCP - Port 4130 - 0.0.0.0/0 - Custom TCP - Port 5000 - 0.0.0.0/0 Be sure the give the EC2 instances a name tag, i.e. `devnet`. diff --git a/.devnet/start.sh b/.devnet/start.sh index 755cacf31b..6d61198721 100755 --- a/.devnet/start.sh +++ b/.devnet/start.sh @@ -37,7 +37,7 @@ start_snarkos_in_tmux() { tmux new-session -d -s snarkos-session # Send the snarkOS start command to the tmux session with the NODE_ID - tmux send-keys -t "snarkos-session" "snarkos start --nodisplay --bft 0.0.0.0:5000 --rest 0.0.0.0:3033 --peers $NODE_IP:4133 --validators $NODE_IP:5000 --verbosity $VERBOSITY --dev $NODE_ID --dev-num-validators $NUM_INSTANCES --validator --metrics" C-m + tmux send-keys -t "snarkos-session" "snarkos start --nodisplay --bft 0.0.0.0:5000 --rest 0.0.0.0:3030 --peers $NODE_IP:4130 --validators $NODE_IP:5000 --verbosity $VERBOSITY --dev $NODE_ID --dev-num-validators $NUM_INSTANCES --validator --metrics" C-m exit # Exit root user EOF diff --git a/Cargo.lock b/Cargo.lock index 398f40ac23..d7dda17b58 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3526,7 +3526,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "anstyle", "anyhow", @@ -3557,7 +3557,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "aleo-std", "anyhow", @@ -3587,7 +3587,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3601,7 +3601,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3612,7 +3612,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3622,7 +3622,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3632,7 +3632,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "indexmap 2.2.2", "itertools 0.11.0", @@ -3650,12 +3650,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3666,7 +3666,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3681,7 +3681,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3696,7 +3696,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3709,7 +3709,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3718,7 +3718,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3728,7 +3728,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3740,7 +3740,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3752,7 +3752,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3763,7 +3763,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3775,7 +3775,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3788,7 +3788,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "bs58", "snarkvm-console-network", @@ -3799,7 +3799,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "blake2s_simd", "smallvec", @@ -3812,7 +3812,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "aleo-std", "rayon", @@ -3823,7 +3823,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "anyhow", "indexmap 2.2.2", @@ -3846,7 +3846,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "anyhow", "bech32", @@ -3864,7 +3864,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "enum_index", "enum_index_derive", @@ -3885,7 +3885,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3900,7 +3900,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3911,7 +3911,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "snarkvm-console-network-environment", ] @@ -3919,7 +3919,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3929,7 +3929,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3940,7 +3940,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3951,7 +3951,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3962,7 +3962,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3973,7 +3973,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "rand", "rayon", @@ -3987,7 +3987,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "aleo-std", "anyhow", @@ -4004,7 +4004,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "aleo-std", "anyhow", @@ -4029,7 +4029,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "anyhow", "rand", @@ -4041,7 +4041,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4060,7 +4060,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-coinbase" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "aleo-std", "anyhow", @@ -4080,7 +4080,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "anyhow", "indexmap 2.2.2", @@ -4098,7 +4098,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -4111,7 +4111,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4124,7 +4124,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "indexmap 2.2.2", "serde_json", @@ -4136,7 +4136,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "bytes", "serde_json", @@ -4147,7 +4147,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4162,7 +4162,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "bytes", "serde_json", @@ -4175,7 +4175,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "snarkvm-console", "snarkvm-ledger-coinbase", @@ -4184,7 +4184,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "async-trait", "reqwest", @@ -4197,7 +4197,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "aleo-std-storage", "anyhow", @@ -4222,7 +4222,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4237,7 +4237,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4246,7 +4246,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "aleo-std", "anyhow", @@ -4271,7 +4271,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "aleo-std", "anyhow", @@ -4295,7 +4295,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "aleo-std", "colored", @@ -4318,7 +4318,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "indexmap 2.2.2", "paste", @@ -4332,7 +4332,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "bincode", "once_cell", @@ -4345,7 +4345,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "aleo-std", "anyhow", @@ -4366,7 +4366,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=62bce04#62bce0440360e2a58838795bfd1d6afa17a6acdf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" dependencies = [ "proc-macro2", "quote 1.0.35", diff --git a/README.md b/README.md index 7bffeeb106..6fa2186ca0 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ Lastly, install `snarkOS`: cargo install --locked --path . ``` -Please ensure ports `4133/tcp` and `3033/tcp` are open on your router and OS firewall. +Please ensure ports `4130/tcp` and `3030/tcp` are open on your router and OS firewall. ## 3. Run an Aleo Node @@ -144,7 +144,7 @@ APrivateKey1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ### 2. My node is unable to connect to peers on the network. -- Ensure ports `4133/tcp` and `3033/tcp` are open on your router and OS firewall. +- Ensure ports `4130/tcp` and `3030/tcp` are open on your router and OS firewall. - Ensure `snarkOS` is started using `./run-client.sh` or `./run-prover.sh`. ### 3. I can't generate a new address ### @@ -191,10 +191,10 @@ OPTIONS: --private-key Specify the node's account private key --private-key-file Specify the path to a file containing the node's account private key - --node Specify the IP address and port for the node server [default: 0.0.0.0:4133] + --node Specify the IP address and port for the node server [default: 0.0.0.0:4130] --connect Specify the IP address and port of a peer to connect to - --rest Specify the IP address and port for the REST server [default: 0.0.0.0:3033] + --rest Specify the IP address and port for the REST server [default: 0.0.0.0:3030] --norest If the flag is set, the node will not initialize the REST server --nodisplay If the flag is set, the node will not render the display diff --git a/build_ubuntu.sh b/build_ubuntu.sh index 53cad73e4a..84d7379c51 100755 --- a/build_ubuntu.sh +++ b/build_ubuntu.sh @@ -31,12 +31,12 @@ source $HOME/.cargo/env cargo install --locked --path . echo "==================================================" -echo " Attention - Please ensure ports 4133 and 3033" +echo " Attention - Please ensure ports 4130 and 3030" echo " are enabled on your local network." echo "" -echo " Cloud Providers - Enable ports 4133 and 3033" +echo " Cloud Providers - Enable ports 4130 and 3030" echo " in your network firewall" echo "" echo " Home Users - Enable port forwarding or NAT rules" -echo " for 4133 and 3033 on your router." +echo " for 4130 and 3030 on your router." echo "==================================================" diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index a6d30e99c3..8887016802 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -76,7 +76,7 @@ pub struct Start { pub private_key_file: Option, /// Specify the IP address and port for the node server - #[clap(default_value = "0.0.0.0:4133", long = "node")] + #[clap(default_value = "0.0.0.0:4130", long = "node")] pub node: SocketAddr, /// Specify the IP address and port for the BFT #[clap(long = "bft")] @@ -89,7 +89,7 @@ pub struct Start { pub validators: String, /// Specify the IP address and port for the REST server - #[clap(default_value = "0.0.0.0:3033", long = "rest")] + #[clap(default_value = "0.0.0.0:3030", long = "rest")] pub rest: SocketAddr, /// Specify the requests per second (RPS) rate limit per IP for the REST server #[clap(default_value = "10", long = "rest-rps")] @@ -789,8 +789,8 @@ mod tests { Start::try_parse_from(["snarkos", "--dev", "3", "--client", "--private-key", ""].iter()).unwrap(); config.parse_development(&mut trusted_peers, &mut trusted_validators).unwrap(); let genesis = config.parse_genesis::().unwrap(); - assert_eq!(config.node, SocketAddr::from_str("0.0.0.0:4133").unwrap()); - assert_eq!(config.rest, SocketAddr::from_str("0.0.0.0:3033").unwrap()); + assert_eq!(config.node, SocketAddr::from_str("0.0.0.0:4130").unwrap()); + assert_eq!(config.rest, SocketAddr::from_str("0.0.0.0:3030").unwrap()); assert_eq!(trusted_peers.len(), 3); assert_eq!(trusted_validators.len(), 2); assert!(!config.validator); @@ -817,7 +817,7 @@ mod tests { "--validators", "IP1,IP2,IP3", "--rest", - "127.0.0.1:3033", + "127.0.0.1:3030", ]; let cli = CLI::parse_from(arg_vec); @@ -827,7 +827,7 @@ mod tests { assert!(start.validator); assert_eq!(start.private_key.as_deref(), Some("PRIVATE_KEY")); assert_eq!(start.cdn, "CDN"); - assert_eq!(start.rest, "127.0.0.1:3033".parse().unwrap()); + assert_eq!(start.rest, "127.0.0.1:3030".parse().unwrap()); assert_eq!(start.network, 3); assert_eq!(start.peers, "IP1,IP2,IP3"); assert_eq!(start.validators, "IP1,IP2,IP3"); diff --git a/node/router/src/lib.rs b/node/router/src/lib.rs index 6f4465aaca..3dab4b01b2 100644 --- a/node/router/src/lib.rs +++ b/node/router/src/lib.rs @@ -381,10 +381,10 @@ impl Router { vec![] } else { vec![ - SocketAddr::from_str("35.224.50.150:4133").unwrap(), - SocketAddr::from_str("35.227.159.141:4133").unwrap(), - SocketAddr::from_str("34.139.203.87:4133").unwrap(), - SocketAddr::from_str("34.150.221.166:4133").unwrap(), + SocketAddr::from_str("35.224.50.150:4130").unwrap(), + SocketAddr::from_str("35.227.159.141:4130").unwrap(), + SocketAddr::from_str("34.139.203.87:4130").unwrap(), + SocketAddr::from_str("34.150.221.166:4130").unwrap(), ] } } diff --git a/node/src/validator/mod.rs b/node/src/validator/mod.rs index fc0c277371..2c964c78a5 100644 --- a/node/src/validator/mod.rs +++ b/node/src/validator/mod.rs @@ -470,8 +470,8 @@ mod tests { #[tokio::test] async fn test_profiler() -> Result<()> { // Specify the node attributes. - let node = SocketAddr::from_str("0.0.0.0:4133").unwrap(); - let rest = SocketAddr::from_str("0.0.0.0:3033").unwrap(); + let node = SocketAddr::from_str("0.0.0.0:4130").unwrap(); + let rest = SocketAddr::from_str("0.0.0.0:3030").unwrap(); let storage_mode = StorageMode::Development(0); // Initialize an (insecure) fixed RNG. From 227902801b27ad2cbe52686b8b57f5c049ec3610 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sat, 10 Feb 2024 21:08:59 -0800 Subject: [PATCH 045/551] Fix test --- cli/src/commands/start.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index 8887016802..5acb847118 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -789,8 +789,8 @@ mod tests { Start::try_parse_from(["snarkos", "--dev", "3", "--client", "--private-key", ""].iter()).unwrap(); config.parse_development(&mut trusted_peers, &mut trusted_validators).unwrap(); let genesis = config.parse_genesis::().unwrap(); - assert_eq!(config.node, SocketAddr::from_str("0.0.0.0:4130").unwrap()); - assert_eq!(config.rest, SocketAddr::from_str("0.0.0.0:3030").unwrap()); + assert_eq!(config.node, SocketAddr::from_str("0.0.0.0:4133").unwrap()); + assert_eq!(config.rest, SocketAddr::from_str("0.0.0.0:3033").unwrap()); assert_eq!(trusted_peers.len(), 3); assert_eq!(trusted_validators.len(), 2); assert!(!config.validator); From 0cb865dc32f340252fe1fb2aae9bb57dd5d77fb5 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sat, 10 Feb 2024 21:26:08 -0800 Subject: [PATCH 046/551] Add logging and more fetch time --- node/bft/src/bft.rs | 3 +++ node/bft/src/gateway.rs | 4 +++- node/bft/src/lib.rs | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 7affd30b6a..ad31827efd 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -440,6 +440,9 @@ impl BFT { return Ok(()); } + /* Proceeding to check if the leader is ready to be committed. */ + trace!("Checking if the leader is ready to be committed for round {commit_round}..."); + // Retrieve the committee lookback for the commit round. let Ok(committee_lookback) = self.ledger().get_committee_lookback_for_round(commit_round) else { bail!("BFT failed to retrieve the committee with lag for commit round {commit_round}"); diff --git a/node/bft/src/gateway.rs b/node/bft/src/gateway.rs index 71562ed068..06030e5d5d 100644 --- a/node/bft/src/gateway.rs +++ b/node/bft/src/gateway.rs @@ -607,7 +607,9 @@ impl Gateway { // Ensure the block response is well-formed. blocks.ensure_response_is_well_formed(peer_ip, request.start_height, request.end_height)?; // Send the blocks to the sync module. - return sync_sender.advance_with_sync_blocks(peer_ip, blocks.0).await; + if let Err(e) = sync_sender.advance_with_sync_blocks(peer_ip, blocks.0).await { + warn!("Unable to process block response from '{peer_ip}' - {e}"); + } } Ok(()) } diff --git a/node/bft/src/lib.rs b/node/bft/src/lib.rs index 0b2f2a53ea..e466b9d749 100644 --- a/node/bft/src/lib.rs +++ b/node/bft/src/lib.rs @@ -49,7 +49,7 @@ pub const MEMORY_POOL_PORT: u16 = 5000; // port /// The maximum number of milliseconds to wait before proposing a batch. pub const MAX_BATCH_DELAY_IN_MS: u64 = 2500; // ms /// The maximum number of milliseconds to wait before timing out on a fetch. -pub const MAX_FETCH_TIMEOUT_IN_MS: u64 = 2 * MAX_BATCH_DELAY_IN_MS; // ms +pub const MAX_FETCH_TIMEOUT_IN_MS: u64 = 3 * MAX_BATCH_DELAY_IN_MS; // ms /// The maximum number of seconds allowed for the leader to send their certificate. pub const MAX_LEADER_CERTIFICATE_DELAY_IN_SECS: i64 = 2 * MAX_BATCH_DELAY_IN_MS as i64 / 1000; // seconds /// The maximum number of seconds before the timestamp is considered expired. From cbc30f55ad8cd800959b84a548758d1877e76f11 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sat, 10 Feb 2024 21:35:31 -0800 Subject: [PATCH 047/551] Fix network ID --- cli/src/commands/clean.rs | 2 +- cli/src/commands/start.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cli/src/commands/clean.rs b/cli/src/commands/clean.rs index 88fa7f0212..a133577e77 100644 --- a/cli/src/commands/clean.rs +++ b/cli/src/commands/clean.rs @@ -22,7 +22,7 @@ use std::path::PathBuf; #[derive(Debug, Parser)] pub struct Clean { /// Specify the network to remove from storage. - #[clap(default_value = "3", long = "network")] + #[clap(default_value = "0", long = "network")] pub network: u16, /// Enables development mode, specify the unique ID of the local node to clean. #[clap(long)] diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index 5acb847118..900d755a15 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -55,7 +55,7 @@ const DEVELOPMENT_MODE_NUM_GENESIS_COMMITTEE_MEMBERS: u16 = 4; #[derive(Clone, Debug, Parser)] pub struct Start { /// Specify the network ID of this node - #[clap(default_value = "3", long = "network")] + #[clap(default_value = "0", long = "network")] pub network: u16, /// Specify this node as a validator @@ -140,7 +140,7 @@ impl Start { let mut cli = self.clone(); // Parse the network. match cli.network { - 3 => { + 0 => { // Parse the node from the configurations. let node = cli.parse_node::().await.expect("Failed to parse the node"); // If the display is enabled, render the display. From c286dd32782d751e323901bcb37f265260fd8bd5 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sat, 10 Feb 2024 21:43:43 -0800 Subject: [PATCH 048/551] Handle Phase 3 TODOs --- cli/src/commands/start.rs | 3 +- node/router/src/routing.rs | 25 +----- node/src/client/mod.rs | 3 +- node/src/lib.rs | 153 ++----------------------------------- node/src/validator/mod.rs | 3 +- 5 files changed, 10 insertions(+), 177 deletions(-) diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index 900d755a15..c1315e22bf 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -414,10 +414,9 @@ impl Start { println!("🪪 Your Aleo address is {}.\n", account.address().to_string().bold()); // Print the node type and network. println!( - "🧭 Starting {} on {} {} at {}.\n", + "🧭 Starting {} on {} at {}.\n", node_type.description().bold(), N::NAME.bold(), - "Phase 3".bold(), self.node.to_string().bold() ); diff --git a/node/router/src/routing.rs b/node/router/src/routing.rs index 1fdc9c7ca2..d2d2457c62 100644 --- a/node/router/src/routing.rs +++ b/node/router/src/routing.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::{messages::Message, Heartbeat, Inbound, Outbound}; +use crate::{Heartbeat, Inbound, Outbound}; use snarkos_node_tcp::{ protocols::{Disconnect, Handshake, OnConnect}, P2P, @@ -37,9 +37,6 @@ pub trait Routing: self.enable_listener().await; // Initialize the heartbeat. self.initialize_heartbeat(); - // Initialize the report. - #[cfg(not(feature = "test"))] - self.initialize_report(); } // Start listening for inbound connections. @@ -59,24 +56,4 @@ pub trait Routing: } }); } - - /// Initialize a new instance of the report. - fn initialize_report(&self) { - let self_clone = self.clone(); - self.router().spawn(async move { - loop { - // Prepare the report. - let mut report = std::collections::HashMap::new(); - report.insert("message_version".to_string(), Message::::VERSION.to_string()); - report.insert("node_address".to_string(), self_clone.router().address().to_string()); - report.insert("node_type".to_string(), self_clone.router().node_type().to_string()); - report.insert("is_dev".to_string(), self_clone.router().is_dev().to_string()); - // Transmit the report. - let url = "https://vm.aleo.org/mainnet/report"; - let _ = reqwest::Client::new().post(url).json(&report).send().await; - // Sleep for a fixed duration in seconds. - tokio::time::sleep(Duration::from_secs(6 * 60 * 60)).await; - } - }); - } } diff --git a/node/src/client/mod.rs b/node/src/client/mod.rs index a26f4e5510..c44e02996c 100644 --- a/node/src/client/mod.rs +++ b/node/src/client/mod.rs @@ -92,8 +92,7 @@ impl> Client { // Initialize the ledger. let ledger = Ledger::::load(genesis.clone(), storage_mode.clone())?; - // TODO: Remove me after Phase 3. - let ledger = crate::phase_3_reset(ledger, storage_mode.clone())?; + // Initialize the CDN. if let Some(base_url) = cdn { // Sync the ledger with the CDN. diff --git a/node/src/lib.rs b/node/src/lib.rs index d50a5ad9de..4d7dfde7a7 100644 --- a/node/src/lib.rs +++ b/node/src/lib.rs @@ -60,156 +60,15 @@ pub fn log_clean_error(storage_mode: &StorageMode) { } } -use snarkvm::{ - ledger::store::ConsensusStorage, - prelude::{const_assert, hrp2, AleoID, Field, Ledger, Network}, -}; - -use anyhow::{bail, Result}; - -// TODO: Remove me after Phase 3. -pub fn phase_3_reset>( - ledger: Ledger, - storage_mode: StorageMode, -) -> Result> { - use core::str::FromStr; - - /// Removes the specified ledger from storage. - pub(crate) fn remove_ledger(network: u16, storage_mode: &StorageMode) -> Result { - // Construct the path to the ledger in storage. - let mut path = aleo_std::aleo_ledger_dir(network, storage_mode.clone()); - - // Delete the parent folder. - path.pop(); - - // Prepare the path string. - let path_string = format!("(in \"{}\")", path.display()); - - // Check if the path to the ledger exists in storage. - if path.exists() { - // Remove the ledger files from storage. - match std::fs::remove_dir_all(&path) { - Ok(_) => Ok(format!("✅ Cleaned the snarkOS node storage {path_string}")), - Err(error) => { - bail!("Failed to remove the snarkOS node storage {path_string}\n{}", error.to_string()) - } - } - } else { - Ok(format!("✅ No snarkOS node storage was found {path_string}")) - } - } - - type ID = AleoID, { hrp2!("ab") }>; - - if let Ok(block) = ledger.get_block(28250) { - if *block.hash() == *ID::::from_str("ab1fxetqjm0ppruay8vlg6gtt52d5fkeydmrk0talp04ymjm65acg9sh8d0r5")? { - let genesis = ledger.get_block(0)?; - drop(ledger); - println!( - "{}.\n\n\nMIGRATION SUCCEEDED. RESTART THIS SNARKOS NODE AGAIN.\n\n", - remove_ledger(N::ID, &storage_mode)? - ); - // Sleep for 5 seconds to allow the user to read the message. - std::thread::sleep(std::time::Duration::from_secs(5)); - return Ledger::::load(genesis.clone(), storage_mode); - } - } else if let Ok(block) = ledger.get_block(28251) { - if *block.hash() == *ID::::from_str("ab1ngmc9wf3kz73lxg9ylx75vday82a26xqthjykzrwyhngnr25uvqqau9eyh")? { - let genesis = ledger.get_block(0)?; - drop(ledger); - println!( - "{}.\n\n\nMIGRATION SUCCEEDED. RESTART THIS SNARKOS NODE AGAIN.\n\n", - remove_ledger(N::ID, &storage_mode)? - ); - // Sleep for 5 seconds to allow the user to read the message. - std::thread::sleep(std::time::Duration::from_secs(5)); - return Ledger::::load(genesis.clone(), storage_mode); - } - } else if let Ok(block) = ledger.get_block(28252) { - if *block.hash() == *ID::::from_str("ab1k6msq00mzrlmm3e0xzgynks5mqh2zrhd35akqqts24sd9u5x9yxs355qgv")? { - let genesis = ledger.get_block(0)?; - drop(ledger); - println!( - "{}.\n\n\nMIGRATION SUCCEEDED. RESTART THIS SNARKOS NODE AGAIN.\n\n", - remove_ledger(N::ID, &storage_mode)? - ); - // Sleep for 5 seconds to allow the user to read the message. - std::thread::sleep(std::time::Duration::from_secs(5)); - return Ledger::::load(genesis.clone(), storage_mode); - } - } else if let Ok(block) = ledger.get_block(115314) { - if *block.hash() == *ID::::from_str("ab13eckyhvhpv5zdhw8xz2zskrmm0a5hgeq7f5sjaw4errx0678pgpsjhuaqf")? { - let genesis = ledger.get_block(0)?; - drop(ledger); - println!( - "{}.\n\n\nMIGRATION SUCCEEDED. RESTART THIS SNARKOS NODE AGAIN.\n\n", - remove_ledger(N::ID, &storage_mode)? - ); - // Sleep for 5 seconds to allow the user to read the message. - std::thread::sleep(std::time::Duration::from_secs(5)); - return Ledger::::load(genesis.clone(), storage_mode); - } - } else if let Ok(block) = ledger.get_block(115315) { - if *block.hash() == *ID::::from_str("ab1axs5ltm6kjezsjxw35taf3xjpherrhpu6868h3ezhc3ap8pyrggqrrkjcg")? { - let genesis = ledger.get_block(0)?; - drop(ledger); - println!( - "{}.\n\n\nMIGRATION SUCCEEDED. RESTART THIS SNARKOS NODE AGAIN.\n\n", - remove_ledger(N::ID, &storage_mode)? - ); - // Sleep for 5 seconds to allow the user to read the message. - std::thread::sleep(std::time::Duration::from_secs(5)); - return Ledger::::load(genesis.clone(), storage_mode); - } - } else if let Ok(block) = ledger.get_block(726845) { - if *block.hash() == *ID::::from_str("ab1tf3v9qef0uh3ygsc0qqem7dzeyy2m8aqz583a80z60l8t5l22u9s84y38z")? { - let genesis = ledger.get_block(0)?; - drop(ledger); - println!( - "{}.\n\n\nMIGRATION SUCCEEDED. RESTART THIS SNARKOS NODE AGAIN.\n\n", - remove_ledger(N::ID, &storage_mode)? - ); - // Sleep for 5 seconds to allow the user to read the message. - std::thread::sleep(std::time::Duration::from_secs(5)); - return Ledger::::load(genesis.clone(), storage_mode); - } - } else if let Ok(block) = ledger.get_block(997810) { - if *block.hash() == *ID::::from_str("ab1pap9sxh5fcskw7l3msax4fq2mrqd80kxp0epx9dguxua2e8dacys78key5")? { - let genesis = ledger.get_block(0)?; - drop(ledger); - println!( - "{}.\n\n\nMIGRATION SUCCEEDED. RESTART THIS SNARKOS NODE AGAIN.\n\n", - remove_ledger(N::ID, &storage_mode)? - ); - // Sleep for 5 seconds to allow the user to read the message. - std::thread::sleep(std::time::Duration::from_secs(5)); - return Ledger::::load(genesis.clone(), storage_mode); - } - } else if let Ok(block) = ledger.get_block(997810) { - if *block.hash() == *ID::::from_str("ab1fx4mpz0fdqx75djf3n9grsjkc229xfs8fzmjqsxkajtj8j8sdurqufgvyz")? { - let genesis = ledger.get_block(0)?; - drop(ledger); - println!( - "{}.\n\n\nMIGRATION SUCCEEDED. RESTART THIS SNARKOS NODE AGAIN.\n\n", - remove_ledger(N::ID, &storage_mode)? - ); - // Sleep for 5 seconds to allow the user to read the message. - std::thread::sleep(std::time::Duration::from_secs(5)); - return Ledger::::load(genesis.clone(), storage_mode); - } - } - Ok(ledger) -} - /// Starts the notification message loop. pub fn start_notification_message_loop() -> tokio::task::JoinHandle<()> { - let mut interval = tokio::time::interval(std::time::Duration::from_secs(180)); + // let mut interval = tokio::time::interval(std::time::Duration::from_secs(180)); tokio::spawn(async move { - loop { - interval.tick().await; - // TODO (howardwu): Swap this with the official message for announcements. - // info!("{}", notification_message()); - } + // loop { + // interval.tick().await; + // // TODO (howardwu): Swap this with the official message for announcements. + // // info!("{}", notification_message()); + // } }) } diff --git a/node/src/validator/mod.rs b/node/src/validator/mod.rs index 2c964c78a5..7ac250f1a3 100644 --- a/node/src/validator/mod.rs +++ b/node/src/validator/mod.rs @@ -92,8 +92,7 @@ impl> Validator { // Initialize the ledger. let ledger = Ledger::load(genesis, storage_mode.clone())?; - // TODO: Remove me after Phase 3. - let ledger = crate::phase_3_reset(ledger, storage_mode.clone())?; + // Initialize the CDN. if let Some(base_url) = cdn { // Sync the ledger with the CDN. From 33d40e5bac45630efcef605ca51cec5de6abed11 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sat, 10 Feb 2024 21:55:35 -0800 Subject: [PATCH 049/551] Improve error handling and threshold --- node/bft/src/bft.rs | 5 +++++ node/bft/src/primary.rs | 5 +++++ node/consensus/src/lib.rs | 13 +++++++++++-- node/sync/src/block_sync.rs | 2 +- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index ad31827efd..56fc99ea26 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -118,6 +118,11 @@ impl BFT { Ok(()) } + /// Returns `true` if the primary is synced. + pub fn is_synced(&self) -> bool { + self.primary.is_synced() + } + /// Returns the primary. pub const fn primary(&self) -> &Primary { &self.primary diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index cf9ef53a50..4c560c1684 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -185,6 +185,11 @@ impl Primary { self.storage.current_round() } + /// Returns `true` if the primary is synced. + pub fn is_synced(&self) -> bool { + self.sync.is_synced() + } + /// Returns the gateway. pub const fn gateway(&self) -> &Gateway { &self.gateway diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 366fbd3c15..52aa75a626 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -230,7 +230,10 @@ impl Consensus { trace!("Adding unconfirmed solution '{}' to the memory pool...", fmt_id(solution_id)); // Send the unconfirmed solution to the primary. if let Err(e) = self.primary_sender().send_unconfirmed_solution(solution_id, Data::Object(solution)).await { - warn!("Failed to add unconfirmed solution '{}' to the memory pool - {e}", fmt_id(solution_id)); + // If the BFT is synced, then log the warning. + if self.bft.is_synced() { + warn!("Failed to add unconfirmed solution '{}' to the memory pool - {e}", fmt_id(solution_id)); + } } } Ok(()) @@ -288,7 +291,13 @@ impl Consensus { if let Err(e) = self.primary_sender().send_unconfirmed_transaction(transaction_id, Data::Object(transaction)).await { - warn!("Failed to add unconfirmed transaction '{}' to the memory pool - {e}", fmt_id(transaction_id)); + // If the BFT is synced, then log the warning. + if self.bft.is_synced() { + warn!( + "Failed to add unconfirmed transaction '{}' to the memory pool - {e}", + fmt_id(transaction_id) + ); + } } } Ok(()) diff --git a/node/sync/src/block_sync.rs b/node/sync/src/block_sync.rs index 0bc46e10bf..531f6b6046 100644 --- a/node/sync/src/block_sync.rs +++ b/node/sync/src/block_sync.rs @@ -40,7 +40,7 @@ pub const REDUNDANCY_FACTOR: usize = 3; const EXTRA_REDUNDANCY_FACTOR: usize = REDUNDANCY_FACTOR * 2; const NUM_SYNC_CANDIDATE_PEERS: usize = REDUNDANCY_FACTOR * 5; -const BLOCK_REQUEST_TIMEOUT_IN_SECS: u64 = 60; // 60 seconds +const BLOCK_REQUEST_TIMEOUT_IN_SECS: u64 = 180; // 180 seconds const MAX_BLOCK_REQUESTS: usize = 50; // 50 requests const MAX_BLOCK_REQUEST_TIMEOUTS: usize = 5; // 5 timeouts From 748de1f9ede4f12958c234b0c96be974842983e9 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sat, 10 Feb 2024 22:16:35 -0800 Subject: [PATCH 050/551] Update runtime thresholds --- cli/src/commands/start.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index c1315e22bf..aced751606 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -480,7 +480,7 @@ impl Start { }; let (num_tokio_worker_threads, max_tokio_blocking_threads, num_rayon_cores_global) = - { (num_cores.min(main_cores), 512, num_cores.saturating_sub(main_cores).max(1)) }; + (num_cores, 512, main_cores); // Initialize the parallelization parameters. rayon::ThreadPoolBuilder::new() From 36cfdd331e4b9200bd3b75db971fc739a0483d35 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sat, 10 Feb 2024 22:27:24 -0800 Subject: [PATCH 051/551] Update rev --- Cargo.lock | 116 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 2 +- 2 files changed, 59 insertions(+), 59 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d7dda17b58..f3b2fe265e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3526,7 +3526,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "anstyle", "anyhow", @@ -3557,7 +3557,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "aleo-std", "anyhow", @@ -3587,7 +3587,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3601,7 +3601,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3612,7 +3612,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3622,7 +3622,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3632,7 +3632,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "indexmap 2.2.2", "itertools 0.11.0", @@ -3650,12 +3650,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3666,7 +3666,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3681,7 +3681,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3696,7 +3696,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3709,7 +3709,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3718,7 +3718,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3728,7 +3728,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3740,7 +3740,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3752,7 +3752,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3763,7 +3763,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3775,7 +3775,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3788,7 +3788,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "bs58", "snarkvm-console-network", @@ -3799,7 +3799,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "blake2s_simd", "smallvec", @@ -3812,7 +3812,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "aleo-std", "rayon", @@ -3823,7 +3823,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "anyhow", "indexmap 2.2.2", @@ -3846,7 +3846,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "anyhow", "bech32", @@ -3864,7 +3864,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "enum_index", "enum_index_derive", @@ -3885,7 +3885,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3900,7 +3900,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3911,7 +3911,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "snarkvm-console-network-environment", ] @@ -3919,7 +3919,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3929,7 +3929,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3940,7 +3940,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3951,7 +3951,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3962,7 +3962,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3973,7 +3973,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "rand", "rayon", @@ -3987,7 +3987,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "aleo-std", "anyhow", @@ -4004,7 +4004,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "aleo-std", "anyhow", @@ -4029,7 +4029,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "anyhow", "rand", @@ -4041,7 +4041,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4060,7 +4060,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-coinbase" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "aleo-std", "anyhow", @@ -4080,7 +4080,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "anyhow", "indexmap 2.2.2", @@ -4098,7 +4098,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -4111,7 +4111,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4124,7 +4124,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "indexmap 2.2.2", "serde_json", @@ -4136,7 +4136,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "bytes", "serde_json", @@ -4147,7 +4147,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4162,7 +4162,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "bytes", "serde_json", @@ -4175,7 +4175,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "snarkvm-console", "snarkvm-ledger-coinbase", @@ -4184,7 +4184,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "async-trait", "reqwest", @@ -4197,7 +4197,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "aleo-std-storage", "anyhow", @@ -4222,7 +4222,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4237,7 +4237,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4246,7 +4246,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "aleo-std", "anyhow", @@ -4271,7 +4271,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "aleo-std", "anyhow", @@ -4295,7 +4295,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "aleo-std", "colored", @@ -4318,7 +4318,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "indexmap 2.2.2", "paste", @@ -4332,7 +4332,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "bincode", "once_cell", @@ -4345,7 +4345,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "aleo-std", "anyhow", @@ -4366,7 +4366,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=97cb08d#97cb08dcc2aea125e2054440539d15cf1adad4a1" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" dependencies = [ "proc-macro2", "quote 1.0.35", diff --git a/Cargo.toml b/Cargo.toml index 960b8d5a7a..63ba2ebfb5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "97cb08d" +rev = "7eeb353" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From 86731adc1c11f1d58f8cb0280190dcb82fd0efab Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sat, 10 Feb 2024 22:33:24 -0800 Subject: [PATCH 052/551] Fix devnet script indices --- .devnet/clean.sh | 2 +- .devnet/install.sh | 2 +- .devnet/reinstall.sh | 2 +- .devnet/start.sh | 2 +- .devnet/stop.sh | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.devnet/clean.sh b/.devnet/clean.sh index c3807d8e91..d06f8d5962 100755 --- a/.devnet/clean.sh +++ b/.devnet/clean.sh @@ -38,7 +38,7 @@ EOF } # Loop through aws-n nodes and terminate tmux sessions in parallel -for NODE_ID in $(seq 0 $NUM_INSTANCES); do +for NODE_ID in $(seq 0 $(($NUM_INSTANCES - 1))); do terminate_tmux_session $NODE_ID & done diff --git a/.devnet/install.sh b/.devnet/install.sh index 4c585f2761..82054f11f1 100755 --- a/.devnet/install.sh +++ b/.devnet/install.sh @@ -50,7 +50,7 @@ EOF } # Loop through aws-n nodes and run installations in parallel -for NODE_ID in $(seq 0 $NUM_INSTANCES); do +for NODE_ID in $(seq 0 $(($NUM_INSTANCES - 1))); do run_installation $NODE_ID $BRANCH & done diff --git a/.devnet/reinstall.sh b/.devnet/reinstall.sh index 126fa38b1a..624fa7ab13 100755 --- a/.devnet/reinstall.sh +++ b/.devnet/reinstall.sh @@ -54,7 +54,7 @@ EOF } # Loop through aws-n nodes and run installations in parallel -for NODE_ID in $(seq 0 $NUM_INSTANCES); do +for NODE_ID in $(seq 0 $(($NUM_INSTANCES - 1))); do run_installation $NODE_ID $BRANCH & done diff --git a/.devnet/start.sh b/.devnet/start.sh index 6d61198721..f61cea6af0 100755 --- a/.devnet/start.sh +++ b/.devnet/start.sh @@ -51,7 +51,7 @@ EOF } # Loop through aws-n nodes and start snarkOS in tmux sessions in parallel -for NODE_ID in $(seq 0 $NUM_INSTANCES); do +for NODE_ID in $(seq 0 $(($NUM_INSTANCES - 1))); do start_snarkos_in_tmux $NODE_ID "$NODE_0_IP" & done diff --git a/.devnet/stop.sh b/.devnet/stop.sh index 494e62776d..8899eafd24 100755 --- a/.devnet/stop.sh +++ b/.devnet/stop.sh @@ -34,7 +34,7 @@ EOF } # Loop through aws-n nodes and terminate tmux sessions in parallel -for NODE_ID in $(seq 0 $NUM_INSTANCES); do +for NODE_ID in $(seq 0 $(($NUM_INSTANCES - 1))); do terminate_tmux_session $NODE_ID & done From 81e813fe5fc7fc0d1ad7687c56674c045ce0a777 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sat, 10 Feb 2024 22:43:54 -0800 Subject: [PATCH 053/551] Update the timeout threshold --- node/sync/src/block_sync.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/sync/src/block_sync.rs b/node/sync/src/block_sync.rs index 531f6b6046..ef19fe47bc 100644 --- a/node/sync/src/block_sync.rs +++ b/node/sync/src/block_sync.rs @@ -40,7 +40,7 @@ pub const REDUNDANCY_FACTOR: usize = 3; const EXTRA_REDUNDANCY_FACTOR: usize = REDUNDANCY_FACTOR * 2; const NUM_SYNC_CANDIDATE_PEERS: usize = REDUNDANCY_FACTOR * 5; -const BLOCK_REQUEST_TIMEOUT_IN_SECS: u64 = 180; // 180 seconds +const BLOCK_REQUEST_TIMEOUT_IN_SECS: u64 = 600; // 600 seconds const MAX_BLOCK_REQUESTS: usize = 50; // 50 requests const MAX_BLOCK_REQUEST_TIMEOUTS: usize = 5; // 5 timeouts From 29416d0a07fe0016370c0228321c2d960206b3b3 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sat, 10 Feb 2024 22:54:16 -0800 Subject: [PATCH 054/551] Only construct unconfirmed txs once --- node/bft/src/helpers/storage.rs | 21 ++++++++++----------- node/bft/src/sync/mod.rs | 22 +++++++++++++++++++--- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/node/bft/src/helpers/storage.rs b/node/bft/src/helpers/storage.rs index e1ea607805..c06495b3d0 100644 --- a/node/bft/src/helpers/storage.rs +++ b/node/bft/src/helpers/storage.rs @@ -17,15 +17,14 @@ use snarkos_node_bft_ledger_service::LedgerService; use snarkos_node_bft_storage_service::StorageService; use snarkvm::{ ledger::{ - block::Block, + block::{Block, Transaction}, narwhal::{BatchCertificate, BatchHeader, Transmission, TransmissionID}, }, - prelude::{anyhow, bail, cfg_iter, ensure, Address, Field, Network, Result}, + prelude::{anyhow, bail, ensure, Address, Field, Network, Result}, }; use indexmap::{map::Entry, IndexMap, IndexSet}; use parking_lot::RwLock; -use rayon::prelude::*; use std::{ collections::{HashMap, HashSet}, sync::{ @@ -602,7 +601,12 @@ impl Storage { } /// Syncs the batch certificate with the block. - pub(crate) fn sync_certificate_with_block(&self, block: &Block, certificate: &BatchCertificate) { + pub(crate) fn sync_certificate_with_block( + &self, + block: &Block, + certificate: &BatchCertificate, + unconfirmed_transactions: &HashMap>, + ) { // Skip if the certificate round is below the GC round. if certificate.round() <= self.gc_round() { return; @@ -614,11 +618,6 @@ impl Storage { // Retrieve the transmissions for the certificate. let mut missing_transmissions = HashMap::new(); - // Reconstruct the unconfirmed transactions. - let mut unconfirmed_transactions = cfg_iter!(block.transactions()) - .filter_map(|tx| tx.to_unconfirmed_transaction().map(|unconfirmed| (unconfirmed.id(), unconfirmed)).ok()) - .collect::>(); - // Iterate over the transmission IDs. for transmission_id in certificate.transmission_ids() { // If the transmission ID already exists in the map, skip it. @@ -650,9 +649,9 @@ impl Storage { } TransmissionID::Transaction(transaction_id) => { // Retrieve the transaction. - match unconfirmed_transactions.remove(transaction_id) { + match unconfirmed_transactions.get(transaction_id) { // Insert the transaction. - Some(transaction) => missing_transmissions.insert(*transmission_id, transaction.into()), + Some(transaction) => missing_transmissions.insert(*transmission_id, transaction.clone().into()), // Otherwise, try to load the unconfirmed transaction from the ledger. None => match self.ledger.get_unconfirmed_transaction(*transaction_id) { // Insert the transaction. diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index 685219f1c1..c1664cc275 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -25,11 +25,13 @@ use snarkos_node_sync::{locators::BlockLocators, BlockSync, BlockSyncMode}; use snarkvm::{ console::{network::Network, types::Field}, ledger::{authority::Authority, block::Block, narwhal::BatchCertificate}, + prelude::cfg_iter, }; use anyhow::{bail, Result}; use parking_lot::Mutex; -use std::{future::Future, net::SocketAddr, sync::Arc}; +use rayon::prelude::*; +use std::{collections::HashMap, future::Future, net::SocketAddr, sync::Arc}; use tokio::{ sync::{oneshot, Mutex as TMutex, OnceCell}, task::JoinHandle, @@ -204,10 +206,17 @@ impl Sync { for block in &blocks { // If the block authority is a subdag, then sync the batch certificates with the block. if let Authority::Quorum(subdag) = block.authority() { + // Reconstruct the unconfirmed transactions. + let unconfirmed_transactions = cfg_iter!(block.transactions()) + .filter_map(|tx| { + tx.to_unconfirmed_transaction().map(|unconfirmed| (unconfirmed.id(), unconfirmed)).ok() + }) + .collect::>(); + // Iterate over the certificates. for certificate in subdag.values().flatten() { // Sync the batch certificate with the block. - self.storage.sync_certificate_with_block(block, certificate); + self.storage.sync_certificate_with_block(block, certificate, &unconfirmed_transactions); } } } @@ -277,10 +286,17 @@ impl Sync { // If the block authority is a subdag, then sync the batch certificates with the block. if let Authority::Quorum(subdag) = block.authority() { + // Reconstruct the unconfirmed transactions. + let unconfirmed_transactions = cfg_iter!(block.transactions()) + .filter_map(|tx| { + tx.to_unconfirmed_transaction().map(|unconfirmed| (unconfirmed.id(), unconfirmed)).ok() + }) + .collect::>(); + // Iterate over the certificates. for certificate in subdag.values().flatten() { // Sync the batch certificate with the block. - self.storage.sync_certificate_with_block(&block, certificate); + self.storage.sync_certificate_with_block(&block, certificate, &unconfirmed_transactions); // If a BFT sender was provided, send the certificate to the BFT. if let Some(bft_sender) = self.bft_sender.get() { // Await the callback to continue. From 4d2392fb85b717fcac1b7aa0e2dadf58a81bc59d Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sun, 11 Feb 2024 09:35:52 -0800 Subject: [PATCH 055/551] Update rev --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 63ba2ebfb5..abeb2bc064 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "7eeb353" +rev = "525764a" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From b2ac620f4a07947c9e7f5541dfa6874b26e3d624 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sun, 11 Feb 2024 10:10:33 -0800 Subject: [PATCH 056/551] Fix CLI network ID check --- Cargo.lock | 116 +++++++++++++++++++------------------- cli/src/commands/start.rs | 2 +- 2 files changed, 59 insertions(+), 59 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f3b2fe265e..c8f1f5fd2a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3526,7 +3526,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "anstyle", "anyhow", @@ -3557,7 +3557,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "aleo-std", "anyhow", @@ -3587,7 +3587,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3601,7 +3601,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3612,7 +3612,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3622,7 +3622,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3632,7 +3632,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "indexmap 2.2.2", "itertools 0.11.0", @@ -3650,12 +3650,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3666,7 +3666,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3681,7 +3681,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3696,7 +3696,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3709,7 +3709,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3718,7 +3718,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3728,7 +3728,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3740,7 +3740,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3752,7 +3752,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3763,7 +3763,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3775,7 +3775,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3788,7 +3788,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "bs58", "snarkvm-console-network", @@ -3799,7 +3799,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "blake2s_simd", "smallvec", @@ -3812,7 +3812,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "aleo-std", "rayon", @@ -3823,7 +3823,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "anyhow", "indexmap 2.2.2", @@ -3846,7 +3846,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "anyhow", "bech32", @@ -3864,7 +3864,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "enum_index", "enum_index_derive", @@ -3885,7 +3885,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3900,7 +3900,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3911,7 +3911,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "snarkvm-console-network-environment", ] @@ -3919,7 +3919,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3929,7 +3929,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3940,7 +3940,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3951,7 +3951,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3962,7 +3962,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3973,7 +3973,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "rand", "rayon", @@ -3987,7 +3987,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "aleo-std", "anyhow", @@ -4004,7 +4004,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "aleo-std", "anyhow", @@ -4029,7 +4029,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "anyhow", "rand", @@ -4041,7 +4041,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4060,7 +4060,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-coinbase" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "aleo-std", "anyhow", @@ -4080,7 +4080,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "anyhow", "indexmap 2.2.2", @@ -4098,7 +4098,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -4111,7 +4111,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4124,7 +4124,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "indexmap 2.2.2", "serde_json", @@ -4136,7 +4136,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "bytes", "serde_json", @@ -4147,7 +4147,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4162,7 +4162,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "bytes", "serde_json", @@ -4175,7 +4175,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "snarkvm-console", "snarkvm-ledger-coinbase", @@ -4184,7 +4184,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "async-trait", "reqwest", @@ -4197,7 +4197,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "aleo-std-storage", "anyhow", @@ -4222,7 +4222,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4237,7 +4237,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4246,7 +4246,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "aleo-std", "anyhow", @@ -4271,7 +4271,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "aleo-std", "anyhow", @@ -4295,7 +4295,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "aleo-std", "colored", @@ -4318,7 +4318,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "indexmap 2.2.2", "paste", @@ -4332,7 +4332,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "bincode", "once_cell", @@ -4345,7 +4345,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "aleo-std", "anyhow", @@ -4366,7 +4366,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7eeb353#7eeb3537edb1415931b7599de4df19b0dc43c25d" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" dependencies = [ "proc-macro2", "quote 1.0.35", diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index aced751606..9bbe503989 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -827,7 +827,7 @@ mod tests { assert_eq!(start.private_key.as_deref(), Some("PRIVATE_KEY")); assert_eq!(start.cdn, "CDN"); assert_eq!(start.rest, "127.0.0.1:3030".parse().unwrap()); - assert_eq!(start.network, 3); + assert_eq!(start.network, 0); assert_eq!(start.peers, "IP1,IP2,IP3"); assert_eq!(start.validators, "IP1,IP2,IP3"); } else { From 5d18ede0de7ba752b7a508742dc1d366ae659c46 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sun, 11 Feb 2024 10:43:00 -0800 Subject: [PATCH 057/551] Update interface --- node/bft/src/helpers/storage.rs | 4 ++-- node/bft/src/primary.rs | 13 +++++-------- node/bft/src/sync/mod.rs | 19 ++++++++++++------- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/node/bft/src/helpers/storage.rs b/node/bft/src/helpers/storage.rs index c06495b3d0..cc4b6d81da 100644 --- a/node/bft/src/helpers/storage.rs +++ b/node/bft/src/helpers/storage.rs @@ -604,7 +604,7 @@ impl Storage { pub(crate) fn sync_certificate_with_block( &self, block: &Block, - certificate: &BatchCertificate, + certificate: BatchCertificate, unconfirmed_transactions: &HashMap>, ) { // Skip if the certificate round is below the GC round. @@ -672,7 +672,7 @@ impl Storage { certificate.round(), certificate.transmission_ids().len() ); - if let Err(error) = self.insert_certificate(certificate.clone(), missing_transmissions) { + if let Err(error) = self.insert_certificate(certificate, missing_transmissions) { error!("Failed to insert certificate '{certificate_id}' from block {} - {error}", block.height()); } } diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 2e391112a3..79cd33a12b 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -557,8 +557,7 @@ impl Primary { self.ensure_is_signing_round(batch_round)?; // Ensure the batch header from the peer is valid. - let storage = self.storage.clone(); - let header = batch_header.clone(); + let (storage, header) = (self.storage.clone(), batch_header.clone()); let missing_transmissions = spawn_blocking!(storage.check_batch_header(&header, transmissions))?; // Inserts the missing transmissions into the workers. self.insert_missing_transmissions_into_workers(peer_ip, missing_transmissions.into_iter())?; @@ -1106,9 +1105,8 @@ impl Primary { // Note: Do not change the `Proposal` to use a HashMap. The ordering there is necessary for safety. let transmissions = transmissions.into_iter().collect::>(); // Store the certified batch. - let storage = self.storage.clone(); - let certificate_clone = certificate.clone(); - spawn_blocking!(storage.insert_certificate(certificate_clone, transmissions))?; + let (storage, certificate_) = (self.storage.clone(), certificate.clone()); + spawn_blocking!(storage.insert_certificate(certificate_, transmissions))?; debug!("Stored a batch certificate for round {}", certificate.round()); // If a BFT sender was provided, send the certificate to the BFT. if let Some(bft_sender) = self.bft_sender.get() { @@ -1187,9 +1185,8 @@ impl Primary { // Check if the certificate needs to be stored. if !self.storage.contains_certificate(certificate.id()) { // Store the batch certificate. - let storage = self.storage.clone(); - let certificate_clone = certificate.clone(); - spawn_blocking!(storage.insert_certificate(certificate_clone, missing_transmissions))?; + let (storage, certificate_) = (self.storage.clone(), certificate.clone()); + spawn_blocking!(storage.insert_certificate(certificate_, missing_transmissions))?; debug!("Stored a batch certificate for round {batch_round} from '{peer_ip}'"); // If a BFT sender was provided, send the round and certificate to the BFT. if let Some(bft_sender) = self.bft_sender.get() { diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index b5e71d9c42..75b7c182b8 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -217,9 +217,12 @@ impl Sync { // Iterate over the certificates. for certificate in subdag.values().flatten().cloned() { // Sync the batch certificate with the block. - let storage = self.storage.clone(); - let block = block.clone(); - let _ = spawn_blocking!(Ok(storage.sync_certificate_with_block(&block, &certificate, &unconfirmed_transactions))); + let (storage, block) = (self.storage.clone(), block.clone()); + let unconfirmed_transactions = unconfirmed_transactions.clone(); + let _ = spawn_blocking!({ + storage.sync_certificate_with_block(&block, certificate, &unconfirmed_transactions); + Ok(()) + }); } } } @@ -299,10 +302,12 @@ impl Sync { // Iterate over the certificates. for certificate in subdag.values().flatten() { // Sync the batch certificate with the block. - let storage = self.storage.clone(); - let block_clone = block.clone(); - let certificate_clone = certificate.clone(); - let _ = spawn_blocking!(Ok(storage.sync_certificate_with_block(&block_clone, &certificate_clone, &unconfirmed_transactions))); + let (storage, block_, certificate_) = (self.storage.clone(), block.clone(), certificate.clone()); + let unconfirmed_transactions = unconfirmed_transactions.clone(); + let _ = spawn_blocking!({ + storage.sync_certificate_with_block(&block_, certificate_, &unconfirmed_transactions); + Ok(()) + }); // If a BFT sender was provided, send the certificate to the BFT. if let Some(bft_sender) = self.bft_sender.get() { From 8982335ce8abd2dc7088c60b6846248edfa2e0f5 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sun, 11 Feb 2024 11:05:42 -0800 Subject: [PATCH 058/551] Use rayon over the certificates --- node/bft/src/sync/mod.rs | 57 +++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index 75b7c182b8..e4e4be10de 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -26,7 +26,7 @@ use snarkos_node_sync::{locators::BlockLocators, BlockSync, BlockSyncMode}; use snarkvm::{ console::{network::Network, types::Field}, ledger::{authority::Authority, block::Block, narwhal::BatchCertificate}, - prelude::cfg_iter, + prelude::{cfg_into_iter, cfg_iter}, }; use anyhow::{bail, Result}; @@ -215,13 +215,16 @@ impl Sync { .collect::>(); // Iterate over the certificates. - for certificate in subdag.values().flatten().cloned() { - // Sync the batch certificate with the block. - let (storage, block) = (self.storage.clone(), block.clone()); - let unconfirmed_transactions = unconfirmed_transactions.clone(); - let _ = spawn_blocking!({ - storage.sync_certificate_with_block(&block, certificate, &unconfirmed_transactions); - Ok(()) + for certificates in subdag.values().cloned() { + cfg_into_iter!(certificates).for_each(|certificate| { + // Sync the batch certificate with the block. + // let (storage, block) = (self.storage.clone(), block.clone()); + // let unconfirmed_transactions = unconfirmed_transactions.clone(); + // let _ = spawn_blocking!({ + // storage.sync_certificate_with_block(&block, certificate, &unconfirmed_transactions); + // Ok(()) + // }); + self.storage.sync_certificate_with_block(&block, certificate, &unconfirmed_transactions); }); } } @@ -300,22 +303,28 @@ impl Sync { .collect::>(); // Iterate over the certificates. - for certificate in subdag.values().flatten() { - // Sync the batch certificate with the block. - let (storage, block_, certificate_) = (self.storage.clone(), block.clone(), certificate.clone()); - let unconfirmed_transactions = unconfirmed_transactions.clone(); - let _ = spawn_blocking!({ - storage.sync_certificate_with_block(&block_, certificate_, &unconfirmed_transactions); - Ok(()) - }); - - // If a BFT sender was provided, send the certificate to the BFT. - if let Some(bft_sender) = self.bft_sender.get() { - // Await the callback to continue. - if let Err(e) = bft_sender.send_sync_bft(certificate.clone()).await { - bail!("Sync - {e}"); - }; - } + for certificates in subdag.values().cloned() { + cfg_into_iter!(certificates).for_each(|certificate| { + // Sync the batch certificate with the block. + // let (storage, block_, certificate_) = (self.storage.clone(), block.clone(), certificate.clone()); + // let unconfirmed_transactions = unconfirmed_transactions.clone(); + // let _ = spawn_blocking!({ + // storage.sync_certificate_with_block(&block_, certificate_, &unconfirmed_transactions); + // Ok(()) + // }); + self.storage.sync_certificate_with_block(&block, certificate.clone(), &unconfirmed_transactions); + + // If a BFT sender was provided, send the certificate to the BFT. + if let Some(bft_sender) = self.bft_sender.get() { + // Await the callback to continue. + let bft_sender = bft_sender.clone(); + tokio::spawn(async move { + if let Err(e) = bft_sender.send_sync_bft(certificate).await { + warn!("Sync - {e}"); + }; + }); + } + }) } } From 36f31a1138c810cc2c4714d178568d9a13c3848b Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sun, 11 Feb 2024 11:15:06 -0800 Subject: [PATCH 059/551] Separate out the async logic --- node/bft/src/sync/mod.rs | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index e4e4be10de..a6316f998c 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -14,7 +14,6 @@ use crate::{ helpers::{BFTSender, Pending, Storage, SyncReceiver}, - spawn_blocking, Gateway, Transport, MAX_FETCH_TIMEOUT_IN_MS, @@ -217,14 +216,7 @@ impl Sync { // Iterate over the certificates. for certificates in subdag.values().cloned() { cfg_into_iter!(certificates).for_each(|certificate| { - // Sync the batch certificate with the block. - // let (storage, block) = (self.storage.clone(), block.clone()); - // let unconfirmed_transactions = unconfirmed_transactions.clone(); - // let _ = spawn_blocking!({ - // storage.sync_certificate_with_block(&block, certificate, &unconfirmed_transactions); - // Ok(()) - // }); - self.storage.sync_certificate_with_block(&block, certificate, &unconfirmed_transactions); + self.storage.sync_certificate_with_block(block, certificate, &unconfirmed_transactions); }); } } @@ -304,27 +296,21 @@ impl Sync { // Iterate over the certificates. for certificates in subdag.values().cloned() { - cfg_into_iter!(certificates).for_each(|certificate| { + cfg_into_iter!(certificates.clone()).for_each(|certificate| { // Sync the batch certificate with the block. - // let (storage, block_, certificate_) = (self.storage.clone(), block.clone(), certificate.clone()); - // let unconfirmed_transactions = unconfirmed_transactions.clone(); - // let _ = spawn_blocking!({ - // storage.sync_certificate_with_block(&block_, certificate_, &unconfirmed_transactions); - // Ok(()) - // }); self.storage.sync_certificate_with_block(&block, certificate.clone(), &unconfirmed_transactions); + }); + // Sync the BFT DAG with the certificates. + for certificate in certificates { // If a BFT sender was provided, send the certificate to the BFT. if let Some(bft_sender) = self.bft_sender.get() { // Await the callback to continue. - let bft_sender = bft_sender.clone(); - tokio::spawn(async move { - if let Err(e) = bft_sender.send_sync_bft(certificate).await { - warn!("Sync - {e}"); - }; - }); + if let Err(e) = bft_sender.send_sync_bft(certificate).await { + bail!("Sync - {e}"); + }; } - }) + } } } From d419d9d90cec5775dc47ed0f95326905e7f6614b Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sun, 11 Feb 2024 11:35:43 -0800 Subject: [PATCH 060/551] Update core count --- cli/src/commands/start.rs | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index 9bbe503989..003094a329 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -464,23 +464,12 @@ impl Start { fn runtime() -> Runtime { // Retrieve the number of cores. let num_cores = num_cpus::get(); - // Determine the number of main cores. - let main_cores = match num_cores { - // Insufficient - 0..=3 => { - eprintln!("The number of cores is insufficient, at least 4 are needed."); - std::process::exit(1); - } - // Efficiency mode - 4..=8 => 2, - // Standard mode - 9..=16 => 8, - // Performance mode - _ => 16, - }; + // Initialize the number of tokio worker threads, max tokio blocking threads, and rayon cores. + // Note: We intentionally set the number of tokio worker threads and number of rayon cores to be + // more than the number of physical cores, because the node is expected to be I/O-bound. let (num_tokio_worker_threads, max_tokio_blocking_threads, num_rayon_cores_global) = - (num_cores, 512, main_cores); + (2 * num_cores, 512, num_cores); // Initialize the parallelization parameters. rayon::ThreadPoolBuilder::new() From cdbc65f35ca877acec1c040e3ca7a57c4a75821f Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sun, 11 Feb 2024 11:51:08 -0800 Subject: [PATCH 061/551] Update redundancy factor --- node/sync/src/block_sync.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node/sync/src/block_sync.rs b/node/sync/src/block_sync.rs index ef19fe47bc..ee5a2528bd 100644 --- a/node/sync/src/block_sync.rs +++ b/node/sync/src/block_sync.rs @@ -36,8 +36,8 @@ use std::{ time::Instant, }; -pub const REDUNDANCY_FACTOR: usize = 3; -const EXTRA_REDUNDANCY_FACTOR: usize = REDUNDANCY_FACTOR * 2; +pub const REDUNDANCY_FACTOR: usize = 1; +const EXTRA_REDUNDANCY_FACTOR: usize = REDUNDANCY_FACTOR * 3; const NUM_SYNC_CANDIDATE_PEERS: usize = REDUNDANCY_FACTOR * 5; const BLOCK_REQUEST_TIMEOUT_IN_SECS: u64 = 600; // 600 seconds From 09b06653901fd631946676957218835e58dee2d7 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sun, 11 Feb 2024 11:57:33 -0800 Subject: [PATCH 062/551] Optimize validator block sync --- node/bft/src/sync/mod.rs | 45 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index c1664cc275..21a6568f01 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -268,6 +268,32 @@ impl Sync { pub async fn sync_storage_with_blocks(&self) -> Result<()> { // Retrieve the latest block height. let mut current_height = self.ledger.latest_block_height() + 1; + + // Find the sync peers. + let sync_peers = self.block_sync.find_sync_peers().map(|x| x.0).unwrap_or_default(); + // Retrieve the highest block height. + let greatest_peer_height = sync_peers.into_values().max().unwrap_or(0u32); + // Determine the number of maximum number of blocks that would have been garbage collected. + let maximum_gc_blocks = u32::try_from(self.storage.max_gc_rounds())?.saturating_div(2); + // Determine the maximum height that the peer would have garbage collected. + let maximum_gc_height = greatest_peer_height.saturating_sub(maximum_gc_blocks); + + // Determine if we need to sync the ledger without BFT. + if current_height <= maximum_gc_height { + // Try to advance the ledger without the BFT. + while let Some(block) = self.block_sync.process_next_block(current_height) { + info!("Syncing the ledger to block {}...", block.height()); + self.sync_ledger_with_block_without_bft(block).await?; + // Update the current height. + current_height += 1; + } + + // Sync the storage with the ledger if we should transition to the BFT sync. + if current_height >= maximum_gc_height { + self.sync_storage_with_ledger_at_bootup().await?; + } + } + // Try to advance the ledger with sync blocks. while let Some(block) = self.block_sync.process_next_block(current_height) { info!("Syncing the BFT to block {}...", block.height()); @@ -279,6 +305,25 @@ impl Sync { Ok(()) } + /// Syncs the ledger with the given block without using the BFT. + pub async fn sync_ledger_with_block_without_bft(&self, block: Block) -> Result<()> { + // Acquire the sync lock. + let _lock = self.lock.lock().await; + + // Check the next block. + self.ledger.check_next_block(&block)?; + + // Attempt to advance to the next block. + self.ledger.advance_to_next_block(&block)?; + + // Sync the height with the block. + self.storage.sync_height_with_block(block.height()); + // Sync the round with the block. + self.storage.sync_round_with_block(block.round()); + + Ok(()) + } + /// Syncs the storage with the given blocks. pub async fn sync_storage_with_block(&self, block: Block) -> Result<()> { // Acquire the sync lock. From cda89fd7f12229633c720ab0bc07a9b1bd4bbe73 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sun, 11 Feb 2024 12:01:02 -0800 Subject: [PATCH 063/551] nit --- node/bft/src/sync/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index 21a6568f01..48ae3fe50e 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -306,7 +306,7 @@ impl Sync { } /// Syncs the ledger with the given block without using the BFT. - pub async fn sync_ledger_with_block_without_bft(&self, block: Block) -> Result<()> { + async fn sync_ledger_with_block_without_bft(&self, block: Block) -> Result<()> { // Acquire the sync lock. let _lock = self.lock.lock().await; From f779241ef1ab21fcf777e933f542d9983125da82 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sun, 11 Feb 2024 12:04:55 -0800 Subject: [PATCH 064/551] Improve logging --- cli/src/commands/start.rs | 4 ++-- cli/src/helpers/mod.rs | 8 ++++---- node/bft/src/bft.rs | 2 +- node/bft/src/primary.rs | 11 ++++++++--- node/bft/src/sync/mod.rs | 6 +++--- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index 003094a329..bc39048348 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -248,7 +248,7 @@ impl Start { let _ = PrivateKey::::new(&mut rng)?; } let private_key = PrivateKey::::new(&mut rng)?; - println!("🔑 Your development private key for node {dev} is {}\n", private_key.to_string().bold()); + println!("🔑 Your development private key for node {dev} is {}.\n", private_key.to_string().bold()); private_key }) } @@ -411,7 +411,7 @@ impl Start { // If the display is not enabled, render the welcome message. if self.nodisplay { // Print the Aleo address. - println!("🪪 Your Aleo address is {}.\n", account.address().to_string().bold()); + println!("👛 Your Aleo address is {}.\n", account.address().to_string().bold()); // Print the node type and network. println!( "🧭 Starting {} on {} at {}.\n", diff --git a/cli/src/helpers/mod.rs b/cli/src/helpers/mod.rs index 6cabe254b2..de3838b1ad 100644 --- a/cli/src/helpers/mod.rs +++ b/cli/src/helpers/mod.rs @@ -41,8 +41,8 @@ pub fn check_open_files_limit(minimum: u64) { // Warn about too low limit. let warning = [ format!("⚠️ The open files limit ({soft_limit}) for this process is lower than recommended."), - format!("⚠️ To ensure correct behavior of the node, please raise it to at least {minimum}."), - "⚠️ See the `ulimit` command and `/etc/security/limits.conf` for more details.".to_owned(), + format!(" • To ensure correct behavior of the node, please raise it to at least {minimum}."), + " • See the `ulimit` command and `/etc/security/limits.conf` for more details.".to_owned(), ] .join("\n") .yellow() @@ -54,8 +54,8 @@ pub fn check_open_files_limit(minimum: u64) { // Warn about unknown limit. let warning = [ format!("⚠️ Unable to check the open files limit for this process due to {err}."), - format!("⚠️ To ensure correct behavior of the node, please ensure it is at least {minimum}."), - "⚠️ See the `ulimit` command and `/etc/security/limits.conf` for more details.".to_owned(), + format!(" • To ensure correct behavior of the node, please ensure it is at least {minimum}."), + " • See the `ulimit` command and `/etc/security/limits.conf` for more details.".to_owned(), ] .join("\n") .yellow() diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 56fc99ea26..bc72924dfb 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -483,7 +483,7 @@ impl BFT { } /* Proceeding to commit the leader. */ - info!("Proceeding to commit round {commit_round} with leader {leader}..."); + info!("Proceeding to commit round {commit_round} with leader '{}'", fmt_id(leader)); // Commit the leader certificate, and all previous leader certificates since the last committed round. self.commit_leader_certificate::(leader_certificate).await diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 79cd33a12b..ff83a4e8ea 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -554,7 +554,11 @@ impl Primary { // Ensure the batch is for the current round. // This method must be called after fetching previous certificates (above), // and prior to checking the batch header (below). - self.ensure_is_signing_round(batch_round)?; + if let Err(e) = self.ensure_is_signing_round(batch_round) { + // If the primary is not signing for the peer's round, then return early. + trace!("Skipped signing a batch for round {batch_round} from '{peer_ip}' - {e}"); + return Ok(()); + } // Ensure the batch header from the peer is valid. let (storage, header) = (self.storage.clone(), batch_header.clone()); @@ -1266,9 +1270,10 @@ impl Primary { return Ok(Default::default()); } - // Ensure this batch ID is new. + // Ensure this batch ID is new, otherwise return early. if self.storage.contains_batch(batch_header.batch_id()) { - bail!("Batch for round {} from peer has already been processed", batch_header.round()) + trace!("Batch for round {} from peer has already been processed", batch_header.round()); + return Ok(Default::default()); } // Retrieve the workers. diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index a6316f998c..ecf7bd217e 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -13,7 +13,7 @@ // limitations under the License. use crate::{ - helpers::{BFTSender, Pending, Storage, SyncReceiver}, + helpers::{fmt_id, BFTSender, Pending, Storage, SyncReceiver}, Gateway, Transport, MAX_FETCH_TIMEOUT_IN_MS, @@ -358,7 +358,7 @@ impl Sync { if self.pending.insert(certificate_id, peer_ip, Some(callback_sender)) { // Send the certificate request to the peer. if self.gateway.send(peer_ip, Event::CertificateRequest(certificate_id.into())).await.is_none() { - bail!("Unable to fetch batch certificate {certificate_id} - failed to send request") + bail!("Unable to fetch certificate {} - failed to send request", fmt_id(certificate_id)) } } // Wait for the certificate to be fetched. @@ -367,7 +367,7 @@ impl Sync { // If the certificate was fetched, return it. Ok(result) => Ok(result?), // If the certificate was not fetched, return an error. - Err(e) => bail!("Unable to fetch batch certificate {certificate_id} - (timeout) {e}"), + Err(e) => bail!("Unable to fetch certificate {} - (timeout) {e}", fmt_id(certificate_id)), } } From f4b29c14b2d954c7c6129611c4a794c64e363301 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sun, 11 Feb 2024 12:04:55 -0800 Subject: [PATCH 065/551] Improve logging --- cli/src/commands/start.rs | 4 ++-- cli/src/helpers/mod.rs | 8 ++++---- node/bft/src/bft.rs | 2 +- node/bft/src/primary.rs | 11 ++++++++--- node/bft/src/sync/mod.rs | 6 +++--- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index 003094a329..bc39048348 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -248,7 +248,7 @@ impl Start { let _ = PrivateKey::::new(&mut rng)?; } let private_key = PrivateKey::::new(&mut rng)?; - println!("🔑 Your development private key for node {dev} is {}\n", private_key.to_string().bold()); + println!("🔑 Your development private key for node {dev} is {}.\n", private_key.to_string().bold()); private_key }) } @@ -411,7 +411,7 @@ impl Start { // If the display is not enabled, render the welcome message. if self.nodisplay { // Print the Aleo address. - println!("🪪 Your Aleo address is {}.\n", account.address().to_string().bold()); + println!("👛 Your Aleo address is {}.\n", account.address().to_string().bold()); // Print the node type and network. println!( "🧭 Starting {} on {} at {}.\n", diff --git a/cli/src/helpers/mod.rs b/cli/src/helpers/mod.rs index 6cabe254b2..de3838b1ad 100644 --- a/cli/src/helpers/mod.rs +++ b/cli/src/helpers/mod.rs @@ -41,8 +41,8 @@ pub fn check_open_files_limit(minimum: u64) { // Warn about too low limit. let warning = [ format!("⚠️ The open files limit ({soft_limit}) for this process is lower than recommended."), - format!("⚠️ To ensure correct behavior of the node, please raise it to at least {minimum}."), - "⚠️ See the `ulimit` command and `/etc/security/limits.conf` for more details.".to_owned(), + format!(" • To ensure correct behavior of the node, please raise it to at least {minimum}."), + " • See the `ulimit` command and `/etc/security/limits.conf` for more details.".to_owned(), ] .join("\n") .yellow() @@ -54,8 +54,8 @@ pub fn check_open_files_limit(minimum: u64) { // Warn about unknown limit. let warning = [ format!("⚠️ Unable to check the open files limit for this process due to {err}."), - format!("⚠️ To ensure correct behavior of the node, please ensure it is at least {minimum}."), - "⚠️ See the `ulimit` command and `/etc/security/limits.conf` for more details.".to_owned(), + format!(" • To ensure correct behavior of the node, please ensure it is at least {minimum}."), + " • See the `ulimit` command and `/etc/security/limits.conf` for more details.".to_owned(), ] .join("\n") .yellow() diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 56fc99ea26..bc72924dfb 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -483,7 +483,7 @@ impl BFT { } /* Proceeding to commit the leader. */ - info!("Proceeding to commit round {commit_round} with leader {leader}..."); + info!("Proceeding to commit round {commit_round} with leader '{}'", fmt_id(leader)); // Commit the leader certificate, and all previous leader certificates since the last committed round. self.commit_leader_certificate::(leader_certificate).await diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 79cd33a12b..ff83a4e8ea 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -554,7 +554,11 @@ impl Primary { // Ensure the batch is for the current round. // This method must be called after fetching previous certificates (above), // and prior to checking the batch header (below). - self.ensure_is_signing_round(batch_round)?; + if let Err(e) = self.ensure_is_signing_round(batch_round) { + // If the primary is not signing for the peer's round, then return early. + trace!("Skipped signing a batch for round {batch_round} from '{peer_ip}' - {e}"); + return Ok(()); + } // Ensure the batch header from the peer is valid. let (storage, header) = (self.storage.clone(), batch_header.clone()); @@ -1266,9 +1270,10 @@ impl Primary { return Ok(Default::default()); } - // Ensure this batch ID is new. + // Ensure this batch ID is new, otherwise return early. if self.storage.contains_batch(batch_header.batch_id()) { - bail!("Batch for round {} from peer has already been processed", batch_header.round()) + trace!("Batch for round {} from peer has already been processed", batch_header.round()); + return Ok(Default::default()); } // Retrieve the workers. diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index a6316f998c..ecf7bd217e 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -13,7 +13,7 @@ // limitations under the License. use crate::{ - helpers::{BFTSender, Pending, Storage, SyncReceiver}, + helpers::{fmt_id, BFTSender, Pending, Storage, SyncReceiver}, Gateway, Transport, MAX_FETCH_TIMEOUT_IN_MS, @@ -358,7 +358,7 @@ impl Sync { if self.pending.insert(certificate_id, peer_ip, Some(callback_sender)) { // Send the certificate request to the peer. if self.gateway.send(peer_ip, Event::CertificateRequest(certificate_id.into())).await.is_none() { - bail!("Unable to fetch batch certificate {certificate_id} - failed to send request") + bail!("Unable to fetch certificate {} - failed to send request", fmt_id(certificate_id)) } } // Wait for the certificate to be fetched. @@ -367,7 +367,7 @@ impl Sync { // If the certificate was fetched, return it. Ok(result) => Ok(result?), // If the certificate was not fetched, return an error. - Err(e) => bail!("Unable to fetch batch certificate {certificate_id} - (timeout) {e}"), + Err(e) => bail!("Unable to fetch certificate {} - (timeout) {e}", fmt_id(certificate_id)), } } From 3820be30d9ee72348e9419eecf449d1414a94120 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sun, 11 Feb 2024 12:15:11 -0800 Subject: [PATCH 066/551] Update node/bft/src/primary.rs Signed-off-by: Howard Wu <9260812+howardwu@users.noreply.github.com> --- node/bft/src/primary.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index ff83a4e8ea..ac9cad8e30 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -556,7 +556,7 @@ impl Primary { // and prior to checking the batch header (below). if let Err(e) = self.ensure_is_signing_round(batch_round) { // If the primary is not signing for the peer's round, then return early. - trace!("Skipped signing a batch for round {batch_round} from '{peer_ip}' - {e}"); + debug!("{e} from '{peer_ip}'"); return Ok(()); } From 07807715b3565ffbf321b339cbaf6a5d9ec45182 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sun, 11 Feb 2024 12:34:22 -0800 Subject: [PATCH 067/551] Update constant --- node/sync/src/block_sync.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/node/sync/src/block_sync.rs b/node/sync/src/block_sync.rs index ee5a2528bd..97e05561bd 100644 --- a/node/sync/src/block_sync.rs +++ b/node/sync/src/block_sync.rs @@ -36,7 +36,10 @@ use std::{ time::Instant, }; +#[cfg(not(test))] pub const REDUNDANCY_FACTOR: usize = 1; +#[cfg(test)] +pub const REDUNDANCY_FACTOR: usize = 3; const EXTRA_REDUNDANCY_FACTOR: usize = REDUNDANCY_FACTOR * 3; const NUM_SYNC_CANDIDATE_PEERS: usize = REDUNDANCY_FACTOR * 5; From 06566aa84f2e888e7b3ffb2ef115e71d72ef4ad3 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sun, 11 Feb 2024 12:55:13 -0800 Subject: [PATCH 068/551] Limit outgoing certificate requests to REDUNDANCY_FACTOR --- node/bft/src/sync/mod.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index ecf7bd217e..d3cc6d9d15 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -21,7 +21,7 @@ use crate::{ }; use snarkos_node_bft_events::{CertificateRequest, CertificateResponse, Event}; use snarkos_node_bft_ledger_service::LedgerService; -use snarkos_node_sync::{locators::BlockLocators, BlockSync, BlockSyncMode}; +use snarkos_node_sync::{locators::BlockLocators, BlockSync, BlockSyncMode, REDUNDANCY_FACTOR}; use snarkvm::{ console::{network::Network, types::Field}, ledger::{authority::Authority, block::Block, narwhal::BatchCertificate}, @@ -356,9 +356,19 @@ impl Sync { let (callback_sender, callback_receiver) = oneshot::channel(); // Insert the certificate ID into the pending queue. if self.pending.insert(certificate_id, peer_ip, Some(callback_sender)) { - // Send the certificate request to the peer. - if self.gateway.send(peer_ip, Event::CertificateRequest(certificate_id.into())).await.is_none() { - bail!("Unable to fetch certificate {} - failed to send request", fmt_id(certificate_id)) + // Determine how many requests have been sent for the certificate. + let num_requests = self.pending.get(certificate_id).map(|pending| pending.len()).unwrap_or(0); + // If the number of requests is less than the redundancy factor, send the certificate request to the peer. + if num_requests <= REDUNDANCY_FACTOR { + // Send the certificate request to the peer. + if self.gateway.send(peer_ip, Event::CertificateRequest(certificate_id.into())).await.is_none() { + bail!("Unable to fetch batch certificate {certificate_id} - failed to send request") + } + } else { + debug!( + "Skipped sending certificate request to {peer_ip} for {} - already pending {REDUNDANCY_FACTOR} requests", + fmt_id(certificate_id) + ); } } // Wait for the certificate to be fetched. From f1092409013cda9e63c9884cc7cdd88538e1462d Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sun, 11 Feb 2024 12:55:25 -0800 Subject: [PATCH 069/551] Limit outgoing transmission requests to REDUNDANCY_FACTOR --- node/bft/src/worker.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index 7dc0bfc1b8..390fad22a7 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -21,6 +21,7 @@ use crate::{ MAX_WORKERS, }; use snarkos_node_bft_ledger_service::LedgerService; +use snarkos_node_sync::REDUNDANCY_FACTOR; use snarkvm::{ console::prelude::*, ledger::{ @@ -386,9 +387,19 @@ impl Worker { let (callback_sender, callback_receiver) = oneshot::channel(); // Insert the transmission ID into the pending queue. self.pending.insert(transmission_id, peer_ip, Some(callback_sender)); - // Send the transmission request to the peer. - if self.gateway.send(peer_ip, Event::TransmissionRequest(transmission_id.into())).await.is_none() { - bail!("Unable to fetch transmission - failed to send request") + // Determine how many requests have been sent for the transmission. + let num_requests = self.pending.get(transmission_id).map(|pending| pending.len()).unwrap_or(0); + // If the number of requests is less than the redundancy factor, send the transmission request to the peer. + if num_requests <= REDUNDANCY_FACTOR { + // Send the transmission request to the peer. + if self.gateway.send(peer_ip, Event::TransmissionRequest(transmission_id.into())).await.is_none() { + bail!("Unable to fetch transmission - failed to send request") + } + } else { + debug!( + "Skipped sending transmission request to {peer_ip} for {} - already pending {REDUNDANCY_FACTOR} requests", + fmt_id(transmission_id) + ); } // Wait for the transmission to be fetched. match timeout(Duration::from_millis(MAX_FETCH_TIMEOUT_IN_MS), callback_receiver).await { From 36726e6489bbdb8a975af69a0a1c541655826105 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sun, 11 Feb 2024 13:17:04 -0800 Subject: [PATCH 070/551] Handle sync loop with try_sync, and optimize the while loop --- node/bft/src/sync/mod.rs | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index 786d1d8d3f..f8f535fa99 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -99,6 +99,11 @@ impl Sync { let communication = &self_.gateway; // let communication = &node.router; self_.block_sync.try_block_sync(communication).await; + + // Sync the storage with the blocks. + if let Err(e) = self_.sync_storage_with_blocks().await { + error!("Unable to sync storage with blocks - {e}"); + } } })); @@ -122,13 +127,6 @@ impl Sync { continue; } - // Sync the storage with the blocks. - if let Err(e) = self_.sync_storage_with_blocks().await { - // Send the error to the callback. - callback.send(Err(e)).ok(); - continue; - } - // Send the result to the callback. callback.send(Ok(())).ok(); } @@ -185,9 +183,11 @@ impl Sync { // Retrieve the block height. let block_height = latest_block.height(); + // Determine the number of maximum number of blocks that would have been garbage collected. + let max_gc_blocks = u32::try_from(self.storage.max_gc_rounds())?.saturating_div(2); // Determine the earliest height, conservatively set to the block height minus the max GC rounds. // By virtue of the BFT protocol, we can guarantee that all GC range blocks will be loaded. - let gc_height = block_height.saturating_sub(u32::try_from(self.storage.max_gc_rounds())?); + let gc_height = block_height.saturating_sub(max_gc_blocks); // Retrieve the blocks. let blocks = self.ledger.get_blocks(gc_height..block_height.saturating_add(1))?; @@ -270,27 +270,28 @@ impl Sync { // Retrieve the latest block height. let mut current_height = self.ledger.latest_block_height() + 1; - // Find the sync peers. - let sync_peers = self.block_sync.find_sync_peers().map(|x| x.0).unwrap_or_default(); - // Retrieve the highest block height. - let greatest_peer_height = sync_peers.into_values().max().unwrap_or(0u32); + // Retrieve the maximum block height of the peers. + let tip = self.block_sync.find_sync_peers().map(|(x, _)| x.into_values().max().unwrap_or(0)).unwrap_or(0); // Determine the number of maximum number of blocks that would have been garbage collected. - let maximum_gc_blocks = u32::try_from(self.storage.max_gc_rounds())?.saturating_div(2); + let max_gc_blocks = u32::try_from(self.storage.max_gc_rounds())?.saturating_div(2); // Determine the maximum height that the peer would have garbage collected. - let maximum_gc_height = greatest_peer_height.saturating_sub(maximum_gc_blocks); + let max_gc_height = tip.saturating_sub(max_gc_blocks); - // Determine if we need to sync the ledger without BFT. - if current_height <= maximum_gc_height { - // Try to advance the ledger without the BFT. + // Determine if we can sync the ledger without updating the BFT. + if current_height <= max_gc_height { + // Try to advance the ledger without updating the BFT. while let Some(block) = self.block_sync.process_next_block(current_height) { + // Break if the block height is greater than the maximum GC height. + if block.height() >= max_gc_height { + break; + } info!("Syncing the ledger to block {}...", block.height()); self.sync_ledger_with_block_without_bft(block).await?; // Update the current height. current_height += 1; } - // Sync the storage with the ledger if we should transition to the BFT sync. - if current_height >= maximum_gc_height { + if current_height >= max_gc_height { self.sync_storage_with_ledger_at_bootup().await?; } } @@ -313,7 +314,6 @@ impl Sync { // Check the next block. self.ledger.check_next_block(&block)?; - // Attempt to advance to the next block. self.ledger.advance_to_next_block(&block)?; From 8310e0a7ac1ada5693e08927de3d589af7ec886c Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sun, 11 Feb 2024 13:34:27 -0800 Subject: [PATCH 071/551] Handle break and error cases better --- node/bft/src/sync/mod.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index f8f535fa99..6ada95da55 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -281,18 +281,20 @@ impl Sync { if current_height <= max_gc_height { // Try to advance the ledger without updating the BFT. while let Some(block) = self.block_sync.process_next_block(current_height) { - // Break if the block height is greater than the maximum GC height. - if block.height() >= max_gc_height { - break; - } info!("Syncing the ledger to block {}...", block.height()); self.sync_ledger_with_block_without_bft(block).await?; // Update the current height. current_height += 1; + // Break if the current height exceeds the maximum GC height. + if current_height > max_gc_height { + break; + } } // Sync the storage with the ledger if we should transition to the BFT sync. - if current_height >= max_gc_height { - self.sync_storage_with_ledger_at_bootup().await?; + if current_height > max_gc_height { + if let Err(e) = self.sync_storage_with_ledger_at_bootup().await { + error!("BFT sync (with bootup routine) failed - {e}"); + } } } @@ -307,7 +309,7 @@ impl Sync { Ok(()) } - /// Syncs the ledger with the given block without using the BFT. + /// Syncs the ledger with the given block without updating the BFT. async fn sync_ledger_with_block_without_bft(&self, block: Block) -> Result<()> { // Acquire the sync lock. let _lock = self.lock.lock().await; From 95767cacc45ebf42f7e41229729568280b8800d8 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sun, 11 Feb 2024 15:52:58 -0800 Subject: [PATCH 072/551] Add a response lock for more frequent polling --- node/bft/src/sync/mod.rs | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index 6ada95da55..e8fd9a0d6a 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -53,8 +53,10 @@ pub struct Sync { bft_sender: Arc>>, /// The spawned handles. handles: Arc>>>, + /// The response lock. + response_lock: Arc>, /// The sync lock. - lock: Arc>, + sync_lock: Arc>, } impl Sync { @@ -71,7 +73,8 @@ impl Sync { pending: Default::default(), bft_sender: Default::default(), handles: Default::default(), - lock: Default::default(), + response_lock: Default::default(), + sync_lock: Default::default(), } } @@ -127,6 +130,13 @@ impl Sync { continue; } + // Sync the storage with the blocks. + if let Err(e) = self_.sync_storage_with_blocks().await { + // Send the error to the callback. + callback.send(Err(e)).ok(); + continue; + } + // Send the result to the callback. callback.send(Ok(())).ok(); } @@ -192,7 +202,7 @@ impl Sync { let blocks = self.ledger.get_blocks(gc_height..block_height.saturating_add(1))?; // Acquire the sync lock. - let _lock = self.lock.lock().await; + let _lock = self.sync_lock.lock().await; debug!("Syncing storage with the ledger from block {} to {}...", gc_height, block_height.saturating_add(1)); @@ -267,6 +277,9 @@ impl Sync { /// Syncs the storage with the given blocks. pub async fn sync_storage_with_blocks(&self) -> Result<()> { + // Acquire the response lock. + let _lock = self.response_lock.lock().await; + // Retrieve the latest block height. let mut current_height = self.ledger.latest_block_height() + 1; @@ -312,7 +325,7 @@ impl Sync { /// Syncs the ledger with the given block without updating the BFT. async fn sync_ledger_with_block_without_bft(&self, block: Block) -> Result<()> { // Acquire the sync lock. - let _lock = self.lock.lock().await; + let _lock = self.sync_lock.lock().await; // Check the next block. self.ledger.check_next_block(&block)?; @@ -330,7 +343,7 @@ impl Sync { /// Syncs the storage with the given blocks. pub async fn sync_storage_with_block(&self, block: Block) -> Result<()> { // Acquire the sync lock. - let _lock = self.lock.lock().await; + let _lock = self.sync_lock.lock().await; // If the block authority is a subdag, then sync the batch certificates with the block. if let Authority::Quorum(subdag) = block.authority() { @@ -454,8 +467,10 @@ impl Sync { /// Shuts down the primary. pub async fn shut_down(&self) { info!("Shutting down the sync module..."); + // Acquire the response lock. + let _lock = self.response_lock.lock().await; // Acquire the sync lock. - let _lock = self.lock.lock().await; + let _lock = self.sync_lock.lock().await; // Abort the tasks. self.handles.lock().iter().for_each(|handle| handle.abort()); } From cf88c44be7f96c64d42ee86ca93461026e43eefb Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sun, 11 Feb 2024 15:53:14 -0800 Subject: [PATCH 073/551] Add expiration for pending callbacks --- node/bft/src/helpers/pending.rs | 38 ++++++++++++++++++++++++++++----- node/bft/src/sync/mod.rs | 8 +++---- node/bft/src/worker.rs | 8 +++---- 3 files changed, 41 insertions(+), 13 deletions(-) diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index 033d59408b..fa78eb6ff8 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -18,16 +18,15 @@ use std::{ hash::Hash, net::SocketAddr, }; +use time::OffsetDateTime; use tokio::sync::oneshot; #[derive(Debug)] pub struct Pending { /// The map of pending `items` to `peer IPs` that have the item. pending: RwLock>>, - /// TODO (howardwu): Expire callbacks that have not been called after a certain amount of time, - /// or clear the callbacks that are older than a certain round. /// The optional callback queue. - callbacks: Mutex>>>, + callbacks: Mutex, i64)>>>, } impl Default for Pending { @@ -68,6 +67,16 @@ impl Pending { self.pending.read().get(&item.into()).cloned() } + /// Returns the number of pending callbacks for the specified `item`. + pub fn num_callbacks(&self, item: impl Into) -> usize { + let item = item.into(); + // Clear the callbacks that have expired. + self.clear_expired_callbacks_for_item(item); + + // Return the number of live callbacks. + self.callbacks.lock().get(&item).map_or(0, |callbacks| callbacks.len()) + } + /// Inserts the specified `item` and `peer IP` to the pending queue, /// returning `true` if the `peer IP` was newly-inserted into the entry for the `item`. /// @@ -77,9 +86,13 @@ impl Pending { let item = item.into(); // Insert the peer IP into the pending queue. let result = self.pending.write().entry(item).or_default().insert(peer_ip); + + // Clear the callbacks that have expired. + self.clear_expired_callbacks_for_item(item); + // If a callback is provided, insert it into the callback queue. if let Some(callback) = callback { - self.callbacks.lock().entry(item).or_default().push(callback); + self.callbacks.lock().entry(item).or_default().push((callback, OffsetDateTime::now_utc().unix_timestamp())); } // Return the result. result @@ -96,7 +109,7 @@ impl Pending { if let Some(callbacks) = self.callbacks.lock().remove(&item) { if let Some(callback_value) = callback_value { // Send a notification to the callback. - for callback in callbacks { + for (callback, _) in callbacks { callback.send(callback_value.clone()).ok(); } } @@ -104,6 +117,21 @@ impl Pending { // Return the result. result } + + /// Removes the callbacks for the specified `item` that have expired. + pub fn clear_expired_callbacks_for_item(&self, item: impl Into) { + // Initialize the callback timeout in seconds. + const CALLBACK_TIMEOUT_IN_SECS: i64 = 5; + + // Fetch the current timestamp. + let now = OffsetDateTime::now_utc().unix_timestamp(); + + // Clear the callbacks that have expired. + if let Some(callbacks) = self.callbacks.lock().get_mut(&item.into()) { + // Remove the callbacks that have expired. + callbacks.retain(|(_, timestamp)| now - *timestamp <= CALLBACK_TIMEOUT_IN_SECS); + } + } } #[cfg(test)] diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index d3cc6d9d15..994ab9a83f 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -356,10 +356,10 @@ impl Sync { let (callback_sender, callback_receiver) = oneshot::channel(); // Insert the certificate ID into the pending queue. if self.pending.insert(certificate_id, peer_ip, Some(callback_sender)) { - // Determine how many requests have been sent for the certificate. - let num_requests = self.pending.get(certificate_id).map(|pending| pending.len()).unwrap_or(0); - // If the number of requests is less than the redundancy factor, send the certificate request to the peer. - if num_requests <= REDUNDANCY_FACTOR { + // Determine how many requests are pending for the certificate. + let num_pending_requests = self.pending.num_callbacks(certificate_id); + // If the number of requests is less than or equal to the redundancy factor, send the certificate request to the peer. + if num_pending_requests <= REDUNDANCY_FACTOR { // Send the certificate request to the peer. if self.gateway.send(peer_ip, Event::CertificateRequest(certificate_id.into())).await.is_none() { bail!("Unable to fetch batch certificate {certificate_id} - failed to send request") diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index 390fad22a7..a88ed0b502 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -387,10 +387,10 @@ impl Worker { let (callback_sender, callback_receiver) = oneshot::channel(); // Insert the transmission ID into the pending queue. self.pending.insert(transmission_id, peer_ip, Some(callback_sender)); - // Determine how many requests have been sent for the transmission. - let num_requests = self.pending.get(transmission_id).map(|pending| pending.len()).unwrap_or(0); - // If the number of requests is less than the redundancy factor, send the transmission request to the peer. - if num_requests <= REDUNDANCY_FACTOR { + // Determine how many requests are pending for the transmission. + let num_pending_requests = self.pending.num_callbacks(transmission_id); + // If the number of requests is less than or equal to the the redundancy factor, send the transmission request to the peer. + if num_pending_requests <= REDUNDANCY_FACTOR { // Send the transmission request to the peer. if self.gateway.send(peer_ip, Event::TransmissionRequest(transmission_id.into())).await.is_none() { bail!("Unable to fetch transmission - failed to send request") From c90466954a7625631c53a435f8260f67189f5b4d Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sun, 11 Feb 2024 16:11:29 -0800 Subject: [PATCH 074/551] Allow syncing ledger to tip without bft first --- node/bft/src/sync/mod.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index e8fd9a0d6a..dc0d974db2 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -290,18 +290,14 @@ impl Sync { // Determine the maximum height that the peer would have garbage collected. let max_gc_height = tip.saturating_sub(max_gc_blocks); - // Determine if we can sync the ledger without updating the BFT. + // Determine if we can sync the ledger without updating the BFT first. if current_height <= max_gc_height { - // Try to advance the ledger without updating the BFT. + // Try to advance the ledger *to tip* without updating the BFT. while let Some(block) = self.block_sync.process_next_block(current_height) { info!("Syncing the ledger to block {}...", block.height()); self.sync_ledger_with_block_without_bft(block).await?; // Update the current height. current_height += 1; - // Break if the current height exceeds the maximum GC height. - if current_height > max_gc_height { - break; - } } // Sync the storage with the ledger if we should transition to the BFT sync. if current_height > max_gc_height { From 0ac9bfcaf8c5980be1095cbc88ea45e579b77679 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sun, 11 Feb 2024 16:41:55 -0800 Subject: [PATCH 075/551] Use NUM_REDUNDANT_REQUESTS --- node/bft/src/helpers/pending.rs | 5 +++++ node/bft/src/sync/mod.rs | 8 ++++---- node/bft/src/worker.rs | 7 +++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index fa78eb6ff8..dc5893a171 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -21,6 +21,11 @@ use std::{ use time::OffsetDateTime; use tokio::sync::oneshot; +#[cfg(not(test))] +pub const NUM_REDUNDANT_REQUESTS: usize = 2; +#[cfg(test)] +pub const NUM_REDUNDANT_REQUESTS: usize = 10; + #[derive(Debug)] pub struct Pending { /// The map of pending `items` to `peer IPs` that have the item. diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index 019b994607..a454bcd0d1 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -13,7 +13,7 @@ // limitations under the License. use crate::{ - helpers::{fmt_id, BFTSender, Pending, Storage, SyncReceiver}, + helpers::{fmt_id, BFTSender, Pending, Storage, SyncReceiver, NUM_REDUNDANT_REQUESTS}, Gateway, Transport, MAX_FETCH_TIMEOUT_IN_MS, @@ -21,7 +21,7 @@ use crate::{ }; use snarkos_node_bft_events::{CertificateRequest, CertificateResponse, Event}; use snarkos_node_bft_ledger_service::LedgerService; -use snarkos_node_sync::{locators::BlockLocators, BlockSync, BlockSyncMode, REDUNDANCY_FACTOR}; +use snarkos_node_sync::{locators::BlockLocators, BlockSync, BlockSyncMode}; use snarkvm::{ console::{network::Network, types::Field}, ledger::{authority::Authority, block::Block, narwhal::BatchCertificate}, @@ -415,14 +415,14 @@ impl Sync { // Determine how many requests are pending for the certificate. let num_pending_requests = self.pending.num_callbacks(certificate_id); // If the number of requests is less than or equal to the redundancy factor, send the certificate request to the peer. - if num_pending_requests <= REDUNDANCY_FACTOR { + if num_pending_requests <= NUM_REDUNDANT_REQUESTS { // Send the certificate request to the peer. if self.gateway.send(peer_ip, Event::CertificateRequest(certificate_id.into())).await.is_none() { bail!("Unable to fetch batch certificate {certificate_id} - failed to send request") } } else { debug!( - "Skipped sending certificate request to {peer_ip} for {} - already pending {REDUNDANCY_FACTOR} requests", + "Skipped sending certificate request to {peer_ip} for {} - already pending {NUM_REDUNDANT_REQUESTS} requests", fmt_id(certificate_id) ); } diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index a88ed0b502..090b04d6aa 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -14,14 +14,13 @@ use crate::{ events::{Event, TransmissionRequest, TransmissionResponse}, - helpers::{fmt_id, Pending, Ready, Storage, WorkerReceiver}, + helpers::{fmt_id, Pending, Ready, Storage, WorkerReceiver, NUM_REDUNDANT_REQUESTS}, ProposedBatch, Transport, MAX_FETCH_TIMEOUT_IN_MS, MAX_WORKERS, }; use snarkos_node_bft_ledger_service::LedgerService; -use snarkos_node_sync::REDUNDANCY_FACTOR; use snarkvm::{ console::prelude::*, ledger::{ @@ -390,14 +389,14 @@ impl Worker { // Determine how many requests are pending for the transmission. let num_pending_requests = self.pending.num_callbacks(transmission_id); // If the number of requests is less than or equal to the the redundancy factor, send the transmission request to the peer. - if num_pending_requests <= REDUNDANCY_FACTOR { + if num_pending_requests <= NUM_REDUNDANT_REQUESTS { // Send the transmission request to the peer. if self.gateway.send(peer_ip, Event::TransmissionRequest(transmission_id.into())).await.is_none() { bail!("Unable to fetch transmission - failed to send request") } } else { debug!( - "Skipped sending transmission request to {peer_ip} for {} - already pending {REDUNDANCY_FACTOR} requests", + "Skipped sending transmission request to {peer_ip} for {} - already pending {NUM_REDUNDANT_REQUESTS} requests", fmt_id(transmission_id) ); } From 82758cc5231db54bd3fdd6a49d78b20dc95598a9 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sun, 11 Feb 2024 17:01:18 -0800 Subject: [PATCH 076/551] Add test for expired callbacks --- node/bft/src/helpers/pending.rs | 56 +++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index dc5893a171..c79a334f8b 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -26,6 +26,8 @@ pub const NUM_REDUNDANT_REQUESTS: usize = 2; #[cfg(test)] pub const NUM_REDUNDANT_REQUESTS: usize = 10; +const CALLBACK_TIMEOUT_IN_SECS: i64 = 5; + #[derive(Debug)] pub struct Pending { /// The map of pending `items` to `peer IPs` that have the item. @@ -125,9 +127,6 @@ impl Pending { /// Removes the callbacks for the specified `item` that have expired. pub fn clear_expired_callbacks_for_item(&self, item: impl Into) { - // Initialize the callback timeout in seconds. - const CALLBACK_TIMEOUT_IN_SECS: i64 = 5; - // Fetch the current timestamp. let now = OffsetDateTime::now_utc().unix_timestamp(); @@ -147,6 +146,8 @@ mod tests { prelude::{Rng, TestRng}, }; + use std::{thread, time::Duration}; + type CurrentNetwork = snarkvm::prelude::MainnetV0; #[test] @@ -206,6 +207,55 @@ mod tests { // Check empty again. assert!(pending.is_empty()); } + + #[test] + fn test_expired_callbacks() { + let rng = &mut TestRng::default(); + + // Initialize the ready queue. + let pending = Pending::, ()>::new(); + + // Check initially empty. + assert!(pending.is_empty()); + assert_eq!(pending.len(), 0); + + // Initialize the commitments. + let commitment_1 = TransmissionID::Solution(PuzzleCommitment::from_g1_affine(rng.gen())); + + // Initialize the SocketAddrs. + let addr_1 = SocketAddr::from(([127, 0, 0, 1], 1234)); + let addr_2 = SocketAddr::from(([127, 0, 0, 1], 2345)); + let addr_3 = SocketAddr::from(([127, 0, 0, 1], 3456)); + + // Initialize the callbacks. + let (callback_sender_1, _) = oneshot::channel(); + let (callback_sender_2, _) = oneshot::channel(); + let (callback_sender_3, _) = oneshot::channel(); + + // Insert the commitments. + assert!(pending.insert(commitment_1, addr_1, Some(callback_sender_1))); + assert!(pending.insert(commitment_1, addr_2, Some(callback_sender_2))); + + // Sleep for a few seconds. + thread::sleep(Duration::from_secs(CALLBACK_TIMEOUT_IN_SECS as u64 - 1)); + + assert!(pending.insert(commitment_1, addr_3, Some(callback_sender_3))); + + // Check that the number of callbacks has not changed. + assert_eq!(pending.num_callbacks(commitment_1), 3); + + // Wait for 2 seconds. + thread::sleep(Duration::from_secs(2)); + + // Ensure that the expired callbacks have been removed. + assert_eq!(pending.num_callbacks(commitment_1), 1); + + // Wait for `CALLBACK_TIMEOUT_IN_SECS` seconds. + thread::sleep(Duration::from_secs(CALLBACK_TIMEOUT_IN_SECS as u64)); + + // Ensure that the expired callbacks have been removed. + assert_eq!(pending.num_callbacks(commitment_1), 0); + } } #[cfg(test)] From 310d9b624c3214db6327356bdb4004f85492d0e0 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sun, 11 Feb 2024 17:34:42 -0800 Subject: [PATCH 077/551] Clean up logging --- node/bft/src/helpers/pending.rs | 10 +++++----- node/bft/src/sync/mod.rs | 5 +---- node/bft/src/worker.rs | 5 +---- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index c79a334f8b..7c30e31f97 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +use crate::MAX_FETCH_TIMEOUT_IN_MS; + use parking_lot::{Mutex, RwLock}; use std::{ collections::{HashMap, HashSet}, @@ -26,7 +28,7 @@ pub const NUM_REDUNDANT_REQUESTS: usize = 2; #[cfg(test)] pub const NUM_REDUNDANT_REQUESTS: usize = 10; -const CALLBACK_TIMEOUT_IN_SECS: i64 = 5; +const CALLBACK_TIMEOUT_IN_SECS: i64 = MAX_FETCH_TIMEOUT_IN_MS as i64 / 1000; #[derive(Debug)] pub struct Pending { @@ -79,7 +81,6 @@ impl Pending { let item = item.into(); // Clear the callbacks that have expired. self.clear_expired_callbacks_for_item(item); - // Return the number of live callbacks. self.callbacks.lock().get(&item).map_or(0, |callbacks| callbacks.len()) } @@ -127,11 +128,10 @@ impl Pending { /// Removes the callbacks for the specified `item` that have expired. pub fn clear_expired_callbacks_for_item(&self, item: impl Into) { - // Fetch the current timestamp. - let now = OffsetDateTime::now_utc().unix_timestamp(); - // Clear the callbacks that have expired. if let Some(callbacks) = self.callbacks.lock().get_mut(&item.into()) { + // Fetch the current timestamp. + let now = OffsetDateTime::now_utc().unix_timestamp(); // Remove the callbacks that have expired. callbacks.retain(|(_, timestamp)| now - *timestamp <= CALLBACK_TIMEOUT_IN_SECS); } diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index a454bcd0d1..46cc1885d2 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -421,10 +421,7 @@ impl Sync { bail!("Unable to fetch batch certificate {certificate_id} - failed to send request") } } else { - debug!( - "Skipped sending certificate request to {peer_ip} for {} - already pending {NUM_REDUNDANT_REQUESTS} requests", - fmt_id(certificate_id) - ); + trace!("Skipped sending redundant request for certificate {} to '{peer_ip}'", fmt_id(certificate_id)); } } // Wait for the certificate to be fetched. diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index 090b04d6aa..4e59a399e8 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -395,10 +395,7 @@ impl Worker { bail!("Unable to fetch transmission - failed to send request") } } else { - debug!( - "Skipped sending transmission request to {peer_ip} for {} - already pending {NUM_REDUNDANT_REQUESTS} requests", - fmt_id(transmission_id) - ); + trace!("Skipped sending redundant request for transmission {} to '{peer_ip}'", fmt_id(transmission_id)); } // Wait for the transmission to be fetched. match timeout(Duration::from_millis(MAX_FETCH_TIMEOUT_IN_MS), callback_receiver).await { From 735ad691721956f5d5ebd4070aca58621cac0bdc Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sun, 11 Feb 2024 17:40:27 -0800 Subject: [PATCH 078/551] Clean up logging --- node/router/messages/src/helpers/codec.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/router/messages/src/helpers/codec.rs b/node/router/messages/src/helpers/codec.rs index a3bba2abf8..e3a12b7227 100644 --- a/node/router/messages/src/helpers/codec.rs +++ b/node/router/messages/src/helpers/codec.rs @@ -80,7 +80,7 @@ impl Decoder for MessageCodec { match Message::read_le(reader) { Ok(message) => Ok(Some(message)), Err(error) => { - error!("Failed to deserialize a message: {}", error); + warn!("Failed to deserialize a message - {}", error); Err(std::io::ErrorKind::InvalidData.into()) } } From be8e6ce65c58a91d24ab9d52e260b4f5d5395cf1 Mon Sep 17 00:00:00 2001 From: Victor Sint Nicolaas Date: Mon, 12 Feb 2024 11:08:25 +0100 Subject: [PATCH 079/551] Limit number of deployments in mempool. At 10 deployments we won't run out of memory. At 5 deployments, we won't take too much compute time. We always interweave the verification of some executions and deployments. --- node/consensus/src/lib.rs | 48 ++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 52aa75a626..578f937975 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -53,6 +53,11 @@ use tokio::{ task::JoinHandle, }; +/// Percentage of mempool transactions capacity reserved for deployments. +const CAPACITY_FOR_DEPLOYMENTS: usize = 20; +/// Percentage of mempool transactions capacity reserved for executions. +const CAPACITY_FOR_EXECUTIONS: usize = 80; + #[derive(Clone)] pub struct Consensus { /// The ledger. @@ -63,8 +68,10 @@ pub struct Consensus { primary_sender: Arc>>, /// The unconfirmed solutions queue. solutions_queue: Arc, ProverSolution>>>, - /// The unconfirmed transactions queue. - transactions_queue: Arc>>>, + /// The unconfirmed deployment transactions queue. + deployments_queue: Arc>>>, + /// The unconfirmed execution transactions queue. + executions_queue: Arc>>>, /// The recently-seen unconfirmed solutions. seen_solutions: Arc, ()>>>, /// The recently-seen unconfirmed transactions. @@ -101,8 +108,13 @@ impl Consensus { solutions_queue: Arc::new(Mutex::new(LruCache::new( NonZeroUsize::new(BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH).unwrap(), ))), - transactions_queue: Arc::new(Mutex::new(LruCache::new( - NonZeroUsize::new(BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH).unwrap(), + deployments_queue: Arc::new(Mutex::new(LruCache::new( + NonZeroUsize::new(BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH * CAPACITY_FOR_DEPLOYMENTS / 100) + .unwrap(), + ))), + executions_queue: Arc::new(Mutex::new(LruCache::new( + NonZeroUsize::new(BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH * CAPACITY_FOR_EXECUTIONS / 100) + .unwrap(), ))), seen_solutions: Arc::new(Mutex::new(LruCache::new(NonZeroUsize::new(1 << 16).unwrap()))), seen_transactions: Arc::new(Mutex::new(LruCache::new(NonZeroUsize::new(1 << 16).unwrap()))), @@ -260,7 +272,11 @@ impl Consensus { } // Add the transaction to the memory pool. trace!("Received unconfirmed transaction '{}' in the queue", fmt_id(transaction_id)); - if self.transactions_queue.lock().put(transaction_id, transaction).is_some() { + if transaction.is_deploy() { + if self.deployments_queue.lock().put(transaction_id, transaction).is_some() { + bail!("Transaction '{}' exists in the memory pool", fmt_id(transaction_id)); + } + } else if self.executions_queue.lock().put(transaction_id, transaction).is_some() { bail!("Transaction '{}' exists in the memory pool", fmt_id(transaction_id)); } } @@ -274,14 +290,20 @@ impl Consensus { let transactions = { // Determine the available capacity. let capacity = BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH.saturating_sub(num_unconfirmed); - // Acquire the lock on the queue. - let mut queue = self.transactions_queue.lock(); - // Determine the number of transactions to send. - let num_transactions = queue.len().min(capacity); - // Drain the solutions from the queue. - (0..num_transactions) - .filter_map(|_| queue.pop_lru().map(|(_, transaction)| transaction)) - .collect::>() + // Acquire the lock on the deployments queue. + let mut deployments_queue = self.deployments_queue.lock(); + // Acquire the lock on the executions queue. + let mut executions_queue = self.executions_queue.lock(); + // Determine the number of deployments to send. + let num_deployments = deployments_queue.len().min(capacity * CAPACITY_FOR_DEPLOYMENTS / 100); + // Determine the number of executions to send. + let num_executions = executions_queue.len().min(capacity.saturating_sub(num_deployments)); + // Drain the deployments from the queue. + let deployments = (0..num_deployments).filter_map(|_| deployments_queue.pop_lru().map(|(_, tx)| tx)); + // Drain the executions from the queue. + let executions = (0..num_executions).filter_map(|_| executions_queue.pop_lru().map(|(_, tx)| tx)); + // Interleave the transactions to prevent having too many consecutive deployments. + executions.interleave(deployments).collect_vec() }; // Iterate over the transactions. for transaction in transactions.into_iter() { From f93060b9d08cdc6c53830cb280dc70f0c49bffde Mon Sep 17 00:00:00 2001 From: Victor Sint Nicolaas Date: Mon, 12 Feb 2024 12:06:31 +0100 Subject: [PATCH 080/551] Use single lock for transactions_queue --- node/consensus/src/lib.rs | 68 ++++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 26 deletions(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 578f937975..055bac88ec 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -58,6 +58,27 @@ const CAPACITY_FOR_DEPLOYMENTS: usize = 20; /// Percentage of mempool transactions capacity reserved for executions. const CAPACITY_FOR_EXECUTIONS: usize = 80; +/// Helper struct to track incoming transactions. +struct TransactionsQueue { + pub deployments: LruCache>, + pub executions: LruCache>, +} + +impl Default for TransactionsQueue { + fn default() -> Self { + Self { + deployments: LruCache::new( + NonZeroUsize::new(BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH * CAPACITY_FOR_DEPLOYMENTS / 100) + .unwrap(), + ), + executions: LruCache::new( + NonZeroUsize::new(BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH * CAPACITY_FOR_EXECUTIONS / 100) + .unwrap(), + ), + } + } +} + #[derive(Clone)] pub struct Consensus { /// The ledger. @@ -68,10 +89,8 @@ pub struct Consensus { primary_sender: Arc>>, /// The unconfirmed solutions queue. solutions_queue: Arc, ProverSolution>>>, - /// The unconfirmed deployment transactions queue. - deployments_queue: Arc>>>, - /// The unconfirmed execution transactions queue. - executions_queue: Arc>>>, + /// The unconfirmed transactions queue. + transactions_queue: Arc>>, /// The recently-seen unconfirmed solutions. seen_solutions: Arc, ()>>>, /// The recently-seen unconfirmed transactions. @@ -108,14 +127,7 @@ impl Consensus { solutions_queue: Arc::new(Mutex::new(LruCache::new( NonZeroUsize::new(BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH).unwrap(), ))), - deployments_queue: Arc::new(Mutex::new(LruCache::new( - NonZeroUsize::new(BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH * CAPACITY_FOR_DEPLOYMENTS / 100) - .unwrap(), - ))), - executions_queue: Arc::new(Mutex::new(LruCache::new( - NonZeroUsize::new(BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH * CAPACITY_FOR_EXECUTIONS / 100) - .unwrap(), - ))), + transactions_queue: Default::default(), seen_solutions: Arc::new(Mutex::new(LruCache::new(NonZeroUsize::new(1 << 16).unwrap()))), seen_transactions: Arc::new(Mutex::new(LruCache::new(NonZeroUsize::new(1 << 16).unwrap()))), handles: Default::default(), @@ -273,10 +285,10 @@ impl Consensus { // Add the transaction to the memory pool. trace!("Received unconfirmed transaction '{}' in the queue", fmt_id(transaction_id)); if transaction.is_deploy() { - if self.deployments_queue.lock().put(transaction_id, transaction).is_some() { + if self.transactions_queue.lock().deployments.put(transaction_id, transaction).is_some() { bail!("Transaction '{}' exists in the memory pool", fmt_id(transaction_id)); } - } else if self.executions_queue.lock().put(transaction_id, transaction).is_some() { + } else if self.transactions_queue.lock().executions.put(transaction_id, transaction).is_some() { bail!("Transaction '{}' exists in the memory pool", fmt_id(transaction_id)); } } @@ -290,20 +302,24 @@ impl Consensus { let transactions = { // Determine the available capacity. let capacity = BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH.saturating_sub(num_unconfirmed); - // Acquire the lock on the deployments queue. - let mut deployments_queue = self.deployments_queue.lock(); - // Acquire the lock on the executions queue. - let mut executions_queue = self.executions_queue.lock(); + // Acquire the lock on the transactions queue. + let mut tx_queue = self.transactions_queue.lock(); // Determine the number of deployments to send. - let num_deployments = deployments_queue.len().min(capacity * CAPACITY_FOR_DEPLOYMENTS / 100); + let num_deployments = tx_queue.deployments.len().min(capacity * CAPACITY_FOR_DEPLOYMENTS / 100); // Determine the number of executions to send. - let num_executions = executions_queue.len().min(capacity.saturating_sub(num_deployments)); - // Drain the deployments from the queue. - let deployments = (0..num_deployments).filter_map(|_| deployments_queue.pop_lru().map(|(_, tx)| tx)); - // Drain the executions from the queue. - let executions = (0..num_executions).filter_map(|_| executions_queue.pop_lru().map(|(_, tx)| tx)); - // Interleave the transactions to prevent having too many consecutive deployments. - executions.interleave(deployments).collect_vec() + let num_executions = tx_queue.executions.len().min(capacity.saturating_sub(num_deployments)); + // Interleave deployments and executions to prevent having too many consecutive deployments. + let is_deployment_iter = (0..num_deployments).map(|_| true).interleave((0..num_executions).map(|_| false)); + // Drain the transactions from the queue. + is_deployment_iter + .filter_map(|is_deployment| { + if is_deployment { + tx_queue.deployments.pop_lru().map(|(_, tx)| tx) + } else { + tx_queue.executions.pop_lru().map(|(_, tx)| tx) + } + }) + .collect_vec() }; // Iterate over the transactions. for transaction in transactions.into_iter() { From a5d33497357627c50b75bb63750451083a86edd6 Mon Sep 17 00:00:00 2001 From: Victor Sint Nicolaas Date: Mon, 12 Feb 2024 12:38:03 +0100 Subject: [PATCH 081/551] Improve wording of interleaving --- node/consensus/src/lib.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 055bac88ec..30bc32c7e6 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -308,12 +308,13 @@ impl Consensus { let num_deployments = tx_queue.deployments.len().min(capacity * CAPACITY_FOR_DEPLOYMENTS / 100); // Determine the number of executions to send. let num_executions = tx_queue.executions.len().min(capacity.saturating_sub(num_deployments)); - // Interleave deployments and executions to prevent having too many consecutive deployments. - let is_deployment_iter = (0..num_deployments).map(|_| true).interleave((0..num_executions).map(|_| false)); - // Drain the transactions from the queue. - is_deployment_iter - .filter_map(|is_deployment| { - if is_deployment { + // Create an iterator which will select interleaved deployments and executions within the capacity. + // Note: interleaving ensures we will never have consecutive invalid deployments blocking the queue. + let selector_iter = (0..num_deployments).map(|_| true).interleave((0..num_executions).map(|_| false)); + // Drain the transactions from the queue, interleaving deployments and executions. + selector_iter + .filter_map(|select_deployment| { + if select_deployment { tx_queue.deployments.pop_lru().map(|(_, tx)| tx) } else { tx_queue.executions.pop_lru().map(|(_, tx)| tx) From 2ea0bdcee9fad2de443622f1d22e2879a448dc84 Mon Sep 17 00:00:00 2001 From: Victor Sint Nicolaas Date: Mon, 12 Feb 2024 16:00:55 +0100 Subject: [PATCH 082/551] Introduce MAXIMUM_NUMBER_OF_PROVERS to maintain connections with --- node/router/src/heartbeat.rs | 45 ++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/node/router/src/heartbeat.rs b/node/router/src/heartbeat.rs index 992b38763a..ec8b82d063 100644 --- a/node/router/src/heartbeat.rs +++ b/node/router/src/heartbeat.rs @@ -38,6 +38,8 @@ pub trait Heartbeat: Outbound { const MINIMUM_NUMBER_OF_PEERS: usize = 3; /// The median number of peers to maintain connections with. const MEDIAN_NUMBER_OF_PEERS: usize = max(Self::MAXIMUM_NUMBER_OF_PEERS / 2, Self::MINIMUM_NUMBER_OF_PEERS); + /// The maximum number of provers to maintain connections with. + const MAXIMUM_NUMBER_OF_PROVERS: usize = Self::MAXIMUM_NUMBER_OF_PEERS / 4; /// The maximum number of peers permitted to maintain connections with. const MAXIMUM_NUMBER_OF_PEERS: usize = 21; @@ -68,6 +70,7 @@ pub trait Heartbeat: Outbound { assert!(Self::MINIMUM_NUMBER_OF_PEERS <= Self::MAXIMUM_NUMBER_OF_PEERS); assert!(Self::MINIMUM_NUMBER_OF_PEERS <= Self::MEDIAN_NUMBER_OF_PEERS); assert!(Self::MEDIAN_NUMBER_OF_PEERS <= Self::MAXIMUM_NUMBER_OF_PEERS); + assert!(Self::MAXIMUM_NUMBER_OF_PROVERS <= Self::MAXIMUM_NUMBER_OF_PEERS); } /// This function logs the connected peers. @@ -130,15 +133,22 @@ pub trait Heartbeat: Outbound { /// TODO (howardwu): If the node is a validator, keep the validator. /// This function keeps the number of connected peers within the allowed range. fn handle_connected_peers(&self) { + // Obtain the number of connected provers. + let num_connected_provers = self.router().number_of_connected_provers(); + // Compute the number of surplus provers. + let num_surplus_provers = num_connected_provers.saturating_sub(Self::MAXIMUM_NUMBER_OF_PROVERS); // Obtain the number of connected peers. let num_connected = self.router().number_of_connected_peers(); - // Compute the number of surplus peers. - let num_surplus = num_connected.saturating_sub(Self::MAXIMUM_NUMBER_OF_PEERS); + // Compute the number of surplus clients and validators. + let num_surplus_clients_validators = + num_connected.saturating_sub(Self::MAXIMUM_NUMBER_OF_PEERS).saturating_sub(num_connected_provers); // Compute the number of deficit peers. let num_deficient = Self::MEDIAN_NUMBER_OF_PEERS.saturating_sub(num_connected); - if num_surplus > 0 { - debug!("Exceeded maximum number of connected peers, disconnecting from {num_surplus} peers"); + if num_surplus_provers > 0 || num_surplus_clients_validators > 0 { + debug!( + "Exceeded maximum number of connected peers, disconnecting from ({num_surplus_provers} + {num_surplus_clients_validators}) peers" + ); // Retrieve the trusted peers. let trusted = self.router().trusted_peers(); @@ -148,18 +158,33 @@ pub trait Heartbeat: Outbound { // Initialize an RNG. let rng = &mut OsRng; - // TODO (howardwu): As a validator, prioritize disconnecting from clients and provers. + // Determine the provers to disconnect from. + let prover_ips_to_disconnect = self + .router() + .connected_provers() + .into_iter() + .filter(|peer_ip| !trusted.contains(peer_ip) && !bootstrap.contains(peer_ip)) + .choose_multiple(rng, num_surplus_provers); + + // TODO (howardwu): As a validator, prioritize disconnecting from clients. // Remove RNG, pick the `n` oldest nodes. - // Determine the peers to disconnect from. + // Determine the clients and validators to disconnect from. let peer_ips_to_disconnect = self .router() - .connected_peers() + .get_connected_peers() .into_iter() - .filter(|peer_ip| !trusted.contains(peer_ip) && !bootstrap.contains(peer_ip)) - .choose_multiple(rng, num_surplus); + .filter_map(|peer| { + let peer_ip = peer.ip(); + if !trusted.contains(&peer_ip) && !bootstrap.contains(&peer_ip) && !peer.is_prover() { + Some(peer_ip) + } else { + None + } + }) + .choose_multiple(rng, num_surplus_clients_validators); // Proceed to send disconnect requests to these peers. - for peer_ip in peer_ips_to_disconnect { + for peer_ip in peer_ips_to_disconnect.into_iter().chain(prover_ips_to_disconnect) { // TODO (howardwu): Remove this after specializing this function. if self.router().node_type().is_prover() { if let Some(peer) = self.router().get_connected_peer(&peer_ip) { From 806d01846576debc7bab74cbb4e8d92d74ba5abd Mon Sep 17 00:00:00 2001 From: Victor Sint Nicolaas Date: Mon, 12 Feb 2024 16:59:49 +0100 Subject: [PATCH 083/551] Clean up and correct num_peer calculations --- node/router/src/heartbeat.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/node/router/src/heartbeat.rs b/node/router/src/heartbeat.rs index ec8b82d063..30074f0abb 100644 --- a/node/router/src/heartbeat.rs +++ b/node/router/src/heartbeat.rs @@ -137,13 +137,14 @@ pub trait Heartbeat: Outbound { let num_connected_provers = self.router().number_of_connected_provers(); // Compute the number of surplus provers. let num_surplus_provers = num_connected_provers.saturating_sub(Self::MAXIMUM_NUMBER_OF_PROVERS); + // Compute the number of provers remaining connected. + let num_remaining_provers = num_connected_provers.saturating_sub(num_surplus_provers); // Obtain the number of connected peers. let num_connected = self.router().number_of_connected_peers(); + // Compute the total number of surplus peers. + let num_surplus_peers = num_connected.saturating_sub(Self::MAXIMUM_NUMBER_OF_PEERS); // Compute the number of surplus clients and validators. - let num_surplus_clients_validators = - num_connected.saturating_sub(Self::MAXIMUM_NUMBER_OF_PEERS).saturating_sub(num_connected_provers); - // Compute the number of deficit peers. - let num_deficient = Self::MEDIAN_NUMBER_OF_PEERS.saturating_sub(num_connected); + let num_surplus_clients_validators = num_surplus_peers.saturating_sub(num_remaining_provers); if num_surplus_provers > 0 || num_surplus_clients_validators > 0 { debug!( @@ -201,6 +202,11 @@ pub trait Heartbeat: Outbound { } } + // Obtain the number of connected peers. + let num_connected = self.router().number_of_connected_peers(); + // Compute the number of deficit peers. + let num_deficient = Self::MEDIAN_NUMBER_OF_PEERS.saturating_sub(num_connected); + if num_deficient > 0 { // Initialize an RNG. let rng = &mut OsRng; From 02a08ec20401adb911c37027fb1080bb039b92cc Mon Sep 17 00:00:00 2001 From: Victor Sint Nicolaas Date: Mon, 12 Feb 2024 17:00:02 +0100 Subject: [PATCH 084/551] short circuit on the most common check --- node/router/src/heartbeat.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/router/src/heartbeat.rs b/node/router/src/heartbeat.rs index 30074f0abb..3f68656bdb 100644 --- a/node/router/src/heartbeat.rs +++ b/node/router/src/heartbeat.rs @@ -176,7 +176,7 @@ pub trait Heartbeat: Outbound { .into_iter() .filter_map(|peer| { let peer_ip = peer.ip(); - if !trusted.contains(&peer_ip) && !bootstrap.contains(&peer_ip) && !peer.is_prover() { + if !peer.is_prover() && !trusted.contains(&peer_ip) && !bootstrap.contains(&peer_ip) { Some(peer_ip) } else { None From 211d8c6c1bd27ac34fbfd3c773a6c90c431684fa Mon Sep 17 00:00:00 2001 From: Victor Sint Nicolaas Date: Mon, 12 Feb 2024 17:08:55 +0100 Subject: [PATCH 085/551] Further clean up num_peer calculations --- node/router/src/heartbeat.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/node/router/src/heartbeat.rs b/node/router/src/heartbeat.rs index 3f68656bdb..e7bb28d423 100644 --- a/node/router/src/heartbeat.rs +++ b/node/router/src/heartbeat.rs @@ -133,16 +133,17 @@ pub trait Heartbeat: Outbound { /// TODO (howardwu): If the node is a validator, keep the validator. /// This function keeps the number of connected peers within the allowed range. fn handle_connected_peers(&self) { + // Obtain the number of connected peers. + let num_connected = self.router().number_of_connected_peers(); + // Compute the total number of surplus peers. + let num_surplus_peers = num_connected.saturating_sub(Self::MAXIMUM_NUMBER_OF_PEERS); + // Obtain the number of connected provers. let num_connected_provers = self.router().number_of_connected_provers(); // Compute the number of surplus provers. let num_surplus_provers = num_connected_provers.saturating_sub(Self::MAXIMUM_NUMBER_OF_PROVERS); // Compute the number of provers remaining connected. let num_remaining_provers = num_connected_provers.saturating_sub(num_surplus_provers); - // Obtain the number of connected peers. - let num_connected = self.router().number_of_connected_peers(); - // Compute the total number of surplus peers. - let num_surplus_peers = num_connected.saturating_sub(Self::MAXIMUM_NUMBER_OF_PEERS); // Compute the number of surplus clients and validators. let num_surplus_clients_validators = num_surplus_peers.saturating_sub(num_remaining_provers); From 9ed6534a1f1629a7d26fa3157dab4a6428f7faa4 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 12 Feb 2024 17:34:58 -0800 Subject: [PATCH 086/551] Update rev - 425db4d --- Cargo.lock | 117 +++++++++++++++++++++++++++-------------------------- Cargo.toml | 2 +- 2 files changed, 60 insertions(+), 59 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c8f1f5fd2a..5c11dcec77 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3526,7 +3526,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "anstyle", "anyhow", @@ -3557,7 +3557,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "aleo-std", "anyhow", @@ -3587,7 +3587,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3601,7 +3601,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3612,7 +3612,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3622,7 +3622,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3632,7 +3632,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "indexmap 2.2.2", "itertools 0.11.0", @@ -3650,12 +3650,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3666,7 +3666,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3681,7 +3681,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3696,7 +3696,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3709,7 +3709,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3718,7 +3718,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3728,7 +3728,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3740,7 +3740,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3752,7 +3752,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3763,7 +3763,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3775,7 +3775,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3788,7 +3788,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "bs58", "snarkvm-console-network", @@ -3799,7 +3799,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "blake2s_simd", "smallvec", @@ -3812,7 +3812,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "aleo-std", "rayon", @@ -3823,7 +3823,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "anyhow", "indexmap 2.2.2", @@ -3846,7 +3846,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "anyhow", "bech32", @@ -3864,7 +3864,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "enum_index", "enum_index_derive", @@ -3885,7 +3885,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3900,7 +3900,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3911,7 +3911,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "snarkvm-console-network-environment", ] @@ -3919,7 +3919,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3929,7 +3929,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3940,7 +3940,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3951,7 +3951,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3962,7 +3962,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3973,7 +3973,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "rand", "rayon", @@ -3987,7 +3987,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "aleo-std", "anyhow", @@ -4004,7 +4004,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "aleo-std", "anyhow", @@ -4029,7 +4029,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "anyhow", "rand", @@ -4041,7 +4041,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4060,7 +4060,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-coinbase" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "aleo-std", "anyhow", @@ -4080,7 +4080,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "anyhow", "indexmap 2.2.2", @@ -4098,7 +4098,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -4111,7 +4111,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4124,7 +4124,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "indexmap 2.2.2", "serde_json", @@ -4136,7 +4136,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "bytes", "serde_json", @@ -4147,7 +4147,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4162,7 +4162,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "bytes", "serde_json", @@ -4175,7 +4175,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "snarkvm-console", "snarkvm-ledger-coinbase", @@ -4184,7 +4184,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "async-trait", "reqwest", @@ -4197,7 +4197,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "aleo-std-storage", "anyhow", @@ -4208,6 +4208,7 @@ dependencies = [ "rayon", "rocksdb", "serde", + "serde_json", "snarkvm-console", "snarkvm-ledger-authority", "snarkvm-ledger-block", @@ -4222,7 +4223,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4237,7 +4238,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4246,7 +4247,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "aleo-std", "anyhow", @@ -4271,7 +4272,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "aleo-std", "anyhow", @@ -4295,7 +4296,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "aleo-std", "colored", @@ -4318,7 +4319,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "indexmap 2.2.2", "paste", @@ -4332,7 +4333,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "bincode", "once_cell", @@ -4345,7 +4346,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "aleo-std", "anyhow", @@ -4366,7 +4367,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=425db4d#425db4da1dfd1e33b45adf7027787ee8cf91a1b4" dependencies = [ "proc-macro2", "quote 1.0.35", diff --git a/Cargo.toml b/Cargo.toml index abeb2bc064..d835a44f50 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "525764a" +rev = "425db4d" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From 0592a13b9e90bb62312b29030db8d91ffabbd8d7 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 12 Feb 2024 17:35:18 -0800 Subject: [PATCH 087/551] Pass through bonded_balances --- cli/src/commands/start.rs | 20 +++++++++++--------- node/bft/tests/common/primary.rs | 11 ++++++++--- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index bc39048348..6882b20570 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -514,6 +514,7 @@ fn load_or_compute_genesis( genesis_private_key: PrivateKey, committee: Committee, public_balances: indexmap::IndexMap, u64>, + bonded_balances: indexmap::IndexMap, (Address, u64)>, rng: &mut ChaChaRng, ) -> Result> { // Construct the preimage. @@ -523,6 +524,7 @@ fn load_or_compute_genesis( preimage.extend(genesis_private_key.to_bytes_le()?); preimage.extend(committee.to_bytes_le()?); preimage.extend(&to_bytes_le![public_balances.iter().collect::>()]?); + preimage.extend(&to_bytes_le![bonded_balances.iter().collect::>()]?); // Input the parameters' metadata. preimage.extend(snarkvm::parameters::mainnet::BondPublicVerifier::METADATA.as_bytes()); @@ -566,7 +568,7 @@ fn load_or_compute_genesis( // Initialize a new VM. let vm = VM::from(ConsensusStore::>::open(Some(0))?)?; // Initialize the genesis block. - let block = vm.genesis_quorum(&genesis_private_key, committee, public_balances, rng)?; + let block = vm.genesis_quorum(&genesis_private_key, committee, public_balances, bonded_balances, rng)?; // Write the genesis block to the file. std::fs::write(&file_path, block.to_bytes_le()?)?; // Return the genesis block. @@ -593,10 +595,10 @@ mod tests { let config = Start::try_parse_from(["snarkos", "--peers", "1.2.3.4:5,6.7.8.9:0"].iter()).unwrap(); assert!(config.parse_trusted_peers().is_ok()); - assert_eq!(config.parse_trusted_peers().unwrap(), vec![ - SocketAddr::from_str("1.2.3.4:5").unwrap(), - SocketAddr::from_str("6.7.8.9:0").unwrap() - ]); + assert_eq!( + config.parse_trusted_peers().unwrap(), + vec![SocketAddr::from_str("1.2.3.4:5").unwrap(), SocketAddr::from_str("6.7.8.9:0").unwrap()] + ); } #[test] @@ -611,10 +613,10 @@ mod tests { let config = Start::try_parse_from(["snarkos", "--validators", "1.2.3.4:5,6.7.8.9:0"].iter()).unwrap(); assert!(config.parse_trusted_validators().is_ok()); - assert_eq!(config.parse_trusted_validators().unwrap(), vec![ - SocketAddr::from_str("1.2.3.4:5").unwrap(), - SocketAddr::from_str("6.7.8.9:0").unwrap() - ]); + assert_eq!( + config.parse_trusted_validators().unwrap(), + vec![SocketAddr::from_str("1.2.3.4:5").unwrap(), SocketAddr::from_str("6.7.8.9:0").unwrap()] + ); } #[test] diff --git a/node/bft/tests/common/primary.rs b/node/bft/tests/common/primary.rs index 2f90c03220..ef7eb91619 100644 --- a/node/bft/tests/common/primary.rs +++ b/node/bft/tests/common/primary.rs @@ -131,6 +131,8 @@ impl TestNetwork { } let (accounts, committee) = new_test_committee(config.num_nodes); + let bonded_balances: IndexMap<_, _> = + committee.members().iter().map(|(address, (amount, _))| (*address, (*address, *amount))).collect(); let gen_key = *accounts[0].private_key(); let public_balance_per_validator = (1_500_000_000_000_000 - (config.num_nodes as u64) * 1_000_000_000_000) / (config.num_nodes as u64); @@ -142,7 +144,8 @@ impl TestNetwork { let mut validators = HashMap::with_capacity(config.num_nodes as usize); for (id, account) in accounts.into_iter().enumerate() { let mut rng = TestRng::fixed(id as u64); - let gen_ledger = genesis_ledger(gen_key, committee.clone(), balances.clone(), &mut rng); + let gen_ledger = + genesis_ledger(gen_key, committee.clone(), balances.clone(), bonded_balances.clone(), &mut rng); let ledger = Arc::new(TranslucentLedgerService::new(gen_ledger, Default::default())); let storage = Storage::new( ledger.clone(), @@ -347,6 +350,7 @@ fn genesis_block( genesis_private_key: PrivateKey, committee: Committee, public_balances: IndexMap, u64>, + bonded_balances: IndexMap, (Address, u64)>, rng: &mut (impl Rng + CryptoRng), ) -> Block { // Initialize the store. @@ -354,13 +358,14 @@ fn genesis_block( // Initialize a new VM. let vm = VM::from(store).unwrap(); // Initialize the genesis block. - vm.genesis_quorum(&genesis_private_key, committee, public_balances, rng).unwrap() + vm.genesis_quorum(&genesis_private_key, committee, public_balances, bonded_balances, rng).unwrap() } fn genesis_ledger( genesis_private_key: PrivateKey, committee: Committee, public_balances: IndexMap, u64>, + bonded_balances: IndexMap, (Address, u64)>, rng: &mut (impl Rng + CryptoRng), ) -> CurrentLedger { let cache_key = @@ -379,7 +384,7 @@ fn genesis_ledger( return Block::from_bytes_le(&buffer).unwrap(); } - let block = genesis_block(genesis_private_key, committee, public_balances, rng); + let block = genesis_block(genesis_private_key, committee, public_balances, bonded_balances, rng); std::fs::write(&file_path, block.to_bytes_le().unwrap()).unwrap(); block }) From 821e9bda225d8554320c817b60c1f0b5a3868196 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 12 Feb 2024 18:15:57 -0800 Subject: [PATCH 088/551] Add custom bonded balances to CLI --- cli/src/commands/start.rs | 106 ++++++++++++++++++++++++++++---------- 1 file changed, 80 insertions(+), 26 deletions(-) diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index 6882b20570..2bfae269a8 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -23,7 +23,7 @@ use snarkvm::{ }, ledger::{ block::Block, - committee::{Committee, MIN_VALIDATOR_STAKE}, + committee::{Committee, MIN_DELEGATOR_STAKE, MIN_VALIDATOR_STAKE}, store::{helpers::memory::ConsensusMemory, ConsensusStore}, }, prelude::{FromBytes, ToBits, ToBytes}, @@ -36,6 +36,7 @@ use anyhow::{bail, ensure, Result}; use clap::Parser; use colored::Colorize; use core::str::FromStr; +use indexmap::IndexMap; use rand::SeedableRng; use rand_chacha::ChaChaRng; use std::{net::SocketAddr, path::PathBuf}; @@ -127,6 +128,10 @@ pub struct Start { /// Specify the path to a directory containing the ledger #[clap(long = "storage_path")] pub storage_path: Option, + + #[clap(long)] + /// If development mode is enabled, specify the custom bonded balances as a json object. (default: None) + dev_bonded_balances: Option, } impl Start { @@ -314,24 +319,73 @@ impl Start { // Initialize the development private keys. let development_private_keys = (0..num_committee_members).map(|_| PrivateKey::::new(&mut rng)).collect::>>()?; - - // Construct the committee. - let committee = { - // Calculate the committee stake per member. - let stake_per_member = - N::STARTING_SUPPLY.saturating_div(2).saturating_div(num_committee_members as u64); - ensure!(stake_per_member >= MIN_VALIDATOR_STAKE, "Committee stake per member is too low"); - - // Construct the committee members and distribute stakes evenly among committee members. - let members = development_private_keys - .iter() - .map(|private_key| Ok((Address::try_from(private_key)?, (stake_per_member, true)))) - .collect::>>()?; - - // Output the committee. - Committee::::new(0u64, members)? + // Initialize the development addresses. + let development_addresses = + development_private_keys.iter().map(Address::::try_from).collect::>>()?; + + // Construct the committee based on the state of the bonded balances. + let (committee, bonded_balances) = match &self.dev_bonded_balances { + Some(bonded_balances) => { + // Parse the bonded balances. + let bonded_balances: IndexMap, (Address, u64)> = + serde_json::from_str(bonded_balances)?; + + // Construct the committee members. + let mut members = IndexMap::new(); + for (staker_address, (validator_address, amount)) in bonded_balances.iter() { + // Ensure that the staking amount is sufficient. + match staker_address == validator_address { + true => ensure!(amount >= &MIN_VALIDATOR_STAKE, "Validator stake is too low"), + false => ensure!(amount >= &MIN_DELEGATOR_STAKE, "Delegator stake is too low"), + } + + // Ensure that the validator address is included in the list of development addresses. + ensure!( + development_addresses.contains(validator_address), + "Validator address {validator_address} is not included in the list of development addresses" + ); + + // Add or update the validator entry in the list of members. + members + .entry(*validator_address) + .and_modify(|(stake, _)| *stake += amount) + .or_insert((*amount, true)); + } + // Construct the committee. + let committee = Committee::::new(0u64, members)?; + (committee, bonded_balances) + } + None => { + // Calculate the committee stake per member. + let stake_per_member = + N::STARTING_SUPPLY.saturating_div(2).saturating_div(num_committee_members as u64); + ensure!(stake_per_member >= MIN_VALIDATOR_STAKE, "Committee stake per member is too low"); + + // Construct the committee members and distribute stakes evenly among committee members. + let members = development_addresses + .iter() + .map(|address| (*address, (stake_per_member, true))) + .collect::>(); + + // Construct the bonded balances. + let bonded_balances = members + .iter() + .map(|(address, (stake, _))| (*address, (*address, *stake))) + .collect::>(); + // Construct the committee. + let committee = Committee::::new(0u64, members)?; + + (committee, bonded_balances) + } }; + // Ensure that the number of committee members is correct. + ensure!( + committee.members().len() == num_committee_members as usize, + "Number of committee members {} does not match the expected number of members {num_committee_members}", + committee.members().len() + ); + // Calculate the public balance per validator. let remaining_balance = N::STARTING_SUPPLY.saturating_sub(committee.total_stake()); let public_balance_per_validator = remaining_balance.saturating_div(num_committee_members as u64); @@ -357,7 +411,7 @@ impl Start { } // Construct the genesis block. - load_or_compute_genesis(development_private_keys[0], committee, public_balances, &mut rng) + load_or_compute_genesis(development_private_keys[0], committee, public_balances, bonded_balances, &mut rng) } else { // If the `dev_num_validators` flag is set, inform the user that it is ignored. if self.dev_num_validators.is_some() { @@ -595,10 +649,10 @@ mod tests { let config = Start::try_parse_from(["snarkos", "--peers", "1.2.3.4:5,6.7.8.9:0"].iter()).unwrap(); assert!(config.parse_trusted_peers().is_ok()); - assert_eq!( - config.parse_trusted_peers().unwrap(), - vec![SocketAddr::from_str("1.2.3.4:5").unwrap(), SocketAddr::from_str("6.7.8.9:0").unwrap()] - ); + assert_eq!(config.parse_trusted_peers().unwrap(), vec![ + SocketAddr::from_str("1.2.3.4:5").unwrap(), + SocketAddr::from_str("6.7.8.9:0").unwrap() + ]); } #[test] @@ -613,10 +667,10 @@ mod tests { let config = Start::try_parse_from(["snarkos", "--validators", "1.2.3.4:5,6.7.8.9:0"].iter()).unwrap(); assert!(config.parse_trusted_validators().is_ok()); - assert_eq!( - config.parse_trusted_validators().unwrap(), - vec![SocketAddr::from_str("1.2.3.4:5").unwrap(), SocketAddr::from_str("6.7.8.9:0").unwrap()] - ); + assert_eq!(config.parse_trusted_validators().unwrap(), vec![ + SocketAddr::from_str("1.2.3.4:5").unwrap(), + SocketAddr::from_str("6.7.8.9:0").unwrap() + ]); } #[test] From bcedf4e12613be09d6bbc57d17d147fcaf627a85 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 12 Feb 2024 18:32:10 -0800 Subject: [PATCH 089/551] Add struct for BondedBalances --- cli/src/commands/start.rs | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index 2bfae269a8..8205d35c05 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -39,6 +39,7 @@ use core::str::FromStr; use indexmap::IndexMap; use rand::SeedableRng; use rand_chacha::ChaChaRng; +use serde::{Deserialize, Serialize}; use std::{net::SocketAddr, path::PathBuf}; use tokio::runtime::{self, Runtime}; @@ -52,6 +53,17 @@ const DEVELOPMENT_MODE_RNG_SEED: u64 = 1234567890u64; /// The development mode number of genesis committee members. const DEVELOPMENT_MODE_NUM_GENESIS_COMMITTEE_MEMBERS: u16 = 4; +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +struct BondedBalances(IndexMap); + +impl FromStr for BondedBalances { + type Err = serde_json::Error; + + fn from_str(s: &str) -> Result { + serde_json::from_str(s) + } +} + /// Starts the snarkOS node. #[derive(Clone, Debug, Parser)] pub struct Start { @@ -131,7 +143,7 @@ pub struct Start { #[clap(long)] /// If development mode is enabled, specify the custom bonded balances as a json object. (default: None) - dev_bonded_balances: Option, + dev_bonded_balances: Option, } impl Start { @@ -327,8 +339,15 @@ impl Start { let (committee, bonded_balances) = match &self.dev_bonded_balances { Some(bonded_balances) => { // Parse the bonded balances. - let bonded_balances: IndexMap, (Address, u64)> = - serde_json::from_str(bonded_balances)?; + let bonded_balances = bonded_balances + .0 + .iter() + .map(|(staker_address, (validator_address, amount))| { + let staker_addr = Address::::from_str(staker_address)?; + let validator_addr = Address::::from_str(validator_address)?; + Ok((staker_addr, (validator_addr, *amount))) + }) + .collect::>>()?; // Construct the committee members. let mut members = IndexMap::new(); From 94f88e28e696820d0235e45058e947b167e387e5 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 13 Feb 2024 14:00:26 -0800 Subject: [PATCH 090/551] Update rev - 8680d90 --- Cargo.lock | 118 +++++++++++++++++++++++++++-------------------------- Cargo.toml | 2 +- 2 files changed, 61 insertions(+), 59 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c8f1f5fd2a..f4ba14a111 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3526,7 +3526,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "anstyle", "anyhow", @@ -3557,7 +3557,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "aleo-std", "anyhow", @@ -3587,7 +3587,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3601,7 +3601,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3612,7 +3612,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3622,7 +3622,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3632,7 +3632,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "indexmap 2.2.2", "itertools 0.11.0", @@ -3650,12 +3650,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3666,7 +3666,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3681,7 +3681,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3696,7 +3696,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3709,7 +3709,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3718,7 +3718,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3728,7 +3728,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3740,7 +3740,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3752,7 +3752,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3763,7 +3763,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3775,7 +3775,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3788,7 +3788,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "bs58", "snarkvm-console-network", @@ -3799,7 +3799,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "blake2s_simd", "smallvec", @@ -3812,7 +3812,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "aleo-std", "rayon", @@ -3823,7 +3823,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "anyhow", "indexmap 2.2.2", @@ -3846,7 +3846,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "anyhow", "bech32", @@ -3864,7 +3864,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "enum_index", "enum_index_derive", @@ -3885,7 +3885,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3900,7 +3900,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3911,7 +3911,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "snarkvm-console-network-environment", ] @@ -3919,7 +3919,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3929,7 +3929,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3940,7 +3940,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3951,7 +3951,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3962,7 +3962,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3973,7 +3973,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "rand", "rayon", @@ -3987,7 +3987,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "aleo-std", "anyhow", @@ -4004,7 +4004,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "aleo-std", "anyhow", @@ -4029,7 +4029,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "anyhow", "rand", @@ -4041,7 +4041,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4060,7 +4060,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-coinbase" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "aleo-std", "anyhow", @@ -4080,7 +4080,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "anyhow", "indexmap 2.2.2", @@ -4098,7 +4098,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -4111,7 +4111,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4124,7 +4124,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "indexmap 2.2.2", "serde_json", @@ -4136,7 +4136,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "bytes", "serde_json", @@ -4147,7 +4147,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "indexmap 2.2.2", "rayon", @@ -4162,7 +4162,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "bytes", "serde_json", @@ -4175,7 +4175,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "snarkvm-console", "snarkvm-ledger-coinbase", @@ -4184,7 +4184,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "async-trait", "reqwest", @@ -4197,7 +4197,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "aleo-std-storage", "anyhow", @@ -4208,6 +4208,7 @@ dependencies = [ "rayon", "rocksdb", "serde", + "serde_json", "snarkvm-console", "snarkvm-ledger-authority", "snarkvm-ledger-block", @@ -4222,7 +4223,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4237,7 +4238,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4246,7 +4247,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "aleo-std", "anyhow", @@ -4271,11 +4272,12 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "aleo-std", "anyhow", "indexmap 2.2.2", + "lru", "parking_lot", "rand", "rayon", @@ -4295,7 +4297,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "aleo-std", "colored", @@ -4318,7 +4320,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "indexmap 2.2.2", "paste", @@ -4332,7 +4334,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "bincode", "once_cell", @@ -4345,7 +4347,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "aleo-std", "anyhow", @@ -4366,7 +4368,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=525764a#525764a56e5cb0d8cff5efa0c2bb1d959bbf4d1f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=8680d90#8680d90c3534c05f8ac878d252c059ef5b3ee7a1" dependencies = [ "proc-macro2", "quote 1.0.35", diff --git a/Cargo.toml b/Cargo.toml index abeb2bc064..2a5d622bca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "525764a" +rev = "8680d90" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From f0a4ddac7cac2b42a2947d374e88ba6755679709 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Tue, 13 Feb 2024 17:33:37 -0800 Subject: [PATCH 091/551] Update node/router/src/heartbeat.rs Signed-off-by: Howard Wu <9260812+howardwu@users.noreply.github.com> --- node/router/src/heartbeat.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node/router/src/heartbeat.rs b/node/router/src/heartbeat.rs index e7bb28d423..9eb1247ea0 100644 --- a/node/router/src/heartbeat.rs +++ b/node/router/src/heartbeat.rs @@ -38,10 +38,10 @@ pub trait Heartbeat: Outbound { const MINIMUM_NUMBER_OF_PEERS: usize = 3; /// The median number of peers to maintain connections with. const MEDIAN_NUMBER_OF_PEERS: usize = max(Self::MAXIMUM_NUMBER_OF_PEERS / 2, Self::MINIMUM_NUMBER_OF_PEERS); - /// The maximum number of provers to maintain connections with. - const MAXIMUM_NUMBER_OF_PROVERS: usize = Self::MAXIMUM_NUMBER_OF_PEERS / 4; /// The maximum number of peers permitted to maintain connections with. const MAXIMUM_NUMBER_OF_PEERS: usize = 21; + /// The maximum number of provers to maintain connections with. + const MAXIMUM_NUMBER_OF_PROVERS: usize = Self::MAXIMUM_NUMBER_OF_PEERS / 4; /// Handles the heartbeat request. fn heartbeat(&self) { From d15de735fa93153c554dcc1c75ab7ca10306901b Mon Sep 17 00:00:00 2001 From: Jos Dehaes Date: Wed, 14 Feb 2024 20:39:43 +0100 Subject: [PATCH 092/551] fix: don't try to propose a batch when we're not yet synced --- node/bft/src/bft.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index bc72924dfb..7662f27b7f 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -251,6 +251,7 @@ impl BFT { // Update to the next round in storage. if let Err(e) = self.storage().increment_to_next_round(current_round) { warn!("BFT failed to increment to the next round from round {current_round} - {e}"); + return false; } // Update the timer for the leader certificate. self.leader_certificate_timer.store(now(), Ordering::SeqCst); From ed079fa112bf182ae92a82883f9abd8e525dad8f Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Wed, 14 Feb 2024 16:19:40 -0800 Subject: [PATCH 093/551] Update rev --- Cargo.lock | 116 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 2 +- 2 files changed, 59 insertions(+), 59 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d08cc2ce8d..f8cde5e5e5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3517,7 +3517,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "anstyle", "anyhow", @@ -3548,7 +3548,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "aleo-std", "anyhow", @@ -3578,7 +3578,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3592,7 +3592,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3603,7 +3603,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3613,7 +3613,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3623,7 +3623,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "indexmap 2.2.3", "itertools 0.11.0", @@ -3641,12 +3641,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3657,7 +3657,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3672,7 +3672,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3687,7 +3687,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3700,7 +3700,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3709,7 +3709,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3719,7 +3719,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3731,7 +3731,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3743,7 +3743,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3754,7 +3754,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3766,7 +3766,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3779,7 +3779,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "bs58", "snarkvm-console-network", @@ -3790,7 +3790,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "blake2s_simd", "smallvec", @@ -3803,7 +3803,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "aleo-std", "rayon", @@ -3814,7 +3814,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "anyhow", "indexmap 2.2.3", @@ -3837,7 +3837,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "anyhow", "bech32", @@ -3855,7 +3855,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "enum_index", "enum_index_derive", @@ -3876,7 +3876,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3891,7 +3891,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3902,7 +3902,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "snarkvm-console-network-environment", ] @@ -3910,7 +3910,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3920,7 +3920,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3931,7 +3931,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3942,7 +3942,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3953,7 +3953,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3964,7 +3964,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "rand", "rayon", @@ -3978,7 +3978,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "aleo-std", "anyhow", @@ -3995,7 +3995,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "aleo-std", "anyhow", @@ -4020,7 +4020,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "anyhow", "rand", @@ -4032,7 +4032,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "indexmap 2.2.3", "rayon", @@ -4051,7 +4051,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-coinbase" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "aleo-std", "anyhow", @@ -4071,7 +4071,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "anyhow", "indexmap 2.2.3", @@ -4089,7 +4089,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -4102,7 +4102,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "indexmap 2.2.3", "rayon", @@ -4115,7 +4115,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "indexmap 2.2.3", "serde_json", @@ -4127,7 +4127,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "bytes", "serde_json", @@ -4138,7 +4138,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "indexmap 2.2.3", "rayon", @@ -4153,7 +4153,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "bytes", "serde_json", @@ -4166,7 +4166,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "snarkvm-console", "snarkvm-ledger-coinbase", @@ -4175,7 +4175,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "async-trait", "reqwest", @@ -4188,7 +4188,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "aleo-std-storage", "anyhow", @@ -4214,7 +4214,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4229,7 +4229,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4238,7 +4238,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "aleo-std", "anyhow", @@ -4263,7 +4263,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "aleo-std", "anyhow", @@ -4288,7 +4288,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "aleo-std", "colored", @@ -4311,7 +4311,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "indexmap 2.2.3", "paste", @@ -4325,7 +4325,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "bincode", "once_cell", @@ -4338,7 +4338,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "aleo-std", "anyhow", @@ -4359,7 +4359,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=88347f3#88347f37d6912d295f3de50dc8a575bd79e0d522" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" dependencies = [ "proc-macro2", "quote 1.0.35", diff --git a/Cargo.toml b/Cargo.toml index 807f5938cf..e7c47953bf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "88347f3" +rev = "6e182c6" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From 36451607c02149eb48d082a19fda75eb01be79f9 Mon Sep 17 00:00:00 2001 From: Jos Dehaes Date: Thu, 15 Feb 2024 11:33:20 +0100 Subject: [PATCH 094/551] feat: more metrics - gateway messages received - certified batches --- Cargo.toml | 5 +- node/bft/events/Cargo.toml | 2 +- node/bft/events/src/helpers/codec.rs | 9 ++- node/bft/src/primary.rs | 3 + node/metrics/snarkOS-grafana.json | 108 ++++++++++++++++++++++----- node/metrics/src/names.rs | 8 +- 6 files changed, 111 insertions(+), 24 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e7c47953bf..b0743a59b9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,8 +45,9 @@ version = "=0.1.24" default-features = false [workspace.dependencies.snarkvm] -git = "https://github.com/AleoHQ/snarkVM.git" -rev = "6e182c6" +git = "https://github.com/joske/snarkVM.git" +branch = "feat/histogram_labels" +#rev = "6e182c6" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] diff --git a/node/bft/events/Cargo.toml b/node/bft/events/Cargo.toml index 5eb134b4c7..afb195706b 100644 --- a/node/bft/events/Cargo.toml +++ b/node/bft/events/Cargo.toml @@ -18,7 +18,7 @@ edition = "2021" [features] default = [ ] -metrics = [ "dep:metrics" ] +metrics = ["dep:metrics", "snarkvm/metrics"] [dependencies.anyhow] version = "1.0" diff --git a/node/bft/events/src/helpers/codec.rs b/node/bft/events/src/helpers/codec.rs index 0d0c273d18..f7185c8a65 100644 --- a/node/bft/events/src/helpers/codec.rs +++ b/node/bft/events/src/helpers/codec.rs @@ -13,6 +13,7 @@ // limitations under the License. use crate::Event; +use metrics::histogram_label; use snarkvm::prelude::{FromBytes, Network, ToBytes}; use bytes::{Buf, BufMut, Bytes, BytesMut}; @@ -83,11 +84,15 @@ impl Decoder for EventCodec { Some(bytes) => bytes, None => return Ok(None), }; - + let bytes_len = bytes.len() as f64; // Convert the bytes to an event, or fail if it is not valid. let reader = bytes.reader(); match Event::read_le(reader) { - Ok(event) => Ok(Some(event)), + Ok(event) => { + #[cfg(feature = "metrics")] + histogram_label(metrics::tcp::TCP_GATEWAY, "event", String::from(event.name().clone()), bytes_len); + Ok(Some(event)) + } Err(error) => { error!("Failed to deserialize an event: {}", error); Err(std::io::ErrorKind::InvalidData.into()) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index ac9cad8e30..4d2cd1e019 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -698,6 +698,9 @@ impl Primary { self.reinsert_transmissions_into_workers(proposal)?; return Err(e); } + + #[cfg(feature = "metrics")] + metrics::increment_gauge(metrics::bft::CERTIFIED_BATCHES, 1.0); Ok(()) } diff --git a/node/metrics/snarkOS-grafana.json b/node/metrics/snarkOS-grafana.json index 87070f09a4..25bd765970 100644 --- a/node/metrics/snarkOS-grafana.json +++ b/node/metrics/snarkOS-grafana.json @@ -979,13 +979,84 @@ "title": "Elected Leaders", "type": "stat" }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 6, + "x": 0, + "y": 42 + }, + "id": 40, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "10.2.3", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "snarkos_bft_primary_certified_batches", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "__auto", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Certified Batches", + "type": "stat" + }, { "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, - "y": 42 + "y": 50 }, "id": 10, "panels": [], @@ -1057,7 +1128,7 @@ "h": 8, "w": 9, "x": 0, - "y": 43 + "y": 51 }, "id": 8, "options": { @@ -1181,7 +1252,7 @@ "h": 8, "w": 9, "x": 9, - "y": 43 + "y": 51 }, "id": 14, "options": { @@ -1274,8 +1345,7 @@ "value": 80 } ] - }, - "unit": "s" + } }, "overrides": [] }, @@ -1283,7 +1353,7 @@ "h": 8, "w": 12, "x": 6, - "y": 51 + "y": 59 }, "id": 38, "options": { @@ -1325,7 +1395,7 @@ "h": 1, "w": 24, "x": 0, - "y": 59 + "y": 67 }, "id": 4, "panels": [], @@ -1396,7 +1466,7 @@ "h": 8, "w": 12, "x": 6, - "y": 60 + "y": 68 }, "id": 37, "options": { @@ -1480,7 +1550,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null }, { "color": "red", @@ -1496,7 +1567,7 @@ "h": 8, "w": 12, "x": 0, - "y": 68 + "y": 76 }, "id": 32, "options": { @@ -1580,7 +1651,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null }, { "color": "red", @@ -1596,7 +1668,7 @@ "h": 8, "w": 12, "x": 12, - "y": 68 + "y": 76 }, "id": 33, "options": { @@ -1683,7 +1755,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null }, { "color": "red", @@ -1699,7 +1772,7 @@ "h": 8, "w": 12, "x": 0, - "y": 76 + "y": 84 }, "id": 34, "options": { @@ -1783,7 +1856,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null }, { "color": "red", @@ -1799,7 +1873,7 @@ "h": 8, "w": 12, "x": 12, - "y": 76 + "y": 84 }, "id": 35, "options": { @@ -1867,6 +1941,6 @@ "timezone": "", "title": "snarkOS", "uid": "ahTJm4-4k", - "version": 1, + "version": 2, "weekStart": "" } \ No newline at end of file diff --git a/node/metrics/src/names.rs b/node/metrics/src/names.rs index 6f244e5f40..8194341846 100644 --- a/node/metrics/src/names.rs +++ b/node/metrics/src/names.rs @@ -14,11 +14,12 @@ pub(super) const COUNTER_NAMES: [&str; 1] = [bft::LEADERS_ELECTED]; -pub(super) const GAUGE_NAMES: [&str; 12] = [ +pub(super) const GAUGE_NAMES: [&str; 13] = [ bft::CONNECTED, bft::CONNECTING, bft::LAST_STORED_ROUND, bft::PROPOSAL_ROUND, + bft::CERTIFIED_BATCHES, blocks::HEIGHT, blocks::TRANSACTIONS, consensus::COMMITTED_CERTIFICATES, @@ -29,7 +30,7 @@ pub(super) const GAUGE_NAMES: [&str; 12] = [ tcp::TCP_TASKS, ]; -pub(super) const HISTOGRAM_NAMES: [&str; 7] = [ +pub(super) const HISTOGRAM_NAMES: [&str; 8] = [ bft::COMMIT_ROUNDS_LATENCY, consensus::CERTIFICATE_COMMIT_LATENCY, consensus::BLOCK_LATENCY, @@ -37,6 +38,7 @@ pub(super) const HISTOGRAM_NAMES: [&str; 7] = [ tcp::NOISE_CODEC_DECRYPTION_TIME, tcp::NOISE_CODEC_ENCRYPTION_SIZE, tcp::NOISE_CODEC_DECRYPTION_SIZE, + tcp::TCP_GATEWAY, ]; pub mod bft { @@ -46,6 +48,7 @@ pub mod bft { pub const LAST_STORED_ROUND: &str = "snarkos_bft_last_stored_round"; pub const LEADERS_ELECTED: &str = "snarkos_bft_leaders_elected_total"; pub const PROPOSAL_ROUND: &str = "snarkos_bft_primary_proposal_round"; + pub const CERTIFIED_BATCHES: &str = "snarkos_bft_primary_certified_batches"; } pub mod blocks { @@ -72,4 +75,5 @@ pub mod tcp { pub const NOISE_CODEC_ENCRYPTION_SIZE: &str = "snarkos_tcp_noise_codec_encryption_size"; pub const NOISE_CODEC_DECRYPTION_SIZE: &str = "snarkos_tcp_noise_codec_decryption_size"; pub const TCP_TASKS: &str = "snarkos_tcp_tasks_total"; + pub const TCP_GATEWAY: &str = "snarkos_tcp_gateway_messages_received"; } From f7eaf849e7a67a0c1807310f7ee46f2e8804106b Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Thu, 15 Feb 2024 13:16:25 -0800 Subject: [PATCH 095/551] Fix rev and add feature flag guard --- Cargo.lock | 116 +++++++++++++-------------- Cargo.toml | 5 +- node/bft/events/src/helpers/codec.rs | 11 ++- 3 files changed, 68 insertions(+), 64 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f8cde5e5e5..28ac9c23bc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3517,7 +3517,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "anstyle", "anyhow", @@ -3548,7 +3548,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "aleo-std", "anyhow", @@ -3578,7 +3578,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3592,7 +3592,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3603,7 +3603,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3613,7 +3613,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3623,7 +3623,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "indexmap 2.2.3", "itertools 0.11.0", @@ -3641,12 +3641,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3657,7 +3657,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3672,7 +3672,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3687,7 +3687,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3700,7 +3700,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3709,7 +3709,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3719,7 +3719,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3731,7 +3731,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3743,7 +3743,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3754,7 +3754,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3766,7 +3766,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3779,7 +3779,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "bs58", "snarkvm-console-network", @@ -3790,7 +3790,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "blake2s_simd", "smallvec", @@ -3803,7 +3803,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "aleo-std", "rayon", @@ -3814,7 +3814,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "anyhow", "indexmap 2.2.3", @@ -3837,7 +3837,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "anyhow", "bech32", @@ -3855,7 +3855,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "enum_index", "enum_index_derive", @@ -3876,7 +3876,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3891,7 +3891,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3902,7 +3902,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "snarkvm-console-network-environment", ] @@ -3910,7 +3910,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3920,7 +3920,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3931,7 +3931,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3942,7 +3942,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3953,7 +3953,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3964,7 +3964,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "rand", "rayon", @@ -3978,7 +3978,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "aleo-std", "anyhow", @@ -3995,7 +3995,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "aleo-std", "anyhow", @@ -4020,7 +4020,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "anyhow", "rand", @@ -4032,7 +4032,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "indexmap 2.2.3", "rayon", @@ -4051,7 +4051,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-coinbase" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "aleo-std", "anyhow", @@ -4071,7 +4071,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "anyhow", "indexmap 2.2.3", @@ -4089,7 +4089,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -4102,7 +4102,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "indexmap 2.2.3", "rayon", @@ -4115,7 +4115,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "indexmap 2.2.3", "serde_json", @@ -4127,7 +4127,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "bytes", "serde_json", @@ -4138,7 +4138,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "indexmap 2.2.3", "rayon", @@ -4153,7 +4153,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "bytes", "serde_json", @@ -4166,7 +4166,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "snarkvm-console", "snarkvm-ledger-coinbase", @@ -4175,7 +4175,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "async-trait", "reqwest", @@ -4188,7 +4188,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "aleo-std-storage", "anyhow", @@ -4214,7 +4214,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4229,7 +4229,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4238,7 +4238,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "aleo-std", "anyhow", @@ -4263,7 +4263,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "aleo-std", "anyhow", @@ -4288,7 +4288,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "aleo-std", "colored", @@ -4311,7 +4311,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "indexmap 2.2.3", "paste", @@ -4325,7 +4325,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "bincode", "once_cell", @@ -4338,7 +4338,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "aleo-std", "anyhow", @@ -4359,7 +4359,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=6e182c6#6e182c6d6c9ec92a0140dbf543e9149699b68c60" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" dependencies = [ "proc-macro2", "quote 1.0.35", diff --git a/Cargo.toml b/Cargo.toml index b0743a59b9..58de9ea971 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,9 +45,8 @@ version = "=0.1.24" default-features = false [workspace.dependencies.snarkvm] -git = "https://github.com/joske/snarkVM.git" -branch = "feat/histogram_labels" -#rev = "6e182c6" +git = "https://github.com/AleoHQ/snarkVM.git" +rev = "b396a51" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] diff --git a/node/bft/events/src/helpers/codec.rs b/node/bft/events/src/helpers/codec.rs index f7185c8a65..e9498427ec 100644 --- a/node/bft/events/src/helpers/codec.rs +++ b/node/bft/events/src/helpers/codec.rs @@ -13,7 +13,6 @@ // limitations under the License. use crate::Event; -use metrics::histogram_label; use snarkvm::prelude::{FromBytes, Network, ToBytes}; use bytes::{Buf, BufMut, Bytes, BytesMut}; @@ -84,13 +83,19 @@ impl Decoder for EventCodec { Some(bytes) => bytes, None => return Ok(None), }; - let bytes_len = bytes.len() as f64; + #[cfg(feature = "metrics")] + let num_bytes = bytes.len() as f64; // Convert the bytes to an event, or fail if it is not valid. let reader = bytes.reader(); match Event::read_le(reader) { Ok(event) => { #[cfg(feature = "metrics")] - histogram_label(metrics::tcp::TCP_GATEWAY, "event", String::from(event.name().clone()), bytes_len); + metrics::histogram_label( + metrics::tcp::TCP_GATEWAY, + "event", + String::from(event.name().clone()), + num_bytes, + ); Ok(Some(event)) } Err(error) => { From a8f9a7ca24df60d54db59d7b0c5cb9913c25915c Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Fri, 16 Feb 2024 13:07:07 -0800 Subject: [PATCH 096/551] Update rev --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 58de9ea971..4547d9587a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "b396a51" +rev = "bb54fc4" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From 53832420252d62e5cd26843dc57ab2d08089be20 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Fri, 16 Feb 2024 15:25:51 -0800 Subject: [PATCH 097/551] Update analytics tool --- .devnet/.analytics/analytics.js | 114 ++++++++++++++++++++++++-------- .devnet/.analytics/package.json | 2 - .devnet/analytics.sh | 20 +++++- 3 files changed, 104 insertions(+), 32 deletions(-) diff --git a/.devnet/.analytics/analytics.js b/.devnet/.analytics/analytics.js index 897eb1cb10..fc88a2c785 100644 --- a/.devnet/.analytics/analytics.js +++ b/.devnet/.analytics/analytics.js @@ -6,6 +6,44 @@ const yargs = require('yargs'); const dimStart = "\x1b[2m"; const dimEnd = "\x1b[0m"; +// Function to get the IP address of a given AWS node +async function getIPAddress(awsNodeName) { + // Read the ~/.ssh/config file + const sshConfigFile = fs.readFileSync(`${process.env.HOME}/.ssh/config`, 'utf8'); + + // Use regular expressions to extract the associated IP address + const regex = new RegExp(`Host\\s+${awsNodeName}[\\s\\S]*?HostName\\s+(\\S+)`); + const match = sshConfigFile.match(regex); + + if (match && match[1]) { + return match[1]; + } else { + console.error(`No IP address found for ${awsNodeName} in ~/.ssh/config`); + } +} + +// Function to get the count of AWS nodes based on the naming convention aws-nXX in the SSH config file +async function getAWSNodeCount() { + // Read the ~/.ssh/config file + const sshConfigFile = fs.readFileSync(`${process.env.HOME}/.ssh/config`, 'utf8'); + + // Regular expression to match all aws-nXX formats + const regex = /Host\s+(aws-n\d+)/g; + let match; + let highestNumber = -1; + + // Iterate over all matches and find the highest number + while ((match = regex.exec(sshConfigFile)) !== null) { + const nodeNumber = parseInt(match[1].replace('aws-n', ''), 10); + if (nodeNumber > highestNumber) { + highestNumber = nodeNumber; + } + } + + // Return the count of nodes, adding 1 because it starts from 0 + return highestNumber >= 0 ? highestNumber + 1 : 0; +} + // Function to fetch block data async function fetchBlockData(baseUrl, height) { try { @@ -77,10 +115,28 @@ async function calculateRoundsInBlocks(baseUrl, latestHeight) { } } +async function checkBlockHash(blockHeight) { + const numNodes = await getAWSNodeCount(); + console.log(`Detected ${numNodes} AWS nodes... \n`); + + for (let i = 0; i < numNodes; i++) { + // Define the AWS node name to search for (e.g., aws-n1) + const awsNodeName = `aws-n${i}`; + // Get the IP address of the AWS node + const ipAddress = await getIPAddress(awsNodeName); + // Define the base URL for the node + const baseUrl = `http://${ipAddress}:3030/mainnet/block`; + + // Fetch the block data + const blockData = await fetchBlockData(baseUrl, blockHeight); + console.log(`${awsNodeName} - Block ${blockHeight} - ${blockData.block_hash}`); + } +} + // Main function to fetch block metrics -async function fetchBlockMetrics(baseUrl, metricType) { +async function fetchBlockMetrics(metricType, optionalBlockHeight) { // Function to get the latest block height - async function getLatestBlockHeight() { + async function getLatestBlockHeight(baseUrl) { try { const response = await axios.get(`${baseUrl}/height/latest`); const latestHeight = response.data; @@ -92,7 +148,17 @@ async function fetchBlockMetrics(baseUrl, metricType) { } } - const latestHeight = await getLatestBlockHeight(); + // Define the AWS node name to search for (e.g., aws-n1) + const awsNodeName = 'aws-n1'; + // Get the IP address of the AWS node + const ipAddress = await getIPAddress(awsNodeName); + // Define the base URL for the node. + const baseUrl = `http://${ipAddress}:3030/mainnet/block`; + + console.log(`${dimStart}IP Address: ${ipAddress}${dimEnd}`); + console.log(`${dimStart}Base URL: ${baseUrl}${dimEnd}`); + + const latestHeight = await getLatestBlockHeight(baseUrl); if (latestHeight === null) { console.error('Unable to fetch latest block height, try again...'); return; @@ -104,6 +170,8 @@ async function fetchBlockMetrics(baseUrl, metricType) { calculateAverageBlockTime(baseUrl, latestHeight); } else if (metricType === 'roundsInBlocks') { calculateRoundsInBlocks(baseUrl, latestHeight); + } else if (metricType === 'checkBlockHash' && optionalBlockHeight) { + checkBlockHash(optionalBlockHeight); } else { console.error('Invalid metric type. Supported types: "averageBlockTime" or "roundsInBlocks".'); } @@ -115,35 +183,27 @@ async function main() { .options({ 'metric-type': { alias: 'm', - describe: 'Metric type to fetch (averageBlockTime or roundsInBlocks)', + describe: 'Metric type to fetch (averageBlockTime, roundsInBlocks, or checkBlockHash)', demandOption: true, - choices: ['averageBlockTime', 'roundsInBlocks'], + choices: ['averageBlockTime', 'roundsInBlocks', 'checkBlockHash'], + }, + 'block-height': { + alias: 'b', + describe: 'Block height to examine for checkBlockHash metric', + type: 'number', }, }) + .check((argv) => { + // Check if metric-type is checkBlockHash and block-height is provided + if (argv['metric-type'] === 'checkBlockHash' && (isNaN(argv['block-height']) || argv['block-height'] == null)) { + throw new Error('Block height is required when metric-type is checkBlockHash'); + } + return true; // Indicate that the arguments passed the check + }) .argv; - // Read the ~/.ssh/config file - const sshConfigFile = fs.readFileSync(`${process.env.HOME}/.ssh/config`, 'utf8'); - - // Define the AWS node name to search for (e.g., aws-n1) - const awsNodeName = 'aws-n1'; - - // Use regular expressions to extract the IP address associated with aws-n0 - const regex = new RegExp(`Host\\s+${awsNodeName}[\\s\\S]*?HostName\\s+(\\S+)`); - const match = sshConfigFile.match(regex); - - if (match && match[1]) { - const ipAddress = match[1]; - const baseUrl = `http://${ipAddress}:3030/mainnet/block`; - - console.log(`${dimStart}IP Address: ${ipAddress}${dimEnd}`); - console.log(`${dimStart}Base URL: ${baseUrl}${dimEnd}`); - - // Fetch and output the specified block metric - fetchBlockMetrics(baseUrl, argv['metric-type']); - } else { - console.error(`No IP address found for ${awsNodeName} in ~/.ssh/config`); - } + // Fetch and output the specified block metric + fetchBlockMetrics(argv['metric-type'], argv['block-height']); } // Run the main function diff --git a/.devnet/.analytics/package.json b/.devnet/.analytics/package.json index ebb359a766..267cfc4826 100644 --- a/.devnet/.analytics/package.json +++ b/.devnet/.analytics/package.json @@ -4,8 +4,6 @@ "description": "", "main": "analytics.js", "scripts": { - "averageBlockTime": "node analytics.js --metric-type averageBlockTime", - "roundsInBlocks": "node analytics.js --metric-type roundsInBlocks", "test": "echo \"Error: no test specified\" && exit 1" }, "author": "The Aleo Team", diff --git a/.devnet/analytics.sh b/.devnet/analytics.sh index e2671f552b..9284f3a7e7 100755 --- a/.devnet/analytics.sh +++ b/.devnet/analytics.sh @@ -16,16 +16,30 @@ fi # Prompt the user to select a metric type PS3="Select a metric type: " -options=("Average Block Time" "Rounds in Blocks" "Quit") +options=("Average Block Time" "Rounds in Blocks" "Check Block Hash" "Quit") select opt in "${options[@]}" do case $opt in "Average Block Time") - npm run averageBlockTime + echo "" + node analytics.js --metric-type averageBlockTime break ;; "Rounds in Blocks") - npm run roundsInBlocks + echo "" + node analytics.js --metric-type roundsInBlocks + break + ;; + "Check Block Hash") + echo "You selected 'Check Block Hash'. Please enter the block height:" + read blockHeight + echo "" + # Validate input is an integer + if ! [[ "$blockHeight" =~ ^[0-9]+$ ]]; then + echo "Error: Block height must be a positive integer." + exit 1 + fi + node analytics.js --metric-type checkBlockHash --block-height "$blockHeight" break ;; "Quit") From 2590a9b5ee0c3b92f9ba352058441659a6986c9b Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sat, 17 Feb 2024 12:38:35 -0800 Subject: [PATCH 098/551] Handle analytics response --- .devnet/.analytics/analytics.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.devnet/.analytics/analytics.js b/.devnet/.analytics/analytics.js index fc88a2c785..601be7a19f 100644 --- a/.devnet/.analytics/analytics.js +++ b/.devnet/.analytics/analytics.js @@ -129,7 +129,11 @@ async function checkBlockHash(blockHeight) { // Fetch the block data const blockData = await fetchBlockData(baseUrl, blockHeight); - console.log(`${awsNodeName} - Block ${blockHeight} - ${blockData.block_hash}`); + if (blockData && blockData.block_hash) { + console.log(`${awsNodeName} - Block ${blockHeight} - ${blockData.block_hash}`); + } else { + console.log(`${awsNodeName} - Block ${blockHeight} - No block hash found`); + } } } From 42c87f8075fdc774e0e4c7a0347c444947e8f47c Mon Sep 17 00:00:00 2001 From: Victor Sint Nicolaas Date: Mon, 19 Feb 2024 14:43:01 +0100 Subject: [PATCH 099/551] Check if the number of peers received is less than u8::MAX --- node/router/src/inbound.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/node/router/src/inbound.rs b/node/router/src/inbound.rs index 925d6f5d20..8ecea86964 100644 --- a/node/router/src/inbound.rs +++ b/node/router/src/inbound.rs @@ -39,6 +39,9 @@ use snarkos_node_tcp::is_bogon_ip; use std::{net::SocketAddr, time::Instant}; use tokio::task::spawn_blocking; +/// The max number of peers to send in a `PeerResponse` message. +const MAX_PEERS_TO_SEND: usize = u8::MAX as usize; + #[async_trait] pub trait Inbound: Reading + Outbound { /// The maximum number of puzzle requests per interval. @@ -265,9 +268,11 @@ pub trait Inbound: Reading + Outbound { // Filter out invalid addresses. let peers = match self.router().is_dev() { // In development mode, relax the validity requirements to make operating devnets more flexible. - true => peers.into_iter().filter(|ip| !is_bogon_ip(ip.ip())).take(u8::MAX as usize).collect(), + true => peers.into_iter().filter(|ip| !is_bogon_ip(ip.ip())).take(MAX_PEERS_TO_SEND).collect(), // In production mode, ensure the peer IPs are valid. - false => peers.into_iter().filter(|ip| self.router().is_valid_peer_ip(ip)).take(u8::MAX as usize).collect(), + false => { + peers.into_iter().filter(|ip| self.router().is_valid_peer_ip(ip)).take(MAX_PEERS_TO_SEND).collect() + } }; // Send a `PeerResponse` message to the peer. self.send(peer_ip, Message::PeerResponse(PeerResponse { peers })); @@ -276,6 +281,10 @@ pub trait Inbound: Reading + Outbound { /// Handles a `PeerResponse` message. fn peer_response(&self, _peer_ip: SocketAddr, peers: &[SocketAddr]) -> bool { + // Check if the number of peers received is less than MAX_PEERS_TO_SEND. + if peers.len() > MAX_PEERS_TO_SEND { + return false; + } // Filter out invalid addresses. let peers = match self.router().is_dev() { // In development mode, relax the validity requirements to make operating devnets more flexible. From 50c2fab5b9e28603032680bad195796ebc945235 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Mon, 19 Feb 2024 14:09:58 +0100 Subject: [PATCH 100/551] feat: handle more POSIX signals on UNIX systems Signed-off-by: ljedrz --- node/src/traits.rs | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/node/src/traits.rs b/node/src/traits.rs index 12947ca3f2..6fd41686c6 100644 --- a/node/src/traits.rs +++ b/node/src/traits.rs @@ -17,6 +17,8 @@ use snarkvm::prelude::{Address, Network, PrivateKey, ViewKey}; use once_cell::sync::OnceCell; use std::{ + future::Future, + io, sync::{ atomic::{AtomicBool, Ordering}, Arc, @@ -53,15 +55,40 @@ pub trait NodeInterface: Routing { /// Handles OS signals for the node to intercept and perform a clean shutdown. /// The optional `shutdown_flag` flag can be used to cleanly terminate the syncing process. - /// Note: Only Ctrl-C is supported; it should work on both Unix-family systems and Windows. fn handle_signals(shutdown_flag: Arc) -> Arc> { // In order for the signal handler to be started as early as possible, a reference to the node needs // to be passed to it at a later time. let node: Arc> = Default::default(); + #[cfg(target_family = "unix")] + fn signal_listener() -> impl Future> { + use tokio::signal::unix::{signal, SignalKind}; + + // Handle SIGINT, SIGTERM, SIGQUIT, and SIGHUP. + let mut s_int = signal(SignalKind::interrupt()).unwrap(); + let mut s_term = signal(SignalKind::terminate()).unwrap(); + let mut s_quit = signal(SignalKind::quit()).unwrap(); + let mut s_hup = signal(SignalKind::hangup()).unwrap(); + + // Return when any of the signals above is received. + async move { + tokio::select!( + _ = s_int.recv() => (), + _ = s_term.recv() => (), + _ = s_quit.recv() => (), + _ = s_hup.recv() => (), + ); + Ok(()) + } + } + #[cfg(not(target_family = "unix"))] + fn signal_listener() -> impl Future> { + tokio::signal::ctrl_c() + } + let node_clone = node.clone(); tokio::task::spawn(async move { - match tokio::signal::ctrl_c().await { + match signal_listener().await { Ok(()) => { match node_clone.get() { // If the node is already initialized, then shut it down. From 4cbae9ee3e7b828ba09dbb4ec9dbe9ae8e9ce187 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 19 Feb 2024 10:39:56 -0800 Subject: [PATCH 101/551] Update snarkVM rev - 1cebaaf --- Cargo.lock | 116 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 2 +- 2 files changed, 59 insertions(+), 59 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 28ac9c23bc..2739759410 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3517,7 +3517,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "anstyle", "anyhow", @@ -3548,7 +3548,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "aleo-std", "anyhow", @@ -3578,7 +3578,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3592,7 +3592,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3603,7 +3603,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3613,7 +3613,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3623,7 +3623,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "indexmap 2.2.3", "itertools 0.11.0", @@ -3641,12 +3641,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3657,7 +3657,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3672,7 +3672,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3687,7 +3687,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3700,7 +3700,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3709,7 +3709,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3719,7 +3719,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3731,7 +3731,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3743,7 +3743,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3754,7 +3754,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3766,7 +3766,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3779,7 +3779,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "bs58", "snarkvm-console-network", @@ -3790,7 +3790,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "blake2s_simd", "smallvec", @@ -3803,7 +3803,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "aleo-std", "rayon", @@ -3814,7 +3814,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "anyhow", "indexmap 2.2.3", @@ -3837,7 +3837,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "anyhow", "bech32", @@ -3855,7 +3855,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "enum_index", "enum_index_derive", @@ -3876,7 +3876,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3891,7 +3891,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3902,7 +3902,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "snarkvm-console-network-environment", ] @@ -3910,7 +3910,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3920,7 +3920,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3931,7 +3931,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3942,7 +3942,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3953,7 +3953,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3964,7 +3964,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "rand", "rayon", @@ -3978,7 +3978,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "aleo-std", "anyhow", @@ -3995,7 +3995,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "aleo-std", "anyhow", @@ -4020,7 +4020,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "anyhow", "rand", @@ -4032,7 +4032,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "indexmap 2.2.3", "rayon", @@ -4051,7 +4051,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-coinbase" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "aleo-std", "anyhow", @@ -4071,7 +4071,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "anyhow", "indexmap 2.2.3", @@ -4089,7 +4089,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -4102,7 +4102,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "indexmap 2.2.3", "rayon", @@ -4115,7 +4115,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "indexmap 2.2.3", "serde_json", @@ -4127,7 +4127,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "bytes", "serde_json", @@ -4138,7 +4138,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "indexmap 2.2.3", "rayon", @@ -4153,7 +4153,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "bytes", "serde_json", @@ -4166,7 +4166,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "snarkvm-console", "snarkvm-ledger-coinbase", @@ -4175,7 +4175,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "async-trait", "reqwest", @@ -4188,7 +4188,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "aleo-std-storage", "anyhow", @@ -4214,7 +4214,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4229,7 +4229,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4238,7 +4238,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "aleo-std", "anyhow", @@ -4263,7 +4263,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "aleo-std", "anyhow", @@ -4288,7 +4288,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "aleo-std", "colored", @@ -4311,7 +4311,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "indexmap 2.2.3", "paste", @@ -4325,7 +4325,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "bincode", "once_cell", @@ -4338,7 +4338,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "aleo-std", "anyhow", @@ -4359,7 +4359,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=b396a51#b396a51396cfca0cc4de0a0f794063cee8aea719" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" dependencies = [ "proc-macro2", "quote 1.0.35", diff --git a/Cargo.toml b/Cargo.toml index 4547d9587a..a6529d6884 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "bb54fc4" +rev = "1cebaaf" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From a49f7daf8a837f42ce3ad54837eb18053be4a135 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Mon, 19 Feb 2024 10:45:56 -0800 Subject: [PATCH 102/551] Update bootstrap peers --- node/router/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/node/router/src/lib.rs b/node/router/src/lib.rs index 3dab4b01b2..84b00a5031 100644 --- a/node/router/src/lib.rs +++ b/node/router/src/lib.rs @@ -381,10 +381,10 @@ impl Router { vec![] } else { vec![ - SocketAddr::from_str("35.224.50.150:4130").unwrap(), - SocketAddr::from_str("35.227.159.141:4130").unwrap(), - SocketAddr::from_str("34.139.203.87:4130").unwrap(), - SocketAddr::from_str("34.150.221.166:4130").unwrap(), + SocketAddr::from_str("64.23.169.88:4130").unwrap(), + SocketAddr::from_str("146.190.35.174:4130").unwrap(), + SocketAddr::from_str("45.55.201.67:4130").unwrap(), + SocketAddr::from_str("45.55.201.80:4130").unwrap(), ] } } From 1be1c0b7824553b2fa4e1cadd3b9efd2fcbe9019 Mon Sep 17 00:00:00 2001 From: mdelle1 <108158289+mdelle1@users.noreply.github.com> Date: Mon, 19 Feb 2024 18:38:14 -0500 Subject: [PATCH 103/551] Adds quorum check before advancing from odd and even rounds in BFT --- node/bft/src/bft.rs | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 7662f27b7f..571bfa6cea 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -322,6 +322,14 @@ impl BFT { committee: Committee, current_round: u64, ) -> bool { + // Retrieve the authors for the current round. + let authors = certificates.into_iter().map(|c| c.author()).collect(); + // Check if quorum threshold is reached. + let is_quorum = committee.is_quorum_threshold_reached(&authors); + if !is_quorum { + info!("BFT failed to advance to the next round - quorum threshold not reached in even round {current_round}. "); + return false; + } // If the leader certificate is set for the current even round, return 'true'. if let Some(leader_certificate) = self.leader_certificate.read().as_ref() { if leader_certificate.round() == current_round { @@ -330,11 +338,8 @@ impl BFT { } // If the timer has expired, and we can achieve quorum threshold (2f + 1) without the leader, return 'true'. if self.is_timer_expired() { - debug!("BFT (timer expired) - Checking for quorum threshold (without the leader)"); - // Retrieve the certificate authors. - let authors = certificates.into_iter().map(|c| c.author()).collect(); - // Determine if the quorum threshold is reached. - return committee.is_quorum_threshold_reached(&authors); + debug!("BFT (timer expired) - Advancing from round {current_round} to the next round (without the leader)"); + return true; } // Otherwise, return 'false'. false @@ -363,14 +368,6 @@ impl BFT { error!("BFT does not compute stakes for the leader certificate in an even round"); return false; } - - // Retrieve the leader certificate. - let Some(leader_certificate) = self.leader_certificate.read().clone() else { - // If there is no leader certificate for the previous round, return 'true'. - return true; - }; - // Retrieve the leader certificate ID. - let leader_certificate_id = leader_certificate.id(); // Retrieve the certificates for the current round. let current_certificates = self.storage().get_certificates_for_round(current_round); // Retrieve the committee lookback for the current round. @@ -381,7 +378,21 @@ impl BFT { return false; } }; - + // Retrieve the authors of the current certificates. + let authors = current_certificates.clone().into_iter().map(|c| c.author()).collect(); + // Check if quorum threshold is reached. + let is_quorum = previous_committee.clone().is_quorum_threshold_reached(&authors); + if !is_quorum { + info!("BFT failed to advance to the next round - quorum threshold not reached in odd round {current_round}. "); + return false; + } + // Retrieve the leader certificate. + let Some(leader_certificate) = self.leader_certificate.read().clone() else { + // If there is no leader certificate for the previous round, return 'true'. + return true; + }; + // Retrieve the leader certificate ID. + let leader_certificate_id = leader_certificate.id(); // Compute the stake for the leader certificate. let (stake_with_leader, stake_without_leader) = self.compute_stake_for_leader_certificate(leader_certificate_id, current_certificates, &committee_lookback); From 37b3a9d31dd144c06dce1e276495642f5dd00db9 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 19 Feb 2024 15:51:07 -0800 Subject: [PATCH 104/551] Add fee transmission check in ensure_transmission_id_matches --- node/bft/ledger-service/src/ledger.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/node/bft/ledger-service/src/ledger.rs b/node/bft/ledger-service/src/ledger.rs index 1f42f909b0..d754dc2ef9 100644 --- a/node/bft/ledger-service/src/ledger.rs +++ b/node/bft/ledger-service/src/ledger.rs @@ -185,6 +185,7 @@ impl> LedgerService for CoreLedgerService< (TransmissionID::Transaction(expected_transaction_id), Transmission::Transaction(transaction_data)) => { match transaction_data.clone().deserialize_blocking() { Ok(transaction) => { + // Ensure the transaction ID matches the expected transaction ID. if transaction.id() != expected_transaction_id { bail!( "Received mismatching transaction ID - expected {}, found {}", @@ -193,6 +194,11 @@ impl> LedgerService for CoreLedgerService< ); } + // Ensure the transaction is not a fee transaction. + if transaction.is_fee() { + bail!("Received a fee transaction in a transmission"); + } + // Update the transmission with the deserialized transaction. *transaction_data = Data::Object(transaction); } From e59535e397fc99825600b5ec77b0eac6a177c775 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 19 Feb 2024 15:51:51 -0800 Subject: [PATCH 105/551] Perform basic check on transmissions in batch proposals --- node/bft/src/primary.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 4d2cd1e019..2061e11add 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -549,7 +549,16 @@ impl Primary { } // If the peer is ahead, use the batch header to sync up to the peer. - let transmissions = self.sync_with_batch_header_from_peer(peer_ip, &batch_header).await?; + let mut transmissions = self.sync_with_batch_header_from_peer(peer_ip, &batch_header).await?; + + // Check that the transmission ids match and are not fee transactions. + for (transmission_id, transmission) in transmissions.iter_mut() { + // If the transmission is invalid, then return early. + if let Err(err) = self.ledger.ensure_transmission_id_matches(*transmission_id, transmission) { + debug!("Batch propose from '{peer_ip}' contains an invalid transmission - {err}",); + return Ok(()); + } + } // Ensure the batch is for the current round. // This method must be called after fetching previous certificates (above), From 5883484b435449c966d5688050c3b995fb64fb3f Mon Sep 17 00:00:00 2001 From: mdelle1 <108158289+mdelle1@users.noreply.github.com> Date: Mon, 19 Feb 2024 19:04:28 -0500 Subject: [PATCH 106/551] Uses committee lookback --- node/bft/src/bft.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 571bfa6cea..7df2d5ddd4 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -381,7 +381,7 @@ impl BFT { // Retrieve the authors of the current certificates. let authors = current_certificates.clone().into_iter().map(|c| c.author()).collect(); // Check if quorum threshold is reached. - let is_quorum = previous_committee.clone().is_quorum_threshold_reached(&authors); + let is_quorum = committee_lookback.clone().is_quorum_threshold_reached(&authors); if !is_quorum { info!("BFT failed to advance to the next round - quorum threshold not reached in odd round {current_round}. "); return false; From 9a5d470f98566c0eeae68e8871c4feae1f688342 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 19 Feb 2024 19:40:02 -0800 Subject: [PATCH 107/551] Update is_proposing check --- node/bft/src/primary.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 4d2cd1e019..8dea9e33a2 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -722,6 +722,8 @@ impl Primary { // Retrieve the batch certificate author. let author = certificate.author(); + // Retrieve the batch certificate round. + let certificate_round = certificate.round(); // Ensure the batch certificate is from an authorized validator. if !self.gateway.is_authorized_validator_ip(peer_ip) { @@ -751,14 +753,19 @@ impl Primary { // Check if the certificates have reached the quorum threshold. let is_quorum = committee_lookback.is_quorum_threshold_reached(&authors); - // Determine if we are currently proposing a round. + // Determine if we are currently proposing a round that is relevant. // Note: This is important, because while our peers have advanced, // they may not be proposing yet, and thus still able to sign our proposed batch. - let is_proposing = self.proposed_batch.read().is_some(); + let should_advance = match &*self.proposed_batch.read() { + // We advance if the proposal round is less than the current round that was just certified. + Some(proposal) => proposal.round() < certificate_round, + // If there's no proposal, we consider advancing. + None => true, + }; // Determine whether to advance to the next round. - if is_quorum && !is_proposing { - // If we have reached the quorum threshold, then proceed to the next round. + if is_quorum && should_advance { + // If we have reached the quorum threshold and the round should advance, then proceed to the next round. self.try_increment_to_the_next_round(current_round + 1).await?; } Ok(()) From 129f89c9efe6954bb724c7f5ce8bbfed8cef9e34 Mon Sep 17 00:00:00 2001 From: miazn Date: Mon, 19 Feb 2024 22:41:25 -0500 Subject: [PATCH 108/551] add plaintext codec message metrics, as well as inbound/outbound for tcp --- node/bft/events/src/helpers/codec.rs | 17 ++++++++++--- node/metrics/src/names.rs | 12 ++++++--- node/router/Cargo.toml | 2 +- node/router/messages/Cargo.toml | 7 +++++ node/router/messages/src/helpers/codec.rs | 31 +++++++++++++++++++---- 5 files changed, 57 insertions(+), 12 deletions(-) diff --git a/node/bft/events/src/helpers/codec.rs b/node/bft/events/src/helpers/codec.rs index e9498427ec..4d25ad975b 100644 --- a/node/bft/events/src/helpers/codec.rs +++ b/node/bft/events/src/helpers/codec.rs @@ -68,8 +68,19 @@ impl Encoder> for EventCodec { .map_err(|_| std::io::Error::new(std::io::ErrorKind::InvalidData, "serialization error"))?; let serialized_event = dst.split_to(dst.len()).freeze(); - - self.codec.encode(serialized_event, dst) + #[cfg(feature = "metrics")] + let num_bytes = serialized_event.len() as f64; + + self.codec.encode(serialized_event, dst)?; + + #[cfg(feature = "metrics")] + metrics::histogram_label( + metrics::tcp::TCP_GATEWAY_EVENTS_OUTBOUND, + "event", + String::from(event.name().clone()), + num_bytes, + ); + Ok(()) } } @@ -91,7 +102,7 @@ impl Decoder for EventCodec { Ok(event) => { #[cfg(feature = "metrics")] metrics::histogram_label( - metrics::tcp::TCP_GATEWAY, + metrics::tcp::TCP_GATEWAY_EVENTS_INBOUND, "event", String::from(event.name().clone()), num_bytes, diff --git a/node/metrics/src/names.rs b/node/metrics/src/names.rs index 8194341846..9bd38563fe 100644 --- a/node/metrics/src/names.rs +++ b/node/metrics/src/names.rs @@ -30,7 +30,7 @@ pub(super) const GAUGE_NAMES: [&str; 13] = [ tcp::TCP_TASKS, ]; -pub(super) const HISTOGRAM_NAMES: [&str; 8] = [ +pub(super) const HISTOGRAM_NAMES: [&str; 11] = [ bft::COMMIT_ROUNDS_LATENCY, consensus::CERTIFICATE_COMMIT_LATENCY, consensus::BLOCK_LATENCY, @@ -38,7 +38,10 @@ pub(super) const HISTOGRAM_NAMES: [&str; 8] = [ tcp::NOISE_CODEC_DECRYPTION_TIME, tcp::NOISE_CODEC_ENCRYPTION_SIZE, tcp::NOISE_CODEC_DECRYPTION_SIZE, - tcp::TCP_GATEWAY, + tcp::TCP_GATEWAY_EVENTS_OUTBOUND, + tcp::TCP_GATEWAY_EVENTS_INBOUND, + tcp::TCP_GATEWAY_MESSAGES_OUTBOUND, + tcp::TCP_GATEWAY_MESSAGES_INBOUND, ]; pub mod bft { @@ -75,5 +78,8 @@ pub mod tcp { pub const NOISE_CODEC_ENCRYPTION_SIZE: &str = "snarkos_tcp_noise_codec_encryption_size"; pub const NOISE_CODEC_DECRYPTION_SIZE: &str = "snarkos_tcp_noise_codec_decryption_size"; pub const TCP_TASKS: &str = "snarkos_tcp_tasks_total"; - pub const TCP_GATEWAY: &str = "snarkos_tcp_gateway_messages_received"; + pub const TCP_GATEWAY_EVENTS_OUTBOUND: &str = "snarkos_tcp_gateway_events_outbound"; + pub const TCP_GATEWAY_EVENTS_INBOUND: &str = "snarkos_tcp_gateway_events_inbound"; + pub const TCP_GATEWAY_MESSAGES_OUTBOUND: &str = "snarkos_tcp_gateway_messages_outbound"; + pub const TCP_GATEWAY_MESSAGES_INBOUND: &str = "snarkos_tcp_gateway_messages_inbound"; } diff --git a/node/router/Cargo.toml b/node/router/Cargo.toml index c0483487ce..380f2081a7 100644 --- a/node/router/Cargo.toml +++ b/node/router/Cargo.toml @@ -18,7 +18,7 @@ edition = "2021" [features] test = [ ] -metrics = [ "dep:metrics" ] +metrics = [ "dep:metrics", "snarkos-node-router-messages/metrics" ] [dependencies.anyhow] version = "1.0.79" diff --git a/node/router/messages/Cargo.toml b/node/router/messages/Cargo.toml index 503ef8c1f6..72692c528f 100644 --- a/node/router/messages/Cargo.toml +++ b/node/router/messages/Cargo.toml @@ -19,6 +19,7 @@ edition = "2021" [features] default = [ ] test = [ ] +metrics = ["dep:metrics", "snarkvm/metrics"] [dependencies.anyhow] version = "1.0" @@ -30,6 +31,12 @@ version = "1" version = "2.1" features = [ "serde", "rayon" ] +[dependencies.metrics] +package = "snarkos-node-metrics" +path = "../../metrics" +version = "=2.2.7" +optional = true + [dependencies.rayon] version = "1" diff --git a/node/router/messages/src/helpers/codec.rs b/node/router/messages/src/helpers/codec.rs index e3a12b7227..93753a5536 100644 --- a/node/router/messages/src/helpers/codec.rs +++ b/node/router/messages/src/helpers/codec.rs @@ -51,7 +51,7 @@ impl Default for MessageCodec { impl Encoder> for MessageCodec { type Error = std::io::Error; - fn encode(&mut self, message: Message, dst: &mut BytesMut) -> Result<(), Self::Error> { + fn encode(&mut self, message: Message, dst: &mut BytesMut) -> Result<(), Self::Error> { // Serialize the payload directly into dst. message .write_le(&mut dst.writer()) @@ -59,8 +59,19 @@ impl Encoder> for MessageCodec { .map_err(|_| std::io::Error::new(std::io::ErrorKind::InvalidData, "serialization error"))?; let serialized_message = dst.split_to(dst.len()).freeze(); - - self.codec.encode(serialized_message, dst) + #[cfg(feature = "metrics")] + let num_bytes = serialized_message.len() as f64; + + self.codec.encode(serialized_message, dst)?; + + #[cfg(feature = "metrics")] + metrics::histogram_label( + metrics::tcp::TCP_GATEWAY_MESSAGES_OUTBOUND, + "message", + String::from(message.name().clone()), + num_bytes, + ); + Ok(()) } } @@ -74,11 +85,21 @@ impl Decoder for MessageCodec { Some(bytes) => bytes, None => return Ok(None), }; - + #[cfg(feature = "metrics")] + let num_bytes = bytes.len() as f64; // Convert the bytes to a message, or fail if it is not valid. let reader = bytes.reader(); match Message::read_le(reader) { - Ok(message) => Ok(Some(message)), + Ok(message) => { + #[cfg(feature = "metrics")] + metrics::histogram_label( + metrics::tcp::TCP_GATEWAY_MESSAGES_INBOUND, + "message", + String::from(message.name().clone()), + num_bytes, + ); + Ok(Some(message)) + } Err(error) => { warn!("Failed to deserialize a message - {}", error); Err(std::io::ErrorKind::InvalidData.into()) From ebdec6c1d5c427abe7077411d6504a017597cf7c Mon Sep 17 00:00:00 2001 From: ljedrz Date: Tue, 20 Feb 2024 12:58:09 +0100 Subject: [PATCH 109/551] perf: cache the recently queried committees Signed-off-by: ljedrz --- node/bft/ledger-service/Cargo.toml | 6 ++++-- node/bft/ledger-service/src/ledger.rs | 27 ++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/node/bft/ledger-service/Cargo.toml b/node/bft/ledger-service/Cargo.toml index 8a37cdb97e..69d912a82d 100644 --- a/node/bft/ledger-service/Cargo.toml +++ b/node/bft/ledger-service/Cargo.toml @@ -20,7 +20,7 @@ edition = "2021" default = [ ] ledger = [ "rand", "tokio", "tracing" ] ledger-write = [ ] -mock = [ "parking_lot", "tracing" ] +mock = [ "tracing" ] prover = [ ] test = [ "mock", "translucent" ] translucent = [ "ledger" ] @@ -32,9 +32,11 @@ version = "0.1" version = "2.1" features = [ "serde", "rayon" ] +[dependencies.lru] +version = "0.12" + [dependencies.parking_lot] version = "0.12" -optional = true [dependencies.rand] version = "0.8" diff --git a/node/bft/ledger-service/src/ledger.rs b/node/bft/ledger-service/src/ledger.rs index 1f42f909b0..3af160028e 100644 --- a/node/bft/ledger-service/src/ledger.rs +++ b/node/bft/ledger-service/src/ledger.rs @@ -26,6 +26,8 @@ use snarkvm::{ }; use indexmap::IndexMap; +use lru::LruCache; +use parking_lot::Mutex; use std::{ fmt, ops::Range, @@ -35,18 +37,23 @@ use std::{ }, }; +/// The capacity of the LRU holiding the recently queried committees. +const COMMITTEE_CACHE_SIZE: usize = 16; + /// A core ledger service. pub struct CoreLedgerService> { ledger: Ledger, coinbase_verifying_key: Arc>, shutdown: Arc, + committee_cache: Arc>>>, } impl> CoreLedgerService { /// Initializes a new core ledger service. pub fn new(ledger: Ledger, shutdown: Arc) -> Self { let coinbase_verifying_key = Arc::new(ledger.coinbase_puzzle().coinbase_verifying_key().clone()); - Self { ledger, coinbase_verifying_key, shutdown } + let committee_cache = Arc::new(Mutex::new(LruCache::new(COMMITTEE_CACHE_SIZE.try_into().unwrap()))); + Self { ledger, coinbase_verifying_key, shutdown, committee_cache } } } @@ -127,20 +134,30 @@ impl> LedgerService for CoreLedgerService< /// Returns the committee for the given round. /// If the given round is in the future, then the current committee is returned. fn get_committee_for_round(&self, round: u64) -> Result> { - match self.ledger.get_committee_for_round(round)? { + // Check if the committee is already in the cache. + if let Some(committee) = self.committee_cache.lock().get(&round) { + return Ok(committee.clone()); + } + + let committee = match self.ledger.get_committee_for_round(round)? { // Return the committee if it exists. - Some(committee) => Ok(committee), + Some(committee) => committee, // Return the current committee if the round is in the future. None => { // Retrieve the current committee. let current_committee = self.current_committee()?; // Return the current committee if the round is in the future. match current_committee.starting_round() <= round { - true => Ok(current_committee), + true => current_committee, false => bail!("No committee found for round {round} in the ledger"), } } - } + }; + + // Insert the committee into the cache. + self.committee_cache.lock().push(round, committee.clone()); + + Ok(committee) } /// Returns the committee lookback for the given round. From 497e42c1ea684ca52c0b6fb37247e9c86f160e1d Mon Sep 17 00:00:00 2001 From: ljedrz Date: Tue, 20 Feb 2024 13:04:55 +0100 Subject: [PATCH 110/551] chore: adjust the lockfile Signed-off-by: ljedrz --- Cargo.lock | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.lock b/Cargo.lock index 2739759410..8ada6baf5c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3309,6 +3309,7 @@ version = "2.2.7" dependencies = [ "async-trait", "indexmap 2.2.3", + "lru", "parking_lot", "rand", "snarkvm", From d5659b694a562a6f52dea3a0796818ee19126fb5 Mon Sep 17 00:00:00 2001 From: miazn Date: Tue, 20 Feb 2024 08:53:51 -0500 Subject: [PATCH 111/551] fix transactions metric -> counter to gauge --- node/bft/events/src/helpers/codec.rs | 4 +--- node/consensus/src/lib.rs | 2 +- node/router/messages/src/helpers/codec.rs | 6 ++---- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/node/bft/events/src/helpers/codec.rs b/node/bft/events/src/helpers/codec.rs index 4d25ad975b..74ae0ed7ce 100644 --- a/node/bft/events/src/helpers/codec.rs +++ b/node/bft/events/src/helpers/codec.rs @@ -70,10 +70,8 @@ impl Encoder> for EventCodec { let serialized_event = dst.split_to(dst.len()).freeze(); #[cfg(feature = "metrics")] let num_bytes = serialized_event.len() as f64; - self.codec.encode(serialized_event, dst)?; - - #[cfg(feature = "metrics")] + #[cfg(feature = "metrics")] metrics::histogram_label( metrics::tcp::TCP_GATEWAY_EVENTS_OUTBOUND, "event", diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 30bc32c7e6..27c1afe2d1 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -407,7 +407,7 @@ impl Consensus { let block_latency = next_block_timestamp - current_block_timestamp; metrics::gauge(metrics::blocks::HEIGHT, next_block.height() as f64); - metrics::counter(metrics::blocks::TRANSACTIONS, next_block.transactions().len() as u64); + metrics::gauge(metrics::blocks::TRANSACTIONS, next_block.transactions().len() as f64); metrics::gauge(metrics::consensus::LAST_COMMITTED_ROUND, next_block.round() as f64); metrics::gauge(metrics::consensus::COMMITTED_CERTIFICATES, num_committed_certificates as f64); metrics::histogram(metrics::consensus::CERTIFICATE_COMMIT_LATENCY, elapsed.as_secs_f64()); diff --git a/node/router/messages/src/helpers/codec.rs b/node/router/messages/src/helpers/codec.rs index 93753a5536..1cd34882f0 100644 --- a/node/router/messages/src/helpers/codec.rs +++ b/node/router/messages/src/helpers/codec.rs @@ -51,7 +51,7 @@ impl Default for MessageCodec { impl Encoder> for MessageCodec { type Error = std::io::Error; - fn encode(&mut self, message: Message, dst: &mut BytesMut) -> Result<(), Self::Error> { + fn encode(&mut self, message: Message, dst: &mut BytesMut) -> Result<(), Self::Error> { // Serialize the payload directly into dst. message .write_le(&mut dst.writer()) @@ -61,10 +61,8 @@ impl Encoder> for MessageCodec { let serialized_message = dst.split_to(dst.len()).freeze(); #[cfg(feature = "metrics")] let num_bytes = serialized_message.len() as f64; - self.codec.encode(serialized_message, dst)?; - - #[cfg(feature = "metrics")] + #[cfg(feature = "metrics")] metrics::histogram_label( metrics::tcp::TCP_GATEWAY_MESSAGES_OUTBOUND, "message", From 590516402b2b5b98a00e6706d06836bf183c709e Mon Sep 17 00:00:00 2001 From: miazn Date: Tue, 20 Feb 2024 10:26:17 -0500 Subject: [PATCH 112/551] add better metric names for router messages --- node/metrics/src/names.rs | 8 ++++---- node/router/messages/src/helpers/codec.rs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/node/metrics/src/names.rs b/node/metrics/src/names.rs index 9bd38563fe..2b094b677f 100644 --- a/node/metrics/src/names.rs +++ b/node/metrics/src/names.rs @@ -40,8 +40,8 @@ pub(super) const HISTOGRAM_NAMES: [&str; 11] = [ tcp::NOISE_CODEC_DECRYPTION_SIZE, tcp::TCP_GATEWAY_EVENTS_OUTBOUND, tcp::TCP_GATEWAY_EVENTS_INBOUND, - tcp::TCP_GATEWAY_MESSAGES_OUTBOUND, - tcp::TCP_GATEWAY_MESSAGES_INBOUND, + tcp::TCP_ROUTER_MESSAGES_OUTBOUND, + tcp::TCP_ROUTER_MESSAGES_INBOUND, ]; pub mod bft { @@ -80,6 +80,6 @@ pub mod tcp { pub const TCP_TASKS: &str = "snarkos_tcp_tasks_total"; pub const TCP_GATEWAY_EVENTS_OUTBOUND: &str = "snarkos_tcp_gateway_events_outbound"; pub const TCP_GATEWAY_EVENTS_INBOUND: &str = "snarkos_tcp_gateway_events_inbound"; - pub const TCP_GATEWAY_MESSAGES_OUTBOUND: &str = "snarkos_tcp_gateway_messages_outbound"; - pub const TCP_GATEWAY_MESSAGES_INBOUND: &str = "snarkos_tcp_gateway_messages_inbound"; + pub const TCP_ROUTER_MESSAGES_OUTBOUND: &str = "snarkos_tcp_router_messages_outbound"; + pub const TCP_ROUTER_MESSAGES_INBOUND: &str = "snarkos_tcp_router_messages_inbound"; } diff --git a/node/router/messages/src/helpers/codec.rs b/node/router/messages/src/helpers/codec.rs index 1cd34882f0..56662ac319 100644 --- a/node/router/messages/src/helpers/codec.rs +++ b/node/router/messages/src/helpers/codec.rs @@ -64,7 +64,7 @@ impl Encoder> for MessageCodec { self.codec.encode(serialized_message, dst)?; #[cfg(feature = "metrics")] metrics::histogram_label( - metrics::tcp::TCP_GATEWAY_MESSAGES_OUTBOUND, + metrics::tcp::TCP_ROUTER_MESSAGES_OUTBOUND, "message", String::from(message.name().clone()), num_bytes, @@ -91,7 +91,7 @@ impl Decoder for MessageCodec { Ok(message) => { #[cfg(feature = "metrics")] metrics::histogram_label( - metrics::tcp::TCP_GATEWAY_MESSAGES_INBOUND, + metrics::tcp::TCP_ROUTER_MESSAGES_INBOUND, "message", String::from(message.name().clone()), num_bytes, From 3bb601b726254e4f6f47d7a420e5c7fd02323b3f Mon Sep 17 00:00:00 2001 From: miazn Date: Tue, 20 Feb 2024 13:22:47 -0500 Subject: [PATCH 113/551] make gauge increment and not set absolute --- node/consensus/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 27c1afe2d1..ea8d04d853 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -407,7 +407,7 @@ impl Consensus { let block_latency = next_block_timestamp - current_block_timestamp; metrics::gauge(metrics::blocks::HEIGHT, next_block.height() as f64); - metrics::gauge(metrics::blocks::TRANSACTIONS, next_block.transactions().len() as f64); + metrics::increment_gauge(metrics::blocks::TRANSACTIONS, next_block.transactions().len() as f64); metrics::gauge(metrics::consensus::LAST_COMMITTED_ROUND, next_block.round() as f64); metrics::gauge(metrics::consensus::COMMITTED_CERTIFICATES, num_committed_certificates as f64); metrics::histogram(metrics::consensus::CERTIFICATE_COMMIT_LATENCY, elapsed.as_secs_f64()); From 71d129fe0df1c9d93bb1a6d380f536666cb4cac0 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 20 Feb 2024 15:49:18 -0800 Subject: [PATCH 114/551] Add round check in signed proposals cache --- node/bft/src/primary.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 4d2cd1e019..cb6f776daf 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -525,6 +525,13 @@ impl Primary { if let Some((signed_round, signed_batch_id, signature)) = self.signed_proposals.read().get(&batch_author).copied() { + // If the signed round is ahead of the peer's batch round, then the validator is malicious. + if signed_round > batch_header.round() { + // Proceed to disconnect the validator. + self.gateway.disconnect(peer_ip); + bail!("Malicious peer - proposed a batch for a previous round ({})", batch_header.round()); + } + // If the round matches and the batch ID differs, then the validator is malicious. if signed_round == batch_header.round() && signed_batch_id != batch_header.batch_id() { // Proceed to disconnect the validator. From 0e88b08a5c6858208ff8254159cab246b728bdeb Mon Sep 17 00:00:00 2001 From: ljedrz Date: Wed, 21 Feb 2024 10:33:22 +0100 Subject: [PATCH 115/551] fix: only cache committies with matching rounds Signed-off-by: ljedrz --- node/bft/ledger-service/src/ledger.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/node/bft/ledger-service/src/ledger.rs b/node/bft/ledger-service/src/ledger.rs index 3af160028e..1eafd41582 100644 --- a/node/bft/ledger-service/src/ledger.rs +++ b/node/bft/ledger-service/src/ledger.rs @@ -139,25 +139,24 @@ impl> LedgerService for CoreLedgerService< return Ok(committee.clone()); } - let committee = match self.ledger.get_committee_for_round(round)? { + match self.ledger.get_committee_for_round(round)? { // Return the committee if it exists. - Some(committee) => committee, + Some(committee) => { + // Insert the committee into the cache. + self.committee_cache.lock().push(round, committee.clone()); + Ok(committee) + } // Return the current committee if the round is in the future. None => { // Retrieve the current committee. let current_committee = self.current_committee()?; // Return the current committee if the round is in the future. match current_committee.starting_round() <= round { - true => current_committee, + true => Ok(current_committee), false => bail!("No committee found for round {round} in the ledger"), } } - }; - - // Insert the committee into the cache. - self.committee_cache.lock().push(round, committee.clone()); - - Ok(committee) + } } /// Returns the committee lookback for the given round. From c1fafe81ee003ac8ebf02352437ed928fbee951b Mon Sep 17 00:00:00 2001 From: ljedrz Date: Wed, 21 Feb 2024 14:42:38 +0100 Subject: [PATCH 116/551] perf: skip the timed batch proposal if round progression already triggered one Signed-off-by: ljedrz --- node/bft/src/primary.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 8dea9e33a2..5107a026d2 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -900,6 +900,11 @@ impl Primary { debug!("Skipping batch proposal {}", "(node is syncing)".dimmed()); continue; } + // A best-effort attempt to skip the scheduled batch proposal if + // round progression already triggered one. + if self_.propose_lock.try_lock().is_err() { + continue; + }; // If there is no proposed batch, attempt to propose a batch. // Note: Do NOT spawn a task around this function call. Proposing a batch is a critical path, // and only one batch needs be proposed at a time. From 49c576cda967ac2ede0876742973274639ec52cb Mon Sep 17 00:00:00 2001 From: miazn Date: Wed, 21 Feb 2024 17:42:12 -0500 Subject: [PATCH 117/551] remove tcp events/msgs metircs --- node/bft/events/src/helpers/codec.rs | 27 ++++------------------- node/metrics/src/names.rs | 10 +-------- node/router/Cargo.toml | 2 +- node/router/messages/Cargo.toml | 7 ------ node/router/messages/src/helpers/codec.rs | 27 ++++------------------- 5 files changed, 10 insertions(+), 63 deletions(-) diff --git a/node/bft/events/src/helpers/codec.rs b/node/bft/events/src/helpers/codec.rs index 74ae0ed7ce..0d0c273d18 100644 --- a/node/bft/events/src/helpers/codec.rs +++ b/node/bft/events/src/helpers/codec.rs @@ -68,17 +68,8 @@ impl Encoder> for EventCodec { .map_err(|_| std::io::Error::new(std::io::ErrorKind::InvalidData, "serialization error"))?; let serialized_event = dst.split_to(dst.len()).freeze(); - #[cfg(feature = "metrics")] - let num_bytes = serialized_event.len() as f64; - self.codec.encode(serialized_event, dst)?; - #[cfg(feature = "metrics")] - metrics::histogram_label( - metrics::tcp::TCP_GATEWAY_EVENTS_OUTBOUND, - "event", - String::from(event.name().clone()), - num_bytes, - ); - Ok(()) + + self.codec.encode(serialized_event, dst) } } @@ -92,21 +83,11 @@ impl Decoder for EventCodec { Some(bytes) => bytes, None => return Ok(None), }; - #[cfg(feature = "metrics")] - let num_bytes = bytes.len() as f64; + // Convert the bytes to an event, or fail if it is not valid. let reader = bytes.reader(); match Event::read_le(reader) { - Ok(event) => { - #[cfg(feature = "metrics")] - metrics::histogram_label( - metrics::tcp::TCP_GATEWAY_EVENTS_INBOUND, - "event", - String::from(event.name().clone()), - num_bytes, - ); - Ok(Some(event)) - } + Ok(event) => Ok(Some(event)), Err(error) => { error!("Failed to deserialize an event: {}", error); Err(std::io::ErrorKind::InvalidData.into()) diff --git a/node/metrics/src/names.rs b/node/metrics/src/names.rs index 2b094b677f..bcf163a533 100644 --- a/node/metrics/src/names.rs +++ b/node/metrics/src/names.rs @@ -30,7 +30,7 @@ pub(super) const GAUGE_NAMES: [&str; 13] = [ tcp::TCP_TASKS, ]; -pub(super) const HISTOGRAM_NAMES: [&str; 11] = [ +pub(super) const HISTOGRAM_NAMES: [&str; 7] = [ bft::COMMIT_ROUNDS_LATENCY, consensus::CERTIFICATE_COMMIT_LATENCY, consensus::BLOCK_LATENCY, @@ -38,10 +38,6 @@ pub(super) const HISTOGRAM_NAMES: [&str; 11] = [ tcp::NOISE_CODEC_DECRYPTION_TIME, tcp::NOISE_CODEC_ENCRYPTION_SIZE, tcp::NOISE_CODEC_DECRYPTION_SIZE, - tcp::TCP_GATEWAY_EVENTS_OUTBOUND, - tcp::TCP_GATEWAY_EVENTS_INBOUND, - tcp::TCP_ROUTER_MESSAGES_OUTBOUND, - tcp::TCP_ROUTER_MESSAGES_INBOUND, ]; pub mod bft { @@ -78,8 +74,4 @@ pub mod tcp { pub const NOISE_CODEC_ENCRYPTION_SIZE: &str = "snarkos_tcp_noise_codec_encryption_size"; pub const NOISE_CODEC_DECRYPTION_SIZE: &str = "snarkos_tcp_noise_codec_decryption_size"; pub const TCP_TASKS: &str = "snarkos_tcp_tasks_total"; - pub const TCP_GATEWAY_EVENTS_OUTBOUND: &str = "snarkos_tcp_gateway_events_outbound"; - pub const TCP_GATEWAY_EVENTS_INBOUND: &str = "snarkos_tcp_gateway_events_inbound"; - pub const TCP_ROUTER_MESSAGES_OUTBOUND: &str = "snarkos_tcp_router_messages_outbound"; - pub const TCP_ROUTER_MESSAGES_INBOUND: &str = "snarkos_tcp_router_messages_inbound"; } diff --git a/node/router/Cargo.toml b/node/router/Cargo.toml index 380f2081a7..c0483487ce 100644 --- a/node/router/Cargo.toml +++ b/node/router/Cargo.toml @@ -18,7 +18,7 @@ edition = "2021" [features] test = [ ] -metrics = [ "dep:metrics", "snarkos-node-router-messages/metrics" ] +metrics = [ "dep:metrics" ] [dependencies.anyhow] version = "1.0.79" diff --git a/node/router/messages/Cargo.toml b/node/router/messages/Cargo.toml index 72692c528f..503ef8c1f6 100644 --- a/node/router/messages/Cargo.toml +++ b/node/router/messages/Cargo.toml @@ -19,7 +19,6 @@ edition = "2021" [features] default = [ ] test = [ ] -metrics = ["dep:metrics", "snarkvm/metrics"] [dependencies.anyhow] version = "1.0" @@ -31,12 +30,6 @@ version = "1" version = "2.1" features = [ "serde", "rayon" ] -[dependencies.metrics] -package = "snarkos-node-metrics" -path = "../../metrics" -version = "=2.2.7" -optional = true - [dependencies.rayon] version = "1" diff --git a/node/router/messages/src/helpers/codec.rs b/node/router/messages/src/helpers/codec.rs index 56662ac319..e3a12b7227 100644 --- a/node/router/messages/src/helpers/codec.rs +++ b/node/router/messages/src/helpers/codec.rs @@ -59,17 +59,8 @@ impl Encoder> for MessageCodec { .map_err(|_| std::io::Error::new(std::io::ErrorKind::InvalidData, "serialization error"))?; let serialized_message = dst.split_to(dst.len()).freeze(); - #[cfg(feature = "metrics")] - let num_bytes = serialized_message.len() as f64; - self.codec.encode(serialized_message, dst)?; - #[cfg(feature = "metrics")] - metrics::histogram_label( - metrics::tcp::TCP_ROUTER_MESSAGES_OUTBOUND, - "message", - String::from(message.name().clone()), - num_bytes, - ); - Ok(()) + + self.codec.encode(serialized_message, dst) } } @@ -83,21 +74,11 @@ impl Decoder for MessageCodec { Some(bytes) => bytes, None => return Ok(None), }; - #[cfg(feature = "metrics")] - let num_bytes = bytes.len() as f64; + // Convert the bytes to a message, or fail if it is not valid. let reader = bytes.reader(); match Message::read_le(reader) { - Ok(message) => { - #[cfg(feature = "metrics")] - metrics::histogram_label( - metrics::tcp::TCP_ROUTER_MESSAGES_INBOUND, - "message", - String::from(message.name().clone()), - num_bytes, - ); - Ok(Some(message)) - } + Ok(message) => Ok(Some(message)), Err(error) => { warn!("Failed to deserialize a message - {}", error); Err(std::io::ErrorKind::InvalidData.into()) From e9533b6facea5420a61259e3110cd38beba460a9 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Wed, 21 Feb 2024 15:42:49 -0800 Subject: [PATCH 118/551] Update rev --- Cargo.lock | 116 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 2 +- 2 files changed, 59 insertions(+), 59 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2739759410..2125c799c7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3517,7 +3517,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "anstyle", "anyhow", @@ -3548,7 +3548,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "aleo-std", "anyhow", @@ -3578,7 +3578,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3592,7 +3592,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3603,7 +3603,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3613,7 +3613,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3623,7 +3623,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "indexmap 2.2.3", "itertools 0.11.0", @@ -3641,12 +3641,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3657,7 +3657,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3672,7 +3672,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3687,7 +3687,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3700,7 +3700,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3709,7 +3709,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3719,7 +3719,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3731,7 +3731,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3743,7 +3743,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3754,7 +3754,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3766,7 +3766,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3779,7 +3779,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "bs58", "snarkvm-console-network", @@ -3790,7 +3790,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "blake2s_simd", "smallvec", @@ -3803,7 +3803,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "aleo-std", "rayon", @@ -3814,7 +3814,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "anyhow", "indexmap 2.2.3", @@ -3837,7 +3837,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "anyhow", "bech32", @@ -3855,7 +3855,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "enum_index", "enum_index_derive", @@ -3876,7 +3876,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3891,7 +3891,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3902,7 +3902,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "snarkvm-console-network-environment", ] @@ -3910,7 +3910,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3920,7 +3920,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3931,7 +3931,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3942,7 +3942,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3953,7 +3953,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3964,7 +3964,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "rand", "rayon", @@ -3978,7 +3978,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "aleo-std", "anyhow", @@ -3995,7 +3995,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "aleo-std", "anyhow", @@ -4020,7 +4020,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "anyhow", "rand", @@ -4032,7 +4032,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "indexmap 2.2.3", "rayon", @@ -4051,7 +4051,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-coinbase" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "aleo-std", "anyhow", @@ -4071,7 +4071,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "anyhow", "indexmap 2.2.3", @@ -4089,7 +4089,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -4102,7 +4102,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "indexmap 2.2.3", "rayon", @@ -4115,7 +4115,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "indexmap 2.2.3", "serde_json", @@ -4127,7 +4127,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "bytes", "serde_json", @@ -4138,7 +4138,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "indexmap 2.2.3", "rayon", @@ -4153,7 +4153,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "bytes", "serde_json", @@ -4166,7 +4166,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "snarkvm-console", "snarkvm-ledger-coinbase", @@ -4175,7 +4175,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "async-trait", "reqwest", @@ -4188,7 +4188,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "aleo-std-storage", "anyhow", @@ -4214,7 +4214,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4229,7 +4229,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4238,7 +4238,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "aleo-std", "anyhow", @@ -4263,7 +4263,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "aleo-std", "anyhow", @@ -4288,7 +4288,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "aleo-std", "colored", @@ -4311,7 +4311,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "indexmap 2.2.3", "paste", @@ -4325,7 +4325,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "bincode", "once_cell", @@ -4338,7 +4338,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "aleo-std", "anyhow", @@ -4359,7 +4359,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1cebaaf#1cebaaf6c1f95381e307d049e819e12a60491a83" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" dependencies = [ "proc-macro2", "quote 1.0.35", diff --git a/Cargo.toml b/Cargo.toml index a6529d6884..80a795532c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "1cebaaf" +rev = "569cf5a" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From 3161da038571b63bf7e329e0594e8e6fb3f8b235 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Thu, 22 Feb 2024 16:30:55 +0100 Subject: [PATCH 119/551] perf: cache the latest leader Signed-off-by: ljedrz --- node/bft/ledger-service/Cargo.toml | 3 +- node/bft/ledger-service/src/ledger.rs | 18 ++++++- node/bft/ledger-service/src/mock.rs | 10 +++- node/bft/ledger-service/src/prover.rs | 12 ++++- node/bft/ledger-service/src/traits.rs | 8 ++- node/bft/ledger-service/src/translucent.rs | 12 ++++- node/bft/src/bft.rs | 61 +++++++++++++++++----- node/bft/src/worker.rs | 3 ++ 8 files changed, 106 insertions(+), 21 deletions(-) diff --git a/node/bft/ledger-service/Cargo.toml b/node/bft/ledger-service/Cargo.toml index 8a37cdb97e..10004b4adf 100644 --- a/node/bft/ledger-service/Cargo.toml +++ b/node/bft/ledger-service/Cargo.toml @@ -20,7 +20,7 @@ edition = "2021" default = [ ] ledger = [ "rand", "tokio", "tracing" ] ledger-write = [ ] -mock = [ "parking_lot", "tracing" ] +mock = [ "tracing" ] prover = [ ] test = [ "mock", "translucent" ] translucent = [ "ledger" ] @@ -34,7 +34,6 @@ features = [ "serde", "rayon" ] [dependencies.parking_lot] version = "0.12" -optional = true [dependencies.rand] version = "0.8" diff --git a/node/bft/ledger-service/src/ledger.rs b/node/bft/ledger-service/src/ledger.rs index 1f42f909b0..f04ca70f86 100644 --- a/node/bft/ledger-service/src/ledger.rs +++ b/node/bft/ledger-service/src/ledger.rs @@ -22,10 +22,11 @@ use snarkvm::{ store::ConsensusStorage, Ledger, }, - prelude::{bail, Field, Network, Result}, + prelude::{bail, Address, Field, Network, Result}, }; use indexmap::IndexMap; +use parking_lot::RwLock; use std::{ fmt, ops::Range, @@ -35,18 +36,21 @@ use std::{ }, }; +type LatestLeader = (u64, Address); + /// A core ledger service. pub struct CoreLedgerService> { ledger: Ledger, coinbase_verifying_key: Arc>, shutdown: Arc, + latest_leader: Arc>>>, } impl> CoreLedgerService { /// Initializes a new core ledger service. pub fn new(ledger: Ledger, shutdown: Arc) -> Self { let coinbase_verifying_key = Arc::new(ledger.coinbase_puzzle().coinbase_verifying_key().clone()); - Self { ledger, coinbase_verifying_key, shutdown } + Self { ledger, coinbase_verifying_key, shutdown, latest_leader: Default::default() } } } @@ -74,6 +78,16 @@ impl> LedgerService for CoreLedgerService< self.ledger.latest_block() } + /// Returns the latest cached leader and its associated round. + fn latest_leader(&self) -> Option<(u64, Address)> { + *self.latest_leader.read() + } + + /// Updates the latest cached leader and its associated round. + fn update_latest_leader(&self, round: u64, leader: Address) { + *self.latest_leader.write() = Some((round, leader)); + } + /// Returns `true` if the given block height exists in the ledger. fn contains_block_height(&self, height: u32) -> bool { self.ledger.contains_block_height(height).unwrap_or(false) diff --git a/node/bft/ledger-service/src/mock.rs b/node/bft/ledger-service/src/mock.rs index c36679a40e..6731ff1f9e 100644 --- a/node/bft/ledger-service/src/mock.rs +++ b/node/bft/ledger-service/src/mock.rs @@ -20,7 +20,7 @@ use snarkvm::{ committee::Committee, narwhal::{BatchCertificate, Data, Subdag, Transmission, TransmissionID}, }, - prelude::{bail, ensure, Field, Network, Result}, + prelude::{bail, ensure, Address, Field, Network, Result}, }; use indexmap::IndexMap; @@ -68,6 +68,14 @@ impl LedgerService for MockLedgerService { unreachable!("MockLedgerService does not support latest_block") } + /// Returns the latest cached leader and its associated round. + fn latest_leader(&self) -> Option<(u64, Address)> { + None + } + + /// Updates the latest cached leader and its associated round. + fn update_latest_leader(&self, _round: u64, _leader: Address) {} + /// Returns `true` if the given block height exists in the canonical ledger. fn contains_block_height(&self, height: u32) -> bool { self.height_to_hash.lock().contains_key(&height) diff --git a/node/bft/ledger-service/src/prover.rs b/node/bft/ledger-service/src/prover.rs index 6edfbafd4c..78827c8b5d 100644 --- a/node/bft/ledger-service/src/prover.rs +++ b/node/bft/ledger-service/src/prover.rs @@ -20,7 +20,7 @@ use snarkvm::{ committee::Committee, narwhal::{BatchCertificate, Data, Subdag, Transmission, TransmissionID}, }, - prelude::{bail, Field, Network, Result}, + prelude::{bail, Address, Field, Network, Result}, }; use indexmap::IndexMap; @@ -56,6 +56,16 @@ impl LedgerService for ProverLedgerService { unreachable!("Latest block does not exist in prover") } + /// Returns the latest cached leader and its associated round. + fn latest_leader(&self) -> Option<(u64, Address)> { + unreachable!("Latest leader does not exist in prover"); + } + + /// Updates the latest cached leader and its associated round. + fn update_latest_leader(&self, _round: u64, _leader: Address) { + unreachable!("Latest leader does not exist in prover"); + } + /// Returns `true` if the given block height exists in the ledger. fn contains_block_height(&self, _height: u32) -> bool { false diff --git a/node/bft/ledger-service/src/traits.rs b/node/bft/ledger-service/src/traits.rs index a97fdeb373..f24f323729 100644 --- a/node/bft/ledger-service/src/traits.rs +++ b/node/bft/ledger-service/src/traits.rs @@ -19,7 +19,7 @@ use snarkvm::{ committee::Committee, narwhal::{BatchCertificate, Data, Subdag, Transmission, TransmissionID}, }, - prelude::{Field, Network, Result}, + prelude::{Address, Field, Network, Result}, }; use indexmap::IndexMap; @@ -36,6 +36,12 @@ pub trait LedgerService: Debug + Send + Sync { /// Returns the latest block in the ledger. fn latest_block(&self) -> Block; + /// Returns the latest cached leader and its associated round. + fn latest_leader(&self) -> Option<(u64, Address)>; + + /// Updates the latest cached leader and its associated round. + fn update_latest_leader(&self, round: u64, leader: Address); + /// Returns `true` if the given block height exists in the ledger. fn contains_block_height(&self, height: u32) -> bool; diff --git a/node/bft/ledger-service/src/translucent.rs b/node/bft/ledger-service/src/translucent.rs index 34afa15667..142ac0ffcd 100644 --- a/node/bft/ledger-service/src/translucent.rs +++ b/node/bft/ledger-service/src/translucent.rs @@ -24,7 +24,7 @@ use snarkvm::{ store::ConsensusStorage, Ledger, }, - prelude::{narwhal::BatchCertificate, Field, Network, Result}, + prelude::{narwhal::BatchCertificate, Address, Field, Network, Result}, }; use std::{ fmt, @@ -67,6 +67,16 @@ impl> LedgerService for TranslucentLedgerS self.inner.latest_block() } + /// Returns the latest cached leader and its associated round. + fn latest_leader(&self) -> Option<(u64, Address)> { + self.inner.latest_leader() + } + + /// Updates the latest cached leader and its associated round. + fn update_latest_leader(&self, round: u64, leader: Address) { + self.inner.update_latest_leader(round, leader); + } + /// Returns `true` if the given block height exists in the ledger. fn contains_block_height(&self, height: u32) -> bool { self.inner.contains_block_height(height) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 7662f27b7f..e47c080f42 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -298,11 +298,22 @@ impl BFT { } }; // Determine the leader of the current round. - let leader = match committee_lookback.get_leader(current_round) { - Ok(leader) => leader, - Err(e) => { - error!("BFT failed to compute the leader for the even round {current_round} - {e}"); - return false; + let leader = match self.ledger().latest_leader() { + Some((cached_round, cached_leader)) if cached_round == current_round => cached_leader, + _ => { + // Compute the leader for the current round. + let computed_leader = match committee_lookback.get_leader(current_round) { + Ok(leader) => leader, + Err(e) => { + error!("BFT failed to compute the leader for the even round {current_round} - {e}"); + return false; + } + }; + + // Cache the computed leader. + self.ledger().update_latest_leader(current_round, computed_leader); + + computed_leader } }; // Find and set the leader certificate, if the leader was present in the current even round. @@ -453,10 +464,23 @@ impl BFT { let Ok(committee_lookback) = self.ledger().get_committee_lookback_for_round(commit_round) else { bail!("BFT failed to retrieve the committee with lag for commit round {commit_round}"); }; - // Compute the leader for the commit round. - let Ok(leader) = committee_lookback.get_leader(commit_round) else { - bail!("BFT failed to compute the leader for commit round {commit_round}"); + + // Either retrieve the cached leader or compute it. + let leader = match self.ledger().latest_leader() { + Some((cached_round, cached_leader)) if cached_round == commit_round => cached_leader, + _ => { + // Compute the leader for the commit round. + let Ok(computed_leader) = committee_lookback.get_leader(commit_round) else { + bail!("BFT failed to compute the leader for commit round {commit_round}"); + }; + + // Cache the computed leader. + self.ledger().update_latest_leader(commit_round, computed_leader); + + computed_leader + } }; + // Retrieve the leader certificate for the commit round. let Some(leader_certificate) = self.dag.read().get_certificate_for_round_with_author(commit_round, leader) else { @@ -512,11 +536,22 @@ impl BFT { bail!("BFT failed to retrieve a previous committee lookback for the even round {round} - {e}"); } }; - // Compute the leader address for the leader round. - let leader = match previous_committee_lookback.get_leader(round) { - Ok(leader) => leader, - Err(e) => { - bail!("BFT failed to compute the leader for the even round {round} - {e}"); + // Either retrieve the cached leader or compute it. + let leader = match self.ledger().latest_leader() { + Some((cached_round, cached_leader)) if cached_round == round => cached_leader, + _ => { + // Compute the leader for the commit round. + let computed_leader = match previous_committee_lookback.get_leader(round) { + Ok(leader) => leader, + Err(e) => { + bail!("BFT failed to compute the leader for the even round {round} - {e}"); + } + }; + + // Cache the computed leader. + self.ledger().update_latest_leader(round, computed_leader); + + computed_leader } }; // Retrieve the previous leader certificate. diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index 4e59a399e8..8d93c5cd98 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -463,6 +463,7 @@ mod tests { committee::Committee, narwhal::{BatchCertificate, Subdag, Transmission, TransmissionID}, }, + prelude::Address, }; use bytes::Bytes; @@ -489,6 +490,8 @@ mod tests { fn latest_round(&self) -> u64; fn latest_block_height(&self) -> u32; fn latest_block(&self) -> Block; + fn latest_leader(&self) -> Option<(u64, Address)>; + fn update_latest_leader(&self, round: u64, leader: Address); fn contains_block_height(&self, height: u32) -> bool; fn get_block_height(&self, hash: &N::BlockHash) -> Result; fn get_block_hash(&self, height: u32) -> Result; From ac024b051420de188b737978207961e5e338464b Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 22 Feb 2024 17:00:12 -0800 Subject: [PATCH 120/551] Create a dedicated function for garbage collection --- node/bft/src/helpers/storage.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/node/bft/src/helpers/storage.rs b/node/bft/src/helpers/storage.rs index fba04dfcc4..0c59963300 100644 --- a/node/bft/src/helpers/storage.rs +++ b/node/bft/src/helpers/storage.rs @@ -204,6 +204,12 @@ impl Storage { // Update the current round. self.current_round.store(next_round, Ordering::SeqCst); + // Perform garbage collection. + self.garbage_collect_certificates(next_round); + } + + /// Update the storage by performing garbage collection based on the next round. + fn garbage_collect_certificates(&self, next_round: u64) { // Fetch the current GC round. let current_gc_round = self.gc_round(); // Compute the next GC round. From e4a957c682b85d2c4d5c0a7de440e413b906e1c9 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 22 Feb 2024 17:04:57 -0800 Subject: [PATCH 121/551] Implement garbage collection on commit --- node/bft/src/bft.rs | 6 ++++++ node/bft/src/helpers/storage.rs | 5 +---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 7662f27b7f..2157dce6d7 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -495,6 +495,8 @@ impl BFT { &self, leader_certificate: BatchCertificate, ) -> Result<()> { + // Fetch the leader round. + let latest_leader_round = leader_certificate.round(); // Determine the list of all previous leader certificates since the last committed round. // The order of the leader certificates is from **newest** to **oldest**. let mut leader_certificates = vec![leader_certificate.clone()]; @@ -621,6 +623,10 @@ impl BFT { } } } + + // Perform garbage collection based on the latest committed leader round. + self.storage().garbage_collect_certificates(latest_leader_round); + Ok(()) } diff --git a/node/bft/src/helpers/storage.rs b/node/bft/src/helpers/storage.rs index 0c59963300..32ffb3ecb8 100644 --- a/node/bft/src/helpers/storage.rs +++ b/node/bft/src/helpers/storage.rs @@ -203,13 +203,10 @@ impl Storage { fn update_current_round(&self, next_round: u64) { // Update the current round. self.current_round.store(next_round, Ordering::SeqCst); - - // Perform garbage collection. - self.garbage_collect_certificates(next_round); } /// Update the storage by performing garbage collection based on the next round. - fn garbage_collect_certificates(&self, next_round: u64) { + pub(crate) fn garbage_collect_certificates(&self, next_round: u64) { // Fetch the current GC round. let current_gc_round = self.gc_round(); // Compute the next GC round. From ed6409f345832a6a1910313e44728601a347c8bf Mon Sep 17 00:00:00 2001 From: mdelle1 <108158289+mdelle1@users.noreply.github.com> Date: Thu, 22 Feb 2024 20:06:04 -0500 Subject: [PATCH 122/551] Updates authorized validator set --- node/bft/src/gateway.rs | 48 ++++++++++++++++++++++++++++++++++------- node/bft/src/primary.rs | 2 +- 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/node/bft/src/gateway.rs b/node/bft/src/gateway.rs index 06030e5d5d..21191860c5 100644 --- a/node/bft/src/gateway.rs +++ b/node/bft/src/gateway.rs @@ -14,7 +14,7 @@ use crate::{ events::{EventCodec, PrimaryPing}, - helpers::{assign_to_worker, Cache, PrimarySender, Resolver, SyncSender, WorkerSender}, + helpers::{assign_to_worker, Cache, PrimarySender, Resolver, SyncSender, WorkerSender, Storage}, spawn_blocking, Worker, CONTEXT, @@ -88,6 +88,9 @@ const MIN_CONNECTED_VALIDATORS: usize = 175; /// The maximum number of validators to send in a validators response event. const MAX_VALIDATORS_TO_SEND: usize = 200; +/// The maximum number of blocks tolerated before the primary is considered behind its peers. +pub const MAX_BLOCKS_BEHIND: u32 = 1; // blocks + /// Part of the Gateway API that deals with networking. /// This is a separate trait to allow for easier testing/mocking. #[async_trait] @@ -100,6 +103,8 @@ pub trait Transport: Send + Sync { pub struct Gateway { /// The account of the node. account: Account, + /// The storage. + storage: Storage, /// The ledger service. ledger: Arc>, /// The TCP stack. @@ -133,6 +138,7 @@ impl Gateway { /// Initializes a new gateway. pub fn new( account: Account, + storage: Storage, ledger: Arc>, ip: Option, trusted_validators: &[SocketAddr], @@ -149,6 +155,7 @@ impl Gateway { // Return the gateway. Ok(Self { account, + storage, ledger, tcp, cache: Default::default(), @@ -335,13 +342,38 @@ impl Gateway { // 1. New validators should be able to connect immediately once bonded as a committee member. // 2. Existing validators must remain connected until they are no longer bonded as a committee member. // (i.e. meaning they must stay online until the next block has been produced) - self.ledger - .get_committee_lookback_for_round(self.ledger.latest_round()) - .map_or(false, |committee| committee.is_committee_member(validator_address)) - || self - .ledger - .current_committee() - .map_or(false, |committee| committee.is_committee_member(validator_address)) + + // Retrieve the latest ledger block height. + let latest_ledger_height = self.ledger.latest_block_height(); + // Retrieve the earliest block height to consider from the sync range tolerance. + let earliest_sync_ledger_height = latest_ledger_height.saturating_sub(MAX_BLOCKS_BEHIND); + // Initialize a flag to check if the validator is in a previous committee with lookback. + let mut is_val_in_previous_committee_lookback = false; + + // Determine if the validator is in any of the previous committees with lookback up until the sync range tolerance. + if let Ok(block) = self.ledger.get_block(earliest_sync_ledger_height){ + // Retrieve the block round. + let block_round = block.header().metadata().round(); + for round in (block_round..self.storage.current_round()).step_by(2){ + if let Ok(previous_committee_lookback) = self.ledger.get_committee_lookback_for_round(round) { + // Determine if the validator is in the committee. + if previous_committee_lookback.is_committee_member(validator_address){ + // Set the tracker to 'true'. + is_val_in_previous_committee_lookback = true; + break; + } + } + } + } + // Determine if the validator is in the current committee with lookback. + let is_val_in_current_committee_lookback = match self.ledger.get_committee_lookback_for_round(self.storage.current_round()) { + Ok(current_committee_lookback) => current_committee_lookback.is_committee_member(validator_address), + Err(_) => false, + }; + // Determine if the validator is in the latest committee on the ledger. + let is_val_in_latest_committee = self.ledger.current_committee().map_or(false, |committee| committee.is_committee_member(validator_address)); + + return is_val_in_previous_committee_lookback || is_val_in_current_committee_lookback || is_val_in_latest_committee; } /// Returns the maximum number of connected peers. diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 8dea9e33a2..aea25c4861 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -108,7 +108,7 @@ impl Primary { dev: Option, ) -> Result { // Initialize the gateway. - let gateway = Gateway::new(account, ledger.clone(), ip, trusted_validators, dev)?; + let gateway = Gateway::new(account, storage.clone(), ledger.clone(), ip, trusted_validators, dev)?; // Initialize the sync module. let sync = Sync::new(gateway.clone(), storage.clone(), ledger.clone()); // Initialize the primary instance. From b1c0ddc9a291430b29386e286df7776945041b14 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 22 Feb 2024 17:53:16 -0800 Subject: [PATCH 123/551] Cleanup --- node/bft/src/gateway.rs | 81 +++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 43 deletions(-) diff --git a/node/bft/src/gateway.rs b/node/bft/src/gateway.rs index 21191860c5..277b9ae53d 100644 --- a/node/bft/src/gateway.rs +++ b/node/bft/src/gateway.rs @@ -14,7 +14,7 @@ use crate::{ events::{EventCodec, PrimaryPing}, - helpers::{assign_to_worker, Cache, PrimarySender, Resolver, SyncSender, WorkerSender, Storage}, + helpers::{assign_to_worker, Cache, PrimarySender, Resolver, Storage, SyncSender, WorkerSender}, spawn_blocking, Worker, CONTEXT, @@ -39,7 +39,7 @@ use snarkos_node_bft_events::{ ValidatorsResponse, }; use snarkos_node_bft_ledger_service::LedgerService; -use snarkos_node_sync::communication_service::CommunicationService; +use snarkos_node_sync::{communication_service::CommunicationService, MAX_BLOCKS_BEHIND}; use snarkos_node_tcp::{ is_bogon_ip, is_unspecified_or_broadcast_ip, @@ -88,9 +88,6 @@ const MIN_CONNECTED_VALIDATORS: usize = 175; /// The maximum number of validators to send in a validators response event. const MAX_VALIDATORS_TO_SEND: usize = 200; -/// The maximum number of blocks tolerated before the primary is considered behind its peers. -pub const MAX_BLOCKS_BEHIND: u32 = 1; // blocks - /// Part of the Gateway API that deals with networking. /// This is a separate trait to allow for easier testing/mocking. #[async_trait] @@ -103,8 +100,8 @@ pub trait Transport: Send + Sync { pub struct Gateway { /// The account of the node. account: Account, - /// The storage. - storage: Storage, + /// The storage. + storage: Storage, /// The ledger service. ledger: Arc>, /// The TCP stack. @@ -337,43 +334,35 @@ impl Gateway { /// Returns `true` if the given address is an authorized validator. pub fn is_authorized_validator_address(&self, validator_address: Address) -> bool { - // Determine if the validator address is a member of the committee lookback or the current committee. + // Retrieve the previous block height to consider from the sync tolerance. + let previous_block_height = self.ledger.latest_block_height().saturating_sub(MAX_BLOCKS_BEHIND); + // Determine if the validator is in any of the previous committee lookbacks. + let exists_in_previous_committee_lookback = match self.ledger.get_block(previous_block_height) { + Ok(block) => (block.round()..self.storage.current_round()).step_by(2).any(|round| { + self.ledger + .get_committee_lookback_for_round(round) + .map_or(false, |committee| committee.is_committee_member(validator_address)) + }), + Err(_) => false, + }; + + // Determine if the validator is in the current committee with lookback. + let exists_in_current_committee_lookback = self + .ledger + .get_committee_lookback_for_round(self.storage.current_round()) + .map_or(false, |committee| committee.is_committee_member(validator_address)); + + // Determine if the validator is in the latest committee on the ledger. + let exists_in_latest_committee = + self.ledger.current_committee().map_or(false, |committee| committee.is_committee_member(validator_address)); + + // Determine if the validator address is a member of the previous committee lookbacks, + // the committee lookback, or the current committee. // We allow leniency in this validation check in order to accommodate these two scenarios: // 1. New validators should be able to connect immediately once bonded as a committee member. // 2. Existing validators must remain connected until they are no longer bonded as a committee member. // (i.e. meaning they must stay online until the next block has been produced) - - // Retrieve the latest ledger block height. - let latest_ledger_height = self.ledger.latest_block_height(); - // Retrieve the earliest block height to consider from the sync range tolerance. - let earliest_sync_ledger_height = latest_ledger_height.saturating_sub(MAX_BLOCKS_BEHIND); - // Initialize a flag to check if the validator is in a previous committee with lookback. - let mut is_val_in_previous_committee_lookback = false; - - // Determine if the validator is in any of the previous committees with lookback up until the sync range tolerance. - if let Ok(block) = self.ledger.get_block(earliest_sync_ledger_height){ - // Retrieve the block round. - let block_round = block.header().metadata().round(); - for round in (block_round..self.storage.current_round()).step_by(2){ - if let Ok(previous_committee_lookback) = self.ledger.get_committee_lookback_for_round(round) { - // Determine if the validator is in the committee. - if previous_committee_lookback.is_committee_member(validator_address){ - // Set the tracker to 'true'. - is_val_in_previous_committee_lookback = true; - break; - } - } - } - } - // Determine if the validator is in the current committee with lookback. - let is_val_in_current_committee_lookback = match self.ledger.get_committee_lookback_for_round(self.storage.current_round()) { - Ok(current_committee_lookback) => current_committee_lookback.is_committee_member(validator_address), - Err(_) => false, - }; - // Determine if the validator is in the latest committee on the ledger. - let is_val_in_latest_committee = self.ledger.current_committee().map_or(false, |committee| committee.is_committee_member(validator_address)); - - return is_val_in_previous_committee_lookback || is_val_in_current_committee_lookback || is_val_in_latest_committee; + exists_in_previous_committee_lookback || exists_in_current_committee_lookback || exists_in_latest_committee } /// Returns the maximum number of connected peers. @@ -1434,6 +1423,7 @@ mod prop_tests { .prop_map(|(storage, _, private_key, address)| { Gateway::new( Account::try_from(private_key).unwrap(), + storage.clone(), storage.ledger().clone(), address.ip(), &[], @@ -1482,7 +1472,9 @@ mod prop_tests { let (storage, _, private_key, dev) = input; let account = Account::try_from(private_key).unwrap(); - let gateway = Gateway::new(account.clone(), storage.ledger().clone(), dev.ip(), &[], dev.port()).unwrap(); + let gateway = + Gateway::new(account.clone(), storage.clone(), storage.ledger().clone(), dev.ip(), &[], dev.port()) + .unwrap(); let tcp_config = gateway.tcp().config(); assert_eq!(tcp_config.listener_ip, Some(IpAddr::V4(Ipv4Addr::LOCALHOST))); assert_eq!(tcp_config.desired_listening_port, Some(MEMORY_POOL_PORT + dev.port().unwrap())); @@ -1497,7 +1489,9 @@ mod prop_tests { let (storage, _, private_key, dev) = input; let account = Account::try_from(private_key).unwrap(); - let gateway = Gateway::new(account.clone(), storage.ledger().clone(), dev.ip(), &[], dev.port()).unwrap(); + let gateway = + Gateway::new(account.clone(), storage.clone(), storage.ledger().clone(), dev.ip(), &[], dev.port()) + .unwrap(); let tcp_config = gateway.tcp().config(); if let Some(socket_addr) = dev.ip() { assert_eq!(tcp_config.listener_ip, Some(socket_addr.ip())); @@ -1522,7 +1516,8 @@ mod prop_tests { let worker_storage = storage.clone(); let account = Account::try_from(private_key).unwrap(); - let gateway = Gateway::new(account, storage.ledger().clone(), dev.ip(), &[], dev.port()).unwrap(); + let gateway = + Gateway::new(account, storage.clone(), storage.ledger().clone(), dev.ip(), &[], dev.port()).unwrap(); let (primary_sender, _) = init_primary_channels(); From 68d11b0460d1ea734559f84489fe5549a8f68c2d Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 22 Feb 2024 18:03:11 -0800 Subject: [PATCH 124/551] nit --- node/bft/src/bft.rs | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 7df2d5ddd4..91a29e2a50 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -322,13 +322,14 @@ impl BFT { committee: Committee, current_round: u64, ) -> bool { - // Retrieve the authors for the current round. + // Retrieve the authors for the current round. let authors = certificates.into_iter().map(|c| c.author()).collect(); - // Check if quorum threshold is reached. - let is_quorum = committee.is_quorum_threshold_reached(&authors); - if !is_quorum { - info!("BFT failed to advance to the next round - quorum threshold not reached in even round {current_round}. "); - return false; + // Check if quorum threshold is reached. + if !committee.is_quorum_threshold_reached(&authors) { + info!( + "BFT failed to advance to the next round - quorum threshold not reached in even round {current_round}. " + ); + return false; } // If the leader certificate is set for the current even round, return 'true'. if let Some(leader_certificate) = self.leader_certificate.read().as_ref() { @@ -339,7 +340,7 @@ impl BFT { // If the timer has expired, and we can achieve quorum threshold (2f + 1) without the leader, return 'true'. if self.is_timer_expired() { debug!("BFT (timer expired) - Advancing from round {current_round} to the next round (without the leader)"); - return true; + return true; } // Otherwise, return 'false'. false @@ -378,13 +379,14 @@ impl BFT { return false; } }; - // Retrieve the authors of the current certificates. + // Retrieve the authors of the current certificates. let authors = current_certificates.clone().into_iter().map(|c| c.author()).collect(); - // Check if quorum threshold is reached. - let is_quorum = committee_lookback.clone().is_quorum_threshold_reached(&authors); - if !is_quorum { - info!("BFT failed to advance to the next round - quorum threshold not reached in odd round {current_round}. "); - return false; + // Check if quorum threshold is reached. + if !committee_lookback.is_quorum_threshold_reached(&authors) { + info!( + "BFT failed to advance to the next round - quorum threshold not reached in odd round {current_round}. " + ); + return false; } // Retrieve the leader certificate. let Some(leader_certificate) = self.leader_certificate.read().clone() else { From 2078b11e83da9d748b91770ae948c9873c640a01 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 22 Feb 2024 18:06:08 -0800 Subject: [PATCH 125/551] Update logs --- node/bft/src/bft.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 91a29e2a50..3ea0cd4b67 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -326,9 +326,7 @@ impl BFT { let authors = certificates.into_iter().map(|c| c.author()).collect(); // Check if quorum threshold is reached. if !committee.is_quorum_threshold_reached(&authors) { - info!( - "BFT failed to advance to the next round - quorum threshold not reached in even round {current_round}. " - ); + debug!("BFT failed to reach quorum threshold in even round {current_round}"); return false; } // If the leader certificate is set for the current even round, return 'true'. @@ -383,9 +381,7 @@ impl BFT { let authors = current_certificates.clone().into_iter().map(|c| c.author()).collect(); // Check if quorum threshold is reached. if !committee_lookback.is_quorum_threshold_reached(&authors) { - info!( - "BFT failed to advance to the next round - quorum threshold not reached in odd round {current_round}. " - ); + debug!("BFT failed reach quorum threshold in odd round {current_round}. "); return false; } // Retrieve the leader certificate. From 86acd1dfba79aedc27ca0348022f989710522ba3 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Fri, 23 Feb 2024 14:40:03 +0100 Subject: [PATCH 126/551] perf: adjust blocking tasks in the primary Signed-off-by: ljedrz --- node/bft/src/primary.rs | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 8dea9e33a2..de9eea237a 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -630,7 +630,7 @@ impl Primary { let BatchSignature { batch_id, signature } = batch_signature; // Retrieve the signer. - let signer = spawn_blocking!(Ok(signature.to_address()))?; + let signer = signature.to_address(); // Ensure the batch signature is signed by the validator. if self.gateway.resolver().get_address(peer_ip).map_or(true, |address| address != signer) { @@ -643,15 +643,16 @@ impl Primary { bail!("Invalid peer - received a batch signature from myself ({signer})"); } - let proposal = { + let self_ = self.clone(); + let Some(proposal) = spawn_blocking!({ // Acquire the write lock. - let mut proposed_batch = self.proposed_batch.write(); + let mut proposed_batch = self_.proposed_batch.write(); // Add the signature to the batch, and determine if the batch is ready to be certified. match proposed_batch.as_mut() { Some(proposal) => { // Ensure the batch ID matches the currently proposed batch ID. if proposal.batch_id() != batch_id { - match self.storage.contains_batch(batch_id) { + match self_.storage.contains_batch(batch_id) { true => bail!("This batch was already certified"), false => bail!( "Unknown batch ID '{batch_id}', expected '{}' for round {}", @@ -661,9 +662,9 @@ impl Primary { } } // Retrieve the committee lookback for the round. - let committee_lookback = self.ledger.get_committee_lookback_for_round(proposal.round())?; + let committee_lookback = self_.ledger.get_committee_lookback_for_round(proposal.round())?; // Retrieve the address of the validator. - let Some(signer) = self.gateway.resolver().get_address(peer_ip) else { + let Some(signer) = self_.gateway.resolver().get_address(peer_ip) else { bail!("Signature is from a disconnected validator"); }; // Add the signature to the batch. @@ -672,17 +673,20 @@ impl Primary { // Check if the batch is ready to be certified. if !proposal.is_quorum_threshold_reached(&committee_lookback) { // If the batch is not ready to be certified, return early. - return Ok(()); + return Ok(None); } } // There is no proposed batch, so return early. - None => return Ok(()), + None => return Ok(None), }; // Retrieve the batch proposal, clearing the proposed batch. match proposed_batch.take() { - Some(proposal) => proposal, - None => return Ok(()), + Some(proposal) => Ok(Some(proposal)), + None => Ok(None), } + })? + else { + return Ok(()); }; /* Proceeding to certify the batch. */ @@ -793,7 +797,8 @@ impl Primary { tokio::time::sleep(Duration::from_millis(PRIMARY_PING_IN_MS)).await; // Retrieve the block locators. - let block_locators = match self_.sync.get_block_locators() { + let self__ = self_.clone(); + let block_locators = match spawn_blocking!(self__.sync.get_block_locators()) { Ok(block_locators) => block_locators, Err(e) => { warn!("Failed to retrieve block locators - {e}"); @@ -1114,7 +1119,7 @@ impl Primary { /// Stores the certified batch and broadcasts it to all validators, returning the certificate. async fn store_and_broadcast_certificate(&self, proposal: &Proposal, committee: &Committee) -> Result<()> { // Create the batch certificate and transmissions. - let (certificate, transmissions) = proposal.to_certificate(committee)?; + let (certificate, transmissions) = tokio::task::block_in_place(|| proposal.to_certificate(committee))?; // Convert the transmissions into a HashMap. // Note: Do not change the `Proposal` to use a HashMap. The ordering there is necessary for safety. let transmissions = transmissions.into_iter().collect::>(); @@ -1840,7 +1845,7 @@ mod tests { ); } - #[tokio::test] + #[tokio::test(flavor = "multi_thread")] async fn test_batch_signature_from_peer() { let mut rng = TestRng::default(); let (primary, accounts) = primary_without_handlers(&mut rng).await; @@ -1875,7 +1880,7 @@ mod tests { assert_eq!(primary.current_round(), round + 1); } - #[tokio::test] + #[tokio::test(flavor = "multi_thread")] async fn test_batch_signature_from_peer_in_round() { let round = 5; let mut rng = TestRng::default(); From ce1dadf7d578c7073fc2ed0171aed0356aeb8c73 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Fri, 23 Feb 2024 17:08:12 +0100 Subject: [PATCH 127/551] perf: use a blocking task to execute test transactions Signed-off-by: ljedrz --- node/src/validator/mod.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/node/src/validator/mod.rs b/node/src/validator/mod.rs index 7ac250f1a3..efb8003f6e 100644 --- a/node/src/validator/mod.rs +++ b/node/src/validator/mod.rs @@ -16,7 +16,7 @@ mod router; use crate::traits::NodeInterface; use snarkos_account::Account; -use snarkos_node_bft::{helpers::init_primary_channels, ledger_service::CoreLedgerService}; +use snarkos_node_bft::{helpers::init_primary_channels, ledger_service::CoreLedgerService, spawn_blocking}; use snarkos_node_consensus::Consensus; use snarkos_node_rest::Rest; use snarkos_node_router::{ @@ -386,15 +386,16 @@ impl> Validator { // Prepare the inputs. let inputs = [Value::from(Literal::Address(self_.address())), Value::from(Literal::U64(U64::new(1)))]; // Execute the transaction. - let transaction = match self_.ledger.vm().execute( - self_.private_key(), + let self__ = self_.clone(); + let transaction = match spawn_blocking!(self__.ledger.vm().execute( + self__.private_key(), locator, inputs.into_iter(), None, 10_000, None, &mut rand::thread_rng(), - ) { + )) { Ok(transaction) => transaction, Err(error) => { error!("Transaction pool encountered an execution error - {error}"); From ac9983f43e2fca7f10edd13ee07a3f39a9c61f6c Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 23 Feb 2024 10:46:07 -0800 Subject: [PATCH 128/551] Update the mempool capacity --- node/consensus/src/lib.rs | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 30bc32c7e6..5b5a7970cb 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -53,10 +53,12 @@ use tokio::{ task::JoinHandle, }; -/// Percentage of mempool transactions capacity reserved for deployments. -const CAPACITY_FOR_DEPLOYMENTS: usize = 20; -/// Percentage of mempool transactions capacity reserved for executions. -const CAPACITY_FOR_EXECUTIONS: usize = 80; +/// The capacity of the mempool reserved for deployments. +const CAPACITY_FOR_DEPLOYMENTS: usize = 1 << 8; +/// The capacity of the mempool reserved for executions. +const CAPACITY_FOR_EXECUTIONS: usize = 1 << 10; +/// The capacity of the mempool reserved for solutions. +const CAPACITY_FOR_SOLUTIONS: usize = 1 << 10; /// Helper struct to track incoming transactions. struct TransactionsQueue { @@ -67,14 +69,8 @@ struct TransactionsQueue { impl Default for TransactionsQueue { fn default() -> Self { Self { - deployments: LruCache::new( - NonZeroUsize::new(BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH * CAPACITY_FOR_DEPLOYMENTS / 100) - .unwrap(), - ), - executions: LruCache::new( - NonZeroUsize::new(BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH * CAPACITY_FOR_EXECUTIONS / 100) - .unwrap(), - ), + deployments: LruCache::new(NonZeroUsize::new(CAPACITY_FOR_DEPLOYMENTS).unwrap()), + executions: LruCache::new(NonZeroUsize::new(CAPACITY_FOR_EXECUTIONS).unwrap()), } } } @@ -124,9 +120,7 @@ impl Consensus { ledger, bft, primary_sender: Default::default(), - solutions_queue: Arc::new(Mutex::new(LruCache::new( - NonZeroUsize::new(BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH).unwrap(), - ))), + solutions_queue: Arc::new(Mutex::new(LruCache::new(NonZeroUsize::new(CAPACITY_FOR_SOLUTIONS).unwrap()))), transactions_queue: Default::default(), seen_solutions: Arc::new(Mutex::new(LruCache::new(NonZeroUsize::new(1 << 16).unwrap()))), seen_transactions: Arc::new(Mutex::new(LruCache::new(NonZeroUsize::new(1 << 16).unwrap()))), From c88ce780278f5bd329a24c25a7c163e763ea182b Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sun, 25 Feb 2024 22:37:51 -0800 Subject: [PATCH 129/551] Update snarkVM rev - ee10658 --- Cargo.lock | 116 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 2 +- 2 files changed, 59 insertions(+), 59 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2125c799c7..c44ed08831 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3517,7 +3517,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "anstyle", "anyhow", @@ -3548,7 +3548,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "aleo-std", "anyhow", @@ -3578,7 +3578,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3592,7 +3592,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3603,7 +3603,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3613,7 +3613,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3623,7 +3623,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "indexmap 2.2.3", "itertools 0.11.0", @@ -3641,12 +3641,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3657,7 +3657,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3672,7 +3672,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3687,7 +3687,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3700,7 +3700,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3709,7 +3709,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3719,7 +3719,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3731,7 +3731,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3743,7 +3743,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3754,7 +3754,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3766,7 +3766,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3779,7 +3779,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "bs58", "snarkvm-console-network", @@ -3790,7 +3790,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "blake2s_simd", "smallvec", @@ -3803,7 +3803,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "aleo-std", "rayon", @@ -3814,7 +3814,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "anyhow", "indexmap 2.2.3", @@ -3837,7 +3837,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "anyhow", "bech32", @@ -3855,7 +3855,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "enum_index", "enum_index_derive", @@ -3876,7 +3876,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3891,7 +3891,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3902,7 +3902,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "snarkvm-console-network-environment", ] @@ -3910,7 +3910,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3920,7 +3920,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3931,7 +3931,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3942,7 +3942,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3953,7 +3953,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3964,7 +3964,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "rand", "rayon", @@ -3978,7 +3978,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "aleo-std", "anyhow", @@ -3995,7 +3995,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "aleo-std", "anyhow", @@ -4020,7 +4020,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "anyhow", "rand", @@ -4032,7 +4032,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "indexmap 2.2.3", "rayon", @@ -4051,7 +4051,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-coinbase" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "aleo-std", "anyhow", @@ -4071,7 +4071,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "anyhow", "indexmap 2.2.3", @@ -4089,7 +4089,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -4102,7 +4102,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "indexmap 2.2.3", "rayon", @@ -4115,7 +4115,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "indexmap 2.2.3", "serde_json", @@ -4127,7 +4127,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "bytes", "serde_json", @@ -4138,7 +4138,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "indexmap 2.2.3", "rayon", @@ -4153,7 +4153,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "bytes", "serde_json", @@ -4166,7 +4166,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "snarkvm-console", "snarkvm-ledger-coinbase", @@ -4175,7 +4175,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "async-trait", "reqwest", @@ -4188,7 +4188,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "aleo-std-storage", "anyhow", @@ -4214,7 +4214,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4229,7 +4229,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4238,7 +4238,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "aleo-std", "anyhow", @@ -4263,7 +4263,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "aleo-std", "anyhow", @@ -4288,7 +4288,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "aleo-std", "colored", @@ -4311,7 +4311,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "indexmap 2.2.3", "paste", @@ -4325,7 +4325,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "bincode", "once_cell", @@ -4338,7 +4338,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "aleo-std", "anyhow", @@ -4359,7 +4359,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=569cf5a#569cf5a6c7169875c3d3a480eaefe987653870f6" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" dependencies = [ "proc-macro2", "quote 1.0.35", diff --git a/Cargo.toml b/Cargo.toml index 80a795532c..78fd45e916 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "569cf5a" +rev = "ee10658" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From 624112da0a37eb8aa9a8abb548cbefe7a9317be2 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sun, 25 Feb 2024 22:40:22 -0800 Subject: [PATCH 130/551] Add committee ID checks --- node/bft/src/primary.rs | 48 ++++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 8dea9e33a2..23f4db1c6d 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -337,7 +337,7 @@ impl Primary { } // Check if the primary is connected to enough validators to reach quorum threshold. - { + let committee_lookback = { // Retrieve the committee to check against. let committee_lookback = self.ledger.get_committee_lookback_for_round(round)?; // Retrieve the connected validator addresses. @@ -353,7 +353,9 @@ impl Primary { trace!("Primary is connected to {} validators", connected_validators.len() - 1); return Ok(()); } - } + + committee_lookback + }; // Compute the previous round. let previous_round = round.saturating_sub(1); @@ -451,6 +453,8 @@ impl Primary { // Retrieve the private key. let private_key = *self.gateway.account().private_key(); + // Retrieve the committee id. + let committee_id = committee_lookback.id(); // Prepare the transmission IDs. let transmission_ids = transmissions.keys().copied().collect(); // Prepare the previous batch certificate IDs. @@ -460,13 +464,13 @@ impl Primary { &private_key, round, now(), + committee_id, transmission_ids, previous_certificate_ids, &mut rand::thread_rng() ))?; // Construct the proposal. - let proposal = - Proposal::new(self.ledger.get_committee_lookback_for_round(round)?, batch_header.clone(), transmissions)?; + let proposal = Proposal::new(committee_lookback, batch_header.clone(), transmissions)?; // Broadcast the batch to all validators for signing. self.gateway.broadcast(Event::BatchPropose(batch_header.into())); // Set the proposed batch. @@ -521,6 +525,17 @@ impl Primary { bail!("Invalid peer - proposed batch from myself ({batch_author})"); } + // Ensure that the batch proposal's committee ID matches the expected committee ID. + let expected_committee_id = self.ledger.get_committee_lookback_for_round(batch_round)?.id(); + if expected_committee_id != batch_header.committee_id() { + // Proceed to disconnect the validator. + self.gateway.disconnect(peer_ip); + bail!( + "Malicious peer - proposed batch has an incorrect committee ID ({expected_committee_id} != {})", + batch_header.committee_id() + ); + } + // Retrieve the cached round and batch ID for this validator. if let Some((signed_round, signed_batch_id, signature)) = self.signed_proposals.read().get(&batch_author).copied() @@ -1525,8 +1540,16 @@ mod tests { ] .into(); // Sign the batch header. - let batch_header = - BatchHeader::new(private_key, round, timestamp, transmission_ids, previous_certificate_ids, rng).unwrap(); + let batch_header = BatchHeader::new( + private_key, + round, + timestamp, + committee.id(), + transmission_ids, + previous_certificate_ids, + rng, + ) + .unwrap(); // Construct the proposal. Proposal::new(committee, batch_header, transmissions).unwrap() } @@ -1584,6 +1607,7 @@ mod tests { accounts.iter().find(|&(_, acct)| acct.address() == primary_address).map(|(_, acct)| acct.clone()).unwrap(); let private_key = author.private_key(); + let committee_id = Field::rand(rng); let (solution_commitment, solution) = sample_unconfirmed_solution(rng); let (transaction_id, transaction) = sample_unconfirmed_transaction(rng); let transmission_ids = [solution_commitment.into(), (&transaction_id).into()].into(); @@ -1593,8 +1617,16 @@ mod tests { ] .into(); - let batch_header = - BatchHeader::new(private_key, round, timestamp, transmission_ids, previous_certificate_ids, rng).unwrap(); + let batch_header = BatchHeader::new( + private_key, + round, + timestamp, + committee_id, + transmission_ids, + previous_certificate_ids, + rng, + ) + .unwrap(); let signatures = peer_signatures_for_batch(primary_address, accounts, batch_header.batch_id(), rng); let certificate = BatchCertificate::::from(batch_header, signatures).unwrap(); (certificate, transmissions) From 0bcb76077ab840927e7678f17de7258b19c6da78 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sun, 25 Feb 2024 22:40:43 -0800 Subject: [PATCH 131/551] Use committee_id in tests --- node/bft/events/src/certificate_response.rs | 13 +++++++++++-- node/bft/src/helpers/proposal.rs | 1 + node/bft/src/helpers/storage.rs | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/node/bft/events/src/certificate_response.rs b/node/bft/events/src/certificate_response.rs index d81f28f1bc..e24c3db3f4 100644 --- a/node/bft/events/src/certificate_response.rs +++ b/node/bft/events/src/certificate_response.rs @@ -86,11 +86,20 @@ pub mod prop_tests { (Just(committee.clone()), any::(), vec(any_transmission(), 0..16)) .prop_map(|(committee, selector, transmissions)| { let mut rng = TestRng::default(); - let CommitteeContext(_, ValidatorSet(validators)) = committee; + let CommitteeContext(committee, ValidatorSet(validators)) = committee; let signer = selector.select(validators); let transmission_ids = transmissions.into_iter().map(|(id, _)| id).collect(); - BatchHeader::new(&signer.private_key, 0, now(), transmission_ids, Default::default(), &mut rng).unwrap() + BatchHeader::new( + &signer.private_key, + 0, + now(), + committee.id(), + transmission_ids, + Default::default(), + &mut rng, + ) + .unwrap() }) .boxed() } diff --git a/node/bft/src/helpers/proposal.rs b/node/bft/src/helpers/proposal.rs index 7b26e0f9fe..1137ddaa68 100644 --- a/node/bft/src/helpers/proposal.rs +++ b/node/bft/src/helpers/proposal.rs @@ -205,6 +205,7 @@ mod prop_tests { &signer.private_key, committee.starting_round(), now(), + committee.id(), transmission_map.keys().cloned().collect(), Default::default(), &mut rng, diff --git a/node/bft/src/helpers/storage.rs b/node/bft/src/helpers/storage.rs index fba04dfcc4..b390c57391 100644 --- a/node/bft/src/helpers/storage.rs +++ b/node/bft/src/helpers/storage.rs @@ -1107,6 +1107,7 @@ pub mod prop_tests { selector: Selector, ) { let CommitteeContext(committee, ValidatorSet(validators)) = context; + let committee_id = committee.id(); // Initialize the storage. let ledger = Arc::new(MockLedgerService::new(committee)); @@ -1128,6 +1129,7 @@ pub mod prop_tests { &signer.private_key, 0, now(), + committee_id, transmission_map.keys().cloned().collect(), Default::default(), &mut rng, From 76ccdb1a68610918aee15d1eaac448d8f139e2e8 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 26 Feb 2024 10:32:22 -0800 Subject: [PATCH 132/551] Add committee ID check to processing batch certificate --- node/bft/src/primary.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 23f4db1c6d..2041a6c067 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -739,6 +739,8 @@ impl Primary { let author = certificate.author(); // Retrieve the batch certificate round. let certificate_round = certificate.round(); + // Retrieve the batch certificate committee ID. + let committee_id = certificate.committee_id(); // Ensure the batch certificate is from an authorized validator. if !self.gateway.is_authorized_validator_ip(peer_ip) { @@ -768,6 +770,16 @@ impl Primary { // Check if the certificates have reached the quorum threshold. let is_quorum = committee_lookback.is_quorum_threshold_reached(&authors); + // Ensure that the batch certificate's committee ID matches the expected committee ID. + let expected_certificate_id = committee_lookback.id(); + if expected_certificate_id != committee_id { + // Proceed to disconnect the validator. + self.gateway.disconnect(peer_ip); + bail!( + "Committee deviation detected - Batch certificate has a diverging committee ID ({expected_certificate_id} != {committee_id})" + ); + } + // Determine if we are currently proposing a round that is relevant. // Note: This is important, because while our peers have advanced, // they may not be proposing yet, and thus still able to sign our proposed batch. From cd9bad2c75ac349d94f59eea713438e2d464d648 Mon Sep 17 00:00:00 2001 From: Victor Sint Nicolaas Date: Tue, 27 Feb 2024 11:59:55 +0100 Subject: [PATCH 133/551] Add --dev-traffic flag --- .devnet/start.sh | 2 +- cli/src/commands/start.rs | 9 ++++++++- devnet.sh | 4 ++-- node/src/node.rs | 2 ++ node/src/validator/mod.rs | 11 +++++++---- node/tests/common/node.rs | 1 + 6 files changed, 21 insertions(+), 8 deletions(-) diff --git a/.devnet/start.sh b/.devnet/start.sh index f61cea6af0..5214836d71 100755 --- a/.devnet/start.sh +++ b/.devnet/start.sh @@ -37,7 +37,7 @@ start_snarkos_in_tmux() { tmux new-session -d -s snarkos-session # Send the snarkOS start command to the tmux session with the NODE_ID - tmux send-keys -t "snarkos-session" "snarkos start --nodisplay --bft 0.0.0.0:5000 --rest 0.0.0.0:3030 --peers $NODE_IP:4130 --validators $NODE_IP:5000 --verbosity $VERBOSITY --dev $NODE_ID --dev-num-validators $NUM_INSTANCES --validator --metrics" C-m + tmux send-keys -t "snarkos-session" "snarkos start --nodisplay --bft 0.0.0.0:5000 --rest 0.0.0.0:3030 --peers $NODE_IP:4130 --validators $NODE_IP:5000 --verbosity $VERBOSITY --dev $NODE_ID --dev-traffic --dev-num-validators $NUM_INSTANCES --validator --metrics" C-m exit # Exit root user EOF diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index 8205d35c05..7039744a92 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -137,6 +137,9 @@ pub struct Start { /// If development mode is enabled, specify the number of genesis validators (default: 4) #[clap(long)] pub dev_num_validators: Option, + /// If developtment mode is enabled, specify whether node 0 should generate traffic to drive the network + #[clap(long = "dev-traffic")] + pub dev_traffic: bool, /// Specify the path to a directory containing the ledger #[clap(long = "storage_path")] pub storage_path: Option, @@ -436,6 +439,10 @@ impl Start { if self.dev_num_validators.is_some() { eprintln!("The '--dev-num-validators' flag is ignored because '--dev' is not set"); } + // If the `dev_traffic` flag is set, inform the user that it is ignored. + if self.dev_traffic { + eprintln!("The '--dev-traffic' flag is ignored because '--dev' is not set"); + } Block::from_bytes_le(N::genesis_bytes()) } @@ -527,7 +534,7 @@ impl Start { // Initialize the node. let bft_ip = if self.dev.is_some() { self.bft } else { None }; match node_type { - NodeType::Validator => Node::new_validator(self.node, bft_ip, rest_ip, self.rest_rps, account, &trusted_peers, &trusted_validators, genesis, cdn, storage_mode).await, + NodeType::Validator => Node::new_validator(self.node, bft_ip, rest_ip, self.rest_rps, account, &trusted_peers, &trusted_validators, genesis, cdn, self.dev_traffic, storage_mode).await, NodeType::Prover => Node::new_prover(self.node, account, &trusted_peers, genesis, storage_mode).await, NodeType::Client => Node::new_client(self.node, rest_ip, self.rest_rps, account, &trusted_peers, genesis, cdn, storage_mode).await, } diff --git a/devnet.sh b/devnet.sh index e91627335a..f4458625a2 100755 --- a/devnet.sh +++ b/devnet.sh @@ -64,12 +64,12 @@ for validator_index in "${validator_indices[@]}"; do # Send the command to start the validator to the new window and capture output to the log file if [ "$validator_index" -eq 0 ]; then - tmux send-keys -t "devnet:window$validator_index" "snarkos start --nodisplay --dev $validator_index --dev-num-validators $total_validators --validator --logfile $log_file --metrics" C-m + tmux send-keys -t "devnet:window$validator_index" "snarkos start --nodisplay --dev $validator_index --dev-traffic --dev-num-validators $total_validators --validator --logfile $log_file --metrics" C-m else # Create a new window with a unique name window_index=$((validator_index + index_offset)) tmux new-window -t "devnet:$window_index" -n "window$validator_index" - tmux send-keys -t "devnet:window$validator_index" "snarkos start --nodisplay --dev $validator_index --dev-num-validators $total_validators --validator --logfile $log_file" C-m + tmux send-keys -t "devnet:window$validator_index" "snarkos start --nodisplay --dev $validator_index --dev-traffic --dev-num-validators $total_validators --validator --logfile $log_file" C-m fi done diff --git a/node/src/node.rs b/node/src/node.rs index e6435d6ef6..908812543c 100644 --- a/node/src/node.rs +++ b/node/src/node.rs @@ -49,6 +49,7 @@ impl Node { trusted_validators: &[SocketAddr], genesis: Block, cdn: Option, + dev_traffic: bool, storage_mode: StorageMode, ) -> Result { Ok(Self::Validator(Arc::new( @@ -62,6 +63,7 @@ impl Node { trusted_validators, genesis, cdn, + dev_traffic, storage_mode, ) .await?, diff --git a/node/src/validator/mod.rs b/node/src/validator/mod.rs index 7ac250f1a3..7066e85057 100644 --- a/node/src/validator/mod.rs +++ b/node/src/validator/mod.rs @@ -82,6 +82,7 @@ impl> Validator { trusted_validators: &[SocketAddr], genesis: Block, cdn: Option, + dev_traffic: bool, storage_mode: StorageMode, ) -> Result { // Prepare the shutdown flag. @@ -139,7 +140,7 @@ impl> Validator { shutdown, }; // Initialize the transaction pool. - node.initialize_transaction_pool(storage_mode)?; + node.initialize_transaction_pool(storage_mode, dev_traffic)?; // Initialize the REST server. if let Some(rest_ip) = rest_ip { @@ -339,7 +340,7 @@ impl> Validator { // } /// Initialize the transaction pool. - fn initialize_transaction_pool(&self, storage_mode: StorageMode) -> Result<()> { + fn initialize_transaction_pool(&self, storage_mode: StorageMode, dev_traffic: bool) -> Result<()> { use snarkvm::console::{ program::{Identifier, Literal, ProgramID, Value}, types::U64, @@ -353,8 +354,8 @@ impl> Validator { match storage_mode { // If the node is running in development mode, only generate if you are allowed. StorageMode::Development(id) => { - // If the node is not the first node, do not start the loop. - if id != 0 { + // If the node is not the first node, or if we should not create dev traffic, do not start the loop. + if id != 0 || !dev_traffic { return Ok(()); } } @@ -472,6 +473,7 @@ mod tests { let node = SocketAddr::from_str("0.0.0.0:4130").unwrap(); let rest = SocketAddr::from_str("0.0.0.0:3030").unwrap(); let storage_mode = StorageMode::Development(0); + let dev_traffic = true; // Initialize an (insecure) fixed RNG. let mut rng = ChaChaRng::seed_from_u64(1234567890u64); @@ -494,6 +496,7 @@ mod tests { &[], genesis, None, + dev_traffic, storage_mode, ) .await diff --git a/node/tests/common/node.rs b/node/tests/common/node.rs index 80c0262903..f62fc7a295 100644 --- a/node/tests/common/node.rs +++ b/node/tests/common/node.rs @@ -58,6 +58,7 @@ pub async fn validator() -> Validator Date: Tue, 27 Feb 2024 12:12:31 +0100 Subject: [PATCH 134/551] Clean up where we warn about --dev-traffic --- cli/src/commands/start.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index 7039744a92..d9d71c0941 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -439,10 +439,6 @@ impl Start { if self.dev_num_validators.is_some() { eprintln!("The '--dev-num-validators' flag is ignored because '--dev' is not set"); } - // If the `dev_traffic` flag is set, inform the user that it is ignored. - if self.dev_traffic { - eprintln!("The '--dev-traffic' flag is ignored because '--dev' is not set"); - } Block::from_bytes_le(N::genesis_bytes()) } @@ -531,10 +527,22 @@ impl Start { None => StorageMode::from(self.dev), }; + // Determine whether to generate background traffic in dev mode. + let dev_traffic = match self.dev { + Some(_) => self.dev_traffic, + None => { + // If the `dev_traffic` flag is set, inform the user that it is ignored. + if self.dev_traffic { + eprintln!("The '--dev-traffic' flag is ignored because '--dev' is not set"); + } + false + } + }; + // Initialize the node. let bft_ip = if self.dev.is_some() { self.bft } else { None }; match node_type { - NodeType::Validator => Node::new_validator(self.node, bft_ip, rest_ip, self.rest_rps, account, &trusted_peers, &trusted_validators, genesis, cdn, self.dev_traffic, storage_mode).await, + NodeType::Validator => Node::new_validator(self.node, bft_ip, rest_ip, self.rest_rps, account, &trusted_peers, &trusted_validators, genesis, cdn, dev_traffic, storage_mode).await, NodeType::Prover => Node::new_prover(self.node, account, &trusted_peers, genesis, storage_mode).await, NodeType::Client => Node::new_client(self.node, rest_ip, self.rest_rps, account, &trusted_peers, genesis, cdn, storage_mode).await, } From e99ad64ba2bae3c78b66750dd874f2e09d025646 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 27 Feb 2024 13:57:47 -0800 Subject: [PATCH 135/551] Tune values --- node/consensus/src/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 5b5a7970cb..574ed2eaf8 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -54,11 +54,13 @@ use tokio::{ }; /// The capacity of the mempool reserved for deployments. -const CAPACITY_FOR_DEPLOYMENTS: usize = 1 << 8; +const CAPACITY_FOR_DEPLOYMENTS: usize = 1 << 5; /// The capacity of the mempool reserved for executions. const CAPACITY_FOR_EXECUTIONS: usize = 1 << 10; /// The capacity of the mempool reserved for solutions. const CAPACITY_FOR_SOLUTIONS: usize = 1 << 10; +/// The maximum number of deployments the primary processes from the mempool at any given round. +const CAPACITY_FOR_DEPLOYMENT_VERIFICATION: usize = 1 << 3; /// Helper struct to track incoming transactions. struct TransactionsQueue { @@ -299,7 +301,7 @@ impl Consensus { // Acquire the lock on the transactions queue. let mut tx_queue = self.transactions_queue.lock(); // Determine the number of deployments to send. - let num_deployments = tx_queue.deployments.len().min(capacity * CAPACITY_FOR_DEPLOYMENTS / 100); + let num_deployments = tx_queue.deployments.len().min(CAPACITY_FOR_DEPLOYMENT_VERIFICATION); // Determine the number of executions to send. let num_executions = tx_queue.executions.len().min(capacity.saturating_sub(num_deployments)); // Create an iterator which will select interleaved deployments and executions within the capacity. From 3d8382370fdd4599ce689a01b26666f24bf4c62e Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 27 Feb 2024 14:10:48 -0800 Subject: [PATCH 136/551] Use a percentage for deployment verification --- node/consensus/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 574ed2eaf8..a725f37ab2 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -59,8 +59,8 @@ const CAPACITY_FOR_DEPLOYMENTS: usize = 1 << 5; const CAPACITY_FOR_EXECUTIONS: usize = 1 << 10; /// The capacity of the mempool reserved for solutions. const CAPACITY_FOR_SOLUTIONS: usize = 1 << 10; -/// The maximum number of deployments the primary processes from the mempool at any given round. -const CAPACITY_FOR_DEPLOYMENT_VERIFICATION: usize = 1 << 3; +/// The percentage of the transmissions being processed that are deployments. +const DEPLOYMENT_VERIFICATION_RATE: usize = 15; /// Helper struct to track incoming transactions. struct TransactionsQueue { @@ -301,7 +301,7 @@ impl Consensus { // Acquire the lock on the transactions queue. let mut tx_queue = self.transactions_queue.lock(); // Determine the number of deployments to send. - let num_deployments = tx_queue.deployments.len().min(CAPACITY_FOR_DEPLOYMENT_VERIFICATION); + let num_deployments = tx_queue.deployments.len().min(capacity * DEPLOYMENT_VERIFICATION_RATE / 100); // Determine the number of executions to send. let num_executions = tx_queue.executions.len().min(capacity.saturating_sub(num_deployments)); // Create an iterator which will select interleaved deployments and executions within the capacity. From 9bd3df5221a17803334d8d0301517808accd2277 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 27 Feb 2024 15:40:39 -0800 Subject: [PATCH 137/551] Fix mock ledger test with get_block_round --- node/bft/ledger-service/src/ledger.rs | 5 ++++ node/bft/ledger-service/src/mock.rs | 28 ++++++++++++++++++---- node/bft/ledger-service/src/prover.rs | 5 ++++ node/bft/ledger-service/src/traits.rs | 3 +++ node/bft/ledger-service/src/translucent.rs | 5 ++++ node/bft/src/gateway.rs | 4 ++-- node/bft/src/worker.rs | 1 + 7 files changed, 44 insertions(+), 7 deletions(-) diff --git a/node/bft/ledger-service/src/ledger.rs b/node/bft/ledger-service/src/ledger.rs index 1f42f909b0..4864534aa1 100644 --- a/node/bft/ledger-service/src/ledger.rs +++ b/node/bft/ledger-service/src/ledger.rs @@ -89,6 +89,11 @@ impl> LedgerService for CoreLedgerService< self.ledger.get_hash(height) } + /// Returns the block round for the given block height, if it exists. + fn get_block_round(&self, height: u32) -> Result { + self.ledger.get_block(height).map(|block| block.round()) + } + /// Returns the block for the given block height. fn get_block(&self, height: u32) -> Result> { self.ledger.get_block(height) diff --git a/node/bft/ledger-service/src/mock.rs b/node/bft/ledger-service/src/mock.rs index c36679a40e..26974f3061 100644 --- a/node/bft/ledger-service/src/mock.rs +++ b/node/bft/ledger-service/src/mock.rs @@ -32,7 +32,7 @@ use tracing::*; #[derive(Debug)] pub struct MockLedgerService { committee: Committee, - height_to_hash: Mutex>, + height_to_hash: Mutex>, } impl MockLedgerService { @@ -45,7 +45,7 @@ impl MockLedgerService { pub fn new_at_height(committee: Committee, height: u32) -> Self { let mut height_to_hash = BTreeMap::new(); for i in 0..=height { - height_to_hash.insert(i, (Field::::from_u32(i)).into()); + height_to_hash.insert(i, (i as u64 * 2, Field::::from_u32(i).into())); } Self { committee, height_to_hash: Mutex::new(height_to_hash) } } @@ -75,7 +75,12 @@ impl LedgerService for MockLedgerService { /// Returns the canonical block height for the given block hash, if it exists. fn get_block_height(&self, hash: &N::BlockHash) -> Result { - match self.height_to_hash.lock().iter().find_map(|(height, h)| if h == hash { Some(*height) } else { None }) { + match self + .height_to_hash + .lock() + .iter() + .find_map(|(height, (_, h))| if h == hash { Some(*height) } else { None }) + { Some(height) => Ok(height), None => bail!("Missing block {hash}"), } @@ -84,7 +89,20 @@ impl LedgerService for MockLedgerService { /// Returns the canonical block hash for the given block height, if it exists. fn get_block_hash(&self, height: u32) -> Result { match self.height_to_hash.lock().get(&height).cloned() { - Some(hash) => Ok(hash), + Some((_, hash)) => Ok(hash), + None => bail!("Missing block {height}"), + } + } + + /// Returns the block round for the given block height, if it exists. + fn get_block_round(&self, height: u32) -> Result { + match self + .height_to_hash + .lock() + .iter() + .find_map(|(h, (round, _))| if *h == height { Some(*round) } else { None }) + { + Some(round) => Ok(round), None => bail!("Missing block {height}"), } } @@ -197,7 +215,7 @@ impl LedgerService for MockLedgerService { block.height(), self.latest_block_height() ); - self.height_to_hash.lock().insert(block.height(), block.hash()); + self.height_to_hash.lock().insert(block.height(), (block.round(), block.hash())); Ok(()) } } diff --git a/node/bft/ledger-service/src/prover.rs b/node/bft/ledger-service/src/prover.rs index 6edfbafd4c..357e1f49cf 100644 --- a/node/bft/ledger-service/src/prover.rs +++ b/node/bft/ledger-service/src/prover.rs @@ -71,6 +71,11 @@ impl LedgerService for ProverLedgerService { bail!("Block {height} does not exist in prover") } + /// Returns the block round for the given block height, if it exists. + fn get_block_round(&self, height: u32) -> Result { + bail!("Block {height} does not exist in prover") + } + /// Returns the block for the given block height. fn get_block(&self, height: u32) -> Result> { bail!("Block {height} does not exist in prover") diff --git a/node/bft/ledger-service/src/traits.rs b/node/bft/ledger-service/src/traits.rs index a97fdeb373..c4700afa8f 100644 --- a/node/bft/ledger-service/src/traits.rs +++ b/node/bft/ledger-service/src/traits.rs @@ -45,6 +45,9 @@ pub trait LedgerService: Debug + Send + Sync { /// Returns the block hash for the given block height, if it exists. fn get_block_hash(&self, height: u32) -> Result; + /// Returns the block round for the given block height, if it exists. + fn get_block_round(&self, height: u32) -> Result; + /// Returns the block for the given block height. fn get_block(&self, height: u32) -> Result>; diff --git a/node/bft/ledger-service/src/translucent.rs b/node/bft/ledger-service/src/translucent.rs index 34afa15667..4077a4d751 100644 --- a/node/bft/ledger-service/src/translucent.rs +++ b/node/bft/ledger-service/src/translucent.rs @@ -82,6 +82,11 @@ impl> LedgerService for TranslucentLedgerS self.inner.get_block_hash(height) } + /// Returns the block round for the given block height, if it exists. + fn get_block_round(&self, height: u32) -> Result { + self.inner.get_block_round(height) + } + /// Returns the block for the given block height. fn get_block(&self, height: u32) -> Result> { self.inner.get_block(height) diff --git a/node/bft/src/gateway.rs b/node/bft/src/gateway.rs index 277b9ae53d..c51184fece 100644 --- a/node/bft/src/gateway.rs +++ b/node/bft/src/gateway.rs @@ -337,8 +337,8 @@ impl Gateway { // Retrieve the previous block height to consider from the sync tolerance. let previous_block_height = self.ledger.latest_block_height().saturating_sub(MAX_BLOCKS_BEHIND); // Determine if the validator is in any of the previous committee lookbacks. - let exists_in_previous_committee_lookback = match self.ledger.get_block(previous_block_height) { - Ok(block) => (block.round()..self.storage.current_round()).step_by(2).any(|round| { + let exists_in_previous_committee_lookback = match self.ledger.get_block_round(previous_block_height) { + Ok(block_round) => (block_round..self.storage.current_round()).step_by(2).any(|round| { self.ledger .get_committee_lookback_for_round(round) .map_or(false, |committee| committee.is_committee_member(validator_address)) diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index 4e59a399e8..7b0d38480e 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -492,6 +492,7 @@ mod tests { fn contains_block_height(&self, height: u32) -> bool; fn get_block_height(&self, hash: &N::BlockHash) -> Result; fn get_block_hash(&self, height: u32) -> Result; + fn get_block_round(&self, height: u32) -> Result; fn get_block(&self, height: u32) -> Result>; fn get_blocks(&self, heights: Range) -> Result>>; fn get_solution(&self, solution_id: &PuzzleCommitment) -> Result>; From 1b89d09c3fc003d382549388514d5028eda200d4 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 27 Feb 2024 22:15:20 -0800 Subject: [PATCH 138/551] Clarify MockLedgerService variable name --- node/bft/ledger-service/src/mock.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/node/bft/ledger-service/src/mock.rs b/node/bft/ledger-service/src/mock.rs index 26974f3061..df9530b201 100644 --- a/node/bft/ledger-service/src/mock.rs +++ b/node/bft/ledger-service/src/mock.rs @@ -32,13 +32,13 @@ use tracing::*; #[derive(Debug)] pub struct MockLedgerService { committee: Committee, - height_to_hash: Mutex>, + height_to_round_and_hash: Mutex>, } impl MockLedgerService { /// Initializes a new mock ledger service. pub fn new(committee: Committee) -> Self { - Self { committee, height_to_hash: Default::default() } + Self { committee, height_to_round_and_hash: Default::default() } } /// Initializes a new mock ledger service at the specified height. @@ -47,7 +47,7 @@ impl MockLedgerService { for i in 0..=height { height_to_hash.insert(i, (i as u64 * 2, Field::::from_u32(i).into())); } - Self { committee, height_to_hash: Mutex::new(height_to_hash) } + Self { committee, height_to_round_and_hash: Mutex::new(height_to_hash) } } } @@ -55,12 +55,12 @@ impl MockLedgerService { impl LedgerService for MockLedgerService { /// Returns the latest round in the ledger. fn latest_round(&self) -> u64 { - *self.height_to_hash.lock().keys().last().unwrap_or(&0) as u64 + *self.height_to_round_and_hash.lock().keys().last().unwrap_or(&0) as u64 } /// Returns the latest block height in the canonical ledger. fn latest_block_height(&self) -> u32 { - self.height_to_hash.lock().last_key_value().map(|(height, _)| *height).unwrap_or(0) + self.height_to_round_and_hash.lock().last_key_value().map(|(height, _)| *height).unwrap_or(0) } /// Returns the latest block in the ledger. @@ -70,13 +70,13 @@ impl LedgerService for MockLedgerService { /// Returns `true` if the given block height exists in the canonical ledger. fn contains_block_height(&self, height: u32) -> bool { - self.height_to_hash.lock().contains_key(&height) + self.height_to_round_and_hash.lock().contains_key(&height) } /// Returns the canonical block height for the given block hash, if it exists. fn get_block_height(&self, hash: &N::BlockHash) -> Result { match self - .height_to_hash + .height_to_round_and_hash .lock() .iter() .find_map(|(height, (_, h))| if h == hash { Some(*height) } else { None }) @@ -88,7 +88,7 @@ impl LedgerService for MockLedgerService { /// Returns the canonical block hash for the given block height, if it exists. fn get_block_hash(&self, height: u32) -> Result { - match self.height_to_hash.lock().get(&height).cloned() { + match self.height_to_round_and_hash.lock().get(&height).cloned() { Some((_, hash)) => Ok(hash), None => bail!("Missing block {height}"), } @@ -97,7 +97,7 @@ impl LedgerService for MockLedgerService { /// Returns the block round for the given block height, if it exists. fn get_block_round(&self, height: u32) -> Result { match self - .height_to_hash + .height_to_round_and_hash .lock() .iter() .find_map(|(h, (round, _))| if *h == height { Some(*round) } else { None }) @@ -215,7 +215,7 @@ impl LedgerService for MockLedgerService { block.height(), self.latest_block_height() ); - self.height_to_hash.lock().insert(block.height(), (block.round(), block.hash())); + self.height_to_round_and_hash.lock().insert(block.height(), (block.round(), block.hash())); Ok(()) } } From ea6b41eab52eaab58da2cbee3a5b85d24e1460c6 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 28 Feb 2024 12:19:41 -0800 Subject: [PATCH 139/551] Ensure the callback expiration is at least the fetch timeout --- node/bft/src/helpers/pending.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index 7c30e31f97..cc712c5bdc 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -28,7 +28,9 @@ pub const NUM_REDUNDANT_REQUESTS: usize = 2; #[cfg(test)] pub const NUM_REDUNDANT_REQUESTS: usize = 10; -const CALLBACK_TIMEOUT_IN_SECS: i64 = MAX_FETCH_TIMEOUT_IN_MS as i64 / 1000; +/// The maximum number of seconds to wait before expiring a callback. +/// We ensure that we don't truncate `MAX_FETCH_TIMEOUT_IN_MS` when converting to seconds. +const CALLBACK_EXPIRATION_IN_SECS: i64 = (MAX_FETCH_TIMEOUT_IN_MS as i64 + (1000 - 1)) / 1000; #[derive(Debug)] pub struct Pending { @@ -133,7 +135,7 @@ impl Pending { // Fetch the current timestamp. let now = OffsetDateTime::now_utc().unix_timestamp(); // Remove the callbacks that have expired. - callbacks.retain(|(_, timestamp)| now - *timestamp <= CALLBACK_TIMEOUT_IN_SECS); + callbacks.retain(|(_, timestamp)| now - *timestamp <= CALLBACK_EXPIRATION_IN_SECS); } } } @@ -237,7 +239,7 @@ mod tests { assert!(pending.insert(commitment_1, addr_2, Some(callback_sender_2))); // Sleep for a few seconds. - thread::sleep(Duration::from_secs(CALLBACK_TIMEOUT_IN_SECS as u64 - 1)); + thread::sleep(Duration::from_secs(CALLBACK_EXPIRATION_IN_SECS as u64 - 1)); assert!(pending.insert(commitment_1, addr_3, Some(callback_sender_3))); @@ -250,8 +252,8 @@ mod tests { // Ensure that the expired callbacks have been removed. assert_eq!(pending.num_callbacks(commitment_1), 1); - // Wait for `CALLBACK_TIMEOUT_IN_SECS` seconds. - thread::sleep(Duration::from_secs(CALLBACK_TIMEOUT_IN_SECS as u64)); + // Wait for ` CALLBACK_EXPIRATION_IN_SECS` seconds. + thread::sleep(Duration::from_secs(CALLBACK_EXPIRATION_IN_SECS as u64)); // Ensure that the expired callbacks have been removed. assert_eq!(pending.num_callbacks(commitment_1), 0); From c2b9fa133be0be866a80d5f6700291066804f880 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 28 Feb 2024 14:23:48 -0800 Subject: [PATCH 140/551] Remove expired items from pending --- node/bft/src/helpers/pending.rs | 65 ++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index cc712c5bdc..c9fe9f7936 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -130,13 +130,29 @@ impl Pending { /// Removes the callbacks for the specified `item` that have expired. pub fn clear_expired_callbacks_for_item(&self, item: impl Into) { + let item = item.into(); // Clear the callbacks that have expired. - if let Some(callbacks) = self.callbacks.lock().get_mut(&item.into()) { + if let Some(callbacks) = self.callbacks.lock().get_mut(&item) { // Fetch the current timestamp. let now = OffsetDateTime::now_utc().unix_timestamp(); // Remove the callbacks that have expired. callbacks.retain(|(_, timestamp)| now - *timestamp <= CALLBACK_EXPIRATION_IN_SECS); } + + // If there are no callbacks for the item, remove the item from the pending queue. + let mut callbacks = self.callbacks.lock(); + if callbacks.get(&item).map_or(true, |callbacks| callbacks.is_empty()) { + callbacks.remove(&item); + self.pending.write().remove(&item); + } + } + + /// Removes the callbacks for all items have that expired. + pub fn clear_expired_callbacks(&self) { + let items = self.pending.read().keys().copied().collect::>(); + for item in items.into_iter() { + self.clear_expired_callbacks_for_item(item); + } } } @@ -258,6 +274,53 @@ mod tests { // Ensure that the expired callbacks have been removed. assert_eq!(pending.num_callbacks(commitment_1), 0); } + + #[test] + fn test_expired_items() { + let rng = &mut TestRng::default(); + + // Initialize the ready queue. + let pending = Pending::, ()>::new(); + + // Check initially empty. + assert!(pending.is_empty()); + assert_eq!(pending.len(), 0); + + // Initialize the commitments. + let commitment_1 = TransmissionID::Solution(PuzzleCommitment::from_g1_affine(rng.gen())); + let commitment_2 = TransmissionID::Solution(PuzzleCommitment::from_g1_affine(rng.gen())); + + // Initialize the SocketAddrs. + let addr_1 = SocketAddr::from(([127, 0, 0, 1], 1234)); + let addr_2 = SocketAddr::from(([127, 0, 0, 1], 2345)); + let addr_3 = SocketAddr::from(([127, 0, 0, 1], 3456)); + + // Initialize the callbacks. + let (callback_sender_1, _) = oneshot::channel(); + let (callback_sender_2, _) = oneshot::channel(); + let (callback_sender_3, _) = oneshot::channel(); + + // Insert the commitments. + assert!(pending.insert(commitment_1, addr_1, Some(callback_sender_1))); + assert!(pending.insert(commitment_1, addr_2, Some(callback_sender_2))); + assert!(pending.insert(commitment_2, addr_3, Some(callback_sender_3))); + + // Ensure that the items have not been expired yet. + assert_eq!(pending.num_callbacks(commitment_1), 2); + assert_eq!(pending.num_callbacks(commitment_2), 1); + assert_eq!(pending.len(), 1); + + // Wait for ` CALLBACK_EXPIRATION_IN_SECS + 1` seconds. + thread::sleep(Duration::from_secs(CALLBACK_EXPIRATION_IN_SECS as u64 + 1)); + + // Expire the pending callbacks. + pending.clear_expired_callbacks(); + + // Ensure that the items have been expired. + assert_eq!(pending.num_callbacks(commitment_1), 0); + assert_eq!(pending.num_callbacks(commitment_2), 0); + assert_eq!(pending.len(), 0); + } } #[cfg(test)] From 2a74b76f9cddfb7589a8b12bc10019418516c75f Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 28 Feb 2024 14:25:38 -0800 Subject: [PATCH 141/551] Periodically clear expired items --- node/bft/src/sync/mod.rs | 19 +++++++++++++++---- node/bft/src/worker.rs | 12 ++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index 46cc1885d2..66e319011e 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -31,7 +31,7 @@ use snarkvm::{ use anyhow::{bail, Result}; use parking_lot::Mutex; use rayon::prelude::*; -use std::{collections::HashMap, future::Future, net::SocketAddr, sync::Arc}; +use std::{collections::HashMap, future::Future, net::SocketAddr, sync::Arc, time::Duration}; use tokio::{ sync::{oneshot, Mutex as TMutex, OnceCell}, task::JoinHandle, @@ -97,7 +97,7 @@ impl Sync { self.handles.lock().push(tokio::spawn(async move { loop { // Sleep briefly to avoid triggering spam detection. - tokio::time::sleep(std::time::Duration::from_millis(PRIMARY_PING_IN_MS)).await; + tokio::time::sleep(Duration::from_millis(PRIMARY_PING_IN_MS)).await; // Perform the sync routine. let communication = &self_.gateway; // let communication = &node.router; @@ -110,6 +110,18 @@ impl Sync { } })); + // Start the pending queue expiration loop. + let self_ = self.clone(); + self.spawn(async move { + loop { + // Sleep briefly. + tokio::time::sleep(Duration::from_millis(MAX_FETCH_TIMEOUT_IN_MS)).await; + + // Remove the expired pending transmission requests. + self_.pending.clear_expired_callbacks(); + } + }); + // Retrieve the sync receiver. let SyncReceiver { mut rx_block_sync_advance_with_sync_blocks, @@ -425,8 +437,7 @@ impl Sync { } } // Wait for the certificate to be fetched. - match tokio::time::timeout(core::time::Duration::from_millis(MAX_FETCH_TIMEOUT_IN_MS), callback_receiver).await - { + match tokio::time::timeout(Duration::from_millis(MAX_FETCH_TIMEOUT_IN_MS), callback_receiver).await { // If the certificate was fetched, return it. Ok(result) => Ok(result?), // If the certificate was not fetched, return an error. diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index 4e59a399e8..929f64a098 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -350,6 +350,18 @@ impl Worker { fn start_handlers(&self, receiver: WorkerReceiver) { let WorkerReceiver { mut rx_worker_ping, mut rx_transmission_request, mut rx_transmission_response } = receiver; + // Start the pending queue expiration loop. + let self_ = self.clone(); + self.spawn(async move { + loop { + // Sleep briefly. + tokio::time::sleep(Duration::from_millis(MAX_FETCH_TIMEOUT_IN_MS)).await; + + // Remove the expired pending certificate requests. + self_.pending.clear_expired_callbacks(); + } + }); + // Process the ping events. let self_ = self.clone(); self.spawn(async move { From 60289d4098968699aaf67f432260eaa220599193 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 28 Feb 2024 17:39:45 -0800 Subject: [PATCH 142/551] Minor fix --- node/bft/src/helpers/pending.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index c9fe9f7936..5a42a5cc17 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -97,13 +97,14 @@ impl Pending { // Insert the peer IP into the pending queue. let result = self.pending.write().entry(item).or_default().insert(peer_ip); - // Clear the callbacks that have expired. - self.clear_expired_callbacks_for_item(item); - // If a callback is provided, insert it into the callback queue. if let Some(callback) = callback { self.callbacks.lock().entry(item).or_default().push((callback, OffsetDateTime::now_utc().unix_timestamp())); } + + // Clear the callbacks that have expired. + self.clear_expired_callbacks_for_item(item); + // Return the result. result } @@ -139,9 +140,10 @@ impl Pending { callbacks.retain(|(_, timestamp)| now - *timestamp <= CALLBACK_EXPIRATION_IN_SECS); } - // If there are no callbacks for the item, remove the item from the pending queue. + // If there are no more remaining callbacks for the item, remove the item from the pending queue. + // If the item was added to the pending queue without a callback, do not remove the item. let mut callbacks = self.callbacks.lock(); - if callbacks.get(&item).map_or(true, |callbacks| callbacks.is_empty()) { + if callbacks.get(&item).map_or(false, |callback_values| callback_values.is_empty()) { callbacks.remove(&item); self.pending.write().remove(&item); } From 124cdcc696579045184b7827e76ca1d73108e01d Mon Sep 17 00:00:00 2001 From: Aliez Date: Thu, 29 Feb 2024 14:40:31 +0900 Subject: [PATCH 143/551] Update README.md Signed-off-by: Aliez --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6fa2186ca0..e482287ca4 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,8 @@ * [2.1 Requirements](#21-requirements) * [2.2 Installation](#22-installation) * [3. Run an Aleo Node](#3-run-an-aleo-node) - * [3a. Run an Aleo Client](#3a-run-an-aleo-client) - * [3b. Run an Aleo Prover](#3b-run-an-aleo-prover) + * [3.1 Run an Aleo Client](#31-run-an-aleo-client) + * [3.2 Run an Aleo Prover](#32-run-an-aleo-prover) * [4. FAQs](#4-faqs) * [5. Command Line Interface](#5-command-line-interface) * [6. Development Guide](#6-development-guide) @@ -96,7 +96,7 @@ Please ensure ports `4130/tcp` and `3030/tcp` are open on your router and OS fir ## 3. Run an Aleo Node -## 3a. Run an Aleo Client +## 3.1 Run an Aleo Client Start by following the instructions in the [Build Guide](#2-build-guide). @@ -105,7 +105,7 @@ Next, to start a client node, from the `snarkOS` directory, run: ./run-client.sh ``` -## 3b. Run an Aleo Prover +## 3.2 Run an Aleo Prover Start by following the instructions in the [Build Guide](#2-build-guide). From e6a0fff68cc89c3e05e38b5e43b8e1cc60dc2f85 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 29 Feb 2024 11:39:10 -0800 Subject: [PATCH 144/551] cleanup --- node/bft/src/helpers/pending.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index 5a42a5cc17..0397cb64aa 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -132,20 +132,20 @@ impl Pending { /// Removes the callbacks for the specified `item` that have expired. pub fn clear_expired_callbacks_for_item(&self, item: impl Into) { let item = item.into(); + // Acquire the callbacks lock. + let mut callbacks = self.callbacks.lock(); // Clear the callbacks that have expired. - if let Some(callbacks) = self.callbacks.lock().get_mut(&item) { + if let Some(callback_values) = callbacks.get_mut(&item) { // Fetch the current timestamp. let now = OffsetDateTime::now_utc().unix_timestamp(); // Remove the callbacks that have expired. - callbacks.retain(|(_, timestamp)| now - *timestamp <= CALLBACK_EXPIRATION_IN_SECS); - } + callback_values.retain(|(_, timestamp)| now - *timestamp <= CALLBACK_EXPIRATION_IN_SECS); - // If there are no more remaining callbacks for the item, remove the item from the pending queue. - // If the item was added to the pending queue without a callback, do not remove the item. - let mut callbacks = self.callbacks.lock(); - if callbacks.get(&item).map_or(false, |callback_values| callback_values.is_empty()) { - callbacks.remove(&item); - self.pending.write().remove(&item); + // If there are no more remaining callbacks for the item, remove the item from the pending queue. + if callback_values.is_empty() { + callbacks.remove(&item); + self.pending.write().remove(&item); + } } } @@ -310,7 +310,7 @@ mod tests { // Ensure that the items have not been expired yet. assert_eq!(pending.num_callbacks(commitment_1), 2); assert_eq!(pending.num_callbacks(commitment_2), 1); - assert_eq!(pending.len(), 1); + assert_eq!(pending.len(), 2); // Wait for ` CALLBACK_EXPIRATION_IN_SECS + 1` seconds. thread::sleep(Duration::from_secs(CALLBACK_EXPIRATION_IN_SECS as u64 + 1)); From 9b9f178b0cb0fec87c151334a7afd120658b041d Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 1 Mar 2024 14:57:27 -0800 Subject: [PATCH 145/551] Use redundancy based on committee size and num requests based on unique peer ips --- node/bft/src/helpers/pending.rs | 13 +++++++++---- node/bft/src/sync/mod.rs | 23 +++++++++++++++++------ node/bft/src/worker.rs | 22 +++++++++++++++++----- 3 files changed, 43 insertions(+), 15 deletions(-) diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index 7c30e31f97..07a2af93cb 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -23,10 +23,10 @@ use std::{ use time::OffsetDateTime; use tokio::sync::oneshot; -#[cfg(not(test))] -pub const NUM_REDUNDANT_REQUESTS: usize = 2; -#[cfg(test)] -pub const NUM_REDUNDANT_REQUESTS: usize = 10; +/// Returns the maximum number of redundant requests for the specified number of validators. +pub const fn max_redundant_requests(num_validators: usize) -> usize { + num_validators.saturating_div(2) +} const CALLBACK_TIMEOUT_IN_SECS: i64 = MAX_FETCH_TIMEOUT_IN_MS as i64 / 1000; @@ -76,6 +76,11 @@ impl Pending { self.pending.read().get(&item.into()).cloned() } + /// Returns the number of pending peer IPs for the specified `item`. + pub fn num_pending_peers(&self, item: impl Into) -> usize { + self.pending.read().get(&item.into()).map_or(0, |peer_ips| peer_ips.len()) + } + /// Returns the number of pending callbacks for the specified `item`. pub fn num_callbacks(&self, item: impl Into) -> usize { let item = item.into(); diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index 46cc1885d2..01cffd485e 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -13,7 +13,7 @@ // limitations under the License. use crate::{ - helpers::{fmt_id, BFTSender, Pending, Storage, SyncReceiver, NUM_REDUNDANT_REQUESTS}, + helpers::{fmt_id, max_redundant_requests, BFTSender, Pending, Storage, SyncReceiver}, Gateway, Transport, MAX_FETCH_TIMEOUT_IN_MS, @@ -25,7 +25,7 @@ use snarkos_node_sync::{locators::BlockLocators, BlockSync, BlockSyncMode}; use snarkvm::{ console::{network::Network, types::Field}, ledger::{authority::Authority, block::Block, narwhal::BatchCertificate}, - prelude::{cfg_into_iter, cfg_iter}, + prelude::{cfg_into_iter, cfg_iter, committee::Committee}, }; use anyhow::{bail, Result}; @@ -412,16 +412,27 @@ impl Sync { let (callback_sender, callback_receiver) = oneshot::channel(); // Insert the certificate ID into the pending queue. if self.pending.insert(certificate_id, peer_ip, Some(callback_sender)) { - // Determine how many requests are pending for the certificate. - let num_pending_requests = self.pending.num_callbacks(certificate_id); + // Determine how many pending peers have the certificate as been requested from. + let num_pending_requests = self.pending.num_pending_peers(certificate_id); + + // Calculate the max number of redundant requests. + let num_validators = self + .ledger + .get_committee_lookback_for_round(self.storage.current_round()) + .map_or(Committee::::MAX_COMMITTEE_SIZE as usize, |committee| committee.num_members()); + let num_redundant_requests = max_redundant_requests(num_validators); + // If the number of requests is less than or equal to the redundancy factor, send the certificate request to the peer. - if num_pending_requests <= NUM_REDUNDANT_REQUESTS { + if num_pending_requests <= num_redundant_requests { // Send the certificate request to the peer. if self.gateway.send(peer_ip, Event::CertificateRequest(certificate_id.into())).await.is_none() { bail!("Unable to fetch batch certificate {certificate_id} - failed to send request") } } else { - trace!("Skipped sending redundant request for certificate {} to '{peer_ip}'", fmt_id(certificate_id)); + debug!( + "Skipped sending redundant request for certificate {} to '{peer_ip}' ({num_pending_requests} > {num_redundant_requests})", + fmt_id(certificate_id) + ); } } // Wait for the certificate to be fetched. diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index 4e59a399e8..9839448c80 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -14,7 +14,7 @@ use crate::{ events::{Event, TransmissionRequest, TransmissionResponse}, - helpers::{fmt_id, Pending, Ready, Storage, WorkerReceiver, NUM_REDUNDANT_REQUESTS}, + helpers::{fmt_id, max_redundant_requests, Pending, Ready, Storage, WorkerReceiver}, ProposedBatch, Transport, MAX_FETCH_TIMEOUT_IN_MS, @@ -28,6 +28,7 @@ use snarkvm::{ coinbase::{ProverSolution, PuzzleCommitment}, narwhal::{BatchHeader, Data, Transmission, TransmissionID}, }, + prelude::committee::Committee, }; use indexmap::{IndexMap, IndexSet}; @@ -386,16 +387,27 @@ impl Worker { let (callback_sender, callback_receiver) = oneshot::channel(); // Insert the transmission ID into the pending queue. self.pending.insert(transmission_id, peer_ip, Some(callback_sender)); - // Determine how many requests are pending for the transmission. - let num_pending_requests = self.pending.num_callbacks(transmission_id); + // Determine how many pending peers have the transmission as been requested from. + let num_pending_requests = self.pending.num_pending_peers(transmission_id); + + // Calculate the max number of redundant requests. + let num_validators = self + .ledger + .get_committee_lookback_for_round(self.storage.current_round()) + .map_or(Committee::::MAX_COMMITTEE_SIZE as usize, |committee| committee.num_members()); + let num_redundant_requests = max_redundant_requests(num_validators); + // If the number of requests is less than or equal to the the redundancy factor, send the transmission request to the peer. - if num_pending_requests <= NUM_REDUNDANT_REQUESTS { + if num_pending_requests <= num_redundant_requests { // Send the transmission request to the peer. if self.gateway.send(peer_ip, Event::TransmissionRequest(transmission_id.into())).await.is_none() { bail!("Unable to fetch transmission - failed to send request") } } else { - trace!("Skipped sending redundant request for transmission {} to '{peer_ip}'", fmt_id(transmission_id)); + debug!( + "Skipped sending redundant request for transmission {} to '{peer_ip}' ({num_pending_requests} > {num_redundant_requests})", + fmt_id(transmission_id) + ); } // Wait for the transmission to be fetched. match timeout(Duration::from_millis(MAX_FETCH_TIMEOUT_IN_MS), callback_receiver).await { From b7457efa2b15954e79fa2f029dee10a67542c742 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 1 Mar 2024 15:00:47 -0800 Subject: [PATCH 146/551] Add expected values to MockLedger --- node/bft/src/worker.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index 9839448c80..0f2a7f9a60 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -544,10 +544,12 @@ mod tests { let rng = &mut TestRng::default(); // Sample a committee. let committee = snarkvm::ledger::committee::test_helpers::sample_committee(rng); + let committee_clone = committee.clone(); // Setup the mock gateway and ledger. let gateway = MockGateway::default(); let mut mock_ledger = MockLedger::default(); mock_ledger.expect_current_committee().returning(move || Ok(committee.clone())); + mock_ledger.expect_get_committee_lookback_for_round().returning(move |_| Ok(committee_clone.clone())); mock_ledger.expect_contains_transmission().returning(|_| Ok(false)); mock_ledger.expect_check_solution_basic().returning(|_, _| Ok(())); let ledger: Arc> = Arc::new(mock_ledger); @@ -577,6 +579,7 @@ mod tests { let rng = &mut TestRng::default(); // Sample a committee. let committee = snarkvm::ledger::committee::test_helpers::sample_committee(rng); + let committee_clone = committee.clone(); // Setup the mock gateway and ledger. let mut gateway = MockGateway::default(); gateway.expect_send().returning(|_, _| { @@ -585,6 +588,7 @@ mod tests { }); let mut mock_ledger = MockLedger::default(); mock_ledger.expect_current_committee().returning(move || Ok(committee.clone())); + mock_ledger.expect_get_committee_lookback_for_round().returning(move |_| Ok(committee_clone.clone())); mock_ledger.expect_ensure_transmission_id_matches().returning(|_, _| Ok(())); let ledger: Arc> = Arc::new(mock_ledger); // Initialize the storage. @@ -612,6 +616,7 @@ mod tests { let rng = &mut TestRng::default(); // Sample a committee. let committee = snarkvm::ledger::committee::test_helpers::sample_committee(rng); + let committee_clone = committee.clone(); // Setup the mock gateway and ledger. let mut gateway = MockGateway::default(); gateway.expect_send().returning(|_, _| { @@ -620,6 +625,7 @@ mod tests { }); let mut mock_ledger = MockLedger::default(); mock_ledger.expect_current_committee().returning(move || Ok(committee.clone())); + mock_ledger.expect_get_committee_lookback_for_round().returning(move |_| Ok(committee_clone.clone())); mock_ledger.expect_contains_transmission().returning(|_| Ok(false)); mock_ledger.expect_check_solution_basic().returning(|_, _| Ok(())); let ledger: Arc> = Arc::new(mock_ledger); @@ -650,6 +656,7 @@ mod tests { let rng = &mut TestRng::default(); // Sample a committee. let committee = snarkvm::ledger::committee::test_helpers::sample_committee(rng); + let committee_clone = committee.clone(); // Setup the mock gateway and ledger. let mut gateway = MockGateway::default(); gateway.expect_send().returning(|_, _| { @@ -658,6 +665,7 @@ mod tests { }); let mut mock_ledger = MockLedger::default(); mock_ledger.expect_current_committee().returning(move || Ok(committee.clone())); + mock_ledger.expect_get_committee_lookback_for_round().returning(move |_| Ok(committee_clone.clone())); mock_ledger.expect_contains_transmission().returning(|_| Ok(false)); mock_ledger.expect_check_solution_basic().returning(|_, _| Err(anyhow!(""))); let ledger: Arc> = Arc::new(mock_ledger); @@ -688,6 +696,7 @@ mod tests { let mut rng = &mut TestRng::default(); // Sample a committee. let committee = snarkvm::ledger::committee::test_helpers::sample_committee(rng); + let committee_clone = committee.clone(); // Setup the mock gateway and ledger. let mut gateway = MockGateway::default(); gateway.expect_send().returning(|_, _| { @@ -696,6 +705,7 @@ mod tests { }); let mut mock_ledger = MockLedger::default(); mock_ledger.expect_current_committee().returning(move || Ok(committee.clone())); + mock_ledger.expect_get_committee_lookback_for_round().returning(move |_| Ok(committee_clone.clone())); mock_ledger.expect_contains_transmission().returning(|_| Ok(false)); mock_ledger.expect_check_transaction_basic().returning(|_, _| Ok(())); let ledger: Arc> = Arc::new(mock_ledger); @@ -726,6 +736,7 @@ mod tests { let mut rng = &mut TestRng::default(); // Sample a committee. let committee = snarkvm::ledger::committee::test_helpers::sample_committee(rng); + let committee_clone = committee.clone(); // Setup the mock gateway and ledger. let mut gateway = MockGateway::default(); gateway.expect_send().returning(|_, _| { @@ -734,6 +745,7 @@ mod tests { }); let mut mock_ledger = MockLedger::default(); mock_ledger.expect_current_committee().returning(move || Ok(committee.clone())); + mock_ledger.expect_get_committee_lookback_for_round().returning(move |_| Ok(committee_clone.clone())); mock_ledger.expect_contains_transmission().returning(|_| Ok(false)); mock_ledger.expect_check_transaction_basic().returning(|_, _| Err(anyhow!(""))); let ledger: Arc> = Arc::new(mock_ledger); From f32a0f56f5dba68af55b0ea1fe68d2aa8c0702b4 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 1 Mar 2024 15:07:22 -0800 Subject: [PATCH 147/551] Use dedicated function to find num validators --- node/bft/src/sync/mod.rs | 10 +++++++--- node/bft/src/worker.rs | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index 01cffd485e..48ea3cfd25 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -398,6 +398,11 @@ impl Sync { pub fn get_block_locators(&self) -> Result> { self.block_sync.get_block_locators() } + + /// Returns the number of validators in the committee lookback for the given round. + pub fn num_validators_in_committee_lookback(&self, round: u64) -> Option { + self.ledger.get_committee_lookback_for_round(round).map(|committee| committee.num_members()).ok() + } } // Methods to assist with fetching batch certificates from peers. @@ -417,9 +422,8 @@ impl Sync { // Calculate the max number of redundant requests. let num_validators = self - .ledger - .get_committee_lookback_for_round(self.storage.current_round()) - .map_or(Committee::::MAX_COMMITTEE_SIZE as usize, |committee| committee.num_members()); + .num_validators_in_committee_lookback(self.storage.current_round()) + .unwrap_or(Committee::::MAX_COMMITTEE_SIZE as usize); let num_redundant_requests = max_redundant_requests(num_validators); // If the number of requests is less than or equal to the redundancy factor, send the certificate request to the peer. diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index 0f2a7f9a60..46b28251f0 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -143,6 +143,11 @@ impl Worker { pub fn transactions(&self) -> impl '_ + Iterator>)> { self.ready.transactions() } + + /// Returns the number of validators in the committee lookback for the given round. + pub fn num_validators_in_committee_lookback(&self, round: u64) -> Option { + self.ledger.get_committee_lookback_for_round(round).map(|committee| committee.num_members()).ok() + } } impl Worker { @@ -392,9 +397,8 @@ impl Worker { // Calculate the max number of redundant requests. let num_validators = self - .ledger - .get_committee_lookback_for_round(self.storage.current_round()) - .map_or(Committee::::MAX_COMMITTEE_SIZE as usize, |committee| committee.num_members()); + .num_validators_in_committee_lookback(self.storage.current_round()) + .unwrap_or(Committee::::MAX_COMMITTEE_SIZE as usize); let num_redundant_requests = max_redundant_requests(num_validators); // If the number of requests is less than or equal to the the redundancy factor, send the transmission request to the peer. From 35927aeace8aee2d9fabbad0520bccc911c9c532 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 1 Mar 2024 15:15:35 -0800 Subject: [PATCH 148/551] nit --- node/bft/src/helpers/pending.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index 07a2af93cb..ddd5eec3b5 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -23,13 +23,13 @@ use std::{ use time::OffsetDateTime; use tokio::sync::oneshot; +const CALLBACK_TIMEOUT_IN_SECS: i64 = MAX_FETCH_TIMEOUT_IN_MS as i64 / 1000; + /// Returns the maximum number of redundant requests for the specified number of validators. pub const fn max_redundant_requests(num_validators: usize) -> usize { num_validators.saturating_div(2) } -const CALLBACK_TIMEOUT_IN_SECS: i64 = MAX_FETCH_TIMEOUT_IN_MS as i64 / 1000; - #[derive(Debug)] pub struct Pending { /// The map of pending `items` to `peer IPs` that have the item. From c9d3e94d39576fcc529c34bf6495eada9c8c7c50 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 1 Mar 2024 16:45:21 -0800 Subject: [PATCH 149/551] Track the number of sent requests --- node/bft/src/helpers/pending.rs | 40 +++++++++++++++++++++++------- node/bft/src/sync/mod.rs | 43 +++++++++++++++++---------------- node/bft/src/worker.rs | 16 ++++++------ 3 files changed, 62 insertions(+), 37 deletions(-) diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index ddd5eec3b5..4d818ea2c8 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -35,7 +35,8 @@ pub struct Pending { /// The map of pending `items` to `peer IPs` that have the item. pending: RwLock>>, /// The optional callback queue. - callbacks: Mutex, i64)>>>, + /// Each callback has a timeout and a flag indicating if it is associated with a sent request. + callbacks: Mutex, i64, bool)>>>, } impl Default for Pending { @@ -90,12 +91,29 @@ impl Pending { self.callbacks.lock().get(&item).map_or(0, |callbacks| callbacks.len()) } + /// Returns the number of pending sent requests for the specified `item`. + pub fn num_sent_requests(&self, item: impl Into) -> usize { + let item = item.into(); + // Clear the callbacks that have expired. + self.clear_expired_callbacks_for_item(item); + // Return the number of live callbacks. + self.callbacks + .lock() + .get(&item) + .map_or(0, |callbacks| callbacks.iter().filter(|(_, _, request_sent)| *request_sent).count()) + } + /// Inserts the specified `item` and `peer IP` to the pending queue, /// returning `true` if the `peer IP` was newly-inserted into the entry for the `item`. /// /// In addition, an optional `callback` may be provided, that is triggered upon removal. /// Note: The callback, if provided, is **always** inserted into the callback queue. - pub fn insert(&self, item: impl Into, peer_ip: SocketAddr, callback: Option>) -> bool { + pub fn insert( + &self, + item: impl Into, + peer_ip: SocketAddr, + callback: Option<(oneshot::Sender, bool)>, + ) -> bool { let item = item.into(); // Insert the peer IP into the pending queue. let result = self.pending.write().entry(item).or_default().insert(peer_ip); @@ -104,8 +122,12 @@ impl Pending { self.clear_expired_callbacks_for_item(item); // If a callback is provided, insert it into the callback queue. - if let Some(callback) = callback { - self.callbacks.lock().entry(item).or_default().push((callback, OffsetDateTime::now_utc().unix_timestamp())); + if let Some((callback, request_sent)) = callback { + self.callbacks.lock().entry(item).or_default().push(( + callback, + OffsetDateTime::now_utc().unix_timestamp(), + request_sent, + )); } // Return the result. result @@ -122,7 +144,7 @@ impl Pending { if let Some(callbacks) = self.callbacks.lock().remove(&item) { if let Some(callback_value) = callback_value { // Send a notification to the callback. - for (callback, _) in callbacks { + for (callback, _, _) in callbacks { callback.send(callback_value.clone()).ok(); } } @@ -138,7 +160,7 @@ impl Pending { // Fetch the current timestamp. let now = OffsetDateTime::now_utc().unix_timestamp(); // Remove the callbacks that have expired. - callbacks.retain(|(_, timestamp)| now - *timestamp <= CALLBACK_TIMEOUT_IN_SECS); + callbacks.retain(|(_, timestamp, _)| now - *timestamp <= CALLBACK_TIMEOUT_IN_SECS); } } } @@ -238,13 +260,13 @@ mod tests { let (callback_sender_3, _) = oneshot::channel(); // Insert the commitments. - assert!(pending.insert(commitment_1, addr_1, Some(callback_sender_1))); - assert!(pending.insert(commitment_1, addr_2, Some(callback_sender_2))); + assert!(pending.insert(commitment_1, addr_1, Some((callback_sender_1, true)))); + assert!(pending.insert(commitment_1, addr_2, Some((callback_sender_2, true)))); // Sleep for a few seconds. thread::sleep(Duration::from_secs(CALLBACK_TIMEOUT_IN_SECS as u64 - 1)); - assert!(pending.insert(commitment_1, addr_3, Some(callback_sender_3))); + assert!(pending.insert(commitment_1, addr_3, Some((callback_sender_3, true)))); // Check that the number of callbacks has not changed. assert_eq!(pending.num_callbacks(commitment_1), 3); diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index 48ea3cfd25..cb3e89457e 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -415,29 +415,30 @@ impl Sync { ) -> Result> { // Initialize a oneshot channel. let (callback_sender, callback_receiver) = oneshot::channel(); + // Determine how many sent requests are pending. + let num_sent_requests = self.pending.num_sent_requests(certificate_id); + // Calculate the max number of redundant requests. + let num_validators = self + .num_validators_in_committee_lookback(self.storage.current_round()) + .unwrap_or(Committee::::MAX_COMMITTEE_SIZE as usize); + let num_redundant_requests = max_redundant_requests(num_validators); + // Determine if we should send a certificate request to the peer. + let should_send_request = num_sent_requests < num_redundant_requests; + // Insert the certificate ID into the pending queue. - if self.pending.insert(certificate_id, peer_ip, Some(callback_sender)) { - // Determine how many pending peers have the certificate as been requested from. - let num_pending_requests = self.pending.num_pending_peers(certificate_id); - - // Calculate the max number of redundant requests. - let num_validators = self - .num_validators_in_committee_lookback(self.storage.current_round()) - .unwrap_or(Committee::::MAX_COMMITTEE_SIZE as usize); - let num_redundant_requests = max_redundant_requests(num_validators); - - // If the number of requests is less than or equal to the redundancy factor, send the certificate request to the peer. - if num_pending_requests <= num_redundant_requests { - // Send the certificate request to the peer. - if self.gateway.send(peer_ip, Event::CertificateRequest(certificate_id.into())).await.is_none() { - bail!("Unable to fetch batch certificate {certificate_id} - failed to send request") - } - } else { - debug!( - "Skipped sending redundant request for certificate {} to '{peer_ip}' ({num_pending_requests} > {num_redundant_requests})", - fmt_id(certificate_id) - ); + self.pending.insert(certificate_id, peer_ip, Some((callback_sender, should_send_request))); + + // If the number of requests is less than or equal to the redundancy factor, send the certificate request to the peer. + if should_send_request { + // Send the certificate request to the peer. + if self.gateway.send(peer_ip, Event::CertificateRequest(certificate_id.into())).await.is_none() { + bail!("Unable to fetch batch certificate {certificate_id} - failed to send request") } + } else { + debug!( + "Skipped sending redundant request for certificate {} to '{peer_ip}' (Already pending {num_sent_requests} requests)", + fmt_id(certificate_id) + ); } // Wait for the certificate to be fetched. match tokio::time::timeout(core::time::Duration::from_millis(MAX_FETCH_TIMEOUT_IN_MS), callback_receiver).await diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index 46b28251f0..5db38b607c 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -390,26 +390,28 @@ impl Worker { ) -> Result<(TransmissionID, Transmission)> { // Initialize a oneshot channel. let (callback_sender, callback_receiver) = oneshot::channel(); - // Insert the transmission ID into the pending queue. - self.pending.insert(transmission_id, peer_ip, Some(callback_sender)); - // Determine how many pending peers have the transmission as been requested from. - let num_pending_requests = self.pending.num_pending_peers(transmission_id); - + // Determine how many sent requests are pending. + let num_sent_requests = self.pending.num_sent_requests(transmission_id); // Calculate the max number of redundant requests. let num_validators = self .num_validators_in_committee_lookback(self.storage.current_round()) .unwrap_or(Committee::::MAX_COMMITTEE_SIZE as usize); let num_redundant_requests = max_redundant_requests(num_validators); + // Determine if we should send a transmission request to the peer. + let should_send_request = num_sent_requests < num_redundant_requests; + + // Insert the transmission ID into the pending queue. + self.pending.insert(transmission_id, peer_ip, Some((callback_sender, should_send_request))); // If the number of requests is less than or equal to the the redundancy factor, send the transmission request to the peer. - if num_pending_requests <= num_redundant_requests { + if should_send_request { // Send the transmission request to the peer. if self.gateway.send(peer_ip, Event::TransmissionRequest(transmission_id.into())).await.is_none() { bail!("Unable to fetch transmission - failed to send request") } } else { debug!( - "Skipped sending redundant request for transmission {} to '{peer_ip}' ({num_pending_requests} > {num_redundant_requests})", + "Skipped sending redundant request for transmission {} to '{peer_ip}' (Already pending {num_sent_requests} requests)", fmt_id(transmission_id) ); } From 44f498bc29cde5301178936115fe2835beaeebcc Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sat, 2 Mar 2024 13:08:52 -0700 Subject: [PATCH 150/551] Update node/bft/src/primary.rs Signed-off-by: Howard Wu <9260812+howardwu@users.noreply.github.com> --- node/bft/src/primary.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 5107a026d2..e6b76f12dd 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -903,6 +903,7 @@ impl Primary { // A best-effort attempt to skip the scheduled batch proposal if // round progression already triggered one. if self_.propose_lock.try_lock().is_err() { + trace!("Skipping batch proposal {}", "(node is already proposing)".dimmed()); continue; }; // If there is no proposed batch, attempt to propose a batch. From 093532d8f3d26418db4b4dd019e9c36625120021 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sat, 2 Mar 2024 15:06:17 -0800 Subject: [PATCH 151/551] nit: reorder items --- node/bft/ledger-service/src/ledger.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/node/bft/ledger-service/src/ledger.rs b/node/bft/ledger-service/src/ledger.rs index 1eafd41582..520822971a 100644 --- a/node/bft/ledger-service/src/ledger.rs +++ b/node/bft/ledger-service/src/ledger.rs @@ -44,8 +44,8 @@ const COMMITTEE_CACHE_SIZE: usize = 16; pub struct CoreLedgerService> { ledger: Ledger, coinbase_verifying_key: Arc>, - shutdown: Arc, committee_cache: Arc>>>, + shutdown: Arc, } impl> CoreLedgerService { @@ -53,7 +53,7 @@ impl> CoreLedgerService { pub fn new(ledger: Ledger, shutdown: Arc) -> Self { let coinbase_verifying_key = Arc::new(ledger.coinbase_puzzle().coinbase_verifying_key().clone()); let committee_cache = Arc::new(Mutex::new(LruCache::new(COMMITTEE_CACHE_SIZE.try_into().unwrap()))); - Self { ledger, coinbase_verifying_key, shutdown, committee_cache } + Self { ledger, coinbase_verifying_key, committee_cache, shutdown } } } @@ -144,6 +144,7 @@ impl> LedgerService for CoreLedgerService< Some(committee) => { // Insert the committee into the cache. self.committee_cache.lock().push(round, committee.clone()); + // Return the committee. Ok(committee) } // Return the current committee if the round is in the future. From 691baca258bd1c4b157bfcfe8e9c04c0a8a2b91a Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sat, 2 Mar 2024 15:13:46 -0800 Subject: [PATCH 152/551] nit: feature optional --- node/bft/ledger-service/Cargo.toml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/node/bft/ledger-service/Cargo.toml b/node/bft/ledger-service/Cargo.toml index 69d912a82d..40d0ca87b8 100644 --- a/node/bft/ledger-service/Cargo.toml +++ b/node/bft/ledger-service/Cargo.toml @@ -18,9 +18,9 @@ edition = "2021" [features] default = [ ] -ledger = [ "rand", "tokio", "tracing" ] +ledger = [ "parking_lot", "rand", "tokio", "tracing" ] ledger-write = [ ] -mock = [ "tracing" ] +mock = [ "parking_lot", "tracing" ] prover = [ ] test = [ "mock", "translucent" ] translucent = [ "ledger" ] @@ -37,6 +37,7 @@ version = "0.12" [dependencies.parking_lot] version = "0.12" +optional = true [dependencies.rand] version = "0.8" From 40c93f7c25e4c48225a7248e8b3316a474cea8b6 Mon Sep 17 00:00:00 2001 From: Raymond Chu <14917648+raychu86@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:12:52 -0800 Subject: [PATCH 153/551] Update node/bft/src/helpers/pending.rs Co-authored-by: Howard Wu <9260812+howardwu@users.noreply.github.com> Signed-off-by: Raymond Chu <14917648+raychu86@users.noreply.github.com> --- node/bft/src/helpers/pending.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index 4d818ea2c8..e8366c6bb4 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -27,7 +27,10 @@ const CALLBACK_TIMEOUT_IN_SECS: i64 = MAX_FETCH_TIMEOUT_IN_MS as i64 / 1000; /// Returns the maximum number of redundant requests for the specified number of validators. pub const fn max_redundant_requests(num_validators: usize) -> usize { - num_validators.saturating_div(2) + // Note: It is adequate to set this value to the availability threshold, + // as with high probability one will respond honestly (in the best and worst case + // with stake spread across the validators evenly and unevenly, respectively). + 1 + num_validators.saturating_div(3) } #[derive(Debug)] From db874eade07d4ca1bfe55cc275cd4608e1cd4b2a Mon Sep 17 00:00:00 2001 From: Raymond Chu <14917648+raychu86@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:13:25 -0800 Subject: [PATCH 154/551] Update node/bft/src/worker.rs Co-authored-by: Howard Wu <9260812+howardwu@users.noreply.github.com> Signed-off-by: Raymond Chu <14917648+raychu86@users.noreply.github.com> --- node/bft/src/worker.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index 5db38b607c..b60ffb5e19 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -411,7 +411,7 @@ impl Worker { } } else { debug!( - "Skipped sending redundant request for transmission {} to '{peer_ip}' (Already pending {num_sent_requests} requests)", + "Skipped sending request for transmission {} to '{peer_ip}' ({num_sent_requests} redundant requests)", fmt_id(transmission_id) ); } From 4e309215219f41401d7bd33d4f110017c7814ec0 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:14:38 -0800 Subject: [PATCH 155/551] Remove unused function --- node/bft/src/helpers/pending.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index e8366c6bb4..8a3983410f 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -80,11 +80,6 @@ impl Pending { self.pending.read().get(&item.into()).cloned() } - /// Returns the number of pending peer IPs for the specified `item`. - pub fn num_pending_peers(&self, item: impl Into) -> usize { - self.pending.read().get(&item.into()).map_or(0, |peer_ips| peer_ips.len()) - } - /// Returns the number of pending callbacks for the specified `item`. pub fn num_callbacks(&self, item: impl Into) -> usize { let item = item.into(); From 9f39301cd73f39a7744300b9a58d7d151493628b Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:23:17 -0800 Subject: [PATCH 156/551] Cleanup derivation of max redundant requests --- node/bft/src/helpers/pending.rs | 14 ++++++++++++-- node/bft/src/sync/mod.rs | 14 +++----------- node/bft/src/worker.rs | 13 ++----------- 3 files changed, 17 insertions(+), 24 deletions(-) diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index 8a3983410f..d0cf7ff850 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -13,20 +13,30 @@ // limitations under the License. use crate::MAX_FETCH_TIMEOUT_IN_MS; +use snarkos_node_bft_ledger_service::LedgerService; +use snarkvm::{console::network::Network, ledger::committee::Committee}; use parking_lot::{Mutex, RwLock}; use std::{ collections::{HashMap, HashSet}, hash::Hash, net::SocketAddr, + sync::Arc, }; use time::OffsetDateTime; use tokio::sync::oneshot; const CALLBACK_TIMEOUT_IN_SECS: i64 = MAX_FETCH_TIMEOUT_IN_MS as i64 / 1000; -/// Returns the maximum number of redundant requests for the specified number of validators. -pub const fn max_redundant_requests(num_validators: usize) -> usize { +/// Returns the maximum number of redundant requests for the number of validators in the specified round. +pub fn max_redundant_requests(ledger: &Arc>, round: u64) -> usize { + // Determine the number of validators in the committee lookback for the given round. + let num_validators = ledger + .get_committee_lookback_for_round(round) + .map(|committee| committee.num_members()) + .ok() + .unwrap_or(Committee::::MAX_COMMITTEE_SIZE as usize); + // Note: It is adequate to set this value to the availability threshold, // as with high probability one will respond honestly (in the best and worst case // with stake spread across the validators evenly and unevenly, respectively). diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index cb3e89457e..7d707534af 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -25,7 +25,7 @@ use snarkos_node_sync::{locators::BlockLocators, BlockSync, BlockSyncMode}; use snarkvm::{ console::{network::Network, types::Field}, ledger::{authority::Authority, block::Block, narwhal::BatchCertificate}, - prelude::{cfg_into_iter, cfg_iter, committee::Committee}, + prelude::{cfg_into_iter, cfg_iter}, }; use anyhow::{bail, Result}; @@ -398,11 +398,6 @@ impl Sync { pub fn get_block_locators(&self) -> Result> { self.block_sync.get_block_locators() } - - /// Returns the number of validators in the committee lookback for the given round. - pub fn num_validators_in_committee_lookback(&self, round: u64) -> Option { - self.ledger.get_committee_lookback_for_round(round).map(|committee| committee.num_members()).ok() - } } // Methods to assist with fetching batch certificates from peers. @@ -417,11 +412,8 @@ impl Sync { let (callback_sender, callback_receiver) = oneshot::channel(); // Determine how many sent requests are pending. let num_sent_requests = self.pending.num_sent_requests(certificate_id); - // Calculate the max number of redundant requests. - let num_validators = self - .num_validators_in_committee_lookback(self.storage.current_round()) - .unwrap_or(Committee::::MAX_COMMITTEE_SIZE as usize); - let num_redundant_requests = max_redundant_requests(num_validators); + // Determine the maximum number of redundant requests. + let num_redundant_requests = max_redundant_requests(&self.ledger, self.storage.current_round()); // Determine if we should send a certificate request to the peer. let should_send_request = num_sent_requests < num_redundant_requests; diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index b60ffb5e19..f8e9781929 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -28,7 +28,6 @@ use snarkvm::{ coinbase::{ProverSolution, PuzzleCommitment}, narwhal::{BatchHeader, Data, Transmission, TransmissionID}, }, - prelude::committee::Committee, }; use indexmap::{IndexMap, IndexSet}; @@ -143,11 +142,6 @@ impl Worker { pub fn transactions(&self) -> impl '_ + Iterator>)> { self.ready.transactions() } - - /// Returns the number of validators in the committee lookback for the given round. - pub fn num_validators_in_committee_lookback(&self, round: u64) -> Option { - self.ledger.get_committee_lookback_for_round(round).map(|committee| committee.num_members()).ok() - } } impl Worker { @@ -392,11 +386,8 @@ impl Worker { let (callback_sender, callback_receiver) = oneshot::channel(); // Determine how many sent requests are pending. let num_sent_requests = self.pending.num_sent_requests(transmission_id); - // Calculate the max number of redundant requests. - let num_validators = self - .num_validators_in_committee_lookback(self.storage.current_round()) - .unwrap_or(Committee::::MAX_COMMITTEE_SIZE as usize); - let num_redundant_requests = max_redundant_requests(num_validators); + // Determine the maximum number of redundant requests. + let num_redundant_requests = max_redundant_requests(&self.ledger, self.storage.current_round()); // Determine if we should send a transmission request to the peer. let should_send_request = num_sent_requests < num_redundant_requests; From b5f04fbea07a28cfad61f56fadb777cb6a922fd6 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:40:29 -0800 Subject: [PATCH 157/551] Add test for num_sent_requests --- node/bft/src/helpers/pending.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index d0cf7ff850..a79f7213e2 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -185,6 +185,8 @@ mod tests { type CurrentNetwork = snarkvm::prelude::MainnetV0; + const ITERATIONS: usize = 100; + #[test] fn test_pending() { let rng = &mut TestRng::default(); @@ -291,6 +293,37 @@ mod tests { // Ensure that the expired callbacks have been removed. assert_eq!(pending.num_callbacks(commitment_1), 0); } + + #[test] + fn test_num_sent_requests() { + let rng = &mut TestRng::default(); + + // Initialize the ready queue. + let pending = Pending::, ()>::new(); + + for _ in 0..ITERATIONS { + // Generate a commitment. + let commitment = TransmissionID::Solution(PuzzleCommitment::from_g1_affine(rng.gen())); + // Check if the number of sent requests is correct. + let mut expected_num_sent_requests = 0; + for i in 0..ITERATIONS { + // Generate a peer address. + let addr = SocketAddr::from(([127, 0, 0, 1], i as u16)); + // Initialize a callback. + let (callback_sender, _) = oneshot::channel(); + // Randomly determine if the callback is associated with a sent request. + let is_sent_request = rng.gen(); + // Increment the expected number of sent requests. + if is_sent_request { + expected_num_sent_requests += 1; + } + // Insert the commitment. + assert!(pending.insert(commitment, addr, Some((callback_sender, is_sent_request)))); + } + // Ensure that the number of sent requests is correct. + assert_eq!(pending.num_sent_requests(commitment), expected_num_sent_requests); + } + } } #[cfg(test)] From 27e3262e35cc4e2ccf02f3bcc794a788f1881fca Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sat, 2 Mar 2024 17:22:23 -0800 Subject: [PATCH 158/551] Add transmission request flooding test --- node/bft/src/worker.rs | 71 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index f8e9781929..922618e7f7 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -767,6 +767,77 @@ mod tests { assert!(!worker.pending.contains(transmission_id)); assert!(!worker.ready.contains(transmission_id)); } + + #[tokio::test] + async fn test_flood_transmission_requests() { + let mut rng = &mut TestRng::default(); + // Sample a committee. + let committee = snarkvm::ledger::committee::test_helpers::sample_committee(rng); + let committee_clone = committee.clone(); + // Setup the mock gateway and ledger. + let mut gateway = MockGateway::default(); + gateway.expect_send().returning(|_, _| { + let (_tx, rx) = oneshot::channel(); + Some(rx) + }); + let mut mock_ledger = MockLedger::default(); + mock_ledger.expect_current_committee().returning(move || Ok(committee.clone())); + mock_ledger.expect_get_committee_lookback_for_round().returning(move |_| Ok(committee_clone.clone())); + mock_ledger.expect_contains_transmission().returning(|_| Ok(false)); + mock_ledger.expect_check_transaction_basic().returning(|_, _| Ok(())); + let ledger: Arc> = Arc::new(mock_ledger); + // Initialize the storage. + let storage = Storage::::new(ledger.clone(), Arc::new(BFTMemoryService::new()), 1); + + // Create the Worker. + let worker = Worker::new(0, Arc::new(gateway), storage, ledger, Default::default()).unwrap(); + let transaction_id: ::TransactionID = Field::::rand(&mut rng).into(); + let transmission_id = TransmissionID::Transaction(transaction_id); + let peer_ip = SocketAddr::from(([127, 0, 0, 1], 1234)); + + // Determine the number of redundant requests are sent. + let num_redundant_requests = max_redundant_requests(&worker.ledger, worker.storage.current_round()); + // Flood the pending queue with transmission requests. + for _ in 0..(num_redundant_requests * 10) { + let worker_ = worker.clone(); + tokio::spawn(async move { + let _ = worker_.send_transmission_request(peer_ip, transmission_id).await; + }); + // Check that the number of sent requests does not exceed the maximum number of redundant requests. + assert!(worker.pending.num_sent_requests(transmission_id) <= num_redundant_requests); + tokio::time::sleep(Duration::from_millis(10)).await; + } + // Check that the number of sent requests does not exceed the maximum number of redundant requests. + assert_eq!(worker.pending.num_sent_requests(transmission_id), num_redundant_requests); + + // Let all the requests expire. + tokio::time::sleep(Duration::from_millis(MAX_FETCH_TIMEOUT_IN_MS)).await; + assert_eq!(worker.pending.num_sent_requests(transmission_id), 0); + + // Flood the pending queue with transmission requests again. + for _ in 0..(num_redundant_requests * 10) { + let worker_ = worker.clone(); + tokio::spawn(async move { + let _ = worker_.send_transmission_request(peer_ip, transmission_id).await; + }); + assert!(worker.pending.num_sent_requests(transmission_id) <= num_redundant_requests); + tokio::time::sleep(Duration::from_millis(10)).await; + } + // Check that the number of sent requests does not exceed the maximum number of redundant requests. + assert_eq!(worker.pending.num_sent_requests(transmission_id), num_redundant_requests); + + // Check that fulfilling a transmission request clears the pending queue. + let result = worker + .process_unconfirmed_transaction( + transaction_id, + Data::Buffer(Bytes::from((0..512).map(|_| rng.gen::()).collect::>())), + ) + .await; + assert!(result.is_ok()); + assert_eq!(worker.pending.num_sent_requests(transmission_id), 0); + assert!(!worker.pending.contains(transmission_id)); + assert!(worker.ready.contains(transmission_id)); + } } #[cfg(test)] From 99d9b6f76bc1bec89d22e17d2df58397fa7d1672 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sat, 2 Mar 2024 18:32:46 -0800 Subject: [PATCH 159/551] Add more checks to flood test --- node/bft/src/worker.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index 922618e7f7..074d4d5b00 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -797,34 +797,40 @@ mod tests { // Determine the number of redundant requests are sent. let num_redundant_requests = max_redundant_requests(&worker.ledger, worker.storage.current_round()); + let num_flood_requests = num_redundant_requests * 10; // Flood the pending queue with transmission requests. - for _ in 0..(num_redundant_requests * 10) { + for i in 1..=num_flood_requests { let worker_ = worker.clone(); tokio::spawn(async move { let _ = worker_.send_transmission_request(peer_ip, transmission_id).await; }); + tokio::time::sleep(Duration::from_millis(10)).await; // Check that the number of sent requests does not exceed the maximum number of redundant requests. assert!(worker.pending.num_sent_requests(transmission_id) <= num_redundant_requests); - tokio::time::sleep(Duration::from_millis(10)).await; + assert_eq!(worker.pending.num_callbacks(transmission_id), i); } // Check that the number of sent requests does not exceed the maximum number of redundant requests. assert_eq!(worker.pending.num_sent_requests(transmission_id), num_redundant_requests); + assert_eq!(worker.pending.num_callbacks(transmission_id), num_flood_requests); // Let all the requests expire. - tokio::time::sleep(Duration::from_millis(MAX_FETCH_TIMEOUT_IN_MS)).await; + tokio::time::sleep(Duration::from_millis(MAX_FETCH_TIMEOUT_IN_MS + 1000)).await; assert_eq!(worker.pending.num_sent_requests(transmission_id), 0); + assert_eq!(worker.pending.num_callbacks(transmission_id), 0); // Flood the pending queue with transmission requests again. - for _ in 0..(num_redundant_requests * 10) { + for i in 1..=num_flood_requests { let worker_ = worker.clone(); tokio::spawn(async move { let _ = worker_.send_transmission_request(peer_ip, transmission_id).await; }); - assert!(worker.pending.num_sent_requests(transmission_id) <= num_redundant_requests); tokio::time::sleep(Duration::from_millis(10)).await; + assert!(worker.pending.num_sent_requests(transmission_id) <= num_redundant_requests); + assert_eq!(worker.pending.num_callbacks(transmission_id), i); } // Check that the number of sent requests does not exceed the maximum number of redundant requests. assert_eq!(worker.pending.num_sent_requests(transmission_id), num_redundant_requests); + assert_eq!(worker.pending.num_callbacks(transmission_id), num_flood_requests); // Check that fulfilling a transmission request clears the pending queue. let result = worker @@ -835,6 +841,7 @@ mod tests { .await; assert!(result.is_ok()); assert_eq!(worker.pending.num_sent_requests(transmission_id), 0); + assert_eq!(worker.pending.num_callbacks(transmission_id), 0); assert!(!worker.pending.contains(transmission_id)); assert!(worker.ready.contains(transmission_id)); } From f2c799bc7f0b978cae730c0b323f0d56b462a1d6 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sat, 2 Mar 2024 18:38:17 -0800 Subject: [PATCH 160/551] Add additional resending and flooding tests --- node/bft/src/helpers/pending.rs | 2 +- node/bft/src/sync/mod.rs | 2 +- node/bft/src/worker.rs | 27 ++++- node/bft/tests/bft_e2e.rs | 2 + node/bft/tests/common/primary.rs | 6 +- node/bft/tests/components/mod.rs | 80 +++++++++++++++ node/bft/tests/components/pending.rs | 29 ++++++ node/bft/tests/components/worker.rs | 141 +++++++++++++++++++++++++++ 8 files changed, 282 insertions(+), 7 deletions(-) create mode 100644 node/bft/tests/components/mod.rs create mode 100644 node/bft/tests/components/pending.rs create mode 100644 node/bft/tests/components/worker.rs diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index a79f7213e2..4ea0d322b5 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -29,7 +29,7 @@ use tokio::sync::oneshot; const CALLBACK_TIMEOUT_IN_SECS: i64 = MAX_FETCH_TIMEOUT_IN_MS as i64 / 1000; /// Returns the maximum number of redundant requests for the number of validators in the specified round. -pub fn max_redundant_requests(ledger: &Arc>, round: u64) -> usize { +pub fn max_redundant_requests(ledger: Arc>, round: u64) -> usize { // Determine the number of validators in the committee lookback for the given round. let num_validators = ledger .get_committee_lookback_for_round(round) diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index 7d707534af..7499bbfbc6 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -413,7 +413,7 @@ impl Sync { // Determine how many sent requests are pending. let num_sent_requests = self.pending.num_sent_requests(certificate_id); // Determine the maximum number of redundant requests. - let num_redundant_requests = max_redundant_requests(&self.ledger, self.storage.current_round()); + let num_redundant_requests = max_redundant_requests(self.ledger.clone(), self.storage.current_round()); // Determine if we should send a certificate request to the peer. let should_send_request = num_sent_requests < num_redundant_requests; diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index 074d4d5b00..e196703747 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -90,6 +90,11 @@ impl Worker { pub const fn id(&self) -> u8 { self.id } + + /// Returns a reference to the pending transmissions queue. + pub fn pending(&self) -> &Arc, Transmission>> { + &self.pending + } } impl Worker { @@ -387,7 +392,7 @@ impl Worker { // Determine how many sent requests are pending. let num_sent_requests = self.pending.num_sent_requests(transmission_id); // Determine the maximum number of redundant requests. - let num_redundant_requests = max_redundant_requests(&self.ledger, self.storage.current_round()); + let num_redundant_requests = max_redundant_requests(self.ledger.clone(), self.storage.current_round()); // Determine if we should send a transmission request to the peer. let should_send_request = num_sent_requests < num_redundant_requests; @@ -536,6 +541,24 @@ mod tests { } } + #[tokio::test] + async fn test_max_redundant_requests() { + let rng = &mut TestRng::default(); + // Sample a committee. + let committee = snarkvm::ledger::committee::test_helpers::sample_committee_for_round_and_size(0, 100, rng); + let committee_clone = committee.clone(); + // Setup the mock ledger. + let mut mock_ledger = MockLedger::default(); + mock_ledger.expect_current_committee().returning(move || Ok(committee.clone())); + mock_ledger.expect_get_committee_lookback_for_round().returning(move |_| Ok(committee_clone.clone())); + mock_ledger.expect_contains_transmission().returning(|_| Ok(false)); + mock_ledger.expect_check_solution_basic().returning(|_, _| Ok(())); + let ledger: Arc> = Arc::new(mock_ledger); + + // Ensure the maximum number of redundant requests is correct and consistent across iterations. + assert_eq!(max_redundant_requests(ledger, 0), 34, "Update me if the formula changes"); + } + #[tokio::test] async fn test_process_transmission() { let rng = &mut TestRng::default(); @@ -796,7 +819,7 @@ mod tests { let peer_ip = SocketAddr::from(([127, 0, 0, 1], 1234)); // Determine the number of redundant requests are sent. - let num_redundant_requests = max_redundant_requests(&worker.ledger, worker.storage.current_round()); + let num_redundant_requests = max_redundant_requests(worker.ledger.clone(), worker.storage.current_round()); let num_flood_requests = num_redundant_requests * 10; // Flood the pending queue with transmission requests. for i in 1..=num_flood_requests { diff --git a/node/bft/tests/bft_e2e.rs b/node/bft/tests/bft_e2e.rs index cd2a442f52..22f2be82da 100644 --- a/node/bft/tests/bft_e2e.rs +++ b/node/bft/tests/bft_e2e.rs @@ -14,6 +14,8 @@ #[allow(dead_code)] mod common; +#[allow(dead_code)] +mod components; use crate::common::primary::{TestNetwork, TestNetworkConfig}; use deadline::deadline; diff --git a/node/bft/tests/common/primary.rs b/node/bft/tests/common/primary.rs index ef7eb91619..43b4ce8d38 100644 --- a/node/bft/tests/common/primary.rs +++ b/node/bft/tests/common/primary.rs @@ -324,7 +324,7 @@ impl TestNetwork { } // Initializes a new test committee. -fn new_test_committee(n: u16) -> (Vec>, Committee) { +pub fn new_test_committee(n: u16) -> (Vec>, Committee) { let mut accounts = Vec::with_capacity(n as usize); let mut members = IndexMap::with_capacity(n as usize); for i in 0..n { @@ -346,7 +346,7 @@ fn genesis_cache() -> &'static Mutex, Block>> { CACHE.get_or_init(|| Mutex::new(HashMap::new())) } -fn genesis_block( +pub fn genesis_block( genesis_private_key: PrivateKey, committee: Committee, public_balances: IndexMap, u64>, @@ -361,7 +361,7 @@ fn genesis_block( vm.genesis_quorum(&genesis_private_key, committee, public_balances, bonded_balances, rng).unwrap() } -fn genesis_ledger( +pub fn genesis_ledger( genesis_private_key: PrivateKey, committee: Committee, public_balances: IndexMap, u64>, diff --git a/node/bft/tests/components/mod.rs b/node/bft/tests/components/mod.rs new file mode 100644 index 0000000000..1a11df65a7 --- /dev/null +++ b/node/bft/tests/components/mod.rs @@ -0,0 +1,80 @@ +// Copyright (C) 2019-2023 Aleo Systems Inc. +// This file is part of the snarkOS library. + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// http://www.apache.org/licenses/LICENSE-2.0 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +pub mod pending; +pub mod worker; + +use crate::common::{primary, CurrentNetwork, TranslucentLedgerService}; +use snarkos_account::Account; +use snarkos_node_bft::{helpers::Storage, Gateway, Worker}; +use snarkos_node_bft_ledger_service::LedgerService; +use snarkos_node_bft_storage_service::BFTMemoryService; +use snarkvm::{ + console::{account::Address, network::Network}, + ledger::{narwhal::BatchHeader, store::helpers::memory::ConsensusMemory}, + prelude::TestRng, +}; + +use indexmap::IndexMap; +use parking_lot::RwLock; +use std::{str::FromStr, sync::Arc}; + +const ITERATIONS: u32 = 100; + +/// Samples a new ledger with the given number of nodes. +pub fn sample_ledger( + num_nodes: u16, + rng: &mut TestRng, +) -> Arc>> { + let (accounts, committee) = primary::new_test_committee(num_nodes); + let bonded_balances: IndexMap<_, _> = + committee.members().iter().map(|(address, (amount, _))| (*address, (*address, *amount))).collect(); + let gen_key = *accounts[0].private_key(); + let public_balance_per_validator = + (1_500_000_000_000_000 - (num_nodes as u64) * 1_000_000_000_000) / (num_nodes as u64); + let mut balances = IndexMap::, u64>::new(); + for account in accounts.iter() { + balances.insert(account.address(), public_balance_per_validator); + } + + let gen_ledger = + primary::genesis_ledger(gen_key, committee.clone(), balances.clone(), bonded_balances.clone(), rng); + Arc::new(TranslucentLedgerService::new(gen_ledger, Default::default())) +} + +/// Samples a new storage with the given ledger. +pub fn sample_storage(ledger: Arc>>) -> Storage { + Storage::new(ledger, Arc::new(BFTMemoryService::new()), BatchHeader::::MAX_GC_ROUNDS as u64) +} + +/// Samples a new gateway with the given ledger. +pub fn sample_gateway(ledger: Arc>>) -> Gateway { + let num_nodes: u16 = ledger.current_committee().unwrap().num_members().try_into().unwrap(); + let (accounts, _committee) = primary::new_test_committee(num_nodes); + let account = Account::from_str(&accounts[0].private_key().to_string()).unwrap(); + // Initialize the gateway. + Gateway::new(account, ledger, None, &[], None).unwrap() +} + +/// Samples a new worker with the given ledger. +pub fn sample_worker(id: u8, ledger: Arc>>) -> Worker { + // Sample a storage. + let storage = sample_storage(ledger.clone()); + // Sample a gateway. + let gateway = sample_gateway(ledger.clone()); + // Sample a dummy proposed batch. + let proposed_batch = Arc::new(RwLock::new(None)); + // Construct the worker instance. + Worker::new(id, Arc::new(gateway.clone()), storage.clone(), ledger, proposed_batch).unwrap() +} diff --git a/node/bft/tests/components/pending.rs b/node/bft/tests/components/pending.rs new file mode 100644 index 0000000000..b1405207d4 --- /dev/null +++ b/node/bft/tests/components/pending.rs @@ -0,0 +1,29 @@ +// Copyright (C) 2019-2023 Aleo Systems Inc. +// This file is part of the snarkOS library. + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// http://www.apache.org/licenses/LICENSE-2.0 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use crate::components::sample_ledger; +use snarkos_node_bft::helpers::max_redundant_requests; +use snarkvm::prelude::TestRng; + +#[test] +fn test_max_redundant_requests() { + const NUM_NODES: u16 = 100; + + // Initialize the RNG. + let rng = &mut TestRng::default(); + // Sample a ledger. + let ledger = sample_ledger(NUM_NODES, rng); + // Ensure the maximum number of redundant requests is correct and consistent across iterations. + assert_eq!(max_redundant_requests(ledger, 0), 34, "Update me if the formula changes"); +} diff --git a/node/bft/tests/components/worker.rs b/node/bft/tests/components/worker.rs new file mode 100644 index 0000000000..279bc1bf92 --- /dev/null +++ b/node/bft/tests/components/worker.rs @@ -0,0 +1,141 @@ +// Copyright (C) 2019-2023 Aleo Systems Inc. +// This file is part of the snarkOS library. + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// http://www.apache.org/licenses/LICENSE-2.0 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use crate::{ + common::CurrentNetwork, + components::{sample_ledger, sample_worker}, +}; +use snarkos_node_bft::helpers::max_redundant_requests; +use snarkvm::{ + ledger::narwhal::TransmissionID, + prelude::{Network, TestRng}, +}; + +use std::net::SocketAddr; + +#[tokio::test] +#[rustfmt::skip] +async fn test_resend_transmission_request() { + const NUM_NODES: u16 = 100; + + // Initialize the RNG. + let rng = &mut TestRng::default(); + // Sample a ledger. + let ledger = sample_ledger(NUM_NODES, rng); + // Sample a worker. + let worker = sample_worker(0, ledger.clone()); + + // Prepare a dummy transmission ID. + let peer_ip = SocketAddr::from(([127, 0, 0, 1], 1234)); + let transmission_id = TransmissionID::Transaction(::TransactionID::default()); + + // Ensure the worker does not have the dummy transmission ID. + assert!(!worker.contains_transmission(transmission_id), "Transmission should not exist"); + + // Send a request to fetch the dummy transmission. + let worker_ = worker.clone(); + tokio::spawn(async move { worker_.get_or_fetch_transmission(peer_ip, transmission_id).await }); + + tokio::time::sleep(std::time::Duration::from_millis(10)).await; + + let pending = worker.pending(); + // Ensure the transmission ID exists in the pending queue. + assert!(pending.contains(transmission_id), "Missing a transmission in the pending queue"); + // Ensure the peer IP is in the pending queue for the transmission ID. + assert!(pending.contains_peer(transmission_id, peer_ip), "Missing a peer IP for transmission in the pending queue"); + assert_eq!(pending.get(transmission_id), Some([peer_ip].into_iter().collect()), "Missing a peer IP for transmission in the pending queue"); + // Ensure the number of callbacks is correct. + assert_eq!(pending.num_callbacks(transmission_id), 1, "Incorrect number of callbacks for transmission"); + // Ensure the number of sent requests is correct. + assert_eq!(pending.num_sent_requests(transmission_id), 1, "Incorrect number of sent requests for transmission"); + + // Rebroadcast the same request to fetch the dummy transmission. + for i in 1..=10 { + let worker_ = worker.clone(); + tokio::spawn(async move { worker_.get_or_fetch_transmission(peer_ip, transmission_id).await }); + + tokio::time::sleep(std::time::Duration::from_millis(10)).await; + + // Ensure the transmission ID exists in the pending queue. + assert!(pending.contains(transmission_id), "Missing a transmission in the pending queue"); + // Ensure the peer IP is in the pending queue for the transmission ID. + assert!(pending.contains_peer(transmission_id, peer_ip), "Missing a peer IP for transmission in the pending queue"); + assert_eq!(pending.get(transmission_id), Some([peer_ip].into_iter().collect()), "Missing a peer IP for transmission in the pending queue"); + // Ensure the number of callbacks is correct. + assert_eq!(pending.num_callbacks(transmission_id), 1 + i, "Incorrect number of callbacks for transmission"); + // Ensure the number of sent requests is correct. + assert_eq!(pending.num_sent_requests(transmission_id), 1 + i, "Incorrect number of sent requests for transmission"); + } +} + +#[tokio::test] +#[rustfmt::skip] +async fn test_flood_transmission_requests() { + const NUM_NODES: u16 = 100; + + // Initialize the RNG. + let rng = &mut TestRng::default(); + // Sample a ledger. + let ledger = sample_ledger(NUM_NODES, rng); + // Sample a worker. + let worker = sample_worker(0, ledger.clone()); + + // Determine the maximum number of redundant requests. + let max_redundancy = max_redundant_requests(ledger.clone(), 0); + assert_eq!(max_redundancy, 34, "Update me if the formula changes"); + + // Prepare a dummy transmission ID. + let peer_ip = SocketAddr::from(([127, 0, 0, 1], 1234)); + let transmission_id = TransmissionID::Transaction(::TransactionID::default()); + + // Ensure the worker does not have the dummy transmission ID. + assert!(!worker.contains_transmission(transmission_id), "Transmission should not exist"); + + // Send the maximum number of redundant requests to fetch the dummy transmission. + for _ in 0..max_redundancy { + let worker_ = worker.clone(); + tokio::spawn(async move { worker_.get_or_fetch_transmission(peer_ip, transmission_id).await }); + } + + tokio::time::sleep(std::time::Duration::from_millis(10)).await; + + let pending = worker.pending(); + // Ensure the transmission ID exists in the pending queue. + assert!(pending.contains(transmission_id), "Missing a transmission in the pending queue"); + // Ensure the peer IP is in the pending queue for the transmission ID. + assert!(pending.contains_peer(transmission_id, peer_ip), "Missing a peer IP for transmission in the pending queue"); + assert_eq!(pending.get(transmission_id), Some([peer_ip].into_iter().collect()), "Missing a peer IP for transmission in the pending queue"); + // Ensure the number of callbacks is correct. + assert_eq!(pending.num_callbacks(transmission_id), max_redundancy, "Incorrect number of callbacks for transmission"); + // Ensure the number of sent requests is correct. + assert_eq!(pending.num_sent_requests(transmission_id), max_redundancy, "Incorrect number of sent requests for transmission"); + + // Ensure any further redundant requests are not sent. + for i in 1..=20 { + let worker_ = worker.clone(); + tokio::spawn(async move { worker_.get_or_fetch_transmission(peer_ip, transmission_id).await }); + + tokio::time::sleep(std::time::Duration::from_millis(10)).await; + + // Ensure the transmission ID exists in the pending queue. + assert!(pending.contains(transmission_id), "Missing a transmission in the pending queue"); + // Ensure the peer IP is in the pending queue for the transmission ID. + assert!(pending.contains_peer(transmission_id, peer_ip), "Missing a peer IP for transmission in the pending queue"); + assert_eq!(pending.get(transmission_id), Some([peer_ip].into_iter().collect()), "Missing a peer IP for transmission in the pending queue"); + // Ensure the number of callbacks is correct. + assert_eq!(pending.num_callbacks(transmission_id), max_redundancy + i, "Incorrect number of callbacks for transmission"); + // Ensure the number of sent requests is correct. + assert_eq!(pending.num_sent_requests(transmission_id), max_redundancy, "Incorrect number of sent requests for transmission"); + } +} From a0e929225a03cf0cc342effa6e390b606028c2df Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sat, 2 Mar 2024 18:44:07 -0800 Subject: [PATCH 161/551] nit log --- node/bft/src/sync/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index 7499bbfbc6..555bdb5a48 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -428,7 +428,7 @@ impl Sync { } } else { debug!( - "Skipped sending redundant request for certificate {} to '{peer_ip}' (Already pending {num_sent_requests} requests)", + "Skipped sending request for certificate {} to '{peer_ip}' ({num_sent_requests} redundant requests)", fmt_id(certificate_id) ); } From 3e3c0a4ae4b4559074fe92f13cc0f388ffdc1d49 Mon Sep 17 00:00:00 2001 From: Raymond Chu <14917648+raychu86@users.noreply.github.com> Date: Sat, 2 Mar 2024 20:07:39 -0800 Subject: [PATCH 162/551] Update Cargo.toml Co-authored-by: Howard Wu <9260812+howardwu@users.noreply.github.com> Signed-off-by: Raymond Chu <14917648+raychu86@users.noreply.github.com> --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 78fd45e916..76177a3d83 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "ee10658" +rev = "46f2625" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From d7a02081ab427855eb16226389941be4e8b70898 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sat, 2 Mar 2024 20:13:32 -0800 Subject: [PATCH 163/551] nit: logs --- Cargo.lock | 116 ++++++++++++++++++++-------------------- node/bft/src/primary.rs | 22 ++++---- 2 files changed, 67 insertions(+), 71 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3c842aebea..08bcb0824d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3518,7 +3518,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "anstyle", "anyhow", @@ -3549,7 +3549,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "aleo-std", "anyhow", @@ -3579,7 +3579,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3593,7 +3593,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3604,7 +3604,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3614,7 +3614,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3624,7 +3624,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "indexmap 2.2.3", "itertools 0.11.0", @@ -3642,12 +3642,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3658,7 +3658,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3673,7 +3673,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3688,7 +3688,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3701,7 +3701,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3710,7 +3710,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3720,7 +3720,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3732,7 +3732,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3744,7 +3744,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3755,7 +3755,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3767,7 +3767,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3780,7 +3780,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "bs58", "snarkvm-console-network", @@ -3791,7 +3791,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "blake2s_simd", "smallvec", @@ -3804,7 +3804,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "aleo-std", "rayon", @@ -3815,7 +3815,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "anyhow", "indexmap 2.2.3", @@ -3838,7 +3838,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "anyhow", "bech32", @@ -3856,7 +3856,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "enum_index", "enum_index_derive", @@ -3877,7 +3877,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3892,7 +3892,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3903,7 +3903,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "snarkvm-console-network-environment", ] @@ -3911,7 +3911,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3921,7 +3921,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3932,7 +3932,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3943,7 +3943,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3954,7 +3954,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3965,7 +3965,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "rand", "rayon", @@ -3979,7 +3979,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "aleo-std", "anyhow", @@ -3996,7 +3996,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "aleo-std", "anyhow", @@ -4021,7 +4021,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "anyhow", "rand", @@ -4033,7 +4033,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "indexmap 2.2.3", "rayon", @@ -4052,7 +4052,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-coinbase" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "aleo-std", "anyhow", @@ -4072,7 +4072,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "anyhow", "indexmap 2.2.3", @@ -4090,7 +4090,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -4103,7 +4103,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "indexmap 2.2.3", "rayon", @@ -4116,7 +4116,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "indexmap 2.2.3", "serde_json", @@ -4128,7 +4128,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "bytes", "serde_json", @@ -4139,7 +4139,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "indexmap 2.2.3", "rayon", @@ -4154,7 +4154,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "bytes", "serde_json", @@ -4167,7 +4167,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "snarkvm-console", "snarkvm-ledger-coinbase", @@ -4176,7 +4176,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "async-trait", "reqwest", @@ -4189,7 +4189,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "aleo-std-storage", "anyhow", @@ -4215,7 +4215,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4230,7 +4230,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4239,7 +4239,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "aleo-std", "anyhow", @@ -4264,7 +4264,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "aleo-std", "anyhow", @@ -4289,7 +4289,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "aleo-std", "colored", @@ -4312,7 +4312,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "indexmap 2.2.3", "paste", @@ -4326,7 +4326,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "bincode", "once_cell", @@ -4339,7 +4339,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "aleo-std", "anyhow", @@ -4360,7 +4360,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ee10658#ee10658cd589de8af56d7e4162ce11af0bb71804" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" dependencies = [ "proc-macro2", "quote 1.0.35", diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 7e3ee8d661..e4729641fb 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -336,10 +336,10 @@ impl Primary { bail!("Primary is safely skipping {}", format!("(round {round} was already certified)").dimmed()); } + // Retrieve the committee to check against. + let committee_lookback = self.ledger.get_committee_lookback_for_round(round)?; // Check if the primary is connected to enough validators to reach quorum threshold. - let committee_lookback = { - // Retrieve the committee to check against. - let committee_lookback = self.ledger.get_committee_lookback_for_round(round)?; + { // Retrieve the connected validator addresses. let mut connected_validators = self.gateway.connected_addresses(); // Append the primary to the set. @@ -353,9 +353,7 @@ impl Primary { trace!("Primary is connected to {} validators", connected_validators.len() - 1); return Ok(()); } - - committee_lookback - }; + } // Compute the previous round. let previous_round = round.saturating_sub(1); @@ -453,7 +451,7 @@ impl Primary { // Retrieve the private key. let private_key = *self.gateway.account().private_key(); - // Retrieve the committee id. + // Retrieve the committee ID. let committee_id = committee_lookback.id(); // Prepare the transmission IDs. let transmission_ids = transmissions.keys().copied().collect(); @@ -531,7 +529,7 @@ impl Primary { // Proceed to disconnect the validator. self.gateway.disconnect(peer_ip); bail!( - "Malicious peer - proposed batch has an incorrect committee ID ({expected_committee_id} != {})", + "Malicious peer - proposed batch has a different committee ID ({expected_committee_id} != {})", batch_header.committee_id() ); } @@ -775,13 +773,11 @@ impl Primary { let is_quorum = committee_lookback.is_quorum_threshold_reached(&authors); // Ensure that the batch certificate's committee ID matches the expected committee ID. - let expected_certificate_id = committee_lookback.id(); - if expected_certificate_id != committee_id { + let expected_committee_id = committee_lookback.id(); + if expected_committee_id != committee_id { // Proceed to disconnect the validator. self.gateway.disconnect(peer_ip); - bail!( - "Committee deviation detected - Batch certificate has a diverging committee ID ({expected_certificate_id} != {committee_id})" - ); + bail!("Batch certificate has a different committee ID ({expected_committee_id} != {committee_id})"); } // Determine if we are currently proposing a round that is relevant. From 71230f240337c0743f62d2e8e870abfb34ab6b9d Mon Sep 17 00:00:00 2001 From: Victor Sint Nicolaas Date: Sun, 3 Mar 2024 19:38:43 +0100 Subject: [PATCH 164/551] Re-order dev_traffic argument --- cli/src/commands/start.rs | 2 +- node/src/node.rs | 4 ++-- node/src/validator/mod.rs | 4 ++-- node/tests/common/node.rs | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index d9d71c0941..ab9b7666ec 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -542,7 +542,7 @@ impl Start { // Initialize the node. let bft_ip = if self.dev.is_some() { self.bft } else { None }; match node_type { - NodeType::Validator => Node::new_validator(self.node, bft_ip, rest_ip, self.rest_rps, account, &trusted_peers, &trusted_validators, genesis, cdn, dev_traffic, storage_mode).await, + NodeType::Validator => Node::new_validator(self.node, bft_ip, rest_ip, self.rest_rps, account, &trusted_peers, &trusted_validators, genesis, cdn, storage_mode, dev_traffic).await, NodeType::Prover => Node::new_prover(self.node, account, &trusted_peers, genesis, storage_mode).await, NodeType::Client => Node::new_client(self.node, rest_ip, self.rest_rps, account, &trusted_peers, genesis, cdn, storage_mode).await, } diff --git a/node/src/node.rs b/node/src/node.rs index 908812543c..0203f505e0 100644 --- a/node/src/node.rs +++ b/node/src/node.rs @@ -49,8 +49,8 @@ impl Node { trusted_validators: &[SocketAddr], genesis: Block, cdn: Option, - dev_traffic: bool, storage_mode: StorageMode, + dev_traffic: bool, ) -> Result { Ok(Self::Validator(Arc::new( Validator::new( @@ -63,8 +63,8 @@ impl Node { trusted_validators, genesis, cdn, - dev_traffic, storage_mode, + dev_traffic, ) .await?, ))) diff --git a/node/src/validator/mod.rs b/node/src/validator/mod.rs index 7066e85057..0c3431ddc4 100644 --- a/node/src/validator/mod.rs +++ b/node/src/validator/mod.rs @@ -82,8 +82,8 @@ impl> Validator { trusted_validators: &[SocketAddr], genesis: Block, cdn: Option, - dev_traffic: bool, storage_mode: StorageMode, + dev_traffic: bool, ) -> Result { // Prepare the shutdown flag. let shutdown: Arc = Default::default(); @@ -496,8 +496,8 @@ mod tests { &[], genesis, None, - dev_traffic, storage_mode, + dev_traffic, ) .await .unwrap(); diff --git a/node/tests/common/node.rs b/node/tests/common/node.rs index f62fc7a295..81630cc9da 100644 --- a/node/tests/common/node.rs +++ b/node/tests/common/node.rs @@ -58,8 +58,8 @@ pub async fn validator() -> Validator Date: Sun, 3 Mar 2024 19:58:08 +0100 Subject: [PATCH 165/551] Explicitly set default --dev-traffic value --- cli/src/commands/start.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index ab9b7666ec..ad2b1a7825 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -138,7 +138,7 @@ pub struct Start { #[clap(long)] pub dev_num_validators: Option, /// If developtment mode is enabled, specify whether node 0 should generate traffic to drive the network - #[clap(long = "dev-traffic")] + #[clap(default_value = "false", long = "dev-traffic")] pub dev_traffic: bool, /// Specify the path to a directory containing the ledger #[clap(long = "storage_path")] From 281acb5d355f2ed5166b3217084eaf910afa0b90 Mon Sep 17 00:00:00 2001 From: Victor Sint Nicolaas Date: Sun, 3 Mar 2024 19:58:46 +0100 Subject: [PATCH 166/551] add --dev-traffic usage to README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6fa2186ca0..2807478563 100644 --- a/README.md +++ b/README.md @@ -210,7 +210,7 @@ OPTIONS: In the first terminal, start the first validator by running: ``` -cargo run --release -- start --nodisplay --dev 0 --validator +cargo run --release -- start --nodisplay --dev 0 --validator --dev-traffic ``` In the second terminal, start the second validator by running: ``` From f8c28276dc78434c1dfb373a5104d1842b1828ce Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sun, 3 Mar 2024 12:10:46 -0800 Subject: [PATCH 167/551] Update function name to ensure_transmission_is_well_formed --- node/bft/ledger-service/src/ledger.rs | 4 ++-- node/bft/ledger-service/src/mock.rs | 4 ++-- node/bft/ledger-service/src/prover.rs | 4 ++-- node/bft/ledger-service/src/traits.rs | 4 ++-- node/bft/ledger-service/src/translucent.rs | 2 +- node/bft/src/primary.rs | 4 ++-- node/bft/src/worker.rs | 8 ++++---- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/node/bft/ledger-service/src/ledger.rs b/node/bft/ledger-service/src/ledger.rs index e5c98a2af1..211ea55332 100644 --- a/node/bft/ledger-service/src/ledger.rs +++ b/node/bft/ledger-service/src/ledger.rs @@ -191,8 +191,8 @@ impl> LedgerService for CoreLedgerService< } } - /// Ensures the given transmission ID matches the given transmission. - fn ensure_transmission_id_matches( + /// Ensures that the given transmission is not a fee and matches the given transmission ID. + fn ensure_transmission_is_well_formed( &self, transmission_id: TransmissionID, transmission: &mut Transmission, diff --git a/node/bft/ledger-service/src/mock.rs b/node/bft/ledger-service/src/mock.rs index c36679a40e..00236723ab 100644 --- a/node/bft/ledger-service/src/mock.rs +++ b/node/bft/ledger-service/src/mock.rs @@ -143,8 +143,8 @@ impl LedgerService for MockLedgerService { Ok(false) } - /// Ensures the given transmission ID matches the given transmission. - fn ensure_transmission_id_matches( + /// Ensures that the given transmission is not a fee and matches the given transmission ID. + fn ensure_transmission_is_well_formed( &self, transmission_id: TransmissionID, _transmission: &mut Transmission, diff --git a/node/bft/ledger-service/src/prover.rs b/node/bft/ledger-service/src/prover.rs index 6edfbafd4c..be3e181aaf 100644 --- a/node/bft/ledger-service/src/prover.rs +++ b/node/bft/ledger-service/src/prover.rs @@ -124,8 +124,8 @@ impl LedgerService for ProverLedgerService { bail!("Transmission '{transmission_id}' does not exist in prover") } - /// Ensures the given transmission ID matches the given transmission. - fn ensure_transmission_id_matches( + /// Ensures that the given transmission is not a fee and matches the given transmission ID. + fn ensure_transmission_is_well_formed( &self, _transmission_id: TransmissionID, _transmission: &mut Transmission, diff --git a/node/bft/ledger-service/src/traits.rs b/node/bft/ledger-service/src/traits.rs index a97fdeb373..ff25ae0ca7 100644 --- a/node/bft/ledger-service/src/traits.rs +++ b/node/bft/ledger-service/src/traits.rs @@ -78,8 +78,8 @@ pub trait LedgerService: Debug + Send + Sync { /// Returns `true` if the ledger contains the given transmission ID. fn contains_transmission(&self, transmission_id: &TransmissionID) -> Result; - /// Ensures the given transmission ID matches the given transmission. - fn ensure_transmission_id_matches( + /// Ensures that the given transmission is not a fee and matches the given transmission ID. + fn ensure_transmission_is_well_formed( &self, transmission_id: TransmissionID, transmission: &mut Transmission, diff --git a/node/bft/ledger-service/src/translucent.rs b/node/bft/ledger-service/src/translucent.rs index 34afa15667..09c0c1792c 100644 --- a/node/bft/ledger-service/src/translucent.rs +++ b/node/bft/ledger-service/src/translucent.rs @@ -135,7 +135,7 @@ impl> LedgerService for TranslucentLedgerS } /// Always succeeds. - fn ensure_transmission_id_matches( + fn ensure_transmission_is_well_formed( &self, _transmission_id: TransmissionID, _transmission: &mut Transmission, diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 536384b2ea..ed0275ed8a 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -573,8 +573,8 @@ impl Primary { // Check that the transmission ids match and are not fee transactions. for (transmission_id, transmission) in transmissions.iter_mut() { - // If the transmission is invalid, then return early. - if let Err(err) = self.ledger.ensure_transmission_id_matches(*transmission_id, transmission) { + // If the transmission is not well-formed, then return early. + if let Err(err) = self.ledger.ensure_transmission_is_well_formed(*transmission_id, transmission) { debug!("Batch propose from '{peer_ip}' contains an invalid transmission - {err}",); return Ok(()); } diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index e196703747..bfe975f608 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -428,8 +428,8 @@ impl Worker { let exists = self.pending.get(transmission_id).unwrap_or_default().contains(&peer_ip); // If the peer IP exists, finish the pending request. if exists { - // Ensure the transmission ID matches the transmission. - match self.ledger.ensure_transmission_id_matches(transmission_id, &mut transmission) { + // Ensure the transmission is not a fee and matches the transmission ID. + match self.ledger.ensure_transmission_is_well_formed(transmission_id, &mut transmission) { Ok(()) => { // Remove the transmission ID from the pending queue. self.pending.remove(transmission_id, Some(transmission)); @@ -516,7 +516,7 @@ mod tests { fn get_committee_lookback_for_round(&self, round: u64) -> Result>; fn contains_certificate(&self, certificate_id: &Field) -> Result; fn contains_transmission(&self, transmission_id: &TransmissionID) -> Result; - fn ensure_transmission_id_matches( + fn ensure_transmission_is_well_formed( &self, transmission_id: TransmissionID, transmission: &mut Transmission, @@ -609,7 +609,7 @@ mod tests { let mut mock_ledger = MockLedger::default(); mock_ledger.expect_current_committee().returning(move || Ok(committee.clone())); mock_ledger.expect_get_committee_lookback_for_round().returning(move |_| Ok(committee_clone.clone())); - mock_ledger.expect_ensure_transmission_id_matches().returning(|_, _| Ok(())); + mock_ledger.expect_ensure_transmission_is_well_formed().returning(|_, _| Ok(())); let ledger: Arc> = Arc::new(mock_ledger); // Initialize the storage. let storage = Storage::::new(ledger.clone(), Arc::new(BFTMemoryService::new()), 1); From 7022ebbc677b49998af23613e9607a5f40d647c4 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sun, 3 Mar 2024 14:34:08 -0800 Subject: [PATCH 168/551] Use the certificate_round for lookback selection --- node/bft/src/primary.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index ead1edaac9..6f11aaf00a 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -765,15 +765,13 @@ impl Primary { // Store the certificate, after ensuring it is valid. self.sync_with_certificate_from_peer(peer_ip, certificate).await?; - // If there are enough certificates to reach quorum threshold for the current round, + // If there are enough certificates to reach quorum threshold for the certificate round, // then proceed to advance to the next round. - // Retrieve the current round. - let current_round = self.current_round(); // Retrieve the committee lookback. - let committee_lookback = self.ledger.get_committee_lookback_for_round(current_round)?; + let committee_lookback = self.ledger.get_committee_lookback_for_round(certificate_round)?; // Retrieve the certificates. - let certificates = self.storage.get_certificates_for_round(current_round); + let certificates = self.storage.get_certificates_for_round(certificate_round); // Construct a set over the authors. let authors = certificates.iter().map(BatchCertificate::author).collect(); // Check if the certificates have reached the quorum threshold. @@ -797,8 +795,11 @@ impl Primary { None => true, }; + // Retrieve the current round. + let current_round = self.current_round(); + // Determine whether to advance to the next round. - if is_quorum && should_advance { + if is_quorum && should_advance && certificate_round >= current_round { // If we have reached the quorum threshold and the round should advance, then proceed to the next round. self.try_increment_to_the_next_round(current_round + 1).await?; } From 6e8c6d28b096bfae276b5a3656000c4a8aab8129 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Sun, 3 Mar 2024 15:07:54 -0800 Subject: [PATCH 169/551] Add the rps limit to start.sh script --- .devnet/start.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devnet/start.sh b/.devnet/start.sh index f61cea6af0..f4c635892b 100755 --- a/.devnet/start.sh +++ b/.devnet/start.sh @@ -37,7 +37,7 @@ start_snarkos_in_tmux() { tmux new-session -d -s snarkos-session # Send the snarkOS start command to the tmux session with the NODE_ID - tmux send-keys -t "snarkos-session" "snarkos start --nodisplay --bft 0.0.0.0:5000 --rest 0.0.0.0:3030 --peers $NODE_IP:4130 --validators $NODE_IP:5000 --verbosity $VERBOSITY --dev $NODE_ID --dev-num-validators $NUM_INSTANCES --validator --metrics" C-m + tmux send-keys -t "snarkos-session" "snarkos start --nodisplay --bft 0.0.0.0:5000 --rest 0.0.0.0:3030 --peers $NODE_IP:4130 --validators $NODE_IP:5000 --rest-rps 1000 --verbosity $VERBOSITY --dev $NODE_ID --dev-num-validators $NUM_INSTANCES --validator --metrics" C-m exit # Exit root user EOF From 3e6c2a5f45639072983c3343530dab555fad7826 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sun, 3 Mar 2024 15:22:44 -0800 Subject: [PATCH 170/551] Do not gc during bootup --- node/bft/src/bft.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 2157dce6d7..0ca528f96f 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -624,8 +624,10 @@ impl BFT { } } - // Perform garbage collection based on the latest committed leader round. - self.storage().garbage_collect_certificates(latest_leader_round); + // Perform garbage collection based on the latest committed leader round if the node is not syncing. + if !IS_SYNCING { + self.storage().garbage_collect_certificates(latest_leader_round); + } Ok(()) } From 3b7269ee2bc18882cad758ff1fe33195fdb00387 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sun, 3 Mar 2024 16:25:17 -0800 Subject: [PATCH 171/551] Adjust capacities --- node/consensus/src/lib.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 7aa1796837..5a3c6b3bd3 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -53,14 +53,18 @@ use tokio::{ task::JoinHandle, }; -/// The capacity of the mempool reserved for deployments. -const CAPACITY_FOR_DEPLOYMENTS: usize = 1 << 5; -/// The capacity of the mempool reserved for executions. +/// The capacity of the queue reserved for deployments. +/// Note: This is an inbound queue capacity, not a Narwhal-enforced capacity. +const CAPACITY_FOR_DEPLOYMENTS: usize = 1 << 4; +/// The capacity of the queue reserved for executions. +/// Note: This is an inbound queue capacity, not a Narwhal-enforced capacity. const CAPACITY_FOR_EXECUTIONS: usize = 1 << 10; -/// The capacity of the mempool reserved for solutions. +/// The capacity of the queue reserved for solutions. +/// Note: This is an inbound queue capacity, not a Narwhal-enforced capacity. const CAPACITY_FOR_SOLUTIONS: usize = 1 << 10; -/// The percentage of the transmissions being processed that are deployments. -const DEPLOYMENT_VERIFICATION_RATE: usize = 15; +/// The **suggested** maximum number of deployments in each interval. +/// Note: This is an inbound queue limit, not a Narwhal-enforced limit. +const MAX_DEPLOYMENTS_PER_INTERVAL: usize = 1; /// Helper struct to track incoming transactions. struct TransactionsQueue { @@ -301,7 +305,7 @@ impl Consensus { // Acquire the lock on the transactions queue. let mut tx_queue = self.transactions_queue.lock(); // Determine the number of deployments to send. - let num_deployments = tx_queue.deployments.len().min(capacity * DEPLOYMENT_VERIFICATION_RATE / 100); + let num_deployments = tx_queue.deployments.len().min(capacity).min(MAX_DEPLOYMENTS_PER_INTERVAL); // Determine the number of executions to send. let num_executions = tx_queue.executions.len().min(capacity.saturating_sub(num_deployments)); // Create an iterator which will select interleaved deployments and executions within the capacity. From aa0299bcb12225d3bf9eefed9272e1a20545f7fd Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sun, 3 Mar 2024 18:45:25 -0800 Subject: [PATCH 172/551] Perform GC on initialization to ensure our gc_round is correct --- node/bft/src/helpers/storage.rs | 2 ++ node/bft/src/sync/mod.rs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/node/bft/src/helpers/storage.rs b/node/bft/src/helpers/storage.rs index 90911ab594..f10efd0d1a 100644 --- a/node/bft/src/helpers/storage.rs +++ b/node/bft/src/helpers/storage.rs @@ -114,6 +114,8 @@ impl Storage { })); // Update the storage to the current round. storage.update_current_round(current_round); + // Perform GC on the current round. + storage.garbage_collect_certificates(current_round); // Return the storage. storage } diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index 555bdb5a48..153e6556b3 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -212,6 +212,8 @@ impl Sync { self.storage.sync_height_with_block(latest_block.height()); // Sync the round with the block. self.storage.sync_round_with_block(latest_block.round()); + // Perform GC on the latest block round. + self.storage.garbage_collect_certificates(latest_block.round()); // Iterate over the blocks. for block in &blocks { // If the block authority is a subdag, then sync the batch certificates with the block. From 0aeccc0d1d55f23dd24130dd50dee9cc49239e5f Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sun, 3 Mar 2024 19:40:10 -0800 Subject: [PATCH 173/551] Add test for gc on storage init --- node/bft/src/worker.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index bfe975f608..428f9e378f 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -486,6 +486,8 @@ mod tests { type CurrentNetwork = snarkvm::prelude::MainnetV0; + const ITERATIONS: usize = 100; + mock! { Gateway {} #[async_trait] @@ -868,6 +870,34 @@ mod tests { assert!(!worker.pending.contains(transmission_id)); assert!(worker.ready.contains(transmission_id)); } + + #[tokio::test] + async fn test_storage_gc_on_initialization() { + let rng = &mut TestRng::default(); + + for _ in 0..ITERATIONS { + // Mock the ledger round. + let max_gc_rounds = rng.gen_range(50..=100); + let latest_ledger_round = rng.gen_range((max_gc_rounds + 1)..1000); + let expected_gc_round = latest_ledger_round - max_gc_rounds; + + // Sample a committee. + let committee = + snarkvm::ledger::committee::test_helpers::sample_committee_for_round(latest_ledger_round, rng); + + // Setup the mock gateway and ledger. + let mut mock_ledger = MockLedger::default(); + mock_ledger.expect_current_committee().returning(move || Ok(committee.clone())); + + let ledger: Arc> = Arc::new(mock_ledger); + // Initialize the storage. + let storage = + Storage::::new(ledger.clone(), Arc::new(BFTMemoryService::new()), max_gc_rounds); + + // Ensure that the storage GC round is correct. + assert_eq!(storage.gc_round(), expected_gc_round); + } + } } #[cfg(test)] From f54d3bb5a0c82bc74677feea48dbc3e29356a71b Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sun, 3 Mar 2024 20:13:49 -0800 Subject: [PATCH 174/551] Add test to ensure BFT performs GC on commit --- node/bft/src/bft.rs | 67 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 0ca528f96f..7667863b0b 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -1226,4 +1226,71 @@ mod tests { assert_eq!(result.unwrap_err().to_string(), error_msg); Ok(()) } + + #[tokio::test] + #[tracing_test::traced_test] + async fn test_bft_gc_on_commit() -> Result<()> { + let rng = &mut TestRng::default(); + + // Initialize the round parameters. + let max_gc_rounds = 1; + let committee_round = 0; + let commit_round = 2; + let current_round = commit_round + 1; + + // Sample the certificates. + let (_, certificates) = snarkvm::ledger::narwhal::batch_certificate::test_helpers::sample_batch_certificate_with_previous_certificates( + current_round, + rng, + ); + + // Initialize the committee. + let committee = snarkvm::ledger::committee::test_helpers::sample_committee_for_round_and_members( + committee_round, + vec![ + certificates[0].author(), + certificates[1].author(), + certificates[2].author(), + certificates[3].author(), + ], + rng, + ); + + // Initialize the ledger. + let ledger = Arc::new(MockLedgerService::new(committee.clone())); + + // Initialize the storage. + let transmissions = Arc::new(BFTMemoryService::new()); + let storage = Storage::new(ledger.clone(), transmissions, max_gc_rounds); + // Insert the certificates into the storage. + for certificate in certificates.iter() { + storage.testing_only_insert_certificate_testing_only(certificate.clone()); + } + + // Get the leader certificate. + let leader = committee.get_leader(commit_round).unwrap(); + let leader_certificate = storage.get_certificate_for_round_with_author(commit_round, leader).unwrap(); + + // Initialize the BFT. + let account = Account::new(rng)?; + let bft = BFT::new(account, storage.clone(), ledger, None, &[], None)?; + // Insert a mock DAG in the BFT. + *bft.dag.write() = crate::helpers::dag::test_helpers::mock_dag_with_modified_last_committed_round(commit_round); + + // Ensure that the `gc_round` has not been updated yet. + assert_eq!(bft.storage().gc_round(), committee_round.saturating_sub(max_gc_rounds)); + + // Insert the certificates into the BFT. + for certificate in certificates { + assert!(bft.update_dag::(certificate).await.is_ok()); + } + + // Commit the leader certificate. + bft.commit_leader_certificate::(leader_certificate).await.unwrap(); + + // Ensure that the `gc_round` has been updated. + assert_eq!(bft.storage().gc_round(), commit_round - max_gc_rounds); + + Ok(()) + } } From 3595e07a1ed48dadda0b7de975eeb222d5a73c53 Mon Sep 17 00:00:00 2001 From: Raymond Chu <14917648+raychu86@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:12:52 -0800 Subject: [PATCH 175/551] Update node/bft/src/helpers/pending.rs Co-authored-by: Howard Wu <9260812+howardwu@users.noreply.github.com> Signed-off-by: Raymond Chu <14917648+raychu86@users.noreply.github.com> --- node/bft/src/helpers/pending.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index 4d818ea2c8..e8366c6bb4 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -27,7 +27,10 @@ const CALLBACK_TIMEOUT_IN_SECS: i64 = MAX_FETCH_TIMEOUT_IN_MS as i64 / 1000; /// Returns the maximum number of redundant requests for the specified number of validators. pub const fn max_redundant_requests(num_validators: usize) -> usize { - num_validators.saturating_div(2) + // Note: It is adequate to set this value to the availability threshold, + // as with high probability one will respond honestly (in the best and worst case + // with stake spread across the validators evenly and unevenly, respectively). + 1 + num_validators.saturating_div(3) } #[derive(Debug)] From 7a5012ab582ecdf1f155b19a9e05d67a408d0490 Mon Sep 17 00:00:00 2001 From: Raymond Chu <14917648+raychu86@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:13:25 -0800 Subject: [PATCH 176/551] Update node/bft/src/worker.rs Co-authored-by: Howard Wu <9260812+howardwu@users.noreply.github.com> Signed-off-by: Raymond Chu <14917648+raychu86@users.noreply.github.com> --- node/bft/src/worker.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index 869d312790..6934a43dc1 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -411,7 +411,7 @@ impl Worker { } } else { debug!( - "Skipped sending redundant request for transmission {} to '{peer_ip}' (Already pending {num_sent_requests} requests)", + "Skipped sending request for transmission {} to '{peer_ip}' ({num_sent_requests} redundant requests)", fmt_id(transmission_id) ); } From 9e6e7019e94dd3be029507e16cd414bee16f8dfd Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:14:38 -0800 Subject: [PATCH 177/551] Remove unused function --- node/bft/src/helpers/pending.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index e8366c6bb4..8a3983410f 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -80,11 +80,6 @@ impl Pending { self.pending.read().get(&item.into()).cloned() } - /// Returns the number of pending peer IPs for the specified `item`. - pub fn num_pending_peers(&self, item: impl Into) -> usize { - self.pending.read().get(&item.into()).map_or(0, |peer_ips| peer_ips.len()) - } - /// Returns the number of pending callbacks for the specified `item`. pub fn num_callbacks(&self, item: impl Into) -> usize { let item = item.into(); From f7d4e23cbfa55152623021ecc268c6e8dfb3421a Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:23:17 -0800 Subject: [PATCH 178/551] Cleanup derivation of max redundant requests --- node/bft/src/helpers/pending.rs | 14 ++++++++++++-- node/bft/src/sync/mod.rs | 14 +++----------- node/bft/src/worker.rs | 13 ++----------- 3 files changed, 17 insertions(+), 24 deletions(-) diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index 8a3983410f..d0cf7ff850 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -13,20 +13,30 @@ // limitations under the License. use crate::MAX_FETCH_TIMEOUT_IN_MS; +use snarkos_node_bft_ledger_service::LedgerService; +use snarkvm::{console::network::Network, ledger::committee::Committee}; use parking_lot::{Mutex, RwLock}; use std::{ collections::{HashMap, HashSet}, hash::Hash, net::SocketAddr, + sync::Arc, }; use time::OffsetDateTime; use tokio::sync::oneshot; const CALLBACK_TIMEOUT_IN_SECS: i64 = MAX_FETCH_TIMEOUT_IN_MS as i64 / 1000; -/// Returns the maximum number of redundant requests for the specified number of validators. -pub const fn max_redundant_requests(num_validators: usize) -> usize { +/// Returns the maximum number of redundant requests for the number of validators in the specified round. +pub fn max_redundant_requests(ledger: &Arc>, round: u64) -> usize { + // Determine the number of validators in the committee lookback for the given round. + let num_validators = ledger + .get_committee_lookback_for_round(round) + .map(|committee| committee.num_members()) + .ok() + .unwrap_or(Committee::::MAX_COMMITTEE_SIZE as usize); + // Note: It is adequate to set this value to the availability threshold, // as with high probability one will respond honestly (in the best and worst case // with stake spread across the validators evenly and unevenly, respectively). diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index cb3e89457e..7d707534af 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -25,7 +25,7 @@ use snarkos_node_sync::{locators::BlockLocators, BlockSync, BlockSyncMode}; use snarkvm::{ console::{network::Network, types::Field}, ledger::{authority::Authority, block::Block, narwhal::BatchCertificate}, - prelude::{cfg_into_iter, cfg_iter, committee::Committee}, + prelude::{cfg_into_iter, cfg_iter}, }; use anyhow::{bail, Result}; @@ -398,11 +398,6 @@ impl Sync { pub fn get_block_locators(&self) -> Result> { self.block_sync.get_block_locators() } - - /// Returns the number of validators in the committee lookback for the given round. - pub fn num_validators_in_committee_lookback(&self, round: u64) -> Option { - self.ledger.get_committee_lookback_for_round(round).map(|committee| committee.num_members()).ok() - } } // Methods to assist with fetching batch certificates from peers. @@ -417,11 +412,8 @@ impl Sync { let (callback_sender, callback_receiver) = oneshot::channel(); // Determine how many sent requests are pending. let num_sent_requests = self.pending.num_sent_requests(certificate_id); - // Calculate the max number of redundant requests. - let num_validators = self - .num_validators_in_committee_lookback(self.storage.current_round()) - .unwrap_or(Committee::::MAX_COMMITTEE_SIZE as usize); - let num_redundant_requests = max_redundant_requests(num_validators); + // Determine the maximum number of redundant requests. + let num_redundant_requests = max_redundant_requests(&self.ledger, self.storage.current_round()); // Determine if we should send a certificate request to the peer. let should_send_request = num_sent_requests < num_redundant_requests; diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index 6934a43dc1..02755e65a6 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -28,7 +28,6 @@ use snarkvm::{ coinbase::{ProverSolution, PuzzleCommitment}, narwhal::{BatchHeader, Data, Transmission, TransmissionID}, }, - prelude::committee::Committee, }; use indexmap::{IndexMap, IndexSet}; @@ -143,11 +142,6 @@ impl Worker { pub fn transactions(&self) -> impl '_ + Iterator>)> { self.ready.transactions() } - - /// Returns the number of validators in the committee lookback for the given round. - pub fn num_validators_in_committee_lookback(&self, round: u64) -> Option { - self.ledger.get_committee_lookback_for_round(round).map(|committee| committee.num_members()).ok() - } } impl Worker { @@ -392,11 +386,8 @@ impl Worker { let (callback_sender, callback_receiver) = oneshot::channel(); // Determine how many sent requests are pending. let num_sent_requests = self.pending.num_sent_requests(transmission_id); - // Calculate the max number of redundant requests. - let num_validators = self - .num_validators_in_committee_lookback(self.storage.current_round()) - .unwrap_or(Committee::::MAX_COMMITTEE_SIZE as usize); - let num_redundant_requests = max_redundant_requests(num_validators); + // Determine the maximum number of redundant requests. + let num_redundant_requests = max_redundant_requests(&self.ledger, self.storage.current_round()); // Determine if we should send a transmission request to the peer. let should_send_request = num_sent_requests < num_redundant_requests; From f2f911e97e5067babcb3ff97018398600565abd1 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:40:29 -0800 Subject: [PATCH 179/551] Add test for num_sent_requests --- node/bft/src/helpers/pending.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index d0cf7ff850..a79f7213e2 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -185,6 +185,8 @@ mod tests { type CurrentNetwork = snarkvm::prelude::MainnetV0; + const ITERATIONS: usize = 100; + #[test] fn test_pending() { let rng = &mut TestRng::default(); @@ -291,6 +293,37 @@ mod tests { // Ensure that the expired callbacks have been removed. assert_eq!(pending.num_callbacks(commitment_1), 0); } + + #[test] + fn test_num_sent_requests() { + let rng = &mut TestRng::default(); + + // Initialize the ready queue. + let pending = Pending::, ()>::new(); + + for _ in 0..ITERATIONS { + // Generate a commitment. + let commitment = TransmissionID::Solution(PuzzleCommitment::from_g1_affine(rng.gen())); + // Check if the number of sent requests is correct. + let mut expected_num_sent_requests = 0; + for i in 0..ITERATIONS { + // Generate a peer address. + let addr = SocketAddr::from(([127, 0, 0, 1], i as u16)); + // Initialize a callback. + let (callback_sender, _) = oneshot::channel(); + // Randomly determine if the callback is associated with a sent request. + let is_sent_request = rng.gen(); + // Increment the expected number of sent requests. + if is_sent_request { + expected_num_sent_requests += 1; + } + // Insert the commitment. + assert!(pending.insert(commitment, addr, Some((callback_sender, is_sent_request)))); + } + // Ensure that the number of sent requests is correct. + assert_eq!(pending.num_sent_requests(commitment), expected_num_sent_requests); + } + } } #[cfg(test)] From bbea388a3241b20864709617eb522000acf6cb5f Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sat, 2 Mar 2024 17:22:23 -0800 Subject: [PATCH 180/551] Add transmission request flooding test --- node/bft/src/worker.rs | 71 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index 02755e65a6..37a106c836 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -770,6 +770,77 @@ mod tests { assert!(!worker.pending.contains(transmission_id)); assert!(!worker.ready.contains(transmission_id)); } + + #[tokio::test] + async fn test_flood_transmission_requests() { + let mut rng = &mut TestRng::default(); + // Sample a committee. + let committee = snarkvm::ledger::committee::test_helpers::sample_committee(rng); + let committee_clone = committee.clone(); + // Setup the mock gateway and ledger. + let mut gateway = MockGateway::default(); + gateway.expect_send().returning(|_, _| { + let (_tx, rx) = oneshot::channel(); + Some(rx) + }); + let mut mock_ledger = MockLedger::default(); + mock_ledger.expect_current_committee().returning(move || Ok(committee.clone())); + mock_ledger.expect_get_committee_lookback_for_round().returning(move |_| Ok(committee_clone.clone())); + mock_ledger.expect_contains_transmission().returning(|_| Ok(false)); + mock_ledger.expect_check_transaction_basic().returning(|_, _| Ok(())); + let ledger: Arc> = Arc::new(mock_ledger); + // Initialize the storage. + let storage = Storage::::new(ledger.clone(), Arc::new(BFTMemoryService::new()), 1); + + // Create the Worker. + let worker = Worker::new(0, Arc::new(gateway), storage, ledger, Default::default()).unwrap(); + let transaction_id: ::TransactionID = Field::::rand(&mut rng).into(); + let transmission_id = TransmissionID::Transaction(transaction_id); + let peer_ip = SocketAddr::from(([127, 0, 0, 1], 1234)); + + // Determine the number of redundant requests are sent. + let num_redundant_requests = max_redundant_requests(&worker.ledger, worker.storage.current_round()); + // Flood the pending queue with transmission requests. + for _ in 0..(num_redundant_requests * 10) { + let worker_ = worker.clone(); + tokio::spawn(async move { + let _ = worker_.send_transmission_request(peer_ip, transmission_id).await; + }); + // Check that the number of sent requests does not exceed the maximum number of redundant requests. + assert!(worker.pending.num_sent_requests(transmission_id) <= num_redundant_requests); + tokio::time::sleep(Duration::from_millis(10)).await; + } + // Check that the number of sent requests does not exceed the maximum number of redundant requests. + assert_eq!(worker.pending.num_sent_requests(transmission_id), num_redundant_requests); + + // Let all the requests expire. + tokio::time::sleep(Duration::from_millis(MAX_FETCH_TIMEOUT_IN_MS)).await; + assert_eq!(worker.pending.num_sent_requests(transmission_id), 0); + + // Flood the pending queue with transmission requests again. + for _ in 0..(num_redundant_requests * 10) { + let worker_ = worker.clone(); + tokio::spawn(async move { + let _ = worker_.send_transmission_request(peer_ip, transmission_id).await; + }); + assert!(worker.pending.num_sent_requests(transmission_id) <= num_redundant_requests); + tokio::time::sleep(Duration::from_millis(10)).await; + } + // Check that the number of sent requests does not exceed the maximum number of redundant requests. + assert_eq!(worker.pending.num_sent_requests(transmission_id), num_redundant_requests); + + // Check that fulfilling a transmission request clears the pending queue. + let result = worker + .process_unconfirmed_transaction( + transaction_id, + Data::Buffer(Bytes::from((0..512).map(|_| rng.gen::()).collect::>())), + ) + .await; + assert!(result.is_ok()); + assert_eq!(worker.pending.num_sent_requests(transmission_id), 0); + assert!(!worker.pending.contains(transmission_id)); + assert!(worker.ready.contains(transmission_id)); + } } #[cfg(test)] From 23f27379fd638624419de1cf39a934d0abf34b4e Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sat, 2 Mar 2024 18:32:46 -0800 Subject: [PATCH 181/551] Add more checks to flood test --- node/bft/src/worker.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index 37a106c836..606561b483 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -800,34 +800,40 @@ mod tests { // Determine the number of redundant requests are sent. let num_redundant_requests = max_redundant_requests(&worker.ledger, worker.storage.current_round()); + let num_flood_requests = num_redundant_requests * 10; // Flood the pending queue with transmission requests. - for _ in 0..(num_redundant_requests * 10) { + for i in 1..=num_flood_requests { let worker_ = worker.clone(); tokio::spawn(async move { let _ = worker_.send_transmission_request(peer_ip, transmission_id).await; }); + tokio::time::sleep(Duration::from_millis(10)).await; // Check that the number of sent requests does not exceed the maximum number of redundant requests. assert!(worker.pending.num_sent_requests(transmission_id) <= num_redundant_requests); - tokio::time::sleep(Duration::from_millis(10)).await; + assert_eq!(worker.pending.num_callbacks(transmission_id), i); } // Check that the number of sent requests does not exceed the maximum number of redundant requests. assert_eq!(worker.pending.num_sent_requests(transmission_id), num_redundant_requests); + assert_eq!(worker.pending.num_callbacks(transmission_id), num_flood_requests); // Let all the requests expire. - tokio::time::sleep(Duration::from_millis(MAX_FETCH_TIMEOUT_IN_MS)).await; + tokio::time::sleep(Duration::from_millis(MAX_FETCH_TIMEOUT_IN_MS + 1000)).await; assert_eq!(worker.pending.num_sent_requests(transmission_id), 0); + assert_eq!(worker.pending.num_callbacks(transmission_id), 0); // Flood the pending queue with transmission requests again. - for _ in 0..(num_redundant_requests * 10) { + for i in 1..=num_flood_requests { let worker_ = worker.clone(); tokio::spawn(async move { let _ = worker_.send_transmission_request(peer_ip, transmission_id).await; }); - assert!(worker.pending.num_sent_requests(transmission_id) <= num_redundant_requests); tokio::time::sleep(Duration::from_millis(10)).await; + assert!(worker.pending.num_sent_requests(transmission_id) <= num_redundant_requests); + assert_eq!(worker.pending.num_callbacks(transmission_id), i); } // Check that the number of sent requests does not exceed the maximum number of redundant requests. assert_eq!(worker.pending.num_sent_requests(transmission_id), num_redundant_requests); + assert_eq!(worker.pending.num_callbacks(transmission_id), num_flood_requests); // Check that fulfilling a transmission request clears the pending queue. let result = worker @@ -838,6 +844,7 @@ mod tests { .await; assert!(result.is_ok()); assert_eq!(worker.pending.num_sent_requests(transmission_id), 0); + assert_eq!(worker.pending.num_callbacks(transmission_id), 0); assert!(!worker.pending.contains(transmission_id)); assert!(worker.ready.contains(transmission_id)); } From eb18ebb77759af9c7dfe6ca8445e9690ddd9bf4b Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sat, 2 Mar 2024 18:38:17 -0800 Subject: [PATCH 182/551] Add additional resending and flooding tests --- node/bft/src/helpers/pending.rs | 2 +- node/bft/src/sync/mod.rs | 2 +- node/bft/src/worker.rs | 27 ++++- node/bft/tests/bft_e2e.rs | 2 + node/bft/tests/common/primary.rs | 6 +- node/bft/tests/components/mod.rs | 80 +++++++++++++++ node/bft/tests/components/pending.rs | 29 ++++++ node/bft/tests/components/worker.rs | 141 +++++++++++++++++++++++++++ 8 files changed, 282 insertions(+), 7 deletions(-) create mode 100644 node/bft/tests/components/mod.rs create mode 100644 node/bft/tests/components/pending.rs create mode 100644 node/bft/tests/components/worker.rs diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index a79f7213e2..4ea0d322b5 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -29,7 +29,7 @@ use tokio::sync::oneshot; const CALLBACK_TIMEOUT_IN_SECS: i64 = MAX_FETCH_TIMEOUT_IN_MS as i64 / 1000; /// Returns the maximum number of redundant requests for the number of validators in the specified round. -pub fn max_redundant_requests(ledger: &Arc>, round: u64) -> usize { +pub fn max_redundant_requests(ledger: Arc>, round: u64) -> usize { // Determine the number of validators in the committee lookback for the given round. let num_validators = ledger .get_committee_lookback_for_round(round) diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index 7d707534af..7499bbfbc6 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -413,7 +413,7 @@ impl Sync { // Determine how many sent requests are pending. let num_sent_requests = self.pending.num_sent_requests(certificate_id); // Determine the maximum number of redundant requests. - let num_redundant_requests = max_redundant_requests(&self.ledger, self.storage.current_round()); + let num_redundant_requests = max_redundant_requests(self.ledger.clone(), self.storage.current_round()); // Determine if we should send a certificate request to the peer. let should_send_request = num_sent_requests < num_redundant_requests; diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index 606561b483..6a9e88cfaa 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -90,6 +90,11 @@ impl Worker { pub const fn id(&self) -> u8 { self.id } + + /// Returns a reference to the pending transmissions queue. + pub fn pending(&self) -> &Arc, Transmission>> { + &self.pending + } } impl Worker { @@ -387,7 +392,7 @@ impl Worker { // Determine how many sent requests are pending. let num_sent_requests = self.pending.num_sent_requests(transmission_id); // Determine the maximum number of redundant requests. - let num_redundant_requests = max_redundant_requests(&self.ledger, self.storage.current_round()); + let num_redundant_requests = max_redundant_requests(self.ledger.clone(), self.storage.current_round()); // Determine if we should send a transmission request to the peer. let should_send_request = num_sent_requests < num_redundant_requests; @@ -539,6 +544,24 @@ mod tests { } } + #[tokio::test] + async fn test_max_redundant_requests() { + let rng = &mut TestRng::default(); + // Sample a committee. + let committee = snarkvm::ledger::committee::test_helpers::sample_committee_for_round_and_size(0, 100, rng); + let committee_clone = committee.clone(); + // Setup the mock ledger. + let mut mock_ledger = MockLedger::default(); + mock_ledger.expect_current_committee().returning(move || Ok(committee.clone())); + mock_ledger.expect_get_committee_lookback_for_round().returning(move |_| Ok(committee_clone.clone())); + mock_ledger.expect_contains_transmission().returning(|_| Ok(false)); + mock_ledger.expect_check_solution_basic().returning(|_, _| Ok(())); + let ledger: Arc> = Arc::new(mock_ledger); + + // Ensure the maximum number of redundant requests is correct and consistent across iterations. + assert_eq!(max_redundant_requests(ledger, 0), 34, "Update me if the formula changes"); + } + #[tokio::test] async fn test_process_transmission() { let rng = &mut TestRng::default(); @@ -799,7 +822,7 @@ mod tests { let peer_ip = SocketAddr::from(([127, 0, 0, 1], 1234)); // Determine the number of redundant requests are sent. - let num_redundant_requests = max_redundant_requests(&worker.ledger, worker.storage.current_round()); + let num_redundant_requests = max_redundant_requests(worker.ledger.clone(), worker.storage.current_round()); let num_flood_requests = num_redundant_requests * 10; // Flood the pending queue with transmission requests. for i in 1..=num_flood_requests { diff --git a/node/bft/tests/bft_e2e.rs b/node/bft/tests/bft_e2e.rs index cd2a442f52..22f2be82da 100644 --- a/node/bft/tests/bft_e2e.rs +++ b/node/bft/tests/bft_e2e.rs @@ -14,6 +14,8 @@ #[allow(dead_code)] mod common; +#[allow(dead_code)] +mod components; use crate::common::primary::{TestNetwork, TestNetworkConfig}; use deadline::deadline; diff --git a/node/bft/tests/common/primary.rs b/node/bft/tests/common/primary.rs index ef7eb91619..43b4ce8d38 100644 --- a/node/bft/tests/common/primary.rs +++ b/node/bft/tests/common/primary.rs @@ -324,7 +324,7 @@ impl TestNetwork { } // Initializes a new test committee. -fn new_test_committee(n: u16) -> (Vec>, Committee) { +pub fn new_test_committee(n: u16) -> (Vec>, Committee) { let mut accounts = Vec::with_capacity(n as usize); let mut members = IndexMap::with_capacity(n as usize); for i in 0..n { @@ -346,7 +346,7 @@ fn genesis_cache() -> &'static Mutex, Block>> { CACHE.get_or_init(|| Mutex::new(HashMap::new())) } -fn genesis_block( +pub fn genesis_block( genesis_private_key: PrivateKey, committee: Committee, public_balances: IndexMap, u64>, @@ -361,7 +361,7 @@ fn genesis_block( vm.genesis_quorum(&genesis_private_key, committee, public_balances, bonded_balances, rng).unwrap() } -fn genesis_ledger( +pub fn genesis_ledger( genesis_private_key: PrivateKey, committee: Committee, public_balances: IndexMap, u64>, diff --git a/node/bft/tests/components/mod.rs b/node/bft/tests/components/mod.rs new file mode 100644 index 0000000000..1a11df65a7 --- /dev/null +++ b/node/bft/tests/components/mod.rs @@ -0,0 +1,80 @@ +// Copyright (C) 2019-2023 Aleo Systems Inc. +// This file is part of the snarkOS library. + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// http://www.apache.org/licenses/LICENSE-2.0 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +pub mod pending; +pub mod worker; + +use crate::common::{primary, CurrentNetwork, TranslucentLedgerService}; +use snarkos_account::Account; +use snarkos_node_bft::{helpers::Storage, Gateway, Worker}; +use snarkos_node_bft_ledger_service::LedgerService; +use snarkos_node_bft_storage_service::BFTMemoryService; +use snarkvm::{ + console::{account::Address, network::Network}, + ledger::{narwhal::BatchHeader, store::helpers::memory::ConsensusMemory}, + prelude::TestRng, +}; + +use indexmap::IndexMap; +use parking_lot::RwLock; +use std::{str::FromStr, sync::Arc}; + +const ITERATIONS: u32 = 100; + +/// Samples a new ledger with the given number of nodes. +pub fn sample_ledger( + num_nodes: u16, + rng: &mut TestRng, +) -> Arc>> { + let (accounts, committee) = primary::new_test_committee(num_nodes); + let bonded_balances: IndexMap<_, _> = + committee.members().iter().map(|(address, (amount, _))| (*address, (*address, *amount))).collect(); + let gen_key = *accounts[0].private_key(); + let public_balance_per_validator = + (1_500_000_000_000_000 - (num_nodes as u64) * 1_000_000_000_000) / (num_nodes as u64); + let mut balances = IndexMap::, u64>::new(); + for account in accounts.iter() { + balances.insert(account.address(), public_balance_per_validator); + } + + let gen_ledger = + primary::genesis_ledger(gen_key, committee.clone(), balances.clone(), bonded_balances.clone(), rng); + Arc::new(TranslucentLedgerService::new(gen_ledger, Default::default())) +} + +/// Samples a new storage with the given ledger. +pub fn sample_storage(ledger: Arc>>) -> Storage { + Storage::new(ledger, Arc::new(BFTMemoryService::new()), BatchHeader::::MAX_GC_ROUNDS as u64) +} + +/// Samples a new gateway with the given ledger. +pub fn sample_gateway(ledger: Arc>>) -> Gateway { + let num_nodes: u16 = ledger.current_committee().unwrap().num_members().try_into().unwrap(); + let (accounts, _committee) = primary::new_test_committee(num_nodes); + let account = Account::from_str(&accounts[0].private_key().to_string()).unwrap(); + // Initialize the gateway. + Gateway::new(account, ledger, None, &[], None).unwrap() +} + +/// Samples a new worker with the given ledger. +pub fn sample_worker(id: u8, ledger: Arc>>) -> Worker { + // Sample a storage. + let storage = sample_storage(ledger.clone()); + // Sample a gateway. + let gateway = sample_gateway(ledger.clone()); + // Sample a dummy proposed batch. + let proposed_batch = Arc::new(RwLock::new(None)); + // Construct the worker instance. + Worker::new(id, Arc::new(gateway.clone()), storage.clone(), ledger, proposed_batch).unwrap() +} diff --git a/node/bft/tests/components/pending.rs b/node/bft/tests/components/pending.rs new file mode 100644 index 0000000000..b1405207d4 --- /dev/null +++ b/node/bft/tests/components/pending.rs @@ -0,0 +1,29 @@ +// Copyright (C) 2019-2023 Aleo Systems Inc. +// This file is part of the snarkOS library. + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// http://www.apache.org/licenses/LICENSE-2.0 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use crate::components::sample_ledger; +use snarkos_node_bft::helpers::max_redundant_requests; +use snarkvm::prelude::TestRng; + +#[test] +fn test_max_redundant_requests() { + const NUM_NODES: u16 = 100; + + // Initialize the RNG. + let rng = &mut TestRng::default(); + // Sample a ledger. + let ledger = sample_ledger(NUM_NODES, rng); + // Ensure the maximum number of redundant requests is correct and consistent across iterations. + assert_eq!(max_redundant_requests(ledger, 0), 34, "Update me if the formula changes"); +} diff --git a/node/bft/tests/components/worker.rs b/node/bft/tests/components/worker.rs new file mode 100644 index 0000000000..279bc1bf92 --- /dev/null +++ b/node/bft/tests/components/worker.rs @@ -0,0 +1,141 @@ +// Copyright (C) 2019-2023 Aleo Systems Inc. +// This file is part of the snarkOS library. + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// http://www.apache.org/licenses/LICENSE-2.0 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use crate::{ + common::CurrentNetwork, + components::{sample_ledger, sample_worker}, +}; +use snarkos_node_bft::helpers::max_redundant_requests; +use snarkvm::{ + ledger::narwhal::TransmissionID, + prelude::{Network, TestRng}, +}; + +use std::net::SocketAddr; + +#[tokio::test] +#[rustfmt::skip] +async fn test_resend_transmission_request() { + const NUM_NODES: u16 = 100; + + // Initialize the RNG. + let rng = &mut TestRng::default(); + // Sample a ledger. + let ledger = sample_ledger(NUM_NODES, rng); + // Sample a worker. + let worker = sample_worker(0, ledger.clone()); + + // Prepare a dummy transmission ID. + let peer_ip = SocketAddr::from(([127, 0, 0, 1], 1234)); + let transmission_id = TransmissionID::Transaction(::TransactionID::default()); + + // Ensure the worker does not have the dummy transmission ID. + assert!(!worker.contains_transmission(transmission_id), "Transmission should not exist"); + + // Send a request to fetch the dummy transmission. + let worker_ = worker.clone(); + tokio::spawn(async move { worker_.get_or_fetch_transmission(peer_ip, transmission_id).await }); + + tokio::time::sleep(std::time::Duration::from_millis(10)).await; + + let pending = worker.pending(); + // Ensure the transmission ID exists in the pending queue. + assert!(pending.contains(transmission_id), "Missing a transmission in the pending queue"); + // Ensure the peer IP is in the pending queue for the transmission ID. + assert!(pending.contains_peer(transmission_id, peer_ip), "Missing a peer IP for transmission in the pending queue"); + assert_eq!(pending.get(transmission_id), Some([peer_ip].into_iter().collect()), "Missing a peer IP for transmission in the pending queue"); + // Ensure the number of callbacks is correct. + assert_eq!(pending.num_callbacks(transmission_id), 1, "Incorrect number of callbacks for transmission"); + // Ensure the number of sent requests is correct. + assert_eq!(pending.num_sent_requests(transmission_id), 1, "Incorrect number of sent requests for transmission"); + + // Rebroadcast the same request to fetch the dummy transmission. + for i in 1..=10 { + let worker_ = worker.clone(); + tokio::spawn(async move { worker_.get_or_fetch_transmission(peer_ip, transmission_id).await }); + + tokio::time::sleep(std::time::Duration::from_millis(10)).await; + + // Ensure the transmission ID exists in the pending queue. + assert!(pending.contains(transmission_id), "Missing a transmission in the pending queue"); + // Ensure the peer IP is in the pending queue for the transmission ID. + assert!(pending.contains_peer(transmission_id, peer_ip), "Missing a peer IP for transmission in the pending queue"); + assert_eq!(pending.get(transmission_id), Some([peer_ip].into_iter().collect()), "Missing a peer IP for transmission in the pending queue"); + // Ensure the number of callbacks is correct. + assert_eq!(pending.num_callbacks(transmission_id), 1 + i, "Incorrect number of callbacks for transmission"); + // Ensure the number of sent requests is correct. + assert_eq!(pending.num_sent_requests(transmission_id), 1 + i, "Incorrect number of sent requests for transmission"); + } +} + +#[tokio::test] +#[rustfmt::skip] +async fn test_flood_transmission_requests() { + const NUM_NODES: u16 = 100; + + // Initialize the RNG. + let rng = &mut TestRng::default(); + // Sample a ledger. + let ledger = sample_ledger(NUM_NODES, rng); + // Sample a worker. + let worker = sample_worker(0, ledger.clone()); + + // Determine the maximum number of redundant requests. + let max_redundancy = max_redundant_requests(ledger.clone(), 0); + assert_eq!(max_redundancy, 34, "Update me if the formula changes"); + + // Prepare a dummy transmission ID. + let peer_ip = SocketAddr::from(([127, 0, 0, 1], 1234)); + let transmission_id = TransmissionID::Transaction(::TransactionID::default()); + + // Ensure the worker does not have the dummy transmission ID. + assert!(!worker.contains_transmission(transmission_id), "Transmission should not exist"); + + // Send the maximum number of redundant requests to fetch the dummy transmission. + for _ in 0..max_redundancy { + let worker_ = worker.clone(); + tokio::spawn(async move { worker_.get_or_fetch_transmission(peer_ip, transmission_id).await }); + } + + tokio::time::sleep(std::time::Duration::from_millis(10)).await; + + let pending = worker.pending(); + // Ensure the transmission ID exists in the pending queue. + assert!(pending.contains(transmission_id), "Missing a transmission in the pending queue"); + // Ensure the peer IP is in the pending queue for the transmission ID. + assert!(pending.contains_peer(transmission_id, peer_ip), "Missing a peer IP for transmission in the pending queue"); + assert_eq!(pending.get(transmission_id), Some([peer_ip].into_iter().collect()), "Missing a peer IP for transmission in the pending queue"); + // Ensure the number of callbacks is correct. + assert_eq!(pending.num_callbacks(transmission_id), max_redundancy, "Incorrect number of callbacks for transmission"); + // Ensure the number of sent requests is correct. + assert_eq!(pending.num_sent_requests(transmission_id), max_redundancy, "Incorrect number of sent requests for transmission"); + + // Ensure any further redundant requests are not sent. + for i in 1..=20 { + let worker_ = worker.clone(); + tokio::spawn(async move { worker_.get_or_fetch_transmission(peer_ip, transmission_id).await }); + + tokio::time::sleep(std::time::Duration::from_millis(10)).await; + + // Ensure the transmission ID exists in the pending queue. + assert!(pending.contains(transmission_id), "Missing a transmission in the pending queue"); + // Ensure the peer IP is in the pending queue for the transmission ID. + assert!(pending.contains_peer(transmission_id, peer_ip), "Missing a peer IP for transmission in the pending queue"); + assert_eq!(pending.get(transmission_id), Some([peer_ip].into_iter().collect()), "Missing a peer IP for transmission in the pending queue"); + // Ensure the number of callbacks is correct. + assert_eq!(pending.num_callbacks(transmission_id), max_redundancy + i, "Incorrect number of callbacks for transmission"); + // Ensure the number of sent requests is correct. + assert_eq!(pending.num_sent_requests(transmission_id), max_redundancy, "Incorrect number of sent requests for transmission"); + } +} From 274c1acd1c825edf4dd197847e0177c9e56b0614 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sat, 2 Mar 2024 18:44:07 -0800 Subject: [PATCH 183/551] nit log --- node/bft/src/sync/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index 7499bbfbc6..555bdb5a48 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -428,7 +428,7 @@ impl Sync { } } else { debug!( - "Skipped sending redundant request for certificate {} to '{peer_ip}' (Already pending {num_sent_requests} requests)", + "Skipped sending request for certificate {} to '{peer_ip}' ({num_sent_requests} redundant requests)", fmt_id(certificate_id) ); } From 2f3d1121d5e1ea202d8b3d5ad4a6a0c4357b490b Mon Sep 17 00:00:00 2001 From: Jos Dehaes Date: Mon, 4 Mar 2024 14:54:51 +0100 Subject: [PATCH 184/551] feat: more TPS metrics --- node/consensus/src/lib.rs | 17 +- node/metrics/snarkOS-grafana.json | 528 ++++++++++++++++++++++++++++-- node/metrics/src/names.rs | 12 +- 3 files changed, 527 insertions(+), 30 deletions(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index ea8d04d853..d590173f5b 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -212,6 +212,11 @@ impl Consensus { impl Consensus { /// Adds the given unconfirmed solution to the memory pool. pub async fn add_unconfirmed_solution(&self, solution: ProverSolution) -> Result<()> { + #[cfg(feature = "metrics")] + { + metrics::increment_gauge(metrics::consensus::SOLUTIONS, 1f64); + metrics::increment_gauge(metrics::consensus::TRANSMISSIONS, 1f64); + } // Process the unconfirmed solution. { let solution_id = solution.commitment(); @@ -265,6 +270,11 @@ impl Consensus { /// Adds the given unconfirmed transaction to the memory pool. pub async fn add_unconfirmed_transaction(&self, transaction: Transaction) -> Result<()> { + #[cfg(feature = "metrics")] + { + metrics::increment_gauge(metrics::consensus::TRANSACTIONS, 1f64); + metrics::increment_gauge(metrics::consensus::TRANSMISSIONS, 1f64); + } // Process the unconfirmed transaction. { let transaction_id = transaction.id(); @@ -405,9 +415,14 @@ impl Consensus { let elapsed = std::time::Duration::from_secs((snarkos_node_bft::helpers::now() - start) as u64); let next_block_timestamp = next_block.header().metadata().timestamp(); let block_latency = next_block_timestamp - current_block_timestamp; + let num_sol = next_block.solutions().len(); + let num_tx = next_block.transactions().len(); + let num_transmissions = num_tx + num_sol; metrics::gauge(metrics::blocks::HEIGHT, next_block.height() as f64); - metrics::increment_gauge(metrics::blocks::TRANSACTIONS, next_block.transactions().len() as f64); + metrics::increment_gauge(metrics::blocks::SOLUTIONS, num_sol as f64); + metrics::increment_gauge(metrics::blocks::TRANSACTIONS, num_tx as f64); + metrics::increment_gauge(metrics::blocks::TRANSMISSIONS, num_transmissions as f64); metrics::gauge(metrics::consensus::LAST_COMMITTED_ROUND, next_block.round() as f64); metrics::gauge(metrics::consensus::COMMITTED_CERTIFICATES, num_committed_certificates as f64); metrics::histogram(metrics::consensus::CERTIFICATE_COMMIT_LATENCY, elapsed.as_secs_f64()); diff --git a/node/metrics/snarkOS-grafana.json b/node/metrics/snarkOS-grafana.json index 25bd765970..03eeeacec4 100644 --- a/node/metrics/snarkOS-grafana.json +++ b/node/metrics/snarkOS-grafana.json @@ -564,10 +564,6 @@ { "color": "green", "value": null - }, - { - "color": "red", - "value": 80 } ] } @@ -614,6 +610,198 @@ "title": "Total Transactions", "type": "timeseries" }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "displayName": "Total Solutions", + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 25 + }, + "id": 41, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "snarkos_blocks_solutions_total", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "__auto", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Total Solutions", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "displayName": "Total Transmissions", + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 25 + }, + "id": 42, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "snarkos_blocks_transmissions_total", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "__auto", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Total Transmissions", + "type": "timeseries" + }, { "datasource": { "type": "prometheus", @@ -678,7 +866,7 @@ "h": 8, "w": 12, "x": 0, - "y": 25 + "y": 33 }, "id": 31, "options": { @@ -720,7 +908,7 @@ "h": 1, "w": 24, "x": 0, - "y": 33 + "y": 41 }, "id": 18, "panels": [], @@ -754,7 +942,7 @@ "h": 8, "w": 6, "x": 0, - "y": 34 + "y": 42 }, "id": 16, "options": { @@ -820,7 +1008,7 @@ "h": 8, "w": 6, "x": 6, - "y": 34 + "y": 42 }, "id": 25, "options": { @@ -882,7 +1070,7 @@ "h": 8, "w": 6, "x": 12, - "y": 34 + "y": 42 }, "id": 12, "options": { @@ -944,7 +1132,7 @@ "h": 8, "w": 6, "x": 18, - "y": 34 + "y": 42 }, "id": 24, "options": { @@ -996,10 +1184,6 @@ { "color": "green", "value": null - }, - { - "color": "red", - "value": 80 } ] } @@ -1010,7 +1194,7 @@ "h": 8, "w": 6, "x": 0, - "y": 42 + "y": 50 }, "id": 40, "options": { @@ -1056,7 +1240,7 @@ "h": 1, "w": 24, "x": 0, - "y": 50 + "y": 58 }, "id": 10, "panels": [], @@ -1128,7 +1312,7 @@ "h": 8, "w": 9, "x": 0, - "y": 51 + "y": 59 }, "id": 8, "options": { @@ -1252,7 +1436,7 @@ "h": 8, "w": 9, "x": 9, - "y": 51 + "y": 59 }, "id": 14, "options": { @@ -1289,6 +1473,294 @@ "title": "Commit Rounds Latency", "type": "timeseries" }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "displayName": "Total Transactions", + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 9, + "x": 0, + "y": 67 + }, + "id": 43, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "snarkos_consensus_transactions_total", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "__auto", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Total Transactions", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "displayName": "Total Solutions", + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 9, + "x": 9, + "y": 67 + }, + "id": 44, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "snarkos_consensus_solutions_total", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "__auto", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Total Solutions", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "displayName": "Total Transmissions", + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 9, + "x": 0, + "y": 75 + }, + "id": 45, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "snarkos_consensus_transmissions_total", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "__auto", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Total Transmissions", + "type": "timeseries" + }, { "datasource": { "type": "prometheus", @@ -1351,9 +1823,9 @@ }, "gridPos": { "h": 8, - "w": 12, - "x": 6, - "y": 59 + "w": 9, + "x": 9, + "y": 75 }, "id": 38, "options": { @@ -1395,7 +1867,7 @@ "h": 1, "w": 24, "x": 0, - "y": 67 + "y": 83 }, "id": 4, "panels": [], @@ -1466,7 +1938,7 @@ "h": 8, "w": 12, "x": 6, - "y": 68 + "y": 84 }, "id": 37, "options": { @@ -1567,7 +2039,7 @@ "h": 8, "w": 12, "x": 0, - "y": 76 + "y": 92 }, "id": 32, "options": { @@ -1668,7 +2140,7 @@ "h": 8, "w": 12, "x": 12, - "y": 76 + "y": 92 }, "id": 33, "options": { @@ -1772,7 +2244,7 @@ "h": 8, "w": 12, "x": 0, - "y": 84 + "y": 100 }, "id": 34, "options": { @@ -1873,7 +2345,7 @@ "h": 8, "w": 12, "x": 12, - "y": 84 + "y": 100 }, "id": 35, "options": { @@ -1941,6 +2413,6 @@ "timezone": "", "title": "snarkOS", "uid": "ahTJm4-4k", - "version": 2, + "version": 1, "weekStart": "" } \ No newline at end of file diff --git a/node/metrics/src/names.rs b/node/metrics/src/names.rs index bcf163a533..47fa0573ff 100644 --- a/node/metrics/src/names.rs +++ b/node/metrics/src/names.rs @@ -14,16 +14,21 @@ pub(super) const COUNTER_NAMES: [&str; 1] = [bft::LEADERS_ELECTED]; -pub(super) const GAUGE_NAMES: [&str; 13] = [ +pub(super) const GAUGE_NAMES: [&str; 18] = [ bft::CONNECTED, bft::CONNECTING, bft::LAST_STORED_ROUND, bft::PROPOSAL_ROUND, bft::CERTIFIED_BATCHES, blocks::HEIGHT, + blocks::SOLUTIONS, blocks::TRANSACTIONS, + blocks::TRANSMISSIONS, consensus::COMMITTED_CERTIFICATES, consensus::LAST_COMMITTED_ROUND, + consensus::SOLUTIONS, + consensus::TRANSACTIONS, + consensus::TRANSMISSIONS, router::CONNECTED, router::CANDIDATE, router::RESTRICTED, @@ -53,6 +58,8 @@ pub mod bft { pub mod blocks { pub const HEIGHT: &str = "snarkos_blocks_height_total"; pub const TRANSACTIONS: &str = "snarkos_blocks_transactions_total"; + pub const TRANSMISSIONS: &str = "snarkos_blocks_transmissions_total"; + pub const SOLUTIONS: &str = "snarkos_blocks_solutions_total"; } pub mod consensus { @@ -60,6 +67,9 @@ pub mod consensus { pub const COMMITTED_CERTIFICATES: &str = "snarkos_consensus_committed_certificates_total"; pub const LAST_COMMITTED_ROUND: &str = "snarkos_consensus_last_committed_round"; pub const BLOCK_LATENCY: &str = "snarkos_consensus_block_latency_secs"; + pub const TRANSACTIONS: &str = "snarkos_consensus_transactions_total"; + pub const TRANSMISSIONS: &str = "snarkos_consensus_transmissions_total"; + pub const SOLUTIONS: &str = "snarkos_consensus_solutions_total"; } pub mod router { From 8c3bfbafdfbf308bbdeb05892f3122294f5f4fdf Mon Sep 17 00:00:00 2001 From: Jos Dehaes Date: Mon, 4 Mar 2024 15:20:44 +0100 Subject: [PATCH 185/551] fix: review comments --- node/consensus/src/lib.rs | 8 ++++---- node/metrics/snarkOS-grafana.json | 12 ++++++------ node/metrics/src/names.rs | 12 ++++++------ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index d590173f5b..af0b568c01 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -214,8 +214,8 @@ impl Consensus { pub async fn add_unconfirmed_solution(&self, solution: ProverSolution) -> Result<()> { #[cfg(feature = "metrics")] { - metrics::increment_gauge(metrics::consensus::SOLUTIONS, 1f64); - metrics::increment_gauge(metrics::consensus::TRANSMISSIONS, 1f64); + metrics::increment_gauge(metrics::consensus::UNCONFIRMED_SOLUTIONS, 1f64); + metrics::increment_gauge(metrics::consensus::UNCONFIRMED_TRANSMISSIONS, 1f64); } // Process the unconfirmed solution. { @@ -272,8 +272,8 @@ impl Consensus { pub async fn add_unconfirmed_transaction(&self, transaction: Transaction) -> Result<()> { #[cfg(feature = "metrics")] { - metrics::increment_gauge(metrics::consensus::TRANSACTIONS, 1f64); - metrics::increment_gauge(metrics::consensus::TRANSMISSIONS, 1f64); + metrics::increment_gauge(metrics::consensus::UNCONFIRMED_TRANSACTIONS, 1f64); + metrics::increment_gauge(metrics::consensus::UNCONFIRMED_TRANSMISSIONS, 1f64); } // Process the unconfirmed transaction. { diff --git a/node/metrics/snarkOS-grafana.json b/node/metrics/snarkOS-grafana.json index 03eeeacec4..8e0a7cacfe 100644 --- a/node/metrics/snarkOS-grafana.json +++ b/node/metrics/snarkOS-grafana.json @@ -1556,7 +1556,7 @@ }, "disableTextWrap": false, "editorMode": "builder", - "expr": "snarkos_consensus_transactions_total", + "expr": "snarkos_consensus_unconfirmed_transactions_total", "fullMetaSearch": false, "includeNullMetadata": true, "instant": false, @@ -1566,7 +1566,7 @@ "useBackend": false } ], - "title": "Total Transactions", + "title": "Total Unconfirmed Transactions", "type": "timeseries" }, { @@ -1652,7 +1652,7 @@ }, "disableTextWrap": false, "editorMode": "builder", - "expr": "snarkos_consensus_solutions_total", + "expr": "snarkos_consensus_unconfirmed_solutions_total", "fullMetaSearch": false, "includeNullMetadata": true, "instant": false, @@ -1662,7 +1662,7 @@ "useBackend": false } ], - "title": "Total Solutions", + "title": "Total Unconfirmed Solutions", "type": "timeseries" }, { @@ -1748,7 +1748,7 @@ }, "disableTextWrap": false, "editorMode": "builder", - "expr": "snarkos_consensus_transmissions_total", + "expr": "snarkos_consensus_unconfirmed_transmissions_total", "fullMetaSearch": false, "includeNullMetadata": true, "instant": false, @@ -1758,7 +1758,7 @@ "useBackend": false } ], - "title": "Total Transmissions", + "title": "Total Unconfirmed Transmissions", "type": "timeseries" }, { diff --git a/node/metrics/src/names.rs b/node/metrics/src/names.rs index 47fa0573ff..7afcc59845 100644 --- a/node/metrics/src/names.rs +++ b/node/metrics/src/names.rs @@ -26,9 +26,9 @@ pub(super) const GAUGE_NAMES: [&str; 18] = [ blocks::TRANSMISSIONS, consensus::COMMITTED_CERTIFICATES, consensus::LAST_COMMITTED_ROUND, - consensus::SOLUTIONS, - consensus::TRANSACTIONS, - consensus::TRANSMISSIONS, + consensus::UNCONFIRMED_SOLUTIONS, + consensus::UNCONFIRMED_TRANSACTIONS, + consensus::UNCONFIRMED_TRANSMISSIONS, router::CONNECTED, router::CANDIDATE, router::RESTRICTED, @@ -67,9 +67,9 @@ pub mod consensus { pub const COMMITTED_CERTIFICATES: &str = "snarkos_consensus_committed_certificates_total"; pub const LAST_COMMITTED_ROUND: &str = "snarkos_consensus_last_committed_round"; pub const BLOCK_LATENCY: &str = "snarkos_consensus_block_latency_secs"; - pub const TRANSACTIONS: &str = "snarkos_consensus_transactions_total"; - pub const TRANSMISSIONS: &str = "snarkos_consensus_transmissions_total"; - pub const SOLUTIONS: &str = "snarkos_consensus_solutions_total"; + pub const UNCONFIRMED_TRANSACTIONS: &str = "snarkos_consensus_unconfirmed_transactions_total"; + pub const UNCONFIRMED_TRANSMISSIONS: &str = "snarkos_consensus_unconfirmed_transmissions_total"; + pub const UNCONFIRMED_SOLUTIONS: &str = "snarkos_consensus_unconfirmed_solutions_total"; } pub mod router { From 8f39e383c98742b40358a5bd8c90f8828b2109b7 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Mon, 4 Mar 2024 15:37:23 +0100 Subject: [PATCH 186/551] perf: process batch proposal transmissions using rayon Signed-off-by: ljedrz --- node/bft/src/primary.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index f5e5758b9a..6271d5582d 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -58,6 +58,7 @@ use colored::Colorize; use futures::stream::{FuturesUnordered, StreamExt}; use indexmap::{IndexMap, IndexSet}; use parking_lot::{Mutex, RwLock}; +use rayon::prelude::*; use std::{ collections::{HashMap, HashSet}, future::Future, @@ -572,12 +573,12 @@ impl Primary { let mut transmissions = self.sync_with_batch_header_from_peer(peer_ip, &batch_header).await?; // Check that the transmission ids match and are not fee transactions. - for (transmission_id, transmission) in transmissions.iter_mut() { + if let Err(err) = transmissions.par_iter_mut().try_for_each(|(transmission_id, transmission)| { // If the transmission is not well-formed, then return early. - if let Err(err) = self.ledger.ensure_transmission_is_well_formed(*transmission_id, transmission) { - debug!("Batch propose from '{peer_ip}' contains an invalid transmission - {err}",); - return Ok(()); - } + self.ledger.ensure_transmission_is_well_formed(*transmission_id, transmission) + }) { + debug!("Batch propose from '{peer_ip}' contains an invalid transmission - {err}",); + return Ok(()); } // Ensure the batch is for the current round. From dca89af8efc0e923e788bf03d239735166849534 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Mon, 4 Mar 2024 11:52:50 +0100 Subject: [PATCH 187/551] perf: use a blocking task to process transmission responses in the worker Signed-off-by: ljedrz --- node/bft/src/worker.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index 428f9e378f..7e6f886dda 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -15,6 +15,7 @@ use crate::{ events::{Event, TransmissionRequest, TransmissionResponse}, helpers::{fmt_id, max_redundant_requests, Pending, Ready, Storage, WorkerReceiver}, + spawn_blocking, ProposedBatch, Transport, MAX_FETCH_TIMEOUT_IN_MS, @@ -376,7 +377,11 @@ impl Worker { self.spawn(async move { while let Some((peer_ip, transmission_response)) = rx_transmission_response.recv().await { // Process the transmission response. - self_.finish_transmission_request(peer_ip, transmission_response); + let self__ = self_.clone(); + let _ = spawn_blocking!({ + self__.finish_transmission_request(peer_ip, transmission_response); + Ok(()) + }); } }); } From b1b348577e31a3089126e99b5b4e3ad046e84a48 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Mon, 4 Mar 2024 14:39:37 +0100 Subject: [PATCH 188/551] perf: use a blocking task in sync_ledger_with_block_without_bft Signed-off-by: ljedrz --- node/bft/src/sync/mod.rs | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index 153e6556b3..608e152417 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -325,17 +325,21 @@ impl Sync { // Acquire the sync lock. let _lock = self.sync_lock.lock().await; - // Check the next block. - self.ledger.check_next_block(&block)?; - // Attempt to advance to the next block. - self.ledger.advance_to_next_block(&block)?; - - // Sync the height with the block. - self.storage.sync_height_with_block(block.height()); - // Sync the round with the block. - self.storage.sync_round_with_block(block.round()); - - Ok(()) + let self_ = self.clone(); + tokio::task::spawn_blocking(move || { + // Check the next block. + self_.ledger.check_next_block(&block)?; + // Attempt to advance to the next block. + self_.ledger.advance_to_next_block(&block)?; + + // Sync the height with the block. + self_.storage.sync_height_with_block(block.height()); + // Sync the round with the block. + self_.storage.sync_round_with_block(block.round()); + + Ok(()) + }) + .await? } /// Syncs the storage with the given blocks. From 910784ed8d6952d8736010fbde086d13a4a294eb Mon Sep 17 00:00:00 2001 From: Haruka Date: Tue, 5 Mar 2024 02:53:45 +0900 Subject: [PATCH 189/551] Skip seen transactions and solutions instead of bailing --- node/router/src/inbound.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/node/router/src/inbound.rs b/node/router/src/inbound.rs index 3f29d28257..f57933fbea 100644 --- a/node/router/src/inbound.rs +++ b/node/router/src/inbound.rs @@ -210,7 +210,8 @@ pub trait Inbound: Reading + Outbound { let seen_before = self.router().cache.insert_inbound_solution(peer_ip, message.solution_id).is_some(); // Determine whether to propagate the solution. if seen_before { - bail!("Skipping 'UnconfirmedSolution' from '{peer_ip}'") + trace!("Skipping 'UnconfirmedSolution' from '{peer_ip}'"); + return Ok(()); } // Perform the deferred non-blocking deserialization of the solution. let solution = match message.solution.deserialize().await { @@ -235,7 +236,8 @@ pub trait Inbound: Reading + Outbound { self.router().cache.insert_inbound_transaction(peer_ip, message.transaction_id).is_some(); // Determine whether to propagate the transaction. if seen_before { - bail!("Skipping 'UnconfirmedTransaction' from '{peer_ip}'") + trace!("Skipping 'UnconfirmedTransaction' from '{peer_ip}'"); + return Ok(()); } // Perform the deferred non-blocking deserialization of the transaction. let transaction = match message.transaction.deserialize().await { From 3276178532e5013d2019da9db7c07d52a97c6a5f Mon Sep 17 00:00:00 2001 From: Jos Dehaes Date: Tue, 5 Mar 2024 09:52:11 +0100 Subject: [PATCH 190/551] feat: jemalloc by default on linux --- Cargo.toml | 6 ++---- snarkos/main.rs | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 76177a3d83..e8e3e82f87 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,7 +55,6 @@ name = "snarkos" path = "snarkos/main.rs" [features] -jemalloc = [ "tikv-jemallocator" ] metrics = [ "snarkos-node-metrics", "snarkos-node/metrics" ] [dependencies.anyhow] @@ -120,9 +119,8 @@ version = "=2.2.7" path = "./node/tcp" version = "=2.2.7" -[dependencies.tikv-jemallocator] -version = "0.5" -optional = true +[target.'cfg(target_os = "linux")'.dependencies] +tikv-jemallocator = "0.5" [dev-dependencies.rusty-hook] version = "0.11.2" diff --git a/snarkos/main.rs b/snarkos/main.rs index 64cef2f182..6ace71ef93 100644 --- a/snarkos/main.rs +++ b/snarkos/main.rs @@ -17,10 +17,10 @@ use snarkos_cli::{commands::CLI, helpers::Updater}; use clap::Parser; use std::process::exit; -#[cfg(feature = "jemalloc")] +#[cfg(target_os = "linux")] use tikv_jemallocator::Jemalloc; -#[cfg(feature = "jemalloc")] +#[cfg(target_os = "linux")] #[global_allocator] static GLOBAL: Jemalloc = Jemalloc; From b4a0a5fa97dd78e7a36d371a4e01d0e7e6db3854 Mon Sep 17 00:00:00 2001 From: Niklas Date: Tue, 5 Mar 2024 13:47:15 +0100 Subject: [PATCH 191/551] chore: remove unused noise codec And repurpose the proptest for the `EventCodec`. --- node/bft/events/src/helpers/codec.rs | 292 +-------------------------- 1 file changed, 7 insertions(+), 285 deletions(-) diff --git a/node/bft/events/src/helpers/codec.rs b/node/bft/events/src/helpers/codec.rs index 0d0c273d18..73b764c453 100644 --- a/node/bft/events/src/helpers/codec.rs +++ b/node/bft/events/src/helpers/codec.rs @@ -15,14 +15,8 @@ use crate::Event; use snarkvm::prelude::{FromBytes, Network, ToBytes}; -use bytes::{Buf, BufMut, Bytes, BytesMut}; +use bytes::{Buf, BufMut, BytesMut}; use core::marker::PhantomData; -use rayon::{ - iter::{IndexedParallelIterator, ParallelIterator}, - prelude::ParallelSlice, -}; -use snow::{HandshakeState, StatelessTransportState}; -use std::{io, sync::Arc}; use tokio_util::codec::{Decoder, Encoder, LengthDelimitedCodec}; use tracing::*; @@ -96,297 +90,25 @@ impl Decoder for EventCodec { } } -/* NOISE CODEC */ - -// The maximum message size for noise messages. If the data to be encrypted exceeds it, it is chunked. -const MAX_MESSAGE_LEN: usize = 65535; - -#[derive(Clone, Debug, PartialEq, Eq)] -pub enum EventOrBytes { - Bytes(Bytes), - Event(Event), -} - -impl ToBytes for EventOrBytes { - fn write_le(&self, mut writer: W) -> io::Result<()> { - match self { - Self::Bytes(bytes) => { - 0u8.write_le(&mut writer)?; - writer.write_all(bytes) - } - Self::Event(event) => { - 1u8.write_le(&mut writer)?; - event.write_le(writer) - } - } - } -} - -#[derive(Clone)] -pub struct PostHandshakeState { - state: Arc, - tx_nonce: u64, - rx_nonce: u64, -} - -pub enum NoiseState { - Handshake(Box), - PostHandshake(PostHandshakeState), - Failed, -} - -impl Clone for NoiseState { - fn clone(&self) -> Self { - match self { - Self::Handshake(..) => unreachable!(), - Self::PostHandshake(ph_state) => Self::PostHandshake(ph_state.clone()), - Self::Failed => unreachable!("Forbidden: cloning noise handshake"), - } - } -} - -impl NoiseState { - pub fn into_post_handshake_state(self) -> Self { - if let Self::Handshake(noise_state) = self { - match noise_state.into_stateless_transport_mode() { - Ok(new_state) => { - return Self::PostHandshake(PostHandshakeState { - state: Arc::new(new_state), - tx_nonce: 0, - rx_nonce: 0, - }); - } - Err(error) => { - warn!("Handshake not finished - {error}"); - } - } - } else { - warn!("Handshake in wrong state"); - } - - NoiseState::Failed - } -} - -pub struct NoiseCodec { - codec: LengthDelimitedCodec, - event_codec: EventCodec, - pub noise_state: NoiseState, -} - -impl NoiseCodec { - pub fn new(noise_state: NoiseState) -> Self { - Self { codec: LengthDelimitedCodec::new(), event_codec: EventCodec::default(), noise_state } - } -} - -impl Encoder> for NoiseCodec { - type Error = std::io::Error; - - fn encode(&mut self, message_or_bytes: EventOrBytes, dst: &mut BytesMut) -> Result<(), Self::Error> { - #[cfg(feature = "metrics")] - let start = std::time::Instant::now(); - - let ciphertext = match self.noise_state { - NoiseState::Handshake(ref mut noise) => { - match message_or_bytes { - // Don't allow message sending before the noise handshake has completed. - EventOrBytes::Event(_) => unimplemented!(), - EventOrBytes::Bytes(bytes) => { - let mut buffer = [0u8; MAX_MESSAGE_LEN]; - let len = noise - .write_message(&bytes, &mut buffer[..]) - .map_err(|e| Self::Error::new(io::ErrorKind::InvalidInput, e))?; - - #[cfg(feature = "metrics")] - metrics::histogram(metrics::tcp::NOISE_CODEC_ENCRYPTION_SIZE, len as f64); - - buffer[..len].into() - } - } - } - - NoiseState::PostHandshake(ref mut noise) => { - // Encode the message using the event codec. - let mut bytes = BytesMut::new(); - match message_or_bytes { - // Don't allow sending raw bytes after the noise handshake has completed. - EventOrBytes::Bytes(_) => panic!("Unsupported post-handshake"), - EventOrBytes::Event(event) => self.event_codec.encode(event, &mut bytes)?, - } - - #[cfg(feature = "metrics")] - metrics::histogram(metrics::tcp::NOISE_CODEC_ENCRYPTION_SIZE, bytes.len() as f64); - - // Chunk the payload if necessary and encrypt with Noise. - // - // A Noise transport message is simply an AEAD ciphertext that is less than or - // equal to 65535 bytes in length, and that consists of an encrypted payload plus - // 16 bytes of authentication data. - // - // See: https://noiseprotocol.org/noise.html#the-handshakestate-object - const TAG_LEN: usize = 16; - let encrypted_chunks = bytes - .par_chunks(MAX_MESSAGE_LEN - TAG_LEN) - .enumerate() - .map(|(nonce_offset, plaintext_chunk)| { - let mut buffer = vec![0u8; MAX_MESSAGE_LEN]; - let len = noise - .state - .write_message(noise.tx_nonce + nonce_offset as u64, plaintext_chunk, &mut buffer) - .map_err(|e| Self::Error::new(io::ErrorKind::InvalidInput, e))?; - - buffer.truncate(len); - - Ok(buffer) - }) - .collect::>>>()?; - - let mut buffer = BytesMut::with_capacity(encrypted_chunks.len()); - for chunk in encrypted_chunks { - buffer.extend_from_slice(&chunk); - noise.tx_nonce += 1; - } - - buffer - } - - NoiseState::Failed => unreachable!("Noise handshake failed to encode"), - }; - - // Encode the resulting ciphertext using the length-delimited codec. - #[allow(clippy::let_and_return)] - let result = self.codec.encode(ciphertext.freeze(), dst); - - #[cfg(feature = "metrics")] - metrics::histogram(metrics::tcp::NOISE_CODEC_ENCRYPTION_TIME, start.elapsed().as_micros() as f64); - result - } -} - -impl Decoder for NoiseCodec { - type Error = io::Error; - type Item = EventOrBytes; - - fn decode(&mut self, src: &mut BytesMut) -> Result, Self::Error> { - #[cfg(feature = "metrics")] - metrics::histogram(metrics::tcp::NOISE_CODEC_DECRYPTION_SIZE, src.len() as f64); - #[cfg(feature = "metrics")] - let start = std::time::Instant::now(); - - // Decode the ciphertext with the length-delimited codec. - let Some(bytes) = self.codec.decode(src)? else { - return Ok(None); - }; - - let msg = match self.noise_state { - NoiseState::Handshake(ref mut noise) => { - // Decrypt the ciphertext in handshake mode. - let mut buffer = [0u8; MAX_MESSAGE_LEN]; - let len = noise.read_message(&bytes, &mut buffer).map_err(|_| io::ErrorKind::InvalidData)?; - - Some(EventOrBytes::Bytes(Bytes::copy_from_slice(&buffer[..len]))) - } - - NoiseState::PostHandshake(ref mut noise) => { - // Noise decryption. - let decrypted_chunks = bytes - .par_chunks(MAX_MESSAGE_LEN) - .enumerate() - .map(|(nonce_offset, encrypted_chunk)| { - let mut buffer = vec![0u8; MAX_MESSAGE_LEN]; - - // Decrypt the ciphertext in post-handshake mode. - let len = noise - .state - .read_message(noise.rx_nonce + nonce_offset as u64, encrypted_chunk, &mut buffer) - .map_err(|_| io::ErrorKind::InvalidData)?; - - buffer.truncate(len); - Ok(buffer) - }) - .collect::>>>()?; - - // Collect chunks into plaintext to be passed to the message codecs. - let mut plaintext = BytesMut::new(); - for chunk in decrypted_chunks { - plaintext.extend_from_slice(&chunk); - noise.rx_nonce += 1; - } - - // Decode with message codecs. - self.event_codec.decode(&mut plaintext)?.map(|msg| EventOrBytes::Event(msg)) - } - - NoiseState::Failed => unreachable!("Noise handshake failed to decode"), - }; - - #[cfg(feature = "metrics")] - metrics::histogram(metrics::tcp::NOISE_CODEC_DECRYPTION_TIME, start.elapsed().as_micros() as f64); - Ok(msg) - } -} - #[cfg(test)] mod tests { use super::*; use crate::prop_tests::any_event; - - use snow::{params::NoiseParams, Builder}; use test_strategy::proptest; type CurrentNetwork = snarkvm::prelude::MainnetV0; - fn handshake_xx() -> (NoiseCodec, NoiseCodec) { - let params: NoiseParams = NOISE_HANDSHAKE_TYPE.parse().unwrap(); - let initiator_builder = Builder::new(params.clone()); - let initiator_kp = initiator_builder.generate_keypair().unwrap(); - let initiator = initiator_builder.local_private_key(&initiator_kp.private).build_initiator().unwrap(); - - let responder_builder = Builder::new(params); - let responder_kp = responder_builder.generate_keypair().unwrap(); - let responder = responder_builder.local_private_key(&responder_kp.private).build_responder().unwrap(); - - let mut initiator_codec = NoiseCodec::new(NoiseState::Handshake(Box::new(initiator))); - let mut responder_codec = NoiseCodec::new(NoiseState::Handshake(Box::new(responder))); - - let mut ciphertext = BytesMut::new(); - - // -> e - assert!(initiator_codec.encode(EventOrBytes::Bytes(Bytes::new()), &mut ciphertext).is_ok()); - assert!( - matches!(responder_codec.decode(&mut ciphertext).unwrap().unwrap(), EventOrBytes::Bytes(bytes) if bytes.is_empty()) - ); - - // <- e, ee, s, es - assert!(responder_codec.encode(EventOrBytes::Bytes(Bytes::new()), &mut ciphertext).is_ok()); - assert!( - matches!(initiator_codec.decode(&mut ciphertext).unwrap().unwrap(), EventOrBytes::Bytes(bytes) if bytes.is_empty()) - ); - - // -> s, se - assert!(initiator_codec.encode(EventOrBytes::Bytes(Bytes::new()), &mut ciphertext).is_ok()); - assert!( - matches!(responder_codec.decode(&mut ciphertext).unwrap().unwrap(), EventOrBytes::Bytes(bytes) if bytes.is_empty()) - ); - - initiator_codec.noise_state = initiator_codec.noise_state.into_post_handshake_state(); - responder_codec.noise_state = responder_codec.noise_state.into_post_handshake_state(); - - (initiator_codec, responder_codec) - } - - fn assert_roundtrip(msg: EventOrBytes) { - let (mut initiator_codec, mut responder_codec) = handshake_xx(); - let mut ciphertext = BytesMut::new(); + fn assert_roundtrip(msg: Event) { + let mut codec: EventCodec = Default::default(); + let mut encoded_event = BytesMut::new(); - assert!(initiator_codec.encode(msg.clone(), &mut ciphertext).is_ok()); - let decoded = responder_codec.decode(&mut ciphertext).unwrap().unwrap(); + assert!(codec.encode(msg.clone(), &mut encoded_event).is_ok()); + let decoded = codec.decode(&mut encoded_event).unwrap().unwrap(); assert_eq!(decoded.to_bytes_le().unwrap(), msg.to_bytes_le().unwrap()); } #[proptest] fn event_roundtrip(#[strategy(any_event())] event: Event) { - assert_roundtrip(EventOrBytes::Event(event)) + assert_roundtrip(event) } } From 077b0022e3d83e61014ec2a0f097a87d8aa856ce Mon Sep 17 00:00:00 2001 From: Niklas Date: Tue, 5 Mar 2024 15:14:17 +0100 Subject: [PATCH 192/551] deps: remove `snow` --- Cargo.lock | 196 -------------------------------- node/bft/Cargo.toml | 3 - node/bft/events/Cargo.toml | 3 - node/router/messages/Cargo.toml | 3 - 4 files changed, 205 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 08bcb0824d..9d7edd0403 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,41 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "aead" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" -dependencies = [ - "crypto-common", - "generic-array", -] - -[[package]] -name = "aes" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" -dependencies = [ - "cfg-if", - "cipher", - "cpufeatures", -] - -[[package]] -name = "aes-gcm" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1" -dependencies = [ - "aead", - "aes", - "cipher", - "ctr", - "ghash", - "subtle", -] - [[package]] name = "ahash" version = "0.8.7" @@ -545,30 +510,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "chacha20" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" -dependencies = [ - "cfg-if", - "cipher", - "cpufeatures", -] - -[[package]] -name = "chacha20poly1305" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35" -dependencies = [ - "aead", - "chacha20", - "cipher", - "poly1305", - "zeroize", -] - [[package]] name = "chrono" version = "0.4.34" @@ -590,17 +531,6 @@ dependencies = [ "envmnt", ] -[[package]] -name = "cipher" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" -dependencies = [ - "crypto-common", - "inout", - "zeroize", -] - [[package]] name = "clang-sys" version = "1.7.0" @@ -784,19 +714,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array", - "rand_core", "typenum", ] -[[package]] -name = "ctr" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" -dependencies = [ - "cipher", -] - [[package]] name = "curl" version = "0.4.46" @@ -827,33 +747,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "curve25519-dalek" -version = "4.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a677b8922c94e01bdbb12126b0bc852f00447528dee1782229af9c720c3f348" -dependencies = [ - "cfg-if", - "cpufeatures", - "curve25519-dalek-derive", - "fiat-crypto", - "platforms", - "rustc_version", - "subtle", - "zeroize", -] - -[[package]] -name = "curve25519-dalek-derive" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" -dependencies = [ - "proc-macro2", - "quote 1.0.35", - "syn 2.0.48", -] - [[package]] name = "dashmap" version = "5.5.3" @@ -1006,12 +899,6 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" -[[package]] -name = "fiat-crypto" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1676f435fc1dadde4d03e43f5d62b259e1ce5f40bd4ffb21db2b42ebe59c1382" - [[package]] name = "flate2" version = "1.0.28" @@ -1211,16 +1098,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "ghash" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d930750de5717d2dd0b8c0d42c076c0e884c81a73e6cab859bbd2339c71e3e40" -dependencies = [ - "opaque-debug", - "polyval", -] - [[package]] name = "gimli" version = "0.28.1" @@ -1590,15 +1467,6 @@ version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8" -[[package]] -name = "inout" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" -dependencies = [ - "generic-array", -] - [[package]] name = "instant" version = "0.1.12" @@ -2137,12 +2005,6 @@ dependencies = [ "parking_lot_core", ] -[[package]] -name = "opaque-debug" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" - [[package]] name = "open" version = "5.0.1" @@ -2321,35 +2183,6 @@ version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb" -[[package]] -name = "platforms" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "626dec3cac7cc0e1577a2ec3fc496277ec2baa084bebad95bb6fdbfae235f84c" - -[[package]] -name = "poly1305" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" -dependencies = [ - "cpufeatures", - "opaque-debug", - "universal-hash", -] - -[[package]] -name = "polyval" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52cff9d1d4dee5fe6d03729099f4a310a41179e0a10dbf542039873f2e826fb" -dependencies = [ - "cfg-if", - "cpufeatures", - "opaque-debug", - "universal-hash", -] - [[package]] name = "portable-atomic" version = "1.6.0" @@ -3271,7 +3104,6 @@ dependencies = [ "snarkos-node-sync", "snarkos-node-tcp", "snarkvm", - "snow", "test-strategy", "time", "tokio", @@ -3296,7 +3128,6 @@ dependencies = [ "snarkos-node-metrics", "snarkos-node-sync-locators", "snarkvm", - "snow", "test-strategy", "time", "tokio-util", @@ -3455,7 +3286,6 @@ dependencies = [ "snarkos-node-bft-events", "snarkos-node-sync-locators", "snarkvm", - "snow", "test-strategy", "tokio", "tokio-util", @@ -4367,22 +4197,6 @@ dependencies = [ "syn 2.0.48", ] -[[package]] -name = "snow" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "850948bee068e713b8ab860fe1adc4d109676ab4c3b621fd8147f06b261f2f85" -dependencies = [ - "aes-gcm", - "blake2", - "chacha20poly1305", - "curve25519-dalek", - "rand_core", - "rustc_version", - "sha2", - "subtle", -] - [[package]] name = "socket2" version = "0.5.5" @@ -5053,16 +4867,6 @@ version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" -[[package]] -name = "universal-hash" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" -dependencies = [ - "crypto-common", - "subtle", -] - [[package]] name = "untrusted" version = "0.9.0" diff --git a/node/bft/Cargo.toml b/node/bft/Cargo.toml index 300e6adb21..86f15dd7e3 100644 --- a/node/bft/Cargo.toml +++ b/node/bft/Cargo.toml @@ -97,9 +97,6 @@ version = "=2.2.7" [dependencies.snarkvm] workspace = true -[dependencies.snow] -version = "0.9" - [dependencies.time] version = "0.3" diff --git a/node/bft/events/Cargo.toml b/node/bft/events/Cargo.toml index afb195706b..1dc1de94cb 100644 --- a/node/bft/events/Cargo.toml +++ b/node/bft/events/Cargo.toml @@ -49,9 +49,6 @@ version = "=2.2.7" [dependencies.snarkvm] workspace = true -[dependencies.snow] -version = "0.9" - [dependencies.tokio-util] version = "0.7" features = [ "codec" ] diff --git a/node/router/messages/Cargo.toml b/node/router/messages/Cargo.toml index 503ef8c1f6..22999d4294 100644 --- a/node/router/messages/Cargo.toml +++ b/node/router/messages/Cargo.toml @@ -47,9 +47,6 @@ version = "=2.2.7" [dependencies.snarkvm] workspace = true -[dependencies.snow] -version = "0.9.6" - [dependencies.tokio] version = "1.28" features = [ From f0c1ab81f6f32e621ac7a4da2dd6d38790fa900a Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Tue, 5 Mar 2024 14:38:30 -0800 Subject: [PATCH 193/551] Adds devnet script to fetch log files --- .devnet/fetch-logs.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 .devnet/fetch-logs.sh diff --git a/.devnet/fetch-logs.sh b/.devnet/fetch-logs.sh new file mode 100755 index 0000000000..aa518e584f --- /dev/null +++ b/.devnet/fetch-logs.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# Determine the number of AWS EC2 instances by checking ~/.ssh/config +NODE_ID=0 +while [ -n "$(grep "aws-n${NODE_ID}" ~/.ssh/config)" ]; do + NODE_ID=$((NODE_ID + 1)) +done + +# Read the number of AWS EC2 instances to query from the user +read -p "Enter the number of AWS EC2 instances to query (default: $NODE_ID): " NUM_INSTANCES +NUM_INSTANCES="${NUM_INSTANCES:-$NODE_ID}" + +echo "Using $NUM_INSTANCES AWS EC2 instances for querying." + +# Define the directory where logs will be saved +log_directory="$HOME/snarkos_logs" + +# Create the log directory if it doesn't already exist +mkdir -p "$log_directory" + +# Loop from 0 to 49 +for i in $(seq 0 $(($NUM_INSTANCES - 1))); do + echo "Connecting to aws-n$i..." + # Use sftp to connect, execute commands, and exit + sftp aws-n$i << EOF +cd /tmp +get snarkos.log "$log_directory/snarkos-$i.log" +EOF + echo "Downloaded snarkos.log from aws-n$i as snarkos-$i.log into $log_directory" +done + +echo "All files have been downloaded to $log_directory." From f033e7fe3b1003888ea38a09bd35bb1bab463045 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 5 Mar 2024 16:25:43 -0800 Subject: [PATCH 194/551] Update sync_bft_dag_at_bootup to commit all provided certs --- node/bft/src/bft.rs | 51 +++++++++++---------------------------------- 1 file changed, 12 insertions(+), 39 deletions(-) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 7667863b0b..fc0a63d997 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -789,51 +789,24 @@ impl BFT { }); } - /// Syncs the BFT DAG with the given leader certificates and batch certificates. + /// Syncs the BFT DAG with the given batch certificates. These batch certificates **must** + /// already exist in the ledger. /// - /// This method starts by inserting all certificates (except the latest leader certificate) - /// into the DAG. Then, it commits all leader certificates (except the latest leader certificate). - /// Finally, it updates the DAG with the latest leader certificate. + /// This method commits all the certificates into the dag. + /// Note that there is no need to insert the certificates into the DAG, because these certificates + /// already exist in the ledger and therefor do not need to be re-ordered into future + /// committed subdags. async fn sync_bft_dag_at_bootup( &self, - leader_certificates: Vec>, + _leader_certificates: Vec>, certificates: Vec>, ) { - // Split the leader certificates into past leader certificates and the latest leader certificate. - let (past_leader_certificates, leader_certificate) = { - // Compute the penultimate index. - let index = leader_certificates.len().saturating_sub(1); - // Split the leader certificates. - let (past, latest) = leader_certificates.split_at(index); - debug_assert!(latest.len() == 1, "There should only be one latest leader certificate"); - // Retrieve the latest leader certificate. - match latest.first() { - Some(leader_certificate) => (past, leader_certificate.clone()), - // If there is no latest leader certificate, return early. - None => return, - } - }; - { - // Acquire the BFT write lock. - let mut dag = self.dag.write(); - // Iterate over the certificates. - for certificate in certificates { - // If the certificate is not the latest leader certificate, insert it. - if leader_certificate.id() != certificate.id() { - // Insert the certificate into the DAG. - dag.insert(certificate); - } - } + // Acquire the BFT write lock. + let mut dag = self.dag.write(); - // Iterate over the leader certificates. - for leader_certificate in past_leader_certificates { - // Commit the leader certificate. - dag.commit(leader_certificate, self.storage().max_gc_rounds()); - } - } - // Commit the latest leader certificate. - if let Err(e) = self.commit_leader_certificate::(leader_certificate).await { - error!("BFT failed to update the DAG with the latest leader certificate - {e}"); + // Commit all the certificates excluding the latest leader certificate. + for certificate in certificates { + dag.commit(&certificate, self.storage().max_gc_rounds()); } } From 33399cc97a5bf26329d0e629c35ef9a190dae3e1 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 5 Mar 2024 16:28:07 -0800 Subject: [PATCH 195/551] Skip ordering certs if it exists in the ledger --- node/bft/src/bft.rs | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index fc0a63d997..a73c75ef23 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -665,6 +665,11 @@ impl BFT { if self.dag.read().is_recently_committed(previous_round, *previous_certificate_id) { continue; } + // If the previous certificate already exists in the ledger, continue. + if ALLOW_LEDGER_ACCESS && self.ledger().contains_certificate(previous_certificate_id).unwrap_or(false) { + continue; + } + // Retrieve the previous certificate. let previous_certificate = { // Start by retrieving the previous certificate from the DAG. @@ -675,28 +680,11 @@ impl BFT { None => match self.storage().get_certificate(*previous_certificate_id) { // If the previous certificate is found, return it. Some(previous_certificate) => previous_certificate, - // Otherwise, retrieve the previous certificate from the ledger. - None => { - if ALLOW_LEDGER_ACCESS { - match self.ledger().get_batch_certificate(previous_certificate_id) { - // If the previous certificate is found, return it. - Ok(previous_certificate) => previous_certificate, - // Otherwise, the previous certificate is missing, and throw an error. - Err(e) => { - bail!( - "Missing previous certificate {} for round {previous_round} - {e}", - fmt_id(previous_certificate_id) - ) - } - } - } else { - // Otherwise, the previous certificate is missing, and throw an error. - bail!( - "Missing previous certificate {} for round {previous_round}", - fmt_id(previous_certificate_id) - ) - } - } + // Otherwise, the previous certificate is missing, and throw an error. + None => bail!( + "Missing previous certificate {} for round {previous_round}", + fmt_id(previous_certificate_id) + ), }, } }; From 690323e6f0e5adcc32c5ba95155bce1d7966ceee Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 5 Mar 2024 16:31:07 -0800 Subject: [PATCH 196/551] Remove unused leader_certificates in channel --- node/bft/src/bft.rs | 10 +++------- node/bft/src/helpers/channels.rs | 4 ++-- node/bft/src/sync/mod.rs | 20 ++------------------ 3 files changed, 7 insertions(+), 27 deletions(-) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index a73c75ef23..531fc6f10e 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -759,8 +759,8 @@ impl BFT { // Process the request to sync the BFT DAG at bootup. let self_ = self.clone(); self.spawn(async move { - while let Some((leader_certificates, certificates)) = rx_sync_bft_dag_at_bootup.recv().await { - self_.sync_bft_dag_at_bootup(leader_certificates, certificates).await; + while let Some(certificates) = rx_sync_bft_dag_at_bootup.recv().await { + self_.sync_bft_dag_at_bootup(certificates).await; } }); @@ -784,11 +784,7 @@ impl BFT { /// Note that there is no need to insert the certificates into the DAG, because these certificates /// already exist in the ledger and therefor do not need to be re-ordered into future /// committed subdags. - async fn sync_bft_dag_at_bootup( - &self, - _leader_certificates: Vec>, - certificates: Vec>, - ) { + async fn sync_bft_dag_at_bootup(&self, certificates: Vec>) { // Acquire the BFT write lock. let mut dag = self.dag.write(); diff --git a/node/bft/src/helpers/channels.rs b/node/bft/src/helpers/channels.rs index 8981883522..932c123530 100644 --- a/node/bft/src/helpers/channels.rs +++ b/node/bft/src/helpers/channels.rs @@ -63,7 +63,7 @@ pub fn init_consensus_channels() -> (ConsensusSender, ConsensusRe pub struct BFTSender { pub tx_primary_round: mpsc::Sender<(u64, oneshot::Sender)>, pub tx_primary_certificate: mpsc::Sender<(BatchCertificate, oneshot::Sender>)>, - pub tx_sync_bft_dag_at_bootup: mpsc::Sender<(Vec>, Vec>)>, + pub tx_sync_bft_dag_at_bootup: mpsc::Sender>>, pub tx_sync_bft: mpsc::Sender<(BatchCertificate, oneshot::Sender>)>, } @@ -103,7 +103,7 @@ impl BFTSender { pub struct BFTReceiver { pub rx_primary_round: mpsc::Receiver<(u64, oneshot::Sender)>, pub rx_primary_certificate: mpsc::Receiver<(BatchCertificate, oneshot::Sender>)>, - pub rx_sync_bft_dag_at_bootup: mpsc::Receiver<(Vec>, Vec>)>, + pub rx_sync_bft_dag_at_bootup: mpsc::Receiver>>, pub rx_sync_bft: mpsc::Receiver<(BatchCertificate, oneshot::Sender>)>, } diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index 153e6556b3..753e62cbb2 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -236,22 +236,6 @@ impl Sync { /* Sync the BFT DAG */ - // Retrieve the leader certificates. - let leader_certificates = blocks - .iter() - .flat_map(|block| { - match block.authority() { - // If the block authority is a beacon, then skip the block. - Authority::Beacon(_) => None, - // If the block authority is a subdag, then retrieve the certificates. - Authority::Quorum(subdag) => Some(subdag.leader_certificate().clone()), - } - }) - .collect::>(); - if leader_certificates.is_empty() { - return Ok(()); - } - // Construct a list of the certificates. let certificates = blocks .iter() @@ -266,10 +250,10 @@ impl Sync { .flatten() .collect::>(); - // If a BFT sender was provided, send the certificate to the BFT. + // If a BFT sender was provided, send the certificates to the BFT. if let Some(bft_sender) = self.bft_sender.get() { // Await the callback to continue. - if let Err(e) = bft_sender.tx_sync_bft_dag_at_bootup.send((leader_certificates, certificates)).await { + if let Err(e) = bft_sender.tx_sync_bft_dag_at_bootup.send(certificates).await { bail!("Failed to update the BFT DAG from sync: {e}"); } } From 04b0407cddc75a0f6186ac4fc45b30cc3a2b9b90 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 5 Mar 2024 16:35:16 -0800 Subject: [PATCH 197/551] Remove unused IS_SYNCING const generic --- node/bft/src/bft.rs | 98 +++++++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 53 deletions(-) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 531fc6f10e..80af3a1270 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -487,11 +487,11 @@ impl BFT { info!("Proceeding to commit round {commit_round} with leader '{}'", fmt_id(leader)); // Commit the leader certificate, and all previous leader certificates since the last committed round. - self.commit_leader_certificate::(leader_certificate).await + self.commit_leader_certificate::(leader_certificate).await } /// Commits the leader certificate, and all previous leader certificates since the last committed round. - async fn commit_leader_certificate( + async fn commit_leader_certificate( &self, leader_certificate: BatchCertificate, ) -> Result<()> { @@ -549,10 +549,6 @@ impl BFT { let mut transmissions = IndexMap::new(); // Start from the oldest leader certificate. for certificate in commit_subdag.values().flatten() { - // Update the DAG. - if IS_SYNCING { - self.dag.write().commit(certificate, self.storage().max_gc_rounds()); - } // Retrieve the transmissions. for transmission_id in certificate.transmission_ids() { // If the transmission already exists in the map, skip it. @@ -576,58 +572,54 @@ impl BFT { transmissions.insert(*transmission_id, transmission); } } - // If the node is not syncing, trigger consensus, as this will build a new block for the ledger. - if !IS_SYNCING { - // Construct the subdag. - let subdag = Subdag::from(commit_subdag.clone())?; - // Retrieve the anchor round. - let anchor_round = subdag.anchor_round(); - // Retrieve the number of transmissions. - let num_transmissions = transmissions.len(); - // Retrieve metadata about the subdag. - let subdag_metadata = subdag.iter().map(|(round, c)| (*round, c.len())).collect::>(); - - // Ensure the subdag anchor round matches the leader round. - ensure!( - anchor_round == leader_round, - "BFT failed to commit - the subdag anchor round {anchor_round} does not match the leader round {leader_round}", - ); - - // Trigger consensus. - if let Some(consensus_sender) = self.consensus_sender.get() { - // Initialize a callback sender and receiver. - let (callback_sender, callback_receiver) = oneshot::channel(); - // Send the subdag and transmissions to consensus. - consensus_sender.tx_consensus_subdag.send((subdag, transmissions, callback_sender)).await?; - // Await the callback to continue. - match callback_receiver.await { - Ok(Ok(())) => (), // continue - Ok(Err(e)) => { - error!("BFT failed to advance the subdag for round {anchor_round} - {e}"); - return Ok(()); - } - Err(e) => { - error!("BFT failed to receive the callback for round {anchor_round} - {e}"); - return Ok(()); - } + // Trigger consensus, as this will build a new block for the ledger. + // Construct the subdag. + let subdag = Subdag::from(commit_subdag.clone())?; + // Retrieve the anchor round. + let anchor_round = subdag.anchor_round(); + // Retrieve the number of transmissions. + let num_transmissions = transmissions.len(); + // Retrieve metadata about the subdag. + let subdag_metadata = subdag.iter().map(|(round, c)| (*round, c.len())).collect::>(); + + // Ensure the subdag anchor round matches the leader round. + ensure!( + anchor_round == leader_round, + "BFT failed to commit - the subdag anchor round {anchor_round} does not match the leader round {leader_round}", + ); + + // Trigger consensus. + if let Some(consensus_sender) = self.consensus_sender.get() { + // Initialize a callback sender and receiver. + let (callback_sender, callback_receiver) = oneshot::channel(); + // Send the subdag and transmissions to consensus. + consensus_sender.tx_consensus_subdag.send((subdag, transmissions, callback_sender)).await?; + // Await the callback to continue. + match callback_receiver.await { + Ok(Ok(())) => (), // continue + Ok(Err(e)) => { + error!("BFT failed to advance the subdag for round {anchor_round} - {e}"); + return Ok(()); + } + Err(e) => { + error!("BFT failed to receive the callback for round {anchor_round} - {e}"); + return Ok(()); } } + } - info!( - "\n\nCommitting a subdag from round {anchor_round} with {num_transmissions} transmissions: {subdag_metadata:?}\n" - ); - // Update the DAG, as the subdag was successfully included into a block. - let mut dag_write = self.dag.write(); - for certificate in commit_subdag.values().flatten() { - dag_write.commit(certificate, self.storage().max_gc_rounds()); - } + info!( + "\n\nCommitting a subdag from round {anchor_round} with {num_transmissions} transmissions: {subdag_metadata:?}\n" + ); + // Update the DAG, as the subdag was successfully included into a block. + let mut dag_write = self.dag.write(); + for certificate in commit_subdag.values().flatten() { + dag_write.commit(certificate, self.storage().max_gc_rounds()); } } - // Perform garbage collection based on the latest committed leader round if the node is not syncing. - if !IS_SYNCING { - self.storage().garbage_collect_certificates(latest_leader_round); - } + // Perform garbage collection based on the latest committed leader round. + self.storage().garbage_collect_certificates(latest_leader_round); Ok(()) } @@ -1243,7 +1235,7 @@ mod tests { } // Commit the leader certificate. - bft.commit_leader_certificate::(leader_certificate).await.unwrap(); + bft.commit_leader_certificate::(leader_certificate).await.unwrap(); // Ensure that the `gc_round` has been updated. assert_eq!(bft.storage().gc_round(), commit_round - max_gc_rounds); From 09fe4baa3070dcdcc7001bcb7aebda9bbcfc7a8e Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 5 Mar 2024 18:59:44 -0800 Subject: [PATCH 198/551] Add test for sync_bft_dag_at_bootup --- node/bft/src/bft.rs | 89 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 80af3a1270..8b4549446b 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -1242,4 +1242,93 @@ mod tests { Ok(()) } + + #[tokio::test] + #[tracing_test::traced_test] + async fn test_sync_bft_dag_at_bootup() -> Result<()> { + let rng = &mut TestRng::default(); + + // Initialize the round parameters. + let max_gc_rounds = 1; + let committee_round = 0; + let commit_round = 2; + let current_round = commit_round + 1; + + // Sample the current certificate and previous certificates. + let (_, certificates) = snarkvm::ledger::narwhal::batch_certificate::test_helpers::sample_batch_certificate_with_previous_certificates( + current_round, + rng, + ); + + // Initialize the committee. + let committee = snarkvm::ledger::committee::test_helpers::sample_committee_for_round_and_members( + committee_round, + vec![ + certificates[0].author(), + certificates[1].author(), + certificates[2].author(), + certificates[3].author(), + ], + rng, + ); + + // Initialize the ledger. + let ledger = Arc::new(MockLedgerService::new(committee.clone())); + + // Initialize the storage. + let storage = Storage::new(ledger.clone(), Arc::new(BFTMemoryService::new()), max_gc_rounds); + // Insert the certificates into the storage. + for certificate in certificates.iter() { + storage.testing_only_insert_certificate_testing_only(certificate.clone()); + } + + // Get the leader certificate. + let leader = committee.get_leader(commit_round).unwrap(); + let leader_certificate = storage.get_certificate_for_round_with_author(commit_round, leader).unwrap(); + + // Initialize the BFT. + let account = Account::new(rng)?; + let bft = BFT::new(account.clone(), storage, ledger.clone(), None, &[], None)?; + + // Insert a mock DAG in the BFT. + *bft.dag.write() = crate::helpers::dag::test_helpers::mock_dag_with_modified_last_committed_round(commit_round); + + // Insert the previous certificates into the BFT. + for certificate in certificates.clone() { + assert!(bft.update_dag::(certificate).await.is_ok()); + } + + // Commit the leader certificate. + bft.commit_leader_certificate::(leader_certificate.clone()).await.unwrap(); + + // Simulate a bootup of the BFT. + + // Initialize a new instance of storage. + let storage_2 = Storage::new(ledger.clone(), Arc::new(BFTMemoryService::new()), max_gc_rounds); + // Initialize a new instance of BFT. + let bootup_bft = BFT::new(account, storage_2, ledger, None, &[], None)?; + + // Sync the BFT DAG at bootup. + bootup_bft.sync_bft_dag_at_bootup(certificates.clone()).await; + + // Check that the BFT starts from the same last committed round. + assert_eq!(bft.dag.read().last_committed_round(), bootup_bft.dag.read().last_committed_round()); + + // Ensure that both BFTs have committed the leader certificate. + assert!(bft.dag.read().is_recently_committed(leader_certificate.round(), leader_certificate.id())); + assert!(bootup_bft.dag.read().is_recently_committed(leader_certificate.round(), leader_certificate.id())); + + // Check the state of the bootup BFT. + for certificate in certificates { + let certificate_round = certificate.round(); + let certificate_id = certificate.id(); + // Check that the bootup BFT has committed the certificates. + assert!(bootup_bft.dag.read().is_recently_committed(certificate_round, certificate_id)); + // Check that the bootup BFT does not contain the certificates in its graph, because + // it should not need to order them again in subsequent subdags. + assert!(!bootup_bft.dag.read().contains_certificate_in_round(certificate_round, certificate_id)); + } + + Ok(()) + } } From fc66ecf0f109c03bbf35326c1ba1e5f526967b0a Mon Sep 17 00:00:00 2001 From: ljedrz Date: Wed, 6 Mar 2024 13:09:02 +0100 Subject: [PATCH 199/551] feat: use cfg_iter_mut instead of par_iter_mut Signed-off-by: ljedrz --- node/bft/src/primary.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 6271d5582d..5e438e8f9c 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -573,7 +573,7 @@ impl Primary { let mut transmissions = self.sync_with_batch_header_from_peer(peer_ip, &batch_header).await?; // Check that the transmission ids match and are not fee transactions. - if let Err(err) = transmissions.par_iter_mut().try_for_each(|(transmission_id, transmission)| { + if let Err(err) = cfg_iter_mut!(transmissions).try_for_each(|(transmission_id, transmission)| { // If the transmission is not well-formed, then return early. self.ledger.ensure_transmission_is_well_formed(*transmission_id, transmission) }) { From a8f885e7c4d0cbd7990f32bfb9b620d752b61a12 Mon Sep 17 00:00:00 2001 From: Jos Dehaes Date: Thu, 7 Mar 2024 21:43:18 +0100 Subject: [PATCH 200/551] fix: x86_64 only --- Cargo.toml | 2 +- snarkos/main.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e8e3e82f87..631f31be53 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -119,7 +119,7 @@ version = "=2.2.7" path = "./node/tcp" version = "=2.2.7" -[target.'cfg(target_os = "linux")'.dependencies] +[target.'cfg(all(target_os = "linux", target_arch = "x86_64"))'.dependencies] tikv-jemallocator = "0.5" [dev-dependencies.rusty-hook] diff --git a/snarkos/main.rs b/snarkos/main.rs index 6ace71ef93..61a86949b8 100644 --- a/snarkos/main.rs +++ b/snarkos/main.rs @@ -17,10 +17,10 @@ use snarkos_cli::{commands::CLI, helpers::Updater}; use clap::Parser; use std::process::exit; -#[cfg(target_os = "linux")] +#[cfg(all(target_os = "linux", target_arch = "x86_64"))] use tikv_jemallocator::Jemalloc; -#[cfg(target_os = "linux")] +#[cfg(all(target_os = "linux", target_arch = "x86_64"))] #[global_allocator] static GLOBAL: Jemalloc = Jemalloc; From efc697e9637f6330e4ee4a8fb7ce374b7f0cfc9a Mon Sep 17 00:00:00 2001 From: mdelle1 <108158289+mdelle1@users.noreply.github.com> Date: Thu, 7 Mar 2024 17:54:11 -0500 Subject: [PATCH 201/551] Adds unit test for pre and post shutdown bft sync --- node/bft/src/bft.rs | 204 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 204 insertions(+) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 8b4549446b..926d064042 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -1331,4 +1331,208 @@ mod tests { Ok(()) } + + #[tokio::test] + #[tracing_test::traced_test] + async fn test_sync_bft_dag_at_bootup_shutdown() -> Result<()> { + + /* + BFT bootup unit test - + 1. Run one uninterrupted BFT on a set of certificates for 2 leader commits. + 2. Run a separate bootup BFT that syncs with a set of pre shutdown certificates, and then commits a second leader normally over a set of post shutdown certificates. + 3. Observe that the uninterrupted BFT and the bootup BFT end in the same state. + */ + + use snarkvm::console::{ + account::PrivateKey, + account::Address, + }; + use indexmap::{IndexMap, IndexSet}; + + let rng = &mut TestRng::default(); + + // Initialize the round parameters. + let max_gc_rounds = snarkvm::ledger::narwhal::BatchHeader::::MAX_GC_ROUNDS as u64; + let committee_round = 0; + let commit_round = 2; + let current_round = commit_round + 1; + let next_round = current_round + 1; + + // Sample 5 rounds of batch certificates starting at the genesis round from a static set of 4 authors. + let (round_to_certificates_map, committee) = { + let private_keys = vec![ + PrivateKey::new(rng).unwrap(), + PrivateKey::new(rng).unwrap(), + PrivateKey::new(rng).unwrap(), + PrivateKey::new(rng).unwrap() + ]; + let addresses = vec![ + Address::try_from(private_keys[0])?, + Address::try_from(private_keys[1])?, + Address::try_from(private_keys[2])?, + Address::try_from(private_keys[3])?, + ]; + let committee = snarkvm::ledger::committee::test_helpers::sample_committee_for_round_and_members( + committee_round, + addresses, + rng, + ); + // Initialize a mapping from the round number to the set of batch certificates in the round. + let mut round_to_certificates_map: IndexMap>> = IndexMap::new(); + let mut previous_certificates = IndexSet::with_capacity(4); + // Initialize the genesis batch certificates. + for _ in 0..4 { + previous_certificates.insert(sample_batch_certificate(rng)); + } + for round in 0..commit_round+3 { + let mut current_certificates = IndexSet::new(); + let previous_certificate_ids: IndexSet<_> = if round == 0 || round == 1 { + IndexSet::new() + } else { + previous_certificates.iter().map(|c| c.id()).collect() + }; + let transmission_ids = snarkvm::ledger::narwhal::transmission_id::test_helpers::sample_transmission_ids(rng).into_iter().collect::>(); + let timestamp = time::OffsetDateTime::now_utc().unix_timestamp(); + let committee_id = committee.id(); + for i in 0..4 { + let batch_header = snarkvm::ledger::narwhal::BatchHeader::new(&private_keys[i], round, timestamp, committee_id, transmission_ids.clone(), previous_certificate_ids.clone(), rng).unwrap(); + let mut signatures = IndexSet::with_capacity(4); + for j in 0..4 { + if i != j { + signatures.insert(private_keys[j].sign(&[batch_header.batch_id()], rng).unwrap()); + } + } + let certificate = snarkvm::ledger::narwhal::BatchCertificate::from(batch_header, signatures).unwrap(); + current_certificates.insert(certificate); + } + // Update the mapping. + round_to_certificates_map.insert(round, current_certificates.clone()); + previous_certificates = current_certificates.clone(); + } + (round_to_certificates_map, committee) + }; + + // Initialize the ledger. + let ledger = Arc::new(MockLedgerService::new(committee.clone())); + // Initialize the storage. + let storage = Storage::new(ledger.clone(), Arc::new(BFTMemoryService::new()), max_gc_rounds); + // Get the leaders for the next 2 commit rounds. + let leader = committee.get_leader(commit_round).unwrap(); + let next_leader = committee.get_leader(next_round).unwrap(); + // Insert the pre shutdown certificates into the storage. + let mut pre_shutdown_certificates: Vec> = Vec::new(); + for i in 1..=commit_round { + let certificates = (*round_to_certificates_map.get(&i).unwrap()).clone(); + if i == commit_round { // Only insert the leader certificate for the commit round. + let leader_certificate = certificates.iter().find(|certificate| certificate.author() == leader).clone(); + if let Some(c) = leader_certificate{ + pre_shutdown_certificates.push(c.clone()); + } + continue; + } + pre_shutdown_certificates.extend(certificates); + } + for certificate in pre_shutdown_certificates.iter() { + storage.testing_only_insert_certificate_testing_only(certificate.clone()); + } + // Insert the post shutdown certificates into the storage. + let mut post_shutdown_certificates: Vec> = Vec::new(); + for j in commit_round..=commit_round+2 { + let certificate = (*round_to_certificates_map.get(&j).unwrap()).clone(); + post_shutdown_certificates.extend(certificate); + } + for certificate in post_shutdown_certificates.iter() { + storage.testing_only_insert_certificate_testing_only(certificate.clone()); + } + // Get the leader certificates. + let leader_certificate = storage.get_certificate_for_round_with_author(commit_round, leader).unwrap(); + let next_leader_certificate = storage.get_certificate_for_round_with_author(next_round, next_leader).unwrap(); + + // Initialize the BFT without bootup. + let account = Account::new(rng)?; + let bft = BFT::new(account.clone(), storage, ledger.clone(), None, &[], None)?; + + // Insert a mock DAG in the BFT without bootup. + *bft.dag.write() = crate::helpers::dag::test_helpers::mock_dag_with_modified_last_committed_round(0); + + // Insert the certificates into the BFT without bootup. + for certificate in pre_shutdown_certificates.clone() { + assert!(bft.update_dag::(certificate).await.is_ok()); + } + + // Insert the post shutdown certificates into the BFT without bootup. + for certificate in post_shutdown_certificates.clone() { + assert!(bft.update_dag::(certificate).await.is_ok()); + } + // Commit the second leader certificate. + let commit_subdag = bft.order_dag_with_dfs::(next_leader_certificate.clone()).unwrap(); + let commit_subdag_metadata = commit_subdag.iter().map(|(round, c)| (*round, c.len())).collect::>(); + bft.commit_leader_certificate::(next_leader_certificate.clone()).await.unwrap(); + + // Simulate a bootup of the BFT. + + // Initialize a new instance of storage. + let bootup_storage = Storage::new(ledger.clone(), Arc::new(BFTMemoryService::new()), max_gc_rounds); + + // Initialize a new instance of BFT with bootup. + let bootup_bft = BFT::new(account, bootup_storage.clone(), ledger.clone(), None, &[], None)?; + + // Sync the BFT DAG at bootup. + bootup_bft.sync_bft_dag_at_bootup(pre_shutdown_certificates.clone()).await; + + // Insert the post shutdown certificates to the storage and BFT with bootup. + for certificate in post_shutdown_certificates.iter() { + bootup_bft.storage().testing_only_insert_certificate_testing_only(certificate.clone()); + } + for certificate in post_shutdown_certificates.clone() { + assert!(bootup_bft.update_dag::(certificate).await.is_ok()); + } + // Commit the second leader certificate. + let commit_subdag_bootup = bootup_bft.order_dag_with_dfs::(next_leader_certificate.clone()).unwrap(); + let commit_subdag_metadata_bootup = commit_subdag_bootup.iter().map(|(round, c)| (*round, c.len())).collect::>(); + let committed_certificates_bootup = commit_subdag_bootup.values().flatten(); + bootup_bft.commit_leader_certificate::(next_leader_certificate.clone()).await.unwrap(); + + // Check that the final state of both BFTs is the same. + + // Check that both BFTs start from the same last committed round. + assert_eq!(bft.dag.read().last_committed_round(), bootup_bft.dag.read().last_committed_round()); + + // Ensure that both BFTs have committed the leader certificates. + assert!(bft.dag.read().is_recently_committed(leader_certificate.round(), leader_certificate.id())); + assert!(bft.dag.read().is_recently_committed(next_leader_certificate.round(), next_leader_certificate.id())); + assert!(bootup_bft.dag.read().is_recently_committed(leader_certificate.round(), leader_certificate.id())); + assert!(bootup_bft.dag.read().is_recently_committed(next_leader_certificate.round(), next_leader_certificate.id())); + + // Check that the bootup BFT has committed the pre shutdown certificates. + for certificate in pre_shutdown_certificates.clone() { + let certificate_round = certificate.round(); + let certificate_id = certificate.id(); + // Check that both BFTs have committed the certificates. + assert!(bft.dag.read().is_recently_committed(certificate_round, certificate_id)); + assert!(bootup_bft.dag.read().is_recently_committed(certificate_round, certificate_id)); + // Check that the bootup BFT does not contain the certificates in its graph, because + // it should not need to order them again in subsequent subdags. + assert!(!bft.dag.read().contains_certificate_in_round(certificate_round, certificate_id)); + assert!(!bootup_bft.dag.read().contains_certificate_in_round(certificate_round, certificate_id)); + } + + // Check that that the bootup BFT has committed the subdag stemming from the second leader certificate in consensus. + for certificate in committed_certificates_bootup.clone() { + let certificate_round = certificate.round(); + let certificate_id = certificate.id(); + // Check that the both BFTs have committed the certificates. + assert!(bft.dag.read().is_recently_committed(certificate_round, certificate_id)); + assert!(bootup_bft.dag.read().is_recently_committed(certificate_round, certificate_id)); + // Check that the bootup BFT does not contain the certificates in its graph, because + // it should not need to order them again in subsequent subdags. + assert!(!bft.dag.read().contains_certificate_in_round(certificate_round, certificate_id)); + assert!(!bootup_bft.dag.read().contains_certificate_in_round(certificate_round, certificate_id)); + } + + // Check that the commit subdag metadata for the second leader is the same for both BFTs. + assert_eq!(commit_subdag_metadata_bootup, commit_subdag_metadata); + + Ok(()) + } } From 191c75ea82c644d7412064a484185710f34d942f Mon Sep 17 00:00:00 2001 From: mdelle1 <108158289+mdelle1@users.noreply.github.com> Date: Thu, 7 Mar 2024 18:00:07 -0500 Subject: [PATCH 202/551] Adds unit test for duplicate vertices in commit subdags after bft sync --- node/bft/src/bft.rs | 141 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 926d064042..8447343f65 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -1535,4 +1535,145 @@ mod tests { Ok(()) } + + #[tokio::test] + #[tracing_test::traced_test] + async fn test_sync_bft_dag_at_bootup_dfs() -> Result<()> { + + /* + BFT bootup unit test - + 1. Run a bootup BFT that syncs with a set of pre shutdown certificates. + 2. Add post shutdown certificates to the bootup BFT. + 2. Observe that in the commit subdag of the second leader certificate, there are no repeated vertices from the pre shutdown certificates. + */ + + use snarkvm::console::{ + account::PrivateKey, + account::Address, + }; + use indexmap::{IndexMap, IndexSet}; + + let rng = &mut TestRng::default(); + + // Initialize the round parameters. + let max_gc_rounds = snarkvm::ledger::narwhal::BatchHeader::::MAX_GC_ROUNDS as u64; + let committee_round = 0; + let commit_round = 2; + let current_round = commit_round + 1; + let next_round = current_round + 1; + + // Sample 5 rounds of batch certificates starting at the genesis round from a static set of 4 authors. + let (round_to_certificates_map, committee) = { + let private_keys = vec![ + PrivateKey::new(rng).unwrap(), + PrivateKey::new(rng).unwrap(), + PrivateKey::new(rng).unwrap(), + PrivateKey::new(rng).unwrap() + ]; + let addresses = vec![ + Address::try_from(private_keys[0])?, + Address::try_from(private_keys[1])?, + Address::try_from(private_keys[2])?, + Address::try_from(private_keys[3])?, + ]; + let committee = snarkvm::ledger::committee::test_helpers::sample_committee_for_round_and_members( + committee_round, + addresses, + rng, + ); + // Initialize a mapping from the round number to the set of batch certificates in the round. + let mut round_to_certificates_map: IndexMap>> = IndexMap::new(); + let mut previous_certificates = IndexSet::with_capacity(4); + // Initialize the genesis batch certificates. + for _ in 0..4 { + previous_certificates.insert(sample_batch_certificate(rng)); + } + for round in 0..=commit_round+2 { + let mut current_certificates = IndexSet::new(); + let previous_certificate_ids: IndexSet<_> = if round == 0 || round == 1 { + IndexSet::new() + } else { + previous_certificates.iter().map(|c| c.id()).collect() + }; + let transmission_ids = snarkvm::ledger::narwhal::transmission_id::test_helpers::sample_transmission_ids(rng).into_iter().collect::>(); + let timestamp = time::OffsetDateTime::now_utc().unix_timestamp(); + let committee_id = committee.id(); + for i in 0..4 { + let batch_header = snarkvm::ledger::narwhal::BatchHeader::new(&private_keys[i], round, timestamp, committee_id, transmission_ids.clone(), previous_certificate_ids.clone(), rng).unwrap(); + let mut signatures = IndexSet::with_capacity(4); + for j in 0..4 { + if i != j { + signatures.insert(private_keys[j].sign(&[batch_header.batch_id()], rng).unwrap()); + } + } + let certificate = snarkvm::ledger::narwhal::BatchCertificate::from(batch_header, signatures).unwrap(); + current_certificates.insert(certificate); + } + // Update the mapping. + round_to_certificates_map.insert(round, current_certificates.clone()); + previous_certificates = current_certificates.clone(); + } + (round_to_certificates_map, committee) + }; + + // Initialize the ledger. + let ledger = Arc::new(MockLedgerService::new(committee.clone())); + // Initialize the storage. + let storage = Storage::new(ledger.clone(), Arc::new(BFTMemoryService::new()), max_gc_rounds); + // Get the leaders for the next 2 commit rounds. + let leader = committee.get_leader(commit_round).unwrap(); + let next_leader = committee.get_leader(next_round).unwrap(); + // Insert the pre shutdown certificates into the storage. + let mut pre_shutdown_certificates: Vec> = Vec::new(); + for i in 1..=commit_round { + let certificates = (*round_to_certificates_map.get(&i).unwrap()).clone(); + if i == commit_round { // Only insert the leader certificate for the commit round. + let leader_certificate = certificates.iter().find(|certificate| certificate.author() == leader).clone(); + if let Some(c) = leader_certificate{ + pre_shutdown_certificates.push(c.clone()); + } + continue; + } + pre_shutdown_certificates.extend(certificates); + } + for certificate in pre_shutdown_certificates.iter() { + storage.testing_only_insert_certificate_testing_only(certificate.clone()); + } + // Initialize the bootup BFT. + let account = Account::new(rng)?; + let bootup_bft = BFT::new(account.clone(), storage.clone(), ledger.clone(), None, &[], None)?; + // Insert a mock DAG in the BFT without bootup. + *bootup_bft.dag.write() = crate::helpers::dag::test_helpers::mock_dag_with_modified_last_committed_round(0); + // Sync the BFT DAG at bootup. + bootup_bft.sync_bft_dag_at_bootup(pre_shutdown_certificates.clone()).await; + + // Insert the post shutdown certificates into the storage. + let mut post_shutdown_certificates: Vec> = Vec::new(); + for j in commit_round..=commit_round+2 { + let certificate = (*round_to_certificates_map.get(&j).unwrap()).clone(); + post_shutdown_certificates.extend(certificate); + } + for certificate in post_shutdown_certificates.iter() { + storage.testing_only_insert_certificate_testing_only(certificate.clone()); + } + + // Insert the post shutdown certificates into the DAG. + for certificate in post_shutdown_certificates.clone() { + assert!(bootup_bft.update_dag::(certificate).await.is_ok()); + } + + // Get the next leader certificate to commit. + let next_leader_certificate = storage.get_certificate_for_round_with_author(next_round, next_leader).unwrap(); + let commit_subdag = bootup_bft.order_dag_with_dfs::(next_leader_certificate).unwrap(); + let committed_certificates = commit_subdag.values().flatten(); + + // Check that none of the certificates synced from the bootup appear in the subdag for the next commit round. + for pre_shutdown_certificate in pre_shutdown_certificates.clone() { + for committed_certificate in committed_certificates.clone(){ + assert_ne!(pre_shutdown_certificate.id(), committed_certificate.id()); + } + } + Ok(()) + + } } From 10a4dc9265b3954f997be37d36b7a39dd34e35b5 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 7 Mar 2024 15:11:06 -0800 Subject: [PATCH 203/551] clippy --- node/bft/src/bft.rs | 296 ++++++++++++++++++++++++-------------------- 1 file changed, 163 insertions(+), 133 deletions(-) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 8447343f65..60236fd31b 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -1335,79 +1335,91 @@ mod tests { #[tokio::test] #[tracing_test::traced_test] async fn test_sync_bft_dag_at_bootup_shutdown() -> Result<()> { - - /* - BFT bootup unit test - + /* + BFT bootup unit test - 1. Run one uninterrupted BFT on a set of certificates for 2 leader commits. - 2. Run a separate bootup BFT that syncs with a set of pre shutdown certificates, and then commits a second leader normally over a set of post shutdown certificates. - 3. Observe that the uninterrupted BFT and the bootup BFT end in the same state. + 2. Run a separate bootup BFT that syncs with a set of pre shutdown certificates, and then commits a second leader normally over a set of post shutdown certificates. + 3. Observe that the uninterrupted BFT and the bootup BFT end in the same state. */ - use snarkvm::console::{ - account::PrivateKey, - account::Address, - }; use indexmap::{IndexMap, IndexSet}; + use snarkvm::console::account::{Address, PrivateKey}; let rng = &mut TestRng::default(); // Initialize the round parameters. - let max_gc_rounds = snarkvm::ledger::narwhal::BatchHeader::::MAX_GC_ROUNDS as u64; + let max_gc_rounds = snarkvm::ledger::narwhal::BatchHeader::::MAX_GC_ROUNDS as u64; let committee_round = 0; let commit_round = 2; let current_round = commit_round + 1; - let next_round = current_round + 1; + let next_round = current_round + 1; - // Sample 5 rounds of batch certificates starting at the genesis round from a static set of 4 authors. + // Sample 5 rounds of batch certificates starting at the genesis round from a static set of 4 authors. let (round_to_certificates_map, committee) = { let private_keys = vec![ - PrivateKey::new(rng).unwrap(), - PrivateKey::new(rng).unwrap(), - PrivateKey::new(rng).unwrap(), - PrivateKey::new(rng).unwrap() - ]; + PrivateKey::new(rng).unwrap(), + PrivateKey::new(rng).unwrap(), + PrivateKey::new(rng).unwrap(), + PrivateKey::new(rng).unwrap(), + ]; let addresses = vec![ - Address::try_from(private_keys[0])?, + Address::try_from(private_keys[0])?, Address::try_from(private_keys[1])?, Address::try_from(private_keys[2])?, Address::try_from(private_keys[3])?, - ]; + ]; let committee = snarkvm::ledger::committee::test_helpers::sample_committee_for_round_and_members( committee_round, - addresses, + addresses, rng, ); - // Initialize a mapping from the round number to the set of batch certificates in the round. - let mut round_to_certificates_map: IndexMap>> = IndexMap::new(); + // Initialize a mapping from the round number to the set of batch certificates in the round. + let mut round_to_certificates_map: IndexMap< + u64, + IndexSet>, + > = IndexMap::new(); let mut previous_certificates = IndexSet::with_capacity(4); - // Initialize the genesis batch certificates. + // Initialize the genesis batch certificates. for _ in 0..4 { previous_certificates.insert(sample_batch_certificate(rng)); } - for round in 0..commit_round+3 { - let mut current_certificates = IndexSet::new(); + for round in 0..commit_round + 3 { + let mut current_certificates = IndexSet::new(); let previous_certificate_ids: IndexSet<_> = if round == 0 || round == 1 { - IndexSet::new() + IndexSet::new() } else { previous_certificates.iter().map(|c| c.id()).collect() }; - let transmission_ids = snarkvm::ledger::narwhal::transmission_id::test_helpers::sample_transmission_ids(rng).into_iter().collect::>(); + let transmission_ids = + snarkvm::ledger::narwhal::transmission_id::test_helpers::sample_transmission_ids(rng) + .into_iter() + .collect::>(); let timestamp = time::OffsetDateTime::now_utc().unix_timestamp(); - let committee_id = committee.id(); - for i in 0..4 { - let batch_header = snarkvm::ledger::narwhal::BatchHeader::new(&private_keys[i], round, timestamp, committee_id, transmission_ids.clone(), previous_certificate_ids.clone(), rng).unwrap(); + let committee_id = committee.id(); + for (i, private_key_1) in private_keys.iter().enumerate() { + let batch_header = snarkvm::ledger::narwhal::BatchHeader::new( + private_key_1, + round, + timestamp, + committee_id, + transmission_ids.clone(), + previous_certificate_ids.clone(), + rng, + ) + .unwrap(); let mut signatures = IndexSet::with_capacity(4); - for j in 0..4 { + for (j, private_key_2) in private_keys.iter().enumerate() { if i != j { - signatures.insert(private_keys[j].sign(&[batch_header.batch_id()], rng).unwrap()); + signatures.insert(private_key_2.sign(&[batch_header.batch_id()], rng).unwrap()); } } - let certificate = snarkvm::ledger::narwhal::BatchCertificate::from(batch_header, signatures).unwrap(); - current_certificates.insert(certificate); + let certificate = + snarkvm::ledger::narwhal::BatchCertificate::from(batch_header, signatures).unwrap(); + current_certificates.insert(certificate); } - // Update the mapping. - round_to_certificates_map.insert(round, current_certificates.clone()); - previous_certificates = current_certificates.clone(); + // Update the mapping. + round_to_certificates_map.insert(round, current_certificates.clone()); + previous_certificates = current_certificates.clone(); } (round_to_certificates_map, committee) }; @@ -1416,42 +1428,44 @@ mod tests { let ledger = Arc::new(MockLedgerService::new(committee.clone())); // Initialize the storage. let storage = Storage::new(ledger.clone(), Arc::new(BFTMemoryService::new()), max_gc_rounds); - // Get the leaders for the next 2 commit rounds. + // Get the leaders for the next 2 commit rounds. let leader = committee.get_leader(commit_round).unwrap(); - let next_leader = committee.get_leader(next_round).unwrap(); - // Insert the pre shutdown certificates into the storage. + let next_leader = committee.get_leader(next_round).unwrap(); + // Insert the pre shutdown certificates into the storage. let mut pre_shutdown_certificates: Vec> = Vec::new(); - for i in 1..=commit_round { - let certificates = (*round_to_certificates_map.get(&i).unwrap()).clone(); - if i == commit_round { // Only insert the leader certificate for the commit round. - let leader_certificate = certificates.iter().find(|certificate| certificate.author() == leader).clone(); - if let Some(c) = leader_certificate{ - pre_shutdown_certificates.push(c.clone()); + for i in 1..=commit_round { + let certificates = (*round_to_certificates_map.get(&i).unwrap()).clone(); + if i == commit_round { + // Only insert the leader certificate for the commit round. + let leader_certificate = certificates.iter().find(|certificate| certificate.author() == leader); + if let Some(c) = leader_certificate { + pre_shutdown_certificates.push(c.clone()); } - continue; + continue; } - pre_shutdown_certificates.extend(certificates); + pre_shutdown_certificates.extend(certificates); } for certificate in pre_shutdown_certificates.iter() { storage.testing_only_insert_certificate_testing_only(certificate.clone()); } - // Insert the post shutdown certificates into the storage. - let mut post_shutdown_certificates: Vec> = Vec::new(); - for j in commit_round..=commit_round+2 { - let certificate = (*round_to_certificates_map.get(&j).unwrap()).clone(); - post_shutdown_certificates.extend(certificate); + // Insert the post shutdown certificates into the storage. + let mut post_shutdown_certificates: Vec> = + Vec::new(); + for j in commit_round..=commit_round + 2 { + let certificate = (*round_to_certificates_map.get(&j).unwrap()).clone(); + post_shutdown_certificates.extend(certificate); } for certificate in post_shutdown_certificates.iter() { storage.testing_only_insert_certificate_testing_only(certificate.clone()); } - // Get the leader certificates. + // Get the leader certificates. let leader_certificate = storage.get_certificate_for_round_with_author(commit_round, leader).unwrap(); let next_leader_certificate = storage.get_certificate_for_round_with_author(next_round, next_leader).unwrap(); - - // Initialize the BFT without bootup. + + // Initialize the BFT without bootup. let account = Account::new(rng)?; let bft = BFT::new(account.clone(), storage, ledger.clone(), None, &[], None)?; - + // Insert a mock DAG in the BFT without bootup. *bft.dag.write() = crate::helpers::dag::test_helpers::mock_dag_with_modified_last_committed_round(0); @@ -1464,7 +1478,7 @@ mod tests { for certificate in post_shutdown_certificates.clone() { assert!(bft.update_dag::(certificate).await.is_ok()); } - // Commit the second leader certificate. + // Commit the second leader certificate. let commit_subdag = bft.order_dag_with_dfs::(next_leader_certificate.clone()).unwrap(); let commit_subdag_metadata = commit_subdag.iter().map(|(round, c)| (*round, c.len())).collect::>(); bft.commit_leader_certificate::(next_leader_certificate.clone()).await.unwrap(); @@ -1473,38 +1487,41 @@ mod tests { // Initialize a new instance of storage. let bootup_storage = Storage::new(ledger.clone(), Arc::new(BFTMemoryService::new()), max_gc_rounds); - - // Initialize a new instance of BFT with bootup. + + // Initialize a new instance of BFT with bootup. let bootup_bft = BFT::new(account, bootup_storage.clone(), ledger.clone(), None, &[], None)?; - // Sync the BFT DAG at bootup. + // Sync the BFT DAG at bootup. bootup_bft.sync_bft_dag_at_bootup(pre_shutdown_certificates.clone()).await; - // Insert the post shutdown certificates to the storage and BFT with bootup. + // Insert the post shutdown certificates to the storage and BFT with bootup. for certificate in post_shutdown_certificates.iter() { bootup_bft.storage().testing_only_insert_certificate_testing_only(certificate.clone()); } for certificate in post_shutdown_certificates.clone() { assert!(bootup_bft.update_dag::(certificate).await.is_ok()); } - // Commit the second leader certificate. + // Commit the second leader certificate. let commit_subdag_bootup = bootup_bft.order_dag_with_dfs::(next_leader_certificate.clone()).unwrap(); - let commit_subdag_metadata_bootup = commit_subdag_bootup.iter().map(|(round, c)| (*round, c.len())).collect::>(); + let commit_subdag_metadata_bootup = + commit_subdag_bootup.iter().map(|(round, c)| (*round, c.len())).collect::>(); let committed_certificates_bootup = commit_subdag_bootup.values().flatten(); bootup_bft.commit_leader_certificate::(next_leader_certificate.clone()).await.unwrap(); - // Check that the final state of both BFTs is the same. + // Check that the final state of both BFTs is the same. // Check that both BFTs start from the same last committed round. assert_eq!(bft.dag.read().last_committed_round(), bootup_bft.dag.read().last_committed_round()); - // Ensure that both BFTs have committed the leader certificates. + // Ensure that both BFTs have committed the leader certificates. assert!(bft.dag.read().is_recently_committed(leader_certificate.round(), leader_certificate.id())); assert!(bft.dag.read().is_recently_committed(next_leader_certificate.round(), next_leader_certificate.id())); assert!(bootup_bft.dag.read().is_recently_committed(leader_certificate.round(), leader_certificate.id())); - assert!(bootup_bft.dag.read().is_recently_committed(next_leader_certificate.round(), next_leader_certificate.id())); + assert!( + bootup_bft.dag.read().is_recently_committed(next_leader_certificate.round(), next_leader_certificate.id()) + ); - // Check that the bootup BFT has committed the pre shutdown certificates. + // Check that the bootup BFT has committed the pre shutdown certificates. for certificate in pre_shutdown_certificates.clone() { let certificate_round = certificate.round(); let certificate_id = certificate.id(); @@ -1517,7 +1534,7 @@ mod tests { assert!(!bootup_bft.dag.read().contains_certificate_in_round(certificate_round, certificate_id)); } - // Check that that the bootup BFT has committed the subdag stemming from the second leader certificate in consensus. + // Check that that the bootup BFT has committed the subdag stemming from the second leader certificate in consensus. for certificate in committed_certificates_bootup.clone() { let certificate_round = certificate.round(); let certificate_id = certificate.id(); @@ -1530,7 +1547,7 @@ mod tests { assert!(!bootup_bft.dag.read().contains_certificate_in_round(certificate_round, certificate_id)); } - // Check that the commit subdag metadata for the second leader is the same for both BFTs. + // Check that the commit subdag metadata for the second leader is the same for both BFTs. assert_eq!(commit_subdag_metadata_bootup, commit_subdag_metadata); Ok(()) @@ -1539,79 +1556,91 @@ mod tests { #[tokio::test] #[tracing_test::traced_test] async fn test_sync_bft_dag_at_bootup_dfs() -> Result<()> { - - /* - BFT bootup unit test - - 1. Run a bootup BFT that syncs with a set of pre shutdown certificates. - 2. Add post shutdown certificates to the bootup BFT. - 2. Observe that in the commit subdag of the second leader certificate, there are no repeated vertices from the pre shutdown certificates. + /* + BFT bootup unit test - + 1. Run a bootup BFT that syncs with a set of pre shutdown certificates. + 2. Add post shutdown certificates to the bootup BFT. + 2. Observe that in the commit subdag of the second leader certificate, there are no repeated vertices from the pre shutdown certificates. */ - use snarkvm::console::{ - account::PrivateKey, - account::Address, - }; use indexmap::{IndexMap, IndexSet}; + use snarkvm::console::account::{Address, PrivateKey}; let rng = &mut TestRng::default(); // Initialize the round parameters. - let max_gc_rounds = snarkvm::ledger::narwhal::BatchHeader::::MAX_GC_ROUNDS as u64; + let max_gc_rounds = snarkvm::ledger::narwhal::BatchHeader::::MAX_GC_ROUNDS as u64; let committee_round = 0; let commit_round = 2; let current_round = commit_round + 1; - let next_round = current_round + 1; + let next_round = current_round + 1; - // Sample 5 rounds of batch certificates starting at the genesis round from a static set of 4 authors. + // Sample 5 rounds of batch certificates starting at the genesis round from a static set of 4 authors. let (round_to_certificates_map, committee) = { let private_keys = vec![ - PrivateKey::new(rng).unwrap(), - PrivateKey::new(rng).unwrap(), - PrivateKey::new(rng).unwrap(), - PrivateKey::new(rng).unwrap() - ]; + PrivateKey::new(rng).unwrap(), + PrivateKey::new(rng).unwrap(), + PrivateKey::new(rng).unwrap(), + PrivateKey::new(rng).unwrap(), + ]; let addresses = vec![ - Address::try_from(private_keys[0])?, + Address::try_from(private_keys[0])?, Address::try_from(private_keys[1])?, Address::try_from(private_keys[2])?, Address::try_from(private_keys[3])?, - ]; + ]; let committee = snarkvm::ledger::committee::test_helpers::sample_committee_for_round_and_members( committee_round, - addresses, + addresses, rng, ); - // Initialize a mapping from the round number to the set of batch certificates in the round. - let mut round_to_certificates_map: IndexMap>> = IndexMap::new(); + // Initialize a mapping from the round number to the set of batch certificates in the round. + let mut round_to_certificates_map: IndexMap< + u64, + IndexSet>, + > = IndexMap::new(); let mut previous_certificates = IndexSet::with_capacity(4); - // Initialize the genesis batch certificates. + // Initialize the genesis batch certificates. for _ in 0..4 { previous_certificates.insert(sample_batch_certificate(rng)); } - for round in 0..=commit_round+2 { - let mut current_certificates = IndexSet::new(); + for round in 0..=commit_round + 2 { + let mut current_certificates = IndexSet::new(); let previous_certificate_ids: IndexSet<_> = if round == 0 || round == 1 { - IndexSet::new() + IndexSet::new() } else { previous_certificates.iter().map(|c| c.id()).collect() }; - let transmission_ids = snarkvm::ledger::narwhal::transmission_id::test_helpers::sample_transmission_ids(rng).into_iter().collect::>(); + let transmission_ids = + snarkvm::ledger::narwhal::transmission_id::test_helpers::sample_transmission_ids(rng) + .into_iter() + .collect::>(); let timestamp = time::OffsetDateTime::now_utc().unix_timestamp(); - let committee_id = committee.id(); - for i in 0..4 { - let batch_header = snarkvm::ledger::narwhal::BatchHeader::new(&private_keys[i], round, timestamp, committee_id, transmission_ids.clone(), previous_certificate_ids.clone(), rng).unwrap(); + let committee_id = committee.id(); + for (i, private_key_1) in private_keys.iter().enumerate() { + let batch_header = snarkvm::ledger::narwhal::BatchHeader::new( + private_key_1, + round, + timestamp, + committee_id, + transmission_ids.clone(), + previous_certificate_ids.clone(), + rng, + ) + .unwrap(); let mut signatures = IndexSet::with_capacity(4); - for j in 0..4 { + for (j, private_key_2) in private_keys.iter().enumerate() { if i != j { - signatures.insert(private_keys[j].sign(&[batch_header.batch_id()], rng).unwrap()); + signatures.insert(private_key_2.sign(&[batch_header.batch_id()], rng).unwrap()); } } - let certificate = snarkvm::ledger::narwhal::BatchCertificate::from(batch_header, signatures).unwrap(); - current_certificates.insert(certificate); + let certificate = + snarkvm::ledger::narwhal::BatchCertificate::from(batch_header, signatures).unwrap(); + current_certificates.insert(certificate); } - // Update the mapping. - round_to_certificates_map.insert(round, current_certificates.clone()); - previous_certificates = current_certificates.clone(); + // Update the mapping. + round_to_certificates_map.insert(round, current_certificates.clone()); + previous_certificates = current_certificates.clone(); } (round_to_certificates_map, committee) }; @@ -1620,60 +1649,61 @@ mod tests { let ledger = Arc::new(MockLedgerService::new(committee.clone())); // Initialize the storage. let storage = Storage::new(ledger.clone(), Arc::new(BFTMemoryService::new()), max_gc_rounds); - // Get the leaders for the next 2 commit rounds. - let leader = committee.get_leader(commit_round).unwrap(); - let next_leader = committee.get_leader(next_round).unwrap(); - // Insert the pre shutdown certificates into the storage. + // Get the leaders for the next 2 commit rounds. + let leader = committee.get_leader(commit_round).unwrap(); + let next_leader = committee.get_leader(next_round).unwrap(); + // Insert the pre shutdown certificates into the storage. let mut pre_shutdown_certificates: Vec> = Vec::new(); - for i in 1..=commit_round { - let certificates = (*round_to_certificates_map.get(&i).unwrap()).clone(); - if i == commit_round { // Only insert the leader certificate for the commit round. - let leader_certificate = certificates.iter().find(|certificate| certificate.author() == leader).clone(); - if let Some(c) = leader_certificate{ - pre_shutdown_certificates.push(c.clone()); + for i in 1..=commit_round { + let certificates = (*round_to_certificates_map.get(&i).unwrap()).clone(); + if i == commit_round { + // Only insert the leader certificate for the commit round. + let leader_certificate = certificates.iter().find(|certificate| certificate.author() == leader); + if let Some(c) = leader_certificate { + pre_shutdown_certificates.push(c.clone()); } - continue; + continue; } - pre_shutdown_certificates.extend(certificates); + pre_shutdown_certificates.extend(certificates); } for certificate in pre_shutdown_certificates.iter() { storage.testing_only_insert_certificate_testing_only(certificate.clone()); } - // Initialize the bootup BFT. + // Initialize the bootup BFT. let account = Account::new(rng)?; let bootup_bft = BFT::new(account.clone(), storage.clone(), ledger.clone(), None, &[], None)?; // Insert a mock DAG in the BFT without bootup. *bootup_bft.dag.write() = crate::helpers::dag::test_helpers::mock_dag_with_modified_last_committed_round(0); - // Sync the BFT DAG at bootup. + // Sync the BFT DAG at bootup. bootup_bft.sync_bft_dag_at_bootup(pre_shutdown_certificates.clone()).await; - // Insert the post shutdown certificates into the storage. - let mut post_shutdown_certificates: Vec> = Vec::new(); - for j in commit_round..=commit_round+2 { - let certificate = (*round_to_certificates_map.get(&j).unwrap()).clone(); - post_shutdown_certificates.extend(certificate); + // Insert the post shutdown certificates into the storage. + let mut post_shutdown_certificates: Vec> = + Vec::new(); + for j in commit_round..=commit_round + 2 { + let certificate = (*round_to_certificates_map.get(&j).unwrap()).clone(); + post_shutdown_certificates.extend(certificate); } for certificate in post_shutdown_certificates.iter() { storage.testing_only_insert_certificate_testing_only(certificate.clone()); } - // Insert the post shutdown certificates into the DAG. + // Insert the post shutdown certificates into the DAG. for certificate in post_shutdown_certificates.clone() { assert!(bootup_bft.update_dag::(certificate).await.is_ok()); } - - // Get the next leader certificate to commit. + + // Get the next leader certificate to commit. let next_leader_certificate = storage.get_certificate_for_round_with_author(next_round, next_leader).unwrap(); let commit_subdag = bootup_bft.order_dag_with_dfs::(next_leader_certificate).unwrap(); let committed_certificates = commit_subdag.values().flatten(); // Check that none of the certificates synced from the bootup appear in the subdag for the next commit round. - for pre_shutdown_certificate in pre_shutdown_certificates.clone() { - for committed_certificate in committed_certificates.clone(){ + for pre_shutdown_certificate in pre_shutdown_certificates.clone() { + for committed_certificate in committed_certificates.clone() { assert_ne!(pre_shutdown_certificate.id(), committed_certificate.id()); } } Ok(()) - } } From c8fc4dea151e963d998355cea6a085eef02bfa04 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 7 Mar 2024 15:37:10 -0800 Subject: [PATCH 204/551] nit --- node/bft/src/bft.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 60236fd31b..8b436dd78b 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -813,6 +813,7 @@ mod tests { use snarkos_node_bft_ledger_service::MockLedgerService; use snarkos_node_bft_storage_service::BFTMemoryService; use snarkvm::{ + console::account::{Address, PrivateKey}, ledger::{ committee::Committee, narwhal::batch_certificate::test_helpers::{sample_batch_certificate, sample_batch_certificate_for_round}, @@ -821,7 +822,7 @@ mod tests { }; use anyhow::Result; - use indexmap::IndexSet; + use indexmap::{IndexMap, IndexSet}; use std::sync::{atomic::Ordering, Arc}; type CurrentNetwork = snarkvm::console::network::MainnetV0; @@ -1341,9 +1342,7 @@ mod tests { 2. Run a separate bootup BFT that syncs with a set of pre shutdown certificates, and then commits a second leader normally over a set of post shutdown certificates. 3. Observe that the uninterrupted BFT and the bootup BFT end in the same state. */ - use indexmap::{IndexMap, IndexSet}; - use snarkvm::console::account::{Address, PrivateKey}; let rng = &mut TestRng::default(); @@ -1563,9 +1562,6 @@ mod tests { 2. Observe that in the commit subdag of the second leader certificate, there are no repeated vertices from the pre shutdown certificates. */ - use indexmap::{IndexMap, IndexSet}; - use snarkvm::console::account::{Address, PrivateKey}; - let rng = &mut TestRng::default(); // Initialize the round parameters. From 6b353a0e24518d0cc250be5363c2379a38f01178 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 7 Mar 2024 16:25:50 -0800 Subject: [PATCH 205/551] Clippy --- node/bft/tests/components/mod.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/node/bft/tests/components/mod.rs b/node/bft/tests/components/mod.rs index 1a11df65a7..2864fe598d 100644 --- a/node/bft/tests/components/mod.rs +++ b/node/bft/tests/components/mod.rs @@ -59,12 +59,15 @@ pub fn sample_storage(ledger: Arc(ledger: Arc>>) -> Gateway { +pub fn sample_gateway( + storage: Storage, + ledger: Arc>>, +) -> Gateway { let num_nodes: u16 = ledger.current_committee().unwrap().num_members().try_into().unwrap(); let (accounts, _committee) = primary::new_test_committee(num_nodes); let account = Account::from_str(&accounts[0].private_key().to_string()).unwrap(); // Initialize the gateway. - Gateway::new(account, ledger, None, &[], None).unwrap() + Gateway::new(account, storage, ledger, None, &[], None).unwrap() } /// Samples a new worker with the given ledger. @@ -72,7 +75,7 @@ pub fn sample_worker(id: u8, ledger: Arc Date: Thu, 7 Mar 2024 16:34:08 -0800 Subject: [PATCH 206/551] nit --- node/bft/src/bft.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 8b436dd78b..a624339f0e 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -1337,12 +1337,10 @@ mod tests { #[tracing_test::traced_test] async fn test_sync_bft_dag_at_bootup_shutdown() -> Result<()> { /* - BFT bootup unit test - 1. Run one uninterrupted BFT on a set of certificates for 2 leader commits. 2. Run a separate bootup BFT that syncs with a set of pre shutdown certificates, and then commits a second leader normally over a set of post shutdown certificates. 3. Observe that the uninterrupted BFT and the bootup BFT end in the same state. */ - use indexmap::{IndexMap, IndexSet}; let rng = &mut TestRng::default(); @@ -1556,7 +1554,6 @@ mod tests { #[tracing_test::traced_test] async fn test_sync_bft_dag_at_bootup_dfs() -> Result<()> { /* - BFT bootup unit test - 1. Run a bootup BFT that syncs with a set of pre shutdown certificates. 2. Add post shutdown certificates to the bootup BFT. 2. Observe that in the commit subdag of the second leader certificate, there are no repeated vertices from the pre shutdown certificates. From 3221e522b5ea0f65323c61c45c42bd2ae2fa64a7 Mon Sep 17 00:00:00 2001 From: Jos Dehaes Date: Wed, 6 Mar 2024 10:59:10 +0100 Subject: [PATCH 207/551] feat: allow-outside-peers --- cli/src/commands/start.rs | 6 +++++- node/router/src/handshake.rs | 6 ++++++ node/router/src/heartbeat.rs | 15 ++++++++++++--- node/router/src/inbound.rs | 3 +++ node/router/src/lib.rs | 14 ++++++++++++++ node/router/tests/common/mod.rs | 3 +++ node/src/client/mod.rs | 1 + node/src/node.rs | 2 ++ node/src/prover/mod.rs | 1 + node/src/validator/mod.rs | 3 +++ node/tests/common/node.rs | 1 + 11 files changed, 51 insertions(+), 4 deletions(-) diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index 8205d35c05..b655be403a 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -144,6 +144,10 @@ pub struct Start { #[clap(long)] /// If development mode is enabled, specify the custom bonded balances as a json object. (default: None) dev_bonded_balances: Option, + + #[clap(long = "allow-outside-peers")] + /// If the flag is set, the validator will allow untrusted peers to connect + allow_outside_peers: bool, } impl Start { @@ -527,7 +531,7 @@ impl Start { // Initialize the node. let bft_ip = if self.dev.is_some() { self.bft } else { None }; match node_type { - NodeType::Validator => Node::new_validator(self.node, bft_ip, rest_ip, self.rest_rps, account, &trusted_peers, &trusted_validators, genesis, cdn, storage_mode).await, + NodeType::Validator => Node::new_validator(self.node, bft_ip, rest_ip, self.rest_rps, account, &trusted_peers, &trusted_validators, genesis, cdn, storage_mode, self.allow_outside_peers).await, NodeType::Prover => Node::new_prover(self.node, account, &trusted_peers, genesis, storage_mode).await, NodeType::Client => Node::new_client(self.node, rest_ip, self.rest_rps, account, &trusted_peers, genesis, cdn, storage_mode).await, } diff --git a/node/router/src/handshake.rs b/node/router/src/handshake.rs index 195298eaea..8a45cee439 100644 --- a/node/router/src/handshake.rs +++ b/node/router/src/handshake.rs @@ -264,6 +264,12 @@ impl Router { if self.is_connected(&peer_ip) { bail!("Dropping connection request from '{peer_ip}' (already connected)") } + // Only allow trusted peers to connect if we are a validator + // (unless allow_outside_peers is set) + let is_validator = self.node_type().is_validator(); + if is_validator && !self.allow_outside_peers() && !self.is_trusted(&peer_ip) { + bail!("Dropping connection request from '{peer_ip}' (untrusted)") + } // Ensure the peer is not restricted. if self.is_restricted(&peer_ip) { bail!("Dropping connection request from '{peer_ip}' (restricted)") diff --git a/node/router/src/heartbeat.rs b/node/router/src/heartbeat.rs index 9eb1247ea0..599da2c6ea 100644 --- a/node/router/src/heartbeat.rs +++ b/node/router/src/heartbeat.rs @@ -107,6 +107,12 @@ pub trait Heartbeat: Outbound { return; } + let is_validator = self.router().node_type().is_validator(); + // Skip if the node is not requesting peers. + if is_validator && !self.router().allow_outside_peers() { + return; + } + // Retrieve the trusted peers. let trusted = self.router().trusted_peers(); // Retrieve the bootstrap peers. @@ -216,9 +222,12 @@ pub trait Heartbeat: Outbound { for peer_ip in self.router().candidate_peers().into_iter().choose_multiple(rng, num_deficient) { self.router().connect(peer_ip); } - // Request more peers from the connected peers. - for peer_ip in self.router().connected_peers().into_iter().choose_multiple(rng, 3) { - self.send(peer_ip, Message::PeerRequest(PeerRequest)); + let is_validator = self.router().node_type().is_validator(); + if !is_validator || self.router().allow_outside_peers() { + // Request more peers from the connected peers. + for peer_ip in self.router().connected_peers().into_iter().choose_multiple(rng, 3) { + self.send(peer_ip, Message::PeerRequest(PeerRequest)); + } } } } diff --git a/node/router/src/inbound.rs b/node/router/src/inbound.rs index 3f29d28257..a44098042d 100644 --- a/node/router/src/inbound.rs +++ b/node/router/src/inbound.rs @@ -125,6 +125,9 @@ pub trait Inbound: Reading + Outbound { if !self.router().cache.contains_outbound_peer_request(peer_ip) { bail!("Peer '{peer_ip}' is not following the protocol (unexpected peer response)") } + if self.router().node_type().is_validator() && !self.router().allow_outside_peers() { + bail!("Not accepting peer response from '{peer_ip}' (validator gossip is disabled)"); + } match self.peer_response(peer_ip, &message.peers) { true => Ok(()), diff --git a/node/router/src/lib.rs b/node/router/src/lib.rs index 84b00a5031..5bba3cac41 100644 --- a/node/router/src/lib.rs +++ b/node/router/src/lib.rs @@ -95,6 +95,8 @@ pub struct InnerRouter { handles: Mutex>>, /// The boolean flag for the development mode. is_dev: bool, + /// If the flag is set, the node will not engage in P2P gossip to request more peers. + allow_outside_peers: bool, } impl Router { @@ -116,6 +118,7 @@ impl Router { trusted_peers: &[SocketAddr], max_peers: u16, is_dev: bool, + allow_outside_peers: bool, ) -> Result { // Initialize the TCP stack. let tcp = Tcp::new(Config::new(node_ip, max_peers)); @@ -133,6 +136,7 @@ impl Router { restricted_peers: Default::default(), handles: Default::default(), is_dev, + allow_outside_peers, }))) } } @@ -251,6 +255,11 @@ impl Router { self.is_dev } + /// Returns `true` if the node is not engaging in P2P gossip to request more peers. + pub fn allow_outside_peers(&self) -> bool { + self.allow_outside_peers + } + /// Returns the listener IP address from the (ambiguous) peer address. pub fn resolve_to_listener(&self, peer_addr: &SocketAddr) -> Option { self.resolver.get_listener(peer_addr) @@ -295,6 +304,11 @@ impl Router { .unwrap_or(false) } + /// Returns `true` if the given IP is trusted. + pub fn is_trusted(&self, ip: &SocketAddr) -> bool { + self.trusted_peers.contains(ip) + } + /// Returns the maximum number of connected peers. pub fn max_connected_peers(&self) -> usize { self.tcp.config().max_connections as usize diff --git a/node/router/tests/common/mod.rs b/node/router/tests/common/mod.rs index c173d43772..780bcbacac 100644 --- a/node/router/tests/common/mod.rs +++ b/node/router/tests/common/mod.rs @@ -78,6 +78,7 @@ pub async fn client(listening_port: u16, max_peers: u16) -> TestRouter TestRouter TestRouter> Client { trusted_peers, Self::MAXIMUM_NUMBER_OF_PEERS as u16, matches!(storage_mode, StorageMode::Development(_)), + false, ) .await?; // Load the coinbase puzzle. diff --git a/node/src/node.rs b/node/src/node.rs index e6435d6ef6..563f81f152 100644 --- a/node/src/node.rs +++ b/node/src/node.rs @@ -50,6 +50,7 @@ impl Node { genesis: Block, cdn: Option, storage_mode: StorageMode, + allow_outside_peers: bool, ) -> Result { Ok(Self::Validator(Arc::new( Validator::new( @@ -63,6 +64,7 @@ impl Node { genesis, cdn, storage_mode, + allow_outside_peers, ) .await?, ))) diff --git a/node/src/prover/mod.rs b/node/src/prover/mod.rs index 0872a35fd7..de71ead0a3 100644 --- a/node/src/prover/mod.rs +++ b/node/src/prover/mod.rs @@ -110,6 +110,7 @@ impl> Prover { trusted_peers, Self::MAXIMUM_NUMBER_OF_PEERS as u16, matches!(storage_mode, StorageMode::Development(_)), + false, ) .await?; // Load the coinbase puzzle. diff --git a/node/src/validator/mod.rs b/node/src/validator/mod.rs index efb8003f6e..8add855f6f 100644 --- a/node/src/validator/mod.rs +++ b/node/src/validator/mod.rs @@ -83,6 +83,7 @@ impl> Validator { genesis: Block, cdn: Option, storage_mode: StorageMode, + allow_outside_peers: bool, ) -> Result { // Prepare the shutdown flag. let shutdown: Arc = Default::default(); @@ -125,6 +126,7 @@ impl> Validator { trusted_peers, Self::MAXIMUM_NUMBER_OF_PEERS as u16, matches!(storage_mode, StorageMode::Development(_)), + allow_outside_peers, ) .await?; @@ -496,6 +498,7 @@ mod tests { genesis, None, storage_mode, + false, ) .await .unwrap(); diff --git a/node/tests/common/node.rs b/node/tests/common/node.rs index 80c0262903..5ac01167a9 100644 --- a/node/tests/common/node.rs +++ b/node/tests/common/node.rs @@ -59,6 +59,7 @@ pub async fn validator() -> Validator Date: Fri, 8 Mar 2024 15:57:40 +0100 Subject: [PATCH 208/551] feat: adjust devnet scripts --- .devnet/start.sh | 2 +- devnet.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.devnet/start.sh b/.devnet/start.sh index f4c635892b..bc90ebfbe3 100755 --- a/.devnet/start.sh +++ b/.devnet/start.sh @@ -37,7 +37,7 @@ start_snarkos_in_tmux() { tmux new-session -d -s snarkos-session # Send the snarkOS start command to the tmux session with the NODE_ID - tmux send-keys -t "snarkos-session" "snarkos start --nodisplay --bft 0.0.0.0:5000 --rest 0.0.0.0:3030 --peers $NODE_IP:4130 --validators $NODE_IP:5000 --rest-rps 1000 --verbosity $VERBOSITY --dev $NODE_ID --dev-num-validators $NUM_INSTANCES --validator --metrics" C-m + tmux send-keys -t "snarkos-session" "snarkos start --nodisplay --bft 0.0.0.0:5000 --rest 0.0.0.0:3030 --allow-outside-peers --peers $NODE_IP:4130 --validators $NODE_IP:5000 --rest-rps 1000 --verbosity $VERBOSITY --dev $NODE_ID --dev-num-validators $NUM_INSTANCES --validator --metrics" C-m exit # Exit root user EOF diff --git a/devnet.sh b/devnet.sh index e91627335a..de69a84081 100755 --- a/devnet.sh +++ b/devnet.sh @@ -64,12 +64,12 @@ for validator_index in "${validator_indices[@]}"; do # Send the command to start the validator to the new window and capture output to the log file if [ "$validator_index" -eq 0 ]; then - tmux send-keys -t "devnet:window$validator_index" "snarkos start --nodisplay --dev $validator_index --dev-num-validators $total_validators --validator --logfile $log_file --metrics" C-m + tmux send-keys -t "devnet:window$validator_index" "snarkos start --nodisplay --dev $validator_index --allow-outside-peers --dev-num-validators $total_validators --validator --logfile $log_file --metrics" C-m else # Create a new window with a unique name window_index=$((validator_index + index_offset)) tmux new-window -t "devnet:$window_index" -n "window$validator_index" - tmux send-keys -t "devnet:window$validator_index" "snarkos start --nodisplay --dev $validator_index --dev-num-validators $total_validators --validator --logfile $log_file" C-m + tmux send-keys -t "devnet:window$validator_index" "snarkos start --nodisplay --dev $validator_index --allow-outside-peers --dev-num-validators $total_validators --validator --logfile $log_file" C-m fi done From ce1ca027e7802a70dcf2ea1c8a1ca9c8842b437d Mon Sep 17 00:00:00 2001 From: Jos Dehaes Date: Fri, 8 Mar 2024 16:13:22 +0100 Subject: [PATCH 209/551] fix: test --- node/tests/common/node.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/tests/common/node.rs b/node/tests/common/node.rs index 5ac01167a9..555ae52b86 100644 --- a/node/tests/common/node.rs +++ b/node/tests/common/node.rs @@ -59,7 +59,7 @@ pub async fn validator() -> Validator Date: Fri, 8 Mar 2024 14:21:49 -0800 Subject: [PATCH 210/551] nit --- node/bft/src/helpers/pending.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index 9ceedd3fe9..d37275fdf2 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -26,11 +26,6 @@ use std::{ use time::OffsetDateTime; use tokio::sync::oneshot; -#[cfg(not(test))] -pub const NUM_REDUNDANT_REQUESTS: usize = 2; -#[cfg(test)] -pub const NUM_REDUNDANT_REQUESTS: usize = 10; - /// The maximum number of seconds to wait before expiring a callback. /// We ensure that we don't truncate `MAX_FETCH_TIMEOUT_IN_MS` when converting to seconds. const CALLBACK_EXPIRATION_IN_SECS: i64 = (MAX_FETCH_TIMEOUT_IN_MS as i64 + (1000 - 1)) / 1000; From 51bcde480c525b630ebb6b1e46a8c10564b0535b Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 8 Mar 2024 14:49:15 -0800 Subject: [PATCH 211/551] Update snarkVM rev - 2fd006a --- Cargo.lock | 116 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 2 +- 2 files changed, 59 insertions(+), 59 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9d7edd0403..6ff8bdd38f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3348,7 +3348,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "anstyle", "anyhow", @@ -3379,7 +3379,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "aleo-std", "anyhow", @@ -3409,7 +3409,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3423,7 +3423,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3434,7 +3434,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3444,7 +3444,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3454,7 +3454,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "indexmap 2.2.3", "itertools 0.11.0", @@ -3472,12 +3472,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3488,7 +3488,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3503,7 +3503,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3518,7 +3518,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3531,7 +3531,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3540,7 +3540,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3550,7 +3550,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3562,7 +3562,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3574,7 +3574,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3585,7 +3585,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3597,7 +3597,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3610,7 +3610,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "bs58", "snarkvm-console-network", @@ -3621,7 +3621,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "blake2s_simd", "smallvec", @@ -3634,7 +3634,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "aleo-std", "rayon", @@ -3645,7 +3645,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "anyhow", "indexmap 2.2.3", @@ -3668,7 +3668,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "anyhow", "bech32", @@ -3686,7 +3686,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "enum_index", "enum_index_derive", @@ -3707,7 +3707,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3722,7 +3722,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3733,7 +3733,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "snarkvm-console-network-environment", ] @@ -3741,7 +3741,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3751,7 +3751,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3762,7 +3762,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3773,7 +3773,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3784,7 +3784,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3795,7 +3795,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "rand", "rayon", @@ -3809,7 +3809,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "aleo-std", "anyhow", @@ -3826,7 +3826,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "aleo-std", "anyhow", @@ -3851,7 +3851,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "anyhow", "rand", @@ -3863,7 +3863,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "indexmap 2.2.3", "rayon", @@ -3882,7 +3882,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-coinbase" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "aleo-std", "anyhow", @@ -3902,7 +3902,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "anyhow", "indexmap 2.2.3", @@ -3920,7 +3920,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -3933,7 +3933,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "indexmap 2.2.3", "rayon", @@ -3946,7 +3946,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "indexmap 2.2.3", "serde_json", @@ -3958,7 +3958,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "bytes", "serde_json", @@ -3969,7 +3969,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "indexmap 2.2.3", "rayon", @@ -3984,7 +3984,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "bytes", "serde_json", @@ -3997,7 +3997,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "snarkvm-console", "snarkvm-ledger-coinbase", @@ -4006,7 +4006,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "async-trait", "reqwest", @@ -4019,7 +4019,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "aleo-std-storage", "anyhow", @@ -4045,7 +4045,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4060,7 +4060,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4069,7 +4069,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "aleo-std", "anyhow", @@ -4094,7 +4094,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "aleo-std", "anyhow", @@ -4119,7 +4119,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "aleo-std", "colored", @@ -4142,7 +4142,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "indexmap 2.2.3", "paste", @@ -4156,7 +4156,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "bincode", "once_cell", @@ -4169,7 +4169,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "aleo-std", "anyhow", @@ -4190,7 +4190,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=46f2625#46f2625223c0ce162d43552f03426cad422f2aed" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" dependencies = [ "proc-macro2", "quote 1.0.35", diff --git a/Cargo.toml b/Cargo.toml index 76177a3d83..4e34f5b632 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "46f2625" +rev = "2fd006a" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From 9e701f9349fcfb3e9fbe0f08889198f2a91f1163 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 8 Mar 2024 14:55:25 -0800 Subject: [PATCH 212/551] Use withdrawal addresses in dev genesis block and dev_bonded_balances --- cli/src/commands/start.rs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index 8205d35c05..d6746c4e96 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -53,8 +53,9 @@ const DEVELOPMENT_MODE_RNG_SEED: u64 = 1234567890u64; /// The development mode number of genesis committee members. const DEVELOPMENT_MODE_NUM_GENESIS_COMMITTEE_MEMBERS: u16 = 4; +/// A mapping of `staker_address` to `(validator_address, withdrawal_address, amount)`. #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] -struct BondedBalances(IndexMap); +struct BondedBalances(IndexMap); impl FromStr for BondedBalances { type Err = serde_json::Error; @@ -342,16 +343,17 @@ impl Start { let bonded_balances = bonded_balances .0 .iter() - .map(|(staker_address, (validator_address, amount))| { + .map(|(staker_address, (validator_address, withdrawal_address, amount))| { let staker_addr = Address::::from_str(staker_address)?; let validator_addr = Address::::from_str(validator_address)?; - Ok((staker_addr, (validator_addr, *amount))) + let withdrawal_addr = Address::::from_str(withdrawal_address)?; + Ok((staker_addr, (validator_addr, withdrawal_addr, *amount))) }) .collect::>>()?; // Construct the committee members. let mut members = IndexMap::new(); - for (staker_address, (validator_address, amount)) in bonded_balances.iter() { + for (staker_address, (validator_address, _, amount)) in bonded_balances.iter() { // Ensure that the staking amount is sufficient. match staker_address == validator_address { true => ensure!(amount >= &MIN_VALIDATOR_STAKE, "Validator stake is too low"), @@ -387,9 +389,10 @@ impl Start { .collect::>(); // Construct the bonded balances. + // Note: The withdrawal address is set to the staker address. let bonded_balances = members .iter() - .map(|(address, (stake, _))| (*address, (*address, *stake))) + .map(|(address, (stake, _))| (*address, (*address, *address, *stake))) .collect::>(); // Construct the committee. let committee = Committee::::new(0u64, members)?; @@ -587,7 +590,7 @@ fn load_or_compute_genesis( genesis_private_key: PrivateKey, committee: Committee, public_balances: indexmap::IndexMap, u64>, - bonded_balances: indexmap::IndexMap, (Address, u64)>, + bonded_balances: indexmap::IndexMap, (Address, Address, u64)>, rng: &mut ChaChaRng, ) -> Result> { // Construct the preimage. @@ -597,7 +600,12 @@ fn load_or_compute_genesis( preimage.extend(genesis_private_key.to_bytes_le()?); preimage.extend(committee.to_bytes_le()?); preimage.extend(&to_bytes_le![public_balances.iter().collect::>()]?); - preimage.extend(&to_bytes_le![bonded_balances.iter().collect::>()]?); + preimage.extend(&to_bytes_le![ + bonded_balances + .iter() + .flat_map(|(staker, (validator, withdrawal, amount))| to_bytes_le![staker, validator, withdrawal, amount]) + .collect::>() + ]?); // Input the parameters' metadata. preimage.extend(snarkvm::parameters::mainnet::BondPublicVerifier::METADATA.as_bytes()); From 15d63fd8f2f11d2238148ef7eac7edaac42884c2 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 8 Mar 2024 14:55:39 -0800 Subject: [PATCH 213/551] Use withdrawal addresses in test ledgers --- node/bft/tests/common/primary.rs | 11 +++++++---- node/bft/tests/components/mod.rs | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/node/bft/tests/common/primary.rs b/node/bft/tests/common/primary.rs index 43b4ce8d38..d1aa748852 100644 --- a/node/bft/tests/common/primary.rs +++ b/node/bft/tests/common/primary.rs @@ -131,8 +131,11 @@ impl TestNetwork { } let (accounts, committee) = new_test_committee(config.num_nodes); - let bonded_balances: IndexMap<_, _> = - committee.members().iter().map(|(address, (amount, _))| (*address, (*address, *amount))).collect(); + let bonded_balances: IndexMap<_, _> = committee + .members() + .iter() + .map(|(address, (amount, _))| (*address, (*address, *address, *amount))) + .collect(); let gen_key = *accounts[0].private_key(); let public_balance_per_validator = (1_500_000_000_000_000 - (config.num_nodes as u64) * 1_000_000_000_000) / (config.num_nodes as u64); @@ -350,7 +353,7 @@ pub fn genesis_block( genesis_private_key: PrivateKey, committee: Committee, public_balances: IndexMap, u64>, - bonded_balances: IndexMap, (Address, u64)>, + bonded_balances: IndexMap, (Address, Address, u64)>, rng: &mut (impl Rng + CryptoRng), ) -> Block { // Initialize the store. @@ -365,7 +368,7 @@ pub fn genesis_ledger( genesis_private_key: PrivateKey, committee: Committee, public_balances: IndexMap, u64>, - bonded_balances: IndexMap, (Address, u64)>, + bonded_balances: IndexMap, (Address, Address, u64)>, rng: &mut (impl Rng + CryptoRng), ) -> CurrentLedger { let cache_key = diff --git a/node/bft/tests/components/mod.rs b/node/bft/tests/components/mod.rs index 1a11df65a7..d4b9654d7f 100644 --- a/node/bft/tests/components/mod.rs +++ b/node/bft/tests/components/mod.rs @@ -39,7 +39,7 @@ pub fn sample_ledger( ) -> Arc>> { let (accounts, committee) = primary::new_test_committee(num_nodes); let bonded_balances: IndexMap<_, _> = - committee.members().iter().map(|(address, (amount, _))| (*address, (*address, *amount))).collect(); + committee.members().iter().map(|(address, (amount, _))| (*address, (*address, *address, *amount))).collect(); let gen_key = *accounts[0].private_key(); let public_balance_per_validator = (1_500_000_000_000_000 - (num_nodes as u64) * 1_000_000_000_000) / (num_nodes as u64); From 72fcd9ad85bcd7a08818c70024206ff931e5ce71 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Fri, 8 Mar 2024 16:07:36 -0800 Subject: [PATCH 214/551] Clippy --- node/bft/ledger-service/src/ledger.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/node/bft/ledger-service/src/ledger.rs b/node/bft/ledger-service/src/ledger.rs index ff9ca24cce..d278719005 100644 --- a/node/bft/ledger-service/src/ledger.rs +++ b/node/bft/ledger-service/src/ledger.rs @@ -41,6 +41,7 @@ use std::{ const COMMITTEE_CACHE_SIZE: usize = 16; /// A core ledger service. +#[allow(clippy::type_complexity)] pub struct CoreLedgerService> { ledger: Ledger, coinbase_verifying_key: Arc>, From 6ad228d52c5f94f213ed8842965b4d3593aa407e Mon Sep 17 00:00:00 2001 From: Raymond Chu <14917648+raychu86@users.noreply.github.com> Date: Fri, 8 Mar 2024 16:33:07 -0800 Subject: [PATCH 215/551] Update node/bft/src/bft.rs Co-authored-by: Howard Wu <9260812+howardwu@users.noreply.github.com> Signed-off-by: Raymond Chu <14917648+raychu86@users.noreply.github.com> --- node/bft/src/bft.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 35ea198962..bf363f0c18 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -807,10 +807,9 @@ impl BFT { /// Syncs the BFT DAG with the given batch certificates. These batch certificates **must** /// already exist in the ledger. /// - /// This method commits all the certificates into the dag. + /// This method commits all the certificates into the DAG. /// Note that there is no need to insert the certificates into the DAG, because these certificates - /// already exist in the ledger and therefor do not need to be re-ordered into future - /// committed subdags. + /// already exist in the ledger and therefore do not need to be re-ordered into future committed subdags. async fn sync_bft_dag_at_bootup(&self, certificates: Vec>) { // Acquire the BFT write lock. let mut dag = self.dag.write(); From 3b4737598690881e4b438ac5e19403724a2e9fa0 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Fri, 8 Mar 2024 18:14:45 -0800 Subject: [PATCH 216/551] bump(chore): snarkVM rev --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 631f31be53..8cf966087a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "46f2625" +rev = "eba8b44" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From de2bd055c2bd8dce1c7b7a634accedb466091cde Mon Sep 17 00:00:00 2001 From: Victor Sint Nicolaas Date: Sat, 9 Mar 2024 10:13:16 +0100 Subject: [PATCH 217/551] Rename dev_traffic to no_dev_txs; ensure tx generation remains the default --- .devnet/start.sh | 2 +- cli/src/commands/start.rs | 18 +++++++++--------- devnet.sh | 4 ++-- node/src/node.rs | 4 ++-- node/src/validator/mod.rs | 12 ++++++------ 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.devnet/start.sh b/.devnet/start.sh index 5214836d71..f61cea6af0 100755 --- a/.devnet/start.sh +++ b/.devnet/start.sh @@ -37,7 +37,7 @@ start_snarkos_in_tmux() { tmux new-session -d -s snarkos-session # Send the snarkOS start command to the tmux session with the NODE_ID - tmux send-keys -t "snarkos-session" "snarkos start --nodisplay --bft 0.0.0.0:5000 --rest 0.0.0.0:3030 --peers $NODE_IP:4130 --validators $NODE_IP:5000 --verbosity $VERBOSITY --dev $NODE_ID --dev-traffic --dev-num-validators $NUM_INSTANCES --validator --metrics" C-m + tmux send-keys -t "snarkos-session" "snarkos start --nodisplay --bft 0.0.0.0:5000 --rest 0.0.0.0:3030 --peers $NODE_IP:4130 --validators $NODE_IP:5000 --verbosity $VERBOSITY --dev $NODE_ID --dev-num-validators $NUM_INSTANCES --validator --metrics" C-m exit # Exit root user EOF diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index ad2b1a7825..e0b149c6bd 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -138,8 +138,8 @@ pub struct Start { #[clap(long)] pub dev_num_validators: Option, /// If developtment mode is enabled, specify whether node 0 should generate traffic to drive the network - #[clap(default_value = "false", long = "dev-traffic")] - pub dev_traffic: bool, + #[clap(default_value = "false", long = "no-dev-txs")] + pub no_dev_txs: bool, /// Specify the path to a directory containing the ledger #[clap(long = "storage_path")] pub storage_path: Option, @@ -527,13 +527,13 @@ impl Start { None => StorageMode::from(self.dev), }; - // Determine whether to generate background traffic in dev mode. - let dev_traffic = match self.dev { - Some(_) => self.dev_traffic, + // Determine whether to generate background transactions in dev mode. + let dev_txs = match self.dev { + Some(_) => !self.no_dev_txs, None => { - // If the `dev_traffic` flag is set, inform the user that it is ignored. - if self.dev_traffic { - eprintln!("The '--dev-traffic' flag is ignored because '--dev' is not set"); + // If the `no_dev_txs` flag is set, inform the user that it is ignored. + if self.no_dev_txs { + eprintln!("The '--no-dev-txs' flag is ignored because '--dev' is not set"); } false } @@ -542,7 +542,7 @@ impl Start { // Initialize the node. let bft_ip = if self.dev.is_some() { self.bft } else { None }; match node_type { - NodeType::Validator => Node::new_validator(self.node, bft_ip, rest_ip, self.rest_rps, account, &trusted_peers, &trusted_validators, genesis, cdn, storage_mode, dev_traffic).await, + NodeType::Validator => Node::new_validator(self.node, bft_ip, rest_ip, self.rest_rps, account, &trusted_peers, &trusted_validators, genesis, cdn, storage_mode, dev_txs).await, NodeType::Prover => Node::new_prover(self.node, account, &trusted_peers, genesis, storage_mode).await, NodeType::Client => Node::new_client(self.node, rest_ip, self.rest_rps, account, &trusted_peers, genesis, cdn, storage_mode).await, } diff --git a/devnet.sh b/devnet.sh index f4458625a2..e91627335a 100755 --- a/devnet.sh +++ b/devnet.sh @@ -64,12 +64,12 @@ for validator_index in "${validator_indices[@]}"; do # Send the command to start the validator to the new window and capture output to the log file if [ "$validator_index" -eq 0 ]; then - tmux send-keys -t "devnet:window$validator_index" "snarkos start --nodisplay --dev $validator_index --dev-traffic --dev-num-validators $total_validators --validator --logfile $log_file --metrics" C-m + tmux send-keys -t "devnet:window$validator_index" "snarkos start --nodisplay --dev $validator_index --dev-num-validators $total_validators --validator --logfile $log_file --metrics" C-m else # Create a new window with a unique name window_index=$((validator_index + index_offset)) tmux new-window -t "devnet:$window_index" -n "window$validator_index" - tmux send-keys -t "devnet:window$validator_index" "snarkos start --nodisplay --dev $validator_index --dev-traffic --dev-num-validators $total_validators --validator --logfile $log_file" C-m + tmux send-keys -t "devnet:window$validator_index" "snarkos start --nodisplay --dev $validator_index --dev-num-validators $total_validators --validator --logfile $log_file" C-m fi done diff --git a/node/src/node.rs b/node/src/node.rs index 0203f505e0..d98376d384 100644 --- a/node/src/node.rs +++ b/node/src/node.rs @@ -50,7 +50,7 @@ impl Node { genesis: Block, cdn: Option, storage_mode: StorageMode, - dev_traffic: bool, + dev_txs: bool, ) -> Result { Ok(Self::Validator(Arc::new( Validator::new( @@ -64,7 +64,7 @@ impl Node { genesis, cdn, storage_mode, - dev_traffic, + dev_txs, ) .await?, ))) diff --git a/node/src/validator/mod.rs b/node/src/validator/mod.rs index 0c3431ddc4..23b4f76920 100644 --- a/node/src/validator/mod.rs +++ b/node/src/validator/mod.rs @@ -83,7 +83,7 @@ impl> Validator { genesis: Block, cdn: Option, storage_mode: StorageMode, - dev_traffic: bool, + dev_txs: bool, ) -> Result { // Prepare the shutdown flag. let shutdown: Arc = Default::default(); @@ -140,7 +140,7 @@ impl> Validator { shutdown, }; // Initialize the transaction pool. - node.initialize_transaction_pool(storage_mode, dev_traffic)?; + node.initialize_transaction_pool(storage_mode, dev_txs)?; // Initialize the REST server. if let Some(rest_ip) = rest_ip { @@ -340,7 +340,7 @@ impl> Validator { // } /// Initialize the transaction pool. - fn initialize_transaction_pool(&self, storage_mode: StorageMode, dev_traffic: bool) -> Result<()> { + fn initialize_transaction_pool(&self, storage_mode: StorageMode, dev_txs: bool) -> Result<()> { use snarkvm::console::{ program::{Identifier, Literal, ProgramID, Value}, types::U64, @@ -355,7 +355,7 @@ impl> Validator { // If the node is running in development mode, only generate if you are allowed. StorageMode::Development(id) => { // If the node is not the first node, or if we should not create dev traffic, do not start the loop. - if id != 0 || !dev_traffic { + if id != 0 || !dev_txs { return Ok(()); } } @@ -473,7 +473,7 @@ mod tests { let node = SocketAddr::from_str("0.0.0.0:4130").unwrap(); let rest = SocketAddr::from_str("0.0.0.0:3030").unwrap(); let storage_mode = StorageMode::Development(0); - let dev_traffic = true; + let dev_txs = true; // Initialize an (insecure) fixed RNG. let mut rng = ChaChaRng::seed_from_u64(1234567890u64); @@ -497,7 +497,7 @@ mod tests { genesis, None, storage_mode, - dev_traffic, + dev_txs, ) .await .unwrap(); From 8a0145c356366e2e747d95851bca37311ea7482f Mon Sep 17 00:00:00 2001 From: Victor Sint Nicolaas Date: Sat, 9 Mar 2024 10:13:24 +0100 Subject: [PATCH 218/551] Revert "add --dev-traffic usage to README" This reverts commit 281acb5d355f2ed5166b3217084eaf910afa0b90. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2807478563..6fa2186ca0 100644 --- a/README.md +++ b/README.md @@ -210,7 +210,7 @@ OPTIONS: In the first terminal, start the first validator by running: ``` -cargo run --release -- start --nodisplay --dev 0 --validator --dev-traffic +cargo run --release -- start --nodisplay --dev 0 --validator ``` In the second terminal, start the second validator by running: ``` From 6003adbfa4c2bb8beec9588e29f0e0be5df88328 Mon Sep 17 00:00:00 2001 From: Jos Dehaes Date: Sun, 10 Mar 2024 23:33:04 +0100 Subject: [PATCH 219/551] fix: rename parameter --- cli/src/commands/start.rs | 6 +++--- node/router/src/handshake.rs | 4 ++-- node/router/src/heartbeat.rs | 4 ++-- node/router/src/inbound.rs | 2 +- node/router/src/lib.rs | 10 +++++----- node/src/node.rs | 4 ++-- node/src/validator/mod.rs | 4 ++-- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index b655be403a..796061cd9f 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -145,9 +145,9 @@ pub struct Start { /// If development mode is enabled, specify the custom bonded balances as a json object. (default: None) dev_bonded_balances: Option, - #[clap(long = "allow-outside-peers")] + #[clap(long = "allow-external-peers")] /// If the flag is set, the validator will allow untrusted peers to connect - allow_outside_peers: bool, + allow_external_peers: bool, } impl Start { @@ -531,7 +531,7 @@ impl Start { // Initialize the node. let bft_ip = if self.dev.is_some() { self.bft } else { None }; match node_type { - NodeType::Validator => Node::new_validator(self.node, bft_ip, rest_ip, self.rest_rps, account, &trusted_peers, &trusted_validators, genesis, cdn, storage_mode, self.allow_outside_peers).await, + NodeType::Validator => Node::new_validator(self.node, bft_ip, rest_ip, self.rest_rps, account, &trusted_peers, &trusted_validators, genesis, cdn, storage_mode, self.allow_external_peers).await, NodeType::Prover => Node::new_prover(self.node, account, &trusted_peers, genesis, storage_mode).await, NodeType::Client => Node::new_client(self.node, rest_ip, self.rest_rps, account, &trusted_peers, genesis, cdn, storage_mode).await, } diff --git a/node/router/src/handshake.rs b/node/router/src/handshake.rs index 8a45cee439..d5ef8cf87a 100644 --- a/node/router/src/handshake.rs +++ b/node/router/src/handshake.rs @@ -265,9 +265,9 @@ impl Router { bail!("Dropping connection request from '{peer_ip}' (already connected)") } // Only allow trusted peers to connect if we are a validator - // (unless allow_outside_peers is set) + // (unless allow_external_peers is set) let is_validator = self.node_type().is_validator(); - if is_validator && !self.allow_outside_peers() && !self.is_trusted(&peer_ip) { + if is_validator && !self.allow_external_peers() && !self.is_trusted(&peer_ip) { bail!("Dropping connection request from '{peer_ip}' (untrusted)") } // Ensure the peer is not restricted. diff --git a/node/router/src/heartbeat.rs b/node/router/src/heartbeat.rs index 599da2c6ea..7498b7d033 100644 --- a/node/router/src/heartbeat.rs +++ b/node/router/src/heartbeat.rs @@ -109,7 +109,7 @@ pub trait Heartbeat: Outbound { let is_validator = self.router().node_type().is_validator(); // Skip if the node is not requesting peers. - if is_validator && !self.router().allow_outside_peers() { + if is_validator && !self.router().allow_external_peers() { return; } @@ -223,7 +223,7 @@ pub trait Heartbeat: Outbound { self.router().connect(peer_ip); } let is_validator = self.router().node_type().is_validator(); - if !is_validator || self.router().allow_outside_peers() { + if !is_validator || self.router().allow_external_peers() { // Request more peers from the connected peers. for peer_ip in self.router().connected_peers().into_iter().choose_multiple(rng, 3) { self.send(peer_ip, Message::PeerRequest(PeerRequest)); diff --git a/node/router/src/inbound.rs b/node/router/src/inbound.rs index a44098042d..10c032936c 100644 --- a/node/router/src/inbound.rs +++ b/node/router/src/inbound.rs @@ -125,7 +125,7 @@ pub trait Inbound: Reading + Outbound { if !self.router().cache.contains_outbound_peer_request(peer_ip) { bail!("Peer '{peer_ip}' is not following the protocol (unexpected peer response)") } - if self.router().node_type().is_validator() && !self.router().allow_outside_peers() { + if self.router().node_type().is_validator() && !self.router().allow_external_peers() { bail!("Not accepting peer response from '{peer_ip}' (validator gossip is disabled)"); } diff --git a/node/router/src/lib.rs b/node/router/src/lib.rs index 5bba3cac41..239202b7d4 100644 --- a/node/router/src/lib.rs +++ b/node/router/src/lib.rs @@ -96,7 +96,7 @@ pub struct InnerRouter { /// The boolean flag for the development mode. is_dev: bool, /// If the flag is set, the node will not engage in P2P gossip to request more peers. - allow_outside_peers: bool, + allow_external_peers: bool, } impl Router { @@ -118,7 +118,7 @@ impl Router { trusted_peers: &[SocketAddr], max_peers: u16, is_dev: bool, - allow_outside_peers: bool, + allow_external_peers: bool, ) -> Result { // Initialize the TCP stack. let tcp = Tcp::new(Config::new(node_ip, max_peers)); @@ -136,7 +136,7 @@ impl Router { restricted_peers: Default::default(), handles: Default::default(), is_dev, - allow_outside_peers, + allow_external_peers, }))) } } @@ -256,8 +256,8 @@ impl Router { } /// Returns `true` if the node is not engaging in P2P gossip to request more peers. - pub fn allow_outside_peers(&self) -> bool { - self.allow_outside_peers + pub fn allow_external_peers(&self) -> bool { + self.allow_external_peers } /// Returns the listener IP address from the (ambiguous) peer address. diff --git a/node/src/node.rs b/node/src/node.rs index 563f81f152..5fcdd5ea5d 100644 --- a/node/src/node.rs +++ b/node/src/node.rs @@ -50,7 +50,7 @@ impl Node { genesis: Block, cdn: Option, storage_mode: StorageMode, - allow_outside_peers: bool, + allow_external_peers: bool, ) -> Result { Ok(Self::Validator(Arc::new( Validator::new( @@ -64,7 +64,7 @@ impl Node { genesis, cdn, storage_mode, - allow_outside_peers, + allow_external_peers, ) .await?, ))) diff --git a/node/src/validator/mod.rs b/node/src/validator/mod.rs index 8add855f6f..cf8bbf13b8 100644 --- a/node/src/validator/mod.rs +++ b/node/src/validator/mod.rs @@ -83,7 +83,7 @@ impl> Validator { genesis: Block, cdn: Option, storage_mode: StorageMode, - allow_outside_peers: bool, + allow_external_peers: bool, ) -> Result { // Prepare the shutdown flag. let shutdown: Arc = Default::default(); @@ -126,7 +126,7 @@ impl> Validator { trusted_peers, Self::MAXIMUM_NUMBER_OF_PEERS as u16, matches!(storage_mode, StorageMode::Development(_)), - allow_outside_peers, + allow_external_peers, ) .await?; From 044ff0c516ee7aa6cc2caf060cd9200470ddd3b3 Mon Sep 17 00:00:00 2001 From: mdelle1 <108158289+mdelle1@users.noreply.github.com> Date: Mon, 11 Mar 2024 11:54:59 -0400 Subject: [PATCH 220/551] Updates unit tests for advancing from even and odd rounds --- node/bft/src/bft.rs | 119 ++++++++++++++++++++++++++++++++------------ 1 file changed, 87 insertions(+), 32 deletions(-) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 3ea0cd4b67..a351b5c282 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -906,34 +906,52 @@ mod tests { fn test_is_leader_quorum_odd() -> Result<()> { let rng = &mut TestRng::default(); - // Sample the test instance. - let (_, account, ledger, storage) = sample_test_instance(None, 10, rng); - assert_eq!(storage.max_gc_rounds(), 10); - - // Initialize the BFT. - let bft = BFT::new(account, storage, ledger, None, &[], None)?; - assert!(bft.is_timer_expired()); // 0 + 5 < now() + // Sample batch certificates. + let mut certificates = IndexSet::new(); + certificates.insert(snarkvm::ledger::narwhal::batch_certificate::test_helpers::sample_batch_certificate_for_round_with_previous_certificate_ids(1, IndexSet::new(), rng)); + certificates.insert(snarkvm::ledger::narwhal::batch_certificate::test_helpers::sample_batch_certificate_for_round_with_previous_certificate_ids(1, IndexSet::new(), rng)); + certificates.insert(snarkvm::ledger::narwhal::batch_certificate::test_helpers::sample_batch_certificate_for_round_with_previous_certificate_ids(1, IndexSet::new(), rng)); + certificates.insert(snarkvm::ledger::narwhal::batch_certificate::test_helpers::sample_batch_certificate_for_round_with_previous_certificate_ids(1, IndexSet::new(), rng)); + + // Initialize the committee. + let committee = snarkvm::ledger::committee::test_helpers::sample_committee_for_round_and_members( + 1, + vec![ + certificates[0].author(), + certificates[1].author(), + certificates[2].author(), + certificates[3].author(), + ], + rng, + ); + // Initialize the ledger. + let ledger = Arc::new(MockLedgerService::new(committee.clone())); + // Initialize the storage. + let storage = Storage::new(ledger.clone(), Arc::new(BFTMemoryService::new()), 10); + // Initialize the account. + let account = Account::new(rng)?; + // Initialize the BFT. + let bft = BFT::new(account.clone(), storage.clone(), ledger.clone(), None, &[], None)?; + assert!(bft.is_timer_expired()); + // Ensure this call succeeds on an odd round. + let result = bft.is_leader_quorum_or_nonleaders_available(1); + // If timer has expired but quorum threshold is not reached, return 'false'. + assert!(!result); + // Insert certificates into storage. + for certificate in certificates.iter() { + storage.testing_only_insert_certificate_testing_only(certificate.clone()); + } // Ensure this call succeeds on an odd round. let result = bft.is_leader_quorum_or_nonleaders_available(1); assert!(result); // no previous leader certificate - // Set the leader certificate. let leader_certificate = sample_batch_certificate(rng); *bft.leader_certificate.write() = Some(leader_certificate); - // Ensure this call succeeds on an odd round. let result = bft.is_leader_quorum_or_nonleaders_available(1); assert!(result); // should now fall through to the end of function - // Set the timer to now(). - bft.leader_certificate_timer.store(now(), Ordering::SeqCst); - assert!(!bft.is_timer_expired()); - - // Ensure this call succeeds on an odd round. - let result = bft.is_leader_quorum_or_nonleaders_available(1); - // Should now return false, as the timer is not expired. - assert!(!result); // should now fall through to end of function Ok(()) } @@ -983,27 +1001,64 @@ mod tests { #[test] #[tracing_test::traced_test] fn test_is_even_round_ready() -> Result<()> { + use crate::MAX_LEADER_CERTIFICATE_DELAY_IN_SECS; let rng = &mut TestRng::default(); - // Sample the test instance. - let (committee, account, ledger, storage) = sample_test_instance(Some(2), 10, rng); - assert_eq!(committee.starting_round(), 2); - assert_eq!(storage.current_round(), 2); - assert_eq!(storage.max_gc_rounds(), 10); - - // Initialize the BFT. - let bft = BFT::new(account, storage, ledger, None, &[], None)?; - - let result = bft.is_even_round_ready_for_next_round(IndexSet::new(), committee.clone(), 2); - assert!(!result); + // Sample batch certificates. + let mut certificates = IndexSet::new(); + certificates.insert(sample_batch_certificate_for_round(2, rng)); + certificates.insert(sample_batch_certificate_for_round(2, rng)); + certificates.insert(sample_batch_certificate_for_round(2, rng)); + certificates.insert(sample_batch_certificate_for_round(2, rng)); + + // Initialize the committee. + let committee = snarkvm::ledger::committee::test_helpers::sample_committee_for_round_and_members( + 2, + vec![ + certificates[0].author(), + certificates[1].author(), + certificates[2].author(), + certificates[3].author(), + ], + rng, + ); + // Initialize the ledger. + let ledger = Arc::new(MockLedgerService::new(committee.clone())); + // Initialize the storage. + let storage = Storage::new(ledger.clone(), Arc::new(BFTMemoryService::new()), 10); + // Initialize the account. + let account = Account::new(rng)?; + // Initialize the BFT. + let bft = BFT::new(account.clone(), storage.clone(), ledger.clone(), None, &[], None)?; // Set the leader certificate. let leader_certificate = sample_batch_certificate_for_round(2, rng); *bft.leader_certificate.write() = Some(leader_certificate); - - let result = bft.is_even_round_ready_for_next_round(IndexSet::new(), committee, 2); - // If leader certificate is set, we should be ready for next round. - assert!(result); + let result = bft.is_even_round_ready_for_next_round(IndexSet::new(), committee.clone(), 2); + // If leader certificate is set but quorum threshold is not reached, we are not ready for the next round. + assert!(!result); + // Once quorum threshold is reached, we are ready for the next round. + let result = bft.is_even_round_ready_for_next_round(certificates.clone(), committee.clone(), 2); + assert!(result); + + // Initialize a new BFT. + let bft_timer = BFT::new(account.clone(), storage.clone(), ledger.clone(), None, &[], None)?; + // If the leader certificate is not set and the timer has not expired, we are not ready for the next round. + let result = bft_timer.is_even_round_ready_for_next_round(certificates.clone(), committee.clone(), 2); + if !bft_timer.is_timer_expired() { + assert!(!result); + } + // Wait for the timer to expire. + let leader_certificate_timeout = std::time::Duration::from_millis(MAX_LEADER_CERTIFICATE_DELAY_IN_SECS as u64 * 1000); + std::thread::sleep(leader_certificate_timeout); + // Once the leader certificate timer has expired and quorum threshold is reached, we are ready to advance to the next round. + let result = bft_timer.is_even_round_ready_for_next_round(certificates.clone(), committee.clone(), 2); + if bft_timer.is_timer_expired() { + assert!(result); + } else { + assert!(!result); + } + Ok(()) } From f57c6945360ce6910a96a41cdc4de76bac4cf071 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 11 Mar 2024 10:20:49 -0700 Subject: [PATCH 221/551] Optimize is_authorized_validator_address --- node/bft/src/gateway.rs | 43 ++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/node/bft/src/gateway.rs b/node/bft/src/gateway.rs index c51184fece..2da658a480 100644 --- a/node/bft/src/gateway.rs +++ b/node/bft/src/gateway.rs @@ -334,35 +334,38 @@ impl Gateway { /// Returns `true` if the given address is an authorized validator. pub fn is_authorized_validator_address(&self, validator_address: Address) -> bool { + // Determine if the validator address is a member of the committee lookback, + // the current committee, or the previous committee lookbacks. + // We allow leniency in this validation check in order to accommodate these two scenarios: + // 1. New validators should be able to connect immediately once bonded as a committee member. + // 2. Existing validators must remain connected until they are no longer bonded as a committee member. + // (i.e. meaning they must stay online until the next block has been produced) + + // Determine if the validator is in the current committee with lookback. + if self + .ledger + .get_committee_lookback_for_round(self.storage.current_round()) + .map_or(false, |committee| committee.is_committee_member(validator_address)) + { + return true; + } + + // Determine if the validator is in the latest committee on the ledger. + if self.ledger.current_committee().map_or(false, |committee| committee.is_committee_member(validator_address)) { + return true; + } + // Retrieve the previous block height to consider from the sync tolerance. let previous_block_height = self.ledger.latest_block_height().saturating_sub(MAX_BLOCKS_BEHIND); // Determine if the validator is in any of the previous committee lookbacks. - let exists_in_previous_committee_lookback = match self.ledger.get_block_round(previous_block_height) { + match self.ledger.get_block_round(previous_block_height) { Ok(block_round) => (block_round..self.storage.current_round()).step_by(2).any(|round| { self.ledger .get_committee_lookback_for_round(round) .map_or(false, |committee| committee.is_committee_member(validator_address)) }), Err(_) => false, - }; - - // Determine if the validator is in the current committee with lookback. - let exists_in_current_committee_lookback = self - .ledger - .get_committee_lookback_for_round(self.storage.current_round()) - .map_or(false, |committee| committee.is_committee_member(validator_address)); - - // Determine if the validator is in the latest committee on the ledger. - let exists_in_latest_committee = - self.ledger.current_committee().map_or(false, |committee| committee.is_committee_member(validator_address)); - - // Determine if the validator address is a member of the previous committee lookbacks, - // the committee lookback, or the current committee. - // We allow leniency in this validation check in order to accommodate these two scenarios: - // 1. New validators should be able to connect immediately once bonded as a committee member. - // 2. Existing validators must remain connected until they are no longer bonded as a committee member. - // (i.e. meaning they must stay online until the next block has been produced) - exists_in_previous_committee_lookback || exists_in_current_committee_lookback || exists_in_latest_committee + } } /// Returns the maximum number of connected peers. From 7d8d262c665928c21d199044b789c5bcccaac7fa Mon Sep 17 00:00:00 2001 From: mdelle1 <108158289+mdelle1@users.noreply.github.com> Date: Mon, 11 Mar 2024 18:29:30 -0400 Subject: [PATCH 222/551] Adds unit test for authorized validators --- node/bft/src/gateway.rs | 61 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/node/bft/src/gateway.rs b/node/bft/src/gateway.rs index 2da658a480..731335b7d8 100644 --- a/node/bft/src/gateway.rs +++ b/node/bft/src/gateway.rs @@ -1555,4 +1555,65 @@ mod prop_tests { ); assert_eq!(gateway.num_workers(), workers.len() as u8); } + #[proptest] + fn test_is_authorized_validator(#[strategy(any_valid_dev_gateway())] input: GatewayInput) { + use indexmap::IndexSet; + use crate::helpers::Storage; + use snarkos_account::Account; + use snarkos_node_bft_ledger_service::MockLedgerService; + use snarkos_node_bft_storage_service::BFTMemoryService; + use snarkvm::{ + ledger::{ + narwhal::batch_certificate::test_helpers::sample_batch_certificate_for_round, + committee::test_helpers::sample_committee_for_round_and_members, + }, + utilities::TestRng, + }; + let rng = &mut TestRng::default(); + + // Initialize the round parameters. + let current_round = 2; + let committee_size = 4; + let max_gc_rounds = snarkvm::ledger::narwhal::BatchHeader::::MAX_GC_ROUNDS as u64; + let (_, _, private_key, dev) = input; + let account = Account::try_from(private_key).unwrap(); + + // Sample the certificates. + let mut certificates = IndexSet::new(); + for _ in 0..committee_size{ + certificates.insert(sample_batch_certificate_for_round(current_round, rng)); + } + let addresses: Vec<_> = certificates.iter() + .map(|certificate| certificate.author()) + .collect(); + // Initialize the committee. + let committee = sample_committee_for_round_and_members( + current_round, + addresses, + rng, + ); + // Sample extra certificates from non-committee members. + for _ in 0..committee_size{ + certificates.insert(sample_batch_certificate_for_round(current_round, rng)); + } + // Initialize the ledger. + let ledger = Arc::new(MockLedgerService::new(committee.clone())); + // Initialize the storage. + let storage = Storage::new(ledger.clone(), Arc::new(BFTMemoryService::new()), max_gc_rounds); + // Initialize the gateway. + let gateway = Gateway::new(account.clone(), storage.clone(), ledger.clone(), dev.ip(), &[], dev.port()).unwrap(); + // Insert certificate to the storage. + for certificate in certificates.iter() { + storage.testing_only_insert_certificate_testing_only(certificate.clone()); + } + // Check that the current committee members are authorized validators. + for i in 0..certificates.clone().len(){ + let is_authorized = gateway.is_authorized_validator_address(certificates[i].author()); + if i < committee_size { + assert!(is_authorized); + } else { + assert!(!is_authorized); + } + } + } } From a13fea18f3e8030f4e6f9c1445dc6378b0ff5971 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 11 Mar 2024 15:49:04 -0700 Subject: [PATCH 223/551] Unify pending and callbacks into a single object --- node/bft/src/helpers/pending.rs | 121 ++++++++++++++++------------ node/bft/src/sync/mod.rs | 2 +- node/bft/src/worker.rs | 2 +- node/bft/tests/components/worker.rs | 8 +- 4 files changed, 75 insertions(+), 58 deletions(-) diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index d37275fdf2..6e43a65c4f 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -16,7 +16,7 @@ use crate::MAX_FETCH_TIMEOUT_IN_MS; use snarkos_node_bft_ledger_service::LedgerService; use snarkvm::{console::network::Network, ledger::committee::Committee}; -use parking_lot::{Mutex, RwLock}; +use parking_lot::RwLock; use std::{ collections::{HashMap, HashSet}, hash::Hash, @@ -47,11 +47,9 @@ pub fn max_redundant_requests(ledger: Arc>, rou #[derive(Debug)] pub struct Pending { - /// The map of pending `items` to `peer IPs` that have the item. - pending: RwLock>>, - /// The optional callback queue. + /// The map of pending `items` to a map of `peer IPs` and their optional `callback` queue. /// Each callback has a timeout and a flag indicating if it is associated with a sent request. - callbacks: Mutex, i64, bool)>>>, + pending: RwLock, i64, bool)>>>>, } impl Default for Pending { @@ -64,7 +62,7 @@ impl Default for Pending Pending { /// Initializes a new instance of the pending queue. pub fn new() -> Self { - Self { pending: Default::default(), callbacks: Default::default() } + Self { pending: Default::default() } } /// Returns `true` if the pending queue is empty. @@ -84,12 +82,12 @@ impl Pending { /// Returns `true` if the pending queue contains the specified `item` for the specified `peer IP`. pub fn contains_peer(&self, item: impl Into, peer_ip: SocketAddr) -> bool { - self.pending.read().get(&item.into()).map_or(false, |peer_ips| peer_ips.contains(&peer_ip)) + self.pending.read().get(&item.into()).map_or(false, |peer_ips| peer_ips.contains_key(&peer_ip)) } /// Returns the peer IPs for the specified `item`. - pub fn get(&self, item: impl Into) -> Option> { - self.pending.read().get(&item.into()).cloned() + pub fn get_peers(&self, item: impl Into) -> Option> { + self.pending.read().get(&item.into()).map(|map| map.keys().cloned().collect()) } /// Returns the number of pending callbacks for the specified `item`. @@ -98,7 +96,7 @@ impl Pending { // Clear the callbacks that have expired. self.clear_expired_callbacks_for_item(item); // Return the number of live callbacks. - self.callbacks.lock().get(&item).map_or(0, |callbacks| callbacks.len()) + self.pending.read().get(&item).map_or(0, |peers| peers.values().flatten().count()) } /// Returns the number of pending sent requests for the specified `item`. @@ -107,10 +105,10 @@ impl Pending { // Clear the callbacks that have expired. self.clear_expired_callbacks_for_item(item); // Return the number of live callbacks. - self.callbacks - .lock() + self.pending + .write() .get(&item) - .map_or(0, |callbacks| callbacks.iter().filter(|(_, _, request_sent)| *request_sent).count()) + .map_or(0, |peers| peers.values().flatten().filter(|(_, _, request_sent)| *request_sent).count()) } /// Inserts the specified `item` and `peer IP` to the pending queue, @@ -125,17 +123,27 @@ impl Pending { callback: Option<(oneshot::Sender, bool)>, ) -> bool { let item = item.into(); - // Insert the peer IP into the pending queue. - let result = self.pending.write().entry(item).or_default().insert(peer_ip); - - // If a callback is provided, insert it into the callback queue. - if let Some((callback, request_sent)) = callback { - self.callbacks.lock().entry(item).or_default().push(( - callback, - OffsetDateTime::now_utc().unix_timestamp(), - request_sent, - )); - } + // Insert the peer IP and optional callback into the pending queue. + let result = { + // Acquire the pending lock. + let mut pending = self.pending.write(); + + // Insert a peer into the pending queue. + let entry = pending.entry(item).or_default(); + + // Check if the peer IP is already present in the entry. + let is_new_peer = entry.contains_key(&peer_ip); + + // Get the entry for the peer IP. + let peer_entry = entry.entry(peer_ip).or_default(); + + // If a callback is provided, insert it into the callback queue. + if let Some((callback, request_sent)) = callback { + peer_entry.push((callback, OffsetDateTime::now_utc().unix_timestamp(), request_sent)); + } + + is_new_peer + }; // Clear the callbacks that have expired. self.clear_expired_callbacks_for_item(item); @@ -149,37 +157,46 @@ impl Pending { /// If the `item` does not exist, `None` is returned. pub fn remove(&self, item: impl Into, callback_value: Option) -> Option> { let item = item.into(); - // Remove the item from the pending queue. - let result = self.pending.write().remove(&item); - // Remove the callback for the item, and process any remaining callbacks. - if let Some(callbacks) = self.callbacks.lock().remove(&item) { - if let Some(callback_value) = callback_value { - // Send a notification to the callback. - for (callback, _, _) in callbacks { - callback.send(callback_value.clone()).ok(); + // Remove the item from the pending queue and process any remaining callbacks. + match self.pending.write().remove(&item) { + Some(callbacks) => { + // Get the peer IPs. + let peer_ips = callbacks.keys().cloned().collect(); + // Process the callbacks. + if let Some(callback_value) = callback_value { + // Send a notification to the callback. + for (callback, _, _) in callbacks.into_values().flat_map(|callbacks| callbacks.into_iter()) { + callback.send(callback_value.clone()).ok(); + } } + // Return the peer IPs. + Some(peer_ips) } + None => None, } - // Return the result. - result } /// Removes the callbacks for the specified `item` that have expired. pub fn clear_expired_callbacks_for_item(&self, item: impl Into) { let item = item.into(); - // Acquire the callbacks lock. - let mut callbacks = self.callbacks.lock(); + let now = OffsetDateTime::now_utc().unix_timestamp(); + + // Acquire the pending lock. + let mut pending = self.pending.write(); + // Clear the callbacks that have expired. - if let Some(callback_values) = callbacks.get_mut(&item) { - // Fetch the current timestamp. - let now = OffsetDateTime::now_utc().unix_timestamp(); - // Remove the callbacks that have expired. - callback_values.retain(|(_, timestamp, _)| now - *timestamp <= CALLBACK_EXPIRATION_IN_SECS); - - // If there are no more remaining callbacks for the item, remove the item from the pending queue. - if callback_values.is_empty() { - callbacks.remove(&item); - self.pending.write().remove(&item); + if let Some(peer_map) = pending.get_mut(&item) { + // Iterate over each peer IP for the item and filter out expired callbacks. + for (_, callbacks) in peer_map.iter_mut() { + callbacks.retain(|(_, timestamp, _)| now - *timestamp <= CALLBACK_EXPIRATION_IN_SECS); + } + + // Remove peer IPs that no longer have any callbacks. + peer_map.retain(|_, callbacks| !callbacks.is_empty()); + + // If there are no more remaining callbacks for the item across all peer IPs, remove the item from pending. + if peer_map.is_empty() { + pending.remove(&item); } } } @@ -250,10 +267,10 @@ mod tests { assert!(!pending.contains(unknown_id)); // Check get. - assert_eq!(pending.get(commitment_1), Some(HashSet::from([addr_1]))); - assert_eq!(pending.get(commitment_2), Some(HashSet::from([addr_2]))); - assert_eq!(pending.get(commitment_3), Some(HashSet::from([addr_3]))); - assert_eq!(pending.get(unknown_id), None); + assert_eq!(pending.get_peers(commitment_1), Some(HashSet::from([addr_1]))); + assert_eq!(pending.get_peers(commitment_2), Some(HashSet::from([addr_2]))); + assert_eq!(pending.get_peers(commitment_3), Some(HashSet::from([addr_3]))); + assert_eq!(pending.get_peers(unknown_id), None); // Check remove. assert!(pending.remove(commitment_1, None).is_some()); @@ -426,13 +443,13 @@ mod prop_tests { assert_eq!(pending.len(), input.count); assert!(!pending.is_empty()); assert!(!pending.contains(Item { id: input.count + 1 })); - assert_eq!(pending.get(Item { id: input.count + 1 }), None); + assert_eq!(pending.get_peers(Item { id: input.count + 1 }), None); assert!(pending.remove(Item { id: input.count + 1 }, None).is_none()); for i in 0..input.count { assert!(pending.contains(Item { id: i })); let peer_ip = SocketAddr::from(([127, 0, 0, 1], i as u16)); assert!(pending.contains_peer(Item { id: i }, peer_ip)); - assert_eq!(pending.get(Item { id: i }), Some(HashSet::from([peer_ip]))); + assert_eq!(pending.get_peers(Item { id: i }), Some(HashSet::from([peer_ip]))); assert!(pending.remove(Item { id: i }, None).is_some()); } assert!(pending.is_empty()); diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index 483c239dff..85475e5701 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -472,7 +472,7 @@ impl Sync { fn finish_certificate_request(&self, peer_ip: SocketAddr, response: CertificateResponse) { let certificate = response.certificate; // Check if the peer IP exists in the pending queue for the given certificate ID. - let exists = self.pending.get(certificate.id()).unwrap_or_default().contains(&peer_ip); + let exists = self.pending.get_peers(certificate.id()).unwrap_or_default().contains(&peer_ip); // If the peer IP exists, finish the pending request. if exists { // TODO: Validate the certificate. diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index 14f9e5e823..50c2c5fd63 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -437,7 +437,7 @@ impl Worker { fn finish_transmission_request(&self, peer_ip: SocketAddr, response: TransmissionResponse) { let TransmissionResponse { transmission_id, mut transmission } = response; // Check if the peer IP exists in the pending queue for the given transmission ID. - let exists = self.pending.get(transmission_id).unwrap_or_default().contains(&peer_ip); + let exists = self.pending.get_peers(transmission_id).unwrap_or_default().contains(&peer_ip); // If the peer IP exists, finish the pending request. if exists { // Ensure the transmission is not a fee and matches the transmission ID. diff --git a/node/bft/tests/components/worker.rs b/node/bft/tests/components/worker.rs index 279bc1bf92..9c76a85df6 100644 --- a/node/bft/tests/components/worker.rs +++ b/node/bft/tests/components/worker.rs @@ -54,7 +54,7 @@ async fn test_resend_transmission_request() { assert!(pending.contains(transmission_id), "Missing a transmission in the pending queue"); // Ensure the peer IP is in the pending queue for the transmission ID. assert!(pending.contains_peer(transmission_id, peer_ip), "Missing a peer IP for transmission in the pending queue"); - assert_eq!(pending.get(transmission_id), Some([peer_ip].into_iter().collect()), "Missing a peer IP for transmission in the pending queue"); + assert_eq!(pending.get_peers(transmission_id), Some([peer_ip].into_iter().collect()), "Missing a peer IP for transmission in the pending queue"); // Ensure the number of callbacks is correct. assert_eq!(pending.num_callbacks(transmission_id), 1, "Incorrect number of callbacks for transmission"); // Ensure the number of sent requests is correct. @@ -71,7 +71,7 @@ async fn test_resend_transmission_request() { assert!(pending.contains(transmission_id), "Missing a transmission in the pending queue"); // Ensure the peer IP is in the pending queue for the transmission ID. assert!(pending.contains_peer(transmission_id, peer_ip), "Missing a peer IP for transmission in the pending queue"); - assert_eq!(pending.get(transmission_id), Some([peer_ip].into_iter().collect()), "Missing a peer IP for transmission in the pending queue"); + assert_eq!(pending.get_peers(transmission_id), Some([peer_ip].into_iter().collect()), "Missing a peer IP for transmission in the pending queue"); // Ensure the number of callbacks is correct. assert_eq!(pending.num_callbacks(transmission_id), 1 + i, "Incorrect number of callbacks for transmission"); // Ensure the number of sent requests is correct. @@ -115,7 +115,7 @@ async fn test_flood_transmission_requests() { assert!(pending.contains(transmission_id), "Missing a transmission in the pending queue"); // Ensure the peer IP is in the pending queue for the transmission ID. assert!(pending.contains_peer(transmission_id, peer_ip), "Missing a peer IP for transmission in the pending queue"); - assert_eq!(pending.get(transmission_id), Some([peer_ip].into_iter().collect()), "Missing a peer IP for transmission in the pending queue"); + assert_eq!(pending.get_peers(transmission_id), Some([peer_ip].into_iter().collect()), "Missing a peer IP for transmission in the pending queue"); // Ensure the number of callbacks is correct. assert_eq!(pending.num_callbacks(transmission_id), max_redundancy, "Incorrect number of callbacks for transmission"); // Ensure the number of sent requests is correct. @@ -132,7 +132,7 @@ async fn test_flood_transmission_requests() { assert!(pending.contains(transmission_id), "Missing a transmission in the pending queue"); // Ensure the peer IP is in the pending queue for the transmission ID. assert!(pending.contains_peer(transmission_id, peer_ip), "Missing a peer IP for transmission in the pending queue"); - assert_eq!(pending.get(transmission_id), Some([peer_ip].into_iter().collect()), "Missing a peer IP for transmission in the pending queue"); + assert_eq!(pending.get_peers(transmission_id), Some([peer_ip].into_iter().collect()), "Missing a peer IP for transmission in the pending queue"); // Ensure the number of callbacks is correct. assert_eq!(pending.num_callbacks(transmission_id), max_redundancy + i, "Incorrect number of callbacks for transmission"); // Ensure the number of sent requests is correct. From d0443cc93ea694a45fbc8ec0083fa59980d8376e Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 11 Mar 2024 15:59:01 -0700 Subject: [PATCH 224/551] clippy --- node/bft/src/gateway.rs | 78 ++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 44 deletions(-) diff --git a/node/bft/src/gateway.rs b/node/bft/src/gateway.rs index 731335b7d8..82ba0d2b11 100644 --- a/node/bft/src/gateway.rs +++ b/node/bft/src/gateway.rs @@ -1365,16 +1365,22 @@ mod prop_tests { }; use snarkos_account::Account; use snarkos_node_bft_ledger_service::MockLedgerService; + use snarkos_node_bft_storage_service::BFTMemoryService; use snarkos_node_tcp::P2P; use snarkvm::{ - ledger::committee::{ - prop_tests::{CommitteeContext, ValidatorSet}, - Committee, + ledger::{ + committee::{ + prop_tests::{CommitteeContext, ValidatorSet}, + test_helpers::sample_committee_for_round_and_members, + Committee, + }, + narwhal::{batch_certificate::test_helpers::sample_batch_certificate_for_round, BatchHeader}, }, prelude::{MainnetV0, PrivateKey}, + utilities::TestRng, }; - use indexmap::IndexMap; + use indexmap::{IndexMap, IndexSet}; use proptest::{ prelude::{any, any_with, Arbitrary, BoxedStrategy, Just, Strategy}, sample::Selector, @@ -1555,64 +1561,48 @@ mod prop_tests { ); assert_eq!(gateway.num_workers(), workers.len() as u8); } + #[proptest] fn test_is_authorized_validator(#[strategy(any_valid_dev_gateway())] input: GatewayInput) { - use indexmap::IndexSet; - use crate::helpers::Storage; - use snarkos_account::Account; - use snarkos_node_bft_ledger_service::MockLedgerService; - use snarkos_node_bft_storage_service::BFTMemoryService; - use snarkvm::{ - ledger::{ - narwhal::batch_certificate::test_helpers::sample_batch_certificate_for_round, - committee::test_helpers::sample_committee_for_round_and_members, - }, - utilities::TestRng, - }; let rng = &mut TestRng::default(); - // Initialize the round parameters. - let current_round = 2; - let committee_size = 4; - let max_gc_rounds = snarkvm::ledger::narwhal::BatchHeader::::MAX_GC_ROUNDS as u64; + // Initialize the round parameters. + let current_round = 2; + let committee_size = 4; + let max_gc_rounds = BatchHeader::::MAX_GC_ROUNDS as u64; let (_, _, private_key, dev) = input; let account = Account::try_from(private_key).unwrap(); - // Sample the certificates. - let mut certificates = IndexSet::new(); - for _ in 0..committee_size{ - certificates.insert(sample_batch_certificate_for_round(current_round, rng)); + // Sample the certificates. + let mut certificates = IndexSet::new(); + for _ in 0..committee_size { + certificates.insert(sample_batch_certificate_for_round(current_round, rng)); } - let addresses: Vec<_> = certificates.iter() - .map(|certificate| certificate.author()) - .collect(); + let addresses: Vec<_> = certificates.iter().map(|certificate| certificate.author()).collect(); // Initialize the committee. - let committee = sample_committee_for_round_and_members( - current_round, - addresses, - rng, - ); - // Sample extra certificates from non-committee members. - for _ in 0..committee_size{ - certificates.insert(sample_batch_certificate_for_round(current_round, rng)); - } + let committee = sample_committee_for_round_and_members(current_round, addresses, rng); + // Sample extra certificates from non-committee members. + for _ in 0..committee_size { + certificates.insert(sample_batch_certificate_for_round(current_round, rng)); + } // Initialize the ledger. let ledger = Arc::new(MockLedgerService::new(committee.clone())); // Initialize the storage. let storage = Storage::new(ledger.clone(), Arc::new(BFTMemoryService::new()), max_gc_rounds); - // Initialize the gateway. - let gateway = Gateway::new(account.clone(), storage.clone(), ledger.clone(), dev.ip(), &[], dev.port()).unwrap(); + // Initialize the gateway. + let gateway = + Gateway::new(account.clone(), storage.clone(), ledger.clone(), dev.ip(), &[], dev.port()).unwrap(); // Insert certificate to the storage. for certificate in certificates.iter() { storage.testing_only_insert_certificate_testing_only(certificate.clone()); } // Check that the current committee members are authorized validators. - for i in 0..certificates.clone().len(){ - let is_authorized = gateway.is_authorized_validator_address(certificates[i].author()); - if i < committee_size { - assert!(is_authorized); - } else { - assert!(!is_authorized); + for i in 0..certificates.clone().len() { + let is_authorized = gateway.is_authorized_validator_address(certificates[i].author()); + if i < committee_size { + assert!(is_authorized); + } else { + assert!(!is_authorized); } } } From 0fcd8900f114d4b8513526e6dc801f532362a281 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 11 Mar 2024 16:57:44 -0700 Subject: [PATCH 225/551] nit --- node/bft/src/bft.rs | 73 ++++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 38 deletions(-) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index a351b5c282..386ad94404 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -857,10 +857,7 @@ impl BFT { #[cfg(test)] mod tests { - use crate::{ - helpers::{now, Storage}, - BFT, - }; + use crate::{helpers::Storage, BFT, MAX_LEADER_CERTIFICATE_DELAY_IN_SECS}; use snarkos_account::Account; use snarkos_node_bft_ledger_service::MockLedgerService; use snarkos_node_bft_storage_service::BFTMemoryService; @@ -874,7 +871,7 @@ mod tests { use anyhow::Result; use indexmap::IndexSet; - use std::sync::{atomic::Ordering, Arc}; + use std::sync::Arc; type CurrentNetwork = snarkvm::console::network::MainnetV0; @@ -906,13 +903,13 @@ mod tests { fn test_is_leader_quorum_odd() -> Result<()> { let rng = &mut TestRng::default(); - // Sample batch certificates. - let mut certificates = IndexSet::new(); - certificates.insert(snarkvm::ledger::narwhal::batch_certificate::test_helpers::sample_batch_certificate_for_round_with_previous_certificate_ids(1, IndexSet::new(), rng)); - certificates.insert(snarkvm::ledger::narwhal::batch_certificate::test_helpers::sample_batch_certificate_for_round_with_previous_certificate_ids(1, IndexSet::new(), rng)); - certificates.insert(snarkvm::ledger::narwhal::batch_certificate::test_helpers::sample_batch_certificate_for_round_with_previous_certificate_ids(1, IndexSet::new(), rng)); - certificates.insert(snarkvm::ledger::narwhal::batch_certificate::test_helpers::sample_batch_certificate_for_round_with_previous_certificate_ids(1, IndexSet::new(), rng)); - + // Sample batch certificates. + let mut certificates = IndexSet::new(); + certificates.insert(snarkvm::ledger::narwhal::batch_certificate::test_helpers::sample_batch_certificate_for_round_with_previous_certificate_ids(1, IndexSet::new(), rng)); + certificates.insert(snarkvm::ledger::narwhal::batch_certificate::test_helpers::sample_batch_certificate_for_round_with_previous_certificate_ids(1, IndexSet::new(), rng)); + certificates.insert(snarkvm::ledger::narwhal::batch_certificate::test_helpers::sample_batch_certificate_for_round_with_previous_certificate_ids(1, IndexSet::new(), rng)); + certificates.insert(snarkvm::ledger::narwhal::batch_certificate::test_helpers::sample_batch_certificate_for_round_with_previous_certificate_ids(1, IndexSet::new(), rng)); + // Initialize the committee. let committee = snarkvm::ledger::committee::test_helpers::sample_committee_for_round_and_members( 1, @@ -931,14 +928,14 @@ mod tests { let storage = Storage::new(ledger.clone(), Arc::new(BFTMemoryService::new()), 10); // Initialize the account. let account = Account::new(rng)?; - // Initialize the BFT. + // Initialize the BFT. let bft = BFT::new(account.clone(), storage.clone(), ledger.clone(), None, &[], None)?; assert!(bft.is_timer_expired()); // Ensure this call succeeds on an odd round. let result = bft.is_leader_quorum_or_nonleaders_available(1); // If timer has expired but quorum threshold is not reached, return 'false'. - assert!(!result); - // Insert certificates into storage. + assert!(!result); + // Insert certificates into storage. for certificate in certificates.iter() { storage.testing_only_insert_certificate_testing_only(certificate.clone()); } @@ -1001,16 +998,15 @@ mod tests { #[test] #[tracing_test::traced_test] fn test_is_even_round_ready() -> Result<()> { - use crate::MAX_LEADER_CERTIFICATE_DELAY_IN_SECS; let rng = &mut TestRng::default(); - // Sample batch certificates. - let mut certificates = IndexSet::new(); - certificates.insert(sample_batch_certificate_for_round(2, rng)); - certificates.insert(sample_batch_certificate_for_round(2, rng)); - certificates.insert(sample_batch_certificate_for_round(2, rng)); - certificates.insert(sample_batch_certificate_for_round(2, rng)); - + // Sample batch certificates. + let mut certificates = IndexSet::new(); + certificates.insert(sample_batch_certificate_for_round(2, rng)); + certificates.insert(sample_batch_certificate_for_round(2, rng)); + certificates.insert(sample_batch_certificate_for_round(2, rng)); + certificates.insert(sample_batch_certificate_for_round(2, rng)); + // Initialize the committee. let committee = snarkvm::ledger::committee::test_helpers::sample_committee_for_round_and_members( 2, @@ -1029,36 +1025,37 @@ mod tests { let storage = Storage::new(ledger.clone(), Arc::new(BFTMemoryService::new()), 10); // Initialize the account. let account = Account::new(rng)?; - // Initialize the BFT. + // Initialize the BFT. let bft = BFT::new(account.clone(), storage.clone(), ledger.clone(), None, &[], None)?; // Set the leader certificate. let leader_certificate = sample_batch_certificate_for_round(2, rng); *bft.leader_certificate.write() = Some(leader_certificate); let result = bft.is_even_round_ready_for_next_round(IndexSet::new(), committee.clone(), 2); - // If leader certificate is set but quorum threshold is not reached, we are not ready for the next round. + // If leader certificate is set but quorum threshold is not reached, we are not ready for the next round. assert!(!result); - // Once quorum threshold is reached, we are ready for the next round. + // Once quorum threshold is reached, we are ready for the next round. let result = bft.is_even_round_ready_for_next_round(certificates.clone(), committee.clone(), 2); - assert!(result); + assert!(result); - // Initialize a new BFT. + // Initialize a new BFT. let bft_timer = BFT::new(account.clone(), storage.clone(), ledger.clone(), None, &[], None)?; // If the leader certificate is not set and the timer has not expired, we are not ready for the next round. let result = bft_timer.is_even_round_ready_for_next_round(certificates.clone(), committee.clone(), 2); - if !bft_timer.is_timer_expired() { - assert!(!result); + if !bft_timer.is_timer_expired() { + assert!(!result); } - // Wait for the timer to expire. - let leader_certificate_timeout = std::time::Duration::from_millis(MAX_LEADER_CERTIFICATE_DELAY_IN_SECS as u64 * 1000); - std::thread::sleep(leader_certificate_timeout); - // Once the leader certificate timer has expired and quorum threshold is reached, we are ready to advance to the next round. + // Wait for the timer to expire. + let leader_certificate_timeout = + std::time::Duration::from_millis(MAX_LEADER_CERTIFICATE_DELAY_IN_SECS as u64 * 1000); + std::thread::sleep(leader_certificate_timeout); + // Once the leader certificate timer has expired and quorum threshold is reached, we are ready to advance to the next round. let result = bft_timer.is_even_round_ready_for_next_round(certificates.clone(), committee.clone(), 2); - if bft_timer.is_timer_expired() { - assert!(result); + if bft_timer.is_timer_expired() { + assert!(result); } else { - assert!(!result); + assert!(!result); } - + Ok(()) } From c9e9d01cfc6bc01ace87567d082a5383dc3a6e57 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 11 Mar 2024 17:16:43 -0700 Subject: [PATCH 226/551] Clarify documentation --- node/bft/src/bft.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 5cf16cc236..cfa14536b9 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -323,10 +323,9 @@ impl BFT { self.is_even_round_ready_for_next_round(current_certificates, committee_lookback, current_round) } - /// Returns 'true' under one of the following conditions: - /// - If the leader certificate is set for the current even round, - /// - The timer for the leader certificate has expired, and we can - /// achieve quorum threshold (2f + 1) without the leader. + /// Returns 'true' if the quorum threshold is reached for this round under one of the following conditions: + /// - If the leader certificate is set for the current even round. + /// - The timer for the leader certificate has expired. fn is_even_round_ready_for_next_round( &self, certificates: IndexSet>, @@ -360,9 +359,8 @@ impl BFT { self.leader_certificate_timer.load(Ordering::SeqCst) + MAX_LEADER_CERTIFICATE_DELAY_IN_SECS <= now() } - /// Returns 'true' if any of the following conditions hold: - /// - The leader certificate is 'None'. - /// - The leader certificate reached quorum threshold `(2f + 1)` (in the previous certificates in the current round). + /// Returns 'true' if the quorum threshold is reached for this round under one of the following conditions: + /// - The leader certificate is `None`. /// - The leader certificate is not included up to availability threshold `(f + 1)` (in the previous certificates of the current round). /// - The leader certificate timer has expired. fn is_leader_quorum_or_nonleaders_available(&self, odd_round: u64) -> bool { @@ -853,6 +851,7 @@ mod tests { use snarkos_node_bft_ledger_service::MockLedgerService; use snarkos_node_bft_storage_service::BFTMemoryService; use snarkvm::{ + console::account::{Address, PrivateKey}, ledger::{ committee::Committee, narwhal::batch_certificate::test_helpers::{sample_batch_certificate, sample_batch_certificate_for_round}, @@ -861,7 +860,7 @@ mod tests { }; use anyhow::Result; - use indexmap::IndexSet; + use indexmap::{IndexMap, IndexSet}; use std::sync::Arc; type CurrentNetwork = snarkvm::console::network::MainnetV0; From 12cca3582d38bc5d7251a4f2753f2f8b69d471ba Mon Sep 17 00:00:00 2001 From: Victor Sint Nicolaas Date: Tue, 12 Mar 2024 14:59:11 +0100 Subject: [PATCH 227/551] Increase CAPACITY_FOR_DEPLOYMENTS to 1 << 10 --- node/consensus/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 5a3c6b3bd3..a57d3bf6dc 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -55,7 +55,7 @@ use tokio::{ /// The capacity of the queue reserved for deployments. /// Note: This is an inbound queue capacity, not a Narwhal-enforced capacity. -const CAPACITY_FOR_DEPLOYMENTS: usize = 1 << 4; +const CAPACITY_FOR_DEPLOYMENTS: usize = 1 << 10; /// The capacity of the queue reserved for executions. /// Note: This is an inbound queue capacity, not a Narwhal-enforced capacity. const CAPACITY_FOR_EXECUTIONS: usize = 1 << 10; From 52ae8c06ce34aae613e68f250b7b0acdaf8d3b2a Mon Sep 17 00:00:00 2001 From: Raymond Chu <14917648+raychu86@users.noreply.github.com> Date: Tue, 12 Mar 2024 16:46:39 -0700 Subject: [PATCH 228/551] Update node/bft/src/bft.rs Co-authored-by: Howard Wu <9260812+howardwu@users.noreply.github.com> Signed-off-by: Raymond Chu <14917648+raychu86@users.noreply.github.com> --- node/bft/src/bft.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index cfa14536b9..01dfd34745 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -323,7 +323,7 @@ impl BFT { self.is_even_round_ready_for_next_round(current_certificates, committee_lookback, current_round) } - /// Returns 'true' if the quorum threshold is reached for this round under one of the following conditions: + /// Returns 'true' if the quorum threshold `(2f + 1)` is reached for this round under one of the following conditions: /// - If the leader certificate is set for the current even round. /// - The timer for the leader certificate has expired. fn is_even_round_ready_for_next_round( From 4d713c02ecf66636bdd170aea1a29f81afae084d Mon Sep 17 00:00:00 2001 From: Raymond Chu <14917648+raychu86@users.noreply.github.com> Date: Tue, 12 Mar 2024 16:46:43 -0700 Subject: [PATCH 229/551] Update node/bft/src/bft.rs Co-authored-by: Howard Wu <9260812+howardwu@users.noreply.github.com> Signed-off-by: Raymond Chu <14917648+raychu86@users.noreply.github.com> --- node/bft/src/bft.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 01dfd34745..4c679a0a4c 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -359,7 +359,7 @@ impl BFT { self.leader_certificate_timer.load(Ordering::SeqCst) + MAX_LEADER_CERTIFICATE_DELAY_IN_SECS <= now() } - /// Returns 'true' if the quorum threshold is reached for this round under one of the following conditions: + /// Returns 'true' if the quorum threshold `(2f + 1)` is reached for this round under one of the following conditions: /// - The leader certificate is `None`. /// - The leader certificate is not included up to availability threshold `(f + 1)` (in the previous certificates of the current round). /// - The leader certificate timer has expired. From aaae7412ada1f9da5c4da1796f66dea404a187f0 Mon Sep 17 00:00:00 2001 From: Raymond Chu <14917648+raychu86@users.noreply.github.com> Date: Tue, 12 Mar 2024 16:47:03 -0700 Subject: [PATCH 230/551] Update node/bft/src/bft.rs Co-authored-by: Howard Wu <9260812+howardwu@users.noreply.github.com> Signed-off-by: Raymond Chu <14917648+raychu86@users.noreply.github.com> --- node/bft/src/bft.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 4c679a0a4c..b5fb9fc3dc 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -398,11 +398,9 @@ impl BFT { // If there is no leader certificate for the previous round, return 'true'. return true; }; - // Retrieve the leader certificate ID. - let leader_certificate_id = leader_certificate.id(); // Compute the stake for the leader certificate. let (stake_with_leader, stake_without_leader) = - self.compute_stake_for_leader_certificate(leader_certificate_id, current_certificates, &committee_lookback); + self.compute_stake_for_leader_certificate(leader_certificate.id(), current_certificates, &committee_lookback); // Return 'true' if any of the following conditions hold: stake_with_leader >= committee_lookback.availability_threshold() || stake_without_leader >= committee_lookback.quorum_threshold() From a682e2a35d0e8c316a040a9c2ac98a2066daf62b Mon Sep 17 00:00:00 2001 From: Jos Dehaes Date: Wed, 13 Mar 2024 08:36:06 +0100 Subject: [PATCH 231/551] fix: rename parameter in script --- .devnet/start.sh | 2 +- devnet.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.devnet/start.sh b/.devnet/start.sh index bc90ebfbe3..77294f080c 100755 --- a/.devnet/start.sh +++ b/.devnet/start.sh @@ -37,7 +37,7 @@ start_snarkos_in_tmux() { tmux new-session -d -s snarkos-session # Send the snarkOS start command to the tmux session with the NODE_ID - tmux send-keys -t "snarkos-session" "snarkos start --nodisplay --bft 0.0.0.0:5000 --rest 0.0.0.0:3030 --allow-outside-peers --peers $NODE_IP:4130 --validators $NODE_IP:5000 --rest-rps 1000 --verbosity $VERBOSITY --dev $NODE_ID --dev-num-validators $NUM_INSTANCES --validator --metrics" C-m + tmux send-keys -t "snarkos-session" "snarkos start --nodisplay --bft 0.0.0.0:5000 --rest 0.0.0.0:3030 --allow-external-peers --peers $NODE_IP:4130 --validators $NODE_IP:5000 --rest-rps 1000 --verbosity $VERBOSITY --dev $NODE_ID --dev-num-validators $NUM_INSTANCES --validator --metrics" C-m exit # Exit root user EOF diff --git a/devnet.sh b/devnet.sh index de69a84081..ce2ac870a4 100755 --- a/devnet.sh +++ b/devnet.sh @@ -64,12 +64,12 @@ for validator_index in "${validator_indices[@]}"; do # Send the command to start the validator to the new window and capture output to the log file if [ "$validator_index" -eq 0 ]; then - tmux send-keys -t "devnet:window$validator_index" "snarkos start --nodisplay --dev $validator_index --allow-outside-peers --dev-num-validators $total_validators --validator --logfile $log_file --metrics" C-m + tmux send-keys -t "devnet:window$validator_index" "snarkos start --nodisplay --dev $validator_index --allow-external-peers --dev-num-validators $total_validators --validator --logfile $log_file --metrics" C-m else # Create a new window with a unique name window_index=$((validator_index + index_offset)) tmux new-window -t "devnet:$window_index" -n "window$validator_index" - tmux send-keys -t "devnet:window$validator_index" "snarkos start --nodisplay --dev $validator_index --allow-outside-peers --dev-num-validators $total_validators --validator --logfile $log_file" C-m + tmux send-keys -t "devnet:window$validator_index" "snarkos start --nodisplay --dev $validator_index --allow-external-peers --dev-num-validators $total_validators --validator --logfile $log_file" C-m fi done From d5c824611d416b5c0415452abe832e4c7b14f31c Mon Sep 17 00:00:00 2001 From: Jos Dehaes Date: Wed, 13 Mar 2024 09:36:55 +0100 Subject: [PATCH 232/551] fix: abstract common code --- node/bft/examples/simple_node.rs | 42 +++++++++++++++++--------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/node/bft/examples/simple_node.rs b/node/bft/examples/simple_node.rs index 1dac1b80de..5fbf68b9dd 100644 --- a/node/bft/examples/simple_node.rs +++ b/node/bft/examples/simple_node.rs @@ -120,16 +120,7 @@ pub async fn start_bft( // Initialize the components. let (committee, account) = initialize_components(node_id, num_nodes)?; // Initialize the translucent ledger service. - let gen_key = account.private_key(); - let public_balance_per_validator = - (1_500_000_000_000_000 - (num_nodes as u64) * 1_000_000_000_000) / (num_nodes as u64); - let mut balances = IndexMap::, u64>::new(); - for address in committee.members().keys() { - balances.insert(*address, public_balance_per_validator); - } - let mut rng = TestRng::default(); - let gen_ledger = genesis_ledger(*gen_key, committee.clone(), balances.clone(), node_id, &mut rng); - let ledger = Arc::new(TranslucentLedgerService::new(gen_ledger, Arc::new(AtomicBool::new(false)))); + let ledger = create_ledger(&account, num_nodes, committee, node_id); // Initialize the storage. let storage = Storage::new( ledger.clone(), @@ -169,16 +160,8 @@ pub async fn start_primary( let (sender, receiver) = init_primary_channels(); // Initialize the components. let (committee, account) = initialize_components(node_id, num_nodes)?; - let gen_key = account.private_key(); - let public_balance_per_validator = - (1_500_000_000_000_000 - (num_nodes as u64) * 1_000_000_000_000) / (num_nodes as u64); - let mut balances = IndexMap::, u64>::new(); - for address in committee.members().keys() { - balances.insert(*address, public_balance_per_validator); - } - let mut rng = TestRng::default(); - let gen_ledger = genesis_ledger(*gen_key, committee.clone(), balances.clone(), node_id, &mut rng); - let ledger = Arc::new(TranslucentLedgerService::new(gen_ledger, Arc::new(AtomicBool::new(false)))); + // Initialize the translucent ledger service. + let ledger = create_ledger(&account, num_nodes, committee, node_id); // Initialize the storage. let storage = Storage::new( ledger.clone(), @@ -202,6 +185,25 @@ pub async fn start_primary( Ok((primary, sender)) } +/// Initialize the translucent ledger service. +fn create_ledger( + account: &Account, + num_nodes: u16, + committee: Committee, + node_id: u16, +) -> Arc>> { + let gen_key = account.private_key(); + let public_balance_per_validator = + (1_500_000_000_000_000 - (num_nodes as u64) * 1_000_000_000_000) / (num_nodes as u64); + let mut balances = IndexMap::, u64>::new(); + for address in committee.members().keys() { + balances.insert(*address, public_balance_per_validator); + } + let mut rng = TestRng::default(); + let gen_ledger = genesis_ledger(*gen_key, committee.clone(), balances.clone(), node_id, &mut rng); + Arc::new(TranslucentLedgerService::new(gen_ledger, Arc::new(AtomicBool::new(false)))) +} + pub type CurrentLedger = Ledger>; fn genesis_cache() -> &'static Mutex, Block>> { From fdea46a7b67db9acbcea21f281856aa30193fcac Mon Sep 17 00:00:00 2001 From: mdelle1 <108158289+mdelle1@users.noreply.github.com> Date: Wed, 13 Mar 2024 11:14:56 -0400 Subject: [PATCH 233/551] Update logs --- node/bft/src/bft.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index b5fb9fc3dc..0a81fbc4bc 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -226,7 +226,7 @@ impl BFT { if let Some(leader_certificate) = self.leader_certificate.read().as_ref() { // Ensure the state of the leader certificate is consistent with the BFT being ready. if !is_ready { - error!(is_ready, "BFT - A leader certificate was found, but 'is_ready' is false"); + debug!(is_ready, "BFT - A leader certificate was found, but 'is_ready' is false"); } // Log the leader election. let leader_round = leader_certificate.round(); From b564967fb4abb57549e6297e5da801430d9d2fe3 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 13 Mar 2024 10:26:30 -0700 Subject: [PATCH 234/551] cargo fmt --- node/bft/src/bft.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 0a81fbc4bc..d19ff3080b 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -399,8 +399,11 @@ impl BFT { return true; }; // Compute the stake for the leader certificate. - let (stake_with_leader, stake_without_leader) = - self.compute_stake_for_leader_certificate(leader_certificate.id(), current_certificates, &committee_lookback); + let (stake_with_leader, stake_without_leader) = self.compute_stake_for_leader_certificate( + leader_certificate.id(), + current_certificates, + &committee_lookback, + ); // Return 'true' if any of the following conditions hold: stake_with_leader >= committee_lookback.availability_threshold() || stake_without_leader >= committee_lookback.quorum_threshold() From bb7664c2bdc9c6d4ad6f4499228a6c7b50a27a3f Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Wed, 13 Mar 2024 14:27:47 -0700 Subject: [PATCH 235/551] Update snarkVM rev --- Cargo.lock | 117 +++++++++++++------------- Cargo.toml | 2 +- node/bft/ledger-service/src/ledger.rs | 2 +- 3 files changed, 61 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d6a460192a..2f3ba90c30 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3348,7 +3348,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "anstyle", "anyhow", @@ -3379,7 +3379,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "aleo-std", "anyhow", @@ -3409,7 +3409,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3423,7 +3423,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3434,7 +3434,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3444,7 +3444,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3454,7 +3454,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "indexmap 2.2.3", "itertools 0.11.0", @@ -3472,12 +3472,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3488,7 +3488,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3503,7 +3503,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3518,7 +3518,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3531,7 +3531,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3540,7 +3540,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3550,7 +3550,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3562,7 +3562,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3574,7 +3574,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3585,7 +3585,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3597,7 +3597,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3610,7 +3610,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "bs58", "snarkvm-console-network", @@ -3621,7 +3621,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "blake2s_simd", "smallvec", @@ -3634,7 +3634,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "aleo-std", "rayon", @@ -3645,7 +3645,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "anyhow", "indexmap 2.2.3", @@ -3668,7 +3668,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "anyhow", "bech32", @@ -3686,7 +3686,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "enum_index", "enum_index_derive", @@ -3707,7 +3707,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3722,7 +3722,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3733,7 +3733,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "snarkvm-console-network-environment", ] @@ -3741,7 +3741,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3751,7 +3751,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3762,7 +3762,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3773,7 +3773,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3784,7 +3784,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3795,7 +3795,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "rand", "rayon", @@ -3809,7 +3809,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "aleo-std", "anyhow", @@ -3826,7 +3826,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "aleo-std", "anyhow", @@ -3851,7 +3851,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "anyhow", "rand", @@ -3863,7 +3863,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "indexmap 2.2.3", "rayon", @@ -3882,7 +3882,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-coinbase" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "aleo-std", "anyhow", @@ -3902,7 +3902,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "anyhow", "indexmap 2.2.3", @@ -3920,7 +3920,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -3933,7 +3933,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "indexmap 2.2.3", "rayon", @@ -3946,7 +3946,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "indexmap 2.2.3", "serde_json", @@ -3958,7 +3958,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "bytes", "serde_json", @@ -3969,7 +3969,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "indexmap 2.2.3", "rayon", @@ -3984,7 +3984,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "bytes", "serde_json", @@ -3997,7 +3997,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "snarkvm-console", "snarkvm-ledger-coinbase", @@ -4006,7 +4006,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "async-trait", "reqwest", @@ -4019,7 +4019,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "aleo-std-storage", "anyhow", @@ -4045,7 +4045,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4060,7 +4060,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4069,7 +4069,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "aleo-std", "anyhow", @@ -4094,11 +4094,12 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "aleo-std", "anyhow", "indexmap 2.2.3", + "itertools 0.11.0", "lru", "parking_lot", "rand", @@ -4119,7 +4120,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "aleo-std", "colored", @@ -4142,7 +4143,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "indexmap 2.2.3", "paste", @@ -4156,7 +4157,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "bincode", "once_cell", @@ -4169,7 +4170,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "aleo-std", "anyhow", @@ -4190,7 +4191,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eba8b44#eba8b441ca877db372d1f28ea30fdb72dd8e9e01" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=1969efc#1969efc3747256c7b5837bce7d33bb7489308f87" dependencies = [ "proc-macro2", "quote 1.0.35", diff --git a/Cargo.toml b/Cargo.toml index 8cf966087a..3ec9cb3a52 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "eba8b44" +rev = "1969efc" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] diff --git a/node/bft/ledger-service/src/ledger.rs b/node/bft/ledger-service/src/ledger.rs index 3044ed2e10..d5b80e8e17 100644 --- a/node/bft/ledger-service/src/ledger.rs +++ b/node/bft/ledger-service/src/ledger.rs @@ -328,7 +328,7 @@ impl> LedgerService for CoreLedgerService< subdag: Subdag, transmissions: IndexMap, Transmission>, ) -> Result> { - self.ledger.prepare_advance_to_next_quorum_block(subdag, transmissions) + self.ledger.prepare_advance_to_next_quorum_block(subdag, transmissions, &mut rand::thread_rng()) } /// Adds the given block as the next block in the ledger. From 4e00085b5ca31e975aa4f334e783b6e23fa6a584 Mon Sep 17 00:00:00 2001 From: miazn Date: Wed, 13 Mar 2024 17:01:34 -0700 Subject: [PATCH 236/551] add metrics for transmission latency and stale transmissions --- node/consensus/src/lib.rs | 53 +++++++++++++++++++++++++++++++++++++-- node/metrics/src/names.rs | 10 ++++++-- 2 files changed, 59 insertions(+), 4 deletions(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index af0b568c01..5ff5b063f2 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -52,6 +52,8 @@ use tokio::{ sync::{oneshot, OnceCell}, task::JoinHandle, }; +#[cfg(feature = "metrics")] +use std::collections::HashMap; /// Percentage of mempool transactions capacity reserved for deployments. const CAPACITY_FOR_DEPLOYMENTS: usize = 20; @@ -97,6 +99,8 @@ pub struct Consensus { seen_transactions: Arc>>, /// The spawned handles. handles: Arc>>>, + #[cfg(feature = "metrics")] + transmissions_queue_timestamps: Arc, i64>>>, } impl Consensus { @@ -131,6 +135,8 @@ impl Consensus { seen_solutions: Arc::new(Mutex::new(LruCache::new(NonZeroUsize::new(1 << 16).unwrap()))), seen_transactions: Arc::new(Mutex::new(LruCache::new(NonZeroUsize::new(1 << 16).unwrap()))), handles: Default::default(), + #[cfg(feature = "metrics")] + transmissions_queue_timestamps: Arc::new(Mutex::new(HashMap::new())) }) } @@ -216,6 +222,7 @@ impl Consensus { { metrics::increment_gauge(metrics::consensus::UNCONFIRMED_SOLUTIONS, 1f64); metrics::increment_gauge(metrics::consensus::UNCONFIRMED_TRANSMISSIONS, 1f64); + self.transmissions_queue_timestamps.lock().insert(TransmissionID::Solution(solution.commitment()), snarkos_node_bft::helpers::now()); } // Process the unconfirmed solution. { @@ -274,6 +281,7 @@ impl Consensus { { metrics::increment_gauge(metrics::consensus::UNCONFIRMED_TRANSACTIONS, 1f64); metrics::increment_gauge(metrics::consensus::UNCONFIRMED_TRANSMISSIONS, 1f64); + self.transmissions_queue_timestamps.lock().insert(TransmissionID::Transaction(transaction.id()), snarkos_node_bft::helpers::now()); } // Process the unconfirmed transaction. { @@ -404,7 +412,7 @@ impl Consensus { let current_block_timestamp = self.ledger.latest_block().header().metadata().timestamp(); // Create the candidate next block. - let next_block = self.ledger.prepare_advance_to_next_quorum_block(subdag, transmissions)?; + let next_block = self.ledger.prepare_advance_to_next_quorum_block(subdag, transmissions)?; // Check that the block is well-formed. self.ledger.check_next_block(&next_block)?; // Advance to the next block. @@ -419,6 +427,8 @@ impl Consensus { let num_tx = next_block.transactions().len(); let num_transmissions = num_tx + num_sol; + self.add_transmission_latency_metric(&next_block); + metrics::gauge(metrics::blocks::HEIGHT, next_block.height() as f64); metrics::increment_gauge(metrics::blocks::SOLUTIONS, num_sol as f64); metrics::increment_gauge(metrics::blocks::TRANSACTIONS, num_tx as f64); @@ -427,10 +437,49 @@ impl Consensus { metrics::gauge(metrics::consensus::COMMITTED_CERTIFICATES, num_committed_certificates as f64); metrics::histogram(metrics::consensus::CERTIFICATE_COMMIT_LATENCY, elapsed.as_secs_f64()); metrics::histogram(metrics::consensus::BLOCK_LATENCY, block_latency as f64); - } + } Ok(()) } + #[cfg(feature = "metrics")] + fn add_transmission_latency_metric(&self, next_block: &Block) { + let age_threshold_seconds = 30 * 60; // 30 minutes set as stale transmission threshold + + let mut keys_to_remove = Vec::new(); + let mut transmission_queue_timestamps = self.transmissions_queue_timestamps.lock(); + + let solution_ids: std::collections::HashSet<_> = next_block.solutions().solution_ids().collect(); + let transaction_ids: std::collections::HashSet<_> = next_block.transaction_ids().collect(); + + for (key, timestamp) in transmission_queue_timestamps.iter() { + let elapsed_time = std::time::Duration::from_secs((snarkos_node_bft::helpers::now() - *timestamp) as u64); + + if elapsed_time.as_secs() > age_threshold_seconds as u64 { + // This entry is stale-- remove it from transmission queue and record it as a stale transmission + metrics::increment_counter(metrics::consensus::STALE_UNCONFIRMED_TRANSMISSIONS); + keys_to_remove.push(key.clone()); + } else { + let transmission_type = match key { + TransmissionID::Solution(solution_id) if solution_ids.contains(solution_id) => Some("solution"), + TransmissionID::Transaction(transaction_id) if transaction_ids.contains(transaction_id) => Some("transaction"), + _ => None, + }; + + if let Some(transmission_type_string) = transmission_type { + metrics::histogram_label(metrics::consensus::TRANSMISSION_LATENCY, "transmission_type", transmission_type_string.to_string(), elapsed_time.as_secs_f64()); + keys_to_remove.push(key.clone()); + } else { + continue + } + } + } + + // Remove keys of stale or seen transmissions + for key in keys_to_remove { + transmission_queue_timestamps.remove(&key); + } + } + /// Reinserts the given transmissions into the memory pool. async fn reinsert_transmissions(&self, transmissions: IndexMap, Transmission>) { // Iterate over the transmissions. diff --git a/node/metrics/src/names.rs b/node/metrics/src/names.rs index 7afcc59845..0c01c8738c 100644 --- a/node/metrics/src/names.rs +++ b/node/metrics/src/names.rs @@ -12,7 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -pub(super) const COUNTER_NAMES: [&str; 1] = [bft::LEADERS_ELECTED]; +pub(super) const COUNTER_NAMES: [&str; 2] = [ + bft::LEADERS_ELECTED, + consensus::STALE_UNCONFIRMED_TRANSMISSIONS, +]; pub(super) const GAUGE_NAMES: [&str; 18] = [ bft::CONNECTED, @@ -35,10 +38,11 @@ pub(super) const GAUGE_NAMES: [&str; 18] = [ tcp::TCP_TASKS, ]; -pub(super) const HISTOGRAM_NAMES: [&str; 7] = [ +pub(super) const HISTOGRAM_NAMES: [&str; 8] = [ bft::COMMIT_ROUNDS_LATENCY, consensus::CERTIFICATE_COMMIT_LATENCY, consensus::BLOCK_LATENCY, + consensus::TRANSMISSION_LATENCY, tcp::NOISE_CODEC_ENCRYPTION_TIME, tcp::NOISE_CODEC_DECRYPTION_TIME, tcp::NOISE_CODEC_ENCRYPTION_SIZE, @@ -70,6 +74,8 @@ pub mod consensus { pub const UNCONFIRMED_TRANSACTIONS: &str = "snarkos_consensus_unconfirmed_transactions_total"; pub const UNCONFIRMED_TRANSMISSIONS: &str = "snarkos_consensus_unconfirmed_transmissions_total"; pub const UNCONFIRMED_SOLUTIONS: &str = "snarkos_consensus_unconfirmed_solutions_total"; + pub const TRANSMISSION_LATENCY: &str = "snarkos_consensus_transmission_latency"; + pub const STALE_UNCONFIRMED_TRANSMISSIONS: &str = "snarkos_consensus_stale_unconfirmed_transmissions"; } pub mod router { From 700d0ef3e1177e5802fa20d0a1f3c3c1659d9aab Mon Sep 17 00:00:00 2001 From: miazn Date: Wed, 13 Mar 2024 17:41:36 -0700 Subject: [PATCH 237/551] add loglines to check metric updates --- node/consensus/src/lib.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 5ff5b063f2..fc3641a4a4 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -223,6 +223,7 @@ impl Consensus { metrics::increment_gauge(metrics::consensus::UNCONFIRMED_SOLUTIONS, 1f64); metrics::increment_gauge(metrics::consensus::UNCONFIRMED_TRANSMISSIONS, 1f64); self.transmissions_queue_timestamps.lock().insert(TransmissionID::Solution(solution.commitment()), snarkos_node_bft::helpers::now()); + info!("added unconfirmed solution to queue"); } // Process the unconfirmed solution. { @@ -282,6 +283,7 @@ impl Consensus { metrics::increment_gauge(metrics::consensus::UNCONFIRMED_TRANSACTIONS, 1f64); metrics::increment_gauge(metrics::consensus::UNCONFIRMED_TRANSMISSIONS, 1f64); self.transmissions_queue_timestamps.lock().insert(TransmissionID::Transaction(transaction.id()), snarkos_node_bft::helpers::now()); + info!("added unconfirmed transaction to queue"); } // Process the unconfirmed transaction. { @@ -443,6 +445,7 @@ impl Consensus { #[cfg(feature = "metrics")] fn add_transmission_latency_metric(&self, next_block: &Block) { + info!("adding latency to next block"); let age_threshold_seconds = 30 * 60; // 30 minutes set as stale transmission threshold let mut keys_to_remove = Vec::new(); @@ -459,6 +462,7 @@ impl Consensus { metrics::increment_counter(metrics::consensus::STALE_UNCONFIRMED_TRANSMISSIONS); keys_to_remove.push(key.clone()); } else { + info!("looking for transmission key {}", key); let transmission_type = match key { TransmissionID::Solution(solution_id) if solution_ids.contains(solution_id) => Some("solution"), TransmissionID::Transaction(transaction_id) if transaction_ids.contains(transaction_id) => Some("transaction"), From 2e8b64dba2128921acb43914c9802d564b1fe84d Mon Sep 17 00:00:00 2001 From: miazn Date: Wed, 13 Mar 2024 20:54:07 -0700 Subject: [PATCH 238/551] testing by verifying loglines --- node/consensus/src/lib.rs | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 21e9ce900a..7122231de8 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -55,18 +55,10 @@ use tokio::{ #[cfg(feature = "metrics")] use std::collections::HashMap; -/// The capacity of the queue reserved for deployments. -/// Note: This is an inbound queue capacity, not a Narwhal-enforced capacity. -const CAPACITY_FOR_DEPLOYMENTS: usize = 1 << 10; -/// The capacity of the queue reserved for executions. -/// Note: This is an inbound queue capacity, not a Narwhal-enforced capacity. -const CAPACITY_FOR_EXECUTIONS: usize = 1 << 10; -/// The capacity of the queue reserved for solutions. -/// Note: This is an inbound queue capacity, not a Narwhal-enforced capacity. -const CAPACITY_FOR_SOLUTIONS: usize = 1 << 10; -/// The **suggested** maximum number of deployments in each interval. -/// Note: This is an inbound queue limit, not a Narwhal-enforced limit. -const MAX_DEPLOYMENTS_PER_INTERVAL: usize = 1; +/// Percentage of mempool transactions capacity reserved for deployments. +const CAPACITY_FOR_DEPLOYMENTS: usize = 20; +/// Percentage of mempool transactions capacity reserved for executions. +const CAPACITY_FOR_EXECUTIONS: usize = 80; /// Helper struct to track incoming transactions. struct TransactionsQueue { @@ -77,8 +69,14 @@ struct TransactionsQueue { impl Default for TransactionsQueue { fn default() -> Self { Self { - deployments: LruCache::new(NonZeroUsize::new(CAPACITY_FOR_DEPLOYMENTS).unwrap()), - executions: LruCache::new(NonZeroUsize::new(CAPACITY_FOR_EXECUTIONS).unwrap()), + deployments: LruCache::new( + NonZeroUsize::new(BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH * CAPACITY_FOR_DEPLOYMENTS / 100) + .unwrap(), + ), + executions: LruCache::new( + NonZeroUsize::new(BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH * CAPACITY_FOR_EXECUTIONS / 100) + .unwrap(), + ), } } } @@ -130,7 +128,9 @@ impl Consensus { ledger, bft, primary_sender: Default::default(), - solutions_queue: Arc::new(Mutex::new(LruCache::new(NonZeroUsize::new(CAPACITY_FOR_SOLUTIONS).unwrap()))), + solutions_queue: Arc::new(Mutex::new(LruCache::new( + NonZeroUsize::new(BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH).unwrap(), + ))), transactions_queue: Default::default(), seen_solutions: Arc::new(Mutex::new(LruCache::new(NonZeroUsize::new(1 << 16).unwrap()))), seen_transactions: Arc::new(Mutex::new(LruCache::new(NonZeroUsize::new(1 << 16).unwrap()))), @@ -223,7 +223,7 @@ impl Consensus { metrics::increment_gauge(metrics::consensus::UNCONFIRMED_SOLUTIONS, 1f64); metrics::increment_gauge(metrics::consensus::UNCONFIRMED_TRANSMISSIONS, 1f64); self.transmissions_queue_timestamps.lock().insert(TransmissionID::Solution(solution.commitment()), snarkos_node_bft::helpers::now()); - info!("added unconfirmed solution to queue"); + info!("added unconfirmed solution {} to queue", solution.commitment()); } // Process the unconfirmed solution. { @@ -283,7 +283,7 @@ impl Consensus { metrics::increment_gauge(metrics::consensus::UNCONFIRMED_TRANSACTIONS, 1f64); metrics::increment_gauge(metrics::consensus::UNCONFIRMED_TRANSMISSIONS, 1f64); self.transmissions_queue_timestamps.lock().insert(TransmissionID::Transaction(transaction.id()), snarkos_node_bft::helpers::now()); - info!("added unconfirmed transaction to queue"); + info!("added unconfirmed transaction {} to queue", transaction.id()); } // Process the unconfirmed transaction. { @@ -325,7 +325,7 @@ impl Consensus { // Acquire the lock on the transactions queue. let mut tx_queue = self.transactions_queue.lock(); // Determine the number of deployments to send. - let num_deployments = tx_queue.deployments.len().min(capacity).min(MAX_DEPLOYMENTS_PER_INTERVAL); + let num_deployments = tx_queue.deployments.len().min(capacity * CAPACITY_FOR_DEPLOYMENTS / 100); // Determine the number of executions to send. let num_executions = tx_queue.executions.len().min(capacity.saturating_sub(num_deployments)); // Create an iterator which will select interleaved deployments and executions within the capacity. From 6f586cd8c490bb6c33487f4b29aaa329dee22743 Mon Sep 17 00:00:00 2001 From: miazn Date: Thu, 14 Mar 2024 12:56:58 -0400 Subject: [PATCH 239/551] remove logging and pull new changes --- node/consensus/src/lib.rs | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 7122231de8..3b77fa68a2 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -55,10 +55,18 @@ use tokio::{ #[cfg(feature = "metrics")] use std::collections::HashMap; -/// Percentage of mempool transactions capacity reserved for deployments. -const CAPACITY_FOR_DEPLOYMENTS: usize = 20; -/// Percentage of mempool transactions capacity reserved for executions. -const CAPACITY_FOR_EXECUTIONS: usize = 80; +/// The capacity of the queue reserved for deployments. +/// Note: This is an inbound queue capacity, not a Narwhal-enforced capacity. +const CAPACITY_FOR_DEPLOYMENTS: usize = 1 << 10; +/// The capacity of the queue reserved for executions. +/// Note: This is an inbound queue capacity, not a Narwhal-enforced capacity. +const CAPACITY_FOR_EXECUTIONS: usize = 1 << 10; +/// The capacity of the queue reserved for solutions. +/// Note: This is an inbound queue capacity, not a Narwhal-enforced capacity. +const CAPACITY_FOR_SOLUTIONS: usize = 1 << 10; +/// The **suggested** maximum number of deployments in each interval. +/// Note: This is an inbound queue limit, not a Narwhal-enforced limit. +const MAX_DEPLOYMENTS_PER_INTERVAL: usize = 1; /// Helper struct to track incoming transactions. struct TransactionsQueue { @@ -69,14 +77,8 @@ struct TransactionsQueue { impl Default for TransactionsQueue { fn default() -> Self { Self { - deployments: LruCache::new( - NonZeroUsize::new(BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH * CAPACITY_FOR_DEPLOYMENTS / 100) - .unwrap(), - ), - executions: LruCache::new( - NonZeroUsize::new(BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH * CAPACITY_FOR_EXECUTIONS / 100) - .unwrap(), - ), + deployments: LruCache::new(NonZeroUsize::new(CAPACITY_FOR_DEPLOYMENTS).unwrap()), + executions: LruCache::new(NonZeroUsize::new(CAPACITY_FOR_EXECUTIONS).unwrap()), } } } @@ -223,7 +225,6 @@ impl Consensus { metrics::increment_gauge(metrics::consensus::UNCONFIRMED_SOLUTIONS, 1f64); metrics::increment_gauge(metrics::consensus::UNCONFIRMED_TRANSMISSIONS, 1f64); self.transmissions_queue_timestamps.lock().insert(TransmissionID::Solution(solution.commitment()), snarkos_node_bft::helpers::now()); - info!("added unconfirmed solution {} to queue", solution.commitment()); } // Process the unconfirmed solution. { @@ -283,7 +284,6 @@ impl Consensus { metrics::increment_gauge(metrics::consensus::UNCONFIRMED_TRANSACTIONS, 1f64); metrics::increment_gauge(metrics::consensus::UNCONFIRMED_TRANSMISSIONS, 1f64); self.transmissions_queue_timestamps.lock().insert(TransmissionID::Transaction(transaction.id()), snarkos_node_bft::helpers::now()); - info!("added unconfirmed transaction {} to queue", transaction.id()); } // Process the unconfirmed transaction. { @@ -325,7 +325,7 @@ impl Consensus { // Acquire the lock on the transactions queue. let mut tx_queue = self.transactions_queue.lock(); // Determine the number of deployments to send. - let num_deployments = tx_queue.deployments.len().min(capacity * CAPACITY_FOR_DEPLOYMENTS / 100); + let num_deployments = tx_queue.deployments.len().min(capacity).min(MAX_DEPLOYMENTS_PER_INTERVAL); // Determine the number of executions to send. let num_executions = tx_queue.executions.len().min(capacity.saturating_sub(num_deployments)); // Create an iterator which will select interleaved deployments and executions within the capacity. @@ -414,7 +414,7 @@ impl Consensus { let current_block_timestamp = self.ledger.latest_block().header().metadata().timestamp(); // Create the candidate next block. - let next_block = self.ledger.prepare_advance_to_next_quorum_block(subdag, transmissions)?; + let next_block = self.ledger.prepare_advance_to_next_quorum_block(subdag, transmissions)?; // Check that the block is well-formed. self.ledger.check_next_block(&next_block)?; // Advance to the next block. @@ -439,13 +439,12 @@ impl Consensus { metrics::gauge(metrics::consensus::COMMITTED_CERTIFICATES, num_committed_certificates as f64); metrics::histogram(metrics::consensus::CERTIFICATE_COMMIT_LATENCY, elapsed.as_secs_f64()); metrics::histogram(metrics::consensus::BLOCK_LATENCY, block_latency as f64); - } + } Ok(()) } #[cfg(feature = "metrics")] fn add_transmission_latency_metric(&self, next_block: &Block) { - info!("adding latency to next block"); let age_threshold_seconds = 30 * 60; // 30 minutes set as stale transmission threshold let mut keys_to_remove = Vec::new(); @@ -462,7 +461,6 @@ impl Consensus { metrics::increment_counter(metrics::consensus::STALE_UNCONFIRMED_TRANSMISSIONS); keys_to_remove.push(key.clone()); } else { - info!("looking for transmission key {}", key); let transmission_type = match key { TransmissionID::Solution(solution_id) if solution_ids.contains(solution_id) => Some("solution"), TransmissionID::Transaction(transaction_id) if transaction_ids.contains(transaction_id) => Some("transaction"), From 27d81a32f72333de607f77b82cab388a000924c0 Mon Sep 17 00:00:00 2001 From: miazn Date: Thu, 14 Mar 2024 12:59:51 -0400 Subject: [PATCH 240/551] pull mainnet-staging --- node/consensus/src/lib.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 3b77fa68a2..747f1815a0 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -130,9 +130,7 @@ impl Consensus { ledger, bft, primary_sender: Default::default(), - solutions_queue: Arc::new(Mutex::new(LruCache::new( - NonZeroUsize::new(BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH).unwrap(), - ))), + solutions_queue: Arc::new(Mutex::new(LruCache::new(NonZeroUsize::new(CAPACITY_FOR_SOLUTIONS).unwrap()))), transactions_queue: Default::default(), seen_solutions: Arc::new(Mutex::new(LruCache::new(NonZeroUsize::new(1 << 16).unwrap()))), seen_transactions: Arc::new(Mutex::new(LruCache::new(NonZeroUsize::new(1 << 16).unwrap()))), From 0c2e30b1893dd582288065963a862137283caef5 Mon Sep 17 00:00:00 2001 From: miazn Date: Thu, 14 Mar 2024 14:10:31 -0400 Subject: [PATCH 241/551] nits --- node/consensus/src/lib.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 747f1815a0..e35006102e 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -442,8 +442,8 @@ impl Consensus { } #[cfg(feature = "metrics")] - fn add_transmission_latency_metric(&self, next_block: &Block) { - let age_threshold_seconds = 30 * 60; // 30 minutes set as stale transmission threshold + fn add_transmission_latency_metric(&self, next_block: &Block) {hold + const AGE_THRESHOLD_SECONDS: i32 = 30 * 60; // 30 minutes set as stale transmission threshold let mut keys_to_remove = Vec::new(); let mut transmission_queue_timestamps = self.transmissions_queue_timestamps.lock(); @@ -454,7 +454,7 @@ impl Consensus { for (key, timestamp) in transmission_queue_timestamps.iter() { let elapsed_time = std::time::Duration::from_secs((snarkos_node_bft::helpers::now() - *timestamp) as u64); - if elapsed_time.as_secs() > age_threshold_seconds as u64 { + if elapsed_time.as_secs() > AGE_THRESHOLD_SECONDS as u64 { // This entry is stale-- remove it from transmission queue and record it as a stale transmission metrics::increment_counter(metrics::consensus::STALE_UNCONFIRMED_TRANSMISSIONS); keys_to_remove.push(key.clone()); @@ -468,8 +468,6 @@ impl Consensus { if let Some(transmission_type_string) = transmission_type { metrics::histogram_label(metrics::consensus::TRANSMISSION_LATENCY, "transmission_type", transmission_type_string.to_string(), elapsed_time.as_secs_f64()); keys_to_remove.push(key.clone()); - } else { - continue } } } From 4dd9375d08b53a699dea222a0728e0a81a6c485d Mon Sep 17 00:00:00 2001 From: miazn Date: Thu, 14 Mar 2024 14:29:33 -0400 Subject: [PATCH 242/551] fix typo --- node/consensus/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index e35006102e..06a02bb0c8 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -442,7 +442,7 @@ impl Consensus { } #[cfg(feature = "metrics")] - fn add_transmission_latency_metric(&self, next_block: &Block) {hold + fn add_transmission_latency_metric(&self, next_block: &Block) { const AGE_THRESHOLD_SECONDS: i32 = 30 * 60; // 30 minutes set as stale transmission threshold let mut keys_to_remove = Vec::new(); From 6e14920d74f1aae67634b79f19733d86c1fe52f4 Mon Sep 17 00:00:00 2001 From: Jos Dehaes Date: Fri, 15 Mar 2024 10:12:41 +0100 Subject: [PATCH 243/551] fix: allow external peers for non-validators --- node/router/tests/common/mod.rs | 4 ++-- node/src/client/mod.rs | 2 +- node/src/prover/mod.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/node/router/tests/common/mod.rs b/node/router/tests/common/mod.rs index 780bcbacac..9a0844a3f9 100644 --- a/node/router/tests/common/mod.rs +++ b/node/router/tests/common/mod.rs @@ -78,7 +78,7 @@ pub async fn client(listening_port: u16, max_peers: u16) -> TestRouter TestRouter> Client { trusted_peers, Self::MAXIMUM_NUMBER_OF_PEERS as u16, matches!(storage_mode, StorageMode::Development(_)), - false, + true, ) .await?; // Load the coinbase puzzle. diff --git a/node/src/prover/mod.rs b/node/src/prover/mod.rs index de71ead0a3..5383b16d88 100644 --- a/node/src/prover/mod.rs +++ b/node/src/prover/mod.rs @@ -110,7 +110,7 @@ impl> Prover { trusted_peers, Self::MAXIMUM_NUMBER_OF_PEERS as u16, matches!(storage_mode, StorageMode::Development(_)), - false, + true, ) .await?; // Load the coinbase puzzle. From 8ecd4e1ca28f77b31976d74250fa7b5d05e28e9d Mon Sep 17 00:00:00 2001 From: Victor Sint Nicolaas Date: Fri, 15 Mar 2024 19:07:20 +0100 Subject: [PATCH 244/551] Use allow_external_peers without checking is_validator --- node/router/src/handshake.rs | 6 ++---- node/router/src/heartbeat.rs | 6 ++---- node/router/src/inbound.rs | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/node/router/src/handshake.rs b/node/router/src/handshake.rs index d5ef8cf87a..57198692d4 100644 --- a/node/router/src/handshake.rs +++ b/node/router/src/handshake.rs @@ -264,10 +264,8 @@ impl Router { if self.is_connected(&peer_ip) { bail!("Dropping connection request from '{peer_ip}' (already connected)") } - // Only allow trusted peers to connect if we are a validator - // (unless allow_external_peers is set) - let is_validator = self.node_type().is_validator(); - if is_validator && !self.allow_external_peers() && !self.is_trusted(&peer_ip) { + // Only allow trusted peers to connect if allow_external_peers is set + if !self.allow_external_peers() && !self.is_trusted(&peer_ip) { bail!("Dropping connection request from '{peer_ip}' (untrusted)") } // Ensure the peer is not restricted. diff --git a/node/router/src/heartbeat.rs b/node/router/src/heartbeat.rs index 7498b7d033..ae84ba21aa 100644 --- a/node/router/src/heartbeat.rs +++ b/node/router/src/heartbeat.rs @@ -107,9 +107,8 @@ pub trait Heartbeat: Outbound { return; } - let is_validator = self.router().node_type().is_validator(); // Skip if the node is not requesting peers. - if is_validator && !self.router().allow_external_peers() { + if !self.router().allow_external_peers() { return; } @@ -222,8 +221,7 @@ pub trait Heartbeat: Outbound { for peer_ip in self.router().candidate_peers().into_iter().choose_multiple(rng, num_deficient) { self.router().connect(peer_ip); } - let is_validator = self.router().node_type().is_validator(); - if !is_validator || self.router().allow_external_peers() { + if self.router().allow_external_peers() { // Request more peers from the connected peers. for peer_ip in self.router().connected_peers().into_iter().choose_multiple(rng, 3) { self.send(peer_ip, Message::PeerRequest(PeerRequest)); diff --git a/node/router/src/inbound.rs b/node/router/src/inbound.rs index 8e26427fdb..e99072dfc2 100644 --- a/node/router/src/inbound.rs +++ b/node/router/src/inbound.rs @@ -125,7 +125,7 @@ pub trait Inbound: Reading + Outbound { if !self.router().cache.contains_outbound_peer_request(peer_ip) { bail!("Peer '{peer_ip}' is not following the protocol (unexpected peer response)") } - if self.router().node_type().is_validator() && !self.router().allow_external_peers() { + if !self.router().allow_external_peers() { bail!("Not accepting peer response from '{peer_ip}' (validator gossip is disabled)"); } From a74d62684ba5c11c07ac8d79472cfa13bfc5ff96 Mon Sep 17 00:00:00 2001 From: Victor Sint Nicolaas Date: Fri, 15 Mar 2024 19:13:08 +0100 Subject: [PATCH 245/551] Nit: Reverse order of arguments --- cli/src/commands/start.rs | 6 +++--- node/router/src/lib.rs | 8 ++++---- node/router/tests/common/mod.rs | 2 +- node/src/client/mod.rs | 4 +++- node/src/node.rs | 4 ++-- node/src/prover/mod.rs | 4 +++- node/src/validator/mod.rs | 6 +++--- node/tests/common/node.rs | 2 +- 8 files changed, 20 insertions(+), 16 deletions(-) diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index 3f8da6a5f6..f618c66e04 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -144,12 +144,12 @@ pub struct Start { #[clap(long = "storage_path")] pub storage_path: Option, - #[clap(long)] /// If development mode is enabled, specify the custom bonded balances as a json object. (default: None) + #[clap(long)] dev_bonded_balances: Option, - #[clap(long = "allow-external-peers")] /// If the flag is set, the validator will allow untrusted peers to connect + #[clap(long = "allow-external-peers")] allow_external_peers: bool, } @@ -546,7 +546,7 @@ impl Start { // Initialize the node. let bft_ip = if self.dev.is_some() { self.bft } else { None }; match node_type { - NodeType::Validator => Node::new_validator(self.node, bft_ip, rest_ip, self.rest_rps, account, &trusted_peers, &trusted_validators, genesis, cdn, storage_mode, dev_txs, self.allow_external_peers).await, + NodeType::Validator => Node::new_validator(self.node, bft_ip, rest_ip, self.rest_rps, account, &trusted_peers, &trusted_validators, genesis, cdn, storage_mode, self.allow_external_peers, dev_txs).await, NodeType::Prover => Node::new_prover(self.node, account, &trusted_peers, genesis, storage_mode).await, NodeType::Client => Node::new_client(self.node, rest_ip, self.rest_rps, account, &trusted_peers, genesis, cdn, storage_mode).await, } diff --git a/node/router/src/lib.rs b/node/router/src/lib.rs index 239202b7d4..c171e72f6d 100644 --- a/node/router/src/lib.rs +++ b/node/router/src/lib.rs @@ -93,10 +93,10 @@ pub struct InnerRouter { restricted_peers: RwLock>, /// The spawned handles. handles: Mutex>>, - /// The boolean flag for the development mode. - is_dev: bool, /// If the flag is set, the node will not engage in P2P gossip to request more peers. allow_external_peers: bool, + /// The boolean flag for the development mode. + is_dev: bool, } impl Router { @@ -117,8 +117,8 @@ impl Router { account: Account, trusted_peers: &[SocketAddr], max_peers: u16, - is_dev: bool, allow_external_peers: bool, + is_dev: bool, ) -> Result { // Initialize the TCP stack. let tcp = Tcp::new(Config::new(node_ip, max_peers)); @@ -135,8 +135,8 @@ impl Router { candidate_peers: Default::default(), restricted_peers: Default::default(), handles: Default::default(), - is_dev, allow_external_peers, + is_dev, }))) } } diff --git a/node/router/tests/common/mod.rs b/node/router/tests/common/mod.rs index 9a0844a3f9..7aa86c0546 100644 --- a/node/router/tests/common/mod.rs +++ b/node/router/tests/common/mod.rs @@ -111,8 +111,8 @@ pub async fn validator(listening_port: u16, max_peers: u16) -> TestRouter> Client { let ledger_service = Arc::new(CoreLedgerService::::new(ledger.clone(), shutdown.clone())); // Initialize the sync module. let sync = BlockSync::new(BlockSyncMode::Router, ledger_service.clone()); + // Determine if the client should allow external peers. + let allow_external_peers = true; // Initialize the node router. let router = Router::new( @@ -116,8 +118,8 @@ impl> Client { account, trusted_peers, Self::MAXIMUM_NUMBER_OF_PEERS as u16, + allow_external_peers, matches!(storage_mode, StorageMode::Development(_)), - true, ) .await?; // Load the coinbase puzzle. diff --git a/node/src/node.rs b/node/src/node.rs index 259f654a0e..9c4ce40299 100644 --- a/node/src/node.rs +++ b/node/src/node.rs @@ -50,8 +50,8 @@ impl Node { genesis: Block, cdn: Option, storage_mode: StorageMode, - dev_txs: bool, allow_external_peers: bool, + dev_txs: bool, ) -> Result { Ok(Self::Validator(Arc::new( Validator::new( @@ -65,8 +65,8 @@ impl Node { genesis, cdn, storage_mode, - dev_txs, allow_external_peers, + dev_txs, ) .await?, ))) diff --git a/node/src/prover/mod.rs b/node/src/prover/mod.rs index 5383b16d88..30b5c04a6d 100644 --- a/node/src/prover/mod.rs +++ b/node/src/prover/mod.rs @@ -101,6 +101,8 @@ impl> Prover { let ledger_service = Arc::new(ProverLedgerService::new()); // Initialize the sync module. let sync = BlockSync::new(BlockSyncMode::Router, ledger_service.clone()); + // Determine if the prover should allow external peers. + let allow_external_peers = true; // Initialize the node router. let router = Router::new( @@ -109,8 +111,8 @@ impl> Prover { account, trusted_peers, Self::MAXIMUM_NUMBER_OF_PEERS as u16, + allow_external_peers, matches!(storage_mode, StorageMode::Development(_)), - true, ) .await?; // Load the coinbase puzzle. diff --git a/node/src/validator/mod.rs b/node/src/validator/mod.rs index d23dc4dab4..643254f2f9 100644 --- a/node/src/validator/mod.rs +++ b/node/src/validator/mod.rs @@ -83,8 +83,8 @@ impl> Validator { genesis: Block, cdn: Option, storage_mode: StorageMode, - dev_txs: bool, allow_external_peers: bool, + dev_txs: bool, ) -> Result { // Prepare the shutdown flag. let shutdown: Arc = Default::default(); @@ -126,8 +126,8 @@ impl> Validator { account, trusted_peers, Self::MAXIMUM_NUMBER_OF_PEERS as u16, - matches!(storage_mode, StorageMode::Development(_)), allow_external_peers, + matches!(storage_mode, StorageMode::Development(_)), ) .await?; @@ -500,8 +500,8 @@ mod tests { genesis, None, storage_mode, - dev_txs, false, + dev_txs, ) .await .unwrap(); diff --git a/node/tests/common/node.rs b/node/tests/common/node.rs index 1c390d71cc..503a6f867e 100644 --- a/node/tests/common/node.rs +++ b/node/tests/common/node.rs @@ -59,8 +59,8 @@ pub async fn validator() -> Validator Date: Fri, 15 Mar 2024 19:23:53 +0100 Subject: [PATCH 246/551] Correct comments --- node/router/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node/router/src/lib.rs b/node/router/src/lib.rs index c171e72f6d..748870deda 100644 --- a/node/router/src/lib.rs +++ b/node/router/src/lib.rs @@ -93,7 +93,7 @@ pub struct InnerRouter { restricted_peers: RwLock>, /// The spawned handles. handles: Mutex>>, - /// If the flag is set, the node will not engage in P2P gossip to request more peers. + /// If the flag is set, the node will engage in P2P gossip to request more peers. allow_external_peers: bool, /// The boolean flag for the development mode. is_dev: bool, @@ -255,7 +255,7 @@ impl Router { self.is_dev } - /// Returns `true` if the node is not engaging in P2P gossip to request more peers. + /// Returns `true` if the node is engaging in P2P gossip to request more peers. pub fn allow_external_peers(&self) -> bool { self.allow_external_peers } From df1d1ae2bf2f3a5da77b5d558f0e095fb5a8d875 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 15 Mar 2024 14:15:26 -0700 Subject: [PATCH 247/551] Update snarkVM rev - 7c6798a --- Cargo.lock | 117 +++++++++++++++++++++++++++-------------------------- Cargo.toml | 2 +- 2 files changed, 60 insertions(+), 59 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 823b7ac943..f72cf76a2a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3301,7 +3301,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "anstyle", "anyhow", @@ -3332,7 +3332,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "aleo-std", "anyhow", @@ -3362,7 +3362,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3376,7 +3376,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3387,7 +3387,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3397,7 +3397,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3407,7 +3407,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "indexmap 2.2.5", "itertools 0.11.0", @@ -3425,12 +3425,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3441,7 +3441,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3456,7 +3456,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3471,7 +3471,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3484,7 +3484,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3493,7 +3493,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3503,7 +3503,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3515,7 +3515,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3527,7 +3527,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3538,7 +3538,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3550,7 +3550,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3563,7 +3563,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "bs58", "snarkvm-console-network", @@ -3574,7 +3574,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "blake2s_simd", "smallvec", @@ -3587,7 +3587,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "aleo-std", "rayon", @@ -3598,7 +3598,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "anyhow", "indexmap 2.2.5", @@ -3621,7 +3621,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "anyhow", "bech32", @@ -3639,7 +3639,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "enum_index", "enum_index_derive", @@ -3660,7 +3660,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3675,7 +3675,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3686,7 +3686,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "snarkvm-console-network-environment", ] @@ -3694,7 +3694,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3704,7 +3704,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3715,7 +3715,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3726,7 +3726,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3737,7 +3737,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3748,7 +3748,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "rand", "rayon", @@ -3762,7 +3762,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "aleo-std", "anyhow", @@ -3779,7 +3779,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "aleo-std", "anyhow", @@ -3804,7 +3804,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "anyhow", "rand", @@ -3816,7 +3816,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3835,7 +3835,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-coinbase" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "aleo-std", "anyhow", @@ -3855,7 +3855,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "anyhow", "indexmap 2.2.5", @@ -3873,7 +3873,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -3886,7 +3886,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3899,7 +3899,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "indexmap 2.2.5", "serde_json", @@ -3911,7 +3911,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "bytes", "serde_json", @@ -3922,7 +3922,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3937,7 +3937,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "bytes", "serde_json", @@ -3950,7 +3950,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "snarkvm-console", "snarkvm-ledger-coinbase", @@ -3959,7 +3959,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "async-trait", "reqwest", @@ -3972,7 +3972,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "aleo-std-storage", "anyhow", @@ -3998,7 +3998,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4013,7 +4013,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4022,7 +4022,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "aleo-std", "anyhow", @@ -4047,11 +4047,12 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "aleo-std", "anyhow", "indexmap 2.2.5", + "itertools 0.11.0", "lru", "parking_lot", "rand", @@ -4072,7 +4073,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "aleo-std", "colored", @@ -4095,7 +4096,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "indexmap 2.2.5", "paste", @@ -4109,7 +4110,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "bincode", "once_cell", @@ -4122,7 +4123,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "aleo-std", "anyhow", @@ -4143,7 +4144,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=2fd006a#2fd006aa26aabfa8238d3e4a369f0dbfcb42d696" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" dependencies = [ "proc-macro2", "quote 1.0.35", diff --git a/Cargo.toml b/Cargo.toml index 4139162dce..99e01ba9f5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "2fd006a" +rev = "7c6798a" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From 1bca44de88376199bf90d746a9ce2f8416c2e0ea Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 15 Mar 2024 15:49:15 -0700 Subject: [PATCH 248/551] Add correct flag for local devnet client node --- devnet.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devnet.sh b/devnet.sh index e91627335a..b0fb9fe410 100755 --- a/devnet.sh +++ b/devnet.sh @@ -87,7 +87,7 @@ for client_index in "${client_indices[@]}"; do tmux new-window -t "devnet:$window_index" -n "window-$window_index" # Send the command to start the validator to the new window and capture output to the log file - tmux send-keys -t "devnet:window-$window_index" "snarkos start --nodisplay --dev $window_index --client --logfile $log_file" C-m + tmux send-keys -t "devnet:window-$window_index" "snarkos start --nodisplay --dev $window_index --dev-num-validators $total_validators --client --logfile $log_file" C-m done # Attach to the tmux session to view and interact with the windows From 8984f812dc4dcd4b5d4d2aa81ea2f55c3d7433e3 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 15 Mar 2024 17:01:14 -0700 Subject: [PATCH 249/551] Update snarkVM rev - 01c8b09 --- Cargo.lock | 116 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 2 +- 2 files changed, 59 insertions(+), 59 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f72cf76a2a..2b724e9d99 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3301,7 +3301,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "anstyle", "anyhow", @@ -3332,7 +3332,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "aleo-std", "anyhow", @@ -3362,7 +3362,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3376,7 +3376,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3387,7 +3387,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3397,7 +3397,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3407,7 +3407,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "indexmap 2.2.5", "itertools 0.11.0", @@ -3425,12 +3425,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3441,7 +3441,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3456,7 +3456,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3471,7 +3471,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3484,7 +3484,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3493,7 +3493,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3503,7 +3503,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3515,7 +3515,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3527,7 +3527,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3538,7 +3538,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3550,7 +3550,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3563,7 +3563,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "bs58", "snarkvm-console-network", @@ -3574,7 +3574,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "blake2s_simd", "smallvec", @@ -3587,7 +3587,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "aleo-std", "rayon", @@ -3598,7 +3598,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "anyhow", "indexmap 2.2.5", @@ -3621,7 +3621,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "anyhow", "bech32", @@ -3639,7 +3639,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "enum_index", "enum_index_derive", @@ -3660,7 +3660,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3675,7 +3675,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3686,7 +3686,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "snarkvm-console-network-environment", ] @@ -3694,7 +3694,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3704,7 +3704,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3715,7 +3715,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3726,7 +3726,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3737,7 +3737,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3748,7 +3748,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "rand", "rayon", @@ -3762,7 +3762,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "aleo-std", "anyhow", @@ -3779,7 +3779,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "aleo-std", "anyhow", @@ -3804,7 +3804,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "anyhow", "rand", @@ -3816,7 +3816,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3835,7 +3835,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-coinbase" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "aleo-std", "anyhow", @@ -3855,7 +3855,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "anyhow", "indexmap 2.2.5", @@ -3873,7 +3873,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -3886,7 +3886,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3899,7 +3899,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "indexmap 2.2.5", "serde_json", @@ -3911,7 +3911,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "bytes", "serde_json", @@ -3922,7 +3922,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3937,7 +3937,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "bytes", "serde_json", @@ -3950,7 +3950,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "snarkvm-console", "snarkvm-ledger-coinbase", @@ -3959,7 +3959,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "async-trait", "reqwest", @@ -3972,7 +3972,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "aleo-std-storage", "anyhow", @@ -3998,7 +3998,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4013,7 +4013,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4022,7 +4022,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "aleo-std", "anyhow", @@ -4047,7 +4047,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "aleo-std", "anyhow", @@ -4073,7 +4073,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "aleo-std", "colored", @@ -4096,7 +4096,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "indexmap 2.2.5", "paste", @@ -4110,7 +4110,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "bincode", "once_cell", @@ -4123,7 +4123,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "aleo-std", "anyhow", @@ -4144,7 +4144,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=7c6798a#7c6798aff6ed82748470bbce64fff7498d01187f" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" dependencies = [ "proc-macro2", "quote 1.0.35", diff --git a/Cargo.toml b/Cargo.toml index 99e01ba9f5..f1107f7c36 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "7c6798a" +rev = "01c8b09" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From 4e6d0d1d196b6477413249c01e32a75fc2bb9138 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 15 Mar 2024 22:50:28 -0700 Subject: [PATCH 250/551] Fix test configs --- node/bft/src/worker.rs | 2 +- node/bft/tests/common/primary.rs | 2 +- node/bft/tests/components/mod.rs | 2 +- node/bft/tests/components/pending.rs | 2 +- node/bft/tests/components/worker.rs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index ffb3fceee3..c699168c62 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -556,7 +556,7 @@ mod tests { async fn test_max_redundant_requests() { let rng = &mut TestRng::default(); // Sample a committee. - let committee = snarkvm::ledger::committee::test_helpers::sample_committee_for_round_and_size(0, 100, rng); + let committee = snarkvm::ledger::committee::test_helpers::sample_committee_for_round_and_size(0, 10, rng); let committee_clone = committee.clone(); // Setup the mock ledger. let mut mock_ledger = MockLedger::default(); diff --git a/node/bft/tests/common/primary.rs b/node/bft/tests/common/primary.rs index d1aa748852..18ace2646f 100644 --- a/node/bft/tests/common/primary.rs +++ b/node/bft/tests/common/primary.rs @@ -138,7 +138,7 @@ impl TestNetwork { .collect(); let gen_key = *accounts[0].private_key(); let public_balance_per_validator = - (1_500_000_000_000_000 - (config.num_nodes as u64) * 1_000_000_000_000) / (config.num_nodes as u64); + (1_500_000_000_000_000 - (config.num_nodes as u64) * 10_000_000_000_000) / (config.num_nodes as u64); let mut balances = IndexMap::, u64>::new(); for account in accounts.iter() { balances.insert(account.address(), public_balance_per_validator); diff --git a/node/bft/tests/components/mod.rs b/node/bft/tests/components/mod.rs index a153ad7b43..a1eb8a1552 100644 --- a/node/bft/tests/components/mod.rs +++ b/node/bft/tests/components/mod.rs @@ -42,7 +42,7 @@ pub fn sample_ledger( committee.members().iter().map(|(address, (amount, _))| (*address, (*address, *address, *amount))).collect(); let gen_key = *accounts[0].private_key(); let public_balance_per_validator = - (1_500_000_000_000_000 - (num_nodes as u64) * 1_000_000_000_000) / (num_nodes as u64); + (1_500_000_000_000_000 - (num_nodes as u64) * 10_000_000_000_000) / (num_nodes as u64); let mut balances = IndexMap::, u64>::new(); for account in accounts.iter() { balances.insert(account.address(), public_balance_per_validator); diff --git a/node/bft/tests/components/pending.rs b/node/bft/tests/components/pending.rs index b1405207d4..b4c1d65223 100644 --- a/node/bft/tests/components/pending.rs +++ b/node/bft/tests/components/pending.rs @@ -18,7 +18,7 @@ use snarkvm::prelude::TestRng; #[test] fn test_max_redundant_requests() { - const NUM_NODES: u16 = 100; + const NUM_NODES: u16 = 10; // Initialize the RNG. let rng = &mut TestRng::default(); diff --git a/node/bft/tests/components/worker.rs b/node/bft/tests/components/worker.rs index 279bc1bf92..a2273b35e2 100644 --- a/node/bft/tests/components/worker.rs +++ b/node/bft/tests/components/worker.rs @@ -27,7 +27,7 @@ use std::net::SocketAddr; #[tokio::test] #[rustfmt::skip] async fn test_resend_transmission_request() { - const NUM_NODES: u16 = 100; + const NUM_NODES: u16 = 10; // Initialize the RNG. let rng = &mut TestRng::default(); From 16c59b9b015aaae62730ba0f447749127822b78d Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 15 Mar 2024 23:16:30 -0700 Subject: [PATCH 251/551] Update expected test value --- node/bft/src/worker.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index c699168c62..dfa6490fe5 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -567,7 +567,7 @@ mod tests { let ledger: Arc> = Arc::new(mock_ledger); // Ensure the maximum number of redundant requests is correct and consistent across iterations. - assert_eq!(max_redundant_requests(ledger, 0), 34, "Update me if the formula changes"); + assert_eq!(max_redundant_requests(ledger, 0), 4, "Update me if the formula changes"); } #[tokio::test] From 2d6b0aa3021529688ebe53118df580923814cf47 Mon Sep 17 00:00:00 2001 From: miazn Date: Mon, 18 Mar 2024 11:36:34 -0400 Subject: [PATCH 252/551] formatting --- node/consensus/src/lib.rs | 39 +++++++++++++++++++++++++-------------- node/metrics/src/names.rs | 5 +---- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 06a02bb0c8..b3a11e174c 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -47,13 +47,13 @@ use colored::Colorize; use indexmap::IndexMap; use lru::LruCache; use parking_lot::Mutex; +#[cfg(feature = "metrics")] +use std::collections::HashMap; use std::{future::Future, net::SocketAddr, num::NonZeroUsize, sync::Arc}; use tokio::{ sync::{oneshot, OnceCell}, task::JoinHandle, }; -#[cfg(feature = "metrics")] -use std::collections::HashMap; /// The capacity of the queue reserved for deployments. /// Note: This is an inbound queue capacity, not a Narwhal-enforced capacity. @@ -102,7 +102,7 @@ pub struct Consensus { /// The spawned handles. handles: Arc>>>, #[cfg(feature = "metrics")] - transmissions_queue_timestamps: Arc, i64>>>, + transmissions_queue_timestamps: Arc, i64>>>, } impl Consensus { @@ -136,7 +136,7 @@ impl Consensus { seen_transactions: Arc::new(Mutex::new(LruCache::new(NonZeroUsize::new(1 << 16).unwrap()))), handles: Default::default(), #[cfg(feature = "metrics")] - transmissions_queue_timestamps: Arc::new(Mutex::new(HashMap::new())) + transmissions_queue_timestamps: Arc::new(Mutex::new(HashMap::new())), }) } @@ -222,7 +222,9 @@ impl Consensus { { metrics::increment_gauge(metrics::consensus::UNCONFIRMED_SOLUTIONS, 1f64); metrics::increment_gauge(metrics::consensus::UNCONFIRMED_TRANSMISSIONS, 1f64); - self.transmissions_queue_timestamps.lock().insert(TransmissionID::Solution(solution.commitment()), snarkos_node_bft::helpers::now()); + self.transmissions_queue_timestamps + .lock() + .insert(TransmissionID::Solution(solution.commitment()), snarkos_node_bft::helpers::now()); } // Process the unconfirmed solution. { @@ -281,7 +283,9 @@ impl Consensus { { metrics::increment_gauge(metrics::consensus::UNCONFIRMED_TRANSACTIONS, 1f64); metrics::increment_gauge(metrics::consensus::UNCONFIRMED_TRANSMISSIONS, 1f64); - self.transmissions_queue_timestamps.lock().insert(TransmissionID::Transaction(transaction.id()), snarkos_node_bft::helpers::now()); + self.transmissions_queue_timestamps + .lock() + .insert(TransmissionID::Transaction(transaction.id()), snarkos_node_bft::helpers::now()); } // Process the unconfirmed transaction. { @@ -444,16 +448,16 @@ impl Consensus { #[cfg(feature = "metrics")] fn add_transmission_latency_metric(&self, next_block: &Block) { const AGE_THRESHOLD_SECONDS: i32 = 30 * 60; // 30 minutes set as stale transmission threshold - + let mut keys_to_remove = Vec::new(); let mut transmission_queue_timestamps = self.transmissions_queue_timestamps.lock(); - + let solution_ids: std::collections::HashSet<_> = next_block.solutions().solution_ids().collect(); let transaction_ids: std::collections::HashSet<_> = next_block.transaction_ids().collect(); - + for (key, timestamp) in transmission_queue_timestamps.iter() { let elapsed_time = std::time::Duration::from_secs((snarkos_node_bft::helpers::now() - *timestamp) as u64); - + if elapsed_time.as_secs() > AGE_THRESHOLD_SECONDS as u64 { // This entry is stale-- remove it from transmission queue and record it as a stale transmission metrics::increment_counter(metrics::consensus::STALE_UNCONFIRMED_TRANSMISSIONS); @@ -461,23 +465,30 @@ impl Consensus { } else { let transmission_type = match key { TransmissionID::Solution(solution_id) if solution_ids.contains(solution_id) => Some("solution"), - TransmissionID::Transaction(transaction_id) if transaction_ids.contains(transaction_id) => Some("transaction"), + TransmissionID::Transaction(transaction_id) if transaction_ids.contains(transaction_id) => { + Some("transaction") + } _ => None, }; if let Some(transmission_type_string) = transmission_type { - metrics::histogram_label(metrics::consensus::TRANSMISSION_LATENCY, "transmission_type", transmission_type_string.to_string(), elapsed_time.as_secs_f64()); + metrics::histogram_label( + metrics::consensus::TRANSMISSION_LATENCY, + "transmission_type", + transmission_type_string.to_string(), + elapsed_time.as_secs_f64(), + ); keys_to_remove.push(key.clone()); } } } - + // Remove keys of stale or seen transmissions for key in keys_to_remove { transmission_queue_timestamps.remove(&key); } } - + /// Reinserts the given transmissions into the memory pool. async fn reinsert_transmissions(&self, transmissions: IndexMap, Transmission>) { // Iterate over the transmissions. diff --git a/node/metrics/src/names.rs b/node/metrics/src/names.rs index 0c01c8738c..b94af54033 100644 --- a/node/metrics/src/names.rs +++ b/node/metrics/src/names.rs @@ -12,10 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -pub(super) const COUNTER_NAMES: [&str; 2] = [ - bft::LEADERS_ELECTED, - consensus::STALE_UNCONFIRMED_TRANSMISSIONS, -]; +pub(super) const COUNTER_NAMES: [&str; 2] = [bft::LEADERS_ELECTED, consensus::STALE_UNCONFIRMED_TRANSMISSIONS]; pub(super) const GAUGE_NAMES: [&str; 18] = [ bft::CONNECTED, From af15155c6dc6c9f5203742c1eff07de3b1330a32 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 18 Mar 2024 09:26:45 -0700 Subject: [PATCH 253/551] Update expected values --- node/bft/tests/components/worker.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/node/bft/tests/components/worker.rs b/node/bft/tests/components/worker.rs index a2273b35e2..d1658bb02f 100644 --- a/node/bft/tests/components/worker.rs +++ b/node/bft/tests/components/worker.rs @@ -36,6 +36,10 @@ async fn test_resend_transmission_request() { // Sample a worker. let worker = sample_worker(0, ledger.clone()); + // Determine the maximum number of redundant requests. + let max_redundancy = max_redundant_requests(ledger.clone(), 0); + assert_eq!(max_redundancy, 4, "Update me if the formula changes"); + // Prepare a dummy transmission ID. let peer_ip = SocketAddr::from(([127, 0, 0, 1], 1234)); let transmission_id = TransmissionID::Transaction(::TransactionID::default()); @@ -75,14 +79,14 @@ async fn test_resend_transmission_request() { // Ensure the number of callbacks is correct. assert_eq!(pending.num_callbacks(transmission_id), 1 + i, "Incorrect number of callbacks for transmission"); // Ensure the number of sent requests is correct. - assert_eq!(pending.num_sent_requests(transmission_id), 1 + i, "Incorrect number of sent requests for transmission"); + assert_eq!(pending.num_sent_requests(transmission_id), (1 + i).min(max_redundancy), "Incorrect number of sent requests for transmission"); } } #[tokio::test] #[rustfmt::skip] async fn test_flood_transmission_requests() { - const NUM_NODES: u16 = 100; + const NUM_NODES: u16 = 10; // Initialize the RNG. let rng = &mut TestRng::default(); @@ -93,7 +97,7 @@ async fn test_flood_transmission_requests() { // Determine the maximum number of redundant requests. let max_redundancy = max_redundant_requests(ledger.clone(), 0); - assert_eq!(max_redundancy, 34, "Update me if the formula changes"); + assert_eq!(max_redundancy, 4, "Update me if the formula changes"); // Prepare a dummy transmission ID. let peer_ip = SocketAddr::from(([127, 0, 0, 1], 1234)); From f4edfc7e1a7434abf6b566d142b40666c4a4c305 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 18 Mar 2024 10:06:42 -0700 Subject: [PATCH 254/551] Update expected max_redundant_requests value --- node/bft/tests/components/pending.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/bft/tests/components/pending.rs b/node/bft/tests/components/pending.rs index b4c1d65223..4f00fb3436 100644 --- a/node/bft/tests/components/pending.rs +++ b/node/bft/tests/components/pending.rs @@ -25,5 +25,5 @@ fn test_max_redundant_requests() { // Sample a ledger. let ledger = sample_ledger(NUM_NODES, rng); // Ensure the maximum number of redundant requests is correct and consistent across iterations. - assert_eq!(max_redundant_requests(ledger, 0), 34, "Update me if the formula changes"); + assert_eq!(max_redundant_requests(ledger, 0), 4, "Update me if the formula changes"); } From aff8f2b6930158d90d4158d124da58a32fcf48a9 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 19 Mar 2024 11:32:27 -0700 Subject: [PATCH 255/551] Update snarkVM rev - e29c1df --- Cargo.lock | 116 +++++++++++++-------------- Cargo.toml | 2 +- node/bft/tests/components/pending.rs | 8 +- node/bft/tests/components/worker.rs | 10 +-- 4 files changed, 68 insertions(+), 68 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2b724e9d99..e76be79509 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3301,7 +3301,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "anstyle", "anyhow", @@ -3332,7 +3332,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "aleo-std", "anyhow", @@ -3362,7 +3362,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3376,7 +3376,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3387,7 +3387,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3397,7 +3397,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3407,7 +3407,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "indexmap 2.2.5", "itertools 0.11.0", @@ -3425,12 +3425,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3441,7 +3441,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3456,7 +3456,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3471,7 +3471,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3484,7 +3484,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3493,7 +3493,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3503,7 +3503,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3515,7 +3515,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3527,7 +3527,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3538,7 +3538,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3550,7 +3550,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3563,7 +3563,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "bs58", "snarkvm-console-network", @@ -3574,7 +3574,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "blake2s_simd", "smallvec", @@ -3587,7 +3587,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "aleo-std", "rayon", @@ -3598,7 +3598,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "anyhow", "indexmap 2.2.5", @@ -3621,7 +3621,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "anyhow", "bech32", @@ -3639,7 +3639,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "enum_index", "enum_index_derive", @@ -3660,7 +3660,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3675,7 +3675,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3686,7 +3686,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "snarkvm-console-network-environment", ] @@ -3694,7 +3694,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3704,7 +3704,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3715,7 +3715,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3726,7 +3726,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3737,7 +3737,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3748,7 +3748,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "rand", "rayon", @@ -3762,7 +3762,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "aleo-std", "anyhow", @@ -3779,7 +3779,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "aleo-std", "anyhow", @@ -3804,7 +3804,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "anyhow", "rand", @@ -3816,7 +3816,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3835,7 +3835,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-coinbase" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "aleo-std", "anyhow", @@ -3855,7 +3855,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "anyhow", "indexmap 2.2.5", @@ -3873,7 +3873,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -3886,7 +3886,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3899,7 +3899,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "indexmap 2.2.5", "serde_json", @@ -3911,7 +3911,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "bytes", "serde_json", @@ -3922,7 +3922,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3937,7 +3937,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "bytes", "serde_json", @@ -3950,7 +3950,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "snarkvm-console", "snarkvm-ledger-coinbase", @@ -3959,7 +3959,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "async-trait", "reqwest", @@ -3972,7 +3972,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "aleo-std-storage", "anyhow", @@ -3998,7 +3998,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4013,7 +4013,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4022,7 +4022,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "aleo-std", "anyhow", @@ -4047,7 +4047,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "aleo-std", "anyhow", @@ -4073,7 +4073,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "aleo-std", "colored", @@ -4096,7 +4096,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "indexmap 2.2.5", "paste", @@ -4110,7 +4110,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "bincode", "once_cell", @@ -4123,7 +4123,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "aleo-std", "anyhow", @@ -4144,7 +4144,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" dependencies = [ "proc-macro2", "quote 1.0.35", diff --git a/Cargo.toml b/Cargo.toml index f1107f7c36..625bd434c5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "01c8b09" +rev = "e29c1df" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] diff --git a/node/bft/tests/components/pending.rs b/node/bft/tests/components/pending.rs index 4f00fb3436..f4766084a5 100644 --- a/node/bft/tests/components/pending.rs +++ b/node/bft/tests/components/pending.rs @@ -12,18 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::components::sample_ledger; +use crate::{common::CurrentNetwork, components::sample_ledger}; use snarkos_node_bft::helpers::max_redundant_requests; -use snarkvm::prelude::TestRng; +use snarkvm::{ledger::committee::Committee, prelude::TestRng}; #[test] fn test_max_redundant_requests() { - const NUM_NODES: u16 = 10; + const NUM_NODES: u16 = Committee::::MAX_COMMITTEE_SIZE; // Initialize the RNG. let rng = &mut TestRng::default(); // Sample a ledger. let ledger = sample_ledger(NUM_NODES, rng); // Ensure the maximum number of redundant requests is correct and consistent across iterations. - assert_eq!(max_redundant_requests(ledger, 0), 4, "Update me if the formula changes"); + assert_eq!(max_redundant_requests(ledger, 0), 34, "Update me if the formula changes"); } diff --git a/node/bft/tests/components/worker.rs b/node/bft/tests/components/worker.rs index d1658bb02f..1877bd859a 100644 --- a/node/bft/tests/components/worker.rs +++ b/node/bft/tests/components/worker.rs @@ -18,7 +18,7 @@ use crate::{ }; use snarkos_node_bft::helpers::max_redundant_requests; use snarkvm::{ - ledger::narwhal::TransmissionID, + ledger::{committee::Committee, narwhal::TransmissionID}, prelude::{Network, TestRng}, }; @@ -27,7 +27,7 @@ use std::net::SocketAddr; #[tokio::test] #[rustfmt::skip] async fn test_resend_transmission_request() { - const NUM_NODES: u16 = 10; + const NUM_NODES: u16 = Committee::::MAX_COMMITTEE_SIZE; // Initialize the RNG. let rng = &mut TestRng::default(); @@ -38,7 +38,7 @@ async fn test_resend_transmission_request() { // Determine the maximum number of redundant requests. let max_redundancy = max_redundant_requests(ledger.clone(), 0); - assert_eq!(max_redundancy, 4, "Update me if the formula changes"); + assert_eq!(max_redundancy, 34, "Update me if the formula changes"); // Prepare a dummy transmission ID. let peer_ip = SocketAddr::from(([127, 0, 0, 1], 1234)); @@ -86,7 +86,7 @@ async fn test_resend_transmission_request() { #[tokio::test] #[rustfmt::skip] async fn test_flood_transmission_requests() { - const NUM_NODES: u16 = 10; + const NUM_NODES: u16 = Committee::::MAX_COMMITTEE_SIZE; // Initialize the RNG. let rng = &mut TestRng::default(); @@ -97,7 +97,7 @@ async fn test_flood_transmission_requests() { // Determine the maximum number of redundant requests. let max_redundancy = max_redundant_requests(ledger.clone(), 0); - assert_eq!(max_redundancy, 4, "Update me if the formula changes"); + assert_eq!(max_redundancy, 34, "Update me if the formula changes"); // Prepare a dummy transmission ID. let peer_ip = SocketAddr::from(([127, 0, 0, 1], 1234)); From 086103ec05772ed22d4c5a8d1fe8560cf41c8486 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 19 Mar 2024 15:56:52 -0700 Subject: [PATCH 256/551] Update snarkVM rev - eefd27d --- Cargo.lock | 116 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 2 +- 2 files changed, 59 insertions(+), 59 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e76be79509..140828d972 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3301,7 +3301,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "anstyle", "anyhow", @@ -3332,7 +3332,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "aleo-std", "anyhow", @@ -3362,7 +3362,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3376,7 +3376,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3387,7 +3387,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3397,7 +3397,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3407,7 +3407,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "indexmap 2.2.5", "itertools 0.11.0", @@ -3425,12 +3425,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3441,7 +3441,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3456,7 +3456,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3471,7 +3471,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3484,7 +3484,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3493,7 +3493,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3503,7 +3503,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3515,7 +3515,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3527,7 +3527,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3538,7 +3538,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3550,7 +3550,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3563,7 +3563,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "bs58", "snarkvm-console-network", @@ -3574,7 +3574,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "blake2s_simd", "smallvec", @@ -3587,7 +3587,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "aleo-std", "rayon", @@ -3598,7 +3598,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "anyhow", "indexmap 2.2.5", @@ -3621,7 +3621,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "anyhow", "bech32", @@ -3639,7 +3639,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "enum_index", "enum_index_derive", @@ -3660,7 +3660,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3675,7 +3675,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3686,7 +3686,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "snarkvm-console-network-environment", ] @@ -3694,7 +3694,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3704,7 +3704,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3715,7 +3715,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3726,7 +3726,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3737,7 +3737,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3748,7 +3748,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "rand", "rayon", @@ -3762,7 +3762,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "aleo-std", "anyhow", @@ -3779,7 +3779,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "aleo-std", "anyhow", @@ -3804,7 +3804,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "anyhow", "rand", @@ -3816,7 +3816,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3835,7 +3835,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-coinbase" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "aleo-std", "anyhow", @@ -3855,7 +3855,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "anyhow", "indexmap 2.2.5", @@ -3873,7 +3873,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -3886,7 +3886,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3899,7 +3899,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "indexmap 2.2.5", "serde_json", @@ -3911,7 +3911,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "bytes", "serde_json", @@ -3922,7 +3922,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3937,7 +3937,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "bytes", "serde_json", @@ -3950,7 +3950,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "snarkvm-console", "snarkvm-ledger-coinbase", @@ -3959,7 +3959,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "async-trait", "reqwest", @@ -3972,7 +3972,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "aleo-std-storage", "anyhow", @@ -3998,7 +3998,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4013,7 +4013,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4022,7 +4022,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "aleo-std", "anyhow", @@ -4047,7 +4047,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "aleo-std", "anyhow", @@ -4073,7 +4073,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "aleo-std", "colored", @@ -4096,7 +4096,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "indexmap 2.2.5", "paste", @@ -4110,7 +4110,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "bincode", "once_cell", @@ -4123,7 +4123,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "aleo-std", "anyhow", @@ -4144,7 +4144,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=e29c1df#e29c1dff55a652f59cfffb584da20d48e05eafbf" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=eefd27d#eefd27d8637c78925f25bdb5878e67a9e2addeeb" dependencies = [ "proc-macro2", "quote 1.0.35", diff --git a/Cargo.toml b/Cargo.toml index 625bd434c5..e97eed2eae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "e29c1df" +rev = "eefd27d" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From efc6468b8add8c14e891a01961aeadbcaec5bba7 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 19 Mar 2024 16:00:09 -0700 Subject: [PATCH 257/551] Use variables instead of constants --- node/bft/src/worker.rs | 7 +++++-- node/bft/tests/common/primary.rs | 6 ++++-- node/bft/tests/components/mod.rs | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index dfa6490fe5..25e0a9bd3b 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -554,9 +554,12 @@ mod tests { #[tokio::test] async fn test_max_redundant_requests() { + const NUM_NODES: u16 = Committee::::MAX_COMMITTEE_SIZE; + let rng = &mut TestRng::default(); // Sample a committee. - let committee = snarkvm::ledger::committee::test_helpers::sample_committee_for_round_and_size(0, 10, rng); + let committee = + snarkvm::ledger::committee::test_helpers::sample_committee_for_round_and_size(0, NUM_NODES, rng); let committee_clone = committee.clone(); // Setup the mock ledger. let mut mock_ledger = MockLedger::default(); @@ -567,7 +570,7 @@ mod tests { let ledger: Arc> = Arc::new(mock_ledger); // Ensure the maximum number of redundant requests is correct and consistent across iterations. - assert_eq!(max_redundant_requests(ledger, 0), 4, "Update me if the formula changes"); + assert_eq!(max_redundant_requests(ledger, 0), 34, "Update me if the formula changes"); } #[tokio::test] diff --git a/node/bft/tests/common/primary.rs b/node/bft/tests/common/primary.rs index 18ace2646f..086112247d 100644 --- a/node/bft/tests/common/primary.rs +++ b/node/bft/tests/common/primary.rs @@ -29,6 +29,7 @@ use snarkvm::{ console::{ account::{Address, PrivateKey}, algorithms::{Hash, BHP256}, + network::Network, }, ledger::{ block::Block, @@ -137,8 +138,9 @@ impl TestNetwork { .map(|(address, (amount, _))| (*address, (*address, *address, *amount))) .collect(); let gen_key = *accounts[0].private_key(); - let public_balance_per_validator = - (1_500_000_000_000_000 - (config.num_nodes as u64) * 10_000_000_000_000) / (config.num_nodes as u64); + let public_balance_per_validator = (::STARTING_SUPPLY + - (config.num_nodes as u64) * MIN_VALIDATOR_STAKE) + / (config.num_nodes as u64); let mut balances = IndexMap::, u64>::new(); for account in accounts.iter() { balances.insert(account.address(), public_balance_per_validator); diff --git a/node/bft/tests/components/mod.rs b/node/bft/tests/components/mod.rs index a1eb8a1552..1c9c573f9e 100644 --- a/node/bft/tests/components/mod.rs +++ b/node/bft/tests/components/mod.rs @@ -22,7 +22,7 @@ use snarkos_node_bft_ledger_service::LedgerService; use snarkos_node_bft_storage_service::BFTMemoryService; use snarkvm::{ console::{account::Address, network::Network}, - ledger::{narwhal::BatchHeader, store::helpers::memory::ConsensusMemory}, + ledger::{committee::MIN_VALIDATOR_STAKE, narwhal::BatchHeader, store::helpers::memory::ConsensusMemory}, prelude::TestRng, }; @@ -42,7 +42,7 @@ pub fn sample_ledger( committee.members().iter().map(|(address, (amount, _))| (*address, (*address, *address, *amount))).collect(); let gen_key = *accounts[0].private_key(); let public_balance_per_validator = - (1_500_000_000_000_000 - (num_nodes as u64) * 10_000_000_000_000) / (num_nodes as u64); + (::STARTING_SUPPLY - (num_nodes as u64) * MIN_VALIDATOR_STAKE) / (num_nodes as u64); let mut balances = IndexMap::, u64>::new(); for account in accounts.iter() { balances.insert(account.address(), public_balance_per_validator); From 7908f9edc1e3b132325c333cf65c4a55fd32914a Mon Sep 17 00:00:00 2001 From: ljedrz Date: Wed, 20 Mar 2024 12:06:00 +0100 Subject: [PATCH 258/551] cleanup: reuse the BlockLocators s11n impl Signed-off-by: ljedrz --- node/router/messages/src/ping.rs | 45 +++++--------------------------- 1 file changed, 7 insertions(+), 38 deletions(-) diff --git a/node/router/messages/src/ping.rs b/node/router/messages/src/ping.rs index c0e982b6ef..05e4f9f719 100644 --- a/node/router/messages/src/ping.rs +++ b/node/router/messages/src/ping.rs @@ -16,7 +16,6 @@ use super::*; use snarkvm::prelude::{FromBytes, ToBytes}; -use indexmap::IndexMap; use std::borrow::Cow; #[derive(Clone, Debug, PartialEq, Eq)] @@ -40,18 +39,7 @@ impl ToBytes for Ping { self.node_type.write_le(&mut writer)?; if let Some(locators) = &self.block_locators { 1u8.write_le(&mut writer)?; - - (locators.recents.len().min(u32::MAX as usize) as u32).write_le(&mut writer)?; - for (height, hash) in locators.recents.iter() { - height.write_le(&mut writer)?; - hash.write_le(&mut writer)?; - } - - (locators.checkpoints.len().min(u32::MAX as usize) as u32).write_le(&mut writer)?; - for (height, hash) in locators.checkpoints.iter() { - height.write_le(&mut writer)?; - hash.write_le(&mut writer)?; - } + locators.write_le(&mut writer)?; } else { 0u8.write_le(&mut writer)?; } @@ -66,32 +54,13 @@ impl FromBytes for Ping { let node_type = NodeType::read_le(&mut reader)?; let selector = u8::read_le(&mut reader)?; + let block_locators = match selector { + 0 => None, + 1 => Some(BlockLocators::read_le(&mut reader)?), + _ => return Err(error("Invalid block locators marker")), + }; - if selector == 0 { - Ok(Self { version, node_type, block_locators: None }) - } else if selector == 1 { - let mut recents = IndexMap::new(); - let num_recents = u32::read_le(&mut reader)?; - for _ in 0..num_recents { - let height = u32::read_le(&mut reader)?; - let hash = N::BlockHash::read_le(&mut reader)?; - recents.insert(height, hash); - } - - let mut checkpoints = IndexMap::new(); - let num_checkpoints = u32::read_le(&mut reader)?; - for _ in 0..num_checkpoints { - let height = u32::read_le(&mut reader)?; - let hash = N::BlockHash::read_le(&mut reader)?; - checkpoints.insert(height, hash); - } - - let block_locators = Some(BlockLocators { recents, checkpoints }); - - Ok(Self { version, node_type, block_locators }) - } else { - Err(error("Invalid selector of optional block locators in ping message")) - } + Ok(Self { version, node_type, block_locators }) } } From 572900f0b2040839884956a6b696551f1d66e584 Mon Sep 17 00:00:00 2001 From: shnacke <93600681+miazn@users.noreply.github.com> Date: Wed, 20 Mar 2024 08:41:22 -0400 Subject: [PATCH 259/551] Update node/consensus/src/lib.rs Co-authored-by: ljedrz Signed-off-by: shnacke <93600681+miazn@users.noreply.github.com> --- node/consensus/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index b3a11e174c..595054d7f6 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -475,7 +475,7 @@ impl Consensus { metrics::histogram_label( metrics::consensus::TRANSMISSION_LATENCY, "transmission_type", - transmission_type_string.to_string(), + transmission_type_string.to_owned(), elapsed_time.as_secs_f64(), ); keys_to_remove.push(key.clone()); From 06aeeb38ad022e0ebaa0b70d7fe9cf622188d27e Mon Sep 17 00:00:00 2001 From: shnacke <93600681+miazn@users.noreply.github.com> Date: Wed, 20 Mar 2024 08:56:28 -0400 Subject: [PATCH 260/551] Update node/consensus/src/lib.rs Co-authored-by: ljedrz Signed-off-by: shnacke <93600681+miazn@users.noreply.github.com> --- node/consensus/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 595054d7f6..3bb9b0d2fe 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -136,7 +136,7 @@ impl Consensus { seen_transactions: Arc::new(Mutex::new(LruCache::new(NonZeroUsize::new(1 << 16).unwrap()))), handles: Default::default(), #[cfg(feature = "metrics")] - transmissions_queue_timestamps: Arc::new(Mutex::new(HashMap::new())), + transmissions_queue_timestamps: Default::default(), }) } From 39c9eb2b1ec072c31662112e7cc60d7255821b34 Mon Sep 17 00:00:00 2001 From: miazn Date: Wed, 20 Mar 2024 09:03:02 -0400 Subject: [PATCH 261/551] changes --- node/consensus/src/lib.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 595054d7f6..fd948cbc6e 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -222,9 +222,10 @@ impl Consensus { { metrics::increment_gauge(metrics::consensus::UNCONFIRMED_SOLUTIONS, 1f64); metrics::increment_gauge(metrics::consensus::UNCONFIRMED_TRANSMISSIONS, 1f64); + let timestamp = snarkos_node_bft::helpers::now(); self.transmissions_queue_timestamps .lock() - .insert(TransmissionID::Solution(solution.commitment()), snarkos_node_bft::helpers::now()); + .insert(TransmissionID::Solution(solution.commitment()), timestamp); } // Process the unconfirmed solution. { @@ -283,9 +284,10 @@ impl Consensus { { metrics::increment_gauge(metrics::consensus::UNCONFIRMED_TRANSACTIONS, 1f64); metrics::increment_gauge(metrics::consensus::UNCONFIRMED_TRANSMISSIONS, 1f64); + let timestamp = snarkos_node_bft::helpers::now(); self.transmissions_queue_timestamps .lock() - .insert(TransmissionID::Transaction(transaction.id()), snarkos_node_bft::helpers::now()); + .insert(TransmissionID::Transaction(transaction.id()), timestamp); } // Process the unconfirmed transaction. { @@ -450,16 +452,17 @@ impl Consensus { const AGE_THRESHOLD_SECONDS: i32 = 30 * 60; // 30 minutes set as stale transmission threshold let mut keys_to_remove = Vec::new(); - let mut transmission_queue_timestamps = self.transmissions_queue_timestamps.lock(); let solution_ids: std::collections::HashSet<_> = next_block.solutions().solution_ids().collect(); let transaction_ids: std::collections::HashSet<_> = next_block.transaction_ids().collect(); + let mut transmission_queue_timestamps = self.transmissions_queue_timestamps.lock(); + let ts_now = snarkos_node_bft::helpers::now(); for (key, timestamp) in transmission_queue_timestamps.iter() { - let elapsed_time = std::time::Duration::from_secs((snarkos_node_bft::helpers::now() - *timestamp) as u64); + let elapsed_time = std::time::Duration::from_secs((ts_now - *timestamp) as u64); if elapsed_time.as_secs() > AGE_THRESHOLD_SECONDS as u64 { - // This entry is stale-- remove it from transmission queue and record it as a stale transmission + // This entry is stale-- remove it from transmission queue and record it as a stale transmission. metrics::increment_counter(metrics::consensus::STALE_UNCONFIRMED_TRANSMISSIONS); keys_to_remove.push(key.clone()); } else { From ac18bdd7a39e886a1252ca0f980f9659cf432fc8 Mon Sep 17 00:00:00 2001 From: miazn Date: Wed, 20 Mar 2024 09:04:06 -0400 Subject: [PATCH 262/551] changes --- node/consensus/src/lib.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index fd948cbc6e..e0bf173ddd 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -285,9 +285,7 @@ impl Consensus { metrics::increment_gauge(metrics::consensus::UNCONFIRMED_TRANSACTIONS, 1f64); metrics::increment_gauge(metrics::consensus::UNCONFIRMED_TRANSMISSIONS, 1f64); let timestamp = snarkos_node_bft::helpers::now(); - self.transmissions_queue_timestamps - .lock() - .insert(TransmissionID::Transaction(transaction.id()), timestamp); + self.transmissions_queue_timestamps.lock().insert(TransmissionID::Transaction(transaction.id()), timestamp); } // Process the unconfirmed transaction. { @@ -457,7 +455,7 @@ impl Consensus { let transaction_ids: std::collections::HashSet<_> = next_block.transaction_ids().collect(); let mut transmission_queue_timestamps = self.transmissions_queue_timestamps.lock(); - let ts_now = snarkos_node_bft::helpers::now(); + let ts_now = snarkos_node_bft::helpers::now(); for (key, timestamp) in transmission_queue_timestamps.iter() { let elapsed_time = std::time::Duration::from_secs((ts_now - *timestamp) as u64); From 51aa1f3f571c366157f6b7272e446e42d7969b5f Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 20 Mar 2024 16:06:05 -0700 Subject: [PATCH 263/551] Skip proposing transmissions that are in previous certificates --- node/bft/src/primary.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index f91cd52bf4..2ef40b2080 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -360,6 +360,10 @@ impl Primary { let previous_round = round.saturating_sub(1); // Retrieve the previous certificates. let previous_certificates = self.storage.get_certificates_for_round(previous_round); + // Retrieve the transmissions included in the previous certificates. + let previous_certificate_transmissions = cfg_iter!(previous_certificates) + .flat_map(|certificate| certificate.transmission_ids()) + .collect::>(); // Check if the batch is ready to be proposed. // Note: The primary starts at round 1, and round 0 contains no certificates, by definition. @@ -400,6 +404,11 @@ impl Primary { trace!("Proposing - Skipping transmission '{}' - Already in ledger", fmt_id(id)); continue; } + // Check if the previous certificates already contain the transmission. + if previous_certificate_transmissions.contains(&id) { + trace!("Proposing - Skipping transmission '{}' - Already in previous certificates", fmt_id(id)); + continue; + } // Check the transmission is still valid. match (id, transmission.clone()) { (TransmissionID::Solution(solution_id), Transmission::Solution(solution)) => { From 639a556e4b2a31eea8c5d8e6e50f27de51aa2957 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 20 Mar 2024 16:09:34 -0700 Subject: [PATCH 264/551] Drain more transmissions from the worker if there aren't enough --- node/bft/src/primary.rs | 80 ++++++++++++++++++++++++----------------- 1 file changed, 48 insertions(+), 32 deletions(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 2ef40b2080..677b18ebda 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -398,43 +398,59 @@ impl Primary { let mut num_transactions = 0; // Take the transmissions from the workers. for worker in self.workers.iter() { - for (id, transmission) in worker.drain(num_transmissions_per_worker) { - // Check if the ledger already contains the transmission. - if self.ledger.contains_transmission(&id).unwrap_or(true) { - trace!("Proposing - Skipping transmission '{}' - Already in ledger", fmt_id(id)); - continue; - } - // Check if the previous certificates already contain the transmission. - if previous_certificate_transmissions.contains(&id) { - trace!("Proposing - Skipping transmission '{}' - Already in previous certificates", fmt_id(id)); - continue; + // Initialize a tracker for included transmissions for the current worker. + let mut num_transmissions_included_for_worker = 0; + // Keep draining the worker until the desired number of transmissions is reached or the worker is empty. + 'outer: while num_transmissions_included_for_worker < num_transmissions_per_worker { + // Determine the number of remaining transmissions for the worker. + let num_remaining_transmissions = + num_transmissions_per_worker.saturating_sub(num_transmissions_included_for_worker); + // Drain the worker. + let mut worker_transmissions = worker.drain(num_remaining_transmissions).peekable(); + // If the worker is empty, break early. + if worker_transmissions.peek().is_none() { + break 'outer; } - // Check the transmission is still valid. - match (id, transmission.clone()) { - (TransmissionID::Solution(solution_id), Transmission::Solution(solution)) => { - // Check if the solution is still valid. - if let Err(e) = self.ledger.check_solution_basic(solution_id, solution).await { - trace!("Proposing - Skipping solution '{}' - {e}", fmt_id(solution_id)); - continue; - } + // Iterate through the worker transmissions. + 'inner: for (id, transmission) in worker_transmissions { + // Check if the ledger already contains the transmission. + if self.ledger.contains_transmission(&id).unwrap_or(true) { + trace!("Proposing - Skipping transmission '{}' - Already in ledger", fmt_id(id)); + continue 'inner; } - (TransmissionID::Transaction(transaction_id), Transmission::Transaction(transaction)) => { - // Check if the transaction is still valid. - if let Err(e) = self.ledger.check_transaction_basic(transaction_id, transaction).await { - trace!("Proposing - Skipping transaction '{}' - {e}", fmt_id(transaction_id)); - continue; + // Check if the previous certificates already contain the transmission. + if previous_certificate_transmissions.contains(&id) { + trace!("Proposing - Skipping transmission '{}' - Already in previous certificates", fmt_id(id)); + continue 'inner; + } + // Check the transmission is still valid. + match (id, transmission.clone()) { + (TransmissionID::Solution(solution_id), Transmission::Solution(solution)) => { + // Check if the solution is still valid. + if let Err(e) = self.ledger.check_solution_basic(solution_id, solution).await { + trace!("Proposing - Skipping solution '{}' - {e}", fmt_id(solution_id)); + continue 'inner; + } + } + (TransmissionID::Transaction(transaction_id), Transmission::Transaction(transaction)) => { + // Check if the transaction is still valid. + if let Err(e) = self.ledger.check_transaction_basic(transaction_id, transaction).await { + trace!("Proposing - Skipping transaction '{}' - {e}", fmt_id(transaction_id)); + continue 'inner; + } + // Increment the number of transactions. + num_transactions += 1; } - // Increment the number of transactions. - num_transactions += 1; + // Note: We explicitly forbid including ratifications, + // as the protocol currently does not support ratifications. + (TransmissionID::Ratification, Transmission::Ratification) => continue, + // All other combinations are clearly invalid. + _ => continue 'inner, } - // Note: We explicitly forbid including ratifications, - // as the protocol currently does not support ratifications. - (TransmissionID::Ratification, Transmission::Ratification) => continue, - // All other combinations are clearly invalid. - _ => continue, + // Insert the transmission into the map. + transmissions.insert(id, transmission); + num_transmissions_included_for_worker += 1; } - // Insert the transmission into the map. - transmissions.insert(id, transmission); } } // If there are no unconfirmed transmissions to propose, return early. From c79299d98279fe8377119874d5f92b0c4b5235f8 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 20 Mar 2024 16:54:04 -0700 Subject: [PATCH 265/551] Add test for skipping transmission from previous certificates --- node/bft/src/primary.rs | 66 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 677b18ebda..5a5899f4b1 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -1786,6 +1786,72 @@ mod tests { assert!(primary.proposed_batch.read().is_some()); } + #[tokio::test] + async fn test_propose_batch_skip_transmissions_from_previous_certificates() { + let round = 3; + let prev_round = round - 1; + let mut rng = TestRng::default(); + let (primary, accounts) = primary_without_handlers(&mut rng).await; + let peer_account = &accounts[1]; + let peer_ip = peer_account.0; + + // Fill primary storage. + store_certificate_chain(&primary, &accounts, round, &mut rng); + + // Get transmissions from previous certificates. + let previous_certificate_ids: IndexSet<_> = + primary.storage.get_certificates_for_round(prev_round).iter().map(|cert| cert.id()).collect(); + + // Track the number of transmissions in the previous round. + let mut num_transmissions_in_previous_round = 0; + + // Create certificates for the current round and add the transmissions to the worker before inserting the certificate to storage. + for (_, account) in accounts.iter() { + let (certificate, transmissions) = create_batch_certificate( + account.address(), + &accounts, + round, + previous_certificate_ids.clone(), + &mut rng, + ); + + // Add the transmissions to the worker. + for (transmission_id, transmission) in transmissions.iter() { + primary.workers[0].process_transmission_from_peer(peer_ip, *transmission_id, transmission.clone()); + } + + // Insert the certificate to storage. + num_transmissions_in_previous_round += transmissions.len(); + primary.storage.insert_certificate(certificate, transmissions).unwrap(); + } + + // Check that the worker has `num_transmissions_in_previous_round` transmissions. + assert_eq!(primary.workers[0].num_transmissions(), num_transmissions_in_previous_round); + + // Advance to the next round. + assert!(primary.storage.increment_to_next_round(round).is_ok()); + + // Generate a solution and a transaction. + let (solution_commitment, solution) = sample_unconfirmed_solution(&mut rng); + let (transaction_id, transaction) = sample_unconfirmed_transaction(&mut rng); + + // Store it on one of the workers. + primary.workers[0].process_unconfirmed_solution(solution_commitment, solution).await.unwrap(); + primary.workers[0].process_unconfirmed_transaction(transaction_id, transaction).await.unwrap(); + + // Check that the worker has `num_transmissions_in_previous_round + 2` transmissions. + assert_eq!(primary.workers[0].num_transmissions(), num_transmissions_in_previous_round + 2); + + // Propose the batch. + assert!(primary.propose_batch().await.is_ok()); + + // Check that the proposal only contains the new transmissions that were not in previous certificates. + let proposed_transmissions = primary.proposed_batch.read().as_ref().unwrap().transmissions().clone(); + assert_eq!(proposed_transmissions.len(), 2); + assert!(proposed_transmissions.contains_key(&TransmissionID::Solution(solution_commitment))); + assert!(proposed_transmissions.contains_key(&TransmissionID::Transaction(transaction_id))); + } + #[tokio::test] async fn test_batch_propose_from_peer() { let mut rng = TestRng::default(); From 1d5bf66373d0205eed05a55737f19b0ac1f13199 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 20 Mar 2024 18:06:18 -0700 Subject: [PATCH 266/551] Add new maximum for transmissions sent to memory pool --- node/bft/src/primary.rs | 3 +++ node/consensus/src/lib.rs | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 5a5899f4b1..f524918f34 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -99,6 +99,9 @@ pub struct Primary { } impl Primary { + /// The maximum number of unconfirmed transmissions to send to the primary. + pub const MAX_TRANSMISSIONS_IN_MEMORY_POOL: usize = BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH * 2; + /// Initializes a new primary instance. pub fn new( account: Account, diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 75b02e89e0..9e76ec452b 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -28,6 +28,7 @@ use snarkos_node_bft::{ Storage as NarwhalStorage, }, spawn_blocking, + Primary, BFT, }; use snarkos_node_bft_ledger_service::LedgerService; @@ -305,13 +306,13 @@ impl Consensus { // If the memory pool of this node is full, return early. let num_unconfirmed = self.num_unconfirmed_transmissions(); - if num_unconfirmed > BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH { + if num_unconfirmed > Primary::::MAX_TRANSMISSIONS_IN_MEMORY_POOL { return Ok(()); } // Retrieve the transactions. let transactions = { // Determine the available capacity. - let capacity = BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH.saturating_sub(num_unconfirmed); + let capacity = Primary::::MAX_TRANSMISSIONS_IN_MEMORY_POOL.saturating_sub(num_unconfirmed); // Acquire the lock on the transactions queue. let mut tx_queue = self.transactions_queue.lock(); // Determine the number of deployments to send. From 777c00d51d70bac6d306c243becf23cb0d7a845a Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 20 Mar 2024 18:12:44 -0700 Subject: [PATCH 267/551] nit --- node/bft/tests/common/primary.rs | 2 +- node/bft/tests/components/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/node/bft/tests/common/primary.rs b/node/bft/tests/common/primary.rs index 086112247d..029c8d54b0 100644 --- a/node/bft/tests/common/primary.rs +++ b/node/bft/tests/common/primary.rs @@ -138,7 +138,7 @@ impl TestNetwork { .map(|(address, (amount, _))| (*address, (*address, *address, *amount))) .collect(); let gen_key = *accounts[0].private_key(); - let public_balance_per_validator = (::STARTING_SUPPLY + let public_balance_per_validator = (CurrentNetwork::STARTING_SUPPLY - (config.num_nodes as u64) * MIN_VALIDATOR_STAKE) / (config.num_nodes as u64); let mut balances = IndexMap::, u64>::new(); diff --git a/node/bft/tests/components/mod.rs b/node/bft/tests/components/mod.rs index 1c9c573f9e..65336665cc 100644 --- a/node/bft/tests/components/mod.rs +++ b/node/bft/tests/components/mod.rs @@ -42,7 +42,7 @@ pub fn sample_ledger( committee.members().iter().map(|(address, (amount, _))| (*address, (*address, *address, *amount))).collect(); let gen_key = *accounts[0].private_key(); let public_balance_per_validator = - (::STARTING_SUPPLY - (num_nodes as u64) * MIN_VALIDATOR_STAKE) / (num_nodes as u64); + (CurrentNetwork::STARTING_SUPPLY - (num_nodes as u64) * MIN_VALIDATOR_STAKE) / (num_nodes as u64); let mut balances = IndexMap::, u64>::new(); for account in accounts.iter() { balances.insert(account.address(), public_balance_per_validator); From 2ea4cc7e6d1b13f716ec0a5cf080ed57ad670724 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 20 Mar 2024 18:54:23 -0700 Subject: [PATCH 268/551] Keep at least one transmission in the proposal --- node/bft/src/primary.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index f524918f34..16c47d5671 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -363,10 +363,6 @@ impl Primary { let previous_round = round.saturating_sub(1); // Retrieve the previous certificates. let previous_certificates = self.storage.get_certificates_for_round(previous_round); - // Retrieve the transmissions included in the previous certificates. - let previous_certificate_transmissions = cfg_iter!(previous_certificates) - .flat_map(|certificate| certificate.transmission_ids()) - .collect::>(); // Check if the batch is ready to be proposed. // Note: The primary starts at round 1, and round 0 contains no certificates, by definition. @@ -421,9 +417,11 @@ impl Primary { trace!("Proposing - Skipping transmission '{}' - Already in ledger", fmt_id(id)); continue 'inner; } - // Check if the previous certificates already contain the transmission. - if previous_certificate_transmissions.contains(&id) { - trace!("Proposing - Skipping transmission '{}' - Already in previous certificates", fmt_id(id)); + // Check if the storage already contain the transmission. + // Note: We do not skip if this is the first transmission in the proposal, to ensure that + // the primary does not propose a batch with no transmissions. + if !transmissions.is_empty() && self.storage.contains_transmission(id) { + trace!("Proposing - Skipping transmission '{}' - Already in storage", fmt_id(id)); continue 'inner; } // Check the transmission is still valid. From e074e0e158cf3e7907ee77f5146026a50c2c5ecc Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 20 Mar 2024 18:56:55 -0700 Subject: [PATCH 269/551] Cleanup test --- node/bft/src/primary.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 16c47d5671..611a3d5c5d 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -1806,6 +1806,17 @@ mod tests { // Track the number of transmissions in the previous round. let mut num_transmissions_in_previous_round = 0; + // Generate a solution and a transaction. + let (solution_commitment, solution) = sample_unconfirmed_solution(&mut rng); + let (transaction_id, transaction) = sample_unconfirmed_transaction(&mut rng); + + // Store it on one of the workers. + primary.workers[0].process_unconfirmed_solution(solution_commitment, solution).await.unwrap(); + primary.workers[0].process_unconfirmed_transaction(transaction_id, transaction).await.unwrap(); + + // Check that the worker has 2 transmissions. + assert_eq!(primary.workers[0].num_transmissions(), 2); + // Create certificates for the current round and add the transmissions to the worker before inserting the certificate to storage. for (_, account) in accounts.iter() { let (certificate, transmissions) = create_batch_certificate( @@ -1826,20 +1837,9 @@ mod tests { primary.storage.insert_certificate(certificate, transmissions).unwrap(); } - // Check that the worker has `num_transmissions_in_previous_round` transmissions. - assert_eq!(primary.workers[0].num_transmissions(), num_transmissions_in_previous_round); - // Advance to the next round. assert!(primary.storage.increment_to_next_round(round).is_ok()); - // Generate a solution and a transaction. - let (solution_commitment, solution) = sample_unconfirmed_solution(&mut rng); - let (transaction_id, transaction) = sample_unconfirmed_transaction(&mut rng); - - // Store it on one of the workers. - primary.workers[0].process_unconfirmed_solution(solution_commitment, solution).await.unwrap(); - primary.workers[0].process_unconfirmed_transaction(transaction_id, transaction).await.unwrap(); - // Check that the worker has `num_transmissions_in_previous_round + 2` transmissions. assert_eq!(primary.workers[0].num_transmissions(), num_transmissions_in_previous_round + 2); From d403902a4c4054a2763dcd3bb4cd5b6b4fbde94e Mon Sep 17 00:00:00 2001 From: miazn Date: Thu, 21 Mar 2024 11:34:09 -0400 Subject: [PATCH 270/551] change from clone to dereference --- node/consensus/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 95c27c2c6c..037015869c 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -462,7 +462,7 @@ impl Consensus { if elapsed_time.as_secs() > AGE_THRESHOLD_SECONDS as u64 { // This entry is stale-- remove it from transmission queue and record it as a stale transmission. metrics::increment_counter(metrics::consensus::STALE_UNCONFIRMED_TRANSMISSIONS); - keys_to_remove.push(key.clone()); + keys_to_remove.push(*key); } else { let transmission_type = match key { TransmissionID::Solution(solution_id) if solution_ids.contains(solution_id) => Some("solution"), @@ -479,7 +479,7 @@ impl Consensus { transmission_type_string.to_owned(), elapsed_time.as_secs_f64(), ); - keys_to_remove.push(key.clone()); + keys_to_remove.push(*key); } } } From 9c2f3a6cd447b3efdceb4ecac84da6dc569df576 Mon Sep 17 00:00:00 2001 From: Pranav Gaddamadugu <23022326+d0cd@users.noreply.github.com> Date: Thu, 21 Mar 2024 13:30:55 -0700 Subject: [PATCH 271/551] Add puzzle --- Cargo.lock | 295 ++++++++++-------- Cargo.toml | 2 +- node/bft/events/src/lib.rs | 8 +- node/bft/events/src/transmission_request.rs | 4 +- node/bft/events/src/transmission_response.rs | 4 +- node/bft/examples/simple_node.rs | 19 +- node/bft/ledger-service/src/ledger.rs | 47 ++- node/bft/ledger-service/src/mock.rs | 12 +- node/bft/ledger-service/src/prover.rs | 10 +- node/bft/ledger-service/src/traits.rs | 10 +- node/bft/ledger-service/src/translucent.rs | 10 +- node/bft/src/bft.rs | 4 +- node/bft/src/helpers/channels.rs | 12 +- node/bft/src/helpers/partition.rs | 4 +- node/bft/src/helpers/pending.rs | 62 ++-- node/bft/src/helpers/ready.rs | 52 +-- node/bft/src/helpers/storage.rs | 16 +- node/bft/src/primary.rs | 43 ++- node/bft/src/worker.rs | 60 ++-- node/bft/tests/common/utils.rs | 25 +- node/consensus/src/lib.rs | 18 +- node/rest/src/routes.rs | 16 +- node/router/messages/src/lib.rs | 2 +- node/router/messages/src/puzzle_response.rs | 21 +- .../messages/src/unconfirmed_solution.rs | 24 +- node/router/src/heartbeat.rs | 2 +- node/router/src/helpers/cache.rs | 42 +-- node/router/src/inbound.rs | 10 +- node/router/tests/common/router.rs | 6 +- node/src/client/mod.rs | 10 +- node/src/client/router.rs | 38 ++- node/src/prover/mod.rs | 100 +++--- node/src/prover/router.rs | 44 ++- node/src/validator/mod.rs | 2 +- node/src/validator/router.rs | 16 +- 35 files changed, 503 insertions(+), 547 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2b724e9d99..aa3ff56f1a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,9 +19,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "ahash" -version = "0.8.7" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", "once_cell", @@ -31,9 +31,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] @@ -202,13 +202,13 @@ checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "async-recursion" -version = "1.0.5" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" +checksum = "30c5ef0ede93efbf733c1a727f3b6b5a1060bbedd5600183e66f6e4be4af0ec5" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -230,18 +230,18 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] name = "async-trait" -version = "0.1.77" +version = "0.1.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" +checksum = "461abc97219de0eaaf81fe3ef974a540158f3d079c2ab200f891f1a2ef201e85" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -382,7 +382,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -408,9 +408,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.2" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" [[package]] name = "blake2" @@ -443,9 +443,9 @@ dependencies = [ [[package]] name = "bs58" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5353f36341f7451062466f0b755b96ac3a9547e4d7f6b70d603fc721a7d7896" +checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" dependencies = [ "tinyvec", ] @@ -573,7 +573,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -682,7 +682,7 @@ version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "crossterm_winapi", "libc", "mio", @@ -1018,7 +1018,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -1584,7 +1584,7 @@ version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "libc", "redox_syscall", ] @@ -1704,9 +1704,9 @@ dependencies = [ [[package]] name = "metrics" -version = "0.22.1" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd71d9db2e4287c3407fa04378b8c2ee570aebe0854431562cdd89ca091854f4" +checksum = "2be3cbd384d4e955b231c895ce10685e3d8260c5ccffae898c96c723b0772835" dependencies = [ "ahash", "portable-atomic", @@ -1733,9 +1733,9 @@ dependencies = [ [[package]] name = "metrics-util" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ece71ab046dcf45604e573329966ec1db5ff4b81cfa170a924ff4c959ab5451a" +checksum = "8b07a5eb561b8cbc16be2d216faf7757f9baf3bfb94dbb0fae3df8387a5bb47f" dependencies = [ "crossbeam-epoch", "crossbeam-utils", @@ -1813,7 +1813,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -1916,7 +1916,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -1999,7 +1999,7 @@ version = "0.10.64" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "cfg-if", "foreign-types", "libc", @@ -2016,7 +2016,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -2139,7 +2139,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -2211,7 +2211,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a41cf62165e97c7f814d2221421dbb9afcbcdb0a88068e5ea206e19951c2cbb5" dependencies = [ "proc-macro2", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -2231,7 +2231,7 @@ checksum = "31b476131c3c86cb68032fdc5cb6d5a1045e3e42d96b69fa599fd77701e1f5bf" dependencies = [ "bit-set", "bit-vec", - "bitflags 2.4.2", + "bitflags 2.5.0", "lazy_static", "num-traits", "rand", @@ -2343,7 +2343,7 @@ version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a5659e52e4ba6e07b2dad9f1158f578ef84a73762625ddb51536019f34d180eb" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "cassowary", "crossterm", "indoc", @@ -2362,7 +2362,7 @@ version = "11.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d86a7c4638d42c44551f4791a20e687dbb4c3de1f33c43dd71e355cd429def1" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", ] [[package]] @@ -2451,9 +2451,9 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "reqwest" -version = "0.11.26" +version = "0.11.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78bf93c4af7a8bb7d879d51cebe797356ff10ae8516ace542b5182d9dcac10b2" +checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" dependencies = [ "base64", "bytes", @@ -2537,11 +2537,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.31" +version = "0.38.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" +checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "errno", "libc", "linux-raw-sys", @@ -2743,7 +2743,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -2876,9 +2876,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.13.1" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "smol_str" @@ -3301,7 +3301,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "anstyle", "anyhow", @@ -3332,7 +3332,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "aleo-std", "anyhow", @@ -3362,7 +3362,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3376,7 +3376,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3387,7 +3387,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3397,7 +3397,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3407,7 +3407,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "indexmap 2.2.5", "itertools 0.11.0", @@ -3425,12 +3425,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3441,7 +3441,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3456,7 +3456,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3471,7 +3471,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3484,7 +3484,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3493,7 +3493,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3503,7 +3503,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3515,7 +3515,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3527,7 +3527,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3538,7 +3538,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3550,7 +3550,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3563,7 +3563,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "bs58", "snarkvm-console-network", @@ -3574,7 +3574,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "blake2s_simd", "smallvec", @@ -3587,7 +3587,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "aleo-std", "rayon", @@ -3598,7 +3598,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "anyhow", "indexmap 2.2.5", @@ -3621,7 +3621,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "anyhow", "bech32", @@ -3639,7 +3639,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "enum_index", "enum_index_derive", @@ -3660,7 +3660,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3675,7 +3675,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3686,7 +3686,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "snarkvm-console-network-environment", ] @@ -3694,7 +3694,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3704,7 +3704,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3715,7 +3715,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3726,7 +3726,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3737,7 +3737,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3748,7 +3748,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "rand", "rayon", @@ -3762,7 +3762,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "aleo-std", "anyhow", @@ -3779,7 +3779,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "aleo-std", "anyhow", @@ -3790,9 +3790,9 @@ dependencies = [ "snarkvm-console", "snarkvm-ledger-authority", "snarkvm-ledger-block", - "snarkvm-ledger-coinbase", "snarkvm-ledger-committee", "snarkvm-ledger-narwhal", + "snarkvm-ledger-puzzle", "snarkvm-ledger-query", "snarkvm-ledger-store", "snarkvm-ledger-test-helpers", @@ -3804,7 +3804,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "anyhow", "rand", @@ -3816,46 +3816,26 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "indexmap 2.2.5", "rayon", "serde_json", "snarkvm-console", "snarkvm-ledger-authority", - "snarkvm-ledger-coinbase", "snarkvm-ledger-committee", "snarkvm-ledger-narwhal-batch-header", "snarkvm-ledger-narwhal-subdag", "snarkvm-ledger-narwhal-transmission-id", + "snarkvm-ledger-puzzle", "snarkvm-synthesizer-program", "snarkvm-synthesizer-snark", ] -[[package]] -name = "snarkvm-ledger-coinbase" -version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" -dependencies = [ - "aleo-std", - "anyhow", - "bincode", - "blake2", - "indexmap 2.2.5", - "rayon", - "serde_json", - "snarkvm-algorithms", - "snarkvm-console", - "snarkvm-curves", - "snarkvm-fields", - "snarkvm-synthesizer-snark", - "snarkvm-utilities", -] - [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "anyhow", "indexmap 2.2.5", @@ -3863,6 +3843,7 @@ dependencies = [ "rand", "rand_chacha", "rand_distr", + "rayon", "serde_json", "snarkvm-console", "snarkvm-ledger-narwhal-batch-header", @@ -3873,7 +3854,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -3886,7 +3867,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3899,9 +3880,10 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "indexmap 2.2.5", + "rayon", "serde_json", "snarkvm-console", "snarkvm-ledger-narwhal-transmission-id", @@ -3911,7 +3893,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "bytes", "serde_json", @@ -3922,7 +3904,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3937,29 +3919,64 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "bytes", "serde_json", "snarkvm-console", "snarkvm-ledger-block", - "snarkvm-ledger-coinbase", "snarkvm-ledger-narwhal-data", + "snarkvm-ledger-puzzle", ] [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "snarkvm-console", - "snarkvm-ledger-coinbase", + "snarkvm-ledger-puzzle", +] + +[[package]] +name = "snarkvm-ledger-puzzle" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" +dependencies = [ + "aleo-std", + "anyhow", + "bincode", + "indexmap 2.2.5", + "lru", + "once_cell", + "parking_lot", + "rand", + "rand_chacha", + "rayon", + "serde_json", + "snarkvm-algorithms", + "snarkvm-console", +] + +[[package]] +name = "snarkvm-ledger-puzzle-epoch" +version = "0.16.19" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" +dependencies = [ + "anyhow", + "colored", + "indexmap 2.2.5", + "rand", + "rand_chacha", + "rayon", + "snarkvm-console", + "snarkvm-ledger-puzzle", ] [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "async-trait", "reqwest", @@ -3972,7 +3989,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "aleo-std-storage", "anyhow", @@ -3987,9 +4004,9 @@ dependencies = [ "snarkvm-console", "snarkvm-ledger-authority", "snarkvm-ledger-block", - "snarkvm-ledger-coinbase", "snarkvm-ledger-committee", "snarkvm-ledger-narwhal-batch-certificate", + "snarkvm-ledger-puzzle", "snarkvm-synthesizer-program", "snarkvm-synthesizer-snark", "tracing", @@ -3998,7 +4015,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4013,7 +4030,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4022,7 +4039,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "aleo-std", "anyhow", @@ -4047,7 +4064,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "aleo-std", "anyhow", @@ -4062,6 +4079,8 @@ dependencies = [ "snarkvm-console", "snarkvm-ledger-block", "snarkvm-ledger-committee", + "snarkvm-ledger-puzzle", + "snarkvm-ledger-puzzle-epoch", "snarkvm-ledger-query", "snarkvm-ledger-store", "snarkvm-synthesizer-process", @@ -4073,7 +4092,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "aleo-std", "colored", @@ -4096,7 +4115,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "indexmap 2.2.5", "paste", @@ -4110,7 +4129,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "bincode", "once_cell", @@ -4123,7 +4142,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "aleo-std", "anyhow", @@ -4144,11 +4163,11 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=01c8b09#01c8b095cfa8bbeb4dedc97543966af8026bce61" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=48dd2db#48dd2db633ea81843df86296a9bcac10a10e47d9" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -4201,7 +4220,7 @@ dependencies = [ "proc-macro2", "quote 1.0.35", "structmeta-derive", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -4212,7 +4231,7 @@ checksum = "a60bcaff7397072dca0017d1db428e30d5002e00b6847703e2e42005c95fbe00" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -4234,7 +4253,7 @@ dependencies = [ "proc-macro2", "quote 1.0.35", "rustversion", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -4267,9 +4286,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.52" +version = "2.0.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" +checksum = "7383cd0e49fff4b6b90ca5670bfd3e9d6a733b3f90c686605aa7eec8c4996032" dependencies = [ "proc-macro2", "quote 1.0.35", @@ -4349,7 +4368,7 @@ dependencies = [ "proc-macro2", "quote 1.0.35", "structmeta", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -4369,7 +4388,7 @@ checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -4484,7 +4503,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -4566,7 +4585,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "bytes", "futures-util", "http 1.1.0", @@ -4633,7 +4652,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -4951,7 +4970,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", "wasm-bindgen-shared", ] @@ -4985,7 +5004,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -5214,7 +5233,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -5234,5 +5253,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.52", + "syn 2.0.53", ] diff --git a/Cargo.toml b/Cargo.toml index f1107f7c36..3f2b142942 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "01c8b09" +rev = "48dd2db" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] diff --git a/node/bft/events/src/lib.rs b/node/bft/events/src/lib.rs index 33ba85c4a0..c6e5c04a8c 100644 --- a/node/bft/events/src/lib.rs +++ b/node/bft/events/src/lib.rs @@ -264,7 +264,7 @@ pub mod prop_tests { }; use snarkvm::{ console::{network::Network, types::Field}, - ledger::{coinbase::PuzzleCommitment, narwhal::TransmissionID}, + ledger::{narwhal::TransmissionID, puzzle::SolutionID}, prelude::{FromBytes, Rng, ToBytes, Uniform}, }; @@ -282,8 +282,8 @@ pub mod prop_tests { time::OffsetDateTime::now_utc().unix_timestamp() } - pub fn any_puzzle_commitment() -> BoxedStrategy> { - Just(0).prop_perturb(|_, mut rng| PuzzleCommitment::from_g1_affine(rng.gen())).boxed() + pub fn any_solution_id() -> BoxedStrategy> { + Just(0).prop_perturb(|_, mut rng| rng.gen::().into()).boxed() } pub fn any_transaction_id() -> BoxedStrategy<::TransactionID> { @@ -295,7 +295,7 @@ pub mod prop_tests { pub fn any_transmission_id() -> BoxedStrategy> { prop_oneof![ any_transaction_id().prop_map(TransmissionID::Transaction), - any_puzzle_commitment().prop_map(TransmissionID::Solution), + any_solution_id().prop_map(TransmissionID::Solution), ] .boxed() } diff --git a/node/bft/events/src/transmission_request.rs b/node/bft/events/src/transmission_request.rs index ec59c764c4..2fded63bb6 100644 --- a/node/bft/events/src/transmission_request.rs +++ b/node/bft/events/src/transmission_request.rs @@ -59,7 +59,7 @@ impl FromBytes for TransmissionRequest { #[cfg(test)] pub mod prop_tests { use crate::{ - prop_tests::{any_puzzle_commitment, any_transaction_id}, + prop_tests::{any_solution_id, any_transaction_id}, TransmissionRequest, }; use snarkvm::{ @@ -78,7 +78,7 @@ pub mod prop_tests { fn any_transmission_id() -> BoxedStrategy> { prop_oneof![ - any_puzzle_commitment().prop_map(TransmissionID::Solution), + any_solution_id().prop_map(TransmissionID::Solution), any_transaction_id().prop_map(TransmissionID::Transaction), ] .boxed() diff --git a/node/bft/events/src/transmission_response.rs b/node/bft/events/src/transmission_response.rs index 45c55a7edc..536f0067af 100644 --- a/node/bft/events/src/transmission_response.rs +++ b/node/bft/events/src/transmission_response.rs @@ -62,7 +62,7 @@ impl FromBytes for TransmissionResponse { #[cfg(test)] pub mod prop_tests { use crate::{ - prop_tests::{any_puzzle_commitment, any_transaction_id}, + prop_tests::{any_solution_id, any_transaction_id}, TransmissionResponse, }; use snarkvm::{ @@ -82,7 +82,7 @@ pub mod prop_tests { pub fn any_transmission() -> BoxedStrategy<(TransmissionID, Transmission)> { prop_oneof![ - (any_puzzle_commitment(), collection::vec(any::(), 256..=256)).prop_map(|(pc, bytes)| ( + (any_solution_id(), collection::vec(any::(), 256..=256)).prop_map(|(pc, bytes)| ( TransmissionID::Solution(pc), Transmission::Solution(Data::Buffer(Bytes::from(bytes))) )), diff --git a/node/bft/examples/simple_node.rs b/node/bft/examples/simple_node.rs index a7328c877e..9b2d22d748 100644 --- a/node/bft/examples/simple_node.rs +++ b/node/bft/examples/simple_node.rs @@ -27,9 +27,9 @@ use snarkos_node_bft_storage_service::BFTMemoryService; use snarkvm::{ ledger::{ block::Transaction, - coinbase::{ProverSolution, PuzzleCommitment}, committee::{Committee, MIN_VALIDATOR_STAKE}, narwhal::{BatchHeader, Data}, + puzzle::{Solution, SolutionID}, }, prelude::{Field, Network, Uniform}, }; @@ -269,28 +269,27 @@ fn fire_unconfirmed_solutions(sender: &PrimarySender, node_id: u // This RNG samples *different* fake solutions for each node. let mut unique_rng = rand_chacha::ChaChaRng::seed_from_u64(node_id as u64); - // A closure to generate a commitment and solution. - fn sample(mut rng: impl Rng) -> (PuzzleCommitment, Data>) { - // Sample a random fake puzzle commitment. - // TODO (howardwu): Use a mutex to bring in the real 'proof target' and change this sampling to a while loop. - let commitment = PuzzleCommitment::::from_g1_affine(rng.gen()); + // A closure to generate a solution ID and solution. + fn sample(mut rng: impl Rng) -> (SolutionID, Data>) { + // Sample a random fake solution ID. + let solution_id = rng.gen::().into(); // Sample random fake solution bytes. let solution = Data::Buffer(Bytes::from((0..1024).map(|_| rng.gen::()).collect::>())); // Return the ID and solution. - (commitment, solution) + (solution_id, solution) } // Initialize a counter. let mut counter = 0; loop { - // Sample a random fake puzzle commitment and solution. - let (commitment, solution) = + // Sample a random fake solution ID and solution. + let (solution_id, solution) = if counter % 2 == 0 { sample(&mut shared_rng) } else { sample(&mut unique_rng) }; // Initialize a callback sender and receiver. let (callback, callback_receiver) = oneshot::channel(); // Send the fake solution. - if let Err(e) = tx_unconfirmed_solution.send((commitment, solution, callback)).await { + if let Err(e) = tx_unconfirmed_solution.send((solution_id, solution, callback)).await { error!("Failed to send unconfirmed solution: {e}"); } let _ = callback_receiver.await; diff --git a/node/bft/ledger-service/src/ledger.rs b/node/bft/ledger-service/src/ledger.rs index d5b80e8e17..5c19e83215 100644 --- a/node/bft/ledger-service/src/ledger.rs +++ b/node/bft/ledger-service/src/ledger.rs @@ -16,9 +16,9 @@ use crate::{fmt_id, spawn_blocking, LedgerService}; use snarkvm::{ ledger::{ block::{Block, Transaction}, - coinbase::{CoinbaseVerifyingKey, ProverSolution, PuzzleCommitment}, committee::Committee, narwhal::{BatchCertificate, Data, Subdag, Transmission, TransmissionID}, + puzzle::{Solution, SolutionID}, store::ConsensusStorage, Ledger, }, @@ -37,14 +37,13 @@ use std::{ }, }; -/// The capacity of the LRU holiding the recently queried committees. +/// The capacity of the LRU holding the recently queried committees. const COMMITTEE_CACHE_SIZE: usize = 16; /// A core ledger service. #[allow(clippy::type_complexity)] pub struct CoreLedgerService> { ledger: Ledger, - coinbase_verifying_key: Arc>, committee_cache: Arc>>>, latest_leader: Arc)>>>, shutdown: Arc, @@ -53,9 +52,8 @@ pub struct CoreLedgerService> { impl> CoreLedgerService { /// Initializes a new core ledger service. pub fn new(ledger: Ledger, shutdown: Arc) -> Self { - let coinbase_verifying_key = Arc::new(ledger.coinbase_puzzle().coinbase_verifying_key().clone()); let committee_cache = Arc::new(Mutex::new(LruCache::new(COMMITTEE_CACHE_SIZE.try_into().unwrap()))); - Self { ledger, coinbase_verifying_key, committee_cache, latest_leader: Default::default(), shutdown } + Self { ledger, committee_cache, latest_leader: Default::default(), shutdown } } } @@ -125,7 +123,7 @@ impl> LedgerService for CoreLedgerService< } /// Returns the solution for the given solution ID. - fn get_solution(&self, solution_id: &PuzzleCommitment) -> Result> { + fn get_solution(&self, solution_id: &SolutionID) -> Result> { self.ledger.get_solution(solution_id) } @@ -203,7 +201,7 @@ impl> LedgerService for CoreLedgerService< fn contains_transmission(&self, transmission_id: &TransmissionID) -> Result { match transmission_id { TransmissionID::Ratification => Ok(false), - TransmissionID::Solution(puzzle_commitment) => self.ledger.contains_puzzle_commitment(puzzle_commitment), + TransmissionID::Solution(solution_id) => self.ledger.contains_solution_id(solution_id), TransmissionID::Transaction(transaction_id) => self.ledger.contains_transaction_id(transaction_id), } } @@ -241,14 +239,14 @@ impl> LedgerService for CoreLedgerService< } } } - (TransmissionID::Solution(expected_commitment), Transmission::Solution(solution_data)) => { + (TransmissionID::Solution(expected_solution_id), Transmission::Solution(solution_data)) => { match solution_data.clone().deserialize_blocking() { Ok(solution) => { - if solution.commitment() != expected_commitment { + if solution.id() != expected_solution_id { bail!( "Received mismatching solution ID - expected {}, found {}", - fmt_id(expected_commitment), - fmt_id(solution.commitment()), + fmt_id(expected_solution_id), + fmt_id(solution.id()), ); } @@ -269,30 +267,25 @@ impl> LedgerService for CoreLedgerService< } /// Checks the given solution is well-formed. - async fn check_solution_basic( - &self, - puzzle_commitment: PuzzleCommitment, - solution: Data>, - ) -> Result<()> { + async fn check_solution_basic(&self, solution_id: SolutionID, solution: Data>) -> Result<()> { // Deserialize the solution. let solution = spawn_blocking!(solution.deserialize_blocking())?; - // Ensure the puzzle commitment matches in the solution. - if puzzle_commitment != solution.commitment() { - bail!("Invalid solution - expected {puzzle_commitment}, found {}", solution.commitment()); + // Ensure the solution ID matches in the solution. + if solution_id != solution.id() { + bail!("Invalid solution - expected {solution_id}, found {}", solution.id()); } - // Retrieve the coinbase verifying key. - let coinbase_verifying_key = self.coinbase_verifying_key.clone(); - // Compute the current epoch challenge. - let epoch_challenge = self.ledger.latest_epoch_challenge()?; + // Compute the current epoch hash. + let epoch_hash = self.ledger.latest_epoch_hash()?; // Retrieve the current proof target. let proof_target = self.ledger.latest_proof_target(); - // Ensure that the prover solution is valid for the given epoch. - if !spawn_blocking!(solution.verify(&coinbase_verifying_key, &epoch_challenge, proof_target))? { - bail!("Invalid prover solution '{puzzle_commitment}' for the current epoch."); + // Ensure that the solution is valid for the given epoch. + let puzzle = self.ledger.puzzle().clone(); + match spawn_blocking!(puzzle.check_solution(&solution, epoch_hash, proof_target)) { + Ok(()) => Ok(()), + Err(e) => bail!("Invalid solution '{}' for the current epoch - {e}", fmt_id(solution_id)), } - Ok(()) } /// Checks the given transaction is well-formed and unique. diff --git a/node/bft/ledger-service/src/mock.rs b/node/bft/ledger-service/src/mock.rs index 9d04f74dfa..681c8cd89e 100644 --- a/node/bft/ledger-service/src/mock.rs +++ b/node/bft/ledger-service/src/mock.rs @@ -16,9 +16,9 @@ use crate::{fmt_id, LedgerService}; use snarkvm::{ ledger::{ block::{Block, Transaction}, - coinbase::{ProverSolution, PuzzleCommitment}, committee::Committee, narwhal::{BatchCertificate, Data, Subdag, Transmission, TransmissionID}, + puzzle::{Solution, SolutionID}, }, prelude::{bail, ensure, Address, Field, Network, Result}, }; @@ -127,7 +127,7 @@ impl LedgerService for MockLedgerService { } /// Returns the solution for the given solution ID. - fn get_solution(&self, _solution_id: &PuzzleCommitment) -> Result> { + fn get_solution(&self, _solution_id: &SolutionID) -> Result> { unreachable!("MockLedgerService does not support get_solution") } @@ -180,12 +180,8 @@ impl LedgerService for MockLedgerService { } /// Checks the given solution is well-formed. - async fn check_solution_basic( - &self, - puzzle_commitment: PuzzleCommitment, - _solution: Data>, - ) -> Result<()> { - trace!("[MockLedgerService] Check solution basic {:?} - Ok", fmt_id(puzzle_commitment)); + async fn check_solution_basic(&self, solution_id: SolutionID, _solution: Data>) -> Result<()> { + trace!("[MockLedgerService] Check solution basic {:?} - Ok", fmt_id(solution_id)); Ok(()) } diff --git a/node/bft/ledger-service/src/prover.rs b/node/bft/ledger-service/src/prover.rs index 57e62c216f..2d3839a19c 100644 --- a/node/bft/ledger-service/src/prover.rs +++ b/node/bft/ledger-service/src/prover.rs @@ -16,9 +16,9 @@ use crate::LedgerService; use snarkvm::{ ledger::{ block::{Block, Transaction}, - coinbase::{ProverSolution, PuzzleCommitment}, committee::Committee, narwhal::{BatchCertificate, Data, Subdag, Transmission, TransmissionID}, + puzzle::{Solution, SolutionID}, }, prelude::{bail, Address, Field, Network, Result}, }; @@ -98,7 +98,7 @@ impl LedgerService for ProverLedgerService { } /// Returns the solution for the given solution ID. - fn get_solution(&self, solution_id: &PuzzleCommitment) -> Result> { + fn get_solution(&self, solution_id: &SolutionID) -> Result> { bail!("Solution '{solution_id}' does not exist in prover") } @@ -149,11 +149,7 @@ impl LedgerService for ProverLedgerService { } /// Checks the given solution is well-formed. - async fn check_solution_basic( - &self, - _puzzle_commitment: PuzzleCommitment, - _solution: Data>, - ) -> Result<()> { + async fn check_solution_basic(&self, _solution_id: SolutionID, _solution: Data>) -> Result<()> { Ok(()) } diff --git a/node/bft/ledger-service/src/traits.rs b/node/bft/ledger-service/src/traits.rs index b419d32958..2bbad3387f 100644 --- a/node/bft/ledger-service/src/traits.rs +++ b/node/bft/ledger-service/src/traits.rs @@ -15,9 +15,9 @@ use snarkvm::{ ledger::{ block::{Block, Transaction}, - coinbase::{ProverSolution, PuzzleCommitment}, committee::Committee, narwhal::{BatchCertificate, Data, Subdag, Transmission, TransmissionID}, + puzzle::{Solution, SolutionID}, }, prelude::{Address, Field, Network, Result}, }; @@ -62,7 +62,7 @@ pub trait LedgerService: Debug + Send + Sync { fn get_blocks(&self, heights: Range) -> Result>>; /// Returns the solution for the given solution ID. - fn get_solution(&self, solution_id: &PuzzleCommitment) -> Result>; + fn get_solution(&self, solution_id: &SolutionID) -> Result>; /// Returns the unconfirmed transaction for the given transaction ID. fn get_unconfirmed_transaction(&self, transaction_id: N::TransactionID) -> Result>; @@ -95,11 +95,7 @@ pub trait LedgerService: Debug + Send + Sync { ) -> Result<()>; /// Checks the given solution is well-formed. - async fn check_solution_basic( - &self, - puzzle_commitment: PuzzleCommitment, - solution: Data>, - ) -> Result<()>; + async fn check_solution_basic(&self, solution_id: SolutionID, solution: Data>) -> Result<()>; /// Checks the given transaction is well-formed and unique. async fn check_transaction_basic( diff --git a/node/bft/ledger-service/src/translucent.rs b/node/bft/ledger-service/src/translucent.rs index 6107d5120c..044cd95eec 100644 --- a/node/bft/ledger-service/src/translucent.rs +++ b/node/bft/ledger-service/src/translucent.rs @@ -18,9 +18,9 @@ use indexmap::IndexMap; use snarkvm::{ ledger::{ block::{Block, Transaction}, - coinbase::{ProverSolution, PuzzleCommitment}, committee::Committee, narwhal::{Data, Subdag, Transmission, TransmissionID}, + puzzle::{Solution, SolutionID}, store::ConsensusStorage, Ledger, }, @@ -109,7 +109,7 @@ impl> LedgerService for TranslucentLedgerS } /// Returns the solution for the given solution ID. - fn get_solution(&self, solution_id: &PuzzleCommitment) -> Result> { + fn get_solution(&self, solution_id: &SolutionID) -> Result> { self.inner.get_solution(solution_id) } @@ -159,11 +159,7 @@ impl> LedgerService for TranslucentLedgerS } /// Always succeeds. - async fn check_solution_basic( - &self, - _puzzle_commitment: PuzzleCommitment, - _solution: Data>, - ) -> Result<()> { + async fn check_solution_basic(&self, _solution_id: SolutionID, _solution: Data>) -> Result<()> { Ok(()) } diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index bf363f0c18..fd96e86ae9 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -33,9 +33,9 @@ use snarkvm::{ console::account::Address, ledger::{ block::Transaction, - coinbase::{ProverSolution, PuzzleCommitment}, committee::Committee, narwhal::{BatchCertificate, Data, Subdag, Transmission, TransmissionID}, + puzzle::{Solution, SolutionID}, }, prelude::{bail, ensure, Field, Network, Result}, }; @@ -183,7 +183,7 @@ impl BFT { } /// Returns the unconfirmed solutions. - pub fn unconfirmed_solutions(&self) -> impl '_ + Iterator, Data>)> { + pub fn unconfirmed_solutions(&self) -> impl '_ + Iterator, Data>)> { self.primary.unconfirmed_solutions() } diff --git a/node/bft/src/helpers/channels.rs b/node/bft/src/helpers/channels.rs index 932c123530..70c6ad617b 100644 --- a/node/bft/src/helpers/channels.rs +++ b/node/bft/src/helpers/channels.rs @@ -25,8 +25,8 @@ use snarkvm::{ console::network::*, ledger::{ block::{Block, Transaction}, - coinbase::{ProverSolution, PuzzleCommitment}, narwhal::{BatchCertificate, Data, Subdag, Transmission, TransmissionID}, + puzzle::{Solution, SolutionID}, }, prelude::Result, }; @@ -126,8 +126,7 @@ pub struct PrimarySender { pub tx_batch_signature: mpsc::Sender<(SocketAddr, BatchSignature)>, pub tx_batch_certified: mpsc::Sender<(SocketAddr, Data>)>, pub tx_primary_ping: mpsc::Sender<(SocketAddr, Data>)>, - pub tx_unconfirmed_solution: - mpsc::Sender<(PuzzleCommitment, Data>, oneshot::Sender>)>, + pub tx_unconfirmed_solution: mpsc::Sender<(SolutionID, Data>, oneshot::Sender>)>, pub tx_unconfirmed_transaction: mpsc::Sender<(N::TransactionID, Data>, oneshot::Sender>)>, } @@ -135,8 +134,8 @@ impl PrimarySender { /// Sends the unconfirmed solution to the primary. pub async fn send_unconfirmed_solution( &self, - solution_id: PuzzleCommitment, - solution: Data>, + solution_id: SolutionID, + solution: Data>, ) -> Result<()> { // Initialize a callback sender and receiver. let (callback_sender, callback_receiver) = oneshot::channel(); @@ -167,8 +166,7 @@ pub struct PrimaryReceiver { pub rx_batch_signature: mpsc::Receiver<(SocketAddr, BatchSignature)>, pub rx_batch_certified: mpsc::Receiver<(SocketAddr, Data>)>, pub rx_primary_ping: mpsc::Receiver<(SocketAddr, Data>)>, - pub rx_unconfirmed_solution: - mpsc::Receiver<(PuzzleCommitment, Data>, oneshot::Sender>)>, + pub rx_unconfirmed_solution: mpsc::Receiver<(SolutionID, Data>, oneshot::Sender>)>, pub rx_unconfirmed_transaction: mpsc::Receiver<(N::TransactionID, Data>, oneshot::Sender>)>, } diff --git a/node/bft/src/helpers/partition.rs b/node/bft/src/helpers/partition.rs index e668eb8c35..8e2f84d981 100644 --- a/node/bft/src/helpers/partition.rs +++ b/node/bft/src/helpers/partition.rs @@ -76,7 +76,7 @@ pub fn assign_to_workers( #[cfg(test)] mod tests { use super::*; - use snarkvm::prelude::coinbase::PuzzleCommitment; + use snarkvm::prelude::puzzle::SolutionID; type CurrentNetwork = snarkvm::prelude::MainnetV0; @@ -90,7 +90,7 @@ mod tests { ]); let hash = sha256d_to_u128(data); assert_eq!(hash, 274520597840828436951879875061540363633u128); - let transmission_id: TransmissionID = TransmissionID::Solution(PuzzleCommitment::default()); + let transmission_id: TransmissionID = TransmissionID::Solution(SolutionID::from(123456789)); let worker_id = assign_to_worker(transmission_id, 5).unwrap(); assert_eq!(worker_id, 4); } diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index 4ea0d322b5..eecbd93c48 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -177,7 +177,7 @@ impl Pending { mod tests { use super::*; use snarkvm::{ - ledger::{coinbase::PuzzleCommitment, narwhal::TransmissionID}, + ledger::narwhal::TransmissionID, prelude::{Rng, TestRng}, }; @@ -198,27 +198,27 @@ mod tests { assert!(pending.is_empty()); assert_eq!(pending.len(), 0); - // Initialize the commitments. - let commitment_1 = TransmissionID::Solution(PuzzleCommitment::from_g1_affine(rng.gen())); - let commitment_2 = TransmissionID::Solution(PuzzleCommitment::from_g1_affine(rng.gen())); - let commitment_3 = TransmissionID::Solution(PuzzleCommitment::from_g1_affine(rng.gen())); + // Initialize the solution IDs. + let solution_id_1 = TransmissionID::Solution(rng.gen::().into()); + let solution_id_2 = TransmissionID::Solution(rng.gen::().into()); + let solution_id_3 = TransmissionID::Solution(rng.gen::().into()); // Initialize the SocketAddrs. let addr_1 = SocketAddr::from(([127, 0, 0, 1], 1234)); let addr_2 = SocketAddr::from(([127, 0, 0, 1], 2345)); let addr_3 = SocketAddr::from(([127, 0, 0, 1], 3456)); - // Insert the commitments. - assert!(pending.insert(commitment_1, addr_1, None)); - assert!(pending.insert(commitment_2, addr_2, None)); - assert!(pending.insert(commitment_3, addr_3, None)); + // Insert the solution IDs. + assert!(pending.insert(solution_id_1, addr_1, None)); + assert!(pending.insert(solution_id_2, addr_2, None)); + assert!(pending.insert(solution_id_3, addr_3, None)); // Check the number of SocketAddrs. assert_eq!(pending.len(), 3); assert!(!pending.is_empty()); // Check the items. - let ids = [commitment_1, commitment_2, commitment_3]; + let ids = [solution_id_1, solution_id_2, solution_id_3]; let peers = [addr_1, addr_2, addr_3]; for i in 0..3 { @@ -226,19 +226,19 @@ mod tests { assert!(pending.contains(id)); assert!(pending.contains_peer(id, peers[i])); } - let unknown_id = TransmissionID::Solution(PuzzleCommitment::from_g1_affine(rng.gen())); + let unknown_id = TransmissionID::Solution(rng.gen::().into()); assert!(!pending.contains(unknown_id)); // Check get. - assert_eq!(pending.get(commitment_1), Some(HashSet::from([addr_1]))); - assert_eq!(pending.get(commitment_2), Some(HashSet::from([addr_2]))); - assert_eq!(pending.get(commitment_3), Some(HashSet::from([addr_3]))); + assert_eq!(pending.get(solution_id_1), Some(HashSet::from([addr_1]))); + assert_eq!(pending.get(solution_id_2), Some(HashSet::from([addr_2]))); + assert_eq!(pending.get(solution_id_3), Some(HashSet::from([addr_3]))); assert_eq!(pending.get(unknown_id), None); // Check remove. - assert!(pending.remove(commitment_1, None).is_some()); - assert!(pending.remove(commitment_2, None).is_some()); - assert!(pending.remove(commitment_3, None).is_some()); + assert!(pending.remove(solution_id_1, None).is_some()); + assert!(pending.remove(solution_id_2, None).is_some()); + assert!(pending.remove(solution_id_3, None).is_some()); assert!(pending.remove(unknown_id, None).is_none()); // Check empty again. @@ -256,8 +256,8 @@ mod tests { assert!(pending.is_empty()); assert_eq!(pending.len(), 0); - // Initialize the commitments. - let commitment_1 = TransmissionID::Solution(PuzzleCommitment::from_g1_affine(rng.gen())); + // Initialize the solution ID. + let solution_id_1 = TransmissionID::Solution(rng.gen::().into()); // Initialize the SocketAddrs. let addr_1 = SocketAddr::from(([127, 0, 0, 1], 1234)); @@ -269,29 +269,29 @@ mod tests { let (callback_sender_2, _) = oneshot::channel(); let (callback_sender_3, _) = oneshot::channel(); - // Insert the commitments. - assert!(pending.insert(commitment_1, addr_1, Some((callback_sender_1, true)))); - assert!(pending.insert(commitment_1, addr_2, Some((callback_sender_2, true)))); + // Insert the solution ID. + assert!(pending.insert(solution_id_1, addr_1, Some((callback_sender_1, true)))); + assert!(pending.insert(solution_id_1, addr_2, Some((callback_sender_2, true)))); // Sleep for a few seconds. thread::sleep(Duration::from_secs(CALLBACK_TIMEOUT_IN_SECS as u64 - 1)); - assert!(pending.insert(commitment_1, addr_3, Some((callback_sender_3, true)))); + assert!(pending.insert(solution_id_1, addr_3, Some((callback_sender_3, true)))); // Check that the number of callbacks has not changed. - assert_eq!(pending.num_callbacks(commitment_1), 3); + assert_eq!(pending.num_callbacks(solution_id_1), 3); // Wait for 2 seconds. thread::sleep(Duration::from_secs(2)); // Ensure that the expired callbacks have been removed. - assert_eq!(pending.num_callbacks(commitment_1), 1); + assert_eq!(pending.num_callbacks(solution_id_1), 1); // Wait for `CALLBACK_TIMEOUT_IN_SECS` seconds. thread::sleep(Duration::from_secs(CALLBACK_TIMEOUT_IN_SECS as u64)); // Ensure that the expired callbacks have been removed. - assert_eq!(pending.num_callbacks(commitment_1), 0); + assert_eq!(pending.num_callbacks(solution_id_1), 0); } #[test] @@ -302,8 +302,8 @@ mod tests { let pending = Pending::, ()>::new(); for _ in 0..ITERATIONS { - // Generate a commitment. - let commitment = TransmissionID::Solution(PuzzleCommitment::from_g1_affine(rng.gen())); + // Generate a solution ID. + let solution_id = TransmissionID::Solution(rng.gen::().into()); // Check if the number of sent requests is correct. let mut expected_num_sent_requests = 0; for i in 0..ITERATIONS { @@ -317,11 +317,11 @@ mod tests { if is_sent_request { expected_num_sent_requests += 1; } - // Insert the commitment. - assert!(pending.insert(commitment, addr, Some((callback_sender, is_sent_request)))); + // Insert the solution ID. + assert!(pending.insert(solution_id, addr, Some((callback_sender, is_sent_request)))); } // Ensure that the number of sent requests is correct. - assert_eq!(pending.num_sent_requests(commitment), expected_num_sent_requests); + assert_eq!(pending.num_sent_requests(solution_id), expected_num_sent_requests); } } } diff --git a/node/bft/src/helpers/ready.rs b/node/bft/src/helpers/ready.rs index 70ad087224..6fa581ccdb 100644 --- a/node/bft/src/helpers/ready.rs +++ b/node/bft/src/helpers/ready.rs @@ -16,8 +16,8 @@ use snarkvm::{ console::prelude::*, ledger::{ block::Transaction, - coinbase::{ProverSolution, PuzzleCommitment}, narwhal::{Data, Transmission, TransmissionID}, + puzzle::{Solution, SolutionID}, }, }; @@ -80,7 +80,7 @@ impl Ready { } /// Returns the solutions in the ready queue. - pub fn solutions(&self) -> impl '_ + Iterator, Data>)> { + pub fn solutions(&self) -> impl '_ + Iterator, Data>)> { self.transmissions.read().clone().into_iter().filter_map(|(id, transmission)| match (id, transmission) { (TransmissionID::Solution(id), Transmission::Solution(solution)) => Some((id, solution)), _ => None, @@ -131,7 +131,7 @@ impl Ready { #[cfg(test)] mod tests { use super::*; - use snarkvm::ledger::{coinbase::PuzzleCommitment, narwhal::Data}; + use snarkvm::ledger::narwhal::Data; use ::bytes::Bytes; @@ -147,38 +147,38 @@ mod tests { // Initialize the ready queue. let ready = Ready::::new(); - // Initialize the commitments. - let commitment_1 = TransmissionID::Solution(PuzzleCommitment::from_g1_affine(rng.gen())); - let commitment_2 = TransmissionID::Solution(PuzzleCommitment::from_g1_affine(rng.gen())); - let commitment_3 = TransmissionID::Solution(PuzzleCommitment::from_g1_affine(rng.gen())); + // Initialize the solution IDs. + let solution_id_1 = TransmissionID::Solution(rng.gen::().into()); + let solution_id_2 = TransmissionID::Solution(rng.gen::().into()); + let solution_id_3 = TransmissionID::Solution(rng.gen::().into()); // Initialize the solutions. let solution_1 = Transmission::Solution(data(rng)); let solution_2 = Transmission::Solution(data(rng)); let solution_3 = Transmission::Solution(data(rng)); - // Insert the commitments. - assert!(ready.insert(commitment_1, solution_1.clone())); - assert!(ready.insert(commitment_2, solution_2.clone())); - assert!(ready.insert(commitment_3, solution_3.clone())); + // Insert the solution IDs. + assert!(ready.insert(solution_id_1, solution_1.clone())); + assert!(ready.insert(solution_id_2, solution_2.clone())); + assert!(ready.insert(solution_id_3, solution_3.clone())); // Check the number of transmissions. assert_eq!(ready.num_transmissions(), 3); // Check the transmission IDs. - let transmission_ids = vec![commitment_1, commitment_2, commitment_3].into_iter().collect::>(); + let transmission_ids = vec![solution_id_1, solution_id_2, solution_id_3].into_iter().collect::>(); assert_eq!(ready.transmission_ids(), transmission_ids); transmission_ids.iter().for_each(|id| assert!(ready.contains(*id))); - // Check that an unknown commitment is not in the ready queue. - let commitment_unknown = TransmissionID::Solution(PuzzleCommitment::from_g1_affine(rng.gen())); - assert!(!ready.contains(commitment_unknown)); + // Check that an unknown solution ID is not in the ready queue. + let solution_id_unknown = TransmissionID::Solution(rng.gen::().into()); + assert!(!ready.contains(solution_id_unknown)); // Check the transmissions. - assert_eq!(ready.get(commitment_1), Some(solution_1.clone())); - assert_eq!(ready.get(commitment_2), Some(solution_2.clone())); - assert_eq!(ready.get(commitment_3), Some(solution_3.clone())); - assert_eq!(ready.get(commitment_unknown), None); + assert_eq!(ready.get(solution_id_1), Some(solution_1.clone())); + assert_eq!(ready.get(solution_id_2), Some(solution_2.clone())); + assert_eq!(ready.get(solution_id_3), Some(solution_3.clone())); + assert_eq!(ready.get(solution_id_unknown), None); // Drain the ready queue. let transmissions = ready.drain(3); @@ -191,7 +191,7 @@ mod tests { // Check the transmissions. assert_eq!( transmissions, - vec![(commitment_1, solution_1), (commitment_2, solution_2), (commitment_3, solution_3)] + vec![(solution_id_1, solution_1), (solution_id_2, solution_2), (solution_id_3, solution_3)] .into_iter() .collect::>() ); @@ -210,15 +210,15 @@ mod tests { // Initialize the ready queue. let ready = Ready::::new(); - // Initialize the commitments. - let commitment = TransmissionID::Solution(PuzzleCommitment::from_g1_affine(rng.gen())); + // Initialize the solution ID. + let solution_id = TransmissionID::Solution(rng.gen::().into()); - // Initialize the solutions. + // Initialize the solution. let solution = Transmission::Solution(data); - // Insert the commitments. - assert!(ready.insert(commitment, solution.clone())); - assert!(!ready.insert(commitment, solution)); + // Insert the solution ID. + assert!(ready.insert(solution_id, solution.clone())); + assert!(!ready.insert(solution_id, solution)); // Check the number of transmissions. assert_eq!(ready.num_transmissions(), 1); diff --git a/node/bft/src/helpers/storage.rs b/node/bft/src/helpers/storage.rs index f10efd0d1a..f69b45b56d 100644 --- a/node/bft/src/helpers/storage.rs +++ b/node/bft/src/helpers/storage.rs @@ -644,17 +644,17 @@ impl Storage { // Retrieve the transmission. match transmission_id { TransmissionID::Ratification => (), - TransmissionID::Solution(puzzle_commitment) => { + TransmissionID::Solution(solution_id) => { // Retrieve the solution. - match block.get_solution(puzzle_commitment) { + match block.get_solution(solution_id) { // Insert the solution. Some(solution) => missing_transmissions.insert(*transmission_id, (*solution).into()), // Otherwise, try to load the solution from the ledger. - None => match self.ledger.get_solution(puzzle_commitment) { + None => match self.ledger.get_solution(solution_id) { // Insert the solution. Ok(solution) => missing_transmissions.insert(*transmission_id, solution.into()), Err(_) => { - error!("Missing solution {puzzle_commitment} in block {}", block.height()); + error!("Missing solution {solution_id} in block {}", block.height()); continue; } }, @@ -960,9 +960,9 @@ pub mod prop_tests { use snarkos_node_bft_storage_service::BFTMemoryService; use snarkvm::{ ledger::{ - coinbase::PuzzleCommitment, committee::prop_tests::{CommitteeContext, ValidatorSet}, narwhal::{BatchHeader, Data}, + puzzle::SolutionID, }, prelude::{Signature, Uniform}, }; @@ -1071,8 +1071,8 @@ pub mod prop_tests { .boxed() } - pub fn any_puzzle_commitment() -> BoxedStrategy> { - Just(0).prop_perturb(|_, rng| PuzzleCommitment::from_g1_affine(CryptoTestRng(rng).gen())).boxed() + pub fn any_solution_id() -> BoxedStrategy> { + Just(0).prop_perturb(|_, rng| CryptoTestRng(rng).gen::().into()).boxed() } pub fn any_transaction_id() -> BoxedStrategy<::TransactionID> { @@ -1086,7 +1086,7 @@ pub mod prop_tests { pub fn any_transmission_id() -> BoxedStrategy> { prop_oneof![ any_transaction_id().prop_map(TransmissionID::Transaction), - any_puzzle_commitment().prop_map(TransmissionID::Solution), + any_solution_id().prop_map(TransmissionID::Solution), ] .boxed() } diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index f91cd52bf4..7032dbd4f9 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -48,8 +48,8 @@ use snarkvm::{ }, ledger::{ block::Transaction, - coinbase::{ProverSolution, PuzzleCommitment}, narwhal::{BatchCertificate, BatchHeader, Data, Transmission, TransmissionID}, + puzzle::{Solution, SolutionID}, }, prelude::committee::Committee, }; @@ -256,7 +256,7 @@ impl Primary { } /// Returns the unconfirmed solutions. - pub fn unconfirmed_solutions(&self) -> impl '_ + Iterator, Data>)> { + pub fn unconfirmed_solutions(&self) -> impl '_ + Iterator, Data>)> { self.workers.iter().flat_map(|worker| worker.solutions()) } @@ -1029,9 +1029,9 @@ impl Primary { // Process the unconfirmed solutions. let self_ = self.clone(); self.spawn(async move { - while let Some((puzzle_commitment, prover_solution, callback)) = rx_unconfirmed_solution.recv().await { + while let Some((solution_id, solution, callback)) = rx_unconfirmed_solution.recv().await { // Compute the worker ID. - let Ok(worker_id) = assign_to_worker(puzzle_commitment, self_.num_workers()) else { + let Ok(worker_id) = assign_to_worker(solution_id, self_.num_workers()) else { error!("Unable to determine the worker ID for the unconfirmed solution"); continue; }; @@ -1040,7 +1040,7 @@ impl Primary { // Retrieve the worker. let worker = &self_.workers[worker_id as usize]; // Process the unconfirmed solution. - let result = worker.process_unconfirmed_solution(puzzle_commitment, prover_solution).await; + let result = worker.process_unconfirmed_solution(solution_id, solution).await; // Send the result to the callback. callback.send(result).ok(); }); @@ -1523,20 +1523,17 @@ mod tests { } // Creates a mock solution. - fn sample_unconfirmed_solution( - rng: &mut TestRng, - ) -> (PuzzleCommitment, Data>) { - // Sample a random fake puzzle commitment. - let affine = rng.gen(); - let commitment = PuzzleCommitment::::from_g1_affine(affine); + fn sample_unconfirmed_solution(rng: &mut TestRng) -> (SolutionID, Data>) { + // Sample a random fake solution ID. + let solution_id = rng.gen::().into(); // Vary the size of the solutions. let size = rng.gen_range(1024..10 * 1024); // Sample random fake solution bytes. let mut vec = vec![0u8; size]; rng.fill_bytes(&mut vec); let solution = Data::Buffer(Bytes::from(vec)); - // Return the ID and solution. - (commitment, solution) + // Return the solution ID and solution. + (solution_id, solution) } // Creates a mock transaction. @@ -1564,15 +1561,15 @@ mod tests { timestamp: i64, rng: &mut TestRng, ) -> Proposal { - let (solution_commitment, solution) = sample_unconfirmed_solution(rng); + let (solution_id, solution) = sample_unconfirmed_solution(rng); let (transaction_id, transaction) = sample_unconfirmed_transaction(rng); // Retrieve the private key. let private_key = author.private_key(); // Prepare the transmission IDs. - let transmission_ids = [solution_commitment.into(), (&transaction_id).into()].into(); + let transmission_ids = [solution_id.into(), (&transaction_id).into()].into(); let transmissions = [ - (solution_commitment.into(), Transmission::Solution(solution)), + (solution_id.into(), Transmission::Solution(solution)), ((&transaction_id).into(), Transmission::Transaction(transaction)), ] .into(); @@ -1645,11 +1642,11 @@ mod tests { let private_key = author.private_key(); let committee_id = Field::rand(rng); - let (solution_commitment, solution) = sample_unconfirmed_solution(rng); + let (solution_id, solution) = sample_unconfirmed_solution(rng); let (transaction_id, transaction) = sample_unconfirmed_transaction(rng); - let transmission_ids = [solution_commitment.into(), (&transaction_id).into()].into(); + let transmission_ids = [solution_id.into(), (&transaction_id).into()].into(); let transmissions = [ - (solution_commitment.into(), Transmission::Solution(solution)), + (solution_id.into(), Transmission::Solution(solution)), ((&transaction_id).into(), Transmission::Transaction(transaction)), ] .into(); @@ -1722,11 +1719,11 @@ mod tests { assert!(primary.proposed_batch.read().is_none()); // Generate a solution and a transaction. - let (solution_commitment, solution) = sample_unconfirmed_solution(&mut rng); + let (solution_id, solution) = sample_unconfirmed_solution(&mut rng); let (transaction_id, transaction) = sample_unconfirmed_transaction(&mut rng); // Store it on one of the workers. - primary.workers[0].process_unconfirmed_solution(solution_commitment, solution).await.unwrap(); + primary.workers[0].process_unconfirmed_solution(solution_id, solution).await.unwrap(); primary.workers[0].process_unconfirmed_transaction(transaction_id, transaction).await.unwrap(); // Try to propose a batch again. This time, it should succeed. @@ -1749,11 +1746,11 @@ mod tests { assert!(primary.proposed_batch.read().is_none()); // Generate a solution and a transaction. - let (solution_commitment, solution) = sample_unconfirmed_solution(&mut rng); + let (solution_id, solution) = sample_unconfirmed_solution(&mut rng); let (transaction_id, transaction) = sample_unconfirmed_transaction(&mut rng); // Store it on one of the workers. - primary.workers[0].process_unconfirmed_solution(solution_commitment, solution).await.unwrap(); + primary.workers[0].process_unconfirmed_solution(solution_id, solution).await.unwrap(); primary.workers[0].process_unconfirmed_transaction(transaction_id, transaction).await.unwrap(); // Propose a batch again. This time, it should succeed. diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index ffb3fceee3..64c319bb6e 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -26,8 +26,8 @@ use snarkvm::{ console::prelude::*, ledger::{ block::Transaction, - coinbase::{ProverSolution, PuzzleCommitment}, narwhal::{BatchHeader, Data, Transmission, TransmissionID}, + puzzle::{Solution, SolutionID}, }, }; @@ -140,7 +140,7 @@ impl Worker { } /// Returns the solutions in the ready queue. - pub fn solutions(&self) -> impl '_ + Iterator, Data>)> { + pub fn solutions(&self) -> impl '_ + Iterator, Data>)> { self.ready.solutions() } @@ -303,24 +303,22 @@ impl Worker { /// Note: This method assumes the incoming solution is valid and does not exist in the ledger. pub(crate) async fn process_unconfirmed_solution( &self, - puzzle_commitment: PuzzleCommitment, - prover_solution: Data>, + solution_id: SolutionID, + solution: Data>, ) -> Result<()> { // Construct the transmission. - let transmission = Transmission::Solution(prover_solution.clone()); - // Remove the puzzle commitment from the pending queue. - self.pending.remove(puzzle_commitment, Some(transmission.clone())); + let transmission = Transmission::Solution(solution.clone()); + // Remove the solution ID from the pending queue. + self.pending.remove(solution_id, Some(transmission.clone())); // Check if the solution exists. - if self.contains_transmission(puzzle_commitment) { - bail!("Solution '{}' already exists.", fmt_id(puzzle_commitment)); + if self.contains_transmission(solution_id) { + bail!("Solution '{}' already exists.", fmt_id(solution_id)); } // Check that the solution is well-formed and unique. - if let Err(e) = self.ledger.check_solution_basic(puzzle_commitment, prover_solution).await { - bail!("Invalid unconfirmed solution '{}': {e}", fmt_id(puzzle_commitment)); - } - // Adds the prover solution to the ready queue. - if self.ready.insert(puzzle_commitment, transmission) { - trace!("Worker {} - Added unconfirmed solution '{}'", self.id, fmt_id(puzzle_commitment)); + self.ledger.check_solution_basic(solution_id, solution).await?; + // Adds the solution to the ready queue. + if self.ready.insert(solution_id, transmission) { + trace!("Worker {} - Added unconfirmed solution '{}'", self.id, fmt_id(solution_id)); } Ok(()) } @@ -340,9 +338,7 @@ impl Worker { bail!("Transaction '{}' already exists.", fmt_id(transaction_id)); } // Check that the transaction is well-formed and unique. - if let Err(e) = self.ledger.check_transaction_basic(transaction_id, transaction).await { - bail!("Invalid unconfirmed transaction '{}': {e}", fmt_id(transaction_id)); - } + self.ledger.check_transaction_basic(transaction_id, transaction).await?; // Adds the transaction to the ready queue. if self.ready.insert(&transaction_id, transmission) { trace!("Worker {} - Added unconfirmed transaction '{}'", self.id, fmt_id(transaction_id)); @@ -519,7 +515,7 @@ mod tests { fn get_block_round(&self, height: u32) -> Result; fn get_block(&self, height: u32) -> Result>; fn get_blocks(&self, heights: Range) -> Result>>; - fn get_solution(&self, solution_id: &PuzzleCommitment) -> Result>; + fn get_solution(&self, solution_id: &SolutionID) -> Result>; fn get_unconfirmed_transaction(&self, transaction_id: N::TransactionID) -> Result>; fn get_batch_certificate(&self, certificate_id: &Field) -> Result>; fn current_committee(&self) -> Result>; @@ -534,8 +530,8 @@ mod tests { ) -> Result<()>; async fn check_solution_basic( &self, - puzzle_commitment: PuzzleCommitment, - solution: Data>, + solution_id: SolutionID, + solution: Data>, ) -> Result<()>; async fn check_transaction_basic( &self, @@ -590,7 +586,7 @@ mod tests { // Create the Worker. let worker = Worker::new(0, Arc::new(gateway), storage, ledger, Default::default()).unwrap(); let data = |rng: &mut TestRng| Data::Buffer(Bytes::from((0..512).map(|_| rng.gen::()).collect::>())); - let transmission_id = TransmissionID::Solution(PuzzleCommitment::from_g1_affine(rng.gen())); + let transmission_id = TransmissionID::Solution(rng.gen::().into()); let peer_ip = SocketAddr::from(([127, 0, 0, 1], 1234)); let transmission = Transmission::Solution(data(rng)); @@ -627,7 +623,7 @@ mod tests { // Create the Worker. let worker = Worker::new(0, Arc::new(gateway), storage, ledger, Default::default()).unwrap(); - let transmission_id = TransmissionID::Solution(PuzzleCommitment::from_g1_affine(rng.gen())); + let transmission_id = TransmissionID::Solution(rng.gen::().into()); let worker_ = worker.clone(); let peer_ip = SocketAddr::from(([127, 0, 0, 1], 1234)); let _ = worker_.send_transmission_request(peer_ip, transmission_id).await; @@ -665,21 +661,21 @@ mod tests { // Create the Worker. let worker = Worker::new(0, Arc::new(gateway), storage, ledger, Default::default()).unwrap(); - let puzzle = PuzzleCommitment::from_g1_affine(rng.gen()); - let transmission_id = TransmissionID::Solution(puzzle); + let solution_id = rng.gen::().into(); + let transmission_id = TransmissionID::Solution(solution_id); let worker_ = worker.clone(); let peer_ip = SocketAddr::from(([127, 0, 0, 1], 1234)); let _ = worker_.send_transmission_request(peer_ip, transmission_id).await; assert!(worker.pending.contains(transmission_id)); let result = worker .process_unconfirmed_solution( - puzzle, + solution_id, Data::Buffer(Bytes::from((0..512).map(|_| rng.gen::()).collect::>())), ) .await; assert!(result.is_ok()); assert!(!worker.pending.contains(transmission_id)); - assert!(worker.ready.contains(puzzle)); + assert!(worker.ready.contains(solution_id)); } #[tokio::test] @@ -705,21 +701,21 @@ mod tests { // Create the Worker. let worker = Worker::new(0, Arc::new(gateway), storage, ledger, Default::default()).unwrap(); - let puzzle = PuzzleCommitment::from_g1_affine(rng.gen()); - let transmission_id = TransmissionID::Solution(puzzle); + let solution_id = rng.gen::().into(); + let transmission_id = TransmissionID::Solution(solution_id); let worker_ = worker.clone(); let peer_ip = SocketAddr::from(([127, 0, 0, 1], 1234)); let _ = worker_.send_transmission_request(peer_ip, transmission_id).await; assert!(worker.pending.contains(transmission_id)); let result = worker .process_unconfirmed_solution( - puzzle, + solution_id, Data::Buffer(Bytes::from((0..512).map(|_| rng.gen::()).collect::>())), ) .await; assert!(result.is_err()); - assert!(!worker.pending.contains(puzzle)); - assert!(!worker.ready.contains(puzzle)); + assert!(!worker.pending.contains(solution_id)); + assert!(!worker.ready.contains(solution_id)); } #[tokio::test] diff --git a/node/bft/tests/common/utils.rs b/node/bft/tests/common/utils.rs index b2d5d5520f..1fa074f102 100644 --- a/node/bft/tests/common/utils.rs +++ b/node/bft/tests/common/utils.rs @@ -18,7 +18,7 @@ use snarkvm::{ ledger::narwhal::Data, prelude::{ block::Transaction, - coinbase::{ProverSolution, PuzzleCommitment}, + puzzle::{Solution, SolutionID}, Field, Network, TestRng, @@ -30,7 +30,7 @@ use std::time::Duration; use ::bytes::Bytes; use rand::Rng; -use tokio::{sync::oneshot, task, task::JoinHandle, time::sleep}; +use tokio::{sync::oneshot, task::JoinHandle, time::sleep}; use tracing::*; use tracing_subscriber::{ layer::{Layer, SubscriberExt}, @@ -83,32 +83,29 @@ pub fn fire_unconfirmed_solutions( // This RNG samples *different* fake solutions for each node. let mut unique_rng = TestRng::fixed(node_id as u64); - // A closure to generate a commitment and solution. - async fn sample(mut rng: impl Rng) -> (PuzzleCommitment, Data>) { - // Sample a random fake puzzle commitment. - // TODO (howardwu): Use a mutex to bring in the real 'proof target' and change this sampling to a while loop. - let affine = rng.gen(); - let commitment = - task::spawn_blocking(move || PuzzleCommitment::::from_g1_affine(affine)).await.unwrap(); + // A closure to generate a solution ID and solution. + async fn sample(mut rng: impl Rng) -> (SolutionID, Data>) { + // Sample a random fake solution ID. + let solution_id = rng.gen::().into(); // Sample random fake solution bytes. let mut vec = vec![0u8; 1024]; rng.fill_bytes(&mut vec); let solution = Data::Buffer(Bytes::from(vec)); - // Return the ID and solution. - (commitment, solution) + // Return the solution ID and solution. + (solution_id, solution) } // Initialize a counter. let mut counter = 0; loop { - // Sample a random fake puzzle commitment and solution. - let (commitment, solution) = + // Sample a random fake solution ID and solution. + let (solution_id, solution) = if counter % 2 == 0 { sample(&mut shared_rng).await } else { sample(&mut unique_rng).await }; // Initialize a callback sender and receiver. let (callback, callback_receiver) = oneshot::channel(); // Send the fake solution. - if let Err(e) = tx_unconfirmed_solution.send((commitment, solution, callback)).await { + if let Err(e) = tx_unconfirmed_solution.send((solution_id, solution, callback)).await { error!("Failed to send unconfirmed solution: {e}"); } let _ = callback_receiver.await; diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 75b02e89e0..b0c9fadd84 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -35,8 +35,8 @@ use snarkos_node_bft_storage_service::BFTPersistentStorage; use snarkvm::{ ledger::{ block::Transaction, - coinbase::{ProverSolution, PuzzleCommitment}, narwhal::{BatchHeader, Data, Subdag, Transmission, TransmissionID}, + puzzle::{Solution, SolutionID}, }, prelude::*, }; @@ -90,11 +90,11 @@ pub struct Consensus { /// The primary sender. primary_sender: Arc>>, /// The unconfirmed solutions queue. - solutions_queue: Arc, ProverSolution>>>, + solutions_queue: Arc, Solution>>>, /// The unconfirmed transactions queue. transactions_queue: Arc>>, /// The recently-seen unconfirmed solutions. - seen_solutions: Arc, ()>>>, + seen_solutions: Arc, ()>>>, /// The recently-seen unconfirmed transactions. seen_transactions: Arc>>, /// The spawned handles. @@ -199,7 +199,7 @@ impl Consensus { } /// Returns the unconfirmed solutions. - pub fn unconfirmed_solutions(&self) -> impl '_ + Iterator, Data>)> { + pub fn unconfirmed_solutions(&self) -> impl '_ + Iterator, Data>)> { self.bft.unconfirmed_solutions() } @@ -211,7 +211,7 @@ impl Consensus { impl Consensus { /// Adds the given unconfirmed solution to the memory pool. - pub async fn add_unconfirmed_solution(&self, solution: ProverSolution) -> Result<()> { + pub async fn add_unconfirmed_solution(&self, solution: Solution) -> Result<()> { #[cfg(feature = "metrics")] { metrics::increment_gauge(metrics::consensus::UNCONFIRMED_SOLUTIONS, 1f64); @@ -219,7 +219,7 @@ impl Consensus { } // Process the unconfirmed solution. { - let solution_id = solution.commitment(); + let solution_id = solution.id(); // Check if the transaction was recently seen. if self.seen_solutions.lock().put(solution_id, ()).is_some() { @@ -255,7 +255,7 @@ impl Consensus { }; // Iterate over the solutions. for solution in solutions.into_iter() { - let solution_id = solution.commitment(); + let solution_id = solution.id(); trace!("Adding unconfirmed solution '{}' to the memory pool...", fmt_id(solution_id)); // Send the unconfirmed solution to the primary. if let Err(e) = self.primary_sender().send_unconfirmed_solution(solution_id, Data::Object(solution)).await { @@ -453,9 +453,9 @@ impl Consensus { // Send the transmission to the primary. match (transmission_id, transmission) { (TransmissionID::Ratification, Transmission::Ratification) => return Ok(()), - (TransmissionID::Solution(commitment), Transmission::Solution(solution)) => { + (TransmissionID::Solution(solution_id), Transmission::Solution(solution)) => { // Send the solution to the primary. - self.primary_sender().tx_unconfirmed_solution.send((commitment, solution, callback)).await?; + self.primary_sender().tx_unconfirmed_solution.send((solution_id, solution, callback)).await?; } (TransmissionID::Transaction(transaction_id), Transmission::Transaction(transaction)) => { // Send the transaction to the primary. diff --git a/node/rest/src/routes.rs b/node/rest/src/routes.rs index b8a5f4c3bd..27fe8ccb89 100644 --- a/node/rest/src/routes.rs +++ b/node/rest/src/routes.rs @@ -15,7 +15,7 @@ use super::*; use snarkos_node_router::messages::UnconfirmedSolution; use snarkvm::{ - ledger::coinbase::ProverSolution, + ledger::puzzle::Solution, prelude::{block::Transaction, Identifier, Plaintext}, }; @@ -335,24 +335,22 @@ impl, R: Routing> Rest { // POST /mainnet/solution/broadcast pub(crate) async fn solution_broadcast( State(rest): State, - Json(prover_solution): Json>, + Json(solution): Json>, ) -> Result { // If the consensus module is enabled, add the unconfirmed solution to the memory pool. if let Some(consensus) = rest.consensus { // Add the unconfirmed solution to the memory pool. - consensus.add_unconfirmed_solution(prover_solution).await?; + consensus.add_unconfirmed_solution(solution).await?; } - let commitment = prover_solution.commitment(); + let solution_id = solution.id(); // Prepare the unconfirmed solution message. - let message = Message::UnconfirmedSolution(UnconfirmedSolution { - solution_id: commitment, - solution: Data::Object(prover_solution), - }); + let message = + Message::UnconfirmedSolution(UnconfirmedSolution { solution_id, solution: Data::Object(solution) }); // Broadcast the unconfirmed solution message. rest.routing.propagate(message, &[]); - Ok(ErasedJson::pretty(commitment)) + Ok(ErasedJson::pretty(solution_id)) } } diff --git a/node/router/messages/src/lib.rs b/node/router/messages/src/lib.rs index 09b065a49d..8fe2c40d9a 100644 --- a/node/router/messages/src/lib.rs +++ b/node/router/messages/src/lib.rs @@ -64,8 +64,8 @@ pub use snarkos_node_bft_events::DataBlocks; use snarkos_node_sync_locators::BlockLocators; use snarkvm::prelude::{ block::{Header, Transaction}, - coinbase::{EpochChallenge, ProverSolution, PuzzleCommitment}, error, + puzzle::{Solution, SolutionID}, Address, FromBytes, Network, diff --git a/node/router/messages/src/puzzle_response.rs b/node/router/messages/src/puzzle_response.rs index dcc1aa803c..ecafccac1d 100644 --- a/node/router/messages/src/puzzle_response.rs +++ b/node/router/messages/src/puzzle_response.rs @@ -23,7 +23,7 @@ use std::borrow::Cow; #[derive(Clone, Debug, PartialEq, Eq)] pub struct PuzzleResponse { - pub epoch_challenge: EpochChallenge, + pub epoch_hash: N::BlockHash, pub block_header: Data>, } @@ -37,24 +37,24 @@ impl MessageTrait for PuzzleResponse { impl ToBytes for PuzzleResponse { fn write_le(&self, mut writer: W) -> io::Result<()> { - self.epoch_challenge.write_le(&mut writer)?; + self.epoch_hash.write_le(&mut writer)?; self.block_header.write_le(&mut writer) } } impl FromBytes for PuzzleResponse { fn read_le(mut reader: R) -> io::Result { - Ok(Self { epoch_challenge: EpochChallenge::read_le(&mut reader)?, block_header: Data::read_le(reader)? }) + Ok(Self { epoch_hash: N::BlockHash::read_le(&mut reader)?, block_header: Data::read_le(reader)? }) } } #[cfg(test)] pub mod prop_tests { - use crate::{challenge_response::prop_tests::any_genesis_header, EpochChallenge, PuzzleResponse}; + use crate::{challenge_response::prop_tests::any_genesis_header, PuzzleResponse}; use snarkvm::{ console::prelude::{FromBytes, ToBytes}, ledger::narwhal::Data, - prelude::{Rng, TestRng}, + prelude::{Network, Rng, TestRng}, }; use bytes::{Buf, BufMut, BytesMut}; @@ -63,19 +63,18 @@ pub mod prop_tests { type CurrentNetwork = snarkvm::prelude::MainnetV0; - pub fn any_epoch_challenge() -> BoxedStrategy> { + pub fn any_epoch_hash() -> BoxedStrategy<::BlockHash> { any::() .prop_map(|seed| { let mut rng = TestRng::fixed(seed); - let degree: u16 = rng.gen_range(1..=u16::MAX); - EpochChallenge::::new(rng.gen(), rng.gen(), degree as u32).unwrap() + rng.gen() }) .boxed() } pub fn any_puzzle_response() -> BoxedStrategy> { - (any_epoch_challenge(), any_genesis_header()) - .prop_map(|(epoch_challenge, bh)| PuzzleResponse { epoch_challenge, block_header: Data::Object(bh) }) + (any_epoch_hash(), any_genesis_header()) + .prop_map(|(epoch_hash, bh)| PuzzleResponse { epoch_hash, block_header: Data::Object(bh) }) .boxed() } @@ -85,7 +84,7 @@ pub mod prop_tests { PuzzleResponse::write_le(&original, &mut buf).unwrap(); let deserialized: PuzzleResponse = PuzzleResponse::read_le(buf.into_inner().reader()).unwrap(); - assert_eq!(original.epoch_challenge, deserialized.epoch_challenge); + assert_eq!(original.epoch_hash, deserialized.epoch_hash); assert_eq!( original.block_header.deserialize_blocking().unwrap(), deserialized.block_header.deserialize_blocking().unwrap(), diff --git a/node/router/messages/src/unconfirmed_solution.rs b/node/router/messages/src/unconfirmed_solution.rs index 43edaf948d..9caf066ab9 100644 --- a/node/router/messages/src/unconfirmed_solution.rs +++ b/node/router/messages/src/unconfirmed_solution.rs @@ -23,8 +23,8 @@ use std::borrow::Cow; #[derive(Clone, Debug, PartialEq, Eq)] pub struct UnconfirmedSolution { - pub solution_id: PuzzleCommitment, - pub solution: Data>, + pub solution_id: SolutionID, + pub solution: Data>, } impl MessageTrait for UnconfirmedSolution { @@ -44,16 +44,15 @@ impl ToBytes for UnconfirmedSolution { impl FromBytes for UnconfirmedSolution { fn read_le(mut reader: R) -> io::Result { - Ok(Self { solution_id: PuzzleCommitment::read_le(&mut reader)?, solution: Data::read_le(reader)? }) + Ok(Self { solution_id: SolutionID::read_le(&mut reader)?, solution: Data::read_le(reader)? }) } } #[cfg(test)] pub mod prop_tests { - use crate::{ProverSolution, PuzzleCommitment, UnconfirmedSolution}; + use crate::{Solution, SolutionID, UnconfirmedSolution}; use snarkvm::{ - algorithms::polycommit::kzg10::{KZGCommitment, KZGProof}, - ledger::{coinbase::PartialSolution, narwhal::Data}, + ledger::narwhal::Data, prelude::{Address, FromBytes, PrivateKey, Rng, TestRng, ToBytes}, }; @@ -63,26 +62,23 @@ pub mod prop_tests { type CurrentNetwork = snarkvm::prelude::MainnetV0; - pub fn any_solution_id() -> BoxedStrategy> { - any::() - .prop_map(|seed| PuzzleCommitment::::new(KZGCommitment(TestRng::fixed(seed).gen()))) - .boxed() + pub fn any_solution_id() -> BoxedStrategy> { + any::().prop_map(|seed| TestRng::fixed(seed).gen::().into()).boxed() } - pub fn any_prover_solution() -> BoxedStrategy> { + pub fn any_solution() -> BoxedStrategy> { any::() .prop_map(|seed| { let mut rng = TestRng::fixed(seed); let private_key = PrivateKey::::new(&mut rng).unwrap(); let address = Address::try_from(private_key).unwrap(); - let partial_solution = PartialSolution::new(address, rng.gen(), KZGCommitment(rng.gen())); - ProverSolution::new(partial_solution, KZGProof { w: rng.gen(), random_v: None }) + Solution::new(rng.gen(), address, rng.gen()).unwrap() }) .boxed() } pub fn any_unconfirmed_solution() -> BoxedStrategy> { - (any_solution_id(), any_prover_solution()) + (any_solution_id(), any_solution()) .prop_map(|(solution_id, ps)| UnconfirmedSolution { solution_id, solution: Data::Object(ps) }) .boxed() } diff --git a/node/router/src/heartbeat.rs b/node/router/src/heartbeat.rs index ae84ba21aa..204052e641 100644 --- a/node/router/src/heartbeat.rs +++ b/node/router/src/heartbeat.rs @@ -277,7 +277,7 @@ pub trait Heartbeat: Outbound { } } - /// This function updates the coinbase puzzle if network has updated. + /// This function updates the puzzle if network has updated. fn handle_puzzle_request(&self) { // No-op } diff --git a/node/router/src/helpers/cache.rs b/node/router/src/helpers/cache.rs index 20c958b9ae..29f46aa63d 100644 --- a/node/router/src/helpers/cache.rs +++ b/node/router/src/helpers/cache.rs @@ -13,7 +13,7 @@ // limitations under the License. use crate::messages::BlockRequest; -use snarkvm::prelude::{coinbase::PuzzleCommitment, Network}; +use snarkvm::prelude::{puzzle::SolutionID, Network}; use core::hash::Hash; use linked_hash_map::LinkedHashMap; @@ -27,8 +27,8 @@ use time::{Duration, OffsetDateTime}; /// The maximum number of items to store in a cache map. const MAX_CACHE_SIZE: usize = 1 << 17; -/// A helper containing the peer IP and solution commitment. -type SolutionKey = (SocketAddr, PuzzleCommitment); +/// A helper containing the peer IP and solution ID. +type SolutionKey = (SocketAddr, SolutionID); /// A helper containing the peer IP and transaction ID. type TransactionKey = (SocketAddr, ::TransactionID); @@ -40,7 +40,7 @@ pub struct Cache { seen_inbound_messages: RwLock>>, /// The map of peer IPs to their recent timestamps. seen_inbound_puzzle_requests: RwLock>>, - /// The map of solution commitments to their last seen timestamp. + /// The map of solution IDs to their last seen timestamp. seen_inbound_solutions: RwLock, OffsetDateTime>>, /// The map of transaction IDs to their last seen timestamp. seen_inbound_transactions: RwLock, OffsetDateTime>>, @@ -48,7 +48,7 @@ pub struct Cache { seen_outbound_block_requests: RwLock>>, /// The map of peer IPs to the number of puzzle requests. seen_outbound_puzzle_requests: RwLock>, - /// The map of solution commitments to their last seen timestamp. + /// The map of solution IDs to their last seen timestamp. seen_outbound_solutions: RwLock, OffsetDateTime>>, /// The map of transaction IDs to their last seen timestamp. seen_outbound_transactions: RwLock, OffsetDateTime>>, @@ -97,13 +97,9 @@ impl Cache { Self::retain_and_insert(&self.seen_inbound_puzzle_requests, peer_ip, 60) } - /// Inserts a solution commitment into the cache, returning the previously seen timestamp if it existed. - pub fn insert_inbound_solution( - &self, - peer_ip: SocketAddr, - solution: PuzzleCommitment, - ) -> Option { - Self::refresh_and_insert(&self.seen_inbound_solutions, (peer_ip, solution)) + /// Inserts a solution ID into the cache, returning the previously seen timestamp if it existed. + pub fn insert_inbound_solution(&self, peer_ip: SocketAddr, solution_id: SolutionID) -> Option { + Self::refresh_and_insert(&self.seen_inbound_solutions, (peer_ip, solution_id)) } /// Inserts a transaction ID into the cache, returning the previously seen timestamp if it existed. @@ -151,13 +147,9 @@ impl Cache { Self::decrement_counter(&self.seen_outbound_puzzle_requests, peer_ip) } - /// Inserts a solution commitment into the cache, returning the previously seen timestamp if it existed. - pub fn insert_outbound_solution( - &self, - peer_ip: SocketAddr, - solution: PuzzleCommitment, - ) -> Option { - Self::refresh_and_insert(&self.seen_outbound_solutions, (peer_ip, solution)) + /// Inserts a solution ID into the cache, returning the previously seen timestamp if it existed. + pub fn insert_outbound_solution(&self, peer_ip: SocketAddr, solution_id: SolutionID) -> Option { + Self::refresh_and_insert(&self.seen_outbound_solutions, (peer_ip, solution_id)) } /// Inserts a transaction ID into the cache, returning the previously seen timestamp if it existed. @@ -270,19 +262,19 @@ mod tests { fn test_inbound_solution() { let cache = Cache::::default(); let peer_ip = SocketAddr::new(Ipv4Addr::LOCALHOST.into(), 1234); - let solution = PuzzleCommitment::::default(); + let solution_id = SolutionID::::from(123456789); // Check that the cache is empty. assert_eq!(cache.seen_inbound_solutions.read().len(), 0); // Insert a solution. - assert!(cache.insert_inbound_solution(peer_ip, solution).is_none()); + assert!(cache.insert_inbound_solution(peer_ip, solution_id).is_none()); // Check that the cache contains the solution. assert_eq!(cache.seen_inbound_solutions.read().len(), 1); // Insert the same solution again. - assert!(cache.insert_inbound_solution(peer_ip, solution).is_some()); + assert!(cache.insert_inbound_solution(peer_ip, solution_id).is_some()); // Check that the cache still contains the solution. assert_eq!(cache.seen_inbound_solutions.read().len(), 1); @@ -314,19 +306,19 @@ mod tests { fn test_outbound_solution() { let cache = Cache::::default(); let peer_ip = SocketAddr::new(Ipv4Addr::LOCALHOST.into(), 1234); - let solution = PuzzleCommitment::::default(); + let solution_id = SolutionID::::from(123456789); // Check that the cache is empty. assert_eq!(cache.seen_outbound_solutions.read().len(), 0); // Insert a solution. - assert!(cache.insert_outbound_solution(peer_ip, solution).is_none()); + assert!(cache.insert_outbound_solution(peer_ip, solution_id).is_none()); // Check that the cache contains the solution. assert_eq!(cache.seen_outbound_solutions.read().len(), 1); // Insert the same solution again. - assert!(cache.insert_outbound_solution(peer_ip, solution).is_some()); + assert!(cache.insert_outbound_solution(peer_ip, solution_id).is_some()); // Check that the cache still contains the solution. assert_eq!(cache.seen_outbound_solutions.read().len(), 1); diff --git a/node/router/src/inbound.rs b/node/router/src/inbound.rs index e99072dfc2..ee7e265cc0 100644 --- a/node/router/src/inbound.rs +++ b/node/router/src/inbound.rs @@ -30,7 +30,7 @@ use crate::{ use snarkos_node_tcp::protocols::Reading; use snarkvm::prelude::{ block::{Block, Header, Transaction}, - coinbase::{EpochChallenge, ProverSolution}, + puzzle::Solution, Network, }; @@ -201,7 +201,7 @@ pub trait Inbound: Reading + Outbound { Err(error) => bail!("[PuzzleResponse] {error}"), }; // Process the puzzle response. - match self.puzzle_response(peer_ip, message.epoch_challenge, header) { + match self.puzzle_response(peer_ip, message.epoch_hash, header) { true => Ok(()), false => bail!("Peer '{peer_ip}' sent an invalid puzzle response"), } @@ -222,7 +222,7 @@ pub trait Inbound: Reading + Outbound { Err(error) => bail!("[UnconfirmedSolution] {error}"), }; // Check that the solution parameters match. - if message.solution_id != solution.commitment() { + if message.solution_id != solution.id() { bail!("Peer '{peer_ip}' is not following the 'UnconfirmedSolution' protocol") } // Handle the unconfirmed solution. @@ -316,14 +316,14 @@ pub trait Inbound: Reading + Outbound { fn puzzle_request(&self, peer_ip: SocketAddr) -> bool; /// Handles a `PuzzleResponse` message. - fn puzzle_response(&self, peer_ip: SocketAddr, _challenge: EpochChallenge, _header: Header) -> bool; + fn puzzle_response(&self, peer_ip: SocketAddr, _epoch_hash: N::BlockHash, _header: Header) -> bool; /// Handles an `UnconfirmedSolution` message. async fn unconfirmed_solution( &self, peer_ip: SocketAddr, serialized: UnconfirmedSolution, - solution: ProverSolution, + solution: Solution, ) -> bool; /// Handles an `UnconfirmedTransaction` message. diff --git a/node/router/tests/common/router.rs b/node/router/tests/common/router.rs index 0ca9f721d4..9dfe4f9e01 100644 --- a/node/router/tests/common/router.rs +++ b/node/router/tests/common/router.rs @@ -39,7 +39,7 @@ use snarkos_node_tcp::{ }; use snarkvm::prelude::{ block::{Block, Header, Transaction}, - coinbase::{EpochChallenge, ProverSolution}, + puzzle::Solution, Network, }; @@ -179,7 +179,7 @@ impl Inbound for TestRouter { } /// Handles an `PuzzleResponse` message. - fn puzzle_response(&self, _peer_ip: SocketAddr, _epoch_challenge: EpochChallenge, _header: Header) -> bool { + fn puzzle_response(&self, _peer_ip: SocketAddr, _epoch_hash: N::BlockHash, _header: Header) -> bool { true } @@ -188,7 +188,7 @@ impl Inbound for TestRouter { &self, _peer_ip: SocketAddr, _serialized: UnconfirmedSolution, - _solution: ProverSolution, + _solution: Solution, ) -> bool { true } diff --git a/node/src/client/mod.rs b/node/src/client/mod.rs index 079613c2f9..385ab355fe 100644 --- a/node/src/client/mod.rs +++ b/node/src/client/mod.rs @@ -35,7 +35,7 @@ use snarkvm::{ console::network::Network, ledger::{ block::{Block, Header}, - coinbase::{CoinbasePuzzle, EpochChallenge, ProverSolution}, + puzzle::{Puzzle, Solution}, store::ConsensusStorage, Ledger, }, @@ -64,8 +64,8 @@ pub struct Client> { sync: Arc>, /// The genesis block. genesis: Block, - /// The coinbase puzzle. - coinbase_puzzle: CoinbasePuzzle, + /// The puzzle. + puzzle: Puzzle, /// The spawned handles. handles: Arc>>>, /// The shutdown signal. @@ -122,8 +122,6 @@ impl> Client { matches!(storage_mode, StorageMode::Development(_)), ) .await?; - // Load the coinbase puzzle. - let coinbase_puzzle = CoinbasePuzzle::::load()?; // Initialize the node. let mut node = Self { ledger: ledger.clone(), @@ -131,7 +129,7 @@ impl> Client { rest: None, sync: Arc::new(sync), genesis, - coinbase_puzzle, + puzzle: ledger.puzzle().clone(), handles: Default::default(), shutdown, }; diff --git a/node/src/client/router.rs b/node/src/client/router.rs index 6123f75e32..898b2bee82 100644 --- a/node/src/client/router.rs +++ b/node/src/client/router.rs @@ -235,11 +235,11 @@ impl> Inbound for Client { true } - /// Disconnects on receipt of a `PuzzleRequest` message. + /// Retrieves the latest epoch hash and latest block header, and returns the puzzle response to the peer. fn puzzle_request(&self, peer_ip: SocketAddr) -> bool { - // Retrieve the latest epoch challenge. - let epoch_challenge = match self.ledger.latest_epoch_challenge() { - Ok(epoch_challenge) => epoch_challenge, + // Retrieve the latest epoch hash. + let epoch_hash = match self.ledger.latest_epoch_hash() { + Ok(epoch_hash) => epoch_hash, Err(error) => { error!("Failed to prepare a puzzle request for '{peer_ip}': {error}"); return false; @@ -248,12 +248,12 @@ impl> Inbound for Client { // Retrieve the latest block header. let block_header = Data::Object(self.ledger.latest_header()); // Send the `PuzzleResponse` message to the peer. - Outbound::send(self, peer_ip, Message::PuzzleResponse(PuzzleResponse { epoch_challenge, block_header })); + Outbound::send(self, peer_ip, Message::PuzzleResponse(PuzzleResponse { epoch_hash, block_header })); true } - /// Saves the latest epoch challenge and latest block header in the node. - fn puzzle_response(&self, peer_ip: SocketAddr, _epoch_challenge: EpochChallenge, _header: Header) -> bool { + /// Saves the latest epoch hash and latest block header in the node. + fn puzzle_response(&self, peer_ip: SocketAddr, _epoch_hash: N::BlockHash, _header: Header) -> bool { debug!("Disconnecting '{peer_ip}' for the following reason - {:?}", DisconnectReason::ProtocolViolation); false } @@ -263,30 +263,28 @@ impl> Inbound for Client { &self, peer_ip: SocketAddr, serialized: UnconfirmedSolution, - solution: ProverSolution, + solution: Solution, ) -> bool { - // Retrieve the latest epoch challenge. - if let Ok(epoch_challenge) = self.ledger.latest_epoch_challenge() { + // Retrieve the latest epoch hash. + if let Ok(epoch_hash) = self.ledger.latest_epoch_hash() { // Retrieve the latest proof target. let proof_target = self.ledger.latest_block().header().proof_target(); - // Ensure that the prover solution is valid for the given epoch. - let coinbase_puzzle = self.coinbase_puzzle.clone(); - let is_valid = tokio::task::spawn_blocking(move || { - solution.verify(coinbase_puzzle.coinbase_verifying_key(), &epoch_challenge, proof_target) - }) - .await; + // Ensure that the solution is valid for the given epoch. + let puzzle = self.puzzle.clone(); + let is_valid = + tokio::task::spawn_blocking(move || puzzle.check_solution(&solution, epoch_hash, proof_target)).await; match is_valid { // If the solution is valid, propagate the `UnconfirmedSolution`. - Ok(Ok(true)) => { + Ok(Ok(())) => { let message = Message::UnconfirmedSolution(serialized); // Propagate the "UnconfirmedSolution". self.propagate(message, &[peer_ip]); } - Ok(Ok(false)) | Ok(Err(_)) => { - trace!("Invalid prover solution '{}' for the proof target.", solution.commitment()) + Ok(Err(_)) => { + trace!("Invalid solution '{}' for the proof target.", solution.id()) } - Err(error) => warn!("Failed to verify the prover solution: {error}"), + Err(error) => warn!("Failed to verify the solution: {error}"), } } true diff --git a/node/src/prover/mod.rs b/node/src/prover/mod.rs index 30b5c04a6d..18d9f33e92 100644 --- a/node/src/prover/mod.rs +++ b/node/src/prover/mod.rs @@ -34,10 +34,11 @@ use snarkvm::{ ledger::narwhal::Data, prelude::{ block::{Block, Header}, - coinbase::{CoinbasePuzzle, EpochChallenge, ProverSolution}, + puzzle::{Puzzle, Solution}, store::ConsensusStorage, Network, }, + synthesizer::VM, }; use aleo_std::StorageMode; @@ -46,6 +47,7 @@ use colored::Colorize; use core::{marker::PhantomData, time::Duration}; use parking_lot::{Mutex, RwLock}; use rand::{rngs::OsRng, CryptoRng, Rng}; +use snarkos_node_bft::helpers::fmt_id; use std::{ net::SocketAddr, sync::{ @@ -64,10 +66,10 @@ pub struct Prover> { sync: Arc>, /// The genesis block. genesis: Block, - /// The coinbase puzzle. - coinbase_puzzle: CoinbasePuzzle, - /// The latest epoch challenge. - latest_epoch_challenge: Arc>>>>, + /// The puzzle. + puzzle: Puzzle, + /// The latest epoch hash. + latest_epoch_hash: Arc>>, /// The latest block header. latest_block_header: Arc>>>, /// The number of puzzle instances. @@ -115,8 +117,6 @@ impl> Prover { matches!(storage_mode, StorageMode::Development(_)), ) .await?; - // Load the coinbase puzzle. - let coinbase_puzzle = CoinbasePuzzle::::load()?; // Compute the maximum number of puzzle instances. let max_puzzle_instances = num_cpus::get().saturating_sub(2).clamp(1, 6); // Initialize the node. @@ -124,8 +124,8 @@ impl> Prover { router, sync: Arc::new(sync), genesis, - coinbase_puzzle, - latest_epoch_challenge: Default::default(), + puzzle: VM::::new_puzzle()?, + latest_epoch_hash: Default::default(), latest_block_header: Default::default(), puzzle_instances: Default::default(), max_puzzle_instances: u8::try_from(max_puzzle_instances)?, @@ -135,8 +135,8 @@ impl> Prover { }; // Initialize the routing. node.initialize_routing().await; - // Initialize the coinbase puzzle. - node.initialize_coinbase_puzzle().await; + // Initialize the puzzle. + node.initialize_puzzle().await; // Initialize the notification message loop. node.handles.lock().push(crate::start_notification_message_loop()); // Pass the node to the signal handler. @@ -152,12 +152,12 @@ impl> NodeInterface for Prover { async fn shut_down(&self) { info!("Shutting down..."); - // Shut down the coinbase puzzle. - trace!("Shutting down the coinbase puzzle..."); + // Shut down the puzzle. + debug!("Shutting down the puzzle..."); self.shutdown.store(true, Ordering::Relaxed); // Abort the tasks. - trace!("Shutting down the prover..."); + debug!("Shutting down the prover..."); self.handles.lock().iter().for_each(|handle| handle.abort()); // Shut down the router. @@ -168,35 +168,35 @@ impl> NodeInterface for Prover { } impl> Prover { - /// Initialize a new instance of the coinbase puzzle. - async fn initialize_coinbase_puzzle(&self) { + /// Initialize a new instance of the puzzle. + async fn initialize_puzzle(&self) { for _ in 0..self.max_puzzle_instances { let prover = self.clone(); self.handles.lock().push(tokio::spawn(async move { - prover.coinbase_puzzle_loop().await; + prover.puzzle_loop().await; })); } } - /// Executes an instance of the coinbase puzzle. - async fn coinbase_puzzle_loop(&self) { + /// Executes an instance of the puzzle. + async fn puzzle_loop(&self) { loop { // If the node is not connected to any peers, then skip this iteration. if self.router.number_of_connected_peers() == 0 { - trace!("Skipping an iteration of the coinbase puzzle (no connected peers)"); + debug!("Skipping an iteration of the puzzle (no connected peers)"); tokio::time::sleep(Duration::from_secs(N::ANCHOR_TIME as u64)).await; continue; } - // If the number of instances of the coinbase puzzle exceeds the maximum, then skip this iteration. + // If the number of instances of the puzzle exceeds the maximum, then skip this iteration. if self.num_puzzle_instances() > self.max_puzzle_instances { // Sleep for a brief period of time. tokio::time::sleep(Duration::from_millis(500)).await; continue; } - // Read the latest epoch challenge. - let latest_epoch_challenge = self.latest_epoch_challenge.read().clone(); + // Read the latest epoch hash. + let latest_epoch_hash = *self.latest_epoch_hash.read(); // Read the latest state. let latest_state = self .latest_block_header @@ -204,20 +204,20 @@ impl> Prover { .as_ref() .map(|header| (header.coinbase_target(), header.proof_target())); - // If the latest epoch challenge and latest state exists, then proceed to generate a prover solution. - if let (Some(challenge), Some((coinbase_target, proof_target))) = (latest_epoch_challenge, latest_state) { - // Execute the coinbase puzzle. + // If the latest epoch hash and latest state exists, then proceed to generate a solution. + if let (Some(epoch_hash), Some((coinbase_target, proof_target))) = (latest_epoch_hash, latest_state) { + // Execute the puzzle. let prover = self.clone(); let result = tokio::task::spawn_blocking(move || { - prover.coinbase_puzzle_iteration(&challenge, coinbase_target, proof_target, &mut OsRng) + prover.puzzle_iteration(epoch_hash, coinbase_target, proof_target, &mut OsRng) }) .await; // If the prover found a solution, then broadcast it. if let Ok(Some((solution_target, solution))) = result { - info!("Found a Solution '{}' (Proof Target {solution_target})", solution.commitment()); - // Broadcast the prover solution. - self.broadcast_prover_solution(solution); + info!("Found a Solution '{}' (Proof Target {solution_target})", solution.id()); + // Broadcast the solution. + self.broadcast_solution(solution); } } else { // Otherwise, sleep for a brief period of time, to await for puzzle state. @@ -226,38 +226,34 @@ impl> Prover { // If the Ctrl-C handler registered the signal, stop the prover. if self.shutdown.load(Ordering::Relaxed) { - trace!("Shutting down the coinbase puzzle..."); + debug!("Shutting down the puzzle..."); break; } } } - /// Performs one iteration of the coinbase puzzle. - fn coinbase_puzzle_iteration( + /// Performs one iteration of the puzzle. + fn puzzle_iteration( &self, - epoch_challenge: &EpochChallenge, + epoch_hash: N::BlockHash, coinbase_target: u64, proof_target: u64, rng: &mut R, - ) -> Option<(u64, ProverSolution)> { + ) -> Option<(u64, Solution)> { // Increment the puzzle instances. self.increment_puzzle_instances(); - trace!( - "Proving 'CoinbasePuzzle' {}", - format!( - "(Epoch {}, Coinbase Target {coinbase_target}, Proof Target {proof_target})", - epoch_challenge.epoch_number(), - ) - .dimmed() + debug!( + "Proving 'Puzzle' for Epoch '{}' {}", + fmt_id(epoch_hash), + format!("(Coinbase Target {coinbase_target}, Proof Target {proof_target})").dimmed() ); - // Compute the prover solution. - let result = self - .coinbase_puzzle - .prove(epoch_challenge, self.address(), rng.gen(), Some(proof_target)) - .ok() - .and_then(|solution| solution.to_target().ok().map(|solution_target| (solution_target, solution))); + // Compute the solution. + let result = + self.puzzle.prove(epoch_hash, self.address(), rng.gen(), Some(proof_target)).ok().and_then(|solution| { + self.puzzle.get_proof_target(&solution).ok().map(|solution_target| (solution_target, solution)) + }); // Decrement the puzzle instances. self.decrement_puzzle_instances(); @@ -265,12 +261,12 @@ impl> Prover { result } - /// Broadcasts the prover solution to the network. - fn broadcast_prover_solution(&self, prover_solution: ProverSolution) { + /// Broadcasts the solution to the network. + fn broadcast_solution(&self, solution: Solution) { // Prepare the unconfirmed solution message. let message = Message::UnconfirmedSolution(UnconfirmedSolution { - solution_id: prover_solution.commitment(), - solution: Data::Object(prover_solution), + solution_id: solution.id(), + solution: Data::Object(solution), }); // Propagate the "UnconfirmedSolution". self.propagate(message, &[]); diff --git a/node/src/prover/router.rs b/node/src/prover/router.rs index f12a876166..a5e1489947 100644 --- a/node/src/prover/router.rs +++ b/node/src/prover/router.rs @@ -117,13 +117,13 @@ impl> Reading for Prover { impl> Routing for Prover {} impl> Heartbeat for Prover { - /// This function updates the coinbase puzzle if network has updated. + /// This function updates the puzzle if network has updated. fn handle_puzzle_request(&self) { // Find the sync peers. if let Some((sync_peers, _)) = self.sync.find_sync_peers() { // Choose the peer with the highest block height. if let Some((peer_ip, _)) = sync_peers.into_iter().max_by_key(|(_, height)| *height) { - // Request the coinbase puzzle from the peer. + // Request the puzzle from the peer. Outbound::send(self, peer_ip, Message::PuzzleRequest(PuzzleRequest)); } } @@ -192,25 +192,23 @@ impl> Inbound for Prover { false } - /// Saves the latest epoch challenge and latest block header in the node. - fn puzzle_response(&self, peer_ip: SocketAddr, epoch_challenge: EpochChallenge, header: Header) -> bool { - // Retrieve the epoch number. - let epoch_number = epoch_challenge.epoch_number(); + /// Saves the latest epoch hash and latest block header in the node. + fn puzzle_response(&self, peer_ip: SocketAddr, epoch_hash: N::BlockHash, header: Header) -> bool { // Retrieve the block height. let block_height = header.height(); info!( - "Coinbase Puzzle (Epoch {epoch_number}, Block {block_height}, Coinbase Target {}, Proof Target {})", + "Puzzle (Block {block_height}, Coinbase Target {}, Proof Target {})", header.coinbase_target(), header.proof_target() ); - // Save the latest epoch challenge in the node. - self.latest_epoch_challenge.write().replace(Arc::new(epoch_challenge)); + // Save the latest epoch hash in the node. + self.latest_epoch_hash.write().replace(epoch_hash); // Save the latest block header in the node. self.latest_block_header.write().replace(header); - trace!("Received 'PuzzleResponse' from '{peer_ip}' (Epoch {epoch_number}, Block {block_height})"); + trace!("Received 'PuzzleResponse' from '{peer_ip}' (Block {block_height})"); true } @@ -219,32 +217,30 @@ impl> Inbound for Prover { &self, peer_ip: SocketAddr, serialized: UnconfirmedSolution, - solution: ProverSolution, + solution: Solution, ) -> bool { - // Retrieve the latest epoch challenge. - let epoch_challenge = self.latest_epoch_challenge.read().clone(); + // Retrieve the latest epoch hash. + let epoch_hash = *self.latest_epoch_hash.read(); // Retrieve the latest proof target. let proof_target = self.latest_block_header.read().as_ref().map(|header| header.proof_target()); - if let (Some(epoch_challenge), Some(proof_target)) = (epoch_challenge, proof_target) { - // Ensure that the prover solution is valid for the given epoch. - let coinbase_puzzle = self.coinbase_puzzle.clone(); - let is_valid = tokio::task::spawn_blocking(move || { - solution.verify(coinbase_puzzle.coinbase_verifying_key(), &epoch_challenge, proof_target) - }) - .await; + if let (Some(epoch_hash), Some(proof_target)) = (epoch_hash, proof_target) { + // Ensure that the solution is valid for the given epoch. + let puzzle = self.puzzle.clone(); + let is_valid = + tokio::task::spawn_blocking(move || puzzle.check_solution(&solution, epoch_hash, proof_target)).await; match is_valid { // If the solution is valid, propagate the `UnconfirmedSolution`. - Ok(Ok(true)) => { + Ok(Ok(())) => { let message = Message::UnconfirmedSolution(serialized); // Propagate the "UnconfirmedSolution". self.propagate(message, &[peer_ip]); } - Ok(Ok(false)) | Ok(Err(_)) => { - trace!("Invalid prover solution '{}' for the proof target.", solution.commitment()) + Ok(Err(_)) => { + trace!("Invalid solution '{}' for the proof target.", solution.id()) } - Err(error) => warn!("Failed to verify the prover solution: {error}"), + Err(error) => warn!("Failed to verify the solution - {error}"), } } true diff --git a/node/src/validator/mod.rs b/node/src/validator/mod.rs index 643254f2f9..6e4046c001 100644 --- a/node/src/validator/mod.rs +++ b/node/src/validator/mod.rs @@ -34,7 +34,7 @@ use snarkos_node_tcp::{ }; use snarkvm::prelude::{ block::{Block, Header}, - coinbase::ProverSolution, + puzzle::Solution, store::ConsensusStorage, Ledger, Network, diff --git a/node/src/validator/router.rs b/node/src/validator/router.rs index 3a01e6046e..fcbc057215 100644 --- a/node/src/validator/router.rs +++ b/node/src/validator/router.rs @@ -27,7 +27,7 @@ use snarkos_node_router::messages::{ use snarkos_node_tcp::{Connection, ConnectionSide, Tcp}; use snarkvm::{ ledger::narwhal::Data, - prelude::{block::Transaction, coinbase::EpochChallenge, error, Network}, + prelude::{block::Transaction, error, Network}, }; use std::{io, net::SocketAddr, time::Duration}; @@ -209,11 +209,11 @@ impl> Inbound for Validator { true } - /// Retrieves the latest epoch challenge and latest block header, and returns the puzzle response to the peer. + /// Retrieves the latest epoch hash and latest block header, and returns the puzzle response to the peer. fn puzzle_request(&self, peer_ip: SocketAddr) -> bool { - // Retrieve the latest epoch challenge. - let epoch_challenge = match self.ledger.latest_epoch_challenge() { - Ok(epoch_challenge) => epoch_challenge, + // Retrieve the latest epoch hash. + let epoch_hash = match self.ledger.latest_epoch_hash() { + Ok(epoch_hash) => epoch_hash, Err(error) => { error!("Failed to prepare a puzzle request for '{peer_ip}': {error}"); return false; @@ -222,12 +222,12 @@ impl> Inbound for Validator { // Retrieve the latest block header. let block_header = Data::Object(self.ledger.latest_header()); // Send the `PuzzleResponse` message to the peer. - Outbound::send(self, peer_ip, Message::PuzzleResponse(PuzzleResponse { epoch_challenge, block_header })); + Outbound::send(self, peer_ip, Message::PuzzleResponse(PuzzleResponse { epoch_hash, block_header })); true } /// Disconnects on receipt of a `PuzzleResponse` message. - fn puzzle_response(&self, peer_ip: SocketAddr, _epoch_challenge: EpochChallenge, _header: Header) -> bool { + fn puzzle_response(&self, peer_ip: SocketAddr, _epoch_hash: N::BlockHash, _header: Header) -> bool { debug!("Disconnecting '{peer_ip}' for the following reason - {:?}", DisconnectReason::ProtocolViolation); false } @@ -237,7 +237,7 @@ impl> Inbound for Validator { &self, peer_ip: SocketAddr, serialized: UnconfirmedSolution, - solution: ProverSolution, + solution: Solution, ) -> bool { // Add the unconfirmed solution to the memory pool. if let Err(error) = self.consensus.add_unconfirmed_solution(solution).await { From 99a837756a83996a38a6453a36d499d400e16485 Mon Sep 17 00:00:00 2001 From: Pranav Gaddamadugu <23022326+d0cd@users.noreply.github.com> Date: Thu, 21 Mar 2024 14:28:41 -0700 Subject: [PATCH 272/551] Fix test --- node/bft/src/helpers/partition.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/bft/src/helpers/partition.rs b/node/bft/src/helpers/partition.rs index 8e2f84d981..fd64cc0932 100644 --- a/node/bft/src/helpers/partition.rs +++ b/node/bft/src/helpers/partition.rs @@ -92,6 +92,6 @@ mod tests { assert_eq!(hash, 274520597840828436951879875061540363633u128); let transmission_id: TransmissionID = TransmissionID::Solution(SolutionID::from(123456789)); let worker_id = assign_to_worker(transmission_id, 5).unwrap(); - assert_eq!(worker_id, 4); + assert_eq!(worker_id, 2); } } From 2a7f2154a89859c112b5841f26b68ee40eb5160b Mon Sep 17 00:00:00 2001 From: Pranav Gaddamadugu <23022326+d0cd@users.noreply.github.com> Date: Thu, 21 Mar 2024 16:30:27 -0700 Subject: [PATCH 273/551] Update dev dep --- node/cdn/Cargo.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/node/cdn/Cargo.toml b/node/cdn/Cargo.toml index aff5c26cba..2078de4a59 100644 --- a/node/cdn/Cargo.toml +++ b/node/cdn/Cargo.toml @@ -60,5 +60,9 @@ features = [ "rt" ] [dependencies.tracing] version = "0.1" +[dev-dependencies.tokio] +version = "1.28" +features = [ "rt", "rt-multi-thread" ] + [dev-dependencies.tokio-test] version = "0.4" From b4cd39327a12805fd3c4e03158552c716ade3ff3 Mon Sep 17 00:00:00 2001 From: Pranav Gaddamadugu <23022326+d0cd@users.noreply.github.com> Date: Thu, 21 Mar 2024 19:13:29 -0700 Subject: [PATCH 274/551] Fix NETWORK_ID --- node/cdn/src/blocks.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/cdn/src/blocks.rs b/node/cdn/src/blocks.rs index 8772b43ec3..a1b4b91e3e 100644 --- a/node/cdn/src/blocks.rs +++ b/node/cdn/src/blocks.rs @@ -48,7 +48,7 @@ const MAXIMUM_PENDING_BLOCKS: u32 = BLOCKS_PER_FILE * CONCURRENT_REQUESTS * 2; /// Maximum number of attempts for a request to the CDN. const MAXIMUM_REQUEST_ATTEMPTS: u8 = 10; /// The supported network. -const NETWORK_ID: u16 = 3; +const NETWORK_ID: u16 = 0; /// Loads blocks from a CDN into the ledger. /// From 840263dd2c610ed88bde2ce34f36a3c93f409600 Mon Sep 17 00:00:00 2001 From: miazn Date: Fri, 22 Mar 2024 13:50:49 -0400 Subject: [PATCH 275/551] update grafana --- node/metrics/snarkOS-grafana.json | 1210 +++++++++++------------------ 1 file changed, 475 insertions(+), 735 deletions(-) diff --git a/node/metrics/snarkOS-grafana.json b/node/metrics/snarkOS-grafana.json index 8e0a7cacfe..d86a954c8d 100644 --- a/node/metrics/snarkOS-grafana.json +++ b/node/metrics/snarkOS-grafana.json @@ -1,41 +1,4 @@ { - "__inputs": [ - { - "name": "DS_PROMETHEUS", - "label": "prometheus", - "description": "", - "type": "datasource", - "pluginId": "prometheus", - "pluginName": "Prometheus" - } - ], - "__elements": {}, - "__requires": [ - { - "type": "grafana", - "id": "grafana", - "name": "Grafana", - "version": "10.2.3" - }, - { - "type": "datasource", - "id": "prometheus", - "name": "Prometheus", - "version": "1.0.0" - }, - { - "type": "panel", - "id": "stat", - "name": "Stat", - "version": "" - }, - { - "type": "panel", - "id": "timeseries", - "name": "Time series", - "version": "" - } - ], "annotations": { "list": [ { @@ -61,11 +24,12 @@ "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 0, - "id": null, + "id": 1, "links": [], "liveNow": false, "panels": [ { + "collapsed": false, "gridPos": { "h": 1, "w": 24, @@ -73,52 +37,88 @@ "y": 0 }, "id": 26, + "panels": [], "title": "Aleo Network", "type": "row" }, { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "fieldConfig": { "defaults": { "color": { - "mode": "palette-classic" + "mode": "thresholds" }, - "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 6, + "x": 0, + "y": 1 + }, + "id": 49, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "10.4.1", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "adgg6tp3e19fkc" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "snarkos_blocks_height_total", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "__auto", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Block Height", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "adgg6tp3e19fkc" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" }, - "displayName": "Connected Peers", "mappings": [], "thresholds": { "mode": "absolute", @@ -129,7 +129,7 @@ }, { "color": "red", - "value": 80 + "value": 60 } ] } @@ -138,43 +138,59 @@ }, "gridPos": { "h": 8, - "w": 12, - "x": 0, + "w": 6, + "x": 6, "y": 1 }, - "id": 27, + "id": 48, "options": { - "legend": { - "calcs": [], - "displayMode": "list", - "placement": "bottom", - "showLegend": true + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false }, - "tooltip": { - "mode": "single", - "sort": "none" - } + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true }, + "pluginVersion": "10.4.1", "targets": [ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "editorMode": "code", - "expr": "snarkos_router_connected_total", + "expr": "avg(\n 1 / rate(snarkos_blocks_height_total{}[1m])\n) < +inf", + "instant": false, "legendFormat": "__auto", "range": true, "refId": "A" } ], - "title": "Connected Peers", - "type": "timeseries" + "title": "Average Seconds/Block over last minute", + "transformations": [ + { + "id": "reduce", + "options": { + "reducers": [ + "mean" + ] + } + } + ], + "type": "stat" }, { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "fieldConfig": { "defaults": { @@ -213,7 +229,6 @@ "mode": "off" } }, - "displayName": "Candidate Peers", "mappings": [], "thresholds": { "mode": "absolute", @@ -221,10 +236,6 @@ { "color": "green", "value": null - }, - { - "color": "red", - "value": 80 } ] } @@ -237,7 +248,7 @@ "x": 12, "y": 1 }, - "id": 28, + "id": 23, "options": { "legend": { "calcs": [], @@ -250,26 +261,27 @@ "sort": "none" } }, + "pluginVersion": "10.4.1", "targets": [ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "editorMode": "code", - "expr": "snarkos_router_candidate_total", + "expr": "snarkos_blocks_height_total", "legendFormat": "__auto", "range": true, "refId": "A" } ], - "title": "Candidate Peers", + "title": "Block Height", "type": "timeseries" }, { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "fieldConfig": { "defaults": { @@ -349,7 +361,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "editorMode": "code", "expr": "snarkos_router_restricted_total", @@ -364,13 +376,46 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "fieldConfig": { "defaults": { "color": { - "mode": "thresholds" + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } }, + "displayName": "Total Transactions", "mappings": [], "thresholds": { "mode": "absolute", @@ -390,43 +435,44 @@ "x": 12, "y": 9 }, - "id": 23, + "id": 36, "options": { - "colorMode": "value", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true }, - "textMode": "auto", - "wideLayout": true + "tooltip": { + "mode": "single", + "sort": "none" + } }, - "pluginVersion": "10.2.3", "targets": [ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, - "editorMode": "code", - "expr": "snarkos_blocks_height_total", + "disableTextWrap": false, + "editorMode": "builder", + "expr": "snarkos_blocks_transactions_total", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, "legendFormat": "__auto", "range": true, - "refId": "A" + "refId": "A", + "useBackend": false } ], - "title": "Block Height", - "type": "stat" + "title": "Total Transactions", + "type": "timeseries" }, { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "fieldConfig": { "defaults": { @@ -502,7 +548,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "editorMode": "builder", "expr": "sum(rate(snarkos_blocks_transactions_total[5m]))", @@ -517,7 +563,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "fieldConfig": { "defaults": { @@ -556,7 +602,7 @@ "mode": "off" } }, - "displayName": "Total Transactions", + "displayName": "Total Transmissions", "mappings": [], "thresholds": { "mode": "absolute", @@ -576,7 +622,7 @@ "x": 12, "y": 17 }, - "id": 36, + "id": 42, "options": { "legend": { "calcs": [], @@ -593,11 +639,11 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "disableTextWrap": false, "editorMode": "builder", - "expr": "snarkos_blocks_transactions_total", + "expr": "snarkos_blocks_solutions_total", "fullMetaSearch": false, "includeNullMetadata": true, "instant": false, @@ -607,13 +653,13 @@ "useBackend": false } ], - "title": "Total Transactions", + "title": "Total Solutions", "type": "timeseries" }, { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "fieldConfig": { "defaults": { @@ -652,7 +698,7 @@ "mode": "off" } }, - "displayName": "Total Solutions", + "displayName": "Total Stake", "mappings": [], "thresholds": { "mode": "absolute", @@ -660,6 +706,10 @@ { "color": "green", "value": null + }, + { + "color": "red", + "value": 80 } ] } @@ -672,7 +722,7 @@ "x": 0, "y": 25 }, - "id": 41, + "id": 31, "options": { "legend": { "calcs": [], @@ -689,11 +739,11 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "disableTextWrap": false, "editorMode": "builder", - "expr": "snarkos_blocks_solutions_total", + "expr": "snarkvm_ledger_committee_total_stake", "fullMetaSearch": false, "includeNullMetadata": true, "instant": false, @@ -703,13 +753,13 @@ "useBackend": false } ], - "title": "Total Solutions", + "title": "Total Stake", "type": "timeseries" }, { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "fieldConfig": { "defaults": { @@ -748,7 +798,6 @@ "mode": "off" } }, - "displayName": "Total Transmissions", "mappings": [], "thresholds": { "mode": "absolute", @@ -756,6 +805,10 @@ { "color": "green", "value": null + }, + { + "color": "red", + "value": 80 } ] } @@ -768,7 +821,7 @@ "x": 12, "y": 25 }, - "id": 42, + "id": 47, "options": { "legend": { "calcs": [], @@ -785,11 +838,11 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "disableTextWrap": false, "editorMode": "builder", - "expr": "snarkos_blocks_transmissions_total", + "expr": "snarkos_bft_connected_total", "fullMetaSearch": false, "includeNullMetadata": true, "instant": false, @@ -799,13 +852,13 @@ "useBackend": false } ], - "title": "Total Transmissions", + "title": "SnarkOS BFT Connected Total", "type": "timeseries" }, { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "fieldConfig": { "defaults": { @@ -844,7 +897,7 @@ "mode": "off" } }, - "displayName": "Total Stake", + "displayName": "Connected Peers", "mappings": [], "thresholds": { "mode": "absolute", @@ -868,7 +921,7 @@ "x": 0, "y": 33 }, - "id": 31, + "id": 27, "options": { "legend": { "calcs": [], @@ -885,46 +938,61 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, - "disableTextWrap": false, - "editorMode": "builder", - "expr": "snarkvm_ledger_committee_total_stake", - "fullMetaSearch": false, - "includeNullMetadata": true, - "instant": false, + "editorMode": "code", + "expr": "snarkos_router_connected_total", "legendFormat": "__auto", "range": true, - "refId": "A", - "useBackend": false + "refId": "A" } ], - "title": "Total Stake", + "title": "Connected Peers", "type": "timeseries" }, - { - "collapsed": false, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 41 - }, - "id": 18, - "panels": [], - "title": "BFT", - "type": "row" - }, { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "fieldConfig": { "defaults": { "color": { - "mode": "thresholds" + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } }, + "displayName": "Candidate Peers", "mappings": [], "thresholds": { "mode": "absolute", @@ -932,6 +1000,10 @@ { "color": "green", "value": null + }, + { + "color": "red", + "value": 80 } ] } @@ -940,51 +1012,56 @@ }, "gridPos": { "h": 8, - "w": 6, - "x": 0, - "y": 42 + "w": 12, + "x": 12, + "y": 33 }, - "id": 16, + "id": 28, "options": { - "colorMode": "value", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true }, - "textMode": "auto", - "wideLayout": true + "tooltip": { + "mode": "single", + "sort": "none" + } }, - "pluginVersion": "10.2.3", "targets": [ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, - "disableTextWrap": false, - "editorMode": "builder", - "expr": "snarkos_bft_primary_proposal_round", - "fullMetaSearch": false, - "includeNullMetadata": true, + "editorMode": "code", + "expr": "snarkos_router_candidate_total", "legendFormat": "__auto", "range": true, - "refId": "A", - "useBackend": false + "refId": "A" } ], - "title": "Current Round", - "type": "stat" + "title": "Candidate Peers", + "type": "timeseries" + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 41 + }, + "id": 18, + "panels": [], + "title": "BFT", + "type": "row" }, { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "fieldConfig": { "defaults": { @@ -1006,11 +1083,11 @@ }, "gridPos": { "h": 8, - "w": 6, - "x": 6, + "w": 8, + "x": 0, "y": 42 }, - "id": 25, + "id": 16, "options": { "colorMode": "value", "graphMode": "area", @@ -1023,30 +1100,35 @@ "fields": "", "values": false }, + "showPercentChange": false, "textMode": "auto", "wideLayout": true }, - "pluginVersion": "10.2.3", + "pluginVersion": "10.4.1", "targets": [ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, - "editorMode": "code", - "expr": "snarkos_consensus_last_committed_round", + "disableTextWrap": false, + "editorMode": "builder", + "expr": "snarkos_bft_primary_proposal_round", + "fullMetaSearch": false, + "includeNullMetadata": true, "legendFormat": "__auto", "range": true, - "refId": "A" + "refId": "A", + "useBackend": false } ], - "title": "Last Committed Round", + "title": "Current Round", "type": "stat" }, { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "fieldConfig": { "defaults": { @@ -1068,11 +1150,11 @@ }, "gridPos": { "h": 8, - "w": 6, - "x": 12, + "w": 8, + "x": 8, "y": 42 }, - "id": 12, + "id": 25, "options": { "colorMode": "value", "graphMode": "area", @@ -1085,30 +1167,31 @@ "fields": "", "values": false }, + "showPercentChange": false, "textMode": "auto", "wideLayout": true }, - "pluginVersion": "10.2.3", + "pluginVersion": "10.4.1", "targets": [ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, - "editorMode": "builder", - "expr": "snarkos_consensus_committed_certificates_total", + "editorMode": "code", + "expr": "snarkos_consensus_last_committed_round", "legendFormat": "__auto", "range": true, "refId": "A" } ], - "title": "Committed Certificates", + "title": "Last Committed Round", "type": "stat" }, { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "fieldConfig": { "defaults": { @@ -1130,8 +1213,8 @@ }, "gridPos": { "h": 8, - "w": 6, - "x": 18, + "w": 8, + "x": 16, "y": 42 }, "id": 24, @@ -1147,15 +1230,16 @@ "fields": "", "values": false }, + "showPercentChange": false, "textMode": "auto", "wideLayout": true }, - "pluginVersion": "10.2.3", + "pluginVersion": "10.4.1", "targets": [ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "editorMode": "code", "expr": "snarkos_bft_leaders_elected_total", @@ -1170,7 +1254,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "fieldConfig": { "defaults": { @@ -1192,371 +1276,37 @@ }, "gridPos": { "h": 8, - "w": 6, - "x": 0, + "w": 7, + "x": 4, "y": 50 }, "id": 40, "options": { "colorMode": "value", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "textMode": "auto", - "wideLayout": true - }, - "pluginVersion": "10.2.3", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "disableTextWrap": false, - "editorMode": "builder", - "expr": "snarkos_bft_primary_certified_batches", - "fullMetaSearch": false, - "includeNullMetadata": true, - "instant": false, - "legendFormat": "__auto", - "range": true, - "refId": "A", - "useBackend": false - } - ], - "title": "Certified Batches", - "type": "stat" - }, - { - "collapsed": false, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 58 - }, - "id": 10, - "panels": [], - "title": "Consensus", - "type": "row" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "displayName": "Average Certificate Commit Latency", - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "s" - }, - "overrides": [] - }, - "gridPos": { - "h": 8, - "w": 9, - "x": 0, - "y": 59 - }, - "id": 8, - "options": { - "legend": { - "calcs": [], - "displayMode": "list", - "placement": "bottom", - "showLegend": true - }, - "tooltip": { - "mode": "single", - "sort": "none" - } - }, - "pluginVersion": "9.4.1", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "disableTextWrap": false, - "editorMode": "builder", - "exemplar": false, - "expr": "avg(snarkos_consensus_certificate_commit_latency_secs)", - "format": "time_series", - "fullMetaSearch": false, - "includeNullMetadata": true, - "instant": false, - "legendFormat": "__auto", - "range": true, - "refId": "A", - "useBackend": false - } - ], - "title": "Certificate Commit Latency", - "transformations": [ - { - "id": "filterByValue", - "options": { - "filters": [ - { - "config": { - "id": "equal", - "options": { - "value": "" - } - }, - "fieldName": "certificate_round" - } - ], - "match": "all", - "type": "exclude" - } - } - ], - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "displayName": "Average round latency", - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 15 - } - ] - }, - "unit": "s" - }, - "overrides": [] - }, - "gridPos": { - "h": 8, - "w": 9, - "x": 9, - "y": 59 - }, - "id": 14, - "options": { - "legend": { - "calcs": [], - "displayMode": "list", - "placement": "bottom", - "showLegend": true - }, - "tooltip": { - "mode": "single", - "sort": "none" - } - }, - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "disableTextWrap": false, - "editorMode": "builder", - "exemplar": false, - "expr": "avg(snarkos_bft_commit_rounds_latency_secs)", - "format": "time_series", - "fullMetaSearch": false, - "includeNullMetadata": true, - "legendFormat": "__auto", - "range": true, - "refId": "A", - "useBackend": false - } - ], - "title": "Commit Rounds Latency", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "displayName": "Total Transactions", - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 8, - "w": 9, - "x": 0, - "y": 67 - }, - "id": 43, - "options": { - "legend": { - "calcs": [], - "displayMode": "list", - "placement": "bottom", - "showLegend": true + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false }, - "tooltip": { - "mode": "single", - "sort": "none" - } + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true }, + "pluginVersion": "10.4.1", "targets": [ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "disableTextWrap": false, "editorMode": "builder", - "expr": "snarkos_consensus_unconfirmed_transactions_total", + "expr": "snarkos_bft_primary_certified_batches", "fullMetaSearch": false, "includeNullMetadata": true, "instant": false, @@ -1566,52 +1316,19 @@ "useBackend": false } ], - "title": "Total Unconfirmed Transactions", - "type": "timeseries" + "title": "Certified Batches", + "type": "stat" }, { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "fieldConfig": { "defaults": { "color": { - "mode": "palette-classic" - }, - "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } + "mode": "thresholds" }, - "displayName": "Total Solutions", "mappings": [], "thresholds": { "mode": "absolute", @@ -1627,48 +1344,61 @@ }, "gridPos": { "h": 8, - "w": 9, - "x": 9, - "y": 67 + "w": 7, + "x": 11, + "y": 50 }, - "id": 44, + "id": 12, "options": { - "legend": { - "calcs": [], - "displayMode": "list", - "placement": "bottom", - "showLegend": true + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false }, - "tooltip": { - "mode": "single", - "sort": "none" - } + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true }, + "pluginVersion": "10.4.1", "targets": [ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, - "disableTextWrap": false, "editorMode": "builder", - "expr": "snarkos_consensus_unconfirmed_solutions_total", - "fullMetaSearch": false, - "includeNullMetadata": true, - "instant": false, + "expr": "snarkos_consensus_committed_certificates_total", "legendFormat": "__auto", "range": true, - "refId": "A", - "useBackend": false + "refId": "A" } ], - "title": "Total Unconfirmed Solutions", - "type": "timeseries" + "title": "Committed Certificates", + "type": "stat" + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 58 + }, + "id": 10, + "panels": [], + "title": "Consensus", + "type": "row" }, { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "fieldConfig": { "defaults": { @@ -1707,7 +1437,7 @@ "mode": "off" } }, - "displayName": "Total Transmissions", + "displayName": "Average Certificate Commit Latency", "mappings": [], "thresholds": { "mode": "absolute", @@ -1715,19 +1445,24 @@ { "color": "green", "value": null + }, + { + "color": "red", + "value": 80 } ] - } + }, + "unit": "s" }, "overrides": [] }, "gridPos": { "h": 8, - "w": 9, + "w": 12, "x": 0, - "y": 75 + "y": 59 }, - "id": 45, + "id": 8, "options": { "legend": { "calcs": [], @@ -1740,15 +1475,18 @@ "sort": "none" } }, + "pluginVersion": "9.4.1", "targets": [ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "disableTextWrap": false, "editorMode": "builder", - "expr": "snarkos_consensus_unconfirmed_transmissions_total", + "exemplar": false, + "expr": "avg(snarkos_consensus_certificate_commit_latency_secs)", + "format": "time_series", "fullMetaSearch": false, "includeNullMetadata": true, "instant": false, @@ -1758,13 +1496,33 @@ "useBackend": false } ], - "title": "Total Unconfirmed Transmissions", + "title": "Certificate Commit Latency", + "transformations": [ + { + "id": "filterByValue", + "options": { + "filters": [ + { + "config": { + "id": "equal", + "options": { + "value": "" + } + }, + "fieldName": "certificate_round" + } + ], + "match": "all", + "type": "exclude" + } + } + ], "type": "timeseries" }, { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "fieldConfig": { "defaults": { @@ -1803,7 +1561,7 @@ "mode": "off" } }, - "displayName": "Average Block Latency", + "displayName": "Average round latency", "mappings": [], "thresholds": { "mode": "absolute", @@ -1814,20 +1572,21 @@ }, { "color": "red", - "value": 80 + "value": 15 } ] - } + }, + "unit": "s" }, "overrides": [] }, "gridPos": { "h": 8, - "w": 9, - "x": 9, - "y": 75 + "w": 12, + "x": 12, + "y": 59 }, - "id": 38, + "id": 14, "options": { "legend": { "calcs": [], @@ -1844,40 +1603,28 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "disableTextWrap": false, "editorMode": "builder", - "expr": "avg(snarkos_consensus_block_latency_secs)", + "exemplar": false, + "expr": "avg(snarkos_bft_commit_rounds_latency_secs)", + "format": "time_series", "fullMetaSearch": false, "includeNullMetadata": true, - "instant": false, "legendFormat": "__auto", "range": true, "refId": "A", "useBackend": false } ], - "title": "Block Latency", + "title": "Commit Rounds Latency", "type": "timeseries" }, - { - "collapsed": false, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 83 - }, - "id": 4, - "panels": [], - "title": "Network", - "type": "row" - }, { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "fieldConfig": { "defaults": { @@ -1916,7 +1663,7 @@ "mode": "off" } }, - "displayName": "Queue Depth", + "displayName": "Total Transactions", "mappings": [], "thresholds": { "mode": "absolute", @@ -1924,10 +1671,6 @@ { "color": "green", "value": null - }, - { - "color": "red", - "value": 80 } ] } @@ -1937,10 +1680,10 @@ "gridPos": { "h": 8, "w": 12, - "x": 6, - "y": 84 + "x": 0, + "y": 67 }, - "id": 37, + "id": 43, "options": { "legend": { "calcs": [], @@ -1957,11 +1700,11 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "disableTextWrap": false, "editorMode": "builder", - "expr": "snarkos_tcp_tasks_total", + "expr": "snarkos_consensus_unconfirmed_transactions_total", "fullMetaSearch": false, "includeNullMetadata": true, "instant": false, @@ -1971,13 +1714,13 @@ "useBackend": false } ], - "title": "TCP Queue Depth", + "title": "Total Unconfirmed Transactions", "type": "timeseries" }, { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "fieldConfig": { "defaults": { @@ -2016,7 +1759,7 @@ "mode": "off" } }, - "displayName": "average encrypt time", + "displayName": "Total Solutions", "mappings": [], "thresholds": { "mode": "absolute", @@ -2024,24 +1767,19 @@ { "color": "green", "value": null - }, - { - "color": "red", - "value": 80 } ] - }, - "unit": "µs" + } }, "overrides": [] }, "gridPos": { "h": 8, "w": 12, - "x": 0, - "y": 92 + "x": 12, + "y": 67 }, - "id": 32, + "id": 44, "options": { "legend": { "calcs": [], @@ -2058,11 +1796,11 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "disableTextWrap": false, "editorMode": "builder", - "expr": "avg(snarkos_tcp_noise_codec_encryption_micros)", + "expr": "snarkos_consensus_unconfirmed_solutions_total", "fullMetaSearch": false, "includeNullMetadata": true, "instant": false, @@ -2072,13 +1810,13 @@ "useBackend": false } ], - "title": "Encryption Time", + "title": "Total Unconfirmed Solutions", "type": "timeseries" }, { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "fieldConfig": { "defaults": { @@ -2117,7 +1855,7 @@ "mode": "off" } }, - "displayName": "average decrypt time", + "displayName": "Total Transmissions", "mappings": [], "thresholds": { "mode": "absolute", @@ -2125,24 +1863,19 @@ { "color": "green", "value": null - }, - { - "color": "red", - "value": 80 } ] - }, - "unit": "µs" + } }, "overrides": [] }, "gridPos": { "h": 8, "w": 12, - "x": 12, - "y": 92 + "x": 0, + "y": 75 }, - "id": 33, + "id": 45, "options": { "legend": { "calcs": [], @@ -2159,30 +1892,27 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "disableTextWrap": false, "editorMode": "builder", - "exemplar": false, - "expr": "avg(snarkos_tcp_noise_codec_decryption_micros)", - "format": "time_series", + "expr": "snarkos_consensus_unconfirmed_transmissions_total", "fullMetaSearch": false, "includeNullMetadata": true, "instant": false, - "interval": "", "legendFormat": "__auto", "range": true, "refId": "A", "useBackend": false } ], - "title": "Decryption Time", + "title": "Total Unconfirmed Transmissions", "type": "timeseries" }, { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "fieldConfig": { "defaults": { @@ -2221,7 +1951,7 @@ "mode": "off" } }, - "displayName": "Average Size", + "displayName": "Average Block Latency", "mappings": [], "thresholds": { "mode": "absolute", @@ -2235,18 +1965,17 @@ "value": 80 } ] - }, - "unit": "decbytes" + } }, "overrides": [] }, "gridPos": { "h": 8, "w": 12, - "x": 0, - "y": 100 + "x": 12, + "y": 75 }, - "id": 34, + "id": 38, "options": { "legend": { "calcs": [], @@ -2263,11 +1992,11 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "disableTextWrap": false, "editorMode": "builder", - "expr": "avg(snarkos_tcp_noise_codec_encryption_size)", + "expr": "avg(snarkos_consensus_block_latency_secs)", "fullMetaSearch": false, "includeNullMetadata": true, "instant": false, @@ -2277,13 +2006,26 @@ "useBackend": false } ], - "title": "Encryption Size", + "title": "Block Latency", "type": "timeseries" }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 83 + }, + "id": 4, + "panels": [], + "title": "Network", + "type": "row" + }, { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "fieldConfig": { "defaults": { @@ -2322,7 +2064,7 @@ "mode": "off" } }, - "displayName": "Average Size", + "displayName": "Queue Depth", "mappings": [], "thresholds": { "mode": "absolute", @@ -2336,18 +2078,17 @@ "value": 80 } ] - }, - "unit": "decbytes" + } }, "overrides": [] }, "gridPos": { "h": 8, "w": 12, - "x": 12, - "y": 100 + "x": 6, + "y": 84 }, - "id": 35, + "id": 37, "options": { "legend": { "calcs": [], @@ -2364,11 +2105,11 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "adgg6tp3e19fkc" }, "disableTextWrap": false, "editorMode": "builder", - "expr": "avg(snarkos_tcp_noise_codec_decryption_size)", + "expr": "snarkos_tcp_tasks_total", "fullMetaSearch": false, "includeNullMetadata": true, "instant": false, @@ -2378,7 +2119,7 @@ "useBackend": false } ], - "title": "Decryption Size", + "title": "TCP Queue Depth", "type": "timeseries" } ], @@ -2393,8 +2134,8 @@ "list": [] }, "time": { - "from": "now-5m", - "to": "now" + "from": "now-30m", + "to": "now-18m" }, "timepicker": { "refresh_intervals": [ @@ -2412,7 +2153,6 @@ }, "timezone": "", "title": "snarkOS", - "uid": "ahTJm4-4k", - "version": 1, + "version": 3, "weekStart": "" } \ No newline at end of file From 7b910e82267d52223cc0a219a7a78d5189902f8d Mon Sep 17 00:00:00 2001 From: miazn Date: Fri, 22 Mar 2024 13:53:31 -0400 Subject: [PATCH 276/551] generalize the prometheus datasource id --- node/metrics/snarkOS-grafana.json | 92 +++++++++++++++---------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/node/metrics/snarkOS-grafana.json b/node/metrics/snarkOS-grafana.json index d86a954c8d..2da0e15189 100644 --- a/node/metrics/snarkOS-grafana.json +++ b/node/metrics/snarkOS-grafana.json @@ -44,7 +44,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "fieldConfig": { "defaults": { @@ -92,7 +92,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "disableTextWrap": false, "editorMode": "builder", @@ -112,7 +112,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "fieldConfig": { "defaults": { @@ -164,7 +164,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "editorMode": "code", "expr": "avg(\n 1 / rate(snarkos_blocks_height_total{}[1m])\n) < +inf", @@ -190,7 +190,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "fieldConfig": { "defaults": { @@ -266,7 +266,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "editorMode": "code", "expr": "snarkos_blocks_height_total", @@ -281,7 +281,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "fieldConfig": { "defaults": { @@ -361,7 +361,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "editorMode": "code", "expr": "snarkos_router_restricted_total", @@ -376,7 +376,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "fieldConfig": { "defaults": { @@ -452,7 +452,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "disableTextWrap": false, "editorMode": "builder", @@ -472,7 +472,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "fieldConfig": { "defaults": { @@ -548,7 +548,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "editorMode": "builder", "expr": "sum(rate(snarkos_blocks_transactions_total[5m]))", @@ -563,7 +563,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "fieldConfig": { "defaults": { @@ -639,7 +639,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "disableTextWrap": false, "editorMode": "builder", @@ -659,7 +659,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "fieldConfig": { "defaults": { @@ -739,7 +739,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "disableTextWrap": false, "editorMode": "builder", @@ -759,7 +759,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "fieldConfig": { "defaults": { @@ -838,7 +838,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "disableTextWrap": false, "editorMode": "builder", @@ -858,7 +858,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "fieldConfig": { "defaults": { @@ -938,7 +938,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "editorMode": "code", "expr": "snarkos_router_connected_total", @@ -953,7 +953,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "fieldConfig": { "defaults": { @@ -1033,7 +1033,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "editorMode": "code", "expr": "snarkos_router_candidate_total", @@ -1061,7 +1061,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "fieldConfig": { "defaults": { @@ -1109,7 +1109,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "disableTextWrap": false, "editorMode": "builder", @@ -1128,7 +1128,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "fieldConfig": { "defaults": { @@ -1176,7 +1176,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "editorMode": "code", "expr": "snarkos_consensus_last_committed_round", @@ -1191,7 +1191,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "fieldConfig": { "defaults": { @@ -1239,7 +1239,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "editorMode": "code", "expr": "snarkos_bft_leaders_elected_total", @@ -1254,7 +1254,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "fieldConfig": { "defaults": { @@ -1302,7 +1302,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "disableTextWrap": false, "editorMode": "builder", @@ -1322,7 +1322,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "fieldConfig": { "defaults": { @@ -1370,7 +1370,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "editorMode": "builder", "expr": "snarkos_consensus_committed_certificates_total", @@ -1398,7 +1398,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "fieldConfig": { "defaults": { @@ -1480,7 +1480,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "disableTextWrap": false, "editorMode": "builder", @@ -1522,7 +1522,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "fieldConfig": { "defaults": { @@ -1603,7 +1603,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "disableTextWrap": false, "editorMode": "builder", @@ -1624,7 +1624,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "fieldConfig": { "defaults": { @@ -1700,7 +1700,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "disableTextWrap": false, "editorMode": "builder", @@ -1720,7 +1720,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "fieldConfig": { "defaults": { @@ -1796,7 +1796,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "disableTextWrap": false, "editorMode": "builder", @@ -1816,7 +1816,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "fieldConfig": { "defaults": { @@ -1892,7 +1892,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "disableTextWrap": false, "editorMode": "builder", @@ -1912,7 +1912,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "fieldConfig": { "defaults": { @@ -1992,7 +1992,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "disableTextWrap": false, "editorMode": "builder", @@ -2025,7 +2025,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "fieldConfig": { "defaults": { @@ -2105,7 +2105,7 @@ { "datasource": { "type": "prometheus", - "uid": "adgg6tp3e19fkc" + "uid": "${DS_PROMETHEUS}" }, "disableTextWrap": false, "editorMode": "builder", From 6eede72197d4fea3242ee3a88ebeb0c65c1a08a1 Mon Sep 17 00:00:00 2001 From: miazn Date: Fri, 22 Mar 2024 13:54:14 -0400 Subject: [PATCH 277/551] default time --- node/metrics/snarkOS-grafana.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node/metrics/snarkOS-grafana.json b/node/metrics/snarkOS-grafana.json index 2da0e15189..485725ba39 100644 --- a/node/metrics/snarkOS-grafana.json +++ b/node/metrics/snarkOS-grafana.json @@ -2134,8 +2134,8 @@ "list": [] }, "time": { - "from": "now-30m", - "to": "now-18m" + "from": "now-5m", + "to": "now" }, "timepicker": { "refresh_intervals": [ From 28d04ab4e886209b484b4dde9ca6e2f57877ea84 Mon Sep 17 00:00:00 2001 From: miazn Date: Fri, 22 Mar 2024 14:03:01 -0400 Subject: [PATCH 278/551] keep default input --- node/metrics/snarkOS-grafana.json | 38 ++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/node/metrics/snarkOS-grafana.json b/node/metrics/snarkOS-grafana.json index 485725ba39..e837e590f7 100644 --- a/node/metrics/snarkOS-grafana.json +++ b/node/metrics/snarkOS-grafana.json @@ -1,4 +1,40 @@ -{ +{ "__inputs": [ + { + "name": "DS_PROMETHEUS", + "label": "prometheus", + "description": "", + "type": "datasource", + "pluginId": "prometheus", + "pluginName": "Prometheus" + } +], +"__elements": {}, +"__requires": [ + { + "type": "grafana", + "id": "grafana", + "name": "Grafana", + "version": "10.2.3" + }, + { + "type": "datasource", + "id": "prometheus", + "name": "Prometheus", + "version": "1.0.0" + }, + { + "type": "panel", + "id": "stat", + "name": "Stat", + "version": "" + }, + { + "type": "panel", + "id": "timeseries", + "name": "Time series", + "version": "" + } +], "annotations": { "list": [ { From 46deaad62cc550fd7adea76e40257b018ebc858c Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 22 Mar 2024 12:22:26 -0700 Subject: [PATCH 279/551] Update num_unconfirmed checks --- node/bft/src/primary.rs | 2 +- node/consensus/src/lib.rs | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 611a3d5c5d..d954c98a6d 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -100,7 +100,7 @@ pub struct Primary { impl Primary { /// The maximum number of unconfirmed transmissions to send to the primary. - pub const MAX_TRANSMISSIONS_IN_MEMORY_POOL: usize = BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH * 2; + pub const MAX_TRANSMISSIONS_TOLERANCE: usize = BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH * 2; /// Initializes a new primary instance. pub fn new( diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 9e76ec452b..c4ec813be1 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -239,14 +239,17 @@ impl Consensus { } // If the memory pool of this node is full, return early. - let num_unconfirmed = self.num_unconfirmed_transmissions(); - if num_unconfirmed > N::MAX_SOLUTIONS || num_unconfirmed > BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH { + let num_unconfirmed_solutions = self.num_unconfirmed_solutions(); + let num_unconfirmed_transmissions = self.num_unconfirmed_transmissions(); + if num_unconfirmed_solutions > N::MAX_SOLUTIONS + || num_unconfirmed_transmissions > Primary::::MAX_TRANSMISSIONS_TOLERANCE + { return Ok(()); } // Retrieve the solutions. let solutions = { // Determine the available capacity. - let capacity = N::MAX_SOLUTIONS.saturating_sub(num_unconfirmed); + let capacity = N::MAX_SOLUTIONS.saturating_sub(num_unconfirmed_solutions); // Acquire the lock on the queue. let mut queue = self.solutions_queue.lock(); // Determine the number of solutions to send. @@ -305,14 +308,14 @@ impl Consensus { } // If the memory pool of this node is full, return early. - let num_unconfirmed = self.num_unconfirmed_transmissions(); - if num_unconfirmed > Primary::::MAX_TRANSMISSIONS_IN_MEMORY_POOL { + let num_unconfirmed_transmissions = self.num_unconfirmed_transmissions(); + if num_unconfirmed_transmissions > Primary::::MAX_TRANSMISSIONS_TOLERANCE { return Ok(()); } // Retrieve the transactions. let transactions = { // Determine the available capacity. - let capacity = Primary::::MAX_TRANSMISSIONS_IN_MEMORY_POOL.saturating_sub(num_unconfirmed); + let capacity = Primary::::MAX_TRANSMISSIONS_TOLERANCE.saturating_sub(num_unconfirmed_transmissions); // Acquire the lock on the transactions queue. let mut tx_queue = self.transactions_queue.lock(); // Determine the number of deployments to send. From da996bd81bb6c234ce8e4c9eb35b3aebddac94b6 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 22 Mar 2024 12:24:52 -0700 Subject: [PATCH 280/551] nit --- node/consensus/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index c4ec813be1..7fcab5b00e 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -241,8 +241,8 @@ impl Consensus { // If the memory pool of this node is full, return early. let num_unconfirmed_solutions = self.num_unconfirmed_solutions(); let num_unconfirmed_transmissions = self.num_unconfirmed_transmissions(); - if num_unconfirmed_solutions > N::MAX_SOLUTIONS - || num_unconfirmed_transmissions > Primary::::MAX_TRANSMISSIONS_TOLERANCE + if num_unconfirmed_solutions >= N::MAX_SOLUTIONS + || num_unconfirmed_transmissions >= Primary::::MAX_TRANSMISSIONS_TOLERANCE { return Ok(()); } @@ -309,7 +309,7 @@ impl Consensus { // If the memory pool of this node is full, return early. let num_unconfirmed_transmissions = self.num_unconfirmed_transmissions(); - if num_unconfirmed_transmissions > Primary::::MAX_TRANSMISSIONS_TOLERANCE { + if num_unconfirmed_transmissions >= Primary::::MAX_TRANSMISSIONS_TOLERANCE { return Ok(()); } // Retrieve the transactions. From 0eb6ee562cf6ff4616f70acacf9d89beae784add Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Fri, 22 Mar 2024 12:41:00 -0700 Subject: [PATCH 281/551] Fix public balance in simple node --- node/bft/examples/simple_node.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/bft/examples/simple_node.rs b/node/bft/examples/simple_node.rs index 340540fc55..1af54fcd55 100644 --- a/node/bft/examples/simple_node.rs +++ b/node/bft/examples/simple_node.rs @@ -194,7 +194,7 @@ fn create_ledger( ) -> Arc>> { let gen_key = account.private_key(); let public_balance_per_validator = - (1_500_000_000_000_000 - (num_nodes as u64) * 1_000_000_000_000) / (num_nodes as u64); + (CurrentNetwork::STARTING_SUPPLY - (num_nodes as u64) * MIN_VALIDATOR_STAKE) / (num_nodes as u64); let mut balances = IndexMap::, u64>::new(); for address in committee.members().keys() { balances.insert(*address, public_balance_per_validator); From fb3c4109180cdef0660e922573d2a2a947d5509f Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Fri, 22 Mar 2024 16:23:17 -0700 Subject: [PATCH 282/551] Update logging --- node/bft/src/bft.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 0373acf740..011ffd8354 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -226,7 +226,7 @@ impl BFT { if let Some(leader_certificate) = self.leader_certificate.read().as_ref() { // Ensure the state of the leader certificate is consistent with the BFT being ready. if !is_ready { - debug!(is_ready, "BFT - A leader certificate was found, but 'is_ready' is false"); + trace!(is_ready, "BFT - A leader certificate was found, but 'is_ready' is false"); } // Log the leader election. let leader_round = leader_certificate.round(); @@ -336,7 +336,7 @@ impl BFT { let authors = certificates.into_iter().map(|c| c.author()).collect(); // Check if quorum threshold is reached. if !committee.is_quorum_threshold_reached(&authors) { - debug!("BFT failed to reach quorum threshold in even round {current_round}"); + trace!("BFT failed to reach quorum threshold in even round {current_round}"); return false; } // If the leader certificate is set for the current even round, return 'true'. @@ -390,7 +390,7 @@ impl BFT { let authors = current_certificates.clone().into_iter().map(|c| c.author()).collect(); // Check if quorum threshold is reached. if !committee_lookback.is_quorum_threshold_reached(&authors) { - debug!("BFT failed reach quorum threshold in odd round {current_round}. "); + trace!("BFT failed reach quorum threshold in odd round {current_round}. "); return false; } // Retrieve the leader certificate. From 0d4a91f7a81aa73754cd67901008a5122f0b8d80 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Fri, 22 Mar 2024 17:10:18 -0700 Subject: [PATCH 283/551] Bump MSRV to 1.76.0 --- .circleci/config.yml | 42 +++++++-------- Cargo.lock | 118 +++++++++++++++++++++---------------------- Cargo.toml | 4 +- rust-toolchain | 2 +- 4 files changed, 83 insertions(+), 83 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 984e1e4c70..522066b223 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -160,7 +160,7 @@ commands: jobs: integration: docker: - - image: cimg/rust:1.74.1 + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: 2xlarge steps: - run_serial_long: @@ -169,7 +169,7 @@ jobs: snarkos: docker: - - image: cimg/rust:1.74.1 + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: 2xlarge steps: - run_serial: @@ -178,7 +178,7 @@ jobs: account: docker: - - image: cimg/rust:1.74.1 + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: xlarge steps: - run_serial: @@ -187,7 +187,7 @@ jobs: cli: docker: - - image: cimg/rust:1.74.1 + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: xlarge steps: - run_serial: @@ -196,7 +196,7 @@ jobs: display: docker: - - image: cimg/rust:1.74.1 + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: xlarge steps: - run_serial: @@ -205,7 +205,7 @@ jobs: node: docker: - - image: cimg/rust:1.74.1 + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: 2xlarge steps: - run_serial: @@ -214,7 +214,7 @@ jobs: node-bft: docker: - - image: cimg/rust:1.74.1 + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: 2xlarge steps: - run_serial: @@ -223,7 +223,7 @@ jobs: node-bft-events: docker: - - image: cimg/rust:1.74.1 + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: 2xlarge steps: - run_serial: @@ -232,7 +232,7 @@ jobs: node-bft-ledger-service: docker: - - image: cimg/rust:1.74.1 + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: xlarge steps: - run_serial: @@ -241,7 +241,7 @@ jobs: node-bft-storage-service: docker: - - image: cimg/rust:1.74.1 + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: xlarge steps: - run_serial: @@ -250,7 +250,7 @@ jobs: node-cdn: docker: - - image: cimg/rust:1.74.1 + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: xlarge steps: - run_serial: @@ -259,7 +259,7 @@ jobs: node-consensus: docker: - - image: cimg/rust:1.74.1 + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: 2xlarge steps: - run_serial: @@ -268,7 +268,7 @@ jobs: node-rest: docker: - - image: cimg/rust:1.74.1 + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: xlarge steps: - run_serial: @@ -277,7 +277,7 @@ jobs: node-router: docker: - - image: cimg/rust:1.74.1 + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: xlarge steps: - run_serial: @@ -286,7 +286,7 @@ jobs: node-router-messages: docker: - - image: cimg/rust:1.74.1 + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: xlarge steps: - run_serial: @@ -295,7 +295,7 @@ jobs: node-sync: docker: - - image: cimg/rust:1.74.1 + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: xlarge steps: - run_serial: @@ -304,7 +304,7 @@ jobs: node-sync-communication-service: docker: - - image: cimg/rust:1.74.1 + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: xlarge steps: - run_serial: @@ -313,7 +313,7 @@ jobs: node-sync-locators: docker: - - image: cimg/rust:1.74.1 + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: xlarge steps: - run_serial: @@ -322,7 +322,7 @@ jobs: node-tcp: docker: - - image: cimg/rust:1.74.1 + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: xlarge steps: - run_serial: @@ -331,7 +331,7 @@ jobs: check-fmt: docker: - - image: cimg/rust:1.74.1 + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: xlarge steps: - checkout @@ -347,7 +347,7 @@ jobs: check-clippy: docker: - - image: cimg/rust:1.74.1 + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: 2xlarge steps: - checkout diff --git a/Cargo.lock b/Cargo.lock index c8f0ccd90d..d2d86d1bb5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3301,7 +3301,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "anstyle", "anyhow", @@ -3332,7 +3332,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "aleo-std", "anyhow", @@ -3362,7 +3362,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3376,7 +3376,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3387,7 +3387,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3397,7 +3397,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3407,7 +3407,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "indexmap 2.2.5", "itertools 0.11.0", @@ -3425,12 +3425,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3441,7 +3441,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3456,7 +3456,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3471,7 +3471,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3484,7 +3484,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3493,7 +3493,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3503,7 +3503,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3515,7 +3515,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3527,7 +3527,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3538,7 +3538,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3550,7 +3550,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3563,7 +3563,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "bs58", "snarkvm-console-network", @@ -3574,7 +3574,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "blake2s_simd", "smallvec", @@ -3587,7 +3587,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "aleo-std", "rayon", @@ -3598,7 +3598,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "anyhow", "indexmap 2.2.5", @@ -3621,7 +3621,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "anyhow", "bech32", @@ -3639,7 +3639,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "enum_index", "enum_index_derive", @@ -3660,7 +3660,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3675,7 +3675,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3686,7 +3686,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "snarkvm-console-network-environment", ] @@ -3694,7 +3694,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3704,7 +3704,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3715,7 +3715,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3726,7 +3726,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3737,7 +3737,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3748,7 +3748,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "rand", "rayon", @@ -3762,7 +3762,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "aleo-std", "anyhow", @@ -3779,7 +3779,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "aleo-std", "anyhow", @@ -3804,7 +3804,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "anyhow", "rand", @@ -3816,7 +3816,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3835,7 +3835,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "anyhow", "indexmap 2.2.5", @@ -3854,7 +3854,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -3867,7 +3867,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3880,7 +3880,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3893,7 +3893,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "bytes", "serde_json", @@ -3904,7 +3904,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3919,7 +3919,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "bytes", "serde_json", @@ -3932,7 +3932,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "snarkvm-console", "snarkvm-ledger-puzzle", @@ -3941,7 +3941,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "aleo-std", "anyhow", @@ -3961,7 +3961,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle-epoch" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "anyhow", "colored", @@ -3976,7 +3976,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "async-trait", "reqwest", @@ -3989,7 +3989,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "aleo-std-storage", "anyhow", @@ -4015,7 +4015,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4030,7 +4030,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4039,7 +4039,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "aleo-std", "anyhow", @@ -4064,7 +4064,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "aleo-std", "anyhow", @@ -4092,7 +4092,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "aleo-std", "colored", @@ -4115,7 +4115,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "indexmap 2.2.5", "paste", @@ -4129,7 +4129,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "bincode", "once_cell", @@ -4142,7 +4142,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "aleo-std", "anyhow", @@ -4163,7 +4163,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=81af174#81af174c8d4b3cc85d93ddeea508c0cd5833e203" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" dependencies = [ "proc-macro2", "quote 1.0.35", diff --git a/Cargo.toml b/Cargo.toml index 78f2d6a496..64d09eb9b1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ keywords = [ categories = [ "cryptography", "operating-systems" ] license = "Apache-2.0" edition = "2021" -rust-version = "1.74.1" +rust-version = "1.76.0" # Attention - Change the MSRV in rust-toolchain and in .circleci/config.yml as well [workspace] members = [ @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "81af174" +rev = "0029b6a" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] diff --git a/rust-toolchain b/rust-toolchain index 80627411dc..32a6ce3c71 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.74.1 +1.76.0 From 6995f7ccc34769e25f256901bf5747ec6f584624 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Fri, 22 Mar 2024 17:15:24 -0700 Subject: [PATCH 284/551] Clippy --- node/bft/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/node/bft/src/lib.rs b/node/bft/src/lib.rs index e466b9d749..d6fcbae66f 100644 --- a/node/bft/src/lib.rs +++ b/node/bft/src/lib.rs @@ -13,6 +13,7 @@ // limitations under the License. #![forbid(unsafe_code)] +#![allow(clippy::blocks_in_conditions)] #![allow(clippy::type_complexity)] #[macro_use] From fcff34df9a578eb7ae34f904d44e3296783845ac Mon Sep 17 00:00:00 2001 From: mdelle1 <108158289+mdelle1@users.noreply.github.com> Date: Sun, 24 Mar 2024 18:14:29 -0400 Subject: [PATCH 285/551] Removes comment --- node/bft/src/helpers/timestamp.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/node/bft/src/helpers/timestamp.rs b/node/bft/src/helpers/timestamp.rs index 0c546bd266..2b361fa3cc 100644 --- a/node/bft/src/helpers/timestamp.rs +++ b/node/bft/src/helpers/timestamp.rs @@ -28,11 +28,6 @@ pub fn check_timestamp_for_liveness(timestamp: i64) -> Result<()> { if timestamp > (now() + MAX_TIMESTAMP_DELTA_IN_SECS) { bail!("Timestamp {timestamp} is too far in the future") } - // TODO (howardwu): Ensure the timestamp is after the previous timestamp. (Needs Bullshark committee) - // // Ensure the timestamp is after the previous timestamp. - // if timestamp <= committee.previous_timestamp() { - // bail!("Timestamp {timestamp} for the proposed batch must be after the previous round timestamp") - // } Ok(()) } From b1bd3bf7457a162641b835d97adb8b6405bef6ed Mon Sep 17 00:00:00 2001 From: Victor Sint Nicolaas Date: Mon, 25 Mar 2024 21:28:59 +0100 Subject: [PATCH 286/551] Make --node optional to ensure it still has an influence even when using --dev --- cli/src/commands/start.rs | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index dbe2bd14bf..a3d2767f80 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -90,8 +90,8 @@ pub struct Start { pub private_key_file: Option, /// Specify the IP address and port for the node server - #[clap(default_value = "0.0.0.0:4130", long = "node")] - pub node: SocketAddr, + #[clap(long = "node")] + pub node: Option, /// Specify the IP address and port for the BFT #[clap(long = "bft")] pub bft: Option, @@ -308,11 +308,15 @@ impl Start { } } // Set the node IP to `4130 + dev`. - self.node = SocketAddr::from_str(&format!("0.0.0.0:{}", 4130 + dev))?; + // + // Note: the `node` flag is an option to detect remote devnet testing. + if self.node.is_none() { + self.node = Some(SocketAddr::from_str(&format!("0.0.0.0:{}", 4130 + dev))?); + } // If the `norest` flag is not set, and the `bft` flag was not overridden, // then set the REST IP to `3030 + dev`. // - // Note: the reason the `bft` flag is an option is to detect for remote devnet testing. + // Note: the `bft` flag is an option to detect remote devnet testing. if !self.norest && self.bft.is_none() { self.rest = SocketAddr::from_str(&format!("0.0.0.0:{}", 3030 + dev))?; } @@ -490,6 +494,10 @@ impl Start { true => None, false => Some(self.rest), }; + // Parse the bft ip. + let bft_ip = if self.dev.is_some() { self.bft } else { None }; + // Parse the node ip. + let node_ip = if let Some(node_ip) = self.node { node_ip } else { SocketAddr::from_str("0.0.0.0:4130").unwrap() }; // If the display is not enabled, render the welcome message. if self.nodisplay { @@ -500,7 +508,7 @@ impl Start { "🧭 Starting {} on {} at {}.\n", node_type.description().bold(), N::NAME.bold(), - self.node.to_string().bold() + node_ip.to_string().bold() ); // If the node is running a REST server, print the REST IP and JWT. @@ -547,11 +555,10 @@ impl Start { }; // Initialize the node. - let bft_ip = if self.dev.is_some() { self.bft } else { None }; match node_type { - NodeType::Validator => Node::new_validator(self.node, bft_ip, rest_ip, self.rest_rps, account, &trusted_peers, &trusted_validators, genesis, cdn, storage_mode, self.allow_external_peers, dev_txs).await, - NodeType::Prover => Node::new_prover(self.node, account, &trusted_peers, genesis, storage_mode).await, - NodeType::Client => Node::new_client(self.node, rest_ip, self.rest_rps, account, &trusted_peers, genesis, cdn, storage_mode).await, + NodeType::Validator => Node::new_validator(node_ip, bft_ip, rest_ip, self.rest_rps, account, &trusted_peers, &trusted_validators, genesis, cdn, storage_mode, self.allow_external_peers, dev_txs).await, + NodeType::Prover => Node::new_prover(node_ip, account, &trusted_peers, genesis, storage_mode).await, + NodeType::Client => Node::new_client(node_ip, rest_ip, self.rest_rps, account, &trusted_peers, genesis, cdn, storage_mode).await, } } @@ -834,7 +841,7 @@ mod tests { let mut config = Start::try_parse_from(["snarkos", "--dev", "0"].iter()).unwrap(); config.parse_development(&mut trusted_peers, &mut trusted_validators).unwrap(); let expected_genesis = config.parse_genesis::().unwrap(); - assert_eq!(config.node, SocketAddr::from_str("0.0.0.0:4130").unwrap()); + assert_eq!(config.node, Some(SocketAddr::from_str("0.0.0.0:4130").unwrap())); assert_eq!(config.rest, SocketAddr::from_str("0.0.0.0:3030").unwrap()); assert_eq!(trusted_peers.len(), 0); assert_eq!(trusted_validators.len(), 1); @@ -849,7 +856,7 @@ mod tests { Start::try_parse_from(["snarkos", "--dev", "1", "--validator", "--private-key", ""].iter()).unwrap(); config.parse_development(&mut trusted_peers, &mut trusted_validators).unwrap(); let genesis = config.parse_genesis::().unwrap(); - assert_eq!(config.node, SocketAddr::from_str("0.0.0.0:4131").unwrap()); + assert_eq!(config.node, Some(SocketAddr::from_str("0.0.0.0:4131").unwrap())); assert_eq!(config.rest, SocketAddr::from_str("0.0.0.0:3031").unwrap()); assert_eq!(trusted_peers.len(), 1); assert_eq!(trusted_validators.len(), 1); @@ -864,7 +871,7 @@ mod tests { Start::try_parse_from(["snarkos", "--dev", "2", "--prover", "--private-key", ""].iter()).unwrap(); config.parse_development(&mut trusted_peers, &mut trusted_validators).unwrap(); let genesis = config.parse_genesis::().unwrap(); - assert_eq!(config.node, SocketAddr::from_str("0.0.0.0:4132").unwrap()); + assert_eq!(config.node, Some(SocketAddr::from_str("0.0.0.0:4132").unwrap())); assert_eq!(config.rest, SocketAddr::from_str("0.0.0.0:3032").unwrap()); assert_eq!(trusted_peers.len(), 2); assert_eq!(trusted_validators.len(), 2); @@ -879,7 +886,7 @@ mod tests { Start::try_parse_from(["snarkos", "--dev", "3", "--client", "--private-key", ""].iter()).unwrap(); config.parse_development(&mut trusted_peers, &mut trusted_validators).unwrap(); let genesis = config.parse_genesis::().unwrap(); - assert_eq!(config.node, SocketAddr::from_str("0.0.0.0:4133").unwrap()); + assert_eq!(config.node, Some(SocketAddr::from_str("0.0.0.0:4133").unwrap())); assert_eq!(config.rest, SocketAddr::from_str("0.0.0.0:3033").unwrap()); assert_eq!(trusted_peers.len(), 3); assert_eq!(trusted_validators.len(), 2); From b6d0eb9fa6628c6b74e19106e5c392b6e1bf07dc Mon Sep 17 00:00:00 2001 From: Niklas Date: Tue, 26 Mar 2024 16:12:11 +0100 Subject: [PATCH 287/551] tests: fix flaky cleanup case --- node/router/tests/common/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/router/tests/common/mod.rs b/node/router/tests/common/mod.rs index 7aa86c0546..db65e89b95 100644 --- a/node/router/tests/common/mod.rs +++ b/node/router/tests/common/mod.rs @@ -111,7 +111,7 @@ pub async fn validator(listening_port: u16, max_peers: u16) -> TestRouter Date: Tue, 26 Mar 2024 14:21:23 -0400 Subject: [PATCH 288/551] fmt --- node/consensus/src/lib.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index cd85df2143..3e470428d2 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -224,9 +224,7 @@ impl Consensus { metrics::increment_gauge(metrics::consensus::UNCONFIRMED_SOLUTIONS, 1f64); metrics::increment_gauge(metrics::consensus::UNCONFIRMED_TRANSMISSIONS, 1f64); let timestamp = snarkos_node_bft::helpers::now(); - self.transmissions_queue_timestamps - .lock() - .insert(TransmissionID::Solution(solution.commitment()), timestamp); + self.transmissions_queue_timestamps.lock().insert(TransmissionID::Solution(solution.id()), timestamp); } // Process the unconfirmed solution. { From 5d43a73d4852b40ffa8e3e0b38baaf65bcef79ec Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 26 Mar 2024 18:25:53 -0400 Subject: [PATCH 289/551] Prevent proposing batches too quickly --- node/bft/src/lib.rs | 2 ++ node/bft/src/primary.rs | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/node/bft/src/lib.rs b/node/bft/src/lib.rs index d6fcbae66f..550fb20232 100644 --- a/node/bft/src/lib.rs +++ b/node/bft/src/lib.rs @@ -49,6 +49,8 @@ pub const MEMORY_POOL_PORT: u16 = 5000; // port /// The maximum number of milliseconds to wait before proposing a batch. pub const MAX_BATCH_DELAY_IN_MS: u64 = 2500; // ms +/// The maximum number of seconds to wait before proposing a batch (rounded down to the nearest second). +pub const MAX_BATCH_DELAY_IN_SECS: u64 = MAX_BATCH_DELAY_IN_MS / 1000; // seconds /// The maximum number of milliseconds to wait before timing out on a fetch. pub const MAX_FETCH_TIMEOUT_IN_MS: u64 = 3 * MAX_BATCH_DELAY_IN_MS; // ms /// The maximum number of seconds allowed for the leader to send their certificate. diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index a2a070183e..5b566a9def 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -33,6 +33,7 @@ use crate::{ Transport, Worker, MAX_BATCH_DELAY_IN_MS, + MAX_BATCH_DELAY_IN_SECS, MAX_WORKERS, PRIMARY_PING_IN_MS, WORKER_PING_IN_MS, @@ -321,6 +322,21 @@ impl Primary { #[cfg(feature = "metrics")] metrics::gauge(metrics::bft::PROPOSAL_ROUND, round as f64); + // Ensure that the primary does not create a new proposal too quickly. + if let Some(previous_certificate) = self + .storage + .get_certificate_for_round_with_author(round.saturating_sub(1), self.gateway.account().address()) + { + // If the primary proposed a previous certificate too recently, return early. + if now().saturating_sub(previous_certificate.timestamp()) < MAX_BATCH_DELAY_IN_SECS as i64 { + debug!( + "Primary is safely skipping a batch proposal {}", + format!("(round {round} was proposed too quickly)").dimmed() + ); + return Ok(()); + } + } + // Ensure the primary has not proposed a batch for this round before. if self.storage.contains_certificate_in_round_from(round, self.gateway.account().address()) { // If a BFT sender was provided, attempt to advance the current round. From 3758d2603db86d745b655495049a17f7e57ebd5e Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 26 Mar 2024 19:21:13 -0400 Subject: [PATCH 290/551] Prevent signing proposals that were created too quickly --- node/bft/src/primary.rs | 47 +++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 5b566a9def..e38436eff2 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -318,23 +318,16 @@ impl Primary { // Retrieve the current round. let round = self.current_round(); + // Compute the previous round. + let previous_round = round.saturating_sub(1); #[cfg(feature = "metrics")] metrics::gauge(metrics::bft::PROPOSAL_ROUND, round as f64); // Ensure that the primary does not create a new proposal too quickly. - if let Some(previous_certificate) = self - .storage - .get_certificate_for_round_with_author(round.saturating_sub(1), self.gateway.account().address()) - { - // If the primary proposed a previous certificate too recently, return early. - if now().saturating_sub(previous_certificate.timestamp()) < MAX_BATCH_DELAY_IN_SECS as i64 { - debug!( - "Primary is safely skipping a batch proposal {}", - format!("(round {round} was proposed too quickly)").dimmed() - ); - return Ok(()); - } + if let Err(e) = self.ensure_proposal_frequency(previous_round, self.gateway.account().address(), now()) { + debug!("Primary is safely skipping a batch proposal - {}", format!("{e}").dimmed()); + return Ok(()); } // Ensure the primary has not proposed a batch for this round before. @@ -375,8 +368,6 @@ impl Primary { } } - // Compute the previous round. - let previous_round = round.saturating_sub(1); // Retrieve the previous certificates. let previous_certificates = self.storage.get_certificates_for_round(previous_round); @@ -611,6 +602,15 @@ impl Primary { } } + // Compute the previous round. + let previous_round = batch_round.saturating_sub(1); + // Ensure that the peer did not propose a batch too quickly. + if let Err(e) = self.ensure_proposal_frequency(previous_round, batch_author, batch_header.timestamp()) { + // Proceed to disconnect the validator. + self.gateway.disconnect(peer_ip); + bail!("Malicious peer - {e} from '{peer_ip}'"); + } + // If the peer is ahead, use the batch header to sync up to the peer. let mut transmissions = self.sync_with_batch_header_from_peer(peer_ip, &batch_header).await?; @@ -1205,6 +1205,25 @@ impl Primary { Ok(()) } + /// Ensure the primary is not creating batch proposals too frequently. + /// This checks that the certificate timestamp for the previous round is within the expected range. + fn ensure_proposal_frequency(&self, previous_round: u64, author: Address, timestamp: i64) -> Result<()> { + // Ensure that the primary does not create a new proposal too quickly. + match self.storage.get_certificate_for_round_with_author(previous_round, author) { + // Ensure that the previous certificate was created at least `MAX_BATCH_DELAY_IN_SECS` seconds ago. + Some(certificate) => { + match timestamp.saturating_sub(certificate.timestamp()) < MAX_BATCH_DELAY_IN_SECS as i64 { + true => { + bail!("Proposed batch was created too quickly after the certificate at round {previous_round}") + } + false => Ok(()), + } + } + // If we do not see a previous certificate for the author, then proceed optimistically. + None => Ok(()), + } + } + /// Stores the certified batch and broadcasts it to all validators, returning the certificate. async fn store_and_broadcast_certificate(&self, proposal: &Proposal, committee: &Committee) -> Result<()> { // Create the batch certificate and transmissions. From 95fe67aad4f79674961427a14e11d41fb25d9053 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 26 Mar 2024 19:35:06 -0400 Subject: [PATCH 291/551] Fix tests and update naming --- node/bft/src/primary.rs | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index e38436eff2..d5687917b2 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -325,7 +325,7 @@ impl Primary { metrics::gauge(metrics::bft::PROPOSAL_ROUND, round as f64); // Ensure that the primary does not create a new proposal too quickly. - if let Err(e) = self.ensure_proposal_frequency(previous_round, self.gateway.account().address(), now()) { + if let Err(e) = self.check_proposal_timestamp(previous_round, self.gateway.account().address(), now()) { debug!("Primary is safely skipping a batch proposal - {}", format!("{e}").dimmed()); return Ok(()); } @@ -605,7 +605,7 @@ impl Primary { // Compute the previous round. let previous_round = batch_round.saturating_sub(1); // Ensure that the peer did not propose a batch too quickly. - if let Err(e) = self.ensure_proposal_frequency(previous_round, batch_author, batch_header.timestamp()) { + if let Err(e) = self.check_proposal_timestamp(previous_round, batch_author, batch_header.timestamp()) { // Proceed to disconnect the validator. self.gateway.disconnect(peer_ip); bail!("Malicious peer - {e} from '{peer_ip}'"); @@ -1207,12 +1207,17 @@ impl Primary { /// Ensure the primary is not creating batch proposals too frequently. /// This checks that the certificate timestamp for the previous round is within the expected range. - fn ensure_proposal_frequency(&self, previous_round: u64, author: Address, timestamp: i64) -> Result<()> { + fn check_proposal_timestamp(&self, previous_round: u64, author: Address, timestamp: i64) -> Result<()> { // Ensure that the primary does not create a new proposal too quickly. match self.storage.get_certificate_for_round_with_author(previous_round, author) { // Ensure that the previous certificate was created at least `MAX_BATCH_DELAY_IN_SECS` seconds ago. Some(certificate) => { - match timestamp.saturating_sub(certificate.timestamp()) < MAX_BATCH_DELAY_IN_SECS as i64 { + // Determine the elapsed time since the previous certificate. + let elapsed = timestamp.checked_sub(certificate.timestamp()).ok_or_else(|| { + anyhow!("Proposed batch has a timestamp earlier than the certificate at round {previous_round}") + })?; + // Ensure the elapsed time is within the expected range. + match elapsed < MAX_BATCH_DELAY_IN_SECS as i64 { true => { bail!("Proposed batch was created too quickly after the certificate at round {previous_round}") } @@ -1894,7 +1899,7 @@ mod tests { let round = 1; let peer_account = &accounts[1]; let peer_ip = peer_account.0; - let timestamp = now(); + let timestamp = now() + MAX_BATCH_DELAY_IN_SECS as i64; let proposal = create_test_proposal( &peer_account.1, primary.ledger.current_committee().unwrap(), @@ -1930,7 +1935,7 @@ mod tests { // Create a valid proposal with an author that isn't the primary. let peer_account = &accounts[1]; let peer_ip = peer_account.0; - let timestamp = now(); + let timestamp = now() + MAX_BATCH_DELAY_IN_SECS as i64; let proposal = create_test_proposal( &peer_account.1, primary.ledger.current_committee().unwrap(), @@ -1961,7 +1966,7 @@ mod tests { let round = 1; let peer_account = &accounts[1]; let peer_ip = peer_account.0; - let timestamp = now(); + let timestamp = now() + MAX_BATCH_DELAY_IN_SECS as i64; let proposal = create_test_proposal( &peer_account.1, primary.ledger.current_committee().unwrap(), @@ -2003,7 +2008,7 @@ mod tests { // Create a valid proposal with an author that isn't the primary. let peer_account = &accounts[1]; let peer_ip = peer_account.0; - let timestamp = now(); + let timestamp = now() + MAX_BATCH_DELAY_IN_SECS as i64; let proposal = create_test_proposal( &peer_account.1, primary.ledger.current_committee().unwrap(), @@ -2041,7 +2046,7 @@ mod tests { // Create a valid proposal. let round = 1; - let timestamp = now(); + let timestamp = now() + MAX_BATCH_DELAY_IN_SECS as i64; let proposal = create_test_proposal( primary.gateway.account(), primary.ledger.current_committee().unwrap(), @@ -2114,7 +2119,7 @@ mod tests { // Create a valid proposal. let round = 1; - let timestamp = now(); + let timestamp = now() + MAX_BATCH_DELAY_IN_SECS as i64; let proposal = create_test_proposal( primary.gateway.account(), primary.ledger.current_committee().unwrap(), @@ -2151,7 +2156,7 @@ mod tests { let previous_certificates = store_certificate_chain(&primary, &accounts, round, &mut rng); // Create a valid proposal. - let timestamp = now(); + let timestamp = now() + MAX_BATCH_DELAY_IN_SECS as i64; let proposal = create_test_proposal( primary.gateway.account(), primary.ledger.current_committee().unwrap(), From 58097554296d80417098710f2bb85e609f38794e Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 26 Mar 2024 19:42:48 -0400 Subject: [PATCH 292/551] Add tests for invalid proposal timestamps --- node/bft/src/primary.rs | 72 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index d5687917b2..a23291572d 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -2038,6 +2038,78 @@ mod tests { ); } + #[tokio::test] + async fn test_batch_propose_from_peer_with_invalid_timestamp() { + let round = 2; + let mut rng = TestRng::default(); + let (primary, accounts) = primary_without_handlers(&mut rng).await; + + // Generate certificates. + let previous_certificates = store_certificate_chain(&primary, &accounts, round, &mut rng); + + // Create a valid proposal with an author that isn't the primary. + let peer_account = &accounts[1]; + let peer_ip = peer_account.0; + let invalid_timestamp = now(); // Use a timestamp that is too early. + let proposal = create_test_proposal( + &peer_account.1, + primary.ledger.current_committee().unwrap(), + round, + previous_certificates, + invalid_timestamp, + &mut rng, + ); + + // Make sure the primary is aware of the transmissions in the proposal. + for (transmission_id, transmission) in proposal.transmissions() { + primary.workers[0].process_transmission_from_peer(peer_ip, *transmission_id, transmission.clone()) + } + + // The author must be known to resolver to pass propose checks. + primary.gateway.resolver().insert_peer(peer_ip, peer_ip, peer_account.1.address()); + + // Try to process the batch proposal from the peer, should error. + assert!( + primary.process_batch_propose_from_peer(peer_ip, (*proposal.batch_header()).clone().into()).await.is_err() + ); + } + + #[tokio::test] + async fn test_batch_propose_from_peer_with_past_timestamp() { + let round = 2; + let mut rng = TestRng::default(); + let (primary, accounts) = primary_without_handlers(&mut rng).await; + + // Generate certificates. + let previous_certificates = store_certificate_chain(&primary, &accounts, round, &mut rng); + + // Create a valid proposal with an author that isn't the primary. + let peer_account = &accounts[1]; + let peer_ip = peer_account.0; + let past_timestamp = now() - 5; // Use a timestamp that is in the past. + let proposal = create_test_proposal( + &peer_account.1, + primary.ledger.current_committee().unwrap(), + round, + previous_certificates, + past_timestamp, + &mut rng, + ); + + // Make sure the primary is aware of the transmissions in the proposal. + for (transmission_id, transmission) in proposal.transmissions() { + primary.workers[0].process_transmission_from_peer(peer_ip, *transmission_id, transmission.clone()) + } + + // The author must be known to resolver to pass propose checks. + primary.gateway.resolver().insert_peer(peer_ip, peer_ip, peer_account.1.address()); + + // Try to process the batch proposal from the peer, should error. + assert!( + primary.process_batch_propose_from_peer(peer_ip, (*proposal.batch_header()).clone().into()).await.is_err() + ); + } + #[tokio::test(flavor = "multi_thread")] async fn test_batch_signature_from_peer() { let mut rng = TestRng::default(); From 742c67faa5a085aca27463d0fd35811c38ddba56 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 26 Mar 2024 20:04:56 -0400 Subject: [PATCH 293/551] Add waits in tests --- node/bft/src/primary.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index a23291572d..2d2ad04585 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -1806,6 +1806,9 @@ mod tests { // Fill primary storage. store_certificate_chain(&primary, &accounts, round, &mut rng); + // Sleep for a while to ensure the primary is ready to propose the next round. + tokio::time::sleep(Duration::from_secs(MAX_BATCH_DELAY_IN_SECS + 1)).await; + // Try to propose a batch. There are no transmissions in the workers so the method should // just return without proposing a batch. assert!(primary.propose_batch().await.is_ok()); @@ -1874,6 +1877,9 @@ mod tests { primary.storage.insert_certificate(certificate, transmissions).unwrap(); } + // Sleep for a while to ensure the primary is ready to propose the next round. + tokio::time::sleep(Duration::from_secs(MAX_BATCH_DELAY_IN_SECS + 1)).await; + // Advance to the next round. assert!(primary.storage.increment_to_next_round(round).is_ok()); From 809342c7419c1510d20ba0d0ac4737f0c2774d89 Mon Sep 17 00:00:00 2001 From: Niklas Date: Wed, 27 Mar 2024 09:53:59 +0100 Subject: [PATCH 294/551] docs: validator peer requirements in router tests --- node/router/tests/common/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/router/tests/common/mod.rs b/node/router/tests/common/mod.rs index db65e89b95..8938e5b067 100644 --- a/node/router/tests/common/mod.rs +++ b/node/router/tests/common/mod.rs @@ -111,7 +111,7 @@ pub async fn validator(listening_port: u16, max_peers: u16) -> TestRouter Date: Wed, 27 Mar 2024 11:39:42 -0400 Subject: [PATCH 295/551] expose difficulty metrics in prometheus --- node/consensus/src/lib.rs | 4 ++++ node/metrics/src/names.rs | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 4adc11f29a..c1f1bba26c 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -422,6 +422,8 @@ impl Consensus { let num_sol = next_block.solutions().len(); let num_tx = next_block.transactions().len(); let num_transmissions = num_tx + num_sol; + let proof_target = next_block.header().proof_target(); + let coinbase_target = next_block.header().coinbase_target(); metrics::gauge(metrics::blocks::HEIGHT, next_block.height() as f64); metrics::increment_gauge(metrics::blocks::SOLUTIONS, num_sol as f64); @@ -431,6 +433,8 @@ impl Consensus { metrics::gauge(metrics::consensus::COMMITTED_CERTIFICATES, num_committed_certificates as f64); metrics::histogram(metrics::consensus::CERTIFICATE_COMMIT_LATENCY, elapsed.as_secs_f64()); metrics::histogram(metrics::consensus::BLOCK_LATENCY, block_latency as f64); + metrics::gauge(metrics::blocks::PROOF_TARGET, proof_target as f64); + metrics::gauge(metrics::blocks::COINBASE_TARGET, coinbase_target as f64); } Ok(()) } diff --git a/node/metrics/src/names.rs b/node/metrics/src/names.rs index 7afcc59845..d12f9e23b0 100644 --- a/node/metrics/src/names.rs +++ b/node/metrics/src/names.rs @@ -14,7 +14,7 @@ pub(super) const COUNTER_NAMES: [&str; 1] = [bft::LEADERS_ELECTED]; -pub(super) const GAUGE_NAMES: [&str; 18] = [ +pub(super) const GAUGE_NAMES: [&str; 20] = [ bft::CONNECTED, bft::CONNECTING, bft::LAST_STORED_ROUND, @@ -24,6 +24,8 @@ pub(super) const GAUGE_NAMES: [&str; 18] = [ blocks::SOLUTIONS, blocks::TRANSACTIONS, blocks::TRANSMISSIONS, + blocks::PROOF_TARGET, + blocks::COINBASE_TARGET, consensus::COMMITTED_CERTIFICATES, consensus::LAST_COMMITTED_ROUND, consensus::UNCONFIRMED_SOLUTIONS, @@ -60,6 +62,8 @@ pub mod blocks { pub const TRANSACTIONS: &str = "snarkos_blocks_transactions_total"; pub const TRANSMISSIONS: &str = "snarkos_blocks_transmissions_total"; pub const SOLUTIONS: &str = "snarkos_blocks_solutions_total"; + pub const PROOF_TARGET: &str = "snarkos_blocks_proof_target"; + pub const COINBASE_TARGET: &str = "snarkos_blocks_coinbase_target"; } pub mod consensus { From 0d5ae5c15b86df80aa177823d6ccfb76721a95ce Mon Sep 17 00:00:00 2001 From: miazn Date: Wed, 27 Mar 2024 12:36:23 -0400 Subject: [PATCH 296/551] add cumulative target --- node/consensus/src/lib.rs | 2 ++ node/metrics/src/names.rs | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index c1f1bba26c..f9a247704e 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -424,6 +424,7 @@ impl Consensus { let num_transmissions = num_tx + num_sol; let proof_target = next_block.header().proof_target(); let coinbase_target = next_block.header().coinbase_target(); + let cumulative_proof_target = next_block.header().cumulative_proof_target(); metrics::gauge(metrics::blocks::HEIGHT, next_block.height() as f64); metrics::increment_gauge(metrics::blocks::SOLUTIONS, num_sol as f64); @@ -435,6 +436,7 @@ impl Consensus { metrics::histogram(metrics::consensus::BLOCK_LATENCY, block_latency as f64); metrics::gauge(metrics::blocks::PROOF_TARGET, proof_target as f64); metrics::gauge(metrics::blocks::COINBASE_TARGET, coinbase_target as f64); + metrics::gauge(metrics::blocks::CUMULATIVE_PROOF_TARGET, cumulative_proof_target as f64); } Ok(()) } diff --git a/node/metrics/src/names.rs b/node/metrics/src/names.rs index d12f9e23b0..b69f32895a 100644 --- a/node/metrics/src/names.rs +++ b/node/metrics/src/names.rs @@ -14,7 +14,7 @@ pub(super) const COUNTER_NAMES: [&str; 1] = [bft::LEADERS_ELECTED]; -pub(super) const GAUGE_NAMES: [&str; 20] = [ +pub(super) const GAUGE_NAMES: [&str; 21] = [ bft::CONNECTED, bft::CONNECTING, bft::LAST_STORED_ROUND, @@ -26,6 +26,7 @@ pub(super) const GAUGE_NAMES: [&str; 20] = [ blocks::TRANSMISSIONS, blocks::PROOF_TARGET, blocks::COINBASE_TARGET, + blocks::CUMULATIVE_PROOF_TARGET, consensus::COMMITTED_CERTIFICATES, consensus::LAST_COMMITTED_ROUND, consensus::UNCONFIRMED_SOLUTIONS, @@ -64,6 +65,7 @@ pub mod blocks { pub const SOLUTIONS: &str = "snarkos_blocks_solutions_total"; pub const PROOF_TARGET: &str = "snarkos_blocks_proof_target"; pub const COINBASE_TARGET: &str = "snarkos_blocks_coinbase_target"; + pub const CUMULATIVE_PROOF_TARGET: &str = "snarkos_blocks_cumulative_proof_target"; } pub mod consensus { From 40fca941b5f5c6dec1e273f9c3168ed9e38bfa33 Mon Sep 17 00:00:00 2001 From: miazn Date: Wed, 27 Mar 2024 13:50:34 -0400 Subject: [PATCH 297/551] add to dashboard --- node/metrics/snarkOS-grafana.json | 206 +++++++++++++++++++++++++++++- 1 file changed, 205 insertions(+), 1 deletion(-) diff --git a/node/metrics/snarkOS-grafana.json b/node/metrics/snarkOS-grafana.json index e837e590f7..6199524ae6 100644 --- a/node/metrics/snarkOS-grafana.json +++ b/node/metrics/snarkOS-grafana.json @@ -596,6 +596,210 @@ "title": "TPS", "type": "timeseries" }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 4, + "x": 12, + "y": 17 + }, + "id": 50, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "11.0.0-68643", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "avg(snarkos_blocks_coinbase_target)", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "__auto", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Coinbase Target", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 4, + "x": 16, + "y": 17 + }, + "id": 52, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "11.0.0-68643", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "avg(snarkos_blocks_proof_target)", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "__auto", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Proof Target", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 4, + "x": 20, + "y": 17 + }, + "id": 51, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "11.0.0-68643", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "avg(snarkos_blocks_cumulative_proof_target)", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "__auto", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Cumulative Proof Target", + "type": "stat" + }, { "datasource": { "type": "prometheus", @@ -656,7 +860,7 @@ "h": 8, "w": 12, "x": 12, - "y": 17 + "y": 25 }, "id": 42, "options": { From 12479f149eb3ee80e67e9103ace3b8f4bb9132a4 Mon Sep 17 00:00:00 2001 From: miazn Date: Wed, 27 Mar 2024 14:04:13 -0400 Subject: [PATCH 298/551] change grafana to timeseries --- node/metrics/snarkOS-grafana.json | 201 +++++++++--------------------- 1 file changed, 62 insertions(+), 139 deletions(-) diff --git a/node/metrics/snarkOS-grafana.json b/node/metrics/snarkOS-grafana.json index 6199524ae6..8993aa776d 100644 --- a/node/metrics/snarkOS-grafana.json +++ b/node/metrics/snarkOS-grafana.json @@ -604,7 +604,39 @@ "fieldConfig": { "defaults": { "color": { - "mode": "thresholds" + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } }, "mappings": [], "thresholds": { @@ -613,6 +645,10 @@ { "color": "green", "value": null + }, + { + "color": "red", + "value": 80 } ] } @@ -621,28 +657,24 @@ }, "gridPos": { "h": 8, - "w": 4, + "w": 12, "x": 12, "y": 17 }, - "id": 50, + "id": 53, "options": { - "colorMode": "value", - "graphMode": "none", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true }, - "showPercentChange": false, - "textMode": "auto", - "wideLayout": true + "tooltip": { + "maxHeight": 600, + "mode": "single", + "sort": "none" + } }, - "pluginVersion": "11.0.0-68643", "targets": [ { "datasource": { @@ -651,154 +683,45 @@ }, "disableTextWrap": false, "editorMode": "code", - "expr": "avg(snarkos_blocks_coinbase_target)", + "expr": "max(snarkos_blocks_coinbase_target)", "fullMetaSearch": false, "includeNullMetadata": true, "instant": false, - "legendFormat": "__auto", + "interval": "", + "legendFormat": "Coinbase Target", "range": true, "refId": "A", "useBackend": false - } - ], - "title": "Coinbase Target", - "type": "stat" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - } - ] - } }, - "overrides": [] - }, - "gridPos": { - "h": 8, - "w": 4, - "x": 16, - "y": 17 - }, - "id": 52, - "options": { - "colorMode": "value", - "graphMode": "none", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "showPercentChange": false, - "textMode": "auto", - "wideLayout": true - }, - "pluginVersion": "11.0.0-68643", - "targets": [ { "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" }, - "disableTextWrap": false, "editorMode": "code", - "expr": "avg(snarkos_blocks_proof_target)", - "fullMetaSearch": false, - "includeNullMetadata": true, + "expr": "max(snarkos_blocks_proof_target)", + "hide": false, "instant": false, - "legendFormat": "__auto", + "legendFormat": "Proof Target", "range": true, - "refId": "A", - "useBackend": false - } - ], - "title": "Proof Target", - "type": "stat" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 8, - "w": 4, - "x": 20, - "y": 17 - }, - "id": 51, - "options": { - "colorMode": "value", - "graphMode": "none", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false + "refId": "B" }, - "showPercentChange": false, - "textMode": "auto", - "wideLayout": true - }, - "pluginVersion": "11.0.0-68643", - "targets": [ { "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" }, - "disableTextWrap": false, "editorMode": "code", - "expr": "avg(snarkos_blocks_cumulative_proof_target)", - "fullMetaSearch": false, - "includeNullMetadata": true, + "expr": "max(snarkos_blocks_cumulative_proof_target)", + "hide": false, "instant": false, - "legendFormat": "__auto", + "legendFormat": "Cumulative Proof Target", "range": true, - "refId": "A", - "useBackend": false + "refId": "C" } ], - "title": "Cumulative Proof Target", - "type": "stat" + "title": "Difficulty", + "type": "timeseries" }, { "datasource": { From 37bb04b28d8133f96675bb7f720e856d29180e07 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 27 Mar 2024 15:26:53 -0400 Subject: [PATCH 299/551] Update log messages --- node/bft/src/primary.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 2d2ad04585..b267f4fc36 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -1214,13 +1214,11 @@ impl Primary { Some(certificate) => { // Determine the elapsed time since the previous certificate. let elapsed = timestamp.checked_sub(certificate.timestamp()).ok_or_else(|| { - anyhow!("Proposed batch has a timestamp earlier than the certificate at round {previous_round}") + anyhow!("Timestamp cannot be before the previous certificate at round {previous_round}") })?; // Ensure the elapsed time is within the expected range. match elapsed < MAX_BATCH_DELAY_IN_SECS as i64 { - true => { - bail!("Proposed batch was created too quickly after the certificate at round {previous_round}") - } + true => bail!("Timestamp is too soon after the previous certificate at round {previous_round}"), false => Ok(()), } } From bc6086340a3967ce217c8b09009600ad7c0368cc Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 27 Mar 2024 15:27:12 -0400 Subject: [PATCH 300/551] Use MIN_BATCH_DELAY_IN_SECS --- node/bft/src/lib.rs | 4 ++-- node/bft/src/primary.rs | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/node/bft/src/lib.rs b/node/bft/src/lib.rs index 550fb20232..ff2fe665a5 100644 --- a/node/bft/src/lib.rs +++ b/node/bft/src/lib.rs @@ -49,8 +49,8 @@ pub const MEMORY_POOL_PORT: u16 = 5000; // port /// The maximum number of milliseconds to wait before proposing a batch. pub const MAX_BATCH_DELAY_IN_MS: u64 = 2500; // ms -/// The maximum number of seconds to wait before proposing a batch (rounded down to the nearest second). -pub const MAX_BATCH_DELAY_IN_SECS: u64 = MAX_BATCH_DELAY_IN_MS / 1000; // seconds +/// The minimum number of seconds to wait before proposing a batch. +pub const MIN_BATCH_DELAY_IN_SECS: u64 = 1; // seconds /// The maximum number of milliseconds to wait before timing out on a fetch. pub const MAX_FETCH_TIMEOUT_IN_MS: u64 = 3 * MAX_BATCH_DELAY_IN_MS; // ms /// The maximum number of seconds allowed for the leader to send their certificate. diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index b267f4fc36..8b033fe4a9 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -33,8 +33,8 @@ use crate::{ Transport, Worker, MAX_BATCH_DELAY_IN_MS, - MAX_BATCH_DELAY_IN_SECS, MAX_WORKERS, + MIN_BATCH_DELAY_IN_SECS, PRIMARY_PING_IN_MS, WORKER_PING_IN_MS, }; @@ -1210,14 +1210,14 @@ impl Primary { fn check_proposal_timestamp(&self, previous_round: u64, author: Address, timestamp: i64) -> Result<()> { // Ensure that the primary does not create a new proposal too quickly. match self.storage.get_certificate_for_round_with_author(previous_round, author) { - // Ensure that the previous certificate was created at least `MAX_BATCH_DELAY_IN_SECS` seconds ago. + // Ensure that the previous certificate was created at least `MIN_BATCH_DELAY_IN_MS` seconds ago. Some(certificate) => { // Determine the elapsed time since the previous certificate. let elapsed = timestamp.checked_sub(certificate.timestamp()).ok_or_else(|| { anyhow!("Timestamp cannot be before the previous certificate at round {previous_round}") })?; // Ensure the elapsed time is within the expected range. - match elapsed < MAX_BATCH_DELAY_IN_SECS as i64 { + match elapsed < MIN_BATCH_DELAY_IN_SECS as i64 { true => bail!("Timestamp is too soon after the previous certificate at round {previous_round}"), false => Ok(()), } @@ -1805,7 +1805,7 @@ mod tests { store_certificate_chain(&primary, &accounts, round, &mut rng); // Sleep for a while to ensure the primary is ready to propose the next round. - tokio::time::sleep(Duration::from_secs(MAX_BATCH_DELAY_IN_SECS + 1)).await; + tokio::time::sleep(Duration::from_secs(MIN_BATCH_DELAY_IN_SECS)).await; // Try to propose a batch. There are no transmissions in the workers so the method should // just return without proposing a batch. @@ -1876,7 +1876,7 @@ mod tests { } // Sleep for a while to ensure the primary is ready to propose the next round. - tokio::time::sleep(Duration::from_secs(MAX_BATCH_DELAY_IN_SECS + 1)).await; + tokio::time::sleep(Duration::from_secs(MIN_BATCH_DELAY_IN_SECS)).await; // Advance to the next round. assert!(primary.storage.increment_to_next_round(round).is_ok()); @@ -1903,7 +1903,7 @@ mod tests { let round = 1; let peer_account = &accounts[1]; let peer_ip = peer_account.0; - let timestamp = now() + MAX_BATCH_DELAY_IN_SECS as i64; + let timestamp = now() + MIN_BATCH_DELAY_IN_SECS as i64; let proposal = create_test_proposal( &peer_account.1, primary.ledger.current_committee().unwrap(), @@ -1939,7 +1939,7 @@ mod tests { // Create a valid proposal with an author that isn't the primary. let peer_account = &accounts[1]; let peer_ip = peer_account.0; - let timestamp = now() + MAX_BATCH_DELAY_IN_SECS as i64; + let timestamp = now() + MIN_BATCH_DELAY_IN_SECS as i64; let proposal = create_test_proposal( &peer_account.1, primary.ledger.current_committee().unwrap(), @@ -1970,7 +1970,7 @@ mod tests { let round = 1; let peer_account = &accounts[1]; let peer_ip = peer_account.0; - let timestamp = now() + MAX_BATCH_DELAY_IN_SECS as i64; + let timestamp = now() + MIN_BATCH_DELAY_IN_SECS as i64; let proposal = create_test_proposal( &peer_account.1, primary.ledger.current_committee().unwrap(), @@ -2012,7 +2012,7 @@ mod tests { // Create a valid proposal with an author that isn't the primary. let peer_account = &accounts[1]; let peer_ip = peer_account.0; - let timestamp = now() + MAX_BATCH_DELAY_IN_SECS as i64; + let timestamp = now() + MIN_BATCH_DELAY_IN_SECS as i64; let proposal = create_test_proposal( &peer_account.1, primary.ledger.current_committee().unwrap(), @@ -2122,7 +2122,7 @@ mod tests { // Create a valid proposal. let round = 1; - let timestamp = now() + MAX_BATCH_DELAY_IN_SECS as i64; + let timestamp = now() + MIN_BATCH_DELAY_IN_SECS as i64; let proposal = create_test_proposal( primary.gateway.account(), primary.ledger.current_committee().unwrap(), @@ -2195,7 +2195,7 @@ mod tests { // Create a valid proposal. let round = 1; - let timestamp = now() + MAX_BATCH_DELAY_IN_SECS as i64; + let timestamp = now() + MIN_BATCH_DELAY_IN_SECS as i64; let proposal = create_test_proposal( primary.gateway.account(), primary.ledger.current_committee().unwrap(), @@ -2232,7 +2232,7 @@ mod tests { let previous_certificates = store_certificate_chain(&primary, &accounts, round, &mut rng); // Create a valid proposal. - let timestamp = now() + MAX_BATCH_DELAY_IN_SECS as i64; + let timestamp = now() + MIN_BATCH_DELAY_IN_SECS as i64; let proposal = create_test_proposal( primary.gateway.account(), primary.ledger.current_committee().unwrap(), From 9eb781eba7c26b8f72a8ea9dba1736e8dded3abd Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 27 Mar 2024 19:30:30 -0400 Subject: [PATCH 301/551] Add to check_proposal_timestamp condition --- node/bft/src/primary.rs | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 8b033fe4a9..dbfa65d0dc 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -1208,22 +1208,32 @@ impl Primary { /// Ensure the primary is not creating batch proposals too frequently. /// This checks that the certificate timestamp for the previous round is within the expected range. fn check_proposal_timestamp(&self, previous_round: u64, author: Address, timestamp: i64) -> Result<()> { - // Ensure that the primary does not create a new proposal too quickly. - match self.storage.get_certificate_for_round_with_author(previous_round, author) { + // Retrieve the timestamp of the previous timestamp to check against. + let previous_timestamp = match self.storage.get_certificate_for_round_with_author(previous_round, author) { // Ensure that the previous certificate was created at least `MIN_BATCH_DELAY_IN_MS` seconds ago. - Some(certificate) => { - // Determine the elapsed time since the previous certificate. - let elapsed = timestamp.checked_sub(certificate.timestamp()).ok_or_else(|| { - anyhow!("Timestamp cannot be before the previous certificate at round {previous_round}") - })?; - // Ensure the elapsed time is within the expected range. - match elapsed < MIN_BATCH_DELAY_IN_SECS as i64 { - true => bail!("Timestamp is too soon after the previous certificate at round {previous_round}"), - false => Ok(()), - } - } - // If we do not see a previous certificate for the author, then proceed optimistically. - None => Ok(()), + Some(certificate) => certificate.timestamp(), + // If we do not see a previous certificate for the author, then proceed check against the earliest timestamp in the previous round. + None => match self + .storage + .get_certificates_for_round(previous_round) + .iter() + .map(BatchCertificate::timestamp) + .min() + { + Some(latest_timestamp) => latest_timestamp, + // If there are no certificates in the previous round, then return early. + None => return Ok(()), + }, + }; + + // Determine the elapsed time since the previous timestamp. + let elapsed = timestamp + .checked_sub(previous_timestamp) + .ok_or_else(|| anyhow!("Timestamp cannot be before the previous certificate at round {previous_round}"))?; + // Ensure that the previous certificate was created at least `MIN_BATCH_DELAY_IN_MS` seconds ago. + match elapsed < MIN_BATCH_DELAY_IN_SECS as i64 { + true => bail!("Timestamp is too soon after the previous certificate at round {previous_round}"), + false => Ok(()), } } From 03cc214d349edd6e016147817e6a1a91fe07fbc4 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 29 Mar 2024 13:09:24 -0400 Subject: [PATCH 302/551] Track the latest batch proposal timestamp --- node/bft/src/primary.rs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index dbfa65d0dc..5ecccd2132 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -91,6 +91,8 @@ pub struct Primary { bft_sender: Arc>>, /// The batch proposal, if the primary is currently proposing a batch. proposed_batch: Arc>, + /// The timestamp of the most recent proposed batch. + latest_proposed_batch_timestamp: Arc>, /// The recently-signed batch proposals (a map from the address to the round, batch ID, and signature). signed_proposals: Arc, (u64, Field, Signature)>>>, /// The spawned handles. @@ -125,6 +127,7 @@ impl Primary { workers: Arc::from(vec![]), bft_sender: Default::default(), proposed_batch: Default::default(), + latest_proposed_batch_timestamp: Default::default(), signed_proposals: Default::default(), handles: Default::default(), propose_lock: Default::default(), @@ -505,6 +508,8 @@ impl Primary { let proposal = Proposal::new(committee_lookback, batch_header.clone(), transmissions)?; // Broadcast the batch to all validators for signing. self.gateway.broadcast(Event::BatchPropose(batch_header.into())); + // Set the timestamp of the latest proposed batch. + *self.latest_proposed_batch_timestamp.write() = proposal.timestamp(); // Set the proposed batch. *self.proposed_batch.write() = Some(proposal); Ok(()) @@ -1212,17 +1217,11 @@ impl Primary { let previous_timestamp = match self.storage.get_certificate_for_round_with_author(previous_round, author) { // Ensure that the previous certificate was created at least `MIN_BATCH_DELAY_IN_MS` seconds ago. Some(certificate) => certificate.timestamp(), - // If we do not see a previous certificate for the author, then proceed check against the earliest timestamp in the previous round. - None => match self - .storage - .get_certificates_for_round(previous_round) - .iter() - .map(BatchCertificate::timestamp) - .min() - { - Some(latest_timestamp) => latest_timestamp, - // If there are no certificates in the previous round, then return early. - None => return Ok(()), + None => match self.gateway.account().address() == author { + // If we are the author, then ensure the previous proposal was created at least `MIN_BATCH_DELAY_IN_MS` seconds ago. + true => *self.latest_proposed_batch_timestamp.read(), + // If we do not see a previous certificate for the author, then proceed optimistically. + false => return Ok(()), }, }; From efcb0c0ecaf4efa8afe9a39049ca17ef2331f2cc Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 29 Mar 2024 16:23:26 -0400 Subject: [PATCH 303/551] Update snarkVM rev - 9637993 --- Cargo.lock | 119 +++++++++++++++++++++++++++-------------------------- Cargo.toml | 2 +- 2 files changed, 61 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d2d86d1bb5..adb5ebb3e5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3301,7 +3301,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "anstyle", "anyhow", @@ -3332,7 +3332,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "aleo-std", "anyhow", @@ -3362,7 +3362,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3376,7 +3376,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3387,7 +3387,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3397,7 +3397,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3407,7 +3407,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "indexmap 2.2.5", "itertools 0.11.0", @@ -3425,12 +3425,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3441,7 +3441,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3456,7 +3456,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3471,7 +3471,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3484,7 +3484,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3493,7 +3493,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3503,7 +3503,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3515,7 +3515,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3527,7 +3527,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3538,7 +3538,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3550,7 +3550,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3563,7 +3563,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "bs58", "snarkvm-console-network", @@ -3574,7 +3574,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "blake2s_simd", "smallvec", @@ -3587,7 +3587,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "aleo-std", "rayon", @@ -3598,7 +3598,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "anyhow", "indexmap 2.2.5", @@ -3621,7 +3621,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "anyhow", "bech32", @@ -3639,7 +3639,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "enum_index", "enum_index_derive", @@ -3660,7 +3660,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3675,7 +3675,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3686,7 +3686,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "snarkvm-console-network-environment", ] @@ -3694,7 +3694,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3704,7 +3704,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3715,7 +3715,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3726,7 +3726,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3737,7 +3737,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3748,7 +3748,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "rand", "rayon", @@ -3762,7 +3762,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "aleo-std", "anyhow", @@ -3779,7 +3779,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "aleo-std", "anyhow", @@ -3804,7 +3804,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "anyhow", "rand", @@ -3816,7 +3816,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3835,7 +3835,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "anyhow", "indexmap 2.2.5", @@ -3854,7 +3854,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -3867,7 +3867,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3880,7 +3880,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3893,7 +3893,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "bytes", "serde_json", @@ -3904,7 +3904,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3919,7 +3919,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "bytes", "serde_json", @@ -3932,7 +3932,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "snarkvm-console", "snarkvm-ledger-puzzle", @@ -3941,7 +3941,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "aleo-std", "anyhow", @@ -3961,7 +3961,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle-epoch" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "anyhow", "colored", @@ -3976,7 +3976,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "async-trait", "reqwest", @@ -3989,7 +3989,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "aleo-std-storage", "anyhow", @@ -4015,7 +4015,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4030,7 +4030,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4039,7 +4039,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "aleo-std", "anyhow", @@ -4064,7 +4064,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "aleo-std", "anyhow", @@ -4086,13 +4086,14 @@ dependencies = [ "snarkvm-synthesizer-process", "snarkvm-synthesizer-program", "snarkvm-synthesizer-snark", + "snarkvm-utilities", "tracing", ] [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "aleo-std", "colored", @@ -4115,7 +4116,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "indexmap 2.2.5", "paste", @@ -4129,7 +4130,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "bincode", "once_cell", @@ -4142,7 +4143,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "aleo-std", "anyhow", @@ -4163,7 +4164,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" dependencies = [ "proc-macro2", "quote 1.0.35", diff --git a/Cargo.toml b/Cargo.toml index 64d09eb9b1..0f36046755 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "0029b6a" +rev = "9637993" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From 5e001d16b4599e4c757af573148a1a27be0aec00 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 29 Mar 2024 17:13:25 -0400 Subject: [PATCH 304/551] Use TestnetV0 network --- cli/src/commands/start.rs | 11 ++++++++++- devnet.sh | 10 +++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index dbe2bd14bf..583f8a2979 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -19,7 +19,7 @@ use snarkvm::{ console::{ account::{Address, PrivateKey}, algorithms::Hash, - network::{MainnetV0, Network}, + network::{MainnetV0, Network, TestnetV0}, }, ledger::{ block::Block, @@ -174,6 +174,15 @@ impl Start { Display::start(node, log_receiver).expect("Failed to initialize the display"); } } + 1 => { + // Parse the node from the configurations. + let node = cli.parse_node::().await.expect("Failed to parse the node"); + // If the display is enabled, render the display. + if !cli.nodisplay { + // Initialize the display. + Display::start(node, log_receiver).expect("Failed to initialize the display"); + } + } _ => panic!("Invalid network ID specified"), }; // Note: Do not move this. The pending await must be here otherwise diff --git a/devnet.sh b/devnet.sh index 20575df593..d1bd3cf6d6 100755 --- a/devnet.sh +++ b/devnet.sh @@ -8,6 +8,10 @@ total_validators=${total_validators:-4} read -p "Enter the total number of clients (default: 2): " total_clients total_clients=${total_clients:-2} +# Read the network ID from user or use a default value of 1 +read -p "Enter the network ID (mainnet = 0, testnet = 1) (default: 1): " network_id +network_id=${network_id:-1} + # Ask the user if they want to run 'cargo install --locked --path .' or use a pre-installed binary read -p "Do you want to run 'cargo install --locked --path .' to build the binary? (y/n, default: y): " build_binary build_binary=${build_binary:-y} @@ -64,12 +68,12 @@ for validator_index in "${validator_indices[@]}"; do # Send the command to start the validator to the new window and capture output to the log file if [ "$validator_index" -eq 0 ]; then - tmux send-keys -t "devnet:window$validator_index" "snarkos start --nodisplay --dev $validator_index --allow-external-peers --dev-num-validators $total_validators --validator --logfile $log_file --metrics" C-m + tmux send-keys -t "devnet:window$validator_index" "snarkos start --nodisplay --network $network_id --dev $validator_index --allow-external-peers --dev-num-validators $total_validators --validator --logfile $log_file --metrics" C-m else # Create a new window with a unique name window_index=$((validator_index + index_offset)) tmux new-window -t "devnet:$window_index" -n "window$validator_index" - tmux send-keys -t "devnet:window$validator_index" "snarkos start --nodisplay --dev $validator_index --allow-external-peers --dev-num-validators $total_validators --validator --logfile $log_file" C-m + tmux send-keys -t "devnet:window$validator_index" "snarkos start --nodisplay --network $network_id --dev $validator_index --allow-external-peers --dev-num-validators $total_validators --validator --logfile $log_file" C-m fi done @@ -87,7 +91,7 @@ for client_index in "${client_indices[@]}"; do tmux new-window -t "devnet:$window_index" -n "window-$window_index" # Send the command to start the validator to the new window and capture output to the log file - tmux send-keys -t "devnet:window-$window_index" "snarkos start --nodisplay --dev $window_index --dev-num-validators $total_validators --client --logfile $log_file" C-m + tmux send-keys -t "devnet:window-$window_index" "snarkos start --nodisplay --network $network_id --dev $window_index --dev-num-validators $total_validators --client --logfile $log_file" C-m done # Attach to the tmux session to view and interact with the windows From 46c6c3acecbab9ced15c934abae8c938c94446b9 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 29 Mar 2024 17:14:05 -0400 Subject: [PATCH 305/551] Use network name in REST routes --- node/rest/src/lib.rs | 83 ++++++++++++++++++++++------------------- node/rest/src/routes.rs | 70 +++++++++++++++++----------------- 2 files changed, 80 insertions(+), 73 deletions(-) diff --git a/node/rest/src/lib.rs b/node/rest/src/lib.rs index 360dc5fd4e..8dfa2dd6ac 100644 --- a/node/rest/src/lib.rs +++ b/node/rest/src/lib.rs @@ -117,71 +117,78 @@ impl, R: Routing> Rest { .expect("Couldn't set up rate limiting for the REST server!"), ); + // Get the network being used. + let network = match N::ID { + snarkvm::console::network::MainnetV0::ID => "mainnet", + snarkvm::console::network::TestnetV0::ID => "testnet", + _ => "mainnet", + }; + let router = { axum::Router::new() // All the endpoints before the call to `route_layer` are protected with JWT auth. - .route("/mainnet/node/address", get(Self::get_node_address)) + .route(&format!("/{network}/node/address"), get(Self::get_node_address)) .route_layer(middleware::from_fn(auth_middleware)) // ----------------- DEPRECATED ROUTES ----------------- // The following `GET ../latest/..` routes will be removed before mainnet. // Please refer to the recommended routes for each endpoint: - // Deprecated: use `/mainnet/block/height/latest` instead. - .route("/mainnet/latest/height", get(Self::latest_height)) - // Deprecated: use `/mainnet/block/hash/latest` instead. - .route("/mainnet/latest/hash", get(Self::latest_hash)) - // Deprecated: use `/mainnet/latest/block/height` instead. - .route("/mainnet/latest/block", get(Self::latest_block)) - // Deprecated: use `/mainnet/stateRoot/latest` instead. - .route("/mainnet/latest/stateRoot", get(Self::latest_state_root)) - // Deprecated: use `/mainnet/committee/latest` instead. - .route("/mainnet/latest/committee", get(Self::latest_committee)) + // Deprecated: use `//block/height/latest` instead. + .route(&format!("/{network}/latest/height"), get(Self::latest_height)) + // Deprecated: use `//block/hash/latest` instead. + .route(&format!("/{network}/latest/hash"), get(Self::latest_hash)) + // Deprecated: use `//latest/block/height` instead. + .route(&format!("/{network}/latest/block"), get(Self::latest_block)) + // Deprecated: use `//stateRoot/latest` instead. + .route(&format!("/{network}/latest/stateRoot"), get(Self::latest_state_root)) + // Deprecated: use `//committee/latest` instead. + .route(&format!("/{network}/latest/committee"), get(Self::latest_committee)) // ------------------------------------------------------ // GET ../block/.. - .route("/mainnet/block/height/latest", get(Self::get_block_height_latest)) - .route("/mainnet/block/hash/latest", get(Self::get_block_hash_latest)) - .route("/mainnet/block/latest", get(Self::get_block_latest)) - .route("/mainnet/block/:height_or_hash", get(Self::get_block)) + .route(&format!("/{network}/block/height/latest"), get(Self::get_block_height_latest)) + .route(&format!("/{network}/block/hash/latest"), get(Self::get_block_hash_latest)) + .route(&format!("/{network}/block/latest"), get(Self::get_block_latest)) + .route(&format!("/{network}/block/:height_or_hash"), get(Self::get_block)) // The path param here is actually only the height, but the name must match the route // above, otherwise there'll be a conflict at runtime. - .route("/mainnet/block/:height_or_hash/transactions", get(Self::get_block_transactions)) + .route(&format!("/{network}/block/:height_or_hash/transactions"), get(Self::get_block_transactions)) // GET and POST ../transaction/.. - .route("/mainnet/transaction/:id", get(Self::get_transaction)) - .route("/mainnet/transaction/confirmed/:id", get(Self::get_confirmed_transaction)) - .route("/mainnet/transaction/broadcast", post(Self::transaction_broadcast)) + .route(&format!("/{network}/transaction/:id"), get(Self::get_transaction)) + .route(&format!("/{network}/transaction/confirmed/:id"), get(Self::get_confirmed_transaction)) + .route(&format!("/{network}/transaction/broadcast"), post(Self::transaction_broadcast)) // POST ../solution/broadcast - .route("/mainnet/solution/broadcast", post(Self::solution_broadcast)) + .route(&format!("/{network}/solution/broadcast"), post(Self::solution_broadcast)) // GET ../find/.. - .route("/mainnet/find/blockHash/:tx_id", get(Self::find_block_hash)) - .route("/mainnet/find/transactionID/deployment/:program_id", get(Self::find_transaction_id_from_program_id)) - .route("/mainnet/find/transactionID/:transition_id", get(Self::find_transaction_id_from_transition_id)) - .route("/mainnet/find/transitionID/:input_or_output_id", get(Self::find_transition_id)) + .route(&format!("/{network}/find/blockHash/:tx_id"), get(Self::find_block_hash)) + .route(&format!("/{network}/find/transactionID/deployment/:program_id"), get(Self::find_transaction_id_from_program_id)) + .route(&format!("/{network}/find/transactionID/:transition_id"), get(Self::find_transaction_id_from_transition_id)) + .route(&format!("/{network}/find/transitionID/:input_or_output_id"), get(Self::find_transition_id)) // GET ../peers/.. - .route("/mainnet/peers/count", get(Self::get_peers_count)) - .route("/mainnet/peers/all", get(Self::get_peers_all)) - .route("/mainnet/peers/all/metrics", get(Self::get_peers_all_metrics)) + .route(&format!("/{network}/peers/count"), get(Self::get_peers_count)) + .route(&format!("/{network}/peers/all"), get(Self::get_peers_all)) + .route(&format!("/{network}/peers/all/metrics"), get(Self::get_peers_all_metrics)) // GET ../program/.. - .route("/mainnet/program/:id", get(Self::get_program)) - .route("/mainnet/program/:id/mappings", get(Self::get_mapping_names)) - .route("/mainnet/program/:id/mapping/:name/:key", get(Self::get_mapping_value)) + .route(&format!("/{network}/program/:id"), get(Self::get_program)) + .route(&format!("/{network}/program/:id/mappings"), get(Self::get_mapping_names)) + .route(&format!("/{network}/program/:id/mapping/:name/:key"), get(Self::get_mapping_value)) // GET misc endpoints. - .route("/mainnet/blocks", get(Self::get_blocks)) - .route("/mainnet/height/:hash", get(Self::get_height)) - .route("/mainnet/memoryPool/transmissions", get(Self::get_memory_pool_transmissions)) - .route("/mainnet/memoryPool/solutions", get(Self::get_memory_pool_solutions)) - .route("/mainnet/memoryPool/transactions", get(Self::get_memory_pool_transactions)) - .route("/mainnet/statePath/:commitment", get(Self::get_state_path_for_commitment)) - .route("/mainnet/stateRoot/latest", get(Self::get_state_root_latest)) - .route("/mainnet/committee/latest", get(Self::get_committee_latest)) + .route(&format!("/{network}/blocks"), get(Self::get_blocks)) + .route(&format!("/{network}/height/:hash"), get(Self::get_height)) + .route(&format!("/{network}/memoryPool/transmissions"), get(Self::get_memory_pool_transmissions)) + .route(&format!("/{network}/memoryPool/solutions"), get(Self::get_memory_pool_solutions)) + .route(&format!("/{network}/memoryPool/transactions"), get(Self::get_memory_pool_transactions)) + .route(&format!("/{network}/statePath/:commitment"), get(Self::get_state_path_for_commitment)) + .route(&format!("/{network}/stateRoot/latest"), get(Self::get_state_root_latest)) + .route(&format!("/{network}/committee/latest"), get(Self::get_committee_latest)) // Pass in `Rest` to make things convenient. .with_state(self.clone()) diff --git a/node/rest/src/routes.rs b/node/rest/src/routes.rs index 27fe8ccb89..c5b6c9e256 100644 --- a/node/rest/src/routes.rs +++ b/node/rest/src/routes.rs @@ -45,54 +45,54 @@ impl, R: Routing> Rest { // Please use the recommended alternatives when implementing new features or refactoring. // Deprecated: Use `get_block_height_latest` instead. - // GET /mainnet/latest/height + // GET //latest/height pub(crate) async fn latest_height(State(rest): State) -> ErasedJson { ErasedJson::pretty(rest.ledger.latest_height()) } // Deprecated: Use `get_block_hash_latest` instead. - // GET /mainnet/latest/hash + // GET //latest/hash pub(crate) async fn latest_hash(State(rest): State) -> ErasedJson { ErasedJson::pretty(rest.ledger.latest_hash()) } // Deprecated: Use `get_block_latest` instead. - // GET /mainnet/latest/block + // GET //latest/block pub(crate) async fn latest_block(State(rest): State) -> ErasedJson { ErasedJson::pretty(rest.ledger.latest_block()) } // Deprecated: Use `get_state_root_latest` instead. - // GET /mainnet/latest/stateRoot + // GET //latest/stateRoot pub(crate) async fn latest_state_root(State(rest): State) -> ErasedJson { ErasedJson::pretty(rest.ledger.latest_state_root()) } // Deprecated: Use `get_committee_latest` instead. - // GET /mainnet/latest/committee + // GET //latest/committee pub(crate) async fn latest_committee(State(rest): State) -> Result { Ok(ErasedJson::pretty(rest.ledger.latest_committee()?)) } // --------------------------------------------------------- - // GET /mainnet/block/height/latest + // GET //block/height/latest pub(crate) async fn get_block_height_latest(State(rest): State) -> ErasedJson { ErasedJson::pretty(rest.ledger.latest_height()) } - // GET /mainnet/block/hash/latest + // GET //block/hash/latest pub(crate) async fn get_block_hash_latest(State(rest): State) -> ErasedJson { ErasedJson::pretty(rest.ledger.latest_hash()) } - // GET /mainnet/block/latest + // GET //block/latest pub(crate) async fn get_block_latest(State(rest): State) -> ErasedJson { ErasedJson::pretty(rest.ledger.latest_block()) } - // GET /mainnet/block/{height} - // GET /mainnet/block/{blockHash} + // GET //block/{height} + // GET //block/{blockHash} pub(crate) async fn get_block( State(rest): State, Path(height_or_hash): Path, @@ -112,7 +112,7 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(block)) } - // GET /mainnet/blocks?start={start_height}&end={end_height} + // GET //blocks?start={start_height}&end={end_height} pub(crate) async fn get_blocks( State(rest): State, Query(block_range): Query, @@ -142,7 +142,7 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(blocks)) } - // GET /mainnet/height/{blockHash} + // GET //height/{blockHash} pub(crate) async fn get_height( State(rest): State, Path(hash): Path, @@ -150,7 +150,7 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(rest.ledger.get_height(&hash)?)) } - // GET /mainnet/block/{height}/transactions + // GET //block/{height}/transactions pub(crate) async fn get_block_transactions( State(rest): State, Path(height): Path, @@ -158,7 +158,7 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(rest.ledger.get_transactions(height)?)) } - // GET /mainnet/transaction/{transactionID} + // GET //transaction/{transactionID} pub(crate) async fn get_transaction( State(rest): State, Path(tx_id): Path, @@ -166,7 +166,7 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(rest.ledger.get_transaction(tx_id)?)) } - // GET /mainnet/transaction/confirmed/{transactionID} + // GET //transaction/confirmed/{transactionID} pub(crate) async fn get_confirmed_transaction( State(rest): State, Path(tx_id): Path, @@ -174,7 +174,7 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(rest.ledger.get_confirmed_transaction(tx_id)?)) } - // GET /mainnet/memoryPool/transmissions + // GET //memoryPool/transmissions pub(crate) async fn get_memory_pool_transmissions(State(rest): State) -> Result { match rest.consensus { Some(consensus) => { @@ -184,7 +184,7 @@ impl, R: Routing> Rest { } } - // GET /mainnet/memoryPool/solutions + // GET //memoryPool/solutions pub(crate) async fn get_memory_pool_solutions(State(rest): State) -> Result { match rest.consensus { Some(consensus) => Ok(ErasedJson::pretty(consensus.unconfirmed_solutions().collect::>())), @@ -192,7 +192,7 @@ impl, R: Routing> Rest { } } - // GET /mainnet/memoryPool/transactions + // GET //memoryPool/transactions pub(crate) async fn get_memory_pool_transactions(State(rest): State) -> Result { match rest.consensus { Some(consensus) => Ok(ErasedJson::pretty(consensus.unconfirmed_transactions().collect::>())), @@ -200,7 +200,7 @@ impl, R: Routing> Rest { } } - // GET /mainnet/program/{programID} + // GET //program/{programID} pub(crate) async fn get_program( State(rest): State, Path(id): Path>, @@ -208,7 +208,7 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(rest.ledger.get_program(id)?)) } - // GET /mainnet/program/{programID}/mappings + // GET //program/{programID}/mappings pub(crate) async fn get_mapping_names( State(rest): State, Path(id): Path>, @@ -216,8 +216,8 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(rest.ledger.vm().finalize_store().get_mapping_names_confirmed(&id)?)) } - // GET /mainnet/program/{programID}/mapping/{mappingName}/{mappingKey} - // GET /mainnet/program/{programID}/mapping/{mappingName}/{mappingKey}?metadata={true} + // GET //program/{programID}/mapping/{mappingName}/{mappingKey} + // GET //program/{programID}/mapping/{mappingName}/{mappingKey}?metadata={true} pub(crate) async fn get_mapping_value( State(rest): State, Path((id, name, key)): Path<(ProgramID, Identifier, Plaintext)>, @@ -238,7 +238,7 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(mapping_value)) } - // GET /mainnet/statePath/{commitment} + // GET //statePath/{commitment} pub(crate) async fn get_state_path_for_commitment( State(rest): State, Path(commitment): Path>, @@ -246,37 +246,37 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(rest.ledger.get_state_path_for_commitment(&commitment)?)) } - // GET /mainnet/stateRoot/latest + // GET //stateRoot/latest pub(crate) async fn get_state_root_latest(State(rest): State) -> ErasedJson { ErasedJson::pretty(rest.ledger.latest_state_root()) } - // GET /mainnet/committee/latest + // GET //committee/latest pub(crate) async fn get_committee_latest(State(rest): State) -> Result { Ok(ErasedJson::pretty(rest.ledger.latest_committee()?)) } - // GET /mainnet/peers/count + // GET //peers/count pub(crate) async fn get_peers_count(State(rest): State) -> ErasedJson { ErasedJson::pretty(rest.routing.router().number_of_connected_peers()) } - // GET /mainnet/peers/all + // GET //peers/all pub(crate) async fn get_peers_all(State(rest): State) -> ErasedJson { ErasedJson::pretty(rest.routing.router().connected_peers()) } - // GET /mainnet/peers/all/metrics + // GET //peers/all/metrics pub(crate) async fn get_peers_all_metrics(State(rest): State) -> ErasedJson { ErasedJson::pretty(rest.routing.router().connected_metrics()) } - // GET /mainnet/node/address + // GET //node/address pub(crate) async fn get_node_address(State(rest): State) -> ErasedJson { ErasedJson::pretty(rest.routing.router().address()) } - // GET /mainnet/find/blockHash/{transactionID} + // GET //find/blockHash/{transactionID} pub(crate) async fn find_block_hash( State(rest): State, Path(tx_id): Path, @@ -284,7 +284,7 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(rest.ledger.find_block_hash(&tx_id)?)) } - // GET /mainnet/find/transactionID/deployment/{programID} + // GET //find/transactionID/deployment/{programID} pub(crate) async fn find_transaction_id_from_program_id( State(rest): State, Path(program_id): Path>, @@ -292,7 +292,7 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(rest.ledger.find_transaction_id_from_program_id(&program_id)?)) } - // GET /mainnet/find/transactionID/{transitionID} + // GET //find/transactionID/{transitionID} pub(crate) async fn find_transaction_id_from_transition_id( State(rest): State, Path(transition_id): Path, @@ -300,7 +300,7 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(rest.ledger.find_transaction_id_from_transition_id(&transition_id)?)) } - // GET /mainnet/find/transitionID/{inputOrOutputID} + // GET //find/transitionID/{inputOrOutputID} pub(crate) async fn find_transition_id( State(rest): State, Path(input_or_output_id): Path>, @@ -308,7 +308,7 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(rest.ledger.find_transition_id(&input_or_output_id)?)) } - // POST /mainnet/transaction/broadcast + // POST //transaction/broadcast pub(crate) async fn transaction_broadcast( State(rest): State, Json(tx): Json>, @@ -332,7 +332,7 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(tx_id)) } - // POST /mainnet/solution/broadcast + // POST //solution/broadcast pub(crate) async fn solution_broadcast( State(rest): State, Json(solution): Json>, From 45cc0b7a0a87f9e9536484802a259e54214777f3 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 29 Mar 2024 17:20:42 -0400 Subject: [PATCH 306/551] Use network ID in preimage of aleo.dev.block --- cli/src/commands/start.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index 583f8a2979..b116e20f34 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -623,6 +623,9 @@ fn load_or_compute_genesis( ) -> Result> { // Construct the preimage. let mut preimage = Vec::new(); + + // Input the network ID. + preimage.extend(&N::ID.to_le_bytes()); // Input the genesis private key, committee, and public balances. preimage.extend(genesis_private_key.to_bytes_le()?); From 86534ffeb78bc987b5c0ff9aa8e64c046fdcbae2 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 29 Mar 2024 21:09:50 -0400 Subject: [PATCH 307/551] Update snarkVM rev - d233d20 --- Cargo.lock | 118 +++++++++++++++++++------------------- Cargo.toml | 2 +- cli/src/commands/start.rs | 2 +- 3 files changed, 61 insertions(+), 61 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index adb5ebb3e5..e777ed04cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3301,7 +3301,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "anstyle", "anyhow", @@ -3332,7 +3332,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "aleo-std", "anyhow", @@ -3362,7 +3362,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3376,7 +3376,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3387,7 +3387,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3397,7 +3397,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3407,7 +3407,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "indexmap 2.2.5", "itertools 0.11.0", @@ -3425,12 +3425,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3441,7 +3441,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3456,7 +3456,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3471,7 +3471,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3484,7 +3484,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3493,7 +3493,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3503,7 +3503,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3515,7 +3515,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3527,7 +3527,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3538,7 +3538,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3550,7 +3550,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3563,7 +3563,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "bs58", "snarkvm-console-network", @@ -3574,7 +3574,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "blake2s_simd", "smallvec", @@ -3587,7 +3587,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "aleo-std", "rayon", @@ -3598,7 +3598,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "anyhow", "indexmap 2.2.5", @@ -3621,7 +3621,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "anyhow", "bech32", @@ -3639,7 +3639,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "enum_index", "enum_index_derive", @@ -3660,7 +3660,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3675,7 +3675,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3686,7 +3686,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "snarkvm-console-network-environment", ] @@ -3694,7 +3694,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3704,7 +3704,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3715,7 +3715,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3726,7 +3726,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3737,7 +3737,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3748,7 +3748,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "rand", "rayon", @@ -3762,7 +3762,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "aleo-std", "anyhow", @@ -3779,7 +3779,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "aleo-std", "anyhow", @@ -3804,7 +3804,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "anyhow", "rand", @@ -3816,7 +3816,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3835,7 +3835,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "anyhow", "indexmap 2.2.5", @@ -3854,7 +3854,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -3867,7 +3867,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3880,7 +3880,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3893,7 +3893,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "bytes", "serde_json", @@ -3904,7 +3904,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3919,7 +3919,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "bytes", "serde_json", @@ -3932,7 +3932,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "snarkvm-console", "snarkvm-ledger-puzzle", @@ -3941,7 +3941,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "aleo-std", "anyhow", @@ -3961,7 +3961,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle-epoch" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "anyhow", "colored", @@ -3976,7 +3976,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "async-trait", "reqwest", @@ -3989,7 +3989,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "aleo-std-storage", "anyhow", @@ -4015,7 +4015,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4030,7 +4030,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4039,7 +4039,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "aleo-std", "anyhow", @@ -4064,7 +4064,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "aleo-std", "anyhow", @@ -4093,7 +4093,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "aleo-std", "colored", @@ -4116,7 +4116,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "indexmap 2.2.5", "paste", @@ -4130,7 +4130,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "bincode", "once_cell", @@ -4143,7 +4143,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "aleo-std", "anyhow", @@ -4164,7 +4164,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=cc45812#cc45812355dae15452054fb67fe3d000e5e2aa96" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d233d20#d233d2018d107bf1261674031b86c577659d0eb7" dependencies = [ "proc-macro2", "quote 1.0.35", diff --git a/Cargo.toml b/Cargo.toml index 0f36046755..37b7763fd5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "9637993" +rev = "d233d20" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index b116e20f34..fd5d315aa6 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -623,7 +623,7 @@ fn load_or_compute_genesis( ) -> Result> { // Construct the preimage. let mut preimage = Vec::new(); - + // Input the network ID. preimage.extend(&N::ID.to_le_bytes()); From f654dae1efa4a0862944fa4935655901a8c77259 Mon Sep 17 00:00:00 2001 From: Victor Sint Nicolaas Date: Mon, 1 Apr 2024 19:45:24 +0200 Subject: [PATCH 308/551] Ensure validator accepts connections from validators --- node/router/src/handshake.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/node/router/src/handshake.rs b/node/router/src/handshake.rs index 57198692d4..92b8f8462e 100644 --- a/node/router/src/handshake.rs +++ b/node/router/src/handshake.rs @@ -17,6 +17,7 @@ use crate::{ Peer, Router, }; +use snarkos_node_router_messages::NodeType; use snarkos_node_tcp::{ConnectionSide, Tcp, P2P}; use snarkvm::{ ledger::narwhal::Data, @@ -202,7 +203,7 @@ impl Router { let peer_ip = peer_ip.unwrap(); // Knowing the peer's listening address, ensure it is allowed to connect. - if let Err(forbidden_message) = self.ensure_peer_is_allowed(peer_ip) { + if let Err(forbidden_message) = self.ensure_peer_is_allowed(peer_ip, peer_request.node_type) { return Err(error(format!("{forbidden_message}"))); } // Verify the challenge request. If a disconnect reason was returned, send the disconnect message and abort. @@ -251,7 +252,7 @@ impl Router { } /// Ensure the peer is allowed to connect. - fn ensure_peer_is_allowed(&self, peer_ip: SocketAddr) -> Result<()> { + fn ensure_peer_is_allowed(&self, peer_ip: SocketAddr, node_type: NodeType) -> Result<()> { // Ensure the peer IP is not this node. if self.is_local_ip(&peer_ip) { bail!("Dropping connection request from '{peer_ip}' (attempted to self-connect)") @@ -265,7 +266,7 @@ impl Router { bail!("Dropping connection request from '{peer_ip}' (already connected)") } // Only allow trusted peers to connect if allow_external_peers is set - if !self.allow_external_peers() && !self.is_trusted(&peer_ip) { + if !node_type.is_validator() && !self.allow_external_peers() && !self.is_trusted(&peer_ip) { bail!("Dropping connection request from '{peer_ip}' (untrusted)") } // Ensure the peer is not restricted. From 9c03d9f367bcdff2a6475dcfbce7090f20b07202 Mon Sep 17 00:00:00 2001 From: Victor Sint Nicolaas Date: Mon, 1 Apr 2024 20:05:06 +0200 Subject: [PATCH 309/551] Add unit test asserting validator connection --- node/router/tests/cleanups.rs | 2 +- node/router/tests/common/mod.rs | 4 +-- node/router/tests/connect.rs | 43 ++++++++++++++++++++++++++++++--- node/router/tests/disconnect.rs | 4 +-- 4 files changed, 45 insertions(+), 8 deletions(-) diff --git a/node/router/tests/cleanups.rs b/node/router/tests/cleanups.rs index 587b0db2ff..ab8507dec8 100644 --- a/node/router/tests/cleanups.rs +++ b/node/router/tests/cleanups.rs @@ -43,7 +43,7 @@ async fn test_connection_cleanups() { let node = match rng.gen_range(0..3) % 3 { 0 => client(0, 1).await, 1 => prover(0, 1).await, - 2 => validator(0, 1).await, + 2 => validator(0, 1, true).await, _ => unreachable!(), }; diff --git a/node/router/tests/common/mod.rs b/node/router/tests/common/mod.rs index 8938e5b067..73d3f5e774 100644 --- a/node/router/tests/common/mod.rs +++ b/node/router/tests/common/mod.rs @@ -104,14 +104,14 @@ pub async fn prover(listening_port: u16, max_peers: u16) -> TestRouter TestRouter { +pub async fn validator(listening_port: u16, max_peers: u16, allow_external_peers: bool) -> TestRouter { Router::new( SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), listening_port), NodeType::Validator, sample_account(), &[], max_peers, - true, // Router tests require validators to connect to peers. + allow_external_peers, true, ) .await diff --git a/node/router/tests/connect.rs b/node/router/tests/connect.rs index 8264ab93d2..e1fa935d54 100644 --- a/node/router/tests/connect.rs +++ b/node/router/tests/connect.rs @@ -22,7 +22,7 @@ use core::time::Duration; #[tokio::test] async fn test_connect_without_handshake() { // Create 2 routers. - let node0 = validator(0, 2).await; + let node0 = validator(0, 2, true).await; let node1 = client(0, 2).await; assert_eq!(node0.number_of_connected_peers(), 0); assert_eq!(node1.number_of_connected_peers(), 0); @@ -78,7 +78,7 @@ async fn test_connect_without_handshake() { #[tokio::test] async fn test_connect_with_handshake() { // Create 2 routers. - let node0 = validator(0, 2).await; + let node0 = validator(0, 2, true).await; let node1 = client(0, 2).await; assert_eq!(node0.number_of_connected_peers(), 0); assert_eq!(node1.number_of_connected_peers(), 0); @@ -150,11 +150,48 @@ async fn test_connect_with_handshake() { } } +#[tokio::test] +async fn test_validator_connection() { + // Create 2 routers. + let node0 = validator(0, 2, false).await; + let node1 = validator(0, 2, false).await; + assert_eq!(node0.number_of_connected_peers(), 0); + assert_eq!(node1.number_of_connected_peers(), 0); + + // Enable handshake protocol. + node0.enable_handshake().await; + node1.enable_handshake().await; + + // Start listening. + node0.tcp().enable_listener().await.unwrap(); + node1.tcp().enable_listener().await.unwrap(); + + { + // Connect node0 to node1. + node0.connect(node1.local_ip()); + // Sleep briefly. + tokio::time::sleep(Duration::from_millis(200)).await; + + print_tcp!(node0); + print_tcp!(node1); + + // Check the TCP level. + assert_eq!(node0.tcp().num_connected(), 1); + assert_eq!(node0.tcp().num_connecting(), 0); + assert_eq!(node1.tcp().num_connected(), 1); + assert_eq!(node1.tcp().num_connecting(), 0); + + // Check the router level. + assert_eq!(node0.number_of_connected_peers(), 1); + assert_eq!(node1.number_of_connected_peers(), 1); + } +} + #[ignore] #[tokio::test] async fn test_connect_simultaneously_with_handshake() { // Create 2 routers. - let node0 = validator(0, 2).await; + let node0 = validator(0, 2, true).await; let node1 = client(0, 2).await; assert_eq!(node0.number_of_connected_peers(), 0); assert_eq!(node1.number_of_connected_peers(), 0); diff --git a/node/router/tests/disconnect.rs b/node/router/tests/disconnect.rs index bbcb6c8e33..3d27583e02 100644 --- a/node/router/tests/disconnect.rs +++ b/node/router/tests/disconnect.rs @@ -22,7 +22,7 @@ use core::time::Duration; #[tokio::test] async fn test_disconnect_without_handshake() { // Create 2 routers. - let node0 = validator(0, 1).await; + let node0 = validator(0, 1, true).await; let node1 = client(0, 1).await; assert_eq!(node0.number_of_connected_peers(), 0); assert_eq!(node1.number_of_connected_peers(), 0); @@ -64,7 +64,7 @@ async fn test_disconnect_without_handshake() { #[tokio::test] async fn test_disconnect_with_handshake() { // Create 2 routers. - let node0 = validator(0, 1).await; + let node0 = validator(0, 1, true).await; let node1 = client(0, 1).await; assert_eq!(node0.number_of_connected_peers(), 0); assert_eq!(node1.number_of_connected_peers(), 0); From b194c02d383ef35b87d360340adcd3800694c484 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 1 Apr 2024 18:04:12 -0400 Subject: [PATCH 310/551] Update Account cli to have optional networks --- cli/src/commands/account.rs | 138 ++++++++++++++++++++++++------------ 1 file changed, 94 insertions(+), 44 deletions(-) diff --git a/cli/src/commands/account.rs b/cli/src/commands/account.rs index 9eefac3a4f..04c9251ebd 100644 --- a/cli/src/commands/account.rs +++ b/cli/src/commands/account.rs @@ -15,6 +15,7 @@ use snarkvm::{ console::{ account::{Address, PrivateKey, Signature}, + network::{MainnetV0, Network, TestnetV0}, prelude::{Environment, Uniform}, program::{ToFields, Value}, types::Field, @@ -36,13 +37,14 @@ use std::{ }; use zeroize::Zeroize; -type Network = snarkvm::prelude::MainnetV0; - /// Commands to manage Aleo accounts. #[derive(Debug, Parser, Zeroize)] pub enum Account { /// Generates a new Aleo account New { + /// Specify the network of the account + #[clap(default_value = "0", long = "network")] + network: u16, /// Seed the RNG with a numeric value #[clap(short = 's', long)] seed: Option, @@ -54,6 +56,9 @@ pub enum Account { discreet: bool, }, Sign { + /// Specify the network of the private key to sign with + #[clap(default_value = "0", long = "network")] + network: u16, /// Specify the account private key of the node #[clap(long = "private-key")] private_key: Option, @@ -71,6 +76,9 @@ pub enum Account { raw: bool, }, Verify { + /// Specify the network of the signature to verify + #[clap(default_value = "0", long = "network")] + network: u16, /// Address to use for verification #[clap(short = 'a', long)] address: String, @@ -87,29 +95,35 @@ pub enum Account { } /// Parse a raw Aleo input into fields -fn aleo_literal_to_fields(input: &str) -> Result>> { - Value::::from_str(input)?.to_fields() +fn aleo_literal_to_fields(input: &str) -> Result>> { + Value::::from_str(input)?.to_fields() } impl Account { pub fn parse(self) -> Result { match self { - Self::New { seed, vanity, discreet } => { + Self::New { network, seed, vanity, discreet } => { // Ensure only the seed or the vanity string is specified. if seed.is_some() && vanity.is_some() { bail!("Cannot specify both the '--seed' and '--vanity' flags"); } - // Generate a vanity account. - if let Some(vanity) = vanity { - Self::new_vanity(&vanity, discreet) - } - // Default to generating a normal account, with an optional seed. - else { - Self::new_seeded(seed, discreet) + match vanity { + // Generate a vanity account for the specified network. + Some(vanity) => match network { + 0 => Self::new_vanity::(vanity.as_str(), discreet), + 1 => Self::new_vanity::(vanity.as_str(), discreet), + _ => bail!("Unsupported network ID"), + }, + // Generate a seeded account for the specified network. + None => match network { + 0 => Self::new_seeded::(seed, discreet), + 1 => Self::new_seeded::(seed, discreet), + _ => bail!("Unsupported network ID"), + }, } } - Self::Sign { message, seed, raw, private_key, private_key_file } => { + Self::Sign { network, message, seed, raw, private_key, private_key_file } => { let key = match (private_key, private_key_file) { (Some(private_key), None) => private_key, (None, Some(private_key_file)) => { @@ -121,16 +135,29 @@ impl Account { bail!("Cannot specify both the '--private-key' and '--private-key-file' flags") } }; - Self::sign(key, message, seed, raw) + + // Sign the message for the specified network. + match network { + 0 => Self::sign::(key, message, seed, raw), + 1 => Self::sign::(key, message, seed, raw), + _ => bail!("Unsupported network ID"), + } + } + Self::Verify { network, address, signature, message, raw } => { + // Verify the signature for the specified network. + match network { + 0 => Self::verify::(address, signature, message, raw), + 1 => Self::verify::(address, signature, message, raw), + _ => bail!("Unsupported network ID"), + } } - Self::Verify { address, signature, message, raw } => Self::verify(address, signature, message, raw), } } /// Generates a new Aleo account with the given vanity string. - fn new_vanity(vanity: &str, discreet: bool) -> Result { + fn new_vanity(vanity: &str, discreet: bool) -> Result { // A closure to generate a new Aleo account. - let sample_account = || snarkos_account::Account::::new(&mut rand::thread_rng()); + let sample_account = || snarkos_account::Account::::new(&mut rand::thread_rng()); const ITERATIONS: u128 = u16::MAX as u128; const ITERATIONS_STR: &str = "65,535"; @@ -201,12 +228,12 @@ impl Account { } /// Generates a new Aleo account with an optional seed. - fn new_seeded(seed: Option, discreet: bool) -> Result { + fn new_seeded(seed: Option, discreet: bool) -> Result { // Recover the seed. let seed = match seed { // Recover the field element deterministically. Some(seed) => { - Field::new(::Field::from_str(&seed).map_err(|e| anyhow!("Invalid seed - {e}"))?) + Field::new(::Field::from_str(&seed).map_err(|e| anyhow!("Invalid seed - {e}"))?) } // Sample a random field element. None => Field::rand(&mut ChaChaRng::from_entropy()), @@ -215,7 +242,7 @@ impl Account { let private_key = PrivateKey::try_from(seed).map_err(|_| anyhow!("Failed to convert the seed into a valid private key"))?; // Construct the account. - let account = snarkos_account::Account::::try_from(private_key)?; + let account = snarkos_account::Account::::try_from(private_key)?; // Print the new Aleo account. if !discreet { return Ok(account.to_string()); @@ -236,13 +263,13 @@ impl Account { } // Sign a message with an Aleo private key - fn sign(key: String, message: String, seed: Option, raw: bool) -> Result { + fn sign(key: String, message: String, seed: Option, raw: bool) -> Result { // Recover the seed. let mut rng = match seed { // Recover the field element deterministically. Some(seed) => { - let field: Field<_> = Field::::new( - ::Field::from_str(&seed).map_err(|e| anyhow!("Invalid seed - {e}"))?, + let field: Field<_> = Field::::new( + ::Field::from_str(&seed).map_err(|e| anyhow!("Invalid seed - {e}"))?, ); // field is always 32 bytes @@ -254,13 +281,13 @@ impl Account { // Parse the private key let private_key = - PrivateKey::::from_str(&key).map_err(|_| anyhow!("Failed to parse a valid private key"))?; + PrivateKey::::from_str(&key).map_err(|_| anyhow!("Failed to parse a valid private key"))?; // Sign the message let signature = if raw { private_key.sign_bytes(message.as_bytes(), &mut rng) } else { let fields = - aleo_literal_to_fields(&message).map_err(|_| anyhow!("Failed to parse a valid Aleo literal"))?; + aleo_literal_to_fields::(&message).map_err(|_| anyhow!("Failed to parse a valid Aleo literal"))?; private_key.sign(&fields, &mut rng) } .map_err(|_| anyhow!("Failed to sign the message"))? @@ -270,12 +297,12 @@ impl Account { } // Verify a signature with an Aleo address - fn verify(address: String, signature: String, message: String, raw: bool) -> Result { + fn verify(address: String, signature: String, message: String, raw: bool) -> Result { // Parse the address - let address = Address::::from_str(&address).map_err(|_| anyhow!("Failed to parse a valid address"))?; + let address = Address::::from_str(&address).map_err(|_| anyhow!("Failed to parse a valid address"))?; // Parse the signature let signature = - Signature::::from_str(&signature).map_err(|_| anyhow!("Failed to parse a valid signature"))?; + Signature::::from_str(&signature).map_err(|_| anyhow!("Failed to parse a valid signature"))?; // Verify the signature let verified = if raw { signature.verify_bytes(&address, message.as_bytes()) @@ -323,7 +350,7 @@ mod tests { #[test] fn test_new() { for _ in 0..3 { - let account = Account::New { seed: None, vanity: None, discreet: false }; + let account = Account::New { network: 0, seed: None, vanity: None, discreet: false }; assert!(account.parse().is_ok()); } } @@ -349,7 +376,7 @@ mod tests { ); let vanity = None; - let account = Account::New { seed, vanity, discreet: false }; + let account = Account::New { network: 0, seed, vanity, discreet: false }; let actual = account.parse().unwrap(); assert_eq!(expected, actual); } @@ -375,7 +402,7 @@ mod tests { ); let vanity = None; - let account = Account::New { seed, vanity, discreet: false }; + let account = Account::New { network: 0, seed, vanity, discreet: false }; let actual = account.parse().unwrap(); assert_eq!(expected, actual); } @@ -384,7 +411,14 @@ mod tests { fn test_signature_raw() { let key = "APrivateKey1zkp61PAYmrYEKLtRWeWhUoDpFnGLNuHrCciSqN49T86dw3p".to_string(); let message = "Hello, world!".to_string(); - let account = Account::Sign { private_key: Some(key), private_key_file: None, message, seed: None, raw: true }; + let account = Account::Sign { + network: 0, + private_key: Some(key), + private_key_file: None, + message, + seed: None, + raw: true, + }; assert!(account.parse().is_ok()); } @@ -392,7 +426,14 @@ mod tests { fn test_signature() { let key = "APrivateKey1zkp61PAYmrYEKLtRWeWhUoDpFnGLNuHrCciSqN49T86dw3p".to_string(); let message = "5field".to_string(); - let account = Account::Sign { private_key: Some(key), private_key_file: None, message, seed: None, raw: false }; + let account = Account::Sign { + network: 0, + private_key: Some(key), + private_key_file: None, + message, + seed: None, + raw: false, + }; assert!(account.parse().is_ok()); } @@ -400,7 +441,14 @@ mod tests { fn test_signature_fail() { let key = "APrivateKey1zkp61PAYmrYEKLtRWeWhUoDpFnGLNuHrCciSqN49T86dw3p".to_string(); let message = "not a literal value".to_string(); - let account = Account::Sign { private_key: Some(key), private_key_file: None, message, seed: None, raw: false }; + let account = Account::Sign { + network: 0, + private_key: Some(key), + private_key_file: None, + message, + seed: None, + raw: false, + }; assert!(account.parse().is_err()); } @@ -410,7 +458,8 @@ mod tests { let key = "APrivateKey1zkp61PAYmrYEKLtRWeWhUoDpFnGLNuHrCciSqN49T86dw3p".to_string(); let message = "Hello, world!".to_string(); let expected = "sign1t2hsaqfhcgvsfg2q3q2stxsffyrvdx98pl0ddkdqngqqtn3vsuprhkv9tkeyzs878ccqp62mfptvvp7m5hjcfnf06cc9pu4khxtkkp8esm5elrqqunzqzmac7kzutl6zk7mqht3c0m9kg4hklv7h2js0qmxavwnpuwyl4lzldl6prs4qeqy9wxyp8y44nnydg3h8sg6ue99qkksrwh0"; - let account = Account::Sign { private_key: Some(key), private_key_file: None, message, seed, raw: true }; + let account = + Account::Sign { network: 0, private_key: Some(key), private_key_file: None, message, seed, raw: true }; let actual = account.parse().unwrap(); assert_eq!(expected, actual); } @@ -421,7 +470,8 @@ mod tests { let key = "APrivateKey1zkp61PAYmrYEKLtRWeWhUoDpFnGLNuHrCciSqN49T86dw3p".to_string(); let message = "5field".to_string(); let expected = "sign16f464jk7zrq0az5jne2zvamhlfkksfj23508tqvmj836jpplkuqefcshgk8k8rx9xxu284fuwaua7fcz3jajvnqynwtymfm0p692vq8esm5elrqqunzqzmac7kzutl6zk7mqht3c0m9kg4hklv7h2js0qmxavwnpuwyl4lzldl6prs4qeqy9wxyp8y44nnydg3h8sg6ue99qk3re27j"; - let account = Account::Sign { private_key: Some(key), private_key_file: None, message, seed, raw: false }; + let account = + Account::Sign { network: 0, private_key: Some(key), private_key_file: None, message, seed, raw: false }; let actual = account.parse().unwrap(); assert_eq!(expected, actual); } @@ -432,14 +482,14 @@ mod tests { let address = "aleo1zecnqchckrzw7dlsyf65g6z5le2rmys403ecwmcafrag0e030yxqrnlg8j"; let signature = "sign1nnvrjlksrkxdpwsrw8kztjukzhmuhe5zf3srk38h7g32u4kqtqpxn3j5a6k8zrqcfx580a96956nsjvluzt64cqf54pdka9mgksfqp8esm5elrqqunzqzmac7kzutl6zk7mqht3c0m9kg4hklv7h2js0qmxavwnpuwyl4lzldl6prs4qeqy9wxyp8y44nnydg3h8sg6ue99qkwsnaqq".to_string(); let message = "Hello, world!".to_string(); - let account = Account::Verify { address: address.to_string(), signature, message, raw: true }; + let account = Account::Verify { network: 0, address: address.to_string(), signature, message, raw: true }; let actual = account.parse(); assert!(actual.is_ok()); // test signature of "Hello, world!" against the message "Different Message" let signature = "sign1nnvrjlksrkxdpwsrw8kztjukzhmuhe5zf3srk38h7g32u4kqtqpxn3j5a6k8zrqcfx580a96956nsjvluzt64cqf54pdka9mgksfqp8esm5elrqqunzqzmac7kzutl6zk7mqht3c0m9kg4hklv7h2js0qmxavwnpuwyl4lzldl6prs4qeqy9wxyp8y44nnydg3h8sg6ue99qkwsnaqq".to_string(); let message = "Different Message".to_string(); - let account = Account::Verify { address: address.to_string(), signature, message, raw: true }; + let account = Account::Verify { network: 0, address: address.to_string(), signature, message, raw: true }; let actual = account.parse(); assert!(actual.is_err()); @@ -447,14 +497,14 @@ mod tests { let signature = "sign1nnvrjlksrkxdpwsrw8kztjukzhmuhe5zf3srk38h7g32u4kqtqpxn3j5a6k8zrqcfx580a96956nsjvluzt64cqf54pdka9mgksfqp8esm5elrqqunzqzmac7kzutl6zk7mqht3c0m9kg4hklv7h2js0qmxavwnpuwyl4lzldl6prs4qeqy9wxyp8y44nnydg3h8sg6ue99qkwsnaqq".to_string(); let message = "Hello, world!".to_string(); let wrong_address = "aleo1uxl69laseuv3876ksh8k0nd7tvpgjt6ccrgccedpjk9qwyfensxst9ftg5".to_string(); - let account = Account::Verify { address: wrong_address, signature, message, raw: true }; + let account = Account::Verify { network: 0, address: wrong_address, signature, message, raw: true }; let actual = account.parse(); assert!(actual.is_err()); // test a valid signature of "Different Message" let signature = "sign1424ztyt9hcm77nq450gvdszrvtg9kvhc4qadg4nzy9y0ah7wdqq7t36cxal42p9jj8e8pjpmc06lfev9nvffcpqv0cxwyr0a2j2tjqlesm5elrqqunzqzmac7kzutl6zk7mqht3c0m9kg4hklv7h2js0qmxavwnpuwyl4lzldl6prs4qeqy9wxyp8y44nnydg3h8sg6ue99qk3yrr50".to_string(); let message = "Different Message".to_string(); - let account = Account::Verify { address: address.to_string(), signature, message, raw: true }; + let account = Account::Verify { network: 0, address: address.to_string(), signature, message, raw: true }; let actual = account.parse(); assert!(actual.is_ok()); } @@ -465,14 +515,14 @@ mod tests { let address = "aleo1zecnqchckrzw7dlsyf65g6z5le2rmys403ecwmcafrag0e030yxqrnlg8j"; let signature = "sign1j7swjfnyujt2vme3ulu88wdyh2ddj85arh64qh6c6khvrx8wvsp8z9wtzde0sahqj2qwz8rgzt803c0ceega53l4hks2mf5sfsv36qhesm5elrqqunzqzmac7kzutl6zk7mqht3c0m9kg4hklv7h2js0qmxavwnpuwyl4lzldl6prs4qeqy9wxyp8y44nnydg3h8sg6ue99qkdetews".to_string(); let message = "5field".to_string(); - let account = Account::Verify { address: address.to_string(), signature, message, raw: false }; + let account = Account::Verify { network: 0, address: address.to_string(), signature, message, raw: false }; let actual = account.parse(); assert!(actual.is_ok()); // test signature of 5u8 against the message 10u8 let signature = "sign1j7swjfnyujt2vme3ulu88wdyh2ddj85arh64qh6c6khvrx8wvsp8z9wtzde0sahqj2qwz8rgzt803c0ceega53l4hks2mf5sfsv36qhesm5elrqqunzqzmac7kzutl6zk7mqht3c0m9kg4hklv7h2js0qmxavwnpuwyl4lzldl6prs4qeqy9wxyp8y44nnydg3h8sg6ue99qkdetews".to_string(); let message = "10field".to_string(); - let account = Account::Verify { address: address.to_string(), signature, message, raw: false }; + let account = Account::Verify { network: 0, address: address.to_string(), signature, message, raw: false }; let actual = account.parse(); assert!(actual.is_err()); @@ -480,14 +530,14 @@ mod tests { let signature = "sign1j7swjfnyujt2vme3ulu88wdyh2ddj85arh64qh6c6khvrx8wvsp8z9wtzde0sahqj2qwz8rgzt803c0ceega53l4hks2mf5sfsv36qhesm5elrqqunzqzmac7kzutl6zk7mqht3c0m9kg4hklv7h2js0qmxavwnpuwyl4lzldl6prs4qeqy9wxyp8y44nnydg3h8sg6ue99qkdetews".to_string(); let message = "5field".to_string(); let wrong_address = "aleo1uxl69laseuv3876ksh8k0nd7tvpgjt6ccrgccedpjk9qwyfensxst9ftg5".to_string(); - let account = Account::Verify { address: wrong_address, signature, message, raw: false }; + let account = Account::Verify { network: 0, address: wrong_address, signature, message, raw: false }; let actual = account.parse(); assert!(actual.is_err()); // test a valid signature of 10u8 let signature = "sign1t9v2t5tljk8pr5t6vkcqgkus0a3v69vryxmfrtwrwg0xtj7yv5qj2nz59e5zcyl50w23lhntxvt6vzeqfyu6dt56698zvfj2l6lz6q0esm5elrqqunzqzmac7kzutl6zk7mqht3c0m9kg4hklv7h2js0qmxavwnpuwyl4lzldl6prs4qeqy9wxyp8y44nnydg3h8sg6ue99qk8rh9kt".to_string(); let message = "10field".to_string(); - let account = Account::Verify { address: address.to_string(), signature, message, raw: false }; + let account = Account::Verify { network: 0, address: address.to_string(), signature, message, raw: false }; let actual = account.parse(); assert!(actual.is_ok()); } From 926b5f7619fbc19312e7e62bc70d8e7dec141f27 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 1 Apr 2024 19:21:43 -0400 Subject: [PATCH 311/551] Update Developer cli to have custom networks --- cli/src/commands/developer/decrypt.rs | 30 +++-- cli/src/commands/developer/deploy.rs | 47 +++++--- cli/src/commands/developer/execute.rs | 84 ++++++++------ cli/src/commands/developer/mod.rs | 31 +++-- cli/src/commands/developer/scan.rs | 106 ++++++++++++------ .../commands/developer/transfer_private.rs | 49 +++++--- 6 files changed, 219 insertions(+), 128 deletions(-) diff --git a/cli/src/commands/developer/decrypt.rs b/cli/src/commands/developer/decrypt.rs index ba0e1358a7..c60df49774 100644 --- a/cli/src/commands/developer/decrypt.rs +++ b/cli/src/commands/developer/decrypt.rs @@ -12,9 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -use super::CurrentNetwork; use snarkvm::{ - console::program::Ciphertext, + console::{ + network::{MainnetV0, Network, TestnetV0}, + program::Ciphertext, + }, prelude::{Record, ViewKey}, }; @@ -26,6 +28,9 @@ use zeroize::Zeroize; /// Decrypts a record ciphertext. #[derive(Debug, Parser, Zeroize)] pub struct Decrypt { + /// Specify the network of the ciphertext to decrypt. + #[clap(default_value = "0", long = "network")] + pub network: u16, /// The record ciphertext to decrypt. #[clap(short, long)] pub ciphertext: String, @@ -36,17 +41,21 @@ pub struct Decrypt { impl Decrypt { pub fn parse(self) -> Result { - // Decrypt the ciphertext. - Self::decrypt_ciphertext(&self.ciphertext, &self.view_key) + // Decrypt the ciphertext for the given network. + match self.network { + 0 => Self::decrypt_ciphertext::(&self.ciphertext, &self.view_key), + 1 => Self::decrypt_ciphertext::(&self.ciphertext, &self.view_key), + _ => bail!("Unsupported network ID"), + } } /// Decrypts the ciphertext record with provided the view key. - fn decrypt_ciphertext(ciphertext: &str, view_key: &str) -> Result { + fn decrypt_ciphertext(ciphertext: &str, view_key: &str) -> Result { // Parse the ciphertext record. - let ciphertext_record = Record::>::from_str(ciphertext)?; + let ciphertext_record = Record::>::from_str(ciphertext)?; // Parse the account view key. - let view_key = ViewKey::::from_str(view_key)?; + let view_key = ViewKey::::from_str(view_key)?; match ciphertext_record.decrypt(&view_key) { Ok(plaintext_record) => Ok(plaintext_record.to_string()), @@ -76,6 +85,8 @@ mod tests { ViewKey, }; + type CurrentNetwork = MainnetV0; + const ITERATIONS: usize = 1000; fn construct_ciphertext( @@ -120,7 +131,7 @@ mod tests { // Decrypt the ciphertext. let expected_plaintext = ciphertext.decrypt(&view_key).unwrap(); - let decrypt = Decrypt { ciphertext: ciphertext.to_string(), view_key: view_key.to_string() }; + let decrypt = Decrypt { network: 0, ciphertext: ciphertext.to_string(), view_key: view_key.to_string() }; let plaintext = decrypt.parse().unwrap(); // Check that the decryption is correct. @@ -148,7 +159,8 @@ mod tests { let ciphertext = construct_ciphertext::(view_key, owner, &mut rng).unwrap(); // Enforce that the decryption fails. - let decrypt = Decrypt { ciphertext: ciphertext.to_string(), view_key: incorrect_view_key.to_string() }; + let decrypt = + Decrypt { network: 0, ciphertext: ciphertext.to_string(), view_key: incorrect_view_key.to_string() }; assert!(decrypt.parse().is_err()); } } diff --git a/cli/src/commands/developer/deploy.rs b/cli/src/commands/developer/deploy.rs index 540bbee8ef..3c57e80167 100644 --- a/cli/src/commands/developer/deploy.rs +++ b/cli/src/commands/developer/deploy.rs @@ -12,9 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -use super::{CurrentAleo, CurrentNetwork, Developer}; +use super::Developer; use snarkvm::{ - console::program::ProgramOwner, + circuit::{Aleo, AleoTestnetV0, AleoV0}, + console::{ + network::{MainnetV0, Network, TestnetV0}, + program::ProgramOwner, + }, prelude::{ block::Transaction, deployment_cost, @@ -37,7 +41,10 @@ use zeroize::Zeroize; #[derive(Debug, Parser)] pub struct Deploy { /// The name of the program to deploy. - program_id: ProgramID, + program_id: String, + /// Specify the network to create a deployment for. + #[clap(default_value = "0", long = "network")] + pub network: u16, /// A path to a directory containing a manifest file. Defaults to the current working directory. #[clap(long)] path: Option, @@ -82,19 +89,32 @@ impl Deploy { bail!("❌ Please specify one of the following actions: --broadcast, --dry-run, --store"); } + // Construct the deployment for the specified network. + match self.network { + 0 => self.construct_deployment::(), + 1 => self.construct_deployment::(), + _ => bail!("Unsupported network ID"), + } + } + + /// Construct and process the deployment transaction. + fn construct_deployment>(&self) -> Result { // Specify the query let query = Query::from(&self.query); // Retrieve the private key. let private_key = PrivateKey::from_str(&self.private_key)?; + // Retrieve the program ID. + let program_id = ProgramID::from_str(&self.program_id)?; + // Fetch the package from the directory. - let package = Developer::parse_package(self.program_id, &self.path)?; + let package = Developer::parse_package(program_id, &self.path)?; - println!("📦 Creating deployment transaction for '{}'...\n", &self.program_id.to_string().bold()); + println!("📦 Creating deployment transaction for '{}'...\n", &program_id.to_string().bold()); // Generate the deployment - let deployment = package.deploy::(None)?; + let deployment = package.deploy::(None)?; let deployment_id = deployment.to_deployment_id()?; // Generate the deployment transaction. @@ -107,7 +127,7 @@ impl Deploy { Some(path) => StorageMode::Custom(path.clone()), None => StorageMode::Production, }; - let store = ConsensusStore::>::open(storage_mode)?; + let store = ConsensusStore::>::open(storage_mode)?; // Initialize the VM. let vm = VM::from(store)?; @@ -146,16 +166,10 @@ impl Deploy { // Create a new transaction. Transaction::from_deployment(owner, deployment, fee)? }; - println!("✅ Created deployment transaction for '{}'", self.program_id.to_string().bold()); + println!("✅ Created deployment transaction for '{}'", program_id.to_string().bold()); // Determine if the transaction should be broadcast, stored, or displayed to the user. - Developer::handle_transaction( - &self.broadcast, - self.dry_run, - &self.store, - transaction, - self.program_id.to_string(), - ) + Developer::handle_transaction(&self.broadcast, self.dry_run, &self.store, transaction, program_id.to_string()) } } @@ -183,7 +197,8 @@ mod tests { let cli = CLI::parse_from(arg_vec); if let Command::Developer(Developer::Deploy(deploy)) = cli.command { - assert_eq!(deploy.program_id, "hello.aleo".try_into().unwrap()); + assert_eq!(deploy.network, 0); + assert_eq!(deploy.program_id, "hello.aleo"); assert_eq!(deploy.private_key, "PRIVATE_KEY"); assert_eq!(deploy.query, "QUERY"); assert_eq!(deploy.priority_fee, 77); diff --git a/cli/src/commands/developer/execute.rs b/cli/src/commands/developer/execute.rs index 02688d153a..754d83ffb6 100644 --- a/cli/src/commands/developer/execute.rs +++ b/cli/src/commands/developer/execute.rs @@ -12,18 +12,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -use super::{CurrentNetwork, Developer}; -use snarkvm::prelude::{ - query::Query, - store::{helpers::memory::ConsensusMemory, ConsensusStore}, - Address, - Identifier, - Locator, - PrivateKey, - Process, - ProgramID, - Value, - VM, +use super::Developer; +use snarkvm::{ + console::network::{MainnetV0, Network, TestnetV0}, + prelude::{ + query::Query, + store::{helpers::memory::ConsensusMemory, ConsensusStore}, + Address, + Identifier, + Locator, + PrivateKey, + Process, + ProgramID, + Value, + VM, + }, }; use aleo_std::StorageMode; @@ -37,11 +40,14 @@ use zeroize::Zeroize; #[derive(Debug, Parser)] pub struct Execute { /// The program identifier. - program_id: ProgramID, + program_id: String, /// The function name. - function: Identifier, + function: String, /// The function inputs. - inputs: Vec>, + inputs: Vec, + /// Specify the network to create an execution for. + #[clap(default_value = "0", long = "network")] + pub network: u16, /// The private key used to generate the execution. #[clap(short, long)] private_key: String, @@ -84,13 +90,32 @@ impl Execute { bail!("❌ Please specify one of the following actions: --broadcast, --dry-run, --store"); } + // Construct the execution for the specified network. + match self.network { + 0 => self.construct_execution::(), + 1 => self.construct_execution::(), + _ => bail!("Unsupported network ID"), + } + } + + /// Construct and process the execution transaction. + fn construct_execution(&self) -> Result { // Specify the query let query = Query::from(&self.query); // Retrieve the private key. let private_key = PrivateKey::from_str(&self.private_key)?; - let locator = Locator::::from_str(&format!("{}/{}", self.program_id, self.function))?; + // Retrieve the program ID. + let program_id = ProgramID::from_str(&self.program_id)?; + + // Retrieve the function. + let function = Identifier::from_str(&self.function)?; + + // Retrieve the inputs. + let inputs = self.inputs.iter().map(|input| Value::from_str(input)).collect::>>>()?; + + let locator = Locator::::from_str(&format!("{}/{}", program_id, function))?; println!("📦 Creating execution transaction for '{}'...\n", &locator.to_string().bold()); // Generate the execution transaction. @@ -103,13 +128,13 @@ impl Execute { Some(path) => StorageMode::Custom(path.clone()), None => StorageMode::Production, }; - let store = ConsensusStore::>::open(storage_mode)?; + let store = ConsensusStore::>::open(storage_mode)?; // Initialize the VM. let vm = VM::from(store)?; // Load the program and it's imports into the process. - load_program(&self.query, &mut vm.process().write(), &self.program_id)?; + load_program(&self.query, &mut vm.process().write(), &program_id)?; // Prepare the fee. let fee_record = match &self.record { @@ -119,15 +144,7 @@ impl Execute { let priority_fee = self.priority_fee.unwrap_or(0); // Create a new transaction. - vm.execute( - &private_key, - (self.program_id, self.function), - self.inputs.iter(), - fee_record, - priority_fee, - Some(query), - rng, - )? + vm.execute(&private_key, (program_id, function), inputs.iter(), fee_record, priority_fee, Some(query), rng)? }; // Check if the public balance is sufficient. @@ -165,11 +182,7 @@ impl Execute { } /// A helper function to recursively load the program and all of its imports into the process. -fn load_program( - endpoint: &str, - process: &mut Process, - program_id: &ProgramID, -) -> Result<()> { +fn load_program(endpoint: &str, process: &mut Process, program_id: &ProgramID) -> Result<()> { // Fetch the program. let program = Developer::fetch_program(program_id, endpoint)?; @@ -222,13 +235,14 @@ mod tests { let cli = CLI::parse_from(arg_vec); if let Command::Developer(Developer::Execute(execute)) = cli.command { + assert_eq!(execute.network, 0); assert_eq!(execute.private_key, "PRIVATE_KEY"); assert_eq!(execute.query, "QUERY"); assert_eq!(execute.priority_fee, Some(77)); assert_eq!(execute.record, Some("RECORD".into())); - assert_eq!(execute.program_id, "hello.aleo".try_into().unwrap()); - assert_eq!(execute.function, "hello".try_into().unwrap()); - assert_eq!(execute.inputs, vec!["1u32".try_into().unwrap(), "2u32".try_into().unwrap()]); + assert_eq!(execute.program_id, "hello.aleo".to_string()); + assert_eq!(execute.function, "hello".to_string()); + assert_eq!(execute.inputs, vec!["1u32".to_string(), "2u32".to_string()]); } else { panic!("Unexpected result of clap parsing!"); } diff --git a/cli/src/commands/developer/mod.rs b/cli/src/commands/developer/mod.rs index d5e2767742..f6cb0b18fa 100644 --- a/cli/src/commands/developer/mod.rs +++ b/cli/src/commands/developer/mod.rs @@ -28,6 +28,7 @@ mod transfer_private; pub use transfer_private::*; use snarkvm::{ + console::network::Network, package::Package, prelude::{ block::Transaction, @@ -51,9 +52,6 @@ use clap::Parser; use colored::Colorize; use std::{path::PathBuf, str::FromStr}; -type CurrentAleo = snarkvm::circuit::AleoV0; -type CurrentNetwork = snarkvm::prelude::MainnetV0; - /// Commands to deploy and execute transactions #[derive(Debug, Parser)] pub enum Developer { @@ -81,7 +79,7 @@ impl Developer { } /// Parse the package from the directory. - fn parse_package(program_id: ProgramID, path: &Option) -> Result> { + fn parse_package(program_id: ProgramID, path: &Option) -> Result> { // Instantiate a path to the directory containing the manifest file. let directory = match path { Some(path) => PathBuf::from_str(path)?, @@ -101,25 +99,22 @@ impl Developer { } /// Parses the record string. If the string is a ciphertext, then attempt to decrypt it. - fn parse_record( - private_key: &PrivateKey, - record: &str, - ) -> Result>> { + fn parse_record(private_key: &PrivateKey, record: &str) -> Result>> { match record.starts_with("record1") { true => { // Parse the ciphertext. - let ciphertext = Record::>::from_str(record)?; + let ciphertext = Record::>::from_str(record)?; // Derive the view key. let view_key = ViewKey::try_from(private_key)?; // Decrypt the ciphertext. ciphertext.decrypt(&view_key) } - false => Record::>::from_str(record), + false => Record::>::from_str(record), } } /// Fetch the program from the given endpoint. - fn fetch_program(program_id: &ProgramID, endpoint: &str) -> Result> { + fn fetch_program(program_id: &ProgramID, endpoint: &str) -> Result> { // Send a request to the query node. let response = ureq::get(&format!("{endpoint}/mainnet/program/{program_id}")).call(); @@ -136,17 +131,17 @@ impl Developer { } /// Fetch the public balance in microcredits associated with the address from the given endpoint. - fn get_public_balance(address: &Address, endpoint: &str) -> Result { + fn get_public_balance(address: &Address, endpoint: &str) -> Result { // Initialize the program id and account identifier. - let credits = ProgramID::::from_str("credits.aleo")?; - let account_mapping = Identifier::::from_str("account")?; + let credits = ProgramID::::from_str("credits.aleo")?; + let account_mapping = Identifier::::from_str("account")?; // Send a request to the query node. let response = ureq::get(&format!("{endpoint}/mainnet/program/{credits}/mapping/{account_mapping}/{address}")).call(); // Deserialize the balance. - let balance: Result>> = match response { + let balance: Result>> = match response { Ok(response) => response.into_json().map_err(|err| err.into()), Err(err) => match err { ureq::Error::Status(_status, response) => { @@ -158,7 +153,7 @@ impl Developer { // Return the balance in microcredits. match balance { - Ok(Some(Value::Plaintext(Plaintext::Literal(Literal::::U64(amount), _)))) => Ok(*amount), + Ok(Some(Value::Plaintext(Plaintext::Literal(Literal::::U64(amount), _)))) => Ok(*amount), Ok(None) => Ok(0), Ok(Some(..)) => bail!("Failed to deserialize balance for {address}"), Err(err) => bail!("Failed to fetch balance for {address}: {err}"), @@ -166,11 +161,11 @@ impl Developer { } /// Determine if the transaction should be broadcast or displayed to user. - fn handle_transaction( + fn handle_transaction( broadcast: &Option, dry_run: bool, store: &Option, - transaction: Transaction, + transaction: Transaction, operation: String, ) -> Result { // Get the transaction id. diff --git a/cli/src/commands/developer/scan.rs b/cli/src/commands/developer/scan.rs index 21be11d4d3..e97896a510 100644 --- a/cli/src/commands/developer/scan.rs +++ b/cli/src/commands/developer/scan.rs @@ -14,8 +14,10 @@ #![allow(clippy::type_complexity)] -use super::CurrentNetwork; -use snarkvm::prelude::{block::Block, Ciphertext, Field, FromBytes, Network, Plaintext, PrivateKey, Record, ViewKey}; +use snarkvm::{ + console::network::{MainnetV0, Network, TestnetV0}, + prelude::{block::Block, Ciphertext, Field, FromBytes, Plaintext, PrivateKey, Record, ViewKey}, +}; use anyhow::{bail, ensure, Result}; use clap::Parser; @@ -28,11 +30,16 @@ use std::{ use zeroize::Zeroize; const MAX_BLOCK_RANGE: u32 = 50; +// TODO (raychu86): This should be configurable based on network. const CDN_ENDPOINT: &str = "https://s3.us-west-1.amazonaws.com/testnet3.blocks/phase3"; /// Scan the snarkOS node for records. #[derive(Debug, Parser, Zeroize)] pub struct Scan { + /// Specify the network to scan. + #[clap(default_value = "0", long = "network")] + pub network: u16, + /// An optional private key scan for unspent records. #[clap(short, long)] private_key: Option, @@ -60,14 +67,24 @@ pub struct Scan { impl Scan { pub fn parse(self) -> Result { + // Scan for records on the given network. + match self.network { + 0 => self.scan_records::(), + 1 => self.scan_records::(), + _ => bail!("Unsupported network ID"), + } + } + + /// Scan the network for records. + fn scan_records(&self) -> Result { // Derive the view key and optional private key. - let (private_key, view_key) = self.parse_account()?; + let (private_key, view_key) = self.parse_account::()?; // Find the start and end height to scan. let (start_height, end_height) = self.parse_block_range()?; // Fetch the records from the network. - let records = Self::fetch_records(private_key, &view_key, &self.endpoint, start_height, end_height)?; + let records = Self::fetch_records::(private_key, &view_key, &self.endpoint, start_height, end_height)?; // Output the decrypted records associated with the view key. if records.is_empty() { @@ -114,6 +131,13 @@ impl Scan { /// Returns the `start` and `end` blocks to scan. fn parse_block_range(&self) -> Result<(u32, u32)> { + // Get the network name. + let network = match self.network { + 0 => "mainnet", + 1 => "testnet", + _ => bail!("Unsupported network ID"), + }; + match (self.start, self.end, self.last) { (Some(start), Some(end), None) => { ensure!(end > start, "The given scan range is invalid (start = {start}, end = {end})"); @@ -122,7 +146,7 @@ impl Scan { } (Some(start), None, None) => { // Request the latest block height from the endpoint. - let endpoint = format!("{}/mainnet/latest/height", self.endpoint); + let endpoint = format!("{}/{network}/latest/height", self.endpoint); let latest_height = u32::from_str(&ureq::get(&endpoint).call()?.into_string()?)?; // Print a warning message if the user is attempting to scan the whole chain. @@ -135,7 +159,7 @@ impl Scan { (None, Some(end), None) => Ok((0, end)), (None, None, Some(last)) => { // Request the latest block height from the endpoint. - let endpoint = format!("{}/mainnet/latest/height", self.endpoint); + let endpoint = format!("{}/{network}/latest/height", self.endpoint); let latest_height = u32::from_str(&ureq::get(&endpoint).call()?.into_string()?)?; Ok((latest_height.saturating_sub(last), latest_height)) @@ -146,18 +170,25 @@ impl Scan { } /// Fetch owned ciphertext records from the endpoint. - fn fetch_records( - private_key: Option>, - view_key: &ViewKey, + fn fetch_records( + private_key: Option>, + view_key: &ViewKey, endpoint: &str, start_height: u32, end_height: u32, - ) -> Result>>> { + ) -> Result>>> { // Check the bounds of the request. if start_height > end_height { bail!("Invalid block range"); } + // Get the network name. + let network = match N::ID { + 0 => "mainnet", + 1 => "testnet", + _ => bail!("Unsupported network ID"), + }; + // Derive the x-coordinate of the address corresponding to the given view key. let address_x_coordinate = view_key.to_address().to_x_coordinate(); @@ -172,10 +203,9 @@ impl Scan { stdout().flush()?; // Fetch the genesis block from the endpoint. - let genesis_block: Block = - ureq::get(&format!("{endpoint}/mainnet/block/0")).call()?.into_json()?; + let genesis_block: Block = ureq::get(&format!("{endpoint}/{network}/block/0")).call()?.into_json()?; // Determine if the endpoint is on a development network. - let is_development_network = genesis_block != Block::from_bytes_le(CurrentNetwork::genesis_bytes())?; + let is_development_network = genesis_block != Block::from_bytes_le(N::genesis_bytes())?; // Determine the request start height. let mut request_start = match is_development_network { @@ -210,9 +240,9 @@ impl Scan { let request_end = request_start.saturating_add(num_blocks_to_request); // Establish the endpoint. - let blocks_endpoint = format!("{endpoint}/mainnet/blocks?start={request_start}&end={request_end}"); + let blocks_endpoint = format!("{endpoint}/{network}/blocks?start={request_start}&end={request_end}"); // Fetch blocks - let blocks: Vec> = ureq::get(&blocks_endpoint).call()?.into_json()?; + let blocks: Vec> = ureq::get(&blocks_endpoint).call()?.into_json()?; // Scan the blocks for owned records. for block in &blocks { @@ -232,15 +262,15 @@ impl Scan { /// Scan the blocks from the CDN. #[allow(clippy::too_many_arguments)] - fn scan_from_cdn( + fn scan_from_cdn( start_height: u32, end_height: u32, cdn: String, endpoint: String, - private_key: Option>, - view_key: ViewKey, - address_x_coordinate: Field, - records: Arc>>>>, + private_key: Option>, + view_key: ViewKey, + address_x_coordinate: Field, + records: Arc>>>>, ) -> Result<()> { // Calculate the number of blocks to scan. let total_blocks = end_height.saturating_sub(start_height); @@ -294,13 +324,13 @@ impl Scan { } /// Scan a block for owned records. - fn scan_block( - block: &Block, + fn scan_block( + block: &Block, endpoint: &str, - private_key: Option>, - view_key: &ViewKey, - address_x_coordinate: &Field, - records: Arc>>>>, + private_key: Option>, + view_key: &ViewKey, + address_x_coordinate: &Field, + records: Arc>>>>, ) -> Result<()> { for (commitment, ciphertext_record) in block.records() { // Check if the record is owned by the given view key. @@ -318,21 +348,27 @@ impl Scan { } /// Decrypts the ciphertext record and filters spend record if a private key was provided. - fn decrypt_record( - private_key: Option>, - view_key: &ViewKey, + fn decrypt_record( + private_key: Option>, + view_key: &ViewKey, endpoint: &str, - commitment: Field, - ciphertext_record: &Record>, - ) -> Result>>> { + commitment: Field, + ciphertext_record: &Record>, + ) -> Result>>> { // Check if a private key was provided. if let Some(private_key) = private_key { // Compute the serial number. - let serial_number = - Record::>::serial_number(private_key, commitment)?; + let serial_number = Record::>::serial_number(private_key, commitment)?; + + // Get the network name. + let network = match N::ID { + 0 => "mainnet", + 1 => "testnet", + _ => bail!("Unsupported network ID"), + }; // Establish the endpoint. - let endpoint = format!("{endpoint}/mainnet/find/transitionID/{serial_number}"); + let endpoint = format!("{endpoint}/{network}/find/transitionID/{serial_number}"); // Check if the record is spent. match ureq::get(&endpoint).call() { diff --git a/cli/src/commands/developer/transfer_private.rs b/cli/src/commands/developer/transfer_private.rs index 1a9d45620f..9b0955047f 100644 --- a/cli/src/commands/developer/transfer_private.rs +++ b/cli/src/commands/developer/transfer_private.rs @@ -12,15 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. -use super::{CurrentNetwork, Developer}; -use snarkvm::prelude::{ - query::Query, - store::{helpers::memory::ConsensusMemory, ConsensusStore}, - Address, - Locator, - PrivateKey, - Value, - VM, +use super::Developer; +use snarkvm::{ + console::network::{MainnetV0, Network, TestnetV0}, + prelude::{ + query::Query, + store::{helpers::memory::ConsensusMemory, ConsensusStore}, + Address, + Locator, + PrivateKey, + Value, + VM, + }, }; use aleo_std::StorageMode; @@ -32,12 +35,15 @@ use zeroize::Zeroize; /// Executes the `transfer_private` function in the `credits.aleo` program. #[derive(Debug, Parser)] pub struct TransferPrivate { + /// Specify the network to create a `transfer_private` for. + #[clap(default_value = "0", long = "network")] + pub network: u16, /// The input record used to craft the transfer. #[clap(long)] input_record: String, /// The recipient address. #[clap(long)] - recipient: Address, + recipient: String, /// The number of microcredits to transfer. #[clap(long)] amount: u64, @@ -83,13 +89,26 @@ impl TransferPrivate { bail!("❌ Please specify one of the following actions: --broadcast, --dry-run, --store"); } + // Construct the transfer for the specified network. + match self.network { + 0 => self.construct_transfer_private::(), + 1 => self.construct_transfer_private::(), + _ => bail!("Unsupported network ID"), + } + } + + /// Construct and process the `transfer_private` transaction. + fn construct_transfer_private(&self) -> Result { // Specify the query let query = Query::from(&self.query); + // Retrieve the recipient. + let recipient = Address::::from_str(&self.recipient)?; + // Retrieve the private key. let private_key = PrivateKey::from_str(&self.private_key)?; - println!("📦 Creating private transfer of {} microcredits to {}...\n", self.amount, self.recipient); + println!("📦 Creating private transfer of {} microcredits to {}...\n", self.amount, recipient); // Generate the transfer_private transaction. let transaction = { @@ -101,7 +120,7 @@ impl TransferPrivate { Some(path) => StorageMode::Custom(path.clone()), None => StorageMode::Production, }; - let store = ConsensusStore::>::open(storage_mode)?; + let store = ConsensusStore::>::open(storage_mode)?; // Initialize the VM. let vm = VM::from(store)?; @@ -114,7 +133,7 @@ impl TransferPrivate { let input_record = Developer::parse_record(&private_key, &self.input_record)?; let inputs = vec![ Value::Record(input_record), - Value::from_str(&format!("{}", self.recipient))?, + Value::from_str(&format!("{}", recipient))?, Value::from_str(&format!("{}u64", self.amount))?, ]; @@ -129,8 +148,8 @@ impl TransferPrivate { rng, )? }; - let locator = Locator::::from_str("credits.aleo/transfer_private")?; - println!("✅ Created private transfer of {} microcredits to {}\n", &self.amount, self.recipient); + let locator = Locator::::from_str("credits.aleo/transfer_private")?; + println!("✅ Created private transfer of {} microcredits to {}\n", &self.amount, recipient); // Determine if the transaction should be broadcast, stored, or displayed to the user. Developer::handle_transaction(&self.broadcast, self.dry_run, &self.store, transaction, locator.to_string()) From 297461215a24fca050881424fd02cd913aff8326 Mon Sep 17 00:00:00 2001 From: Victor Sint Nicolaas Date: Tue, 2 Apr 2024 17:14:09 +0200 Subject: [PATCH 312/551] Only allow validator routers to connect as trusted peers --- node/router/src/handshake.rs | 7 +++-- node/router/tests/cleanups.rs | 2 +- node/router/tests/common/mod.rs | 9 +++++-- node/router/tests/connect.rs | 48 ++++++++++++++++++++++----------- node/router/tests/disconnect.rs | 4 +-- 5 files changed, 45 insertions(+), 25 deletions(-) diff --git a/node/router/src/handshake.rs b/node/router/src/handshake.rs index 92b8f8462e..57198692d4 100644 --- a/node/router/src/handshake.rs +++ b/node/router/src/handshake.rs @@ -17,7 +17,6 @@ use crate::{ Peer, Router, }; -use snarkos_node_router_messages::NodeType; use snarkos_node_tcp::{ConnectionSide, Tcp, P2P}; use snarkvm::{ ledger::narwhal::Data, @@ -203,7 +202,7 @@ impl Router { let peer_ip = peer_ip.unwrap(); // Knowing the peer's listening address, ensure it is allowed to connect. - if let Err(forbidden_message) = self.ensure_peer_is_allowed(peer_ip, peer_request.node_type) { + if let Err(forbidden_message) = self.ensure_peer_is_allowed(peer_ip) { return Err(error(format!("{forbidden_message}"))); } // Verify the challenge request. If a disconnect reason was returned, send the disconnect message and abort. @@ -252,7 +251,7 @@ impl Router { } /// Ensure the peer is allowed to connect. - fn ensure_peer_is_allowed(&self, peer_ip: SocketAddr, node_type: NodeType) -> Result<()> { + fn ensure_peer_is_allowed(&self, peer_ip: SocketAddr) -> Result<()> { // Ensure the peer IP is not this node. if self.is_local_ip(&peer_ip) { bail!("Dropping connection request from '{peer_ip}' (attempted to self-connect)") @@ -266,7 +265,7 @@ impl Router { bail!("Dropping connection request from '{peer_ip}' (already connected)") } // Only allow trusted peers to connect if allow_external_peers is set - if !node_type.is_validator() && !self.allow_external_peers() && !self.is_trusted(&peer_ip) { + if !self.allow_external_peers() && !self.is_trusted(&peer_ip) { bail!("Dropping connection request from '{peer_ip}' (untrusted)") } // Ensure the peer is not restricted. diff --git a/node/router/tests/cleanups.rs b/node/router/tests/cleanups.rs index ab8507dec8..3a8b8ed83f 100644 --- a/node/router/tests/cleanups.rs +++ b/node/router/tests/cleanups.rs @@ -43,7 +43,7 @@ async fn test_connection_cleanups() { let node = match rng.gen_range(0..3) % 3 { 0 => client(0, 1).await, 1 => prover(0, 1).await, - 2 => validator(0, 1, true).await, + 2 => validator(0, 1, &[], true).await, _ => unreachable!(), }; diff --git a/node/router/tests/common/mod.rs b/node/router/tests/common/mod.rs index 73d3f5e774..b42b0a2063 100644 --- a/node/router/tests/common/mod.rs +++ b/node/router/tests/common/mod.rs @@ -104,12 +104,17 @@ pub async fn prover(listening_port: u16, max_peers: u16) -> TestRouter TestRouter { +pub async fn validator( + listening_port: u16, + max_peers: u16, + trusted_peers: &[SocketAddr], + allow_external_peers: bool, +) -> TestRouter { Router::new( SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), listening_port), NodeType::Validator, sample_account(), - &[], + trusted_peers, max_peers, allow_external_peers, true, diff --git a/node/router/tests/connect.rs b/node/router/tests/connect.rs index e1fa935d54..60c9b15449 100644 --- a/node/router/tests/connect.rs +++ b/node/router/tests/connect.rs @@ -22,7 +22,7 @@ use core::time::Duration; #[tokio::test] async fn test_connect_without_handshake() { // Create 2 routers. - let node0 = validator(0, 2, true).await; + let node0 = validator(0, 2, &[], true).await; let node1 = client(0, 2).await; assert_eq!(node0.number_of_connected_peers(), 0); assert_eq!(node1.number_of_connected_peers(), 0); @@ -78,7 +78,7 @@ async fn test_connect_without_handshake() { #[tokio::test] async fn test_connect_with_handshake() { // Create 2 routers. - let node0 = validator(0, 2, true).await; + let node0 = validator(0, 2, &[], true).await; let node1 = client(0, 2).await; assert_eq!(node0.number_of_connected_peers(), 0); assert_eq!(node1.number_of_connected_peers(), 0); @@ -152,18 +152,19 @@ async fn test_connect_with_handshake() { #[tokio::test] async fn test_validator_connection() { - // Create 2 routers. - let node0 = validator(0, 2, false).await; - let node1 = validator(0, 2, false).await; + // Create first router and start listening. + let node0 = validator(0, 2, &[], false).await; assert_eq!(node0.number_of_connected_peers(), 0); - assert_eq!(node1.number_of_connected_peers(), 0); - - // Enable handshake protocol. node0.enable_handshake().await; - node1.enable_handshake().await; - - // Start listening. node0.tcp().enable_listener().await.unwrap(); + + // Get the local IP address from the first router. + let addr0 = node0.local_ip(); + + // Create second router, trusting the first router, and start listening. + let node1 = validator(0, 2, &[addr0], false).await; + assert_eq!(node1.number_of_connected_peers(), 0); + node1.enable_handshake().await; node1.tcp().enable_listener().await.unwrap(); { @@ -175,15 +176,30 @@ async fn test_validator_connection() { print_tcp!(node0); print_tcp!(node1); - // Check the TCP level. + // Check the TCP level - connection was accepted. assert_eq!(node0.tcp().num_connected(), 1); - assert_eq!(node0.tcp().num_connecting(), 0); assert_eq!(node1.tcp().num_connected(), 1); - assert_eq!(node1.tcp().num_connecting(), 0); - // Check the router level. + // Check the router level - connection was accepted. assert_eq!(node0.number_of_connected_peers(), 1); assert_eq!(node1.number_of_connected_peers(), 1); + + // Disconnect the nodes. + node0.disconnect(node1.local_ip()); + node1.disconnect(node0.local_ip()); + + // Connect node1 to node0. + node1.connect(node0.local_ip()); + // Sleep briefly. + tokio::time::sleep(Duration::from_millis(200)).await; + + // Check the TCP level - connection was not accepted. + assert_eq!(node0.tcp().num_connected(), 0); + assert_eq!(node1.tcp().num_connected(), 0); + + // Check the router level - connection was not accepted. + assert_eq!(node0.number_of_connected_peers(), 0); + assert_eq!(node1.number_of_connected_peers(), 0); } } @@ -191,7 +207,7 @@ async fn test_validator_connection() { #[tokio::test] async fn test_connect_simultaneously_with_handshake() { // Create 2 routers. - let node0 = validator(0, 2, true).await; + let node0 = validator(0, 2, &[], true).await; let node1 = client(0, 2).await; assert_eq!(node0.number_of_connected_peers(), 0); assert_eq!(node1.number_of_connected_peers(), 0); diff --git a/node/router/tests/disconnect.rs b/node/router/tests/disconnect.rs index 3d27583e02..df9eee1016 100644 --- a/node/router/tests/disconnect.rs +++ b/node/router/tests/disconnect.rs @@ -22,7 +22,7 @@ use core::time::Duration; #[tokio::test] async fn test_disconnect_without_handshake() { // Create 2 routers. - let node0 = validator(0, 1, true).await; + let node0 = validator(0, 1, &[], true).await; let node1 = client(0, 1).await; assert_eq!(node0.number_of_connected_peers(), 0); assert_eq!(node1.number_of_connected_peers(), 0); @@ -64,7 +64,7 @@ async fn test_disconnect_without_handshake() { #[tokio::test] async fn test_disconnect_with_handshake() { // Create 2 routers. - let node0 = validator(0, 1, true).await; + let node0 = validator(0, 1, &[], true).await; let node1 = client(0, 1).await; assert_eq!(node0.number_of_connected_peers(), 0); assert_eq!(node1.number_of_connected_peers(), 0); From 6ff3343244899d53d81ffd86717c77bcc015c00f Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 2 Apr 2024 15:56:56 -0400 Subject: [PATCH 313/551] Track the proposal timestamp in signed_proposals --- node/bft/src/primary.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index a2a070183e..1bf15b04a1 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -90,8 +90,8 @@ pub struct Primary { bft_sender: Arc>>, /// The batch proposal, if the primary is currently proposing a batch. proposed_batch: Arc>, - /// The recently-signed batch proposals (a map from the address to the round, batch ID, and signature). - signed_proposals: Arc, (u64, Field, Signature)>>>, + /// The recently-signed batch proposals (a map from the address to the round, timestamp, batch ID, and signature). + signed_proposals: Arc, (u64, i64, Field, Signature)>>>, /// The spawned handles. handles: Arc>>>, /// The lock for propose_batch. @@ -562,7 +562,7 @@ impl Primary { } // Retrieve the cached round and batch ID for this validator. - if let Some((signed_round, signed_batch_id, signature)) = + if let Some((signed_round, timestamp, signed_batch_id, signature)) = self.signed_proposals.read().get(&batch_author).copied() { // If the signed round is ahead of the peer's batch round, then the validator is malicious. @@ -626,6 +626,8 @@ impl Primary { // Retrieve the batch ID. let batch_id = batch_header.batch_id(); + // Retrieve the proposal timestamp. + let timestamp = batch_header.timestamp(); // Sign the batch ID. let account = self.gateway.account().clone(); let signature = spawn_blocking!(account.sign(&[batch_id], &mut rand::thread_rng()))?; @@ -644,13 +646,13 @@ impl Primary { if entry.get().0 == batch_round { return Ok(()); } - // Otherwise, cache the round, batch ID, and signature for this validator. - entry.insert((batch_round, batch_id, signature)); + // Otherwise, cache the round, timestamp, batch ID, and signature for this validator. + entry.insert((batch_round, timestamp, batch_id, signature)); } // If the validator has not signed a batch before, then continue. std::collections::hash_map::Entry::Vacant(entry) => { - // Cache the round, batch ID, and signature for this validator. - entry.insert((batch_round, batch_id, signature)); + // Cache the round, timestamp, batch ID, and signature for this validator. + entry.insert((batch_round, timestamp, batch_id, signature)); } }; From 11c4618635729f19087c547cee7843f70b556e49 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 2 Apr 2024 16:01:08 -0400 Subject: [PATCH 314/551] Expire proposals after PROPOSAL_EXPIRATION_IN_SECS --- node/bft/src/lib.rs | 3 ++ node/bft/src/primary.rs | 65 ++++++++++++++++++++++++++++------------- 2 files changed, 48 insertions(+), 20 deletions(-) diff --git a/node/bft/src/lib.rs b/node/bft/src/lib.rs index d6fcbae66f..2a63523f63 100644 --- a/node/bft/src/lib.rs +++ b/node/bft/src/lib.rs @@ -58,6 +58,9 @@ pub const MAX_TIMESTAMP_DELTA_IN_SECS: i64 = 10; // seconds /// The maximum number of workers that can be spawned. pub const MAX_WORKERS: u8 = 1; // worker(s) +/// The number of seconds a proposal is valid for before it expires. +pub const PROPOSAL_EXPIRATION_IN_SECS: i64 = 60; // seconds + /// The frequency at which each primary broadcasts a ping to every other node. /// Note: If this is updated, be sure to update `MAX_BLOCKS_BEHIND` to correspond properly. pub const PRIMARY_PING_IN_MS: u64 = 2 * MAX_BATCH_DELAY_IN_MS; // ms diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 1bf15b04a1..b6516767cf 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -35,6 +35,7 @@ use crate::{ MAX_BATCH_DELAY_IN_MS, MAX_WORKERS, PRIMARY_PING_IN_MS, + PROPOSAL_EXPIRATION_IN_SECS, WORKER_PING_IN_MS, }; use snarkos_account::Account; @@ -572,26 +573,43 @@ impl Primary { bail!("Malicious peer - proposed a batch for a previous round ({})", batch_header.round()); } - // If the round matches and the batch ID differs, then the validator is malicious. - if signed_round == batch_header.round() && signed_batch_id != batch_header.batch_id() { - // Proceed to disconnect the validator. - self.gateway.disconnect(peer_ip); - bail!("Malicious peer - proposed another batch for the same round ({signed_round})"); - } - // If the round and batch ID matches, then skip signing the batch a second time. - // Instead, rebroadcast the cached signature to the peer. - if signed_round == batch_header.round() && signed_batch_id == batch_header.batch_id() { - let gateway = self.gateway.clone(); - tokio::spawn(async move { - debug!("Resending a signature for a batch in round {batch_round} from '{peer_ip}'"); - let event = Event::BatchSignature(BatchSignature::new(batch_header.batch_id(), signature)); - // Resend the batch signature to the peer. - if gateway.send(peer_ip, event).await.is_none() { - warn!("Failed to resend a signature for a batch in round {batch_round} to '{peer_ip}'"); + // If the signed round matches the peer's batch round then check the contents. + if signed_round == batch_header.round() { + // Determine if the proposal has expired. + let is_proposal_expired = now().saturating_sub(timestamp) >= PROPOSAL_EXPIRATION_IN_SECS; + match is_proposal_expired { + // If the proposal has expired, then remove the cached signature. + true => { + self.signed_proposals.write().remove(&batch_author); } - }); - // Return early. - return Ok(()); + // If the proposal has not expired, then check the batch id. + false => match signed_batch_id == batch_header.batch_id() { + // If the batch ID matches, then skip signing the batch a second time. + // Instead, rebroadcast the cached signature to the peer. + true => { + let gateway = self.gateway.clone(); + tokio::spawn(async move { + debug!("Resending a signature for a batch in round {batch_round} from '{peer_ip}'"); + let event = + Event::BatchSignature(BatchSignature::new(batch_header.batch_id(), signature)); + // Resend the batch signature to the peer. + if gateway.send(peer_ip, event).await.is_none() { + warn!( + "Failed to resend a signature for a batch in round {batch_round} to '{peer_ip}'" + ); + } + }); + // Return early. + return Ok(()); + } + // If the batch ID differs, then the validator is malicious. + false => { + // Proceed to disconnect the validator. + self.gateway.disconnect(peer_ip); + bail!("Malicious peer - proposed another batch for the same round ({signed_round})"); + } + }, + } } } @@ -1102,7 +1120,14 @@ impl Primary { async fn check_proposed_batch_for_expiration(&self) -> Result<()> { // Check if the proposed batch is timed out or stale. let is_expired = match self.proposed_batch.read().as_ref() { - Some(proposal) => proposal.round() < self.current_round(), + Some(proposal) => { + // Determine if the proposal is stale. + let is_stale = proposal.round() < self.current_round(); + // Determine if the proposal is timed out. + let is_timed_out = now().saturating_sub(proposal.timestamp()) >= PROPOSAL_EXPIRATION_IN_SECS; + // Determine if the proposal is expired. + is_stale || is_timed_out + } None => false, }; // If the batch is expired, clear the proposed batch. From 2dc94f514a5db82f3667b4c4eb23d3684a5a06f1 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 2 Apr 2024 17:14:45 -0400 Subject: [PATCH 315/551] Cleanup and add tests --- node/bft/src/helpers/proposal.rs | 1 + node/bft/src/lib.rs | 5 + node/bft/src/primary.rs | 188 +++++++++++++++++++++++++++++-- 3 files changed, 186 insertions(+), 8 deletions(-) diff --git a/node/bft/src/helpers/proposal.rs b/node/bft/src/helpers/proposal.rs index 1137ddaa68..06db003c3d 100644 --- a/node/bft/src/helpers/proposal.rs +++ b/node/bft/src/helpers/proposal.rs @@ -28,6 +28,7 @@ use snarkvm::{ use indexmap::{IndexMap, IndexSet}; use std::collections::HashSet; +#[derive(Clone, Debug, PartialEq, Eq)] pub struct Proposal { /// The proposed batch header. batch_header: BatchHeader, diff --git a/node/bft/src/lib.rs b/node/bft/src/lib.rs index 2a63523f63..95a1ee97e8 100644 --- a/node/bft/src/lib.rs +++ b/node/bft/src/lib.rs @@ -59,7 +59,12 @@ pub const MAX_TIMESTAMP_DELTA_IN_SECS: i64 = 10; // seconds pub const MAX_WORKERS: u8 = 1; // worker(s) /// The number of seconds a proposal is valid for before it expires. +#[cfg(not(any(test, feature = "test")))] pub const PROPOSAL_EXPIRATION_IN_SECS: i64 = 60; // seconds +/// The number of seconds a proposal is valid for before it expires. +/// This is set to a deliberately low value (5) for testing purposes only. +#[cfg(any(test, feature = "test"))] +pub const PROPOSAL_EXPIRATION_IN_SECS: i64 = 5; // seconds /// The frequency at which each primary broadcasts a ping to every other node. /// Note: If this is updated, be sure to update `MAX_BLOCKS_BEHIND` to correspond properly. diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index b6516767cf..6ff515f319 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -96,7 +96,7 @@ pub struct Primary { /// The spawned handles. handles: Arc>>>, /// The lock for propose_batch. - propose_lock: Arc>, + propose_lock: Arc>, } impl Primary { @@ -465,14 +465,18 @@ impl Primary { debug!("Primary is safely skipping a batch proposal {}", "(no unconfirmed transactions)".dimmed()); return Ok(()); } - // Ditto if the batch had already been proposed. + // Ditto if the batch had already been proposed and not expired. ensure!(round > 0, "Round 0 cannot have transaction batches"); - if *lock_guard == round { + // Determine the current timestamp. + let current_timestamp = now(); + // Determine if the current proposal is expired. + let is_expired = current_timestamp.saturating_sub(lock_guard.1) >= PROPOSAL_EXPIRATION_IN_SECS; + if lock_guard.0 == round && !is_expired { warn!("Primary is safely skipping a batch proposal - round {round} already proposed"); return Ok(()); } - *lock_guard = round; + *lock_guard = (round, current_timestamp); /* Proceeding to sign & propose the batch. */ info!("Proposing a batch with {} transmissions for round {round}...", transmissions.len()); @@ -489,7 +493,7 @@ impl Primary { let batch_header = spawn_blocking!(BatchHeader::new( &private_key, round, - now(), + current_timestamp, committee_id, transmission_ids, previous_certificate_ids, @@ -563,9 +567,8 @@ impl Primary { } // Retrieve the cached round and batch ID for this validator. - if let Some((signed_round, timestamp, signed_batch_id, signature)) = - self.signed_proposals.read().get(&batch_author).copied() - { + let signed_proposal = self.signed_proposals.read().get(&batch_author).copied(); + if let Some((signed_round, timestamp, signed_batch_id, signature)) = signed_proposal { // If the signed round is ahead of the peer's batch round, then the validator is malicious. if signed_round > batch_header.round() { // Proceed to disconnect the validator. @@ -1877,6 +1880,46 @@ mod tests { assert!(proposed_transmissions.contains_key(&TransmissionID::Transaction(transaction_id))); } + #[tokio::test] + async fn test_propose_batch_expired() { + let round = 3; + let mut rng = TestRng::default(); + let (primary, accounts) = primary_without_handlers(&mut rng).await; + + // Fill primary storage. + store_certificate_chain(&primary, &accounts, round, &mut rng); + + // Try to propose a batch. There are no transmissions in the workers so the method should + // just return without proposing a batch. + assert!(primary.propose_batch().await.is_ok()); + assert!(primary.proposed_batch.read().is_none()); + + // Generate a solution and a transaction. + let (solution_id, solution) = sample_unconfirmed_solution(&mut rng); + let (transaction_id, transaction) = sample_unconfirmed_transaction(&mut rng); + + // Store it on one of the workers. + primary.workers[0].process_unconfirmed_solution(solution_id, solution).await.unwrap(); + primary.workers[0].process_unconfirmed_transaction(transaction_id, transaction).await.unwrap(); + + // Propose a batch again. This time, it should succeed. + assert!(primary.propose_batch().await.is_ok()); + let original_proposed_batch = primary.proposed_batch.read().clone().unwrap(); + + // Try to propose the batch again. This time, it should return the same proposal. + assert!(primary.propose_batch().await.is_ok()); + let proposal = primary.proposed_batch.read().clone().unwrap(); + assert_eq!(proposal, original_proposed_batch); + + // Sleep until the proposal is expired. + tokio::time::sleep(Duration::from_secs(PROPOSAL_EXPIRATION_IN_SECS as u64)).await; + + // Try to propose a batch again. This time the proposal should be expired and a new proposal should be created. + assert!(primary.propose_batch().await.is_ok()); + let new_proposal = primary.proposed_batch.read().clone().unwrap(); + assert_ne!(new_proposal, proposal); + } + #[tokio::test] async fn test_batch_propose_from_peer() { let mut rng = TestRng::default(); @@ -2025,6 +2068,135 @@ mod tests { ); } + #[tokio::test] + async fn test_batch_propose_from_peer_expired() { + let round = 2; + let mut rng = TestRng::default(); + let (primary, accounts) = primary_without_handlers(&mut rng).await; + + // Generate certificates. + let previous_certificates = store_certificate_chain(&primary, &accounts, round, &mut rng); + + // Create a valid proposal with an author that isn't the primary. + let peer_account = &accounts[1]; + let peer_address = peer_account.1.address(); + let peer_ip = peer_account.0; + let timestamp = now(); + let proposal = create_test_proposal( + &peer_account.1, + primary.ledger.current_committee().unwrap(), + round, + previous_certificates.clone(), + timestamp, + &mut rng, + ); + + // Make sure the primary is aware of the transmissions in the proposal. + for (transmission_id, transmission) in proposal.transmissions() { + primary.workers[0].process_transmission_from_peer(peer_ip, *transmission_id, transmission.clone()) + } + + // The author must be known to resolver to pass propose checks. + primary.gateway.resolver().insert_peer(peer_ip, peer_ip, peer_account.1.address()); + + // Try to process the batch proposal from the peer, should succeed. + primary.process_batch_propose_from_peer(peer_ip, (*proposal.batch_header()).clone().into()).await.unwrap(); + + // Fetch the original round and batch ID of the signed proposal. + let original_round = primary.signed_proposals.read().get(&peer_address).unwrap().0; + let original_batch_id = primary.signed_proposals.read().get(&peer_address).unwrap().2; + + // Construct a new proposal. + let new_proposal = create_test_proposal( + &peer_account.1, + primary.ledger.current_committee().unwrap(), + round, + previous_certificates.clone(), + now(), + &mut rng, + ); + + // Try to process the batch proposal from the peer again, should error. + assert!( + primary + .process_batch_propose_from_peer(peer_ip, (*new_proposal.batch_header()).clone().into()) + .await + .is_err() + ); + + // Ensure that the round and batch ID of the signed proposal did not change. + let round = primary.signed_proposals.read().get(&peer_address).unwrap().0; + let batch_id = primary.signed_proposals.read().get(&peer_address).unwrap().2; + assert_eq!(round, original_round); + assert_eq!(batch_id, original_batch_id); + } + + #[tokio::test] + async fn test_batch_propose_from_peer_after_expiration() { + let round = 2; + let mut rng = TestRng::default(); + let (primary, accounts) = primary_without_handlers(&mut rng).await; + + // Generate certificates. + let previous_certificates = store_certificate_chain(&primary, &accounts, round, &mut rng); + + // Create a valid proposal with an author that isn't the primary. + let peer_account = &accounts[1]; + let peer_address = peer_account.1.address(); + let peer_ip = peer_account.0; + let timestamp = now(); + let proposal = create_test_proposal( + &peer_account.1, + primary.ledger.current_committee().unwrap(), + round, + previous_certificates.clone(), + timestamp, + &mut rng, + ); + + // Make sure the primary is aware of the transmissions in the proposal. + for (transmission_id, transmission) in proposal.transmissions() { + primary.workers[0].process_transmission_from_peer(peer_ip, *transmission_id, transmission.clone()) + } + + // The author must be known to resolver to pass propose checks. + primary.gateway.resolver().insert_peer(peer_ip, peer_ip, peer_account.1.address()); + + // Try to process the batch proposal from the peer, should succeed. + primary.process_batch_propose_from_peer(peer_ip, (*proposal.batch_header()).clone().into()).await.unwrap(); + + // Fetch the original round and batch ID of the signed proposal. + let original_round = primary.signed_proposals.read().get(&peer_address).unwrap().0; + let original_batch_id = primary.signed_proposals.read().get(&peer_address).unwrap().2; + + // Sleep until the current proposal is expired. + tokio::time::sleep(Duration::from_secs(PROPOSAL_EXPIRATION_IN_SECS as u64)).await; + + // Create a new proposal after the previous one has expired. + let new_proposal = create_test_proposal( + &peer_account.1, + primary.ledger.current_committee().unwrap(), + round, + previous_certificates, + now(), + &mut rng, + ); + + // Make sure the primary is aware of the transmissions in the proposal. + for (transmission_id, transmission) in new_proposal.transmissions() { + primary.workers[0].process_transmission_from_peer(peer_ip, *transmission_id, transmission.clone()) + } + + // Try to process the batch proposal from the peer, should succeed. + primary.process_batch_propose_from_peer(peer_ip, (*new_proposal.batch_header()).clone().into()).await.unwrap(); + + // Ensure that the batch ID of the signed proposal has changed, but the round has not. + let round = primary.signed_proposals.read().get(&peer_address).unwrap().0; + let batch_id = primary.signed_proposals.read().get(&peer_account.1.address()).unwrap().2; + assert_eq!(round, original_round); + assert_ne!(batch_id, original_batch_id); + } + #[tokio::test(flavor = "multi_thread")] async fn test_batch_signature_from_peer() { let mut rng = TestRng::default(); From ab93cd6710edddf057c5f2b9306fb240e13cde09 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 2 Apr 2024 21:05:19 -0400 Subject: [PATCH 316/551] cleanup --- node/bft/src/primary.rs | 61 +++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 36 deletions(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 6ff515f319..71bf7cb277 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -576,43 +576,32 @@ impl Primary { bail!("Malicious peer - proposed a batch for a previous round ({})", batch_header.round()); } - // If the signed round matches the peer's batch round then check the contents. - if signed_round == batch_header.round() { - // Determine if the proposal has expired. - let is_proposal_expired = now().saturating_sub(timestamp) >= PROPOSAL_EXPIRATION_IN_SECS; - match is_proposal_expired { - // If the proposal has expired, then remove the cached signature. - true => { - self.signed_proposals.write().remove(&batch_author); + // Determine if the proposal has expired. + let is_proposal_expired = now().saturating_sub(timestamp) >= PROPOSAL_EXPIRATION_IN_SECS; + // If the round matches and the proposal has expired, then remove the cached signature. + if signed_round == batch_header.round() && is_proposal_expired { + self.signed_proposals.write().remove(&batch_author); + } + // If the round matches and the batch ID differs, then the validator is malicious. + else if signed_round == batch_header.round() && signed_batch_id != batch_header.batch_id() { + // Proceed to disconnect the validator. + self.gateway.disconnect(peer_ip); + bail!("Malicious peer - proposed another batch for the same round ({signed_round})"); + } + // If the round and batch ID matches, then skip signing the batch a second time. + // Instead, rebroadcast the cached signature to the peer. + else if signed_round == batch_header.round() && signed_batch_id == batch_header.batch_id() { + let gateway = self.gateway.clone(); + tokio::spawn(async move { + debug!("Resending a signature for a batch in round {batch_round} from '{peer_ip}'"); + let event = Event::BatchSignature(BatchSignature::new(batch_header.batch_id(), signature)); + // Resend the batch signature to the peer. + if gateway.send(peer_ip, event).await.is_none() { + warn!("Failed to resend a signature for a batch in round {batch_round} to '{peer_ip}'"); } - // If the proposal has not expired, then check the batch id. - false => match signed_batch_id == batch_header.batch_id() { - // If the batch ID matches, then skip signing the batch a second time. - // Instead, rebroadcast the cached signature to the peer. - true => { - let gateway = self.gateway.clone(); - tokio::spawn(async move { - debug!("Resending a signature for a batch in round {batch_round} from '{peer_ip}'"); - let event = - Event::BatchSignature(BatchSignature::new(batch_header.batch_id(), signature)); - // Resend the batch signature to the peer. - if gateway.send(peer_ip, event).await.is_none() { - warn!( - "Failed to resend a signature for a batch in round {batch_round} to '{peer_ip}'" - ); - } - }); - // Return early. - return Ok(()); - } - // If the batch ID differs, then the validator is malicious. - false => { - // Proceed to disconnect the validator. - self.gateway.disconnect(peer_ip); - bail!("Malicious peer - proposed another batch for the same round ({signed_round})"); - } - }, - } + }); + // Return early. + return Ok(()); } } From 0400e76f83afcbefb236e829d49c12e6000e443e Mon Sep 17 00:00:00 2001 From: Pranav Gaddamadugu <23022326+d0cd@users.noreply.github.com> Date: Tue, 2 Apr 2024 22:46:03 -0700 Subject: [PATCH 317/551] Lower priority of warnings on invalid solutions --- node/consensus/src/lib.rs | 11 ++++++++++- node/src/client/router.rs | 5 ++++- node/src/prover/router.rs | 7 ++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index f9a247704e..348786fb36 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -265,7 +265,16 @@ impl Consensus { if let Err(e) = self.primary_sender().send_unconfirmed_solution(solution_id, Data::Object(solution)).await { // If the BFT is synced, then log the warning. if self.bft.is_synced() { - warn!("Failed to add unconfirmed solution '{}' to the memory pool - {e}", fmt_id(solution_id)); + match self.ledger().latest_block_height() % N::NUM_BLOCKS_PER_EPOCH > 10 { + true => warn!( + "Failed to add unconfirmed solution '{}' to the memory pool - {e}", + fmt_id(solution_id) + ), + false => error!( + "Failed to add unconfirmed solution '{}' to the memory pool - {e}", + fmt_id(solution_id) + ), + } } } } diff --git a/node/src/client/router.rs b/node/src/client/router.rs index 898b2bee82..1f325a1ca8 100644 --- a/node/src/client/router.rs +++ b/node/src/client/router.rs @@ -284,7 +284,10 @@ impl> Inbound for Client { Ok(Err(_)) => { trace!("Invalid solution '{}' for the proof target.", solution.id()) } - Err(error) => warn!("Failed to verify the solution: {error}"), + Err(error) => match self.ledger.latest_height() % N::NUM_BLOCKS_PER_EPOCH > 10 { + true => warn!("Failed to verify the solution - {error}"), + false => trace!("Failed to verify the solution - {error}"), + }, } } true diff --git a/node/src/prover/router.rs b/node/src/prover/router.rs index a5e1489947..8f1771095a 100644 --- a/node/src/prover/router.rs +++ b/node/src/prover/router.rs @@ -240,7 +240,12 @@ impl> Inbound for Prover { Ok(Err(_)) => { trace!("Invalid solution '{}' for the proof target.", solution.id()) } - Err(error) => warn!("Failed to verify the solution - {error}"), + Err(error) => match self.latest_block_header.read().as_ref().map(|header| header.height()) { + Some(height) if height % N::NUM_BLOCKS_PER_EPOCH > 10 => { + warn!("Failed to verify the solution - {error}") + } + _ => trace!("Failed to verify the solution - {error}"), + }, } } true From 7ac2c090b9461d576149cbccea6445811736c932 Mon Sep 17 00:00:00 2001 From: Pranav Gaddamadugu <23022326+d0cd@users.noreply.github.com> Date: Tue, 2 Apr 2024 22:56:34 -0700 Subject: [PATCH 318/551] Clean up and document --- node/consensus/src/lib.rs | 9 +++++---- node/src/client/router.rs | 7 ++++--- node/src/prover/router.rs | 1 + 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 348786fb36..a91d2935c3 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -265,16 +265,17 @@ impl Consensus { if let Err(e) = self.primary_sender().send_unconfirmed_solution(solution_id, Data::Object(solution)).await { // If the BFT is synced, then log the warning. if self.bft.is_synced() { - match self.ledger().latest_block_height() % N::NUM_BLOCKS_PER_EPOCH > 10 { - true => warn!( + // If error occurs in the first 10 blocks of the epoch, then log it as a trace, otherwise log it as a warning. + match self.ledger().latest_block_height() % N::NUM_BLOCKS_PER_EPOCH <= 10 { + true => trace!( "Failed to add unconfirmed solution '{}' to the memory pool - {e}", fmt_id(solution_id) ), - false => error!( + false => warn!( "Failed to add unconfirmed solution '{}' to the memory pool - {e}", fmt_id(solution_id) ), - } + }; } } } diff --git a/node/src/client/router.rs b/node/src/client/router.rs index 1f325a1ca8..62133ab47d 100644 --- a/node/src/client/router.rs +++ b/node/src/client/router.rs @@ -284,9 +284,10 @@ impl> Inbound for Client { Ok(Err(_)) => { trace!("Invalid solution '{}' for the proof target.", solution.id()) } - Err(error) => match self.ledger.latest_height() % N::NUM_BLOCKS_PER_EPOCH > 10 { - true => warn!("Failed to verify the solution - {error}"), - false => trace!("Failed to verify the solution - {error}"), + // If error occurs in the first 10 blocks of the epoch, then log it as a trace, otherwise log it as a warning. + Err(error) => match self.ledger.latest_height() % N::NUM_BLOCKS_PER_EPOCH <= 10 { + true => trace!("Failed to verify the solution - {error}"), + false => warn!("Failed to verify the solution - {error}"), }, } } diff --git a/node/src/prover/router.rs b/node/src/prover/router.rs index 8f1771095a..518c21f91c 100644 --- a/node/src/prover/router.rs +++ b/node/src/prover/router.rs @@ -240,6 +240,7 @@ impl> Inbound for Prover { Ok(Err(_)) => { trace!("Invalid solution '{}' for the proof target.", solution.id()) } + // If error occurs in the first 10 blocks of the epoch, then log it as a trace, otherwise log it as a warning. Err(error) => match self.latest_block_header.read().as_ref().map(|header| header.height()) { Some(height) if height % N::NUM_BLOCKS_PER_EPOCH > 10 => { warn!("Failed to verify the solution - {error}") From 3f8cf7cfb09c3e4319d1b3ca78085d81035be15b Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 3 Apr 2024 12:18:32 -0400 Subject: [PATCH 319/551] Reduce aggressive disconnect --- node/bft/src/primary.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 71bf7cb277..1b6c22bb81 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -569,11 +569,9 @@ impl Primary { // Retrieve the cached round and batch ID for this validator. let signed_proposal = self.signed_proposals.read().get(&batch_author).copied(); if let Some((signed_round, timestamp, signed_batch_id, signature)) = signed_proposal { - // If the signed round is ahead of the peer's batch round, then the validator is malicious. + // If the signed round is ahead of the peer's batch round, then then ignore the proposal. if signed_round > batch_header.round() { - // Proceed to disconnect the validator. - self.gateway.disconnect(peer_ip); - bail!("Malicious peer - proposed a batch for a previous round ({})", batch_header.round()); + bail!("Proposed a batch for a previous round ({})", batch_header.round()); } // Determine if the proposal has expired. @@ -1127,6 +1125,7 @@ impl Primary { // Reset the proposed batch. let proposal = self.proposed_batch.write().take(); if let Some(proposal) = proposal { + debug!("Cleared expired proposal for round {}", proposal.round()); self.reinsert_transmissions_into_workers(proposal)?; } } From ed30f9e1e4e9947c63762bdf4fe56c3bc70a3236 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Wed, 3 Apr 2024 14:43:22 -0700 Subject: [PATCH 320/551] nit: reorder cli flags, improve order --- cli/src/commands/start.rs | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index a3d2767f80..03fe2c82ae 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -55,7 +55,7 @@ const DEVELOPMENT_MODE_NUM_GENESIS_COMMITTEE_MEMBERS: u16 = 4; /// A mapping of `staker_address` to `(validator_address, withdrawal_address, amount)`. #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] -struct BondedBalances(IndexMap); +pub struct BondedBalances(IndexMap); impl FromStr for BondedBalances { type Err = serde_json::Error; @@ -101,6 +101,9 @@ pub struct Start { /// Specify the IP address and port of the validator(s) to connect to #[clap(default_value = "", long = "validators")] pub validators: String, + /// If the flag is set, a node will allow untrusted peers to connect + #[clap(long = "allow-external-peers")] + pub allow_external_peers: bool, /// Specify the IP address and port for the REST server #[clap(default_value = "0.0.0.0:3030", long = "rest")] @@ -125,6 +128,9 @@ pub struct Start { #[clap(default_value = "false", long = "metrics")] pub metrics: bool, + /// Specify the path to a directory containing the ledger + #[clap(long = "storage_path")] + pub storage_path: Option, /// Enables the node to prefetch initial blocks from a CDN #[clap(default_value = "https://s3.us-west-1.amazonaws.com/testnet3.blocks/phase3", long = "cdn")] pub cdn: String, @@ -141,17 +147,9 @@ pub struct Start { /// If developtment mode is enabled, specify whether node 0 should generate traffic to drive the network #[clap(default_value = "false", long = "no-dev-txs")] pub no_dev_txs: bool, - /// Specify the path to a directory containing the ledger - #[clap(long = "storage_path")] - pub storage_path: Option, - - /// If development mode is enabled, specify the custom bonded balances as a json object. (default: None) + /// If development mode is enabled, specify the custom bonded balances as a JSON object (default: None) #[clap(long)] - dev_bonded_balances: Option, - - /// If the flag is set, the validator will allow untrusted peers to connect - #[clap(long = "allow-external-peers")] - allow_external_peers: bool, + pub dev_bonded_balances: Option, } impl Start { @@ -489,15 +487,21 @@ impl Start { // Parse the node type. let node_type = self.parse_node_type(); + // Parse the node IP. + let node_ip = match self.node { + Some(node_ip) => node_ip, + None => SocketAddr::from_str("0.0.0.0:4130").unwrap(), + }; + // Parse the BFT IP. + let bft_ip = match self.dev.is_some() { + true => self.bft, + false => None + }; // Parse the REST IP. let rest_ip = match self.norest { true => None, false => Some(self.rest), }; - // Parse the bft ip. - let bft_ip = if self.dev.is_some() { self.bft } else { None }; - // Parse the node ip. - let node_ip = if let Some(node_ip) = self.node { node_ip } else { SocketAddr::from_str("0.0.0.0:4130").unwrap() }; // If the display is not enabled, render the welcome message. if self.nodisplay { From b17ab57e529f7e35ca4ecc8c299efd5378b6e5f2 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Wed, 3 Apr 2024 14:46:17 -0700 Subject: [PATCH 321/551] Switches storage_path to storage --- cli/src/commands/start.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index 03fe2c82ae..06640bf5be 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -128,9 +128,9 @@ pub struct Start { #[clap(default_value = "false", long = "metrics")] pub metrics: bool, - /// Specify the path to a directory containing the ledger - #[clap(long = "storage_path")] - pub storage_path: Option, + /// Specify the path to a directory containing the storage database for the ledger + #[clap(long = "storage")] + pub storage: Option, /// Enables the node to prefetch initial blocks from a CDN #[clap(default_value = "https://s3.us-west-1.amazonaws.com/testnet3.blocks/phase3", long = "cdn")] pub cdn: String, @@ -541,7 +541,7 @@ impl Start { } // Initialize the storage mode. - let storage_mode = match &self.storage_path { + let storage_mode = match &self.storage { Some(path) => StorageMode::Custom(path.clone()), None => StorageMode::from(self.dev), }; From 1b6386f9688e8b4af0ca176057c30f4d60dfe901 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 3 Apr 2024 17:59:20 -0400 Subject: [PATCH 322/551] Remove unused derivations --- node/bft/src/helpers/proposal.rs | 1 - node/bft/src/primary.rs | 10 +++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/node/bft/src/helpers/proposal.rs b/node/bft/src/helpers/proposal.rs index 06db003c3d..1137ddaa68 100644 --- a/node/bft/src/helpers/proposal.rs +++ b/node/bft/src/helpers/proposal.rs @@ -28,7 +28,6 @@ use snarkvm::{ use indexmap::{IndexMap, IndexSet}; use std::collections::HashSet; -#[derive(Clone, Debug, PartialEq, Eq)] pub struct Proposal { /// The proposed batch header. batch_header: BatchHeader, diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 69773aa750..88d96211b0 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -1945,20 +1945,20 @@ mod tests { // Propose a batch again. This time, it should succeed. assert!(primary.propose_batch().await.is_ok()); - let original_proposed_batch = primary.proposed_batch.read().clone().unwrap(); + let original_proposed_batch_id = primary.proposed_batch.read().as_ref().unwrap().batch_id(); // Try to propose the batch again. This time, it should return the same proposal. assert!(primary.propose_batch().await.is_ok()); - let proposal = primary.proposed_batch.read().clone().unwrap(); - assert_eq!(proposal, original_proposed_batch); + let proposal_batch_id = primary.proposed_batch.read().as_ref().unwrap().batch_id(); + assert_eq!(proposal_batch_id, original_proposed_batch_id); // Sleep until the proposal is expired. tokio::time::sleep(Duration::from_secs(PROPOSAL_EXPIRATION_IN_SECS as u64)).await; // Try to propose a batch again. This time the proposal should be expired and a new proposal should be created. assert!(primary.propose_batch().await.is_ok()); - let new_proposal = primary.proposed_batch.read().clone().unwrap(); - assert_ne!(new_proposal, proposal); + let new_proposal_batch_id = primary.proposed_batch.read().as_ref().unwrap().batch_id(); + assert_ne!(new_proposal_batch_id, original_proposed_batch_id); } #[tokio::test] From 7fec5803a9212182640552655a40dfafea5064d8 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 3 Apr 2024 18:22:59 -0400 Subject: [PATCH 323/551] Unify timestamp checks to a helper method --- node/bft/src/helpers/timestamp.rs | 11 ++++++++++- node/bft/src/primary.rs | 9 +++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/node/bft/src/helpers/timestamp.rs b/node/bft/src/helpers/timestamp.rs index 2b361fa3cc..2769101b7d 100644 --- a/node/bft/src/helpers/timestamp.rs +++ b/node/bft/src/helpers/timestamp.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::MAX_TIMESTAMP_DELTA_IN_SECS; +use crate::{MAX_TIMESTAMP_DELTA_IN_SECS, PROPOSAL_EXPIRATION_IN_SECS}; use snarkvm::prelude::{bail, Result}; use time::OffsetDateTime; @@ -31,6 +31,15 @@ pub fn check_timestamp_for_liveness(timestamp: i64) -> Result<()> { Ok(()) } +/// Returns whether the proposal is expired. +pub fn is_proposal_expired(current_timestamp: i64, proposal_timestamp: i64) -> bool { + debug_assert!( + current_timestamp >= proposal_timestamp, + "Current timestamp must be greater or equal to the proposal timestamp" + ); + current_timestamp.saturating_sub(proposal_timestamp) >= PROPOSAL_EXPIRATION_IN_SECS +} + #[cfg(test)] mod prop_tests { use super::*; diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 88d96211b0..e0b7dcd2df 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -20,6 +20,7 @@ use crate::{ fmt_id, init_sync_channels, init_worker_channels, + is_proposal_expired, now, BFTSender, PrimaryReceiver, @@ -36,7 +37,6 @@ use crate::{ MAX_WORKERS, MIN_BATCH_DELAY_IN_SECS, PRIMARY_PING_IN_MS, - PROPOSAL_EXPIRATION_IN_SECS, WORKER_PING_IN_MS, }; use snarkos_account::Account; @@ -480,7 +480,7 @@ impl Primary { // Determine the current timestamp. let current_timestamp = now(); // Determine if the current proposal is expired. - let is_expired = current_timestamp.saturating_sub(lock_guard.1) >= PROPOSAL_EXPIRATION_IN_SECS; + let is_expired = is_proposal_expired(current_timestamp, lock_guard.1); if lock_guard.0 == round && !is_expired { warn!("Primary is safely skipping a batch proposal - round {round} already proposed"); return Ok(()); @@ -587,7 +587,7 @@ impl Primary { } // Determine if the proposal has expired. - let is_proposal_expired = now().saturating_sub(timestamp) >= PROPOSAL_EXPIRATION_IN_SECS; + let is_proposal_expired = is_proposal_expired(now(), timestamp); // If the round matches and the proposal has expired, then remove the cached signature. if signed_round == batch_header.round() && is_proposal_expired { self.signed_proposals.write().remove(&batch_author); @@ -1135,7 +1135,7 @@ impl Primary { // Determine if the proposal is stale. let is_stale = proposal.round() < self.current_round(); // Determine if the proposal is timed out. - let is_timed_out = now().saturating_sub(proposal.timestamp()) >= PROPOSAL_EXPIRATION_IN_SECS; + let is_timed_out = is_proposal_expired(now(), proposal.timestamp()); // Determine if the proposal is expired. is_stale || is_timed_out } @@ -1557,6 +1557,7 @@ impl Primary { #[cfg(test)] mod tests { use super::*; + use crate::PROPOSAL_EXPIRATION_IN_SECS; use snarkos_node_bft_ledger_service::MockLedgerService; use snarkos_node_bft_storage_service::BFTMemoryService; use snarkvm::{ From 830a8b8ae998e73f7a62c8ac51cf4f5d4c8bd734 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 3 Apr 2024 18:40:47 -0400 Subject: [PATCH 324/551] cleanup --- node/bft/src/primary.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index e0b7dcd2df..2f37854907 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -585,22 +585,22 @@ impl Primary { if signed_round > batch_header.round() { bail!("Proposed a batch for a previous round ({})", batch_header.round()); } - - // Determine if the proposal has expired. - let is_proposal_expired = is_proposal_expired(now(), timestamp); - // If the round matches and the proposal has expired, then remove the cached signature. - if signed_round == batch_header.round() && is_proposal_expired { - self.signed_proposals.write().remove(&batch_author); - } - // If the round matches and the batch ID differs, then the validator is malicious. - else if signed_round == batch_header.round() && signed_batch_id != batch_header.batch_id() { - // Proceed to disconnect the validator. - self.gateway.disconnect(peer_ip); - bail!("Malicious peer - proposed another batch for the same round ({signed_round})"); + // If the round matches and the batch ID differs, then check if the proposal is expired. + if signed_round == batch_header.round() && signed_batch_id != batch_header.batch_id() { + // Check if the proposal has expired. + match is_proposal_expired(now(), timestamp) { + // If the proposal has expired, then remove the cached signature. + true => self.signed_proposals.write().remove(&batch_author), + // If the proposal has not expired, then disconnect the validator. + false => { + self.gateway.disconnect(peer_ip); + bail!("Proposed another batch for the same round ({signed_round}) prior to expiration"); + } + }; } // If the round and batch ID matches, then skip signing the batch a second time. // Instead, rebroadcast the cached signature to the peer. - else if signed_round == batch_header.round() && signed_batch_id == batch_header.batch_id() { + if signed_round == batch_header.round() && signed_batch_id == batch_header.batch_id() { let gateway = self.gateway.clone(); tokio::spawn(async move { debug!("Resending a signature for a batch in round {batch_round} from '{peer_ip}'"); From 2e756352b21d71f12ac4e4cdb47e04280ef7fc39 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 3 Apr 2024 18:53:32 -0400 Subject: [PATCH 325/551] Fix tests --- node/bft/src/primary.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 2f37854907..5e27aa3d21 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -1936,6 +1936,9 @@ mod tests { assert!(primary.propose_batch().await.is_ok()); assert!(primary.proposed_batch.read().is_none()); + // Sleep for a while to ensure the primary is ready to propose the next round. + tokio::time::sleep(Duration::from_secs(MIN_BATCH_DELAY_IN_SECS)).await; + // Generate a solution and a transaction. let (solution_id, solution) = sample_unconfirmed_solution(&mut rng); let (transaction_id, transaction) = sample_unconfirmed_transaction(&mut rng); @@ -2119,6 +2122,9 @@ mod tests { // Generate certificates. let previous_certificates = store_certificate_chain(&primary, &accounts, round, &mut rng); + // Sleep for a while to ensure the primary is ready to propose the next round. + tokio::time::sleep(Duration::from_secs(MIN_BATCH_DELAY_IN_SECS)).await; + // Create a valid proposal with an author that isn't the primary. let peer_account = &accounts[1]; let peer_address = peer_account.1.address(); @@ -2182,6 +2188,9 @@ mod tests { // Generate certificates. let previous_certificates = store_certificate_chain(&primary, &accounts, round, &mut rng); + // Sleep for a while to ensure the primary is ready to propose the next round. + tokio::time::sleep(Duration::from_secs(MIN_BATCH_DELAY_IN_SECS)).await; + // Create a valid proposal with an author that isn't the primary. let peer_account = &accounts[1]; let peer_address = peer_account.1.address(); @@ -2332,6 +2341,9 @@ mod tests { // Store the proposal on the primary. *primary.proposed_batch.write() = Some(proposal); + // Sleep for a while to ensure the primary is ready to process the proposal. + tokio::time::sleep(Duration::from_secs(1)).await; + // Each committee member signs the batch. let signatures = peer_signatures_for_proposal(&primary, &accounts, &mut rng); @@ -2370,6 +2382,9 @@ mod tests { // Store the proposal on the primary. *primary.proposed_batch.write() = Some(proposal); + // Sleep for a while to ensure the primary is ready to process the proposal. + tokio::time::sleep(Duration::from_secs(1)).await; + // Each committee member signs the batch. let signatures = peer_signatures_for_proposal(&primary, &accounts, &mut rng); @@ -2405,6 +2420,9 @@ mod tests { // Store the proposal on the primary. *primary.proposed_batch.write() = Some(proposal); + // Sleep for a while to ensure the primary is ready to process the proposal. + tokio::time::sleep(Duration::from_secs(1)).await; + // Each committee member signs the batch. let signatures = peer_signatures_for_proposal(&primary, &accounts, &mut rng); @@ -2442,6 +2460,9 @@ mod tests { // Store the proposal on the primary. *primary.proposed_batch.write() = Some(proposal); + // Sleep for a while to ensure the primary is ready to process the proposal. + tokio::time::sleep(Duration::from_secs(1)).await; + // Each committee member signs the batch. let signatures = peer_signatures_for_proposal(&primary, &accounts, &mut rng); From 982b0171ee214e40fb65affc72d777365442a973 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 3 Apr 2024 18:58:11 -0400 Subject: [PATCH 326/551] Bump snarkVM rev - 39282a1 --- Cargo.lock | 119 +++++++++++++++++++++++++++-------------------------- Cargo.toml | 2 +- 2 files changed, 61 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d2d86d1bb5..e63e24e687 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3301,7 +3301,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "anstyle", "anyhow", @@ -3332,7 +3332,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "aleo-std", "anyhow", @@ -3362,7 +3362,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3376,7 +3376,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3387,7 +3387,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3397,7 +3397,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3407,7 +3407,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "indexmap 2.2.5", "itertools 0.11.0", @@ -3425,12 +3425,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3441,7 +3441,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3456,7 +3456,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3471,7 +3471,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3484,7 +3484,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3493,7 +3493,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3503,7 +3503,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3515,7 +3515,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3527,7 +3527,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3538,7 +3538,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3550,7 +3550,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3563,7 +3563,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "bs58", "snarkvm-console-network", @@ -3574,7 +3574,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "blake2s_simd", "smallvec", @@ -3587,7 +3587,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "aleo-std", "rayon", @@ -3598,7 +3598,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "anyhow", "indexmap 2.2.5", @@ -3621,7 +3621,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "anyhow", "bech32", @@ -3639,7 +3639,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "enum_index", "enum_index_derive", @@ -3660,7 +3660,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3675,7 +3675,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3686,7 +3686,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "snarkvm-console-network-environment", ] @@ -3694,7 +3694,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3704,7 +3704,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3715,7 +3715,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3726,7 +3726,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3737,7 +3737,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3748,7 +3748,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "rand", "rayon", @@ -3762,7 +3762,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "aleo-std", "anyhow", @@ -3779,7 +3779,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "aleo-std", "anyhow", @@ -3804,7 +3804,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "anyhow", "rand", @@ -3816,7 +3816,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3835,7 +3835,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "anyhow", "indexmap 2.2.5", @@ -3854,7 +3854,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -3867,7 +3867,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3880,7 +3880,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3893,7 +3893,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "bytes", "serde_json", @@ -3904,7 +3904,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3919,7 +3919,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "bytes", "serde_json", @@ -3932,7 +3932,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "snarkvm-console", "snarkvm-ledger-puzzle", @@ -3941,7 +3941,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "aleo-std", "anyhow", @@ -3961,7 +3961,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle-epoch" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "anyhow", "colored", @@ -3976,7 +3976,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "async-trait", "reqwest", @@ -3989,7 +3989,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "aleo-std-storage", "anyhow", @@ -4015,7 +4015,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4030,7 +4030,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4039,7 +4039,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "aleo-std", "anyhow", @@ -4064,7 +4064,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "aleo-std", "anyhow", @@ -4086,13 +4086,14 @@ dependencies = [ "snarkvm-synthesizer-process", "snarkvm-synthesizer-program", "snarkvm-synthesizer-snark", + "snarkvm-utilities", "tracing", ] [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "aleo-std", "colored", @@ -4115,7 +4116,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "indexmap 2.2.5", "paste", @@ -4129,7 +4130,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "bincode", "once_cell", @@ -4142,7 +4143,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "aleo-std", "anyhow", @@ -4163,7 +4164,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=0029b6a#0029b6a7ba23998c56c8abf4a1772c1f2763a0d4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" dependencies = [ "proc-macro2", "quote 1.0.35", diff --git a/Cargo.toml b/Cargo.toml index 64d09eb9b1..dd552cadf4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "0029b6a" +rev = "39282a1" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From 18486887cea28130493db8c8c72c9909080d9d08 Mon Sep 17 00:00:00 2001 From: Pranav Gaddamadugu <23022326+d0cd@users.noreply.github.com> Date: Wed, 3 Apr 2024 16:02:32 -0700 Subject: [PATCH 327/551] Silence instead of tracing solution errors within 10 blocks of the interval --- node/consensus/src/lib.rs | 13 +++---------- node/src/client/router.rs | 11 ++++++----- node/src/prover/router.rs | 13 +++++++------ 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index a91d2935c3..ea9a935968 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -265,16 +265,9 @@ impl Consensus { if let Err(e) = self.primary_sender().send_unconfirmed_solution(solution_id, Data::Object(solution)).await { // If the BFT is synced, then log the warning. if self.bft.is_synced() { - // If error occurs in the first 10 blocks of the epoch, then log it as a trace, otherwise log it as a warning. - match self.ledger().latest_block_height() % N::NUM_BLOCKS_PER_EPOCH <= 10 { - true => trace!( - "Failed to add unconfirmed solution '{}' to the memory pool - {e}", - fmt_id(solution_id) - ), - false => warn!( - "Failed to add unconfirmed solution '{}' to the memory pool - {e}", - fmt_id(solution_id) - ), + // If error occurs after the first 10 blocks of the epoch, log it as a warning, otherwise ignore. + if self.ledger().latest_block_height() % N::NUM_BLOCKS_PER_EPOCH <= 10 { + warn!("Failed to add unconfirmed solution '{}' to the memory pool - {e}", fmt_id(solution_id)) }; } } diff --git a/node/src/client/router.rs b/node/src/client/router.rs index 62133ab47d..f7cb2510aa 100644 --- a/node/src/client/router.rs +++ b/node/src/client/router.rs @@ -284,11 +284,12 @@ impl> Inbound for Client { Ok(Err(_)) => { trace!("Invalid solution '{}' for the proof target.", solution.id()) } - // If error occurs in the first 10 blocks of the epoch, then log it as a trace, otherwise log it as a warning. - Err(error) => match self.ledger.latest_height() % N::NUM_BLOCKS_PER_EPOCH <= 10 { - true => trace!("Failed to verify the solution - {error}"), - false => warn!("Failed to verify the solution - {error}"), - }, + // If error occurs after the first 10 blocks of the epoch, log it as a warning, otherwise ignore. + Err(error) => { + if self.ledger.latest_height() % N::NUM_BLOCKS_PER_EPOCH <= 10 { + warn!("Failed to verify the solution - {error}") + } + } } } true diff --git a/node/src/prover/router.rs b/node/src/prover/router.rs index 518c21f91c..1628ffac32 100644 --- a/node/src/prover/router.rs +++ b/node/src/prover/router.rs @@ -240,13 +240,14 @@ impl> Inbound for Prover { Ok(Err(_)) => { trace!("Invalid solution '{}' for the proof target.", solution.id()) } - // If error occurs in the first 10 blocks of the epoch, then log it as a trace, otherwise log it as a warning. - Err(error) => match self.latest_block_header.read().as_ref().map(|header| header.height()) { - Some(height) if height % N::NUM_BLOCKS_PER_EPOCH > 10 => { - warn!("Failed to verify the solution - {error}") + // If error occurs after the first 10 blocks of the epoch, log it as a warning, otherwise ignore. + Err(error) => { + if let Some(height) = self.latest_block_header.read().as_ref().map(|header| header.height()) { + if height % N::NUM_BLOCKS_PER_EPOCH > 10 { + warn!("Failed to verify the solution - {error}") + } } - _ => trace!("Failed to verify the solution - {error}"), - }, + } } } true From 080ee55a7c7b009e42426bf11d012fe1a38cc55a Mon Sep 17 00:00:00 2001 From: Pranav Gaddamadugu <23022326+d0cd@users.noreply.github.com> Date: Wed, 3 Apr 2024 16:03:59 -0700 Subject: [PATCH 328/551] Fix --- node/consensus/src/lib.rs | 2 +- node/src/client/router.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index ea9a935968..12005de1cf 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -266,7 +266,7 @@ impl Consensus { // If the BFT is synced, then log the warning. if self.bft.is_synced() { // If error occurs after the first 10 blocks of the epoch, log it as a warning, otherwise ignore. - if self.ledger().latest_block_height() % N::NUM_BLOCKS_PER_EPOCH <= 10 { + if self.ledger().latest_block_height() % N::NUM_BLOCKS_PER_EPOCH > 10 { warn!("Failed to add unconfirmed solution '{}' to the memory pool - {e}", fmt_id(solution_id)) }; } diff --git a/node/src/client/router.rs b/node/src/client/router.rs index f7cb2510aa..d71e21eb7e 100644 --- a/node/src/client/router.rs +++ b/node/src/client/router.rs @@ -286,7 +286,7 @@ impl> Inbound for Client { } // If error occurs after the first 10 blocks of the epoch, log it as a warning, otherwise ignore. Err(error) => { - if self.ledger.latest_height() % N::NUM_BLOCKS_PER_EPOCH <= 10 { + if self.ledger.latest_height() % N::NUM_BLOCKS_PER_EPOCH > 10 { warn!("Failed to verify the solution - {error}") } } From d389dd5d4aa8645452acd270c6d91d171e182528 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 4 Apr 2024 15:10:25 -0400 Subject: [PATCH 329/551] Update snarkVM rev - 36a1e0f --- Cargo.lock | 118 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 2 +- 2 files changed, 60 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e63e24e687..d5ea3a4e02 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3301,7 +3301,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "anstyle", "anyhow", @@ -3332,7 +3332,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "aleo-std", "anyhow", @@ -3362,7 +3362,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3376,7 +3376,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3387,7 +3387,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3397,7 +3397,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3407,7 +3407,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "indexmap 2.2.5", "itertools 0.11.0", @@ -3425,12 +3425,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3441,7 +3441,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3456,7 +3456,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3471,7 +3471,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3484,7 +3484,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3493,7 +3493,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3503,7 +3503,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3515,7 +3515,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3527,7 +3527,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3538,7 +3538,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3550,7 +3550,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3563,7 +3563,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "bs58", "snarkvm-console-network", @@ -3574,7 +3574,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "blake2s_simd", "smallvec", @@ -3587,7 +3587,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "aleo-std", "rayon", @@ -3598,7 +3598,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "anyhow", "indexmap 2.2.5", @@ -3621,7 +3621,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "anyhow", "bech32", @@ -3639,7 +3639,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "enum_index", "enum_index_derive", @@ -3660,7 +3660,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3675,7 +3675,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3686,7 +3686,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "snarkvm-console-network-environment", ] @@ -3694,7 +3694,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3704,7 +3704,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3715,7 +3715,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3726,7 +3726,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3737,7 +3737,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3748,7 +3748,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "rand", "rayon", @@ -3762,7 +3762,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "aleo-std", "anyhow", @@ -3779,7 +3779,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "aleo-std", "anyhow", @@ -3804,7 +3804,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "anyhow", "rand", @@ -3816,7 +3816,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3835,7 +3835,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "anyhow", "indexmap 2.2.5", @@ -3854,7 +3854,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -3867,7 +3867,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3880,7 +3880,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3893,7 +3893,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "bytes", "serde_json", @@ -3904,7 +3904,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3919,7 +3919,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "bytes", "serde_json", @@ -3932,7 +3932,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "snarkvm-console", "snarkvm-ledger-puzzle", @@ -3941,7 +3941,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "aleo-std", "anyhow", @@ -3961,7 +3961,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle-epoch" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "anyhow", "colored", @@ -3976,7 +3976,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "async-trait", "reqwest", @@ -3989,7 +3989,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "aleo-std-storage", "anyhow", @@ -4015,7 +4015,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4030,7 +4030,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4039,7 +4039,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "aleo-std", "anyhow", @@ -4064,7 +4064,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "aleo-std", "anyhow", @@ -4093,7 +4093,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "aleo-std", "colored", @@ -4116,7 +4116,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "indexmap 2.2.5", "paste", @@ -4130,7 +4130,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "bincode", "once_cell", @@ -4143,7 +4143,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "aleo-std", "anyhow", @@ -4164,7 +4164,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=39282a1#39282a1b53527b98f746b51014c41fb0377b17a4" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" dependencies = [ "proc-macro2", "quote 1.0.35", diff --git a/Cargo.toml b/Cargo.toml index dd552cadf4..ed8b581b81 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "39282a1" +rev = "36a1e0f" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From 2913459787d1912593bc69f29102766889e06f2e Mon Sep 17 00:00:00 2001 From: Pranav Gaddamadugu <23022326+d0cd@users.noreply.github.com> Date: Thu, 4 Apr 2024 21:52:21 -0700 Subject: [PATCH 330/551] Update snarkVM rev - ed20562 --- Cargo.lock | 118 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 2 +- 2 files changed, 60 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d5ea3a4e02..6c549775cc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3301,7 +3301,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "anstyle", "anyhow", @@ -3332,7 +3332,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "aleo-std", "anyhow", @@ -3362,7 +3362,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3376,7 +3376,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3387,7 +3387,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3397,7 +3397,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3407,7 +3407,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "indexmap 2.2.5", "itertools 0.11.0", @@ -3425,12 +3425,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3441,7 +3441,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3456,7 +3456,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3471,7 +3471,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3484,7 +3484,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3493,7 +3493,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3503,7 +3503,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3515,7 +3515,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3527,7 +3527,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3538,7 +3538,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3550,7 +3550,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3563,7 +3563,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "bs58", "snarkvm-console-network", @@ -3574,7 +3574,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "blake2s_simd", "smallvec", @@ -3587,7 +3587,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "aleo-std", "rayon", @@ -3598,7 +3598,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "anyhow", "indexmap 2.2.5", @@ -3621,7 +3621,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "anyhow", "bech32", @@ -3639,7 +3639,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "enum_index", "enum_index_derive", @@ -3660,7 +3660,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3675,7 +3675,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3686,7 +3686,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "snarkvm-console-network-environment", ] @@ -3694,7 +3694,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3704,7 +3704,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3715,7 +3715,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3726,7 +3726,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3737,7 +3737,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3748,7 +3748,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "rand", "rayon", @@ -3762,7 +3762,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "aleo-std", "anyhow", @@ -3779,7 +3779,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "aleo-std", "anyhow", @@ -3804,7 +3804,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "anyhow", "rand", @@ -3816,7 +3816,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3835,7 +3835,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "anyhow", "indexmap 2.2.5", @@ -3854,7 +3854,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -3867,7 +3867,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3880,7 +3880,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3893,7 +3893,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "bytes", "serde_json", @@ -3904,7 +3904,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3919,7 +3919,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "bytes", "serde_json", @@ -3932,7 +3932,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "snarkvm-console", "snarkvm-ledger-puzzle", @@ -3941,7 +3941,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "aleo-std", "anyhow", @@ -3961,7 +3961,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle-epoch" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "anyhow", "colored", @@ -3976,7 +3976,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "async-trait", "reqwest", @@ -3989,7 +3989,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "aleo-std-storage", "anyhow", @@ -4015,7 +4015,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4030,7 +4030,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4039,7 +4039,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "aleo-std", "anyhow", @@ -4064,7 +4064,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "aleo-std", "anyhow", @@ -4093,7 +4093,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "aleo-std", "colored", @@ -4116,7 +4116,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "indexmap 2.2.5", "paste", @@ -4130,7 +4130,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "bincode", "once_cell", @@ -4143,7 +4143,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "aleo-std", "anyhow", @@ -4164,7 +4164,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=36a1e0f#36a1e0fb285762eae8e15e93270845fc86938336" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "proc-macro2", "quote 1.0.35", diff --git a/Cargo.toml b/Cargo.toml index ed8b581b81..81b8254f8b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "36a1e0f" +rev = "ed20562" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From 8357eaee8986c6023ee1672fcbf23c3a03559769 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Mon, 8 Apr 2024 13:13:27 -0700 Subject: [PATCH 331/551] nit: reorder --- node/consensus/src/lib.rs | 83 ++++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 41 deletions(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 6538d2c2a8..fa97681b00 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -48,14 +48,15 @@ use colored::Colorize; use indexmap::IndexMap; use lru::LruCache; use parking_lot::Mutex; -#[cfg(feature = "metrics")] -use std::collections::HashMap; use std::{future::Future, net::SocketAddr, num::NonZeroUsize, sync::Arc}; use tokio::{ sync::{oneshot, OnceCell}, task::JoinHandle, }; +#[cfg(feature = "metrics")] +use std::collections::HashMap; + /// The capacity of the queue reserved for deployments. /// Note: This is an inbound queue capacity, not a Narwhal-enforced capacity. const CAPACITY_FOR_DEPLOYMENTS: usize = 1 << 10; @@ -100,10 +101,10 @@ pub struct Consensus { seen_solutions: Arc, ()>>>, /// The recently-seen unconfirmed transactions. seen_transactions: Arc>>, - /// The spawned handles. - handles: Arc>>>, #[cfg(feature = "metrics")] transmissions_queue_timestamps: Arc, i64>>>, + /// The spawned handles. + handles: Arc>>>, } impl Consensus { @@ -135,9 +136,9 @@ impl Consensus { transactions_queue: Default::default(), seen_solutions: Arc::new(Mutex::new(LruCache::new(NonZeroUsize::new(1 << 16).unwrap()))), seen_transactions: Arc::new(Mutex::new(LruCache::new(NonZeroUsize::new(1 << 16).unwrap()))), - handles: Default::default(), #[cfg(feature = "metrics")] transmissions_queue_timestamps: Default::default(), + handles: Default::default(), }) } @@ -456,6 +457,42 @@ impl Consensus { Ok(()) } + /// Reinserts the given transmissions into the memory pool. + async fn reinsert_transmissions(&self, transmissions: IndexMap, Transmission>) { + // Iterate over the transmissions. + for (transmission_id, transmission) in transmissions.into_iter() { + // Reinsert the transmission into the memory pool. + if let Err(e) = self.reinsert_transmission(transmission_id, transmission).await { + warn!("Unable to reinsert transmission {} into the memory pool - {e}", fmt_id(transmission_id)); + } + } + } + + /// Reinserts the given transmission into the memory pool. + async fn reinsert_transmission( + &self, + transmission_id: TransmissionID, + transmission: Transmission, + ) -> Result<()> { + // Initialize a callback sender and receiver. + let (callback, callback_receiver) = oneshot::channel(); + // Send the transmission to the primary. + match (transmission_id, transmission) { + (TransmissionID::Ratification, Transmission::Ratification) => return Ok(()), + (TransmissionID::Solution(solution_id), Transmission::Solution(solution)) => { + // Send the solution to the primary. + self.primary_sender().tx_unconfirmed_solution.send((solution_id, solution, callback)).await?; + } + (TransmissionID::Transaction(transaction_id), Transmission::Transaction(transaction)) => { + // Send the transaction to the primary. + self.primary_sender().tx_unconfirmed_transaction.send((transaction_id, transaction, callback)).await?; + } + _ => bail!("Mismatching `(transmission_id, transmission)` pair in consensus"), + } + // Await the callback. + callback_receiver.await? + } + #[cfg(feature = "metrics")] fn add_transmission_latency_metric(&self, next_block: &Block) { const AGE_THRESHOLD_SECONDS: i32 = 30 * 60; // 30 minutes set as stale transmission threshold @@ -501,42 +538,6 @@ impl Consensus { } } - /// Reinserts the given transmissions into the memory pool. - async fn reinsert_transmissions(&self, transmissions: IndexMap, Transmission>) { - // Iterate over the transmissions. - for (transmission_id, transmission) in transmissions.into_iter() { - // Reinsert the transmission into the memory pool. - if let Err(e) = self.reinsert_transmission(transmission_id, transmission).await { - warn!("Unable to reinsert transmission {} into the memory pool - {e}", fmt_id(transmission_id)); - } - } - } - - /// Reinserts the given transmission into the memory pool. - async fn reinsert_transmission( - &self, - transmission_id: TransmissionID, - transmission: Transmission, - ) -> Result<()> { - // Initialize a callback sender and receiver. - let (callback, callback_receiver) = oneshot::channel(); - // Send the transmission to the primary. - match (transmission_id, transmission) { - (TransmissionID::Ratification, Transmission::Ratification) => return Ok(()), - (TransmissionID::Solution(solution_id), Transmission::Solution(solution)) => { - // Send the solution to the primary. - self.primary_sender().tx_unconfirmed_solution.send((solution_id, solution, callback)).await?; - } - (TransmissionID::Transaction(transaction_id), Transmission::Transaction(transaction)) => { - // Send the transaction to the primary. - self.primary_sender().tx_unconfirmed_transaction.send((transaction_id, transaction, callback)).await?; - } - _ => bail!("Mismatching `(transmission_id, transmission)` pair in consensus"), - } - // Await the callback. - callback_receiver.await? - } - /// Spawns a task with the given future; it should only be used for long-running tasks. fn spawn + Send + 'static>(&self, future: T) { self.handles.lock().push(tokio::spawn(future)); From 348b21e7ce83d255d4bf24d2b889fade2c146488 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Mon, 8 Apr 2024 13:15:04 -0700 Subject: [PATCH 332/551] Include the aborted solution IDs and transaction IDs --- node/consensus/src/lib.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index fa97681b00..13b31a1c03 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -497,10 +497,16 @@ impl Consensus { fn add_transmission_latency_metric(&self, next_block: &Block) { const AGE_THRESHOLD_SECONDS: i32 = 30 * 60; // 30 minutes set as stale transmission threshold - let mut keys_to_remove = Vec::new(); + // Retrieve the solution IDs. + let solution_ids: std::collections::HashSet<_> = + next_block.solutions().solution_ids().chain(next_block.aborted_solution_ids()).collect(); + + // Retrieve the transaction IDs. + let transaction_ids: std::collections::HashSet<_> = + next_block.transaction_ids().chain(next_block.aborted_transaction_ids()).collect(); - let solution_ids: std::collections::HashSet<_> = next_block.solutions().solution_ids().collect(); - let transaction_ids: std::collections::HashSet<_> = next_block.transaction_ids().collect(); + // Initialize a list of keys to remove. + let mut keys_to_remove = Vec::new(); let mut transmission_queue_timestamps = self.transmissions_queue_timestamps.lock(); let ts_now = snarkos_node_bft::helpers::now(); From 53bd65d955a9c570035dc4baaa577d9502653441 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Mon, 8 Apr 2024 13:22:54 -0700 Subject: [PATCH 333/551] Parallelize potentially slow for loop --- Cargo.lock | 1 + node/consensus/Cargo.toml | 3 ++ node/consensus/src/lib.rs | 63 +++++++++++++++++++++------------------ 3 files changed, 38 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6c549775cc..9ba6c74fe9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3144,6 +3144,7 @@ dependencies = [ "once_cell", "parking_lot", "rand", + "rayon", "snarkos-account", "snarkos-node-bft", "snarkos-node-bft-ledger-service", diff --git a/node/consensus/Cargo.toml b/node/consensus/Cargo.toml index 81fdcd867b..ac9ccc1afb 100644 --- a/node/consensus/Cargo.toml +++ b/node/consensus/Cargo.toml @@ -48,6 +48,9 @@ version = "0.12" [dependencies.rand] version = "0.8" +[dependencies.rayon] +version = "1" + [dependencies.snarkos-account] path = "../../account" version = "=2.2.7" diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 13b31a1c03..7177f3e6a5 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -54,6 +54,8 @@ use tokio::{ task::JoinHandle, }; +#[cfg(feature = "metrics")] +use rayon::prelude::*; #[cfg(feature = "metrics")] use std::collections::HashMap; @@ -505,40 +507,43 @@ impl Consensus { let transaction_ids: std::collections::HashSet<_> = next_block.transaction_ids().chain(next_block.aborted_transaction_ids()).collect(); - // Initialize a list of keys to remove. - let mut keys_to_remove = Vec::new(); - let mut transmission_queue_timestamps = self.transmissions_queue_timestamps.lock(); let ts_now = snarkos_node_bft::helpers::now(); - for (key, timestamp) in transmission_queue_timestamps.iter() { - let elapsed_time = std::time::Duration::from_secs((ts_now - *timestamp) as u64); - - if elapsed_time.as_secs() > AGE_THRESHOLD_SECONDS as u64 { - // This entry is stale-- remove it from transmission queue and record it as a stale transmission. - metrics::increment_counter(metrics::consensus::STALE_UNCONFIRMED_TRANSMISSIONS); - keys_to_remove.push(*key); - } else { - let transmission_type = match key { - TransmissionID::Solution(solution_id) if solution_ids.contains(solution_id) => Some("solution"), - TransmissionID::Transaction(transaction_id) if transaction_ids.contains(transaction_id) => { - Some("transaction") + + // Determine which keys to remove. + let keys_to_remove = cfg_iter!(transmission_queue_timestamps) + .flat_map(|(key, timestamp)| { + let elapsed_time = std::time::Duration::from_secs((ts_now - *timestamp) as u64); + + if elapsed_time.as_secs() > AGE_THRESHOLD_SECONDS as u64 { + // This entry is stale-- remove it from transmission queue and record it as a stale transmission. + metrics::increment_counter(metrics::consensus::STALE_UNCONFIRMED_TRANSMISSIONS); + Some(*key) + } else { + let transmission_type = match key { + TransmissionID::Solution(solution_id) if solution_ids.contains(solution_id) => Some("solution"), + TransmissionID::Transaction(transaction_id) if transaction_ids.contains(transaction_id) => { + Some("transaction") + } + _ => None, + }; + + if let Some(transmission_type_string) = transmission_type { + metrics::histogram_label( + metrics::consensus::TRANSMISSION_LATENCY, + "transmission_type", + transmission_type_string.to_owned(), + elapsed_time.as_secs_f64(), + ); + Some(*key) + } else { + None } - _ => None, - }; - - if let Some(transmission_type_string) = transmission_type { - metrics::histogram_label( - metrics::consensus::TRANSMISSION_LATENCY, - "transmission_type", - transmission_type_string.to_owned(), - elapsed_time.as_secs_f64(), - ); - keys_to_remove.push(*key); } - } - } + }) + .collect::>(); - // Remove keys of stale or seen transmissions + // Remove keys of stale or seen transmissions. for key in keys_to_remove { transmission_queue_timestamps.remove(&key); } From 1ebf4d599f8ea7b8389f0fb4af2f0f5f19e03557 Mon Sep 17 00:00:00 2001 From: miazn Date: Mon, 8 Apr 2024 17:24:36 -0400 Subject: [PATCH 334/551] remove register histogram --- node/metrics/src/names.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/node/metrics/src/names.rs b/node/metrics/src/names.rs index 7f5820e4cf..4d696c3873 100644 --- a/node/metrics/src/names.rs +++ b/node/metrics/src/names.rs @@ -38,11 +38,10 @@ pub(super) const GAUGE_NAMES: [&str; 21] = [ tcp::TCP_TASKS, ]; -pub(super) const HISTOGRAM_NAMES: [&str; 8] = [ +pub(super) const HISTOGRAM_NAMES: [&str; 7] = [ bft::COMMIT_ROUNDS_LATENCY, consensus::CERTIFICATE_COMMIT_LATENCY, consensus::BLOCK_LATENCY, - consensus::TRANSMISSION_LATENCY, tcp::NOISE_CODEC_ENCRYPTION_TIME, tcp::NOISE_CODEC_DECRYPTION_TIME, tcp::NOISE_CODEC_ENCRYPTION_SIZE, From 8e79de5154be9fd88494a1e6263fbd61e9c2abbb Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 8 Apr 2024 17:59:05 -0400 Subject: [PATCH 335/551] Add aborted_transmissions to find_missing_transmissions --- node/bft/storage-service/src/memory.rs | 22 +++++++++++++------ node/bft/storage-service/src/persistent.rs | 25 ++++++++++++++++------ node/bft/storage-service/src/traits.rs | 6 +++++- 3 files changed, 38 insertions(+), 15 deletions(-) diff --git a/node/bft/storage-service/src/memory.rs b/node/bft/storage-service/src/memory.rs index f91623bd3f..d4ffc6ca98 100644 --- a/node/bft/storage-service/src/memory.rs +++ b/node/bft/storage-service/src/memory.rs @@ -20,7 +20,7 @@ use snarkvm::{ use indexmap::{indexset, map::Entry, IndexMap, IndexSet}; use parking_lot::RwLock; -use std::collections::HashMap; +use std::collections::{HashMap, HashSet}; use tracing::error; /// A BFT in-memory storage service. @@ -63,6 +63,7 @@ impl StorageService for BFTMemoryService { &self, batch_header: &BatchHeader, mut transmissions: HashMap, Transmission>, + aborted_transmissions: HashSet>, ) -> Result, Transmission>> { // Initialize a list for the missing transmissions from storage. let mut missing_transmissions = HashMap::new(); @@ -70,14 +71,21 @@ impl StorageService for BFTMemoryService { let known_transmissions = self.transmissions.read(); // Ensure the declared transmission IDs are all present in storage or the given transmissions map. for transmission_id in batch_header.transmission_ids() { - // If the transmission ID does not exist, ensure it was provided by the caller. + // If the transmission ID does not exist, ensure it was provided by the caller or aborted. if !known_transmissions.contains_key(transmission_id) { // Retrieve the transmission. - let Some(transmission) = transmissions.remove(transmission_id) else { - bail!("Failed to provide a transmission"); - }; - // Append the transmission. - missing_transmissions.insert(*transmission_id, transmission); + match transmissions.remove(transmission_id) { + // Append the transmission if it exists. + Some(transmission) => { + missing_transmissions.insert(*transmission_id, transmission); + } + // If the transmission does not exist, check if it was aborted. + None => { + if !aborted_transmissions.contains(transmission_id) { + bail!("Failed to provide a transmission"); + } + } + } } } Ok(missing_transmissions) diff --git a/node/bft/storage-service/src/persistent.rs b/node/bft/storage-service/src/persistent.rs index a44b428e18..a3fc665d17 100644 --- a/node/bft/storage-service/src/persistent.rs +++ b/node/bft/storage-service/src/persistent.rs @@ -33,7 +33,10 @@ use snarkvm::{ use aleo_std::StorageMode; use indexmap::{indexset, IndexSet}; -use std::{borrow::Cow, collections::HashMap}; +use std::{ + borrow::Cow, + collections::{HashMap, HashSet}, +}; use tracing::error; /// A BFT persistent storage service. @@ -91,19 +94,27 @@ impl StorageService for BFTPersistentStorage { &self, batch_header: &BatchHeader, mut transmissions: HashMap, Transmission>, + aborted_transmissions: HashSet>, ) -> Result, Transmission>> { // Initialize a list for the missing transmissions from storage. let mut missing_transmissions = HashMap::new(); // Ensure the declared transmission IDs are all present in storage or the given transmissions map. for transmission_id in batch_header.transmission_ids() { - // If the transmission ID does not exist, ensure it was provided by the caller. + // If the transmission ID does not exist, ensure it was provided by the caller or aborted. if !self.contains_transmission(*transmission_id) { // Retrieve the transmission. - let Some(transmission) = transmissions.remove(transmission_id) else { - bail!("Failed to provide a transmission"); - }; - // Append the transmission. - missing_transmissions.insert(*transmission_id, transmission); + match transmissions.remove(transmission_id) { + // Append the transmission if it exists. + Some(transmission) => { + missing_transmissions.insert(*transmission_id, transmission); + } + // If the transmission does not exist, check if it was aborted. + None => { + if !aborted_transmissions.contains(transmission_id) { + bail!("Failed to provide a transmission"); + } + } + } } } Ok(missing_transmissions) diff --git a/node/bft/storage-service/src/traits.rs b/node/bft/storage-service/src/traits.rs index 8770c770fb..d2c1478978 100644 --- a/node/bft/storage-service/src/traits.rs +++ b/node/bft/storage-service/src/traits.rs @@ -18,7 +18,10 @@ use snarkvm::{ }; use indexmap::IndexSet; -use std::{collections::HashMap, fmt::Debug}; +use std::{ + collections::{HashMap, HashSet}, + fmt::Debug, +}; pub trait StorageService: Debug + Send + Sync { /// Returns `true` if the storage contains the specified `transmission ID`. @@ -33,6 +36,7 @@ pub trait StorageService: Debug + Send + Sync { &self, batch_header: &BatchHeader, transmissions: HashMap, Transmission>, + aborted_transmissions: HashSet>, ) -> Result, Transmission>>; /// Inserts the given certificate ID for each of the transmission IDs, using the missing transmissions map, into storage. From bf07a9225e6e6cd998c408c18a41af5001629863 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 8 Apr 2024 18:04:11 -0400 Subject: [PATCH 336/551] Track aborted transactions in insert_certificate and check_certificate --- node/bft/src/helpers/storage.rs | 33 +++++++++++++++++++++++++++------ node/bft/src/primary.rs | 11 ++++++----- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/node/bft/src/helpers/storage.rs b/node/bft/src/helpers/storage.rs index f69b45b56d..1cd51464a0 100644 --- a/node/bft/src/helpers/storage.rs +++ b/node/bft/src/helpers/storage.rs @@ -339,6 +339,7 @@ impl Storage { &self, batch_header: &BatchHeader, transmissions: HashMap, Transmission>, + aborted_transmissions: HashSet>, ) -> Result, Transmission>> { // Retrieve the round. let round = batch_header.round(); @@ -367,7 +368,7 @@ impl Storage { // Retrieve the missing transmissions in storage from the given transmissions. let missing_transmissions = self .transmissions - .find_missing_transmissions(batch_header, transmissions) + .find_missing_transmissions(batch_header, transmissions, aborted_transmissions) .map_err(|e| anyhow!("{e} for round {round} {gc_log}"))?; // Compute the previous round. @@ -435,6 +436,7 @@ impl Storage { &self, certificate: &BatchCertificate, transmissions: HashMap, Transmission>, + aborted_transmissions: HashSet>, ) -> Result, Transmission>> { // Retrieve the round. let round = certificate.round(); @@ -454,7 +456,8 @@ impl Storage { } // Ensure the batch header is well-formed. - let missing_transmissions = self.check_batch_header(certificate.batch_header(), transmissions)?; + let missing_transmissions = + self.check_batch_header(certificate.batch_header(), transmissions, aborted_transmissions)?; // Check the timestamp for liveness. check_timestamp_for_liveness(certificate.timestamp())?; @@ -503,11 +506,12 @@ impl Storage { &self, certificate: BatchCertificate, transmissions: HashMap, Transmission>, + aborted_transmissions: HashSet>, ) -> Result<()> { // Ensure the certificate round is above the GC round. ensure!(certificate.round() > self.gc_round(), "Certificate round is at or below the GC round"); // Ensure the certificate and its transmissions are valid. - let missing_transmissions = self.check_certificate(&certificate, transmissions)?; + let missing_transmissions = self.check_certificate(&certificate, transmissions, aborted_transmissions)?; // Insert the certificate into storage. self.insert_certificate_atomic(certificate, missing_transmissions); Ok(()) @@ -631,6 +635,9 @@ impl Storage { // Retrieve the transmissions for the certificate. let mut missing_transmissions = HashMap::new(); + // Retrieve the aborted transmissions for the certificate. + let mut aborted_transmissions = HashSet::new(); + // Iterate over the transmission IDs. for transmission_id in certificate.transmission_ids() { // If the transmission ID already exists in the map, skip it. @@ -653,8 +660,15 @@ impl Storage { None => match self.ledger.get_solution(solution_id) { // Insert the solution. Ok(solution) => missing_transmissions.insert(*transmission_id, solution.into()), + // Check if the solution is in the aborted solutions. Err(_) => { - error!("Missing solution {solution_id} in block {}", block.height()); + // Insert the aborted solution if it exists in the block. + match block.aborted_solution_ids().contains(solution_id) { + true => { + aborted_transmissions.insert(*transmission_id); + } + false => error!("Missing solution {solution_id} in block {}", block.height()), + } continue; } }, @@ -669,8 +683,15 @@ impl Storage { None => match self.ledger.get_unconfirmed_transaction(*transaction_id) { // Insert the transaction. Ok(transaction) => missing_transmissions.insert(*transmission_id, transaction.into()), + // Check if the transaction is in the aborted transactions. Err(_) => { - warn!("Missing transaction {transaction_id} in block {}", block.height()); + // Insert the aborted transaction if it exists in the block. + match block.aborted_transaction_ids().contains(transaction_id) { + true => { + aborted_transmissions.insert(*transmission_id); + } + false => warn!("Missing transaction {transaction_id} in block {}", block.height()), + } continue; } }, @@ -685,7 +706,7 @@ impl Storage { certificate.round(), certificate.transmission_ids().len() ); - if let Err(error) = self.insert_certificate(certificate, missing_transmissions) { + if let Err(error) = self.insert_certificate(certificate, missing_transmissions, aborted_transmissions) { error!("Failed to insert certificate '{certificate_id}' from block {} - {error}", block.height()); } } diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 5e27aa3d21..c7498697ba 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -647,7 +647,8 @@ impl Primary { // Ensure the batch header from the peer is valid. let (storage, header) = (self.storage.clone(), batch_header.clone()); - let missing_transmissions = spawn_blocking!(storage.check_batch_header(&header, transmissions))?; + let missing_transmissions = + spawn_blocking!(storage.check_batch_header(&header, transmissions, Default::default()))?; // Inserts the missing transmissions into the workers. self.insert_missing_transmissions_into_workers(peer_ip, missing_transmissions.into_iter())?; @@ -1263,7 +1264,7 @@ impl Primary { let transmissions = transmissions.into_iter().collect::>(); // Store the certified batch. let (storage, certificate_) = (self.storage.clone(), certificate.clone()); - spawn_blocking!(storage.insert_certificate(certificate_, transmissions))?; + spawn_blocking!(storage.insert_certificate(certificate_, transmissions, Default::default()))?; debug!("Stored a batch certificate for round {}", certificate.round()); // If a BFT sender was provided, send the certificate to the BFT. if let Some(bft_sender) = self.bft_sender.get() { @@ -1343,7 +1344,7 @@ impl Primary { if !self.storage.contains_certificate(certificate.id()) { // Store the batch certificate. let (storage, certificate_) = (self.storage.clone(), certificate.clone()); - spawn_blocking!(storage.insert_certificate(certificate_, missing_transmissions))?; + spawn_blocking!(storage.insert_certificate(certificate_, missing_transmissions, Default::default()))?; debug!("Stored a batch certificate for round {batch_round} from '{peer_ip}'"); // If a BFT sender was provided, send the round and certificate to the BFT. if let Some(bft_sender) = self.bft_sender.get() { @@ -1777,7 +1778,7 @@ mod tests { rng, ); next_certificates.insert(certificate.id()); - assert!(primary.storage.insert_certificate(certificate, transmissions).is_ok()); + assert!(primary.storage.insert_certificate(certificate, transmissions, Default::default()).is_ok()); } assert!(primary.storage.increment_to_next_round(cur_round).is_ok()); @@ -1900,7 +1901,7 @@ mod tests { // Insert the certificate to storage. num_transmissions_in_previous_round += transmissions.len(); - primary.storage.insert_certificate(certificate, transmissions).unwrap(); + primary.storage.insert_certificate(certificate, transmissions, Default::default()).unwrap(); } // Sleep for a while to ensure the primary is ready to propose the next round. From 190cd43fd6549fa9ee166c5ebe275b8ca9568e62 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 8 Apr 2024 18:31:22 -0400 Subject: [PATCH 337/551] Add test for inserting certificate with aborted transmissions --- node/bft/src/primary.rs | 75 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index c7498697ba..7f86443b93 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -2476,4 +2476,79 @@ mod tests { // Check the round was incremented. assert_eq!(primary.current_round(), round); } + + #[tokio::test] + async fn test_insert_certificate_with_aborted_transmissions() { + let round = 3; + let prev_round = round - 1; + let mut rng = TestRng::default(); + let (primary, accounts) = primary_without_handlers(&mut rng).await; + let peer_account = &accounts[1]; + let peer_ip = peer_account.0; + + // Fill primary storage. + store_certificate_chain(&primary, &accounts, round, &mut rng); + + // Get transmissions from previous certificates. + let previous_certificate_ids: IndexSet<_> = + primary.storage.get_certificates_for_round(prev_round).iter().map(|cert| cert.id()).collect(); + + // Generate a solution and a transaction. + let (solution_commitment, solution) = sample_unconfirmed_solution(&mut rng); + let (transaction_id, transaction) = sample_unconfirmed_transaction(&mut rng); + + // Store it on one of the workers. + primary.workers[0].process_unconfirmed_solution(solution_commitment, solution).await.unwrap(); + primary.workers[0].process_unconfirmed_transaction(transaction_id, transaction).await.unwrap(); + + // Check that the worker has 2 transmissions. + assert_eq!(primary.workers[0].num_transmissions(), 2); + + // Create certificates for the current round. + let account = accounts[0].1.clone(); + let (certificate, transmissions) = + create_batch_certificate(account.address(), &accounts, round, previous_certificate_ids.clone(), &mut rng); + let certificate_id = certificate.id(); + + // Randomly abort some of the transmissions. + let mut aborted_transmissions = HashSet::new(); + let mut transmissions_without_aborted = HashMap::new(); + for (transmission_id, transmission) in transmissions.clone() { + match rng.gen::() { + true => { + // Insert the aborted transmission. + aborted_transmissions.insert(transmission_id); + } + false => { + // Insert the transmission without the aborted transmission. + transmissions_without_aborted.insert(transmission_id, transmission); + } + }; + } + + // Add the non-aborted transmissions to the worker. + for (transmission_id, transmission) in transmissions_without_aborted.iter() { + primary.workers[0].process_transmission_from_peer(peer_ip, *transmission_id, transmission.clone()); + } + + // Check that inserting the transmission with missing transmissions fails. + assert!( + primary + .storage + .check_certificate(&certificate, transmissions_without_aborted.clone(), Default::default()) + .is_err() + ); + assert!( + primary + .storage + .insert_certificate(certificate.clone(), transmissions_without_aborted.clone(), Default::default()) + .is_err() + ); + + // Insert the certificate to storage. + primary.storage.insert_certificate(certificate, transmissions_without_aborted, aborted_transmissions).unwrap(); + + // Ensure the certificate exists in storage. + assert!(primary.storage.contains_certificate(certificate_id)); + } } From e753a81d64baa7679fb14d7b597f25324d4f4161 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 8 Apr 2024 18:38:35 -0400 Subject: [PATCH 338/551] Add ledger check for aborted transmissions --- node/bft/src/helpers/storage.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/node/bft/src/helpers/storage.rs b/node/bft/src/helpers/storage.rs index 1cd51464a0..d97e552fed 100644 --- a/node/bft/src/helpers/storage.rs +++ b/node/bft/src/helpers/storage.rs @@ -662,8 +662,10 @@ impl Storage { Ok(solution) => missing_transmissions.insert(*transmission_id, solution.into()), // Check if the solution is in the aborted solutions. Err(_) => { - // Insert the aborted solution if it exists in the block. - match block.aborted_solution_ids().contains(solution_id) { + // Insert the aborted solution if it exists in the block or ledger. + match block.aborted_solution_ids().contains(solution_id) + || self.ledger.contains_transmission(transmission_id).unwrap_or(false) + { true => { aborted_transmissions.insert(*transmission_id); } @@ -685,8 +687,10 @@ impl Storage { Ok(transaction) => missing_transmissions.insert(*transmission_id, transaction.into()), // Check if the transaction is in the aborted transactions. Err(_) => { - // Insert the aborted transaction if it exists in the block. - match block.aborted_transaction_ids().contains(transaction_id) { + // Insert the aborted transaction if it exists in the block or ledger. + match block.aborted_transaction_ids().contains(transaction_id) + || self.ledger.contains_transmission(transmission_id).unwrap_or(false) + { true => { aborted_transmissions.insert(*transmission_id); } From f812c260a97e87c3648584ef805be6293badc679 Mon Sep 17 00:00:00 2001 From: miazn Date: Tue, 9 Apr 2024 14:32:04 -0400 Subject: [PATCH 339/551] move some metrics to CoreLedgerService, out of consensus --- node/bft/ledger-service/src/ledger.rs | 11 +++++++++++ node/consensus/src/lib.rs | 8 -------- node/metrics/src/names.rs | 12 +++++------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/node/bft/ledger-service/src/ledger.rs b/node/bft/ledger-service/src/ledger.rs index 5c19e83215..d87052ce7d 100644 --- a/node/bft/ledger-service/src/ledger.rs +++ b/node/bft/ledger-service/src/ledger.rs @@ -336,4 +336,15 @@ impl> LedgerService for CoreLedgerService< tracing::info!("\n\nAdvanced to block {} at round {} - {}\n", block.height(), block.round(), block.hash()); Ok(()) } + + #[cfg(feature = "metrics")] + fn update_bft_metrics(&self, block: &Block) { + let num_sol = next_block.solutions().len(); + let num_tx = next_block.transactions().len(); + + metrics::gauge(metrics::bft::HEIGHT, block.height() as f64); + metrics::gauge(metrics::bft::LAST_COMMITTED_ROUND, block.round() as f64); + metrics::increment_gauge(metrics::blocks::SOLUTIONS, num_sol as f64); + metrics::increment_gauge(metrics::blocks::TRANSACTIONS, num_tx as f64); + } } diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 7177f3e6a5..29d50affbe 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -435,20 +435,12 @@ impl Consensus { let elapsed = std::time::Duration::from_secs((snarkos_node_bft::helpers::now() - start) as u64); let next_block_timestamp = next_block.header().metadata().timestamp(); let block_latency = next_block_timestamp - current_block_timestamp; - let num_sol = next_block.solutions().len(); - let num_tx = next_block.transactions().len(); - let num_transmissions = num_tx + num_sol; let proof_target = next_block.header().proof_target(); let coinbase_target = next_block.header().coinbase_target(); let cumulative_proof_target = next_block.header().cumulative_proof_target(); self.add_transmission_latency_metric(&next_block); - metrics::gauge(metrics::blocks::HEIGHT, next_block.height() as f64); - metrics::increment_gauge(metrics::blocks::SOLUTIONS, num_sol as f64); - metrics::increment_gauge(metrics::blocks::TRANSACTIONS, num_tx as f64); - metrics::increment_gauge(metrics::blocks::TRANSMISSIONS, num_transmissions as f64); - metrics::gauge(metrics::consensus::LAST_COMMITTED_ROUND, next_block.round() as f64); metrics::gauge(metrics::consensus::COMMITTED_CERTIFICATES, num_committed_certificates as f64); metrics::histogram(metrics::consensus::CERTIFICATE_COMMIT_LATENCY, elapsed.as_secs_f64()); metrics::histogram(metrics::consensus::BLOCK_LATENCY, block_latency as f64); diff --git a/node/metrics/src/names.rs b/node/metrics/src/names.rs index 4d696c3873..217a7c0ca2 100644 --- a/node/metrics/src/names.rs +++ b/node/metrics/src/names.rs @@ -14,21 +14,20 @@ pub(super) const COUNTER_NAMES: [&str; 2] = [bft::LEADERS_ELECTED, consensus::STALE_UNCONFIRMED_TRANSMISSIONS]; -pub(super) const GAUGE_NAMES: [&str; 21] = [ +pub(super) const GAUGE_NAMES: [&str; 20] = [ bft::CONNECTED, bft::CONNECTING, bft::LAST_STORED_ROUND, bft::PROPOSAL_ROUND, bft::CERTIFIED_BATCHES, - blocks::HEIGHT, + bft::HEIGHT, + bft::LAST_COMMITTED_ROUND, blocks::SOLUTIONS, blocks::TRANSACTIONS, - blocks::TRANSMISSIONS, blocks::PROOF_TARGET, blocks::COINBASE_TARGET, blocks::CUMULATIVE_PROOF_TARGET, consensus::COMMITTED_CERTIFICATES, - consensus::LAST_COMMITTED_ROUND, consensus::UNCONFIRMED_SOLUTIONS, consensus::UNCONFIRMED_TRANSACTIONS, consensus::UNCONFIRMED_TRANSMISSIONS, @@ -56,12 +55,12 @@ pub mod bft { pub const LEADERS_ELECTED: &str = "snarkos_bft_leaders_elected_total"; pub const PROPOSAL_ROUND: &str = "snarkos_bft_primary_proposal_round"; pub const CERTIFIED_BATCHES: &str = "snarkos_bft_primary_certified_batches"; + pub const HEIGHT: &str = "snarkos_bft_height_total"; + pub const LAST_COMMITTED_ROUND: &str = "snarkos_bft_last_committed_round"; } pub mod blocks { - pub const HEIGHT: &str = "snarkos_blocks_height_total"; pub const TRANSACTIONS: &str = "snarkos_blocks_transactions_total"; - pub const TRANSMISSIONS: &str = "snarkos_blocks_transmissions_total"; pub const SOLUTIONS: &str = "snarkos_blocks_solutions_total"; pub const PROOF_TARGET: &str = "snarkos_blocks_proof_target"; pub const COINBASE_TARGET: &str = "snarkos_blocks_coinbase_target"; @@ -71,7 +70,6 @@ pub mod blocks { pub mod consensus { pub const CERTIFICATE_COMMIT_LATENCY: &str = "snarkos_consensus_certificate_commit_latency_secs"; pub const COMMITTED_CERTIFICATES: &str = "snarkos_consensus_committed_certificates_total"; - pub const LAST_COMMITTED_ROUND: &str = "snarkos_consensus_last_committed_round"; pub const BLOCK_LATENCY: &str = "snarkos_consensus_block_latency_secs"; pub const UNCONFIRMED_TRANSACTIONS: &str = "snarkos_consensus_unconfirmed_transactions_total"; pub const UNCONFIRMED_TRANSMISSIONS: &str = "snarkos_consensus_unconfirmed_transmissions_total"; From 2646592b36f1d0806572ad38b084c23937c74ce0 Mon Sep 17 00:00:00 2001 From: miazn Date: Tue, 9 Apr 2024 15:12:37 -0400 Subject: [PATCH 340/551] add func --- node/bft/ledger-service/src/ledger.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/node/bft/ledger-service/src/ledger.rs b/node/bft/ledger-service/src/ledger.rs index d87052ce7d..d91a377847 100644 --- a/node/bft/ledger-service/src/ledger.rs +++ b/node/bft/ledger-service/src/ledger.rs @@ -333,6 +333,10 @@ impl> LedgerService for CoreLedgerService< } // Advance to the next block. self.ledger.advance_to_next_block(block)?; + // Update BFT metrics. + #[cfg(feature = "metrics")] + self.update_bft_metrics(block); + tracing::info!("\n\nAdvanced to block {} at round {} - {}\n", block.height(), block.round(), block.hash()); Ok(()) } From 19ba95e01cad558845c29f2f8ec6c060b60f81b3 Mon Sep 17 00:00:00 2001 From: miazn Date: Tue, 9 Apr 2024 15:47:36 -0400 Subject: [PATCH 341/551] remove unconfirmed transmissions --- node/bft/ledger-service/src/ledger.rs | 4 ++-- node/consensus/src/lib.rs | 2 -- node/metrics/src/names.rs | 4 +--- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/node/bft/ledger-service/src/ledger.rs b/node/bft/ledger-service/src/ledger.rs index d91a377847..2ceec88fbd 100644 --- a/node/bft/ledger-service/src/ledger.rs +++ b/node/bft/ledger-service/src/ledger.rs @@ -343,8 +343,8 @@ impl> LedgerService for CoreLedgerService< #[cfg(feature = "metrics")] fn update_bft_metrics(&self, block: &Block) { - let num_sol = next_block.solutions().len(); - let num_tx = next_block.transactions().len(); + let num_sol = block.solutions().len(); + let num_tx = block.transactions().len(); metrics::gauge(metrics::bft::HEIGHT, block.height() as f64); metrics::gauge(metrics::bft::LAST_COMMITTED_ROUND, block.round() as f64); diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 29d50affbe..3b6471e13d 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -225,7 +225,6 @@ impl Consensus { #[cfg(feature = "metrics")] { metrics::increment_gauge(metrics::consensus::UNCONFIRMED_SOLUTIONS, 1f64); - metrics::increment_gauge(metrics::consensus::UNCONFIRMED_TRANSMISSIONS, 1f64); let timestamp = snarkos_node_bft::helpers::now(); self.transmissions_queue_timestamps.lock().insert(TransmissionID::Solution(solution.id()), timestamp); } @@ -291,7 +290,6 @@ impl Consensus { #[cfg(feature = "metrics")] { metrics::increment_gauge(metrics::consensus::UNCONFIRMED_TRANSACTIONS, 1f64); - metrics::increment_gauge(metrics::consensus::UNCONFIRMED_TRANSMISSIONS, 1f64); let timestamp = snarkos_node_bft::helpers::now(); self.transmissions_queue_timestamps.lock().insert(TransmissionID::Transaction(transaction.id()), timestamp); } diff --git a/node/metrics/src/names.rs b/node/metrics/src/names.rs index 217a7c0ca2..8dec924a7b 100644 --- a/node/metrics/src/names.rs +++ b/node/metrics/src/names.rs @@ -14,7 +14,7 @@ pub(super) const COUNTER_NAMES: [&str; 2] = [bft::LEADERS_ELECTED, consensus::STALE_UNCONFIRMED_TRANSMISSIONS]; -pub(super) const GAUGE_NAMES: [&str; 20] = [ +pub(super) const GAUGE_NAMES: [&str; 19] = [ bft::CONNECTED, bft::CONNECTING, bft::LAST_STORED_ROUND, @@ -30,7 +30,6 @@ pub(super) const GAUGE_NAMES: [&str; 20] = [ consensus::COMMITTED_CERTIFICATES, consensus::UNCONFIRMED_SOLUTIONS, consensus::UNCONFIRMED_TRANSACTIONS, - consensus::UNCONFIRMED_TRANSMISSIONS, router::CONNECTED, router::CANDIDATE, router::RESTRICTED, @@ -72,7 +71,6 @@ pub mod consensus { pub const COMMITTED_CERTIFICATES: &str = "snarkos_consensus_committed_certificates_total"; pub const BLOCK_LATENCY: &str = "snarkos_consensus_block_latency_secs"; pub const UNCONFIRMED_TRANSACTIONS: &str = "snarkos_consensus_unconfirmed_transactions_total"; - pub const UNCONFIRMED_TRANSMISSIONS: &str = "snarkos_consensus_unconfirmed_transmissions_total"; pub const UNCONFIRMED_SOLUTIONS: &str = "snarkos_consensus_unconfirmed_solutions_total"; pub const TRANSMISSION_LATENCY: &str = "snarkos_consensus_transmission_latency"; pub const STALE_UNCONFIRMED_TRANSMISSIONS: &str = "snarkos_consensus_stale_unconfirmed_transmissions"; From 234f11e86c7142c4cdfcf04bc2145b73d523ab78 Mon Sep 17 00:00:00 2001 From: miazn Date: Tue, 9 Apr 2024 16:19:40 -0400 Subject: [PATCH 342/551] fmt --- Cargo.lock | 1 + node/bft/Cargo.toml | 2 +- node/bft/ledger-service/Cargo.toml | 7 +++++++ node/bft/ledger-service/src/ledger.rs | 21 +++++++++------------ 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9ba6c74fe9..e93e06f25d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3096,6 +3096,7 @@ dependencies = [ "lru", "parking_lot", "rand", + "snarkos-node-metrics", "snarkvm", "tokio", "tracing", diff --git a/node/bft/Cargo.toml b/node/bft/Cargo.toml index 86f15dd7e3..660cfabc88 100644 --- a/node/bft/Cargo.toml +++ b/node/bft/Cargo.toml @@ -18,7 +18,7 @@ edition = "2021" [features] default = [ ] -metrics = [ "dep:metrics", "snarkos-node-bft-events/metrics" ] +metrics = [ "dep:metrics", "snarkos-node-bft-events/metrics", "snarkos-node-bft-ledger-service/metrics" ] [dependencies.aleo-std] workspace = true diff --git a/node/bft/ledger-service/Cargo.toml b/node/bft/ledger-service/Cargo.toml index e5a75a795d..6f83c661e4 100644 --- a/node/bft/ledger-service/Cargo.toml +++ b/node/bft/ledger-service/Cargo.toml @@ -20,6 +20,7 @@ edition = "2021" default = [ ] ledger = [ "lru", "parking_lot", "rand", "tokio", "tracing" ] ledger-write = [ ] +metrics = ["dep:metrics", "snarkvm/metrics"] mock = [ "parking_lot", "tracing" ] prover = [ ] test = [ "mock", "translucent" ] @@ -36,6 +37,12 @@ features = [ "serde", "rayon" ] version = "0.12" optional = true +[dependencies.metrics] +package = "snarkos-node-metrics" +path = "../../metrics" +version = "=2.2.7" +optional = true + [dependencies.parking_lot] version = "0.12" optional = true diff --git a/node/bft/ledger-service/src/ledger.rs b/node/bft/ledger-service/src/ledger.rs index 2ceec88fbd..73f09d1f07 100644 --- a/node/bft/ledger-service/src/ledger.rs +++ b/node/bft/ledger-service/src/ledger.rs @@ -335,20 +335,17 @@ impl> LedgerService for CoreLedgerService< self.ledger.advance_to_next_block(block)?; // Update BFT metrics. #[cfg(feature = "metrics")] - self.update_bft_metrics(block); + { + let num_sol = block.solutions().len(); + let num_tx = block.transactions().len(); + + metrics::gauge(metrics::bft::HEIGHT, block.height() as f64); + metrics::gauge(metrics::bft::LAST_COMMITTED_ROUND, block.round() as f64); + metrics::increment_gauge(metrics::blocks::SOLUTIONS, num_sol as f64); + metrics::increment_gauge(metrics::blocks::TRANSACTIONS, num_tx as f64); + } tracing::info!("\n\nAdvanced to block {} at round {} - {}\n", block.height(), block.round(), block.hash()); Ok(()) } - - #[cfg(feature = "metrics")] - fn update_bft_metrics(&self, block: &Block) { - let num_sol = block.solutions().len(); - let num_tx = block.transactions().len(); - - metrics::gauge(metrics::bft::HEIGHT, block.height() as f64); - metrics::gauge(metrics::bft::LAST_COMMITTED_ROUND, block.round() as f64); - metrics::increment_gauge(metrics::blocks::SOLUTIONS, num_sol as f64); - metrics::increment_gauge(metrics::blocks::TRANSACTIONS, num_tx as f64); - } } From 5a3f5b0d4dfd9d1210d22a045a7fe69ea1e44131 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 9 Apr 2024 18:59:31 -0400 Subject: [PATCH 343/551] Optimize check --- node/bft/src/helpers/storage.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/node/bft/src/helpers/storage.rs b/node/bft/src/helpers/storage.rs index d97e552fed..f555099712 100644 --- a/node/bft/src/helpers/storage.rs +++ b/node/bft/src/helpers/storage.rs @@ -638,6 +638,10 @@ impl Storage { // Retrieve the aborted transmissions for the certificate. let mut aborted_transmissions = HashSet::new(); + // Track the block's aborted solutions and transactions. + let aborted_solutions: IndexSet<_> = block.aborted_solution_ids().iter().collect(); + let aborted_transactions: IndexSet<_> = block.aborted_transaction_ids().iter().collect(); + // Iterate over the transmission IDs. for transmission_id in certificate.transmission_ids() { // If the transmission ID already exists in the map, skip it. @@ -663,7 +667,7 @@ impl Storage { // Check if the solution is in the aborted solutions. Err(_) => { // Insert the aborted solution if it exists in the block or ledger. - match block.aborted_solution_ids().contains(solution_id) + match aborted_solutions.contains(solution_id) || self.ledger.contains_transmission(transmission_id).unwrap_or(false) { true => { @@ -688,7 +692,7 @@ impl Storage { // Check if the transaction is in the aborted transactions. Err(_) => { // Insert the aborted transaction if it exists in the block or ledger. - match block.aborted_transaction_ids().contains(transaction_id) + match aborted_transactions.contains(transaction_id) || self.ledger.contains_transmission(transmission_id).unwrap_or(false) { true => { From 003227a91e9661b8d9efdbeb74a9bffafb0a2e01 Mon Sep 17 00:00:00 2001 From: miazn Date: Wed, 10 Apr 2024 16:12:56 -0400 Subject: [PATCH 344/551] add more granular transaction metrics --- node/bft/ledger-service/src/ledger.rs | 39 +++++++++++++++++++++++++++ node/bft/ledger-service/src/traits.rs | 4 +++ node/metrics/src/names.rs | 10 ++++++- 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/node/bft/ledger-service/src/ledger.rs b/node/bft/ledger-service/src/ledger.rs index 73f09d1f07..c7a6d4a463 100644 --- a/node/bft/ledger-service/src/ledger.rs +++ b/node/bft/ledger-service/src/ledger.rs @@ -28,6 +28,8 @@ use snarkvm::{ use indexmap::IndexMap; use lru::LruCache; use parking_lot::{Mutex, RwLock}; +#[cfg(feature = "metrics")] +use std::collections::HashMap; use std::{ fmt, ops::Range, @@ -343,9 +345,46 @@ impl> LedgerService for CoreLedgerService< metrics::gauge(metrics::bft::LAST_COMMITTED_ROUND, block.round() as f64); metrics::increment_gauge(metrics::blocks::SOLUTIONS, num_sol as f64); metrics::increment_gauge(metrics::blocks::TRANSACTIONS, num_tx as f64); + self.update_block_metrics(block); } tracing::info!("\n\nAdvanced to block {} at round {} - {}\n", block.height(), block.round(), block.hash()); Ok(()) } + + #[cfg(feature = "metrics")] + fn update_block_metrics(&self, block: &Block) { + use snarkvm::ledger::ConfirmedTransaction; + + let metrics: HashMap<&'static str, usize> = block.transactions().iter().fold( + HashMap::from([ + ("AcceptedDeploy", 0), + ("AcceptedExecute", 0), + ("RejectedDeploy", 0), + ("RejectedExecute", 0), + ]), + |mut transaction_types, tx| { + match tx { + ConfirmedTransaction::AcceptedDeploy(_, _, _) => { + *transaction_types.get_mut("AcceptedDeploy").unwrap() += 1; + } + ConfirmedTransaction::AcceptedExecute(_, _, _) => { + *transaction_types.get_mut("AcceptedExecute").unwrap() += 1; + } + ConfirmedTransaction::RejectedDeploy(_, _, _, _) => { + *transaction_types.get_mut("RejectedDeploy").unwrap() += 1; + } + ConfirmedTransaction::RejectedExecute(_, _, _, _) => { + *transaction_types.get_mut("RejectedExecute").unwrap() += 1; + } + } + transaction_types + }, + ); + // Increment metrics at the end + metrics::increment_gauge(metrics::blocks::ACCEPTED_DEPLOY, *metrics.get("AcceptedDeploy").unwrap() as f64); + metrics::increment_gauge(metrics::blocks::ACCEPTED_EXECUTE, *metrics.get("AcceptedExecute").unwrap() as f64); + metrics::increment_gauge(metrics::blocks::REJECTED_DEPLOY, *metrics.get("RejectedDeploy").unwrap() as f64); + metrics::increment_gauge(metrics::blocks::REJECTED_EXECUTE, *metrics.get("RejectedExecute").unwrap() as f64); + } } diff --git a/node/bft/ledger-service/src/traits.rs b/node/bft/ledger-service/src/traits.rs index 2bbad3387f..ce99bf9f40 100644 --- a/node/bft/ledger-service/src/traits.rs +++ b/node/bft/ledger-service/src/traits.rs @@ -118,4 +118,8 @@ pub trait LedgerService: Debug + Send + Sync { /// Adds the given block as the next block in the ledger. #[cfg(feature = "ledger-write")] fn advance_to_next_block(&self, block: &Block) -> Result<()>; + + // Updates the block metrics. + #[cfg(feature = "metrics")] + fn update_block_metrics(&self, _block: &Block) {} } diff --git a/node/metrics/src/names.rs b/node/metrics/src/names.rs index 8dec924a7b..3a4f657e86 100644 --- a/node/metrics/src/names.rs +++ b/node/metrics/src/names.rs @@ -14,7 +14,7 @@ pub(super) const COUNTER_NAMES: [&str; 2] = [bft::LEADERS_ELECTED, consensus::STALE_UNCONFIRMED_TRANSMISSIONS]; -pub(super) const GAUGE_NAMES: [&str; 19] = [ +pub(super) const GAUGE_NAMES: [&str; 23] = [ bft::CONNECTED, bft::CONNECTING, bft::LAST_STORED_ROUND, @@ -24,6 +24,10 @@ pub(super) const GAUGE_NAMES: [&str; 19] = [ bft::LAST_COMMITTED_ROUND, blocks::SOLUTIONS, blocks::TRANSACTIONS, + blocks::ACCEPTED_DEPLOY, + blocks::ACCEPTED_EXECUTE, + blocks::REJECTED_DEPLOY, + blocks::REJECTED_EXECUTE, blocks::PROOF_TARGET, blocks::COINBASE_TARGET, blocks::CUMULATIVE_PROOF_TARGET, @@ -61,6 +65,10 @@ pub mod bft { pub mod blocks { pub const TRANSACTIONS: &str = "snarkos_blocks_transactions_total"; pub const SOLUTIONS: &str = "snarkos_blocks_solutions_total"; + pub const ACCEPTED_DEPLOY: &str = "snarkos_blocks_accepted_deploy"; + pub const ACCEPTED_EXECUTE: &str = "snarkos_blocks_accepted_execute"; + pub const REJECTED_DEPLOY: &str = "snarkos_blocks_rejected_deploy"; + pub const REJECTED_EXECUTE: &str = "snarkos_blocks_rejected_execute"; pub const PROOF_TARGET: &str = "snarkos_blocks_proof_target"; pub const COINBASE_TARGET: &str = "snarkos_blocks_coinbase_target"; pub const CUMULATIVE_PROOF_TARGET: &str = "snarkos_blocks_cumulative_proof_target"; From 380bc893ada24a41c767ac4cb5e3594b51d8a311 Mon Sep 17 00:00:00 2001 From: miazn Date: Thu, 11 Apr 2024 13:48:00 -0400 Subject: [PATCH 345/551] add aborted transmissions --- node/bft/ledger-service/src/ledger.rs | 5 ++++- node/metrics/src/names.rs | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/node/bft/ledger-service/src/ledger.rs b/node/bft/ledger-service/src/ledger.rs index c7a6d4a463..f94092a64d 100644 --- a/node/bft/ledger-service/src/ledger.rs +++ b/node/bft/ledger-service/src/ledger.rs @@ -356,6 +356,7 @@ impl> LedgerService for CoreLedgerService< fn update_block_metrics(&self, block: &Block) { use snarkvm::ledger::ConfirmedTransaction; + // Count each type of transaction in the next block. let metrics: HashMap<&'static str, usize> = block.transactions().iter().fold( HashMap::from([ ("AcceptedDeploy", 0), @@ -381,10 +382,12 @@ impl> LedgerService for CoreLedgerService< transaction_types }, ); - // Increment metrics at the end + metrics::increment_gauge(metrics::blocks::ACCEPTED_DEPLOY, *metrics.get("AcceptedDeploy").unwrap() as f64); metrics::increment_gauge(metrics::blocks::ACCEPTED_EXECUTE, *metrics.get("AcceptedExecute").unwrap() as f64); metrics::increment_gauge(metrics::blocks::REJECTED_DEPLOY, *metrics.get("RejectedDeploy").unwrap() as f64); metrics::increment_gauge(metrics::blocks::REJECTED_EXECUTE, *metrics.get("RejectedExecute").unwrap() as f64); + metrics::increment_gauge(metrics::blocks::ABORTED_TRANSACTIONS, block.aborted_transaction_ids().len() as f64); + metrics::increment_gauge(metrics::blocks::ABORTED_SOLUTIONS, block.aborted_solution_ids().len() as f64); } } diff --git a/node/metrics/src/names.rs b/node/metrics/src/names.rs index 3a4f657e86..42c058ab3a 100644 --- a/node/metrics/src/names.rs +++ b/node/metrics/src/names.rs @@ -14,7 +14,7 @@ pub(super) const COUNTER_NAMES: [&str; 2] = [bft::LEADERS_ELECTED, consensus::STALE_UNCONFIRMED_TRANSMISSIONS]; -pub(super) const GAUGE_NAMES: [&str; 23] = [ +pub(super) const GAUGE_NAMES: [&str; 25] = [ bft::CONNECTED, bft::CONNECTING, bft::LAST_STORED_ROUND, @@ -28,6 +28,8 @@ pub(super) const GAUGE_NAMES: [&str; 23] = [ blocks::ACCEPTED_EXECUTE, blocks::REJECTED_DEPLOY, blocks::REJECTED_EXECUTE, + blocks::ABORTED_TRANSACTIONS, + blocks::ABORTED_SOLUTIONS, blocks::PROOF_TARGET, blocks::COINBASE_TARGET, blocks::CUMULATIVE_PROOF_TARGET, @@ -69,6 +71,8 @@ pub mod blocks { pub const ACCEPTED_EXECUTE: &str = "snarkos_blocks_accepted_execute"; pub const REJECTED_DEPLOY: &str = "snarkos_blocks_rejected_deploy"; pub const REJECTED_EXECUTE: &str = "snarkos_blocks_rejected_execute"; + pub const ABORTED_TRANSACTIONS: &str = "snarkos_blocks_aborted_transactions"; + pub const ABORTED_SOLUTIONS: &str = "snarkos_blocks_aborted_solutions"; pub const PROOF_TARGET: &str = "snarkos_blocks_proof_target"; pub const COINBASE_TARGET: &str = "snarkos_blocks_coinbase_target"; pub const CUMULATIVE_PROOF_TARGET: &str = "snarkos_blocks_cumulative_proof_target"; From 19c77c73121623639022d5138cc3266eddb69e3c Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 11 Apr 2024 17:02:19 -0400 Subject: [PATCH 346/551] Choose random set of transmissions in worker ping --- node/bft/src/worker.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index 6919986653..9f31384cdb 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -33,6 +33,7 @@ use snarkvm::{ use indexmap::{IndexMap, IndexSet}; use parking_lot::Mutex; +use rand::seq::IteratorRandom; use std::{future::Future, net::SocketAddr, sync::Arc, time::Duration}; use tokio::{sync::oneshot, task::JoinHandle, time::timeout}; @@ -223,7 +224,8 @@ impl Worker { .ready .transmission_ids() .into_iter() - .take(Self::MAX_TRANSMISSIONS_PER_WORKER_PING) + .choose_multiple(&mut rand::thread_rng(), Self::MAX_TRANSMISSIONS_PER_WORKER_PING) + .into_iter() .collect::>(); // Broadcast the ping event. From d48f75c5a8c4e2b586579a22363cf63818c0e485 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 11 Apr 2024 17:02:45 -0400 Subject: [PATCH 347/551] Remove transaction minimum in proposal --- node/bft/src/primary.rs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 5e27aa3d21..4cb043ff87 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -404,8 +404,6 @@ impl Primary { let num_transmissions_per_worker = BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH / self.num_workers() as usize; // Initialize the map of transmissions. let mut transmissions: IndexMap<_, _> = Default::default(); - // Initialize a tracker for the number of transactions. - let mut num_transactions = 0; // Take the transmissions from the workers. for worker in self.workers.iter() { // Initialize a tracker for included transmissions for the current worker. @@ -450,8 +448,6 @@ impl Primary { trace!("Proposing - Skipping transaction '{}' - {e}", fmt_id(transaction_id)); continue 'inner; } - // Increment the number of transactions. - num_transactions += 1; } // Note: We explicitly forbid including ratifications, // as the protocol currently does not support ratifications. @@ -470,11 +466,6 @@ impl Primary { debug!("Primary is safely skipping a batch proposal {}", "(no unconfirmed transmissions)".dimmed()); return Ok(()); } - // If there are no unconfirmed transactions to propose, return early. - if num_transactions == 0 { - debug!("Primary is safely skipping a batch proposal {}", "(no unconfirmed transactions)".dimmed()); - return Ok(()); - } // Ditto if the batch had already been proposed and not expired. ensure!(round > 0, "Round 0 cannot have transaction batches"); // Determine the current timestamp. From ebbbd175db35455ba64cb7996a11b72fe4e9fbb8 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 11 Apr 2024 17:06:35 -0400 Subject: [PATCH 348/551] Reinsert transmission to worker after failure to create proposal --- node/bft/src/primary.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 4cb043ff87..c8178d4ba5 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -474,6 +474,8 @@ impl Primary { let is_expired = is_proposal_expired(current_timestamp, lock_guard.1); if lock_guard.0 == round && !is_expired { warn!("Primary is safely skipping a batch proposal - round {round} already proposed"); + // Reinsert the transmissions back into the ready queue for the next proposal. + self.reinsert_transmissions_into_workers(transmissions)?; return Ok(()); } @@ -777,7 +779,7 @@ impl Primary { // If there was an error storing the certificate, reinsert the transmissions back into the ready queue. if let Err(e) = self.store_and_broadcast_certificate(&proposal, &committee_lookback).await { // Reinsert the transmissions back into the ready queue for the next proposal. - self.reinsert_transmissions_into_workers(proposal)?; + self.reinsert_transmissions_into_workers(proposal.into_transmissions())?; return Err(e); } @@ -1138,7 +1140,7 @@ impl Primary { let proposal = self.proposed_batch.write().take(); if let Some(proposal) = proposal { debug!("Cleared expired proposal for round {}", proposal.round()); - self.reinsert_transmissions_into_workers(proposal)?; + self.reinsert_transmissions_into_workers(proposal.into_transmissions())?; } } Ok(()) @@ -1287,15 +1289,14 @@ impl Primary { } /// Re-inserts the transmissions from the proposal into the workers. - fn reinsert_transmissions_into_workers(&self, proposal: Proposal) -> Result<()> { + fn reinsert_transmissions_into_workers( + &self, + transmissions: IndexMap, Transmission>, + ) -> Result<()> { // Re-insert the transmissions into the workers. - assign_to_workers( - &self.workers, - proposal.into_transmissions().into_iter(), - |worker, transmission_id, transmission| { - worker.reinsert(transmission_id, transmission); - }, - ) + assign_to_workers(&self.workers, transmissions.into_iter(), |worker, transmission_id, transmission| { + worker.reinsert(transmission_id, transmission); + }) } /// Recursively stores a given batch certificate, after ensuring: From 5287579d28356c03d5dbf3d16daedf8b8703feb3 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 11 Apr 2024 17:08:37 -0400 Subject: [PATCH 349/551] Update MAX_TRANSMISSIONS_TOLERANCE to 1024 --- node/bft/src/primary.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index c8178d4ba5..4cd17221c2 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -104,7 +104,7 @@ pub struct Primary { impl Primary { /// The maximum number of unconfirmed transmissions to send to the primary. - pub const MAX_TRANSMISSIONS_TOLERANCE: usize = BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH * 2; + pub const MAX_TRANSMISSIONS_TOLERANCE: usize = 1 << 10; /// Initializes a new primary instance. pub fn new( From 08361b4220a87d2f027f87866d24d43a61158219 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Thu, 11 Apr 2024 15:51:10 -0700 Subject: [PATCH 350/551] Removes request_timeouts from BlockSync --- node/sync/src/block_sync.rs | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/node/sync/src/block_sync.rs b/node/sync/src/block_sync.rs index 97e05561bd..e300430a83 100644 --- a/node/sync/src/block_sync.rs +++ b/node/sync/src/block_sync.rs @@ -45,7 +45,6 @@ const NUM_SYNC_CANDIDATE_PEERS: usize = REDUNDANCY_FACTOR * 5; const BLOCK_REQUEST_TIMEOUT_IN_SECS: u64 = 600; // 600 seconds const MAX_BLOCK_REQUESTS: usize = 50; // 50 requests -const MAX_BLOCK_REQUEST_TIMEOUTS: usize = 5; // 5 timeouts /// The maximum number of blocks tolerated before the primary is considered behind its peers. pub const MAX_BLOCKS_BEHIND: u32 = 1; // blocks @@ -104,9 +103,6 @@ pub struct BlockSync { /// The map of block height to the timestamp of the last time the block was requested. /// This map is used to determine which requests to remove if they have been pending for too long. request_timestamps: Arc>>, - /// The map of (timed out) peer IPs to their request timestamps. - /// This map is used to determine which peers to remove if they have timed out too many times. - request_timeouts: Arc>>>, /// The boolean indicator of whether the node is synced up to the latest block (within the given tolerance). is_block_synced: Arc, /// The lock to guarantee advance_with_sync_blocks() is called only once at a time. @@ -124,7 +120,6 @@ impl BlockSync { requests: Default::default(), responses: Default::default(), request_timestamps: Default::default(), - request_timeouts: Default::default(), is_block_synced: Default::default(), advance_with_sync_blocks_lock: Default::default(), } @@ -402,8 +397,6 @@ impl BlockSync { self.locators.write().swap_remove(peer_ip); // Remove all block requests to the peer. self.remove_block_requests_to_peer(peer_ip); - // Remove the timeouts for the peer. - self.request_timeouts.write().swap_remove(peer_ip); } } @@ -659,16 +652,6 @@ impl BlockSync { !is_timeout }); - // If there are timeout IPs, then add them to the request timeouts map. - if !timeout_ips.is_empty() { - // Acquire the write lock on the request timeouts map. - let mut request_timeouts = self.request_timeouts.write(); - // Add each timeout IP to the request timeouts map. - for timeout_ip in timeout_ips { - request_timeouts.entry(timeout_ip).or_default().push(now); - } - } - num_timed_out_block_requests } @@ -677,21 +660,12 @@ impl BlockSync { // Retrieve the latest canon height. let latest_canon_height = self.canon.latest_block_height(); - // Compute the timeout frequency of each peer. - let timeouts = self - .request_timeouts - .read() - .iter() - .map(|(peer_ip, timestamps)| (*peer_ip, timestamps.len())) - .collect::>(); - // Pick a set of peers above the latest canon height, and include their locators. let candidate_locators: IndexMap<_, _> = self .locators .read() .iter() .filter(|(_, locators)| locators.latest_locator_height() > latest_canon_height) - .filter(|(ip, _)| timeouts.get(*ip).map(|count| *count < MAX_BLOCK_REQUEST_TIMEOUTS).unwrap_or(true)) .sorted_by(|(_, a), (_, b)| b.latest_locator_height().cmp(&a.latest_locator_height())) .take(NUM_SYNC_CANDIDATE_PEERS) .map(|(peer_ip, locators)| (*peer_ip, locators.clone())) From cced2c25170f6b54d279f36f9d5ef1c5ad134991 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Thu, 11 Apr 2024 15:58:33 -0700 Subject: [PATCH 351/551] Adds a shuffle on the sync_peers --- node/sync/src/block_sync.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/node/sync/src/block_sync.rs b/node/sync/src/block_sync.rs index e300430a83..83c5dd7270 100644 --- a/node/sync/src/block_sync.rs +++ b/node/sync/src/block_sync.rs @@ -726,6 +726,10 @@ impl BlockSync { return None; } + // Shuffle the sync peers prior to returning. This ensures the rest of the stack + // does not rely on the order of the sync peers, and that the sync peers are not biased. + let sync_peers = shuffle_indexmap(sync_peers, &mut rand::thread_rng()); + Some((sync_peers, min_common_ancestor)) } @@ -853,6 +857,18 @@ fn construct_request( (hash, previous_hash, num_sync_ips, is_honest) } +/// Shuffles a given `IndexMap` using the given random number generator. +fn shuffle_indexmap(mut map: IndexMap, rng: &mut R) -> IndexMap +where + K: core::hash::Hash + Eq + Clone, + V: Clone, +{ + use rand::seq::SliceRandom; + let mut pairs: Vec<_> = map.drain(..).collect(); // Drain elements to a vector + pairs.shuffle(rng); // Shuffle the vector of tuples + pairs.into_iter().collect() // Collect back into an IndexMap +} + #[cfg(test)] mod tests { use super::*; From 42094a217e0026320e1372fbb6e08a5b81acfc5a Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Thu, 11 Apr 2024 16:07:05 -0700 Subject: [PATCH 352/551] Remove timeout vec --- node/sync/src/block_sync.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/node/sync/src/block_sync.rs b/node/sync/src/block_sync.rs index 83c5dd7270..7fb7ef94fc 100644 --- a/node/sync/src/block_sync.rs +++ b/node/sync/src/block_sync.rs @@ -22,7 +22,7 @@ use snarkos_node_sync_locators::{CHECKPOINT_INTERVAL, NUM_RECENT_BLOCKS}; use snarkvm::prelude::{block::Block, Network}; use anyhow::{bail, ensure, Result}; -use indexmap::{IndexMap, IndexSet}; +use indexmap::IndexMap; use itertools::Itertools; use parking_lot::{Mutex, RwLock}; use rand::{prelude::IteratorRandom, CryptoRng, Rng}; @@ -621,8 +621,6 @@ impl BlockSync { // Retrieve the current time. let now = Instant::now(); - // Track each unique peer IP that has timed out. - let mut timeout_ips = IndexSet::new(); // Track the number of timed out block requests. let mut num_timed_out_block_requests = 0; @@ -639,10 +637,7 @@ impl BlockSync { // If the request has timed out, then remove it. if is_timeout { // Remove the request entry for the given height. - if let Some((_, _, sync_ips)) = requests.remove(height) { - // Add each sync IP to the timeout IPs. - timeout_ips.extend(sync_ips); - } + requests.remove(height); // Remove the response entry for the given height. responses.remove(height); // Increment the number of timed out block requests. @@ -880,7 +875,7 @@ mod tests { use snarkos_node_bft_ledger_service::MockLedgerService; use snarkvm::prelude::{Field, TestRng}; - use indexmap::indexset; + use indexmap::{indexset, IndexSet}; use snarkvm::ledger::committee::Committee; use std::net::{IpAddr, Ipv4Addr}; From 27aea25c3f1d70e812347d6b076edf4137ffe0ce Mon Sep 17 00:00:00 2001 From: Niklas Date: Wed, 6 Mar 2024 23:05:12 +0100 Subject: [PATCH 353/551] deps(bft): add `pea2pea` to dev deps --- node/bft/Cargo.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/node/bft/Cargo.toml b/node/bft/Cargo.toml index 660cfabc88..2f3d3b20c8 100644 --- a/node/bft/Cargo.toml +++ b/node/bft/Cargo.toml @@ -137,6 +137,9 @@ version = "5" [dev-dependencies.paste] version = "1" +[dev-dependencies.pea2pea] + version = "0.46" + [dev-dependencies.proptest] version = "1.4.0" From 2c67849eb6418e3eb1e5434d277dddfbafbef594 Mon Sep 17 00:00:00 2001 From: Niklas Date: Wed, 6 Mar 2024 23:06:07 +0100 Subject: [PATCH 354/551] tests: implement test peer tooling --- node/bft/tests/common/mod.rs | 1 + node/bft/tests/common/test_peer.rs | 150 +++++++++++++++++++++++++++++ 2 files changed, 151 insertions(+) create mode 100644 node/bft/tests/common/test_peer.rs diff --git a/node/bft/tests/common/mod.rs b/node/bft/tests/common/mod.rs index 2505f6add7..febf3dc3a5 100644 --- a/node/bft/tests/common/mod.rs +++ b/node/bft/tests/common/mod.rs @@ -13,6 +13,7 @@ // limitations under the License. pub mod primary; +pub mod test_peer; pub mod utils; pub type CurrentNetwork = snarkvm::prelude::MainnetV0; diff --git a/node/bft/tests/common/test_peer.rs b/node/bft/tests/common/test_peer.rs new file mode 100644 index 0000000000..db1bf37afe --- /dev/null +++ b/node/bft/tests/common/test_peer.rs @@ -0,0 +1,150 @@ +// Copyright (C) 2019-2023 Aleo Systems Inc. +// This file is part of the snarkOS library. + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// http://www.apache.org/licenses/LICENSE-2.0 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use crate::common::CurrentNetwork; +use snarkos_node_bft_events::{Event, EventCodec}; + +use std::{ + io, + net::{IpAddr, Ipv4Addr, SocketAddr}, + time::Duration, +}; + +use pea2pea::{ + protocols::{Disconnect, Handshake, Reading, Writing}, + Config, + Connection, + ConnectionSide, + Node, + Pea2Pea, +}; + +use tokio::{ + sync::mpsc::{self, Receiver, Sender}, + time::timeout, +}; + +pub struct TestPeer { + inner_node: InnerNode, + inbound_rx: Receiver<(SocketAddr, Event)>, +} + +#[derive(Clone)] +struct InnerNode { + // The pea2pea node instance. + node: Node, + // The inbound channel sender, used to consolidate inbound messages into a single queue so they + // can be read in order in tests. + inbound_tx: Sender<(SocketAddr, Event)>, +} + +impl TestPeer { + pub async fn new() -> Self { + let (tx, rx) = mpsc::channel(100); + let inner_node = InnerNode { + node: Node::new(Config { + listener_ip: Some(IpAddr::V4(Ipv4Addr::LOCALHOST)), + max_connections: 200, + ..Default::default() + }), + inbound_tx: tx, + }; + + inner_node.enable_handshake().await; + inner_node.enable_reading().await; + inner_node.enable_writing().await; + inner_node.enable_disconnect().await; + inner_node.node().start_listening().await.unwrap(); + + Self { inner_node, inbound_rx: rx } + } + + pub fn listening_addr(&self) -> SocketAddr { + self.inner_node.node().listening_addr().expect("addr should be present") + } + + pub async fn connect(&self, target: SocketAddr) -> io::Result<()> { + self.inner_node.node().connect(target).await?; + Ok(()) + } + + // Note: the codec doesn't actually support sending bytes post-handshake, perhaps this should + // be relaxed by making a test-only codec in future. + pub fn unicast(&self, target: SocketAddr, message: Event) -> io::Result<()> { + self.inner_node.unicast(target, message)?; + Ok(()) + } + + pub async fn recv(&mut self) -> (SocketAddr, Event) { + match self.inbound_rx.recv().await { + Some(message) => message, + None => panic!("all senders dropped!"), + } + } + + pub async fn recv_timeout(&mut self, duration: Duration) -> (SocketAddr, Event) { + match timeout(duration, self.recv()).await { + Ok(message) => message, + _ => panic!("timed out waiting for message"), + } + } +} + +impl Pea2Pea for InnerNode { + fn node(&self) -> &Node { + &self.node + } +} + +#[async_trait::async_trait] +impl Handshake for InnerNode { + // Set the timeout on the test peer to be longer than the gateway's timeout. + const TIMEOUT_MS: u64 = 10_000; + + async fn perform_handshake(&self, connection: Connection) -> io::Result { + // Don't perform the Aleo handshake so we can test the edge cases fully. + Ok(connection) + } +} + +#[async_trait::async_trait] +impl Writing for InnerNode { + type Codec = EventCodec; + type Message = Event; + + fn codec(&self, _peer_addr: SocketAddr, _side: ConnectionSide) -> Self::Codec { + Default::default() + } +} + +#[async_trait::async_trait] +impl Reading for InnerNode { + type Codec = EventCodec; + type Message = Event; + + fn codec(&self, _peer_addr: SocketAddr, _side: ConnectionSide) -> Self::Codec { + Default::default() + } + + async fn process_message(&self, peer_addr: SocketAddr, message: Self::Message) -> io::Result<()> { + self.inbound_tx.send((peer_addr, message)).await.map_err(|_| { + io::Error::new(io::ErrorKind::Other, "failed to send message to test peer, all receivers have been dropped") + }) + } +} + +#[async_trait::async_trait] +impl Disconnect for InnerNode { + async fn handle_disconnect(&self, _peer_addr: SocketAddr) {} +} From 816fbf1646926b82c33bfba15566df6abeb822c1 Mon Sep 17 00:00:00 2001 From: Niklas Date: Wed, 6 Mar 2024 23:06:42 +0100 Subject: [PATCH 355/551] tests: implement gateway handshake cases Includes responder side: - timeouts - invalid challenge request/response - unexpected disconnects --- node/bft/tests/gateway_e2e.rs | 263 ++++++++++++++++++++++++++++++++++ 1 file changed, 263 insertions(+) create mode 100644 node/bft/tests/gateway_e2e.rs diff --git a/node/bft/tests/gateway_e2e.rs b/node/bft/tests/gateway_e2e.rs new file mode 100644 index 0000000000..4ed944ae37 --- /dev/null +++ b/node/bft/tests/gateway_e2e.rs @@ -0,0 +1,263 @@ +// Copyright (C) 2019-2023 Aleo Systems Inc. +// This file is part of the snarkOS library. + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// http://www.apache.org/licenses/LICENSE-2.0 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#[allow(dead_code)] +mod common; + +use crate::common::{primary::new_test_committee, test_peer::TestPeer, CurrentNetwork}; +use snarkos_account::Account; +use snarkos_node_bft::{helpers::init_primary_channels, Gateway}; +use snarkos_node_bft_events::{ChallengeRequest, ChallengeResponse, Disconnect, DisconnectReason, Event, WorkerPing}; +use snarkos_node_bft_ledger_service::MockLedgerService; +use snarkos_node_tcp::P2P; +use snarkvm::{ + ledger::{committee::Committee, narwhal::Data}, + prelude::TestRng, +}; + +use std::{net::SocketAddr, str::FromStr, sync::Arc, time::Duration}; + +use deadline::deadline; +use rand::Rng; + +async fn new_test_gateway( + accounts: &[Account], + committee: &Committee, +) -> Gateway { + let ledger = Arc::new(MockLedgerService::new(committee.clone())); + let addr = SocketAddr::from_str("127.0.0.1:0").ok(); + let trusted_validators = []; + let gateway = Gateway::new(accounts.first().unwrap().clone(), ledger, addr, &trusted_validators, None).unwrap(); + + // Set up primary channels, we discard the rx as we're testing the gateway sans BFT. + let (primary_tx, _primary_rx) = init_primary_channels(); + + gateway.run(primary_tx, [].into(), None).await; + + gateway +} + +// The test peer connects to the gateway and completes the no-op handshake (so +// the connection is registered). The gateway's handshake should timeout. +#[tokio::test(flavor = "multi_thread")] +async fn handshake_responder_side_timeout() { + const NUM_NODES: u16 = 4; + let (accounts, committee) = new_test_committee(NUM_NODES); + let gateway = new_test_gateway(&accounts, &committee).await; + let test_peer = TestPeer::new().await; + + // Initiate a connection with the gateway, this will only return once the handshake protocol has + // completed on the test peer's side, which is a no-op. + assert!(test_peer.connect(gateway.local_ip()).await.is_ok()); + + /* Don't send any further messages and wait for the gateway to timeout. */ + + // Check the connection has been registered. + assert_eq!(gateway.tcp().num_connecting(), 1); + + // Check the tcp stack's connection counts, wait longer than the gateway's timeout to ensure + // connecting peers are cleared. + let gateway_clone = gateway.clone(); + deadline!(Duration::from_secs(5), move || gateway_clone.tcp().num_connecting() == 0); + + // Check the test peer hasn't been added to the gateway's connected peers. + assert!(gateway.connected_peers().read().is_empty()); + assert_eq!(gateway.tcp().num_connected(), 0); +} + +// The test peer connects to the gateway and sends an unexpected event. +// The gateway's handshake should be interrupted and the peer should be +// disconnected. +macro_rules! handshake_responder_side_unexpected_event { + ($test_name:ident, $payload:expr) => { + paste::paste! { + #[tokio::test(flavor = "multi_thread")] + async fn []() { + const NUM_NODES: u16 = 4; + let (accounts, committee) = new_test_committee(NUM_NODES); + let gateway = new_test_gateway(&accounts, &committee).await; + let test_peer = TestPeer::new().await; + + // Initiate a connection with the gateway, this will only return once the handshake protocol has + // completed on the test peer's side, which is a no-op. + assert!(test_peer.connect(gateway.local_ip()).await.is_ok()); + + // Check the connection has been registered. + assert_eq!(gateway.tcp().num_connecting(), 1); + + // Send an unexpected event. + let _ = test_peer.unicast( + gateway.local_ip(), + $payload + ); + + // Check the tcp stack's connection counts, make sure the disconnect interrupted handshaking, + // wait a short time to ensure the gateway has time to process the disconnect (note: this is + // shorter than the gateway's timeout, so we can ensure that's not the reason for the + // disconnect). + let gateway_clone = gateway.clone(); + deadline!(Duration::from_secs(1), move || gateway_clone.tcp().num_connecting() == 0); + + // Check the test peer hasn't been added to the gateway's connected peers. + assert!(gateway.connected_peers().read().is_empty()); + assert_eq!(gateway.tcp().num_connected(), 0); + } + } + }; +} + +/* Unexpected disconnects. */ + +macro_rules! handshake_responder_side_unexpected_disconnect { + ($($reason:ident),*) => { + $( + paste::paste! { + handshake_responder_side_unexpected_event!( + [], + Event::Disconnect(Disconnect::from(DisconnectReason::$reason)) + ); + } + )* + } + } + +handshake_responder_side_unexpected_disconnect!( + ProtocolViolation, + NoReasonGiven, + InvalidChallengeResponse, + OutdatedClientVersion +); + +/* Other unexpected event types */ + +handshake_responder_side_unexpected_event!(worker_ping, Event::WorkerPing(WorkerPing::new([].into()))); + +// TODO(nkls): other event types, can be done as a follow up. + +/* Invalid challenge request */ + +#[tokio::test(flavor = "multi_thread")] +async fn handshake_responder_side_invalid_challenge_request() { + const NUM_NODES: u16 = 4; + + let mut rng = TestRng::default(); + let (accounts, committee) = new_test_committee(NUM_NODES); + let gateway = new_test_gateway(&accounts, &committee).await; + let test_peer = TestPeer::new().await; + + // Initiate a connection with the gateway, this will only return once the handshake protocol has + // completed on the test peer's side, which is a no-op. + assert!(test_peer.connect(gateway.local_ip()).await.is_ok()); + + // Check the connection has been registered. + assert_eq!(gateway.tcp().num_connecting(), 1); + + // Use the address from the second peer in the list, the test peer will use the first. + let listener_port = test_peer.listening_addr().port(); + let address = accounts.get(1).unwrap().address(); + let nonce = rng.gen(); + // Set the wrong version so the challenge request is invalid. + let challenge_request = ChallengeRequest { version: 0, listener_port, address, nonce }; + + // Send the message + let _ = test_peer.unicast(gateway.local_ip(), Event::ChallengeRequest(challenge_request)); + + // FIXME(nkls): currently we can't assert on the disconnect type, the message isn't always sent + // before the disconnect. + + // Check the test peer has been removed from the gateway's connecting peers. + let gateway_clone = gateway.clone(); + deadline!(Duration::from_secs(1), move || gateway_clone.tcp().num_connecting() == 0); + // Check the test peer hasn't been added to the gateway's connected peers. + assert!(gateway.connected_peers().read().is_empty()); + assert_eq!(gateway.tcp().num_connected(), 0); +} + +/* Invalid challenge response */ + +#[tokio::test(flavor = "multi_thread")] +async fn handshake_responder_side_invalid_challenge_response() { + const NUM_NODES: u16 = 4; + + let mut rng = TestRng::default(); + let (accounts, committee) = new_test_committee(NUM_NODES); + let gateway = new_test_gateway(&accounts, &committee).await; + let mut test_peer = TestPeer::new().await; + + // Initiate a connection with the gateway, this will only return once the handshake protocol has + // completed on the test peer's side, which is a no-op for the moment. + assert!(test_peer.connect(gateway.local_ip()).await.is_ok()); + + // Check the connection has been registered. + assert_eq!(gateway.tcp().num_connecting(), 1); + + // Use the address from the second peer in the list, the test peer will use the first. + let listener_port = test_peer.listening_addr().port(); + let address = accounts.get(1).unwrap().address(); + let our_nonce = rng.gen(); + let challenge_request = ChallengeRequest { version: 6, listener_port, address, nonce: our_nonce }; + + // Send the challenge request. + let _ = test_peer.unicast(gateway.local_ip(), Event::ChallengeRequest(challenge_request)); + + // Receive the gateway's challenge response. + let (peer_addr, Event::ChallengeResponse(ChallengeResponse { signature, nonce })) = + test_peer.recv_timeout(Duration::from_secs(1)).await + else { + panic!("Expected challenge response") + }; + + // Check the sender is the gateway. + assert_eq!(peer_addr, gateway.local_ip()); + // Check the nonce we sent is in the signature. + assert!( + signature.deserialize_blocking().unwrap().verify_bytes( + &accounts.first().unwrap().address(), + &[our_nonce.to_le_bytes(), nonce.to_le_bytes()].concat() + ) + ); + + // Receive the gateway's challenge request. + let (peer_addr, Event::ChallengeRequest(challenge_request)) = test_peer.recv_timeout(Duration::from_secs(1)).await + else { + panic!("Expected challenge request") + }; + // Check the version, listener port and address are correct. + assert_eq!(peer_addr, gateway.local_ip()); + assert_eq!(challenge_request.version, 6); + assert_eq!(challenge_request.listener_port, gateway.local_ip().port()); + assert_eq!(challenge_request.address, accounts.first().unwrap().address()); + + // Send the challenge response with an invalid signature. + let response_nonce = rng.gen(); + let _ = test_peer.unicast( + gateway.local_ip(), + Event::ChallengeResponse(ChallengeResponse { + signature: Data::Object( + accounts.get(2).unwrap().sign_bytes(&challenge_request.nonce.to_le_bytes(), &mut rng).unwrap(), + ), + nonce: response_nonce, + }), + ); + + // FIXME(nkls): currently we can't assert on the disconnect type, the message isn't always sent + // before the disconnect. + + // Check the test peer has been removed from the gateway's connecting peers. + let gateway_clone = gateway.clone(); + deadline!(Duration::from_secs(1), move || gateway_clone.tcp().num_connecting() == 0); + // Check the test peer hasn't been added to the gateway's connected peers. + assert!(gateway.connected_peers().read().is_empty()); + assert_eq!(gateway.tcp().num_connected(), 0); +} From b9f11e18f3a910ca8f7871d086331e16d47b4ac3 Mon Sep 17 00:00:00 2001 From: Niklas Date: Thu, 7 Mar 2024 13:29:40 +0100 Subject: [PATCH 356/551] tests: `deadline!` assertions to fix CI flakiness --- node/bft/tests/gateway_e2e.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/node/bft/tests/gateway_e2e.rs b/node/bft/tests/gateway_e2e.rs index 4ed944ae37..ab451bed85 100644 --- a/node/bft/tests/gateway_e2e.rs +++ b/node/bft/tests/gateway_e2e.rs @@ -64,7 +64,8 @@ async fn handshake_responder_side_timeout() { /* Don't send any further messages and wait for the gateway to timeout. */ // Check the connection has been registered. - assert_eq!(gateway.tcp().num_connecting(), 1); + let gateway_clone = gateway.clone(); + deadline!(Duration::from_secs(1), move || gateway_clone.tcp().num_connecting() == 1); // Check the tcp stack's connection counts, wait longer than the gateway's timeout to ensure // connecting peers are cleared. @@ -94,7 +95,8 @@ macro_rules! handshake_responder_side_unexpected_event { assert!(test_peer.connect(gateway.local_ip()).await.is_ok()); // Check the connection has been registered. - assert_eq!(gateway.tcp().num_connecting(), 1); + let gateway_clone = gateway.clone(); + deadline!(Duration::from_secs(1), move || gateway_clone.tcp().num_connecting() == 1); // Send an unexpected event. let _ = test_peer.unicast( @@ -161,7 +163,8 @@ async fn handshake_responder_side_invalid_challenge_request() { assert!(test_peer.connect(gateway.local_ip()).await.is_ok()); // Check the connection has been registered. - assert_eq!(gateway.tcp().num_connecting(), 1); + let gateway_clone = gateway.clone(); + deadline!(Duration::from_secs(1), move || gateway_clone.tcp().num_connecting() == 1); // Use the address from the second peer in the list, the test peer will use the first. let listener_port = test_peer.listening_addr().port(); @@ -200,7 +203,8 @@ async fn handshake_responder_side_invalid_challenge_response() { assert!(test_peer.connect(gateway.local_ip()).await.is_ok()); // Check the connection has been registered. - assert_eq!(gateway.tcp().num_connecting(), 1); + let gateway_clone = gateway.clone(); + deadline!(Duration::from_secs(1), move || gateway_clone.tcp().num_connecting() == 1); // Use the address from the second peer in the list, the test peer will use the first. let listener_port = test_peer.listening_addr().port(); From 4cb04786ee7af69c1375b2e7f9dc33b78c843f25 Mon Sep 17 00:00:00 2001 From: Niklas Date: Tue, 19 Mar 2024 16:45:16 +0100 Subject: [PATCH 357/551] tests: fix post-rebase Also moves the test helpers from components into utils. --- node/bft/tests/common/primary.rs | 9 ++-- node/bft/tests/common/utils.rs | 76 ++++++++++++++++++++++++++-- node/bft/tests/components/mod.rs | 65 ------------------------ node/bft/tests/components/pending.rs | 8 +-- node/bft/tests/components/worker.rs | 23 +++++---- node/bft/tests/gateway_e2e.rs | 47 ++++++++--------- 6 files changed, 120 insertions(+), 108 deletions(-) diff --git a/node/bft/tests/common/primary.rs b/node/bft/tests/common/primary.rs index 029c8d54b0..abef3f015e 100644 --- a/node/bft/tests/common/primary.rs +++ b/node/bft/tests/common/primary.rs @@ -127,11 +127,13 @@ impl TestValidator { impl TestNetwork { // Creates a new test network with the given configuration. pub fn new(config: TestNetworkConfig) -> Self { + let mut rng = TestRng::default(); + if let Some(log_level) = config.log_level { initialize_logger(log_level); } - let (accounts, committee) = new_test_committee(config.num_nodes); + let (accounts, committee) = new_test_committee(config.num_nodes, &mut rng); let bonded_balances: IndexMap<_, _> = committee .members() .iter() @@ -148,7 +150,6 @@ impl TestNetwork { let mut validators = HashMap::with_capacity(config.num_nodes as usize); for (id, account) in accounts.into_iter().enumerate() { - let mut rng = TestRng::fixed(id as u64); let gen_ledger = genesis_ledger(gen_key, committee.clone(), balances.clone(), bonded_balances.clone(), &mut rng); let ledger = Arc::new(TranslucentLedgerService::new(gen_ledger, Default::default())); @@ -329,12 +330,12 @@ impl TestNetwork { } // Initializes a new test committee. -pub fn new_test_committee(n: u16) -> (Vec>, Committee) { +pub fn new_test_committee(n: u16, rng: &mut TestRng) -> (Vec>, Committee) { let mut accounts = Vec::with_capacity(n as usize); let mut members = IndexMap::with_capacity(n as usize); for i in 0..n { // Sample the account. - let account = Account::new(&mut TestRng::fixed(i as u64)).unwrap(); + let account = Account::new(rng).unwrap(); info!("Validator {}: {}", i, account.address()); members.insert(account.address(), (MIN_VALIDATOR_STAKE, false)); diff --git a/node/bft/tests/common/utils.rs b/node/bft/tests/common/utils.rs index 1fa074f102..bd558f418a 100644 --- a/node/bft/tests/common/utils.rs +++ b/node/bft/tests/common/utils.rs @@ -12,12 +12,25 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::common::CurrentNetwork; -use snarkos_node_bft::helpers::PrimarySender; +use crate::common::{primary, CurrentNetwork, TranslucentLedgerService}; +use snarkos_account::Account; +use snarkos_node_bft::{ + helpers::{PrimarySender, Storage}, + Gateway, + Worker, +}; + +use snarkos_node_bft_storage_service::BFTMemoryService; use snarkvm::{ - ledger::narwhal::Data, + console::account::Address, + ledger::{ + committee::Committee, + narwhal::{BatchHeader, Data}, + store::helpers::memory::ConsensusMemory, + }, prelude::{ block::Transaction, + committee::MIN_VALIDATOR_STAKE, puzzle::{Solution, SolutionID}, Field, Network, @@ -26,9 +39,11 @@ use snarkvm::{ }, }; -use std::time::Duration; +use std::{sync::Arc, time::Duration}; use ::bytes::Bytes; +use indexmap::IndexMap; +use parking_lot::RwLock; use rand::Rng; use tokio::{sync::oneshot, task::JoinHandle, time::sleep}; use tracing::*; @@ -164,3 +179,56 @@ pub fn fire_unconfirmed_transactions( } }) } + +/// Samples a new ledger with the given number of nodes. +pub fn sample_ledger( + accounts: &[Account], + committee: &Committee, + rng: &mut TestRng, +) -> Arc>> { + let num_nodes = committee.num_members(); + let bonded_balances: IndexMap<_, _> = + committee.members().iter().map(|(address, (amount, _))| (*address, (*address, *address, *amount))).collect(); + let gen_key = *accounts[0].private_key(); + let public_balance_per_validator = + (CurrentNetwork::STARTING_SUPPLY - (num_nodes as u64) * MIN_VALIDATOR_STAKE) / (num_nodes as u64); + let mut balances = IndexMap::, u64>::new(); + for account in accounts.iter() { + balances.insert(account.address(), public_balance_per_validator); + } + + let gen_ledger = + primary::genesis_ledger(gen_key, committee.clone(), balances.clone(), bonded_balances.clone(), rng); + Arc::new(TranslucentLedgerService::new(gen_ledger, Default::default())) +} + +/// Samples a new storage with the given ledger. +pub fn sample_storage(ledger: Arc>>) -> Storage { + Storage::new(ledger, Arc::new(BFTMemoryService::new()), BatchHeader::::MAX_GC_ROUNDS as u64) +} + +/// Samples a new gateway with the given ledger. +pub fn sample_gateway( + account: Account, + storage: Storage, + ledger: Arc>>, +) -> Gateway { + // Initialize the gateway. + Gateway::new(account, storage, ledger, None, &[], None).unwrap() +} + +/// Samples a new worker with the given ledger. +pub fn sample_worker( + id: u8, + account: Account, + ledger: Arc>>, +) -> Worker { + // Sample a storage. + let storage = sample_storage(ledger.clone()); + // Sample a gateway. + let gateway = sample_gateway(account, storage.clone(), ledger.clone()); + // Sample a dummy proposed batch. + let proposed_batch = Arc::new(RwLock::new(None)); + // Construct the worker instance. + Worker::new(id, Arc::new(gateway.clone()), storage.clone(), ledger, proposed_batch).unwrap() +} diff --git a/node/bft/tests/components/mod.rs b/node/bft/tests/components/mod.rs index 65336665cc..d58afbf610 100644 --- a/node/bft/tests/components/mod.rs +++ b/node/bft/tests/components/mod.rs @@ -15,69 +15,4 @@ pub mod pending; pub mod worker; -use crate::common::{primary, CurrentNetwork, TranslucentLedgerService}; -use snarkos_account::Account; -use snarkos_node_bft::{helpers::Storage, Gateway, Worker}; -use snarkos_node_bft_ledger_service::LedgerService; -use snarkos_node_bft_storage_service::BFTMemoryService; -use snarkvm::{ - console::{account::Address, network::Network}, - ledger::{committee::MIN_VALIDATOR_STAKE, narwhal::BatchHeader, store::helpers::memory::ConsensusMemory}, - prelude::TestRng, -}; - -use indexmap::IndexMap; -use parking_lot::RwLock; -use std::{str::FromStr, sync::Arc}; - const ITERATIONS: u32 = 100; - -/// Samples a new ledger with the given number of nodes. -pub fn sample_ledger( - num_nodes: u16, - rng: &mut TestRng, -) -> Arc>> { - let (accounts, committee) = primary::new_test_committee(num_nodes); - let bonded_balances: IndexMap<_, _> = - committee.members().iter().map(|(address, (amount, _))| (*address, (*address, *address, *amount))).collect(); - let gen_key = *accounts[0].private_key(); - let public_balance_per_validator = - (CurrentNetwork::STARTING_SUPPLY - (num_nodes as u64) * MIN_VALIDATOR_STAKE) / (num_nodes as u64); - let mut balances = IndexMap::, u64>::new(); - for account in accounts.iter() { - balances.insert(account.address(), public_balance_per_validator); - } - - let gen_ledger = - primary::genesis_ledger(gen_key, committee.clone(), balances.clone(), bonded_balances.clone(), rng); - Arc::new(TranslucentLedgerService::new(gen_ledger, Default::default())) -} - -/// Samples a new storage with the given ledger. -pub fn sample_storage(ledger: Arc>>) -> Storage { - Storage::new(ledger, Arc::new(BFTMemoryService::new()), BatchHeader::::MAX_GC_ROUNDS as u64) -} - -/// Samples a new gateway with the given ledger. -pub fn sample_gateway( - storage: Storage, - ledger: Arc>>, -) -> Gateway { - let num_nodes: u16 = ledger.current_committee().unwrap().num_members().try_into().unwrap(); - let (accounts, _committee) = primary::new_test_committee(num_nodes); - let account = Account::from_str(&accounts[0].private_key().to_string()).unwrap(); - // Initialize the gateway. - Gateway::new(account, storage, ledger, None, &[], None).unwrap() -} - -/// Samples a new worker with the given ledger. -pub fn sample_worker(id: u8, ledger: Arc>>) -> Worker { - // Sample a storage. - let storage = sample_storage(ledger.clone()); - // Sample a gateway. - let gateway = sample_gateway(storage.clone(), ledger.clone()); - // Sample a dummy proposed batch. - let proposed_batch = Arc::new(RwLock::new(None)); - // Construct the worker instance. - Worker::new(id, Arc::new(gateway.clone()), storage.clone(), ledger, proposed_batch).unwrap() -} diff --git a/node/bft/tests/components/pending.rs b/node/bft/tests/components/pending.rs index f4766084a5..2825637369 100644 --- a/node/bft/tests/components/pending.rs +++ b/node/bft/tests/components/pending.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::{common::CurrentNetwork, components::sample_ledger}; +use crate::common::{primary::new_test_committee, utils::sample_ledger, CurrentNetwork}; use snarkos_node_bft::helpers::max_redundant_requests; use snarkvm::{ledger::committee::Committee, prelude::TestRng}; @@ -21,9 +21,11 @@ fn test_max_redundant_requests() { const NUM_NODES: u16 = Committee::::MAX_COMMITTEE_SIZE; // Initialize the RNG. - let rng = &mut TestRng::default(); + let mut rng = TestRng::default(); + // Initialize the accounts and the committee. + let (accounts, committee) = new_test_committee(NUM_NODES, &mut rng); // Sample a ledger. - let ledger = sample_ledger(NUM_NODES, rng); + let ledger = sample_ledger(&accounts, &committee, &mut rng); // Ensure the maximum number of redundant requests is correct and consistent across iterations. assert_eq!(max_redundant_requests(ledger, 0), 34, "Update me if the formula changes"); } diff --git a/node/bft/tests/components/worker.rs b/node/bft/tests/components/worker.rs index 1877bd859a..2236d73699 100644 --- a/node/bft/tests/components/worker.rs +++ b/node/bft/tests/components/worker.rs @@ -12,9 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::{ - common::CurrentNetwork, - components::{sample_ledger, sample_worker}, +use crate::common::{ + primary::new_test_committee, + utils::{sample_ledger, sample_worker}, + CurrentNetwork, }; use snarkos_node_bft::helpers::max_redundant_requests; use snarkvm::{ @@ -30,11 +31,13 @@ async fn test_resend_transmission_request() { const NUM_NODES: u16 = Committee::::MAX_COMMITTEE_SIZE; // Initialize the RNG. - let rng = &mut TestRng::default(); + let mut rng = TestRng::default(); + // Initialize the accounts and the committee. + let (accounts, committee) = new_test_committee(NUM_NODES, &mut rng); // Sample a ledger. - let ledger = sample_ledger(NUM_NODES, rng); + let ledger = sample_ledger(&accounts, &committee, &mut rng); // Sample a worker. - let worker = sample_worker(0, ledger.clone()); + let worker = sample_worker(0, accounts[0].clone(), ledger.clone()); // Determine the maximum number of redundant requests. let max_redundancy = max_redundant_requests(ledger.clone(), 0); @@ -89,11 +92,13 @@ async fn test_flood_transmission_requests() { const NUM_NODES: u16 = Committee::::MAX_COMMITTEE_SIZE; // Initialize the RNG. - let rng = &mut TestRng::default(); + let mut rng = TestRng::default(); + // Initialize the accounts and the committee. + let (accounts, committee) = new_test_committee(NUM_NODES, &mut rng); // Sample a ledger. - let ledger = sample_ledger(NUM_NODES, rng); + let ledger = sample_ledger(&accounts, &committee, &mut rng); // Sample a worker. - let worker = sample_worker(0, ledger.clone()); + let worker = sample_worker(0, accounts[0].clone(), ledger.clone()); // Determine the maximum number of redundant requests. let max_redundancy = max_redundant_requests(ledger.clone(), 0); diff --git a/node/bft/tests/gateway_e2e.rs b/node/bft/tests/gateway_e2e.rs index ab451bed85..09fd79794c 100644 --- a/node/bft/tests/gateway_e2e.rs +++ b/node/bft/tests/gateway_e2e.rs @@ -15,37 +15,38 @@ #[allow(dead_code)] mod common; -use crate::common::{primary::new_test_committee, test_peer::TestPeer, CurrentNetwork}; +use crate::common::{ + primary::new_test_committee, + test_peer::TestPeer, + utils::{sample_gateway, sample_ledger, sample_storage}, + CurrentNetwork, +}; use snarkos_account::Account; use snarkos_node_bft::{helpers::init_primary_channels, Gateway}; use snarkos_node_bft_events::{ChallengeRequest, ChallengeResponse, Disconnect, DisconnectReason, Event, WorkerPing}; -use snarkos_node_bft_ledger_service::MockLedgerService; use snarkos_node_tcp::P2P; -use snarkvm::{ - ledger::{committee::Committee, narwhal::Data}, - prelude::TestRng, -}; +use snarkvm::{ledger::narwhal::Data, prelude::TestRng}; -use std::{net::SocketAddr, str::FromStr, sync::Arc, time::Duration}; +use std::time::Duration; use deadline::deadline; use rand::Rng; async fn new_test_gateway( - accounts: &[Account], - committee: &Committee, -) -> Gateway { - let ledger = Arc::new(MockLedgerService::new(committee.clone())); - let addr = SocketAddr::from_str("127.0.0.1:0").ok(); - let trusted_validators = []; - let gateway = Gateway::new(accounts.first().unwrap().clone(), ledger, addr, &trusted_validators, None).unwrap(); + num_nodes: u16, + rng: &mut TestRng, +) -> (Vec>, Gateway) { + let (accounts, committee) = new_test_committee(num_nodes, rng); + let ledger = sample_ledger(&accounts, &committee, rng); + let storage = sample_storage(ledger.clone()); + let gateway = sample_gateway(accounts[0].clone(), storage, ledger); // Set up primary channels, we discard the rx as we're testing the gateway sans BFT. let (primary_tx, _primary_rx) = init_primary_channels(); gateway.run(primary_tx, [].into(), None).await; - gateway + (accounts, gateway) } // The test peer connects to the gateway and completes the no-op handshake (so @@ -53,8 +54,9 @@ async fn new_test_gateway( #[tokio::test(flavor = "multi_thread")] async fn handshake_responder_side_timeout() { const NUM_NODES: u16 = 4; - let (accounts, committee) = new_test_committee(NUM_NODES); - let gateway = new_test_gateway(&accounts, &committee).await; + + let mut rng = TestRng::default(); + let (_accounts, gateway) = new_test_gateway(NUM_NODES, &mut rng).await; let test_peer = TestPeer::new().await; // Initiate a connection with the gateway, this will only return once the handshake protocol has @@ -86,8 +88,9 @@ macro_rules! handshake_responder_side_unexpected_event { #[tokio::test(flavor = "multi_thread")] async fn []() { const NUM_NODES: u16 = 4; - let (accounts, committee) = new_test_committee(NUM_NODES); - let gateway = new_test_gateway(&accounts, &committee).await; + + let mut rng = TestRng::default(); + let (_accounts, gateway) = new_test_gateway(NUM_NODES, &mut rng).await; let test_peer = TestPeer::new().await; // Initiate a connection with the gateway, this will only return once the handshake protocol has @@ -154,8 +157,7 @@ async fn handshake_responder_side_invalid_challenge_request() { const NUM_NODES: u16 = 4; let mut rng = TestRng::default(); - let (accounts, committee) = new_test_committee(NUM_NODES); - let gateway = new_test_gateway(&accounts, &committee).await; + let (accounts, gateway) = new_test_gateway(NUM_NODES, &mut rng).await; let test_peer = TestPeer::new().await; // Initiate a connection with the gateway, this will only return once the handshake protocol has @@ -194,8 +196,7 @@ async fn handshake_responder_side_invalid_challenge_response() { const NUM_NODES: u16 = 4; let mut rng = TestRng::default(); - let (accounts, committee) = new_test_committee(NUM_NODES); - let gateway = new_test_gateway(&accounts, &committee).await; + let (accounts, gateway) = new_test_gateway(NUM_NODES, &mut rng).await; let mut test_peer = TestPeer::new().await; // Initiate a connection with the gateway, this will only return once the handshake protocol has From 88dfdc6f7c67550642db8d53042d5ee28dd6e5c9 Mon Sep 17 00:00:00 2001 From: Niklas Date: Mon, 25 Mar 2024 14:49:47 +0100 Subject: [PATCH 358/551] deps: update `pea2pea` --- node/Cargo.toml | 2 +- node/bft/Cargo.toml | 2 +- node/bft/tests/common/test_peer.rs | 12 ++++-------- node/bft/tests/gateway_e2e.rs | 2 ++ node/tests/common/test_peer.rs | 12 ++++-------- 5 files changed, 12 insertions(+), 18 deletions(-) diff --git a/node/Cargo.toml b/node/Cargo.toml index 88e23403fd..82cf32b8e6 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -129,7 +129,7 @@ version = "0.2" version = "1" [dev-dependencies.pea2pea] -version = "0.46" +version = "0.49" [dev-dependencies.snarkos-node-router] path = "./router" diff --git a/node/bft/Cargo.toml b/node/bft/Cargo.toml index 2f3d3b20c8..8b2c5ed86c 100644 --- a/node/bft/Cargo.toml +++ b/node/bft/Cargo.toml @@ -138,7 +138,7 @@ version = "5" version = "1" [dev-dependencies.pea2pea] - version = "0.46" + version = "0.49" [dev-dependencies.proptest] version = "1.4.0" diff --git a/node/bft/tests/common/test_peer.rs b/node/bft/tests/common/test_peer.rs index db1bf37afe..508ab75d6f 100644 --- a/node/bft/tests/common/test_peer.rs +++ b/node/bft/tests/common/test_peer.rs @@ -22,7 +22,7 @@ use std::{ }; use pea2pea::{ - protocols::{Disconnect, Handshake, Reading, Writing}, + protocols::{Handshake, OnDisconnect, Reading, Writing}, Config, Connection, ConnectionSide, @@ -54,8 +54,8 @@ impl TestPeer { let (tx, rx) = mpsc::channel(100); let inner_node = InnerNode { node: Node::new(Config { - listener_ip: Some(IpAddr::V4(Ipv4Addr::LOCALHOST)), max_connections: 200, + listener_addr: Some(SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 0)), ..Default::default() }), inbound_tx: tx, @@ -107,7 +107,6 @@ impl Pea2Pea for InnerNode { } } -#[async_trait::async_trait] impl Handshake for InnerNode { // Set the timeout on the test peer to be longer than the gateway's timeout. const TIMEOUT_MS: u64 = 10_000; @@ -118,7 +117,6 @@ impl Handshake for InnerNode { } } -#[async_trait::async_trait] impl Writing for InnerNode { type Codec = EventCodec; type Message = Event; @@ -128,7 +126,6 @@ impl Writing for InnerNode { } } -#[async_trait::async_trait] impl Reading for InnerNode { type Codec = EventCodec; type Message = Event; @@ -144,7 +141,6 @@ impl Reading for InnerNode { } } -#[async_trait::async_trait] -impl Disconnect for InnerNode { - async fn handle_disconnect(&self, _peer_addr: SocketAddr) {} +impl OnDisconnect for InnerNode { + async fn on_disconnect(&self, _peer_addr: SocketAddr) {} } diff --git a/node/bft/tests/gateway_e2e.rs b/node/bft/tests/gateway_e2e.rs index 09fd79794c..46a270bf56 100644 --- a/node/bft/tests/gateway_e2e.rs +++ b/node/bft/tests/gateway_e2e.rs @@ -59,6 +59,8 @@ async fn handshake_responder_side_timeout() { let (_accounts, gateway) = new_test_gateway(NUM_NODES, &mut rng).await; let test_peer = TestPeer::new().await; + dbg!(test_peer.listening_addr()); + // Initiate a connection with the gateway, this will only return once the handshake protocol has // completed on the test peer's side, which is a no-op. assert!(test_peer.connect(gateway.local_ip()).await.is_ok()); diff --git a/node/tests/common/test_peer.rs b/node/tests/common/test_peer.rs index 4c7cfc037a..1a2bbcd337 100644 --- a/node/tests/common/test_peer.rs +++ b/node/tests/common/test_peer.rs @@ -30,7 +30,7 @@ use std::{ use futures_util::{sink::SinkExt, TryStreamExt}; use pea2pea::{ - protocols::{Disconnect, Handshake, Reading, Writing}, + protocols::{Handshake, OnDisconnect, Reading, Writing}, Config, Connection, ConnectionSide, @@ -82,8 +82,8 @@ impl TestPeer { pub async fn new(node_type: NodeType, account: Account) -> Self { let peer = Self { node: Node::new(Config { - listener_ip: Some(IpAddr::V4(Ipv4Addr::LOCALHOST)), max_connections: 200, + listener_addr: Some(SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 0)), ..Default::default() }), node_type, @@ -113,7 +113,6 @@ impl TestPeer { } } -#[async_trait::async_trait] impl Handshake for TestPeer { async fn perform_handshake(&self, mut conn: Connection) -> io::Result { let rng = &mut TestRng::default(); @@ -174,7 +173,6 @@ impl Handshake for TestPeer { } } -#[async_trait::async_trait] impl Writing for TestPeer { type Codec = MessageCodec; type Message = Message; @@ -184,7 +182,6 @@ impl Writing for TestPeer { } } -#[async_trait::async_trait] impl Reading for TestPeer { type Codec = MessageCodec; type Message = Message; @@ -198,7 +195,6 @@ impl Reading for TestPeer { } } -#[async_trait::async_trait] -impl Disconnect for TestPeer { - async fn handle_disconnect(&self, _peer_addr: SocketAddr) {} +impl OnDisconnect for TestPeer { + async fn on_disconnect(&self, _peer_addr: SocketAddr) {} } From e01a32992765259328efa1942b4f3463ed91ae73 Mon Sep 17 00:00:00 2001 From: Niklas Date: Tue, 19 Mar 2024 16:49:11 +0100 Subject: [PATCH 359/551] chore: update lock file --- Cargo.lock | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e93e06f25d..cd3394f07c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2080,14 +2080,12 @@ checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" [[package]] name = "pea2pea" -version = "0.46.0" +version = "0.49.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1051ff6b30971947b93dc4d76f281a276200a3a0fffd95abe8274e8d92455f2" +checksum = "908db9c51d2d2a4c379bce9395cac8305a464780b0c809969001501743207191" dependencies = [ - "async-trait", "bytes", "futures-util", - "once_cell", "parking_lot", "tokio", "tokio-util", @@ -3042,6 +3040,7 @@ dependencies = [ "open", "parking_lot", "paste", + "pea2pea", "proptest", "rand", "rand_chacha", From 1fb1448b164c01ba584d7ebb226bc1d1a7b29f53 Mon Sep 17 00:00:00 2001 From: Niklas Date: Fri, 12 Apr 2024 17:40:35 +0100 Subject: [PATCH 360/551] chore: clean up a little lingering noise --- node/bft/events/src/helpers/codec.rs | 3 --- node/metrics/src/names.rs | 15 ++------------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/node/bft/events/src/helpers/codec.rs b/node/bft/events/src/helpers/codec.rs index 73b764c453..cee8db29cf 100644 --- a/node/bft/events/src/helpers/codec.rs +++ b/node/bft/events/src/helpers/codec.rs @@ -25,9 +25,6 @@ const MAX_HANDSHAKE_SIZE: usize = 1024 * 1024; // 1 MiB /// The maximum size of an event that can be transmitted in the network. const MAX_EVENT_SIZE: usize = 128 * 1024 * 1024; // 128 MiB -/// The type of noise handshake to use for network encryption. -pub const NOISE_HANDSHAKE_TYPE: &str = "Noise_XX_25519_ChaChaPoly_BLAKE2s"; - /// The codec used to decode and encode network `Event`s. pub struct EventCodec { codec: LengthDelimitedCodec, diff --git a/node/metrics/src/names.rs b/node/metrics/src/names.rs index 8dec924a7b..45ef04e8fd 100644 --- a/node/metrics/src/names.rs +++ b/node/metrics/src/names.rs @@ -36,15 +36,8 @@ pub(super) const GAUGE_NAMES: [&str; 19] = [ tcp::TCP_TASKS, ]; -pub(super) const HISTOGRAM_NAMES: [&str; 7] = [ - bft::COMMIT_ROUNDS_LATENCY, - consensus::CERTIFICATE_COMMIT_LATENCY, - consensus::BLOCK_LATENCY, - tcp::NOISE_CODEC_ENCRYPTION_TIME, - tcp::NOISE_CODEC_DECRYPTION_TIME, - tcp::NOISE_CODEC_ENCRYPTION_SIZE, - tcp::NOISE_CODEC_DECRYPTION_SIZE, -]; +pub(super) const HISTOGRAM_NAMES: [&str; 3] = + [bft::COMMIT_ROUNDS_LATENCY, consensus::CERTIFICATE_COMMIT_LATENCY, consensus::BLOCK_LATENCY]; pub mod bft { pub const COMMIT_ROUNDS_LATENCY: &str = "snarkos_bft_commit_rounds_latency_secs"; // <-- This one doesn't even make sense. @@ -83,9 +76,5 @@ pub mod router { } pub mod tcp { - pub const NOISE_CODEC_ENCRYPTION_TIME: &str = "snarkos_tcp_noise_codec_encryption_micros"; - pub const NOISE_CODEC_DECRYPTION_TIME: &str = "snarkos_tcp_noise_codec_decryption_micros"; - pub const NOISE_CODEC_ENCRYPTION_SIZE: &str = "snarkos_tcp_noise_codec_encryption_size"; - pub const NOISE_CODEC_DECRYPTION_SIZE: &str = "snarkos_tcp_noise_codec_decryption_size"; pub const TCP_TASKS: &str = "snarkos_tcp_tasks_total"; } From f9c470368de29928c6d633470dda8b98e79951b0 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 12 Apr 2024 14:47:52 -0400 Subject: [PATCH 361/551] Construct the requests based on the largest valid range of blocks --- node/sync/src/block_sync.rs | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/node/sync/src/block_sync.rs b/node/sync/src/block_sync.rs index 7fb7ef94fc..18646a9f24 100644 --- a/node/sync/src/block_sync.rs +++ b/node/sync/src/block_sync.rs @@ -22,7 +22,7 @@ use snarkos_node_sync_locators::{CHECKPOINT_INTERVAL, NUM_RECENT_BLOCKS}; use snarkvm::prelude::{block::Block, Network}; use anyhow::{bail, ensure, Result}; -use indexmap::IndexMap; +use indexmap::{IndexMap, IndexSet}; use itertools::Itertools; use parking_lot::{Mutex, RwLock}; use rand::{prelude::IteratorRandom, CryptoRng, Rng}; @@ -402,7 +402,7 @@ impl BlockSync { impl BlockSync { /// Returns a list of block requests, if the node needs to sync. - fn prepare_block_requests(&self) -> Vec<(u32, SyncRequest)> { + fn prepare_block_requests(&self) -> IndexMap> { // Remove timed out block requests. self.remove_timed_out_block_requests(); // Prepare the block requests. @@ -417,7 +417,7 @@ impl BlockSync { // Update the state of `is_block_synced` for the sync module. self.update_is_block_synced(0, MAX_BLOCKS_BEHIND); // Return an empty list of block requests. - Vec::new() + Default::default() } } @@ -734,13 +734,13 @@ impl BlockSync { sync_peers: IndexMap>, min_common_ancestor: u32, rng: &mut R, - ) -> Vec<(u32, SyncRequest)> { + ) -> IndexMap> { // Retrieve the latest canon height. let latest_canon_height = self.canon.latest_block_height(); // If the minimum common ancestor is at or below the latest canon height, then return early. if min_common_ancestor <= latest_canon_height { - return vec![]; + return Default::default(); } // Compute the start height for the block request. @@ -748,12 +748,13 @@ impl BlockSync { // Compute the end height for the block request. let end_height = (min_common_ancestor + 1).min(start_height + MAX_BLOCK_REQUESTS as u32); - let mut requests = Vec::with_capacity((start_height..end_height).len()); + let mut request_hashes = IndexMap::with_capacity((start_height..end_height).len()); + let mut max_num_sync_ips = 1; for height in start_height..end_height { // Ensure the current height is not canonized or already requested. if self.check_block_request(height).is_err() { - continue; + break; } // Construct the block request. @@ -769,14 +770,22 @@ impl BlockSync { } } - // Pick the sync peers. - let sync_ips = sync_peers.keys().copied().choose_multiple(rng, num_sync_ips); + // Update the maximum number of sync IPs. + max_num_sync_ips = max_num_sync_ips.max(num_sync_ips); // Append the request. - requests.push((height, (hash, previous_hash, sync_ips.into_iter().collect()))); + request_hashes.insert(height, (hash, previous_hash)); } - requests + // Pick the sync peers. + let sync_ips: IndexSet<_> = + sync_peers.keys().copied().choose_multiple(rng, max_num_sync_ips).into_iter().collect(); + + // Construct the requests with the same sync ips. + request_hashes + .into_iter() + .map(|(height, (hash, previous_hash))| (height, (hash, previous_hash, sync_ips.clone()))) + .collect() } } From 7a5f07316f83d86bc0d1c3ec8e478b6c321c1b16 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 12 Apr 2024 15:16:00 -0400 Subject: [PATCH 362/551] Increase block request range to 5 --- Cargo.lock | 488 +++++++++++++------------- node/bft/events/src/block_response.rs | 2 +- node/sync/Cargo.toml | 4 + node/sync/src/block_sync.rs | 42 ++- 4 files changed, 280 insertions(+), 256 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e93e06f25d..b1078054f0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -80,7 +80,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72f2a841f04c2eaeb5a95312e5201a9e4b7c95b64ca99870d6bd2e2376df540a" dependencies = [ "proc-macro2", - "quote 1.0.35", + "quote 1.0.36", "syn 1.0.109", ] @@ -91,7 +91,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6118baab6285accf088b31d5ea5029c37bbf9d98e62b4d8720a0a5a66bc2e427" dependencies = [ "proc-macro2", - "quote 1.0.35", + "quote 1.0.36", "syn 1.0.109", ] @@ -106,9 +106,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.16" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "android-tzdata" @@ -184,9 +184,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.81" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" +checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" [[package]] name = "arrayref" @@ -207,8 +207,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "30c5ef0ede93efbf733c1a727f3b6b5a1060bbedd5600183e66f6e4be4af0ec5" dependencies = [ "proc-macro2", - "quote 1.0.35", - "syn 2.0.53", + "quote 1.0.36", + "syn 2.0.58", ] [[package]] @@ -229,32 +229,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", - "quote 1.0.35", - "syn 2.0.53", + "quote 1.0.36", + "syn 2.0.58", ] [[package]] name = "async-trait" -version = "0.1.78" +version = "0.1.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "461abc97219de0eaaf81fe3ef974a540158f3d079c2ab200f891f1a2ef201e85" +checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", - "quote 1.0.35", - "syn 2.0.53", + "quote 1.0.36", + "syn 2.0.58", ] [[package]] name = "autocfg" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" [[package]] name = "axum" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1236b4b292f6c4d6dc34604bb5120d85c3fe1d1aa596bd5cc52ca054d13e7b9e" +checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" dependencies = [ "async-trait", "axum-core", @@ -276,7 +276,7 @@ dependencies = [ "serde_json", "serde_path_to_error", "serde_urlencoded", - "sync_wrapper", + "sync_wrapper 1.0.1", "tokio", "tower", "tower-layer", @@ -299,7 +299,7 @@ dependencies = [ "mime", "pin-project-lite", "rustversion", - "sync_wrapper", + "sync_wrapper 0.1.2", "tower-layer", "tower-service", "tracing", @@ -307,9 +307,9 @@ dependencies = [ [[package]] name = "axum-extra" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "895ff42f72016617773af68fb90da2a9677d89c62338ec09162d4909d86fdd8f" +checksum = "0be6ea09c9b96cb5076af0de2e383bd2bc0c18f827cf1967bdd353e0b910d733" dependencies = [ "axum", "axum-core", @@ -326,13 +326,14 @@ dependencies = [ "tower", "tower-layer", "tower-service", + "tracing", ] [[package]] name = "backtrace" -version = "0.3.69" +version = "0.3.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" dependencies = [ "addr2line", "cc", @@ -349,6 +350,12 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +[[package]] +name = "base64" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" + [[package]] name = "bech32" version = "0.9.1" @@ -378,11 +385,11 @@ dependencies = [ "peeking_take_while", "prettyplease", "proc-macro2", - "quote 1.0.35", + "quote 1.0.36", "regex", "rustc-hash", "shlex", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] @@ -452,9 +459,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.15.4" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "byteorder" @@ -464,9 +471,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" [[package]] name = "bzip2-sys" @@ -487,9 +494,9 @@ checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" [[package]] name = "cc" -version = "1.0.90" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" +checksum = "2678b2e3449475e95b0aa6f9b506a28e61b3dc8996592b983695e8ebb58a8b41" dependencies = [ "jobserver", "libc", @@ -512,14 +519,14 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.35" +version = "0.4.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eaf5903dcbc0a39312feb77df2ff4c76387d591b9fc7b04a238dcf8bb62639a" +checksum = "8a0d04d43504c61aa6c7531f1871dd0d418d91130162063b789da00fd7057a5e" dependencies = [ "android-tzdata", "iana-time-zone", "num-traits", - "windows-targets 0.52.4", + "windows-targets 0.52.5", ] [[package]] @@ -544,9 +551,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.3" +version = "4.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "949626d00e063efc93b6dca932419ceb5432f99769911c0b995f7e884c778813" +checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" dependencies = [ "clap_builder", "clap_derive", @@ -566,14 +573,14 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.3" +version = "4.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90239a040c80f5e14809ca132ddc4176ab33d5e17e49691793296e3fcb34d72f" +checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" dependencies = [ "heck 0.5.0", "proc-macro2", - "quote 1.0.35", - "syn 2.0.53", + "quote 1.0.36", + "syn 2.0.58", ] [[package]] @@ -835,9 +842,9 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "encoding_rs" -version = "0.8.33" +version = "0.8.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" dependencies = [ "cfg-if", ] @@ -895,9 +902,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.1" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" [[package]] name = "flate2" @@ -1017,8 +1024,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", - "quote 1.0.35", - "syn 2.0.53", + "quote 1.0.36", + "syn 2.0.58", ] [[package]] @@ -1087,9 +1094,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" dependencies = [ "cfg-if", "js-sys", @@ -1132,9 +1139,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fbd2820c5e49886948654ab546d0688ff24530286bdcf8fca3cefb16d4618eb" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" dependencies = [ "bytes", "fnv", @@ -1142,26 +1149,7 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap 2.2.5", - "slab", - "tokio", - "tokio-util", - "tracing", -] - -[[package]] -name = "h2" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51ee2dd2e4f378392eeff5d51618cd9a63166a2513846bbc55f21cfacd9199d4" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http 1.1.0", - "indexmap 2.2.5", + "indexmap 2.2.6", "slab", "tokio", "tokio-util", @@ -1190,7 +1178,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "322106e6bd0cba2d5ead589ddb8150a13d7c4217cf80d7c4f682ca994ccc6aa9" dependencies = [ - "base64", + "base64 0.21.7", "bytes", "headers-core", "http 1.1.0", @@ -1316,7 +1304,7 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2 0.3.25", + "h2", "http 0.2.12", "http-body 0.4.6", "httparse", @@ -1339,7 +1327,6 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "h2 0.4.3", "http 1.1.0", "http-body 1.0.0", "httparse", @@ -1424,9 +1411,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.5" +version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", "hashbrown 0.14.3", @@ -1449,9 +1436,9 @@ dependencies = [ [[package]] name = "indoc" -version = "2.0.4" +version = "2.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8" +checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" [[package]] name = "instant" @@ -1507,15 +1494,15 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "jobserver" -version = "0.1.28" +version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6" +checksum = "685a7d121ee3f65ae4fddd72b25a04bb36b6af81bc0828f7d5434c0fe60fa3a2" dependencies = [ "libc", ] @@ -1531,11 +1518,11 @@ dependencies = [ [[package]] name = "jsonwebtoken" -version = "9.2.0" +version = "9.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c7ea04a7c5c055c175f189b6dc6ba036fd62306b58c66c9f6389036c503a3f4" +checksum = "b9ae10193d25051e74945f1ea2d0b42e03cc3b890f7e4cc5faa44997d808193f" dependencies = [ - "base64", + "base64 0.21.7", "js-sys", "pem", "ring", @@ -1569,7 +1556,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" dependencies = [ "cfg-if", - "windows-targets 0.52.4", + "windows-targets 0.52.5", ] [[package]] @@ -1580,13 +1567,12 @@ checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "libredox" -version = "0.0.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ "bitflags 2.5.0", "libc", - "redox_syscall", ] [[package]] @@ -1606,9 +1592,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.15" +version = "1.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "037731f5d3aaa87a5675e895b63ddff1a87624bc29f77004ea829809654e48f6" +checksum = "5e143b5e666b2695d28f6bca6497720813f699c9602dd7f5cac91008b8ada7f9" dependencies = [ "cc", "libc", @@ -1689,9 +1675,9 @@ checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" [[package]] name = "memchr" -version = "2.7.1" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" [[package]] name = "memoffset" @@ -1718,10 +1704,10 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9bf4e7146e30ad172c42c39b3246864bd2d3c6396780711a1baf749cfe423e21" dependencies = [ - "base64", + "base64 0.21.7", "hyper 0.14.28", "hyper-tls", - "indexmap 2.2.5", + "indexmap 2.2.6", "ipnet", "metrics", "metrics-util", @@ -1812,8 +1798,8 @@ checksum = "af7cbce79ec385a1d4f54baa90a76401eb15d9cab93685f62e7e9f942aa00ae2" dependencies = [ "cfg-if", "proc-macro2", - "quote 1.0.35", - "syn 2.0.53", + "quote 1.0.36", + "syn 2.0.58", ] [[package]] @@ -1915,8 +1901,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", - "quote 1.0.35", - "syn 2.0.53", + "quote 1.0.36", + "syn 2.0.58", ] [[package]] @@ -2015,8 +2001,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", - "quote 1.0.35", - "syn 2.0.53", + "quote 1.0.36", + "syn 2.0.58", ] [[package]] @@ -2027,9 +2013,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.101" +version = "0.9.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dda2b0f344e78efc2facf7d195d098df0dd72151b26ab98da807afc26c198dff" +checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" dependencies = [ "cc", "libc", @@ -2108,11 +2094,11 @@ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" [[package]] name = "pem" -version = "3.0.3" +version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b8fcc794035347fb64beda2d3b462595dd2753e3f268d89c5aae77e8cf2c310" +checksum = "8e459365e590736a54c3fa561947c84837534b8e9af6fc5bf781307e82658fae" dependencies = [ - "base64", + "base64 0.22.0", "serde", ] @@ -2138,15 +2124,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", - "quote 1.0.35", - "syn 2.0.53", + "quote 1.0.36", + "syn 2.0.58", ] [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -2206,12 +2192,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a41cf62165e97c7f814d2221421dbb9afcbcdb0a88068e5ea206e19951c2cbb5" +checksum = "8d3928fb5db768cb86f891ff014f0144589297e3c6a1aba6ed7cecfdace270c7" dependencies = [ "proc-macro2", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] @@ -2237,7 +2223,7 @@ dependencies = [ "rand", "rand_chacha", "rand_xorshift", - "regex-syntax 0.8.2", + "regex-syntax 0.8.3", "rusty-fork", "tempfile", "unarray", @@ -2245,9 +2231,9 @@ dependencies = [ [[package]] name = "quanta" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ca0b7bac0b97248c40bb77288fc52029cf1459c0461ea1b05ee32ccf011de2c" +checksum = "8e5167a477619228a0b284fac2674e3c388cba90631d7b7de620e6f1fcd08da5" dependencies = [ "crossbeam-utils", "libc", @@ -2281,9 +2267,9 @@ checksum = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -2367,9 +2353,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4963ed1bc86e4f3ee217022bd855b297cef07fb9eac5dfa1f788b220b49b3bd" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" dependencies = [ "either", "rayon-core", @@ -2396,9 +2382,9 @@ dependencies = [ [[package]] name = "redox_users" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" +checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" dependencies = [ "getrandom", "libredox", @@ -2407,14 +2393,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.3" +version = "1.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" dependencies = [ "aho-corasick", "memchr", "regex-automata 0.4.6", - "regex-syntax 0.8.2", + "regex-syntax 0.8.3", ] [[package]] @@ -2434,7 +2420,7 @@ checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.2", + "regex-syntax 0.8.3", ] [[package]] @@ -2445,9 +2431,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" [[package]] name = "reqwest" @@ -2455,12 +2441,12 @@ version = "0.11.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" dependencies = [ - "base64", + "base64 0.21.7", "bytes", "encoding_rs", "futures-core", "futures-util", - "h2 0.3.25", + "h2", "http 0.2.12", "http-body 0.4.6", "hyper 0.14.28", @@ -2477,7 +2463,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", - "sync_wrapper", + "sync_wrapper 0.1.2", "system-configuration", "tokio", "tokio-native-tls", @@ -2550,9 +2536,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.22.2" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e87c9956bd9807afa1f77e0f7594af32566e830e088a5576d27c5b6f30f49d41" +checksum = "99008d7ad0bbbea527ec27bddbc0e432c5b87d8175178cee68d2eec9c4a1813c" dependencies = [ "log", "ring", @@ -2568,14 +2554,14 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" dependencies = [ - "base64", + "base64 0.21.7", ] [[package]] name = "rustls-pki-types" -version = "1.3.1" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ede67b28608b4c60685c7d54122d4400d90f62b40caee7700e700380a390fa8" +checksum = "ecd36cc4259e3e4514335c4a138c6b43171a8d61d8f5c9348f9fc7529416f247" [[package]] name = "rustls-webpki" @@ -2590,9 +2576,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" +checksum = "80af6f9131f277a45a3fba6ce8e2258037bb0477a67e610d3c1fe046ab31de47" [[package]] name = "rusty-fork" @@ -2650,9 +2636,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "security-framework" -version = "2.9.2" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" +checksum = "770452e37cad93e0a50d5abc3990d2bc351c36d0328f86cefec2f2fb206eaef6" dependencies = [ "bitflags 1.3.2", "core-foundation", @@ -2663,9 +2649,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.9.1" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" +checksum = "41f3cc463c0ef97e11c3461a9d3787412d30e8e7eb907c79180c4a57bf7c04ef" dependencies = [ "core-foundation-sys", "libc", @@ -2742,17 +2728,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", - "quote 1.0.35", - "syn 2.0.53", + "quote 1.0.36", + "syn 2.0.58", ] [[package]] name = "serde_json" -version = "1.0.114" +version = "1.0.115" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" +checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" dependencies = [ - "indexmap 2.2.5", + "indexmap 2.2.6", "itoa", "ryu", "serde", @@ -2935,7 +2921,7 @@ dependencies = [ "clap", "colored", "crossterm", - "indexmap 2.2.5", + "indexmap 2.2.6", "nix", "num_cpus", "parking_lot", @@ -2994,7 +2980,7 @@ dependencies = [ "colored", "deadline", "futures-util", - "indexmap 2.2.5", + "indexmap 2.2.6", "num_cpus", "once_cell", "parking_lot", @@ -3036,7 +3022,7 @@ dependencies = [ "colored", "deadline", "futures", - "indexmap 2.2.5", + "indexmap 2.2.6", "itertools 0.12.1", "mockall", "open", @@ -3074,7 +3060,7 @@ version = "2.2.7" dependencies = [ "anyhow", "bytes", - "indexmap 2.2.5", + "indexmap 2.2.6", "proptest", "rayon", "serde", @@ -3092,7 +3078,7 @@ name = "snarkos-node-bft-ledger-service" version = "2.2.7" dependencies = [ "async-trait", - "indexmap 2.2.5", + "indexmap 2.2.6", "lru", "parking_lot", "rand", @@ -3107,7 +3093,7 @@ name = "snarkos-node-bft-storage-service" version = "2.2.7" dependencies = [ "aleo-std", - "indexmap 2.2.5", + "indexmap 2.2.6", "parking_lot", "snarkvm", "tracing", @@ -3139,7 +3125,7 @@ dependencies = [ "aleo-std", "anyhow", "colored", - "indexmap 2.2.5", + "indexmap 2.2.6", "itertools 0.12.1", "lru", "once_cell", @@ -3174,7 +3160,7 @@ dependencies = [ "axum", "axum-extra", "http 1.1.0", - "indexmap 2.2.5", + "indexmap 2.2.6", "jsonwebtoken", "once_cell", "parking_lot", @@ -3205,7 +3191,7 @@ dependencies = [ "deadline", "futures", "futures-util", - "indexmap 2.2.5", + "indexmap 2.2.6", "linked-hash-map", "parking_lot", "peak_alloc", @@ -3234,7 +3220,7 @@ version = "2.2.7" dependencies = [ "anyhow", "bytes", - "indexmap 2.2.5", + "indexmap 2.2.6", "proptest", "rayon", "serde", @@ -3252,13 +3238,14 @@ name = "snarkos-node-sync" version = "2.2.7" dependencies = [ "anyhow", - "indexmap 2.2.5", + "indexmap 2.2.6", "itertools 0.12.1", "once_cell", "parking_lot", "rand", "serde", "snarkos-node-bft-ledger-service", + "snarkos-node-router", "snarkos-node-sync-communication-service", "snarkos-node-sync-locators", "snarkvm", @@ -3279,7 +3266,7 @@ name = "snarkos-node-sync-locators" version = "2.2.7" dependencies = [ "anyhow", - "indexmap 2.2.5", + "indexmap 2.2.6", "serde", "snarkvm", "tracing", @@ -3310,7 +3297,7 @@ dependencies = [ "clap", "colored", "dotenvy", - "indexmap 2.2.5", + "indexmap 2.2.6", "num-format", "once_cell", "parking_lot", @@ -3343,7 +3330,7 @@ dependencies = [ "fxhash", "hashbrown 0.14.3", "hex", - "indexmap 2.2.5", + "indexmap 2.2.6", "itertools 0.11.0", "num-traits", "parking_lot", @@ -3411,7 +3398,7 @@ name = "snarkvm-circuit-environment" version = "0.16.19" source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ - "indexmap 2.2.5", + "indexmap 2.2.6", "itertools 0.11.0", "nom", "num-traits", @@ -3603,7 +3590,7 @@ version = "0.16.19" source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "anyhow", - "indexmap 2.2.5", + "indexmap 2.2.6", "itertools 0.11.0", "lazy_static", "once_cell", @@ -3645,7 +3632,7 @@ source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef59 dependencies = [ "enum_index", "enum_index_derive", - "indexmap 2.2.5", + "indexmap 2.2.6", "num-derive", "num-traits", "once_cell", @@ -3785,7 +3772,7 @@ source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef59 dependencies = [ "aleo-std", "anyhow", - "indexmap 2.2.5", + "indexmap 2.2.6", "parking_lot", "rand", "rayon", @@ -3820,7 +3807,7 @@ name = "snarkvm-ledger-block" version = "0.16.19" source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ - "indexmap 2.2.5", + "indexmap 2.2.6", "rayon", "serde_json", "snarkvm-console", @@ -3840,7 +3827,7 @@ version = "0.16.19" source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "anyhow", - "indexmap 2.2.5", + "indexmap 2.2.6", "proptest", "rand", "rand_chacha", @@ -3871,7 +3858,7 @@ name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ - "indexmap 2.2.5", + "indexmap 2.2.6", "rayon", "serde_json", "snarkvm-console", @@ -3884,7 +3871,7 @@ name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ - "indexmap 2.2.5", + "indexmap 2.2.6", "rayon", "serde_json", "snarkvm-console", @@ -3908,7 +3895,7 @@ name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ - "indexmap 2.2.5", + "indexmap 2.2.6", "rayon", "serde_json", "snarkvm-console", @@ -3948,7 +3935,7 @@ dependencies = [ "aleo-std", "anyhow", "bincode", - "indexmap 2.2.5", + "indexmap 2.2.6", "lru", "once_cell", "parking_lot", @@ -3967,7 +3954,7 @@ source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef59 dependencies = [ "anyhow", "colored", - "indexmap 2.2.5", + "indexmap 2.2.6", "rand", "rand_chacha", "rayon", @@ -3996,7 +3983,7 @@ dependencies = [ "aleo-std-storage", "anyhow", "bincode", - "indexmap 2.2.5", + "indexmap 2.2.6", "once_cell", "parking_lot", "rayon", @@ -4050,7 +4037,7 @@ dependencies = [ "colored", "curl", "hex", - "indexmap 2.2.5", + "indexmap 2.2.6", "itertools 0.11.0", "lazy_static", "parking_lot", @@ -4070,7 +4057,7 @@ source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef59 dependencies = [ "aleo-std", "anyhow", - "indexmap 2.2.5", + "indexmap 2.2.6", "itertools 0.11.0", "lru", "parking_lot", @@ -4099,7 +4086,7 @@ source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef59 dependencies = [ "aleo-std", "colored", - "indexmap 2.2.5", + "indexmap 2.2.6", "once_cell", "parking_lot", "rand", @@ -4120,7 +4107,7 @@ name = "snarkvm-synthesizer-program" version = "0.16.19" source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ - "indexmap 2.2.5", + "indexmap 2.2.6", "paste", "rand", "rand_chacha", @@ -4169,8 +4156,8 @@ version = "0.16.19" source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" dependencies = [ "proc-macro2", - "quote 1.0.35", - "syn 2.0.53", + "quote 1.0.36", + "syn 2.0.58", ] [[package]] @@ -4204,15 +4191,15 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebd1b177894da2a2d9120208c3386066af06a488255caabc5de8ddca22dbc3ce" dependencies = [ - "quote 1.0.35", + "quote 1.0.36", "syn 1.0.109", ] [[package]] name = "strsim" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "structmeta" @@ -4221,9 +4208,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ad9e09554f0456d67a69c1584c9798ba733a5b50349a6c0d0948710523922d" dependencies = [ "proc-macro2", - "quote 1.0.35", + "quote 1.0.36", "structmeta-derive", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] @@ -4233,8 +4220,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a60bcaff7397072dca0017d1db428e30d5002e00b6847703e2e42005c95fbe00" dependencies = [ "proc-macro2", - "quote 1.0.35", - "syn 2.0.53", + "quote 1.0.36", + "syn 2.0.58", ] [[package]] @@ -4254,9 +4241,9 @@ checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" dependencies = [ "heck 0.4.1", "proc-macro2", - "quote 1.0.35", + "quote 1.0.36", "rustversion", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] @@ -4283,18 +4270,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", - "quote 1.0.35", + "quote 1.0.36", "unicode-ident", ] [[package]] name = "syn" -version = "2.0.53" +version = "2.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7383cd0e49fff4b6b90ca5670bfd3e9d6a733b3f90c686605aa7eec8c4996032" +checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" dependencies = [ "proc-macro2", - "quote 1.0.35", + "quote 1.0.36", "unicode-ident", ] @@ -4304,6 +4291,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "sync_wrapper" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" + [[package]] name = "synom" version = "0.11.3" @@ -4351,7 +4344,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ "cfg-if", - "fastrand 2.0.1", + "fastrand 2.0.2", "rustix", "windows-sys 0.52.0", ] @@ -4369,9 +4362,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8361c808554228ad09bfed70f5c823caf8a3450b6881cc3a38eb57e8c08c1d9" dependencies = [ "proc-macro2", - "quote 1.0.35", + "quote 1.0.36", "structmeta", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] @@ -4390,8 +4383,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", - "quote 1.0.35", - "syn 2.0.53", + "quote 1.0.36", + "syn 2.0.58", ] [[package]] @@ -4426,9 +4419,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.34" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", @@ -4447,9 +4440,9 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ "num-conv", "time-core", @@ -4481,9 +4474,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.36.0" +version = "1.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" +checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" dependencies = [ "backtrace", "bytes", @@ -4505,8 +4498,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", - "quote 1.0.35", - "syn 2.0.53", + "quote 1.0.36", + "syn 2.0.58", ] [[package]] @@ -4654,8 +4647,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", - "quote 1.0.35", - "syn 2.0.53", + "quote 1.0.36", + "syn 2.0.58", ] [[package]] @@ -4771,7 +4764,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c49adbab879d2e0dd7f75edace5f0ac2156939ecb7e6a1e8fa14e53728328c48" dependencies = [ "lazy_static", - "quote 1.0.35", + "quote 1.0.36", "syn 1.0.109", ] @@ -4782,7 +4775,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "258bc1c4f8e2e73a977812ab339d503e6feeb92700f6d07a6de4d321522d5c08" dependencies = [ "lazy_static", - "quote 1.0.35", + "quote 1.0.36", "syn 1.0.109", ] @@ -4864,7 +4857,7 @@ version = "2.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11f214ce18d8b2cbe84ed3aa6486ed3f5b285cf8d8fbdbce9f3f767a724adc35" dependencies = [ - "base64", + "base64 0.21.7", "flate2", "log", "once_cell", @@ -4972,8 +4965,8 @@ dependencies = [ "log", "once_cell", "proc-macro2", - "quote 1.0.35", - "syn 2.0.53", + "quote 1.0.36", + "syn 2.0.58", "wasm-bindgen-shared", ] @@ -4995,7 +4988,7 @@ version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ - "quote 1.0.35", + "quote 1.0.36", "wasm-bindgen-macro-support", ] @@ -5006,8 +4999,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", - "quote 1.0.35", - "syn 2.0.53", + "quote 1.0.36", + "syn 2.0.58", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -5074,7 +5067,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.4", + "windows-targets 0.52.5", ] [[package]] @@ -5092,7 +5085,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.4", + "windows-targets 0.52.5", ] [[package]] @@ -5112,17 +5105,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" dependencies = [ - "windows_aarch64_gnullvm 0.52.4", - "windows_aarch64_msvc 0.52.4", - "windows_i686_gnu 0.52.4", - "windows_i686_msvc 0.52.4", - "windows_x86_64_gnu 0.52.4", - "windows_x86_64_gnullvm 0.52.4", - "windows_x86_64_msvc 0.52.4", + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", ] [[package]] @@ -5133,9 +5127,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" [[package]] name = "windows_aarch64_msvc" @@ -5145,9 +5139,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" [[package]] name = "windows_i686_gnu" @@ -5157,9 +5151,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.4" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" [[package]] name = "windows_i686_msvc" @@ -5169,9 +5169,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" [[package]] name = "windows_x86_64_gnu" @@ -5181,9 +5181,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" [[package]] name = "windows_x86_64_gnullvm" @@ -5193,9 +5193,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" [[package]] name = "windows_x86_64_msvc" @@ -5205,9 +5205,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] name = "winreg" @@ -5235,8 +5235,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", - "quote 1.0.35", - "syn 2.0.53", + "quote 1.0.36", + "syn 2.0.58", ] [[package]] @@ -5255,6 +5255,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", - "quote 1.0.35", - "syn 2.0.53", + "quote 1.0.36", + "syn 2.0.58", ] diff --git a/node/bft/events/src/block_response.rs b/node/bft/events/src/block_response.rs index 1ca7ab86ef..2bf1f20057 100644 --- a/node/bft/events/src/block_response.rs +++ b/node/bft/events/src/block_response.rs @@ -64,7 +64,7 @@ pub struct DataBlocks(pub Vec>); impl DataBlocks { /// The maximum number of blocks that can be sent in a single message. - pub const MAXIMUM_NUMBER_OF_BLOCKS: u8 = 1; + pub const MAXIMUM_NUMBER_OF_BLOCKS: u8 = 5; /// Ensures that the blocks are well-formed in a block response. pub fn ensure_response_is_well_formed( diff --git a/node/sync/Cargo.toml b/node/sync/Cargo.toml index a5f13d43d0..491dfb6557 100644 --- a/node/sync/Cargo.toml +++ b/node/sync/Cargo.toml @@ -47,6 +47,10 @@ path = "../bft/ledger-service" version = "=2.2.7" features = [ "ledger-write" ] +[dependencies.snarkos-node-router] +path = "../router" +version = "=2.2.7" + [dependencies.snarkos-node-sync-communication-service] path = "communication-service" version = "=2.2.7" diff --git a/node/sync/src/block_sync.rs b/node/sync/src/block_sync.rs index 18646a9f24..49a151f8da 100644 --- a/node/sync/src/block_sync.rs +++ b/node/sync/src/block_sync.rs @@ -17,6 +17,7 @@ use crate::{ locators::BlockLocators, }; use snarkos_node_bft_ledger_service::LedgerService; +use snarkos_node_router::messages::DataBlocks; use snarkos_node_sync_communication_service::CommunicationService; use snarkos_node_sync_locators::{CHECKPOINT_INTERVAL, NUM_RECENT_BLOCKS}; use snarkvm::prelude::{block::Block, Network}; @@ -231,26 +232,45 @@ impl BlockSync { } // Process the block requests. - 'outer: for (height, (hash, previous_hash, sync_ips)) in block_requests { - // Insert the block request into the sync pool. - if let Err(error) = self.insert_block_request(height, (hash, previous_hash, sync_ips.clone())) { - warn!("Block sync failed - {error}"); - // Break out of the loop. - break 'outer; + 'outer: for requests in block_requests.chunks(DataBlocks::::MAXIMUM_NUMBER_OF_BLOCKS as usize) { + // Retrieve the starting height and the sync IPs. + let (start_height, sync_ips) = match requests.first() { + Some((height, (_, _, sync_ips))) => (*height, sync_ips), + None => { + warn!("Block sync failed - no block requests"); + break 'outer; + } + }; + + // TODO (raychu86): Unify the sync_ip selection or select new sync IPS for each block request. + + // Calculate the end height. + let end_height = start_height.saturating_add(requests.len() as u32); + + // Insert the chunk of block requests. + for (height, (hash, previous_hash, _)) in requests.iter() { + // Insert the block request into the sync pool using the sync IPs from the last block request in the chunk. + if let Err(error) = self.insert_block_request(*height, (*hash, *previous_hash, sync_ips.clone())) { + warn!("Block sync failed - {error}"); + // Break out of the loop. + break 'outer; + } } /* Send the block request to the peers */ // Construct the message. - let message = C::prepare_block_request(height, height + 1); + let message = C::prepare_block_request(start_height, end_height); // Send the message to the peers. for sync_ip in sync_ips { - let sender = communication.send(sync_ip, message.clone()).await; + let sender = communication.send(*sync_ip, message.clone()).await; // If the send fails for any peer, remove the block request from the sync pool. if sender.is_none() { warn!("Failed to send block request to peer '{sync_ip}'"); // Remove the entire block request from the sync pool. - self.remove_block_request(height); + for height in start_height..end_height { + self.remove_block_request(height); + } // Break out of the loop. break 'outer; } @@ -402,7 +422,7 @@ impl BlockSync { impl BlockSync { /// Returns a list of block requests, if the node needs to sync. - fn prepare_block_requests(&self) -> IndexMap> { + fn prepare_block_requests(&self) -> Vec<(u32, SyncRequest)> { // Remove timed out block requests. self.remove_timed_out_block_requests(); // Prepare the block requests. @@ -734,7 +754,7 @@ impl BlockSync { sync_peers: IndexMap>, min_common_ancestor: u32, rng: &mut R, - ) -> IndexMap> { + ) -> Vec<(u32, SyncRequest)> { // Retrieve the latest canon height. let latest_canon_height = self.canon.latest_block_height(); From 2d5ab54b6892659c24a34ccf5d2185ce7f6c0311 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 12 Apr 2024 15:38:41 -0400 Subject: [PATCH 363/551] Randomly select sync ips per chunk --- node/sync/src/block_sync.rs | 46 ++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/node/sync/src/block_sync.rs b/node/sync/src/block_sync.rs index 49a151f8da..cba68973df 100644 --- a/node/sync/src/block_sync.rs +++ b/node/sync/src/block_sync.rs @@ -214,7 +214,7 @@ impl BlockSync { pub async fn try_block_sync(&self, communication: &C) { // Prepare the block requests, if any. // In the process, we update the state of `is_block_synced` for the sync module. - let block_requests = self.prepare_block_requests(); + let (block_requests, sync_peers) = self.prepare_block_requests(); trace!("Prepared {} block requests", block_requests.len()); // If there are no block requests, but there are pending block responses in the sync pool, @@ -242,7 +242,13 @@ impl BlockSync { } }; - // TODO (raychu86): Unify the sync_ip selection or select new sync IPS for each block request. + // Use a randomly sampled subset of the sync IPs. + let sync_ips: IndexSet<_> = sync_peers + .keys() + .copied() + .choose_multiple(&mut rand::thread_rng(), sync_ips.len()) + .into_iter() + .collect(); // Calculate the end height. let end_height = start_height.saturating_add(requests.len() as u32); @@ -263,7 +269,7 @@ impl BlockSync { let message = C::prepare_block_request(start_height, end_height); // Send the message to the peers. for sync_ip in sync_ips { - let sender = communication.send(*sync_ip, message.clone()).await; + let sender = communication.send(sync_ip, message.clone()).await; // If the send fails for any peer, remove the block request from the sync pool. if sender.is_none() { warn!("Failed to send block request to peer '{sync_ip}'"); @@ -421,8 +427,9 @@ impl BlockSync { } impl BlockSync { - /// Returns a list of block requests, if the node needs to sync. - fn prepare_block_requests(&self) -> Vec<(u32, SyncRequest)> { + /// Returns a list of block requests and the sync peers, if the node needs to sync. + #[allow(clippy::type_complexity)] + fn prepare_block_requests(&self) -> (Vec<(u32, SyncRequest)>, IndexMap>) { // Remove timed out block requests. self.remove_timed_out_block_requests(); // Prepare the block requests. @@ -432,12 +439,12 @@ impl BlockSync { // Update the state of `is_block_synced` for the sync module. self.update_is_block_synced(greatest_peer_height, MAX_BLOCKS_BEHIND); // Return the list of block requests. - self.construct_requests(sync_peers, min_common_ancestor, &mut rand::thread_rng()) + (self.construct_requests(&sync_peers, min_common_ancestor, &mut rand::thread_rng()), sync_peers) } else { // Update the state of `is_block_synced` for the sync module. self.update_is_block_synced(0, MAX_BLOCKS_BEHIND); // Return an empty list of block requests. - Default::default() + (Default::default(), Default::default()) } } @@ -751,7 +758,7 @@ impl BlockSync { /// Given the sync peers and their minimum common ancestor, return a list of block requests. fn construct_requests( &self, - sync_peers: IndexMap>, + sync_peers: &IndexMap>, min_common_ancestor: u32, rng: &mut R, ) -> Vec<(u32, SyncRequest)> { @@ -778,7 +785,7 @@ impl BlockSync { } // Construct the block request. - let (hash, previous_hash, num_sync_ips, is_honest) = construct_request(height, &sync_peers); + let (hash, previous_hash, num_sync_ips, is_honest) = construct_request(height, sync_peers); // Handle the dishonest case. if !is_honest { @@ -797,6 +804,7 @@ impl BlockSync { request_hashes.insert(height, (hash, previous_hash)); } + // TODO (raychu86): Remove this. Just return the required num_sync_ips. // Pick the sync peers. let sync_ips: IndexSet<_> = sync_peers.keys().copied().choose_multiple(rng, max_num_sync_ips).into_iter().collect(); @@ -954,7 +962,7 @@ mod tests { }; // Prepare the block requests. - let requests = sync.prepare_block_requests(); + let (requests, _) = sync.prepare_block_requests(); // If there are no peers, then there should be no requests. if peers.is_empty() { @@ -1056,7 +1064,7 @@ mod tests { sync.update_peer_locators(peer_3, sample_block_locators(10)).unwrap(); // Prepare the block requests. - let requests = sync.prepare_block_requests(); + let (requests, _) = sync.prepare_block_requests(); assert_eq!(requests.len(), 10); // Check the requests. @@ -1098,7 +1106,7 @@ mod tests { sync.update_peer_locators(peer_3, sample_block_locators(10)).unwrap(); // Prepare the block requests. - let requests = sync.prepare_block_requests(); + let (requests, _) = sync.prepare_block_requests(); assert_eq!(requests.len(), 0); // When there are NUM_REDUNDANCY+1 peers ahead, and 1 is on a fork, then there should be block requests. @@ -1108,7 +1116,7 @@ mod tests { sync.update_peer_locators(peer_4, sample_block_locators(10)).unwrap(); // Prepare the block requests. - let requests = sync.prepare_block_requests(); + let (requests, _) = sync.prepare_block_requests(); assert_eq!(requests.len(), 10); // Check the requests. @@ -1142,7 +1150,7 @@ mod tests { sync.update_peer_locators(peer_3, sample_block_locators_with_fork(20, 10)).unwrap(); // Prepare the block requests. - let requests = sync.prepare_block_requests(); + let (requests, _) = sync.prepare_block_requests(); assert_eq!(requests.len(), 0); // When there are NUM_REDUNDANCY+1 peers ahead, and peer 3 is on a fork, then there should be block requests. @@ -1152,7 +1160,7 @@ mod tests { sync.update_peer_locators(peer_4, sample_block_locators(10)).unwrap(); // Prepare the block requests. - let requests = sync.prepare_block_requests(); + let (requests, _) = sync.prepare_block_requests(); assert_eq!(requests.len(), 10); // Check the requests. @@ -1173,7 +1181,7 @@ mod tests { sync.update_peer_locators(sample_peer_ip(1), sample_block_locators(10)).unwrap(); // Prepare the block requests. - let requests = sync.prepare_block_requests(); + let (requests, _) = sync.prepare_block_requests(); assert_eq!(requests.len(), 10); for (height, (hash, previous_hash, sync_ips)) in requests.clone() { @@ -1291,7 +1299,7 @@ mod tests { sync.update_peer_locators(peer_ip, sample_block_locators(10)).unwrap(); // Prepare the block requests. - let requests = sync.prepare_block_requests(); + let (requests, _) = sync.prepare_block_requests(); assert_eq!(requests.len(), 10); for (height, (hash, previous_hash, sync_ips)) in requests.clone() { @@ -1312,14 +1320,14 @@ mod tests { } // As there is no peer, it should not be possible to prepare block requests. - let requests = sync.prepare_block_requests(); + let (requests, _) = sync.prepare_block_requests(); assert_eq!(requests.len(), 0); // Add the peer again. sync.update_peer_locators(peer_ip, sample_block_locators(10)).unwrap(); // Prepare the block requests. - let requests = sync.prepare_block_requests(); + let (requests, _) = sync.prepare_block_requests(); assert_eq!(requests.len(), 10); for (height, (hash, previous_hash, sync_ips)) in requests { From 24d0cfaf6cd64b52b2f924180194ad704b7b022b Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 12 Apr 2024 15:50:58 -0400 Subject: [PATCH 364/551] Find the first start height that is valid --- node/sync/src/block_sync.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/node/sync/src/block_sync.rs b/node/sync/src/block_sync.rs index cba68973df..44550196cd 100644 --- a/node/sync/src/block_sync.rs +++ b/node/sync/src/block_sync.rs @@ -781,7 +781,12 @@ impl BlockSync { for height in start_height..end_height { // Ensure the current height is not canonized or already requested. if self.check_block_request(height).is_err() { - break; + // If the sequence of block requests is interrupted, then return early. + // Otherwise, continue until the first start height that is new. + match request_hashes.is_empty() { + true => continue, + false => break, + } } // Construct the block request. From 4511ac4afa5f3d33692042694184fda828bd4168 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 12 Apr 2024 16:09:28 -0400 Subject: [PATCH 365/551] Increase expected end height to match MAXIMUM_NUMBER_OF_BLOCKS --- node/sync/src/block_sync.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/node/sync/src/block_sync.rs b/node/sync/src/block_sync.rs index 44550196cd..3b597b91e7 100644 --- a/node/sync/src/block_sync.rs +++ b/node/sync/src/block_sync.rs @@ -773,7 +773,8 @@ impl BlockSync { // Compute the start height for the block request. let start_height = latest_canon_height + 1; // Compute the end height for the block request. - let end_height = (min_common_ancestor + 1).min(start_height + MAX_BLOCK_REQUESTS as u32); + let max_blocks_to_request = MAX_BLOCK_REQUESTS as u32 * DataBlocks::::MAXIMUM_NUMBER_OF_BLOCKS as u32; + let end_height = (min_common_ancestor + 1).min(start_height + max_blocks_to_request); let mut request_hashes = IndexMap::with_capacity((start_height..end_height).len()); let mut max_num_sync_ips = 1; From 062871476d70720a6584f3a20afa6f80ea4b9cfb Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 12 Apr 2024 17:30:32 -0400 Subject: [PATCH 366/551] Change MAXIMUM_NUMBER_OF_BLOCKS to 10 --- node/bft/events/src/block_response.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/bft/events/src/block_response.rs b/node/bft/events/src/block_response.rs index 2bf1f20057..ea56fa9579 100644 --- a/node/bft/events/src/block_response.rs +++ b/node/bft/events/src/block_response.rs @@ -64,7 +64,7 @@ pub struct DataBlocks(pub Vec>); impl DataBlocks { /// The maximum number of blocks that can be sent in a single message. - pub const MAXIMUM_NUMBER_OF_BLOCKS: u8 = 5; + pub const MAXIMUM_NUMBER_OF_BLOCKS: u8 = 10; /// Ensures that the blocks are well-formed in a block response. pub fn ensure_response_is_well_formed( From d6589a2d36c6d15f0229ad249c86a85d7d390a69 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 12 Apr 2024 17:43:50 -0400 Subject: [PATCH 367/551] Update DataBlocks::MAXIMUM_NUMBER_OF_BLOCKS to 10 --- node/bft/events/src/block_response.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/bft/events/src/block_response.rs b/node/bft/events/src/block_response.rs index 1ca7ab86ef..ea56fa9579 100644 --- a/node/bft/events/src/block_response.rs +++ b/node/bft/events/src/block_response.rs @@ -64,7 +64,7 @@ pub struct DataBlocks(pub Vec>); impl DataBlocks { /// The maximum number of blocks that can be sent in a single message. - pub const MAXIMUM_NUMBER_OF_BLOCKS: u8 = 1; + pub const MAXIMUM_NUMBER_OF_BLOCKS: u8 = 10; /// Ensures that the blocks are well-formed in a block response. pub fn ensure_response_is_well_formed( From ff93a40ce0c0dc5f1fd5b83add69ee3ff01a00ba Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 12 Apr 2024 17:51:30 -0400 Subject: [PATCH 368/551] Update MAX_EVENT_SIZE to 256mb --- node/bft/events/src/helpers/codec.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/bft/events/src/helpers/codec.rs b/node/bft/events/src/helpers/codec.rs index 73b764c453..6bd37959eb 100644 --- a/node/bft/events/src/helpers/codec.rs +++ b/node/bft/events/src/helpers/codec.rs @@ -23,7 +23,7 @@ use tracing::*; /// The maximum size of an event that can be transmitted during the handshake. const MAX_HANDSHAKE_SIZE: usize = 1024 * 1024; // 1 MiB /// The maximum size of an event that can be transmitted in the network. -const MAX_EVENT_SIZE: usize = 128 * 1024 * 1024; // 128 MiB +const MAX_EVENT_SIZE: usize = 256 * 1024 * 1024; // 256 MiB /// The type of noise handshake to use for network encryption. pub const NOISE_HANDSHAKE_TYPE: &str = "Noise_XX_25519_ChaChaPoly_BLAKE2s"; From 0148db262c9571050fabdddecac38897203dde99 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 12 Apr 2024 19:12:55 -0400 Subject: [PATCH 369/551] Remove transmission minimum in proposal --- node/bft/src/primary.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 4cd17221c2..4fc0fc3cc9 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -461,11 +461,6 @@ impl Primary { } } } - // If there are no unconfirmed transmissions to propose, return early. - if transmissions.is_empty() { - debug!("Primary is safely skipping a batch proposal {}", "(no unconfirmed transmissions)".dimmed()); - return Ok(()); - } // Ditto if the batch had already been proposed and not expired. ensure!(round > 0, "Round 0 cannot have transaction batches"); // Determine the current timestamp. From aae1e50721ce9689ffdec3f4da25d629b62793f1 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 12 Apr 2024 19:36:02 -0400 Subject: [PATCH 370/551] Update MAX_TRANSMISSIONS_TOLERANCE --- node/bft/src/primary.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 4fc0fc3cc9..196814e8e5 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -104,7 +104,7 @@ pub struct Primary { impl Primary { /// The maximum number of unconfirmed transmissions to send to the primary. - pub const MAX_TRANSMISSIONS_TOLERANCE: usize = 1 << 10; + pub const MAX_TRANSMISSIONS_TOLERANCE: usize = BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH * 2; /// Initializes a new primary instance. pub fn new( From 86b706e93eec89200afa07d0f597bdccb03e2c10 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 12 Apr 2024 19:56:06 -0400 Subject: [PATCH 371/551] Allow proposals with no transmissions --- node/bft/src/helpers/proposal.rs | 2 -- node/bft/src/primary.rs | 23 +++++++++++++---------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/node/bft/src/helpers/proposal.rs b/node/bft/src/helpers/proposal.rs index 1137ddaa68..a3a7ae7f8c 100644 --- a/node/bft/src/helpers/proposal.rs +++ b/node/bft/src/helpers/proposal.rs @@ -48,8 +48,6 @@ impl Proposal { ensure!(batch_header.round() >= committee.starting_round(), "Batch round must be >= the committee round"); // Ensure the batch author is a member of the committee. ensure!(committee.is_committee_member(batch_header.author()), "The batch author is not a committee member"); - // Ensure the transmissions are not empty. - ensure!(!transmissions.is_empty(), "The transmissions are empty"); // Ensure the transmission IDs match in the batch header and transmissions. ensure!( batch_header.transmission_ids().len() == transmissions.len(), diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 196814e8e5..e58aee0450 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -1792,11 +1792,6 @@ mod tests { // Check there is no batch currently proposed. assert!(primary.proposed_batch.read().is_none()); - // Try to propose a batch. There are no transmissions in the workers so the method should - // just return without proposing a batch. - assert!(primary.propose_batch().await.is_ok()); - assert!(primary.proposed_batch.read().is_none()); - // Generate a solution and a transaction. let (solution_id, solution) = sample_unconfirmed_solution(&mut rng); let (transaction_id, transaction) = sample_unconfirmed_transaction(&mut rng); @@ -1810,6 +1805,19 @@ mod tests { assert!(primary.proposed_batch.read().is_some()); } + #[tokio::test] + async fn test_propose_batch_with_no_transmissions() { + let mut rng = TestRng::default(); + let (primary, _) = primary_without_handlers(&mut rng).await; + + // Check there is no batch currently proposed. + assert!(primary.proposed_batch.read().is_none()); + + // Try to propose a batch with no transmissions. + assert!(primary.propose_batch().await.is_ok()); + assert!(primary.proposed_batch.read().is_some()); + } + #[tokio::test] async fn test_propose_batch_in_round() { let round = 3; @@ -1822,11 +1830,6 @@ mod tests { // Sleep for a while to ensure the primary is ready to propose the next round. tokio::time::sleep(Duration::from_secs(MIN_BATCH_DELAY_IN_SECS)).await; - // Try to propose a batch. There are no transmissions in the workers so the method should - // just return without proposing a batch. - assert!(primary.propose_batch().await.is_ok()); - assert!(primary.proposed_batch.read().is_none()); - // Generate a solution and a transaction. let (solution_id, solution) = sample_unconfirmed_solution(&mut rng); let (transaction_id, transaction) = sample_unconfirmed_transaction(&mut rng); From 29cf16a019b1d4247128029919c01c9b7c6edc70 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 12 Apr 2024 20:19:13 -0400 Subject: [PATCH 372/551] Bump snarkVM rev - d48f6fb --- Cargo.lock | 118 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 2 +- 2 files changed, 60 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cd3394f07c..f8e8f17fc7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3302,7 +3302,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "anstyle", "anyhow", @@ -3333,7 +3333,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "aleo-std", "anyhow", @@ -3363,7 +3363,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3377,7 +3377,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3388,7 +3388,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3398,7 +3398,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3408,7 +3408,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "indexmap 2.2.5", "itertools 0.11.0", @@ -3426,12 +3426,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3442,7 +3442,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3457,7 +3457,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3472,7 +3472,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3485,7 +3485,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3494,7 +3494,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3504,7 +3504,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3516,7 +3516,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3528,7 +3528,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3539,7 +3539,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3551,7 +3551,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3564,7 +3564,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "bs58", "snarkvm-console-network", @@ -3575,7 +3575,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "blake2s_simd", "smallvec", @@ -3588,7 +3588,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "aleo-std", "rayon", @@ -3599,7 +3599,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "anyhow", "indexmap 2.2.5", @@ -3622,7 +3622,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "anyhow", "bech32", @@ -3640,7 +3640,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "enum_index", "enum_index_derive", @@ -3661,7 +3661,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3676,7 +3676,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3687,7 +3687,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "snarkvm-console-network-environment", ] @@ -3695,7 +3695,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3705,7 +3705,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3716,7 +3716,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3727,7 +3727,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3738,7 +3738,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3749,7 +3749,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "rand", "rayon", @@ -3763,7 +3763,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "aleo-std", "anyhow", @@ -3780,7 +3780,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "aleo-std", "anyhow", @@ -3805,7 +3805,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "anyhow", "rand", @@ -3817,7 +3817,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3836,7 +3836,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "anyhow", "indexmap 2.2.5", @@ -3855,7 +3855,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -3868,7 +3868,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3881,7 +3881,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3894,7 +3894,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "bytes", "serde_json", @@ -3905,7 +3905,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "indexmap 2.2.5", "rayon", @@ -3920,7 +3920,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "bytes", "serde_json", @@ -3933,7 +3933,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "snarkvm-console", "snarkvm-ledger-puzzle", @@ -3942,7 +3942,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "aleo-std", "anyhow", @@ -3962,7 +3962,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle-epoch" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "anyhow", "colored", @@ -3977,7 +3977,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "async-trait", "reqwest", @@ -3990,7 +3990,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "aleo-std-storage", "anyhow", @@ -4016,7 +4016,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4031,7 +4031,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4040,7 +4040,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "aleo-std", "anyhow", @@ -4065,7 +4065,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "aleo-std", "anyhow", @@ -4094,7 +4094,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "aleo-std", "colored", @@ -4117,7 +4117,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "indexmap 2.2.5", "paste", @@ -4131,7 +4131,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "bincode", "once_cell", @@ -4144,7 +4144,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "aleo-std", "anyhow", @@ -4165,7 +4165,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=ed20562#ed20562d6f97ef593f051ce3cc848644e785f817" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" dependencies = [ "proc-macro2", "quote 1.0.35", diff --git a/Cargo.toml b/Cargo.toml index 81b8254f8b..ae4b77d9c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "ed20562" +rev = "d48f6fb" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From 1c952d7e3ba9fc110513a58de97dfecdfeaa9e44 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 12 Apr 2024 20:25:52 -0400 Subject: [PATCH 373/551] Reinsert transmission to worker after failure to create header or proposal --- node/bft/src/primary.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index e58aee0450..9ca81cea90 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -487,8 +487,8 @@ impl Primary { let transmission_ids = transmissions.keys().copied().collect(); // Prepare the previous batch certificate IDs. let previous_certificate_ids = previous_certificates.into_iter().map(|c| c.id()).collect(); - // Sign the batch header. - let batch_header = spawn_blocking!(BatchHeader::new( + // Sign the batch header and construct the proposal. + let (batch_header, proposal) = spawn_blocking!(BatchHeader::new( &private_key, round, current_timestamp, @@ -496,9 +496,18 @@ impl Primary { transmission_ids, previous_certificate_ids, &mut rand::thread_rng() - ))?; - // Construct the proposal. - let proposal = Proposal::new(committee_lookback, batch_header.clone(), transmissions)?; + )) + .and_then(|batch_header| { + Proposal::new(committee_lookback, batch_header.clone(), transmissions.clone()) + .map(|proposal| (batch_header, proposal)) + }) + .map_err(|err| { + // On error, reinsert the transmissions and then propagate the error. + if let Err(e) = self.reinsert_transmissions_into_workers(transmissions) { + error!("Failed to reinsert transmissions: {e:?}"); + } + err + })?; // Broadcast the batch to all validators for signing. self.gateway.broadcast(Event::BatchPropose(batch_header.into())); // Set the timestamp of the latest proposed batch. From b9c7f23dff98a2fd1df9cc62a193510a328b6e5a Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 12 Apr 2024 20:39:02 -0400 Subject: [PATCH 374/551] Use proper Network::ID in match cases --- cli/src/commands/account.rs | 16 ++++++++-------- cli/src/commands/developer/decrypt.rs | 4 ++-- cli/src/commands/developer/deploy.rs | 4 ++-- cli/src/commands/developer/execute.rs | 4 ++-- cli/src/commands/developer/scan.rs | 16 ++++++++-------- cli/src/commands/developer/transfer_private.rs | 4 ++-- cli/src/commands/start.rs | 4 ++-- 7 files changed, 26 insertions(+), 26 deletions(-) diff --git a/cli/src/commands/account.rs b/cli/src/commands/account.rs index 04c9251ebd..b08aed7085 100644 --- a/cli/src/commands/account.rs +++ b/cli/src/commands/account.rs @@ -111,14 +111,14 @@ impl Account { match vanity { // Generate a vanity account for the specified network. Some(vanity) => match network { - 0 => Self::new_vanity::(vanity.as_str(), discreet), - 1 => Self::new_vanity::(vanity.as_str(), discreet), + MainnetV0::ID => Self::new_vanity::(vanity.as_str(), discreet), + TestnetV0::ID => Self::new_vanity::(vanity.as_str(), discreet), _ => bail!("Unsupported network ID"), }, // Generate a seeded account for the specified network. None => match network { - 0 => Self::new_seeded::(seed, discreet), - 1 => Self::new_seeded::(seed, discreet), + MainnetV0::ID => Self::new_seeded::(seed, discreet), + TestnetV0::ID => Self::new_seeded::(seed, discreet), _ => bail!("Unsupported network ID"), }, } @@ -138,16 +138,16 @@ impl Account { // Sign the message for the specified network. match network { - 0 => Self::sign::(key, message, seed, raw), - 1 => Self::sign::(key, message, seed, raw), + MainnetV0::ID => Self::sign::(key, message, seed, raw), + TestnetV0::ID => Self::sign::(key, message, seed, raw), _ => bail!("Unsupported network ID"), } } Self::Verify { network, address, signature, message, raw } => { // Verify the signature for the specified network. match network { - 0 => Self::verify::(address, signature, message, raw), - 1 => Self::verify::(address, signature, message, raw), + MainnetV0::ID => Self::verify::(address, signature, message, raw), + TestnetV0::ID => Self::verify::(address, signature, message, raw), _ => bail!("Unsupported network ID"), } } diff --git a/cli/src/commands/developer/decrypt.rs b/cli/src/commands/developer/decrypt.rs index c60df49774..49ac845d9e 100644 --- a/cli/src/commands/developer/decrypt.rs +++ b/cli/src/commands/developer/decrypt.rs @@ -43,8 +43,8 @@ impl Decrypt { pub fn parse(self) -> Result { // Decrypt the ciphertext for the given network. match self.network { - 0 => Self::decrypt_ciphertext::(&self.ciphertext, &self.view_key), - 1 => Self::decrypt_ciphertext::(&self.ciphertext, &self.view_key), + MainnetV0::ID => Self::decrypt_ciphertext::(&self.ciphertext, &self.view_key), + TestnetV0::ID => Self::decrypt_ciphertext::(&self.ciphertext, &self.view_key), _ => bail!("Unsupported network ID"), } } diff --git a/cli/src/commands/developer/deploy.rs b/cli/src/commands/developer/deploy.rs index 3c57e80167..2d3ace70f5 100644 --- a/cli/src/commands/developer/deploy.rs +++ b/cli/src/commands/developer/deploy.rs @@ -91,8 +91,8 @@ impl Deploy { // Construct the deployment for the specified network. match self.network { - 0 => self.construct_deployment::(), - 1 => self.construct_deployment::(), + MainnetV0::ID => self.construct_deployment::(), + TestnetV0::ID => self.construct_deployment::(), _ => bail!("Unsupported network ID"), } } diff --git a/cli/src/commands/developer/execute.rs b/cli/src/commands/developer/execute.rs index 754d83ffb6..0958a53928 100644 --- a/cli/src/commands/developer/execute.rs +++ b/cli/src/commands/developer/execute.rs @@ -92,8 +92,8 @@ impl Execute { // Construct the execution for the specified network. match self.network { - 0 => self.construct_execution::(), - 1 => self.construct_execution::(), + MainnetV0::ID => self.construct_execution::(), + TestnetV0::ID => self.construct_execution::(), _ => bail!("Unsupported network ID"), } } diff --git a/cli/src/commands/developer/scan.rs b/cli/src/commands/developer/scan.rs index e97896a510..79bce5cd94 100644 --- a/cli/src/commands/developer/scan.rs +++ b/cli/src/commands/developer/scan.rs @@ -69,8 +69,8 @@ impl Scan { pub fn parse(self) -> Result { // Scan for records on the given network. match self.network { - 0 => self.scan_records::(), - 1 => self.scan_records::(), + MainnetV0::ID => self.scan_records::(), + TestnetV0::ID => self.scan_records::(), _ => bail!("Unsupported network ID"), } } @@ -133,8 +133,8 @@ impl Scan { fn parse_block_range(&self) -> Result<(u32, u32)> { // Get the network name. let network = match self.network { - 0 => "mainnet", - 1 => "testnet", + MainnetV0::ID => "mainnet", + TestnetV0::ID => "testnet", _ => bail!("Unsupported network ID"), }; @@ -184,8 +184,8 @@ impl Scan { // Get the network name. let network = match N::ID { - 0 => "mainnet", - 1 => "testnet", + MainnetV0::ID => "mainnet", + TestnetV0::ID => "testnet", _ => bail!("Unsupported network ID"), }; @@ -362,8 +362,8 @@ impl Scan { // Get the network name. let network = match N::ID { - 0 => "mainnet", - 1 => "testnet", + MainnetV0::ID => "mainnet", + TestnetV0::ID => "testnet", _ => bail!("Unsupported network ID"), }; diff --git a/cli/src/commands/developer/transfer_private.rs b/cli/src/commands/developer/transfer_private.rs index 9b0955047f..08517cb2f1 100644 --- a/cli/src/commands/developer/transfer_private.rs +++ b/cli/src/commands/developer/transfer_private.rs @@ -91,8 +91,8 @@ impl TransferPrivate { // Construct the transfer for the specified network. match self.network { - 0 => self.construct_transfer_private::(), - 1 => self.construct_transfer_private::(), + MainnetV0::ID => self.construct_transfer_private::(), + TestnetV0::ID => self.construct_transfer_private::(), _ => bail!("Unsupported network ID"), } } diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index cca07ad311..6693ae44ba 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -163,7 +163,7 @@ impl Start { let mut cli = self.clone(); // Parse the network. match cli.network { - 0 => { + MainnetV0::ID => { // Parse the node from the configurations. let node = cli.parse_node::().await.expect("Failed to parse the node"); // If the display is enabled, render the display. @@ -172,7 +172,7 @@ impl Start { Display::start(node, log_receiver).expect("Failed to initialize the display"); } } - 1 => { + TestnetV0::ID => { // Parse the node from the configurations. let node = cli.parse_node::().await.expect("Failed to parse the node"); // If the display is enabled, render the display. From 51ae568ba411f2b1cd52e42dfd2f18b401700253 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 12 Apr 2024 20:55:59 -0400 Subject: [PATCH 375/551] Fix flaky test --- node/bft/src/primary.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index b93e25e7e2..5224bf8084 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -2513,7 +2513,7 @@ mod tests { let mut aborted_transmissions = HashSet::new(); let mut transmissions_without_aborted = HashMap::new(); for (transmission_id, transmission) in transmissions.clone() { - match rng.gen::() { + match rng.gen::() || aborted_transmissions.is_empty() { true => { // Insert the aborted transmission. aborted_transmissions.insert(transmission_id); From a1c12869b7b50d5a2b1d5c675175f26110cd11b5 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sun, 14 Apr 2024 14:26:31 -0400 Subject: [PATCH 376/551] Bump snarkVM rev - 69c25a8 --- Cargo.lock | 118 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 2 +- 2 files changed, 60 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6b24180b64..ecb396be5d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3288,7 +3288,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "anstyle", "anyhow", @@ -3319,7 +3319,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "aleo-std", "anyhow", @@ -3349,7 +3349,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3363,7 +3363,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3374,7 +3374,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3384,7 +3384,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3394,7 +3394,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "indexmap 2.2.6", "itertools 0.11.0", @@ -3412,12 +3412,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3428,7 +3428,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3443,7 +3443,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3458,7 +3458,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3471,7 +3471,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3480,7 +3480,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3490,7 +3490,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3502,7 +3502,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3514,7 +3514,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3525,7 +3525,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3537,7 +3537,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3550,7 +3550,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "bs58", "snarkvm-console-network", @@ -3561,7 +3561,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "blake2s_simd", "smallvec", @@ -3574,7 +3574,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "aleo-std", "rayon", @@ -3585,7 +3585,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "anyhow", "indexmap 2.2.6", @@ -3608,7 +3608,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "anyhow", "bech32", @@ -3626,7 +3626,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "enum_index", "enum_index_derive", @@ -3647,7 +3647,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3662,7 +3662,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3673,7 +3673,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "snarkvm-console-network-environment", ] @@ -3681,7 +3681,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3691,7 +3691,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3702,7 +3702,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3713,7 +3713,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3724,7 +3724,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3735,7 +3735,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "rand", "rayon", @@ -3749,7 +3749,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "aleo-std", "anyhow", @@ -3766,7 +3766,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "aleo-std", "anyhow", @@ -3791,7 +3791,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "anyhow", "rand", @@ -3803,7 +3803,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3822,7 +3822,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "anyhow", "indexmap 2.2.6", @@ -3841,7 +3841,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -3854,7 +3854,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3867,7 +3867,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3880,7 +3880,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "bytes", "serde_json", @@ -3891,7 +3891,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3906,7 +3906,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "bytes", "serde_json", @@ -3919,7 +3919,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "snarkvm-console", "snarkvm-ledger-puzzle", @@ -3928,7 +3928,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "aleo-std", "anyhow", @@ -3948,7 +3948,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle-epoch" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "anyhow", "colored", @@ -3963,7 +3963,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "async-trait", "reqwest", @@ -3976,7 +3976,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "aleo-std-storage", "anyhow", @@ -4002,7 +4002,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4017,7 +4017,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4026,7 +4026,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "aleo-std", "anyhow", @@ -4051,7 +4051,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "aleo-std", "anyhow", @@ -4080,7 +4080,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "aleo-std", "colored", @@ -4103,7 +4103,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "indexmap 2.2.6", "paste", @@ -4117,7 +4117,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "bincode", "once_cell", @@ -4130,7 +4130,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "aleo-std", "anyhow", @@ -4151,7 +4151,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=d48f6fb#d48f6fb7d7ca36d134407baebcc59952fe58c546" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" dependencies = [ "proc-macro2", "quote 1.0.36", diff --git a/Cargo.toml b/Cargo.toml index ae4b77d9c9..5fc7d3a190 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "d48f6fb" +rev = "69c25a8" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From 58b10da9346508f2d6d9c4aa55e61d8522a47f7b Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sun, 14 Apr 2024 15:07:47 -0400 Subject: [PATCH 377/551] Add aborted transmissions ID to BFTMemoryService --- node/bft/src/helpers/storage.rs | 13 ++++++-- node/bft/storage-service/src/memory.rs | 43 ++++++++++++++++++++++++-- node/bft/storage-service/src/traits.rs | 1 + 3 files changed, 52 insertions(+), 5 deletions(-) diff --git a/node/bft/src/helpers/storage.rs b/node/bft/src/helpers/storage.rs index f555099712..916a5fe24b 100644 --- a/node/bft/src/helpers/storage.rs +++ b/node/bft/src/helpers/storage.rs @@ -511,9 +511,10 @@ impl Storage { // Ensure the certificate round is above the GC round. ensure!(certificate.round() > self.gc_round(), "Certificate round is at or below the GC round"); // Ensure the certificate and its transmissions are valid. - let missing_transmissions = self.check_certificate(&certificate, transmissions, aborted_transmissions)?; + let missing_transmissions = + self.check_certificate(&certificate, transmissions, aborted_transmissions.clone())?; // Insert the certificate into storage. - self.insert_certificate_atomic(certificate, missing_transmissions); + self.insert_certificate_atomic(certificate, aborted_transmissions, missing_transmissions); Ok(()) } @@ -525,6 +526,7 @@ impl Storage { fn insert_certificate_atomic( &self, certificate: BatchCertificate, + aborted_transmission_ids: HashSet>, missing_transmissions: HashMap, Transmission>, ) { // Retrieve the round. @@ -545,7 +547,12 @@ impl Storage { // Insert the batch ID. self.batch_ids.write().insert(batch_id, round); // Insert the certificate ID for each of the transmissions into storage. - self.transmissions.insert_transmissions(certificate_id, transmission_ids, missing_transmissions); + self.transmissions.insert_transmissions( + certificate_id, + transmission_ids, + aborted_transmission_ids, + missing_transmissions, + ); } /// Removes the given `certificate ID` from storage. diff --git a/node/bft/storage-service/src/memory.rs b/node/bft/storage-service/src/memory.rs index d4ffc6ca98..2a05b72764 100644 --- a/node/bft/storage-service/src/memory.rs +++ b/node/bft/storage-service/src/memory.rs @@ -28,6 +28,8 @@ use tracing::error; pub struct BFTMemoryService { /// The map of `transmission ID` to `(transmission, certificate IDs)` entries. transmissions: RwLock, (Transmission, IndexSet>)>>, + /// The map of `aborted transmission ID` to `certificate IDs` entries. + aborted_transmission_ids: RwLock, IndexSet>>>, } impl Default for BFTMemoryService { @@ -40,7 +42,7 @@ impl Default for BFTMemoryService { impl BFTMemoryService { /// Initializes a new BFT in-memory storage service. pub fn new() -> Self { - Self { transmissions: Default::default() } + Self { transmissions: Default::default(), aborted_transmission_ids: Default::default() } } } @@ -49,10 +51,11 @@ impl StorageService for BFTMemoryService { fn contains_transmission(&self, transmission_id: TransmissionID) -> bool { // Check if the transmission ID exists in storage. self.transmissions.read().contains_key(&transmission_id) + || self.aborted_transmission_ids.read().contains_key(&transmission_id) } /// Returns the transmission for the given `transmission ID`. - /// If the transmission ID does not exist in storage, `None` is returned. + /// If the transmission does not exist in storage, `None` is returned. fn get_transmission(&self, transmission_id: TransmissionID) -> Option> { // Get the transmission. self.transmissions.read().get(&transmission_id).map(|(transmission, _)| transmission).cloned() @@ -96,10 +99,13 @@ impl StorageService for BFTMemoryService { &self, certificate_id: Field, transmission_ids: IndexSet>, + aborted_transmission_ids: HashSet>, mut missing_transmissions: HashMap, Transmission>, ) { // Acquire the transmissions write lock. let mut transmissions = self.transmissions.write(); + // Acquire the aborted transmission IDs write lock. + let mut aborted_transmission_ids_lock = self.aborted_transmission_ids.write(); // Inserts the following: // - Inserts **only the missing** transmissions from storage. // - Inserts the certificate ID into the corresponding set for **all** transmissions. @@ -124,6 +130,23 @@ impl StorageService for BFTMemoryService { } } } + // Inserts the aborted transmission IDs. + for aborted_transmission_id in aborted_transmission_ids { + // Retrieve the transmission entry. + match aborted_transmission_ids_lock.entry(aborted_transmission_id) { + Entry::Occupied(mut occupied_entry) => { + let certificate_ids = occupied_entry.get_mut(); + // Insert the certificate ID into the set. + certificate_ids.insert(certificate_id); + } + Entry::Vacant(vacant_entry) => { + // Prepare the set of certificate IDs. + let certificate_ids = indexset! { certificate_id }; + // Insert the transmission and a new set with the certificate ID. + vacant_entry.insert(certificate_ids); + } + } + } } /// Removes the certificate ID for the transmissions from storage. @@ -132,6 +155,8 @@ impl StorageService for BFTMemoryService { fn remove_transmissions(&self, certificate_id: &Field, transmission_ids: &IndexSet>) { // Acquire the transmissions write lock. let mut transmissions = self.transmissions.write(); + // Acquire the aborted transmission IDs write lock. + let mut aborted_transmission_ids = self.aborted_transmission_ids.write(); // If this is the last certificate ID for the transmission ID, remove the transmission. for transmission_id in transmission_ids { // Remove the certificate ID for the transmission ID, and determine if there are any more certificate IDs. @@ -148,6 +173,20 @@ impl StorageService for BFTMemoryService { } Entry::Vacant(_) => {} } + // Remove the certificate ID for the aborted transmission ID, and determine if there are any more certificate IDs. + match aborted_transmission_ids.entry(*transmission_id) { + Entry::Occupied(mut occupied_entry) => { + let certificate_ids = occupied_entry.get_mut(); + // Remove the certificate ID for the transmission ID. + certificate_ids.swap_remove(certificate_id); + // If there are no more certificate IDs for the transmission ID, remove the transmission. + if certificate_ids.is_empty() { + // Remove the entry for the transmission ID. + occupied_entry.shift_remove(); + } + } + Entry::Vacant(_) => {} + } } } diff --git a/node/bft/storage-service/src/traits.rs b/node/bft/storage-service/src/traits.rs index d2c1478978..34f088d546 100644 --- a/node/bft/storage-service/src/traits.rs +++ b/node/bft/storage-service/src/traits.rs @@ -44,6 +44,7 @@ pub trait StorageService: Debug + Send + Sync { &self, certificate_id: Field, transmission_ids: IndexSet>, + aborted_transmission_ids: HashSet>, missing_transmissions: HashMap, Transmission>, ); From 5a0e235f976a095588912f4f6926fb6ad36c1074 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sun, 14 Apr 2024 15:08:21 -0400 Subject: [PATCH 378/551] Add aborted transmissions ID to BFTPersistentStorage --- node/bft/storage-service/src/persistent.rs | 106 ++++++++++++++++++--- 1 file changed, 94 insertions(+), 12 deletions(-) diff --git a/node/bft/storage-service/src/persistent.rs b/node/bft/storage-service/src/persistent.rs index a3fc665d17..03c9569443 100644 --- a/node/bft/storage-service/src/persistent.rs +++ b/node/bft/storage-service/src/persistent.rs @@ -44,19 +44,37 @@ use tracing::error; pub struct BFTPersistentStorage { /// The map of `transmission ID` to `(transmission, certificate IDs)` entries. transmissions: DataMap, (Transmission, IndexSet>)>, + /// The map of `aborted transmission ID` to `certificate IDs` entries. + aborted_transmission_ids: DataMap, IndexSet>>, } impl BFTPersistentStorage { /// Initializes a new BFT persistent storage service. pub fn open(storage_mode: StorageMode) -> Result { - Ok(Self { transmissions: internal::RocksDB::open_map(N::ID, storage_mode, MapID::BFT(BFTMap::Transmissions))? }) + Ok(Self { + transmissions: internal::RocksDB::open_map(N::ID, storage_mode.clone(), MapID::BFT(BFTMap::Transmissions))?, + aborted_transmission_ids: internal::RocksDB::open_map( + N::ID, + storage_mode, + MapID::BFT(BFTMap::AbortedTransmissionIDs), + )?, + }) } /// Initializes a new BFT persistent storage service. #[cfg(any(test, feature = "test"))] pub fn open_testing(temp_dir: std::path::PathBuf, dev: Option) -> Result { Ok(Self { - transmissions: internal::RocksDB::open_map_testing(temp_dir, dev, MapID::BFT(BFTMap::Transmissions))?, + transmissions: internal::RocksDB::open_map_testing( + temp_dir.clone(), + dev, + MapID::BFT(BFTMap::Transmissions), + )?, + aborted_transmission_ids: internal::RocksDB::open_map_testing( + temp_dir, + dev, + MapID::BFT(BFTMap::AbortedTransmissionIDs), + )?, }) } } @@ -65,13 +83,19 @@ impl StorageService for BFTPersistentStorage { /// Returns `true` if the storage contains the specified `transmission ID`. fn contains_transmission(&self, transmission_id: TransmissionID) -> bool { // Check if the transmission ID exists in storage. - let result = self.transmissions.contains_key_confirmed(&transmission_id); - // If the result is an error, log the error. - if let Err(error) = &result { - error!("Failed to check if transmission ID exists in storage - {error}"); + match self.transmissions.contains_key_confirmed(&transmission_id) { + Ok(true) => return true, + Ok(false) => (), + Err(error) => error!("Failed to check if transmission ID exists in confirmed storage - {error}"), + } + // Check if the transmission ID is in aborted storage. + match self.aborted_transmission_ids.contains_key_confirmed(&transmission_id) { + Ok(result) => result, + Err(error) => { + error!("Failed to check if aborted transmission ID exists in storage - {error}"); + false + } } - // Return the result. - result.unwrap_or(false) } /// Returns the transmission for the given `transmission ID`. @@ -125,6 +149,7 @@ impl StorageService for BFTPersistentStorage { &self, certificate_id: Field, transmission_ids: IndexSet>, + aborted_transmission_ids: HashSet>, mut missing_transmissions: HashMap, Transmission>, ) { // Inserts the following: @@ -163,6 +188,34 @@ impl StorageService for BFTPersistentStorage { } } } + // Inserts the aborted transmission IDs. + for aborted_transmission_id in aborted_transmission_ids { + // Retrieve the transmission entry. + match self.aborted_transmission_ids.get_confirmed(&aborted_transmission_id) { + Ok(Some(entry)) => { + let mut certificate_ids = cow_to_cloned!(entry); + // Insert the certificate ID into the set. + certificate_ids.insert(certificate_id); + // Update the transmission entry. + if let Err(e) = self.aborted_transmission_ids.insert(aborted_transmission_id, certificate_ids) { + error!("Failed to insert aborted transmission ID {aborted_transmission_id} into storage - {e}"); + } + } + Ok(None) => { + // Prepare the set of certificate IDs. + let certificate_ids = indexset! { certificate_id }; + // Insert the transmission and a new set with the certificate ID. + if let Err(e) = self.aborted_transmission_ids.insert(aborted_transmission_id, certificate_ids) { + error!("Failed to insert aborted transmission ID {aborted_transmission_id} into storage - {e}"); + } + } + Err(e) => { + error!( + "Failed to process the 'insert' for aborted transmission ID {aborted_transmission_id} into storage - {e}" + ); + } + } + } } /// Removes the certificate ID for the transmissions from storage. @@ -170,7 +223,7 @@ impl StorageService for BFTPersistentStorage { /// If the transmission no longer references any certificate IDs, the entry is removed from storage. fn remove_transmissions(&self, certificate_id: &Field, transmission_ids: &IndexSet>) { // If this is the last certificate ID for the transmission ID, remove the transmission. - 'outer: for transmission_id in transmission_ids { + for transmission_id in transmission_ids { // Retrieve the transmission entry. match self.transmissions.get_confirmed(transmission_id) { Ok(Some(entry)) => { @@ -182,7 +235,6 @@ impl StorageService for BFTPersistentStorage { // Remove the transmission entry. if let Err(e) = self.transmissions.remove(transmission_id) { error!("Failed to remove transmission {transmission_id} (now empty) from storage - {e}"); - continue 'outer; } } // Otherwise, update the transmission entry. @@ -192,14 +244,44 @@ impl StorageService for BFTPersistentStorage { error!( "Failed to remove transmission {transmission_id} for certificate {certificate_id} from storage - {e}" ); - continue 'outer; } } } Ok(None) => { /* no-op */ } Err(e) => { error!("Failed to process the 'remove' for transmission {transmission_id} from storage - {e}"); - continue 'outer; + } + } + // Retrieve the aborted transmission ID entry. + match self.aborted_transmission_ids.get_confirmed(transmission_id) { + Ok(Some(entry)) => { + let mut certificate_ids = cow_to_cloned!(entry); + // Insert the certificate ID into the set. + certificate_ids.swap_remove(certificate_id); + // If there are no more certificate IDs for the transmission ID, remove the transmission. + if certificate_ids.is_empty() { + // Remove the transmission entry. + if let Err(e) = self.aborted_transmission_ids.remove(transmission_id) { + error!( + "Failed to remove aborted transmission ID {transmission_id} (now empty) from storage - {e}" + ); + } + } + // Otherwise, update the transmission entry. + else { + // Update the transmission entry. + if let Err(e) = self.aborted_transmission_ids.insert(*transmission_id, certificate_ids) { + error!( + "Failed to remove aborted transmission ID {transmission_id} for certificate {certificate_id} from storage - {e}" + ); + } + } + } + Ok(None) => { /* no-op */ } + Err(e) => { + error!( + "Failed to process the 'remove' for aborted transmission ID {transmission_id} from storage - {e}" + ); } } } From a4975807d83fb707bc99610431f645e36658b2b6 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Sun, 14 Apr 2024 15:27:52 -0400 Subject: [PATCH 379/551] Update tests and add check that aborted transmisssion IDs exist in storage --- node/bft/src/helpers/storage.rs | 21 +++++++++++++-------- node/bft/src/primary.rs | 10 +++++++++- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/node/bft/src/helpers/storage.rs b/node/bft/src/helpers/storage.rs index 916a5fe24b..bdaff5bc7d 100644 --- a/node/bft/src/helpers/storage.rs +++ b/node/bft/src/helpers/storage.rs @@ -785,7 +785,12 @@ impl Storage { .map(|id| (*id, Transmission::Transaction(snarkvm::ledger::narwhal::Data::Buffer(bytes::Bytes::new())))) .collect::>(); // Insert the certificate ID for each of the transmissions into storage. - self.transmissions.insert_transmissions(certificate_id, transmission_ids, missing_transmissions); + self.transmissions.insert_transmissions( + certificate_id, + transmission_ids, + Default::default(), + missing_transmissions, + ); } } @@ -894,7 +899,7 @@ mod tests { let (missing_transmissions, transmissions) = sample_transmissions(&certificate, rng); // Insert the certificate. - storage.insert_certificate_atomic(certificate.clone(), missing_transmissions); + storage.insert_certificate_atomic(certificate.clone(), Default::default(), missing_transmissions); // Ensure the certificate exists in storage. assert!(storage.contains_certificate(certificate_id)); // Ensure the certificate is stored in the correct round. @@ -966,21 +971,21 @@ mod tests { let (missing_transmissions, transmissions) = sample_transmissions(&certificate, rng); // Insert the certificate. - storage.insert_certificate_atomic(certificate.clone(), missing_transmissions.clone()); + storage.insert_certificate_atomic(certificate.clone(), Default::default(), missing_transmissions.clone()); // Ensure the certificate exists in storage. assert!(storage.contains_certificate(certificate_id)); // Check that the underlying storage representation is correct. assert_storage(&storage, &rounds, &certificates, &batch_ids, &transmissions); // Insert the certificate again - without any missing transmissions. - storage.insert_certificate_atomic(certificate.clone(), Default::default()); + storage.insert_certificate_atomic(certificate.clone(), Default::default(), Default::default()); // Ensure the certificate exists in storage. assert!(storage.contains_certificate(certificate_id)); // Check that the underlying storage representation remains unchanged. assert_storage(&storage, &rounds, &certificates, &batch_ids, &transmissions); // Insert the certificate again - with all of the original missing transmissions. - storage.insert_certificate_atomic(certificate, missing_transmissions); + storage.insert_certificate_atomic(certificate, Default::default(), missing_transmissions); // Ensure the certificate exists in storage. assert!(storage.contains_certificate(certificate_id)); // Check that the underlying storage representation remains unchanged. @@ -1212,21 +1217,21 @@ pub mod prop_tests { // Insert the certificate. let missing_transmissions: HashMap, Transmission> = transmission_map.into_iter().collect(); - storage.insert_certificate_atomic(certificate.clone(), missing_transmissions.clone()); + storage.insert_certificate_atomic(certificate.clone(), Default::default(), missing_transmissions.clone()); // Ensure the certificate exists in storage. assert!(storage.contains_certificate(certificate_id)); // Check that the underlying storage representation is correct. assert_storage(&storage, &rounds, &certificates, &batch_ids, &internal_transmissions); // Insert the certificate again - without any missing transmissions. - storage.insert_certificate_atomic(certificate.clone(), Default::default()); + storage.insert_certificate_atomic(certificate.clone(), Default::default(), Default::default()); // Ensure the certificate exists in storage. assert!(storage.contains_certificate(certificate_id)); // Check that the underlying storage representation remains unchanged. assert_storage(&storage, &rounds, &certificates, &batch_ids, &internal_transmissions); // Insert the certificate again - with all of the original missing transmissions. - storage.insert_certificate_atomic(certificate, missing_transmissions); + storage.insert_certificate_atomic(certificate, Default::default(), missing_transmissions); // Ensure the certificate exists in storage. assert!(storage.contains_certificate(certificate_id)); // Check that the underlying storage representation remains unchanged. diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 5224bf8084..5306d4db08 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -2545,9 +2545,17 @@ mod tests { ); // Insert the certificate to storage. - primary.storage.insert_certificate(certificate, transmissions_without_aborted, aborted_transmissions).unwrap(); + primary + .storage + .insert_certificate(certificate, transmissions_without_aborted, aborted_transmissions.clone()) + .unwrap(); // Ensure the certificate exists in storage. assert!(primary.storage.contains_certificate(certificate_id)); + // Ensure that the aborted transmissions are exist in the storage. + for aborted_transmission_id in aborted_transmissions { + assert!(primary.storage.contains_transmission(aborted_transmission_id)); + assert!(primary.storage.get_transmission(aborted_transmission_id).is_none()); + } } } From ff6161c23f62f16669d6c81ebca2dddad3712143 Mon Sep 17 00:00:00 2001 From: miazn Date: Mon, 15 Apr 2024 09:35:24 -0400 Subject: [PATCH 380/551] make standalone ledger func, counters atomic --- Cargo.lock | 1 + node/bft/ledger-service/Cargo.toml | 3 ++ node/bft/ledger-service/src/ledger.rs | 45 ++------------------------- node/bft/ledger-service/src/lib.rs | 42 +++++++++++++++++++++++++ node/bft/ledger-service/src/traits.rs | 4 --- node/metrics/snarkOS-grafana.json | 8 ++--- 6 files changed, 53 insertions(+), 50 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e93e06f25d..c2edd3f397 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3096,6 +3096,7 @@ dependencies = [ "lru", "parking_lot", "rand", + "rayon", "snarkos-node-metrics", "snarkvm", "tokio", diff --git a/node/bft/ledger-service/Cargo.toml b/node/bft/ledger-service/Cargo.toml index 6f83c661e4..d0c1272459 100644 --- a/node/bft/ledger-service/Cargo.toml +++ b/node/bft/ledger-service/Cargo.toml @@ -51,6 +51,9 @@ optional = true version = "0.8" optional = true +[dependencies.rayon] +version = "1" + [dependencies.snarkvm] workspace = true diff --git a/node/bft/ledger-service/src/ledger.rs b/node/bft/ledger-service/src/ledger.rs index f94092a64d..7ed8061eba 100644 --- a/node/bft/ledger-service/src/ledger.rs +++ b/node/bft/ledger-service/src/ledger.rs @@ -25,11 +25,11 @@ use snarkvm::{ prelude::{bail, Address, Field, Network, Result}, }; +#[cfg(feature = "metrics")] +use crate::update_block_metrics; use indexmap::IndexMap; use lru::LruCache; use parking_lot::{Mutex, RwLock}; -#[cfg(feature = "metrics")] -use std::collections::HashMap; use std::{ fmt, ops::Range, @@ -345,49 +345,10 @@ impl> LedgerService for CoreLedgerService< metrics::gauge(metrics::bft::LAST_COMMITTED_ROUND, block.round() as f64); metrics::increment_gauge(metrics::blocks::SOLUTIONS, num_sol as f64); metrics::increment_gauge(metrics::blocks::TRANSACTIONS, num_tx as f64); - self.update_block_metrics(block); + update_block_metrics(block); } tracing::info!("\n\nAdvanced to block {} at round {} - {}\n", block.height(), block.round(), block.hash()); Ok(()) } - - #[cfg(feature = "metrics")] - fn update_block_metrics(&self, block: &Block) { - use snarkvm::ledger::ConfirmedTransaction; - - // Count each type of transaction in the next block. - let metrics: HashMap<&'static str, usize> = block.transactions().iter().fold( - HashMap::from([ - ("AcceptedDeploy", 0), - ("AcceptedExecute", 0), - ("RejectedDeploy", 0), - ("RejectedExecute", 0), - ]), - |mut transaction_types, tx| { - match tx { - ConfirmedTransaction::AcceptedDeploy(_, _, _) => { - *transaction_types.get_mut("AcceptedDeploy").unwrap() += 1; - } - ConfirmedTransaction::AcceptedExecute(_, _, _) => { - *transaction_types.get_mut("AcceptedExecute").unwrap() += 1; - } - ConfirmedTransaction::RejectedDeploy(_, _, _, _) => { - *transaction_types.get_mut("RejectedDeploy").unwrap() += 1; - } - ConfirmedTransaction::RejectedExecute(_, _, _, _) => { - *transaction_types.get_mut("RejectedExecute").unwrap() += 1; - } - } - transaction_types - }, - ); - - metrics::increment_gauge(metrics::blocks::ACCEPTED_DEPLOY, *metrics.get("AcceptedDeploy").unwrap() as f64); - metrics::increment_gauge(metrics::blocks::ACCEPTED_EXECUTE, *metrics.get("AcceptedExecute").unwrap() as f64); - metrics::increment_gauge(metrics::blocks::REJECTED_DEPLOY, *metrics.get("RejectedDeploy").unwrap() as f64); - metrics::increment_gauge(metrics::blocks::REJECTED_EXECUTE, *metrics.get("RejectedExecute").unwrap() as f64); - metrics::increment_gauge(metrics::blocks::ABORTED_TRANSACTIONS, block.aborted_transaction_ids().len() as f64); - metrics::increment_gauge(metrics::blocks::ABORTED_SOLUTIONS, block.aborted_solution_ids().len() as f64); - } } diff --git a/node/bft/ledger-service/src/lib.rs b/node/bft/ledger-service/src/lib.rs index 9a19b681df..023c1373f5 100644 --- a/node/bft/ledger-service/src/lib.rs +++ b/node/bft/ledger-service/src/lib.rs @@ -37,6 +37,13 @@ pub mod translucent; #[cfg(feature = "translucent")] pub use translucent::*; +#[cfg(feature = "metrics")] +use rayon::iter::ParallelIterator; +#[cfg(feature = "metrics")] +use snarkvm::prelude::{Block, Network}; +#[cfg(feature = "metrics")] +use std::sync::atomic::{AtomicUsize, Ordering}; + pub mod traits; pub use traits::*; @@ -60,3 +67,38 @@ macro_rules! spawn_blocking { } }; } + +#[cfg(feature = "metrics")] +fn update_block_metrics(block: &Block) { + use snarkvm::ledger::ConfirmedTransaction; + + let accepted_deploy = AtomicUsize::new(0); + let accepted_execute = AtomicUsize::new(0); + let rejected_deploy = AtomicUsize::new(0); + let rejected_execute = AtomicUsize::new(0); + + // Add transaction to atomic counter based on enum type match. + block.transactions().par_iter().for_each(|tx| match tx { + ConfirmedTransaction::AcceptedDeploy(_, _, _) => { + accepted_deploy.fetch_add(1, Ordering::Relaxed); + } + ConfirmedTransaction::AcceptedExecute(_, _, _) => { + accepted_execute.fetch_add(1, Ordering::Relaxed); + } + ConfirmedTransaction::RejectedDeploy(_, _, _, _) => { + rejected_deploy.fetch_add(1, Ordering::Relaxed); + } + ConfirmedTransaction::RejectedExecute(_, _, _, _) => { + rejected_execute.fetch_add(1, Ordering::Relaxed); + } + }); + + metrics::increment_gauge(metrics::blocks::ACCEPTED_DEPLOY, accepted_deploy.load(Ordering::Relaxed) as f64); + metrics::increment_gauge(metrics::blocks::ACCEPTED_EXECUTE, accepted_execute.load(Ordering::Relaxed) as f64); + metrics::increment_gauge(metrics::blocks::REJECTED_DEPLOY, rejected_deploy.load(Ordering::Relaxed) as f64); + metrics::increment_gauge(metrics::blocks::REJECTED_EXECUTE, rejected_execute.load(Ordering::Relaxed) as f64); + + // Update aborted transactions and solutions. + metrics::increment_gauge(metrics::blocks::ABORTED_TRANSACTIONS, block.aborted_transaction_ids().len() as f64); + metrics::increment_gauge(metrics::blocks::ABORTED_SOLUTIONS, block.aborted_solution_ids().len() as f64); +} diff --git a/node/bft/ledger-service/src/traits.rs b/node/bft/ledger-service/src/traits.rs index ce99bf9f40..2bbad3387f 100644 --- a/node/bft/ledger-service/src/traits.rs +++ b/node/bft/ledger-service/src/traits.rs @@ -118,8 +118,4 @@ pub trait LedgerService: Debug + Send + Sync { /// Adds the given block as the next block in the ledger. #[cfg(feature = "ledger-write")] fn advance_to_next_block(&self, block: &Block) -> Result<()>; - - // Updates the block metrics. - #[cfg(feature = "metrics")] - fn update_block_metrics(&self, _block: &Block) {} } diff --git a/node/metrics/snarkOS-grafana.json b/node/metrics/snarkOS-grafana.json index 8993aa776d..b708e5d2ba 100644 --- a/node/metrics/snarkOS-grafana.json +++ b/node/metrics/snarkOS-grafana.json @@ -132,7 +132,7 @@ }, "disableTextWrap": false, "editorMode": "builder", - "expr": "snarkos_blocks_height_total", + "expr": "snarkos_bft_height_total", "fullMetaSearch": false, "includeNullMetadata": true, "instant": false, @@ -203,7 +203,7 @@ "uid": "${DS_PROMETHEUS}" }, "editorMode": "code", - "expr": "avg(\n 1 / rate(snarkos_blocks_height_total{}[1m])\n) < +inf", + "expr": "avg(\n 1 / rate(snarkos_bft_height_total{}[1m])\n) < +inf", "instant": false, "legendFormat": "__auto", "range": true, @@ -305,7 +305,7 @@ "uid": "${DS_PROMETHEUS}" }, "editorMode": "code", - "expr": "snarkos_blocks_height_total", + "expr": "snarkos_bft_height_total", "legendFormat": "__auto", "range": true, "refId": "A" @@ -1342,7 +1342,7 @@ "uid": "${DS_PROMETHEUS}" }, "editorMode": "code", - "expr": "snarkos_consensus_last_committed_round", + "expr": "snarkos_bft_last_committed_round", "legendFormat": "__auto", "range": true, "refId": "A" From ba9a7b661950a68cc02b56bb8568e94c9f80ebeb Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 15 Apr 2024 12:55:48 -0400 Subject: [PATCH 381/551] nit --- node/bft/src/primary.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 5306d4db08..c9d2ed61cd 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -2552,7 +2552,7 @@ mod tests { // Ensure the certificate exists in storage. assert!(primary.storage.contains_certificate(certificate_id)); - // Ensure that the aborted transmissions are exist in the storage. + // Ensure that the aborted transmission IDs exist in storage. for aborted_transmission_id in aborted_transmissions { assert!(primary.storage.contains_transmission(aborted_transmission_id)); assert!(primary.storage.get_transmission(aborted_transmission_id).is_none()); From 7e6d2298fe7e23401bd158cf379f8de7c3ecb529 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 15 Apr 2024 16:29:44 -0400 Subject: [PATCH 382/551] Add transactions and solutions from the pending queue to the rest endpoints --- node/consensus/src/lib.rs | 21 +++++++++++++++++++++ node/rest/src/routes.rs | 14 ++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 3b6471e13d..db809ecf5c 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -219,6 +219,27 @@ impl Consensus { } } +impl Consensus { + /// Returns the solutions in the pending queue. + pub fn pending_queue_solutions(&self) -> impl '_ + Iterator, Data>)> { + // Return an iterator over the solutions in the pending queue. + self.solutions_queue.lock().clone().into_iter().map(|(id, solution)| (id, Data::Object(solution))) + } + + /// Returns the transactions in the pending queue. + pub fn pending_queue_transactions(&self) -> impl '_ + Iterator>)> { + // Acquire the lock on the transactions queue. + let tx_queue = self.transactions_queue.lock(); + // Return an iterator over the deployment and execution transactions in the pending queue. + tx_queue + .deployments + .clone() + .into_iter() + .chain(tx_queue.executions.clone()) + .map(|(id, tx)| (id, Data::Object(tx))) + } +} + impl Consensus { /// Adds the given unconfirmed solution to the memory pool. pub async fn add_unconfirmed_solution(&self, solution: Solution) -> Result<()> { diff --git a/node/rest/src/routes.rs b/node/rest/src/routes.rs index c5b6c9e256..8a6e7e3568 100644 --- a/node/rest/src/routes.rs +++ b/node/rest/src/routes.rs @@ -187,7 +187,12 @@ impl, R: Routing> Rest { // GET //memoryPool/solutions pub(crate) async fn get_memory_pool_solutions(State(rest): State) -> Result { match rest.consensus { - Some(consensus) => Ok(ErasedJson::pretty(consensus.unconfirmed_solutions().collect::>())), + Some(consensus) => Ok(ErasedJson::pretty( + consensus + .unconfirmed_solutions() + .chain(consensus.pending_queue_solutions()) + .collect::>(), + )), None => Err(RestError("Route isn't available for this node type".to_string())), } } @@ -195,7 +200,12 @@ impl, R: Routing> Rest { // GET //memoryPool/transactions pub(crate) async fn get_memory_pool_transactions(State(rest): State) -> Result { match rest.consensus { - Some(consensus) => Ok(ErasedJson::pretty(consensus.unconfirmed_transactions().collect::>())), + Some(consensus) => Ok(ErasedJson::pretty( + consensus + .unconfirmed_transactions() + .chain(consensus.pending_queue_transactions()) + .collect::>(), + )), None => Err(RestError("Route isn't available for this node type".to_string())), } } From 8f403d468a619c31f3b0bfee7f1437bc19617672 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 15 Apr 2024 16:44:07 -0400 Subject: [PATCH 383/551] Add stateRoot endpoints --- node/rest/src/lib.rs | 2 ++ node/rest/src/routes.rs | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/node/rest/src/lib.rs b/node/rest/src/lib.rs index 8dfa2dd6ac..5f3dce4289 100644 --- a/node/rest/src/lib.rs +++ b/node/rest/src/lib.rs @@ -169,6 +169,7 @@ impl, R: Routing> Rest { .route(&format!("/{network}/find/transactionID/deployment/:program_id"), get(Self::find_transaction_id_from_program_id)) .route(&format!("/{network}/find/transactionID/:transition_id"), get(Self::find_transaction_id_from_transition_id)) .route(&format!("/{network}/find/transitionID/:input_or_output_id"), get(Self::find_transition_id)) + .route(&format!("/{network}/find/blockHeight/stateRoot/:state_root"), get(Self::find_block_height_from_state_root)) // GET ../peers/.. .route(&format!("/{network}/peers/count"), get(Self::get_peers_count)) @@ -187,6 +188,7 @@ impl, R: Routing> Rest { .route(&format!("/{network}/memoryPool/solutions"), get(Self::get_memory_pool_solutions)) .route(&format!("/{network}/memoryPool/transactions"), get(Self::get_memory_pool_transactions)) .route(&format!("/{network}/statePath/:commitment"), get(Self::get_state_path_for_commitment)) + .route(&format!("/{network}/stateRoot/:height"), get(Self::get_state_root)) .route(&format!("/{network}/stateRoot/latest"), get(Self::get_state_root_latest)) .route(&format!("/{network}/committee/latest"), get(Self::get_committee_latest)) diff --git a/node/rest/src/routes.rs b/node/rest/src/routes.rs index 8a6e7e3568..e4e988716f 100644 --- a/node/rest/src/routes.rs +++ b/node/rest/src/routes.rs @@ -97,7 +97,7 @@ impl, R: Routing> Rest { State(rest): State, Path(height_or_hash): Path, ) -> Result { - // Manually parse the height or the height or the hash, axum doesn't support different types + // Manually parse the height or the height of the hash, axum doesn't support different types // for the same path param. let block = if let Ok(height) = height_or_hash.parse::() { rest.ledger.get_block(height)? @@ -150,7 +150,7 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(rest.ledger.get_height(&hash)?)) } - // GET //block/{height}/transactions + // GET //block/{height}/transactions pub(crate) async fn get_block_transactions( State(rest): State, Path(height): Path, @@ -256,6 +256,14 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(rest.ledger.get_state_path_for_commitment(&commitment)?)) } + // GET //stateRoot/{height} + pub(crate) async fn get_state_root( + State(rest): State, + Path(height): Path, + ) -> Result { + Ok(ErasedJson::pretty(rest.ledger.get_state_root(height)?)) + } + // GET //stateRoot/latest pub(crate) async fn get_state_root_latest(State(rest): State) -> ErasedJson { ErasedJson::pretty(rest.ledger.latest_state_root()) @@ -318,6 +326,14 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(rest.ledger.find_transition_id(&input_or_output_id)?)) } + // GET //find/blockHeight/stateRoot/{stateRoot} + pub(crate) async fn find_block_height_from_state_root( + State(rest): State, + Path(state_root): Path, + ) -> Result { + Ok(ErasedJson::pretty(rest.ledger.find_block_height_from_state_root(state_root)?)) + } + // POST //transaction/broadcast pub(crate) async fn transaction_broadcast( State(rest): State, From 51127d9aba91729e5a6c9153ecd6f284a5b79aa9 Mon Sep 17 00:00:00 2001 From: miazn Date: Mon, 15 Apr 2024 20:24:03 -0400 Subject: [PATCH 384/551] change to cfg_iter macro --- node/bft/ledger-service/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node/bft/ledger-service/src/lib.rs b/node/bft/ledger-service/src/lib.rs index 023c1373f5..c3375d5a34 100644 --- a/node/bft/ledger-service/src/lib.rs +++ b/node/bft/ledger-service/src/lib.rs @@ -40,7 +40,7 @@ pub use translucent::*; #[cfg(feature = "metrics")] use rayon::iter::ParallelIterator; #[cfg(feature = "metrics")] -use snarkvm::prelude::{Block, Network}; +use snarkvm::prelude::{cfg_iter, Block, Network}; #[cfg(feature = "metrics")] use std::sync::atomic::{AtomicUsize, Ordering}; @@ -78,7 +78,7 @@ fn update_block_metrics(block: &Block) { let rejected_execute = AtomicUsize::new(0); // Add transaction to atomic counter based on enum type match. - block.transactions().par_iter().for_each(|tx| match tx { + cfg_iter!(block.transactions()).for_each(|tx| match tx { ConfirmedTransaction::AcceptedDeploy(_, _, _) => { accepted_deploy.fetch_add(1, Ordering::Relaxed); } From b69fef6f4afbc71516298ba272770b3b96691412 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 15 Apr 2024 21:41:49 -0400 Subject: [PATCH 385/551] Reintroduce IS_SYNCING const generic --- node/bft/src/bft.rs | 161 ++++++++++++++++++++------------------- node/bft/src/sync/mod.rs | 19 +++-- 2 files changed, 98 insertions(+), 82 deletions(-) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 011ffd8354..b2f05a7b0d 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -445,7 +445,10 @@ impl BFT { impl BFT { /// Stores the certificate in the DAG, and attempts to commit one or more anchors. - async fn update_dag(&self, certificate: BatchCertificate) -> Result<()> { + async fn update_dag( + &self, + certificate: BatchCertificate, + ) -> Result<()> { // Acquire the BFT lock. let _lock = self.lock.lock().await; @@ -519,11 +522,11 @@ impl BFT { info!("Proceeding to commit round {commit_round} with leader '{}'", fmt_id(leader)); // Commit the leader certificate, and all previous leader certificates since the last committed round. - self.commit_leader_certificate::(leader_certificate).await + self.commit_leader_certificate::(leader_certificate).await } /// Commits the leader certificate, and all previous leader certificates since the last committed round. - async fn commit_leader_certificate( + async fn commit_leader_certificate( &self, leader_certificate: BatchCertificate, ) -> Result<()> { @@ -588,72 +591,76 @@ impl BFT { Ok(subdag) => subdag, Err(e) => bail!("BFT failed to order the DAG with DFS - {e}"), }; - // Initialize a map for the deduped transmissions. - let mut transmissions = IndexMap::new(); - // Start from the oldest leader certificate. - for certificate in commit_subdag.values().flatten() { - // Retrieve the transmissions. - for transmission_id in certificate.transmission_ids() { - // If the transmission already exists in the map, skip it. - if transmissions.contains_key(transmission_id) { - continue; - } - // If the transmission already exists in the ledger, skip it. - // Note: On failure to read from the ledger, we skip including this transmission, out of safety. - if self.ledger().contains_transmission(transmission_id).unwrap_or(true) { - continue; + // If the node is not syncing, trigger consensus, as this will build a new block for the ledger. + if !IS_SYNCING { + // Initialize a map for the deduped transmissions. + let mut transmissions = IndexMap::new(); + // Start from the oldest leader certificate. + for certificate in commit_subdag.values().flatten() { + // Retrieve the transmissions. + for transmission_id in certificate.transmission_ids() { + // If the transmission already exists in the map, skip it. + if transmissions.contains_key(transmission_id) { + continue; + } + // If the transmission already exists in the ledger, skip it. + // Note: On failure to read from the ledger, we skip including this transmission, out of safety. + if self.ledger().contains_transmission(transmission_id).unwrap_or(true) { + continue; + } + // Retrieve the transmission. + let Some(transmission) = self.storage().get_transmission(*transmission_id) else { + bail!( + "BFT failed to retrieve transmission '{}' from round {}", + fmt_id(transmission_id), + certificate.round() + ); + }; + // Add the transmission to the set. + transmissions.insert(*transmission_id, transmission); } - // Retrieve the transmission. - let Some(transmission) = self.storage().get_transmission(*transmission_id) else { - bail!( - "BFT failed to retrieve transmission '{}' from round {}", - fmt_id(transmission_id), - certificate.round() - ); - }; - // Add the transmission to the set. - transmissions.insert(*transmission_id, transmission); } - } - // Trigger consensus, as this will build a new block for the ledger. - // Construct the subdag. - let subdag = Subdag::from(commit_subdag.clone())?; - // Retrieve the anchor round. - let anchor_round = subdag.anchor_round(); - // Retrieve the number of transmissions. - let num_transmissions = transmissions.len(); - // Retrieve metadata about the subdag. - let subdag_metadata = subdag.iter().map(|(round, c)| (*round, c.len())).collect::>(); - - // Ensure the subdag anchor round matches the leader round. - ensure!( - anchor_round == leader_round, - "BFT failed to commit - the subdag anchor round {anchor_round} does not match the leader round {leader_round}", - ); - - // Trigger consensus. - if let Some(consensus_sender) = self.consensus_sender.get() { - // Initialize a callback sender and receiver. - let (callback_sender, callback_receiver) = oneshot::channel(); - // Send the subdag and transmissions to consensus. - consensus_sender.tx_consensus_subdag.send((subdag, transmissions, callback_sender)).await?; - // Await the callback to continue. - match callback_receiver.await { - Ok(Ok(())) => (), // continue - Ok(Err(e)) => { - error!("BFT failed to advance the subdag for round {anchor_round} - {e}"); - return Ok(()); - } - Err(e) => { - error!("BFT failed to receive the callback for round {anchor_round} - {e}"); - return Ok(()); + // Trigger consensus, as this will build a new block for the ledger. + // Construct the subdag. + let subdag = Subdag::from(commit_subdag.clone())?; + // Retrieve the anchor round. + let anchor_round = subdag.anchor_round(); + // Retrieve the number of transmissions. + let num_transmissions = transmissions.len(); + // Retrieve metadata about the subdag. + let subdag_metadata = subdag.iter().map(|(round, c)| (*round, c.len())).collect::>(); + + // Ensure the subdag anchor round matches the leader round. + ensure!( + anchor_round == leader_round, + "BFT failed to commit - the subdag anchor round {anchor_round} does not match the leader round {leader_round}", + ); + + // Trigger consensus. + if let Some(consensus_sender) = self.consensus_sender.get() { + // Initialize a callback sender and receiver. + let (callback_sender, callback_receiver) = oneshot::channel(); + // Send the subdag and transmissions to consensus. + consensus_sender.tx_consensus_subdag.send((subdag, transmissions, callback_sender)).await?; + // Await the callback to continue. + match callback_receiver.await { + Ok(Ok(())) => (), // continue + Ok(Err(e)) => { + error!("BFT failed to advance the subdag for round {anchor_round} - {e}"); + return Ok(()); + } + Err(e) => { + error!("BFT failed to receive the callback for round {anchor_round} - {e}"); + return Ok(()); + } } } + + info!( + "\n\nCommitting a subdag from round {anchor_round} with {num_transmissions} transmissions: {subdag_metadata:?}\n" + ); } - info!( - "\n\nCommitting a subdag from round {anchor_round} with {num_transmissions} transmissions: {subdag_metadata:?}\n" - ); // Update the DAG, as the subdag was successfully included into a block. let mut dag_write = self.dag.write(); for certificate in commit_subdag.values().flatten() { @@ -784,7 +791,7 @@ impl BFT { self.spawn(async move { while let Some((certificate, callback)) = rx_primary_certificate.recv().await { // Update the DAG with the certificate. - let result = self_.update_dag::(certificate).await; + let result = self_.update_dag::(certificate).await; // Send the callback **after** updating the DAG. // Note: We must await the DAG update before proceeding. callback.send(result).ok(); @@ -804,7 +811,7 @@ impl BFT { self.spawn(async move { while let Some((certificate, callback)) = rx_sync_bft.recv().await { // Update the DAG with the certificate. - let result = self_.update_dag::(certificate).await; + let result = self_.update_dag::(certificate).await; // Send the callback **after** updating the DAG. // Note: We must await the DAG update before proceeding. callback.send(result).ok(); @@ -1175,7 +1182,7 @@ mod tests { // Insert the previous certificates into the BFT. for certificate in previous_certificates.clone() { - assert!(bft.update_dag::(certificate).await.is_ok()); + assert!(bft.update_dag::(certificate).await.is_ok()); } // Ensure this call succeeds and returns all given certificates. @@ -1205,7 +1212,7 @@ mod tests { // Insert the previous certificates into the BFT. for certificate in previous_certificates.clone() { - assert!(bft.update_dag::(certificate).await.is_ok()); + assert!(bft.update_dag::(certificate).await.is_ok()); } // Ensure this call succeeds and returns all given certificates. @@ -1326,11 +1333,11 @@ mod tests { // Insert the certificates into the BFT. for certificate in certificates { - assert!(bft.update_dag::(certificate).await.is_ok()); + assert!(bft.update_dag::(certificate).await.is_ok()); } // Commit the leader certificate. - bft.commit_leader_certificate::(leader_certificate).await.unwrap(); + bft.commit_leader_certificate::(leader_certificate).await.unwrap(); // Ensure that the `gc_round` has been updated. assert_eq!(bft.storage().gc_round(), commit_round - max_gc_rounds); @@ -1390,11 +1397,11 @@ mod tests { // Insert the previous certificates into the BFT. for certificate in certificates.clone() { - assert!(bft.update_dag::(certificate).await.is_ok()); + assert!(bft.update_dag::(certificate).await.is_ok()); } // Commit the leader certificate. - bft.commit_leader_certificate::(leader_certificate.clone()).await.unwrap(); + bft.commit_leader_certificate::(leader_certificate.clone()).await.unwrap(); // Simulate a bootup of the BFT. @@ -1562,17 +1569,17 @@ mod tests { // Insert the certificates into the BFT without bootup. for certificate in pre_shutdown_certificates.clone() { - assert!(bft.update_dag::(certificate).await.is_ok()); + assert!(bft.update_dag::(certificate).await.is_ok()); } // Insert the post shutdown certificates into the BFT without bootup. for certificate in post_shutdown_certificates.clone() { - assert!(bft.update_dag::(certificate).await.is_ok()); + assert!(bft.update_dag::(certificate).await.is_ok()); } // Commit the second leader certificate. let commit_subdag = bft.order_dag_with_dfs::(next_leader_certificate.clone()).unwrap(); let commit_subdag_metadata = commit_subdag.iter().map(|(round, c)| (*round, c.len())).collect::>(); - bft.commit_leader_certificate::(next_leader_certificate.clone()).await.unwrap(); + bft.commit_leader_certificate::(next_leader_certificate.clone()).await.unwrap(); // Simulate a bootup of the BFT. @@ -1590,14 +1597,14 @@ mod tests { bootup_bft.storage().testing_only_insert_certificate_testing_only(certificate.clone()); } for certificate in post_shutdown_certificates.clone() { - assert!(bootup_bft.update_dag::(certificate).await.is_ok()); + assert!(bootup_bft.update_dag::(certificate).await.is_ok()); } // Commit the second leader certificate. let commit_subdag_bootup = bootup_bft.order_dag_with_dfs::(next_leader_certificate.clone()).unwrap(); let commit_subdag_metadata_bootup = commit_subdag_bootup.iter().map(|(round, c)| (*round, c.len())).collect::>(); let committed_certificates_bootup = commit_subdag_bootup.values().flatten(); - bootup_bft.commit_leader_certificate::(next_leader_certificate.clone()).await.unwrap(); + bootup_bft.commit_leader_certificate::(next_leader_certificate.clone()).await.unwrap(); // Check that the final state of both BFTs is the same. @@ -1777,7 +1784,7 @@ mod tests { // Insert the post shutdown certificates into the DAG. for certificate in post_shutdown_certificates.clone() { - assert!(bootup_bft.update_dag::(certificate).await.is_ok()); + assert!(bootup_bft.update_dag::(certificate).await.is_ok()); } // Get the next leader certificate to commit. diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index cf01843ed2..ec16ecc613 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -360,12 +360,21 @@ impl Sync { } } - // Sync the height with the block. - self.storage.sync_height_with_block(block.height()); - // Sync the round with the block. - self.storage.sync_round_with_block(block.round()); + let self_ = self.clone(); + tokio::task::spawn_blocking(move || { + // Check the next block. + self_.ledger.check_next_block(&block)?; + // Attempt to advance to the next block. + self_.ledger.advance_to_next_block(&block)?; - Ok(()) + // Sync the height with the block. + self_.storage.sync_height_with_block(block.height()); + // Sync the round with the block. + self_.storage.sync_round_with_block(block.round()); + + Ok(()) + }) + .await? } } From fffaa67880a553dcaef4e800bace7fe709dff9f8 Mon Sep 17 00:00:00 2001 From: Victor Sint Nicolaas Date: Tue, 16 Apr 2024 15:59:52 +0200 Subject: [PATCH 386/551] Add get_delegators_for_validator --- node/rest/src/lib.rs | 1 + node/rest/src/routes.rs | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/node/rest/src/lib.rs b/node/rest/src/lib.rs index 8dfa2dd6ac..886a7f0ac5 100644 --- a/node/rest/src/lib.rs +++ b/node/rest/src/lib.rs @@ -189,6 +189,7 @@ impl, R: Routing> Rest { .route(&format!("/{network}/statePath/:commitment"), get(Self::get_state_path_for_commitment)) .route(&format!("/{network}/stateRoot/latest"), get(Self::get_state_root_latest)) .route(&format!("/{network}/committee/latest"), get(Self::get_committee_latest)) + .route(&format!("/{network}/delegators/:validator"), get(Self::get_delegators_for_validator)) // Pass in `Rest` to make things convenient. .with_state(self.clone()) diff --git a/node/rest/src/routes.rs b/node/rest/src/routes.rs index c5b6c9e256..068f68dcd5 100644 --- a/node/rest/src/routes.rs +++ b/node/rest/src/routes.rs @@ -16,7 +16,7 @@ use super::*; use snarkos_node_router::messages::UnconfirmedSolution; use snarkvm::{ ledger::puzzle::Solution, - prelude::{block::Transaction, Identifier, Plaintext}, + prelude::{block::Transaction, Address, Identifier, Plaintext}, }; use indexmap::IndexMap; @@ -256,6 +256,14 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(rest.ledger.latest_committee()?)) } + // GET //delegators/{validator} + pub(crate) async fn get_delegators_for_validator( + State(rest): State, + Path(validator): Path>, + ) -> Result { + Ok(ErasedJson::pretty(rest.ledger.get_delegators_for_validator(&validator)?)) + } + // GET //peers/count pub(crate) async fn get_peers_count(State(rest): State) -> ErasedJson { ErasedJson::pretty(rest.routing.router().number_of_connected_peers()) From e7d4720c268968add1710559f7fd4093d47eac0b Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 16 Apr 2024 10:28:14 -0400 Subject: [PATCH 387/551] Nit log --- node/bft/storage-service/src/memory.rs | 4 +++- node/bft/storage-service/src/persistent.rs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/node/bft/storage-service/src/memory.rs b/node/bft/storage-service/src/memory.rs index 2a05b72764..38cd430d68 100644 --- a/node/bft/storage-service/src/memory.rs +++ b/node/bft/storage-service/src/memory.rs @@ -120,7 +120,9 @@ impl StorageService for BFTMemoryService { Entry::Vacant(vacant_entry) => { // Retrieve the missing transmission. let Some(transmission) = missing_transmissions.remove(&transmission_id) else { - error!("Failed to provide a missing transmission {transmission_id}"); + if !aborted_transmission_ids.contains(&transmission_id) { + error!("Failed to provide a missing transmission {transmission_id}"); + } continue 'outer; }; // Prepare the set of certificate IDs. diff --git a/node/bft/storage-service/src/persistent.rs b/node/bft/storage-service/src/persistent.rs index 03c9569443..b18b3771d7 100644 --- a/node/bft/storage-service/src/persistent.rs +++ b/node/bft/storage-service/src/persistent.rs @@ -171,7 +171,9 @@ impl StorageService for BFTPersistentStorage { Ok(None) => { // Retrieve the missing transmission. let Some(transmission) = missing_transmissions.remove(&transmission_id) else { - error!("Failed to provide a missing transmission {transmission_id}"); + if !aborted_transmission_ids.contains(&transmission_id) { + error!("Failed to provide a missing transmission {transmission_id}"); + } continue 'outer; }; // Prepare the set of certificate IDs. From d9c3826a5535d7c5ea0ff79257c67eae1a538d18 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 16 Apr 2024 12:09:37 -0400 Subject: [PATCH 388/551] Update snarkVM rev - da3d78a --- Cargo.lock | 118 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 2 +- 2 files changed, 60 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ecb396be5d..c2ff74add0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3288,7 +3288,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "anstyle", "anyhow", @@ -3319,7 +3319,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "aleo-std", "anyhow", @@ -3349,7 +3349,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3363,7 +3363,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3374,7 +3374,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3384,7 +3384,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3394,7 +3394,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "indexmap 2.2.6", "itertools 0.11.0", @@ -3412,12 +3412,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3428,7 +3428,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3443,7 +3443,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3458,7 +3458,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3471,7 +3471,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3480,7 +3480,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3490,7 +3490,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3502,7 +3502,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3514,7 +3514,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3525,7 +3525,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3537,7 +3537,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3550,7 +3550,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "bs58", "snarkvm-console-network", @@ -3561,7 +3561,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "blake2s_simd", "smallvec", @@ -3574,7 +3574,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "aleo-std", "rayon", @@ -3585,7 +3585,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "anyhow", "indexmap 2.2.6", @@ -3608,7 +3608,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "anyhow", "bech32", @@ -3626,7 +3626,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "enum_index", "enum_index_derive", @@ -3647,7 +3647,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3662,7 +3662,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3673,7 +3673,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "snarkvm-console-network-environment", ] @@ -3681,7 +3681,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3691,7 +3691,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3702,7 +3702,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3713,7 +3713,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3724,7 +3724,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3735,7 +3735,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "rand", "rayon", @@ -3749,7 +3749,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "aleo-std", "anyhow", @@ -3766,7 +3766,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "aleo-std", "anyhow", @@ -3791,7 +3791,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "anyhow", "rand", @@ -3803,7 +3803,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3822,7 +3822,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "anyhow", "indexmap 2.2.6", @@ -3841,7 +3841,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -3854,7 +3854,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3867,7 +3867,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3880,7 +3880,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "bytes", "serde_json", @@ -3891,7 +3891,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3906,7 +3906,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "bytes", "serde_json", @@ -3919,7 +3919,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "snarkvm-console", "snarkvm-ledger-puzzle", @@ -3928,7 +3928,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "aleo-std", "anyhow", @@ -3948,7 +3948,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle-epoch" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "anyhow", "colored", @@ -3963,7 +3963,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "async-trait", "reqwest", @@ -3976,7 +3976,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "aleo-std-storage", "anyhow", @@ -4002,7 +4002,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4017,7 +4017,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4026,7 +4026,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "aleo-std", "anyhow", @@ -4051,7 +4051,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "aleo-std", "anyhow", @@ -4080,7 +4080,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "aleo-std", "colored", @@ -4103,7 +4103,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "indexmap 2.2.6", "paste", @@ -4117,7 +4117,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "bincode", "once_cell", @@ -4130,7 +4130,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "aleo-std", "anyhow", @@ -4151,7 +4151,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=69c25a8#69c25a89f1e53e66294339bfa0c038761b60dda3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" dependencies = [ "proc-macro2", "quote 1.0.36", diff --git a/Cargo.toml b/Cargo.toml index 5fc7d3a190..f582089b07 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "69c25a8" +rev = "da3d78a" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From e908b39552b2faf3db993015a4a6412fab79592c Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 16 Apr 2024 12:15:20 -0400 Subject: [PATCH 389/551] Update endpoint name --- node/rest/src/lib.rs | 2 +- node/rest/src/routes.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/node/rest/src/lib.rs b/node/rest/src/lib.rs index 5f3dce4289..914cccbbca 100644 --- a/node/rest/src/lib.rs +++ b/node/rest/src/lib.rs @@ -169,7 +169,7 @@ impl, R: Routing> Rest { .route(&format!("/{network}/find/transactionID/deployment/:program_id"), get(Self::find_transaction_id_from_program_id)) .route(&format!("/{network}/find/transactionID/:transition_id"), get(Self::find_transaction_id_from_transition_id)) .route(&format!("/{network}/find/transitionID/:input_or_output_id"), get(Self::find_transition_id)) - .route(&format!("/{network}/find/blockHeight/stateRoot/:state_root"), get(Self::find_block_height_from_state_root)) + .route(&format!("/{network}/find/blockHeight/:state_root"), get(Self::find_block_height_from_state_root)) // GET ../peers/.. .route(&format!("/{network}/peers/count"), get(Self::get_peers_count)) diff --git a/node/rest/src/routes.rs b/node/rest/src/routes.rs index e4e988716f..c948000513 100644 --- a/node/rest/src/routes.rs +++ b/node/rest/src/routes.rs @@ -326,7 +326,7 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(rest.ledger.find_transition_id(&input_or_output_id)?)) } - // GET //find/blockHeight/stateRoot/{stateRoot} + // GET //find/blockHeight/{stateRoot} pub(crate) async fn find_block_height_from_state_root( State(rest): State, Path(state_root): Path, From c0af3fb68e024e1891d6765b599793d4f7130ec6 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 16 Apr 2024 15:10:03 -0400 Subject: [PATCH 390/551] Rename getter functions --- node/bft/src/bft.rs | 24 ++++++++--------- node/bft/src/primary.rs | 16 +++++------ node/consensus/src/lib.rs | 57 ++++++++++++++++++++++++++++++++------- node/rest/src/routes.rs | 14 ++-------- 4 files changed, 69 insertions(+), 42 deletions(-) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 011ffd8354..68bdf5c798 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -172,24 +172,24 @@ impl BFT { } impl BFT { - /// Returns the unconfirmed transmission IDs. - pub fn unconfirmed_transmission_ids(&self) -> impl '_ + Iterator> { - self.primary.unconfirmed_transmission_ids() + /// Returns the worker transmission IDs. + pub fn worker_transmission_ids(&self) -> impl '_ + Iterator> { + self.primary.worker_transmission_ids() } - /// Returns the unconfirmed transmissions. - pub fn unconfirmed_transmissions(&self) -> impl '_ + Iterator, Transmission)> { - self.primary.unconfirmed_transmissions() + /// Returns the worker transmissions. + pub fn worker_transmissions(&self) -> impl '_ + Iterator, Transmission)> { + self.primary.worker_transmissions() } - /// Returns the unconfirmed solutions. - pub fn unconfirmed_solutions(&self) -> impl '_ + Iterator, Data>)> { - self.primary.unconfirmed_solutions() + /// Returns the worker solutions. + pub fn worker_solutions(&self) -> impl '_ + Iterator, Data>)> { + self.primary.worker_solutions() } - /// Returns the unconfirmed transactions. - pub fn unconfirmed_transactions(&self) -> impl '_ + Iterator>)> { - self.primary.unconfirmed_transactions() + /// Returns the worker transactions. + pub fn worker_transactions(&self) -> impl '_ + Iterator>)> { + self.primary.worker_transactions() } } diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 5224bf8084..613ee895fa 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -253,23 +253,23 @@ impl Primary { } impl Primary { - /// Returns the unconfirmed transmission IDs. - pub fn unconfirmed_transmission_ids(&self) -> impl '_ + Iterator> { + /// Returns the worker transmission IDs. + pub fn worker_transmission_ids(&self) -> impl '_ + Iterator> { self.workers.iter().flat_map(|worker| worker.transmission_ids()) } - /// Returns the unconfirmed transmissions. - pub fn unconfirmed_transmissions(&self) -> impl '_ + Iterator, Transmission)> { + /// Returns the worker transmissions. + pub fn worker_transmissions(&self) -> impl '_ + Iterator, Transmission)> { self.workers.iter().flat_map(|worker| worker.transmissions()) } - /// Returns the unconfirmed solutions. - pub fn unconfirmed_solutions(&self) -> impl '_ + Iterator, Data>)> { + /// Returns the worker solutions. + pub fn worker_solutions(&self) -> impl '_ + Iterator, Data>)> { self.workers.iter().flat_map(|worker| worker.solutions()) } - /// Returns the unconfirmed transactions. - pub fn unconfirmed_transactions(&self) -> impl '_ + Iterator>)> { + /// Returns the worker transactions. + pub fn worker_transactions(&self) -> impl '_ + Iterator>)> { self.workers.iter().flat_map(|worker| worker.transactions()) } } diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index db809ecf5c..910de82e1e 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -200,37 +200,64 @@ impl Consensus { impl Consensus { /// Returns the unconfirmed transmission IDs. pub fn unconfirmed_transmission_ids(&self) -> impl '_ + Iterator> { - self.bft.unconfirmed_transmission_ids() + self.bft.worker_transmission_ids().chain(self.inbound_transmission_ids()) } /// Returns the unconfirmed transmissions. pub fn unconfirmed_transmissions(&self) -> impl '_ + Iterator, Transmission)> { - self.bft.unconfirmed_transmissions() + self.bft.worker_transmissions().chain(self.inbound_transmissions()) } /// Returns the unconfirmed solutions. pub fn unconfirmed_solutions(&self) -> impl '_ + Iterator, Data>)> { - self.bft.unconfirmed_solutions() + self.bft.worker_solutions().chain(self.inbound_solutions()) } /// Returns the unconfirmed transactions. pub fn unconfirmed_transactions(&self) -> impl '_ + Iterator>)> { - self.bft.unconfirmed_transactions() + self.bft.worker_transactions().chain(self.inbound_transactions()) } } impl Consensus { - /// Returns the solutions in the pending queue. - pub fn pending_queue_solutions(&self) -> impl '_ + Iterator, Data>)> { - // Return an iterator over the solutions in the pending queue. + /// Returns the worker transmission IDs. + pub fn worker_transmission_ids(&self) -> impl '_ + Iterator> { + self.bft.worker_transmission_ids() + } + + /// Returns the worker transmissions. + pub fn worker_transmissions(&self) -> impl '_ + Iterator, Transmission)> { + self.bft.worker_transmissions() + } + + /// Returns the worker solutions. + pub fn worker_solutions(&self) -> impl '_ + Iterator, Data>)> { + self.bft.worker_solutions() + } + + /// Returns the worker transactions. + pub fn worker_transactions(&self) -> impl '_ + Iterator>)> { + self.bft.worker_transactions() + } +} + +impl Consensus { + /// Returns the transmission IDs in the inbound queue. + pub fn inbound_transmission_ids(&self) -> impl '_ + Iterator> { + self.inbound_transmissions().map(|(id, _)| id) + } + + /// Returns the solutions in the inbound queue. + pub fn inbound_solutions(&self) -> impl '_ + Iterator, Data>)> { + // Return an iterator over the solutions in the inbound queue. self.solutions_queue.lock().clone().into_iter().map(|(id, solution)| (id, Data::Object(solution))) } - /// Returns the transactions in the pending queue. - pub fn pending_queue_transactions(&self) -> impl '_ + Iterator>)> { + /// Returns the transactions in the inbound queue. + pub fn inbound_transactions(&self) -> impl '_ + Iterator>)> { // Acquire the lock on the transactions queue. let tx_queue = self.transactions_queue.lock(); - // Return an iterator over the deployment and execution transactions in the pending queue. + // Return an iterator over the deployment and execution transactions in the inbound queue. tx_queue .deployments .clone() @@ -238,6 +265,16 @@ impl Consensus { .chain(tx_queue.executions.clone()) .map(|(id, tx)| (id, Data::Object(tx))) } + + /// Returns the transmissions in the inbound queue. + pub fn inbound_transmissions(&self) -> impl '_ + Iterator, Transmission)> { + self.inbound_transactions() + .map(|(id, tx)| (TransmissionID::Transaction(id), Transmission::Transaction(tx))) + .chain( + self.inbound_solutions() + .map(|(id, solution)| (TransmissionID::Solution(id), Transmission::Solution(solution))), + ) + } } impl Consensus { diff --git a/node/rest/src/routes.rs b/node/rest/src/routes.rs index c948000513..b0f236b47b 100644 --- a/node/rest/src/routes.rs +++ b/node/rest/src/routes.rs @@ -187,12 +187,7 @@ impl, R: Routing> Rest { // GET //memoryPool/solutions pub(crate) async fn get_memory_pool_solutions(State(rest): State) -> Result { match rest.consensus { - Some(consensus) => Ok(ErasedJson::pretty( - consensus - .unconfirmed_solutions() - .chain(consensus.pending_queue_solutions()) - .collect::>(), - )), + Some(consensus) => Ok(ErasedJson::pretty(consensus.unconfirmed_solutions().collect::>())), None => Err(RestError("Route isn't available for this node type".to_string())), } } @@ -200,12 +195,7 @@ impl, R: Routing> Rest { // GET //memoryPool/transactions pub(crate) async fn get_memory_pool_transactions(State(rest): State) -> Result { match rest.consensus { - Some(consensus) => Ok(ErasedJson::pretty( - consensus - .unconfirmed_transactions() - .chain(consensus.pending_queue_transactions()) - .collect::>(), - )), + Some(consensus) => Ok(ErasedJson::pretty(consensus.unconfirmed_transactions().collect::>())), None => Err(RestError("Route isn't available for this node type".to_string())), } } From d87fdecaecca7ff5361d147769cb672224c39e43 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 16 Apr 2024 15:11:35 -0400 Subject: [PATCH 391/551] nit --- node/consensus/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 910de82e1e..4462814c3e 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -200,22 +200,22 @@ impl Consensus { impl Consensus { /// Returns the unconfirmed transmission IDs. pub fn unconfirmed_transmission_ids(&self) -> impl '_ + Iterator> { - self.bft.worker_transmission_ids().chain(self.inbound_transmission_ids()) + self.worker_transmission_ids().chain(self.inbound_transmission_ids()) } /// Returns the unconfirmed transmissions. pub fn unconfirmed_transmissions(&self) -> impl '_ + Iterator, Transmission)> { - self.bft.worker_transmissions().chain(self.inbound_transmissions()) + self.worker_transmissions().chain(self.inbound_transmissions()) } /// Returns the unconfirmed solutions. pub fn unconfirmed_solutions(&self) -> impl '_ + Iterator, Data>)> { - self.bft.worker_solutions().chain(self.inbound_solutions()) + self.worker_solutions().chain(self.inbound_solutions()) } /// Returns the unconfirmed transactions. pub fn unconfirmed_transactions(&self) -> impl '_ + Iterator>)> { - self.bft.worker_transactions().chain(self.inbound_transactions()) + self.worker_transactions().chain(self.inbound_transactions()) } } From 1ac9997abad84ae1ea342000b9aa47404da2455c Mon Sep 17 00:00:00 2001 From: miazn Date: Tue, 16 Apr 2024 15:59:49 -0400 Subject: [PATCH 392/551] add optional to cargo.toml --- node/bft/ledger-service/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/node/bft/ledger-service/Cargo.toml b/node/bft/ledger-service/Cargo.toml index d0c1272459..40200675e1 100644 --- a/node/bft/ledger-service/Cargo.toml +++ b/node/bft/ledger-service/Cargo.toml @@ -53,6 +53,7 @@ optional = true [dependencies.rayon] version = "1" +optional = true [dependencies.snarkvm] workspace = true From 1064bbb5176294b1d5fc3b064549f2b1afeab95a Mon Sep 17 00:00:00 2001 From: miazn Date: Wed, 17 Apr 2024 15:28:38 -0400 Subject: [PATCH 393/551] make rayon install optional --- node/bft/ledger-service/Cargo.toml | 3 ++- node/bft/ledger-service/src/lib.rs | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/node/bft/ledger-service/Cargo.toml b/node/bft/ledger-service/Cargo.toml index 40200675e1..41225467e8 100644 --- a/node/bft/ledger-service/Cargo.toml +++ b/node/bft/ledger-service/Cargo.toml @@ -20,9 +20,10 @@ edition = "2021" default = [ ] ledger = [ "lru", "parking_lot", "rand", "tokio", "tracing" ] ledger-write = [ ] -metrics = ["dep:metrics", "snarkvm/metrics"] +metrics = ["dep:metrics", "snarkvm/metrics", "rayon"] mock = [ "parking_lot", "tracing" ] prover = [ ] +serial = [ ] test = [ "mock", "translucent" ] translucent = [ "ledger" ] diff --git a/node/bft/ledger-service/src/lib.rs b/node/bft/ledger-service/src/lib.rs index c3375d5a34..ce31a69784 100644 --- a/node/bft/ledger-service/src/lib.rs +++ b/node/bft/ledger-service/src/lib.rs @@ -37,7 +37,7 @@ pub mod translucent; #[cfg(feature = "translucent")] pub use translucent::*; -#[cfg(feature = "metrics")] +#[cfg(all(not(feature = "serial"), feature = "metrics"))] use rayon::iter::ParallelIterator; #[cfg(feature = "metrics")] use snarkvm::prelude::{cfg_iter, Block, Network}; @@ -69,7 +69,7 @@ macro_rules! spawn_blocking { } #[cfg(feature = "metrics")] -fn update_block_metrics(block: &Block) { +pub fn update_block_metrics(block: &Block) { use snarkvm::ledger::ConfirmedTransaction; let accepted_deploy = AtomicUsize::new(0); From 06dec108cf69fc178c421d4b0be4d1062bf55ea0 Mon Sep 17 00:00:00 2001 From: miazn Date: Thu, 18 Apr 2024 15:41:12 -0400 Subject: [PATCH 394/551] restructure metrics functions to metrics crate for optional dependencies --- Cargo.lock | 4 +- node/bft/ledger-service/Cargo.toml | 2 +- node/bft/ledger-service/src/ledger.rs | 4 +- node/bft/ledger-service/src/lib.rs | 42 ----------- node/consensus/Cargo.toml | 3 - node/consensus/src/lib.rs | 58 +------------- node/metrics/Cargo.toml | 12 +++ node/metrics/src/lib.rs | 105 ++++++++++++++++++++++++++ 8 files changed, 123 insertions(+), 107 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e9ab7c60bb..3747ccc37d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3131,7 +3131,6 @@ dependencies = [ "once_cell", "parking_lot", "rand", - "rayon", "snarkos-account", "snarkos-node-bft", "snarkos-node-bft-ledger-service", @@ -3148,7 +3147,10 @@ name = "snarkos-node-metrics" version = "2.2.7" dependencies = [ "metrics-exporter-prometheus", + "parking_lot", + "rayon", "snarkvm", + "time", "tokio", ] diff --git a/node/bft/ledger-service/Cargo.toml b/node/bft/ledger-service/Cargo.toml index 41225467e8..f032388195 100644 --- a/node/bft/ledger-service/Cargo.toml +++ b/node/bft/ledger-service/Cargo.toml @@ -20,7 +20,7 @@ edition = "2021" default = [ ] ledger = [ "lru", "parking_lot", "rand", "tokio", "tracing" ] ledger-write = [ ] -metrics = ["dep:metrics", "snarkvm/metrics", "rayon"] +metrics = ["dep:metrics", "snarkvm/metrics"] mock = [ "parking_lot", "tracing" ] prover = [ ] serial = [ ] diff --git a/node/bft/ledger-service/src/ledger.rs b/node/bft/ledger-service/src/ledger.rs index 7ed8061eba..abf29f5e35 100644 --- a/node/bft/ledger-service/src/ledger.rs +++ b/node/bft/ledger-service/src/ledger.rs @@ -25,8 +25,6 @@ use snarkvm::{ prelude::{bail, Address, Field, Network, Result}, }; -#[cfg(feature = "metrics")] -use crate::update_block_metrics; use indexmap::IndexMap; use lru::LruCache; use parking_lot::{Mutex, RwLock}; @@ -345,7 +343,7 @@ impl> LedgerService for CoreLedgerService< metrics::gauge(metrics::bft::LAST_COMMITTED_ROUND, block.round() as f64); metrics::increment_gauge(metrics::blocks::SOLUTIONS, num_sol as f64); metrics::increment_gauge(metrics::blocks::TRANSACTIONS, num_tx as f64); - update_block_metrics(block); + metrics::update_block_metrics(block); } tracing::info!("\n\nAdvanced to block {} at round {} - {}\n", block.height(), block.round(), block.hash()); diff --git a/node/bft/ledger-service/src/lib.rs b/node/bft/ledger-service/src/lib.rs index ce31a69784..9a19b681df 100644 --- a/node/bft/ledger-service/src/lib.rs +++ b/node/bft/ledger-service/src/lib.rs @@ -37,13 +37,6 @@ pub mod translucent; #[cfg(feature = "translucent")] pub use translucent::*; -#[cfg(all(not(feature = "serial"), feature = "metrics"))] -use rayon::iter::ParallelIterator; -#[cfg(feature = "metrics")] -use snarkvm::prelude::{cfg_iter, Block, Network}; -#[cfg(feature = "metrics")] -use std::sync::atomic::{AtomicUsize, Ordering}; - pub mod traits; pub use traits::*; @@ -67,38 +60,3 @@ macro_rules! spawn_blocking { } }; } - -#[cfg(feature = "metrics")] -pub fn update_block_metrics(block: &Block) { - use snarkvm::ledger::ConfirmedTransaction; - - let accepted_deploy = AtomicUsize::new(0); - let accepted_execute = AtomicUsize::new(0); - let rejected_deploy = AtomicUsize::new(0); - let rejected_execute = AtomicUsize::new(0); - - // Add transaction to atomic counter based on enum type match. - cfg_iter!(block.transactions()).for_each(|tx| match tx { - ConfirmedTransaction::AcceptedDeploy(_, _, _) => { - accepted_deploy.fetch_add(1, Ordering::Relaxed); - } - ConfirmedTransaction::AcceptedExecute(_, _, _) => { - accepted_execute.fetch_add(1, Ordering::Relaxed); - } - ConfirmedTransaction::RejectedDeploy(_, _, _, _) => { - rejected_deploy.fetch_add(1, Ordering::Relaxed); - } - ConfirmedTransaction::RejectedExecute(_, _, _, _) => { - rejected_execute.fetch_add(1, Ordering::Relaxed); - } - }); - - metrics::increment_gauge(metrics::blocks::ACCEPTED_DEPLOY, accepted_deploy.load(Ordering::Relaxed) as f64); - metrics::increment_gauge(metrics::blocks::ACCEPTED_EXECUTE, accepted_execute.load(Ordering::Relaxed) as f64); - metrics::increment_gauge(metrics::blocks::REJECTED_DEPLOY, rejected_deploy.load(Ordering::Relaxed) as f64); - metrics::increment_gauge(metrics::blocks::REJECTED_EXECUTE, rejected_execute.load(Ordering::Relaxed) as f64); - - // Update aborted transactions and solutions. - metrics::increment_gauge(metrics::blocks::ABORTED_TRANSACTIONS, block.aborted_transaction_ids().len() as f64); - metrics::increment_gauge(metrics::blocks::ABORTED_SOLUTIONS, block.aborted_solution_ids().len() as f64); -} diff --git a/node/consensus/Cargo.toml b/node/consensus/Cargo.toml index ac9ccc1afb..81fdcd867b 100644 --- a/node/consensus/Cargo.toml +++ b/node/consensus/Cargo.toml @@ -48,9 +48,6 @@ version = "0.12" [dependencies.rand] version = "0.8" -[dependencies.rayon] -version = "1" - [dependencies.snarkos-account] path = "../../account" version = "=2.2.7" diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 3b6471e13d..c3ff877f75 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -54,8 +54,6 @@ use tokio::{ task::JoinHandle, }; -#[cfg(feature = "metrics")] -use rayon::prelude::*; #[cfg(feature = "metrics")] use std::collections::HashMap; @@ -437,7 +435,7 @@ impl Consensus { let coinbase_target = next_block.header().coinbase_target(); let cumulative_proof_target = next_block.header().cumulative_proof_target(); - self.add_transmission_latency_metric(&next_block); + metrics::add_transmission_latency_metric(&self.transmissions_queue_timestamps, &next_block); metrics::gauge(metrics::consensus::COMMITTED_CERTIFICATES, num_committed_certificates as f64); metrics::histogram(metrics::consensus::CERTIFICATE_COMMIT_LATENCY, elapsed.as_secs_f64()); @@ -485,60 +483,6 @@ impl Consensus { callback_receiver.await? } - #[cfg(feature = "metrics")] - fn add_transmission_latency_metric(&self, next_block: &Block) { - const AGE_THRESHOLD_SECONDS: i32 = 30 * 60; // 30 minutes set as stale transmission threshold - - // Retrieve the solution IDs. - let solution_ids: std::collections::HashSet<_> = - next_block.solutions().solution_ids().chain(next_block.aborted_solution_ids()).collect(); - - // Retrieve the transaction IDs. - let transaction_ids: std::collections::HashSet<_> = - next_block.transaction_ids().chain(next_block.aborted_transaction_ids()).collect(); - - let mut transmission_queue_timestamps = self.transmissions_queue_timestamps.lock(); - let ts_now = snarkos_node_bft::helpers::now(); - - // Determine which keys to remove. - let keys_to_remove = cfg_iter!(transmission_queue_timestamps) - .flat_map(|(key, timestamp)| { - let elapsed_time = std::time::Duration::from_secs((ts_now - *timestamp) as u64); - - if elapsed_time.as_secs() > AGE_THRESHOLD_SECONDS as u64 { - // This entry is stale-- remove it from transmission queue and record it as a stale transmission. - metrics::increment_counter(metrics::consensus::STALE_UNCONFIRMED_TRANSMISSIONS); - Some(*key) - } else { - let transmission_type = match key { - TransmissionID::Solution(solution_id) if solution_ids.contains(solution_id) => Some("solution"), - TransmissionID::Transaction(transaction_id) if transaction_ids.contains(transaction_id) => { - Some("transaction") - } - _ => None, - }; - - if let Some(transmission_type_string) = transmission_type { - metrics::histogram_label( - metrics::consensus::TRANSMISSION_LATENCY, - "transmission_type", - transmission_type_string.to_owned(), - elapsed_time.as_secs_f64(), - ); - Some(*key) - } else { - None - } - } - }) - .collect::>(); - - // Remove keys of stale or seen transmissions. - for key in keys_to_remove { - transmission_queue_timestamps.remove(&key); - } - } - /// Spawns a task with the given future; it should only be used for long-running tasks. fn spawn + Send + 'static>(&self, future: T) { self.handles.lock().push(tokio::spawn(future)); diff --git a/node/metrics/Cargo.toml b/node/metrics/Cargo.toml index 22128ba622..863355c071 100644 --- a/node/metrics/Cargo.toml +++ b/node/metrics/Cargo.toml @@ -17,11 +17,20 @@ license = "Apache-2.0" edition = "2021" [features] +default = [ "rayon", "snarkvm/metrics"] metrics = [ "snarkvm/metrics" ] +serial = ["snarkvm/metrics"] [dependencies.metrics-exporter-prometheus] version = "0.13" +[dependencies.parking_lot] +version = "0.12" + +[dependencies.rayon] +version = "1" +optional = true + [dependencies.snarkvm] workspace = true features = [ "metrics" ] @@ -29,3 +38,6 @@ features = [ "metrics" ] [dependencies.tokio] version = "1.28" features = [ "rt" ] + +[dependencies.time] +version = "0.3" \ No newline at end of file diff --git a/node/metrics/src/lib.rs b/node/metrics/src/lib.rs index 0543a64eea..c2315eac53 100644 --- a/node/metrics/src/lib.rs +++ b/node/metrics/src/lib.rs @@ -16,8 +16,23 @@ mod names; // Expose the names at the crate level for easy access. pub use names::*; +use parking_lot::Mutex; // Re-export the snarkVM metrics. +#[cfg(not(feature = "serial"))] +use rayon::prelude::*; pub use snarkvm::metrics::*; +use snarkvm::{ + ledger::narwhal::TransmissionID, + prelude::{cfg_iter, Block, Network}, +}; +use std::{ + collections::HashMap, + sync::{ + atomic::{AtomicUsize, Ordering}, + Arc, + }, +}; +use time::OffsetDateTime; /// Initializes the metrics and returns a handle to the task running the metrics exporter. pub fn initialize_metrics() { @@ -38,3 +53,93 @@ pub fn initialize_metrics() { register_histogram(name); } } + +pub fn update_block_metrics(block: &Block) { + use snarkvm::ledger::ConfirmedTransaction; + + let accepted_deploy = AtomicUsize::new(0); + let accepted_execute = AtomicUsize::new(0); + let rejected_deploy = AtomicUsize::new(0); + let rejected_execute = AtomicUsize::new(0); + + // Add transaction to atomic counter based on enum type match. + cfg_iter!(block.transactions()).for_each(|tx| match tx { + ConfirmedTransaction::AcceptedDeploy(_, _, _) => { + accepted_deploy.fetch_add(1, Ordering::Relaxed); + } + ConfirmedTransaction::AcceptedExecute(_, _, _) => { + accepted_execute.fetch_add(1, Ordering::Relaxed); + } + ConfirmedTransaction::RejectedDeploy(_, _, _, _) => { + rejected_deploy.fetch_add(1, Ordering::Relaxed); + } + ConfirmedTransaction::RejectedExecute(_, _, _, _) => { + rejected_execute.fetch_add(1, Ordering::Relaxed); + } + }); + + increment_gauge(blocks::ACCEPTED_DEPLOY, accepted_deploy.load(Ordering::Relaxed) as f64); + increment_gauge(blocks::ACCEPTED_EXECUTE, accepted_execute.load(Ordering::Relaxed) as f64); + increment_gauge(blocks::REJECTED_DEPLOY, rejected_deploy.load(Ordering::Relaxed) as f64); + increment_gauge(blocks::REJECTED_EXECUTE, rejected_execute.load(Ordering::Relaxed) as f64); + + // Update aborted transactions and solutions. + increment_gauge(blocks::ABORTED_TRANSACTIONS, block.aborted_transaction_ids().len() as f64); + increment_gauge(blocks::ABORTED_SOLUTIONS, block.aborted_solution_ids().len() as f64); +} + +pub fn add_transmission_latency_metric( + transmissions_queue_timestamps: &Arc, i64>>>, + block: &Block, +) { + const AGE_THRESHOLD_SECONDS: i32 = 30 * 60; // 30 minutes set as stale transmission threshold + + // Retrieve the solution IDs. + let solution_ids: std::collections::HashSet<_> = + block.solutions().solution_ids().chain(block.aborted_solution_ids()).collect(); + + // Retrieve the transaction IDs. + let transaction_ids: std::collections::HashSet<_> = + block.transaction_ids().chain(block.aborted_transaction_ids()).collect(); + + let mut transmission_queue_timestamps = transmissions_queue_timestamps.lock(); + let ts_now = OffsetDateTime::now_utc().unix_timestamp(); + + // Determine which keys to remove. + let keys_to_remove = cfg_iter!(transmission_queue_timestamps) + .flat_map(|(key, timestamp)| { + let elapsed_time = std::time::Duration::from_secs((ts_now - *timestamp) as u64); + + if elapsed_time.as_secs() > AGE_THRESHOLD_SECONDS as u64 { + // This entry is stale-- remove it from transmission queue and record it as a stale transmission. + increment_counter(consensus::STALE_UNCONFIRMED_TRANSMISSIONS); + Some(*key) + } else { + let transmission_type = match key { + TransmissionID::Solution(solution_id) if solution_ids.contains(solution_id) => Some("solution"), + TransmissionID::Transaction(transaction_id) if transaction_ids.contains(transaction_id) => { + Some("transaction") + } + _ => None, + }; + + if let Some(transmission_type_string) = transmission_type { + histogram_label( + consensus::TRANSMISSION_LATENCY, + "transmission_type", + transmission_type_string.to_owned(), + elapsed_time.as_secs_f64(), + ); + Some(*key) + } else { + None + } + } + }) + .collect::>(); + + // Remove keys of stale or seen transmissions. + for key in keys_to_remove { + transmission_queue_timestamps.remove(&key); + } +} From 7bbc7086be6b131fd99386fd57132805bf5b9918 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 18 Apr 2024 18:25:09 -0400 Subject: [PATCH 395/551] Add seen_inbound_block_requests to cache --- node/router/src/helpers/cache.rs | 64 +++++++++++++++++++++++++++++++- node/router/src/inbound.rs | 9 ++++- 2 files changed, 71 insertions(+), 2 deletions(-) diff --git a/node/router/src/helpers/cache.rs b/node/router/src/helpers/cache.rs index 29f46aa63d..db803a16c0 100644 --- a/node/router/src/helpers/cache.rs +++ b/node/router/src/helpers/cache.rs @@ -40,6 +40,8 @@ pub struct Cache { seen_inbound_messages: RwLock>>, /// The map of peer IPs to their recent timestamps. seen_inbound_puzzle_requests: RwLock>>, + /// The map of peer IPs to their recent timestamps. + seen_inbound_block_requests: RwLock>>, /// The map of solution IDs to their last seen timestamp. seen_inbound_solutions: RwLock, OffsetDateTime>>, /// The map of transaction IDs to their last seen timestamp. @@ -64,12 +66,16 @@ impl Default for Cache { } impl Cache { + const INBOUND_BLOCK_REQUEST_INTERVAL: i64 = 60; + const INBOUND_PUZZLE_REQUEST_INTERVAL: i64 = 60; + /// Initializes a new instance of the cache. pub fn new() -> Self { Self { seen_inbound_connections: Default::default(), seen_inbound_messages: Default::default(), seen_inbound_puzzle_requests: Default::default(), + seen_inbound_block_requests: Default::default(), seen_inbound_solutions: RwLock::new(LinkedHashMap::with_capacity(MAX_CACHE_SIZE)), seen_inbound_transactions: RwLock::new(LinkedHashMap::with_capacity(MAX_CACHE_SIZE)), seen_outbound_block_requests: Default::default(), @@ -94,7 +100,12 @@ impl Cache { /// Inserts a new timestamp for the given peer IP, returning the number of recent requests. pub fn insert_inbound_puzzle_request(&self, peer_ip: SocketAddr) -> usize { - Self::retain_and_insert(&self.seen_inbound_puzzle_requests, peer_ip, 60) + Self::retain_and_insert(&self.seen_inbound_puzzle_requests, peer_ip, Self::INBOUND_PUZZLE_REQUEST_INTERVAL) + } + + /// Inserts a new timestamp for the given peer IP, returning the number of recent block requests. + pub fn insert_inbound_block_request(&self, peer_ip: SocketAddr) -> usize { + Self::retain_and_insert(&self.seen_inbound_block_requests, peer_ip, Self::INBOUND_BLOCK_REQUEST_INTERVAL) } /// Inserts a solution ID into the cache, returning the previously seen timestamp if it existed. @@ -113,6 +124,16 @@ impl Cache { } impl Cache { + /// Returns `true` if the cache contains the block request for the given peer. + pub fn contains_inbound_block_request(&self, peer_ip: &SocketAddr) -> bool { + Self::retain(&self.seen_inbound_block_requests, *peer_ip, Self::INBOUND_BLOCK_REQUEST_INTERVAL) > 0 + } + + /// Returns the number of recent block requests for the given peer. + pub fn num_outbound_block_requests(&self, peer_ip: &SocketAddr) -> usize { + self.seen_outbound_block_requests.read().get(peer_ip).map(|r| r.len()).unwrap_or(0) + } + /// Returns `true` if the cache contains the block request for the given peer. pub fn contains_outbound_block_request(&self, peer_ip: &SocketAddr, request: &BlockRequest) -> bool { self.seen_outbound_block_requests.read().get(peer_ip).map(|r| r.contains(request)).unwrap_or(false) @@ -200,6 +221,26 @@ impl Cache { timestamps.len() } + /// Returns the number of recent entries. + fn retain( + map: &RwLock>>, + key: K, + interval_in_secs: i64, + ) -> usize { + // Fetch the current timestamp. + let now = OffsetDateTime::now_utc(); + + let mut map_write = map.write(); + // Load the entry for the key. + let timestamps = map_write.entry(key).or_default(); + // Retain only the timestamps that are within the recent interval. + while timestamps.front().map_or(false, |t| now - *t > Duration::seconds(interval_in_secs)) { + timestamps.pop_front(); + } + // Return the frequency of recent requests. + timestamps.len() + } + /// Increments the key's counter in the map, returning the updated counter. fn increment_counter(map: &RwLock>, key: K) -> u32 { let mut map_write = map.write(); @@ -258,6 +299,27 @@ mod tests { type CurrentNetwork = MainnetV0; + #[test] + fn test_inbound_block_request() { + let cache = Cache::::default(); + let peer_ip = SocketAddr::new(Ipv4Addr::LOCALHOST.into(), 1234); + + // Check that the cache is empty. + assert_eq!(cache.seen_inbound_block_requests.read().len(), 0); + + // Insert a block request.. + assert_eq!(cache.insert_inbound_block_request(peer_ip), 1); + + // Check that the cache contains the block request. + assert!(cache.contains_inbound_block_request(&peer_ip)); + + // Insert another block request for the same peer. + assert_eq!(cache.insert_inbound_block_request(peer_ip), 2); + + // Check that the cache contains the block requests. + assert!(cache.contains_inbound_block_request(&peer_ip)); + } + #[test] fn test_inbound_solution() { let cache = Cache::::default(); diff --git a/node/router/src/inbound.rs b/node/router/src/inbound.rs index ee7e265cc0..da4befd45e 100644 --- a/node/router/src/inbound.rs +++ b/node/router/src/inbound.rs @@ -46,6 +46,8 @@ const MAX_PEERS_TO_SEND: usize = u8::MAX as usize; pub trait Inbound: Reading + Outbound { /// The maximum number of puzzle requests per interval. const MAXIMUM_PUZZLE_REQUESTS_PER_INTERVAL: usize = 5; + /// The maximum number of block requests per interval. + const MAXIMUM_BLOCK_REQUESTS_PER_INTERVAL: usize = 256; /// The duration in seconds to sleep in between ping requests with a connected peer. const PING_SLEEP_IN_SECS: u64 = 20; // 20 seconds /// The time frame to enforce the `MESSAGE_LIMIT`. @@ -75,7 +77,12 @@ pub trait Inbound: Reading + Outbound { match message { Message::BlockRequest(message) => { let BlockRequest { start_height, end_height } = &message; - + // Insert the block request for the peer, and fetch the recent frequency. + let frequency = self.router().cache.insert_inbound_block_request(peer_ip); + // Check if the number of block requests is within the limit. + if frequency > Self::MAXIMUM_BLOCK_REQUESTS_PER_INTERVAL { + bail!("Peer '{peer_ip}' is not following the protocol (excessive block requests)") + } // Ensure the block request is well-formed. if start_height >= end_height { bail!("Block request from '{peer_ip}' has an invalid range ({start_height}..{end_height})") From 276fc17a20b021758d801795446dae11f1fcabe6 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 18 Apr 2024 18:26:10 -0400 Subject: [PATCH 396/551] Add is_block_synced to Outbound --- node/router/src/outbound.rs | 3 +++ node/router/tests/common/router.rs | 5 +++++ node/src/client/router.rs | 5 +++++ node/src/prover/router.rs | 5 +++++ node/src/validator/router.rs | 5 +++++ 5 files changed, 23 insertions(+) diff --git a/node/router/src/outbound.rs b/node/router/src/outbound.rs index 20713962c9..f3c419d70d 100644 --- a/node/router/src/outbound.rs +++ b/node/router/src/outbound.rs @@ -28,6 +28,9 @@ pub trait Outbound: Writing> { /// Returns a reference to the router. fn router(&self) -> &Router; + /// Returns `true` if the node is synced up to the latest block (within the given tolerance). + fn is_block_synced(&self) -> bool; + /// Sends a "Ping" message to the given peer. fn send_ping(&self, peer_ip: SocketAddr, block_locators: Option>) { self.send(peer_ip, Message::Ping(Ping::new(self.router().node_type(), block_locators))); diff --git a/node/router/tests/common/router.rs b/node/router/tests/common/router.rs index 9dfe4f9e01..769e88f2bc 100644 --- a/node/router/tests/common/router.rs +++ b/node/router/tests/common/router.rs @@ -149,6 +149,11 @@ impl Outbound for TestRouter { fn router(&self) -> &Router { &self.0 } + + /// Returns `true` if the node is synced up to the latest block (within the given tolerance). + fn is_block_synced(&self) -> bool { + true + } } #[async_trait] diff --git a/node/src/client/router.rs b/node/src/client/router.rs index d71e21eb7e..1245ec8265 100644 --- a/node/src/client/router.rs +++ b/node/src/client/router.rs @@ -163,6 +163,11 @@ impl> Outbound for Client { fn router(&self) -> &Router { &self.router } + + /// Returns `true` if the node is synced up to the latest block (within the given tolerance). + fn is_block_synced(&self) -> bool { + self.sync.is_block_synced() + } } #[async_trait] diff --git a/node/src/prover/router.rs b/node/src/prover/router.rs index 1628ffac32..f2aff9bef7 100644 --- a/node/src/prover/router.rs +++ b/node/src/prover/router.rs @@ -135,6 +135,11 @@ impl> Outbound for Prover { fn router(&self) -> &Router { &self.router } + + /// Returns `true` if the node is synced up to the latest block (within the given tolerance). + fn is_block_synced(&self) -> bool { + true + } } #[async_trait] diff --git a/node/src/validator/router.rs b/node/src/validator/router.rs index fcbc057215..4976f85438 100644 --- a/node/src/validator/router.rs +++ b/node/src/validator/router.rs @@ -137,6 +137,11 @@ impl> Outbound for Validator { fn router(&self) -> &Router { &self.router } + + /// Returns `true` if the node is synced up to the latest block (within the given tolerance). + fn is_block_synced(&self) -> bool { + self.sync.is_block_synced() + } } #[async_trait] From e7b0e4380169dfdb0e5edadf6d0f6367c43fe3d1 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 18 Apr 2024 18:26:32 -0400 Subject: [PATCH 397/551] Do not peer refresh a sync peer --- node/router/src/heartbeat.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/node/router/src/heartbeat.rs b/node/router/src/heartbeat.rs index 204052e641..dca8c6d225 100644 --- a/node/router/src/heartbeat.rs +++ b/node/router/src/heartbeat.rs @@ -123,6 +123,8 @@ pub trait Heartbeat: Outbound { .get_connected_peers() .iter() .filter(|peer| !trusted.contains(&peer.ip()) && !bootstrap.contains(&peer.ip())) + .filter(|peer| !self.router().cache.contains_inbound_block_request(&peer.ip())) // Skip if the peer is syncing. + .filter(|peer| self.is_block_synced() || self.router().cache.num_outbound_block_requests(&peer.ip()) == 0) // Skip if you are syncing from this peer. .min_by_key(|peer| peer.last_seen()) .map(|peer| peer.ip()); From 4ae5926de0991efa59d2cc81a435fc2cb5fe22de Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 18 Apr 2024 18:26:10 -0400 Subject: [PATCH 398/551] Add is_block_synced to Outbound --- node/router/src/outbound.rs | 3 +++ node/router/tests/common/router.rs | 5 +++++ node/src/client/router.rs | 5 +++++ node/src/prover/router.rs | 5 +++++ node/src/validator/router.rs | 5 +++++ 5 files changed, 23 insertions(+) diff --git a/node/router/src/outbound.rs b/node/router/src/outbound.rs index 20713962c9..f3c419d70d 100644 --- a/node/router/src/outbound.rs +++ b/node/router/src/outbound.rs @@ -28,6 +28,9 @@ pub trait Outbound: Writing> { /// Returns a reference to the router. fn router(&self) -> &Router; + /// Returns `true` if the node is synced up to the latest block (within the given tolerance). + fn is_block_synced(&self) -> bool; + /// Sends a "Ping" message to the given peer. fn send_ping(&self, peer_ip: SocketAddr, block_locators: Option>) { self.send(peer_ip, Message::Ping(Ping::new(self.router().node_type(), block_locators))); diff --git a/node/router/tests/common/router.rs b/node/router/tests/common/router.rs index 9dfe4f9e01..769e88f2bc 100644 --- a/node/router/tests/common/router.rs +++ b/node/router/tests/common/router.rs @@ -149,6 +149,11 @@ impl Outbound for TestRouter { fn router(&self) -> &Router { &self.0 } + + /// Returns `true` if the node is synced up to the latest block (within the given tolerance). + fn is_block_synced(&self) -> bool { + true + } } #[async_trait] diff --git a/node/src/client/router.rs b/node/src/client/router.rs index d71e21eb7e..1245ec8265 100644 --- a/node/src/client/router.rs +++ b/node/src/client/router.rs @@ -163,6 +163,11 @@ impl> Outbound for Client { fn router(&self) -> &Router { &self.router } + + /// Returns `true` if the node is synced up to the latest block (within the given tolerance). + fn is_block_synced(&self) -> bool { + self.sync.is_block_synced() + } } #[async_trait] diff --git a/node/src/prover/router.rs b/node/src/prover/router.rs index 1628ffac32..f2aff9bef7 100644 --- a/node/src/prover/router.rs +++ b/node/src/prover/router.rs @@ -135,6 +135,11 @@ impl> Outbound for Prover { fn router(&self) -> &Router { &self.router } + + /// Returns `true` if the node is synced up to the latest block (within the given tolerance). + fn is_block_synced(&self) -> bool { + true + } } #[async_trait] diff --git a/node/src/validator/router.rs b/node/src/validator/router.rs index fcbc057215..4976f85438 100644 --- a/node/src/validator/router.rs +++ b/node/src/validator/router.rs @@ -137,6 +137,11 @@ impl> Outbound for Validator { fn router(&self) -> &Router { &self.router } + + /// Returns `true` if the node is synced up to the latest block (within the given tolerance). + fn is_block_synced(&self) -> bool { + self.sync.is_block_synced() + } } #[async_trait] From 0eef8ed0e39b5dde74dd392597c2c33cee1cf19f Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 18 Apr 2024 18:34:34 -0400 Subject: [PATCH 399/551] Perform clone after seen_before check --- node/router/src/inbound.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/node/router/src/inbound.rs b/node/router/src/inbound.rs index ee7e265cc0..0610aea0ce 100644 --- a/node/router/src/inbound.rs +++ b/node/router/src/inbound.rs @@ -207,8 +207,6 @@ pub trait Inbound: Reading + Outbound { } } Message::UnconfirmedSolution(message) => { - // Clone the serialized message. - let serialized = message.clone(); // Update the timestamp for the unconfirmed solution. let seen_before = self.router().cache.insert_inbound_solution(peer_ip, message.solution_id).is_some(); // Determine whether to propagate the solution. @@ -216,6 +214,8 @@ pub trait Inbound: Reading + Outbound { trace!("Skipping 'UnconfirmedSolution' from '{peer_ip}'"); return Ok(()); } + // Clone the serialized message. + let serialized = message.clone(); // Perform the deferred non-blocking deserialization of the solution. let solution = match message.solution.deserialize().await { Ok(solution) => solution, @@ -232,8 +232,6 @@ pub trait Inbound: Reading + Outbound { } } Message::UnconfirmedTransaction(message) => { - // Clone the serialized message. - let serialized = message.clone(); // Update the timestamp for the unconfirmed transaction. let seen_before = self.router().cache.insert_inbound_transaction(peer_ip, message.transaction_id).is_some(); @@ -242,6 +240,8 @@ pub trait Inbound: Reading + Outbound { trace!("Skipping 'UnconfirmedTransaction' from '{peer_ip}'"); return Ok(()); } + // Clone the serialized message. + let serialized = message.clone(); // Perform the deferred non-blocking deserialization of the transaction. let transaction = match message.transaction.deserialize().await { Ok(transaction) => transaction, From bdfb225f464620fc006058552367d113dea325b6 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 18 Apr 2024 18:35:16 -0400 Subject: [PATCH 400/551] Do not process unconfirmed solution if node is syncing --- node/router/src/inbound.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/node/router/src/inbound.rs b/node/router/src/inbound.rs index 0610aea0ce..70c5c6b60e 100644 --- a/node/router/src/inbound.rs +++ b/node/router/src/inbound.rs @@ -207,6 +207,11 @@ pub trait Inbound: Reading + Outbound { } } Message::UnconfirmedSolution(message) => { + // Do not process unconfirmed solutions if the node is syncing. + if !self.is_block_synced() { + trace!("Skipped processing unconfirmed solution '{}' (node is syncing)", message.solution_id); + return Ok(()); + } // Update the timestamp for the unconfirmed solution. let seen_before = self.router().cache.insert_inbound_solution(peer_ip, message.solution_id).is_some(); // Determine whether to propagate the solution. From 877bf7fd619370c0122f010872d115cff561ed95 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 18 Apr 2024 18:48:22 -0400 Subject: [PATCH 401/551] Verify the solution prior to broadcasting --- node/rest/src/routes.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/node/rest/src/routes.rs b/node/rest/src/routes.rs index c5b6c9e256..325f6eaa29 100644 --- a/node/rest/src/routes.rs +++ b/node/rest/src/routes.rs @@ -338,9 +338,23 @@ impl, R: Routing> Rest { Json(solution): Json>, ) -> Result { // If the consensus module is enabled, add the unconfirmed solution to the memory pool. - if let Some(consensus) = rest.consensus { + // Otherwise, verify it prior to broadcasting. + match rest.consensus { // Add the unconfirmed solution to the memory pool. - consensus.add_unconfirmed_solution(solution).await?; + Some(consensus) => consensus.add_unconfirmed_solution(solution).await?, + // Verify the solution. + None => { + // Compute the current epoch hash. + let epoch_hash = rest.ledger.latest_epoch_hash()?; + // Retrieve the current proof target. + let proof_target = rest.ledger.latest_proof_target(); + // Ensure that the solution is valid for the given epoch. + let puzzle = rest.ledger.puzzle().clone(); + // Verify the solution. + if let Err(err) = puzzle.check_solution(&solution, epoch_hash, proof_target) { + return Err(RestError(format!("Invalid solution `{}` - {err}", solution.id()))); + } + } } let solution_id = solution.id(); From 67a5fddc9b38551ab84ad9a5f0676b12f8636657 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 18 Apr 2024 18:50:14 -0400 Subject: [PATCH 402/551] Do not process unconfirmed transaction if node is syncing --- node/router/src/inbound.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/node/router/src/inbound.rs b/node/router/src/inbound.rs index 70c5c6b60e..61577de95f 100644 --- a/node/router/src/inbound.rs +++ b/node/router/src/inbound.rs @@ -237,6 +237,11 @@ pub trait Inbound: Reading + Outbound { } } Message::UnconfirmedTransaction(message) => { + // Do not process unconfirmed transactions if the node is syncing. + if !self.is_block_synced() { + trace!("Skipped processing unconfirmed transaction '{}' (node is syncing)", message.transaction_id); + return Ok(()); + } // Update the timestamp for the unconfirmed transaction. let seen_before = self.router().cache.insert_inbound_transaction(peer_ip, message.transaction_id).is_some(); From 244fc000ff50a2da794d5cbefcbb7d35d7708a54 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 18 Apr 2024 19:01:20 -0400 Subject: [PATCH 403/551] Use tokio task for REST solution verification --- node/rest/src/routes.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/node/rest/src/routes.rs b/node/rest/src/routes.rs index 325f6eaa29..2e6575d84f 100644 --- a/node/rest/src/routes.rs +++ b/node/rest/src/routes.rs @@ -350,9 +350,13 @@ impl, R: Routing> Rest { let proof_target = rest.ledger.latest_proof_target(); // Ensure that the solution is valid for the given epoch. let puzzle = rest.ledger.puzzle().clone(); - // Verify the solution. - if let Err(err) = puzzle.check_solution(&solution, epoch_hash, proof_target) { - return Err(RestError(format!("Invalid solution `{}` - {err}", solution.id()))); + // Verify the solution in a blocking task. + match tokio::task::spawn_blocking(move || puzzle.check_solution(&solution, epoch_hash, proof_target)) + .await + { + Ok(Ok(())) => {} + Ok(Err(err)) => return Err(RestError(format!("Invalid solution `{}` - {err}", solution.id()))), + Err(err) => return Err(RestError(format!("Invalid solution `{}` - {err}", solution.id()))), } } } From cabf7b4e5448d9f7730497e78bb1d09941e96ea9 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 18 Apr 2024 20:28:19 -0400 Subject: [PATCH 404/551] Update MAXIMUM_NUMBER_OF_BLOCKS to 5 --- node/bft/events/src/block_response.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/bft/events/src/block_response.rs b/node/bft/events/src/block_response.rs index ea56fa9579..2bf1f20057 100644 --- a/node/bft/events/src/block_response.rs +++ b/node/bft/events/src/block_response.rs @@ -64,7 +64,7 @@ pub struct DataBlocks(pub Vec>); impl DataBlocks { /// The maximum number of blocks that can be sent in a single message. - pub const MAXIMUM_NUMBER_OF_BLOCKS: u8 = 10; + pub const MAXIMUM_NUMBER_OF_BLOCKS: u8 = 5; /// Ensures that the blocks are well-formed in a block response. pub fn ensure_response_is_well_formed( From 3c5bba1eb8b2d3cc2a283382a7b8bfe362862e78 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 19 Apr 2024 15:22:45 -0400 Subject: [PATCH 405/551] Fix ordering --- node/consensus/src/lib.rs | 20 ++++++++++---------- node/rest/src/lib.rs | 2 +- node/rest/src/routes.rs | 10 +++++----- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 4462814c3e..7fb6af37c8 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -247,6 +247,16 @@ impl Consensus { self.inbound_transmissions().map(|(id, _)| id) } + /// Returns the transmissions in the inbound queue. + pub fn inbound_transmissions(&self) -> impl '_ + Iterator, Transmission)> { + self.inbound_transactions() + .map(|(id, tx)| (TransmissionID::Transaction(id), Transmission::Transaction(tx))) + .chain( + self.inbound_solutions() + .map(|(id, solution)| (TransmissionID::Solution(id), Transmission::Solution(solution))), + ) + } + /// Returns the solutions in the inbound queue. pub fn inbound_solutions(&self) -> impl '_ + Iterator, Data>)> { // Return an iterator over the solutions in the inbound queue. @@ -265,16 +275,6 @@ impl Consensus { .chain(tx_queue.executions.clone()) .map(|(id, tx)| (id, Data::Object(tx))) } - - /// Returns the transmissions in the inbound queue. - pub fn inbound_transmissions(&self) -> impl '_ + Iterator, Transmission)> { - self.inbound_transactions() - .map(|(id, tx)| (TransmissionID::Transaction(id), Transmission::Transaction(tx))) - .chain( - self.inbound_solutions() - .map(|(id, solution)| (TransmissionID::Solution(id), Transmission::Solution(solution))), - ) - } } impl Consensus { diff --git a/node/rest/src/lib.rs b/node/rest/src/lib.rs index 914cccbbca..6f5382916a 100644 --- a/node/rest/src/lib.rs +++ b/node/rest/src/lib.rs @@ -188,8 +188,8 @@ impl, R: Routing> Rest { .route(&format!("/{network}/memoryPool/solutions"), get(Self::get_memory_pool_solutions)) .route(&format!("/{network}/memoryPool/transactions"), get(Self::get_memory_pool_transactions)) .route(&format!("/{network}/statePath/:commitment"), get(Self::get_state_path_for_commitment)) - .route(&format!("/{network}/stateRoot/:height"), get(Self::get_state_root)) .route(&format!("/{network}/stateRoot/latest"), get(Self::get_state_root_latest)) + .route(&format!("/{network}/stateRoot/:height"), get(Self::get_state_root)) .route(&format!("/{network}/committee/latest"), get(Self::get_committee_latest)) // Pass in `Rest` to make things convenient. diff --git a/node/rest/src/routes.rs b/node/rest/src/routes.rs index b0f236b47b..a94a7ed1a1 100644 --- a/node/rest/src/routes.rs +++ b/node/rest/src/routes.rs @@ -246,6 +246,11 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(rest.ledger.get_state_path_for_commitment(&commitment)?)) } + // GET //stateRoot/latest + pub(crate) async fn get_state_root_latest(State(rest): State) -> ErasedJson { + ErasedJson::pretty(rest.ledger.latest_state_root()) + } + // GET //stateRoot/{height} pub(crate) async fn get_state_root( State(rest): State, @@ -254,11 +259,6 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(rest.ledger.get_state_root(height)?)) } - // GET //stateRoot/latest - pub(crate) async fn get_state_root_latest(State(rest): State) -> ErasedJson { - ErasedJson::pretty(rest.ledger.latest_state_root()) - } - // GET //committee/latest pub(crate) async fn get_committee_latest(State(rest): State) -> Result { Ok(ErasedJson::pretty(rest.ledger.latest_committee()?)) From cca3c4415cf20e99aee946b1dab2fd6e077791cf Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 19 Apr 2024 15:25:29 -0400 Subject: [PATCH 406/551] Update ordering for find/blockHeight --- node/rest/src/lib.rs | 2 +- node/rest/src/routes.rs | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/node/rest/src/lib.rs b/node/rest/src/lib.rs index 6f5382916a..9fe3ef2eca 100644 --- a/node/rest/src/lib.rs +++ b/node/rest/src/lib.rs @@ -166,10 +166,10 @@ impl, R: Routing> Rest { // GET ../find/.. .route(&format!("/{network}/find/blockHash/:tx_id"), get(Self::find_block_hash)) + .route(&format!("/{network}/find/blockHeight/:state_root"), get(Self::find_block_height_from_state_root)) .route(&format!("/{network}/find/transactionID/deployment/:program_id"), get(Self::find_transaction_id_from_program_id)) .route(&format!("/{network}/find/transactionID/:transition_id"), get(Self::find_transaction_id_from_transition_id)) .route(&format!("/{network}/find/transitionID/:input_or_output_id"), get(Self::find_transition_id)) - .route(&format!("/{network}/find/blockHeight/:state_root"), get(Self::find_block_height_from_state_root)) // GET ../peers/.. .route(&format!("/{network}/peers/count"), get(Self::get_peers_count)) diff --git a/node/rest/src/routes.rs b/node/rest/src/routes.rs index a94a7ed1a1..0a800c782a 100644 --- a/node/rest/src/routes.rs +++ b/node/rest/src/routes.rs @@ -292,6 +292,14 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(rest.ledger.find_block_hash(&tx_id)?)) } + // GET //find/blockHeight/{stateRoot} + pub(crate) async fn find_block_height_from_state_root( + State(rest): State, + Path(state_root): Path, + ) -> Result { + Ok(ErasedJson::pretty(rest.ledger.find_block_height_from_state_root(state_root)?)) + } + // GET //find/transactionID/deployment/{programID} pub(crate) async fn find_transaction_id_from_program_id( State(rest): State, @@ -316,14 +324,6 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(rest.ledger.find_transition_id(&input_or_output_id)?)) } - // GET //find/blockHeight/{stateRoot} - pub(crate) async fn find_block_height_from_state_root( - State(rest): State, - Path(state_root): Path, - ) -> Result { - Ok(ErasedJson::pretty(rest.ledger.find_block_height_from_state_root(state_root)?)) - } - // POST //transaction/broadcast pub(crate) async fn transaction_broadcast( State(rest): State, From 06c874b0855de982a541004635a0d2be5dda9ab5 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 19 Apr 2024 15:33:01 -0400 Subject: [PATCH 407/551] Bump snarkVM rev - 43abe1b --- Cargo.lock | 118 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 2 +- 2 files changed, 60 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 221b275936..a9adda3236 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3289,7 +3289,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "anstyle", "anyhow", @@ -3320,7 +3320,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "aleo-std", "anyhow", @@ -3350,7 +3350,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3364,7 +3364,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3375,7 +3375,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3385,7 +3385,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3395,7 +3395,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "indexmap 2.2.6", "itertools 0.11.0", @@ -3413,12 +3413,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3429,7 +3429,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3444,7 +3444,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3459,7 +3459,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3472,7 +3472,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3481,7 +3481,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3491,7 +3491,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3503,7 +3503,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3515,7 +3515,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3526,7 +3526,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3538,7 +3538,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3551,7 +3551,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "bs58", "snarkvm-console-network", @@ -3562,7 +3562,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "blake2s_simd", "smallvec", @@ -3575,7 +3575,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "aleo-std", "rayon", @@ -3586,7 +3586,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "anyhow", "indexmap 2.2.6", @@ -3609,7 +3609,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "anyhow", "bech32", @@ -3627,7 +3627,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "enum_index", "enum_index_derive", @@ -3648,7 +3648,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3663,7 +3663,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3674,7 +3674,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "snarkvm-console-network-environment", ] @@ -3682,7 +3682,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3692,7 +3692,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3703,7 +3703,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3714,7 +3714,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3725,7 +3725,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3736,7 +3736,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "rand", "rayon", @@ -3750,7 +3750,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "aleo-std", "anyhow", @@ -3767,7 +3767,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "aleo-std", "anyhow", @@ -3792,7 +3792,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "anyhow", "rand", @@ -3804,7 +3804,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3823,7 +3823,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "anyhow", "indexmap 2.2.6", @@ -3842,7 +3842,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -3855,7 +3855,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3868,7 +3868,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3881,7 +3881,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "bytes", "serde_json", @@ -3892,7 +3892,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3907,7 +3907,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "bytes", "serde_json", @@ -3920,7 +3920,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "snarkvm-console", "snarkvm-ledger-puzzle", @@ -3929,7 +3929,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "aleo-std", "anyhow", @@ -3949,7 +3949,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle-epoch" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "anyhow", "colored", @@ -3964,7 +3964,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "async-trait", "reqwest", @@ -3977,7 +3977,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "aleo-std-storage", "anyhow", @@ -4003,7 +4003,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4018,7 +4018,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4027,7 +4027,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "aleo-std", "anyhow", @@ -4052,7 +4052,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "aleo-std", "anyhow", @@ -4081,7 +4081,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "aleo-std", "colored", @@ -4104,7 +4104,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "indexmap 2.2.6", "paste", @@ -4118,7 +4118,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "bincode", "once_cell", @@ -4131,7 +4131,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "aleo-std", "anyhow", @@ -4152,7 +4152,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=da3d78a#da3d78a5726ce5b07581203a9aaff3fe39fc3057" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" dependencies = [ "proc-macro2", "quote 1.0.36", diff --git a/Cargo.toml b/Cargo.toml index f582089b07..afd6efcd79 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "da3d78a" +rev = "43abe1b" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From e26d17437264ef763f73097d9a9242d5b77cdb35 Mon Sep 17 00:00:00 2001 From: mia <93600681+miazn@users.noreply.github.com> Date: Fri, 19 Apr 2024 15:34:43 -0400 Subject: [PATCH 408/551] Update node/metrics/Cargo.toml Co-authored-by: Raymond Chu <14917648+raychu86@users.noreply.github.com> Signed-off-by: mia <93600681+miazn@users.noreply.github.com> --- node/metrics/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/metrics/Cargo.toml b/node/metrics/Cargo.toml index 863355c071..e6c35ffdaa 100644 --- a/node/metrics/Cargo.toml +++ b/node/metrics/Cargo.toml @@ -40,4 +40,4 @@ version = "1.28" features = [ "rt" ] [dependencies.time] -version = "0.3" \ No newline at end of file +version = "0.3" From 98e2189b82b01ca340221fefaf29032ad3c086ee Mon Sep 17 00:00:00 2001 From: miazn Date: Fri, 19 Apr 2024 15:41:16 -0400 Subject: [PATCH 409/551] import reordering --- Cargo.lock | 1 - node/bft/ledger-service/Cargo.toml | 5 ----- node/metrics/Cargo.toml | 6 +++--- node/metrics/src/lib.rs | 1 + 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8ade536a66..1def69e351 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3081,7 +3081,6 @@ dependencies = [ "lru", "parking_lot", "rand", - "rayon", "snarkos-node-metrics", "snarkvm", "tokio", diff --git a/node/bft/ledger-service/Cargo.toml b/node/bft/ledger-service/Cargo.toml index f032388195..6f83c661e4 100644 --- a/node/bft/ledger-service/Cargo.toml +++ b/node/bft/ledger-service/Cargo.toml @@ -23,7 +23,6 @@ ledger-write = [ ] metrics = ["dep:metrics", "snarkvm/metrics"] mock = [ "parking_lot", "tracing" ] prover = [ ] -serial = [ ] test = [ "mock", "translucent" ] translucent = [ "ledger" ] @@ -52,10 +51,6 @@ optional = true version = "0.8" optional = true -[dependencies.rayon] -version = "1" -optional = true - [dependencies.snarkvm] workspace = true diff --git a/node/metrics/Cargo.toml b/node/metrics/Cargo.toml index e6c35ffdaa..36c757bed1 100644 --- a/node/metrics/Cargo.toml +++ b/node/metrics/Cargo.toml @@ -35,9 +35,9 @@ optional = true workspace = true features = [ "metrics" ] +[dependencies.time] +version = "0.3" + [dependencies.tokio] version = "1.28" features = [ "rt" ] - -[dependencies.time] -version = "0.3" diff --git a/node/metrics/src/lib.rs b/node/metrics/src/lib.rs index c2315eac53..0bd6f7dae4 100644 --- a/node/metrics/src/lib.rs +++ b/node/metrics/src/lib.rs @@ -17,6 +17,7 @@ mod names; // Expose the names at the crate level for easy access. pub use names::*; use parking_lot::Mutex; + // Re-export the snarkVM metrics. #[cfg(not(feature = "serial"))] use rayon::prelude::*; From 2e42c4181d3c77091ecc43c7d7340aaf3284aced Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 19 Apr 2024 15:57:09 -0400 Subject: [PATCH 410/551] Cleanup --- node/sync/src/block_sync.rs | 86 +++++++++++++++++++++++------------- node/sync/src/helpers/mod.rs | 3 ++ 2 files changed, 59 insertions(+), 30 deletions(-) diff --git a/node/sync/src/block_sync.rs b/node/sync/src/block_sync.rs index 3b597b91e7..403315fb04 100644 --- a/node/sync/src/block_sync.rs +++ b/node/sync/src/block_sync.rs @@ -13,7 +13,7 @@ // limitations under the License. use crate::{ - helpers::{PeerPair, SyncRequest}, + helpers::{PeerPair, PrepareSyncRequest, SyncRequest}, locators::BlockLocators, }; use snarkos_node_bft_ledger_service::LedgerService; @@ -234,8 +234,8 @@ impl BlockSync { // Process the block requests. 'outer: for requests in block_requests.chunks(DataBlocks::::MAXIMUM_NUMBER_OF_BLOCKS as usize) { // Retrieve the starting height and the sync IPs. - let (start_height, sync_ips) = match requests.first() { - Some((height, (_, _, sync_ips))) => (*height, sync_ips), + let (start_height, max_num_sync_ips) = match requests.first() { + Some((height, (_, _, max_num_sync_ips))) => (*height, *max_num_sync_ips), None => { warn!("Block sync failed - no block requests"); break 'outer; @@ -246,7 +246,7 @@ impl BlockSync { let sync_ips: IndexSet<_> = sync_peers .keys() .copied() - .choose_multiple(&mut rand::thread_rng(), sync_ips.len()) + .choose_multiple(&mut rand::thread_rng(), max_num_sync_ips) .into_iter() .collect(); @@ -429,7 +429,7 @@ impl BlockSync { impl BlockSync { /// Returns a list of block requests and the sync peers, if the node needs to sync. #[allow(clippy::type_complexity)] - fn prepare_block_requests(&self) -> (Vec<(u32, SyncRequest)>, IndexMap>) { + fn prepare_block_requests(&self) -> (Vec<(u32, PrepareSyncRequest)>, IndexMap>) { // Remove timed out block requests. self.remove_timed_out_block_requests(); // Prepare the block requests. @@ -439,7 +439,7 @@ impl BlockSync { // Update the state of `is_block_synced` for the sync module. self.update_is_block_synced(greatest_peer_height, MAX_BLOCKS_BEHIND); // Return the list of block requests. - (self.construct_requests(&sync_peers, min_common_ancestor, &mut rand::thread_rng()), sync_peers) + (self.construct_requests(&sync_peers, min_common_ancestor), sync_peers) } else { // Update the state of `is_block_synced` for the sync module. self.update_is_block_synced(0, MAX_BLOCKS_BEHIND); @@ -756,12 +756,11 @@ impl BlockSync { } /// Given the sync peers and their minimum common ancestor, return a list of block requests. - fn construct_requests( + fn construct_requests( &self, sync_peers: &IndexMap>, min_common_ancestor: u32, - rng: &mut R, - ) -> Vec<(u32, SyncRequest)> { + ) -> Vec<(u32, PrepareSyncRequest)> { // Retrieve the latest canon height. let latest_canon_height = self.canon.latest_block_height(); @@ -776,7 +775,9 @@ impl BlockSync { let max_blocks_to_request = MAX_BLOCK_REQUESTS as u32 * DataBlocks::::MAXIMUM_NUMBER_OF_BLOCKS as u32; let end_height = (min_common_ancestor + 1).min(start_height + max_blocks_to_request); + // Construct the block hashes to request. let mut request_hashes = IndexMap::with_capacity((start_height..end_height).len()); + // Track the largest number of sync IPs required for any block request in the sequence of requests. let mut max_num_sync_ips = 1; for height in start_height..end_height { @@ -810,15 +811,10 @@ impl BlockSync { request_hashes.insert(height, (hash, previous_hash)); } - // TODO (raychu86): Remove this. Just return the required num_sync_ips. - // Pick the sync peers. - let sync_ips: IndexSet<_> = - sync_peers.keys().copied().choose_multiple(rng, max_num_sync_ips).into_iter().collect(); - // Construct the requests with the same sync ips. request_hashes .into_iter() - .map(|(height, (hash, previous_hash))| (height, (hash, previous_hash, sync_ips.clone()))) + .map(|(height, (hash, previous_hash))| (height, (hash, previous_hash, max_num_sync_ips))) .collect() } } @@ -952,6 +948,8 @@ mod tests { min_common_ancestor: u32, peers: IndexSet, ) { + let rng = &mut TestRng::default(); + // Check test assumptions are met. assert_eq!(sync.canon.latest_block_height(), 0, "This test assumes the sync pool is at genesis"); @@ -968,7 +966,7 @@ mod tests { }; // Prepare the block requests. - let (requests, _) = sync.prepare_block_requests(); + let (requests, sync_peers) = sync.prepare_block_requests(); // If there are no peers, then there should be no requests. if peers.is_empty() { @@ -980,7 +978,10 @@ mod tests { let expected_num_requests = core::cmp::min(min_common_ancestor as usize, MAX_BLOCK_REQUESTS); assert_eq!(requests.len(), expected_num_requests); - for (idx, (height, (hash, previous_hash, sync_ips))) in requests.into_iter().enumerate() { + for (idx, (height, (hash, previous_hash, num_sync_ips))) in requests.into_iter().enumerate() { + // Construct the sync IPs. + let sync_ips: IndexSet<_> = + sync_peers.keys().choose_multiple(rng, num_sync_ips).into_iter().copied().collect(); assert_eq!(height, 1 + idx as u32); assert_eq!(hash, Some((Field::::from_u32(height)).into())); assert_eq!(previous_hash, Some((Field::::from_u32(height - 1)).into())); @@ -1074,16 +1075,17 @@ mod tests { assert_eq!(requests.len(), 10); // Check the requests. - for (idx, (height, (hash, previous_hash, sync_ips))) in requests.into_iter().enumerate() { + for (idx, (height, (hash, previous_hash, num_sync_ips))) in requests.into_iter().enumerate() { assert_eq!(height, 1 + idx as u32); assert_eq!(hash, Some((Field::::from_u32(height)).into())); assert_eq!(previous_hash, Some((Field::::from_u32(height - 1)).into())); - assert_eq!(sync_ips.len(), 1); // Only 1 needed since we have redundancy factor on this (recent locator) hash. + assert_eq!(num_sync_ips, 1); // Only 1 needed since we have redundancy factor on this (recent locator) hash. } } #[test] fn test_prepare_block_requests_with_leading_fork_at_10() { + let rng = &mut TestRng::default(); let sync = sample_sync_at_height(0); // Intuitively, peer 1's fork is at peer 2 and peer 3's height. @@ -1122,11 +1124,14 @@ mod tests { sync.update_peer_locators(peer_4, sample_block_locators(10)).unwrap(); // Prepare the block requests. - let (requests, _) = sync.prepare_block_requests(); + let (requests, sync_peers) = sync.prepare_block_requests(); assert_eq!(requests.len(), 10); // Check the requests. - for (idx, (height, (hash, previous_hash, sync_ips))) in requests.into_iter().enumerate() { + for (idx, (height, (hash, previous_hash, num_sync_ips))) in requests.into_iter().enumerate() { + // Construct the sync IPs. + let sync_ips: IndexSet<_> = + sync_peers.keys().choose_multiple(rng, num_sync_ips).into_iter().copied().collect(); assert_eq!(height, 1 + idx as u32); assert_eq!(hash, Some((Field::::from_u32(height)).into())); assert_eq!(previous_hash, Some((Field::::from_u32(height - 1)).into())); @@ -1137,6 +1142,7 @@ mod tests { #[test] fn test_prepare_block_requests_with_trailing_fork_at_9() { + let rng = &mut TestRng::default(); let sync = sample_sync_at_height(0); // Peer 1 and 2 diverge from peer 3 at block 10. We only sync when there are NUM_REDUNDANCY peers @@ -1166,11 +1172,14 @@ mod tests { sync.update_peer_locators(peer_4, sample_block_locators(10)).unwrap(); // Prepare the block requests. - let (requests, _) = sync.prepare_block_requests(); + let (requests, sync_peers) = sync.prepare_block_requests(); assert_eq!(requests.len(), 10); // Check the requests. - for (idx, (height, (hash, previous_hash, sync_ips))) in requests.into_iter().enumerate() { + for (idx, (height, (hash, previous_hash, num_sync_ips))) in requests.into_iter().enumerate() { + // Construct the sync IPs. + let sync_ips: IndexSet<_> = + sync_peers.keys().choose_multiple(rng, num_sync_ips).into_iter().copied().collect(); assert_eq!(height, 1 + idx as u32); assert_eq!(hash, Some((Field::::from_u32(height)).into())); assert_eq!(previous_hash, Some((Field::::from_u32(height - 1)).into())); @@ -1181,16 +1190,20 @@ mod tests { #[test] fn test_insert_block_requests() { + let rng = &mut TestRng::default(); let sync = sample_sync_at_height(0); // Add a peer. sync.update_peer_locators(sample_peer_ip(1), sample_block_locators(10)).unwrap(); // Prepare the block requests. - let (requests, _) = sync.prepare_block_requests(); + let (requests, sync_peers) = sync.prepare_block_requests(); assert_eq!(requests.len(), 10); - for (height, (hash, previous_hash, sync_ips)) in requests.clone() { + for (height, (hash, previous_hash, num_sync_ips)) in requests.clone() { + // Construct the sync IPs. + let sync_ips: IndexSet<_> = + sync_peers.keys().choose_multiple(rng, num_sync_ips).into_iter().copied().collect(); // Insert the block request. sync.insert_block_request(height, (hash, previous_hash, sync_ips.clone())).unwrap(); // Check that the block requests were inserted. @@ -1198,13 +1211,19 @@ mod tests { assert!(sync.get_block_request_timestamp(height).is_some()); } - for (height, (hash, previous_hash, sync_ips)) in requests.clone() { + for (height, (hash, previous_hash, num_sync_ips)) in requests.clone() { + // Construct the sync IPs. + let sync_ips: IndexSet<_> = + sync_peers.keys().choose_multiple(rng, num_sync_ips).into_iter().copied().collect(); // Check that the block requests are still inserted. assert_eq!(sync.get_block_request(height), Some((hash, previous_hash, sync_ips))); assert!(sync.get_block_request_timestamp(height).is_some()); } - for (height, (hash, previous_hash, sync_ips)) in requests { + for (height, (hash, previous_hash, num_sync_ips)) in requests { + // Construct the sync IPs. + let sync_ips: IndexSet<_> = + sync_peers.keys().choose_multiple(rng, num_sync_ips).into_iter().copied().collect(); // Ensure that the block requests cannot be inserted twice. sync.insert_block_request(height, (hash, previous_hash, sync_ips.clone())).unwrap_err(); // Check that the block requests are still inserted. @@ -1298,6 +1317,7 @@ mod tests { #[test] fn test_requests_insert_remove_insert() { + let rng = &mut TestRng::default(); let sync = sample_sync_at_height(0); // Add a peer. @@ -1305,10 +1325,13 @@ mod tests { sync.update_peer_locators(peer_ip, sample_block_locators(10)).unwrap(); // Prepare the block requests. - let (requests, _) = sync.prepare_block_requests(); + let (requests, sync_peers) = sync.prepare_block_requests(); assert_eq!(requests.len(), 10); - for (height, (hash, previous_hash, sync_ips)) in requests.clone() { + for (height, (hash, previous_hash, num_sync_ips)) in requests.clone() { + // Construct the sync IPs. + let sync_ips: IndexSet<_> = + sync_peers.keys().choose_multiple(rng, num_sync_ips).into_iter().copied().collect(); // Insert the block request. sync.insert_block_request(height, (hash, previous_hash, sync_ips.clone())).unwrap(); // Check that the block requests were inserted. @@ -1336,7 +1359,10 @@ mod tests { let (requests, _) = sync.prepare_block_requests(); assert_eq!(requests.len(), 10); - for (height, (hash, previous_hash, sync_ips)) in requests { + for (height, (hash, previous_hash, num_sync_ips)) in requests { + // Construct the sync IPs. + let sync_ips: IndexSet<_> = + sync_peers.keys().choose_multiple(rng, num_sync_ips).into_iter().copied().collect(); // Insert the block request. sync.insert_block_request(height, (hash, previous_hash, sync_ips.clone())).unwrap(); // Check that the block requests were inserted. diff --git a/node/sync/src/helpers/mod.rs b/node/sync/src/helpers/mod.rs index 99f8b71e84..ce876fd12a 100644 --- a/node/sync/src/helpers/mod.rs +++ b/node/sync/src/helpers/mod.rs @@ -18,6 +18,9 @@ use core::hash::Hash; use indexmap::IndexSet; use std::net::SocketAddr; +/// A tuple of the block hash (optional), previous block hash (optional), and the number of sync IPS to request from. +pub type PrepareSyncRequest = (Option<::BlockHash>, Option<::BlockHash>, usize); + /// A tuple of the block hash (optional), previous block hash (optional), and sync IPs. pub type SyncRequest = (Option<::BlockHash>, Option<::BlockHash>, IndexSet); From f38883fad86429d7d280e5c1f6c950b9b6f0afef Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Fri, 19 Apr 2024 14:22:24 -0600 Subject: [PATCH 411/551] Update node/metrics/src/lib.rs Signed-off-by: Howard Wu <9260812+howardwu@users.noreply.github.com> --- node/metrics/src/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/node/metrics/src/lib.rs b/node/metrics/src/lib.rs index 0bd6f7dae4..f25f53caef 100644 --- a/node/metrics/src/lib.rs +++ b/node/metrics/src/lib.rs @@ -16,12 +16,14 @@ mod names; // Expose the names at the crate level for easy access. pub use names::*; -use parking_lot::Mutex; // Re-export the snarkVM metrics. +pub use snarkvm::metrics::*; + #[cfg(not(feature = "serial"))] use rayon::prelude::*; -pub use snarkvm::metrics::*; + +use parking_lot::Mutex; use snarkvm::{ ledger::narwhal::TransmissionID, prelude::{cfg_iter, Block, Network}, From 999aa1754169475833b8f9b92cf5556ad2c024d8 Mon Sep 17 00:00:00 2001 From: Pranav Gaddamadugu <23022326+d0cd@users.noreply.github.com> Date: Fri, 19 Apr 2024 19:02:57 -0700 Subject: [PATCH 412/551] Add SYNCED metric --- Cargo.lock | 1 + node/metrics/src/names.rs | 4 +++- node/sync/Cargo.toml | 5 +++++ node/sync/src/block_sync.rs | 3 +++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 85b2d7171a..e4e66038d3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3246,6 +3246,7 @@ dependencies = [ "rand", "serde", "snarkos-node-bft-ledger-service", + "snarkos-node-metrics", "snarkos-node-router", "snarkos-node-sync-communication-service", "snarkos-node-sync-locators", diff --git a/node/metrics/src/names.rs b/node/metrics/src/names.rs index 3214a992f8..a85713622b 100644 --- a/node/metrics/src/names.rs +++ b/node/metrics/src/names.rs @@ -14,7 +14,7 @@ pub(super) const COUNTER_NAMES: [&str; 2] = [bft::LEADERS_ELECTED, consensus::STALE_UNCONFIRMED_TRANSMISSIONS]; -pub(super) const GAUGE_NAMES: [&str; 25] = [ +pub(super) const GAUGE_NAMES: [&str; 26] = [ bft::CONNECTED, bft::CONNECTING, bft::LAST_STORED_ROUND, @@ -22,6 +22,7 @@ pub(super) const GAUGE_NAMES: [&str; 25] = [ bft::CERTIFIED_BATCHES, bft::HEIGHT, bft::LAST_COMMITTED_ROUND, + bft::SYNCED, blocks::SOLUTIONS, blocks::TRANSACTIONS, blocks::ACCEPTED_DEPLOY, @@ -55,6 +56,7 @@ pub mod bft { pub const CERTIFIED_BATCHES: &str = "snarkos_bft_primary_certified_batches"; pub const HEIGHT: &str = "snarkos_bft_height_total"; pub const LAST_COMMITTED_ROUND: &str = "snarkos_bft_last_committed_round"; + pub const SYNCED: &str = "snarkos_bft_synced_total"; } pub mod blocks { diff --git a/node/sync/Cargo.toml b/node/sync/Cargo.toml index 491dfb6557..b53b0a4375 100644 --- a/node/sync/Cargo.toml +++ b/node/sync/Cargo.toml @@ -47,6 +47,11 @@ path = "../bft/ledger-service" version = "=2.2.7" features = [ "ledger-write" ] +[dependencies.snarkos-node-metrics] +path = "../metrics" +version = "=2.2.7" +optional = true + [dependencies.snarkos-node-router] path = "../router" version = "=2.2.7" diff --git a/node/sync/src/block_sync.rs b/node/sync/src/block_sync.rs index 403315fb04..e0913ba8d0 100644 --- a/node/sync/src/block_sync.rs +++ b/node/sync/src/block_sync.rs @@ -17,6 +17,7 @@ use crate::{ locators::BlockLocators, }; use snarkos_node_bft_ledger_service::LedgerService; +use snarkos_node_metrics as metrics; use snarkos_node_router::messages::DataBlocks; use snarkos_node_sync_communication_service::CommunicationService; use snarkos_node_sync_locators::{CHECKPOINT_INTERVAL, NUM_RECENT_BLOCKS}; @@ -345,6 +346,8 @@ impl BlockSync { } // Update the latest height. current_height = self.canon.latest_block_height(); + // Update the `SYNCED` metric. + metrics::increment_gauge(metrics::bft::SYNCED, 1); } } } From e94b8b0d269618ae645fd9ee971a8d532e2b37da Mon Sep 17 00:00:00 2001 From: Pranav Gaddamadugu <23022326+d0cd@users.noreply.github.com> Date: Fri, 19 Apr 2024 19:25:42 -0700 Subject: [PATCH 413/551] Update SYNCED metric for validators --- node/bft/src/sync/mod.rs | 8 ++++++++ node/sync/Cargo.toml | 4 +++- node/sync/src/block_sync.rs | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index ec16ecc613..b92d0801fb 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -321,6 +321,10 @@ impl Sync { // Sync the round with the block. self_.storage.sync_round_with_block(block.round()); + // Update the `SYNCED` metric. + #[cfg(feature = "metrics")] + metrics::increment_gauge(metrics::bft::SYNCED, 1); + Ok(()) }) .await? @@ -372,6 +376,10 @@ impl Sync { // Sync the round with the block. self_.storage.sync_round_with_block(block.round()); + // Update the `SYNCED` metric. + #[cfg(feature = "metrics")] + metrics::increment_gauge(metrics::bft::SYNCED, 1); + Ok(()) }) .await? diff --git a/node/sync/Cargo.toml b/node/sync/Cargo.toml index b53b0a4375..f2b309e43f 100644 --- a/node/sync/Cargo.toml +++ b/node/sync/Cargo.toml @@ -18,6 +18,7 @@ edition = "2021" [features] default = [ ] +metrics = [ "dep:metrics" ] test = [ "snarkos-node-sync-locators/test" ] [dependencies.anyhow] @@ -47,7 +48,8 @@ path = "../bft/ledger-service" version = "=2.2.7" features = [ "ledger-write" ] -[dependencies.snarkos-node-metrics] +[dependencies.metrics] +package = "snarkos-node-metrics" path = "../metrics" version = "=2.2.7" optional = true diff --git a/node/sync/src/block_sync.rs b/node/sync/src/block_sync.rs index e0913ba8d0..a8420f4e69 100644 --- a/node/sync/src/block_sync.rs +++ b/node/sync/src/block_sync.rs @@ -17,7 +17,6 @@ use crate::{ locators::BlockLocators, }; use snarkos_node_bft_ledger_service::LedgerService; -use snarkos_node_metrics as metrics; use snarkos_node_router::messages::DataBlocks; use snarkos_node_sync_communication_service::CommunicationService; use snarkos_node_sync_locators::{CHECKPOINT_INTERVAL, NUM_RECENT_BLOCKS}; @@ -347,6 +346,7 @@ impl BlockSync { // Update the latest height. current_height = self.canon.latest_block_height(); // Update the `SYNCED` metric. + #[cfg(feature = "metrics")] metrics::increment_gauge(metrics::bft::SYNCED, 1); } } From d9bd0db4a8b4ced5da5d9d7ef928fa38f6a85b31 Mon Sep 17 00:00:00 2001 From: Pranav Gaddamadugu <23022326+d0cd@users.noreply.github.com> Date: Mon, 22 Apr 2024 11:25:18 -0700 Subject: [PATCH 414/551] Update metric to IS_SYNCED --- node/bft/src/sync/mod.rs | 8 -------- node/metrics/src/names.rs | 4 ++-- node/sync/src/block_sync.rs | 6 +++--- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index b92d0801fb..ec16ecc613 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -321,10 +321,6 @@ impl Sync { // Sync the round with the block. self_.storage.sync_round_with_block(block.round()); - // Update the `SYNCED` metric. - #[cfg(feature = "metrics")] - metrics::increment_gauge(metrics::bft::SYNCED, 1); - Ok(()) }) .await? @@ -376,10 +372,6 @@ impl Sync { // Sync the round with the block. self_.storage.sync_round_with_block(block.round()); - // Update the `SYNCED` metric. - #[cfg(feature = "metrics")] - metrics::increment_gauge(metrics::bft::SYNCED, 1); - Ok(()) }) .await? diff --git a/node/metrics/src/names.rs b/node/metrics/src/names.rs index a85713622b..7fcb8e2fa8 100644 --- a/node/metrics/src/names.rs +++ b/node/metrics/src/names.rs @@ -22,7 +22,7 @@ pub(super) const GAUGE_NAMES: [&str; 26] = [ bft::CERTIFIED_BATCHES, bft::HEIGHT, bft::LAST_COMMITTED_ROUND, - bft::SYNCED, + bft::IS_SYNCED, blocks::SOLUTIONS, blocks::TRANSACTIONS, blocks::ACCEPTED_DEPLOY, @@ -56,7 +56,7 @@ pub mod bft { pub const CERTIFIED_BATCHES: &str = "snarkos_bft_primary_certified_batches"; pub const HEIGHT: &str = "snarkos_bft_height_total"; pub const LAST_COMMITTED_ROUND: &str = "snarkos_bft_last_committed_round"; - pub const SYNCED: &str = "snarkos_bft_synced_total"; + pub const IS_SYNCED: &str = "snarkos_bft_is_synced"; } pub mod blocks { diff --git a/node/sync/src/block_sync.rs b/node/sync/src/block_sync.rs index a8420f4e69..d1a510da02 100644 --- a/node/sync/src/block_sync.rs +++ b/node/sync/src/block_sync.rs @@ -345,9 +345,6 @@ impl BlockSync { } // Update the latest height. current_height = self.canon.latest_block_height(); - // Update the `SYNCED` metric. - #[cfg(feature = "metrics")] - metrics::increment_gauge(metrics::bft::SYNCED, 1); } } } @@ -464,6 +461,9 @@ impl BlockSync { let is_synced = num_blocks_behind <= max_blocks_behind; // Update the sync status. self.is_block_synced.store(is_synced, Ordering::SeqCst); + // Update the `IS_SYNCED` metric. + #[cfg(feature = "metrics")] + metrics::gauge(metrics::bft::IS_SYNCED, is_synced); } /// Inserts a block request for the given height. From 8c983e0a575bfbe5dbe017f78442770edc4d75db Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 22 Apr 2024 18:51:37 -0400 Subject: [PATCH 415/551] Perform block advancement after quorum check --- node/bft/src/sync/mod.rs | 80 +++++++++++++++++++++++++++++++--------- 1 file changed, 62 insertions(+), 18 deletions(-) diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index ec16ecc613..0e1bf2acdc 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -293,11 +293,69 @@ impl Sync { } } + // Track the previous block. + let mut previous_block = None; // Try to advance the ledger with sync blocks. while let Some(block) = self.block_sync.process_next_block(current_height) { info!("Syncing the BFT to block {}...", block.height()); // Sync the storage with the block. - self.sync_storage_with_block(block).await?; + self.sync_storage_with_block(&block).await?; + + // Check if the previous block is ready to be added to the ledger. + // Ensure that the previous block's leader certificate meets the quorum threshold based + // on the certificates in the current block. + // Note: We do not advance to the last block in the loop because we would be unable to + // validate if the leader certificate in the block has been certified properly. + if let Some(previous_block) = previous_block.replace(block) { + // Retrieve the subdag from the block. + let Authority::Quorum(subdag) = previous_block.authority() else { + bail!("Received a block with an unexpected authority type"); + }; + + // Fetch the leader certificate and the relevant rounds. + let leader_certificate = subdag.leader_certificate(); + let commit_round = leader_certificate.round(); + let certificate_round = commit_round.saturating_add(1); + + // Get the committee lookback for the commit round. + let committee_lookback = self.ledger.get_committee_lookback_for_round(commit_round)?; + // Retrieve all of the certificates for the **certificate** round. + let certificates = self.storage.get_certificates_for_round(certificate_round); + // Construct a set over the authors who included the leader's certificate in the certificate round. + let authors = certificates + .iter() + .filter_map(|c| match c.previous_certificate_ids().contains(&leader_certificate.id()) { + true => Some(c.author()), + false => None, + }) + .collect(); + + // Check if the leader is ready to be committed. + match committee_lookback.is_quorum_threshold_reached(&authors) { + // Advance to the next block if quorum threshold was reached. + true => { + let self_ = self.clone(); + tokio::task::spawn_blocking(move || { + // Check the next block. + self_.ledger.check_next_block(&previous_block)?; + // Attempt to advance to the next block. + self_.ledger.advance_to_next_block(&previous_block)?; + + // Sync the height with the block. + self_.storage.sync_height_with_block(previous_block.height()); + // Sync the round with the block. + self_.storage.sync_round_with_block(previous_block.round()); + + Ok::<(), anyhow::Error>(()) + }) + .await??; + } + false => { + bail!("Quorum was not reached for block {} at round {commit_round}", previous_block.height()) + } + } + } + // Update the current height. current_height += 1; } @@ -327,7 +385,7 @@ impl Sync { } /// Syncs the storage with the given blocks. - pub async fn sync_storage_with_block(&self, block: Block) -> Result<()> { + pub async fn sync_storage_with_block(&self, block: &Block) -> Result<()> { // Acquire the sync lock. let _lock = self.sync_lock.lock().await; @@ -344,7 +402,7 @@ impl Sync { for certificates in subdag.values().cloned() { cfg_into_iter!(certificates.clone()).for_each(|certificate| { // Sync the batch certificate with the block. - self.storage.sync_certificate_with_block(&block, certificate.clone(), &unconfirmed_transactions); + self.storage.sync_certificate_with_block(block, certificate.clone(), &unconfirmed_transactions); }); // Sync the BFT DAG with the certificates. @@ -360,21 +418,7 @@ impl Sync { } } - let self_ = self.clone(); - tokio::task::spawn_blocking(move || { - // Check the next block. - self_.ledger.check_next_block(&block)?; - // Attempt to advance to the next block. - self_.ledger.advance_to_next_block(&block)?; - - // Sync the height with the block. - self_.storage.sync_height_with_block(block.height()); - // Sync the round with the block. - self_.storage.sync_round_with_block(block.round()); - - Ok(()) - }) - .await? + Ok(()) } } From da40a7b5714647669a0ce09a7c5b4047cc6de59f Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 22 Apr 2024 20:49:14 -0400 Subject: [PATCH 416/551] Cleanup and add tracker for latest block --- node/bft/src/sync/mod.rs | 134 +++++++++++++++++++++------------------ 1 file changed, 73 insertions(+), 61 deletions(-) diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index 0e1bf2acdc..aeaac62b99 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -57,6 +57,8 @@ pub struct Sync { response_lock: Arc>, /// The sync lock. sync_lock: Arc>, + /// The latest block received by a peer. + latest_block_response: Arc>>>, } impl Sync { @@ -75,6 +77,7 @@ impl Sync { handles: Default::default(), response_lock: Default::default(), sync_lock: Default::default(), + latest_block_response: Default::default(), } } @@ -107,6 +110,11 @@ impl Sync { if let Err(e) = self_.sync_storage_with_blocks().await { error!("Unable to sync storage with blocks - {e}"); } + + // If the node is synced, clear the `latest_block_response`. + if self_.is_synced() { + *self_.latest_block_response.lock().await = None; + } } })); @@ -293,69 +301,11 @@ impl Sync { } } - // Track the previous block. - let mut previous_block = None; // Try to advance the ledger with sync blocks. while let Some(block) = self.block_sync.process_next_block(current_height) { info!("Syncing the BFT to block {}...", block.height()); // Sync the storage with the block. - self.sync_storage_with_block(&block).await?; - - // Check if the previous block is ready to be added to the ledger. - // Ensure that the previous block's leader certificate meets the quorum threshold based - // on the certificates in the current block. - // Note: We do not advance to the last block in the loop because we would be unable to - // validate if the leader certificate in the block has been certified properly. - if let Some(previous_block) = previous_block.replace(block) { - // Retrieve the subdag from the block. - let Authority::Quorum(subdag) = previous_block.authority() else { - bail!("Received a block with an unexpected authority type"); - }; - - // Fetch the leader certificate and the relevant rounds. - let leader_certificate = subdag.leader_certificate(); - let commit_round = leader_certificate.round(); - let certificate_round = commit_round.saturating_add(1); - - // Get the committee lookback for the commit round. - let committee_lookback = self.ledger.get_committee_lookback_for_round(commit_round)?; - // Retrieve all of the certificates for the **certificate** round. - let certificates = self.storage.get_certificates_for_round(certificate_round); - // Construct a set over the authors who included the leader's certificate in the certificate round. - let authors = certificates - .iter() - .filter_map(|c| match c.previous_certificate_ids().contains(&leader_certificate.id()) { - true => Some(c.author()), - false => None, - }) - .collect(); - - // Check if the leader is ready to be committed. - match committee_lookback.is_quorum_threshold_reached(&authors) { - // Advance to the next block if quorum threshold was reached. - true => { - let self_ = self.clone(); - tokio::task::spawn_blocking(move || { - // Check the next block. - self_.ledger.check_next_block(&previous_block)?; - // Attempt to advance to the next block. - self_.ledger.advance_to_next_block(&previous_block)?; - - // Sync the height with the block. - self_.storage.sync_height_with_block(previous_block.height()); - // Sync the round with the block. - self_.storage.sync_round_with_block(previous_block.round()); - - Ok::<(), anyhow::Error>(()) - }) - .await??; - } - false => { - bail!("Quorum was not reached for block {} at round {commit_round}", previous_block.height()) - } - } - } - + self.sync_storage_with_block(block).await?; // Update the current height. current_height += 1; } @@ -385,9 +335,11 @@ impl Sync { } /// Syncs the storage with the given blocks. - pub async fn sync_storage_with_block(&self, block: &Block) -> Result<()> { + pub async fn sync_storage_with_block(&self, block: Block) -> Result<()> { // Acquire the sync lock. let _lock = self.sync_lock.lock().await; + // Acquire the latest block response lock. + let mut latest_block_response = self.latest_block_response.lock().await; // If the block authority is a subdag, then sync the batch certificates with the block. if let Authority::Quorum(subdag) = block.authority() { @@ -402,7 +354,7 @@ impl Sync { for certificates in subdag.values().cloned() { cfg_into_iter!(certificates.clone()).for_each(|certificate| { // Sync the batch certificate with the block. - self.storage.sync_certificate_with_block(block, certificate.clone(), &unconfirmed_transactions); + self.storage.sync_certificate_with_block(&block, certificate.clone(), &unconfirmed_transactions); }); // Sync the BFT DAG with the certificates. @@ -418,6 +370,66 @@ impl Sync { } } + // Check if the previous block is ready to be added to the ledger. + // Ensure that the previous block's leader certificate meets the quorum threshold based + // on the certificates in the current block. + // Note: We do not advance to the last block in the loop because we would be unable to + // validate if the leader certificate in the block has been certified properly. + if let Some(previous_block) = latest_block_response.replace(block) { + // Return early if this block has already been processed. + if self.ledger.contains_block_height(previous_block.height()) { + return Ok(()); + } + + // Retrieve the subdag from the block. + let Authority::Quorum(subdag) = previous_block.authority() else { + bail!("Received a block with an unexpected authority type"); + }; + + // Fetch the leader certificate and the relevant rounds. + let leader_certificate = subdag.leader_certificate(); + let commit_round = leader_certificate.round(); + let certificate_round = commit_round.saturating_add(1); + + // Get the committee lookback for the commit round. + let committee_lookback = self.ledger.get_committee_lookback_for_round(commit_round)?; + // Retrieve all of the certificates for the **certificate** round. + let certificates = self.storage.get_certificates_for_round(certificate_round); + // Construct a set over the authors who included the leader's certificate in the certificate round. + let authors = certificates + .iter() + .filter_map(|c| match c.previous_certificate_ids().contains(&leader_certificate.id()) { + true => Some(c.author()), + false => None, + }) + .collect(); + + // Check if the leader is ready to be committed. + match committee_lookback.is_quorum_threshold_reached(&authors) { + // Advance to the next block if quorum threshold was reached. + true => { + let self_ = self.clone(); + tokio::task::spawn_blocking(move || { + // Check the next block. + self_.ledger.check_next_block(&previous_block)?; + // Attempt to advance to the next block. + self_.ledger.advance_to_next_block(&previous_block)?; + + // Sync the height with the block. + self_.storage.sync_height_with_block(previous_block.height()); + // Sync the round with the block. + self_.storage.sync_round_with_block(previous_block.round()); + + Ok::<(), anyhow::Error>(()) + }) + .await??; + } + false => { + bail!("Quorum was not reached for block {} at round {commit_round}", previous_block.height()) + } + } + } + Ok(()) } } From 14eadb4484ee0b36f7422e10345bad114749cb1d Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 22 Apr 2024 21:08:29 -0400 Subject: [PATCH 417/551] Nit --- node/bft/src/sync/mod.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index aeaac62b99..f95d048135 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -57,8 +57,8 @@ pub struct Sync { response_lock: Arc>, /// The sync lock. sync_lock: Arc>, - /// The latest block received by a peer. - latest_block_response: Arc>>>, + /// The last block response. + last_block_response: Arc>>>, } impl Sync { @@ -77,7 +77,7 @@ impl Sync { handles: Default::default(), response_lock: Default::default(), sync_lock: Default::default(), - latest_block_response: Default::default(), + last_block_response: Default::default(), } } @@ -113,7 +113,7 @@ impl Sync { // If the node is synced, clear the `latest_block_response`. if self_.is_synced() { - *self_.latest_block_response.lock().await = None; + *self_.last_block_response.lock().await = None; } } })); @@ -339,7 +339,7 @@ impl Sync { // Acquire the sync lock. let _lock = self.sync_lock.lock().await; // Acquire the latest block response lock. - let mut latest_block_response = self.latest_block_response.lock().await; + let mut latest_block_response = self.last_block_response.lock().await; // If the block authority is a subdag, then sync the batch certificates with the block. if let Authority::Quorum(subdag) = block.authority() { @@ -376,7 +376,7 @@ impl Sync { // Note: We do not advance to the last block in the loop because we would be unable to // validate if the leader certificate in the block has been certified properly. if let Some(previous_block) = latest_block_response.replace(block) { - // Return early if this block has already been processed. + // Return early if this block has already been processed or is not the next block to add. if self.ledger.contains_block_height(previous_block.height()) { return Ok(()); } From aebc0906c0d5feefb16a542b2073c6d589d2a0b2 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 22 Apr 2024 21:09:21 -0400 Subject: [PATCH 418/551] nit comment --- node/bft/src/sync/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index f95d048135..3e60343058 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -376,7 +376,7 @@ impl Sync { // Note: We do not advance to the last block in the loop because we would be unable to // validate if the leader certificate in the block has been certified properly. if let Some(previous_block) = latest_block_response.replace(block) { - // Return early if this block has already been processed or is not the next block to add. + // Return early if this block has already been processed. if self.ledger.contains_block_height(previous_block.height()) { return Ok(()); } From e7e7c5af5160d0f43b2b864985af3a432a121eca Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 22 Apr 2024 21:10:55 -0400 Subject: [PATCH 419/551] Use last block response --- node/bft/src/sync/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index 3e60343058..159c00c000 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -111,7 +111,7 @@ impl Sync { error!("Unable to sync storage with blocks - {e}"); } - // If the node is synced, clear the `latest_block_response`. + // If the node is synced, clear the `last_block_response`. if self_.is_synced() { *self_.last_block_response.lock().await = None; } @@ -338,8 +338,8 @@ impl Sync { pub async fn sync_storage_with_block(&self, block: Block) -> Result<()> { // Acquire the sync lock. let _lock = self.sync_lock.lock().await; - // Acquire the latest block response lock. - let mut latest_block_response = self.last_block_response.lock().await; + // Acquire the last block response lock. + let mut last_block_response = self.last_block_response.lock().await; // If the block authority is a subdag, then sync the batch certificates with the block. if let Authority::Quorum(subdag) = block.authority() { @@ -375,7 +375,7 @@ impl Sync { // on the certificates in the current block. // Note: We do not advance to the last block in the loop because we would be unable to // validate if the leader certificate in the block has been certified properly. - if let Some(previous_block) = latest_block_response.replace(block) { + if let Some(previous_block) = last_block_response.replace(block) { // Return early if this block has already been processed. if self.ledger.contains_block_height(previous_block.height()) { return Ok(()); From a95e6c7dce7e75f1bc5b9f46c9d76375c5471687 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 22 Apr 2024 21:53:35 -0400 Subject: [PATCH 420/551] Update logs and add check --- node/bft/src/sync/mod.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index 159c00c000..2a0528bde4 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -376,8 +376,10 @@ impl Sync { // Note: We do not advance to the last block in the loop because we would be unable to // validate if the leader certificate in the block has been certified properly. if let Some(previous_block) = last_block_response.replace(block) { - // Return early if this block has already been processed. - if self.ledger.contains_block_height(previous_block.height()) { + // Return early if this block has already been processed or is not the next block to add. + if self.ledger.contains_block_height(previous_block.height()) + || self.ledger.latest_block_height().saturating_add(1) != previous_block.height() + { return Ok(()); } @@ -425,7 +427,8 @@ impl Sync { .await??; } false => { - bail!("Quorum was not reached for block {} at round {commit_round}", previous_block.height()) + debug!("Quorum was not reached for block {} at round {commit_round}", previous_block.height()); + return Ok(()); } } } From 37695419bac73eb946b119dcdff4027f34ceb404 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 23 Apr 2024 10:52:07 -0400 Subject: [PATCH 421/551] Use availability threshold --- node/bft/src/sync/mod.rs | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index 2a0528bde4..b6ef1e4224 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -370,21 +370,23 @@ impl Sync { } } - // Check if the previous block is ready to be added to the ledger. - // Ensure that the previous block's leader certificate meets the quorum threshold based - // on the certificates in the current block. - // Note: We do not advance to the last block in the loop because we would be unable to + // Check if the last block response is ready to be added to the ledger. + // Ensure that the previous block's leader certificate meets the availability threshold + // based on the certificates in the current block. + // Note: We do not advance to the most recent block response because we would be unable to // validate if the leader certificate in the block has been certified properly. - if let Some(previous_block) = last_block_response.replace(block) { + if let Some(last_block) = last_block_response.replace(block) { + // Retrieve the height of the last block. + let last_block_height = last_block.height(); // Return early if this block has already been processed or is not the next block to add. - if self.ledger.contains_block_height(previous_block.height()) - || self.ledger.latest_block_height().saturating_add(1) != previous_block.height() + if self.ledger.contains_block_height(last_block_height) + || self.ledger.latest_block_height().saturating_add(1) != last_block_height { return Ok(()); } // Retrieve the subdag from the block. - let Authority::Quorum(subdag) = previous_block.authority() else { + let Authority::Quorum(subdag) = last_block.authority() else { bail!("Received a block with an unexpected authority type"); }; @@ -407,27 +409,29 @@ impl Sync { .collect(); // Check if the leader is ready to be committed. - match committee_lookback.is_quorum_threshold_reached(&authors) { + match committee_lookback.is_availability_threshold_reached(&authors) { // Advance to the next block if quorum threshold was reached. true => { let self_ = self.clone(); tokio::task::spawn_blocking(move || { // Check the next block. - self_.ledger.check_next_block(&previous_block)?; + self_.ledger.check_next_block(&last_block)?; // Attempt to advance to the next block. - self_.ledger.advance_to_next_block(&previous_block)?; + self_.ledger.advance_to_next_block(&last_block)?; // Sync the height with the block. - self_.storage.sync_height_with_block(previous_block.height()); + self_.storage.sync_height_with_block(last_block.height()); // Sync the round with the block. - self_.storage.sync_round_with_block(previous_block.round()); + self_.storage.sync_round_with_block(last_block.round()); Ok::<(), anyhow::Error>(()) }) .await??; } false => { - debug!("Quorum was not reached for block {} at round {commit_round}", previous_block.height()); + debug!( + "Availability threshold was not reached for block {last_block_height} at round {commit_round}", + ); return Ok(()); } } From 88a70b96c6c0bc78846dbfa8e1a9da7da12a77a0 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 23 Apr 2024 22:49:07 -0400 Subject: [PATCH 422/551] Add is_linked checks during sync --- node/bft/src/sync/mod.rs | 131 ++++++++++++++++++++++++++++----------- 1 file changed, 95 insertions(+), 36 deletions(-) diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index b6ef1e4224..594fcf1202 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -57,8 +57,8 @@ pub struct Sync { response_lock: Arc>, /// The sync lock. sync_lock: Arc>, - /// The last block response. - last_block_response: Arc>>>, + /// The latest block responses. + latest_block_responses: Arc>>>, } impl Sync { @@ -77,7 +77,7 @@ impl Sync { handles: Default::default(), response_lock: Default::default(), sync_lock: Default::default(), - last_block_response: Default::default(), + latest_block_responses: Default::default(), } } @@ -111,9 +111,9 @@ impl Sync { error!("Unable to sync storage with blocks - {e}"); } - // If the node is synced, clear the `last_block_response`. + // If the node is synced, clear the `latest_block_responses`. if self_.is_synced() { - *self_.last_block_response.lock().await = None; + self_.latest_block_responses.lock().await.clear(); } } })); @@ -338,8 +338,13 @@ impl Sync { pub async fn sync_storage_with_block(&self, block: Block) -> Result<()> { // Acquire the sync lock. let _lock = self.sync_lock.lock().await; - // Acquire the last block response lock. - let mut last_block_response = self.last_block_response.lock().await; + // Acquire the latest block responses lock. + let mut latest_block_responses = self.latest_block_responses.lock().await; + + // If this block has already been processed, return early. + if self.ledger.contains_block_height(block.height()) || latest_block_responses.contains_key(&block.height()) { + return Ok(()); + } // If the block authority is a subdag, then sync the batch certificates with the block. if let Authority::Quorum(subdag) = block.authority() { @@ -370,28 +375,36 @@ impl Sync { } } - // Check if the last block response is ready to be added to the ledger. + // Fetch the latest block height. + let latest_block_height = self.ledger.latest_block_height(); + let next_block_height = latest_block_height.saturating_add(1); + + // Insert the latest block response. + latest_block_responses.insert(block.height(), block); + // Clear the latest block responses of older blocks. + latest_block_responses.retain(|height, _| *height > latest_block_height); + + // Get a list of contiguous blocks from the latest block responses. + let contiguous_blocks: Vec> = (next_block_height..) + .take_while(|&k| latest_block_responses.contains_key(&k)) + .filter_map(|k| latest_block_responses.get(&k).cloned()) + .collect(); + + // Check if the block response is ready to be added to the ledger. // Ensure that the previous block's leader certificate meets the availability threshold // based on the certificates in the current block. + // If the availability threshold is not met, process the next block and check if it is linked to the current block. // Note: We do not advance to the most recent block response because we would be unable to // validate if the leader certificate in the block has been certified properly. - if let Some(last_block) = last_block_response.replace(block) { - // Retrieve the height of the last block. - let last_block_height = last_block.height(); - // Return early if this block has already been processed or is not the next block to add. - if self.ledger.contains_block_height(last_block_height) - || self.ledger.latest_block_height().saturating_add(1) != last_block_height - { - return Ok(()); - } - - // Retrieve the subdag from the block. - let Authority::Quorum(subdag) = last_block.authority() else { - bail!("Received a block with an unexpected authority type"); - }; + for next_block in contiguous_blocks.into_iter() { + // Retrieve the height of the next block. + let next_block_height = next_block.height(); // Fetch the leader certificate and the relevant rounds. - let leader_certificate = subdag.leader_certificate(); + let leader_certificate = match next_block.authority() { + Authority::Quorum(subdag) => subdag.leader_certificate().clone(), + _ => bail!("Received a block with an unexpected authority type."), + }; let commit_round = leader_certificate.round(); let certificate_round = commit_round.saturating_add(1); @@ -409,36 +422,82 @@ impl Sync { .collect(); // Check if the leader is ready to be committed. - match committee_lookback.is_availability_threshold_reached(&authors) { - // Advance to the next block if quorum threshold was reached. - true => { + if committee_lookback.is_availability_threshold_reached(&authors) { + // Initialize the current certificate. + let mut current_certificate = leader_certificate; + // Check if there are any linked blocks that need to be added. + let mut blocks_to_add = vec![next_block]; + + // Check if there are other blocks to process based on `is_linked`. + for height in (self.ledger.latest_block_height().saturating_add(1)..next_block_height).rev() { + // Retrieve the previous block. + let previous_block = match latest_block_responses.get(&height) { + Some(block) => block, + None => bail!("Block {height} is missing from the latest block responses."), + }; + // Retrieve the previous certificate. + let previous_certificate = match previous_block.authority() { + Authority::Quorum(subdag) => subdag.leader_certificate().clone(), + _ => bail!("Received a block with an unexpected authority type."), + }; + // Determine if there is a path between the previous certificate and the current certificate. + if self.is_linked(previous_certificate.clone(), current_certificate.clone())? { + // Add the previous leader certificate to the list of certificates to commit. + blocks_to_add.insert(0, previous_block.clone()); + // Update the current certificate to the previous leader certificate. + current_certificate = previous_certificate; + } + } + + // Add the blocks to the ledger. + for block in blocks_to_add { + let block_height = block.height(); let self_ = self.clone(); tokio::task::spawn_blocking(move || { // Check the next block. - self_.ledger.check_next_block(&last_block)?; + self_.ledger.check_next_block(&block)?; // Attempt to advance to the next block. - self_.ledger.advance_to_next_block(&last_block)?; + self_.ledger.advance_to_next_block(&block)?; // Sync the height with the block. - self_.storage.sync_height_with_block(last_block.height()); + self_.storage.sync_height_with_block(block.height()); // Sync the round with the block. - self_.storage.sync_round_with_block(last_block.round()); + self_.storage.sync_round_with_block(block.round()); Ok::<(), anyhow::Error>(()) }) .await??; + // Remove the block height from the latest block responses. + latest_block_responses.remove(&block_height); } - false => { - debug!( - "Availability threshold was not reached for block {last_block_height} at round {commit_round}", - ); - return Ok(()); - } + } else { + trace!("Availability threshold was not reached for block {next_block_height} at round {commit_round}"); } } Ok(()) } + + /// Returns `true` if there is a path from the previous certificate to the current certificate. + fn is_linked( + &self, + previous_certificate: BatchCertificate, + current_certificate: BatchCertificate, + ) -> Result { + // Initialize the list containing the traversal. + let mut traversal = vec![current_certificate.clone()]; + // Iterate over the rounds from the current certificate to the previous certificate. + for round in (previous_certificate.round()..current_certificate.round()).rev() { + // Retrieve all of the certificates for this past round. + let certificates = self.storage.get_certificates_for_round(round); + // Filter the certificates to only include those that are in the traversal. + traversal = certificates + .into_iter() + .filter(|p| traversal.iter().any(|c| c.previous_certificate_ids().contains(&p.id()))) + .collect(); + } + Ok(traversal.contains(&previous_certificate)) + } } // Methods to assist with the block sync module. From f46499172d8f5d7c0e3fb03c48c53d213c12ece4 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 23 Apr 2024 23:04:39 -0400 Subject: [PATCH 423/551] Clear latest block responses on faulty blocks --- node/bft/src/sync/mod.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index 594fcf1202..6a7cba2a40 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -451,7 +451,14 @@ impl Sync { // Add the blocks to the ledger. for block in blocks_to_add { + // Check that the blocks are sequential and can be added to the ledger. let block_height = block.height(); + if block_height != self.ledger.latest_block_height().saturating_add(1) { + debug!("Removing block {block_height} from the latest block responses - not sequential."); + latest_block_responses.remove(&block_height); + continue; + } + let self_ = self.clone(); tokio::task::spawn_blocking(move || { // Check the next block. From 455078c0946b13f0de2e0fb966e18b3489779eeb Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 24 Apr 2024 11:31:24 -0400 Subject: [PATCH 424/551] Add logs --- node/bft/src/sync/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index 6a7cba2a40..2f6ee127c2 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -421,6 +421,7 @@ impl Sync { }) .collect(); + debug!("Validating sync block {next_block_height} at round {commit_round}..."); // Check if the leader is ready to be committed. if committee_lookback.is_availability_threshold_reached(&authors) { // Initialize the current certificate. @@ -442,6 +443,7 @@ impl Sync { }; // Determine if there is a path between the previous certificate and the current certificate. if self.is_linked(previous_certificate.clone(), current_certificate.clone())? { + debug!("Previous sync block {height} is linked to the current block {next_block_height}"); // Add the previous leader certificate to the list of certificates to commit. blocks_to_add.insert(0, previous_block.clone()); // Update the current certificate to the previous leader certificate. @@ -478,7 +480,9 @@ impl Sync { latest_block_responses.remove(&block_height); } } else { - trace!("Availability threshold was not reached for block {next_block_height} at round {commit_round}"); + debug!( + "Availability threshold was not reached for block {next_block_height} at round {commit_round}. Checking next block..." + ); } } From eedbd31e4bfca0a88aaa8f7f29c4944bbcc92403 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 24 Apr 2024 17:46:16 -0400 Subject: [PATCH 425/551] nits --- node/bft/src/sync/mod.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index 2f6ee127c2..48c5e1b23e 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -377,7 +377,6 @@ impl Sync { // Fetch the latest block height. let latest_block_height = self.ledger.latest_block_height(); - let next_block_height = latest_block_height.saturating_add(1); // Insert the latest block response. latest_block_responses.insert(block.height(), block); @@ -385,7 +384,7 @@ impl Sync { latest_block_responses.retain(|height, _| *height > latest_block_height); // Get a list of contiguous blocks from the latest block responses. - let contiguous_blocks: Vec> = (next_block_height..) + let contiguous_blocks: Vec> = (latest_block_height.saturating_add(1)..) .take_while(|&k| latest_block_responses.contains_key(&k)) .filter_map(|k| latest_block_responses.get(&k).cloned()) .collect(); @@ -432,9 +431,8 @@ impl Sync { // Check if there are other blocks to process based on `is_linked`. for height in (self.ledger.latest_block_height().saturating_add(1)..next_block_height).rev() { // Retrieve the previous block. - let previous_block = match latest_block_responses.get(&height) { - Some(block) => block, - None => bail!("Block {height} is missing from the latest block responses."), + let Some(previous_block) = latest_block_responses.get(&height) else { + bail!("Block {height} is missing from the latest block responses."); }; // Retrieve the previous certificate. let previous_certificate = match previous_block.authority() { @@ -456,8 +454,7 @@ impl Sync { // Check that the blocks are sequential and can be added to the ledger. let block_height = block.height(); if block_height != self.ledger.latest_block_height().saturating_add(1) { - debug!("Removing block {block_height} from the latest block responses - not sequential."); - latest_block_responses.remove(&block_height); + warn!("Skipping block {block_height} from the latest block responses - not sequential."); continue; } From 7d346351e0cb354027f50b8ddb70ef0596774b59 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 24 Apr 2024 18:11:30 -0400 Subject: [PATCH 426/551] Add is_block_synced checks to rest endpoints --- node/rest/src/lib.rs | 10 ++++++++++ node/rest/src/routes.rs | 19 +++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/node/rest/src/lib.rs b/node/rest/src/lib.rs index 8dfa2dd6ac..2ecf04e53b 100644 --- a/node/rest/src/lib.rs +++ b/node/rest/src/lib.rs @@ -224,3 +224,13 @@ async fn log_middleware( Ok(next.run(request).await) } + +/// Formats an ID into a truncated identifier (for logging purposes). +pub fn fmt_id(id: impl ToString) -> String { + let id = id.to_string(); + let mut formatted_id = id.chars().take(16).collect::(); + if id.chars().count() > 16 { + formatted_id.push_str(".."); + } + formatted_id +} diff --git a/node/rest/src/routes.rs b/node/rest/src/routes.rs index 2e6575d84f..5e3c21f2bd 100644 --- a/node/rest/src/routes.rs +++ b/node/rest/src/routes.rs @@ -313,6 +313,11 @@ impl, R: Routing> Rest { State(rest): State, Json(tx): Json>, ) -> Result { + // Do not process the transaction if the node is syncing. + if !rest.routing.is_block_synced() { + return Err(RestError(format!("Unable to broadcast transaction {} - node is syncing.", fmt_id(tx.id())))); + } + // If the consensus module is enabled, add the unconfirmed transaction to the memory pool. if let Some(consensus) = rest.consensus { // Add the unconfirmed transaction to the memory pool. @@ -337,6 +342,14 @@ impl, R: Routing> Rest { State(rest): State, Json(solution): Json>, ) -> Result { + // Do not process the solution if the node is syncing. + if !rest.routing.is_block_synced() { + return Err(RestError(format!( + "Unable to broadcast solution {} - node is syncing.", + fmt_id(solution.id()) + ))); + } + // If the consensus module is enabled, add the unconfirmed solution to the memory pool. // Otherwise, verify it prior to broadcasting. match rest.consensus { @@ -355,8 +368,10 @@ impl, R: Routing> Rest { .await { Ok(Ok(())) => {} - Ok(Err(err)) => return Err(RestError(format!("Invalid solution `{}` - {err}", solution.id()))), - Err(err) => return Err(RestError(format!("Invalid solution `{}` - {err}", solution.id()))), + Ok(Err(err)) => { + return Err(RestError(format!("Invalid solution `{}` - {err}", fmt_id(solution.id())))); + } + Err(err) => return Err(RestError(format!("Invalid solution `{}` - {err}", fmt_id(solution.id())))), } } } From 55c8a6e03b7000b12c71b2dfaf01bc8ecafd914c Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 24 Apr 2024 18:16:50 -0400 Subject: [PATCH 427/551] nits --- node/rest/src/routes.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/node/rest/src/routes.rs b/node/rest/src/routes.rs index 5e3c21f2bd..319c061a63 100644 --- a/node/rest/src/routes.rs +++ b/node/rest/src/routes.rs @@ -315,7 +315,7 @@ impl, R: Routing> Rest { ) -> Result { // Do not process the transaction if the node is syncing. if !rest.routing.is_block_synced() { - return Err(RestError(format!("Unable to broadcast transaction {} - node is syncing.", fmt_id(tx.id())))); + return Err(RestError(format!("Unable to broadcast transaction '{}' (node is syncing)", fmt_id(tx.id())))); } // If the consensus module is enabled, add the unconfirmed transaction to the memory pool. @@ -345,7 +345,7 @@ impl, R: Routing> Rest { // Do not process the solution if the node is syncing. if !rest.routing.is_block_synced() { return Err(RestError(format!( - "Unable to broadcast solution {} - node is syncing.", + "Unable to broadcast solution '{}' (node is syncing)", fmt_id(solution.id()) ))); } @@ -369,9 +369,9 @@ impl, R: Routing> Rest { { Ok(Ok(())) => {} Ok(Err(err)) => { - return Err(RestError(format!("Invalid solution `{}` - {err}", fmt_id(solution.id())))); + return Err(RestError(format!("Invalid solution '{}' - {err}", fmt_id(solution.id())))); } - Err(err) => return Err(RestError(format!("Invalid solution `{}` - {err}", fmt_id(solution.id())))), + Err(err) => return Err(RestError(format!("Invalid solution '{}' - {err}", fmt_id(solution.id())))), } } } From 4669e3d20f9257ee605f471e539cbbf7e6605b7a Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 24 Apr 2024 18:47:00 -0400 Subject: [PATCH 428/551] Bump snarkVM rev - aef07da --- .devnet/start_sync_test.sh | 59 +++++++++++++++++++ Cargo.lock | 118 ++++++++++++++++++------------------- Cargo.toml | 2 +- 3 files changed, 119 insertions(+), 60 deletions(-) create mode 100755 .devnet/start_sync_test.sh diff --git a/.devnet/start_sync_test.sh b/.devnet/start_sync_test.sh new file mode 100755 index 0000000000..6ca5fbb77a --- /dev/null +++ b/.devnet/start_sync_test.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +# Determine the number of AWS EC2 instances by checking ~/.ssh/config +NODE_ID=0 +while [ -n "$(grep "aws-n${NODE_ID}" ~/.ssh/config)" ]; do + NODE_ID=$((NODE_ID + 1)) +done + +# Read the number of AWS EC2 instances to query from the user +read -p "Enter the number of AWS EC2 instances to query (default: $NODE_ID): " NUM_INSTANCES +NUM_INSTANCES="${NUM_INSTANCES:-$NODE_ID}" + +echo "Using $NUM_INSTANCES AWS EC2 instances for querying." + +# Read the verbosity level from the user (default: 1) +read -p "Enter the verbosity level (default: 1): " VERBOSITY +VERBOSITY="${VERBOSITY:-1}" + +echo "Using verbosity level $VERBOSITY." + +# Get the IP address of NODE 0 from the SSH config for aws-n0 +NODE_0_IP=$(awk '/Host aws-n0/{f=1} f&&/HostName/{print $2; exit}' ~/.ssh/config) + +# Define a function to start snarkOS in a tmux session on a node +start_snarkos_in_tmux() { + local NODE_ID=$1 + local NODE_IP=$2 + + # SSH into the node and start snarkOS in a new tmux session + ssh -o StrictHostKeyChecking=no aws-n$NODE_ID << EOF + # Commands to run on the remote instance + sudo -i # Switch to root user + WORKSPACE=~/snarkOS + cd \$WORKSPACE + + # Start snarkOS within a new tmux session named "snarkos-session" + tmux new-session -d -s snarkos-session + + # Send the snarkOS start command to the tmux session with the NODE_ID + tmux send-keys -t "snarkos-session" "snarkos start --client --nocdn --nodisplay --rest 0.0.0.0:3030 --node 0.0.0.0:4130 --verbosity 4 --metrics --logfile "/tmp/snarkos-syncing-range-3.log" --peers 167.71.249.65:4130,157.245.218.195:4130,167.71.249.55:4130" C-m + + exit # Exit root user +EOF + + # Check the exit status of the SSH command + if [ $? -eq 0 ]; then + echo "snarkOS started successfully in a tmux session on aws-n$NODE_ID." + else + echo "Failed to start snarkOS in a tmux session on aws-n$NODE_ID." + fi +} + +# Loop through aws-n nodes and start snarkOS in tmux sessions in parallel +for NODE_ID in $(seq 0 $(($NUM_INSTANCES - 1))); do + start_snarkos_in_tmux $NODE_ID "$NODE_0_IP" & +done + +# Wait for all background jobs to finish +wait diff --git a/Cargo.lock b/Cargo.lock index e4e66038d3..47161b7847 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3292,7 +3292,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "anstyle", "anyhow", @@ -3323,7 +3323,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "aleo-std", "anyhow", @@ -3353,7 +3353,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3367,7 +3367,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3378,7 +3378,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3388,7 +3388,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3398,7 +3398,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "indexmap 2.2.6", "itertools 0.11.0", @@ -3416,12 +3416,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3432,7 +3432,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3447,7 +3447,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3462,7 +3462,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3475,7 +3475,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3484,7 +3484,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3494,7 +3494,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3506,7 +3506,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3518,7 +3518,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3529,7 +3529,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3541,7 +3541,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3554,7 +3554,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "bs58", "snarkvm-console-network", @@ -3565,7 +3565,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "blake2s_simd", "smallvec", @@ -3578,7 +3578,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "aleo-std", "rayon", @@ -3589,7 +3589,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "anyhow", "indexmap 2.2.6", @@ -3612,7 +3612,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "anyhow", "bech32", @@ -3630,7 +3630,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "enum_index", "enum_index_derive", @@ -3651,7 +3651,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3666,7 +3666,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3677,7 +3677,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "snarkvm-console-network-environment", ] @@ -3685,7 +3685,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3695,7 +3695,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3706,7 +3706,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3717,7 +3717,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3728,7 +3728,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3739,7 +3739,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "rand", "rayon", @@ -3753,7 +3753,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "aleo-std", "anyhow", @@ -3770,7 +3770,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "aleo-std", "anyhow", @@ -3795,7 +3795,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "anyhow", "rand", @@ -3807,7 +3807,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3826,7 +3826,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "anyhow", "indexmap 2.2.6", @@ -3845,7 +3845,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -3858,7 +3858,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3871,7 +3871,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3884,7 +3884,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "bytes", "serde_json", @@ -3895,7 +3895,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3910,7 +3910,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "bytes", "serde_json", @@ -3923,7 +3923,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "snarkvm-console", "snarkvm-ledger-puzzle", @@ -3932,7 +3932,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "aleo-std", "anyhow", @@ -3952,7 +3952,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle-epoch" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "anyhow", "colored", @@ -3967,7 +3967,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "async-trait", "reqwest", @@ -3980,7 +3980,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "aleo-std-storage", "anyhow", @@ -4006,7 +4006,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4021,7 +4021,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4030,7 +4030,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "aleo-std", "anyhow", @@ -4055,7 +4055,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "aleo-std", "anyhow", @@ -4084,7 +4084,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "aleo-std", "colored", @@ -4107,7 +4107,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "indexmap 2.2.6", "paste", @@ -4121,7 +4121,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "bincode", "once_cell", @@ -4134,7 +4134,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "aleo-std", "anyhow", @@ -4155,7 +4155,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=43abe1b#43abe1ba7cdb4de6a435905a1688cca4caf0c7e3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" dependencies = [ "proc-macro2", "quote 1.0.36", diff --git a/Cargo.toml b/Cargo.toml index afd6efcd79..d4e12cf020 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "43abe1b" +rev = "aef07da" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From 040631f410f99c6f997eb4a13e2809196b7a21ef Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 13 Mar 2024 18:02:19 -0700 Subject: [PATCH 429/551] Add tracker for num_blocks_behind --- node/bft/src/sync/mod.rs | 5 +++++ node/sync/src/block_sync.rs | 13 ++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index ec16ecc613..f1dc8db8eb 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -388,6 +388,11 @@ impl Sync { self.block_sync.is_block_synced() } + /// Returns the number of blocks the node is behind the greatest peer height. + pub fn num_blocks_behind(&self) -> u32 { + self.block_sync.num_blocks_behind() + } + /// Returns `true` if the node is in gateway mode. pub const fn is_gateway_mode(&self) -> bool { self.block_sync.mode().is_gateway() diff --git a/node/sync/src/block_sync.rs b/node/sync/src/block_sync.rs index d1a510da02..36535679f4 100644 --- a/node/sync/src/block_sync.rs +++ b/node/sync/src/block_sync.rs @@ -31,7 +31,7 @@ use std::{ collections::BTreeMap, net::{IpAddr, Ipv4Addr, SocketAddr}, sync::{ - atomic::{AtomicBool, Ordering}, + atomic::{AtomicBool, AtomicU32, Ordering}, Arc, }, time::Instant, @@ -106,6 +106,8 @@ pub struct BlockSync { request_timestamps: Arc>>, /// The boolean indicator of whether the node is synced up to the latest block (within the given tolerance). is_block_synced: Arc, + /// The number of blocks the peer is behind the greatest peer height. + num_blocks_behind: Arc, /// The lock to guarantee advance_with_sync_blocks() is called only once at a time. advance_with_sync_blocks_lock: Arc>, } @@ -122,6 +124,7 @@ impl BlockSync { responses: Default::default(), request_timestamps: Default::default(), is_block_synced: Default::default(), + num_blocks_behind: Default::default(), advance_with_sync_blocks_lock: Default::default(), } } @@ -137,6 +140,12 @@ impl BlockSync { pub fn is_block_synced(&self) -> bool { self.is_block_synced.load(Ordering::SeqCst) } + + /// Returns the number of blocks the node is behind the greatest peer height. + #[inline] + pub fn num_blocks_behind(&self) -> u32 { + self.num_blocks_behind.load(Ordering::SeqCst) + } } #[allow(dead_code)] @@ -459,6 +468,8 @@ impl BlockSync { let num_blocks_behind = greatest_peer_height.saturating_sub(canon_height); // Determine if the primary is synced. let is_synced = num_blocks_behind <= max_blocks_behind; + // Update the num blocks behind. + self.num_blocks_behind.store(num_blocks_behind, Ordering::SeqCst); // Update the sync status. self.is_block_synced.store(is_synced, Ordering::SeqCst); // Update the `IS_SYNCED` metric. From baf3d10972c1821eba49c6d2fcf2c4458bd9b508 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 25 Apr 2024 02:06:34 -0400 Subject: [PATCH 430/551] Add num_blocks_behind to Outbound --- node/router/src/outbound.rs | 3 +++ node/router/tests/common/router.rs | 5 +++++ node/src/client/router.rs | 5 +++++ node/src/prover/router.rs | 5 +++++ node/src/validator/router.rs | 5 +++++ 5 files changed, 23 insertions(+) diff --git a/node/router/src/outbound.rs b/node/router/src/outbound.rs index f3c419d70d..677db6db21 100644 --- a/node/router/src/outbound.rs +++ b/node/router/src/outbound.rs @@ -31,6 +31,9 @@ pub trait Outbound: Writing> { /// Returns `true` if the node is synced up to the latest block (within the given tolerance). fn is_block_synced(&self) -> bool; + /// Returns the number of blocks this node is behind its furthest peer. + fn num_blocks_behind(&self) -> u32; + /// Sends a "Ping" message to the given peer. fn send_ping(&self, peer_ip: SocketAddr, block_locators: Option>) { self.send(peer_ip, Message::Ping(Ping::new(self.router().node_type(), block_locators))); diff --git a/node/router/tests/common/router.rs b/node/router/tests/common/router.rs index 769e88f2bc..06c3f4c7d4 100644 --- a/node/router/tests/common/router.rs +++ b/node/router/tests/common/router.rs @@ -154,6 +154,11 @@ impl Outbound for TestRouter { fn is_block_synced(&self) -> bool { true } + + /// Returns the number of blocks this node is behind its furthest peer. + fn num_blocks_behind(&self) -> u32 { + 0 + } } #[async_trait] diff --git a/node/src/client/router.rs b/node/src/client/router.rs index 1245ec8265..93e8b3a5a2 100644 --- a/node/src/client/router.rs +++ b/node/src/client/router.rs @@ -168,6 +168,11 @@ impl> Outbound for Client { fn is_block_synced(&self) -> bool { self.sync.is_block_synced() } + + /// Returns the number of blocks this node is behind its furthest peer. + fn num_blocks_behind(&self) -> u32 { + self.sync.num_blocks_behind() + } } #[async_trait] diff --git a/node/src/prover/router.rs b/node/src/prover/router.rs index f2aff9bef7..3232f86502 100644 --- a/node/src/prover/router.rs +++ b/node/src/prover/router.rs @@ -140,6 +140,11 @@ impl> Outbound for Prover { fn is_block_synced(&self) -> bool { true } + + /// Returns the number of blocks this node is behind its furthest peer. + fn num_blocks_behind(&self) -> u32 { + 0 + } } #[async_trait] diff --git a/node/src/validator/router.rs b/node/src/validator/router.rs index 4976f85438..cda8a32391 100644 --- a/node/src/validator/router.rs +++ b/node/src/validator/router.rs @@ -142,6 +142,11 @@ impl> Outbound for Validator { fn is_block_synced(&self) -> bool { self.sync.is_block_synced() } + + /// Returns the number of blocks this node is behind its furthest peer. + fn num_blocks_behind(&self) -> u32 { + self.sync.num_blocks_behind() + } } #[async_trait] From 546773d70e45970d21e0bb1303d2643f45c92621 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 25 Apr 2024 02:07:15 -0400 Subject: [PATCH 431/551] Add sync leniency for rest processing --- node/rest/src/routes.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/node/rest/src/routes.rs b/node/rest/src/routes.rs index 1bc54e8e09..671da08aaa 100644 --- a/node/rest/src/routes.rs +++ b/node/rest/src/routes.rs @@ -39,6 +39,10 @@ pub(crate) struct Metadata { metadata: bool, } +/// The maximum number of blocks the client can be behind it's latest peer before it skips +/// processing incoming transactions and solutions. +const SYNC_LENIENCY: u32 = 10; + impl, R: Routing> Rest { // ----------------- DEPRECATED FUNCTIONS ----------------- // The functions below are associated with deprecated routes. @@ -329,8 +333,8 @@ impl, R: Routing> Rest { State(rest): State, Json(tx): Json>, ) -> Result { - // Do not process the transaction if the node is syncing. - if !rest.routing.is_block_synced() { + // Do not process the transaction if the node is too far behind. + if !rest.routing.num_blocks_behind() > SYNC_LENIENCY { return Err(RestError(format!("Unable to broadcast transaction '{}' (node is syncing)", fmt_id(tx.id())))); } @@ -358,8 +362,8 @@ impl, R: Routing> Rest { State(rest): State, Json(solution): Json>, ) -> Result { - // Do not process the solution if the node is syncing. - if !rest.routing.is_block_synced() { + // Do not process the solution if the node is too far behind. + if !rest.routing.num_blocks_behind() > SYNC_LENIENCY { return Err(RestError(format!( "Unable to broadcast solution '{}' (node is syncing)", fmt_id(solution.id()) From 89a5f24c94d3bb57c1d7d14c05847984949aee0a Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 25 Apr 2024 02:11:11 -0400 Subject: [PATCH 432/551] Update function documentation --- node/router/src/outbound.rs | 2 +- node/router/tests/common/router.rs | 2 +- node/src/client/router.rs | 2 +- node/src/prover/router.rs | 2 +- node/src/validator/router.rs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/node/router/src/outbound.rs b/node/router/src/outbound.rs index 677db6db21..716a745086 100644 --- a/node/router/src/outbound.rs +++ b/node/router/src/outbound.rs @@ -31,7 +31,7 @@ pub trait Outbound: Writing> { /// Returns `true` if the node is synced up to the latest block (within the given tolerance). fn is_block_synced(&self) -> bool; - /// Returns the number of blocks this node is behind its furthest peer. + /// Returns the number of blocks this node is behind the greatest peer height. fn num_blocks_behind(&self) -> u32; /// Sends a "Ping" message to the given peer. diff --git a/node/router/tests/common/router.rs b/node/router/tests/common/router.rs index 06c3f4c7d4..44a6f3c74e 100644 --- a/node/router/tests/common/router.rs +++ b/node/router/tests/common/router.rs @@ -155,7 +155,7 @@ impl Outbound for TestRouter { true } - /// Returns the number of blocks this node is behind its furthest peer. + /// Returns the number of blocks this node is behind the greatest peer height. fn num_blocks_behind(&self) -> u32 { 0 } diff --git a/node/src/client/router.rs b/node/src/client/router.rs index 93e8b3a5a2..53f7356f8e 100644 --- a/node/src/client/router.rs +++ b/node/src/client/router.rs @@ -169,7 +169,7 @@ impl> Outbound for Client { self.sync.is_block_synced() } - /// Returns the number of blocks this node is behind its furthest peer. + /// Returns the number of blocks this node is behind the greatest peer height. fn num_blocks_behind(&self) -> u32 { self.sync.num_blocks_behind() } diff --git a/node/src/prover/router.rs b/node/src/prover/router.rs index 3232f86502..46935e2c5b 100644 --- a/node/src/prover/router.rs +++ b/node/src/prover/router.rs @@ -141,7 +141,7 @@ impl> Outbound for Prover { true } - /// Returns the number of blocks this node is behind its furthest peer. + /// Returns the number of blocks this node is behind the greatest peer height. fn num_blocks_behind(&self) -> u32 { 0 } diff --git a/node/src/validator/router.rs b/node/src/validator/router.rs index cda8a32391..0ac3743ae1 100644 --- a/node/src/validator/router.rs +++ b/node/src/validator/router.rs @@ -143,7 +143,7 @@ impl> Outbound for Validator { self.sync.is_block_synced() } - /// Returns the number of blocks this node is behind its furthest peer. + /// Returns the number of blocks this node is behind the greatest peer height. fn num_blocks_behind(&self) -> u32 { self.sync.num_blocks_behind() } From 5c2804fee3a5cb6ecd4c7119eb6eff44d4d32ae2 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 25 Apr 2024 02:35:52 -0400 Subject: [PATCH 433/551] Use SYNC_LENIENCY in inbound processing --- node/rest/src/routes.rs | 6 +----- node/router/src/inbound.rs | 12 ++++++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/node/rest/src/routes.rs b/node/rest/src/routes.rs index 671da08aaa..e3e431d5e1 100644 --- a/node/rest/src/routes.rs +++ b/node/rest/src/routes.rs @@ -13,7 +13,7 @@ // limitations under the License. use super::*; -use snarkos_node_router::messages::UnconfirmedSolution; +use snarkos_node_router::{messages::UnconfirmedSolution, SYNC_LENIENCY}; use snarkvm::{ ledger::puzzle::Solution, prelude::{block::Transaction, Identifier, Plaintext}, @@ -39,10 +39,6 @@ pub(crate) struct Metadata { metadata: bool, } -/// The maximum number of blocks the client can be behind it's latest peer before it skips -/// processing incoming transactions and solutions. -const SYNC_LENIENCY: u32 = 10; - impl, R: Routing> Rest { // ----------------- DEPRECATED FUNCTIONS ----------------- // The functions below are associated with deprecated routes. diff --git a/node/router/src/inbound.rs b/node/router/src/inbound.rs index 1e35f1e1a1..d2803166ed 100644 --- a/node/router/src/inbound.rs +++ b/node/router/src/inbound.rs @@ -42,6 +42,10 @@ use tokio::task::spawn_blocking; /// The max number of peers to send in a `PeerResponse` message. const MAX_PEERS_TO_SEND: usize = u8::MAX as usize; +/// The maximum number of blocks the client can be behind it's latest peer before it skips +/// processing incoming transactions and solutions. +pub const SYNC_LENIENCY: u32 = 10; + #[async_trait] pub trait Inbound: Reading + Outbound { /// The maximum number of puzzle requests per interval. @@ -214,8 +218,8 @@ pub trait Inbound: Reading + Outbound { } } Message::UnconfirmedSolution(message) => { - // Do not process unconfirmed solutions if the node is syncing. - if !self.is_block_synced() { + // Do not process unconfirmed solutions if the node is too far behind. + if self.num_blocks_behind() > SYNC_LENIENCY { trace!("Skipped processing unconfirmed solution '{}' (node is syncing)", message.solution_id); return Ok(()); } @@ -244,8 +248,8 @@ pub trait Inbound: Reading + Outbound { } } Message::UnconfirmedTransaction(message) => { - // Do not process unconfirmed transactions if the node is syncing. - if !self.is_block_synced() { + // Do not process unconfirmed transactions if the node is too far behind. + if self.num_blocks_behind() > SYNC_LENIENCY { trace!("Skipped processing unconfirmed transaction '{}' (node is syncing)", message.transaction_id); return Ok(()); } From 08a40be59c946adb95f0dd1c13dc203ba79a326f Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 25 Apr 2024 12:48:01 -0400 Subject: [PATCH 434/551] Fix check --- node/rest/src/routes.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node/rest/src/routes.rs b/node/rest/src/routes.rs index e3e431d5e1..219dd6e975 100644 --- a/node/rest/src/routes.rs +++ b/node/rest/src/routes.rs @@ -330,7 +330,7 @@ impl, R: Routing> Rest { Json(tx): Json>, ) -> Result { // Do not process the transaction if the node is too far behind. - if !rest.routing.num_blocks_behind() > SYNC_LENIENCY { + if rest.routing.num_blocks_behind() > SYNC_LENIENCY { return Err(RestError(format!("Unable to broadcast transaction '{}' (node is syncing)", fmt_id(tx.id())))); } @@ -359,7 +359,7 @@ impl, R: Routing> Rest { Json(solution): Json>, ) -> Result { // Do not process the solution if the node is too far behind. - if !rest.routing.num_blocks_behind() > SYNC_LENIENCY { + if rest.routing.num_blocks_behind() > SYNC_LENIENCY { return Err(RestError(format!( "Unable to broadcast solution '{}' (node is syncing)", fmt_id(solution.id()) From 3095707556c1c294875760709400726bca6dca42 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 25 Apr 2024 17:36:11 -0400 Subject: [PATCH 435/551] Add unit test for syncing is_linked blocks --- node/bft/src/sync/mod.rs | 236 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 236 insertions(+) diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index 48c5e1b23e..c1d212bb43 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -615,3 +615,239 @@ impl Sync { self.handles.lock().iter().for_each(|handle| handle.abort()); } } +#[cfg(test)] +mod tests { + use super::*; + + use crate::{helpers::now, ledger_service::CoreLedgerService, storage_service::BFTMemoryService}; + use snarkos_account::Account; + use snarkvm::{ + console::{ + account::{Address, PrivateKey}, + network::MainnetV0, + }, + ledger::{ + narwhal::{BatchCertificate, BatchHeader, Subdag}, + store::{helpers::memory::ConsensusMemory, ConsensusStore}, + }, + prelude::{Ledger, VM}, + utilities::TestRng, + }; + + use aleo_std::StorageMode; + use indexmap::IndexSet; + use rand::Rng; + use std::collections::BTreeMap; + + type CurrentNetwork = MainnetV0; + type CurrentLedger = Ledger>; + type CurrentConsensusStore = ConsensusStore>; + + #[tokio::test] + #[tracing_test::traced_test] + async fn test_commit_via_is_linked() -> anyhow::Result<()> { + let rng = &mut TestRng::default(); + // Initialize the round parameters. + let max_gc_rounds = BatchHeader::::MAX_GC_ROUNDS as u64; + let commit_round = 2; + + // Initialize the store. + let store = CurrentConsensusStore::open(None).unwrap(); + let account: Account = Account::new(rng)?; + + // Create a genesis block with a seeded RNG to reproduce the same genesis private keys. + let seed: u64 = rng.gen(); + let genesis_rng = &mut TestRng::from_seed(seed); + let genesis = VM::from(store).unwrap().genesis_beacon(account.private_key(), genesis_rng).unwrap(); + + // Extract the private keys from the genesis committee by using the same RNG to sample private keys. + let genesis_rng = &mut TestRng::from_seed(seed); + let private_keys = [ + *account.private_key(), + PrivateKey::new(genesis_rng)?, + PrivateKey::new(genesis_rng)?, + PrivateKey::new(genesis_rng)?, + ]; + + // Initialize the ledger with the genesis block. + let ledger = CurrentLedger::load(genesis.clone(), StorageMode::Production).unwrap(); + // Initialize the ledger. + let core_ledger = Arc::new(CoreLedgerService::new(ledger.clone(), Default::default())); + + // Sample 5 rounds of batch certificates starting at the genesis round from a static set of 4 authors. + let (round_to_certificates_map, committee) = { + let addresses = vec![ + Address::try_from(private_keys[0])?, + Address::try_from(private_keys[1])?, + Address::try_from(private_keys[2])?, + Address::try_from(private_keys[3])?, + ]; + + let committee = ledger.latest_committee().unwrap(); + + // Initialize a mapping from the round number to the set of batch certificates in the round. + let mut round_to_certificates_map: HashMap>> = + HashMap::new(); + let mut previous_certificates: IndexSet> = IndexSet::with_capacity(4); + + for round in 0..=commit_round + 8 { + let mut current_certificates = IndexSet::new(); + let previous_certificate_ids: IndexSet<_> = if round == 0 || round == 1 { + IndexSet::new() + } else { + previous_certificates.iter().map(|c| c.id()).collect() + }; + let committee_id = committee.id(); + + // Create a certificate for the leader. + if round <= 5 { + let leader = committee.get_leader(round).unwrap(); + let i = addresses.iter().position(|&address| address == leader).unwrap(); + let batch_header = BatchHeader::new( + &private_keys[i], + round, + now(), + committee_id, + Default::default(), + previous_certificate_ids.clone(), + rng, + ) + .unwrap(); + // Sign the batch header. + let mut signatures = IndexSet::with_capacity(4); + for (j, private_key_2) in private_keys.iter().enumerate() { + if i != j { + signatures.insert(private_key_2.sign(&[batch_header.batch_id()], rng).unwrap()); + } + } + current_certificates.insert(BatchCertificate::from(batch_header, signatures).unwrap()); + } + + // Create a certificate for each validator. + if round > 5 { + for (i, private_key_1) in private_keys.iter().enumerate() { + let batch_header = BatchHeader::new( + private_key_1, + round, + now(), + committee_id, + Default::default(), + previous_certificate_ids.clone(), + rng, + ) + .unwrap(); + // Sign the batch header. + let mut signatures = IndexSet::with_capacity(4); + for (j, private_key_2) in private_keys.iter().enumerate() { + if i != j { + signatures.insert(private_key_2.sign(&[batch_header.batch_id()], rng).unwrap()); + } + } + current_certificates.insert(BatchCertificate::from(batch_header, signatures).unwrap()); + } + } + // Update the map of certificates. + round_to_certificates_map.insert(round, current_certificates.clone()); + previous_certificates = current_certificates.clone(); + } + (round_to_certificates_map, committee) + }; + + // Initialize the storage. + let storage = Storage::new(core_ledger.clone(), Arc::new(BFTMemoryService::new()), max_gc_rounds); + // Insert certificates into storage. + let mut certificates: Vec> = Vec::new(); + for i in 1..=commit_round + 8 { + let c = (*round_to_certificates_map.get(&i).unwrap()).clone(); + certificates.extend(c); + } + for certificate in certificates.clone().iter() { + storage.testing_only_insert_certificate_testing_only(certificate.clone()); + } + + // Create block 1. + let leader_round_1 = commit_round; + let leader_1 = committee.get_leader(leader_round_1).unwrap(); + let leader_certificate = storage.get_certificate_for_round_with_author(commit_round, leader_1).unwrap(); + let block_1 = { + let mut subdag_map: BTreeMap>> = BTreeMap::new(); + let mut leader_cert_map = IndexSet::new(); + leader_cert_map.insert(leader_certificate.clone()); + let mut previous_cert_map = IndexSet::new(); + for cert in storage.get_certificates_for_round(commit_round - 1) { + previous_cert_map.insert(cert); + } + subdag_map.insert(commit_round, leader_cert_map.clone()); + subdag_map.insert(commit_round - 1, previous_cert_map.clone()); + let subdag = Subdag::from(subdag_map.clone())?; + core_ledger.prepare_advance_to_next_quorum_block(subdag, Default::default())? + }; + // Insert block 1. + core_ledger.advance_to_next_block(&block_1)?; + + // Create block 2. + let leader_round_2 = commit_round + 2; + let leader_2 = committee.get_leader(leader_round_2).unwrap(); + let leader_certificate_2 = storage.get_certificate_for_round_with_author(leader_round_2, leader_2).unwrap(); + let block_2 = { + let mut subdag_map_2: BTreeMap>> = BTreeMap::new(); + let mut leader_cert_map_2 = IndexSet::new(); + leader_cert_map_2.insert(leader_certificate_2.clone()); + let mut previous_cert_map_2 = IndexSet::new(); + for cert in storage.get_certificates_for_round(leader_round_2 - 1) { + previous_cert_map_2.insert(cert); + } + subdag_map_2.insert(leader_round_2, leader_cert_map_2.clone()); + subdag_map_2.insert(leader_round_2 - 1, previous_cert_map_2.clone()); + let subdag_2 = Subdag::from(subdag_map_2.clone())?; + core_ledger.prepare_advance_to_next_quorum_block(subdag_2, Default::default())? + }; + // Insert block 2. + core_ledger.advance_to_next_block(&block_2)?; + + // Create block 3 + let leader_round_3 = commit_round + 4; + let leader_3 = committee.get_leader(leader_round_3).unwrap(); + let leader_certificate_3 = storage.get_certificate_for_round_with_author(leader_round_3, leader_3).unwrap(); + let block_3 = { + let mut subdag_map_3: BTreeMap>> = BTreeMap::new(); + let mut leader_cert_map_3 = IndexSet::new(); + leader_cert_map_3.insert(leader_certificate_3.clone()); + let mut previous_cert_map_3 = IndexSet::new(); + for cert in storage.get_certificates_for_round(leader_round_3 - 1) { + previous_cert_map_3.insert(cert); + } + subdag_map_3.insert(leader_round_3, leader_cert_map_3.clone()); + subdag_map_3.insert(leader_round_3 - 1, previous_cert_map_3.clone()); + let subdag_3 = Subdag::from(subdag_map_3.clone())?; + core_ledger.prepare_advance_to_next_quorum_block(subdag_3, Default::default())? + }; + // Insert block 3. + core_ledger.advance_to_next_block(&block_3)?; + + // Initialize the syncing ledger. + let syncing_ledger = Arc::new(CoreLedgerService::new( + CurrentLedger::load(genesis, StorageMode::Production).unwrap(), + Default::default(), + )); + // Initialize the gateway. + let gateway = Gateway::new(account.clone(), storage.clone(), syncing_ledger.clone(), None, &[], None)?; + // Initialize the sync module. + let sync = Sync::new(gateway.clone(), storage.clone(), syncing_ledger.clone()); + // Try to sync block 1. + sync.sync_storage_with_block(block_1).await?; + // Ensure that the sync ledger has not advanced. + assert_eq!(syncing_ledger.latest_block_height(), 0); + // Try to sync block 2. + sync.sync_storage_with_block(block_2).await?; + // Ensure that the sync ledger has not advanced. + assert_eq!(syncing_ledger.latest_block_height(), 0); + // Try to sync block 3. + sync.sync_storage_with_block(block_3).await?; + // Ensure blocks 1 and 2 were added to the ledger. + assert!(syncing_ledger.contains_block_height(1)); + assert!(syncing_ledger.contains_block_height(2)); + + Ok(()) + } +} From 8426d35bd7c3f8afe60cd1c25b572d0dddf94c1d Mon Sep 17 00:00:00 2001 From: ghostant-1017 Date: Sun, 28 Apr 2024 14:31:59 +0800 Subject: [PATCH 436/551] Decrement counter --- node/router/src/inbound.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/node/router/src/inbound.rs b/node/router/src/inbound.rs index d2803166ed..b8d985040b 100644 --- a/node/router/src/inbound.rs +++ b/node/router/src/inbound.rs @@ -136,6 +136,7 @@ pub trait Inbound: Reading + Outbound { if !self.router().cache.contains_outbound_peer_request(peer_ip) { bail!("Peer '{peer_ip}' is not following the protocol (unexpected peer response)") } + self.router().cache.decrement_outbound_peer_requests(peer_ip); if !self.router().allow_external_peers() { bail!("Not accepting peer response from '{peer_ip}' (validator gossip is disabled)"); } From fe8fb4b3f2dbb7e0066efda15459357521b4e43e Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 29 Apr 2024 12:03:14 -0400 Subject: [PATCH 437/551] Resolve merge --- node/bft/src/helpers/pending.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index acfd70953e..b122e74ce1 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -267,10 +267,10 @@ mod tests { assert!(!pending.contains(unknown_id)); // Check get. - assert_eq!(pending.get(solution_id_1), Some(HashSet::from([addr_1]))); - assert_eq!(pending.get(solution_id_2), Some(HashSet::from([addr_2]))); - assert_eq!(pending.get(solution_id_3), Some(HashSet::from([addr_3]))); - assert_eq!(pending.get(unknown_id), None); + assert_eq!(pending.get_peers(solution_id_1), Some(HashSet::from([addr_1]))); + assert_eq!(pending.get_peers(solution_id_2), Some(HashSet::from([addr_2]))); + assert_eq!(pending.get_peers(solution_id_3), Some(HashSet::from([addr_3]))); + assert_eq!(pending.get_peers(unknown_id), None); // Check remove. assert!(pending.remove(solution_id_1, None).is_some()); @@ -373,9 +373,9 @@ mod tests { assert!(pending.is_empty()); assert_eq!(pending.len(), 0); - // Initialize the commitments. - let commitment_1 = TransmissionID::Solution(PuzzleCommitment::from_g1_affine(rng.gen())); - let commitment_2 = TransmissionID::Solution(PuzzleCommitment::from_g1_affine(rng.gen())); + // Initialize the solution IDs. + let solution_id_1 = TransmissionID::Solution(rng.gen::().into()); + let solution_id_2 = TransmissionID::Solution(rng.gen::().into()); // Initialize the SocketAddrs. let addr_1 = SocketAddr::from(([127, 0, 0, 1], 1234)); @@ -388,13 +388,13 @@ mod tests { let (callback_sender_3, _) = oneshot::channel(); // Insert the commitments. - assert!(pending.insert(commitment_1, addr_1, Some((callback_sender_1, true)))); - assert!(pending.insert(commitment_1, addr_2, Some((callback_sender_2, true)))); - assert!(pending.insert(commitment_2, addr_3, Some((callback_sender_3, true)))); + assert!(pending.insert(solution_id_1, addr_1, Some((callback_sender_1, true)))); + assert!(pending.insert(solution_id_1, addr_2, Some((callback_sender_2, true)))); + assert!(pending.insert(solution_id_2, addr_3, Some((callback_sender_3, true)))); // Ensure that the items have not been expired yet. - assert_eq!(pending.num_callbacks(commitment_1), 2); - assert_eq!(pending.num_callbacks(commitment_2), 1); + assert_eq!(pending.num_callbacks(solution_id_1), 2); + assert_eq!(pending.num_callbacks(solution_id_2), 1); assert_eq!(pending.len(), 2); // Wait for ` CALLBACK_EXPIRATION_IN_SECS + 1` seconds. @@ -404,8 +404,8 @@ mod tests { pending.clear_expired_callbacks(); // Ensure that the items have been expired. - assert_eq!(pending.num_callbacks(commitment_1), 0); - assert_eq!(pending.num_callbacks(commitment_2), 0); + assert_eq!(pending.num_callbacks(solution_id_1), 0); + assert_eq!(pending.num_callbacks(solution_id_2), 0); assert_eq!(pending.len(), 0); } } From 7c43fe2b4f0ec26960f5f0b38193dbf38ea92755 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 29 Apr 2024 12:30:32 -0400 Subject: [PATCH 438/551] Use read instead of write --- node/bft/src/helpers/pending.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index b122e74ce1..b82744ab7f 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -28,7 +28,7 @@ use tokio::sync::oneshot; /// The maximum number of seconds to wait before expiring a callback. /// We ensure that we don't truncate `MAX_FETCH_TIMEOUT_IN_MS` when converting to seconds. -const CALLBACK_EXPIRATION_IN_SECS: i64 = (MAX_FETCH_TIMEOUT_IN_MS as i64 + (1000 - 1)) / 1000; +const CALLBACK_EXPIRATION_IN_SECS: i64 = MAX_FETCH_TIMEOUT_IN_MS.div_ceil(1000) as i64; /// Returns the maximum number of redundant requests for the number of validators in the specified round. pub fn max_redundant_requests(ledger: Arc>, round: u64) -> usize { @@ -106,7 +106,7 @@ impl Pending { self.clear_expired_callbacks_for_item(item); // Return the number of live callbacks. self.pending - .write() + .read() .get(&item) .map_or(0, |peers| peers.values().flatten().filter(|(_, _, request_sent)| *request_sent).count()) } From ad0d54c3c059c052789948111c0e954add1d61a5 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 29 Apr 2024 12:32:49 -0400 Subject: [PATCH 439/551] Reduce instances of fetching current timestamp --- node/bft/src/helpers/pending.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index b82744ab7f..7d1adda644 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -93,8 +93,9 @@ impl Pending { /// Returns the number of pending callbacks for the specified `item`. pub fn num_callbacks(&self, item: impl Into) -> usize { let item = item.into(); + let now = OffsetDateTime::now_utc().unix_timestamp(); // Clear the callbacks that have expired. - self.clear_expired_callbacks_for_item(item); + self.clear_expired_callbacks_for_item(now, item); // Return the number of live callbacks. self.pending.read().get(&item).map_or(0, |peers| peers.values().flatten().count()) } @@ -102,8 +103,9 @@ impl Pending { /// Returns the number of pending sent requests for the specified `item`. pub fn num_sent_requests(&self, item: impl Into) -> usize { let item = item.into(); + let now = OffsetDateTime::now_utc().unix_timestamp(); // Clear the callbacks that have expired. - self.clear_expired_callbacks_for_item(item); + self.clear_expired_callbacks_for_item(now, item); // Return the number of live callbacks. self.pending .read() @@ -123,6 +125,7 @@ impl Pending { callback: Option<(oneshot::Sender, bool)>, ) -> bool { let item = item.into(); + let now = OffsetDateTime::now_utc().unix_timestamp(); // Insert the peer IP and optional callback into the pending queue. let result = { // Acquire the pending lock. @@ -139,14 +142,14 @@ impl Pending { // If a callback is provided, insert it into the callback queue. if let Some((callback, request_sent)) = callback { - peer_entry.push((callback, OffsetDateTime::now_utc().unix_timestamp(), request_sent)); + peer_entry.push((callback, now, request_sent)); } is_new_peer }; // Clear the callbacks that have expired. - self.clear_expired_callbacks_for_item(item); + self.clear_expired_callbacks_for_item(now, item); // Return the result. result @@ -177,9 +180,8 @@ impl Pending { } /// Removes the callbacks for the specified `item` that have expired. - pub fn clear_expired_callbacks_for_item(&self, item: impl Into) { + pub fn clear_expired_callbacks_for_item(&self, now: i64, item: impl Into) { let item = item.into(); - let now = OffsetDateTime::now_utc().unix_timestamp(); // Acquire the pending lock. let mut pending = self.pending.write(); @@ -204,8 +206,9 @@ impl Pending { /// Removes the callbacks for all items have that expired. pub fn clear_expired_callbacks(&self) { let items = self.pending.read().keys().copied().collect::>(); + let now = OffsetDateTime::now_utc().unix_timestamp(); for item in items.into_iter() { - self.clear_expired_callbacks_for_item(item); + self.clear_expired_callbacks_for_item(now, item); } } } From 042c94d044775d2098ce3f6324973dbafdee7ddc Mon Sep 17 00:00:00 2001 From: ljedrz Date: Tue, 2 Apr 2024 11:55:20 +0200 Subject: [PATCH 440/551] feat: store current batch proposal to disk on shutdown Signed-off-by: ljedrz --- cli/src/commands/clean.rs | 8 +++++ node/bft/src/gateway.rs | 5 ++++ node/bft/src/helpers/proposal.rs | 40 +++++++++++++++++++++++-- node/bft/src/primary.rs | 50 ++++++++++++++++++++++++++++++-- 4 files changed, 99 insertions(+), 4 deletions(-) diff --git a/cli/src/commands/clean.rs b/cli/src/commands/clean.rs index a133577e77..066ef52fd0 100644 --- a/cli/src/commands/clean.rs +++ b/cli/src/commands/clean.rs @@ -16,6 +16,7 @@ use aleo_std::StorageMode; use anyhow::{bail, Result}; use clap::Parser; use colored::Colorize; +use snarkos_node::bft::batch_proposal_path; use std::path::PathBuf; /// Cleans the snarkOS node storage. @@ -35,6 +36,13 @@ pub struct Clean { impl Clean { /// Cleans the snarkOS node storage. pub fn parse(self) -> Result { + // Remove the current batch proposal file, if it exists. + let proposal_path = batch_proposal_path(self.network, self.dev); + if proposal_path.exists() { + if let Err(err) = std::fs::remove_file(&proposal_path) { + bail!("Failed to remove the current batch proposal file at {}: {err}", proposal_path.display()); + } + } // Remove the specified ledger from storage. Self::remove_ledger(self.network, match self.path { Some(path) => StorageMode::Custom(path), diff --git a/node/bft/src/gateway.rs b/node/bft/src/gateway.rs index 82ba0d2b11..0e404ff635 100644 --- a/node/bft/src/gateway.rs +++ b/node/bft/src/gateway.rs @@ -261,6 +261,11 @@ impl Gateway { &self.account } + /// Returns the dev identifier of the node. + pub const fn dev(&self) -> Option { + self.dev + } + /// Returns the IP address of this node. pub fn local_ip(&self) -> SocketAddr { self.tcp.listening_addr().expect("The TCP listener is not enabled") diff --git a/node/bft/src/helpers/proposal.rs b/node/bft/src/helpers/proposal.rs index a3a7ae7f8c..098800f565 100644 --- a/node/bft/src/helpers/proposal.rs +++ b/node/bft/src/helpers/proposal.rs @@ -22,11 +22,11 @@ use snarkvm::{ committee::Committee, narwhal::{BatchCertificate, BatchHeader, Transmission, TransmissionID}, }, - prelude::{bail, ensure, Itertools, Result}, + prelude::{bail, ensure, FromBytes, Itertools, Result, ToBytes}, }; use indexmap::{IndexMap, IndexSet}; -use std::collections::HashSet; +use std::{collections::HashSet, io}; pub struct Proposal { /// The proposed batch header. @@ -167,6 +167,42 @@ impl Proposal { } } +impl ToBytes for Proposal { + fn write_le(&self, mut writer: W) -> io::Result<()> { + self.batch_header.write_le(&mut writer)?; + u32::try_from(self.transmissions.len()).map_err(|_| io::ErrorKind::Other)?.write_le(&mut writer)?; + for (transmission_id, transmission) in &self.transmissions { + transmission_id.write_le(&mut writer)?; + transmission.write_le(&mut writer)?; + } + u32::try_from(self.signatures.len()).map_err(|_| io::ErrorKind::Other)?.write_le(&mut writer)?; + for signature in &self.signatures { + signature.write_le(&mut writer)?; + } + Ok(()) + } +} + +impl FromBytes for Proposal { + fn read_le(mut reader: R) -> io::Result { + let batch_header = FromBytes::read_le(&mut reader)?; + let num_transmissions = u32::read_le(&mut reader)?; + let mut transmissions = IndexMap::default(); + for _ in 0..num_transmissions { + let transmission_id = FromBytes::read_le(&mut reader)?; + let transmission = FromBytes::read_le(&mut reader)?; + transmissions.insert(transmission_id, transmission); + } + let num_signatures = u32::read_le(&mut reader)?; + let mut signatures = IndexSet::default(); + for _ in 0..num_signatures { + signatures.insert(FromBytes::read_le(&mut reader)?); + } + + Ok(Self { batch_header, transmissions, signatures }) + } +} + #[cfg(test)] mod prop_tests { use crate::helpers::{ diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 0a8259afcc..d0a18ebd9c 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -39,6 +39,7 @@ use crate::{ PRIMARY_PING_IN_MS, WORKER_PING_IN_MS, }; +use aleo_std::{aleo_ledger_dir, StorageMode}; use snarkos_account::Account; use snarkos_node_bft_events::PrimaryPing; use snarkos_node_bft_ledger_service::LedgerService; @@ -53,7 +54,7 @@ use snarkvm::{ narwhal::{BatchCertificate, BatchHeader, Data, Transmission, TransmissionID}, puzzle::{Solution, SolutionID}, }, - prelude::committee::Committee, + prelude::{committee::Committee, ToBytes}, }; use colored::Colorize; @@ -63,8 +64,10 @@ use parking_lot::{Mutex, RwLock}; use rayon::prelude::*; use std::{ collections::{HashMap, HashSet}, + fs, future::Future, net::SocketAddr, + path::PathBuf, sync::Arc, time::Duration, }; @@ -76,6 +79,21 @@ use tokio::{ /// A helper type for an optional proposed batch. pub type ProposedBatch = RwLock>>; +// Returns the path where a batch proposal file may be stored. +pub fn batch_proposal_path(network: u16, dev: Option) -> PathBuf { + // Obtain the path to the ledger. + let mut path = aleo_ledger_dir(network, StorageMode::from(dev)); + // Go to the folder right above the ledger. + path.pop(); + // Append the proposal's file name. + path.push(&format!( + "current_batch_proposal-{network}{}", + if let Some(id) = dev { format!("-{id}") } else { "".into() } + )); + + path +} + #[derive(Clone)] pub struct Primary { /// The sync module. @@ -119,6 +137,19 @@ impl Primary { let gateway = Gateway::new(account, storage.clone(), ledger.clone(), ip, trusted_validators, dev)?; // Initialize the sync module. let sync = Sync::new(gateway.clone(), storage.clone(), ledger.clone()); + // Check for the existence of a batch proposal file. + let proposed_batch = ProposedBatch::::default(); + let proposal_path = batch_proposal_path(N::ID, dev); + if let Ok(serialized_proposal) = fs::read(&proposal_path) { + match Proposal::::from_bytes_le(&serialized_proposal) { + Ok(proposal) => *proposed_batch.write() = Some(proposal), + Err(_) => bail!("Couldn't deserialize the proposal stored at {}", proposal_path.display()), + } + if let Err(err) = fs::remove_file(&proposal_path) { + bail!("Failed to remove the current batch proposal file at {}: {err}", proposal_path.display()); + } + } + // Initialize the primary instance. Ok(Self { sync, @@ -127,7 +158,7 @@ impl Primary { ledger, workers: Arc::from(vec![]), bft_sender: Default::default(), - proposed_batch: Default::default(), + proposed_batch: Arc::new(proposed_batch), latest_proposed_batch_timestamp: Default::default(), signed_proposals: Default::default(), handles: Default::default(), @@ -1546,6 +1577,21 @@ impl Primary { self.workers.iter().for_each(|worker| worker.shut_down()); // Abort the tasks. self.handles.lock().iter().for_each(|handle| handle.abort()); + // Save the current batch proposal to disk. + if let Some(proposal) = self.proposed_batch.write().take() { + let proposal_path = batch_proposal_path(N::ID, self.gateway.dev()); + + match proposal.to_bytes_le() { + Ok(proposal) => { + if let Err(err) = fs::write(&proposal_path, proposal) { + error!("Couldn't store the current proposal at {}: {err}.", proposal_path.display()); + } + } + Err(err) => { + error!("Couldn't serialize the current proposal: {err}."); + } + }; + } // Close the gateway. self.gateway.shut_down().await; } From b8a586d144895cf777bc6eb4b7f01b2bc65f925d Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 29 Apr 2024 18:25:23 -0400 Subject: [PATCH 441/551] Introduce dedicated SignedProposals object --- node/bft/src/helpers/mod.rs | 3 + node/bft/src/helpers/signed_proposals.rs | 97 ++++++++++++++++++++++++ node/bft/src/primary.rs | 8 +- 3 files changed, 104 insertions(+), 4 deletions(-) create mode 100644 node/bft/src/helpers/signed_proposals.rs diff --git a/node/bft/src/helpers/mod.rs b/node/bft/src/helpers/mod.rs index f690aa4cd9..fda524619f 100644 --- a/node/bft/src/helpers/mod.rs +++ b/node/bft/src/helpers/mod.rs @@ -36,6 +36,9 @@ pub use ready::*; pub mod resolver; pub use resolver::*; +pub mod signed_proposals; +pub use signed_proposals::*; + pub mod storage; pub use storage::*; diff --git a/node/bft/src/helpers/signed_proposals.rs b/node/bft/src/helpers/signed_proposals.rs new file mode 100644 index 0000000000..52f72be794 --- /dev/null +++ b/node/bft/src/helpers/signed_proposals.rs @@ -0,0 +1,97 @@ +// Copyright (C) 2019-2023 Aleo Systems Inc. +// This file is part of the snarkOS library. + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// http://www.apache.org/licenses/LICENSE-2.0 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use snarkvm::{ + console::{ + account::{Address, Signature}, + network::Network, + types::Field, + }, + prelude::{FromBytes, ToBytes}, +}; + +use std::{collections::HashMap, io, ops::Deref}; + +/// A helper type for the signed proposals. +#[derive(Clone, PartialEq, Eq)] +pub struct SignedProposals(pub HashMap, (u64, i64, Field, Signature)>); + +impl SignedProposals { + /// Ensure that every signed proposal is associated with the `expected_signer`. + pub fn is_valid(&self, expected_signer: Address) -> bool { + self.0.iter().all(|(_, (_, _, _, signature))| signature.to_address() == expected_signer) + } +} + +impl ToBytes for SignedProposals { + fn write_le(&self, mut writer: W) -> io::Result<()> { + // Write the number of signed proposals. + u32::try_from(self.0.len()).map_err(|_| io::ErrorKind::Other)?.write_le(&mut writer)?; + // Serialize the signed proposals. + for (address, (round, timestamp, batch_id, signature)) in &self.0 { + // Write the address. + address.write_le(&mut writer)?; + // Write the round. + round.write_le(&mut writer)?; + // Write the timestamp. + timestamp.write_le(&mut writer)?; + // Write the batch id. + batch_id.write_le(&mut writer)?; + // Write the signature. + signature.write_le(&mut writer)?; + } + + Ok(()) + } +} + +impl FromBytes for SignedProposals { + fn read_le(mut reader: R) -> io::Result { + // Read the number of signed proposals. + let num_signed_proposals = u32::read_le(&mut reader)?; + // Deserialize the signed proposals. + let mut signed_proposals = HashMap::default(); + for _ in 0..num_signed_proposals { + // Read the address. + let address = FromBytes::read_le(&mut reader)?; + // Read the round. + let round = FromBytes::read_le(&mut reader)?; + // Read the timestamp. + let timestamp = FromBytes::read_le(&mut reader)?; + // Read the batch id. + let batch_id = FromBytes::read_le(&mut reader)?; + // Read the signature. + let signature = FromBytes::read_le(&mut reader)?; + // Insert the signed proposal. + signed_proposals.insert(address, (round, timestamp, batch_id, signature)); + } + + Ok(Self(signed_proposals)) + } +} + +impl Deref for SignedProposals { + type Target = HashMap, (u64, i64, Field, Signature)>; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl Default for SignedProposals { + /// Initializes a new instance of the signed proposals. + fn default() -> Self { + Self(Default::default()) + } +} diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index d0a18ebd9c..d7bba5b22c 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -26,6 +26,7 @@ use crate::{ PrimaryReceiver, PrimarySender, Proposal, + SignedProposals, Storage, }, spawn_blocking, @@ -45,7 +46,6 @@ use snarkos_node_bft_events::PrimaryPing; use snarkos_node_bft_ledger_service::LedgerService; use snarkvm::{ console::{ - account::Signature, prelude::*, types::{Address, Field}, }, @@ -113,7 +113,7 @@ pub struct Primary { /// The timestamp of the most recent proposed batch. latest_proposed_batch_timestamp: Arc>, /// The recently-signed batch proposals (a map from the address to the round, timestamp, batch ID, and signature). - signed_proposals: Arc, (u64, i64, Field, Signature)>>>, + signed_proposals: Arc>>, /// The spawned handles. handles: Arc>>>, /// The lock for propose_batch. @@ -618,7 +618,7 @@ impl Primary { // Check if the proposal has expired. match is_proposal_expired(now(), timestamp) { // If the proposal has expired, then remove the cached signature. - true => self.signed_proposals.write().remove(&batch_author), + true => self.signed_proposals.write().0.remove(&batch_author), // If the proposal has not expired, then disconnect the validator. false => { self.gateway.disconnect(peer_ip); @@ -695,7 +695,7 @@ impl Primary { // Note: Due to the need to sync the batch header with the peer, it is possible // for the primary to receive the same 'BatchPropose' event again, whereby only // one instance of this handler should sign the batch. This check guarantees this. - match self.signed_proposals.write().entry(batch_author) { + match self.signed_proposals.write().0.entry(batch_author) { std::collections::hash_map::Entry::Occupied(mut entry) => { // If the validator has already signed a batch for this round, then return early, // since, if the peer still has not received the signature, they will request it again, From 6088bc14f84e754a7cb14b9acf8c65e98315fc46 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 29 Apr 2024 18:57:24 -0400 Subject: [PATCH 442/551] Minor fix --- node/bft/src/helpers/pending.rs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index 7d1adda644..8205f7c4df 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -135,7 +135,7 @@ impl Pending { let entry = pending.entry(item).or_default(); // Check if the peer IP is already present in the entry. - let is_new_peer = entry.contains_key(&peer_ip); + let is_new_peer = !entry.contains_key(&peer_ip); // Get the entry for the peer IP. let peer_entry = entry.entry(peer_ip).or_default(); @@ -248,10 +248,15 @@ mod tests { let addr_2 = SocketAddr::from(([127, 0, 0, 1], 2345)); let addr_3 = SocketAddr::from(([127, 0, 0, 1], 3456)); + // Initialize the callbacks. + let (callback_sender_1, _) = oneshot::channel(); + let (callback_sender_2, _) = oneshot::channel(); + let (callback_sender_3, _) = oneshot::channel(); + // Insert the solution IDs. - assert!(pending.insert(solution_id_1, addr_1, None)); - assert!(pending.insert(solution_id_2, addr_2, None)); - assert!(pending.insert(solution_id_3, addr_3, None)); + assert!(pending.insert(solution_id_1, addr_1, Some((callback_sender_1, true)))); + assert!(pending.insert(solution_id_2, addr_2, Some((callback_sender_2, true)))); + assert!(pending.insert(solution_id_3, addr_3, Some((callback_sender_3, true)))); // Check the number of SocketAddrs. assert_eq!(pending.len(), 3); @@ -434,7 +439,12 @@ mod prop_tests { pub fn to_pending(&self) -> Pending { let pending = Pending::::new(); for i in 0..self.count { - pending.insert(Item { id: i }, SocketAddr::from(([127, 0, 0, 1], i as u16)), None); + let (callback_sender_1, _) = oneshot::channel(); + pending.insert( + Item { id: i }, + SocketAddr::from(([127, 0, 0, 1], i as u16)), + Some((callback_sender_1, true)), + ); } pending } From 8a1ab3b188176bac445f8355ba7876284d566af1 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 29 Apr 2024 18:58:48 -0400 Subject: [PATCH 443/551] nit --- node/bft/src/helpers/pending.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index 8205f7c4df..47f98ca804 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -439,11 +439,10 @@ mod prop_tests { pub fn to_pending(&self) -> Pending { let pending = Pending::::new(); for i in 0..self.count { - let (callback_sender_1, _) = oneshot::channel(); pending.insert( Item { id: i }, SocketAddr::from(([127, 0, 0, 1], i as u16)), - Some((callback_sender_1, true)), + Some((oneshot::channel().0, true)), ); } pending From 296020e07f26f73832f6edba1f39393ea316c3d4 Mon Sep 17 00:00:00 2001 From: Raymond Chu <14917648+raychu86@users.noreply.github.com> Date: Tue, 30 Apr 2024 08:54:28 -0700 Subject: [PATCH 444/551] Update node/bft/src/helpers/pending.rs Co-authored-by: ljedrz Signed-off-by: Raymond Chu <14917648+raychu86@users.noreply.github.com> --- node/bft/src/helpers/pending.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index 47f98ca804..4093b724a3 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -164,7 +164,7 @@ impl Pending { match self.pending.write().remove(&item) { Some(callbacks) => { // Get the peer IPs. - let peer_ips = callbacks.keys().cloned().collect(); + let peer_ips = callbacks.keys().copied().collect(); // Process the callbacks. if let Some(callback_value) = callback_value { // Send a notification to the callback. From a39996d213f0a3e9c2556bb305d1fce2e00bc1d6 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 30 Apr 2024 12:08:26 -0400 Subject: [PATCH 445/551] Address comments --- node/bft/src/helpers/pending.rs | 4 ++-- node/bft/src/sync/mod.rs | 7 ++++++- node/bft/src/worker.rs | 6 +++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index 4093b724a3..fafbcc3db9 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -97,7 +97,7 @@ impl Pending { // Clear the callbacks that have expired. self.clear_expired_callbacks_for_item(now, item); // Return the number of live callbacks. - self.pending.read().get(&item).map_or(0, |peers| peers.values().flatten().count()) + self.pending.read().get(&item).map_or(0, |peers| peers.values().fold(0, |acc, v| acc.saturating_add(v.len()))) } /// Returns the number of pending sent requests for the specified `item`. @@ -414,7 +414,7 @@ mod tests { // Ensure that the items have been expired. assert_eq!(pending.num_callbacks(solution_id_1), 0); assert_eq!(pending.num_callbacks(solution_id_2), 0); - assert_eq!(pending.len(), 0); + assert!(pending.is_empty()); } } diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index c92cebfa7e..2593386125 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -14,6 +14,7 @@ use crate::{ helpers::{fmt_id, max_redundant_requests, BFTSender, Pending, Storage, SyncReceiver}, + spawn_blocking, Gateway, Transport, MAX_FETCH_TIMEOUT_IN_MS, @@ -126,7 +127,11 @@ impl Sync { tokio::time::sleep(Duration::from_millis(MAX_FETCH_TIMEOUT_IN_MS)).await; // Remove the expired pending transmission requests. - self_.pending.clear_expired_callbacks(); + let self__ = self_.clone(); + let _ = spawn_blocking!({ + self__.pending.clear_expired_callbacks(); + Ok(()) + }); } }); diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index 8dad9dbc10..7033b4173a 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -362,7 +362,11 @@ impl Worker { tokio::time::sleep(Duration::from_millis(MAX_FETCH_TIMEOUT_IN_MS)).await; // Remove the expired pending certificate requests. - self_.pending.clear_expired_callbacks(); + let self__ = self_.clone(); + let _ = spawn_blocking!({ + self__.pending.clear_expired_callbacks(); + Ok(()) + }); } }); From 964599be38d5dfe56f5d4701ad4cccf98819c8d1 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 30 Apr 2024 12:19:22 -0400 Subject: [PATCH 446/551] Use singluar lock and remove collect --- node/bft/src/helpers/pending.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index fafbcc3db9..f4192d8866 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -205,11 +205,23 @@ impl Pending { /// Removes the callbacks for all items have that expired. pub fn clear_expired_callbacks(&self) { - let items = self.pending.read().keys().copied().collect::>(); let now = OffsetDateTime::now_utc().unix_timestamp(); - for item in items.into_iter() { - self.clear_expired_callbacks_for_item(now, item); - } + // Acquire the pending lock once for write access. + let mut pending = self.pending.write(); + + // Iterate over all items in pending to modify the data structure in-place. + pending.retain(|_, peer_map| { + // Iterate over each peer IP for the item and filter out expired callbacks. + for (_, callbacks) in peer_map.iter_mut() { + callbacks.retain(|(_, timestamp, _)| now - *timestamp <= CALLBACK_EXPIRATION_IN_SECS); + } + + // Remove peer IPs that no longer have any callbacks. + peer_map.retain(|_, callbacks| !callbacks.is_empty()); + + // Keep the item in the pending map only if there are callbacks left. + !peer_map.is_empty() + }); } } From f380d6f8124e9039aa36b2c4bb122d94e6f95efa Mon Sep 17 00:00:00 2001 From: Niklas Date: Mon, 29 Apr 2024 12:19:06 +0100 Subject: [PATCH 447/551] Add checks for MAX_TRANSACTION_SIZE Co-authored-by: Pranav Gaddamadugu <23022326+d0cd@users.noreply.github.com> --- node/bft/ledger-service/src/ledger.rs | 12 +++++++++--- node/rest/src/routes.rs | 10 +++++++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/node/bft/ledger-service/src/ledger.rs b/node/bft/ledger-service/src/ledger.rs index abf29f5e35..399723180e 100644 --- a/node/bft/ledger-service/src/ledger.rs +++ b/node/bft/ledger-service/src/ledger.rs @@ -22,7 +22,7 @@ use snarkvm::{ store::ConsensusStorage, Ledger, }, - prelude::{bail, Address, Field, Network, Result}, + prelude::{bail, Address, Field, FromBytes, Network, Result}, }; use indexmap::IndexMap; @@ -30,6 +30,7 @@ use lru::LruCache; use parking_lot::{Mutex, RwLock}; use std::{ fmt, + io::Read, ops::Range, sync::{ atomic::{AtomicBool, Ordering}, @@ -294,8 +295,13 @@ impl> LedgerService for CoreLedgerService< transaction_id: N::TransactionID, transaction: Data>, ) -> Result<()> { - // Deserialize the transaction. - let transaction = spawn_blocking!(transaction.deserialize_blocking())?; + // Deserialize the transaction. If the transaction exceeds the maximum size, then return an error. + let transaction = spawn_blocking!({ + match transaction { + Data::Object(transaction) => Ok(transaction), + Data::Buffer(bytes) => Ok(Transaction::::read_le(&mut bytes.take(N::MAX_TRANSACTION_SIZE as u64))?), + } + })?; // Ensure the transaction ID matches in the transaction. if transaction_id != transaction.id() { bail!("Invalid transaction - expected {transaction_id}, found {}", transaction.id()); diff --git a/node/rest/src/routes.rs b/node/rest/src/routes.rs index 219dd6e975..49eb37c4cc 100644 --- a/node/rest/src/routes.rs +++ b/node/rest/src/routes.rs @@ -16,13 +16,14 @@ use super::*; use snarkos_node_router::{messages::UnconfirmedSolution, SYNC_LENIENCY}; use snarkvm::{ ledger::puzzle::Solution, - prelude::{block::Transaction, Identifier, Plaintext}, + prelude::{block::Transaction, Identifier, Plaintext, ToBytes}, }; use indexmap::IndexMap; use rayon::prelude::*; use serde::{Deserialize, Serialize}; use serde_json::json; +use snarkvm::prelude::LimitedWriter; /// The `get_blocks` query object. #[derive(Deserialize, Serialize)] @@ -334,6 +335,13 @@ impl, R: Routing> Rest { return Err(RestError(format!("Unable to broadcast transaction '{}' (node is syncing)", fmt_id(tx.id())))); } + // If the transaction exceeds the transaction size limit, return an error. + // TODO: Should this be a blocking task? + let buffer = Vec::with_capacity(N::MAX_TRANSACTION_SIZE); + if tx.write_le(LimitedWriter::new(buffer, N::MAX_TRANSACTION_SIZE)).is_err() { + return Err(RestError("Transaction size exceeds the byte limit".to_string())); + } + // If the consensus module is enabled, add the unconfirmed transaction to the memory pool. if let Some(consensus) = rest.consensus { // Add the unconfirmed transaction to the memory pool. From c0bb346211df17dd2ac175d55aba1a9b80bc8a6a Mon Sep 17 00:00:00 2001 From: Niklas Date: Sun, 21 Apr 2024 18:36:25 +0100 Subject: [PATCH 448/551] tests: add large execution transaction helper --- .../messages/src/unconfirmed_transaction.rs | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/node/router/messages/src/unconfirmed_transaction.rs b/node/router/messages/src/unconfirmed_transaction.rs index ae24a9ff21..c64f0de490 100644 --- a/node/router/messages/src/unconfirmed_transaction.rs +++ b/node/router/messages/src/unconfirmed_transaction.rs @@ -60,7 +60,10 @@ impl FromBytes for UnconfirmedTransaction { pub mod prop_tests { use crate::{Transaction, UnconfirmedTransaction}; use snarkvm::{ - ledger::{ledger_test_helpers::sample_fee_public_transaction, narwhal::Data}, + ledger::{ + ledger_test_helpers::{sample_fee_public_transaction, sample_large_execution_transaction}, + narwhal::Data, + }, prelude::{FromBytes, TestRng, ToBytes}, }; @@ -79,12 +82,27 @@ pub mod prop_tests { .boxed() } + pub fn any_large_transaction() -> BoxedStrategy> { + any::() + .prop_map(|seed| { + let mut rng = TestRng::fixed(seed); + sample_large_execution_transaction(&mut rng) + }) + .boxed() + } + pub fn any_unconfirmed_transaction() -> BoxedStrategy> { any_transaction() .prop_map(|tx| UnconfirmedTransaction { transaction_id: tx.id(), transaction: Data::Object(tx) }) .boxed() } + pub fn any_large_unconfirmed_transaction() -> BoxedStrategy> { + any_large_transaction() + .prop_map(|tx| UnconfirmedTransaction { transaction_id: tx.id(), transaction: Data::Object(tx) }) + .boxed() + } + #[proptest] fn unconfirmed_transaction_roundtrip( #[strategy(any_unconfirmed_transaction())] original: UnconfirmedTransaction, From 899bfb5a8770a332324b8f23bd9ad5768b96c9b8 Mon Sep 17 00:00:00 2001 From: Niklas Date: Sun, 21 Apr 2024 18:37:43 +0100 Subject: [PATCH 449/551] feat: check transaction length before decoding --- node/router/messages/src/helpers/codec.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/node/router/messages/src/helpers/codec.rs b/node/router/messages/src/helpers/codec.rs index e3a12b7227..e41d76b120 100644 --- a/node/router/messages/src/helpers/codec.rs +++ b/node/router/messages/src/helpers/codec.rs @@ -75,6 +75,23 @@ impl Decoder for MessageCodec { None => return Ok(None), }; + // Store the length to be checked against the max message size for each variant. + let len = bytes.len(); + if len < 2 { + return Err(std::io::Error::new(std::io::ErrorKind::InvalidData, "invalid message")); + } + + // Check the first two bytes for the message ID. + let id_bytes: [u8; 2] = (&bytes[..2]) + .try_into() + .map_err(|_| std::io::Error::new(std::io::ErrorKind::InvalidData, "id couldn't be deserialized"))?; + let id = u16::from_le_bytes(id_bytes); + + // SPECIAL CASE: check the transaction message isn't too large. + if id == 12 && len > N::MAX_TRANSACTION_SIZE { + return Err(std::io::Error::new(std::io::ErrorKind::InvalidData, "transaction is too large"))?; + } + // Convert the bytes to a message, or fail if it is not valid. let reader = bytes.reader(); match Message::read_le(reader) { From e3f7f3c1fbfac5f6dbb624294b2cced90d5fb12e Mon Sep 17 00:00:00 2001 From: Niklas Date: Sun, 21 Apr 2024 18:38:50 +0100 Subject: [PATCH 450/551] tests: proptest codec with unconfirmed transactions --- node/router/messages/src/helpers/codec.rs | 33 +++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/node/router/messages/src/helpers/codec.rs b/node/router/messages/src/helpers/codec.rs index e41d76b120..52f8b083da 100644 --- a/node/router/messages/src/helpers/codec.rs +++ b/node/router/messages/src/helpers/codec.rs @@ -103,3 +103,36 @@ impl Decoder for MessageCodec { } } } + +#[cfg(test)] +mod tests { + use super::*; + + use crate::{ + unconfirmed_transaction::prop_tests::{any_large_unconfirmed_transaction, any_unconfirmed_transaction}, + UnconfirmedTransaction, + }; + + use proptest::prelude::ProptestConfig; + use test_strategy::proptest; + + type CurrentNetwork = snarkvm::prelude::MainnetV0; + + #[proptest] + fn unconfirmed_transaction(#[strategy(any_unconfirmed_transaction())] tx: UnconfirmedTransaction) { + let mut bytes = BytesMut::new(); + let mut codec = MessageCodec::::default(); + assert!(codec.encode(Message::UnconfirmedTransaction(tx), &mut bytes).is_ok()); + assert!(codec.decode(&mut bytes).is_ok()); + } + + #[proptest(ProptestConfig { cases : 10, ..ProptestConfig::default() })] + fn overly_large_unconfirmed_transaction( + #[strategy(any_large_unconfirmed_transaction())] tx: UnconfirmedTransaction, + ) { + let mut bytes = BytesMut::new(); + let mut codec = MessageCodec::::default(); + assert!(codec.encode(Message::UnconfirmedTransaction(tx), &mut bytes).is_ok()); + assert!(matches!(codec.decode(&mut bytes), Err(err) if err.kind() == std::io::ErrorKind::InvalidData)); + } +} From a92a0fe5125b084c357cf7000892c9d39c317d15 Mon Sep 17 00:00:00 2001 From: Niklas Date: Tue, 23 Apr 2024 14:59:03 +0100 Subject: [PATCH 451/551] ref: move byte length check into `Message` --- node/router/messages/src/helpers/codec.rs | 17 +---------------- node/router/messages/src/lib.rs | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/node/router/messages/src/helpers/codec.rs b/node/router/messages/src/helpers/codec.rs index 52f8b083da..c9ecb0f227 100644 --- a/node/router/messages/src/helpers/codec.rs +++ b/node/router/messages/src/helpers/codec.rs @@ -75,22 +75,7 @@ impl Decoder for MessageCodec { None => return Ok(None), }; - // Store the length to be checked against the max message size for each variant. - let len = bytes.len(); - if len < 2 { - return Err(std::io::Error::new(std::io::ErrorKind::InvalidData, "invalid message")); - } - - // Check the first two bytes for the message ID. - let id_bytes: [u8; 2] = (&bytes[..2]) - .try_into() - .map_err(|_| std::io::Error::new(std::io::ErrorKind::InvalidData, "id couldn't be deserialized"))?; - let id = u16::from_le_bytes(id_bytes); - - // SPECIAL CASE: check the transaction message isn't too large. - if id == 12 && len > N::MAX_TRANSACTION_SIZE { - return Err(std::io::Error::new(std::io::ErrorKind::InvalidData, "transaction is too large"))?; - } + Self::Item::check_size(&bytes)?; // Convert the bytes to a message, or fail if it is not valid. let reader = bytes.reader(); diff --git a/node/router/messages/src/lib.rs b/node/router/messages/src/lib.rs index 8fe2c40d9a..ab75c13673 100644 --- a/node/router/messages/src/lib.rs +++ b/node/router/messages/src/lib.rs @@ -152,6 +152,28 @@ impl Message { Self::UnconfirmedTransaction(..) => 12, } } + + /// Checks the message byte length. To be used before deserialization. + pub fn check_size(bytes: &[u8]) -> io::Result<()> { + // Store the length to be checked against the max message size for each variant. + let len = bytes.len(); + if len < 2 { + return Err(io::Error::new(io::ErrorKind::InvalidData, "invalid message")); + } + + // Check the first two bytes for the message ID. + let id_bytes: [u8; 2] = (&bytes[..2]) + .try_into() + .map_err(|_| io::Error::new(io::ErrorKind::InvalidData, "id couldn't be deserialized"))?; + let id = u16::from_le_bytes(id_bytes); + + // SPECIAL CASE: check the transaction message isn't too large. + if id == 12 && len > N::MAX_TRANSACTION_SIZE { + return Err(io::Error::new(io::ErrorKind::InvalidData, "transaction is too large"))?; + } + + Ok(()) + } } impl ToBytes for Message { From fe7cbfa4e64e1088aee2b894f29f00b17f3d946b Mon Sep 17 00:00:00 2001 From: Niklas Date: Mon, 29 Apr 2024 12:06:25 +0100 Subject: [PATCH 452/551] deps: update snarkVM rev --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index d4e12cf020..f7fd192394 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "aef07da" +rev = "afacda3" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From 79efabe8243db7bc370706068a5a0f377c29dd4b Mon Sep 17 00:00:00 2001 From: Niklas Date: Mon, 29 Apr 2024 12:06:49 +0100 Subject: [PATCH 453/551] chore: update lock file --- Cargo.lock | 118 ++++++++++++++++++++++++++--------------------------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 47161b7847..c03fdce72c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3292,7 +3292,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "anstyle", "anyhow", @@ -3323,7 +3323,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "aleo-std", "anyhow", @@ -3353,7 +3353,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3367,7 +3367,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3378,7 +3378,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3388,7 +3388,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3398,7 +3398,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "indexmap 2.2.6", "itertools 0.11.0", @@ -3416,12 +3416,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3432,7 +3432,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3447,7 +3447,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3462,7 +3462,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3475,7 +3475,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3484,7 +3484,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3494,7 +3494,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3506,7 +3506,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3518,7 +3518,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3529,7 +3529,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3541,7 +3541,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3554,7 +3554,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "bs58", "snarkvm-console-network", @@ -3565,7 +3565,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "blake2s_simd", "smallvec", @@ -3578,7 +3578,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "aleo-std", "rayon", @@ -3589,7 +3589,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "anyhow", "indexmap 2.2.6", @@ -3612,7 +3612,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "anyhow", "bech32", @@ -3630,7 +3630,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "enum_index", "enum_index_derive", @@ -3651,7 +3651,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3666,7 +3666,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3677,7 +3677,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "snarkvm-console-network-environment", ] @@ -3685,7 +3685,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3695,7 +3695,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3706,7 +3706,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3717,7 +3717,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3728,7 +3728,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3739,7 +3739,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "rand", "rayon", @@ -3753,7 +3753,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "aleo-std", "anyhow", @@ -3770,7 +3770,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "aleo-std", "anyhow", @@ -3795,7 +3795,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "anyhow", "rand", @@ -3807,7 +3807,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3826,7 +3826,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "anyhow", "indexmap 2.2.6", @@ -3845,7 +3845,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -3858,7 +3858,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3871,7 +3871,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3884,7 +3884,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "bytes", "serde_json", @@ -3895,7 +3895,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3910,7 +3910,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "bytes", "serde_json", @@ -3923,7 +3923,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "snarkvm-console", "snarkvm-ledger-puzzle", @@ -3932,7 +3932,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "aleo-std", "anyhow", @@ -3952,7 +3952,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle-epoch" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "anyhow", "colored", @@ -3967,7 +3967,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "async-trait", "reqwest", @@ -3980,7 +3980,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "aleo-std-storage", "anyhow", @@ -4006,7 +4006,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4021,7 +4021,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4030,7 +4030,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "aleo-std", "anyhow", @@ -4055,7 +4055,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "aleo-std", "anyhow", @@ -4084,7 +4084,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "aleo-std", "colored", @@ -4107,7 +4107,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "indexmap 2.2.6", "paste", @@ -4121,7 +4121,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "bincode", "once_cell", @@ -4134,7 +4134,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "aleo-std", "anyhow", @@ -4155,7 +4155,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" dependencies = [ "proc-macro2", "quote 1.0.36", From ec4946d601ec051348fdfd66827b0a58d0d86ac9 Mon Sep 17 00:00:00 2001 From: Niklas Date: Tue, 30 Apr 2024 12:59:03 +0100 Subject: [PATCH 454/551] ref: move message size check to `UnconfirmedTransaction` --- node/router/messages/src/helpers/codec.rs | 4 ++-- .../messages/src/unconfirmed_transaction.rs | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/node/router/messages/src/helpers/codec.rs b/node/router/messages/src/helpers/codec.rs index c9ecb0f227..ca95988132 100644 --- a/node/router/messages/src/helpers/codec.rs +++ b/node/router/messages/src/helpers/codec.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::Message; +use crate::{Message, UnconfirmedTransaction}; use snarkvm::prelude::{FromBytes, Network, ToBytes}; use ::bytes::{Buf, BufMut, BytesMut}; @@ -75,7 +75,7 @@ impl Decoder for MessageCodec { None => return Ok(None), }; - Self::Item::check_size(&bytes)?; + UnconfirmedTransaction::::check_size(&bytes)?; // Convert the bytes to a message, or fail if it is not valid. let reader = bytes.reader(); diff --git a/node/router/messages/src/unconfirmed_transaction.rs b/node/router/messages/src/unconfirmed_transaction.rs index c64f0de490..f46eb8b157 100644 --- a/node/router/messages/src/unconfirmed_transaction.rs +++ b/node/router/messages/src/unconfirmed_transaction.rs @@ -56,6 +56,30 @@ impl FromBytes for UnconfirmedTransaction { } } +impl UnconfirmedTransaction { + /// Checks the message byte length. To be used before deserialization. + pub fn check_size(bytes: &[u8]) -> io::Result<()> { + // Store the length to be checked against the max message size for each variant. + let len = bytes.len(); + if len < 2 { + return Err(io::Error::new(io::ErrorKind::InvalidData, "invalid message")); + } + + // Check the first two bytes for the message ID. + let id_bytes: [u8; 2] = (&bytes[..2]) + .try_into() + .map_err(|_| io::Error::new(io::ErrorKind::InvalidData, "id couldn't be deserialized"))?; + let id = u16::from_le_bytes(id_bytes); + + // SPECIAL CASE: check the transaction message isn't too large. + if id == 12 && len > N::MAX_TRANSACTION_SIZE { + return Err(io::Error::new(io::ErrorKind::InvalidData, "transaction is too large"))?; + } + + Ok(()) + } +} + #[cfg(test)] pub mod prop_tests { use crate::{Transaction, UnconfirmedTransaction}; From 778030ebadea25d0c790c66d0162b11295ef8b38 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 30 Apr 2024 13:21:59 -0400 Subject: [PATCH 455/551] Resolve flaky test with sleep --- node/bft/src/helpers/pending.rs | 2 +- node/bft/src/worker.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index f4192d8866..cf68a39e54 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -28,7 +28,7 @@ use tokio::sync::oneshot; /// The maximum number of seconds to wait before expiring a callback. /// We ensure that we don't truncate `MAX_FETCH_TIMEOUT_IN_MS` when converting to seconds. -const CALLBACK_EXPIRATION_IN_SECS: i64 = MAX_FETCH_TIMEOUT_IN_MS.div_ceil(1000) as i64; +pub(crate) const CALLBACK_EXPIRATION_IN_SECS: i64 = MAX_FETCH_TIMEOUT_IN_MS.div_ceil(1000) as i64; /// Returns the maximum number of redundant requests for the number of validators in the specified round. pub fn max_redundant_requests(ledger: Arc>, round: u64) -> usize { diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index 7033b4173a..dc82d775ce 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -487,6 +487,7 @@ impl Worker { #[cfg(test)] mod tests { use super::*; + use crate::helpers::CALLBACK_EXPIRATION_IN_SECS; use snarkos_node_bft_ledger_service::LedgerService; use snarkos_node_bft_storage_service::BFTMemoryService; use snarkvm::{ @@ -865,7 +866,7 @@ mod tests { assert_eq!(worker.pending.num_callbacks(transmission_id), num_flood_requests); // Let all the requests expire. - tokio::time::sleep(Duration::from_millis(MAX_FETCH_TIMEOUT_IN_MS + 1000)).await; + tokio::time::sleep(Duration::from_secs(CALLBACK_EXPIRATION_IN_SECS as u64 + 1)).await; assert_eq!(worker.pending.num_sent_requests(transmission_id), 0); assert_eq!(worker.pending.num_callbacks(transmission_id), 0); From dc6a4f5066ede6a0510c5da2582f2c3b96b29a4f Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 30 Apr 2024 16:38:43 -0400 Subject: [PATCH 456/551] Introduce ProposalCache that is stored and loaded --- cli/src/commands/clean.rs | 12 +- node/bft/src/helpers/mod.rs | 3 + node/bft/src/helpers/proposal_cache.rs | 141 +++++++++++++++++++++++ node/bft/src/helpers/signed_proposals.rs | 10 +- node/bft/src/primary.rs | 69 ++++------- 5 files changed, 177 insertions(+), 58 deletions(-) create mode 100644 node/bft/src/helpers/proposal_cache.rs diff --git a/cli/src/commands/clean.rs b/cli/src/commands/clean.rs index 066ef52fd0..9dc323773b 100644 --- a/cli/src/commands/clean.rs +++ b/cli/src/commands/clean.rs @@ -16,7 +16,7 @@ use aleo_std::StorageMode; use anyhow::{bail, Result}; use clap::Parser; use colored::Colorize; -use snarkos_node::bft::batch_proposal_path; +use snarkos_node::bft::helpers::proposal_cache_path; use std::path::PathBuf; /// Cleans the snarkOS node storage. @@ -36,11 +36,11 @@ pub struct Clean { impl Clean { /// Cleans the snarkOS node storage. pub fn parse(self) -> Result { - // Remove the current batch proposal file, if it exists. - let proposal_path = batch_proposal_path(self.network, self.dev); - if proposal_path.exists() { - if let Err(err) = std::fs::remove_file(&proposal_path) { - bail!("Failed to remove the current batch proposal file at {}: {err}", proposal_path.display()); + // Remove the current proposal cache file, if it exists. + let proposal_cache_path = proposal_cache_path(self.network, self.dev); + if proposal_cache_path.exists() { + if let Err(err) = std::fs::remove_file(&proposal_cache_path) { + bail!("Failed to remove the current proposal cache file at {}: {err}", proposal_cache_path.display()); } } // Remove the specified ledger from storage. diff --git a/node/bft/src/helpers/mod.rs b/node/bft/src/helpers/mod.rs index fda524619f..c37950839d 100644 --- a/node/bft/src/helpers/mod.rs +++ b/node/bft/src/helpers/mod.rs @@ -30,6 +30,9 @@ pub use pending::*; pub mod proposal; pub use proposal::*; +pub mod proposal_cache; +pub use proposal_cache::*; + pub mod ready; pub use ready::*; diff --git a/node/bft/src/helpers/proposal_cache.rs b/node/bft/src/helpers/proposal_cache.rs new file mode 100644 index 0000000000..8f68be681d --- /dev/null +++ b/node/bft/src/helpers/proposal_cache.rs @@ -0,0 +1,141 @@ +// Copyright (C) 2019-2023 Aleo Systems Inc. +// This file is part of the snarkOS library. + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// http://www.apache.org/licenses/LICENSE-2.0 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use crate::helpers::{Proposal, SignedProposals}; + +use snarkvm::{ + console::{account::Address, network::Network}, + prelude::{anyhow, bail, FromBytes, IoResult, Read, Result, ToBytes, Write}, +}; + +use aleo_std::{aleo_ledger_dir, StorageMode}; +use std::{fs, path::PathBuf}; + +// Returns the path where a proposal cache file may be stored. +pub fn proposal_cache_path(network: u16, dev: Option) -> PathBuf { + // Obtain the path to the ledger. + let mut path = aleo_ledger_dir(network, StorageMode::from(dev)); + // Go to the folder right above the ledger. + path.pop(); + // Append the proposal store's file name. + path.push(&format!( + "current-proposal-cache-{network}{}", + if let Some(id) = dev { format!("-{id}") } else { "".into() } + )); + + path +} + +/// A helper type for the cache of proposal and signed proposals. +pub struct ProposalCache { + proposal: Option>, + signed_proposals: SignedProposals, +} + +impl ProposalCache { + /// Initializes a new instance of the proposal cache. + pub fn new(proposal: Option>, signed_proposals: SignedProposals) -> Self { + Self { proposal, signed_proposals } + } + + /// Ensure that the proposal and every signed proposal is associated with the `expected_signer`. + pub fn is_valid(&self, expected_signer: Address) -> bool { + self.proposal.as_ref().map(|proposal| proposal.batch_header().author() == expected_signer).unwrap_or(true) + && self.signed_proposals.is_valid(expected_signer) + } + + /// Returns `true` if a proposal cache exists for the given network and `dev`. + pub fn exists(dev: Option) -> bool { + proposal_cache_path(N::ID, dev).exists() + } + + /// Load the proposal cache from the file system and ensure that the proposal cache is valid. + pub fn load(expected_signer: Address, dev: Option) -> Result { + // Load the proposal cache from the file system. + let proposal_path = proposal_cache_path(N::ID, dev); + + // Deserialize the proposal cache from the file system. + let proposal_cache = match fs::read(&proposal_path) { + Ok(bytes) => match Self::from_bytes_le(&bytes) { + Ok(proposal_cache) => proposal_cache, + Err(_) => bail!("Couldn't deserialize the proposal stored at {}", proposal_path.display()), + }, + Err(_) => { + bail!("Couldn't read the proposal stored at {}", proposal_path.display()); + } + }; + + // Ensure the proposal cache is valid. + if !proposal_cache.is_valid(expected_signer) { + bail!("The proposal cache is invalid for the given address {expected_signer}"); + } + + Ok(proposal_cache) + } + + /// Store the proposal cache to the file system. + pub fn store(&self, dev: Option) -> Result<()> { + let path = proposal_cache_path(N::ID, dev); + info!("Storing the proposal cache to {}...", path.display()); + + // Serialize the proposal cache. + let bytes = self.to_bytes_le()?; + // Store the proposal cache to the file system. + fs::write(&path, bytes) + .map_err(|err| anyhow!("Couldn't write the proposal cache to {} - {err}", path.display()))?; + + Ok(()) + } + + /// Returns the proposal and signed proposals. + pub fn into(self) -> (Option>, SignedProposals) { + (self.proposal, self.signed_proposals) + } +} + +impl ToBytes for ProposalCache { + fn write_le(&self, mut writer: W) -> IoResult<()> { + // Serialize the `proposal`. + self.proposal.is_some().write_le(&mut writer)?; + if let Some(proposal) = &self.proposal { + proposal.write_le(&mut writer)?; + } + // Serialize the `signed_proposals`. + self.signed_proposals.write_le(&mut writer)?; + + Ok(()) + } +} + +impl FromBytes for ProposalCache { + fn read_le(mut reader: R) -> IoResult { + // Deserialize `proposal`. + let has_proposal: bool = FromBytes::read_le(&mut reader)?; + let proposal = match has_proposal { + true => Some(Proposal::read_le(&mut reader)?), + false => None, + }; + // Deserialize `signed_proposals`. + let signed_proposals = SignedProposals::read_le(&mut reader)?; + + Ok(Self::new(proposal, signed_proposals)) + } +} + +impl Default for ProposalCache { + /// Initializes a new instance of the proposal cache. + fn default() -> Self { + Self::new(None, Default::default()) + } +} diff --git a/node/bft/src/helpers/signed_proposals.rs b/node/bft/src/helpers/signed_proposals.rs index 52f72be794..98e9f0bc24 100644 --- a/node/bft/src/helpers/signed_proposals.rs +++ b/node/bft/src/helpers/signed_proposals.rs @@ -18,10 +18,10 @@ use snarkvm::{ network::Network, types::Field, }, - prelude::{FromBytes, ToBytes}, + prelude::{error, FromBytes, IoResult, Read, ToBytes, Write}, }; -use std::{collections::HashMap, io, ops::Deref}; +use std::{collections::HashMap, ops::Deref}; /// A helper type for the signed proposals. #[derive(Clone, PartialEq, Eq)] @@ -35,9 +35,9 @@ impl SignedProposals { } impl ToBytes for SignedProposals { - fn write_le(&self, mut writer: W) -> io::Result<()> { + fn write_le(&self, mut writer: W) -> IoResult<()> { // Write the number of signed proposals. - u32::try_from(self.0.len()).map_err(|_| io::ErrorKind::Other)?.write_le(&mut writer)?; + u32::try_from(self.0.len()).map_err(error)?.write_le(&mut writer)?; // Serialize the signed proposals. for (address, (round, timestamp, batch_id, signature)) in &self.0 { // Write the address. @@ -57,7 +57,7 @@ impl ToBytes for SignedProposals { } impl FromBytes for SignedProposals { - fn read_le(mut reader: R) -> io::Result { + fn read_le(mut reader: R) -> IoResult { // Read the number of signed proposals. let num_signed_proposals = u32::read_le(&mut reader)?; // Deserialize the signed proposals. diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index d7bba5b22c..4cf6e7cc81 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -26,6 +26,7 @@ use crate::{ PrimaryReceiver, PrimarySender, Proposal, + ProposalCache, SignedProposals, Storage, }, @@ -40,7 +41,6 @@ use crate::{ PRIMARY_PING_IN_MS, WORKER_PING_IN_MS, }; -use aleo_std::{aleo_ledger_dir, StorageMode}; use snarkos_account::Account; use snarkos_node_bft_events::PrimaryPing; use snarkos_node_bft_ledger_service::LedgerService; @@ -54,7 +54,7 @@ use snarkvm::{ narwhal::{BatchCertificate, BatchHeader, Data, Transmission, TransmissionID}, puzzle::{Solution, SolutionID}, }, - prelude::{committee::Committee, ToBytes}, + prelude::committee::Committee, }; use colored::Colorize; @@ -64,10 +64,8 @@ use parking_lot::{Mutex, RwLock}; use rayon::prelude::*; use std::{ collections::{HashMap, HashSet}, - fs, future::Future, net::SocketAddr, - path::PathBuf, sync::Arc, time::Duration, }; @@ -79,21 +77,6 @@ use tokio::{ /// A helper type for an optional proposed batch. pub type ProposedBatch = RwLock>>; -// Returns the path where a batch proposal file may be stored. -pub fn batch_proposal_path(network: u16, dev: Option) -> PathBuf { - // Obtain the path to the ledger. - let mut path = aleo_ledger_dir(network, StorageMode::from(dev)); - // Go to the folder right above the ledger. - path.pop(); - // Append the proposal's file name. - path.push(&format!( - "current_batch_proposal-{network}{}", - if let Some(id) = dev { format!("-{id}") } else { "".into() } - )); - - path -} - #[derive(Clone)] pub struct Primary { /// The sync module. @@ -137,18 +120,19 @@ impl Primary { let gateway = Gateway::new(account, storage.clone(), ledger.clone(), ip, trusted_validators, dev)?; // Initialize the sync module. let sync = Sync::new(gateway.clone(), storage.clone(), ledger.clone()); - // Check for the existence of a batch proposal file. - let proposed_batch = ProposedBatch::::default(); - let proposal_path = batch_proposal_path(N::ID, dev); - if let Ok(serialized_proposal) = fs::read(&proposal_path) { - match Proposal::::from_bytes_le(&serialized_proposal) { - Ok(proposal) => *proposed_batch.write() = Some(proposal), - Err(_) => bail!("Couldn't deserialize the proposal stored at {}", proposal_path.display()), - } - if let Err(err) = fs::remove_file(&proposal_path) { - bail!("Failed to remove the current batch proposal file at {}: {err}", proposal_path.display()); - } - } + + // Fetch the signed proposals from the file system if it exists. + let proposal_cache = match ProposalCache::::exists(dev) { + true => match ProposalCache::::load(gateway.account().address(), dev) { + Ok(proposal) => proposal, + Err(err) => { + bail!("Failed to read the signed proposals from the file system - {err}."); + } + }, + false => ProposalCache::default(), + }; + // Extract the proposal and signed proposals. + let (proposed_batch, signed_proposals) = proposal_cache.into(); // Initialize the primary instance. Ok(Self { @@ -158,9 +142,9 @@ impl Primary { ledger, workers: Arc::from(vec![]), bft_sender: Default::default(), - proposed_batch: Arc::new(proposed_batch), + proposed_batch: Arc::new(RwLock::new(proposed_batch)), latest_proposed_batch_timestamp: Default::default(), - signed_proposals: Default::default(), + signed_proposals: Arc::new(RwLock::new(signed_proposals)), handles: Default::default(), propose_lock: Default::default(), }) @@ -1577,20 +1561,11 @@ impl Primary { self.workers.iter().for_each(|worker| worker.shut_down()); // Abort the tasks. self.handles.lock().iter().for_each(|handle| handle.abort()); - // Save the current batch proposal to disk. - if let Some(proposal) = self.proposed_batch.write().take() { - let proposal_path = batch_proposal_path(N::ID, self.gateway.dev()); - - match proposal.to_bytes_le() { - Ok(proposal) => { - if let Err(err) = fs::write(&proposal_path, proposal) { - error!("Couldn't store the current proposal at {}: {err}.", proposal_path.display()); - } - } - Err(err) => { - error!("Couldn't serialize the current proposal: {err}."); - } - }; + // Save the current proposal cache to disk. + let proposal_cache = + ProposalCache::new(self.proposed_batch.write().take(), self.signed_proposals.write().clone()); + if let Err(err) = proposal_cache.store(self.gateway.dev()) { + error!("Failed to store the current proposal cache: {err}"); } // Close the gateway. self.gateway.shut_down().await; From 10a8bc2e01bf3afef2e2a9127b27ebe43706eb37 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 30 Apr 2024 17:20:10 -0400 Subject: [PATCH 457/551] Remove proposal expiration --- node/bft/src/helpers/signed_proposals.rs | 17 +- node/bft/src/helpers/timestamp.rs | 11 +- node/bft/src/lib.rs | 8 - node/bft/src/primary.rs | 251 +++-------------------- 4 files changed, 32 insertions(+), 255 deletions(-) diff --git a/node/bft/src/helpers/signed_proposals.rs b/node/bft/src/helpers/signed_proposals.rs index 98e9f0bc24..53a945536a 100644 --- a/node/bft/src/helpers/signed_proposals.rs +++ b/node/bft/src/helpers/signed_proposals.rs @@ -23,14 +23,15 @@ use snarkvm::{ use std::{collections::HashMap, ops::Deref}; -/// A helper type for the signed proposals. +/// The recently-signed batch proposals. +/// A map of `address` to (`round`, `batch ID`, `signature`). #[derive(Clone, PartialEq, Eq)] -pub struct SignedProposals(pub HashMap, (u64, i64, Field, Signature)>); +pub struct SignedProposals(pub HashMap, (u64, Field, Signature)>); impl SignedProposals { /// Ensure that every signed proposal is associated with the `expected_signer`. pub fn is_valid(&self, expected_signer: Address) -> bool { - self.0.iter().all(|(_, (_, _, _, signature))| signature.to_address() == expected_signer) + self.0.iter().all(|(_, (_, _, signature))| signature.to_address() == expected_signer) } } @@ -39,13 +40,11 @@ impl ToBytes for SignedProposals { // Write the number of signed proposals. u32::try_from(self.0.len()).map_err(error)?.write_le(&mut writer)?; // Serialize the signed proposals. - for (address, (round, timestamp, batch_id, signature)) in &self.0 { + for (address, (round, batch_id, signature)) in &self.0 { // Write the address. address.write_le(&mut writer)?; // Write the round. round.write_le(&mut writer)?; - // Write the timestamp. - timestamp.write_le(&mut writer)?; // Write the batch id. batch_id.write_le(&mut writer)?; // Write the signature. @@ -67,14 +66,12 @@ impl FromBytes for SignedProposals { let address = FromBytes::read_le(&mut reader)?; // Read the round. let round = FromBytes::read_le(&mut reader)?; - // Read the timestamp. - let timestamp = FromBytes::read_le(&mut reader)?; // Read the batch id. let batch_id = FromBytes::read_le(&mut reader)?; // Read the signature. let signature = FromBytes::read_le(&mut reader)?; // Insert the signed proposal. - signed_proposals.insert(address, (round, timestamp, batch_id, signature)); + signed_proposals.insert(address, (round, batch_id, signature)); } Ok(Self(signed_proposals)) @@ -82,7 +79,7 @@ impl FromBytes for SignedProposals { } impl Deref for SignedProposals { - type Target = HashMap, (u64, i64, Field, Signature)>; + type Target = HashMap, (u64, Field, Signature)>; fn deref(&self) -> &Self::Target { &self.0 diff --git a/node/bft/src/helpers/timestamp.rs b/node/bft/src/helpers/timestamp.rs index 2769101b7d..2b361fa3cc 100644 --- a/node/bft/src/helpers/timestamp.rs +++ b/node/bft/src/helpers/timestamp.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::{MAX_TIMESTAMP_DELTA_IN_SECS, PROPOSAL_EXPIRATION_IN_SECS}; +use crate::MAX_TIMESTAMP_DELTA_IN_SECS; use snarkvm::prelude::{bail, Result}; use time::OffsetDateTime; @@ -31,15 +31,6 @@ pub fn check_timestamp_for_liveness(timestamp: i64) -> Result<()> { Ok(()) } -/// Returns whether the proposal is expired. -pub fn is_proposal_expired(current_timestamp: i64, proposal_timestamp: i64) -> bool { - debug_assert!( - current_timestamp >= proposal_timestamp, - "Current timestamp must be greater or equal to the proposal timestamp" - ); - current_timestamp.saturating_sub(proposal_timestamp) >= PROPOSAL_EXPIRATION_IN_SECS -} - #[cfg(test)] mod prop_tests { use super::*; diff --git a/node/bft/src/lib.rs b/node/bft/src/lib.rs index 9fa6b1e4ee..ff2fe665a5 100644 --- a/node/bft/src/lib.rs +++ b/node/bft/src/lib.rs @@ -60,14 +60,6 @@ pub const MAX_TIMESTAMP_DELTA_IN_SECS: i64 = 10; // seconds /// The maximum number of workers that can be spawned. pub const MAX_WORKERS: u8 = 1; // worker(s) -/// The number of seconds a proposal is valid for before it expires. -#[cfg(not(any(test, feature = "test")))] -pub const PROPOSAL_EXPIRATION_IN_SECS: i64 = 60; // seconds -/// The number of seconds a proposal is valid for before it expires. -/// This is set to a deliberately low value (5) for testing purposes only. -#[cfg(any(test, feature = "test"))] -pub const PROPOSAL_EXPIRATION_IN_SECS: i64 = 5; // seconds - /// The frequency at which each primary broadcasts a ping to every other node. /// Note: If this is updated, be sure to update `MAX_BLOCKS_BEHIND` to correspond properly. pub const PRIMARY_PING_IN_MS: u64 = 2 * MAX_BATCH_DELAY_IN_MS; // ms diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 4cf6e7cc81..9e57f3c1cf 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -20,7 +20,6 @@ use crate::{ fmt_id, init_sync_channels, init_worker_channels, - is_proposal_expired, now, BFTSender, PrimaryReceiver, @@ -95,12 +94,12 @@ pub struct Primary { proposed_batch: Arc>, /// The timestamp of the most recent proposed batch. latest_proposed_batch_timestamp: Arc>, - /// The recently-signed batch proposals (a map from the address to the round, timestamp, batch ID, and signature). + /// The recently-signed batch proposals. signed_proposals: Arc>>, /// The spawned handles. handles: Arc>>>, /// The lock for propose_batch. - propose_lock: Arc>, + propose_lock: Arc>, } impl Primary { @@ -133,6 +132,8 @@ impl Primary { }; // Extract the proposal and signed proposals. let (proposed_batch, signed_proposals) = proposal_cache.into(); + // Construct the propose lock based on the proposed batch round. + let propose_lock = Arc::new(TMutex::new(proposed_batch.as_ref().map(Proposal::round).unwrap_or(0))); // Initialize the primary instance. Ok(Self { @@ -146,7 +147,7 @@ impl Primary { latest_proposed_batch_timestamp: Default::default(), signed_proposals: Arc::new(RwLock::new(signed_proposals)), handles: Default::default(), - propose_lock: Default::default(), + propose_lock, }) } @@ -481,15 +482,14 @@ impl Primary { // Determine the current timestamp. let current_timestamp = now(); // Determine if the current proposal is expired. - let is_expired = is_proposal_expired(current_timestamp, lock_guard.1); - if lock_guard.0 == round && !is_expired { + if *lock_guard == round { warn!("Primary is safely skipping a batch proposal - round {round} already proposed"); // Reinsert the transmissions back into the ready queue for the next proposal. self.reinsert_transmissions_into_workers(transmissions)?; return Ok(()); } - *lock_guard = (round, current_timestamp); + *lock_guard = round; /* Proceeding to sign & propose the batch. */ info!("Proposing a batch with {} transmissions for round {round}...", transmissions.len()); @@ -591,24 +591,21 @@ impl Primary { } // Retrieve the cached round and batch ID for this validator. - let signed_proposal = self.signed_proposals.read().get(&batch_author).copied(); - if let Some((signed_round, timestamp, signed_batch_id, signature)) = signed_proposal { - // If the signed round is ahead of the peer's batch round, then then ignore the proposal. + if let Some((signed_round, signed_batch_id, signature)) = + self.signed_proposals.read().get(&batch_author).copied() + { + // If the signed round is ahead of the peer's batch round, then the validator is malicious. if signed_round > batch_header.round() { - bail!("Proposed a batch for a previous round ({})", batch_header.round()); + // Proceed to disconnect the validator. + self.gateway.disconnect(peer_ip); + bail!("Malicious peer - proposed a batch for a previous round ({})", batch_header.round()); } - // If the round matches and the batch ID differs, then check if the proposal is expired. + + // If the round matches and the batch ID differs, then the validator is malicious. if signed_round == batch_header.round() && signed_batch_id != batch_header.batch_id() { - // Check if the proposal has expired. - match is_proposal_expired(now(), timestamp) { - // If the proposal has expired, then remove the cached signature. - true => self.signed_proposals.write().0.remove(&batch_author), - // If the proposal has not expired, then disconnect the validator. - false => { - self.gateway.disconnect(peer_ip); - bail!("Proposed another batch for the same round ({signed_round}) prior to expiration"); - } - }; + // Proceed to disconnect the validator. + self.gateway.disconnect(peer_ip); + bail!("Malicious peer - proposed another batch for the same round ({signed_round})"); } // If the round and batch ID matches, then skip signing the batch a second time. // Instead, rebroadcast the cached signature to the peer. @@ -668,8 +665,6 @@ impl Primary { // Retrieve the batch ID. let batch_id = batch_header.batch_id(); - // Retrieve the proposal timestamp. - let timestamp = batch_header.timestamp(); // Sign the batch ID. let account = self.gateway.account().clone(); let signature = spawn_blocking!(account.sign(&[batch_id], &mut rand::thread_rng()))?; @@ -688,13 +683,13 @@ impl Primary { if entry.get().0 == batch_round { return Ok(()); } - // Otherwise, cache the round, timestamp, batch ID, and signature for this validator. - entry.insert((batch_round, timestamp, batch_id, signature)); + // Otherwise, cache the round, batch ID, and signature for this validator. + entry.insert((batch_round, batch_id, signature)); } // If the validator has not signed a batch before, then continue. std::collections::hash_map::Entry::Vacant(entry) => { - // Cache the round, timestamp, batch ID, and signature for this validator. - entry.insert((batch_round, timestamp, batch_id, signature)); + // Cache the round, batch ID, and signature for this validator. + entry.insert((batch_round, batch_id, signature)); } }; @@ -1144,14 +1139,7 @@ impl Primary { async fn check_proposed_batch_for_expiration(&self) -> Result<()> { // Check if the proposed batch is timed out or stale. let is_expired = match self.proposed_batch.read().as_ref() { - Some(proposal) => { - // Determine if the proposal is stale. - let is_stale = proposal.round() < self.current_round(); - // Determine if the proposal is timed out. - let is_timed_out = is_proposal_expired(now(), proposal.timestamp()); - // Determine if the proposal is expired. - is_stale || is_timed_out - } + Some(proposal) => proposal.round() < self.current_round(), None => false, }; // If the batch is expired, clear the proposed batch. @@ -1575,7 +1563,6 @@ impl Primary { #[cfg(test)] mod tests { use super::*; - use crate::PROPOSAL_EXPIRATION_IN_SECS; use snarkos_node_bft_ledger_service::MockLedgerService; use snarkos_node_bft_storage_service::BFTMemoryService; use snarkvm::{ @@ -1943,49 +1930,6 @@ mod tests { assert!(proposed_transmissions.contains_key(&TransmissionID::Transaction(transaction_id))); } - #[tokio::test] - async fn test_propose_batch_expired() { - let round = 3; - let mut rng = TestRng::default(); - let (primary, accounts) = primary_without_handlers(&mut rng).await; - - // Fill primary storage. - store_certificate_chain(&primary, &accounts, round, &mut rng); - - // Try to propose a batch. There are no transmissions in the workers so the method should - // just return without proposing a batch. - assert!(primary.propose_batch().await.is_ok()); - assert!(primary.proposed_batch.read().is_none()); - - // Sleep for a while to ensure the primary is ready to propose the next round. - tokio::time::sleep(Duration::from_secs(MIN_BATCH_DELAY_IN_SECS)).await; - - // Generate a solution and a transaction. - let (solution_id, solution) = sample_unconfirmed_solution(&mut rng); - let (transaction_id, transaction) = sample_unconfirmed_transaction(&mut rng); - - // Store it on one of the workers. - primary.workers[0].process_unconfirmed_solution(solution_id, solution).await.unwrap(); - primary.workers[0].process_unconfirmed_transaction(transaction_id, transaction).await.unwrap(); - - // Propose a batch again. This time, it should succeed. - assert!(primary.propose_batch().await.is_ok()); - let original_proposed_batch_id = primary.proposed_batch.read().as_ref().unwrap().batch_id(); - - // Try to propose the batch again. This time, it should return the same proposal. - assert!(primary.propose_batch().await.is_ok()); - let proposal_batch_id = primary.proposed_batch.read().as_ref().unwrap().batch_id(); - assert_eq!(proposal_batch_id, original_proposed_batch_id); - - // Sleep until the proposal is expired. - tokio::time::sleep(Duration::from_secs(PROPOSAL_EXPIRATION_IN_SECS as u64)).await; - - // Try to propose a batch again. This time the proposal should be expired and a new proposal should be created. - assert!(primary.propose_batch().await.is_ok()); - let new_proposal_batch_id = primary.proposed_batch.read().as_ref().unwrap().batch_id(); - assert_ne!(new_proposal_batch_id, original_proposed_batch_id); - } - #[tokio::test] async fn test_batch_propose_from_peer() { let mut rng = TestRng::default(); @@ -2134,141 +2078,6 @@ mod tests { ); } - #[tokio::test] - async fn test_batch_propose_from_peer_expired() { - let round = 2; - let mut rng = TestRng::default(); - let (primary, accounts) = primary_without_handlers(&mut rng).await; - - // Generate certificates. - let previous_certificates = store_certificate_chain(&primary, &accounts, round, &mut rng); - - // Sleep for a while to ensure the primary is ready to propose the next round. - tokio::time::sleep(Duration::from_secs(MIN_BATCH_DELAY_IN_SECS)).await; - - // Create a valid proposal with an author that isn't the primary. - let peer_account = &accounts[1]; - let peer_address = peer_account.1.address(); - let peer_ip = peer_account.0; - let timestamp = now(); - let proposal = create_test_proposal( - &peer_account.1, - primary.ledger.current_committee().unwrap(), - round, - previous_certificates.clone(), - timestamp, - &mut rng, - ); - - // Make sure the primary is aware of the transmissions in the proposal. - for (transmission_id, transmission) in proposal.transmissions() { - primary.workers[0].process_transmission_from_peer(peer_ip, *transmission_id, transmission.clone()) - } - - // The author must be known to resolver to pass propose checks. - primary.gateway.resolver().insert_peer(peer_ip, peer_ip, peer_account.1.address()); - - // Try to process the batch proposal from the peer, should succeed. - primary.process_batch_propose_from_peer(peer_ip, (*proposal.batch_header()).clone().into()).await.unwrap(); - - // Fetch the original round and batch ID of the signed proposal. - let original_round = primary.signed_proposals.read().get(&peer_address).unwrap().0; - let original_batch_id = primary.signed_proposals.read().get(&peer_address).unwrap().2; - - // Construct a new proposal. - let new_proposal = create_test_proposal( - &peer_account.1, - primary.ledger.current_committee().unwrap(), - round, - previous_certificates.clone(), - now(), - &mut rng, - ); - - // Try to process the batch proposal from the peer again, should error. - assert!( - primary - .process_batch_propose_from_peer(peer_ip, (*new_proposal.batch_header()).clone().into()) - .await - .is_err() - ); - - // Ensure that the round and batch ID of the signed proposal did not change. - let round = primary.signed_proposals.read().get(&peer_address).unwrap().0; - let batch_id = primary.signed_proposals.read().get(&peer_address).unwrap().2; - assert_eq!(round, original_round); - assert_eq!(batch_id, original_batch_id); - } - - #[tokio::test] - async fn test_batch_propose_from_peer_after_expiration() { - let round = 2; - let mut rng = TestRng::default(); - let (primary, accounts) = primary_without_handlers(&mut rng).await; - - // Generate certificates. - let previous_certificates = store_certificate_chain(&primary, &accounts, round, &mut rng); - - // Sleep for a while to ensure the primary is ready to propose the next round. - tokio::time::sleep(Duration::from_secs(MIN_BATCH_DELAY_IN_SECS)).await; - - // Create a valid proposal with an author that isn't the primary. - let peer_account = &accounts[1]; - let peer_address = peer_account.1.address(); - let peer_ip = peer_account.0; - let timestamp = now(); - let proposal = create_test_proposal( - &peer_account.1, - primary.ledger.current_committee().unwrap(), - round, - previous_certificates.clone(), - timestamp, - &mut rng, - ); - - // Make sure the primary is aware of the transmissions in the proposal. - for (transmission_id, transmission) in proposal.transmissions() { - primary.workers[0].process_transmission_from_peer(peer_ip, *transmission_id, transmission.clone()) - } - - // The author must be known to resolver to pass propose checks. - primary.gateway.resolver().insert_peer(peer_ip, peer_ip, peer_account.1.address()); - - // Try to process the batch proposal from the peer, should succeed. - primary.process_batch_propose_from_peer(peer_ip, (*proposal.batch_header()).clone().into()).await.unwrap(); - - // Fetch the original round and batch ID of the signed proposal. - let original_round = primary.signed_proposals.read().get(&peer_address).unwrap().0; - let original_batch_id = primary.signed_proposals.read().get(&peer_address).unwrap().2; - - // Sleep until the current proposal is expired. - tokio::time::sleep(Duration::from_secs(PROPOSAL_EXPIRATION_IN_SECS as u64)).await; - - // Create a new proposal after the previous one has expired. - let new_proposal = create_test_proposal( - &peer_account.1, - primary.ledger.current_committee().unwrap(), - round, - previous_certificates, - now(), - &mut rng, - ); - - // Make sure the primary is aware of the transmissions in the proposal. - for (transmission_id, transmission) in new_proposal.transmissions() { - primary.workers[0].process_transmission_from_peer(peer_ip, *transmission_id, transmission.clone()) - } - - // Try to process the batch proposal from the peer, should succeed. - primary.process_batch_propose_from_peer(peer_ip, (*new_proposal.batch_header()).clone().into()).await.unwrap(); - - // Ensure that the batch ID of the signed proposal has changed, but the round has not. - let round = primary.signed_proposals.read().get(&peer_address).unwrap().0; - let batch_id = primary.signed_proposals.read().get(&peer_account.1.address()).unwrap().2; - assert_eq!(round, original_round); - assert_ne!(batch_id, original_batch_id); - } - #[tokio::test] async fn test_batch_propose_from_peer_with_invalid_timestamp() { let round = 2; @@ -2362,9 +2171,6 @@ mod tests { // Store the proposal on the primary. *primary.proposed_batch.write() = Some(proposal); - // Sleep for a while to ensure the primary is ready to process the proposal. - tokio::time::sleep(Duration::from_secs(1)).await; - // Each committee member signs the batch. let signatures = peer_signatures_for_proposal(&primary, &accounts, &mut rng); @@ -2403,9 +2209,6 @@ mod tests { // Store the proposal on the primary. *primary.proposed_batch.write() = Some(proposal); - // Sleep for a while to ensure the primary is ready to process the proposal. - tokio::time::sleep(Duration::from_secs(1)).await; - // Each committee member signs the batch. let signatures = peer_signatures_for_proposal(&primary, &accounts, &mut rng); @@ -2441,9 +2244,6 @@ mod tests { // Store the proposal on the primary. *primary.proposed_batch.write() = Some(proposal); - // Sleep for a while to ensure the primary is ready to process the proposal. - tokio::time::sleep(Duration::from_secs(1)).await; - // Each committee member signs the batch. let signatures = peer_signatures_for_proposal(&primary, &accounts, &mut rng); @@ -2481,9 +2281,6 @@ mod tests { // Store the proposal on the primary. *primary.proposed_batch.write() = Some(proposal); - // Sleep for a while to ensure the primary is ready to process the proposal. - tokio::time::sleep(Duration::from_secs(1)).await; - // Each committee member signs the batch. let signatures = peer_signatures_for_proposal(&primary, &accounts, &mut rng); From c1af74f20794de95c3eaf1cbe54e481717fd829e Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 30 Apr 2024 17:22:24 -0400 Subject: [PATCH 458/551] Nit --- cli/src/commands/clean.rs | 3 ++- node/bft/src/helpers/proposal.rs | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cli/src/commands/clean.rs b/cli/src/commands/clean.rs index 9dc323773b..c1725e3fd2 100644 --- a/cli/src/commands/clean.rs +++ b/cli/src/commands/clean.rs @@ -12,11 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. +use snarkos_node::bft::helpers::proposal_cache_path; + use aleo_std::StorageMode; use anyhow::{bail, Result}; use clap::Parser; use colored::Colorize; -use snarkos_node::bft::helpers::proposal_cache_path; use std::path::PathBuf; /// Cleans the snarkOS node storage. diff --git a/node/bft/src/helpers/proposal.rs b/node/bft/src/helpers/proposal.rs index 098800f565..a04a321653 100644 --- a/node/bft/src/helpers/proposal.rs +++ b/node/bft/src/helpers/proposal.rs @@ -22,11 +22,11 @@ use snarkvm::{ committee::Committee, narwhal::{BatchCertificate, BatchHeader, Transmission, TransmissionID}, }, - prelude::{bail, ensure, FromBytes, Itertools, Result, ToBytes}, + prelude::{bail, ensure, error, FromBytes, IoResult, Itertools, Read, Result, ToBytes, Write}, }; use indexmap::{IndexMap, IndexSet}; -use std::{collections::HashSet, io}; +use std::collections::HashSet; pub struct Proposal { /// The proposed batch header. @@ -168,14 +168,14 @@ impl Proposal { } impl ToBytes for Proposal { - fn write_le(&self, mut writer: W) -> io::Result<()> { + fn write_le(&self, mut writer: W) -> IoResult<()> { self.batch_header.write_le(&mut writer)?; - u32::try_from(self.transmissions.len()).map_err(|_| io::ErrorKind::Other)?.write_le(&mut writer)?; + u32::try_from(self.transmissions.len()).map_err(error)?.write_le(&mut writer)?; for (transmission_id, transmission) in &self.transmissions { transmission_id.write_le(&mut writer)?; transmission.write_le(&mut writer)?; } - u32::try_from(self.signatures.len()).map_err(|_| io::ErrorKind::Other)?.write_le(&mut writer)?; + u32::try_from(self.signatures.len()).map_err(error)?.write_le(&mut writer)?; for signature in &self.signatures { signature.write_le(&mut writer)?; } @@ -184,7 +184,7 @@ impl ToBytes for Proposal { } impl FromBytes for Proposal { - fn read_le(mut reader: R) -> io::Result { + fn read_le(mut reader: R) -> IoResult { let batch_header = FromBytes::read_le(&mut reader)?; let num_transmissions = u32::read_le(&mut reader)?; let mut transmissions = IndexMap::default(); From 72dc8d2bbd7bc9f11666d1c2676a0e00e33796a2 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 30 Apr 2024 17:53:55 -0400 Subject: [PATCH 459/551] Add additional safety check --- node/bft/src/primary.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 9e57f3c1cf..8661df3026 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -311,6 +311,21 @@ impl Primary { // If there is a batch being proposed already, // rebroadcast the batch header to the non-signers, and return early. if let Some(proposal) = self.proposed_batch.read().as_ref() { + // Ensure that the storage is caught up to the proposal before proceeding to rebroadcast this. + if self.current_round() < proposal.round() + || proposal + .batch_header() + .previous_certificate_ids() + .iter() + .any(|id| !self.storage.contains_certificate(*id)) + { + // TODO (raychu86): Explicitly request the missing certificates from peers. + debug!( + "Cannot propose a batch for round {} - the current storage is not caught up to the proposed batch.", + proposal.round() + ); + return Ok(()); + } // Construct the event. // TODO(ljedrz): the BatchHeader should be serialized only once in advance before being sent to non-signers. let event = Event::BatchPropose(proposal.batch_header().clone().into()); From ceb5a811bb7112e4b1d90fb1c5a9c860f6d46e38 Mon Sep 17 00:00:00 2001 From: Niklas Date: Wed, 1 May 2024 05:37:48 +0100 Subject: [PATCH 460/551] ref: revert move message size check to `UnconfirmedTransaction` --- node/router/messages/src/helpers/codec.rs | 4 ++-- .../messages/src/unconfirmed_transaction.rs | 24 ------------------- 2 files changed, 2 insertions(+), 26 deletions(-) diff --git a/node/router/messages/src/helpers/codec.rs b/node/router/messages/src/helpers/codec.rs index ca95988132..c9ecb0f227 100644 --- a/node/router/messages/src/helpers/codec.rs +++ b/node/router/messages/src/helpers/codec.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::{Message, UnconfirmedTransaction}; +use crate::Message; use snarkvm::prelude::{FromBytes, Network, ToBytes}; use ::bytes::{Buf, BufMut, BytesMut}; @@ -75,7 +75,7 @@ impl Decoder for MessageCodec { None => return Ok(None), }; - UnconfirmedTransaction::::check_size(&bytes)?; + Self::Item::check_size(&bytes)?; // Convert the bytes to a message, or fail if it is not valid. let reader = bytes.reader(); diff --git a/node/router/messages/src/unconfirmed_transaction.rs b/node/router/messages/src/unconfirmed_transaction.rs index f46eb8b157..c64f0de490 100644 --- a/node/router/messages/src/unconfirmed_transaction.rs +++ b/node/router/messages/src/unconfirmed_transaction.rs @@ -56,30 +56,6 @@ impl FromBytes for UnconfirmedTransaction { } } -impl UnconfirmedTransaction { - /// Checks the message byte length. To be used before deserialization. - pub fn check_size(bytes: &[u8]) -> io::Result<()> { - // Store the length to be checked against the max message size for each variant. - let len = bytes.len(); - if len < 2 { - return Err(io::Error::new(io::ErrorKind::InvalidData, "invalid message")); - } - - // Check the first two bytes for the message ID. - let id_bytes: [u8; 2] = (&bytes[..2]) - .try_into() - .map_err(|_| io::Error::new(io::ErrorKind::InvalidData, "id couldn't be deserialized"))?; - let id = u16::from_le_bytes(id_bytes); - - // SPECIAL CASE: check the transaction message isn't too large. - if id == 12 && len > N::MAX_TRANSACTION_SIZE { - return Err(io::Error::new(io::ErrorKind::InvalidData, "transaction is too large"))?; - } - - Ok(()) - } -} - #[cfg(test)] pub mod prop_tests { use crate::{Transaction, UnconfirmedTransaction}; From bf377940a4da5be107118faf163ee80f6de3e6ae Mon Sep 17 00:00:00 2001 From: Niklas Date: Wed, 1 May 2024 05:46:28 +0100 Subject: [PATCH 461/551] ref: import ordering --- node/rest/src/routes.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/node/rest/src/routes.rs b/node/rest/src/routes.rs index 49eb37c4cc..bd73287d9f 100644 --- a/node/rest/src/routes.rs +++ b/node/rest/src/routes.rs @@ -16,14 +16,13 @@ use super::*; use snarkos_node_router::{messages::UnconfirmedSolution, SYNC_LENIENCY}; use snarkvm::{ ledger::puzzle::Solution, - prelude::{block::Transaction, Identifier, Plaintext, ToBytes}, + prelude::{block::Transaction, Identifier, LimitedWriter, Plaintext, ToBytes}, }; use indexmap::IndexMap; use rayon::prelude::*; use serde::{Deserialize, Serialize}; use serde_json::json; -use snarkvm::prelude::LimitedWriter; /// The `get_blocks` query object. #[derive(Deserialize, Serialize)] From 9208c5d1d8338490cfdfb2aa621ea1c01799ec69 Mon Sep 17 00:00:00 2001 From: Niklas Date: Wed, 1 May 2024 05:54:10 +0100 Subject: [PATCH 462/551] deps: update snarkVM rev --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index f7fd192394..5600054a6f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "afacda3" +rev = "57641ca" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From 96c756fad70108ad251acd72abd77fb7568e347a Mon Sep 17 00:00:00 2001 From: Niklas Date: Wed, 1 May 2024 05:54:22 +0100 Subject: [PATCH 463/551] chore: update lock file --- Cargo.lock | 118 ++++++++++++++++++++++++++--------------------------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c03fdce72c..7adfdba0b8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3292,7 +3292,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "anstyle", "anyhow", @@ -3323,7 +3323,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "aleo-std", "anyhow", @@ -3353,7 +3353,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3367,7 +3367,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3378,7 +3378,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3388,7 +3388,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3398,7 +3398,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "indexmap 2.2.6", "itertools 0.11.0", @@ -3416,12 +3416,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3432,7 +3432,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3447,7 +3447,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3462,7 +3462,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3475,7 +3475,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3484,7 +3484,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3494,7 +3494,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3506,7 +3506,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3518,7 +3518,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3529,7 +3529,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3541,7 +3541,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3554,7 +3554,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "bs58", "snarkvm-console-network", @@ -3565,7 +3565,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "blake2s_simd", "smallvec", @@ -3578,7 +3578,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "aleo-std", "rayon", @@ -3589,7 +3589,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "anyhow", "indexmap 2.2.6", @@ -3612,7 +3612,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "anyhow", "bech32", @@ -3630,7 +3630,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "enum_index", "enum_index_derive", @@ -3651,7 +3651,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3666,7 +3666,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3677,7 +3677,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-console-network-environment", ] @@ -3685,7 +3685,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3695,7 +3695,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3706,7 +3706,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3717,7 +3717,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3728,7 +3728,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3739,7 +3739,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "rand", "rayon", @@ -3753,7 +3753,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "aleo-std", "anyhow", @@ -3770,7 +3770,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "aleo-std", "anyhow", @@ -3795,7 +3795,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "anyhow", "rand", @@ -3807,7 +3807,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3826,7 +3826,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "anyhow", "indexmap 2.2.6", @@ -3845,7 +3845,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -3858,7 +3858,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3871,7 +3871,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3884,7 +3884,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "bytes", "serde_json", @@ -3895,7 +3895,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3910,7 +3910,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "bytes", "serde_json", @@ -3923,7 +3923,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-console", "snarkvm-ledger-puzzle", @@ -3932,7 +3932,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "aleo-std", "anyhow", @@ -3952,7 +3952,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle-epoch" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "anyhow", "colored", @@ -3967,7 +3967,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "async-trait", "reqwest", @@ -3980,7 +3980,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "aleo-std-storage", "anyhow", @@ -4006,7 +4006,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4021,7 +4021,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4030,7 +4030,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "aleo-std", "anyhow", @@ -4055,7 +4055,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "aleo-std", "anyhow", @@ -4084,7 +4084,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "aleo-std", "colored", @@ -4107,7 +4107,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "indexmap 2.2.6", "paste", @@ -4121,7 +4121,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "bincode", "once_cell", @@ -4134,7 +4134,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "aleo-std", "anyhow", @@ -4155,7 +4155,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=afacda3#afacda3707fca2b80cdbb686ebe91f9739df74f9" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "proc-macro2", "quote 1.0.36", From 5876dec5a4a6ad5fe059dd81a9a70e49bcdae540 Mon Sep 17 00:00:00 2001 From: Niklas Date: Wed, 1 May 2024 06:36:17 +0100 Subject: [PATCH 464/551] feat: check tx length in `ensure_transmission_is_well_formed` --- node/bft/ledger-service/src/ledger.rs | 41 +++++++++++++-------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/node/bft/ledger-service/src/ledger.rs b/node/bft/ledger-service/src/ledger.rs index 399723180e..b39763f61c 100644 --- a/node/bft/ledger-service/src/ledger.rs +++ b/node/bft/ledger-service/src/ledger.rs @@ -216,29 +216,26 @@ impl> LedgerService for CoreLedgerService< match (transmission_id, transmission) { (TransmissionID::Ratification, Transmission::Ratification) => {} (TransmissionID::Transaction(expected_transaction_id), Transmission::Transaction(transaction_data)) => { - match transaction_data.clone().deserialize_blocking() { - Ok(transaction) => { - // Ensure the transaction ID matches the expected transaction ID. - if transaction.id() != expected_transaction_id { - bail!( - "Received mismatching transaction ID - expected {}, found {}", - fmt_id(expected_transaction_id), - fmt_id(transaction.id()), - ); - } - - // Ensure the transaction is not a fee transaction. - if transaction.is_fee() { - bail!("Received a fee transaction in a transmission"); - } - - // Update the transmission with the deserialized transaction. - *transaction_data = Data::Object(transaction); - } - Err(err) => { - bail!("Failed to deserialize transaction: {err}"); - } + // Deserialize the transaction. If the transaction exceeds the maximum size, then return an error. + let transaction = match transaction_data.clone() { + Data::Object(transaction) => transaction, + Data::Buffer(bytes) => Transaction::::read_le(&mut bytes.take(N::MAX_TRANSACTION_SIZE as u64))?, + }; + // Ensure the transaction ID matches the expected transaction ID. + if transaction.id() != expected_transaction_id { + bail!( + "Received mismatching transaction ID - expected {}, found {}", + fmt_id(expected_transaction_id), + fmt_id(transaction.id()), + ); } + // Ensure the transaction is not a fee transaction. + if transaction.is_fee() { + bail!("Received a fee transaction in a transmission"); + } + + // Update the transmission with the deserialized transaction. + *transaction_data = Data::Object(transaction); } (TransmissionID::Solution(expected_solution_id), Transmission::Solution(solution_data)) => { match solution_data.clone().deserialize_blocking() { From 7aaf2765bc7c53152f87b913c78b62892db54792 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 1 May 2024 15:33:09 -0400 Subject: [PATCH 465/551] Address comments --- node/bft/src/helpers/proposal_cache.rs | 11 +++++------ node/bft/src/primary.rs | 13 +++++-------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/node/bft/src/helpers/proposal_cache.rs b/node/bft/src/helpers/proposal_cache.rs index 8f68be681d..f4450e4765 100644 --- a/node/bft/src/helpers/proposal_cache.rs +++ b/node/bft/src/helpers/proposal_cache.rs @@ -63,17 +63,16 @@ impl ProposalCache { /// Load the proposal cache from the file system and ensure that the proposal cache is valid. pub fn load(expected_signer: Address, dev: Option) -> Result { // Load the proposal cache from the file system. - let proposal_path = proposal_cache_path(N::ID, dev); + let path = proposal_cache_path(N::ID, dev); + info!("Loading the proposal cache from {}...", path.display(),); // Deserialize the proposal cache from the file system. - let proposal_cache = match fs::read(&proposal_path) { + let proposal_cache = match fs::read(&path) { Ok(bytes) => match Self::from_bytes_le(&bytes) { Ok(proposal_cache) => proposal_cache, - Err(_) => bail!("Couldn't deserialize the proposal stored at {}", proposal_path.display()), + Err(_) => bail!("Couldn't deserialize the proposal stored at {}", path.display()), }, - Err(_) => { - bail!("Couldn't read the proposal stored at {}", proposal_path.display()); - } + Err(_) => bail!("Couldn't read the proposal stored at {}", path.display()), }; // Ensure the proposal cache is valid. diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 8661df3026..086970bfa0 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -321,8 +321,9 @@ impl Primary { { // TODO (raychu86): Explicitly request the missing certificates from peers. debug!( - "Cannot propose a batch for round {} - the current storage is not caught up to the proposed batch.", - proposal.round() + "Cannot propose a batch for round {} - the current storage {} is not caught up to the proposed batch.", + proposal.round(), + self.current_round(), ); return Ok(()); } @@ -611,16 +612,12 @@ impl Primary { { // If the signed round is ahead of the peer's batch round, then the validator is malicious. if signed_round > batch_header.round() { - // Proceed to disconnect the validator. - self.gateway.disconnect(peer_ip); - bail!("Malicious peer - proposed a batch for a previous round ({})", batch_header.round()); + bail!("Peer ({batch_author}) proposed a batch for a previous round ({})", batch_header.round()); } // If the round matches and the batch ID differs, then the validator is malicious. if signed_round == batch_header.round() && signed_batch_id != batch_header.batch_id() { - // Proceed to disconnect the validator. - self.gateway.disconnect(peer_ip); - bail!("Malicious peer - proposed another batch for the same round ({signed_round})"); + bail!("Peer ({batch_author}) proposed another batch for the same round ({signed_round})"); } // If the round and batch ID matches, then skip signing the batch a second time. // Instead, rebroadcast the cached signature to the peer. From 53eca2ffd697a50145a8f341bf60d6573872ac03 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 1 May 2024 15:35:07 -0400 Subject: [PATCH 466/551] nit --- node/bft/src/primary.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 086970bfa0..9ad93078a6 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -308,11 +308,16 @@ impl Primary { return Ok(()); } + // Retrieve the current round. + let round = self.current_round(); + // Compute the previous round. + let previous_round = round.saturating_sub(1); + // If there is a batch being proposed already, // rebroadcast the batch header to the non-signers, and return early. if let Some(proposal) = self.proposed_batch.read().as_ref() { // Ensure that the storage is caught up to the proposal before proceeding to rebroadcast this. - if self.current_round() < proposal.round() + if round < proposal.round() || proposal .batch_header() .previous_certificate_ids() @@ -321,9 +326,8 @@ impl Primary { { // TODO (raychu86): Explicitly request the missing certificates from peers. debug!( - "Cannot propose a batch for round {} - the current storage {} is not caught up to the proposed batch.", + "Cannot propose a batch for round {} - the current storage (round {round}) is not caught up to the proposed batch.", proposal.round(), - self.current_round(), ); return Ok(()); } @@ -352,11 +356,6 @@ impl Primary { return Ok(()); } - // Retrieve the current round. - let round = self.current_round(); - // Compute the previous round. - let previous_round = round.saturating_sub(1); - #[cfg(feature = "metrics")] metrics::gauge(metrics::bft::PROPOSAL_ROUND, round as f64); From e4d817583073688bde5a37df2d66d50cb0d0591f Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 1 May 2024 19:31:10 -0400 Subject: [PATCH 467/551] Add periodic round increments if quorum is met --- node/bft/src/primary.rs | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 9ad93078a6..51dee338bc 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -1102,6 +1102,46 @@ impl Primary { } }); + // Periodically try to increment to the next round. + // Note: This is necessary to ensure that the primary is not stuck on a previous round + // despite having received enough certificates to advance to the next round. + let self_ = self.clone(); + self.spawn(async move { + loop { + // Sleep briefly. + tokio::time::sleep(Duration::from_millis(MAX_BATCH_DELAY_IN_MS)).await; + // If the primary is not synced, then do not increment to the next round. + if !self_.sync.is_synced() { + trace!("Skipping round increment {}", "(node is syncing)".dimmed()); + continue; + } + // Attempt to increment to the next round. + let next_round = self_.current_round().saturating_add(1); + // Determine if the quorum threshold is reached for the current round. + let is_quorum_threshold_reached = { + // Retrieve the certificates for the next round. + let certificates = self_.storage.get_certificates_for_round(next_round); + // If there are no certificates, then skip this check. + if certificates.is_empty() { + continue; + } + let authors = certificates.iter().map(BatchCertificate::author).collect(); + let Ok(committee_lookback) = self_.ledger.get_committee_lookback_for_round(next_round) else { + warn!("Failed to retrieve the committee lookback for round {next_round}"); + continue; + }; + committee_lookback.is_quorum_threshold_reached(&authors) + }; + // Attempt to increment to the next round if the quorum threshold is reached. + if is_quorum_threshold_reached { + debug!("Quorum threshold reached for round {}", next_round); + if let Err(e) = self_.try_increment_to_the_next_round(next_round).await { + warn!("Failed to increment to the next round - {e}"); + } + } + } + }); + // Process the unconfirmed solutions. let self_ = self.clone(); self.spawn(async move { From d3dc630ad4b3e97abdb1cbf8feb49b507e0158d9 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 1 May 2024 20:21:53 -0400 Subject: [PATCH 468/551] Store the latest storage round to ProposalCache --- node/bft/src/helpers/proposal_cache.rs | 32 ++++++++++++++++++-------- node/bft/src/primary.rs | 21 +++++++++++------ 2 files changed, 37 insertions(+), 16 deletions(-) diff --git a/node/bft/src/helpers/proposal_cache.rs b/node/bft/src/helpers/proposal_cache.rs index f4450e4765..ef95e4e8d6 100644 --- a/node/bft/src/helpers/proposal_cache.rs +++ b/node/bft/src/helpers/proposal_cache.rs @@ -39,19 +39,28 @@ pub fn proposal_cache_path(network: u16, dev: Option) -> PathBuf { /// A helper type for the cache of proposal and signed proposals. pub struct ProposalCache { + /// The latest round this node was on prior to the reboot. + latest_round: u64, + /// The latest proposal this node has created. proposal: Option>, + /// The signed proposals this node has received. signed_proposals: SignedProposals, } impl ProposalCache { /// Initializes a new instance of the proposal cache. - pub fn new(proposal: Option>, signed_proposals: SignedProposals) -> Self { - Self { proposal, signed_proposals } + pub fn new(latest_round: u64, proposal: Option>, signed_proposals: SignedProposals) -> Self { + Self { latest_round, proposal, signed_proposals } } /// Ensure that the proposal and every signed proposal is associated with the `expected_signer`. pub fn is_valid(&self, expected_signer: Address) -> bool { - self.proposal.as_ref().map(|proposal| proposal.batch_header().author() == expected_signer).unwrap_or(true) + self.proposal + .as_ref() + .map(|proposal| { + proposal.batch_header().author() == expected_signer && self.latest_round == proposal.round() + }) + .unwrap_or(true) && self.signed_proposals.is_valid(expected_signer) } @@ -64,7 +73,6 @@ impl ProposalCache { pub fn load(expected_signer: Address, dev: Option) -> Result { // Load the proposal cache from the file system. let path = proposal_cache_path(N::ID, dev); - info!("Loading the proposal cache from {}...", path.display(),); // Deserialize the proposal cache from the file system. let proposal_cache = match fs::read(&path) { @@ -80,6 +88,8 @@ impl ProposalCache { bail!("The proposal cache is invalid for the given address {expected_signer}"); } + info!("Loaded the proposal cache from {} at round {}", path.display(), proposal_cache.latest_round); + Ok(proposal_cache) } @@ -97,14 +107,16 @@ impl ProposalCache { Ok(()) } - /// Returns the proposal and signed proposals. - pub fn into(self) -> (Option>, SignedProposals) { - (self.proposal, self.signed_proposals) + /// Returns the latest round, proposal and signed proposals. + pub fn into(self) -> (u64, Option>, SignedProposals) { + (self.latest_round, self.proposal, self.signed_proposals) } } impl ToBytes for ProposalCache { fn write_le(&self, mut writer: W) -> IoResult<()> { + // Serialize the `latest_round`. + self.latest_round.write_le(&mut writer)?; // Serialize the `proposal`. self.proposal.is_some().write_le(&mut writer)?; if let Some(proposal) = &self.proposal { @@ -119,6 +131,8 @@ impl ToBytes for ProposalCache { impl FromBytes for ProposalCache { fn read_le(mut reader: R) -> IoResult { + // Deserialize `latest_round`. + let latest_round = u64::read_le(&mut reader)?; // Deserialize `proposal`. let has_proposal: bool = FromBytes::read_le(&mut reader)?; let proposal = match has_proposal { @@ -128,13 +142,13 @@ impl FromBytes for ProposalCache { // Deserialize `signed_proposals`. let signed_proposals = SignedProposals::read_le(&mut reader)?; - Ok(Self::new(proposal, signed_proposals)) + Ok(Self::new(latest_round, proposal, signed_proposals)) } } impl Default for ProposalCache { /// Initializes a new instance of the proposal cache. fn default() -> Self { - Self::new(None, Default::default()) + Self::new(0, None, Default::default()) } } diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 51dee338bc..afaf41e2f1 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -131,9 +131,7 @@ impl Primary { false => ProposalCache::default(), }; // Extract the proposal and signed proposals. - let (proposed_batch, signed_proposals) = proposal_cache.into(); - // Construct the propose lock based on the proposed batch round. - let propose_lock = Arc::new(TMutex::new(proposed_batch.as_ref().map(Proposal::round).unwrap_or(0))); + let (latest_certificate_round, proposed_batch, signed_proposals) = proposal_cache.into(); // Initialize the primary instance. Ok(Self { @@ -147,7 +145,7 @@ impl Primary { latest_proposed_batch_timestamp: Default::default(), signed_proposals: Arc::new(RwLock::new(signed_proposals)), handles: Default::default(), - propose_lock, + propose_lock: Arc::new(TMutex::new(latest_certificate_round)), }) } @@ -313,6 +311,12 @@ impl Primary { // Compute the previous round. let previous_round = round.saturating_sub(1); + // If the current storage round is below the current latest round, then return early. + if round < *lock_guard { + debug!("Cannot propose a batch for round {round} - the latest proposal cache round is {}", *lock_guard); + return Ok(()); + } + // If there is a batch being proposed already, // rebroadcast the batch header to the non-signers, and return early. if let Some(proposal) = self.proposed_batch.read().as_ref() { @@ -324,7 +328,6 @@ impl Primary { .iter() .any(|id| !self.storage.contains_certificate(*id)) { - // TODO (raychu86): Explicitly request the missing certificates from peers. debug!( "Cannot propose a batch for round {} - the current storage (round {round}) is not caught up to the proposed batch.", proposal.round(), @@ -1601,8 +1604,12 @@ impl Primary { // Abort the tasks. self.handles.lock().iter().for_each(|handle| handle.abort()); // Save the current proposal cache to disk. - let proposal_cache = - ProposalCache::new(self.proposed_batch.write().take(), self.signed_proposals.write().clone()); + let proposal_cache = { + let proposal = self.proposed_batch.write().take(); + let signed_proposals = self.signed_proposals.write().clone(); + let latest_round = proposal.as_ref().map(Proposal::round).unwrap_or(self.storage.current_round()); + ProposalCache::new(latest_round, proposal, signed_proposals) + }; if let Err(err) = proposal_cache.store(self.gateway.dev()) { error!("Failed to store the current proposal cache: {err}"); } From 600e8631f8effdf18176ad8e7a4d774c623c3d6a Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 1 May 2024 20:27:50 -0400 Subject: [PATCH 469/551] Bump snarkVM rev - 57641ca --- Cargo.lock | 118 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 2 +- 2 files changed, 60 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 47161b7847..7adfdba0b8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3292,7 +3292,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "anstyle", "anyhow", @@ -3323,7 +3323,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "aleo-std", "anyhow", @@ -3353,7 +3353,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3367,7 +3367,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3378,7 +3378,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3388,7 +3388,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3398,7 +3398,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "indexmap 2.2.6", "itertools 0.11.0", @@ -3416,12 +3416,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3432,7 +3432,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3447,7 +3447,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3462,7 +3462,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3475,7 +3475,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3484,7 +3484,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3494,7 +3494,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3506,7 +3506,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3518,7 +3518,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3529,7 +3529,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3541,7 +3541,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3554,7 +3554,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "bs58", "snarkvm-console-network", @@ -3565,7 +3565,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "blake2s_simd", "smallvec", @@ -3578,7 +3578,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "aleo-std", "rayon", @@ -3589,7 +3589,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "anyhow", "indexmap 2.2.6", @@ -3612,7 +3612,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "anyhow", "bech32", @@ -3630,7 +3630,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "enum_index", "enum_index_derive", @@ -3651,7 +3651,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3666,7 +3666,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3677,7 +3677,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-console-network-environment", ] @@ -3685,7 +3685,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3695,7 +3695,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3706,7 +3706,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3717,7 +3717,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3728,7 +3728,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3739,7 +3739,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "rand", "rayon", @@ -3753,7 +3753,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "aleo-std", "anyhow", @@ -3770,7 +3770,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "aleo-std", "anyhow", @@ -3795,7 +3795,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "anyhow", "rand", @@ -3807,7 +3807,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3826,7 +3826,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "anyhow", "indexmap 2.2.6", @@ -3845,7 +3845,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -3858,7 +3858,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3871,7 +3871,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3884,7 +3884,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "bytes", "serde_json", @@ -3895,7 +3895,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3910,7 +3910,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "bytes", "serde_json", @@ -3923,7 +3923,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "snarkvm-console", "snarkvm-ledger-puzzle", @@ -3932,7 +3932,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "aleo-std", "anyhow", @@ -3952,7 +3952,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle-epoch" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "anyhow", "colored", @@ -3967,7 +3967,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "async-trait", "reqwest", @@ -3980,7 +3980,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "aleo-std-storage", "anyhow", @@ -4006,7 +4006,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4021,7 +4021,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4030,7 +4030,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "aleo-std", "anyhow", @@ -4055,7 +4055,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "aleo-std", "anyhow", @@ -4084,7 +4084,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "aleo-std", "colored", @@ -4107,7 +4107,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "indexmap 2.2.6", "paste", @@ -4121,7 +4121,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "bincode", "once_cell", @@ -4134,7 +4134,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "aleo-std", "anyhow", @@ -4155,7 +4155,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=aef07da#aef07da8ed38aa4c3cdb2d946e0b6c783cc72cd3" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" dependencies = [ "proc-macro2", "quote 1.0.36", diff --git a/Cargo.toml b/Cargo.toml index d4e12cf020..5600054a6f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "aef07da" +rev = "57641ca" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From a5a9c3a1c73bf5ffeaf9bb236c7fb49873b70000 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 1 May 2024 20:58:19 -0400 Subject: [PATCH 470/551] Use propose lock for latest round --- node/bft/src/primary.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index afaf41e2f1..1cd5e09d91 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -1607,7 +1607,7 @@ impl Primary { let proposal_cache = { let proposal = self.proposed_batch.write().take(); let signed_proposals = self.signed_proposals.write().clone(); - let latest_round = proposal.as_ref().map(Proposal::round).unwrap_or(self.storage.current_round()); + let latest_round = proposal.as_ref().map(Proposal::round).unwrap_or(*self.propose_lock.lock().await); ProposalCache::new(latest_round, proposal, signed_proposals) }; if let Err(err) = proposal_cache.store(self.gateway.dev()) { From 011bb6060821c639700582b2938fee95d27401fd Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 1 May 2024 21:51:47 -0400 Subject: [PATCH 471/551] Add unit tests --- node/bft/src/helpers/proposal.rs | 35 ++++++++++++ node/bft/src/helpers/proposal_cache.rs | 39 ++++++++++++++ node/bft/src/helpers/signed_proposals.rs | 62 ++++++++++++++++++++- node/bft/src/helpers/storage.rs | 4 +- node/bft/src/primary.rs | 68 ++++++++++++++++++++++-- 5 files changed, 202 insertions(+), 6 deletions(-) diff --git a/node/bft/src/helpers/proposal.rs b/node/bft/src/helpers/proposal.rs index a04a321653..0305aa6e30 100644 --- a/node/bft/src/helpers/proposal.rs +++ b/node/bft/src/helpers/proposal.rs @@ -28,6 +28,7 @@ use snarkvm::{ use indexmap::{IndexMap, IndexSet}; use std::collections::HashSet; +#[derive(Debug, PartialEq, Eq)] pub struct Proposal { /// The proposed batch header. batch_header: BatchHeader, @@ -203,6 +204,40 @@ impl FromBytes for Proposal { } } +#[cfg(test)] +pub(crate) mod tests { + use super::*; + use crate::helpers::storage::tests::sample_transmissions; + use snarkvm::{console::network::MainnetV0, utilities::TestRng}; + + type CurrentNetwork = MainnetV0; + + const ITERATIONS: usize = 100; + + pub(crate) fn sample_proposal(rng: &mut TestRng) -> Proposal { + let certificate = snarkvm::ledger::narwhal::batch_certificate::test_helpers::sample_batch_certificate(rng); + let (_, transmissions) = sample_transmissions(&certificate, rng); + + let transmissions = transmissions.into_iter().map(|(id, (t, _))| (id, t)).collect::>(); + let batch_header = certificate.batch_header().clone(); + let signatures = certificate.signatures().copied().collect(); + + Proposal { batch_header, transmissions, signatures } + } + + #[test] + fn test_bytes() { + let rng = &mut TestRng::default(); + + for _ in 0..ITERATIONS { + let expected = sample_proposal(rng); + // Check the byte representation. + let expected_bytes = expected.to_bytes_le().unwrap(); + assert_eq!(expected, Proposal::read_le(&expected_bytes[..]).unwrap()); + } + } +} + #[cfg(test)] mod prop_tests { use crate::helpers::{ diff --git a/node/bft/src/helpers/proposal_cache.rs b/node/bft/src/helpers/proposal_cache.rs index ef95e4e8d6..b9570d22ee 100644 --- a/node/bft/src/helpers/proposal_cache.rs +++ b/node/bft/src/helpers/proposal_cache.rs @@ -38,6 +38,7 @@ pub fn proposal_cache_path(network: u16, dev: Option) -> PathBuf { } /// A helper type for the cache of proposal and signed proposals. +#[derive(Debug, PartialEq, Eq)] pub struct ProposalCache { /// The latest round this node was on prior to the reboot. latest_round: u64, @@ -152,3 +153,41 @@ impl Default for ProposalCache { Self::new(0, None, Default::default()) } } + +#[cfg(test)] +mod tests { + use super::*; + use crate::helpers::{proposal::tests::sample_proposal, signed_proposals::tests::sample_signed_proposals}; + use snarkvm::{ + console::{account::PrivateKey, network::MainnetV0}, + utilities::TestRng, + }; + + type CurrentNetwork = MainnetV0; + + const ITERATIONS: usize = 100; + + pub(crate) fn sample_proposal_cache( + signer: &PrivateKey, + rng: &mut TestRng, + ) -> ProposalCache { + let proposal = sample_proposal(rng); + let signed_proposals = sample_signed_proposals(signer, rng); + let round = proposal.round(); + + ProposalCache::new(round, Some(proposal), signed_proposals) + } + + #[test] + fn test_bytes() { + let rng = &mut TestRng::default(); + let singer_private_key = PrivateKey::::new(rng).unwrap(); + + for _ in 0..ITERATIONS { + let expected = sample_proposal_cache(&singer_private_key, rng); + // Check the byte representation. + let expected_bytes = expected.to_bytes_le().unwrap(); + assert_eq!(expected, ProposalCache::read_le(&expected_bytes[..]).unwrap()); + } + } +} diff --git a/node/bft/src/helpers/signed_proposals.rs b/node/bft/src/helpers/signed_proposals.rs index 53a945536a..2fd4a7aee6 100644 --- a/node/bft/src/helpers/signed_proposals.rs +++ b/node/bft/src/helpers/signed_proposals.rs @@ -25,7 +25,7 @@ use std::{collections::HashMap, ops::Deref}; /// The recently-signed batch proposals. /// A map of `address` to (`round`, `batch ID`, `signature`). -#[derive(Clone, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct SignedProposals(pub HashMap, (u64, Field, Signature)>); impl SignedProposals { @@ -92,3 +92,63 @@ impl Default for SignedProposals { Self(Default::default()) } } + +#[cfg(test)] +pub(crate) mod tests { + use super::*; + use snarkvm::{ + console::{account::PrivateKey, network::MainnetV0}, + utilities::{TestRng, Uniform}, + }; + + use rand::Rng; + + type CurrentNetwork = MainnetV0; + + const ITERATIONS: usize = 100; + + pub(crate) fn sample_signed_proposals( + signer: &PrivateKey, + rng: &mut TestRng, + ) -> SignedProposals { + let mut signed_proposals: HashMap<_, _> = Default::default(); + for _ in 0..CurrentNetwork::MAX_CERTIFICATES { + let private_key = PrivateKey::::new(rng).unwrap(); + let address = Address::try_from(&private_key).unwrap(); + + // Add the signed proposal to the map. + let round = rng.gen(); + let batch_id = Field::rand(rng); + let signature = signer.sign(&[batch_id], rng).unwrap(); + signed_proposals.insert(address, (round, batch_id, signature)); + } + + SignedProposals(signed_proposals) + } + + #[test] + fn test_bytes() { + let rng = &mut TestRng::default(); + let singer_private_key = PrivateKey::::new(rng).unwrap(); + + for _ in 0..ITERATIONS { + let expected = sample_signed_proposals(&singer_private_key, rng); + // Check the byte representation. + let expected_bytes = expected.to_bytes_le().unwrap(); + assert_eq!(expected, SignedProposals::read_le(&expected_bytes[..]).unwrap()); + } + } + + #[test] + fn test_is_valid() { + let rng = &mut TestRng::default(); + + for _ in 0..ITERATIONS { + let singer_private_key = PrivateKey::::new(rng).unwrap(); + let singer_address = Address::try_from(&singer_private_key).unwrap(); + let signed_proposals = sample_signed_proposals(&singer_private_key, rng); + // Ensure that the signed proposals are valid. + assert!(signed_proposals.is_valid(singer_address)); + } + } +} diff --git a/node/bft/src/helpers/storage.rs b/node/bft/src/helpers/storage.rs index bdaff5bc7d..d1ec13eaff 100644 --- a/node/bft/src/helpers/storage.rs +++ b/node/bft/src/helpers/storage.rs @@ -795,7 +795,7 @@ impl Storage { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use snarkos_node_bft_ledger_service::MockLedgerService; use snarkos_node_bft_storage_service::BFTMemoryService; @@ -841,7 +841,7 @@ mod tests { } /// Samples the random transmissions, returning the missing transmissions and the transmissions. - fn sample_transmissions( + pub(crate) fn sample_transmissions( certificate: &BatchCertificate, rng: &mut TestRng, ) -> ( diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 1cd5e09d91..263da07827 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -311,9 +311,9 @@ impl Primary { // Compute the previous round. let previous_round = round.saturating_sub(1); - // If the current storage round is below the current latest round, then return early. + // If the current storage round is below the latest proposal round, then return early. if round < *lock_guard { - debug!("Cannot propose a batch for round {round} - the latest proposal cache round is {}", *lock_guard); + warn!("Cannot propose a batch for round {round} - the latest proposal cache round is {}", *lock_guard); return Ok(()); } @@ -328,7 +328,7 @@ impl Primary { .iter() .any(|id| !self.storage.contains_certificate(*id)) { - debug!( + warn!( "Cannot propose a batch for round {} - the current storage (round {round}) is not caught up to the proposed batch.", proposal.round(), ); @@ -2208,6 +2208,68 @@ mod tests { ); } + #[tokio::test] + async fn test_propose_batch_with_storage_round_behind_proposal_lock() { + let round = 3; + let mut rng = TestRng::default(); + let (primary, _) = primary_without_handlers(&mut rng).await; + + // Check there is no batch currently proposed. + assert!(primary.proposed_batch.read().is_none()); + + // Generate a solution and a transaction. + let (solution_id, solution) = sample_unconfirmed_solution(&mut rng); + let (transaction_id, transaction) = sample_unconfirmed_transaction(&mut rng); + + // Store it on one of the workers. + primary.workers[0].process_unconfirmed_solution(solution_id, solution).await.unwrap(); + primary.workers[0].process_unconfirmed_transaction(transaction_id, transaction).await.unwrap(); + + // Set the proposal lock to a round ahead of the storage. + let old_proposal_lock_round = *primary.propose_lock.lock().await; + *primary.propose_lock.lock().await = round + 1; + + // Propose a batch and enforce that it fails. + assert!(primary.propose_batch().await.is_ok()); + assert!(primary.proposed_batch.read().is_none()); + + // Set the proposal lock back to the old round. + *primary.propose_lock.lock().await = old_proposal_lock_round; + + // Try to propose a batch again. This time, it should succeed. + assert!(primary.propose_batch().await.is_ok()); + assert!(primary.proposed_batch.read().is_some()); + } + + #[tokio::test] + async fn test_propose_batch_with_storage_round_behind_proposal() { + let round = 5; + let mut rng = TestRng::default(); + let (primary, accounts) = primary_without_handlers(&mut rng).await; + + // Generate previous certificates. + let previous_certificates = store_certificate_chain(&primary, &accounts, round, &mut rng); + + // Create a valid proposal. + let timestamp = now(); + let proposal = create_test_proposal( + primary.gateway.account(), + primary.ledger.current_committee().unwrap(), + round + 1, + previous_certificates, + timestamp, + &mut rng, + ); + + // Store the proposal on the primary. + *primary.proposed_batch.write() = Some(proposal); + + // Try to propose a batch will terminate early because the storage is behind the proposal. + assert!(primary.propose_batch().await.is_ok()); + assert!(primary.proposed_batch.read().is_some()); + assert!(primary.proposed_batch.read().as_ref().unwrap().round() > primary.current_round()); + } + #[tokio::test(flavor = "multi_thread")] async fn test_batch_signature_from_peer() { let mut rng = TestRng::default(); From 052b2874e668d15c1a285ef52074458f9396e8a1 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 1 May 2024 21:53:12 -0400 Subject: [PATCH 472/551] Update filename in dev instances --- node/bft/src/helpers/proposal_cache.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/node/bft/src/helpers/proposal_cache.rs b/node/bft/src/helpers/proposal_cache.rs index b9570d22ee..0c0350243b 100644 --- a/node/bft/src/helpers/proposal_cache.rs +++ b/node/bft/src/helpers/proposal_cache.rs @@ -24,15 +24,17 @@ use std::{fs, path::PathBuf}; // Returns the path where a proposal cache file may be stored. pub fn proposal_cache_path(network: u16, dev: Option) -> PathBuf { + const PROPOSAL_CACHE_FILE_NAME: &str = "current-proposal-cache"; + // Obtain the path to the ledger. let mut path = aleo_ledger_dir(network, StorageMode::from(dev)); // Go to the folder right above the ledger. path.pop(); // Append the proposal store's file name. - path.push(&format!( - "current-proposal-cache-{network}{}", - if let Some(id) = dev { format!("-{id}") } else { "".into() } - )); + match dev { + Some(id) => path.push(&format!(".{PROPOSAL_CACHE_FILE_NAME}-{}-{}", network, id)), + None => path.push(&format!("{PROPOSAL_CACHE_FILE_NAME}-{}", network)), + } path } From d038389f1420baa45963ec23aa1d3eb4328ee9a6 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 1 May 2024 22:00:03 -0400 Subject: [PATCH 473/551] Add documentation --- node/bft/src/helpers/proposal.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/node/bft/src/helpers/proposal.rs b/node/bft/src/helpers/proposal.rs index 0305aa6e30..effcee81b9 100644 --- a/node/bft/src/helpers/proposal.rs +++ b/node/bft/src/helpers/proposal.rs @@ -170,13 +170,18 @@ impl Proposal { impl ToBytes for Proposal { fn write_le(&self, mut writer: W) -> IoResult<()> { + // Write the batch header. self.batch_header.write_le(&mut writer)?; + // Write the number of transmissions. u32::try_from(self.transmissions.len()).map_err(error)?.write_le(&mut writer)?; + // Write the transmissions. for (transmission_id, transmission) in &self.transmissions { transmission_id.write_le(&mut writer)?; transmission.write_le(&mut writer)?; } + // Write the number of signatures. u32::try_from(self.signatures.len()).map_err(error)?.write_le(&mut writer)?; + // Write the signatures. for signature in &self.signatures { signature.write_le(&mut writer)?; } @@ -186,15 +191,20 @@ impl ToBytes for Proposal { impl FromBytes for Proposal { fn read_le(mut reader: R) -> IoResult { + // Read the batch header. let batch_header = FromBytes::read_le(&mut reader)?; + // Read the number of transmissions. let num_transmissions = u32::read_le(&mut reader)?; + // Read the transmissions. let mut transmissions = IndexMap::default(); for _ in 0..num_transmissions { let transmission_id = FromBytes::read_le(&mut reader)?; let transmission = FromBytes::read_le(&mut reader)?; transmissions.insert(transmission_id, transmission); } + // Read the number of signatures. let num_signatures = u32::read_le(&mut reader)?; + // Read the signatures. let mut signatures = IndexSet::default(); for _ in 0..num_signatures { signatures.insert(FromBytes::read_le(&mut reader)?); From c53f5fdc50cc47c68b04dad81e380e339e708e7b Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 2 May 2024 11:31:38 -0400 Subject: [PATCH 474/551] nits --- node/bft/src/helpers/proposal.rs | 8 ++++++++ node/bft/src/helpers/proposal_cache.rs | 2 +- node/bft/src/primary.rs | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/node/bft/src/helpers/proposal.rs b/node/bft/src/helpers/proposal.rs index effcee81b9..aefb1bd753 100644 --- a/node/bft/src/helpers/proposal.rs +++ b/node/bft/src/helpers/proposal.rs @@ -195,6 +195,10 @@ impl FromBytes for Proposal { let batch_header = FromBytes::read_le(&mut reader)?; // Read the number of transmissions. let num_transmissions = u32::read_le(&mut reader)?; + // Ensure the number of transmissions is within bounds (this is an early safety check). + if num_transmissions as usize > BatchHeader::::MAX_TRANSMISSIONS_PER_BATCH { + return Err(error("Invalid number of transmissions in the proposal")); + } // Read the transmissions. let mut transmissions = IndexMap::default(); for _ in 0..num_transmissions { @@ -204,6 +208,10 @@ impl FromBytes for Proposal { } // Read the number of signatures. let num_signatures = u32::read_le(&mut reader)?; + // Ensure the number of signatures is within bounds (this is an early safety check). + if num_signatures as usize > Committee::::MAX_COMMITTEE_SIZE as usize { + return Err(error("Invalid number of signatures in the proposal")); + } // Read the signatures. let mut signatures = IndexSet::default(); for _ in 0..num_signatures { diff --git a/node/bft/src/helpers/proposal_cache.rs b/node/bft/src/helpers/proposal_cache.rs index 0c0350243b..030aa9936f 100644 --- a/node/bft/src/helpers/proposal_cache.rs +++ b/node/bft/src/helpers/proposal_cache.rs @@ -74,7 +74,7 @@ impl ProposalCache { /// Load the proposal cache from the file system and ensure that the proposal cache is valid. pub fn load(expected_signer: Address, dev: Option) -> Result { - // Load the proposal cache from the file system. + // Construct the proposal cache file system path. let path = proposal_cache_path(N::ID, dev); // Deserialize the proposal cache from the file system. diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 263da07827..2953f7aa95 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -1128,11 +1128,11 @@ impl Primary { if certificates.is_empty() { continue; } - let authors = certificates.iter().map(BatchCertificate::author).collect(); let Ok(committee_lookback) = self_.ledger.get_committee_lookback_for_round(next_round) else { warn!("Failed to retrieve the committee lookback for round {next_round}"); continue; }; + let authors = certificates.iter().map(BatchCertificate::author).collect(); committee_lookback.is_quorum_threshold_reached(&authors) }; // Attempt to increment to the next round if the quorum threshold is reached. @@ -1606,7 +1606,7 @@ impl Primary { // Save the current proposal cache to disk. let proposal_cache = { let proposal = self.proposed_batch.write().take(); - let signed_proposals = self.signed_proposals.write().clone(); + let signed_proposals = self.signed_proposals.read().clone(); let latest_round = proposal.as_ref().map(Proposal::round).unwrap_or(*self.propose_lock.lock().await); ProposalCache::new(latest_round, proposal, signed_proposals) }; From a2b887ff530ec5c00acedc53e055db7d6c6beb98 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 2 May 2024 13:58:05 -0400 Subject: [PATCH 475/551] Disable transaction loop for production environments --- node/src/validator/mod.rs | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/node/src/validator/mod.rs b/node/src/validator/mod.rs index 6e4046c001..294dfcba1a 100644 --- a/node/src/validator/mod.rs +++ b/node/src/validator/mod.rs @@ -361,20 +361,8 @@ impl> Validator { return Ok(()); } } - _ => { - // Retrieve the genesis committee. - let Ok(Some(committee)) = self.ledger.get_committee_for_round(0) else { - // If the genesis committee is not available, do not start the loop. - return Ok(()); - }; - // Retrieve the first member. - // Note: It is guaranteed that the committee has at least one member. - let first_member = committee.members().first().unwrap().0; - // If the node is not the first member, do not start the loop. - if self.address() != *first_member { - return Ok(()); - } - } + // If the node is not running in development mode, do not generate dev traffic. + _ => return Ok(()), } let self_ = self.clone(); From 2b75824d45a8d985507dfceba72077796366738a Mon Sep 17 00:00:00 2001 From: Niklas Date: Thu, 2 May 2024 21:53:30 +0200 Subject: [PATCH 476/551] ref: adjust the buffer size in `transaction_broadcast` --- node/rest/src/routes.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/node/rest/src/routes.rs b/node/rest/src/routes.rs index bd73287d9f..c6abb8fe8a 100644 --- a/node/rest/src/routes.rs +++ b/node/rest/src/routes.rs @@ -335,8 +335,10 @@ impl, R: Routing> Rest { } // If the transaction exceeds the transaction size limit, return an error. + // The buffer is initially roughly sized to hold a `transfer_public`, + // most transactions will be smaller and this reduces unnecessary allocations. // TODO: Should this be a blocking task? - let buffer = Vec::with_capacity(N::MAX_TRANSACTION_SIZE); + let buffer = Vec::with_capacity(3000); if tx.write_le(LimitedWriter::new(buffer, N::MAX_TRANSACTION_SIZE)).is_err() { return Err(RestError("Transaction size exceeds the byte limit".to_string())); } From 8d3a58b3b320f292e56174f0c66d6314995e0dac Mon Sep 17 00:00:00 2001 From: Niklas Date: Wed, 1 May 2024 20:19:54 +0100 Subject: [PATCH 477/551] feat: limit rest body size to 512KiB --- node/rest/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node/rest/src/lib.rs b/node/rest/src/lib.rs index fa12b09dae..c7d01c9480 100644 --- a/node/rest/src/lib.rs +++ b/node/rest/src/lib.rs @@ -200,8 +200,8 @@ impl, R: Routing> Rest { .layer(middleware::from_fn(log_middleware)) // Enable CORS. .layer(cors) - // Cap body size at 10MB. - .layer(DefaultBodyLimit::max(10 * 1024 * 1024)) + // Cap body size at 512KiB. + .layer(DefaultBodyLimit::max(512 * 1024)) .layer(GovernorLayer { // We can leak this because it is created only once and it persists. config: Box::leak(governor_config), From edb846a460dd9693ec88da63f601c52b3944a749 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 2 May 2024 17:29:30 -0400 Subject: [PATCH 478/551] Update logs and add minor optimization --- node/bft/src/bft.rs | 4 +++- node/bft/src/primary.rs | 23 +++++++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 62252c0b85..fe3937e89e 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -199,7 +199,9 @@ impl BFT { // Ensure the current round is at least the storage round (this is a sanity check). let storage_round = self.storage().current_round(); if current_round < storage_round { - warn!("BFT is safely skipping an update for round {current_round}, as storage is at round {storage_round}"); + debug!( + "BFT is safely skipping an update for round {current_round}, as storage is at round {storage_round}" + ); return false; } diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 2953f7aa95..7ff2d33015 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -384,7 +384,8 @@ impl Primary { } } } - bail!("Primary is safely skipping {}", format!("(round {round} was already certified)").dimmed()); + debug!("Primary is safely skipping {}", format!("(round {round} was already certified)").dimmed()); + return Ok(()); } // Retrieve the committee to check against. @@ -638,6 +639,16 @@ impl Primary { } } + // Ensure that the batch header doesn't already exist in storage. + // Note this is already checked in `check_batch_header`, however we can return early here without creating a blocking task. + if self.storage.contains_batch(batch_header.batch_id()) { + debug!( + "Primary is safely skipping a batch proposal from '{peer_ip}' - {}", + format!("batch for round {batch_round} already exists in storage").dimmed() + ); + return Ok(()); + } + // Compute the previous round. let previous_round = batch_round.saturating_sub(1); // Ensure that the peer did not propose a batch too quickly. @@ -762,7 +773,15 @@ impl Primary { // Ensure the batch ID matches the currently proposed batch ID. if proposal.batch_id() != batch_id { match self_.storage.contains_batch(batch_id) { - true => bail!("This batch was already certified"), + // If this batch was already certified, return early. + true => { + debug!( + "Primary is safely skipping a a batch signature from {peer_ip} for round {} - batch is already certified", + proposal.round() + ); + return Ok(None); + } + // If the batch ID is unknown, return an error. false => bail!( "Unknown batch ID '{batch_id}', expected '{}' for round {}", proposal.batch_id(), From 913db14f08e34d7a27814194a22c9400fe599691 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Fri, 3 May 2024 12:53:28 -0600 Subject: [PATCH 479/551] Update block_sync.rs Signed-off-by: Howard Wu <9260812+howardwu@users.noreply.github.com> --- node/sync/src/block_sync.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/node/sync/src/block_sync.rs b/node/sync/src/block_sync.rs index 36535679f4..6660a7fdaa 100644 --- a/node/sync/src/block_sync.rs +++ b/node/sync/src/block_sync.rs @@ -389,6 +389,9 @@ impl BlockSync { self.locators.write().insert(peer_ip, locators.clone()); // Compute the common ancestor with this node. + // Attention: Please do not optimize this loop, as it performs fork-detection. In addition, + // by iterating upwards, it also early-terminates malicious block locators at the *first* point + // of bifurcation in their ledger history, which is a critical safety guarantee provided here. let mut ancestor = 0; for (height, hash) in locators.clone().into_iter() { if let Ok(canon_hash) = self.canon.get_block_hash(height) { From fc340c679960e63612c536d69e71405b77e113f4 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 3 May 2024 20:38:09 -0400 Subject: [PATCH 480/551] Bump snarkVM rev - 5c57a48 --- Cargo.lock | 118 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 2 +- 2 files changed, 60 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7adfdba0b8..474b1e9a32 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3292,7 +3292,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "anstyle", "anyhow", @@ -3323,7 +3323,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "aleo-std", "anyhow", @@ -3353,7 +3353,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3367,7 +3367,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3378,7 +3378,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3388,7 +3388,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3398,7 +3398,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "indexmap 2.2.6", "itertools 0.11.0", @@ -3416,12 +3416,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3432,7 +3432,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3447,7 +3447,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3462,7 +3462,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3475,7 +3475,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3484,7 +3484,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3494,7 +3494,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3506,7 +3506,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3518,7 +3518,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3529,7 +3529,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3541,7 +3541,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3554,7 +3554,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "bs58", "snarkvm-console-network", @@ -3565,7 +3565,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "blake2s_simd", "smallvec", @@ -3578,7 +3578,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "aleo-std", "rayon", @@ -3589,7 +3589,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "anyhow", "indexmap 2.2.6", @@ -3612,7 +3612,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "anyhow", "bech32", @@ -3630,7 +3630,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "enum_index", "enum_index_derive", @@ -3651,7 +3651,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3666,7 +3666,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3677,7 +3677,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "snarkvm-console-network-environment", ] @@ -3685,7 +3685,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3695,7 +3695,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3706,7 +3706,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3717,7 +3717,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3728,7 +3728,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3739,7 +3739,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "rand", "rayon", @@ -3753,7 +3753,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "aleo-std", "anyhow", @@ -3770,7 +3770,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "aleo-std", "anyhow", @@ -3795,7 +3795,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "anyhow", "rand", @@ -3807,7 +3807,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3826,7 +3826,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "anyhow", "indexmap 2.2.6", @@ -3845,7 +3845,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -3858,7 +3858,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3871,7 +3871,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3884,7 +3884,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "bytes", "serde_json", @@ -3895,7 +3895,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3910,7 +3910,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "bytes", "serde_json", @@ -3923,7 +3923,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "snarkvm-console", "snarkvm-ledger-puzzle", @@ -3932,7 +3932,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "aleo-std", "anyhow", @@ -3952,7 +3952,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle-epoch" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "anyhow", "colored", @@ -3967,7 +3967,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "async-trait", "reqwest", @@ -3980,7 +3980,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "aleo-std-storage", "anyhow", @@ -4006,7 +4006,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4021,7 +4021,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4030,7 +4030,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "aleo-std", "anyhow", @@ -4055,7 +4055,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "aleo-std", "anyhow", @@ -4084,7 +4084,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "aleo-std", "colored", @@ -4107,7 +4107,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "indexmap 2.2.6", "paste", @@ -4121,7 +4121,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "bincode", "once_cell", @@ -4134,7 +4134,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "aleo-std", "anyhow", @@ -4155,7 +4155,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=57641ca#57641caff674ed383a49ae0edd8c52dec835c22b" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" dependencies = [ "proc-macro2", "quote 1.0.36", diff --git a/Cargo.toml b/Cargo.toml index 5600054a6f..f1257dc901 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "57641ca" +rev = "5c57a48" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From 1c748800b4cf6d8a85c0bf18534dd0cdb91dca66 Mon Sep 17 00:00:00 2001 From: Michael Turner Date: Sat, 4 May 2024 14:53:38 -0400 Subject: [PATCH 481/551] Put delegator retrieval into a blocking task + return an error if the node is too far behind --- node/rest/src/routes.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/node/rest/src/routes.rs b/node/rest/src/routes.rs index 28a94a9b7d..2d0f4003ce 100644 --- a/node/rest/src/routes.rs +++ b/node/rest/src/routes.rs @@ -269,7 +269,17 @@ impl, R: Routing> Rest { State(rest): State, Path(validator): Path>, ) -> Result { - Ok(ErasedJson::pretty(rest.ledger.get_delegators_for_validator(&validator)?)) + // Do not process the request if the node is too far behind to avoid sending outdated data. + if rest.routing.num_blocks_behind() > SYNC_LENIENCY { + return Err(RestError("Unable to request delegators (node is syncing)".to_string())); + } + + // Return the delegators for the given validator. + match tokio::task::spawn_blocking(move || rest.ledger.get_delegators_for_validator(&validator)).await { + Ok(Ok(delegators)) => Ok(ErasedJson::pretty(delegators)), + Ok(Err(err)) => Err(RestError(format!("Unable to request delegators - {err}"))), + Err(err) => Err(RestError(format!("Unable to request delegators - {err}"))), + } } // GET //peers/count From 8a127c77e27631d8e841cd901a1e18d513a0a2f5 Mon Sep 17 00:00:00 2001 From: Jos Dehaes Date: Thu, 25 Apr 2024 09:30:01 +0200 Subject: [PATCH 482/551] feat: dim logs on shutdown --- cli/Cargo.toml | 6 ++ cli/src/commands/start.rs | 24 ++++--- cli/src/helpers/dynamic_format.rs | 101 ++++++++++++++++++++++++++++++ cli/src/helpers/logger.rs | 17 ++++- cli/src/helpers/mod.rs | 3 + node/src/client/mod.rs | 4 +- node/src/node.rs | 14 ++++- node/src/prover/mod.rs | 4 +- node/src/validator/mod.rs | 5 +- node/tests/common/node.rs | 8 ++- 10 files changed, 162 insertions(+), 24 deletions(-) create mode 100644 cli/src/helpers/dynamic_format.rs diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 0ad106cb6e..7fdb352b4f 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -103,6 +103,9 @@ workspace = true [dependencies.sys-info] version = "0.9" +[dependencies.time] +version = "0.3" + [dependencies.thiserror] version = "1.0" @@ -110,6 +113,9 @@ version = "1.0" version = "1.28" features = [ "rt" ] +[dependencies.tracing] +version = "0.1" + [dependencies.tracing-subscriber] version = "0.3" features = [ "env-filter" ] diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index 6693ae44ba..09627331dd 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -40,7 +40,11 @@ use indexmap::IndexMap; use rand::SeedableRng; use rand_chacha::ChaChaRng; use serde::{Deserialize, Serialize}; -use std::{net::SocketAddr, path::PathBuf}; +use std::{ + net::SocketAddr, + path::PathBuf, + sync::{atomic::AtomicBool, Arc}, +}; use tokio::runtime::{self, Runtime}; /// The recommended minimum number of 'open files' limit for a validator. @@ -155,8 +159,12 @@ pub struct Start { impl Start { /// Starts the snarkOS node. pub fn parse(self) -> Result { + // Prepare the shutdown flag. + let shutdown: Arc = Default::default(); + // Initialize the logger. - let log_receiver = crate::helpers::initialize_logger(self.verbosity, self.nodisplay, self.logfile.clone()); + let log_receiver = + crate::helpers::initialize_logger(self.verbosity, self.nodisplay, self.logfile.clone(), shutdown.clone()); // Initialize the runtime. Self::runtime().block_on(async move { // Clone the configurations. @@ -165,7 +173,7 @@ impl Start { match cli.network { MainnetV0::ID => { // Parse the node from the configurations. - let node = cli.parse_node::().await.expect("Failed to parse the node"); + let node = cli.parse_node::(shutdown.clone()).await.expect("Failed to parse the node"); // If the display is enabled, render the display. if !cli.nodisplay { // Initialize the display. @@ -174,7 +182,7 @@ impl Start { } TestnetV0::ID => { // Parse the node from the configurations. - let node = cli.parse_node::().await.expect("Failed to parse the node"); + let node = cli.parse_node::(shutdown.clone()).await.expect("Failed to parse the node"); // If the display is enabled, render the display. if !cli.nodisplay { // Initialize the display. @@ -475,7 +483,7 @@ impl Start { /// Returns the node type corresponding to the given configurations. #[rustfmt::skip] - async fn parse_node(&mut self) -> Result> { + async fn parse_node(&mut self, shutdown: Arc) -> Result> { // Print the welcome. println!("{}", crate::helpers::welcome_message()); @@ -569,9 +577,9 @@ impl Start { // Initialize the node. match node_type { - NodeType::Validator => Node::new_validator(node_ip, bft_ip, rest_ip, self.rest_rps, account, &trusted_peers, &trusted_validators, genesis, cdn, storage_mode, self.allow_external_peers, dev_txs).await, - NodeType::Prover => Node::new_prover(node_ip, account, &trusted_peers, genesis, storage_mode).await, - NodeType::Client => Node::new_client(node_ip, rest_ip, self.rest_rps, account, &trusted_peers, genesis, cdn, storage_mode).await, + NodeType::Validator => Node::new_validator(node_ip, bft_ip, rest_ip, self.rest_rps, account, &trusted_peers, &trusted_validators, genesis, cdn, storage_mode, self.allow_external_peers, dev_txs, shutdown.clone()).await, + NodeType::Prover => Node::new_prover(node_ip, account, &trusted_peers, genesis, storage_mode, shutdown.clone()).await, + NodeType::Client => Node::new_client(node_ip, rest_ip, self.rest_rps, account, &trusted_peers, genesis, cdn, storage_mode, shutdown.clone()).await, } } diff --git a/cli/src/helpers/dynamic_format.rs b/cli/src/helpers/dynamic_format.rs new file mode 100644 index 0000000000..127c1d10eb --- /dev/null +++ b/cli/src/helpers/dynamic_format.rs @@ -0,0 +1,101 @@ +// Copyright (C) 2019-2023 Aleo Systems Inc. +// This file is part of the snarkOS library. + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// http://www.apache.org/licenses/LICENSE-2.0 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use std::sync::{ + atomic::{AtomicBool, Ordering}, + Arc, +}; + +use time::format_description::{self, BorrowedFormatItem}; +use tracing::{Event, Subscriber}; +use tracing_subscriber::{ + fmt::{format::Writer, FmtContext, FormatEvent, FormatFields}, + registry::LookupSpan, +}; + +pub struct DynamicFormatter<'b> { + dim_format: DimFormat<'b>, + default_format: tracing_subscriber::fmt::format::Format, + dim: Arc, +} + +impl<'b, S, N> FormatEvent for DynamicFormatter<'b> +where + S: Subscriber + for<'a> LookupSpan<'a>, + N: for<'a> FormatFields<'a> + 'static, +{ + fn format_event(&self, ctx: &FmtContext<'_, S, N>, writer: Writer<'_>, event: &Event<'_>) -> std::fmt::Result { + if self.dim.load(Ordering::Relaxed) { + self.dim_format.format_event(ctx, writer, event) + } else { + self.default_format.format_event(ctx, writer, event) + } + } +} + +impl<'b> DynamicFormatter<'b> { + pub fn new(dim: Arc) -> Self { + let dim_format = DimFormat::new(); + let default_format = tracing_subscriber::fmt::format::Format::default(); + Self { dim_format, default_format, dim } + } +} + +struct DimFormat<'b> { + fmt: Vec>, +} + +impl<'b> DimFormat<'b> { + fn new() -> Self { + let format = format_description::parse("[year]-[month]-[day]T[hour]:[minute]:[second].[subsecond digits:6]Z") + .expect("failed to set timestampt format"); + Self { fmt: format } + } +} + +impl<'b, S, N> FormatEvent for DimFormat<'b> +where + S: Subscriber + for<'a> LookupSpan<'a>, + N: for<'a> FormatFields<'a> + 'static, +{ + fn format_event(&self, ctx: &FmtContext<'_, S, N>, mut writer: Writer<'_>, event: &Event<'_>) -> std::fmt::Result { + // set the DIM style + if writer.has_ansi_escapes() { + write!(writer, "\x1b[2m")?; + } + + let date_time = time::OffsetDateTime::now_utc(); + write!(writer, "{} ", date_time.format(&self.fmt).map_err(|_| std::fmt::Error)?)?; + + let meta = event.metadata(); + let fmt_level = match *meta.level() { + tracing::Level::ERROR => "ERROR", + tracing::Level::WARN => "WARN ", + tracing::Level::INFO => "INFO ", + tracing::Level::DEBUG => "DEBUG", + tracing::Level::TRACE => "TRACE", + }; + write!(writer, "{}", fmt_level)?; + + write!(writer, "{}: ", meta.target())?; + + ctx.format_fields(writer.by_ref(), event)?; + + // reset the style + if writer.has_ansi_escapes() { + write!(writer, "\x1b[0m")?; + } + writeln!(writer) + } +} diff --git a/cli/src/helpers/logger.rs b/cli/src/helpers/logger.rs index 2bb5cf66ad..2fe07285d2 100644 --- a/cli/src/helpers/logger.rs +++ b/cli/src/helpers/logger.rs @@ -12,10 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::helpers::LogWriter; +use crate::helpers::{DynamicFormatter, LogWriter}; use crossterm::tty::IsTty; -use std::{fs::File, io, path::Path}; +use std::{ + fs::File, + io, + path::Path, + sync::{atomic::AtomicBool, Arc}, +}; use tokio::sync::mpsc; use tracing_subscriber::{ layer::{Layer, SubscriberExt}, @@ -34,7 +39,12 @@ use tracing_subscriber::{ /// 5 => info, debug, trace, snarkos_node_router=trace /// 6 => info, debug, trace, snarkos_node_tcp=trace /// ``` -pub fn initialize_logger>(verbosity: u8, nodisplay: bool, logfile: P) -> mpsc::Receiver> { +pub fn initialize_logger>( + verbosity: u8, + nodisplay: bool, + logfile: P, + shutdown: Arc, +) -> mpsc::Receiver> { match verbosity { 0 => std::env::set_var("RUST_LOG", "info"), 1 => std::env::set_var("RUST_LOG", "debug"), @@ -111,6 +121,7 @@ pub fn initialize_logger>(verbosity: u8, nodisplay: bool, logfile .with_ansi(log_sender.is_none() && io::stdout().is_tty()) .with_writer(move || LogWriter::new(&log_sender)) .with_target(verbosity > 2) + .event_format(DynamicFormatter::new(shutdown)) .with_filter(filter), ) .with( diff --git a/cli/src/helpers/mod.rs b/cli/src/helpers/mod.rs index de3838b1ad..7ea38c52f1 100644 --- a/cli/src/helpers/mod.rs +++ b/cli/src/helpers/mod.rs @@ -18,6 +18,9 @@ pub use bech32m::*; mod log_writer; use log_writer::*; +mod dynamic_format; +use dynamic_format::*; + pub mod logger; pub use logger::*; diff --git a/node/src/client/mod.rs b/node/src/client/mod.rs index 385ab355fe..f098f0af3e 100644 --- a/node/src/client/mod.rs +++ b/node/src/client/mod.rs @@ -83,10 +83,8 @@ impl> Client { genesis: Block, cdn: Option, storage_mode: StorageMode, + shutdown: Arc, ) -> Result { - // Prepare the shutdown flag. - let shutdown: Arc = Default::default(); - // Initialize the signal handler. let signal_node = Self::handle_signals(shutdown.clone()); diff --git a/node/src/node.rs b/node/src/node.rs index 9c4ce40299..f5fe6d2faa 100644 --- a/node/src/node.rs +++ b/node/src/node.rs @@ -26,7 +26,10 @@ use snarkvm::prelude::{ use aleo_std::StorageMode; use anyhow::Result; -use std::{net::SocketAddr, sync::Arc}; +use std::{ + net::SocketAddr, + sync::{atomic::AtomicBool, Arc}, +}; pub enum Node { /// A validator is a full node, capable of validating blocks. @@ -52,6 +55,7 @@ impl Node { storage_mode: StorageMode, allow_external_peers: bool, dev_txs: bool, + shutdown: Arc, ) -> Result { Ok(Self::Validator(Arc::new( Validator::new( @@ -67,6 +71,7 @@ impl Node { storage_mode, allow_external_peers, dev_txs, + shutdown, ) .await?, ))) @@ -79,8 +84,9 @@ impl Node { trusted_peers: &[SocketAddr], genesis: Block, storage_mode: StorageMode, + shutdown: Arc, ) -> Result { - Ok(Self::Prover(Arc::new(Prover::new(node_ip, account, trusted_peers, genesis, storage_mode).await?))) + Ok(Self::Prover(Arc::new(Prover::new(node_ip, account, trusted_peers, genesis, storage_mode, shutdown).await?))) } /// Initializes a new client node. @@ -93,9 +99,11 @@ impl Node { genesis: Block, cdn: Option, storage_mode: StorageMode, + shutdown: Arc, ) -> Result { Ok(Self::Client(Arc::new( - Client::new(node_ip, rest_ip, rest_rps, account, trusted_peers, genesis, cdn, storage_mode).await?, + Client::new(node_ip, rest_ip, rest_rps, account, trusted_peers, genesis, cdn, storage_mode, shutdown) + .await?, ))) } diff --git a/node/src/prover/mod.rs b/node/src/prover/mod.rs index 18d9f33e92..2286ed0370 100644 --- a/node/src/prover/mod.rs +++ b/node/src/prover/mod.rs @@ -92,10 +92,8 @@ impl> Prover { trusted_peers: &[SocketAddr], genesis: Block, storage_mode: StorageMode, + shutdown: Arc, ) -> Result { - // Prepare the shutdown flag. - let shutdown: Arc = Default::default(); - // Initialize the signal handler. let signal_node = Self::handle_signals(shutdown.clone()); diff --git a/node/src/validator/mod.rs b/node/src/validator/mod.rs index 294dfcba1a..47bc33699c 100644 --- a/node/src/validator/mod.rs +++ b/node/src/validator/mod.rs @@ -85,10 +85,8 @@ impl> Validator { storage_mode: StorageMode, allow_external_peers: bool, dev_txs: bool, + shutdown: Arc, ) -> Result { - // Prepare the shutdown flag. - let shutdown: Arc = Default::default(); - // Initialize the signal handler. let signal_node = Self::handle_signals(shutdown.clone()); @@ -490,6 +488,7 @@ mod tests { storage_mode, false, dev_txs, + Arc::new(AtomicBool::new(false)), ) .await .unwrap(); diff --git a/node/tests/common/node.rs b/node/tests/common/node.rs index 503a6f867e..aedfd88dd7 100644 --- a/node/tests/common/node.rs +++ b/node/tests/common/node.rs @@ -18,7 +18,10 @@ use snarkos_node::{Client, Prover, Validator}; use snarkvm::prelude::{store::helpers::memory::ConsensusMemory, MainnetV0 as CurrentNetwork}; use aleo_std::StorageMode; -use std::str::FromStr; +use std::{ + str::FromStr, + sync::{atomic::AtomicBool, Arc}, +}; pub async fn client() -> Client> { Client::new( @@ -30,6 +33,7 @@ pub async fn client() -> Client> sample_genesis_block(), None, // No CDN. StorageMode::Production, + Arc::new(AtomicBool::new(false)), ) .await .expect("couldn't create client instance") @@ -42,6 +46,7 @@ pub async fn prover() -> Prover> &[], sample_genesis_block(), StorageMode::Production, + Arc::new(AtomicBool::new(false)), ) .await .expect("couldn't create prover instance") @@ -61,6 +66,7 @@ pub async fn validator() -> Validator Date: Thu, 25 Apr 2024 16:18:03 +0200 Subject: [PATCH 483/551] feat: add warning to wait until shutdown complete --- node/src/traits.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/node/src/traits.rs b/node/src/traits.rs index 6fd41686c6..56a6a4b592 100644 --- a/node/src/traits.rs +++ b/node/src/traits.rs @@ -90,6 +90,7 @@ pub trait NodeInterface: Routing { tokio::task::spawn(async move { match signal_listener().await { Ok(()) => { + warn!("Orderly shutdown started, please wait until shutdown is complete."); match node_clone.get() { // If the node is already initialized, then shut it down. Some(node) => node.shut_down().await, From abf19f6e660f89a43b52790a8249716a1ab492f9 Mon Sep 17 00:00:00 2001 From: Jos Dehaes Date: Tue, 30 Apr 2024 13:24:33 +0200 Subject: [PATCH 484/551] fix: avoid lifetime annotations --- cli/src/helpers/dynamic_format.rs | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/cli/src/helpers/dynamic_format.rs b/cli/src/helpers/dynamic_format.rs index 127c1d10eb..82662d4860 100644 --- a/cli/src/helpers/dynamic_format.rs +++ b/cli/src/helpers/dynamic_format.rs @@ -17,20 +17,23 @@ use std::sync::{ Arc, }; -use time::format_description::{self, BorrowedFormatItem}; +use time::{ + format_description::{self, OwnedFormatItem}, + OffsetDateTime, +}; use tracing::{Event, Subscriber}; use tracing_subscriber::{ fmt::{format::Writer, FmtContext, FormatEvent, FormatFields}, registry::LookupSpan, }; -pub struct DynamicFormatter<'b> { - dim_format: DimFormat<'b>, +pub struct DynamicFormatter { + dim_format: DimFormat, default_format: tracing_subscriber::fmt::format::Format, dim: Arc, } -impl<'b, S, N> FormatEvent for DynamicFormatter<'b> +impl FormatEvent for DynamicFormatter where S: Subscriber + for<'a> LookupSpan<'a>, N: for<'a> FormatFields<'a> + 'static, @@ -44,7 +47,7 @@ where } } -impl<'b> DynamicFormatter<'b> { +impl DynamicFormatter { pub fn new(dim: Arc) -> Self { let dim_format = DimFormat::new(); let default_format = tracing_subscriber::fmt::format::Format::default(); @@ -52,19 +55,20 @@ impl<'b> DynamicFormatter<'b> { } } -struct DimFormat<'b> { - fmt: Vec>, +struct DimFormat { + fmt: OwnedFormatItem, } -impl<'b> DimFormat<'b> { +impl DimFormat { fn new() -> Self { - let format = format_description::parse("[year]-[month]-[day]T[hour]:[minute]:[second].[subsecond digits:6]Z") - .expect("failed to set timestampt format"); + let format = + format_description::parse_owned::<2>("[year]-[month]-[day]T[hour]:[minute]:[second].[subsecond digits:6]Z") + .expect("failed to set timestampt format"); Self { fmt: format } } } -impl<'b, S, N> FormatEvent for DimFormat<'b> +impl FormatEvent for DimFormat where S: Subscriber + for<'a> LookupSpan<'a>, N: for<'a> FormatFields<'a> + 'static, @@ -75,7 +79,7 @@ where write!(writer, "\x1b[2m")?; } - let date_time = time::OffsetDateTime::now_utc(); + let date_time = OffsetDateTime::now_utc(); write!(writer, "{} ", date_time.format(&self.fmt).map_err(|_| std::fmt::Error)?)?; let meta = event.metadata(); From 1534c8730b2f2b1581072462fc5b40cae3abe720 Mon Sep 17 00:00:00 2001 From: Jos Dehaes Date: Tue, 30 Apr 2024 13:31:40 +0200 Subject: [PATCH 485/551] fix: review comments --- cli/src/commands/start.rs | 2 +- cli/src/helpers/dynamic_format.rs | 8 +++++++- node/src/traits.rs | 2 +- node/src/validator/mod.rs | 2 +- node/tests/common/node.rs | 11 ++++------- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index 09627331dd..2cfd66d310 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -579,7 +579,7 @@ impl Start { match node_type { NodeType::Validator => Node::new_validator(node_ip, bft_ip, rest_ip, self.rest_rps, account, &trusted_peers, &trusted_validators, genesis, cdn, storage_mode, self.allow_external_peers, dev_txs, shutdown.clone()).await, NodeType::Prover => Node::new_prover(node_ip, account, &trusted_peers, genesis, storage_mode, shutdown.clone()).await, - NodeType::Client => Node::new_client(node_ip, rest_ip, self.rest_rps, account, &trusted_peers, genesis, cdn, storage_mode, shutdown.clone()).await, + NodeType::Client => Node::new_client(node_ip, rest_ip, self.rest_rps, account, &trusted_peers, genesis, cdn, storage_mode, shutdown).await, } } diff --git a/cli/src/helpers/dynamic_format.rs b/cli/src/helpers/dynamic_format.rs index 82662d4860..6e062857ad 100644 --- a/cli/src/helpers/dynamic_format.rs +++ b/cli/src/helpers/dynamic_format.rs @@ -27,9 +27,11 @@ use tracing_subscriber::{ registry::LookupSpan, }; +/// A formatter that can switch between the default formatter and the DIM style. pub struct DynamicFormatter { dim_format: DimFormat, default_format: tracing_subscriber::fmt::format::Format, + // This is the shutdown flag. When set to true, switch to the DIM format. dim: Arc, } @@ -59,6 +61,9 @@ struct DimFormat { fmt: OwnedFormatItem, } +/// A custom format for the DIM style. +/// This formatter is quite basic and does not support all the features of the default formatter. +/// It does support all the default fields of the default formatter. impl DimFormat { fn new() -> Self { let format = @@ -73,8 +78,9 @@ where S: Subscriber + for<'a> LookupSpan<'a>, N: for<'a> FormatFields<'a> + 'static, { + /// Format like the `Full` format, but using the DIM tty style. fn format_event(&self, ctx: &FmtContext<'_, S, N>, mut writer: Writer<'_>, event: &Event<'_>) -> std::fmt::Result { - // set the DIM style + // set the DIM style if we are in TTY mode if writer.has_ansi_escapes() { write!(writer, "\x1b[2m")?; } diff --git a/node/src/traits.rs b/node/src/traits.rs index 56a6a4b592..9efe64350b 100644 --- a/node/src/traits.rs +++ b/node/src/traits.rs @@ -90,7 +90,7 @@ pub trait NodeInterface: Routing { tokio::task::spawn(async move { match signal_listener().await { Ok(()) => { - warn!("Orderly shutdown started, please wait until shutdown is complete."); + warn!("Orderly shutdown started, please wait until it is complete."); match node_clone.get() { // If the node is already initialized, then shut it down. Some(node) => node.shut_down().await, diff --git a/node/src/validator/mod.rs b/node/src/validator/mod.rs index 47bc33699c..3b618bcc67 100644 --- a/node/src/validator/mod.rs +++ b/node/src/validator/mod.rs @@ -488,7 +488,7 @@ mod tests { storage_mode, false, dev_txs, - Arc::new(AtomicBool::new(false)), + Default::default(), ) .await .unwrap(); diff --git a/node/tests/common/node.rs b/node/tests/common/node.rs index aedfd88dd7..c88e35d969 100644 --- a/node/tests/common/node.rs +++ b/node/tests/common/node.rs @@ -18,10 +18,7 @@ use snarkos_node::{Client, Prover, Validator}; use snarkvm::prelude::{store::helpers::memory::ConsensusMemory, MainnetV0 as CurrentNetwork}; use aleo_std::StorageMode; -use std::{ - str::FromStr, - sync::{atomic::AtomicBool, Arc}, -}; +use std::str::FromStr; pub async fn client() -> Client> { Client::new( @@ -33,7 +30,7 @@ pub async fn client() -> Client> sample_genesis_block(), None, // No CDN. StorageMode::Production, - Arc::new(AtomicBool::new(false)), + Default::default(), ) .await .expect("couldn't create client instance") @@ -46,7 +43,7 @@ pub async fn prover() -> Prover> &[], sample_genesis_block(), StorageMode::Production, - Arc::new(AtomicBool::new(false)), + Default::default(), ) .await .expect("couldn't create prover instance") @@ -66,7 +63,7 @@ pub async fn validator() -> Validator Date: Tue, 30 Apr 2024 13:31:52 +0200 Subject: [PATCH 486/551] chore: update lock file --- Cargo.lock | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 474b1e9a32..569b4fef22 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2938,7 +2938,9 @@ dependencies = [ "snarkvm", "sys-info", "thiserror", + "time", "tokio", + "tracing", "tracing-subscriber 0.3.18", "ureq", "zeroize", From dad784ffc5cfe6b1b2145092f2460558dc120780 Mon Sep 17 00:00:00 2001 From: Jos Dehaes Date: Thu, 2 May 2024 10:00:17 +0200 Subject: [PATCH 487/551] fix: improve shutdown warning --- node/src/traits.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/node/src/traits.rs b/node/src/traits.rs index 9efe64350b..df99285f5a 100644 --- a/node/src/traits.rs +++ b/node/src/traits.rs @@ -90,7 +90,8 @@ pub trait NodeInterface: Routing { tokio::task::spawn(async move { match signal_listener().await { Ok(()) => { - warn!("Orderly shutdown started, please wait until it is complete."); + warn!("Graceful shutdown started!"); + warn!("NOTE: PLEASE WAIT UNTIL THE SHUTDOWN PROCESS COMPLETES TO AVOID DATA CORRUPTION"); match node_clone.get() { // If the node is already initialized, then shut it down. Some(node) => node.shut_down().await, From eae0034898f7b97779a1a5ec3fda0af58c06acbc Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 6 May 2024 20:39:40 -0400 Subject: [PATCH 488/551] Move proposal cache loading --- node/bft/src/primary.rs | 63 +++++++++++++++++++++++++++---------- node/sync/src/block_sync.rs | 2 +- 2 files changed, 48 insertions(+), 17 deletions(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 7ff2d33015..63b52f5293 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -43,6 +43,7 @@ use crate::{ use snarkos_account::Account; use snarkos_node_bft_events::PrimaryPing; use snarkos_node_bft_ledger_service::LedgerService; +use snarkos_node_sync::DUMMY_SELF_IP; use snarkvm::{ console::{ prelude::*, @@ -120,19 +121,6 @@ impl Primary { // Initialize the sync module. let sync = Sync::new(gateway.clone(), storage.clone(), ledger.clone()); - // Fetch the signed proposals from the file system if it exists. - let proposal_cache = match ProposalCache::::exists(dev) { - true => match ProposalCache::::load(gateway.account().address(), dev) { - Ok(proposal) => proposal, - Err(err) => { - bail!("Failed to read the signed proposals from the file system - {err}."); - } - }, - false => ProposalCache::default(), - }; - // Extract the proposal and signed proposals. - let (latest_certificate_round, proposed_batch, signed_proposals) = proposal_cache.into(); - // Initialize the primary instance. Ok(Self { sync, @@ -141,14 +129,55 @@ impl Primary { ledger, workers: Arc::from(vec![]), bft_sender: Default::default(), - proposed_batch: Arc::new(RwLock::new(proposed_batch)), + proposed_batch: Default::default(), latest_proposed_batch_timestamp: Default::default(), - signed_proposals: Arc::new(RwLock::new(signed_proposals)), + signed_proposals: Default::default(), handles: Default::default(), - propose_lock: Arc::new(TMutex::new(latest_certificate_round)), + propose_lock: Default::default(), }) } + /// Load the proposal cache file and update the Primary state with the stored data. + async fn load_proposal_cache(&self) -> Result<()> { + // Fetch the signed proposals from the file system if it exists. + let proposal_cache = match ProposalCache::::exists(self.gateway.dev()) { + true => match ProposalCache::::load(self.gateway.account().address(), self.gateway.dev()) { + Ok(proposal) => proposal, + Err(err) => { + bail!("Failed to read the signed proposals from the file system - {err}."); + } + }, + false => return Ok(()), + }; + // Extract the proposal and signed proposals. + let (latest_certificate_round, proposed_batch, signed_proposals) = proposal_cache.into(); + + // Update the storage with the pending certificates. + // The Storage should have been initialized with the latest certificate round. + + // Write the proposed batch. + *self.proposed_batch.write() = proposed_batch; + // Write the signed proposals. + *self.signed_proposals.write() = signed_proposals; + // Writ the propose lock. + *self.propose_lock.lock().await = latest_certificate_round; + + // Update the storage with the pending certificates. + // The Storage should have been initialized with the latest certificate round. + // TODO (raychu86): Uncomment this section. + // for certificate in pending_certificates { + // let batch_id = certificate.batch_id(); + // // We use a dummy IP because the node should not need to request from any peers. + // // The storage should have stored all the transmissions in the BFT persistent storage. Otherwise, we + // // skip the certificate. + // if let Err(err) = self.sync_with_certificate_from_peer(DUMMY_SELF_IP, certificate) { + // warn!("Failed to load stored certificate {} - {err}", fmt_id(batch_id)); + // } + // } + + Ok(()) + } + /// Run the primary instance. pub async fn run( &mut self, @@ -194,6 +223,8 @@ impl Primary { let (sync_sender, sync_receiver) = init_sync_channels(); // Next, initialize the sync module. self.sync.run(bft_sender, sync_receiver).await?; + // Load the proposal cache. + self.load_proposal_cache().await?; // Next, initialize the gateway. self.gateway.run(primary_sender, worker_senders, Some(sync_sender)).await; // Lastly, start the primary handlers. diff --git a/node/sync/src/block_sync.rs b/node/sync/src/block_sync.rs index 6660a7fdaa..525962ed0c 100644 --- a/node/sync/src/block_sync.rs +++ b/node/sync/src/block_sync.rs @@ -52,7 +52,7 @@ pub const MAX_BLOCKS_BEHIND: u32 = 1; // blocks /// This is a dummy IP address that is used to represent the local node. /// Note: This here does not need to be a real IP address, but it must be unique/distinct from all other connections. -const DUMMY_SELF_IP: SocketAddr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 0); +pub const DUMMY_SELF_IP: SocketAddr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 0); #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] pub enum BlockSyncMode { From f24e9f63c58db7f98badaaec80bb4788885caa6c Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 6 May 2024 21:10:13 -0400 Subject: [PATCH 489/551] Store and load the pending certificates --- node/bft/src/helpers/proposal_cache.rs | 42 ++++++++++++++++++++------ node/bft/src/helpers/storage.rs | 29 ++++++++++++++++++ node/bft/src/primary.rs | 27 ++++++++--------- 3 files changed, 73 insertions(+), 25 deletions(-) diff --git a/node/bft/src/helpers/proposal_cache.rs b/node/bft/src/helpers/proposal_cache.rs index 030aa9936f..3a374effe3 100644 --- a/node/bft/src/helpers/proposal_cache.rs +++ b/node/bft/src/helpers/proposal_cache.rs @@ -16,13 +16,15 @@ use crate::helpers::{Proposal, SignedProposals}; use snarkvm::{ console::{account::Address, network::Network}, - prelude::{anyhow, bail, FromBytes, IoResult, Read, Result, ToBytes, Write}, + ledger::narwhal::BatchCertificate, + prelude::{anyhow, bail, error, FromBytes, IoResult, Read, Result, ToBytes, Write}, }; use aleo_std::{aleo_ledger_dir, StorageMode}; +use indexmap::IndexSet; use std::{fs, path::PathBuf}; -// Returns the path where a proposal cache file may be stored. +/// Returns the path where a proposal cache file may be stored. pub fn proposal_cache_path(network: u16, dev: Option) -> PathBuf { const PROPOSAL_CACHE_FILE_NAME: &str = "current-proposal-cache"; @@ -48,12 +50,19 @@ pub struct ProposalCache { proposal: Option>, /// The signed proposals this node has received. signed_proposals: SignedProposals, + /// The pending certificates in storage that have not been included in the ledger. + pending_certificates: IndexSet>, } impl ProposalCache { /// Initializes a new instance of the proposal cache. - pub fn new(latest_round: u64, proposal: Option>, signed_proposals: SignedProposals) -> Self { - Self { latest_round, proposal, signed_proposals } + pub fn new( + latest_round: u64, + proposal: Option>, + signed_proposals: SignedProposals, + pending_certificates: IndexSet>, + ) -> Self { + Self { latest_round, proposal, signed_proposals, pending_certificates } } /// Ensure that the proposal and every signed proposal is associated with the `expected_signer`. @@ -110,9 +119,9 @@ impl ProposalCache { Ok(()) } - /// Returns the latest round, proposal and signed proposals. - pub fn into(self) -> (u64, Option>, SignedProposals) { - (self.latest_round, self.proposal, self.signed_proposals) + /// Returns the latest round, proposal, signed proposals, and pending certificates. + pub fn into(self) -> (u64, Option>, SignedProposals, IndexSet>) { + (self.latest_round, self.proposal, self.signed_proposals, self.pending_certificates) } } @@ -127,6 +136,12 @@ impl ToBytes for ProposalCache { } // Serialize the `signed_proposals`. self.signed_proposals.write_le(&mut writer)?; + // Write the number of pending certificates. + u32::try_from(self.pending_certificates.len()).map_err(error)?.write_le(&mut writer)?; + // Serialize the pending certificates. + for certificate in &self.pending_certificates { + certificate.write_le(&mut writer)?; + } Ok(()) } @@ -144,15 +159,20 @@ impl FromBytes for ProposalCache { }; // Deserialize `signed_proposals`. let signed_proposals = SignedProposals::read_le(&mut reader)?; + // Read the number of pending certificates. + let num_certificates = u32::read_le(&mut reader)?; + // Deserialize the pending certificates. + let pending_certificates = + (0..num_certificates).map(|_| BatchCertificate::read_le(&mut reader)).collect::>>()?; - Ok(Self::new(latest_round, proposal, signed_proposals)) + Ok(Self::new(latest_round, proposal, signed_proposals, pending_certificates)) } } impl Default for ProposalCache { /// Initializes a new instance of the proposal cache. fn default() -> Self { - Self::new(0, None, Default::default()) + Self::new(0, None, Default::default(), Default::default()) } } @@ -162,6 +182,7 @@ mod tests { use crate::helpers::{proposal::tests::sample_proposal, signed_proposals::tests::sample_signed_proposals}; use snarkvm::{ console::{account::PrivateKey, network::MainnetV0}, + ledger::narwhal::batch_certificate::test_helpers::sample_batch_certificates, utilities::TestRng, }; @@ -176,8 +197,9 @@ mod tests { let proposal = sample_proposal(rng); let signed_proposals = sample_signed_proposals(signer, rng); let round = proposal.round(); + let pending_certificates = sample_batch_certificates(rng); - ProposalCache::new(round, Some(proposal), signed_proposals) + ProposalCache::new(round, Some(proposal), signed_proposals, pending_certificates) } #[test] diff --git a/node/bft/src/helpers/storage.rs b/node/bft/src/helpers/storage.rs index d1ec13eaff..bda8bce766 100644 --- a/node/bft/src/helpers/storage.rs +++ b/node/bft/src/helpers/storage.rs @@ -323,6 +323,35 @@ impl Storage { } } + /// Returns the certificates that have not yet been included in the ledger. + /// Note that the order of this set is by round and then insertion. + pub(crate) fn get_pending_certificates(&self) -> IndexSet> { + let mut pending_certificates = IndexSet::new(); + + // Obtain the read locks. + let rounds = self.rounds.read(); + let certificates = self.certificates.read(); + + // Iterate over the rounds. + for (_, certificates_for_round) in rounds.clone().sorted_by(|a, _, b, _| a.cmp(b)) { + // Iterate over the certificates for the round. + for (certificate_id, _, _) in certificates_for_round { + // Skip the certificate if it already exists in the ledger. + if self.ledger.contains_certificate(&certificate_id).unwrap_or(false) { + continue; + } + + // Add the certificate to the pending certificates. + match certificates.get(&certificate_id).cloned() { + Some(certificate) => pending_certificates.insert(certificate), + None => continue, + }; + } + } + + pending_certificates + } + /// Checks the given `batch_header` for validity, returning the missing transmissions from storage. /// /// This method ensures the following invariants: diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 63b52f5293..06de7aa93f 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -150,10 +150,7 @@ impl Primary { false => return Ok(()), }; // Extract the proposal and signed proposals. - let (latest_certificate_round, proposed_batch, signed_proposals) = proposal_cache.into(); - - // Update the storage with the pending certificates. - // The Storage should have been initialized with the latest certificate round. + let (latest_certificate_round, proposed_batch, signed_proposals, pending_certificates) = proposal_cache.into(); // Write the proposed batch. *self.proposed_batch.write() = proposed_batch; @@ -164,16 +161,15 @@ impl Primary { // Update the storage with the pending certificates. // The Storage should have been initialized with the latest certificate round. - // TODO (raychu86): Uncomment this section. - // for certificate in pending_certificates { - // let batch_id = certificate.batch_id(); - // // We use a dummy IP because the node should not need to request from any peers. - // // The storage should have stored all the transmissions in the BFT persistent storage. Otherwise, we - // // skip the certificate. - // if let Err(err) = self.sync_with_certificate_from_peer(DUMMY_SELF_IP, certificate) { - // warn!("Failed to load stored certificate {} - {err}", fmt_id(batch_id)); - // } - // } + for certificate in pending_certificates { + let batch_id = certificate.batch_id(); + // We use a dummy IP because the node should not need to request from any peers. + // The storage should have stored all the transmissions in the BFT persistent storage. Otherwise, we + // skip the certificate. + if let Err(err) = self.sync_with_certificate_from_peer(DUMMY_SELF_IP, certificate).await { + warn!("Failed to load stored certificate {} - {err}", fmt_id(batch_id)); + } + } Ok(()) } @@ -1658,7 +1654,8 @@ impl Primary { let proposal = self.proposed_batch.write().take(); let signed_proposals = self.signed_proposals.read().clone(); let latest_round = proposal.as_ref().map(Proposal::round).unwrap_or(*self.propose_lock.lock().await); - ProposalCache::new(latest_round, proposal, signed_proposals) + let pending_certificates = self.storage.get_pending_certificates(); + ProposalCache::new(latest_round, proposal, signed_proposals, pending_certificates) }; if let Err(err) = proposal_cache.store(self.gateway.dev()) { error!("Failed to store the current proposal cache: {err}"); From 6faa05a79fbbffe5d20efe5f12e3f1325d402880 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Mon, 6 May 2024 21:22:13 -0400 Subject: [PATCH 490/551] Sync storage with ledger at bootup prior to loading proposal cache --- node/bft/src/primary.rs | 62 +++++++++++++++++++++------------------- node/bft/src/sync/mod.rs | 9 ++++-- 2 files changed, 39 insertions(+), 32 deletions(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 06de7aa93f..05069d2aa4 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -140,38 +140,40 @@ impl Primary { /// Load the proposal cache file and update the Primary state with the stored data. async fn load_proposal_cache(&self) -> Result<()> { // Fetch the signed proposals from the file system if it exists. - let proposal_cache = match ProposalCache::::exists(self.gateway.dev()) { + match ProposalCache::::exists(self.gateway.dev()) { + // If the proposal cache exists, then process the proposal cache. true => match ProposalCache::::load(self.gateway.account().address(), self.gateway.dev()) { - Ok(proposal) => proposal, + Ok(proposal_cache) => { + // Extract the proposal and signed proposals. + let (latest_certificate_round, proposed_batch, signed_proposals, pending_certificates) = + proposal_cache.into(); + + // Write the proposed batch. + *self.proposed_batch.write() = proposed_batch; + // Write the signed proposals. + *self.signed_proposals.write() = signed_proposals; + // Writ the propose lock. + *self.propose_lock.lock().await = latest_certificate_round; + + // Update the storage with the pending certificates. + for certificate in pending_certificates { + let batch_id = certificate.batch_id(); + // We use a dummy IP because the node should not need to request from any peers. + // The storage should have stored all the transmissions. If not, we simply + // skip the certificate. + if let Err(err) = self.sync_with_certificate_from_peer(DUMMY_SELF_IP, certificate).await { + warn!("Failed to load stored certificate {} from proposal cache - {err}", fmt_id(batch_id)); + } + } + Ok(()) + } Err(err) => { bail!("Failed to read the signed proposals from the file system - {err}."); } }, - false => return Ok(()), - }; - // Extract the proposal and signed proposals. - let (latest_certificate_round, proposed_batch, signed_proposals, pending_certificates) = proposal_cache.into(); - - // Write the proposed batch. - *self.proposed_batch.write() = proposed_batch; - // Write the signed proposals. - *self.signed_proposals.write() = signed_proposals; - // Writ the propose lock. - *self.propose_lock.lock().await = latest_certificate_round; - - // Update the storage with the pending certificates. - // The Storage should have been initialized with the latest certificate round. - for certificate in pending_certificates { - let batch_id = certificate.batch_id(); - // We use a dummy IP because the node should not need to request from any peers. - // The storage should have stored all the transmissions in the BFT persistent storage. Otherwise, we - // skip the certificate. - if let Err(err) = self.sync_with_certificate_from_peer(DUMMY_SELF_IP, certificate).await { - warn!("Failed to load stored certificate {} - {err}", fmt_id(batch_id)); - } + // If the proposal cache does not exist, then return early. + false => Ok(()), } - - Ok(()) } /// Run the primary instance. @@ -217,10 +219,12 @@ impl Primary { // First, initialize the sync channels. let (sync_sender, sync_receiver) = init_sync_channels(); - // Next, initialize the sync module. - self.sync.run(bft_sender, sync_receiver).await?; - // Load the proposal cache. + // Next, initialize the sync module and sync the storage from ledger. + self.sync.initialize(bft_sender).await?; + // Next, load and process the proposal cache before running the sync module. self.load_proposal_cache().await?; + // Next, run the sync module. + self.sync.run(sync_receiver).await?; // Next, initialize the gateway. self.gateway.run(primary_sender, worker_senders, Some(sync_sender)).await; // Lastly, start the primary handlers. diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index 2593386125..4f4353ca49 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -82,8 +82,8 @@ impl Sync { } } - /// Starts the sync module. - pub async fn run(&self, bft_sender: Option>, sync_receiver: SyncReceiver) -> Result<()> { + /// Initializes the sync module and sync the storage with the ledger at bootup. + pub async fn initialize(&self, bft_sender: Option>) -> Result<()> { // If a BFT sender was provided, set it. if let Some(bft_sender) = bft_sender { self.bft_sender.set(bft_sender).expect("BFT sender already set in gateway"); @@ -92,8 +92,11 @@ impl Sync { info!("Syncing storage with the ledger..."); // Sync the storage with the ledger. - self.sync_storage_with_ledger_at_bootup().await?; + self.sync_storage_with_ledger_at_bootup().await + } + /// Starts the sync module. + pub async fn run(&self, sync_receiver: SyncReceiver) -> Result<()> { info!("Starting the sync module..."); // Start the block sync loop. From 3df364ec961187a287ee9d758c7043208bc0ebab Mon Sep 17 00:00:00 2001 From: miazn Date: Wed, 8 May 2024 13:46:31 -0400 Subject: [PATCH 491/551] add committee endpoint for specific block --- node/rest/src/lib.rs | 1 + node/rest/src/routes.rs | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/node/rest/src/lib.rs b/node/rest/src/lib.rs index c7d01c9480..8cbbe05422 100644 --- a/node/rest/src/lib.rs +++ b/node/rest/src/lib.rs @@ -191,6 +191,7 @@ impl, R: Routing> Rest { .route(&format!("/{network}/stateRoot/latest"), get(Self::get_state_root_latest)) .route(&format!("/{network}/stateRoot/:height"), get(Self::get_state_root)) .route(&format!("/{network}/committee/latest"), get(Self::get_committee_latest)) + .route(&format!("/{network}/committee/:height"), get(Self::get_committee)) // Pass in `Rest` to make things convenient. .with_state(self.clone()) diff --git a/node/rest/src/routes.rs b/node/rest/src/routes.rs index c6abb8fe8a..ec4193d501 100644 --- a/node/rest/src/routes.rs +++ b/node/rest/src/routes.rs @@ -264,6 +264,14 @@ impl, R: Routing> Rest { Ok(ErasedJson::pretty(rest.ledger.latest_committee()?)) } + // GET //committee/{height} + pub(crate) async fn get_committee( + State(rest): State, + Path(height): Path, + ) -> Result { + Ok(ErasedJson::pretty(rest.ledger.get_committee(height)?)) + } + // GET //peers/count pub(crate) async fn get_peers_count(State(rest): State) -> ErasedJson { ErasedJson::pretty(rest.routing.router().number_of_connected_peers()) From dd2691962e9877ebcf3f31728614f9a1a0701d7d Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 8 May 2024 15:13:27 -0400 Subject: [PATCH 492/551] Add --network to snarkos clean in devnet script --- devnet.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devnet.sh b/devnet.sh index d1bd3cf6d6..83ea2cc6b1 100755 --- a/devnet.sh +++ b/devnet.sh @@ -32,7 +32,7 @@ if [[ $clear_ledger == "y" ]]; then for ((index = 0; index < $((total_validators + total_clients)); index++)); do # Run 'snarkos clean' for each node in the background - snarkos clean --dev $index & + snarkos clean --network $network_id --dev $index & # Store the process ID of the background task clean_processes+=($!) From 4970677aa72b556401835c7084d3303b454b9db6 Mon Sep 17 00:00:00 2001 From: mdelle1 <108158289+mdelle1@users.noreply.github.com> Date: Wed, 8 May 2024 15:30:39 -0400 Subject: [PATCH 493/551] Adds unit test for pending certificates --- node/bft/src/sync/mod.rs | 179 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 179 insertions(+) diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index 4f4353ca49..5c48d66b3a 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -874,4 +874,183 @@ mod tests { Ok(()) } + + #[tokio::test] + #[tracing_test::traced_test] + async fn test_pending_certificates() -> anyhow::Result<()> { + let rng = &mut TestRng::default(); + // Initialize the round parameters. + let max_gc_rounds = BatchHeader::::MAX_GC_ROUNDS as u64; + let commit_round = 2; + + // Initialize the store. + let store = CurrentConsensusStore::open(None).unwrap(); + let account: Account = Account::new(rng)?; + + // Create a genesis block with a seeded RNG to reproduce the same genesis private keys. + let seed: u64 = rng.gen(); + let genesis_rng = &mut TestRng::from_seed(seed); + let genesis = VM::from(store).unwrap().genesis_beacon(account.private_key(), genesis_rng).unwrap(); + + // Extract the private keys from the genesis committee by using the same RNG to sample private keys. + let genesis_rng = &mut TestRng::from_seed(seed); + let private_keys = [ + *account.private_key(), + PrivateKey::new(genesis_rng)?, + PrivateKey::new(genesis_rng)?, + PrivateKey::new(genesis_rng)?, + ]; + // Initialize the ledger with the genesis block. + let ledger = CurrentLedger::load(genesis.clone(), StorageMode::Production).unwrap(); + // Initialize the ledger. + let core_ledger = Arc::new(CoreLedgerService::new(ledger.clone(), Default::default())); + // Sample rounds of batch certificates starting at the genesis round from a static set of 4 authors. + let (round_to_certificates_map, committee) = { + // Initialize the committee. + let committee = ledger.latest_committee().unwrap(); + // Initialize a mapping from the round number to the set of batch certificates in the round. + let mut round_to_certificates_map: HashMap>> = + HashMap::new(); + let mut previous_certificates: IndexSet> = IndexSet::with_capacity(4); + + for round in 0..=commit_round + 8 { + let mut current_certificates = IndexSet::new(); + let previous_certificate_ids: IndexSet<_> = if round == 0 || round == 1 { + IndexSet::new() + } else { + previous_certificates.iter().map(|c| c.id()).collect() + }; + let committee_id = committee.id(); + // Create a certificate for each validator. + for (i, private_key_1) in private_keys.iter().enumerate() { + let batch_header = BatchHeader::new( + private_key_1, + round, + now(), + committee_id, + Default::default(), + previous_certificate_ids.clone(), + rng, + ) + .unwrap(); + // Sign the batch header. + let mut signatures = IndexSet::with_capacity(4); + for (j, private_key_2) in private_keys.iter().enumerate() { + if i != j { + signatures.insert(private_key_2.sign(&[batch_header.batch_id()], rng).unwrap()); + } + } + current_certificates.insert(BatchCertificate::from(batch_header, signatures).unwrap()); + } + + // Update the map of certificates. + round_to_certificates_map.insert(round, current_certificates.clone()); + previous_certificates = current_certificates.clone(); + + } + (round_to_certificates_map, committee) + }; + + // Initialize the storage. + let storage = Storage::new(core_ledger.clone(), Arc::new(BFTMemoryService::new()), max_gc_rounds); + // Insert certificates into storage. + let mut certificates: Vec> = Vec::new(); + for i in 1..=commit_round + 8 { + let c = (*round_to_certificates_map.get(&i).unwrap()).clone(); + certificates.extend(c); + } + for certificate in certificates.clone().iter() { + storage.testing_only_insert_certificate_testing_only(certificate.clone()); + } + // Create block 1. + let leader_round_1 = commit_round; + let leader_1 = committee.get_leader(leader_round_1).unwrap(); + let leader_certificate = storage.get_certificate_for_round_with_author(commit_round, leader_1).unwrap(); + let mut subdag_map: BTreeMap>> = BTreeMap::new(); + let block_1 = { + let mut leader_cert_map = IndexSet::new(); + leader_cert_map.insert(leader_certificate.clone()); + let mut previous_cert_map = IndexSet::new(); + for cert in storage.get_certificates_for_round(commit_round - 1) { + previous_cert_map.insert(cert); + } + subdag_map.insert(commit_round, leader_cert_map.clone()); + subdag_map.insert(commit_round - 1, previous_cert_map.clone()); + let subdag = Subdag::from(subdag_map.clone())?; + core_ledger.prepare_advance_to_next_quorum_block(subdag, Default::default())? + }; + // Insert block 1. + core_ledger.advance_to_next_block(&block_1)?; + + // Create block 2. + let leader_round_2 = commit_round + 2; + let leader_2 = committee.get_leader(leader_round_2).unwrap(); + let leader_certificate_2 = storage.get_certificate_for_round_with_author(leader_round_2, leader_2).unwrap(); + let mut subdag_map_2: BTreeMap>> = BTreeMap::new(); + let block_2 = { + let mut leader_cert_map_2 = IndexSet::new(); + leader_cert_map_2.insert(leader_certificate_2.clone()); + let mut previous_cert_map_2 = IndexSet::new(); + for cert in storage.get_certificates_for_round(leader_round_2 - 1) { + previous_cert_map_2.insert(cert); + } + subdag_map_2.insert(leader_round_2, leader_cert_map_2.clone()); + subdag_map_2.insert(leader_round_2 - 1, previous_cert_map_2.clone()); + let subdag_2 = Subdag::from(subdag_map_2.clone())?; + core_ledger.prepare_advance_to_next_quorum_block(subdag_2, Default::default())? + }; + // Insert block 2. + core_ledger.advance_to_next_block(&block_2)?; + + // Create block 3 + let leader_round_3 = commit_round + 4; + let leader_3 = committee.get_leader(leader_round_3).unwrap(); + let leader_certificate_3 = storage.get_certificate_for_round_with_author(leader_round_3, leader_3).unwrap(); + let mut subdag_map_3: BTreeMap>> = BTreeMap::new(); + let block_3 = { + let mut leader_cert_map_3 = IndexSet::new(); + leader_cert_map_3.insert(leader_certificate_3.clone()); + let mut previous_cert_map_3 = IndexSet::new(); + for cert in storage.get_certificates_for_round(leader_round_3 - 1) { + previous_cert_map_3.insert(cert); + } + subdag_map_3.insert(leader_round_3, leader_cert_map_3.clone()); + subdag_map_3.insert(leader_round_3 - 1, previous_cert_map_3.clone()); + let subdag_3 = Subdag::from(subdag_map_3.clone())?; + core_ledger.prepare_advance_to_next_quorum_block(subdag_3, Default::default())? + }; + // Insert block 3. + core_ledger.advance_to_next_block(&block_3)?; + + /* + Check that the pending certificates are computed correctly. + */ + + // Retrieve the pending certificates. + let pending_certificates = storage.get_pending_certificates(); + // Check that all of the pending certificates are not contained in the ledger. + for certificate in pending_certificates.clone() { + assert!(!core_ledger.contains_certificate(&certificate.id()).unwrap_or(false)); + } + // Initialize an empty set to be populated with the committed certificates in the block subdags. + let mut committed_certificates: IndexSet> = IndexSet::new(); + { + let subdag_maps = [&subdag_map, &subdag_map_2, &subdag_map_3]; + for subdag in subdag_maps.iter() { + for subdag_certificates in subdag.values() { + committed_certificates.extend(subdag_certificates.iter().cloned()); + } + } + }; + // Create the set of candidate pending certificates as the set of all certificates minus the set of the committed certificates. + let mut candidate_pending_certificates: IndexSet> = IndexSet::new(); + for certificate in certificates.clone(){ + if !committed_certificates.contains(&certificate){ + candidate_pending_certificates.insert(certificate); + } + } + // Check that the set of pending certificates is equal to the set of candidate pending certificates. + assert_eq!(pending_certificates, candidate_pending_certificates); + Ok(()) + } } From 89a3b32e7b620d9aeef3c81297a33c40c88864b9 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 8 May 2024 15:43:15 -0400 Subject: [PATCH 494/551] cargo fmt --- node/bft/src/sync/mod.rs | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index 5c48d66b3a..545c477b2a 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -906,7 +906,7 @@ mod tests { let core_ledger = Arc::new(CoreLedgerService::new(ledger.clone(), Default::default())); // Sample rounds of batch certificates starting at the genesis round from a static set of 4 authors. let (round_to_certificates_map, committee) = { - // Initialize the committee. + // Initialize the committee. let committee = ledger.latest_committee().unwrap(); // Initialize a mapping from the round number to the set of batch certificates in the round. let mut round_to_certificates_map: HashMap>> = @@ -946,7 +946,6 @@ mod tests { // Update the map of certificates. round_to_certificates_map.insert(round, current_certificates.clone()); previous_certificates = current_certificates.clone(); - } (round_to_certificates_map, committee) }; @@ -1024,16 +1023,16 @@ mod tests { /* Check that the pending certificates are computed correctly. - */ - - // Retrieve the pending certificates. - let pending_certificates = storage.get_pending_certificates(); - // Check that all of the pending certificates are not contained in the ledger. + */ + + // Retrieve the pending certificates. + let pending_certificates = storage.get_pending_certificates(); + // Check that all of the pending certificates are not contained in the ledger. for certificate in pending_certificates.clone() { - assert!(!core_ledger.contains_certificate(&certificate.id()).unwrap_or(false)); + assert!(!core_ledger.contains_certificate(&certificate.id()).unwrap_or(false)); } - // Initialize an empty set to be populated with the committed certificates in the block subdags. - let mut committed_certificates: IndexSet> = IndexSet::new(); + // Initialize an empty set to be populated with the committed certificates in the block subdags. + let mut committed_certificates: IndexSet> = IndexSet::new(); { let subdag_maps = [&subdag_map, &subdag_map_2, &subdag_map_3]; for subdag in subdag_maps.iter() { @@ -1041,15 +1040,15 @@ mod tests { committed_certificates.extend(subdag_certificates.iter().cloned()); } } - }; - // Create the set of candidate pending certificates as the set of all certificates minus the set of the committed certificates. - let mut candidate_pending_certificates: IndexSet> = IndexSet::new(); - for certificate in certificates.clone(){ - if !committed_certificates.contains(&certificate){ - candidate_pending_certificates.insert(certificate); + }; + // Create the set of candidate pending certificates as the set of all certificates minus the set of the committed certificates. + let mut candidate_pending_certificates: IndexSet> = IndexSet::new(); + for certificate in certificates.clone() { + if !committed_certificates.contains(&certificate) { + candidate_pending_certificates.insert(certificate); } } - // Check that the set of pending certificates is equal to the set of candidate pending certificates. + // Check that the set of pending certificates is equal to the set of candidate pending certificates. assert_eq!(pending_certificates, candidate_pending_certificates); Ok(()) } From dfe074fc522cacedd2eacb96a70c788553aee275 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 8 May 2024 17:56:45 -0400 Subject: [PATCH 495/551] Remove usage of current commitee round if the round is in the future --- node/bft/ledger-service/src/ledger.rs | 8 +++----- node/bft/ledger-service/src/mock.rs | 1 - node/bft/ledger-service/src/prover.rs | 2 -- node/bft/ledger-service/src/traits.rs | 2 -- node/bft/ledger-service/src/translucent.rs | 1 - 5 files changed, 3 insertions(+), 11 deletions(-) diff --git a/node/bft/ledger-service/src/ledger.rs b/node/bft/ledger-service/src/ledger.rs index b39763f61c..c5a500c50d 100644 --- a/node/bft/ledger-service/src/ledger.rs +++ b/node/bft/ledger-service/src/ledger.rs @@ -148,7 +148,6 @@ impl> LedgerService for CoreLedgerService< } /// Returns the committee for the given round. - /// If the given round is in the future, then the current committee is returned. fn get_committee_for_round(&self, round: u64) -> Result> { // Check if the committee is already in the cache. if let Some(committee) = self.committee_cache.lock().get(&round) { @@ -163,12 +162,12 @@ impl> LedgerService for CoreLedgerService< // Return the committee. Ok(committee) } - // Return the current committee if the round is in the future. + // Return the current committee if the round is equivalent. None => { // Retrieve the current committee. let current_committee = self.current_committee()?; - // Return the current committee if the round is in the future. - match current_committee.starting_round() <= round { + // Return the current committee if the round is equivalent. + match current_committee.starting_round() == round { true => Ok(current_committee), false => bail!("No committee found for round {round} in the ledger"), } @@ -177,7 +176,6 @@ impl> LedgerService for CoreLedgerService< } /// Returns the committee lookback for the given round. - /// If the committee lookback round is in the future, then the current committee is returned. fn get_committee_lookback_for_round(&self, round: u64) -> Result> { // Get the round number for the previous committee. Note, we subtract 2 from odd rounds, // because committees are updated in even rounds. diff --git a/node/bft/ledger-service/src/mock.rs b/node/bft/ledger-service/src/mock.rs index 681c8cd89e..7a182446b6 100644 --- a/node/bft/ledger-service/src/mock.rs +++ b/node/bft/ledger-service/src/mock.rs @@ -147,7 +147,6 @@ impl LedgerService for MockLedgerService { } /// Returns the committee for the given round. - /// If the given round is in the future, then the current committee is returned. fn get_committee_for_round(&self, _round: u64) -> Result> { Ok(self.committee.clone()) } diff --git a/node/bft/ledger-service/src/prover.rs b/node/bft/ledger-service/src/prover.rs index 2d3839a19c..0038e74037 100644 --- a/node/bft/ledger-service/src/prover.rs +++ b/node/bft/ledger-service/src/prover.rs @@ -118,13 +118,11 @@ impl LedgerService for ProverLedgerService { } /// Returns the committee for the given round. - /// If the given round is in the future, then the current committee is returned. fn get_committee_for_round(&self, round: u64) -> Result> { bail!("Committee for round {round} does not exist in prover") } /// Returns the committee lookback for the given round. - /// If the committee lookback round is in the future, then the current committee is returned. fn get_committee_lookback_for_round(&self, round: u64) -> Result> { bail!("Previous committee for round {round} does not exist in prover") } diff --git a/node/bft/ledger-service/src/traits.rs b/node/bft/ledger-service/src/traits.rs index 2bbad3387f..d8477c3a21 100644 --- a/node/bft/ledger-service/src/traits.rs +++ b/node/bft/ledger-service/src/traits.rs @@ -74,11 +74,9 @@ pub trait LedgerService: Debug + Send + Sync { fn current_committee(&self) -> Result>; /// Returns the committee for the given round. - /// If the given round is in the future, then the current committee is returned. fn get_committee_for_round(&self, round: u64) -> Result>; /// Returns the committee lookback for the given round. - /// If the committee lookback round is in the future, then the current committee is returned. fn get_committee_lookback_for_round(&self, round: u64) -> Result>; /// Returns `true` if the ledger contains the given certificate ID. diff --git a/node/bft/ledger-service/src/translucent.rs b/node/bft/ledger-service/src/translucent.rs index 044cd95eec..8a5baf6422 100644 --- a/node/bft/ledger-service/src/translucent.rs +++ b/node/bft/ledger-service/src/translucent.rs @@ -129,7 +129,6 @@ impl> LedgerService for TranslucentLedgerS } /// Returns the committee for the given round. - /// If the given round is in the future, then the current committee is returned. fn get_committee_for_round(&self, round: u64) -> Result> { self.inner.get_committee_for_round(round) } From 209d0c60aa2b80537aed25f7b5ae832ee8483c17 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 8 May 2024 20:00:45 -0400 Subject: [PATCH 496/551] Bump snarkVM rev - 3ebe60c --- Cargo.lock | 119 +++++++++++++++++++++++++++-------------------------- Cargo.toml | 2 +- 2 files changed, 61 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 474b1e9a32..5437b60ed1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3292,7 +3292,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "anstyle", "anyhow", @@ -3323,7 +3323,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "aleo-std", "anyhow", @@ -3353,7 +3353,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3367,7 +3367,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3378,7 +3378,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3388,7 +3388,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3398,7 +3398,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "indexmap 2.2.6", "itertools 0.11.0", @@ -3416,12 +3416,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3432,7 +3432,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3447,7 +3447,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3462,7 +3462,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3475,7 +3475,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3484,7 +3484,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3494,7 +3494,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3506,7 +3506,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3518,7 +3518,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3529,7 +3529,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3541,7 +3541,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3554,7 +3554,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "bs58", "snarkvm-console-network", @@ -3565,7 +3565,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "blake2s_simd", "smallvec", @@ -3578,7 +3578,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "aleo-std", "rayon", @@ -3589,7 +3589,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "anyhow", "indexmap 2.2.6", @@ -3612,7 +3612,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "anyhow", "bech32", @@ -3630,7 +3630,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "enum_index", "enum_index_derive", @@ -3651,7 +3651,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3666,7 +3666,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3677,7 +3677,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "snarkvm-console-network-environment", ] @@ -3685,7 +3685,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3695,7 +3695,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3706,7 +3706,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3717,7 +3717,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3728,7 +3728,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3739,7 +3739,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "rand", "rayon", @@ -3753,7 +3753,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "aleo-std", "anyhow", @@ -3770,7 +3770,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "aleo-std", "anyhow", @@ -3795,7 +3795,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "anyhow", "rand", @@ -3807,7 +3807,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3826,7 +3826,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "anyhow", "indexmap 2.2.6", @@ -3845,7 +3845,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -3858,7 +3858,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3871,7 +3871,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3884,7 +3884,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "bytes", "serde_json", @@ -3895,7 +3895,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3910,7 +3910,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "bytes", "serde_json", @@ -3923,7 +3923,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "snarkvm-console", "snarkvm-ledger-puzzle", @@ -3932,7 +3932,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "aleo-std", "anyhow", @@ -3952,7 +3952,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle-epoch" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "anyhow", "colored", @@ -3967,7 +3967,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "async-trait", "reqwest", @@ -3980,7 +3980,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "aleo-std-storage", "anyhow", @@ -3992,6 +3992,7 @@ dependencies = [ "rocksdb", "serde", "serde_json", + "smallvec", "snarkvm-console", "snarkvm-ledger-authority", "snarkvm-ledger-block", @@ -4006,7 +4007,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4021,7 +4022,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4030,7 +4031,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "aleo-std", "anyhow", @@ -4055,7 +4056,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "aleo-std", "anyhow", @@ -4084,7 +4085,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "aleo-std", "colored", @@ -4107,7 +4108,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "indexmap 2.2.6", "paste", @@ -4121,7 +4122,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "bincode", "once_cell", @@ -4134,7 +4135,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "aleo-std", "anyhow", @@ -4155,7 +4156,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5c57a48#5c57a48204cc7406a87de2a063ebdfd3fd1889ea" +source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" dependencies = [ "proc-macro2", "quote 1.0.36", diff --git a/Cargo.toml b/Cargo.toml index f1257dc901..9ca0b69a7b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoHQ/snarkVM.git" -rev = "5c57a48" +rev = "3ebe60c" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From 7ed91da2e094ed6e47ad7dcffa1a2b2e1af1e593 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 8 May 2024 20:18:42 -0400 Subject: [PATCH 497/551] Add check for number of certificates --- node/bft/src/helpers/proposal_cache.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/node/bft/src/helpers/proposal_cache.rs b/node/bft/src/helpers/proposal_cache.rs index 3a374effe3..cbc6cc18a1 100644 --- a/node/bft/src/helpers/proposal_cache.rs +++ b/node/bft/src/helpers/proposal_cache.rs @@ -15,7 +15,7 @@ use crate::helpers::{Proposal, SignedProposals}; use snarkvm::{ - console::{account::Address, network::Network}, + console::{account::Address, network::Network, program::SUBDAG_CERTIFICATES_DEPTH}, ledger::narwhal::BatchCertificate, prelude::{anyhow, bail, error, FromBytes, IoResult, Read, Result, ToBytes, Write}, }; @@ -161,6 +161,13 @@ impl FromBytes for ProposalCache { let signed_proposals = SignedProposals::read_le(&mut reader)?; // Read the number of pending certificates. let num_certificates = u32::read_le(&mut reader)?; + // Ensure the number of certificates is within bounds. + if num_certificates > 2u32.saturating_pow(SUBDAG_CERTIFICATES_DEPTH as u32) { + return Err(error(format!( + "Number of certificates ({num_certificates}) exceeds the maximum ({})", + 2u32.saturating_pow(SUBDAG_CERTIFICATES_DEPTH as u32) + ))); + }; // Deserialize the pending certificates. let pending_certificates = (0..num_certificates).map(|_| BatchCertificate::read_le(&mut reader)).collect::>>()?; From 05a3fa42d18ac85464cd49bb5b14466c3bc614f9 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 8 May 2024 20:30:27 -0400 Subject: [PATCH 498/551] Add spawn_blocking around the get_blocks GET request --- node/rest/src/routes.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/node/rest/src/routes.rs b/node/rest/src/routes.rs index 821ed0f0b8..20ef762911 100644 --- a/node/rest/src/routes.rs +++ b/node/rest/src/routes.rs @@ -135,11 +135,18 @@ impl, R: Routing> Rest { ))); } - let blocks = cfg_into_iter!((start_height..end_height)) - .map(|height| rest.ledger.get_block(height)) - .collect::, _>>()?; - - Ok(ErasedJson::pretty(blocks)) + // Fetch the blocks from ledger. + match tokio::task::spawn_blocking(move || { + cfg_into_iter!((start_height..end_height)) + .map(|height| rest.ledger.get_block(height)) + .collect::, _>>() + }) + .await + { + Ok(Ok(blocks)) => Ok(ErasedJson::pretty(blocks)), + Ok(Err(err)) => Err(RestError(format!("Failed to get blocks '{start_height}..{end_height}' - {err}"))), + Err(err) => Err(RestError(format!("Failed to get blocks '{start_height}..{end_height}' - {err}"))), + } } // GET //height/{blockHash} From 75e57e472a47e6a2ebeafd434a2b857014be508b Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Wed, 8 May 2024 17:30:31 -0700 Subject: [PATCH 499/551] Update shutdown message --- node/src/traits.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/node/src/traits.rs b/node/src/traits.rs index df99285f5a..e3cd8ad7ed 100644 --- a/node/src/traits.rs +++ b/node/src/traits.rs @@ -90,8 +90,12 @@ pub trait NodeInterface: Routing { tokio::task::spawn(async move { match signal_listener().await { Ok(()) => { - warn!("Graceful shutdown started!"); - warn!("NOTE: PLEASE WAIT UNTIL THE SHUTDOWN PROCESS COMPLETES TO AVOID DATA CORRUPTION"); + warn!("=========================================================================================="); + warn!("⚠️ Attention - Starting the graceful shutdown procedure (ETA: 30 seconds)..."); + warn!("⚠️ Attention - To avoid DATA CORRUPTION, do NOT interrupt snarkOS (or press Ctrl+C again)"); + warn!("⚠️ Attention - Please wait until the shutdown gracefully completes (ETA: 30 seconds)"); + warn!("=========================================================================================="); + match node_clone.get() { // If the node is already initialized, then shut it down. Some(node) => node.shut_down().await, From 996b3bac004cf31662be82600cf8565d3d4ad54a Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 10 May 2024 11:04:35 -0700 Subject: [PATCH 500/551] Add grace period before starting block sync loop --- node/bft/src/sync/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index 545c477b2a..e5dc84731b 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -102,6 +102,11 @@ impl Sync { // Start the block sync loop. let self_ = self.clone(); self.handles.lock().push(tokio::spawn(async move { + // Sleep briefly to allow an initial primary ping to come in prior to entering the loop. + // Ideally, a node does not consider itself synced when it has not received + // any block locators from peer. However, in the initial bootup of validators, + // this needs to happen, so we use this additional sleep as a grace period. + tokio::time::sleep(Duration::from_millis(PRIMARY_PING_IN_MS)).await; loop { // Sleep briefly to avoid triggering spam detection. tokio::time::sleep(Duration::from_millis(PRIMARY_PING_IN_MS)).await; From 6f8880fe10492bb054cd4bf98cb40a6e70081009 Mon Sep 17 00:00:00 2001 From: Niklas Date: Fri, 10 May 2024 14:08:21 +0200 Subject: [PATCH 501/551] perf: include json serialisation in the blocking task --- node/rest/src/routes.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/node/rest/src/routes.rs b/node/rest/src/routes.rs index 20ef762911..422a657018 100644 --- a/node/rest/src/routes.rs +++ b/node/rest/src/routes.rs @@ -135,16 +135,18 @@ impl, R: Routing> Rest { ))); } - // Fetch the blocks from ledger. - match tokio::task::spawn_blocking(move || { - cfg_into_iter!((start_height..end_height)) + // Prepare a closure for the blocking work. + let get_json_blocks = move || -> Result { + let blocks = cfg_into_iter!((start_height..end_height)) .map(|height| rest.ledger.get_block(height)) - .collect::, _>>() - }) - .await - { - Ok(Ok(blocks)) => Ok(ErasedJson::pretty(blocks)), - Ok(Err(err)) => Err(RestError(format!("Failed to get blocks '{start_height}..{end_height}' - {err}"))), + .collect::, _>>()?; + + Ok(ErasedJson::pretty(blocks)) + }; + + // Fetch the blocks from ledger and serialize to json. + match tokio::task::spawn_blocking(get_json_blocks).await { + Ok(json) => json, Err(err) => Err(RestError(format!("Failed to get blocks '{start_height}..{end_height}' - {err}"))), } } From 43a57b01f6a3679d12303474ff1ac27b22b60d69 Mon Sep 17 00:00:00 2001 From: Niklas Date: Mon, 13 May 2024 17:34:38 +0200 Subject: [PATCH 502/551] fix: clear cached validator requests on disconnect --- node/bft/src/gateway.rs | 1 + node/bft/src/helpers/cache.rs | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/node/bft/src/gateway.rs b/node/bft/src/gateway.rs index 0e404ff635..58674b1de0 100644 --- a/node/bft/src/gateway.rs +++ b/node/bft/src/gateway.rs @@ -1085,6 +1085,7 @@ impl Disconnect for Gateway { async fn handle_disconnect(&self, peer_addr: SocketAddr) { if let Some(peer_ip) = self.resolver.get_listener(peer_addr) { self.remove_connected_peer(peer_ip); + self.cache.clear_outbound_validators_requests(peer_ip); } } } diff --git a/node/bft/src/helpers/cache.rs b/node/bft/src/helpers/cache.rs index 7e6bafc0a9..a735185e5e 100644 --- a/node/bft/src/helpers/cache.rs +++ b/node/bft/src/helpers/cache.rs @@ -39,6 +39,10 @@ pub struct Cache { /// The ordered timestamp map of peer IPs and their cache hits on transmission requests. seen_outbound_transmissions: RwLock>>, /// The map of IPs to the number of validators requests. + /// + /// Note: we don't clear this map based on time but only on peer disconnect. + /// This is sufficient to avoid infinite growth as the committee has a fixed number + /// of members. seen_outbound_validators_requests: RwLock>, } @@ -119,6 +123,11 @@ impl Cache { pub fn decrement_outbound_validators_requests(&self, peer_ip: SocketAddr) -> u32 { Self::decrement_counter(&self.seen_outbound_validators_requests, peer_ip) } + + /// Clears the the IP's number of validator requests. + pub fn clear_outbound_validators_requests(&self, peer_ip: SocketAddr) { + self.seen_outbound_validators_requests.write().remove(&peer_ip); + } } impl Cache { @@ -293,4 +302,27 @@ mod tests { outbound_certificate, outbound_transmission } + + #[test] + fn test_seen_outbound_validators_requests() { + let cache = Cache::::default(); + let input = Input::input(); + + // Check the map is empty. + assert!(!cache.contains_outbound_validators_request(input)); + + // Insert some requests. + for _ in 0..3 { + cache.increment_outbound_validators_requests(input); + assert!(cache.contains_outbound_validators_request(input)); + } + + // Remove a request. + cache.decrement_outbound_validators_requests(input); + assert!(cache.contains_outbound_validators_request(input)); + + // Clear all requests. + cache.clear_outbound_validators_requests(input); + assert!(!cache.contains_outbound_validators_request(input)); + } } From f1d9126cdfad18a622770e8025643c307edef29e Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 14 May 2024 11:51:55 -0700 Subject: [PATCH 503/551] Add IS_SYNCING check for fetching certificates --- node/bft/src/primary.rs | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 05069d2aa4..cb0e7e87c7 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -161,7 +161,8 @@ impl Primary { // We use a dummy IP because the node should not need to request from any peers. // The storage should have stored all the transmissions. If not, we simply // skip the certificate. - if let Err(err) = self.sync_with_certificate_from_peer(DUMMY_SELF_IP, certificate).await { + if let Err(err) = self.sync_with_certificate_from_peer::(DUMMY_SELF_IP, certificate).await + { warn!("Failed to load stored certificate {} from proposal cache - {err}", fmt_id(batch_id)); } } @@ -690,7 +691,7 @@ impl Primary { } // If the peer is ahead, use the batch header to sync up to the peer. - let mut transmissions = self.sync_with_batch_header_from_peer(peer_ip, &batch_header).await?; + let mut transmissions = self.sync_with_batch_header_from_peer::(peer_ip, &batch_header).await?; // Check that the transmission ids match and are not fee transactions. if let Err(err) = cfg_iter_mut!(transmissions).try_for_each(|(transmission_id, transmission)| { @@ -902,7 +903,7 @@ impl Primary { } // Store the certificate, after ensuring it is valid. - self.sync_with_certificate_from_peer(peer_ip, certificate).await?; + self.sync_with_certificate_from_peer::(peer_ip, certificate).await?; // If there are enough certificates to reach quorum threshold for the certificate round, // then proceed to advance to the next round. @@ -1421,7 +1422,7 @@ impl Primary { /// - Ensure the previous certificates have reached the quorum threshold. /// - Ensure we have not already signed the batch ID. #[async_recursion::async_recursion] - async fn sync_with_certificate_from_peer( + async fn sync_with_certificate_from_peer( &self, peer_ip: SocketAddr, certificate: BatchCertificate, @@ -1440,8 +1441,16 @@ impl Primary { return Ok(()); } + // If node is not in sync mode and the node is not synced. Then return an error. + if !IS_SYNCING && !self.is_synced() { + bail!( + "Failed to process certificate `{}` at round {batch_round} from '{peer_ip}' (node is syncing)", + fmt_id(certificate.id()) + ); + } + // If the peer is ahead, use the batch header to sync up to the peer. - let missing_transmissions = self.sync_with_batch_header_from_peer(peer_ip, batch_header).await?; + let missing_transmissions = self.sync_with_batch_header_from_peer::(peer_ip, batch_header).await?; // Check if the certificate needs to be stored. if !self.storage.contains_certificate(certificate.id()) { @@ -1462,7 +1471,7 @@ impl Primary { } /// Recursively syncs using the given batch header. - async fn sync_with_batch_header_from_peer( + async fn sync_with_batch_header_from_peer( &self, peer_ip: SocketAddr, batch_header: &BatchHeader, @@ -1475,6 +1484,14 @@ impl Primary { bail!("Round {batch_round} is too far in the past") } + // If node is not in sync mode and the node is not synced. Then return an error. + if !IS_SYNCING && !self.is_synced() { + bail!( + "Failed to process batch header `{}` at round {batch_round} from '{peer_ip}' (node is syncing)", + fmt_id(batch_header.batch_id()) + ); + } + // Determine if quorum threshold is reached on the batch round. let is_quorum_threshold_reached = { let certificates = self.storage.get_certificates_for_round(batch_round); @@ -1510,7 +1527,7 @@ impl Primary { // Iterate through the missing previous certificates. for batch_certificate in missing_previous_certificates { // Store the batch certificate (recursively fetching any missing previous certificates). - self.sync_with_certificate_from_peer(peer_ip, batch_certificate).await?; + self.sync_with_certificate_from_peer::(peer_ip, batch_certificate).await?; } Ok(missing_transmissions) } From c20db62906eed09d7085b57b214ca99d1af9ed8c Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 14 May 2024 14:09:29 -0700 Subject: [PATCH 504/551] Update log condition --- node/bft/storage-service/src/memory.rs | 4 +++- node/bft/storage-service/src/persistent.rs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/node/bft/storage-service/src/memory.rs b/node/bft/storage-service/src/memory.rs index 38cd430d68..25648742e0 100644 --- a/node/bft/storage-service/src/memory.rs +++ b/node/bft/storage-service/src/memory.rs @@ -120,7 +120,9 @@ impl StorageService for BFTMemoryService { Entry::Vacant(vacant_entry) => { // Retrieve the missing transmission. let Some(transmission) = missing_transmissions.remove(&transmission_id) else { - if !aborted_transmission_ids.contains(&transmission_id) { + if !aborted_transmission_ids.contains(&transmission_id) + && !self.contains_transmission(transmission_id) + { error!("Failed to provide a missing transmission {transmission_id}"); } continue 'outer; diff --git a/node/bft/storage-service/src/persistent.rs b/node/bft/storage-service/src/persistent.rs index b18b3771d7..96a9d0c8e5 100644 --- a/node/bft/storage-service/src/persistent.rs +++ b/node/bft/storage-service/src/persistent.rs @@ -171,7 +171,9 @@ impl StorageService for BFTPersistentStorage { Ok(None) => { // Retrieve the missing transmission. let Some(transmission) = missing_transmissions.remove(&transmission_id) else { - if !aborted_transmission_ids.contains(&transmission_id) { + if !aborted_transmission_ids.contains(&transmission_id) + && !self.contains_transmission(transmission_id) + { error!("Failed to provide a missing transmission {transmission_id}"); } continue 'outer; From 6369f108d451bf98fb747311509c578713e5f8ac Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 14 May 2024 14:19:00 -0700 Subject: [PATCH 505/551] Update is_block_synced if there are no requests/responses --- node/sync/src/block_sync.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/node/sync/src/block_sync.rs b/node/sync/src/block_sync.rs index 525962ed0c..b40f94be9c 100644 --- a/node/sync/src/block_sync.rs +++ b/node/sync/src/block_sync.rs @@ -453,8 +453,11 @@ impl BlockSync { // Return the list of block requests. (self.construct_requests(&sync_peers, min_common_ancestor), sync_peers) } else { - // Update the state of `is_block_synced` for the sync module. - self.update_is_block_synced(0, MAX_BLOCKS_BEHIND); + // Update `is_block_synced` for the sync module if there are no pending requests/responses. + if self.requests.read().is_empty() && self.responses.read().is_empty() { + // Update the state of `is_block_synced` for the sync module. + self.update_is_block_synced(0, MAX_BLOCKS_BEHIND); + } // Return an empty list of block requests. (Default::default(), Default::default()) } From cd959aa8937b22fde369c4b310e86b21a9a8d704 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 14 May 2024 18:49:58 -0700 Subject: [PATCH 506/551] nit --- node/sync/src/block_sync.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/sync/src/block_sync.rs b/node/sync/src/block_sync.rs index b40f94be9c..48c9778191 100644 --- a/node/sync/src/block_sync.rs +++ b/node/sync/src/block_sync.rs @@ -453,7 +453,7 @@ impl BlockSync { // Return the list of block requests. (self.construct_requests(&sync_peers, min_common_ancestor), sync_peers) } else { - // Update `is_block_synced` for the sync module if there are no pending requests/responses. + // Update `is_block_synced` if there are no pending requests or responses. if self.requests.read().is_empty() && self.responses.read().is_empty() { // Update the state of `is_block_synced` for the sync module. self.update_is_block_synced(0, MAX_BLOCKS_BEHIND); From 02cca26ef4fe894e072bf07da38eab0b6c751d90 Mon Sep 17 00:00:00 2001 From: Fabiano Prestes Date: Tue, 14 May 2024 22:21:35 -0400 Subject: [PATCH 507/551] modify CircleCI config to use our runners --- .circleci/config.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 522066b223..f307ae18dd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -161,7 +161,7 @@ jobs: integration: docker: - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: 2xlarge + resource_class: anf/2xlarge steps: - run_serial_long: workspace_member: .integration @@ -170,7 +170,7 @@ jobs: snarkos: docker: - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: 2xlarge + resource_class: anf/2xlarge steps: - run_serial: workspace_member: . @@ -206,7 +206,7 @@ jobs: node: docker: - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: 2xlarge + resource_class: anf/2xlarge steps: - run_serial: workspace_member: node @@ -215,7 +215,7 @@ jobs: node-bft: docker: - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: 2xlarge + resource_class: anf/2xlarge steps: - run_serial: workspace_member: node/bft @@ -224,7 +224,7 @@ jobs: node-bft-events: docker: - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: 2xlarge + resource_class: anf/2xlarge steps: - run_serial: workspace_member: node/bft/events @@ -260,7 +260,7 @@ jobs: node-consensus: docker: - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: 2xlarge + resource_class: anf/2xlarge steps: - run_serial: workspace_member: node/consensus @@ -348,7 +348,7 @@ jobs: check-clippy: docker: - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: 2xlarge + resource_class: anf/2xlarge steps: - checkout - setup_environment: From 0e043d4ef704c73121e433803e6cc406c673cd81 Mon Sep 17 00:00:00 2001 From: Fabiano Prestes Date: Tue, 14 May 2024 22:47:12 -0400 Subject: [PATCH 508/551] adding another runner to CircleCI config --- .circleci/config.yml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f307ae18dd..808e08053e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -179,7 +179,7 @@ jobs: account: docker: - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: xlarge + resource_class: anf/xlarge steps: - run_serial: workspace_member: account @@ -188,7 +188,7 @@ jobs: cli: docker: - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: xlarge + resource_class: anf/xlarge steps: - run_serial: workspace_member: cli @@ -197,7 +197,7 @@ jobs: display: docker: - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: xlarge + resource_class: anf/xlarge steps: - run_serial: workspace_member: display @@ -233,7 +233,7 @@ jobs: node-bft-ledger-service: docker: - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: xlarge + resource_class: anf/xlarge steps: - run_serial: workspace_member: node/bft/ledger-service @@ -242,7 +242,7 @@ jobs: node-bft-storage-service: docker: - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: xlarge + resource_class: anf/xlarge steps: - run_serial: workspace_member: node/bft/storage-service @@ -251,7 +251,7 @@ jobs: node-cdn: docker: - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: xlarge + resource_class: anf/xlarge steps: - run_serial: workspace_member: node/cdn @@ -269,7 +269,7 @@ jobs: node-rest: docker: - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: xlarge + resource_class: anf/xlarge steps: - run_serial: workspace_member: node/rest @@ -278,7 +278,7 @@ jobs: node-router: docker: - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: xlarge + resource_class: anf/xlarge steps: - run_serial: workspace_member: node/router @@ -287,7 +287,7 @@ jobs: node-router-messages: docker: - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: xlarge + resource_class: anf/xlarge steps: - run_serial: workspace_member: node/router/messages @@ -296,7 +296,7 @@ jobs: node-sync: docker: - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: xlarge + resource_class: anf/xlarge steps: - run_serial: workspace_member: node/sync @@ -305,7 +305,7 @@ jobs: node-sync-communication-service: docker: - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: xlarge + resource_class: anf/xlarge steps: - run_serial: workspace_member: node/sync/communication-service @@ -314,7 +314,7 @@ jobs: node-sync-locators: docker: - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: xlarge + resource_class: anf/xlarge steps: - run_serial: workspace_member: node/sync/locators @@ -323,7 +323,7 @@ jobs: node-tcp: docker: - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: xlarge + resource_class: anf/xlarge steps: - run_serial: workspace_member: node/tcp @@ -332,7 +332,7 @@ jobs: check-fmt: docker: - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: xlarge + resource_class: anf/xlarge steps: - checkout - install_rust_nightly From e002ef21e1dc54c3fc8ecbb269d58967a361a8b4 Mon Sep 17 00:00:00 2001 From: Fabiano Prestes Date: Tue, 14 May 2024 23:37:45 -0400 Subject: [PATCH 509/551] removing setup_remote_docker --- .circleci/config.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 808e08053e..b6b1ebae6a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -49,7 +49,6 @@ commands: default: snarkos-stable-cache steps: - run: set -e - - setup_remote_docker - run: name: Prepare environment and install dependencies command: | From 877a14e2113cc4767d00d554e4edf4b1be81961f Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 15 May 2024 16:06:03 -0700 Subject: [PATCH 510/551] Fix tests --- node/bft/src/primary.rs | 45 ++++++++++++++++++++++++++++++++++++++++ node/bft/src/sync/mod.rs | 6 ++++++ 2 files changed, 51 insertions(+) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index cb0e7e87c7..b604941fb6 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -2082,6 +2082,8 @@ mod tests { // The author must be known to resolver to pass propose checks. primary.gateway.resolver().insert_peer(peer_ip, peer_ip, peer_account.1.address()); + // The primary must be considered synced. + primary.sync.block_sync().try_block_sync(&primary.gateway.clone()).await; // Try to process the batch proposal from the peer, should succeed. assert!( @@ -2089,6 +2091,39 @@ mod tests { ); } + #[tokio::test] + async fn test_batch_propose_from_peer_when_not_synced() { + let mut rng = TestRng::default(); + let (primary, accounts) = primary_without_handlers(&mut rng).await; + + // Create a valid proposal with an author that isn't the primary. + let round = 1; + let peer_account = &accounts[1]; + let peer_ip = peer_account.0; + let timestamp = now() + MIN_BATCH_DELAY_IN_SECS as i64; + let proposal = create_test_proposal( + &peer_account.1, + primary.ledger.current_committee().unwrap(), + round, + Default::default(), + timestamp, + &mut rng, + ); + + // Make sure the primary is aware of the transmissions in the proposal. + for (transmission_id, transmission) in proposal.transmissions() { + primary.workers[0].process_transmission_from_peer(peer_ip, *transmission_id, transmission.clone()) + } + + // The author must be known to resolver to pass propose checks. + primary.gateway.resolver().insert_peer(peer_ip, peer_ip, peer_account.1.address()); + + // Try to process the batch proposal from the peer, should fail. + assert!( + primary.process_batch_propose_from_peer(peer_ip, (*proposal.batch_header()).clone().into()).await.is_err() + ); + } + #[tokio::test] async fn test_batch_propose_from_peer_in_round() { let round = 2; @@ -2118,6 +2153,8 @@ mod tests { // The author must be known to resolver to pass propose checks. primary.gateway.resolver().insert_peer(peer_ip, peer_ip, peer_account.1.address()); + // The primary must be considered synced. + primary.sync.block_sync().try_block_sync(&primary.gateway.clone()).await; // Try to process the batch proposal from the peer, should succeed. primary.process_batch_propose_from_peer(peer_ip, (*proposal.batch_header()).clone().into()).await.unwrap(); @@ -2149,6 +2186,8 @@ mod tests { // The author must be known to resolver to pass propose checks. primary.gateway.resolver().insert_peer(peer_ip, peer_ip, peer_account.1.address()); + // The primary must be considered synced. + primary.sync.block_sync().try_block_sync(&primary.gateway.clone()).await; // Try to process the batch proposal from the peer, should error. assert!( @@ -2191,6 +2230,8 @@ mod tests { // The author must be known to resolver to pass propose checks. primary.gateway.resolver().insert_peer(peer_ip, peer_ip, peer_account.1.address()); + // The primary must be considered synced. + primary.sync.block_sync().try_block_sync(&primary.gateway.clone()).await; // Try to process the batch proposal from the peer, should error. assert!( @@ -2233,6 +2274,8 @@ mod tests { // The author must be known to resolver to pass propose checks. primary.gateway.resolver().insert_peer(peer_ip, peer_ip, peer_account.1.address()); + // The primary must be considered synced. + primary.sync.block_sync().try_block_sync(&primary.gateway.clone()).await; // Try to process the batch proposal from the peer, should error. assert!( @@ -2269,6 +2312,8 @@ mod tests { // The author must be known to resolver to pass propose checks. primary.gateway.resolver().insert_peer(peer_ip, peer_ip, peer_account.1.address()); + // The primary must be considered synced. + primary.sync.block_sync().try_block_sync(&primary.gateway.clone()).await; // Try to process the batch proposal from the peer, should error. assert!( diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index e5dc84731b..f60ce1a40a 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -557,6 +557,12 @@ impl Sync { pub fn get_block_locators(&self) -> Result> { self.block_sync.get_block_locators() } + + /// Returns the block sync module. + #[cfg(test)] + pub(super) fn block_sync(&self) -> &BlockSync { + &self.block_sync + } } // Methods to assist with fetching batch certificates from peers. From 01087105c3ce00d80bf3e766b7ae284a5933d27d Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 15 May 2024 16:10:18 -0700 Subject: [PATCH 511/551] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index f58c794d33..98b96026ae 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ wasm/Cargo.lock **/build **.ledger-* +**.current-proposal-cache-* **.logs-* validator-* **.bft-storage-*/ From fd6fb7e53f37b41b7a917f0c9255255030ababca Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 15 May 2024 16:57:40 -0700 Subject: [PATCH 512/551] Send one request at a time to peers --- node/bft/src/helpers/pending.rs | 24 +++++++++++++++++++++++- node/bft/src/sync/mod.rs | 5 ++++- node/bft/src/worker.rs | 5 ++++- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index cf68a39e54..31fe2bf57f 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -85,6 +85,16 @@ impl Pending { self.pending.read().get(&item.into()).map_or(false, |peer_ips| peer_ips.contains_key(&peer_ip)) } + /// Returns `true` if the pending queue contains the specified `item` for the specified `peer IP` with a sent request. + pub fn contains_peer_with_sent_request(&self, item: impl Into, peer_ip: SocketAddr) -> bool { + self.pending.read().get(&item.into()).map_or(false, |peer_ips| { + peer_ips + .get(&peer_ip) + .map(|callbacks| callbacks.iter().any(|(_, _, request_sent)| *request_sent)) + .unwrap_or(false) + }) + } + /// Returns the peer IPs for the specified `item`. pub fn get_peers(&self, item: impl Into) -> Option> { self.pending.read().get(&item.into()).map(|map| map.keys().cloned().collect()) @@ -254,24 +264,29 @@ mod tests { let solution_id_1 = TransmissionID::Solution(rng.gen::().into()); let solution_id_2 = TransmissionID::Solution(rng.gen::().into()); let solution_id_3 = TransmissionID::Solution(rng.gen::().into()); + let solution_id_4 = TransmissionID::Solution(rng.gen::().into()); // Initialize the SocketAddrs. let addr_1 = SocketAddr::from(([127, 0, 0, 1], 1234)); let addr_2 = SocketAddr::from(([127, 0, 0, 1], 2345)); let addr_3 = SocketAddr::from(([127, 0, 0, 1], 3456)); + let addr_4 = SocketAddr::from(([127, 0, 0, 1], 3456)); // Initialize the callbacks. let (callback_sender_1, _) = oneshot::channel(); let (callback_sender_2, _) = oneshot::channel(); let (callback_sender_3, _) = oneshot::channel(); + let (callback_sender_4, _) = oneshot::channel(); // Insert the solution IDs. assert!(pending.insert(solution_id_1, addr_1, Some((callback_sender_1, true)))); assert!(pending.insert(solution_id_2, addr_2, Some((callback_sender_2, true)))); assert!(pending.insert(solution_id_3, addr_3, Some((callback_sender_3, true)))); + // Add a callback without a sent request. + assert!(pending.insert(solution_id_4, addr_4, Some((callback_sender_4, false)))); // Check the number of SocketAddrs. - assert_eq!(pending.len(), 3); + assert_eq!(pending.len(), 4); assert!(!pending.is_empty()); // Check the items. @@ -282,7 +297,12 @@ mod tests { let id = ids[i]; assert!(pending.contains(id)); assert!(pending.contains_peer(id, peers[i])); + assert!(pending.contains_peer_with_sent_request(id, peers[i])); } + // Ensure the last item does not have a sent request. + assert!(pending.contains_peer(solution_id_4, addr_4)); + assert!(!pending.contains_peer_with_sent_request(solution_id_4, addr_4)); + let unknown_id = TransmissionID::Solution(rng.gen::().into()); assert!(!pending.contains(unknown_id)); @@ -290,12 +310,14 @@ mod tests { assert_eq!(pending.get_peers(solution_id_1), Some(HashSet::from([addr_1]))); assert_eq!(pending.get_peers(solution_id_2), Some(HashSet::from([addr_2]))); assert_eq!(pending.get_peers(solution_id_3), Some(HashSet::from([addr_3]))); + assert_eq!(pending.get_peers(solution_id_4), Some(HashSet::from([addr_4]))); assert_eq!(pending.get_peers(unknown_id), None); // Check remove. assert!(pending.remove(solution_id_1, None).is_some()); assert!(pending.remove(solution_id_2, None).is_some()); assert!(pending.remove(solution_id_3, None).is_some()); + assert!(pending.remove(solution_id_4, None).is_some()); assert!(pending.remove(unknown_id, None).is_none()); // Check empty again. diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index e5dc84731b..c97b2fc4fc 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -571,10 +571,13 @@ impl Sync { let (callback_sender, callback_receiver) = oneshot::channel(); // Determine how many sent requests are pending. let num_sent_requests = self.pending.num_sent_requests(certificate_id); + // Determine if we've already sent a request to the peer. + let contains_peer_with_sent_request = self.pending.contains_peer_with_sent_request(certificate_id, peer_ip); // Determine the maximum number of redundant requests. let num_redundant_requests = max_redundant_requests(self.ledger.clone(), self.storage.current_round()); // Determine if we should send a certificate request to the peer. - let should_send_request = num_sent_requests < num_redundant_requests; + // We send at most `num_redundant_requests` requests and each peer can only receive one request at a time. + let should_send_request = num_sent_requests < num_redundant_requests && !contains_peer_with_sent_request; // Insert the certificate ID into the pending queue. self.pending.insert(certificate_id, peer_ip, Some((callback_sender, should_send_request))); diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index dc82d775ce..7b8e5301d6 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -410,10 +410,13 @@ impl Worker { let (callback_sender, callback_receiver) = oneshot::channel(); // Determine how many sent requests are pending. let num_sent_requests = self.pending.num_sent_requests(transmission_id); + // Determine if we've already sent a request to the peer. + let contains_peer_with_sent_request = self.pending.contains_peer_with_sent_request(transmission_id, peer_ip); // Determine the maximum number of redundant requests. let num_redundant_requests = max_redundant_requests(self.ledger.clone(), self.storage.current_round()); // Determine if we should send a transmission request to the peer. - let should_send_request = num_sent_requests < num_redundant_requests; + // We send at most `num_redundant_requests` requests and each peer can only receive one request at a time. + let should_send_request = num_sent_requests < num_redundant_requests && !contains_peer_with_sent_request; // Insert the transmission ID into the pending queue. self.pending.insert(transmission_id, peer_ip, Some((callback_sender, should_send_request))); From ac260509ccc1b481d1683de79146da0f1da152c7 Mon Sep 17 00:00:00 2001 From: Fabiano Date: Thu, 16 May 2024 01:14:32 -0400 Subject: [PATCH 513/551] bootstrap peers for Testnet Beta --- .circleci/config.yml | 87 ++++++++++++++++----------------- Cargo.toml | 6 +-- node/router/messages/src/lib.rs | 2 +- node/router/src/lib.rs | 8 +-- rust-toolchain | 2 +- 5 files changed, 52 insertions(+), 53 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 522066b223..221d348144 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -49,7 +49,6 @@ commands: default: snarkos-stable-cache steps: - run: set -e - - setup_remote_docker - run: name: Prepare environment and install dependencies command: | @@ -160,8 +159,8 @@ commands: jobs: integration: docker: - - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: 2xlarge + - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + resource_class: anf/2xlarge steps: - run_serial_long: workspace_member: .integration @@ -169,8 +168,8 @@ jobs: snarkos: docker: - - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: 2xlarge + - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + resource_class: anf/2xlarge steps: - run_serial: workspace_member: . @@ -178,8 +177,8 @@ jobs: account: docker: - - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: xlarge + - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + resource_class: anf/xlarge steps: - run_serial: workspace_member: account @@ -187,8 +186,8 @@ jobs: cli: docker: - - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: xlarge + - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + resource_class: anf/xlarge steps: - run_serial: workspace_member: cli @@ -196,8 +195,8 @@ jobs: display: docker: - - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: xlarge + - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + resource_class: anf/xlarge steps: - run_serial: workspace_member: display @@ -205,8 +204,8 @@ jobs: node: docker: - - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: 2xlarge + - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + resource_class: anf/2xlarge steps: - run_serial: workspace_member: node @@ -214,8 +213,8 @@ jobs: node-bft: docker: - - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: 2xlarge + - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + resource_class: anf/2xlarge steps: - run_serial: workspace_member: node/bft @@ -223,8 +222,8 @@ jobs: node-bft-events: docker: - - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: 2xlarge + - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + resource_class: anf/2xlarge steps: - run_serial: workspace_member: node/bft/events @@ -232,8 +231,8 @@ jobs: node-bft-ledger-service: docker: - - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: xlarge + - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + resource_class: anf/xlarge steps: - run_serial: workspace_member: node/bft/ledger-service @@ -241,8 +240,8 @@ jobs: node-bft-storage-service: docker: - - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: xlarge + - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + resource_class: anf/xlarge steps: - run_serial: workspace_member: node/bft/storage-service @@ -250,8 +249,8 @@ jobs: node-cdn: docker: - - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: xlarge + - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + resource_class: anf/xlarge steps: - run_serial: workspace_member: node/cdn @@ -259,8 +258,8 @@ jobs: node-consensus: docker: - - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: 2xlarge + - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + resource_class: anf/2xlarge steps: - run_serial: workspace_member: node/consensus @@ -268,8 +267,8 @@ jobs: node-rest: docker: - - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: xlarge + - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + resource_class: anf/xlarge steps: - run_serial: workspace_member: node/rest @@ -277,8 +276,8 @@ jobs: node-router: docker: - - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: xlarge + - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + resource_class: anf/xlarge steps: - run_serial: workspace_member: node/router @@ -286,8 +285,8 @@ jobs: node-router-messages: docker: - - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: xlarge + - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + resource_class: anf/xlarge steps: - run_serial: workspace_member: node/router/messages @@ -295,8 +294,8 @@ jobs: node-sync: docker: - - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: xlarge + - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + resource_class: anf/xlarge steps: - run_serial: workspace_member: node/sync @@ -304,8 +303,8 @@ jobs: node-sync-communication-service: docker: - - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: xlarge + - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + resource_class: anf/xlarge steps: - run_serial: workspace_member: node/sync/communication-service @@ -313,8 +312,8 @@ jobs: node-sync-locators: docker: - - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: xlarge + - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + resource_class: anf/xlarge steps: - run_serial: workspace_member: node/sync/locators @@ -322,8 +321,8 @@ jobs: node-tcp: docker: - - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: xlarge + - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + resource_class: anf/xlarge steps: - run_serial: workspace_member: node/tcp @@ -331,8 +330,8 @@ jobs: check-fmt: docker: - - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: xlarge + - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + resource_class: anf/xlarge steps: - checkout - install_rust_nightly @@ -347,8 +346,8 @@ jobs: check-clippy: docker: - - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well - resource_class: 2xlarge + - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + resource_class: anf/2xlarge steps: - checkout - setup_environment: @@ -422,4 +421,4 @@ workflows: only: - mainnet jobs: - - integration + - integration \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 9ca0b69a7b..125bddc4e3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ version = "2.2.7" authors = [ "The Aleo Team " ] description = "A decentralized operating system" homepage = "https://aleo.org" -repository = "https://github.com/AleoHQ/snarkOS" +repository = "https://github.com/AleoNet/snarkOS" keywords = [ "aleo", "cryptography", @@ -15,7 +15,7 @@ keywords = [ categories = [ "cryptography", "operating-systems" ] license = "Apache-2.0" edition = "2021" -rust-version = "1.76.0" # Attention - Change the MSRV in rust-toolchain and in .circleci/config.yml as well +rust-version = "1.78.0" # Attention - Change the MSRV in rust-toolchain and in .circleci/config.yml as well [workspace] members = [ @@ -45,7 +45,7 @@ version = "=0.1.24" default-features = false [workspace.dependencies.snarkvm] -git = "https://github.com/AleoHQ/snarkVM.git" +git = "https://github.com/AleoNet/snarkVM.git" rev = "3ebe60c" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] diff --git a/node/router/messages/src/lib.rs b/node/router/messages/src/lib.rs index ab75c13673..66a3ddd5ce 100644 --- a/node/router/messages/src/lib.rs +++ b/node/router/messages/src/lib.rs @@ -111,7 +111,7 @@ impl From for Message { impl Message { /// The version of the network protocol; it can be incremented in order to force users to update. - pub const VERSION: u32 = 14; + pub const VERSION: u32 = 15; /// Returns the message name. #[inline] diff --git a/node/router/src/lib.rs b/node/router/src/lib.rs index 748870deda..82604e9489 100644 --- a/node/router/src/lib.rs +++ b/node/router/src/lib.rs @@ -395,10 +395,10 @@ impl Router { vec![] } else { vec![ - SocketAddr::from_str("64.23.169.88:4130").unwrap(), - SocketAddr::from_str("146.190.35.174:4130").unwrap(), - SocketAddr::from_str("45.55.201.67:4130").unwrap(), - SocketAddr::from_str("45.55.201.80:4130").unwrap(), + SocketAddr::from_str("34.168.118.156:4130").unwrap(), + SocketAddr::from_str("35.231.152.213:4130").unwrap(), + SocketAddr::from_str("34.17.53.129:4130").unwrap(), + SocketAddr::from_str("35.200.149.162:4130").unwrap(), ] } } diff --git a/rust-toolchain b/rust-toolchain index 32a6ce3c71..54227249d1 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.76.0 +1.78.0 From 5953961ea400838d60a60400023df7d7ac3cb3d7 Mon Sep 17 00:00:00 2001 From: Fabiano Date: Thu, 16 May 2024 01:15:11 -0400 Subject: [PATCH 514/551] update rev of matching branch --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 125bddc4e3..037ee0764a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoNet/snarkVM.git" -rev = "3ebe60c" +rev = "a76593b" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From f3c170821d4e8871e06330ed310d424fa20088cd Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 15 May 2024 22:47:10 -0700 Subject: [PATCH 515/551] Use proper network selection in developer CLI --- cli/src/commands/developer/mod.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/cli/src/commands/developer/mod.rs b/cli/src/commands/developer/mod.rs index f6cb0b18fa..c9a6ed8805 100644 --- a/cli/src/commands/developer/mod.rs +++ b/cli/src/commands/developer/mod.rs @@ -115,8 +115,15 @@ impl Developer { /// Fetch the program from the given endpoint. fn fetch_program(program_id: &ProgramID, endpoint: &str) -> Result> { + // Get the network being used. + let network = match N::ID { + snarkvm::console::network::MainnetV0::ID => "mainnet", + snarkvm::console::network::TestnetV0::ID => "testnet", + _ => "mainnet", + }; + // Send a request to the query node. - let response = ureq::get(&format!("{endpoint}/mainnet/program/{program_id}")).call(); + let response = ureq::get(&format!("{endpoint}/{network}/program/{program_id}")).call(); // Deserialize the program. match response { @@ -136,9 +143,16 @@ impl Developer { let credits = ProgramID::::from_str("credits.aleo")?; let account_mapping = Identifier::::from_str("account")?; + // Get the network being used. + let network = match N::ID { + snarkvm::console::network::MainnetV0::ID => "mainnet", + snarkvm::console::network::TestnetV0::ID => "testnet", + _ => "mainnet", + }; + // Send a request to the query node. let response = - ureq::get(&format!("{endpoint}/mainnet/program/{credits}/mapping/{account_mapping}/{address}")).call(); + ureq::get(&format!("{endpoint}/{network}/program/{credits}/mapping/{account_mapping}/{address}")).call(); // Deserialize the balance. let balance: Result>> = match response { From cca69b225be71b14966b76f147c3f0d0970f0d02 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 15 May 2024 22:56:47 -0700 Subject: [PATCH 516/551] Add cfg flags --- node/bft/src/helpers/storage.rs | 1 + node/bft/src/sync/mod.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/node/bft/src/helpers/storage.rs b/node/bft/src/helpers/storage.rs index bda8bce766..abb93310d8 100644 --- a/node/bft/src/helpers/storage.rs +++ b/node/bft/src/helpers/storage.rs @@ -788,6 +788,7 @@ impl Storage { /// Inserts the given `certificate` into storage. /// /// Note: Do NOT use this in production. This is for **testing only**. + #[cfg(test)] #[doc(hidden)] pub(crate) fn testing_only_insert_certificate_testing_only(&self, certificate: BatchCertificate) { // Retrieve the round. diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index f60ce1a40a..02bb3c3dc2 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -560,6 +560,7 @@ impl Sync { /// Returns the block sync module. #[cfg(test)] + #[doc(hidden)] pub(super) fn block_sync(&self) -> &BlockSync { &self.block_sync } From 302354053f04a96b485b1574856b2a7bcb296821 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 16 May 2024 00:10:32 -0700 Subject: [PATCH 517/551] nit test --- node/bft/src/helpers/pending.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index 31fe2bf57f..690bde5098 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -270,7 +270,7 @@ mod tests { let addr_1 = SocketAddr::from(([127, 0, 0, 1], 1234)); let addr_2 = SocketAddr::from(([127, 0, 0, 1], 2345)); let addr_3 = SocketAddr::from(([127, 0, 0, 1], 3456)); - let addr_4 = SocketAddr::from(([127, 0, 0, 1], 3456)); + let addr_4 = SocketAddr::from(([127, 0, 0, 1], 5678)); // Initialize the callbacks. let (callback_sender_1, _) = oneshot::channel(); From b0ecd1236ab56ec521f23faf2679bbaa793e188d Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 16 May 2024 00:12:25 -0700 Subject: [PATCH 518/551] nit --- node/bft/src/helpers/pending.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index 690bde5098..ca07ee090a 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -270,7 +270,7 @@ mod tests { let addr_1 = SocketAddr::from(([127, 0, 0, 1], 1234)); let addr_2 = SocketAddr::from(([127, 0, 0, 1], 2345)); let addr_3 = SocketAddr::from(([127, 0, 0, 1], 3456)); - let addr_4 = SocketAddr::from(([127, 0, 0, 1], 5678)); + let addr_4 = SocketAddr::from(([127, 0, 0, 1], 4567)); // Initialize the callbacks. let (callback_sender_1, _) = oneshot::channel(); From 9e9c3ac021f6c6389b1c7c8bfc055132514ff314 Mon Sep 17 00:00:00 2001 From: Niklas Date: Thu, 16 May 2024 17:37:02 +0200 Subject: [PATCH 519/551] docs: move cache clear explanation to call site --- node/bft/src/gateway.rs | 4 ++++ node/bft/src/helpers/cache.rs | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/node/bft/src/gateway.rs b/node/bft/src/gateway.rs index 58674b1de0..00cc6b96ea 100644 --- a/node/bft/src/gateway.rs +++ b/node/bft/src/gateway.rs @@ -1085,6 +1085,10 @@ impl Disconnect for Gateway { async fn handle_disconnect(&self, peer_addr: SocketAddr) { if let Some(peer_ip) = self.resolver.get_listener(peer_addr) { self.remove_connected_peer(peer_ip); + + // We don't clear this map based on time but only on peer disconnect. + // This is sufficient to avoid infinite growth as the committee has a fixed number + // of members. self.cache.clear_outbound_validators_requests(peer_ip); } } diff --git a/node/bft/src/helpers/cache.rs b/node/bft/src/helpers/cache.rs index a735185e5e..8c4d436ebe 100644 --- a/node/bft/src/helpers/cache.rs +++ b/node/bft/src/helpers/cache.rs @@ -40,9 +40,6 @@ pub struct Cache { seen_outbound_transmissions: RwLock>>, /// The map of IPs to the number of validators requests. /// - /// Note: we don't clear this map based on time but only on peer disconnect. - /// This is sufficient to avoid infinite growth as the committee has a fixed number - /// of members. seen_outbound_validators_requests: RwLock>, } From 0ebab238d31a582171cf2650a493e15723081b52 Mon Sep 17 00:00:00 2001 From: Fabiano Prestes Date: Thu, 16 May 2024 12:50:24 -0400 Subject: [PATCH 520/551] update snarkVM rev --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 037ee0764a..c4d28f4379 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoNet/snarkVM.git" -rev = "a76593b" +rev = "f8deffb" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From cfa4521945289bc741b9abbc21c0fafdd44271c8 Mon Sep 17 00:00:00 2001 From: Fabiano Date: Thu, 16 May 2024 14:52:09 -0400 Subject: [PATCH 521/551] Bump snarkVM rev - 140ff26 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index c4d28f4379..2972ac42ff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoNet/snarkVM.git" -rev = "f8deffb" +rev = "140ff26" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From 78660866ac02435e28658551eab83b133dc8fc04 Mon Sep 17 00:00:00 2001 From: Fabiano Date: Thu, 16 May 2024 14:59:21 -0400 Subject: [PATCH 522/551] Downgrade Rust version to avoid CI issues --- .circleci/config.yml | 42 +++++++++++++++++++++--------------------- Cargo.toml | 2 +- rust-toolchain | 2 +- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 221d348144..21641255cc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -159,7 +159,7 @@ commands: jobs: integration: docker: - - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: anf/2xlarge steps: - run_serial_long: @@ -168,7 +168,7 @@ jobs: snarkos: docker: - - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: anf/2xlarge steps: - run_serial: @@ -177,7 +177,7 @@ jobs: account: docker: - - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: anf/xlarge steps: - run_serial: @@ -186,7 +186,7 @@ jobs: cli: docker: - - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: anf/xlarge steps: - run_serial: @@ -195,7 +195,7 @@ jobs: display: docker: - - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: anf/xlarge steps: - run_serial: @@ -204,7 +204,7 @@ jobs: node: docker: - - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: anf/2xlarge steps: - run_serial: @@ -213,7 +213,7 @@ jobs: node-bft: docker: - - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: anf/2xlarge steps: - run_serial: @@ -222,7 +222,7 @@ jobs: node-bft-events: docker: - - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: anf/2xlarge steps: - run_serial: @@ -231,7 +231,7 @@ jobs: node-bft-ledger-service: docker: - - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: anf/xlarge steps: - run_serial: @@ -240,7 +240,7 @@ jobs: node-bft-storage-service: docker: - - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: anf/xlarge steps: - run_serial: @@ -249,7 +249,7 @@ jobs: node-cdn: docker: - - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: anf/xlarge steps: - run_serial: @@ -258,7 +258,7 @@ jobs: node-consensus: docker: - - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: anf/2xlarge steps: - run_serial: @@ -267,7 +267,7 @@ jobs: node-rest: docker: - - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: anf/xlarge steps: - run_serial: @@ -276,7 +276,7 @@ jobs: node-router: docker: - - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: anf/xlarge steps: - run_serial: @@ -285,7 +285,7 @@ jobs: node-router-messages: docker: - - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: anf/xlarge steps: - run_serial: @@ -294,7 +294,7 @@ jobs: node-sync: docker: - - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: anf/xlarge steps: - run_serial: @@ -303,7 +303,7 @@ jobs: node-sync-communication-service: docker: - - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: anf/xlarge steps: - run_serial: @@ -312,7 +312,7 @@ jobs: node-sync-locators: docker: - - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: anf/xlarge steps: - run_serial: @@ -321,7 +321,7 @@ jobs: node-tcp: docker: - - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: anf/xlarge steps: - run_serial: @@ -330,7 +330,7 @@ jobs: check-fmt: docker: - - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: anf/xlarge steps: - checkout @@ -346,7 +346,7 @@ jobs: check-clippy: docker: - - image: cimg/rust:1.78.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well + - image: cimg/rust:1.76.0 # Attention - Change the MSRV in Cargo.toml and rust-toolchain as well resource_class: anf/2xlarge steps: - checkout diff --git a/Cargo.toml b/Cargo.toml index 2972ac42ff..3b385228d3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ keywords = [ categories = [ "cryptography", "operating-systems" ] license = "Apache-2.0" edition = "2021" -rust-version = "1.78.0" # Attention - Change the MSRV in rust-toolchain and in .circleci/config.yml as well +rust-version = "1.76.0" # Attention - Change the MSRV in rust-toolchain and in .circleci/config.yml as well [workspace] members = [ diff --git a/rust-toolchain b/rust-toolchain index 54227249d1..32a6ce3c71 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.78.0 +1.76.0 From e00e52d605c15e26b6b16932c9df058bdad24aa1 Mon Sep 17 00:00:00 2001 From: Raymond Chu <14917648+raychu86@users.noreply.github.com> Date: Thu, 16 May 2024 15:02:41 -0700 Subject: [PATCH 523/551] Update node/bft/src/helpers/cache.rs --- node/bft/src/helpers/cache.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/node/bft/src/helpers/cache.rs b/node/bft/src/helpers/cache.rs index 8c4d436ebe..49301a01f7 100644 --- a/node/bft/src/helpers/cache.rs +++ b/node/bft/src/helpers/cache.rs @@ -39,7 +39,6 @@ pub struct Cache { /// The ordered timestamp map of peer IPs and their cache hits on transmission requests. seen_outbound_transmissions: RwLock>>, /// The map of IPs to the number of validators requests. - /// seen_outbound_validators_requests: RwLock>, } From d41f2f2a04fbb572bfc00d46ad6a3449e639258d Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Thu, 16 May 2024 15:18:01 -0700 Subject: [PATCH 524/551] Add network identifier separations --- Cargo.lock | 118 ++++++++++++++++++++--------------------- node/router/src/lib.rs | 13 ++++- 2 files changed, 71 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c726088bb3..05f3cd55d8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3294,7 +3294,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "anstyle", "anyhow", @@ -3325,7 +3325,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "aleo-std", "anyhow", @@ -3355,7 +3355,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3369,7 +3369,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3380,7 +3380,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3390,7 +3390,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3400,7 +3400,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "indexmap 2.2.6", "itertools 0.11.0", @@ -3418,12 +3418,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3434,7 +3434,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3449,7 +3449,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3464,7 +3464,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3477,7 +3477,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3486,7 +3486,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3496,7 +3496,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3508,7 +3508,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3520,7 +3520,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3531,7 +3531,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3543,7 +3543,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3556,7 +3556,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "bs58", "snarkvm-console-network", @@ -3567,7 +3567,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "blake2s_simd", "smallvec", @@ -3580,7 +3580,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "aleo-std", "rayon", @@ -3591,7 +3591,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "anyhow", "indexmap 2.2.6", @@ -3614,7 +3614,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "anyhow", "bech32", @@ -3632,7 +3632,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "enum_index", "enum_index_derive", @@ -3653,7 +3653,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3668,7 +3668,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3679,7 +3679,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-console-network-environment", ] @@ -3687,7 +3687,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3697,7 +3697,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3708,7 +3708,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3719,7 +3719,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3730,7 +3730,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3741,7 +3741,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "rand", "rayon", @@ -3755,7 +3755,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "aleo-std", "anyhow", @@ -3772,7 +3772,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "aleo-std", "anyhow", @@ -3797,7 +3797,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "anyhow", "rand", @@ -3809,7 +3809,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3828,7 +3828,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "anyhow", "indexmap 2.2.6", @@ -3847,7 +3847,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -3860,7 +3860,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3873,7 +3873,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3886,7 +3886,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "bytes", "serde_json", @@ -3897,7 +3897,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3912,7 +3912,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "bytes", "serde_json", @@ -3925,7 +3925,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-console", "snarkvm-ledger-puzzle", @@ -3934,7 +3934,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "aleo-std", "anyhow", @@ -3954,7 +3954,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle-epoch" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "anyhow", "colored", @@ -3969,7 +3969,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "async-trait", "reqwest", @@ -3982,7 +3982,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "aleo-std-storage", "anyhow", @@ -4009,7 +4009,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4024,7 +4024,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4033,7 +4033,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "aleo-std", "anyhow", @@ -4058,7 +4058,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "aleo-std", "anyhow", @@ -4087,7 +4087,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "aleo-std", "colored", @@ -4110,7 +4110,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "indexmap 2.2.6", "paste", @@ -4124,7 +4124,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "bincode", "once_cell", @@ -4137,7 +4137,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "aleo-std", "anyhow", @@ -4158,7 +4158,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoHQ/snarkVM.git?rev=3ebe60c#3ebe60c499285a140ec2171fe8dd06662c325531" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "proc-macro2", "quote 1.0.36", diff --git a/node/router/src/lib.rs b/node/router/src/lib.rs index 82604e9489..9748fc678c 100644 --- a/node/router/src/lib.rs +++ b/node/router/src/lib.rs @@ -390,16 +390,27 @@ impl Router { } /// Returns the list of bootstrap peers. + #[allow(clippy::if_same_then_else)] pub fn bootstrap_peers(&self) -> Vec { if cfg!(feature = "test") || self.is_dev { + // Development testing contains no bootstrap peers. vec![] - } else { + } else if N::ID == 0 { + // Mainnet contains the following bootstrap peers. + vec![ + // TODO: Populate me with Mainnet Beta IP addresses. + ] + } else if N::ID == 1 { + // Testnet contains the following bootstrap peers. vec![ SocketAddr::from_str("34.168.118.156:4130").unwrap(), SocketAddr::from_str("35.231.152.213:4130").unwrap(), SocketAddr::from_str("34.17.53.129:4130").unwrap(), SocketAddr::from_str("35.200.149.162:4130").unwrap(), ] + } else { + // Unrecognized networks contain no bootstrap peers. + vec![] } } From 86d1f2c1493b5454c408967bb9abdaa993dc6c79 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Thu, 16 May 2024 15:19:40 -0700 Subject: [PATCH 525/551] Use direct network struct ID as reference --- node/router/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node/router/src/lib.rs b/node/router/src/lib.rs index 9748fc678c..3703ea6002 100644 --- a/node/router/src/lib.rs +++ b/node/router/src/lib.rs @@ -395,12 +395,12 @@ impl Router { if cfg!(feature = "test") || self.is_dev { // Development testing contains no bootstrap peers. vec![] - } else if N::ID == 0 { + } else if N::ID == snarkvm::console::network::MainnetV0::ID { // Mainnet contains the following bootstrap peers. vec![ // TODO: Populate me with Mainnet Beta IP addresses. ] - } else if N::ID == 1 { + } else if N::ID == snarkvm::console::network::TestnetV0::ID { // Testnet contains the following bootstrap peers. vec![ SocketAddr::from_str("34.168.118.156:4130").unwrap(), From 0b896058cbc0f71ae8f202d986ec43cf18b1eaa6 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Thu, 16 May 2024 15:36:19 -0700 Subject: [PATCH 526/551] Add unknown network ID message --- cli/src/commands/developer/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/src/commands/developer/mod.rs b/cli/src/commands/developer/mod.rs index c9a6ed8805..fcdf6b2ea2 100644 --- a/cli/src/commands/developer/mod.rs +++ b/cli/src/commands/developer/mod.rs @@ -119,7 +119,7 @@ impl Developer { let network = match N::ID { snarkvm::console::network::MainnetV0::ID => "mainnet", snarkvm::console::network::TestnetV0::ID => "testnet", - _ => "mainnet", + unknown_id => bail!("Unknown network ID ({unknown_id})"), }; // Send a request to the query node. @@ -147,7 +147,7 @@ impl Developer { let network = match N::ID { snarkvm::console::network::MainnetV0::ID => "mainnet", snarkvm::console::network::TestnetV0::ID => "testnet", - _ => "mainnet", + unknown_id => bail!("Unknown network ID ({unknown_id})"), }; // Send a request to the query node. From 0567314863f70b8aa9a29785404c4b60873d7cfd Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Thu, 16 May 2024 15:38:40 -0700 Subject: [PATCH 527/551] Add unknown network ID message --- cli/src/commands/account.rs | 8 ++++---- cli/src/commands/developer/decrypt.rs | 2 +- cli/src/commands/developer/deploy.rs | 2 +- cli/src/commands/developer/execute.rs | 2 +- cli/src/commands/developer/scan.rs | 8 ++++---- cli/src/commands/developer/transfer_private.rs | 2 +- node/rest/src/lib.rs | 5 ++++- 7 files changed, 16 insertions(+), 13 deletions(-) diff --git a/cli/src/commands/account.rs b/cli/src/commands/account.rs index b08aed7085..108b866723 100644 --- a/cli/src/commands/account.rs +++ b/cli/src/commands/account.rs @@ -113,13 +113,13 @@ impl Account { Some(vanity) => match network { MainnetV0::ID => Self::new_vanity::(vanity.as_str(), discreet), TestnetV0::ID => Self::new_vanity::(vanity.as_str(), discreet), - _ => bail!("Unsupported network ID"), + unknown_id => bail!("Unknown network ID ({unknown_id})"), }, // Generate a seeded account for the specified network. None => match network { MainnetV0::ID => Self::new_seeded::(seed, discreet), TestnetV0::ID => Self::new_seeded::(seed, discreet), - _ => bail!("Unsupported network ID"), + unknown_id => bail!("Unknown network ID ({unknown_id})"), }, } } @@ -140,7 +140,7 @@ impl Account { match network { MainnetV0::ID => Self::sign::(key, message, seed, raw), TestnetV0::ID => Self::sign::(key, message, seed, raw), - _ => bail!("Unsupported network ID"), + unknown_id => bail!("Unknown network ID ({unknown_id})"), } } Self::Verify { network, address, signature, message, raw } => { @@ -148,7 +148,7 @@ impl Account { match network { MainnetV0::ID => Self::verify::(address, signature, message, raw), TestnetV0::ID => Self::verify::(address, signature, message, raw), - _ => bail!("Unsupported network ID"), + unknown_id => bail!("Unknown network ID ({unknown_id})"), } } } diff --git a/cli/src/commands/developer/decrypt.rs b/cli/src/commands/developer/decrypt.rs index 49ac845d9e..9154337de9 100644 --- a/cli/src/commands/developer/decrypt.rs +++ b/cli/src/commands/developer/decrypt.rs @@ -45,7 +45,7 @@ impl Decrypt { match self.network { MainnetV0::ID => Self::decrypt_ciphertext::(&self.ciphertext, &self.view_key), TestnetV0::ID => Self::decrypt_ciphertext::(&self.ciphertext, &self.view_key), - _ => bail!("Unsupported network ID"), + unknown_id => bail!("Unknown network ID ({unknown_id})"), } } diff --git a/cli/src/commands/developer/deploy.rs b/cli/src/commands/developer/deploy.rs index 2d3ace70f5..c084481859 100644 --- a/cli/src/commands/developer/deploy.rs +++ b/cli/src/commands/developer/deploy.rs @@ -93,7 +93,7 @@ impl Deploy { match self.network { MainnetV0::ID => self.construct_deployment::(), TestnetV0::ID => self.construct_deployment::(), - _ => bail!("Unsupported network ID"), + unknown_id => bail!("Unknown network ID ({unknown_id})"), } } diff --git a/cli/src/commands/developer/execute.rs b/cli/src/commands/developer/execute.rs index 0958a53928..455f258e9c 100644 --- a/cli/src/commands/developer/execute.rs +++ b/cli/src/commands/developer/execute.rs @@ -94,7 +94,7 @@ impl Execute { match self.network { MainnetV0::ID => self.construct_execution::(), TestnetV0::ID => self.construct_execution::(), - _ => bail!("Unsupported network ID"), + unknown_id => bail!("Unknown network ID ({unknown_id})"), } } diff --git a/cli/src/commands/developer/scan.rs b/cli/src/commands/developer/scan.rs index 79bce5cd94..891295a092 100644 --- a/cli/src/commands/developer/scan.rs +++ b/cli/src/commands/developer/scan.rs @@ -71,7 +71,7 @@ impl Scan { match self.network { MainnetV0::ID => self.scan_records::(), TestnetV0::ID => self.scan_records::(), - _ => bail!("Unsupported network ID"), + unknown_id => bail!("Unknown network ID ({unknown_id})"), } } @@ -135,7 +135,7 @@ impl Scan { let network = match self.network { MainnetV0::ID => "mainnet", TestnetV0::ID => "testnet", - _ => bail!("Unsupported network ID"), + unknown_id => bail!("Unknown network ID ({unknown_id})"), }; match (self.start, self.end, self.last) { @@ -186,7 +186,7 @@ impl Scan { let network = match N::ID { MainnetV0::ID => "mainnet", TestnetV0::ID => "testnet", - _ => bail!("Unsupported network ID"), + unknown_id => bail!("Unknown network ID ({unknown_id})"), }; // Derive the x-coordinate of the address corresponding to the given view key. @@ -364,7 +364,7 @@ impl Scan { let network = match N::ID { MainnetV0::ID => "mainnet", TestnetV0::ID => "testnet", - _ => bail!("Unsupported network ID"), + unknown_id => bail!("Unknown network ID ({unknown_id})"), }; // Establish the endpoint. diff --git a/cli/src/commands/developer/transfer_private.rs b/cli/src/commands/developer/transfer_private.rs index 08517cb2f1..0d84ea5930 100644 --- a/cli/src/commands/developer/transfer_private.rs +++ b/cli/src/commands/developer/transfer_private.rs @@ -93,7 +93,7 @@ impl TransferPrivate { match self.network { MainnetV0::ID => self.construct_transfer_private::(), TestnetV0::ID => self.construct_transfer_private::(), - _ => bail!("Unsupported network ID"), + unknown_id => bail!("Unknown network ID ({unknown_id})"), } } diff --git a/node/rest/src/lib.rs b/node/rest/src/lib.rs index f76c668efb..f3195063ca 100644 --- a/node/rest/src/lib.rs +++ b/node/rest/src/lib.rs @@ -121,7 +121,10 @@ impl, R: Routing> Rest { let network = match N::ID { snarkvm::console::network::MainnetV0::ID => "mainnet", snarkvm::console::network::TestnetV0::ID => "testnet", - _ => "mainnet", + unknown_id => { + eprintln!("Unknown network ID ({unknown_id})"); + return; + } }; let router = { From 543db0c63f83fa3c4765b38dbb56b89296788d52 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 17 May 2024 11:58:20 -0700 Subject: [PATCH 528/551] Add network_id selection to .devnet scripts --- .devnet/clean.sh | 8 +++++++- .devnet/start.sh | 8 +++++++- .devnet/start_sync_test.sh | 8 +++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/.devnet/clean.sh b/.devnet/clean.sh index d06f8d5962..2e99572371 100755 --- a/.devnet/clean.sh +++ b/.devnet/clean.sh @@ -12,6 +12,12 @@ NUM_INSTANCES="${NUM_INSTANCES:-$NODE_ID}" echo "Using $NUM_INSTANCES AWS EC2 instances for querying." +# Read the network ID from user or use a default value of 1 +read -p "Enter the network ID (mainnet = 0, testnet = 1) (default: 1): " NETWORK_ID +NETWORK_ID=${NETWORK_ID:-1} + +echo "Using network ID $NETWORK_ID." + # Define a function to terminate the tmux session on a node terminate_tmux_session() { local NODE_ID=$1 @@ -24,7 +30,7 @@ terminate_tmux_session() { cd \$WORKSPACE tmux kill-session -t snarkos-session - snarkos clean --dev $NODE_ID + snarkos clean --dev $NODE_ID --network $NETWORK_ID exit # Exit root user EOF diff --git a/.devnet/start.sh b/.devnet/start.sh index 77294f080c..d93f3e4ffc 100755 --- a/.devnet/start.sh +++ b/.devnet/start.sh @@ -12,6 +12,12 @@ NUM_INSTANCES="${NUM_INSTANCES:-$NODE_ID}" echo "Using $NUM_INSTANCES AWS EC2 instances for querying." +# Read the network ID from user or use a default value of 1 +read -p "Enter the network ID (mainnet = 0, testnet = 1) (default: 1): " NETWORK_ID +NETWORK_ID=${NETWORK_ID:-1} + +echo "Using network ID $NETWORK_ID." + # Read the verbosity level from the user (default: 1) read -p "Enter the verbosity level (default: 1): " VERBOSITY VERBOSITY="${VERBOSITY:-1}" @@ -37,7 +43,7 @@ start_snarkos_in_tmux() { tmux new-session -d -s snarkos-session # Send the snarkOS start command to the tmux session with the NODE_ID - tmux send-keys -t "snarkos-session" "snarkos start --nodisplay --bft 0.0.0.0:5000 --rest 0.0.0.0:3030 --allow-external-peers --peers $NODE_IP:4130 --validators $NODE_IP:5000 --rest-rps 1000 --verbosity $VERBOSITY --dev $NODE_ID --dev-num-validators $NUM_INSTANCES --validator --metrics" C-m + tmux send-keys -t "snarkos-session" "snarkos start --nodisplay --bft 0.0.0.0:5000 --rest 0.0.0.0:3030 --allow-external-peers --peers $NODE_IP:4130 --validators $NODE_IP:5000 --rest-rps 1000 --verbosity $VERBOSITY --network $NETWORK_ID --dev $NODE_ID --dev-num-validators $NUM_INSTANCES --validator --metrics" C-m exit # Exit root user EOF diff --git a/.devnet/start_sync_test.sh b/.devnet/start_sync_test.sh index 6ca5fbb77a..10a9b89c2b 100755 --- a/.devnet/start_sync_test.sh +++ b/.devnet/start_sync_test.sh @@ -12,6 +12,12 @@ NUM_INSTANCES="${NUM_INSTANCES:-$NODE_ID}" echo "Using $NUM_INSTANCES AWS EC2 instances for querying." +# Read the network ID from user or use a default value of 1 +read -p "Enter the network ID (mainnet = 0, testnet = 1) (default: 1): " NETWORK_ID +NETWORK_ID=${NETWORK_ID:-1} + +echo "Using network ID $NETWORK_ID." + # Read the verbosity level from the user (default: 1) read -p "Enter the verbosity level (default: 1): " VERBOSITY VERBOSITY="${VERBOSITY:-1}" @@ -37,7 +43,7 @@ start_snarkos_in_tmux() { tmux new-session -d -s snarkos-session # Send the snarkOS start command to the tmux session with the NODE_ID - tmux send-keys -t "snarkos-session" "snarkos start --client --nocdn --nodisplay --rest 0.0.0.0:3030 --node 0.0.0.0:4130 --verbosity 4 --metrics --logfile "/tmp/snarkos-syncing-range-3.log" --peers 167.71.249.65:4130,157.245.218.195:4130,167.71.249.55:4130" C-m + tmux send-keys -t "snarkos-session" "snarkos start --client --nocdn --nodisplay --rest 0.0.0.0:3030 --node 0.0.0.0:4130 --verbosity 4 --network $NETWORK_ID --metrics --logfile "/tmp/snarkos-syncing-range-3.log" --peers 167.71.249.65:4130,157.245.218.195:4130,167.71.249.55:4130" C-m exit # Exit root user EOF From e7036debb01217ab0229485fab7f5a819d824700 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Fri, 17 May 2024 12:16:04 -0700 Subject: [PATCH 529/551] Add network_id to analytics --- .devnet/.analytics/analytics.js | 32 ++++++++++++++++++++++++++------ .devnet/analytics.sh | 17 ++++++++++++++--- 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/.devnet/.analytics/analytics.js b/.devnet/.analytics/analytics.js index 601be7a19f..2949949313 100644 --- a/.devnet/.analytics/analytics.js +++ b/.devnet/.analytics/analytics.js @@ -115,7 +115,7 @@ async function calculateRoundsInBlocks(baseUrl, latestHeight) { } } -async function checkBlockHash(blockHeight) { +async function checkBlockHash(networkName, blockHeight) { const numNodes = await getAWSNodeCount(); console.log(`Detected ${numNodes} AWS nodes... \n`); @@ -125,7 +125,7 @@ async function checkBlockHash(blockHeight) { // Get the IP address of the AWS node const ipAddress = await getIPAddress(awsNodeName); // Define the base URL for the node - const baseUrl = `http://${ipAddress}:3030/mainnet/block`; + const baseUrl = `http://${ipAddress}:3030/${networkName}/block`; // Fetch the block data const blockData = await fetchBlockData(baseUrl, blockHeight); @@ -138,7 +138,20 @@ async function checkBlockHash(blockHeight) { } // Main function to fetch block metrics -async function fetchBlockMetrics(metricType, optionalBlockHeight) { +async function fetchBlockMetrics(metricType, optionalBlockHeight, networkID) { + // Derive the network name based on the network ID. + let networkName; + switch (networkID) { + case 0: + networkName = "mainnet"; + break; + case 1: + networkName = "testnet"; + break; + default: + throw new Error(`Unknown network ID (${networkID})`); + } + // Function to get the latest block height async function getLatestBlockHeight(baseUrl) { try { @@ -157,7 +170,7 @@ async function fetchBlockMetrics(metricType, optionalBlockHeight) { // Get the IP address of the AWS node const ipAddress = await getIPAddress(awsNodeName); // Define the base URL for the node. - const baseUrl = `http://${ipAddress}:3030/mainnet/block`; + const baseUrl = `http://${ipAddress}:3030/${networkName}/block`; console.log(`${dimStart}IP Address: ${ipAddress}${dimEnd}`); console.log(`${dimStart}Base URL: ${baseUrl}${dimEnd}`); @@ -175,7 +188,7 @@ async function fetchBlockMetrics(metricType, optionalBlockHeight) { } else if (metricType === 'roundsInBlocks') { calculateRoundsInBlocks(baseUrl, latestHeight); } else if (metricType === 'checkBlockHash' && optionalBlockHeight) { - checkBlockHash(optionalBlockHeight); + checkBlockHash(networkName, optionalBlockHeight); } else { console.error('Invalid metric type. Supported types: "averageBlockTime" or "roundsInBlocks".'); } @@ -196,6 +209,13 @@ async function main() { describe: 'Block height to examine for checkBlockHash metric', type: 'number', }, + 'network-id': { + alias: 'n', + describe: 'Network ID to fetch block metrics from', + demandOption: true, + type: 'number', + choices: [0, 1], + } }) .check((argv) => { // Check if metric-type is checkBlockHash and block-height is provided @@ -207,7 +227,7 @@ async function main() { .argv; // Fetch and output the specified block metric - fetchBlockMetrics(argv['metric-type'], argv['block-height']); + fetchBlockMetrics(argv['metric-type'], argv['block-height'], argv['network-id']); } // Run the main function diff --git a/.devnet/analytics.sh b/.devnet/analytics.sh index 9284f3a7e7..0a8a4234c8 100755 --- a/.devnet/analytics.sh +++ b/.devnet/analytics.sh @@ -14,6 +14,17 @@ else echo "Node.js dependencies already installed." fi +# Prompt the user to specify a network ID +while true; do + echo "Please specify a network ID (0 for mainnet, 1 for testnet):" + read networkID + if [[ $networkID == 0 || $networkID == 1 ]]; then + break + else + echo "Invalid network ID. Please enter 0 or 1." + fi +done + # Prompt the user to select a metric type PS3="Select a metric type: " options=("Average Block Time" "Rounds in Blocks" "Check Block Hash" "Quit") @@ -22,12 +33,12 @@ do case $opt in "Average Block Time") echo "" - node analytics.js --metric-type averageBlockTime + node analytics.js --metric-type averageBlockTime --network-id $networkID break ;; "Rounds in Blocks") echo "" - node analytics.js --metric-type roundsInBlocks + node analytics.js --metric-type roundsInBlocks --network-id $networkID break ;; "Check Block Hash") @@ -39,7 +50,7 @@ do echo "Error: Block height must be a positive integer." exit 1 fi - node analytics.js --metric-type checkBlockHash --block-height "$blockHeight" + node analytics.js --metric-type checkBlockHash --block-height "$blockHeight" --network-id $networkID break ;; "Quit") From 3d68ab356861c537e8d68b071d499341b5e52a44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=A9=E7=84=B6?= <81279860+elderhammer@users.noreply.github.com> Date: Mon, 20 May 2024 20:25:21 +0800 Subject: [PATCH 530/551] Avoid unnecessary calculations in propose_batch --- node/bft/src/primary.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 05069d2aa4..fcb7c8af1f 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -348,6 +348,12 @@ impl Primary { return Ok(()); } + // Determine if the current proposal is expired. + if round == *lock_guard { + warn!("Primary is safely skipping a batch proposal - round {round} already proposed"); + return Ok(()); + } + // If there is a batch being proposed already, // rebroadcast the batch header to the non-signers, and return early. if let Some(proposal) = self.proposed_batch.read().as_ref() { @@ -531,13 +537,6 @@ impl Primary { ensure!(round > 0, "Round 0 cannot have transaction batches"); // Determine the current timestamp. let current_timestamp = now(); - // Determine if the current proposal is expired. - if *lock_guard == round { - warn!("Primary is safely skipping a batch proposal - round {round} already proposed"); - // Reinsert the transmissions back into the ready queue for the next proposal. - self.reinsert_transmissions_into_workers(transmissions)?; - return Ok(()); - } *lock_guard = round; From 644cf114702ef71e2a702eb7954f727dfa8d377a Mon Sep 17 00:00:00 2001 From: elderhammer <81279860+elderhammer@users.noreply.github.com> Date: Tue, 21 May 2024 16:12:33 +0800 Subject: [PATCH 531/551] Cancel propose_batch when the current round is 0 --- node/bft/src/primary.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index fcb7c8af1f..7deaae3a7a 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -342,6 +342,9 @@ impl Primary { // Compute the previous round. let previous_round = round.saturating_sub(1); + // If the current round is 0, return early. + ensure!(round > 0, "Round 0 cannot have transaction batches"); + // If the current storage round is below the latest proposal round, then return early. if round < *lock_guard { warn!("Cannot propose a batch for round {round} - the latest proposal cache round is {}", *lock_guard); @@ -533,8 +536,7 @@ impl Primary { } } } - // Ditto if the batch had already been proposed and not expired. - ensure!(round > 0, "Round 0 cannot have transaction batches"); + // Determine the current timestamp. let current_timestamp = now(); From 0e837433c6e8248aed4d004a803a9ae47207edf5 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Tue, 21 May 2024 11:51:34 -0700 Subject: [PATCH 532/551] Clear solutions queue and worker solutions on new epoch --- node/bft/src/helpers/ready.rs | 8 ++++++++ node/bft/src/primary.rs | 7 +++++++ node/bft/src/worker.rs | 7 +++++++ node/consensus/src/lib.rs | 8 ++++++++ 4 files changed, 30 insertions(+) diff --git a/node/bft/src/helpers/ready.rs b/node/bft/src/helpers/ready.rs index 6fa581ccdb..7a366dff81 100644 --- a/node/bft/src/helpers/ready.rs +++ b/node/bft/src/helpers/ready.rs @@ -126,6 +126,14 @@ impl Ready { // Drain the transmission IDs. transmissions.drain(range).collect::>() } + + /// Clears all solutions from the ready queue. + pub(crate) fn clear_solutions(&self) { + // Acquire the write lock. + let mut transmissions = self.transmissions.write(); + // Remove all solutions. + transmissions.retain(|id, _| !matches!(id, TransmissionID::Solution(..))); + } } #[cfg(test)] diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 05069d2aa4..d90576a2f9 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -319,6 +319,13 @@ impl Primary { } } +impl Primary { + /// Clears the worker solutions. + pub fn clear_worker_solutions(&self) { + self.workers.iter().for_each(Worker::clear_solutions); + } +} + impl Primary { /// Proposes the batch for the current round. /// diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index dc82d775ce..96a3f71622 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -151,6 +151,13 @@ impl Worker { } } +impl Worker { + /// Clears the solutions from the ready queue. + pub(super) fn clear_solutions(&self) { + self.ready.clear_solutions() + } +} + impl Worker { /// Returns `true` if the transmission ID exists in the ready queue, proposed batch, storage, or ledger. pub fn contains_transmission(&self, transmission_id: impl Into>) -> bool { diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 530893893d..fdf247dfdd 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -484,6 +484,14 @@ impl Consensus { // Advance to the next block. self.ledger.advance_to_next_block(&next_block)?; + // If the next block starts a new epoch, clear the existing solutions. + if next_block.height() % N::NUM_BLOCKS_PER_EPOCH == 0 { + // Clear the solutions queue. + self.solutions_queue.lock().clear(); + // Clear the worker solutions. + self.bft.primary().clear_worker_solutions(); + } + #[cfg(feature = "metrics")] { let elapsed = std::time::Duration::from_secs((snarkos_node_bft::helpers::now() - start) as u64); From fed9416b4e0ca534a017094dc34d3202d11db491 Mon Sep 17 00:00:00 2001 From: elderhammer <81279860+elderhammer@users.noreply.github.com> Date: Wed, 22 May 2024 11:16:28 +0800 Subject: [PATCH 533/551] Cannot skip proposal re-sending and round update --- node/bft/src/primary.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 7deaae3a7a..bc66b1efa3 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -351,12 +351,6 @@ impl Primary { return Ok(()); } - // Determine if the current proposal is expired. - if round == *lock_guard { - warn!("Primary is safely skipping a batch proposal - round {round} already proposed"); - return Ok(()); - } - // If there is a batch being proposed already, // rebroadcast the batch header to the non-signers, and return early. if let Some(proposal) = self.proposed_batch.read().as_ref() { @@ -428,6 +422,12 @@ impl Primary { return Ok(()); } + // Determine if the current round has been proposed. + if round == *lock_guard { + warn!("Primary is safely skipping a batch proposal - round {round} already proposed"); + return Ok(()); + } + // Retrieve the committee to check against. let committee_lookback = self.ledger.get_committee_lookback_for_round(round)?; // Check if the primary is connected to enough validators to reach quorum threshold. From d1e04801343ccf1588e636db927890b5a7896ec6 Mon Sep 17 00:00:00 2001 From: elderhammer <81279860+elderhammer@users.noreply.github.com> Date: Wed, 22 May 2024 12:32:33 +0800 Subject: [PATCH 534/551] Add necessary comments --- node/bft/src/primary.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index bc66b1efa3..6cc84122f8 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -423,6 +423,10 @@ impl Primary { } // Determine if the current round has been proposed. + // Note: Do NOT make this judgment in advance before rebroadcast and round update. Rebroadcasting is + // good for network reliability and should not be prevented for the already existing proposed_batch. + // If a certificate already exists for the current round, an attempt should be made to advance the + // round as early as possible. if round == *lock_guard { warn!("Primary is safely skipping a batch proposal - round {round} already proposed"); return Ok(()); From bb0a10c0d47a7f052f2911d9184b7840b37db883 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 22 May 2024 15:07:28 -0700 Subject: [PATCH 535/551] Bump snarkVM rev - 895952f --- Cargo.lock | 118 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 2 +- 2 files changed, 60 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 05f3cd55d8..a9af781a4e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3294,7 +3294,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "anstyle", "anyhow", @@ -3325,7 +3325,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "aleo-std", "anyhow", @@ -3355,7 +3355,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3369,7 +3369,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3380,7 +3380,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3390,7 +3390,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3400,7 +3400,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "indexmap 2.2.6", "itertools 0.11.0", @@ -3418,12 +3418,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3434,7 +3434,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3449,7 +3449,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3464,7 +3464,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3477,7 +3477,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3486,7 +3486,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3496,7 +3496,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3508,7 +3508,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3520,7 +3520,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3531,7 +3531,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3543,7 +3543,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3556,7 +3556,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "bs58", "snarkvm-console-network", @@ -3567,7 +3567,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "blake2s_simd", "smallvec", @@ -3580,7 +3580,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "aleo-std", "rayon", @@ -3591,7 +3591,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "anyhow", "indexmap 2.2.6", @@ -3614,7 +3614,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "anyhow", "bech32", @@ -3632,7 +3632,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "enum_index", "enum_index_derive", @@ -3653,7 +3653,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3668,7 +3668,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3679,7 +3679,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "snarkvm-console-network-environment", ] @@ -3687,7 +3687,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3697,7 +3697,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3708,7 +3708,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3719,7 +3719,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3730,7 +3730,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3741,7 +3741,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "rand", "rayon", @@ -3755,7 +3755,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "aleo-std", "anyhow", @@ -3772,7 +3772,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "aleo-std", "anyhow", @@ -3797,7 +3797,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "anyhow", "rand", @@ -3809,7 +3809,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3828,7 +3828,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "anyhow", "indexmap 2.2.6", @@ -3847,7 +3847,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -3860,7 +3860,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3873,7 +3873,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3886,7 +3886,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "bytes", "serde_json", @@ -3897,7 +3897,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3912,7 +3912,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "bytes", "serde_json", @@ -3925,7 +3925,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "snarkvm-console", "snarkvm-ledger-puzzle", @@ -3934,7 +3934,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "aleo-std", "anyhow", @@ -3954,7 +3954,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle-epoch" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "anyhow", "colored", @@ -3969,7 +3969,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "async-trait", "reqwest", @@ -3982,7 +3982,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "aleo-std-storage", "anyhow", @@ -4009,7 +4009,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4024,7 +4024,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4033,7 +4033,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "aleo-std", "anyhow", @@ -4058,7 +4058,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "aleo-std", "anyhow", @@ -4087,7 +4087,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "aleo-std", "colored", @@ -4110,7 +4110,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "indexmap 2.2.6", "paste", @@ -4124,7 +4124,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "bincode", "once_cell", @@ -4137,7 +4137,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "aleo-std", "anyhow", @@ -4158,7 +4158,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" dependencies = [ "proc-macro2", "quote 1.0.36", diff --git a/Cargo.toml b/Cargo.toml index 3b385228d3..9cdb658f90 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoNet/snarkVM.git" -rev = "140ff26" +rev = "895952f" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From fd2b233a7b64f81592d5858bba9a6a8df24a9690 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 22 May 2024 15:15:57 -0700 Subject: [PATCH 536/551] Add support for TestnetV1 --- cli/src/commands/account.rs | 6 +++++- cli/src/commands/developer/decrypt.rs | 3 ++- cli/src/commands/developer/deploy.rs | 5 +++-- cli/src/commands/developer/execute.rs | 3 ++- cli/src/commands/developer/mod.rs | 2 ++ cli/src/commands/developer/scan.rs | 6 +++++- cli/src/commands/developer/transfer_private.rs | 3 ++- cli/src/commands/start.rs | 11 ++++++++++- node/rest/src/lib.rs | 1 + node/router/src/lib.rs | 7 ++++++- 10 files changed, 38 insertions(+), 9 deletions(-) diff --git a/cli/src/commands/account.rs b/cli/src/commands/account.rs index 108b866723..0bc25acb84 100644 --- a/cli/src/commands/account.rs +++ b/cli/src/commands/account.rs @@ -15,7 +15,7 @@ use snarkvm::{ console::{ account::{Address, PrivateKey, Signature}, - network::{MainnetV0, Network, TestnetV0}, + network::{MainnetV0, Network, TestnetV0, TestnetV1}, prelude::{Environment, Uniform}, program::{ToFields, Value}, types::Field, @@ -113,12 +113,14 @@ impl Account { Some(vanity) => match network { MainnetV0::ID => Self::new_vanity::(vanity.as_str(), discreet), TestnetV0::ID => Self::new_vanity::(vanity.as_str(), discreet), + TestnetV1::ID => Self::new_vanity::(vanity.as_str(), discreet), unknown_id => bail!("Unknown network ID ({unknown_id})"), }, // Generate a seeded account for the specified network. None => match network { MainnetV0::ID => Self::new_seeded::(seed, discreet), TestnetV0::ID => Self::new_seeded::(seed, discreet), + TestnetV1::ID => Self::new_seeded::(seed, discreet), unknown_id => bail!("Unknown network ID ({unknown_id})"), }, } @@ -140,6 +142,7 @@ impl Account { match network { MainnetV0::ID => Self::sign::(key, message, seed, raw), TestnetV0::ID => Self::sign::(key, message, seed, raw), + TestnetV1::ID => Self::sign::(key, message, seed, raw), unknown_id => bail!("Unknown network ID ({unknown_id})"), } } @@ -148,6 +151,7 @@ impl Account { match network { MainnetV0::ID => Self::verify::(address, signature, message, raw), TestnetV0::ID => Self::verify::(address, signature, message, raw), + TestnetV1::ID => Self::verify::(address, signature, message, raw), unknown_id => bail!("Unknown network ID ({unknown_id})"), } } diff --git a/cli/src/commands/developer/decrypt.rs b/cli/src/commands/developer/decrypt.rs index 9154337de9..1c623dd0ec 100644 --- a/cli/src/commands/developer/decrypt.rs +++ b/cli/src/commands/developer/decrypt.rs @@ -14,7 +14,7 @@ use snarkvm::{ console::{ - network::{MainnetV0, Network, TestnetV0}, + network::{MainnetV0, Network, TestnetV0, TestnetV1}, program::Ciphertext, }, prelude::{Record, ViewKey}, @@ -45,6 +45,7 @@ impl Decrypt { match self.network { MainnetV0::ID => Self::decrypt_ciphertext::(&self.ciphertext, &self.view_key), TestnetV0::ID => Self::decrypt_ciphertext::(&self.ciphertext, &self.view_key), + TestnetV1::ID => Self::decrypt_ciphertext::(&self.ciphertext, &self.view_key), unknown_id => bail!("Unknown network ID ({unknown_id})"), } } diff --git a/cli/src/commands/developer/deploy.rs b/cli/src/commands/developer/deploy.rs index c084481859..e3009afa0c 100644 --- a/cli/src/commands/developer/deploy.rs +++ b/cli/src/commands/developer/deploy.rs @@ -14,9 +14,9 @@ use super::Developer; use snarkvm::{ - circuit::{Aleo, AleoTestnetV0, AleoV0}, + circuit::{Aleo, AleoTestnetV0, AleoTestnetV1, AleoV0}, console::{ - network::{MainnetV0, Network, TestnetV0}, + network::{MainnetV0, Network, TestnetV0, TestnetV1}, program::ProgramOwner, }, prelude::{ @@ -93,6 +93,7 @@ impl Deploy { match self.network { MainnetV0::ID => self.construct_deployment::(), TestnetV0::ID => self.construct_deployment::(), + TestnetV1::ID => self.construct_deployment::(), unknown_id => bail!("Unknown network ID ({unknown_id})"), } } diff --git a/cli/src/commands/developer/execute.rs b/cli/src/commands/developer/execute.rs index 455f258e9c..6cc9706af2 100644 --- a/cli/src/commands/developer/execute.rs +++ b/cli/src/commands/developer/execute.rs @@ -14,7 +14,7 @@ use super::Developer; use snarkvm::{ - console::network::{MainnetV0, Network, TestnetV0}, + console::network::{MainnetV0, Network, TestnetV0, TestnetV1}, prelude::{ query::Query, store::{helpers::memory::ConsensusMemory, ConsensusStore}, @@ -94,6 +94,7 @@ impl Execute { match self.network { MainnetV0::ID => self.construct_execution::(), TestnetV0::ID => self.construct_execution::(), + TestnetV1::ID => self.construct_execution::(), unknown_id => bail!("Unknown network ID ({unknown_id})"), } } diff --git a/cli/src/commands/developer/mod.rs b/cli/src/commands/developer/mod.rs index fcdf6b2ea2..89da5691bd 100644 --- a/cli/src/commands/developer/mod.rs +++ b/cli/src/commands/developer/mod.rs @@ -119,6 +119,7 @@ impl Developer { let network = match N::ID { snarkvm::console::network::MainnetV0::ID => "mainnet", snarkvm::console::network::TestnetV0::ID => "testnet", + snarkvm::console::network::TestnetV1::ID => "testnet_v1", unknown_id => bail!("Unknown network ID ({unknown_id})"), }; @@ -147,6 +148,7 @@ impl Developer { let network = match N::ID { snarkvm::console::network::MainnetV0::ID => "mainnet", snarkvm::console::network::TestnetV0::ID => "testnet", + snarkvm::console::network::TestnetV1::ID => "testnet_v1", unknown_id => bail!("Unknown network ID ({unknown_id})"), }; diff --git a/cli/src/commands/developer/scan.rs b/cli/src/commands/developer/scan.rs index 891295a092..d8a448bdf2 100644 --- a/cli/src/commands/developer/scan.rs +++ b/cli/src/commands/developer/scan.rs @@ -15,7 +15,7 @@ #![allow(clippy::type_complexity)] use snarkvm::{ - console::network::{MainnetV0, Network, TestnetV0}, + console::network::{MainnetV0, Network, TestnetV0, TestnetV1}, prelude::{block::Block, Ciphertext, Field, FromBytes, Plaintext, PrivateKey, Record, ViewKey}, }; @@ -71,6 +71,7 @@ impl Scan { match self.network { MainnetV0::ID => self.scan_records::(), TestnetV0::ID => self.scan_records::(), + TestnetV1::ID => self.scan_records::(), unknown_id => bail!("Unknown network ID ({unknown_id})"), } } @@ -135,6 +136,7 @@ impl Scan { let network = match self.network { MainnetV0::ID => "mainnet", TestnetV0::ID => "testnet", + TestnetV1::ID => "testnet_v1", unknown_id => bail!("Unknown network ID ({unknown_id})"), }; @@ -186,6 +188,7 @@ impl Scan { let network = match N::ID { MainnetV0::ID => "mainnet", TestnetV0::ID => "testnet", + TestnetV1::ID => "testnet_v1", unknown_id => bail!("Unknown network ID ({unknown_id})"), }; @@ -364,6 +367,7 @@ impl Scan { let network = match N::ID { MainnetV0::ID => "mainnet", TestnetV0::ID => "testnet", + TestnetV1::ID => "testnet_v1", unknown_id => bail!("Unknown network ID ({unknown_id})"), }; diff --git a/cli/src/commands/developer/transfer_private.rs b/cli/src/commands/developer/transfer_private.rs index 0d84ea5930..c016561851 100644 --- a/cli/src/commands/developer/transfer_private.rs +++ b/cli/src/commands/developer/transfer_private.rs @@ -14,7 +14,7 @@ use super::Developer; use snarkvm::{ - console::network::{MainnetV0, Network, TestnetV0}, + console::network::{MainnetV0, Network, TestnetV0, TestnetV1}, prelude::{ query::Query, store::{helpers::memory::ConsensusMemory, ConsensusStore}, @@ -93,6 +93,7 @@ impl TransferPrivate { match self.network { MainnetV0::ID => self.construct_transfer_private::(), TestnetV0::ID => self.construct_transfer_private::(), + TestnetV1::ID => self.construct_transfer_private::(), unknown_id => bail!("Unknown network ID ({unknown_id})"), } } diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index 2cfd66d310..5561987f04 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -19,7 +19,7 @@ use snarkvm::{ console::{ account::{Address, PrivateKey}, algorithms::Hash, - network::{MainnetV0, Network, TestnetV0}, + network::{MainnetV0, Network, TestnetV0, TestnetV1}, }, ledger::{ block::Block, @@ -189,6 +189,15 @@ impl Start { Display::start(node, log_receiver).expect("Failed to initialize the display"); } } + TestnetV1::ID => { + // Parse the node from the configurations. + let node = cli.parse_node::(shutdown.clone()).await.expect("Failed to parse the node"); + // If the display is enabled, render the display. + if !cli.nodisplay { + // Initialize the display. + Display::start(node, log_receiver).expect("Failed to initialize the display"); + } + } _ => panic!("Invalid network ID specified"), }; // Note: Do not move this. The pending await must be here otherwise diff --git a/node/rest/src/lib.rs b/node/rest/src/lib.rs index f3195063ca..7f4d914369 100644 --- a/node/rest/src/lib.rs +++ b/node/rest/src/lib.rs @@ -121,6 +121,7 @@ impl, R: Routing> Rest { let network = match N::ID { snarkvm::console::network::MainnetV0::ID => "mainnet", snarkvm::console::network::TestnetV0::ID => "testnet", + snarkvm::console::network::TestnetV1::ID => "testnet_v1", unknown_id => { eprintln!("Unknown network ID ({unknown_id})"); return; diff --git a/node/router/src/lib.rs b/node/router/src/lib.rs index 3703ea6002..de4840c82a 100644 --- a/node/router/src/lib.rs +++ b/node/router/src/lib.rs @@ -401,13 +401,18 @@ impl Router { // TODO: Populate me with Mainnet Beta IP addresses. ] } else if N::ID == snarkvm::console::network::TestnetV0::ID { - // Testnet contains the following bootstrap peers. + // TestnetV0 contains the following bootstrap peers. vec![ SocketAddr::from_str("34.168.118.156:4130").unwrap(), SocketAddr::from_str("35.231.152.213:4130").unwrap(), SocketAddr::from_str("34.17.53.129:4130").unwrap(), SocketAddr::from_str("35.200.149.162:4130").unwrap(), ] + } else if N::ID == snarkvm::console::network::TestnetV1::ID { + // TestnetV1 contains the following bootstrap peers. + vec![ + // TODO: Populate me with TestnetV1 IP addresses. + ] } else { // Unrecognized networks contain no bootstrap peers. vec![] From 7683ad798de0e21f0c5f0fff847ae304a53601d8 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 23 May 2024 10:45:16 -0700 Subject: [PATCH 537/551] Bump snarkVM rev - 9493c43 --- Cargo.lock | 118 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 2 +- 2 files changed, 60 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a9af781a4e..146cde43db 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3294,7 +3294,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "anstyle", "anyhow", @@ -3325,7 +3325,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "aleo-std", "anyhow", @@ -3355,7 +3355,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3369,7 +3369,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3380,7 +3380,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3390,7 +3390,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3400,7 +3400,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "indexmap 2.2.6", "itertools 0.11.0", @@ -3418,12 +3418,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3434,7 +3434,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3449,7 +3449,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3464,7 +3464,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3477,7 +3477,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3486,7 +3486,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3496,7 +3496,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3508,7 +3508,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3520,7 +3520,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3531,7 +3531,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3543,7 +3543,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3556,7 +3556,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "bs58", "snarkvm-console-network", @@ -3567,7 +3567,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "blake2s_simd", "smallvec", @@ -3580,7 +3580,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "aleo-std", "rayon", @@ -3591,7 +3591,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "anyhow", "indexmap 2.2.6", @@ -3614,7 +3614,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "anyhow", "bech32", @@ -3632,7 +3632,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "enum_index", "enum_index_derive", @@ -3653,7 +3653,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3668,7 +3668,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3679,7 +3679,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "snarkvm-console-network-environment", ] @@ -3687,7 +3687,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3697,7 +3697,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3708,7 +3708,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3719,7 +3719,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3730,7 +3730,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3741,7 +3741,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "rand", "rayon", @@ -3755,7 +3755,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "aleo-std", "anyhow", @@ -3772,7 +3772,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "aleo-std", "anyhow", @@ -3797,7 +3797,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "anyhow", "rand", @@ -3809,7 +3809,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3828,7 +3828,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "anyhow", "indexmap 2.2.6", @@ -3847,7 +3847,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -3860,7 +3860,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3873,7 +3873,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3886,7 +3886,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "bytes", "serde_json", @@ -3897,7 +3897,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3912,7 +3912,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "bytes", "serde_json", @@ -3925,7 +3925,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "snarkvm-console", "snarkvm-ledger-puzzle", @@ -3934,7 +3934,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "aleo-std", "anyhow", @@ -3954,7 +3954,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle-epoch" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "anyhow", "colored", @@ -3969,7 +3969,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "async-trait", "reqwest", @@ -3982,7 +3982,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "aleo-std-storage", "anyhow", @@ -4009,7 +4009,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4024,7 +4024,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4033,7 +4033,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "aleo-std", "anyhow", @@ -4058,7 +4058,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "aleo-std", "anyhow", @@ -4087,7 +4087,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "aleo-std", "colored", @@ -4110,7 +4110,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "indexmap 2.2.6", "paste", @@ -4124,7 +4124,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "bincode", "once_cell", @@ -4137,7 +4137,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "aleo-std", "anyhow", @@ -4158,7 +4158,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=895952f#895952ffa2dff271bc46707e861a8f6e2caab043" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" dependencies = [ "proc-macro2", "quote 1.0.36", diff --git a/Cargo.toml b/Cargo.toml index 9cdb658f90..ee615bb05c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoNet/snarkVM.git" -rev = "895952f" +rev = "9493c43" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From 1688de722704f048ce4bcc23ec7fd0db9e464d38 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 23 May 2024 14:38:18 -0700 Subject: [PATCH 538/551] Use CanaryV0 --- Cargo.lock | 118 +++++++++--------- Cargo.toml | 2 +- cli/src/commands/account.rs | 10 +- cli/src/commands/developer/decrypt.rs | 4 +- cli/src/commands/developer/deploy.rs | 6 +- cli/src/commands/developer/execute.rs | 4 +- cli/src/commands/developer/mod.rs | 4 +- cli/src/commands/developer/scan.rs | 10 +- .../commands/developer/transfer_private.rs | 4 +- cli/src/commands/start.rs | 6 +- devnet.sh | 2 +- node/rest/src/lib.rs | 2 +- node/router/src/lib.rs | 6 +- 13 files changed, 89 insertions(+), 89 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 146cde43db..f3904f90f3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3294,7 +3294,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "anstyle", "anyhow", @@ -3325,7 +3325,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "aleo-std", "anyhow", @@ -3355,7 +3355,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3369,7 +3369,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3380,7 +3380,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3390,7 +3390,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3400,7 +3400,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "indexmap 2.2.6", "itertools 0.11.0", @@ -3418,12 +3418,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3434,7 +3434,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3449,7 +3449,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3464,7 +3464,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3477,7 +3477,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3486,7 +3486,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3496,7 +3496,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3508,7 +3508,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3520,7 +3520,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3531,7 +3531,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3543,7 +3543,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3556,7 +3556,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "bs58", "snarkvm-console-network", @@ -3567,7 +3567,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "blake2s_simd", "smallvec", @@ -3580,7 +3580,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "aleo-std", "rayon", @@ -3591,7 +3591,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "anyhow", "indexmap 2.2.6", @@ -3614,7 +3614,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "anyhow", "bech32", @@ -3632,7 +3632,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "enum_index", "enum_index_derive", @@ -3653,7 +3653,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3668,7 +3668,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3679,7 +3679,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "snarkvm-console-network-environment", ] @@ -3687,7 +3687,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3697,7 +3697,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3708,7 +3708,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3719,7 +3719,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3730,7 +3730,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3741,7 +3741,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "rand", "rayon", @@ -3755,7 +3755,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "aleo-std", "anyhow", @@ -3772,7 +3772,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "aleo-std", "anyhow", @@ -3797,7 +3797,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "anyhow", "rand", @@ -3809,7 +3809,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3828,7 +3828,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "anyhow", "indexmap 2.2.6", @@ -3847,7 +3847,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -3860,7 +3860,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3873,7 +3873,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3886,7 +3886,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "bytes", "serde_json", @@ -3897,7 +3897,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3912,7 +3912,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "bytes", "serde_json", @@ -3925,7 +3925,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "snarkvm-console", "snarkvm-ledger-puzzle", @@ -3934,7 +3934,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "aleo-std", "anyhow", @@ -3954,7 +3954,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle-epoch" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "anyhow", "colored", @@ -3969,7 +3969,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "async-trait", "reqwest", @@ -3982,7 +3982,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "aleo-std-storage", "anyhow", @@ -4009,7 +4009,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4024,7 +4024,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4033,7 +4033,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "aleo-std", "anyhow", @@ -4058,7 +4058,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "aleo-std", "anyhow", @@ -4087,7 +4087,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "aleo-std", "colored", @@ -4110,7 +4110,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "indexmap 2.2.6", "paste", @@ -4124,7 +4124,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "bincode", "once_cell", @@ -4137,7 +4137,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "aleo-std", "anyhow", @@ -4158,7 +4158,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=9493c43#9493c43d04093ab12e1fa559bfcf43c845745456" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" dependencies = [ "proc-macro2", "quote 1.0.36", diff --git a/Cargo.toml b/Cargo.toml index ee615bb05c..1cee08e2f0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoNet/snarkVM.git" -rev = "9493c43" +rev = "d638448" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] diff --git a/cli/src/commands/account.rs b/cli/src/commands/account.rs index 0bc25acb84..29fd401ea0 100644 --- a/cli/src/commands/account.rs +++ b/cli/src/commands/account.rs @@ -15,7 +15,7 @@ use snarkvm::{ console::{ account::{Address, PrivateKey, Signature}, - network::{MainnetV0, Network, TestnetV0, TestnetV1}, + network::{CanaryV0, MainnetV0, Network, TestnetV0}, prelude::{Environment, Uniform}, program::{ToFields, Value}, types::Field, @@ -113,14 +113,14 @@ impl Account { Some(vanity) => match network { MainnetV0::ID => Self::new_vanity::(vanity.as_str(), discreet), TestnetV0::ID => Self::new_vanity::(vanity.as_str(), discreet), - TestnetV1::ID => Self::new_vanity::(vanity.as_str(), discreet), + CanaryV0::ID => Self::new_vanity::(vanity.as_str(), discreet), unknown_id => bail!("Unknown network ID ({unknown_id})"), }, // Generate a seeded account for the specified network. None => match network { MainnetV0::ID => Self::new_seeded::(seed, discreet), TestnetV0::ID => Self::new_seeded::(seed, discreet), - TestnetV1::ID => Self::new_seeded::(seed, discreet), + CanaryV0::ID => Self::new_seeded::(seed, discreet), unknown_id => bail!("Unknown network ID ({unknown_id})"), }, } @@ -142,7 +142,7 @@ impl Account { match network { MainnetV0::ID => Self::sign::(key, message, seed, raw), TestnetV0::ID => Self::sign::(key, message, seed, raw), - TestnetV1::ID => Self::sign::(key, message, seed, raw), + CanaryV0::ID => Self::sign::(key, message, seed, raw), unknown_id => bail!("Unknown network ID ({unknown_id})"), } } @@ -151,7 +151,7 @@ impl Account { match network { MainnetV0::ID => Self::verify::(address, signature, message, raw), TestnetV0::ID => Self::verify::(address, signature, message, raw), - TestnetV1::ID => Self::verify::(address, signature, message, raw), + CanaryV0::ID => Self::verify::(address, signature, message, raw), unknown_id => bail!("Unknown network ID ({unknown_id})"), } } diff --git a/cli/src/commands/developer/decrypt.rs b/cli/src/commands/developer/decrypt.rs index 1c623dd0ec..2a46ac3a27 100644 --- a/cli/src/commands/developer/decrypt.rs +++ b/cli/src/commands/developer/decrypt.rs @@ -14,7 +14,7 @@ use snarkvm::{ console::{ - network::{MainnetV0, Network, TestnetV0, TestnetV1}, + network::{CanaryV0, MainnetV0, Network, TestnetV0}, program::Ciphertext, }, prelude::{Record, ViewKey}, @@ -45,7 +45,7 @@ impl Decrypt { match self.network { MainnetV0::ID => Self::decrypt_ciphertext::(&self.ciphertext, &self.view_key), TestnetV0::ID => Self::decrypt_ciphertext::(&self.ciphertext, &self.view_key), - TestnetV1::ID => Self::decrypt_ciphertext::(&self.ciphertext, &self.view_key), + CanaryV0::ID => Self::decrypt_ciphertext::(&self.ciphertext, &self.view_key), unknown_id => bail!("Unknown network ID ({unknown_id})"), } } diff --git a/cli/src/commands/developer/deploy.rs b/cli/src/commands/developer/deploy.rs index e3009afa0c..7cb2853785 100644 --- a/cli/src/commands/developer/deploy.rs +++ b/cli/src/commands/developer/deploy.rs @@ -14,9 +14,9 @@ use super::Developer; use snarkvm::{ - circuit::{Aleo, AleoTestnetV0, AleoTestnetV1, AleoV0}, + circuit::{Aleo, AleoCanaryV0, AleoTestnetV0, AleoV0}, console::{ - network::{MainnetV0, Network, TestnetV0, TestnetV1}, + network::{CanaryV0, MainnetV0, Network, TestnetV0}, program::ProgramOwner, }, prelude::{ @@ -93,7 +93,7 @@ impl Deploy { match self.network { MainnetV0::ID => self.construct_deployment::(), TestnetV0::ID => self.construct_deployment::(), - TestnetV1::ID => self.construct_deployment::(), + CanaryV0::ID => self.construct_deployment::(), unknown_id => bail!("Unknown network ID ({unknown_id})"), } } diff --git a/cli/src/commands/developer/execute.rs b/cli/src/commands/developer/execute.rs index 6cc9706af2..910109b2b4 100644 --- a/cli/src/commands/developer/execute.rs +++ b/cli/src/commands/developer/execute.rs @@ -14,7 +14,7 @@ use super::Developer; use snarkvm::{ - console::network::{MainnetV0, Network, TestnetV0, TestnetV1}, + console::network::{CanaryV0, MainnetV0, Network, TestnetV0}, prelude::{ query::Query, store::{helpers::memory::ConsensusMemory, ConsensusStore}, @@ -94,7 +94,7 @@ impl Execute { match self.network { MainnetV0::ID => self.construct_execution::(), TestnetV0::ID => self.construct_execution::(), - TestnetV1::ID => self.construct_execution::(), + CanaryV0::ID => self.construct_execution::(), unknown_id => bail!("Unknown network ID ({unknown_id})"), } } diff --git a/cli/src/commands/developer/mod.rs b/cli/src/commands/developer/mod.rs index 89da5691bd..781797a851 100644 --- a/cli/src/commands/developer/mod.rs +++ b/cli/src/commands/developer/mod.rs @@ -119,7 +119,7 @@ impl Developer { let network = match N::ID { snarkvm::console::network::MainnetV0::ID => "mainnet", snarkvm::console::network::TestnetV0::ID => "testnet", - snarkvm::console::network::TestnetV1::ID => "testnet_v1", + snarkvm::console::network::CanaryV0::ID => "canary", unknown_id => bail!("Unknown network ID ({unknown_id})"), }; @@ -148,7 +148,7 @@ impl Developer { let network = match N::ID { snarkvm::console::network::MainnetV0::ID => "mainnet", snarkvm::console::network::TestnetV0::ID => "testnet", - snarkvm::console::network::TestnetV1::ID => "testnet_v1", + snarkvm::console::network::CanaryV0::ID => "canary", unknown_id => bail!("Unknown network ID ({unknown_id})"), }; diff --git a/cli/src/commands/developer/scan.rs b/cli/src/commands/developer/scan.rs index d8a448bdf2..073cc23b6c 100644 --- a/cli/src/commands/developer/scan.rs +++ b/cli/src/commands/developer/scan.rs @@ -15,7 +15,7 @@ #![allow(clippy::type_complexity)] use snarkvm::{ - console::network::{MainnetV0, Network, TestnetV0, TestnetV1}, + console::network::{CanaryV0, MainnetV0, Network, TestnetV0}, prelude::{block::Block, Ciphertext, Field, FromBytes, Plaintext, PrivateKey, Record, ViewKey}, }; @@ -71,7 +71,7 @@ impl Scan { match self.network { MainnetV0::ID => self.scan_records::(), TestnetV0::ID => self.scan_records::(), - TestnetV1::ID => self.scan_records::(), + CanaryV0::ID => self.scan_records::(), unknown_id => bail!("Unknown network ID ({unknown_id})"), } } @@ -136,7 +136,7 @@ impl Scan { let network = match self.network { MainnetV0::ID => "mainnet", TestnetV0::ID => "testnet", - TestnetV1::ID => "testnet_v1", + CanaryV0::ID => "canary", unknown_id => bail!("Unknown network ID ({unknown_id})"), }; @@ -188,7 +188,7 @@ impl Scan { let network = match N::ID { MainnetV0::ID => "mainnet", TestnetV0::ID => "testnet", - TestnetV1::ID => "testnet_v1", + CanaryV0::ID => "canary", unknown_id => bail!("Unknown network ID ({unknown_id})"), }; @@ -367,7 +367,7 @@ impl Scan { let network = match N::ID { MainnetV0::ID => "mainnet", TestnetV0::ID => "testnet", - TestnetV1::ID => "testnet_v1", + CanaryV0::ID => "canary", unknown_id => bail!("Unknown network ID ({unknown_id})"), }; diff --git a/cli/src/commands/developer/transfer_private.rs b/cli/src/commands/developer/transfer_private.rs index c016561851..925ba72d7e 100644 --- a/cli/src/commands/developer/transfer_private.rs +++ b/cli/src/commands/developer/transfer_private.rs @@ -14,7 +14,7 @@ use super::Developer; use snarkvm::{ - console::network::{MainnetV0, Network, TestnetV0, TestnetV1}, + console::network::{CanaryV0, MainnetV0, Network, TestnetV0}, prelude::{ query::Query, store::{helpers::memory::ConsensusMemory, ConsensusStore}, @@ -93,7 +93,7 @@ impl TransferPrivate { match self.network { MainnetV0::ID => self.construct_transfer_private::(), TestnetV0::ID => self.construct_transfer_private::(), - TestnetV1::ID => self.construct_transfer_private::(), + CanaryV0::ID => self.construct_transfer_private::(), unknown_id => bail!("Unknown network ID ({unknown_id})"), } } diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index 5561987f04..433e799bec 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -19,7 +19,7 @@ use snarkvm::{ console::{ account::{Address, PrivateKey}, algorithms::Hash, - network::{MainnetV0, Network, TestnetV0, TestnetV1}, + network::{CanaryV0, MainnetV0, Network, TestnetV0}, }, ledger::{ block::Block, @@ -189,9 +189,9 @@ impl Start { Display::start(node, log_receiver).expect("Failed to initialize the display"); } } - TestnetV1::ID => { + CanaryV0::ID => { // Parse the node from the configurations. - let node = cli.parse_node::(shutdown.clone()).await.expect("Failed to parse the node"); + let node = cli.parse_node::(shutdown.clone()).await.expect("Failed to parse the node"); // If the display is enabled, render the display. if !cli.nodisplay { // Initialize the display. diff --git a/devnet.sh b/devnet.sh index 83ea2cc6b1..63e03c25db 100755 --- a/devnet.sh +++ b/devnet.sh @@ -9,7 +9,7 @@ read -p "Enter the total number of clients (default: 2): " total_clients total_clients=${total_clients:-2} # Read the network ID from user or use a default value of 1 -read -p "Enter the network ID (mainnet = 0, testnet = 1) (default: 1): " network_id +read -p "Enter the network ID (mainnet = 0, testnet = 1, canary = 2) (default: 1): " network_id network_id=${network_id:-1} # Ask the user if they want to run 'cargo install --locked --path .' or use a pre-installed binary diff --git a/node/rest/src/lib.rs b/node/rest/src/lib.rs index 7f4d914369..621775d4cc 100644 --- a/node/rest/src/lib.rs +++ b/node/rest/src/lib.rs @@ -121,7 +121,7 @@ impl, R: Routing> Rest { let network = match N::ID { snarkvm::console::network::MainnetV0::ID => "mainnet", snarkvm::console::network::TestnetV0::ID => "testnet", - snarkvm::console::network::TestnetV1::ID => "testnet_v1", + snarkvm::console::network::CanaryV0::ID => "canary", unknown_id => { eprintln!("Unknown network ID ({unknown_id})"); return; diff --git a/node/router/src/lib.rs b/node/router/src/lib.rs index de4840c82a..8d07e67f7f 100644 --- a/node/router/src/lib.rs +++ b/node/router/src/lib.rs @@ -408,10 +408,10 @@ impl Router { SocketAddr::from_str("34.17.53.129:4130").unwrap(), SocketAddr::from_str("35.200.149.162:4130").unwrap(), ] - } else if N::ID == snarkvm::console::network::TestnetV1::ID { - // TestnetV1 contains the following bootstrap peers. + } else if N::ID == snarkvm::console::network::CanaryV0::ID { + // CanaryV0 contains the following bootstrap peers. vec![ - // TODO: Populate me with TestnetV1 IP addresses. + // TODO: Populate me with CanaryV0 IP addresses. ] } else { // Unrecognized networks contain no bootstrap peers. From 2e56db5c78f534ef7c509f3eb3483e29713bcf48 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 23 May 2024 15:18:52 -0700 Subject: [PATCH 539/551] Bump snarkVM rev - 13b3efa --- Cargo.lock | 118 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 2 +- 2 files changed, 60 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f3904f90f3..2884baf2a0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3294,7 +3294,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "anstyle", "anyhow", @@ -3325,7 +3325,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "aleo-std", "anyhow", @@ -3355,7 +3355,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3369,7 +3369,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3380,7 +3380,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3390,7 +3390,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3400,7 +3400,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "indexmap 2.2.6", "itertools 0.11.0", @@ -3418,12 +3418,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3434,7 +3434,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3449,7 +3449,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3464,7 +3464,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3477,7 +3477,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3486,7 +3486,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3496,7 +3496,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3508,7 +3508,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3520,7 +3520,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3531,7 +3531,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3543,7 +3543,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3556,7 +3556,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "bs58", "snarkvm-console-network", @@ -3567,7 +3567,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "blake2s_simd", "smallvec", @@ -3580,7 +3580,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "aleo-std", "rayon", @@ -3591,7 +3591,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "anyhow", "indexmap 2.2.6", @@ -3614,7 +3614,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "anyhow", "bech32", @@ -3632,7 +3632,7 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "enum_index", "enum_index_derive", @@ -3653,7 +3653,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3668,7 +3668,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3679,7 +3679,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "snarkvm-console-network-environment", ] @@ -3687,7 +3687,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3697,7 +3697,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3708,7 +3708,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3719,7 +3719,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3730,7 +3730,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3741,7 +3741,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "rand", "rayon", @@ -3755,7 +3755,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "aleo-std", "anyhow", @@ -3772,7 +3772,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "aleo-std", "anyhow", @@ -3797,7 +3797,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "anyhow", "rand", @@ -3809,7 +3809,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3828,7 +3828,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "anyhow", "indexmap 2.2.6", @@ -3847,7 +3847,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -3860,7 +3860,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3873,7 +3873,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3886,7 +3886,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "bytes", "serde_json", @@ -3897,7 +3897,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3912,7 +3912,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "bytes", "serde_json", @@ -3925,7 +3925,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "snarkvm-console", "snarkvm-ledger-puzzle", @@ -3934,7 +3934,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "aleo-std", "anyhow", @@ -3954,7 +3954,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle-epoch" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "anyhow", "colored", @@ -3969,7 +3969,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "async-trait", "reqwest", @@ -3982,7 +3982,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "aleo-std-storage", "anyhow", @@ -4009,7 +4009,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4024,7 +4024,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4033,7 +4033,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "aleo-std", "anyhow", @@ -4058,7 +4058,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "aleo-std", "anyhow", @@ -4087,7 +4087,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "aleo-std", "colored", @@ -4110,7 +4110,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "indexmap 2.2.6", "paste", @@ -4124,7 +4124,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "bincode", "once_cell", @@ -4137,7 +4137,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "aleo-std", "anyhow", @@ -4158,7 +4158,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=d638448#d6384482cc3e51d4c673fedb46b0e9c6d3fa1e2b" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" dependencies = [ "proc-macro2", "quote 1.0.36", diff --git a/Cargo.toml b/Cargo.toml index 1cee08e2f0..cc741a5a8a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoNet/snarkVM.git" -rev = "d638448" +rev = "13b3efa" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From 757b20fff87a74ad5c552919f7892dbc37cc4a53 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 23 May 2024 15:36:29 -0700 Subject: [PATCH 540/551] Bump snarkVM rev - 0bd71b5 --- Cargo.lock | 139 ++++++++++++++++++++++++++++++----------------------- Cargo.toml | 2 +- 2 files changed, 81 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2884baf2a0..e6f33e94b5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -849,6 +849,26 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "enum-iterator" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c280b9e6b3ae19e152d8e31cf47f18389781e119d4013a2a2bb0180e5facc635" +dependencies = [ + "enum-iterator-derive", +] + +[[package]] +name = "enum-iterator-derive" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1ab991c1362ac86c61ab6f556cff143daa22e5a15e4e189df818b2fd19fe65b" +dependencies = [ + "proc-macro2", + "quote 1.0.36", + "syn 2.0.58", +] + [[package]] name = "enum_index" version = "0.2.0" @@ -3294,7 +3314,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "anstyle", "anyhow", @@ -3325,7 +3345,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "aleo-std", "anyhow", @@ -3355,7 +3375,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3369,7 +3389,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3380,7 +3400,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3390,7 +3410,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3400,7 +3420,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "indexmap 2.2.6", "itertools 0.11.0", @@ -3418,12 +3438,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3434,7 +3454,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3449,7 +3469,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3464,7 +3484,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3477,7 +3497,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3486,7 +3506,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3496,7 +3516,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3508,7 +3528,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3520,7 +3540,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3531,7 +3551,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3543,7 +3563,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3556,7 +3576,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "bs58", "snarkvm-console-network", @@ -3567,7 +3587,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "blake2s_simd", "smallvec", @@ -3580,7 +3600,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "aleo-std", "rayon", @@ -3591,7 +3611,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "anyhow", "indexmap 2.2.6", @@ -3614,7 +3634,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "anyhow", "bech32", @@ -3632,8 +3652,9 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ + "enum-iterator", "enum_index", "enum_index_derive", "indexmap 2.2.6", @@ -3653,7 +3674,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3668,7 +3689,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3679,7 +3700,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "snarkvm-console-network-environment", ] @@ -3687,7 +3708,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3697,7 +3718,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3708,7 +3729,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3719,7 +3740,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3730,7 +3751,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3741,7 +3762,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "rand", "rayon", @@ -3755,7 +3776,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "aleo-std", "anyhow", @@ -3772,7 +3793,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "aleo-std", "anyhow", @@ -3797,7 +3818,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "anyhow", "rand", @@ -3809,7 +3830,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3828,7 +3849,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "anyhow", "indexmap 2.2.6", @@ -3847,7 +3868,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -3860,7 +3881,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3873,7 +3894,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3886,7 +3907,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "bytes", "serde_json", @@ -3897,7 +3918,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3912,7 +3933,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "bytes", "serde_json", @@ -3925,7 +3946,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "snarkvm-console", "snarkvm-ledger-puzzle", @@ -3934,7 +3955,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "aleo-std", "anyhow", @@ -3954,7 +3975,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle-epoch" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "anyhow", "colored", @@ -3969,7 +3990,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "async-trait", "reqwest", @@ -3982,7 +4003,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "aleo-std-storage", "anyhow", @@ -4009,7 +4030,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4024,7 +4045,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4033,7 +4054,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "aleo-std", "anyhow", @@ -4058,7 +4079,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "aleo-std", "anyhow", @@ -4087,7 +4108,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "aleo-std", "colored", @@ -4110,7 +4131,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "indexmap 2.2.6", "paste", @@ -4124,7 +4145,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "bincode", "once_cell", @@ -4137,7 +4158,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "aleo-std", "anyhow", @@ -4158,7 +4179,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=13b3efa#13b3efabf2d163aa143668276bbeaa70d93ac041" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" dependencies = [ "proc-macro2", "quote 1.0.36", diff --git a/Cargo.toml b/Cargo.toml index cc741a5a8a..7e50d55025 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoNet/snarkVM.git" -rev = "13b3efa" +rev = "0bd71b5" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From 6868f375724046ce1aec71de932985e93209e064 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Thu, 23 May 2024 15:42:56 -0700 Subject: [PATCH 541/551] Add support for canary --- .devnet/.analytics/analytics.js | 5 ++++- .devnet/analytics.sh | 4 ++-- .devnet/clean.sh | 2 +- .devnet/start.sh | 2 +- .devnet/start_sync_test.sh | 2 +- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.devnet/.analytics/analytics.js b/.devnet/.analytics/analytics.js index 2949949313..02fcbb0d1b 100644 --- a/.devnet/.analytics/analytics.js +++ b/.devnet/.analytics/analytics.js @@ -148,6 +148,9 @@ async function fetchBlockMetrics(metricType, optionalBlockHeight, networkID) { case 1: networkName = "testnet"; break; + case 2: + networkName = "canary"; + break; default: throw new Error(`Unknown network ID (${networkID})`); } @@ -214,7 +217,7 @@ async function main() { describe: 'Network ID to fetch block metrics from', demandOption: true, type: 'number', - choices: [0, 1], + choices: [0, 1, 2], } }) .check((argv) => { diff --git a/.devnet/analytics.sh b/.devnet/analytics.sh index 0a8a4234c8..8e12f29889 100755 --- a/.devnet/analytics.sh +++ b/.devnet/analytics.sh @@ -16,9 +16,9 @@ fi # Prompt the user to specify a network ID while true; do - echo "Please specify a network ID (0 for mainnet, 1 for testnet):" + echo "Please specify a network ID (0 for mainnet, 1 for testnet, 2 for canary):" read networkID - if [[ $networkID == 0 || $networkID == 1 ]]; then + if [[ $networkID == 0 || $networkID == 1 || $networkID == 2 ]]; then break else echo "Invalid network ID. Please enter 0 or 1." diff --git a/.devnet/clean.sh b/.devnet/clean.sh index 2e99572371..888356e7a6 100755 --- a/.devnet/clean.sh +++ b/.devnet/clean.sh @@ -13,7 +13,7 @@ NUM_INSTANCES="${NUM_INSTANCES:-$NODE_ID}" echo "Using $NUM_INSTANCES AWS EC2 instances for querying." # Read the network ID from user or use a default value of 1 -read -p "Enter the network ID (mainnet = 0, testnet = 1) (default: 1): " NETWORK_ID +read -p "Enter the network ID (mainnet = 0, testnet = 1, canary = 2) (default: 1): " NETWORK_ID NETWORK_ID=${NETWORK_ID:-1} echo "Using network ID $NETWORK_ID." diff --git a/.devnet/start.sh b/.devnet/start.sh index d93f3e4ffc..a155b4104e 100755 --- a/.devnet/start.sh +++ b/.devnet/start.sh @@ -13,7 +13,7 @@ NUM_INSTANCES="${NUM_INSTANCES:-$NODE_ID}" echo "Using $NUM_INSTANCES AWS EC2 instances for querying." # Read the network ID from user or use a default value of 1 -read -p "Enter the network ID (mainnet = 0, testnet = 1) (default: 1): " NETWORK_ID +read -p "Enter the network ID (mainnet = 0, testnet = 1, canary = 2) (default: 1): " NETWORK_ID NETWORK_ID=${NETWORK_ID:-1} echo "Using network ID $NETWORK_ID." diff --git a/.devnet/start_sync_test.sh b/.devnet/start_sync_test.sh index 10a9b89c2b..41c35dacfd 100755 --- a/.devnet/start_sync_test.sh +++ b/.devnet/start_sync_test.sh @@ -13,7 +13,7 @@ NUM_INSTANCES="${NUM_INSTANCES:-$NODE_ID}" echo "Using $NUM_INSTANCES AWS EC2 instances for querying." # Read the network ID from user or use a default value of 1 -read -p "Enter the network ID (mainnet = 0, testnet = 1) (default: 1): " NETWORK_ID +read -p "Enter the network ID (mainnet = 0, testnet = 1, canary = 2) (default: 1): " NETWORK_ID NETWORK_ID=${NETWORK_ID:-1} echo "Using network ID $NETWORK_ID." From 99592f439be6a045f8ba0c5da6342115e696a719 Mon Sep 17 00:00:00 2001 From: Fabiano Date: Thu, 23 May 2024 21:23:33 -0400 Subject: [PATCH 542/551] Revert "Merge pull request #3266 from AleoNet/optimize/clear-solutions" This reverts commit 7ae9d731a8a315a07000d6a92b0066500fbb8c6e, reversing changes made to b905d53de152e349b28b8885b479094c526de335. --- node/bft/src/helpers/ready.rs | 8 -------- node/bft/src/primary.rs | 7 ------- node/bft/src/worker.rs | 7 ------- node/consensus/src/lib.rs | 8 -------- 4 files changed, 30 deletions(-) diff --git a/node/bft/src/helpers/ready.rs b/node/bft/src/helpers/ready.rs index 7a366dff81..6fa581ccdb 100644 --- a/node/bft/src/helpers/ready.rs +++ b/node/bft/src/helpers/ready.rs @@ -126,14 +126,6 @@ impl Ready { // Drain the transmission IDs. transmissions.drain(range).collect::>() } - - /// Clears all solutions from the ready queue. - pub(crate) fn clear_solutions(&self) { - // Acquire the write lock. - let mut transmissions = self.transmissions.write(); - // Remove all solutions. - transmissions.retain(|id, _| !matches!(id, TransmissionID::Solution(..))); - } } #[cfg(test)] diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index c13b44a10d..b604941fb6 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -320,13 +320,6 @@ impl Primary { } } -impl Primary { - /// Clears the worker solutions. - pub fn clear_worker_solutions(&self) { - self.workers.iter().for_each(Worker::clear_solutions); - } -} - impl Primary { /// Proposes the batch for the current round. /// diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index d58b4ebabf..7b8e5301d6 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -151,13 +151,6 @@ impl Worker { } } -impl Worker { - /// Clears the solutions from the ready queue. - pub(super) fn clear_solutions(&self) { - self.ready.clear_solutions() - } -} - impl Worker { /// Returns `true` if the transmission ID exists in the ready queue, proposed batch, storage, or ledger. pub fn contains_transmission(&self, transmission_id: impl Into>) -> bool { diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index fdf247dfdd..530893893d 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -484,14 +484,6 @@ impl Consensus { // Advance to the next block. self.ledger.advance_to_next_block(&next_block)?; - // If the next block starts a new epoch, clear the existing solutions. - if next_block.height() % N::NUM_BLOCKS_PER_EPOCH == 0 { - // Clear the solutions queue. - self.solutions_queue.lock().clear(); - // Clear the worker solutions. - self.bft.primary().clear_worker_solutions(); - } - #[cfg(feature = "metrics")] { let elapsed = std::time::Duration::from_secs((snarkos_node_bft::helpers::now() - start) as u64); From fa475e8ecb6f91e630c8acaba854d25c4dd805dc Mon Sep 17 00:00:00 2001 From: Fabiano Date: Thu, 23 May 2024 21:23:43 -0400 Subject: [PATCH 543/551] Revert "Merge pull request #3262 from AleoNet/update/devnet-scripts" This reverts commit b905d53de152e349b28b8885b479094c526de335, reversing changes made to 3d7b4d7742062bfafc87e923bff3e0ccc79f6b83. --- .devnet/.analytics/analytics.js | 35 ++++++--------------------------- .devnet/analytics.sh | 17 +++------------- .devnet/clean.sh | 8 +------- .devnet/start.sh | 8 +------- .devnet/start_sync_test.sh | 8 +------- 5 files changed, 12 insertions(+), 64 deletions(-) diff --git a/.devnet/.analytics/analytics.js b/.devnet/.analytics/analytics.js index 02fcbb0d1b..601be7a19f 100644 --- a/.devnet/.analytics/analytics.js +++ b/.devnet/.analytics/analytics.js @@ -115,7 +115,7 @@ async function calculateRoundsInBlocks(baseUrl, latestHeight) { } } -async function checkBlockHash(networkName, blockHeight) { +async function checkBlockHash(blockHeight) { const numNodes = await getAWSNodeCount(); console.log(`Detected ${numNodes} AWS nodes... \n`); @@ -125,7 +125,7 @@ async function checkBlockHash(networkName, blockHeight) { // Get the IP address of the AWS node const ipAddress = await getIPAddress(awsNodeName); // Define the base URL for the node - const baseUrl = `http://${ipAddress}:3030/${networkName}/block`; + const baseUrl = `http://${ipAddress}:3030/mainnet/block`; // Fetch the block data const blockData = await fetchBlockData(baseUrl, blockHeight); @@ -138,23 +138,7 @@ async function checkBlockHash(networkName, blockHeight) { } // Main function to fetch block metrics -async function fetchBlockMetrics(metricType, optionalBlockHeight, networkID) { - // Derive the network name based on the network ID. - let networkName; - switch (networkID) { - case 0: - networkName = "mainnet"; - break; - case 1: - networkName = "testnet"; - break; - case 2: - networkName = "canary"; - break; - default: - throw new Error(`Unknown network ID (${networkID})`); - } - +async function fetchBlockMetrics(metricType, optionalBlockHeight) { // Function to get the latest block height async function getLatestBlockHeight(baseUrl) { try { @@ -173,7 +157,7 @@ async function fetchBlockMetrics(metricType, optionalBlockHeight, networkID) { // Get the IP address of the AWS node const ipAddress = await getIPAddress(awsNodeName); // Define the base URL for the node. - const baseUrl = `http://${ipAddress}:3030/${networkName}/block`; + const baseUrl = `http://${ipAddress}:3030/mainnet/block`; console.log(`${dimStart}IP Address: ${ipAddress}${dimEnd}`); console.log(`${dimStart}Base URL: ${baseUrl}${dimEnd}`); @@ -191,7 +175,7 @@ async function fetchBlockMetrics(metricType, optionalBlockHeight, networkID) { } else if (metricType === 'roundsInBlocks') { calculateRoundsInBlocks(baseUrl, latestHeight); } else if (metricType === 'checkBlockHash' && optionalBlockHeight) { - checkBlockHash(networkName, optionalBlockHeight); + checkBlockHash(optionalBlockHeight); } else { console.error('Invalid metric type. Supported types: "averageBlockTime" or "roundsInBlocks".'); } @@ -212,13 +196,6 @@ async function main() { describe: 'Block height to examine for checkBlockHash metric', type: 'number', }, - 'network-id': { - alias: 'n', - describe: 'Network ID to fetch block metrics from', - demandOption: true, - type: 'number', - choices: [0, 1, 2], - } }) .check((argv) => { // Check if metric-type is checkBlockHash and block-height is provided @@ -230,7 +207,7 @@ async function main() { .argv; // Fetch and output the specified block metric - fetchBlockMetrics(argv['metric-type'], argv['block-height'], argv['network-id']); + fetchBlockMetrics(argv['metric-type'], argv['block-height']); } // Run the main function diff --git a/.devnet/analytics.sh b/.devnet/analytics.sh index 8e12f29889..9284f3a7e7 100755 --- a/.devnet/analytics.sh +++ b/.devnet/analytics.sh @@ -14,17 +14,6 @@ else echo "Node.js dependencies already installed." fi -# Prompt the user to specify a network ID -while true; do - echo "Please specify a network ID (0 for mainnet, 1 for testnet, 2 for canary):" - read networkID - if [[ $networkID == 0 || $networkID == 1 || $networkID == 2 ]]; then - break - else - echo "Invalid network ID. Please enter 0 or 1." - fi -done - # Prompt the user to select a metric type PS3="Select a metric type: " options=("Average Block Time" "Rounds in Blocks" "Check Block Hash" "Quit") @@ -33,12 +22,12 @@ do case $opt in "Average Block Time") echo "" - node analytics.js --metric-type averageBlockTime --network-id $networkID + node analytics.js --metric-type averageBlockTime break ;; "Rounds in Blocks") echo "" - node analytics.js --metric-type roundsInBlocks --network-id $networkID + node analytics.js --metric-type roundsInBlocks break ;; "Check Block Hash") @@ -50,7 +39,7 @@ do echo "Error: Block height must be a positive integer." exit 1 fi - node analytics.js --metric-type checkBlockHash --block-height "$blockHeight" --network-id $networkID + node analytics.js --metric-type checkBlockHash --block-height "$blockHeight" break ;; "Quit") diff --git a/.devnet/clean.sh b/.devnet/clean.sh index 888356e7a6..d06f8d5962 100755 --- a/.devnet/clean.sh +++ b/.devnet/clean.sh @@ -12,12 +12,6 @@ NUM_INSTANCES="${NUM_INSTANCES:-$NODE_ID}" echo "Using $NUM_INSTANCES AWS EC2 instances for querying." -# Read the network ID from user or use a default value of 1 -read -p "Enter the network ID (mainnet = 0, testnet = 1, canary = 2) (default: 1): " NETWORK_ID -NETWORK_ID=${NETWORK_ID:-1} - -echo "Using network ID $NETWORK_ID." - # Define a function to terminate the tmux session on a node terminate_tmux_session() { local NODE_ID=$1 @@ -30,7 +24,7 @@ terminate_tmux_session() { cd \$WORKSPACE tmux kill-session -t snarkos-session - snarkos clean --dev $NODE_ID --network $NETWORK_ID + snarkos clean --dev $NODE_ID exit # Exit root user EOF diff --git a/.devnet/start.sh b/.devnet/start.sh index a155b4104e..77294f080c 100755 --- a/.devnet/start.sh +++ b/.devnet/start.sh @@ -12,12 +12,6 @@ NUM_INSTANCES="${NUM_INSTANCES:-$NODE_ID}" echo "Using $NUM_INSTANCES AWS EC2 instances for querying." -# Read the network ID from user or use a default value of 1 -read -p "Enter the network ID (mainnet = 0, testnet = 1, canary = 2) (default: 1): " NETWORK_ID -NETWORK_ID=${NETWORK_ID:-1} - -echo "Using network ID $NETWORK_ID." - # Read the verbosity level from the user (default: 1) read -p "Enter the verbosity level (default: 1): " VERBOSITY VERBOSITY="${VERBOSITY:-1}" @@ -43,7 +37,7 @@ start_snarkos_in_tmux() { tmux new-session -d -s snarkos-session # Send the snarkOS start command to the tmux session with the NODE_ID - tmux send-keys -t "snarkos-session" "snarkos start --nodisplay --bft 0.0.0.0:5000 --rest 0.0.0.0:3030 --allow-external-peers --peers $NODE_IP:4130 --validators $NODE_IP:5000 --rest-rps 1000 --verbosity $VERBOSITY --network $NETWORK_ID --dev $NODE_ID --dev-num-validators $NUM_INSTANCES --validator --metrics" C-m + tmux send-keys -t "snarkos-session" "snarkos start --nodisplay --bft 0.0.0.0:5000 --rest 0.0.0.0:3030 --allow-external-peers --peers $NODE_IP:4130 --validators $NODE_IP:5000 --rest-rps 1000 --verbosity $VERBOSITY --dev $NODE_ID --dev-num-validators $NUM_INSTANCES --validator --metrics" C-m exit # Exit root user EOF diff --git a/.devnet/start_sync_test.sh b/.devnet/start_sync_test.sh index 41c35dacfd..6ca5fbb77a 100755 --- a/.devnet/start_sync_test.sh +++ b/.devnet/start_sync_test.sh @@ -12,12 +12,6 @@ NUM_INSTANCES="${NUM_INSTANCES:-$NODE_ID}" echo "Using $NUM_INSTANCES AWS EC2 instances for querying." -# Read the network ID from user or use a default value of 1 -read -p "Enter the network ID (mainnet = 0, testnet = 1, canary = 2) (default: 1): " NETWORK_ID -NETWORK_ID=${NETWORK_ID:-1} - -echo "Using network ID $NETWORK_ID." - # Read the verbosity level from the user (default: 1) read -p "Enter the verbosity level (default: 1): " VERBOSITY VERBOSITY="${VERBOSITY:-1}" @@ -43,7 +37,7 @@ start_snarkos_in_tmux() { tmux new-session -d -s snarkos-session # Send the snarkOS start command to the tmux session with the NODE_ID - tmux send-keys -t "snarkos-session" "snarkos start --client --nocdn --nodisplay --rest 0.0.0.0:3030 --node 0.0.0.0:4130 --verbosity 4 --network $NETWORK_ID --metrics --logfile "/tmp/snarkos-syncing-range-3.log" --peers 167.71.249.65:4130,157.245.218.195:4130,167.71.249.55:4130" C-m + tmux send-keys -t "snarkos-session" "snarkos start --client --nocdn --nodisplay --rest 0.0.0.0:3030 --node 0.0.0.0:4130 --verbosity 4 --metrics --logfile "/tmp/snarkos-syncing-range-3.log" --peers 167.71.249.65:4130,157.245.218.195:4130,167.71.249.55:4130" C-m exit # Exit root user EOF From 8c1bba87d3d302aede801093a35a58127ecc12e2 Mon Sep 17 00:00:00 2001 From: Fabiano Date: Thu, 23 May 2024 21:23:57 -0400 Subject: [PATCH 544/551] Revert "Merge pull request #3269 from AleoHQ/feat/testnetv1" This reverts commit 3d7b4d7742062bfafc87e923bff3e0ccc79f6b83, reversing changes made to 6065ee2d4d2e59fed0436d68977cd077f887f5e9. --- Cargo.lock | 139 ++++++++---------- Cargo.toml | 2 +- cli/src/commands/account.rs | 6 +- cli/src/commands/developer/decrypt.rs | 3 +- cli/src/commands/developer/deploy.rs | 5 +- cli/src/commands/developer/execute.rs | 3 +- cli/src/commands/developer/mod.rs | 2 - cli/src/commands/developer/scan.rs | 6 +- .../commands/developer/transfer_private.rs | 3 +- cli/src/commands/start.rs | 11 +- devnet.sh | 2 +- node/rest/src/lib.rs | 1 - node/router/src/lib.rs | 7 +- 13 files changed, 70 insertions(+), 120 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e6f33e94b5..05f3cd55d8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -849,26 +849,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "enum-iterator" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c280b9e6b3ae19e152d8e31cf47f18389781e119d4013a2a2bb0180e5facc635" -dependencies = [ - "enum-iterator-derive", -] - -[[package]] -name = "enum-iterator-derive" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1ab991c1362ac86c61ab6f556cff143daa22e5a15e4e189df818b2fd19fe65b" -dependencies = [ - "proc-macro2", - "quote 1.0.36", - "syn 2.0.58", -] - [[package]] name = "enum_index" version = "0.2.0" @@ -3314,7 +3294,7 @@ dependencies = [ [[package]] name = "snarkvm" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "anstyle", "anyhow", @@ -3345,7 +3325,7 @@ dependencies = [ [[package]] name = "snarkvm-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "aleo-std", "anyhow", @@ -3375,7 +3355,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-circuit-account", "snarkvm-circuit-algorithms", @@ -3389,7 +3369,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-account" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-network", @@ -3400,7 +3380,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-circuit-types", "snarkvm-console-algorithms", @@ -3410,7 +3390,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-collections" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-types", @@ -3420,7 +3400,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "indexmap 2.2.6", "itertools 0.11.0", @@ -3438,12 +3418,12 @@ dependencies = [ [[package]] name = "snarkvm-circuit-environment-witness" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" [[package]] name = "snarkvm-circuit-network" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-circuit-algorithms", "snarkvm-circuit-collections", @@ -3454,7 +3434,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-program" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "paste", "snarkvm-circuit-account", @@ -3469,7 +3449,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-address", @@ -3484,7 +3464,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-address" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3497,7 +3477,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-circuit-environment", "snarkvm-console-types-boolean", @@ -3506,7 +3486,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-field" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3516,7 +3496,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-group" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3528,7 +3508,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3540,7 +3520,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3551,7 +3531,7 @@ dependencies = [ [[package]] name = "snarkvm-circuit-types-string" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-circuit-environment", "snarkvm-circuit-types-boolean", @@ -3563,7 +3543,7 @@ dependencies = [ [[package]] name = "snarkvm-console" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-console-account", "snarkvm-console-algorithms", @@ -3576,7 +3556,7 @@ dependencies = [ [[package]] name = "snarkvm-console-account" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "bs58", "snarkvm-console-network", @@ -3587,7 +3567,7 @@ dependencies = [ [[package]] name = "snarkvm-console-algorithms" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "blake2s_simd", "smallvec", @@ -3600,7 +3580,7 @@ dependencies = [ [[package]] name = "snarkvm-console-collections" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "aleo-std", "rayon", @@ -3611,7 +3591,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "anyhow", "indexmap 2.2.6", @@ -3634,7 +3614,7 @@ dependencies = [ [[package]] name = "snarkvm-console-network-environment" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "anyhow", "bech32", @@ -3652,9 +3632,8 @@ dependencies = [ [[package]] name = "snarkvm-console-program" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ - "enum-iterator", "enum_index", "enum_index_derive", "indexmap 2.2.6", @@ -3674,7 +3653,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-address", @@ -3689,7 +3668,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-address" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3700,7 +3679,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-boolean" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-console-network-environment", ] @@ -3708,7 +3687,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-field" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3718,7 +3697,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-group" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3729,7 +3708,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-integers" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3740,7 +3719,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-scalar" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3751,7 +3730,7 @@ dependencies = [ [[package]] name = "snarkvm-console-types-string" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-console-network-environment", "snarkvm-console-types-boolean", @@ -3762,7 +3741,7 @@ dependencies = [ [[package]] name = "snarkvm-curves" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "rand", "rayon", @@ -3776,7 +3755,7 @@ dependencies = [ [[package]] name = "snarkvm-fields" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "aleo-std", "anyhow", @@ -3793,7 +3772,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "aleo-std", "anyhow", @@ -3818,7 +3797,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-authority" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "anyhow", "rand", @@ -3830,7 +3809,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-block" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3849,7 +3828,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-committee" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "anyhow", "indexmap 2.2.6", @@ -3868,7 +3847,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-ledger-narwhal-batch-certificate", "snarkvm-ledger-narwhal-batch-header", @@ -3881,7 +3860,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-certificate" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3894,7 +3873,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-batch-header" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3907,7 +3886,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-data" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "bytes", "serde_json", @@ -3918,7 +3897,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-subdag" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "indexmap 2.2.6", "rayon", @@ -3933,7 +3912,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "bytes", "serde_json", @@ -3946,7 +3925,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-narwhal-transmission-id" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "snarkvm-console", "snarkvm-ledger-puzzle", @@ -3955,7 +3934,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "aleo-std", "anyhow", @@ -3975,7 +3954,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-puzzle-epoch" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "anyhow", "colored", @@ -3990,7 +3969,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-query" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "async-trait", "reqwest", @@ -4003,7 +3982,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-store" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "aleo-std-storage", "anyhow", @@ -4030,7 +4009,7 @@ dependencies = [ [[package]] name = "snarkvm-ledger-test-helpers" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "once_cell", "snarkvm-circuit", @@ -4045,7 +4024,7 @@ dependencies = [ [[package]] name = "snarkvm-metrics" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "metrics", "metrics-exporter-prometheus", @@ -4054,7 +4033,7 @@ dependencies = [ [[package]] name = "snarkvm-parameters" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "aleo-std", "anyhow", @@ -4079,7 +4058,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "aleo-std", "anyhow", @@ -4108,7 +4087,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-process" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "aleo-std", "colored", @@ -4131,7 +4110,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-program" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "indexmap 2.2.6", "paste", @@ -4145,7 +4124,7 @@ dependencies = [ [[package]] name = "snarkvm-synthesizer-snark" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "bincode", "once_cell", @@ -4158,7 +4137,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "aleo-std", "anyhow", @@ -4179,7 +4158,7 @@ dependencies = [ [[package]] name = "snarkvm-utilities-derives" version = "0.16.19" -source = "git+https://github.com/AleoNet/snarkVM.git?rev=0bd71b5#0bd71b5835f0721b5c22e2ce144da0e19256606d" +source = "git+https://github.com/AleoNet/snarkVM.git?rev=140ff26#140ff26f87697c2e9d18212cce2cc831fc4b146a" dependencies = [ "proc-macro2", "quote 1.0.36", diff --git a/Cargo.toml b/Cargo.toml index 7e50d55025..3b385228d3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoNet/snarkVM.git" -rev = "0bd71b5" +rev = "140ff26" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] diff --git a/cli/src/commands/account.rs b/cli/src/commands/account.rs index 29fd401ea0..108b866723 100644 --- a/cli/src/commands/account.rs +++ b/cli/src/commands/account.rs @@ -15,7 +15,7 @@ use snarkvm::{ console::{ account::{Address, PrivateKey, Signature}, - network::{CanaryV0, MainnetV0, Network, TestnetV0}, + network::{MainnetV0, Network, TestnetV0}, prelude::{Environment, Uniform}, program::{ToFields, Value}, types::Field, @@ -113,14 +113,12 @@ impl Account { Some(vanity) => match network { MainnetV0::ID => Self::new_vanity::(vanity.as_str(), discreet), TestnetV0::ID => Self::new_vanity::(vanity.as_str(), discreet), - CanaryV0::ID => Self::new_vanity::(vanity.as_str(), discreet), unknown_id => bail!("Unknown network ID ({unknown_id})"), }, // Generate a seeded account for the specified network. None => match network { MainnetV0::ID => Self::new_seeded::(seed, discreet), TestnetV0::ID => Self::new_seeded::(seed, discreet), - CanaryV0::ID => Self::new_seeded::(seed, discreet), unknown_id => bail!("Unknown network ID ({unknown_id})"), }, } @@ -142,7 +140,6 @@ impl Account { match network { MainnetV0::ID => Self::sign::(key, message, seed, raw), TestnetV0::ID => Self::sign::(key, message, seed, raw), - CanaryV0::ID => Self::sign::(key, message, seed, raw), unknown_id => bail!("Unknown network ID ({unknown_id})"), } } @@ -151,7 +148,6 @@ impl Account { match network { MainnetV0::ID => Self::verify::(address, signature, message, raw), TestnetV0::ID => Self::verify::(address, signature, message, raw), - CanaryV0::ID => Self::verify::(address, signature, message, raw), unknown_id => bail!("Unknown network ID ({unknown_id})"), } } diff --git a/cli/src/commands/developer/decrypt.rs b/cli/src/commands/developer/decrypt.rs index 2a46ac3a27..9154337de9 100644 --- a/cli/src/commands/developer/decrypt.rs +++ b/cli/src/commands/developer/decrypt.rs @@ -14,7 +14,7 @@ use snarkvm::{ console::{ - network::{CanaryV0, MainnetV0, Network, TestnetV0}, + network::{MainnetV0, Network, TestnetV0}, program::Ciphertext, }, prelude::{Record, ViewKey}, @@ -45,7 +45,6 @@ impl Decrypt { match self.network { MainnetV0::ID => Self::decrypt_ciphertext::(&self.ciphertext, &self.view_key), TestnetV0::ID => Self::decrypt_ciphertext::(&self.ciphertext, &self.view_key), - CanaryV0::ID => Self::decrypt_ciphertext::(&self.ciphertext, &self.view_key), unknown_id => bail!("Unknown network ID ({unknown_id})"), } } diff --git a/cli/src/commands/developer/deploy.rs b/cli/src/commands/developer/deploy.rs index 7cb2853785..c084481859 100644 --- a/cli/src/commands/developer/deploy.rs +++ b/cli/src/commands/developer/deploy.rs @@ -14,9 +14,9 @@ use super::Developer; use snarkvm::{ - circuit::{Aleo, AleoCanaryV0, AleoTestnetV0, AleoV0}, + circuit::{Aleo, AleoTestnetV0, AleoV0}, console::{ - network::{CanaryV0, MainnetV0, Network, TestnetV0}, + network::{MainnetV0, Network, TestnetV0}, program::ProgramOwner, }, prelude::{ @@ -93,7 +93,6 @@ impl Deploy { match self.network { MainnetV0::ID => self.construct_deployment::(), TestnetV0::ID => self.construct_deployment::(), - CanaryV0::ID => self.construct_deployment::(), unknown_id => bail!("Unknown network ID ({unknown_id})"), } } diff --git a/cli/src/commands/developer/execute.rs b/cli/src/commands/developer/execute.rs index 910109b2b4..455f258e9c 100644 --- a/cli/src/commands/developer/execute.rs +++ b/cli/src/commands/developer/execute.rs @@ -14,7 +14,7 @@ use super::Developer; use snarkvm::{ - console::network::{CanaryV0, MainnetV0, Network, TestnetV0}, + console::network::{MainnetV0, Network, TestnetV0}, prelude::{ query::Query, store::{helpers::memory::ConsensusMemory, ConsensusStore}, @@ -94,7 +94,6 @@ impl Execute { match self.network { MainnetV0::ID => self.construct_execution::(), TestnetV0::ID => self.construct_execution::(), - CanaryV0::ID => self.construct_execution::(), unknown_id => bail!("Unknown network ID ({unknown_id})"), } } diff --git a/cli/src/commands/developer/mod.rs b/cli/src/commands/developer/mod.rs index 781797a851..fcdf6b2ea2 100644 --- a/cli/src/commands/developer/mod.rs +++ b/cli/src/commands/developer/mod.rs @@ -119,7 +119,6 @@ impl Developer { let network = match N::ID { snarkvm::console::network::MainnetV0::ID => "mainnet", snarkvm::console::network::TestnetV0::ID => "testnet", - snarkvm::console::network::CanaryV0::ID => "canary", unknown_id => bail!("Unknown network ID ({unknown_id})"), }; @@ -148,7 +147,6 @@ impl Developer { let network = match N::ID { snarkvm::console::network::MainnetV0::ID => "mainnet", snarkvm::console::network::TestnetV0::ID => "testnet", - snarkvm::console::network::CanaryV0::ID => "canary", unknown_id => bail!("Unknown network ID ({unknown_id})"), }; diff --git a/cli/src/commands/developer/scan.rs b/cli/src/commands/developer/scan.rs index 073cc23b6c..891295a092 100644 --- a/cli/src/commands/developer/scan.rs +++ b/cli/src/commands/developer/scan.rs @@ -15,7 +15,7 @@ #![allow(clippy::type_complexity)] use snarkvm::{ - console::network::{CanaryV0, MainnetV0, Network, TestnetV0}, + console::network::{MainnetV0, Network, TestnetV0}, prelude::{block::Block, Ciphertext, Field, FromBytes, Plaintext, PrivateKey, Record, ViewKey}, }; @@ -71,7 +71,6 @@ impl Scan { match self.network { MainnetV0::ID => self.scan_records::(), TestnetV0::ID => self.scan_records::(), - CanaryV0::ID => self.scan_records::(), unknown_id => bail!("Unknown network ID ({unknown_id})"), } } @@ -136,7 +135,6 @@ impl Scan { let network = match self.network { MainnetV0::ID => "mainnet", TestnetV0::ID => "testnet", - CanaryV0::ID => "canary", unknown_id => bail!("Unknown network ID ({unknown_id})"), }; @@ -188,7 +186,6 @@ impl Scan { let network = match N::ID { MainnetV0::ID => "mainnet", TestnetV0::ID => "testnet", - CanaryV0::ID => "canary", unknown_id => bail!("Unknown network ID ({unknown_id})"), }; @@ -367,7 +364,6 @@ impl Scan { let network = match N::ID { MainnetV0::ID => "mainnet", TestnetV0::ID => "testnet", - CanaryV0::ID => "canary", unknown_id => bail!("Unknown network ID ({unknown_id})"), }; diff --git a/cli/src/commands/developer/transfer_private.rs b/cli/src/commands/developer/transfer_private.rs index 925ba72d7e..0d84ea5930 100644 --- a/cli/src/commands/developer/transfer_private.rs +++ b/cli/src/commands/developer/transfer_private.rs @@ -14,7 +14,7 @@ use super::Developer; use snarkvm::{ - console::network::{CanaryV0, MainnetV0, Network, TestnetV0}, + console::network::{MainnetV0, Network, TestnetV0}, prelude::{ query::Query, store::{helpers::memory::ConsensusMemory, ConsensusStore}, @@ -93,7 +93,6 @@ impl TransferPrivate { match self.network { MainnetV0::ID => self.construct_transfer_private::(), TestnetV0::ID => self.construct_transfer_private::(), - CanaryV0::ID => self.construct_transfer_private::(), unknown_id => bail!("Unknown network ID ({unknown_id})"), } } diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index 433e799bec..2cfd66d310 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -19,7 +19,7 @@ use snarkvm::{ console::{ account::{Address, PrivateKey}, algorithms::Hash, - network::{CanaryV0, MainnetV0, Network, TestnetV0}, + network::{MainnetV0, Network, TestnetV0}, }, ledger::{ block::Block, @@ -189,15 +189,6 @@ impl Start { Display::start(node, log_receiver).expect("Failed to initialize the display"); } } - CanaryV0::ID => { - // Parse the node from the configurations. - let node = cli.parse_node::(shutdown.clone()).await.expect("Failed to parse the node"); - // If the display is enabled, render the display. - if !cli.nodisplay { - // Initialize the display. - Display::start(node, log_receiver).expect("Failed to initialize the display"); - } - } _ => panic!("Invalid network ID specified"), }; // Note: Do not move this. The pending await must be here otherwise diff --git a/devnet.sh b/devnet.sh index 63e03c25db..83ea2cc6b1 100755 --- a/devnet.sh +++ b/devnet.sh @@ -9,7 +9,7 @@ read -p "Enter the total number of clients (default: 2): " total_clients total_clients=${total_clients:-2} # Read the network ID from user or use a default value of 1 -read -p "Enter the network ID (mainnet = 0, testnet = 1, canary = 2) (default: 1): " network_id +read -p "Enter the network ID (mainnet = 0, testnet = 1) (default: 1): " network_id network_id=${network_id:-1} # Ask the user if they want to run 'cargo install --locked --path .' or use a pre-installed binary diff --git a/node/rest/src/lib.rs b/node/rest/src/lib.rs index 621775d4cc..f3195063ca 100644 --- a/node/rest/src/lib.rs +++ b/node/rest/src/lib.rs @@ -121,7 +121,6 @@ impl, R: Routing> Rest { let network = match N::ID { snarkvm::console::network::MainnetV0::ID => "mainnet", snarkvm::console::network::TestnetV0::ID => "testnet", - snarkvm::console::network::CanaryV0::ID => "canary", unknown_id => { eprintln!("Unknown network ID ({unknown_id})"); return; diff --git a/node/router/src/lib.rs b/node/router/src/lib.rs index 8d07e67f7f..3703ea6002 100644 --- a/node/router/src/lib.rs +++ b/node/router/src/lib.rs @@ -401,18 +401,13 @@ impl Router { // TODO: Populate me with Mainnet Beta IP addresses. ] } else if N::ID == snarkvm::console::network::TestnetV0::ID { - // TestnetV0 contains the following bootstrap peers. + // Testnet contains the following bootstrap peers. vec![ SocketAddr::from_str("34.168.118.156:4130").unwrap(), SocketAddr::from_str("35.231.152.213:4130").unwrap(), SocketAddr::from_str("34.17.53.129:4130").unwrap(), SocketAddr::from_str("35.200.149.162:4130").unwrap(), ] - } else if N::ID == snarkvm::console::network::CanaryV0::ID { - // CanaryV0 contains the following bootstrap peers. - vec![ - // TODO: Populate me with CanaryV0 IP addresses. - ] } else { // Unrecognized networks contain no bootstrap peers. vec![] From 01f1b8611852cee21e99591636ccf9f7af9b813a Mon Sep 17 00:00:00 2001 From: Fabiano Date: Thu, 23 May 2024 21:24:04 -0400 Subject: [PATCH 545/551] Revert "Merge pull request #3257 from AleoNet/feat/bound-requests" This reverts commit 6065ee2d4d2e59fed0436d68977cd077f887f5e9, reversing changes made to b55162b1a8fa923df4686d3b8a2992bfb7355ec5. --- node/bft/src/helpers/pending.rs | 24 +----------------------- node/bft/src/sync/mod.rs | 5 +---- node/bft/src/worker.rs | 5 +---- 3 files changed, 3 insertions(+), 31 deletions(-) diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index ca07ee090a..cf68a39e54 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -85,16 +85,6 @@ impl Pending { self.pending.read().get(&item.into()).map_or(false, |peer_ips| peer_ips.contains_key(&peer_ip)) } - /// Returns `true` if the pending queue contains the specified `item` for the specified `peer IP` with a sent request. - pub fn contains_peer_with_sent_request(&self, item: impl Into, peer_ip: SocketAddr) -> bool { - self.pending.read().get(&item.into()).map_or(false, |peer_ips| { - peer_ips - .get(&peer_ip) - .map(|callbacks| callbacks.iter().any(|(_, _, request_sent)| *request_sent)) - .unwrap_or(false) - }) - } - /// Returns the peer IPs for the specified `item`. pub fn get_peers(&self, item: impl Into) -> Option> { self.pending.read().get(&item.into()).map(|map| map.keys().cloned().collect()) @@ -264,29 +254,24 @@ mod tests { let solution_id_1 = TransmissionID::Solution(rng.gen::().into()); let solution_id_2 = TransmissionID::Solution(rng.gen::().into()); let solution_id_3 = TransmissionID::Solution(rng.gen::().into()); - let solution_id_4 = TransmissionID::Solution(rng.gen::().into()); // Initialize the SocketAddrs. let addr_1 = SocketAddr::from(([127, 0, 0, 1], 1234)); let addr_2 = SocketAddr::from(([127, 0, 0, 1], 2345)); let addr_3 = SocketAddr::from(([127, 0, 0, 1], 3456)); - let addr_4 = SocketAddr::from(([127, 0, 0, 1], 4567)); // Initialize the callbacks. let (callback_sender_1, _) = oneshot::channel(); let (callback_sender_2, _) = oneshot::channel(); let (callback_sender_3, _) = oneshot::channel(); - let (callback_sender_4, _) = oneshot::channel(); // Insert the solution IDs. assert!(pending.insert(solution_id_1, addr_1, Some((callback_sender_1, true)))); assert!(pending.insert(solution_id_2, addr_2, Some((callback_sender_2, true)))); assert!(pending.insert(solution_id_3, addr_3, Some((callback_sender_3, true)))); - // Add a callback without a sent request. - assert!(pending.insert(solution_id_4, addr_4, Some((callback_sender_4, false)))); // Check the number of SocketAddrs. - assert_eq!(pending.len(), 4); + assert_eq!(pending.len(), 3); assert!(!pending.is_empty()); // Check the items. @@ -297,12 +282,7 @@ mod tests { let id = ids[i]; assert!(pending.contains(id)); assert!(pending.contains_peer(id, peers[i])); - assert!(pending.contains_peer_with_sent_request(id, peers[i])); } - // Ensure the last item does not have a sent request. - assert!(pending.contains_peer(solution_id_4, addr_4)); - assert!(!pending.contains_peer_with_sent_request(solution_id_4, addr_4)); - let unknown_id = TransmissionID::Solution(rng.gen::().into()); assert!(!pending.contains(unknown_id)); @@ -310,14 +290,12 @@ mod tests { assert_eq!(pending.get_peers(solution_id_1), Some(HashSet::from([addr_1]))); assert_eq!(pending.get_peers(solution_id_2), Some(HashSet::from([addr_2]))); assert_eq!(pending.get_peers(solution_id_3), Some(HashSet::from([addr_3]))); - assert_eq!(pending.get_peers(solution_id_4), Some(HashSet::from([addr_4]))); assert_eq!(pending.get_peers(unknown_id), None); // Check remove. assert!(pending.remove(solution_id_1, None).is_some()); assert!(pending.remove(solution_id_2, None).is_some()); assert!(pending.remove(solution_id_3, None).is_some()); - assert!(pending.remove(solution_id_4, None).is_some()); assert!(pending.remove(unknown_id, None).is_none()); // Check empty again. diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index ade20eccc8..02bb3c3dc2 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -578,13 +578,10 @@ impl Sync { let (callback_sender, callback_receiver) = oneshot::channel(); // Determine how many sent requests are pending. let num_sent_requests = self.pending.num_sent_requests(certificate_id); - // Determine if we've already sent a request to the peer. - let contains_peer_with_sent_request = self.pending.contains_peer_with_sent_request(certificate_id, peer_ip); // Determine the maximum number of redundant requests. let num_redundant_requests = max_redundant_requests(self.ledger.clone(), self.storage.current_round()); // Determine if we should send a certificate request to the peer. - // We send at most `num_redundant_requests` requests and each peer can only receive one request at a time. - let should_send_request = num_sent_requests < num_redundant_requests && !contains_peer_with_sent_request; + let should_send_request = num_sent_requests < num_redundant_requests; // Insert the certificate ID into the pending queue. self.pending.insert(certificate_id, peer_ip, Some((callback_sender, should_send_request))); diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index 7b8e5301d6..dc82d775ce 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -410,13 +410,10 @@ impl Worker { let (callback_sender, callback_receiver) = oneshot::channel(); // Determine how many sent requests are pending. let num_sent_requests = self.pending.num_sent_requests(transmission_id); - // Determine if we've already sent a request to the peer. - let contains_peer_with_sent_request = self.pending.contains_peer_with_sent_request(transmission_id, peer_ip); // Determine the maximum number of redundant requests. let num_redundant_requests = max_redundant_requests(self.ledger.clone(), self.storage.current_round()); // Determine if we should send a transmission request to the peer. - // We send at most `num_redundant_requests` requests and each peer can only receive one request at a time. - let should_send_request = num_sent_requests < num_redundant_requests && !contains_peer_with_sent_request; + let should_send_request = num_sent_requests < num_redundant_requests; // Insert the transmission ID into the pending queue. self.pending.insert(transmission_id, peer_ip, Some((callback_sender, should_send_request))); From 223a1b55796ba12d995dc3ccc4373f069168b968 Mon Sep 17 00:00:00 2001 From: Fabiano Date: Thu, 23 May 2024 21:24:20 -0400 Subject: [PATCH 546/551] Revert "Merge pull request #3256 from AleoNet/fix/is-syncing-check" This reverts commit b55162b1a8fa923df4686d3b8a2992bfb7355ec5, reversing changes made to 7ff06a8615a85b41457257fe7ce9764986fae3ce. --- .gitignore | 1 - node/bft/src/helpers/storage.rs | 1 - node/bft/src/primary.rs | 76 ++-------------------- node/bft/src/sync/mod.rs | 7 -- node/bft/storage-service/src/memory.rs | 4 +- node/bft/storage-service/src/persistent.rs | 4 +- node/sync/src/block_sync.rs | 7 +- 7 files changed, 11 insertions(+), 89 deletions(-) diff --git a/.gitignore b/.gitignore index 98b96026ae..f58c794d33 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,6 @@ wasm/Cargo.lock **/build **.ledger-* -**.current-proposal-cache-* **.logs-* validator-* **.bft-storage-*/ diff --git a/node/bft/src/helpers/storage.rs b/node/bft/src/helpers/storage.rs index abb93310d8..bda8bce766 100644 --- a/node/bft/src/helpers/storage.rs +++ b/node/bft/src/helpers/storage.rs @@ -788,7 +788,6 @@ impl Storage { /// Inserts the given `certificate` into storage. /// /// Note: Do NOT use this in production. This is for **testing only**. - #[cfg(test)] #[doc(hidden)] pub(crate) fn testing_only_insert_certificate_testing_only(&self, certificate: BatchCertificate) { // Retrieve the round. diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index b604941fb6..05069d2aa4 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -161,8 +161,7 @@ impl Primary { // We use a dummy IP because the node should not need to request from any peers. // The storage should have stored all the transmissions. If not, we simply // skip the certificate. - if let Err(err) = self.sync_with_certificate_from_peer::(DUMMY_SELF_IP, certificate).await - { + if let Err(err) = self.sync_with_certificate_from_peer(DUMMY_SELF_IP, certificate).await { warn!("Failed to load stored certificate {} from proposal cache - {err}", fmt_id(batch_id)); } } @@ -691,7 +690,7 @@ impl Primary { } // If the peer is ahead, use the batch header to sync up to the peer. - let mut transmissions = self.sync_with_batch_header_from_peer::(peer_ip, &batch_header).await?; + let mut transmissions = self.sync_with_batch_header_from_peer(peer_ip, &batch_header).await?; // Check that the transmission ids match and are not fee transactions. if let Err(err) = cfg_iter_mut!(transmissions).try_for_each(|(transmission_id, transmission)| { @@ -903,7 +902,7 @@ impl Primary { } // Store the certificate, after ensuring it is valid. - self.sync_with_certificate_from_peer::(peer_ip, certificate).await?; + self.sync_with_certificate_from_peer(peer_ip, certificate).await?; // If there are enough certificates to reach quorum threshold for the certificate round, // then proceed to advance to the next round. @@ -1422,7 +1421,7 @@ impl Primary { /// - Ensure the previous certificates have reached the quorum threshold. /// - Ensure we have not already signed the batch ID. #[async_recursion::async_recursion] - async fn sync_with_certificate_from_peer( + async fn sync_with_certificate_from_peer( &self, peer_ip: SocketAddr, certificate: BatchCertificate, @@ -1441,16 +1440,8 @@ impl Primary { return Ok(()); } - // If node is not in sync mode and the node is not synced. Then return an error. - if !IS_SYNCING && !self.is_synced() { - bail!( - "Failed to process certificate `{}` at round {batch_round} from '{peer_ip}' (node is syncing)", - fmt_id(certificate.id()) - ); - } - // If the peer is ahead, use the batch header to sync up to the peer. - let missing_transmissions = self.sync_with_batch_header_from_peer::(peer_ip, batch_header).await?; + let missing_transmissions = self.sync_with_batch_header_from_peer(peer_ip, batch_header).await?; // Check if the certificate needs to be stored. if !self.storage.contains_certificate(certificate.id()) { @@ -1471,7 +1462,7 @@ impl Primary { } /// Recursively syncs using the given batch header. - async fn sync_with_batch_header_from_peer( + async fn sync_with_batch_header_from_peer( &self, peer_ip: SocketAddr, batch_header: &BatchHeader, @@ -1484,14 +1475,6 @@ impl Primary { bail!("Round {batch_round} is too far in the past") } - // If node is not in sync mode and the node is not synced. Then return an error. - if !IS_SYNCING && !self.is_synced() { - bail!( - "Failed to process batch header `{}` at round {batch_round} from '{peer_ip}' (node is syncing)", - fmt_id(batch_header.batch_id()) - ); - } - // Determine if quorum threshold is reached on the batch round. let is_quorum_threshold_reached = { let certificates = self.storage.get_certificates_for_round(batch_round); @@ -1527,7 +1510,7 @@ impl Primary { // Iterate through the missing previous certificates. for batch_certificate in missing_previous_certificates { // Store the batch certificate (recursively fetching any missing previous certificates). - self.sync_with_certificate_from_peer::(peer_ip, batch_certificate).await?; + self.sync_with_certificate_from_peer(peer_ip, batch_certificate).await?; } Ok(missing_transmissions) } @@ -2082,8 +2065,6 @@ mod tests { // The author must be known to resolver to pass propose checks. primary.gateway.resolver().insert_peer(peer_ip, peer_ip, peer_account.1.address()); - // The primary must be considered synced. - primary.sync.block_sync().try_block_sync(&primary.gateway.clone()).await; // Try to process the batch proposal from the peer, should succeed. assert!( @@ -2091,39 +2072,6 @@ mod tests { ); } - #[tokio::test] - async fn test_batch_propose_from_peer_when_not_synced() { - let mut rng = TestRng::default(); - let (primary, accounts) = primary_without_handlers(&mut rng).await; - - // Create a valid proposal with an author that isn't the primary. - let round = 1; - let peer_account = &accounts[1]; - let peer_ip = peer_account.0; - let timestamp = now() + MIN_BATCH_DELAY_IN_SECS as i64; - let proposal = create_test_proposal( - &peer_account.1, - primary.ledger.current_committee().unwrap(), - round, - Default::default(), - timestamp, - &mut rng, - ); - - // Make sure the primary is aware of the transmissions in the proposal. - for (transmission_id, transmission) in proposal.transmissions() { - primary.workers[0].process_transmission_from_peer(peer_ip, *transmission_id, transmission.clone()) - } - - // The author must be known to resolver to pass propose checks. - primary.gateway.resolver().insert_peer(peer_ip, peer_ip, peer_account.1.address()); - - // Try to process the batch proposal from the peer, should fail. - assert!( - primary.process_batch_propose_from_peer(peer_ip, (*proposal.batch_header()).clone().into()).await.is_err() - ); - } - #[tokio::test] async fn test_batch_propose_from_peer_in_round() { let round = 2; @@ -2153,8 +2101,6 @@ mod tests { // The author must be known to resolver to pass propose checks. primary.gateway.resolver().insert_peer(peer_ip, peer_ip, peer_account.1.address()); - // The primary must be considered synced. - primary.sync.block_sync().try_block_sync(&primary.gateway.clone()).await; // Try to process the batch proposal from the peer, should succeed. primary.process_batch_propose_from_peer(peer_ip, (*proposal.batch_header()).clone().into()).await.unwrap(); @@ -2186,8 +2132,6 @@ mod tests { // The author must be known to resolver to pass propose checks. primary.gateway.resolver().insert_peer(peer_ip, peer_ip, peer_account.1.address()); - // The primary must be considered synced. - primary.sync.block_sync().try_block_sync(&primary.gateway.clone()).await; // Try to process the batch proposal from the peer, should error. assert!( @@ -2230,8 +2174,6 @@ mod tests { // The author must be known to resolver to pass propose checks. primary.gateway.resolver().insert_peer(peer_ip, peer_ip, peer_account.1.address()); - // The primary must be considered synced. - primary.sync.block_sync().try_block_sync(&primary.gateway.clone()).await; // Try to process the batch proposal from the peer, should error. assert!( @@ -2274,8 +2216,6 @@ mod tests { // The author must be known to resolver to pass propose checks. primary.gateway.resolver().insert_peer(peer_ip, peer_ip, peer_account.1.address()); - // The primary must be considered synced. - primary.sync.block_sync().try_block_sync(&primary.gateway.clone()).await; // Try to process the batch proposal from the peer, should error. assert!( @@ -2312,8 +2252,6 @@ mod tests { // The author must be known to resolver to pass propose checks. primary.gateway.resolver().insert_peer(peer_ip, peer_ip, peer_account.1.address()); - // The primary must be considered synced. - primary.sync.block_sync().try_block_sync(&primary.gateway.clone()).await; // Try to process the batch proposal from the peer, should error. assert!( diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index 02bb3c3dc2..e5dc84731b 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -557,13 +557,6 @@ impl Sync { pub fn get_block_locators(&self) -> Result> { self.block_sync.get_block_locators() } - - /// Returns the block sync module. - #[cfg(test)] - #[doc(hidden)] - pub(super) fn block_sync(&self) -> &BlockSync { - &self.block_sync - } } // Methods to assist with fetching batch certificates from peers. diff --git a/node/bft/storage-service/src/memory.rs b/node/bft/storage-service/src/memory.rs index 25648742e0..38cd430d68 100644 --- a/node/bft/storage-service/src/memory.rs +++ b/node/bft/storage-service/src/memory.rs @@ -120,9 +120,7 @@ impl StorageService for BFTMemoryService { Entry::Vacant(vacant_entry) => { // Retrieve the missing transmission. let Some(transmission) = missing_transmissions.remove(&transmission_id) else { - if !aborted_transmission_ids.contains(&transmission_id) - && !self.contains_transmission(transmission_id) - { + if !aborted_transmission_ids.contains(&transmission_id) { error!("Failed to provide a missing transmission {transmission_id}"); } continue 'outer; diff --git a/node/bft/storage-service/src/persistent.rs b/node/bft/storage-service/src/persistent.rs index 96a9d0c8e5..b18b3771d7 100644 --- a/node/bft/storage-service/src/persistent.rs +++ b/node/bft/storage-service/src/persistent.rs @@ -171,9 +171,7 @@ impl StorageService for BFTPersistentStorage { Ok(None) => { // Retrieve the missing transmission. let Some(transmission) = missing_transmissions.remove(&transmission_id) else { - if !aborted_transmission_ids.contains(&transmission_id) - && !self.contains_transmission(transmission_id) - { + if !aborted_transmission_ids.contains(&transmission_id) { error!("Failed to provide a missing transmission {transmission_id}"); } continue 'outer; diff --git a/node/sync/src/block_sync.rs b/node/sync/src/block_sync.rs index 48c9778191..525962ed0c 100644 --- a/node/sync/src/block_sync.rs +++ b/node/sync/src/block_sync.rs @@ -453,11 +453,8 @@ impl BlockSync { // Return the list of block requests. (self.construct_requests(&sync_peers, min_common_ancestor), sync_peers) } else { - // Update `is_block_synced` if there are no pending requests or responses. - if self.requests.read().is_empty() && self.responses.read().is_empty() { - // Update the state of `is_block_synced` for the sync module. - self.update_is_block_synced(0, MAX_BLOCKS_BEHIND); - } + // Update the state of `is_block_synced` for the sync module. + self.update_is_block_synced(0, MAX_BLOCKS_BEHIND); // Return an empty list of block requests. (Default::default(), Default::default()) } From 0829e52ec7181622631901c9417543413e0f3b00 Mon Sep 17 00:00:00 2001 From: Fabiano Date: Thu, 23 May 2024 21:24:38 -0400 Subject: [PATCH 547/551] Revert "Merge pull request #3254 from niklaslong/fix/cache" This reverts commit 7ff06a8615a85b41457257fe7ce9764986fae3ce, reversing changes made to 9cc67c91090286d434037a70953062018aefd85c. --- node/bft/src/gateway.rs | 5 ----- node/bft/src/helpers/cache.rs | 28 ---------------------------- 2 files changed, 33 deletions(-) diff --git a/node/bft/src/gateway.rs b/node/bft/src/gateway.rs index 00cc6b96ea..0e404ff635 100644 --- a/node/bft/src/gateway.rs +++ b/node/bft/src/gateway.rs @@ -1085,11 +1085,6 @@ impl Disconnect for Gateway { async fn handle_disconnect(&self, peer_addr: SocketAddr) { if let Some(peer_ip) = self.resolver.get_listener(peer_addr) { self.remove_connected_peer(peer_ip); - - // We don't clear this map based on time but only on peer disconnect. - // This is sufficient to avoid infinite growth as the committee has a fixed number - // of members. - self.cache.clear_outbound_validators_requests(peer_ip); } } } diff --git a/node/bft/src/helpers/cache.rs b/node/bft/src/helpers/cache.rs index 49301a01f7..7e6bafc0a9 100644 --- a/node/bft/src/helpers/cache.rs +++ b/node/bft/src/helpers/cache.rs @@ -119,11 +119,6 @@ impl Cache { pub fn decrement_outbound_validators_requests(&self, peer_ip: SocketAddr) -> u32 { Self::decrement_counter(&self.seen_outbound_validators_requests, peer_ip) } - - /// Clears the the IP's number of validator requests. - pub fn clear_outbound_validators_requests(&self, peer_ip: SocketAddr) { - self.seen_outbound_validators_requests.write().remove(&peer_ip); - } } impl Cache { @@ -298,27 +293,4 @@ mod tests { outbound_certificate, outbound_transmission } - - #[test] - fn test_seen_outbound_validators_requests() { - let cache = Cache::::default(); - let input = Input::input(); - - // Check the map is empty. - assert!(!cache.contains_outbound_validators_request(input)); - - // Insert some requests. - for _ in 0..3 { - cache.increment_outbound_validators_requests(input); - assert!(cache.contains_outbound_validators_request(input)); - } - - // Remove a request. - cache.decrement_outbound_validators_requests(input); - assert!(cache.contains_outbound_validators_request(input)); - - // Clear all requests. - cache.clear_outbound_validators_requests(input); - assert!(!cache.contains_outbound_validators_request(input)); - } } From 7dbaadd4167ad9af7824d52d71605b39afc09e96 Mon Sep 17 00:00:00 2001 From: Fabiano Date: Thu, 23 May 2024 21:24:48 -0400 Subject: [PATCH 548/551] Revert "Merge pull request #3253 from niklaslong/perf/rest" This reverts commit 9cc67c91090286d434037a70953062018aefd85c, reversing changes made to 01ea4768ed62d3f1933745568f023fadcf15cdf1. Signed-off-by: Fabiano --- node/rest/src/routes.rs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/node/rest/src/routes.rs b/node/rest/src/routes.rs index 422a657018..20ef762911 100644 --- a/node/rest/src/routes.rs +++ b/node/rest/src/routes.rs @@ -135,18 +135,16 @@ impl, R: Routing> Rest { ))); } - // Prepare a closure for the blocking work. - let get_json_blocks = move || -> Result { - let blocks = cfg_into_iter!((start_height..end_height)) + // Fetch the blocks from ledger. + match tokio::task::spawn_blocking(move || { + cfg_into_iter!((start_height..end_height)) .map(|height| rest.ledger.get_block(height)) - .collect::, _>>()?; - - Ok(ErasedJson::pretty(blocks)) - }; - - // Fetch the blocks from ledger and serialize to json. - match tokio::task::spawn_blocking(get_json_blocks).await { - Ok(json) => json, + .collect::, _>>() + }) + .await + { + Ok(Ok(blocks)) => Ok(ErasedJson::pretty(blocks)), + Ok(Err(err)) => Err(RestError(format!("Failed to get blocks '{start_height}..{end_height}' - {err}"))), Err(err) => Err(RestError(format!("Failed to get blocks '{start_height}..{end_height}' - {err}"))), } } From d7097badf2ebea1a938646f3461aa418e4b14fe4 Mon Sep 17 00:00:00 2001 From: Fabiano Prestes Date: Thu, 23 May 2024 21:37:47 -0400 Subject: [PATCH 549/551] Revert "Avoid unnecessary calculations in propose_batch" --- node/bft/src/primary.rs | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 6cc84122f8..05069d2aa4 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -342,9 +342,6 @@ impl Primary { // Compute the previous round. let previous_round = round.saturating_sub(1); - // If the current round is 0, return early. - ensure!(round > 0, "Round 0 cannot have transaction batches"); - // If the current storage round is below the latest proposal round, then return early. if round < *lock_guard { warn!("Cannot propose a batch for round {round} - the latest proposal cache round is {}", *lock_guard); @@ -422,16 +419,6 @@ impl Primary { return Ok(()); } - // Determine if the current round has been proposed. - // Note: Do NOT make this judgment in advance before rebroadcast and round update. Rebroadcasting is - // good for network reliability and should not be prevented for the already existing proposed_batch. - // If a certificate already exists for the current round, an attempt should be made to advance the - // round as early as possible. - if round == *lock_guard { - warn!("Primary is safely skipping a batch proposal - round {round} already proposed"); - return Ok(()); - } - // Retrieve the committee to check against. let committee_lookback = self.ledger.get_committee_lookback_for_round(round)?; // Check if the primary is connected to enough validators to reach quorum threshold. @@ -540,9 +527,17 @@ impl Primary { } } } - + // Ditto if the batch had already been proposed and not expired. + ensure!(round > 0, "Round 0 cannot have transaction batches"); // Determine the current timestamp. let current_timestamp = now(); + // Determine if the current proposal is expired. + if *lock_guard == round { + warn!("Primary is safely skipping a batch proposal - round {round} already proposed"); + // Reinsert the transmissions back into the ready queue for the next proposal. + self.reinsert_transmissions_into_workers(transmissions)?; + return Ok(()); + } *lock_guard = round; From 2a93f55ba7abc4de050c2946bf8bee0b0d78db3b Mon Sep 17 00:00:00 2001 From: Fabiano Prestes Date: Fri, 24 May 2024 14:16:15 -0400 Subject: [PATCH 550/551] Bump snarkVM rev - 393b8fb Point to hotfix commit SnarkVM PR 2464 https://github.com/AleoNet/snarkVM/pull/2464 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 3b385228d3..0850fd57db 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoNet/snarkVM.git" -rev = "140ff26" +rev = "393b8fb" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ] From 1137c1f38613300979565937b73194fe98e6feed Mon Sep 17 00:00:00 2001 From: Fabiano Prestes Date: Fri, 24 May 2024 20:50:03 -0400 Subject: [PATCH 551/551] Bump to mainnet snarkVM rev - fddd8b9 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 0850fd57db..c2c1ada9bf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ default-features = false [workspace.dependencies.snarkvm] git = "https://github.com/AleoNet/snarkVM.git" -rev = "393b8fb" +rev = "fddd8b9" #version = "=0.16.18" features = [ "circuit", "console", "rocks" ]