From d1b7a8f7e23d2585cc57d2f6ffda8be16bb08ba0 Mon Sep 17 00:00:00 2001 From: Maciej Zwolinski Date: Wed, 12 Oct 2022 11:50:13 +0200 Subject: [PATCH] Fix compilation without 'parallel' feature Signed-off-by: Maciej Zwolinski --- Cargo.toml | 3 +++ vm/compiler/src/ledger/mod.rs | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 89b615f6b6..9d3020e7c4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -114,6 +114,7 @@ cuda = [ "snarkvm-algorithms/cuda" ] parameters_no_std_out = [ "snarkvm-parameters/no_std_out" ] parallel = [ "rayon", + "snarkvm-algorithms/parallel", "snarkvm-compiler/parallel", "snarkvm-fields/parallel", "snarkvm-utilities/parallel" @@ -124,6 +125,7 @@ noconfig = [ ] path = "./algorithms" version = "0.9.0" optional = true +default-features = false [dependencies.snarkvm-circuit] path = "./circuit" @@ -168,6 +170,7 @@ optional = true [dependencies.snarkvm-compiler] path = "./vm/compiler" version = "0.9.0" +default-features = false [dependencies.anyhow] version = "1.0.64" diff --git a/vm/compiler/src/ledger/mod.rs b/vm/compiler/src/ledger/mod.rs index a8d818c6ed..e73088665b 100644 --- a/vm/compiler/src/ledger/mod.rs +++ b/vm/compiler/src/ledger/mod.rs @@ -218,7 +218,11 @@ impl, P: ProgramStorage> Ledger { ledger.block_tree.append(&hashes)?; // Safety check the existence of every block. - (0..=latest_height).into_par_iter().try_for_each(|height| { + #[cfg(feature = "parallel")] + let heights_iter = (0..=latest_height).into_par_iter(); + #[cfg(not(feature = "parallel"))] + let mut heights_iter = (0..=latest_height).into_iter(); + heights_iter.try_for_each(|height| { ledger.get_block(height)?; Ok::<_, Error>(()) })?; @@ -467,7 +471,11 @@ impl, P: ProgramStorage> Ledger { } // Ensure each transaction is well-formed and unique. - if !block.transactions().par_iter().all(|(_, transaction)| self.check_transaction(transaction).is_ok()) { + #[cfg(feature = "parallel")] + let transactions_iter = block.transactions().par_iter(); + #[cfg(not(feature = "parallel"))] + let mut transactions_iter = block.transactions().iter(); + if !transactions_iter.all(|(_, transaction)| self.check_transaction(transaction).is_ok()) { bail!("Invalid transaction found in the transactions list"); }