Migrates to hot 1.1.4 and adds memory usage improvements for programs

This commit is contained in:
howardwu 2020-12-30 11:32:10 -04:00
parent b7f2790247
commit 1d9215a1ac
15 changed files with 134 additions and 96 deletions

53
Cargo.lock generated
View File

@ -884,6 +884,15 @@ dependencies = [
"slab",
]
[[package]]
name = "fxhash"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c"
dependencies = [
"byteorder",
]
[[package]]
name = "generator"
version = "0.6.23"
@ -2250,9 +2259,9 @@ dependencies = [
[[package]]
name = "rocksdb"
version = "0.13.0"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12069b106981c6103d3eab7dd1c86751482d0779a520b7c14954c8b586c1e643"
checksum = "23d83c02c429044d58474eaf5ae31e062d0de894e21125b47437ec0edc1397e6"
dependencies = [
"libc",
"librocksdb-sys",
@ -2538,8 +2547,7 @@ checksum = "ae524f056d7d770e174287294f562e95044c68e88dec909a00d2094805db9d75"
[[package]]
name = "snarkos-algorithms"
version = "1.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb07037b1575665f3a727ef444c513b4727dda85378c5eba26b4c881bc3046e8"
source = "git+https://github.com/AleoHQ/snarkOS.git#e4a58781a94ba2ffc5aac1ca487e1fb28414bfc9"
dependencies = [
"blake2",
"derivative",
@ -2559,8 +2567,7 @@ dependencies = [
[[package]]
name = "snarkos-curves"
version = "1.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3aee88d337863483d07cd91e5dbc1c12de1375c1a133c49fe18f771924a80d6e"
source = "git+https://github.com/AleoHQ/snarkOS.git#e4a58781a94ba2ffc5aac1ca487e1fb28414bfc9"
dependencies = [
"derivative",
"rand",
@ -2575,8 +2582,7 @@ dependencies = [
[[package]]
name = "snarkos-derives"
version = "1.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8f6ce35f9f73c13e5381c6938747935ca105e22717998489c3e5ddb8c13120d"
source = "git+https://github.com/AleoHQ/snarkOS.git#e4a58781a94ba2ffc5aac1ca487e1fb28414bfc9"
dependencies = [
"proc-macro2 1.0.24",
"quote 1.0.7",
@ -2586,8 +2592,7 @@ dependencies = [
[[package]]
name = "snarkos-dpc"
version = "1.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51ecd7bcea91bbae1e636949b32908df2c674b7381387beadde364d6a3af6ad0"
source = "git+https://github.com/AleoHQ/snarkOS.git#e4a58781a94ba2ffc5aac1ca487e1fb28414bfc9"
dependencies = [
"blake2",
"derivative",
@ -2608,8 +2613,7 @@ dependencies = [
[[package]]
name = "snarkos-errors"
version = "1.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df927c3b41badf8a8479dd6b23340e4799bec44abb7a479cb253d912e888a1ca"
source = "git+https://github.com/AleoHQ/snarkOS.git#e4a58781a94ba2ffc5aac1ca487e1fb28414bfc9"
dependencies = [
"base58",
"bech32",
@ -2625,8 +2629,7 @@ dependencies = [
[[package]]
name = "snarkos-gadgets"
version = "1.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f4bded425072f394dacf206323bcd3d2e199d6ec5f7ced3c36fb77f7d22300b"
source = "git+https://github.com/AleoHQ/snarkOS.git#e4a58781a94ba2ffc5aac1ca487e1fb28414bfc9"
dependencies = [
"derivative",
"digest 0.8.1",
@ -2641,16 +2644,17 @@ dependencies = [
[[package]]
name = "snarkos-models"
version = "1.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38d90d4fd9030e69dcbca1f7eaea3f14c08653f0f06600f42c2022e8cf72f82d"
source = "git+https://github.com/AleoHQ/snarkOS.git#e4a58781a94ba2ffc5aac1ca487e1fb28414bfc9"
dependencies = [
"bincode",
"cfg-if 0.1.10",
"derivative",
"fxhash",
"indexmap",
"itertools 0.9.0",
"rand",
"rand_xorshift",
"serde",
"smallvec",
"snarkos-errors",
"snarkos-utilities",
]
@ -2658,8 +2662,7 @@ dependencies = [
[[package]]
name = "snarkos-objects"
version = "1.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5ec3bdfbe179a157d1484e11ec65fdd3d2bf377ad1a7695753c5f613a57a790"
source = "git+https://github.com/AleoHQ/snarkOS.git#e4a58781a94ba2ffc5aac1ca487e1fb28414bfc9"
dependencies = [
"base58",
"bech32",
@ -2680,8 +2683,7 @@ dependencies = [
[[package]]
name = "snarkos-parameters"
version = "1.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8d7634a5cd35a680b81d58dbd842ee38413e81cd9ad6b8317cd93f84c9513c3"
source = "git+https://github.com/AleoHQ/snarkOS.git#e4a58781a94ba2ffc5aac1ca487e1fb28414bfc9"
dependencies = [
"curl",
"hex",
@ -2694,14 +2696,12 @@ dependencies = [
[[package]]
name = "snarkos-profiler"
version = "1.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0519c9371650425e332e3971ecfc691fbd1c67e03be15c20aba89ac8242ea2b"
source = "git+https://github.com/AleoHQ/snarkOS.git#e4a58781a94ba2ffc5aac1ca487e1fb28414bfc9"
[[package]]
name = "snarkos-storage"
version = "1.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c31a1de407b5d19365e0463ecf4536725055f7b3c52dbe350e153386303eeea"
source = "git+https://github.com/AleoHQ/snarkOS.git#e4a58781a94ba2ffc5aac1ca487e1fb28414bfc9"
dependencies = [
"bincode",
"hex",
@ -2720,8 +2720,7 @@ dependencies = [
[[package]]
name = "snarkos-utilities"
version = "1.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f6e1ccf791ace8d28266d3067d0bf93e3a0c1beafa472f186f55866fe8a7d73"
source = "git+https://github.com/AleoHQ/snarkOS.git#e4a58781a94ba2ffc5aac1ca487e1fb28414bfc9"
dependencies = [
"bincode",
"rand",

View File

@ -69,27 +69,33 @@ path = "./state"
version = "1.0.7"
[dependencies.snarkos-algorithms]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
default-features = false
[dependencies.snarkos-curves]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
default-features = false
[dependencies.snarkos-errors]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
default-features = false
[dependencies.snarkos-gadgets]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
default-features = false
[dependencies.snarkos-models]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
default-features = false
[dependencies.snarkos-utilities]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
[dependencies.clap]
version = "2.33.3"

View File

@ -35,11 +35,13 @@ path = "../input"
version = "1.0.7"
[dependencies.snarkos-errors]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
default-features = false
[dependencies.snarkos-models]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
default-features = false
[dependencies.indexmap]

View File

@ -58,31 +58,38 @@ path = "../type-inference"
version = "1.0.7"
[dependencies.snarkos-curves]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
default-features = false
[dependencies.snarkos-dpc]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
default-features = false
[dependencies.snarkos-errors]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
default-features = false
[dependencies.snarkos-gadgets]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
default-features = false
[dependencies.snarkos-models]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
default-features = false
[dependencies.snarkos-objects]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
default-features = false
[dependencies.snarkos-utilities]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
[dependencies.bincode]
version = "1.0"
@ -123,7 +130,8 @@ version = "0.2"
version = "0.3"
[dev-dependencies.snarkos-algorithms]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
default-features = false
[features]

View File

@ -303,7 +303,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> Compiler<F, G> {
pub fn compile_constraints<CS: ConstraintSystem<F>>(self, cs: &mut CS) -> Result<OutputBytes, CompilerError> {
let path = self.main_file_path;
generate_constraints::<F, G, CS>(cs, self.program, self.program_input, &self.imported_programs).map_err(
generate_constraints::<F, G, CS>(cs, &self.program, &self.program_input, &self.imported_programs).map_err(
|mut error| {
error.set_path(&path);
@ -329,11 +329,11 @@ impl<F: Field + PrimeField, G: GroupType<F>> Compiler<F, G> {
/// Calls the internal generate_constraints method with arguments.
///
pub fn generate_constraints_helper<CS: ConstraintSystem<F>>(
self,
&self,
cs: &mut CS,
) -> Result<OutputBytes, CompilerError> {
let path = self.main_file_path;
generate_constraints::<_, G, _>(cs, self.program, self.program_input, &self.imported_programs).map_err(
let path = &self.main_file_path;
generate_constraints::<_, G, _>(cs, &self.program, &self.program_input, &self.imported_programs).map_err(
|mut error| {
error.set_path(&path);
error
@ -346,7 +346,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstraintSynthesizer<F> for Compil
///
/// Synthesizes the circuit with program input.
///
fn generate_constraints<CS: ConstraintSystem<F>>(self, cs: &mut CS) -> Result<(), SynthesisError> {
fn generate_constraints<CS: ConstraintSystem<F>>(&self, cs: &mut CS) -> Result<(), SynthesisError> {
let output_directory = self.output_directory.clone();
let package_name = self.package_name.clone();
let result = self.generate_constraints_helper(cs).map_err(|e| {

View File

@ -38,15 +38,15 @@ use std::path::Path;
pub fn generate_constraints<F: Field + PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
cs: &mut CS,
program: Program,
input: Input,
program: &Program,
input: &Input,
imported_programs: &ImportParser,
) -> Result<OutputBytes, CompilerError> {
let mut resolved_program = ConstrainedProgram::<F, G>::new();
let program_name = program.get_name();
let main_function_name = new_scope(&program_name, "main");
resolved_program.store_definitions(&program, imported_programs)?;
resolved_program.store_definitions(program, imported_programs)?;
let main = resolved_program.get(&main_function_name).ok_or(CompilerError::NoMain)?;
@ -120,7 +120,7 @@ pub fn generate_test_constraints<F: Field + PrimeField, G: GroupType<F>>(
cs,
&program_name,
test.function,
input, // pass program input into every test
&input, // pass program input into every test
);
match (result.is_ok(), cs.is_satisfied()) {

View File

@ -36,7 +36,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
cs: &mut CS,
scope: &str,
function: Function,
input: Input,
input: &Input,
) -> Result<OutputBytes, FunctionError> {
let function_name = new_scope(scope, function.get_name());
let registers = input.get_registers();
@ -47,7 +47,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
let (input_id, value) = match input_model {
FunctionInput::InputKeyword(keyword) => {
let input_id = Identifier::new_with_span(&keyword.to_string(), &keyword.span);
let value = self.allocate_input_keyword(cs, keyword, &input)?;
let value = self.allocate_input_keyword(cs, keyword, input)?;
(input_id, value)
}

View File

@ -26,19 +26,23 @@ path = "../gadgets"
version = "1.0.7"
[dependencies.snarkos-errors]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
default-features = false
[dependencies.snarkos-gadgets]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
default-features = false
[dependencies.snarkos-models]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
default-features = false
[dependencies.snarkos-utilities]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
[dependencies.rand]
version = "0.7"
@ -52,8 +56,10 @@ default-features = false
version = "1.0"
[dev-dependencies.snarkos-utilities]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
[dev-dependencies.snarkos-curves]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
default-features = false

View File

@ -18,15 +18,18 @@ license = "GPL-3.0"
edition = "2018"
[dependencies.snarkos-errors]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
default-features = false
[dependencies.snarkos-models]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
default-features = false
[dependencies.snarkos-utilities]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
[dependencies.rand]
version = "0.7"
@ -40,7 +43,8 @@ default-features = false
version = "1.0"
[dev-dependencies.snarkos-utilities]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
[dev-dependencies.criterion]
version = "0.3"

View File

@ -18,23 +18,28 @@ license = "GPL-3.0"
edition = "2018"
[dependencies.snarkos-algorithms]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
default-features = false
[dependencies.snarkos-curves]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
default-features = false
[dependencies.snarkos-errors]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
default-features = false
[dependencies.snarkos-gadgets]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
default-features = false
[dependencies.snarkos-models]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
default-features = false
[dependencies.from-pest]

View File

@ -62,7 +62,7 @@ impl CLI for ProveCommand {
let start = Instant::now();
let rng = &mut thread_rng();
let program_proof = Groth16::<Bls12_377, _, Vec<Fr>>::prove(&parameters, program, rng)?;
let program_proof = Groth16::<Bls12_377, _, Vec<Fr>>::prove(&parameters, &program, rng)?;
// Finish the timer
let end = start.elapsed().as_millis();

View File

@ -85,7 +85,7 @@ impl CLI for SetupCommand {
// Run the program setup operation
let rng = &mut thread_rng();
let (proving_key, prepared_verifying_key) =
Groth16::<Bls12_377, Compiler<Fr, _>, Vec<Fr>>::setup(program.clone(), rng).unwrap();
Groth16::<Bls12_377, Compiler<Fr, _>, Vec<Fr>>::setup(&program, rng).unwrap();
// End the timer
let end = setup_start.elapsed().as_millis();

View File

@ -39,7 +39,7 @@ impl<E: PairingEngine> ConstraintSystem<E::Fr> for CircuitSynthesizer<E> {
where
F: FnOnce() -> Result<E::Fr, SynthesisError>,
A: FnOnce() -> AR,
AR: Into<String>,
AR: AsRef<str>,
{
let index = self.aux_assignment.len();
self.aux_assignment.push(f()?);
@ -51,7 +51,7 @@ impl<E: PairingEngine> ConstraintSystem<E::Fr> for CircuitSynthesizer<E> {
where
F: FnOnce() -> Result<E::Fr, SynthesisError>,
A: FnOnce() -> AR,
AR: Into<String>,
AR: AsRef<str>,
{
let index = self.input_assignment.len();
self.input_assignment.push(f()?);
@ -62,7 +62,7 @@ impl<E: PairingEngine> ConstraintSystem<E::Fr> for CircuitSynthesizer<E> {
fn enforce<A, AR, LA, LB, LC>(&mut self, _: A, a: LA, b: LB, c: LC)
where
A: FnOnce() -> AR,
AR: Into<String>,
AR: AsRef<str>,
LA: FnOnce(LinearCombination<E::Fr>) -> LinearCombination<E::Fr>,
LB: FnOnce(LinearCombination<E::Fr>) -> LinearCombination<E::Fr>,
LC: FnOnce(LinearCombination<E::Fr>) -> LinearCombination<E::Fr>,
@ -82,7 +82,7 @@ impl<E: PairingEngine> ConstraintSystem<E::Fr> for CircuitSynthesizer<E> {
fn push_namespace<NR, N>(&mut self, _: N)
where
NR: Into<String>,
NR: AsRef<str>,
N: FnOnce() -> NR,
{
// Do nothing; we don't care about namespaces in this context.

View File

@ -26,31 +26,38 @@ path = "../ast"
version = "1.0.7"
[dependencies.snarkos-algorithms]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
default-features = false
[dependencies.snarkos-curves]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
default-features = false
[dependencies.snarkos-dpc]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
default-features = false
[dependencies.snarkos-errors]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
default-features = false
[dependencies.snarkos-models]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
default-features = false
[dependencies.snarkos-objects]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
default-features = false
[dependencies.snarkos-utilities]
version = "1.1.3"
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"
[dependencies.indexmap]
version = "1.6.1"
@ -66,4 +73,5 @@ version = "0.2"
version = "1.0"
[dev-dependencies.snarkos-storage]
git = "https://github.com/AleoHQ/snarkOS.git"
version = "1.1.4"

View File

@ -98,14 +98,14 @@ fn test_generate_values_from_dpc() {
let payload: [u8; 32] = rng.gen();
let old_record = DPC::generate_record(
&system_parameters,
&sn_nonce,
&dummy_account.address,
system_parameters.clone(),
sn_nonce,
dummy_account.address,
false,
value,
&RecordPayload::from_bytes(&payload),
&noop_program_id,
&noop_program_id,
RecordPayload::from_bytes(&payload),
noop_program_id.clone(),
noop_program_id.clone(),
&mut rng,
)
.unwrap();
@ -137,16 +137,16 @@ fn test_generate_values_from_dpc() {
let memo = [0u8; 32];
let context = <InstantiatedDPC as DPCScheme<L>>::execute_offline(
&system_parameters,
&old_records,
&old_account_private_keys,
&new_record_owners,
system_parameters.clone(),
old_records,
old_account_private_keys,
new_record_owners,
&new_is_dummy_flags,
&new_values,
&new_payloads,
&new_birth_program_ids,
&new_death_program_ids,
&memo,
new_payloads,
new_birth_program_ids,
new_death_program_ids,
memo,
network_id,
&mut rng,
)