Skip to content

Commit

Permalink
Add missing serial flags & replace default flags where necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
iamalwaysuncomfortable committed Mar 21, 2023
1 parent a4d1ecf commit 820aeec
Show file tree
Hide file tree
Showing 14 changed files with 65 additions and 34 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion algorithms/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ harness = false
[dependencies.snarkvm-curves]
path = "../curves"
version = "0.9.14"
default-features = false

[dependencies.snarkvm-fields]
path = "../fields"
Expand All @@ -60,6 +61,7 @@ optional = true
[dependencies.snarkvm-r1cs]
path = "../r1cs"
version = "0.9.14"
default-features = false

[dependencies.snarkvm-utilities]
path = "../utilities"
Expand Down Expand Up @@ -155,7 +157,12 @@ features = [ "preserve_order" ]
version = "1.0"

[features]
default = [ "full" ]
default = [
"full",
"snarkvm-curves/default",
"snarkvm-fields/default",
"snarkvm-utilities/default"
]
full = [ "crypto_hash", "fft", "msm", "polycommit_full", "snark" ]
wasm = [
"crypto_hash",
Expand Down
1 change: 1 addition & 0 deletions algorithms/examples/msm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use snarkvm_utilities::{
};

use anyhow::Result;
#[cfg(not(feature = "serial"))]
use rayon::prelude::*;

const DEFAULT_POWER_OF_TWO: usize = 20;
Expand Down
4 changes: 3 additions & 1 deletion circuit/algorithms/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ default-features = false

[dev-dependencies.snarkvm-curves]
path = "../../curves"
default-features = false

[dev-dependencies.snarkvm-utilities]
path = "../../utilities"
default-features = false

[dev-dependencies.anyhow]
version = "1.0.69"

[features]
default = [ "enable_console" ]
enable_console = [ "console" ]
enable_console = [ "console" ]
11 changes: 7 additions & 4 deletions circuit/environment/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ package = "snarkvm-console-network"
path = "../../console/network"
version = "0.9.14"

[dev-dependencies.snarkvm-algorithms]
path = "../../algorithms"
features = [ "polycommit_full", "snark" ]

[dependencies.snarkvm-circuit-environment-witness]
path = "./witness"
version = "0.9.14"
Expand Down Expand Up @@ -56,10 +60,6 @@ version = "0.2"
[dependencies.once_cell]
version = "1.17.1"

[dev-dependencies.snarkvm-algorithms]
path = "../../algorithms"
features = [ "polycommit_full", "snark" ]

[dev-dependencies.snarkvm-circuit]
path = "../../circuit"

Expand All @@ -68,3 +68,6 @@ path = "../../console/types"

[dev-dependencies.criterion]
version = "0.4"

[features]
default = [ "snarkvm-curves/default" ]
1 change: 1 addition & 0 deletions circuit/types/group/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ version = "0.9.14"

[dev-dependencies.snarkvm-utilities]
path = "../../../utilities"
default-features = false

[features]
default = [ "enable_console" ]
Expand Down
4 changes: 1 addition & 3 deletions console/algorithms/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,14 @@ version = "0.9.14"
[dependencies.blake2s_simd]
version = "1.0"

[dependencies.rayon]
version = "1"

[dependencies.smallvec]
version = "1.10"
default-features = false
features = [ "const_generics", "const_new" ]

[dev-dependencies.snarkvm-curves]
path = "../../curves"
default-features = false

[dev-dependencies.criterion]
version = "0.4.0"
Expand Down
1 change: 1 addition & 0 deletions console/collections/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ path = "../network"
version = "0.4.0"

[features]
serial = [ ]
timer = [ "aleo-std/timer" ]
2 changes: 1 addition & 1 deletion curves/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ rustc_version = "0.4"

[features]
default = [ "snarkvm-fields/default", "snarkvm-utilities/default" ]
serial = [ "snarkvm-fields/serial", "snarkvm-utilities/default-serial" ]
serial = [ ]
2 changes: 1 addition & 1 deletion fields/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ version = "1.0"
[features]
default = [ "snarkvm-utilities/default" ]
profiler = [ "aleo-std/profiler" ]
serial = [ "snarkvm-utilities/default-serial" ]
serial = [ ]
1 change: 1 addition & 0 deletions parameters/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ optional = true

[dev-dependencies.snarkvm-algorithms]
path = "../algorithms"
default-features = false

[dev-dependencies.snarkvm-circuit]
path = "../circuit"
Expand Down
4 changes: 4 additions & 0 deletions synthesizer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ required-features = [ "setup" ]
default = [ ]
aleo-cli = [ ]
cuda = [ "snarkvm-algorithms/cuda" ]
serial = [ ]
setup = [ ]
timer = [ "aleo-std/timer" ]
wasm = [ ]
Expand Down Expand Up @@ -87,6 +88,9 @@ version = "2"
version = "1.9"
features = [ "serde", "rayon" ]

[dependencies.itertools]
version = "0.10.1"

[dependencies.once_cell]
version = "1.17"

Expand Down
53 changes: 34 additions & 19 deletions synthesizer/src/block/transactions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,63 +66,78 @@ impl<'a, N: Network> FromIterator<&'a Transaction<N>> for Transactions<N> {
impl<N: Network> Transactions<N> {
/// Returns `true` if the transactions contains the given transition ID.
pub fn contains_transition(&self, transition_id: &N::TransitionID) -> bool {
match cfg!(feature = "serial") {
false => self.par_values().any(|tx| tx.contains_transition(transition_id)),
true => self.values().any(|tx| tx.contains_transition(transition_id)),
}
cfg_values!(self).any(|tx| tx.contains_transition(transition_id))
}

/// Returns `true` if the transactions contains the given serial number.
pub fn contains_serial_number(&self, serial_number: &Field<N>) -> bool {
match cfg!(feature = "serial") {
false => self.par_values().any(|tx| tx.contains_serial_number(serial_number)),
true => self.values().any(|tx| tx.contains_serial_number(serial_number)),
}
cfg_values!(self).any(|tx| tx.contains_serial_number(serial_number))
}

/// Returns `true` if the transactions contains the given commitment.
pub fn contains_commitment(&self, commitment: &Field<N>) -> bool {
match cfg!(feature = "serial") {
false => self.par_values().any(|tx| tx.contains_commitment(commitment)),
true => self.values().any(|tx| tx.contains_commitment(commitment)),
}
cfg_values!(self).any(|tx| tx.contains_commitment(commitment))
}
}

impl<N: Network> Transactions<N> {
/// Returns the transaction with the given transition ID, if it exists.
pub fn find_transaction_for_transition_id(&self, transition_id: &N::TransitionID) -> Option<&Transaction<N>> {
cfg_values!(self).find_any(|tx| tx.contains_transition(transition_id))
#[cfg(not(feature = "serial"))]
return self.par_values().find_any(|tx| tx.contains_transition(transition_id));
#[cfg(feature = "serial")]
self.values().find(|tx| tx.contains_transition(transition_id))
}

/// Returns the transaction with the given serial number, if it exists.
pub fn find_transaction_for_serial_number(&self, serial_number: &Field<N>) -> Option<&Transaction<N>> {
cfg_values!(self).find_any(|tx| tx.contains_serial_number(serial_number))
#[cfg(not(feature = "serial"))]
return self.par_values().find_any(|tx| tx.contains_serial_number(serial_number));
#[cfg(feature = "serial")]
self.values().find(|tx| tx.contains_serial_number(serial_number))
}

/// Returns the transaction with the given commitment, if it exists.
pub fn find_transaction_for_commitment(&self, commitment: &Field<N>) -> Option<&Transaction<N>> {
cfg_values!(self).find_any(|tx| tx.contains_commitment(commitment))
#[cfg(not(feature = "serial"))]
return self.par_values().find_any(|tx| tx.contains_commitment(commitment));
#[cfg(feature = "serial")]
self.values().find(|tx| tx.contains_commitment(commitment))
}

/// Returns the transition with the corresponding transition ID, if it exists.
pub fn find_transition(&self, transition_id: &N::TransitionID) -> Option<&Transition<N>> {
cfg_values!(self).filter_map(|tx| tx.find_transition(transition_id)).find_any(|_| true)
#[cfg(not(feature = "serial"))]
return self.par_values().filter_map(|tx| tx.find_transition(transition_id)).find_any(|_| true);
#[cfg(feature = "serial")]
self.values().find_map(|tx| tx.find_transition(transition_id))
}

/// Returns the transition for the given serial number, if it exists.
pub fn find_transition_for_serial_number(&self, serial_number: &Field<N>) -> Option<&Transition<N>> {
cfg_values!(self).filter_map(|tx| tx.find_transition_for_serial_number(serial_number)).find_any(|_| true)
#[cfg(not(feature = "serial"))]
return self
.par_values()
.filter_map(|tx| tx.find_transition_for_serial_number(serial_number))
.find_any(|_| true);
#[cfg(feature = "serial")]
self.values().find_map(|tx| tx.find_transition_for_serial_number(serial_number))
}

/// Returns the transition for the given commitment, if it exists.
pub fn find_transition_for_commitment(&self, commitment: &Field<N>) -> Option<&Transition<N>> {
cfg_values!(self).filter_map(|tx| tx.find_transition_for_commitment(commitment)).find_any(|_| true)
#[cfg(not(feature = "serial"))]
return self.par_values().filter_map(|tx| tx.find_transition_for_commitment(commitment)).find_any(|_| true);
#[cfg(feature = "serial")]
self.values().find_map(|tx| tx.find_transition_for_commitment(commitment))
}

/// Returns the record with the corresponding commitment, if it exists.
pub fn find_record(&self, commitment: &Field<N>) -> Option<&Record<N, Ciphertext<N>>> {
cfg_values!(self).filter_map(|tx| tx.find_record(commitment)).find_any(|_| true)
#[cfg(not(feature = "serial"))]
return self.par_values().filter_map(|tx| tx.find_record(commitment)).find_any(|_| true);
#[cfg(feature = "serial")]
self.values().find_map(|tx| tx.find_record(commitment))
}
}

Expand Down
4 changes: 1 addition & 3 deletions utilities/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ features = [ "getrandom", "std_rng" ]

[dependencies.rayon]
version = "1"
optional = true

[dependencies.serde]
version = "1.0"
Expand All @@ -70,8 +69,7 @@ version = "0.3"
default-features = false

[features]
default = [ "aleo-std/cpu", "derive", "num_cpus", "rayon", "std"]
default-serial = [ "derive", "serial", "std" ]
default = [ "aleo-std/cpu", "derive", "num_cpus", "std"]
serial = [ ]
std = [ ]
derive = [ "snarkvm-utilities-derives" ]

0 comments on commit 820aeec

Please sign in to comment.