From cf9d903a2a5fa3163dcc7d61cc4ce0e9a92890e9 Mon Sep 17 00:00:00 2001 From: collin Date: Tue, 16 Jun 2020 19:18:02 -0700 Subject: [PATCH 1/6] remove reserved characters --- Cargo.lock | 98 ------------------- ...false_&&_false.leo => false_and_false.leo} | 0 ...{false_||_false.leo => false_or_false.leo} | 0 compiler/tests/boolean/mod.rs | 16 +-- .../{true_&&_false.leo => true_and_false.leo} | 0 .../{true_&&_true.leo => true_and_true.leo} | 0 .../{true_&&_u32.leo => true_and_u32.leo} | 0 .../{true_||_false.leo => true_or_false.leo} | 0 .../{true_||_true.leo => true_or_true.leo} | 0 .../{true_||_u32.leo => true_or_u32.leo} | 0 10 files changed, 8 insertions(+), 106 deletions(-) rename compiler/tests/boolean/{false_&&_false.leo => false_and_false.leo} (100%) rename compiler/tests/boolean/{false_||_false.leo => false_or_false.leo} (100%) rename compiler/tests/boolean/{true_&&_false.leo => true_and_false.leo} (100%) rename compiler/tests/boolean/{true_&&_true.leo => true_and_true.leo} (100%) rename compiler/tests/boolean/{true_&&_u32.leo => true_and_u32.leo} (100%) rename compiler/tests/boolean/{true_||_false.leo => true_or_false.leo} (100%) rename compiler/tests/boolean/{true_||_true.leo => true_or_true.leo} (100%) rename compiler/tests/boolean/{true_||_u32.leo => true_or_u32.leo} (100%) diff --git a/Cargo.lock b/Cargo.lock index cc730ede97..f1264d6c01 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,30 +74,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bindgen" -version = "0.53.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c72a978d268b1d70b0e963217e60fdabd9523a941457a6c42a7315d15c7e89e5" -dependencies = [ - "bitflags", - "cexpr", - "cfg-if", - "clang-sys", - "clap", - "env_logger", - "lazy_static", - "lazycell", - "log", - "peeking_take_while", - "proc-macro2 1.0.18", - "quote 1.0.7", - "regex", - "rustc-hash", - "shlex", - "which", -] - [[package]] name = "bitflags" version = "1.2.1" @@ -161,24 +137,6 @@ version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" -[[package]] -name = "cc" -version = "1.0.54" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bbb73db36c1246e9034e307d0fba23f9a2e251faa47ade70c1bd252220c8311" -dependencies = [ - "jobserver", -] - -[[package]] -name = "cexpr" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4aedb84272dbe89af497cf81375129abda4fc0a9e7c5d317498c15cc30c0d27" -dependencies = [ - "nom", -] - [[package]] name = "cfg-if" version = "0.1.10" @@ -431,12 +389,6 @@ version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bcc8e0c9bce37868955864dbecd2b1ab2bdf967e6f28066d65aaac620444b65c" -[[package]] -name = "glob" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" - [[package]] name = "hermit-abi" version = "0.1.14" @@ -485,15 +437,6 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e" -[[package]] -name = "jobserver" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c71313ebb9439f74b00d9d2dcec36440beaf57a6aa0623068441dd7cd81a7f2" -dependencies = [ - "libc", -] - [[package]] name = "jsonrpc-core" version = "14.2.0" @@ -655,16 +598,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab250442c86f1850815b5d268639dff018c0627022bc1940eb2d642ca1ce12f0" -[[package]] -name = "nom" -version = "5.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af" -dependencies = [ - "memchr", - "version_check", -] - [[package]] name = "num_cpus" version = "1.13.0" @@ -687,31 +620,6 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" -[[package]] -name = "openssl-probe" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" - -[[package]] -name = "openssl-sys" -version = "0.9.58" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a842db4709b604f0fe5d1170ae3565899be2ad3d9cbc72dedc789ac0511f78de" -dependencies = [ - "autocfg", - "cc", - "libc", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "peeking_take_while" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" - [[package]] name = "pest" version = "2.1.3" @@ -1243,12 +1151,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" -[[package]] -name = "vcpkg" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6454029bf181f092ad1b853286f23e2c507d8e8194d01d92da4a55c274a5508c" - [[package]] name = "vec_map" version = "0.8.2" diff --git a/compiler/tests/boolean/false_&&_false.leo b/compiler/tests/boolean/false_and_false.leo similarity index 100% rename from compiler/tests/boolean/false_&&_false.leo rename to compiler/tests/boolean/false_and_false.leo diff --git a/compiler/tests/boolean/false_||_false.leo b/compiler/tests/boolean/false_or_false.leo similarity index 100% rename from compiler/tests/boolean/false_||_false.leo rename to compiler/tests/boolean/false_or_false.leo diff --git a/compiler/tests/boolean/mod.rs b/compiler/tests/boolean/mod.rs index 01b428e755..c08922b168 100644 --- a/compiler/tests/boolean/mod.rs +++ b/compiler/tests/boolean/mod.rs @@ -121,7 +121,7 @@ fn test_not_u32() { #[test] fn test_true_or_true() { - let bytes = include_bytes!("true_||_true.leo"); + let bytes = include_bytes!("true_or_true.leo"); let program = parse_program(bytes).unwrap(); output_true(program); @@ -129,7 +129,7 @@ fn test_true_or_true() { #[test] fn test_true_or_false() { - let bytes = include_bytes!("true_||_false.leo"); + let bytes = include_bytes!("true_or_false.leo"); let program = parse_program(bytes).unwrap(); output_true(program); @@ -137,7 +137,7 @@ fn test_true_or_false() { #[test] fn test_false_or_false() { - let bytes = include_bytes!("false_||_false.leo"); + let bytes = include_bytes!("false_or_false.leo"); let program = parse_program(bytes).unwrap(); output_false(program); @@ -145,7 +145,7 @@ fn test_false_or_false() { #[test] fn test_true_or_u32() { - let bytes = include_bytes!("true_||_u32.leo"); + let bytes = include_bytes!("true_or_u32.leo"); let program = parse_program(bytes).unwrap(); fail_enforce(program); @@ -155,7 +155,7 @@ fn test_true_or_u32() { #[test] fn test_true_and_true() { - let bytes = include_bytes!("true_&&_true.leo"); + let bytes = include_bytes!("true_and_true.leo"); let program = parse_program(bytes).unwrap(); output_true(program); @@ -163,7 +163,7 @@ fn test_true_and_true() { #[test] fn test_true_and_false() { - let bytes = include_bytes!("true_&&_false.leo"); + let bytes = include_bytes!("true_and_false.leo"); let program = parse_program(bytes).unwrap(); output_false(program); @@ -171,7 +171,7 @@ fn test_true_and_false() { #[test] fn test_false_and_false() { - let bytes = include_bytes!("false_&&_false.leo"); + let bytes = include_bytes!("false_and_false.leo"); let program = parse_program(bytes).unwrap(); output_false(program); @@ -179,7 +179,7 @@ fn test_false_and_false() { #[test] fn test_true_and_u32() { - let bytes = include_bytes!("true_&&_u32.leo"); + let bytes = include_bytes!("true_and_u32.leo"); let program = parse_program(bytes).unwrap(); fail_enforce(program); diff --git a/compiler/tests/boolean/true_&&_false.leo b/compiler/tests/boolean/true_and_false.leo similarity index 100% rename from compiler/tests/boolean/true_&&_false.leo rename to compiler/tests/boolean/true_and_false.leo diff --git a/compiler/tests/boolean/true_&&_true.leo b/compiler/tests/boolean/true_and_true.leo similarity index 100% rename from compiler/tests/boolean/true_&&_true.leo rename to compiler/tests/boolean/true_and_true.leo diff --git a/compiler/tests/boolean/true_&&_u32.leo b/compiler/tests/boolean/true_and_u32.leo similarity index 100% rename from compiler/tests/boolean/true_&&_u32.leo rename to compiler/tests/boolean/true_and_u32.leo diff --git a/compiler/tests/boolean/true_||_false.leo b/compiler/tests/boolean/true_or_false.leo similarity index 100% rename from compiler/tests/boolean/true_||_false.leo rename to compiler/tests/boolean/true_or_false.leo diff --git a/compiler/tests/boolean/true_||_true.leo b/compiler/tests/boolean/true_or_true.leo similarity index 100% rename from compiler/tests/boolean/true_||_true.leo rename to compiler/tests/boolean/true_or_true.leo diff --git a/compiler/tests/boolean/true_||_u32.leo b/compiler/tests/boolean/true_or_u32.leo similarity index 100% rename from compiler/tests/boolean/true_||_u32.leo rename to compiler/tests/boolean/true_or_u32.leo From a5a8ba74de36abc09295bb0f96306f52fa7b4876 Mon Sep 17 00:00:00 2001 From: collin Date: Wed, 17 Jun 2020 19:25:13 -0700 Subject: [PATCH 2/6] fix imports --- ast/src/statements/definition_statement.rs | 3 +-- ast/src/statements/multiple_assignment_statement.rs | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ast/src/statements/definition_statement.rs b/ast/src/statements/definition_statement.rs index 93d24de8f3..a3ad1e11e4 100644 --- a/ast/src/statements/definition_statement.rs +++ b/ast/src/statements/definition_statement.rs @@ -1,10 +1,9 @@ use crate::{ ast::Rule, - common::{LineEnd, Variable}, + common::{Declare, LineEnd, Variable}, expressions::Expression, }; -use crate::common::Declare; use pest::Span; use pest_ast::FromPest; use std::fmt; diff --git a/ast/src/statements/multiple_assignment_statement.rs b/ast/src/statements/multiple_assignment_statement.rs index 55582fee4d..f64b811726 100644 --- a/ast/src/statements/multiple_assignment_statement.rs +++ b/ast/src/statements/multiple_assignment_statement.rs @@ -1,10 +1,9 @@ use crate::{ ast::Rule, - common::{Identifier, LineEnd, Variable}, + common::{Declare, Identifier, LineEnd, Variable}, expressions::Expression, }; -use crate::common::Declare; use pest::Span; use pest_ast::FromPest; use std::fmt; From 635d9ff7cbed8d88e5fd3570507c29115c214342 Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Thu, 18 Jun 2020 23:28:49 -0700 Subject: [PATCH 3/6] Add files via upload --- examples/pedersen_hash/inputs/inputs.leo | 1 + 1 file changed, 1 insertion(+) create mode 100644 examples/pedersen_hash/inputs/inputs.leo diff --git a/examples/pedersen_hash/inputs/inputs.leo b/examples/pedersen_hash/inputs/inputs.leo new file mode 100644 index 0000000000..15685c3c69 --- /dev/null +++ b/examples/pedersen_hash/inputs/inputs.leo @@ -0,0 +1 @@ +[main] From e96cc9b4fb15109cc6953f97ef9c021c982a33fd Mon Sep 17 00:00:00 2001 From: Howard Wu <9260812+howardwu@users.noreply.github.com> Date: Fri, 19 Jun 2020 20:57:24 -0700 Subject: [PATCH 4/6] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 7972ef1f4c..7c41acf630 100644 --- a/README.md +++ b/README.md @@ -355,8 +355,10 @@ function main() -> Circ { ## Imports Both struct and function imports are supported. +```leo import all: `*` import alias: `symbol as alias` +``` `src/simple_import.leo` ```rust From 03b59b573b71ab550c0b82be4f000d5c54746c21 Mon Sep 17 00:00:00 2001 From: howardwu Date: Fri, 19 Jun 2020 22:07:02 -0700 Subject: [PATCH 5/6] Update file extensions to new convention --- Cargo.lock | 248 +++++++++++++++++- compiler/src/compiler.rs | 4 +- compiler/tests/function/mod.rs | 1 + compiler/tests/inputs/{inputs.leo => main.in} | 0 ...inputs_fail_name.leo => main_fail_name.in} | 0 ...inputs_fail_type.leo => main_fail_type.in} | 0 .../{inputs_multiple.leo => main_multiple.in} | 0 compiler/tests/inputs/mod.rs | 18 +- compiler/tests/mod.rs | 3 +- examples/pedersen_hash/inputs/inputs.leo | 1 + leo-inputs/src/lib.rs | 6 +- leo/commands/init.rs | 10 +- leo/commands/new.rs | 5 +- leo/commands/prove.rs | 13 +- leo/errors/cli.rs | 3 + leo/errors/files/inputs.rs | 22 ++ leo/errors/files/mod.rs | 3 + leo/files/checksum.rs | 2 +- leo/files/inputs.rs | 52 ++-- leo/files/proof.rs | 2 +- leo/files/proving_key.rs | 2 +- leo/files/verification_key.rs | 2 +- 22 files changed, 338 insertions(+), 59 deletions(-) rename compiler/tests/inputs/{inputs.leo => main.in} (100%) rename compiler/tests/inputs/{inputs_fail_name.leo => main_fail_name.in} (100%) rename compiler/tests/inputs/{inputs_fail_type.leo => main_fail_type.in} (100%) rename compiler/tests/inputs/{inputs_multiple.leo => main_multiple.in} (100%) create mode 100644 examples/pedersen_hash/inputs/inputs.leo create mode 100644 leo/errors/files/inputs.rs diff --git a/Cargo.lock b/Cargo.lock index f1264d6c01..bf956c5e14 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,6 +74,30 @@ dependencies = [ "serde", ] +[[package]] +name = "bindgen" +version = "0.53.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c72a978d268b1d70b0e963217e60fdabd9523a941457a6c42a7315d15c7e89e5" +dependencies = [ + "bitflags", + "cexpr", + "cfg-if", + "clang-sys", + "clap", + "env_logger", + "lazy_static", + "lazycell", + "log", + "peeking_take_while", + "proc-macro2 1.0.18", + "quote 1.0.7", + "regex", + "rustc-hash", + "shlex", + "which", +] + [[package]] name = "bitflags" version = "1.2.1" @@ -137,6 +161,24 @@ version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" +[[package]] +name = "cc" +version = "1.0.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bbb73db36c1246e9034e307d0fba23f9a2e251faa47ade70c1bd252220c8311" +dependencies = [ + "jobserver", +] + +[[package]] +name = "cexpr" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4aedb84272dbe89af497cf81375129abda4fc0a9e7c5d317498c15cc30c0d27" +dependencies = [ + "nom", +] + [[package]] name = "cfg-if" version = "0.1.10" @@ -152,6 +194,17 @@ dependencies = [ "envmnt", ] +[[package]] +name = "clang-sys" +version = "0.29.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe6837df1d5cba2397b835c8530f51723267e16abbf83892e9e5af4f0e5dd10a" +dependencies = [ + "glob", + "libc", + "libloading", +] + [[package]] name = "clap" version = "2.33.1" @@ -236,6 +289,36 @@ dependencies = [ "subtle", ] +[[package]] +name = "curl" +version = "0.4.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "762e34611d2d5233a506a79072be944fddd057db2f18e04c0d6fa79e3fd466fd" +dependencies = [ + "curl-sys", + "libc", + "openssl-probe", + "openssl-sys", + "schannel", + "socket2", + "winapi", +] + +[[package]] +name = "curl-sys" +version = "0.4.31+curl-7.70.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcd62757cc4f5ab9404bc6ca9f0ae447e729a1403948ce5106bd588ceac6a3b0" +dependencies = [ + "cc", + "libc", + "libz-sys", + "openssl-sys", + "pkg-config", + "vcpkg", + "winapi", +] + [[package]] name = "derivative" version = "2.1.1" @@ -389,6 +472,12 @@ version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bcc8e0c9bce37868955864dbecd2b1ab2bdf967e6f28066d65aaac620444b65c" +[[package]] +name = "glob" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" + [[package]] name = "hermit-abi" version = "0.1.14" @@ -437,6 +526,15 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e" +[[package]] +name = "jobserver" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c71313ebb9439f74b00d9d2dcec36440beaf57a6aa0623068441dd7cd81a7f2" +dependencies = [ + "libc", +] + [[package]] name = "jsonrpc-core" version = "14.2.0" @@ -456,6 +554,12 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +[[package]] +name = "lazycell" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" + [[package]] name = "leo" version = "0.1.0" @@ -547,6 +651,40 @@ version = "0.2.71" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9457b06509d27052635f90d6466700c65095fdf75409b3fbdd903e988b886f49" +[[package]] +name = "libloading" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" +dependencies = [ + "cc", + "winapi", +] + +[[package]] +name = "librocksdb-sys" +version = "6.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "883213ae3d09bfc3d104aefe94b25ebb183b6f4d3a515b23b14817e1f4854005" +dependencies = [ + "bindgen", + "cc", + "glob", + "libc", +] + +[[package]] +name = "libz-sys" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2eb5e43362e38e2bca2fd5f5134c4d4564a23a5c28e9b95411652021a8675ebe" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "log" version = "0.4.8" @@ -598,6 +736,16 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab250442c86f1850815b5d268639dff018c0627022bc1940eb2d642ca1ce12f0" +[[package]] +name = "nom" +version = "5.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af" +dependencies = [ + "memchr", + "version_check", +] + [[package]] name = "num_cpus" version = "1.13.0" @@ -620,6 +768,31 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" +[[package]] +name = "openssl-probe" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" + +[[package]] +name = "openssl-sys" +version = "0.9.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a842db4709b604f0fe5d1170ae3565899be2ad3d9cbc72dedc789ac0511f78de" +dependencies = [ + "autocfg", + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" + [[package]] name = "pest" version = "2.1.3" @@ -676,6 +849,12 @@ dependencies = [ "sha-1", ] +[[package]] +name = "pkg-config" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677" + [[package]] name = "ppv-lite86" version = "0.2.8" @@ -799,6 +978,12 @@ dependencies = [ "num_cpus", ] +[[package]] +name = "redox_syscall" +version = "0.1.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" + [[package]] name = "regex" version = "1.3.9" @@ -817,12 +1002,28 @@ version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8" +[[package]] +name = "rocksdb" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12069b106981c6103d3eab7dd1c86751482d0779a520b7c14954c8b586c1e643" +dependencies = [ + "libc", + "librocksdb-sys", +] + [[package]] name = "rustc-demangle" version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rusty-hook" version = "0.11.1" @@ -841,6 +1042,16 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +[[package]] +name = "schannel" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" +dependencies = [ + "lazy_static", + "winapi", +] + [[package]] name = "scopeguard" version = "1.1.0" @@ -914,6 +1125,12 @@ dependencies = [ "opaque-debug", ] +[[package]] +name = "shlex" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" + [[package]] name = "single" version = "1.0.0" @@ -974,8 +1191,10 @@ name = "snarkos-errors" version = "0.8.0" dependencies = [ "bincode", + "curl", "hex", "jsonrpc-core", + "rocksdb", "thiserror", ] @@ -1016,7 +1235,19 @@ version = "0.8.0" dependencies = [ "rand", "snarkos-derives", - "thiserror", + "snarkos-errors", +] + +[[package]] +name = "socket2" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03088793f677dce356f3ccc2edb1b314ad191ab702a5de3faf49304f7e104918" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "winapi", ] [[package]] @@ -1151,6 +1382,12 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" +[[package]] +name = "vcpkg" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6454029bf181f092ad1b853286f23e2c507d8e8194d01d92da4a55c274a5508c" + [[package]] name = "vec_map" version = "0.8.2" @@ -1175,6 +1412,15 @@ version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" +[[package]] +name = "which" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d011071ae14a2f6671d0b74080ae0cd8ebf3a6f8c9589a2cd45f23126fe29724" +dependencies = [ + "libc", +] + [[package]] name = "winapi" version = "0.3.8" diff --git a/compiler/src/compiler.rs b/compiler/src/compiler.rs index 6195dd21fa..cf1a7ac07e 100644 --- a/compiler/src/compiler.rs +++ b/compiler/src/compiler.rs @@ -105,8 +105,8 @@ impl> Compiler { Ok(()) } - pub fn parse_inputs(&mut self, input_file_path: &PathBuf, input_file_string: &str) -> Result<(), CompilerError> { - let syntax_tree = LeoInputsParser::parse_file(input_file_path, input_file_string)?; + pub fn parse_inputs(&mut self, inputs_string: &str) -> Result<(), CompilerError> { + let syntax_tree = LeoInputsParser::parse_file(&inputs_string)?; // Check number/order of parameters here self.program_inputs = Inputs::from_inputs_file(syntax_tree, self.program.expected_inputs.clone())?; diff --git a/compiler/tests/function/mod.rs b/compiler/tests/function/mod.rs index 88cf63726c..66d87f9516 100644 --- a/compiler/tests/function/mod.rs +++ b/compiler/tests/function/mod.rs @@ -102,6 +102,7 @@ fn test_multiple_returns() { output_multiple(program); } + #[test] fn test_multiple_returns_main() { let bytes = include_bytes!("multiple_main.leo"); diff --git a/compiler/tests/inputs/inputs.leo b/compiler/tests/inputs/main.in similarity index 100% rename from compiler/tests/inputs/inputs.leo rename to compiler/tests/inputs/main.in diff --git a/compiler/tests/inputs/inputs_fail_name.leo b/compiler/tests/inputs/main_fail_name.in similarity index 100% rename from compiler/tests/inputs/inputs_fail_name.leo rename to compiler/tests/inputs/main_fail_name.in diff --git a/compiler/tests/inputs/inputs_fail_type.leo b/compiler/tests/inputs/main_fail_type.in similarity index 100% rename from compiler/tests/inputs/inputs_fail_type.leo rename to compiler/tests/inputs/main_fail_type.in diff --git a/compiler/tests/inputs/inputs_multiple.leo b/compiler/tests/inputs/main_multiple.in similarity index 100% rename from compiler/tests/inputs/inputs_multiple.leo rename to compiler/tests/inputs/main_multiple.in diff --git a/compiler/tests/inputs/mod.rs b/compiler/tests/inputs/mod.rs index 9071a3c65d..da5bf9836d 100644 --- a/compiler/tests/inputs/mod.rs +++ b/compiler/tests/inputs/mod.rs @@ -2,8 +2,6 @@ use crate::{boolean::output_true, parse_program}; use leo_compiler::errors::CompilerError; use leo_inputs::InputParserError; -use std::path::PathBuf; - fn fail_input_parser(error: CompilerError) { match error { CompilerError::InputParserError(InputParserError::InputNotFound(_)) => {} @@ -14,11 +12,11 @@ fn fail_input_parser(error: CompilerError) { #[test] fn test_inputs_pass() { let program_bytes = include_bytes!("main.leo"); - let input_bytes = include_bytes!("inputs.leo"); + let input_bytes = include_bytes!("main.in"); let input_string = String::from_utf8_lossy(input_bytes); let mut program = parse_program(program_bytes).unwrap(); - program.parse_inputs(&PathBuf::new(), &input_string).unwrap(); + program.parse_inputs(&input_string).unwrap(); output_true(program); } @@ -26,11 +24,11 @@ fn test_inputs_pass() { #[test] fn test_inputs_fail_name() { let program_bytes = include_bytes!("main.leo"); - let input_bytes = include_bytes!("inputs_fail_name.leo"); + let input_bytes = include_bytes!("main_fail_name.in"); let input_string = String::from_utf8_lossy(input_bytes); let mut program = parse_program(program_bytes).unwrap(); - let error = program.parse_inputs(&PathBuf::new(), &input_string).unwrap_err(); + let error = program.parse_inputs(&input_string).unwrap_err(); fail_input_parser(error); } @@ -38,11 +36,11 @@ fn test_inputs_fail_name() { #[test] fn test_inputs_fail_type() { let program_bytes = include_bytes!("main.leo"); - let input_bytes = include_bytes!("inputs_fail_type.leo"); + let input_bytes = include_bytes!("main_fail_type.in"); let input_string = String::from_utf8_lossy(input_bytes); let mut program = parse_program(program_bytes).unwrap(); - let error = program.parse_inputs(&PathBuf::new(), &input_string).unwrap_err(); + let error = program.parse_inputs(&input_string).unwrap_err(); fail_input_parser(error); } @@ -50,11 +48,11 @@ fn test_inputs_fail_type() { #[test] fn test_inputs_multiple() { let program_bytes = include_bytes!("main_multiple.leo"); - let input_bytes = include_bytes!("inputs_multiple.leo"); + let input_bytes = include_bytes!("main_multiple.in"); let input_string = String::from_utf8_lossy(input_bytes); let mut program = parse_program(program_bytes).unwrap(); - program.parse_inputs(&PathBuf::new(), &input_string).unwrap(); + program.parse_inputs(&input_string).unwrap(); output_true(program); } diff --git a/compiler/tests/mod.rs b/compiler/tests/mod.rs index 1822a963f8..a1fc25b894 100644 --- a/compiler/tests/mod.rs +++ b/compiler/tests/mod.rs @@ -20,7 +20,6 @@ use leo_compiler::{ use snarkos_curves::edwards_bls12::Fq; use snarkos_models::gadgets::r1cs::TestConstraintSystem; -use std::path::PathBuf; pub type EdwardsTestCompiler = Compiler; pub type EdwardsConstrainedValue = ConstrainedValue; @@ -59,7 +58,7 @@ pub(crate) fn parse_inputs(bytes: &[u8]) -> Result(file_path: &'a PathBuf, input_file: &'a str) -> Result, InputParserError> { + pub fn parse_file(input_file: &str) -> Result { // Parse the file using leo.pest - let mut file = ast::parse(input_file) - .map_err(|error| InputParserError::from(error.with_path(file_path.to_str().unwrap())))?; + let mut file = ast::parse(input_file)?; // Build the abstract syntax tree let syntax_tree = files::File::from_pest(&mut file).map_err(|_| InputParserError::SyntaxTreeError)?; diff --git a/leo/commands/init.rs b/leo/commands/init.rs index 2846940f59..da7161312c 100644 --- a/leo/commands/init.rs +++ b/leo/commands/init.rs @@ -3,10 +3,9 @@ use crate::{ cli_types::*, directories::{InputsDirectory, SourceDirectory}, errors::{CLIError, InitError}, - files::{Gitignore, MainFile, Manifest}, + files::{Gitignore, InputsFile, MainFile, Manifest}, }; -use crate::files::InputsFile; use clap::ArgMatches; use std::env::current_dir; @@ -67,9 +66,10 @@ impl CLI for InitCommand { InputsDirectory::create(&path)?; // Verify the inputs file does not exist - if !InputsFile::exists_at(&path) { - // Create the main file in the source directory - InputsFile::new(&package_name).write_to(&path)?; + let inputs_file = InputsFile::new(&package_name); + if !inputs_file.exists_at(&path) { + // Create the inputs file in the inputs directory + inputs_file.write_to(&path)?; } // Verify the main file does not exist diff --git a/leo/commands/new.rs b/leo/commands/new.rs index 77855177a5..da7ac0c4dd 100644 --- a/leo/commands/new.rs +++ b/leo/commands/new.rs @@ -3,7 +3,7 @@ use crate::{ cli_types::*, directories::{InputsDirectory, SourceDirectory}, errors::{CLIError, NewError}, - files::{Gitignore, MainFile, Manifest}, + files::{Gitignore, InputsFile, MainFile, Manifest}, }; use clap::ArgMatches; @@ -77,6 +77,9 @@ impl CLI for NewCommand { // Create the inputs directory InputsDirectory::create(&path)?; + // Create the inputs file in the inputs directory + InputsFile::new(&package_name).write_to(&path)?; + // Create the main file in the source directory MainFile::new(&package_name).write_to(&path)?; diff --git a/leo/commands/prove.rs b/leo/commands/prove.rs index 070849a3e5..14d66e450b 100644 --- a/leo/commands/prove.rs +++ b/leo/commands/prove.rs @@ -3,15 +3,13 @@ use crate::{ cli_types::*, commands::SetupCommand, errors::CLIError, - files::{Manifest, ProofFile}, + files::{InputsFile, Manifest, ProofFile}, }; use snarkos_algorithms::snark::{create_random_proof, PreparedVerifyingKey, Proof}; use snarkos_curves::bls12_377::Bls12_377; -use crate::{directories::INPUTS_DIRECTORY_NAME, files::INPUTS_FILE_NAME}; use clap::ArgMatches; -use leo_inputs::LeoInputsParser; use rand::thread_rng; use std::{convert::TryFrom, env::current_dir, time::Instant}; @@ -42,14 +40,9 @@ impl CLI for ProveCommand { let path = current_dir()?; let package_name = Manifest::try_from(&path)?.get_package_name(); - // Construct the path to the inputs file in the inputs directory - let mut inputs_file_path = path.clone(); - inputs_file_path.push(INPUTS_DIRECTORY_NAME); - inputs_file_path.push(INPUTS_FILE_NAME); - // Fetch program inputs here - let inputs_file_string = LeoInputsParser::load_file(&inputs_file_path)?; - program.parse_inputs(&inputs_file_path, &inputs_file_string)?; + let inputs_string = InputsFile::new(&package_name).read_from(&path)?; + program.parse_inputs(&inputs_string)?; // Start the timer let start = Instant::now(); diff --git a/leo/errors/cli.rs b/leo/errors/cli.rs index 53599b83cc..54da9d0940 100644 --- a/leo/errors/cli.rs +++ b/leo/errors/cli.rs @@ -20,6 +20,9 @@ pub enum CLIError { #[error("{}", _0)] InputsDirectoryError(#[from] InputsDirectoryError), + #[error("{}", _0)] + InputsFileError(#[from] InputsFileError), + #[error("{}", _0)] MainFileError(#[from] MainFileError), diff --git a/leo/errors/files/inputs.rs b/leo/errors/files/inputs.rs new file mode 100644 index 0000000000..755598d980 --- /dev/null +++ b/leo/errors/files/inputs.rs @@ -0,0 +1,22 @@ +use std::{io, path::PathBuf}; + +#[derive(Debug, Error)] +pub enum InputsFileError { + #[error("{}: {}", _0, _1)] + Crate(&'static str, String), + + #[error("creating: {}", _0)] + Creating(io::Error), + + #[error("Cannot read from the provided file path - {:?}", _0)] + FileReadError(PathBuf), + + #[error("writing: {}", _0)] + Writing(io::Error), +} + +impl From for InputsFileError { + fn from(error: std::io::Error) -> Self { + InputsFileError::Crate("std::io", format!("{}", error)) + } +} diff --git a/leo/errors/files/mod.rs b/leo/errors/files/mod.rs index 556bb337ef..c33f941ef7 100644 --- a/leo/errors/files/mod.rs +++ b/leo/errors/files/mod.rs @@ -4,6 +4,9 @@ pub use self::checksum::*; pub mod gitignore; pub use self::gitignore::*; +pub mod inputs; +pub use self::inputs::*; + pub mod main; pub use self::main::*; diff --git a/leo/files/checksum.rs b/leo/files/checksum.rs index 36d8fd11bf..b71c227808 100644 --- a/leo/files/checksum.rs +++ b/leo/files/checksum.rs @@ -9,7 +9,7 @@ use std::{ path::PathBuf, }; -pub static CHECKSUM_FILE_EXTENSION: &str = ".leo.checksum"; +pub static CHECKSUM_FILE_EXTENSION: &str = ".sum"; #[derive(Deserialize)] pub struct ChecksumFile { diff --git a/leo/files/inputs.rs b/leo/files/inputs.rs index 6dc6abfb8d..10bb9a185e 100644 --- a/leo/files/inputs.rs +++ b/leo/files/inputs.rs @@ -1,11 +1,15 @@ //! The `inputs.leo` file. -use crate::{directories::inputs::INPUTS_DIRECTORY_NAME, errors::MainFileError}; +use crate::{directories::inputs::INPUTS_DIRECTORY_NAME, errors::InputsFileError}; use serde::Deserialize; -use std::{fs::File, io::Write, path::PathBuf}; +use std::{ + fs::{self, File}, + io::Write, + path::PathBuf, +}; -pub static INPUTS_FILE_NAME: &str = "inputs.leo"; +pub static INPUTS_FILE_EXTENSION: &str = ".in"; #[derive(Deserialize)] pub struct InputsFile { @@ -19,25 +23,22 @@ impl InputsFile { } } - pub fn exists_at(path: &PathBuf) -> bool { - let mut path = path.to_owned(); - if path.is_dir() { - if !path.ends_with(INPUTS_DIRECTORY_NAME) { - path.push(PathBuf::from(INPUTS_DIRECTORY_NAME)); - } - path.push(PathBuf::from(INPUTS_FILE_NAME)); - } + pub fn exists_at(&self, path: &PathBuf) -> bool { + let path = self.setup_file_path(path); path.exists() } - pub fn write_to(self, path: &PathBuf) -> Result<(), MainFileError> { - let mut path = path.to_owned(); - if path.is_dir() { - if !path.ends_with(INPUTS_DIRECTORY_NAME) { - path.push(PathBuf::from(INPUTS_DIRECTORY_NAME)); - } - path.push(PathBuf::from(INPUTS_FILE_NAME)); - } + /// Reads the proof from the given file path if it exists. + pub fn read_from(&self, path: &PathBuf) -> Result { + let path = self.setup_file_path(path); + + let inputs = fs::read_to_string(&path).map_err(|_| InputsFileError::FileReadError(path.clone()))?; + Ok(inputs) + } + + /// Writes the standard input format to a file. + pub fn write_to(self, path: &PathBuf) -> Result<(), InputsFileError> { + let path = self.setup_file_path(path); let mut file = File::create(&path)?; Ok(file.write_all(self.template().as_bytes())?) @@ -45,7 +46,7 @@ impl InputsFile { fn template(&self) -> String { format!( - r#"// The inputs for {}/src/main.leo + r#"// The program inputs for {}/src/main.leo [main] a: u32 = 1; b: u32 = 2; @@ -53,4 +54,15 @@ b: u32 = 2; self.package_name ) } + + fn setup_file_path(&self, path: &PathBuf) -> PathBuf { + let mut path = path.to_owned(); + if path.is_dir() { + if !path.ends_with(INPUTS_DIRECTORY_NAME) { + path.push(PathBuf::from(INPUTS_DIRECTORY_NAME)); + } + path.push(PathBuf::from(format!("{}{}", self.package_name, INPUTS_FILE_EXTENSION))); + } + path + } } diff --git a/leo/files/proof.rs b/leo/files/proof.rs index 48e531ad0d..0e6fa5578e 100644 --- a/leo/files/proof.rs +++ b/leo/files/proof.rs @@ -9,7 +9,7 @@ use std::{ path::PathBuf, }; -pub static PROOF_FILE_EXTENSION: &str = ".leo.proof"; +pub static PROOF_FILE_EXTENSION: &str = ".proof"; #[derive(Deserialize)] pub struct ProofFile { diff --git a/leo/files/proving_key.rs b/leo/files/proving_key.rs index 4dcb71ea7b..49b42ba037 100644 --- a/leo/files/proving_key.rs +++ b/leo/files/proving_key.rs @@ -9,7 +9,7 @@ use std::{ path::PathBuf, }; -pub static PROVING_KEY_FILE_EXTENSION: &str = ".leo.pk"; +pub static PROVING_KEY_FILE_EXTENSION: &str = ".lpk"; #[derive(Deserialize)] pub struct ProvingKeyFile { diff --git a/leo/files/verification_key.rs b/leo/files/verification_key.rs index b34f99de07..07071c8b18 100644 --- a/leo/files/verification_key.rs +++ b/leo/files/verification_key.rs @@ -9,7 +9,7 @@ use std::{ path::PathBuf, }; -pub static VERIFICATION_KEY_FILE_EXTENSION: &str = ".leo.vk"; +pub static VERIFICATION_KEY_FILE_EXTENSION: &str = ".lvk"; #[derive(Deserialize)] pub struct VerificationKeyFile { From 825b06e9f18ef2a7d51e1b4d7919f756e623d131 Mon Sep 17 00:00:00 2001 From: howardwu Date: Fri, 19 Jun 2020 22:22:23 -0700 Subject: [PATCH 6/6] Update gitignore file generation --- leo/files/gitignore.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/leo/files/gitignore.rs b/leo/files/gitignore.rs index 6dd6f3b58a..ae9be67cfd 100644 --- a/leo/files/gitignore.rs +++ b/leo/files/gitignore.rs @@ -35,8 +35,7 @@ impl Gitignore { fn template(&self) -> String { format!( - r#"/output -/.leo + r#"outputs/ "#, ) }