mirror of
https://github.com/AleoHQ/leo.git
synced 2024-12-01 18:56:38 +03:00
Merge branch 'master' of github.com:AleoHQ/leo into feature/circuit-self-input
This commit is contained in:
commit
0698f5df59
43
.github/workflows/ci.yml
vendored
43
.github/workflows/ci.yml
vendored
@ -31,6 +31,49 @@ jobs:
|
||||
command: fmt
|
||||
args: --all -- --check
|
||||
|
||||
clippy:
|
||||
name: Clippy
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
RUSTFLAGS: -Dwarnings
|
||||
strategy:
|
||||
matrix:
|
||||
rust:
|
||||
- stable
|
||||
- nightly
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install Rust (${{ matrix.rust }})
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: ${{ matrix.rust }}
|
||||
override: true
|
||||
components: clippy
|
||||
|
||||
- name: Check examples
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: clippy
|
||||
args: --examples --all
|
||||
|
||||
- name: Check examples with all features on stable
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: clippy
|
||||
args: --examples --all-features --all
|
||||
if: matrix.rust == 'stable'
|
||||
|
||||
- name: Check benchmarks on nightly
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: clippy
|
||||
args: --all-features --examples --all --benches
|
||||
if: matrix.rust == 'nightly'
|
||||
|
||||
test:
|
||||
name: Test
|
||||
runs-on: ubuntu-latest
|
||||
|
149
Cargo.lock
generated
149
Cargo.lock
generated
@ -113,6 +113,12 @@ version = "0.12.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff"
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
|
||||
|
||||
[[package]]
|
||||
name = "bech32"
|
||||
version = "0.6.0"
|
||||
@ -403,6 +409,16 @@ dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "console_error_panic_hook"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b8d976903543e0c48546a91908f21588a680a8c8f984df9a5d69feccb2b2a211"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.10",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "const_fn"
|
||||
version = "0.4.3"
|
||||
@ -657,12 +673,6 @@ version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f"
|
||||
|
||||
[[package]]
|
||||
name = "dtoa"
|
||||
version = "0.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "134951f4028bdadb9b84baf4232681efbf277da25144b9b0ad65df75946c422b"
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.6.1"
|
||||
@ -699,9 +709,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.8.1"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "54532e3223c5af90a6a757c90b5c5521564b07e5e7a958681bcd2afad421cdcd"
|
||||
checksum = "f26ecb66b4bdca6c1409b40fb255eefc2bd4f6d135dab3c3124f80ffa2a9661e"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"humantime 2.0.1",
|
||||
@ -1147,9 +1157,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "indicatif"
|
||||
version = "0.13.0"
|
||||
version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8572bccfb0665e70b7faf44ee28841b8e0823450cd4ad562a76b5a3c4bf48487"
|
||||
checksum = "7baab56125e25686df467fe470785512329883aab42696d661247aca2a2896e4"
|
||||
dependencies = [
|
||||
"console",
|
||||
"lazy_static",
|
||||
@ -1286,7 +1296,7 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
||||
|
||||
[[package]]
|
||||
name = "leo-ast"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
dependencies = [
|
||||
"criterion",
|
||||
"leo-grammar",
|
||||
@ -1300,7 +1310,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "leo-compiler"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"hex",
|
||||
@ -1335,7 +1345,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "leo-core"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
dependencies = [
|
||||
"leo-ast",
|
||||
"leo-gadgets",
|
||||
@ -1351,7 +1361,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "leo-gadgets"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
dependencies = [
|
||||
"criterion",
|
||||
"rand",
|
||||
@ -1364,7 +1374,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "leo-grammar"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
dependencies = [
|
||||
"criterion",
|
||||
"from-pest",
|
||||
@ -1380,7 +1390,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "leo-imports"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
dependencies = [
|
||||
"leo-ast",
|
||||
"leo-grammar",
|
||||
@ -1390,7 +1400,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "leo-input"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
dependencies = [
|
||||
"from-pest",
|
||||
"pest",
|
||||
@ -1407,14 +1417,14 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "leo-lang"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"colored",
|
||||
"console",
|
||||
"dirs",
|
||||
"dotenv",
|
||||
"env_logger 0.8.1",
|
||||
"env_logger 0.8.2",
|
||||
"from-pest",
|
||||
"lazy_static",
|
||||
"leo-ast",
|
||||
@ -1448,11 +1458,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "leo-linter"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
|
||||
[[package]]
|
||||
name = "leo-package"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"serde",
|
||||
@ -1466,7 +1476,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "leo-state"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
dependencies = [
|
||||
"leo-ast",
|
||||
"leo-input",
|
||||
@ -1485,7 +1495,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "leo-symbol-table"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
dependencies = [
|
||||
"leo-ast",
|
||||
"leo-core",
|
||||
@ -1497,7 +1507,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "leo-type-inference"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
dependencies = [
|
||||
"leo-ast",
|
||||
"leo-grammar",
|
||||
@ -2011,6 +2021,12 @@ version = "0.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c917123afa01924fc84bb20c4c03f004d9c38e5127e3c039bbf7f4b9c76a2f6b"
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6b063f57ec186e6140e2b8b6921e5f1bd89c7356dda5b33acc5401203ca6131c"
|
||||
|
||||
[[package]]
|
||||
name = "pin-utils"
|
||||
version = "0.1.0"
|
||||
@ -2067,9 +2083,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
|
||||
|
||||
[[package]]
|
||||
name = "quick-xml"
|
||||
version = "0.17.2"
|
||||
version = "0.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fe1e430bdcf30c9fdc25053b9c459bb1a4672af4617b6c783d7d91dc17c6bbb0"
|
||||
checksum = "26aab6b48e2590e4a64d1ed808749ba06257882b461d01ca71baeb747074a6dd"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
@ -2223,11 +2239,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "reqwest"
|
||||
version = "0.10.8"
|
||||
version = "0.10.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e9eaa17ac5d7b838b7503d118fa16ad88f440498bf9ffe5424e621f93190d61e"
|
||||
checksum = "fb15d6255c792356a0f578d8a645c677904dc02e862bebe2ecc18e0c01b9a0ce"
|
||||
dependencies = [
|
||||
"base64 0.12.3",
|
||||
"base64 0.13.0",
|
||||
"bytes 0.5.6",
|
||||
"encoding_rs",
|
||||
"futures-core",
|
||||
@ -2244,7 +2260,7 @@ dependencies = [
|
||||
"mime_guess",
|
||||
"native-tls",
|
||||
"percent-encoding 2.1.0",
|
||||
"pin-project-lite",
|
||||
"pin-project-lite 0.2.0",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_urlencoded",
|
||||
@ -2253,6 +2269,7 @@ dependencies = [
|
||||
"url",
|
||||
"wasm-bindgen",
|
||||
"wasm-bindgen-futures",
|
||||
"wasm-bindgen-test",
|
||||
"web-sys",
|
||||
"winreg",
|
||||
]
|
||||
@ -2297,7 +2314,7 @@ version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
|
||||
dependencies = [
|
||||
"semver",
|
||||
"semver 0.9.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2380,9 +2397,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "self_update"
|
||||
version = "0.20.0"
|
||||
version = "0.22.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c047c1227ffcf31a3b6f64df97c61e79539721facef7ff06a2ece7a7f3052f1f"
|
||||
checksum = "ba18daf40a9db913cba8426cce84fa35abfc0872070fdf763dc7af9545e8a786"
|
||||
dependencies = [
|
||||
"hyper-old-types",
|
||||
"indicatif",
|
||||
@ -2390,7 +2407,7 @@ dependencies = [
|
||||
"quick-xml",
|
||||
"regex",
|
||||
"reqwest",
|
||||
"semver",
|
||||
"semver 0.11.0",
|
||||
"serde_json",
|
||||
"tempfile",
|
||||
"zip",
|
||||
@ -2402,7 +2419,16 @@ version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
|
||||
dependencies = [
|
||||
"semver-parser",
|
||||
"semver-parser 0.7.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6"
|
||||
dependencies = [
|
||||
"semver-parser 0.10.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2411,6 +2437,15 @@ version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
|
||||
|
||||
[[package]]
|
||||
name = "semver-parser"
|
||||
version = "0.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "42ef146c2ad5e5f4b037cd6ce2ebb775401729b19a82040c1beac9d36c7d1428"
|
||||
dependencies = [
|
||||
"pest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.117"
|
||||
@ -2454,14 +2489,14 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_urlencoded"
|
||||
version = "0.6.1"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97"
|
||||
checksum = "edfa57a7f8d9c1d260a549e7224100f6c43d43f9103e06dd8b4095a9b2b43ce9"
|
||||
dependencies = [
|
||||
"dtoa",
|
||||
"form_urlencoded",
|
||||
"itoa",
|
||||
"ryu",
|
||||
"serde",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2899,7 +2934,7 @@ dependencies = [
|
||||
"memchr",
|
||||
"mio",
|
||||
"num_cpus",
|
||||
"pin-project-lite",
|
||||
"pin-project-lite 0.1.11",
|
||||
"slab",
|
||||
]
|
||||
|
||||
@ -2923,7 +2958,7 @@ dependencies = [
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
"log",
|
||||
"pin-project-lite",
|
||||
"pin-project-lite 0.1.11",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
@ -2944,13 +2979,13 @@ checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860"
|
||||
|
||||
[[package]]
|
||||
name = "tracing"
|
||||
version = "0.1.21"
|
||||
version = "0.1.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b0987850db3733619253fe60e17cb59b82d37c7e6c0236bb81e4d6b87c879f27"
|
||||
checksum = "9f47026cdc4080c07e49b37087de021820269d996f581aac150ef9e5583eefe3"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.10",
|
||||
"cfg-if 1.0.0",
|
||||
"log",
|
||||
"pin-project-lite",
|
||||
"pin-project-lite 0.2.0",
|
||||
"tracing-attributes",
|
||||
"tracing-core",
|
||||
]
|
||||
@ -3228,6 +3263,30 @@ version = "0.2.68"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d649a3145108d7d3fbcde896a468d1bd636791823c9921135218ad89be08307"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-test"
|
||||
version = "0.3.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34d1cdc8b98a557f24733d50a1199c4b0635e465eecba9c45b214544da197f64"
|
||||
dependencies = [
|
||||
"console_error_panic_hook",
|
||||
"js-sys",
|
||||
"scoped-tls",
|
||||
"wasm-bindgen",
|
||||
"wasm-bindgen-futures",
|
||||
"wasm-bindgen-test-macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-test-macro"
|
||||
version = "0.3.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e8fb9c67be7439ee8ab1b7db502a49c05e51e2835b66796c705134d9b8e1a585"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.24",
|
||||
"quote 1.0.7",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "web-sys"
|
||||
version = "0.3.45"
|
||||
|
22
Cargo.toml
22
Cargo.toml
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "leo-lang"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
authors = [ "The Aleo Team <hello@aleo.org>" ]
|
||||
description = "The Leo programming language"
|
||||
homepage = "https://aleo.org"
|
||||
@ -37,36 +37,36 @@ members = [
|
||||
"package",
|
||||
"state",
|
||||
"symbol-table",
|
||||
"type-inference",
|
||||
"type-inference"
|
||||
]
|
||||
|
||||
[dependencies.leo-ast]
|
||||
path = "./ast"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
|
||||
[dependencies.leo-compiler]
|
||||
path = "./compiler"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
|
||||
[dependencies.leo-gadgets]
|
||||
path = "./gadgets"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
|
||||
[dependencies.leo-imports]
|
||||
path = "./imports"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
|
||||
[dependencies.leo-input]
|
||||
path = "./input"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
|
||||
[dependencies.leo-package]
|
||||
path = "./package"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
|
||||
[dependencies.leo-state]
|
||||
path = "./state"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
|
||||
[dependencies.snarkos-algorithms]
|
||||
version = "1.1.3"
|
||||
@ -128,11 +128,11 @@ version = "0.7"
|
||||
version = "0.5.1"
|
||||
|
||||
[dependencies.reqwest]
|
||||
version = "0.10.7"
|
||||
version = "0.10.9"
|
||||
features = [ "blocking", "json" ]
|
||||
|
||||
[dependencies.self_update]
|
||||
version = "0.20.0"
|
||||
version = "0.22.0"
|
||||
features = [ "archive-zip" ]
|
||||
|
||||
[dependencies.serde]
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "leo-ast"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
authors = [ "The Aleo Team <hello@aleo.org>" ]
|
||||
description = "Core AST of the Leo programming language"
|
||||
homepage = "https://aleo.org"
|
||||
@ -28,11 +28,11 @@ harness = false
|
||||
|
||||
[dependencies.leo-grammar]
|
||||
path = "../grammar"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
|
||||
[dependencies.leo-input]
|
||||
path = "../input"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
|
||||
[dependencies.snarkos-errors]
|
||||
version = "1.1.3"
|
||||
|
@ -20,64 +20,64 @@ use leo_grammar::Grammar;
|
||||
use criterion::{criterion_group, criterion_main, Criterion};
|
||||
use std::{path::Path, time::Duration};
|
||||
|
||||
fn ast<'ast>(ast: &Grammar<'ast>) -> Ast {
|
||||
fn ast(ast: &Grammar) -> Ast {
|
||||
Ast::new("leo_tree", &ast)
|
||||
}
|
||||
|
||||
fn bench_big_if_else(c: &mut Criterion) {
|
||||
let filepath = Path::new("./big_if_else.leo").to_path_buf();
|
||||
let program_string = include_str!("./big_if_else.leo");
|
||||
let ast = Grammar::new(&filepath, program_string).unwrap();
|
||||
let grammar = Grammar::new(&filepath, program_string).unwrap();
|
||||
|
||||
c.bench_function("Ast::big_if_else", |b| b.iter(|| ast(&ast)));
|
||||
c.bench_function("Ast::big_if_else", |b| b.iter(|| ast(&grammar)));
|
||||
}
|
||||
|
||||
fn bench_big_ternary(c: &mut Criterion) {
|
||||
let filepath = Path::new("./big_ternary.leo").to_path_buf();
|
||||
let program_string = include_str!("./big_ternary.leo");
|
||||
let ast = Grammar::new(&filepath, program_string).unwrap();
|
||||
let grammar = Grammar::new(&filepath, program_string).unwrap();
|
||||
|
||||
c.bench_function("Ast::big_ternary", |b| b.iter(|| ast(&ast)));
|
||||
c.bench_function("Ast::big_ternary", |b| b.iter(|| ast(&grammar)));
|
||||
}
|
||||
|
||||
fn bench_big_circuit(c: &mut Criterion) {
|
||||
let filepath = Path::new("./big_circuit.leo").to_path_buf();
|
||||
let program_string = include_str!("./big_circuit.leo");
|
||||
let ast = Grammar::new(&filepath, program_string).unwrap();
|
||||
let grammar = Grammar::new(&filepath, program_string).unwrap();
|
||||
|
||||
c.bench_function("Ast::big_circuit", |b| b.iter(|| ast(&ast)));
|
||||
c.bench_function("Ast::big_circuit", |b| b.iter(|| ast(&grammar)));
|
||||
}
|
||||
|
||||
fn bench_long_expr(c: &mut Criterion) {
|
||||
let filepath = Path::new("./long_expr.leo").to_path_buf();
|
||||
let program_string = include_str!("./long_expr.leo");
|
||||
let ast = Grammar::new(&filepath, program_string).unwrap();
|
||||
let grammar = Grammar::new(&filepath, program_string).unwrap();
|
||||
|
||||
c.bench_function("Ast::long_expr", |b| b.iter(|| ast(&ast)));
|
||||
c.bench_function("Ast::long_expr", |b| b.iter(|| ast(&grammar)));
|
||||
}
|
||||
|
||||
fn bench_long_array(c: &mut Criterion) {
|
||||
let filepath = Path::new("./long_array.leo").to_path_buf();
|
||||
let program_string = include_str!("./long_array.leo");
|
||||
let ast = Grammar::new(&filepath, program_string).unwrap();
|
||||
let grammar = Grammar::new(&filepath, program_string).unwrap();
|
||||
|
||||
c.bench_function("Ast::long_array", |b| b.iter(|| ast(&ast)));
|
||||
c.bench_function("Ast::long_array", |b| b.iter(|| ast(&grammar)));
|
||||
}
|
||||
|
||||
fn bench_many_foos(c: &mut Criterion) {
|
||||
let filepath = Path::new("./many_foos.leo").to_path_buf();
|
||||
let program_string = include_str!("./many_foos.leo");
|
||||
let ast = Grammar::new(&filepath, program_string).unwrap();
|
||||
let grammar = Grammar::new(&filepath, program_string).unwrap();
|
||||
|
||||
c.bench_function("Ast::many_foos", |b| b.iter(|| ast(&ast)));
|
||||
c.bench_function("Ast::many_foos", |b| b.iter(|| ast(&grammar)));
|
||||
}
|
||||
|
||||
fn bench_many_assigns(c: &mut Criterion) {
|
||||
let filepath = Path::new("./many_assigns.leo").to_path_buf();
|
||||
let program_string = include_str!("./many_assigns.leo");
|
||||
let ast = Grammar::new(&filepath, program_string).unwrap();
|
||||
let grammar = Grammar::new(&filepath, program_string).unwrap();
|
||||
|
||||
c.bench_function("Ast::many_assigns", |b| b.iter(|| ast(&ast)));
|
||||
c.bench_function("Ast::many_assigns", |b| b.iter(|| ast(&grammar)));
|
||||
}
|
||||
|
||||
criterion_group!(
|
||||
|
@ -53,8 +53,8 @@ impl InputValue {
|
||||
Ok(InputValue::Boolean(boolean))
|
||||
}
|
||||
|
||||
fn from_number(integer_type: IntegerType, number: String) -> Result<Self, InputParserError> {
|
||||
Ok(InputValue::Integer(integer_type, number))
|
||||
fn from_number(integer_type: IntegerType, number: String) -> Self {
|
||||
InputValue::Integer(integer_type, number)
|
||||
}
|
||||
|
||||
fn from_group(group: InputGroupValue) -> Self {
|
||||
@ -69,7 +69,7 @@ impl InputValue {
|
||||
match data_type {
|
||||
DataType::Address(_) => Err(InputParserError::implicit_type(data_type, implicit)),
|
||||
DataType::Boolean(_) => Err(InputParserError::implicit_type(data_type, implicit)),
|
||||
DataType::Integer(integer_type) => InputValue::from_number(integer_type, implicit.to_string()),
|
||||
DataType::Integer(integer_type) => Ok(InputValue::from_number(integer_type, implicit.to_string())),
|
||||
DataType::Group(_) => Err(InputParserError::implicit_group(implicit)),
|
||||
DataType::Field(_) => Ok(InputValue::Field(implicit.to_string())),
|
||||
}
|
||||
@ -80,7 +80,7 @@ impl InputValue {
|
||||
(DataType::Address(_), Value::Address(address)) => Ok(InputValue::from_address_value(address)),
|
||||
(DataType::Boolean(_), Value::Boolean(boolean)) => InputValue::from_boolean(boolean),
|
||||
(DataType::Integer(integer_type), Value::Integer(integer)) => {
|
||||
InputValue::from_number(integer_type, integer.to_string())
|
||||
Ok(InputValue::from_number(integer_type, integer.to_string()))
|
||||
}
|
||||
(DataType::Group(_), Value::Group(group)) => Ok(InputValue::from_group(group)),
|
||||
(DataType::Field(_), Value::Field(field)) => Ok(InputValue::from_field(field)),
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "leo-compiler"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
authors = [ "The Aleo Team <hello@aleo.org>" ]
|
||||
description = "Compiler of the Leo programming language"
|
||||
homepage = "https://aleo.org"
|
||||
@ -19,43 +19,43 @@ edition = "2018"
|
||||
|
||||
[dependencies.leo-ast]
|
||||
path = "../ast"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
|
||||
[dependencies.leo-core]
|
||||
path = "../core"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
|
||||
[dependencies.leo-gadgets]
|
||||
path = "../gadgets"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
|
||||
[dependencies.leo-grammar]
|
||||
path = "../grammar"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
|
||||
[dependencies.leo-imports]
|
||||
path = "../imports"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
|
||||
[dependencies.leo-input]
|
||||
path = "../input"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
|
||||
[dependencies.leo-package]
|
||||
path = "../package"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
|
||||
[dependencies.leo-state]
|
||||
path = "../state"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
|
||||
[dependencies.leo-symbol-table]
|
||||
path = "../symbol-table"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
|
||||
[dependencies.leo-type-inference]
|
||||
path = "../type-inference"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
|
||||
[dependencies.snarkos-curves]
|
||||
version = "1.1.3"
|
||||
|
@ -138,7 +138,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
|
||||
// Boolean operations
|
||||
Expression::Not(expression, span) => Ok(evaluate_not(
|
||||
self.enforce_expression(cs, file_scope, function_scope, expected_type, *expression)?,
|
||||
self.enforce_operand(cs, file_scope, function_scope, expected_type, *expression, &span)?,
|
||||
span,
|
||||
)?),
|
||||
Expression::Or(left_right, span) => {
|
||||
|
@ -457,7 +457,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> CondSelectGadget<F> for Constrained
|
||||
|
||||
ConstrainedValue::Array(array)
|
||||
}
|
||||
(ConstrainedValue::Tuple(tuple_1), ConstrainedValue::Array(tuple_2)) => {
|
||||
(ConstrainedValue::Tuple(tuple_1), ConstrainedValue::Tuple(tuple_2)) => {
|
||||
let mut array = Vec::with_capacity(tuple_1.len());
|
||||
|
||||
for (i, (first, second)) in tuple_1.iter().zip(tuple_2.iter()).enumerate() {
|
||||
|
@ -93,6 +93,14 @@ fn test_not_false() {
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_not_mutable() {
|
||||
let bytes = include_bytes!("not_mutable.leo");
|
||||
let program = parse_program(bytes).unwrap();
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_not_u32() {
|
||||
let bytes = include_bytes!("not_u32.leo");
|
||||
|
4
compiler/tests/boolean/not_mutable.leo
Normal file
4
compiler/tests/boolean/not_mutable.leo
Normal file
@ -0,0 +1,4 @@
|
||||
function main () {
|
||||
let mut b = false;
|
||||
let a = !b;
|
||||
}
|
@ -174,3 +174,21 @@ fn test_return_array_tuple_pass() {
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
||||
// Test return tuples
|
||||
|
||||
#[test]
|
||||
fn test_return_tuple() {
|
||||
let bytes = include_bytes!("return_tuple.leo");
|
||||
let program = parse_program(bytes).unwrap();
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_return_tuple_conditional() {
|
||||
let bytes = include_bytes!("return_tuple_conditional.leo");
|
||||
let program = parse_program(bytes).unwrap();
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
11
compiler/tests/function/return_tuple.leo
Normal file
11
compiler/tests/function/return_tuple.leo
Normal file
@ -0,0 +1,11 @@
|
||||
// Returns a tuple of tuples.
|
||||
function tuples() -> ((u8, u8), u32) {
|
||||
let a: (u8, u8) = (1, 2);
|
||||
let b: u32 = 3;
|
||||
|
||||
return (a, b)
|
||||
}
|
||||
|
||||
function main() {
|
||||
let t = tuples();
|
||||
}
|
15
compiler/tests/function/return_tuple_conditional.leo
Normal file
15
compiler/tests/function/return_tuple_conditional.leo
Normal file
@ -0,0 +1,15 @@
|
||||
// Returns a tuple using a conditional "if" statement.
|
||||
function tuple_conditional () -> (
|
||||
i64,
|
||||
i64
|
||||
) {
|
||||
if true {
|
||||
return (1, 1)
|
||||
} else {
|
||||
return (2, 2)
|
||||
}
|
||||
}
|
||||
|
||||
function main() {
|
||||
let t = tuple_conditional();
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "leo-core"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
authors = [ "The Aleo Team <hello@aleo.org>" ]
|
||||
description = "Core package dependencies of the Leo programming language"
|
||||
homepage = "https://aleo.org"
|
||||
@ -19,11 +19,11 @@ edition = "2018"
|
||||
|
||||
[dependencies.leo-ast]
|
||||
path = "../ast"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
|
||||
[dependencies.leo-gadgets]
|
||||
path = "../gadgets"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
|
||||
[dependencies.snarkos-errors]
|
||||
version = "1.1.3"
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "leo-gadgets"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
authors = [ "The Aleo Team <hello@aleo.org>" ]
|
||||
description = "Gadgets of the Leo programming language"
|
||||
homepage = "https://aleo.org"
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "leo-grammar"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
authors = [ "The Aleo Team <hello@aleo.org>" ]
|
||||
description = "AST generated by pest from the Leo grammar rules"
|
||||
homepage = "https://aleo.org"
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "leo-imports"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
authors = [ "The Aleo Team <hello@aleo.org>" ]
|
||||
description = "Import parser for Leo program package dependencies"
|
||||
homepage = "https://aleo.org"
|
||||
@ -19,11 +19,11 @@ edition = "2018"
|
||||
|
||||
[dependencies.leo-ast]
|
||||
path = "../ast"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
|
||||
[dependencies.leo-grammar]
|
||||
path = "../grammar"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
|
||||
[dependencies.thiserror]
|
||||
version = "1.0"
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "leo-input"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
authors = [ "The Aleo Team <hello@aleo.org>" ]
|
||||
description = "Input parser of the Leo programming language"
|
||||
homepage = "https://aleo.org"
|
||||
|
@ -105,7 +105,7 @@ dimension_single = {
|
||||
// Declared in types/array_dimensions.rs
|
||||
dimension_multiple = { "(" ~ number_positive ~ ("," ~ number_positive)* ~ ")"}
|
||||
|
||||
type_tuple = { "(" ~ type_ ~ ("," ~ (type_tuple | type_))+ ~ ")" }
|
||||
type_tuple = { "(" ~ NEWLINE* ~ (type_ ~ ("," ~ NEWLINE* ~ type_)+ ~ ","?)? ~ NEWLINE* ~ ")" }
|
||||
|
||||
/// Values
|
||||
|
||||
|
@ -1 +1 @@
|
||||
v1.0.4
|
||||
v1.0.6
|
@ -22,9 +22,8 @@ use clap::{App, AppSettings, Arg};
|
||||
fn main() -> Result<(), CLIError> {
|
||||
let app = App::new("leo")
|
||||
.version(include_str!("./leo-version"))
|
||||
.before_help("Hello world")
|
||||
// .about("Leo compiler and package manager")
|
||||
// .author("The Aleo Team <hello@aleo.org>")
|
||||
.about("Leo compiler and package manager")
|
||||
.author("The Aleo Team <hello@aleo.org>")
|
||||
.settings(&[
|
||||
AppSettings::ColoredHelp,
|
||||
AppSettings::DisableHelpSubcommand,
|
||||
|
@ -2,7 +2,7 @@ dependencies = { }
|
||||
|
||||
[package]
|
||||
name = "leo-linter"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
authors = [ "The Aleo Team <hello@aleo.org>" ]
|
||||
description = "Linter of the Leo programming language"
|
||||
homepage = "https://aleo.org"
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "leo-package"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
authors = [ "The Aleo Team <hello@aleo.org>" ]
|
||||
description = "Package parser of the Leo programming language"
|
||||
homepage = "https://aleo.org"
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "leo-state"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
authors = [ "The Aleo Team <hello@aleo.org>" ]
|
||||
description = "State parser of the Leo programming language"
|
||||
homepage = "https://aleo.org"
|
||||
@ -19,11 +19,11 @@ edition = "2018"
|
||||
|
||||
[dependencies.leo-input]
|
||||
path = "../input"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
|
||||
[dependencies.leo-ast]
|
||||
path = "../ast"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
|
||||
[dependencies.snarkos-algorithms]
|
||||
version = "1.1.3"
|
||||
|
@ -15,7 +15,7 @@
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{verify_record_commitment, LocalDataVerificationError, StateLeafValues, StateValues};
|
||||
use leo_ast::Input as InputAst;
|
||||
use leo_ast::Input as AstInput;
|
||||
|
||||
use snarkos_algorithms::commitment_tree::CommitmentMerklePath;
|
||||
use snarkos_dpc::base_dpc::{
|
||||
@ -30,31 +30,33 @@ use snarkos_utilities::{bytes::ToBytes, to_bytes, FromBytes};
|
||||
|
||||
use std::convert::TryFrom;
|
||||
|
||||
/// Returns `true` if the path to the local data commitment leaf is a valid path in the record
|
||||
/// commitment merkle tree.
|
||||
pub fn verify_local_data_commitment(
|
||||
system_parameters: &SystemParameters<Components>,
|
||||
input_ast: &InputAst,
|
||||
ast_input: &AstInput,
|
||||
) -> Result<bool, LocalDataVerificationError> {
|
||||
// verify record commitment
|
||||
let typed_record = input_ast.get_record();
|
||||
// verify record commitment.
|
||||
let typed_record = ast_input.get_record();
|
||||
let dpc_record_values = verify_record_commitment(system_parameters, typed_record)?;
|
||||
let record_commitment: Vec<u8> = dpc_record_values.commitment;
|
||||
let record_serial_number: Vec<u8> = dpc_record_values.serial_number;
|
||||
|
||||
// parse typed state values
|
||||
let typed_state = input_ast.get_state();
|
||||
// parse typed state values.
|
||||
let typed_state = ast_input.get_state();
|
||||
let state_values = StateValues::try_from(typed_state)?;
|
||||
let leaf_index: u32 = state_values.leaf_index;
|
||||
let root: Vec<u8> = state_values.root;
|
||||
|
||||
// parse typed state leaf values
|
||||
let typed_state_leaf = input_ast.get_state_leaf();
|
||||
// parse typed state leaf values.
|
||||
let typed_state_leaf = ast_input.get_state_leaf();
|
||||
let state_leaf_values = StateLeafValues::try_from(typed_state_leaf)?;
|
||||
let path: Vec<u8> = state_leaf_values.path;
|
||||
let memo: Vec<u8> = state_leaf_values.memo;
|
||||
let network_id: u8 = state_leaf_values.network_id;
|
||||
let leaf_randomness: Vec<u8> = state_leaf_values.leaf_randomness;
|
||||
|
||||
// Select local data commitment input bytes
|
||||
// Select local data commitment input bytes.
|
||||
let is_death = leaf_index < (Components::NUM_INPUT_RECORDS as u32);
|
||||
let input_bytes = if is_death {
|
||||
to_bytes![record_serial_number, record_commitment, memo, network_id]?
|
||||
@ -62,7 +64,7 @@ pub fn verify_local_data_commitment(
|
||||
to_bytes![record_commitment, memo, network_id]?
|
||||
};
|
||||
|
||||
// Construct local data commitment leaf
|
||||
// Construct local data commitment leaf.
|
||||
let local_data_leaf_randomness = <LocalDataCommitment as CommitmentScheme>::Randomness::read(&leaf_randomness[..])?;
|
||||
let local_data_commitment_leaf = LocalDataCommitment::commit(
|
||||
&system_parameters.local_data_commitment,
|
||||
@ -70,10 +72,10 @@ pub fn verify_local_data_commitment(
|
||||
&local_data_leaf_randomness,
|
||||
)?;
|
||||
|
||||
// Construct record commitment merkle path
|
||||
// Construct record commitment merkle path.
|
||||
let local_data_merkle_path = CommitmentMerklePath::<LocalDataCommitment, LocalDataCRH>::read(&path[..])?;
|
||||
|
||||
// Check record commitment merkle path is valid for the given local data commitment root
|
||||
// Check record commitment merkle path is valid for the given local data commitment root.
|
||||
let local_data_commitment_root = <LocalDataCRH as CRH>::Output::read(&root[..])?;
|
||||
let result = local_data_merkle_path.verify(
|
||||
&system_parameters.local_data_crh,
|
||||
|
@ -14,8 +14,8 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{find_input, input_to_integer_string, input_to_u8_vec, StateLeafValuesError};
|
||||
use leo_ast::StateLeaf as StateLeafAst;
|
||||
use crate::{find_input, input_to_bytes, input_to_integer_string, StateLeafValuesError};
|
||||
use leo_ast::StateLeaf as AstStateLeaf;
|
||||
|
||||
use std::convert::TryFrom;
|
||||
|
||||
@ -24,6 +24,8 @@ static MEMO_PARAMETER_STRING: &str = "memo";
|
||||
static NETWORK_ID_PARAMETER_STRING: &str = "network_id";
|
||||
static LEAF_RANDOMNESS_PARAMETER_STRING: &str = "leaf_randomness";
|
||||
|
||||
/// The serialized values included in the state leaf.
|
||||
/// A new [`StateLeafValues`] type can be constructed from an [`AstStateLeaf`] type.
|
||||
pub struct StateLeafValues {
|
||||
pub path: Vec<u8>,
|
||||
pub memo: Vec<u8>,
|
||||
@ -31,19 +33,19 @@ pub struct StateLeafValues {
|
||||
pub leaf_randomness: Vec<u8>,
|
||||
}
|
||||
|
||||
impl TryFrom<&StateLeafAst> for StateLeafValues {
|
||||
impl TryFrom<&AstStateLeaf> for StateLeafValues {
|
||||
type Error = StateLeafValuesError;
|
||||
|
||||
fn try_from(state_leaf: &StateLeafAst) -> Result<Self, Self::Error> {
|
||||
let parameters = state_leaf.values();
|
||||
fn try_from(ast_state_leaf: &AstStateLeaf) -> Result<Self, Self::Error> {
|
||||
let parameters = ast_state_leaf.values();
|
||||
|
||||
// Lookup path
|
||||
let path_value = find_input(PATH_PARAMETER_STRING.to_owned(), ¶meters)?;
|
||||
let path = input_to_u8_vec(path_value)?;
|
||||
let path = input_to_bytes(path_value)?;
|
||||
|
||||
// Lookup memo
|
||||
let memo_value = find_input(MEMO_PARAMETER_STRING.to_owned(), ¶meters)?;
|
||||
let memo = input_to_u8_vec(memo_value)?;
|
||||
let memo = input_to_bytes(memo_value)?;
|
||||
|
||||
// Lookup network id
|
||||
let network_id_value = find_input(NETWORK_ID_PARAMETER_STRING.to_owned(), ¶meters)?;
|
||||
@ -51,7 +53,7 @@ impl TryFrom<&StateLeafAst> for StateLeafValues {
|
||||
|
||||
// Lookup leaf randomness
|
||||
let leaf_randomness_value = find_input(LEAF_RANDOMNESS_PARAMETER_STRING.to_owned(), ¶meters)?;
|
||||
let leaf_randomness = input_to_u8_vec(leaf_randomness_value)?;
|
||||
let leaf_randomness = input_to_bytes(leaf_randomness_value)?;
|
||||
|
||||
Ok(Self {
|
||||
path,
|
||||
|
@ -14,24 +14,26 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{find_input, input_to_integer_string, input_to_u8_vec, StateValuesError};
|
||||
use leo_ast::State as StateAst;
|
||||
use crate::{find_input, input_to_bytes, input_to_integer_string, StateValuesError};
|
||||
use leo_ast::State as AstState;
|
||||
|
||||
use std::convert::TryFrom;
|
||||
|
||||
static LEAF_INDEX_PARAMETER_STRING: &str = "leaf_index";
|
||||
static ROOT_PARAMETER_STRING: &str = "root";
|
||||
|
||||
/// The serialized values included in the state.
|
||||
/// A new [`StateValues`] type can be constructed from an [`AstState`] type.
|
||||
pub struct StateValues {
|
||||
pub leaf_index: u32,
|
||||
pub root: Vec<u8>,
|
||||
}
|
||||
|
||||
impl TryFrom<&StateAst> for StateValues {
|
||||
impl TryFrom<&AstState> for StateValues {
|
||||
type Error = StateValuesError;
|
||||
|
||||
fn try_from(state: &StateAst) -> Result<Self, Self::Error> {
|
||||
let parameters = state.values();
|
||||
fn try_from(ast_state: &AstState) -> Result<Self, Self::Error> {
|
||||
let parameters = ast_state.values();
|
||||
|
||||
// Lookup leaf index
|
||||
let leaf_index_value = find_input(LEAF_INDEX_PARAMETER_STRING.to_owned(), ¶meters)?;
|
||||
@ -39,7 +41,7 @@ impl TryFrom<&StateAst> for StateValues {
|
||||
|
||||
// Lookup root
|
||||
let root_value = find_input(ROOT_PARAMETER_STRING.to_owned(), ¶meters)?;
|
||||
let root = input_to_u8_vec(root_value)?;
|
||||
let root = input_to_bytes(root_value)?;
|
||||
|
||||
Ok(Self { leaf_index, root })
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{utilities::*, DPCRecordValuesError};
|
||||
use leo_ast::Record as RecordAst;
|
||||
use leo_ast::Record as AstRecord;
|
||||
|
||||
use snarkos_dpc::base_dpc::instantiated::Components;
|
||||
use snarkos_objects::AccountAddress;
|
||||
@ -33,6 +33,8 @@ static SERIAL_NUMBER_NONCE_PARAMETER_STRING: &str = "serial_number_nonce";
|
||||
static COMMITMENT_PARAMETER_STRING: &str = "commitment";
|
||||
static COMMITMENT_RANDOMNESS_PARAMETER_STRING: &str = "commitment_randomness";
|
||||
|
||||
/// The serialized values included in the dpc record.
|
||||
/// A new [`DPCRecordValues`] type can be constructed from an [`AstRecord`] type.
|
||||
pub struct DPCRecordValues {
|
||||
pub serial_number: Vec<u8>,
|
||||
pub owner: AccountAddress<Components>,
|
||||
@ -46,15 +48,15 @@ pub struct DPCRecordValues {
|
||||
pub commitment_randomness: Vec<u8>,
|
||||
}
|
||||
|
||||
impl TryFrom<&RecordAst> for DPCRecordValues {
|
||||
impl TryFrom<&AstRecord> for DPCRecordValues {
|
||||
type Error = DPCRecordValuesError;
|
||||
|
||||
fn try_from(record: &RecordAst) -> Result<Self, Self::Error> {
|
||||
let parameters = record.values();
|
||||
fn try_from(ast_record: &AstRecord) -> Result<Self, Self::Error> {
|
||||
let parameters = ast_record.values();
|
||||
|
||||
// Lookup serial number
|
||||
let serial_number_value = find_input(SERIAL_NUMBER_PARAMETER_STRING.to_owned(), ¶meters)?;
|
||||
let serial_number = input_to_u8_vec(serial_number_value)?;
|
||||
let serial_number = input_to_bytes(serial_number_value)?;
|
||||
|
||||
// Lookup record owner
|
||||
let owner_value = find_input(OWNER_PARAMETER_STRING.to_owned(), ¶meters)?;
|
||||
@ -70,27 +72,27 @@ impl TryFrom<&RecordAst> for DPCRecordValues {
|
||||
|
||||
// Lookup record payload
|
||||
let payload_value = find_input(PAYLOAD_PARAMETER_STRING.to_owned(), ¶meters)?;
|
||||
let payload = input_to_u8_vec(payload_value)?;
|
||||
let payload = input_to_bytes(payload_value)?;
|
||||
|
||||
// Lookup record birth program id
|
||||
let birth_program_id_value = find_input(BIRTH_PROGRAM_ID_PARAMETER_STRING.to_owned(), ¶meters)?;
|
||||
let birth_program_id = input_to_u8_vec(birth_program_id_value)?;
|
||||
let birth_program_id = input_to_bytes(birth_program_id_value)?;
|
||||
|
||||
// Lookup record death program id
|
||||
let death_program_id_value = find_input(DEATH_PROGRAM_ID_PARAMETER_STRING.to_owned(), ¶meters)?;
|
||||
let death_program_id = input_to_u8_vec(death_program_id_value)?;
|
||||
let death_program_id = input_to_bytes(death_program_id_value)?;
|
||||
|
||||
// Lookup record serial number nonce
|
||||
let serial_number_nonce_value = find_input(SERIAL_NUMBER_NONCE_PARAMETER_STRING.to_owned(), ¶meters)?;
|
||||
let serial_number_nonce = input_to_u8_vec(serial_number_nonce_value)?;
|
||||
let serial_number_nonce = input_to_bytes(serial_number_nonce_value)?;
|
||||
|
||||
// Lookup record commitment
|
||||
let commitment_value = find_input(COMMITMENT_PARAMETER_STRING.to_owned(), ¶meters)?;
|
||||
let commitment = input_to_u8_vec(commitment_value)?;
|
||||
let commitment = input_to_bytes(commitment_value)?;
|
||||
|
||||
// Lookup record commitment randomness
|
||||
let commitment_randomness_value = find_input(COMMITMENT_RANDOMNESS_PARAMETER_STRING.to_owned(), ¶meters)?;
|
||||
let commitment_randomness = input_to_u8_vec(commitment_randomness_value)?;
|
||||
let commitment_randomness = input_to_bytes(commitment_randomness_value)?;
|
||||
|
||||
Ok(Self {
|
||||
serial_number,
|
||||
|
@ -15,7 +15,7 @@
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{DPCRecordValues, RecordVerificationError};
|
||||
use leo_ast::Record as RecordAst;
|
||||
use leo_ast::Record as AstRecord;
|
||||
|
||||
use snarkos_dpc::base_dpc::{
|
||||
instantiated::{Components, RecordCommitment},
|
||||
@ -26,12 +26,14 @@ use snarkos_utilities::{bytes::ToBytes, to_bytes, FromBytes};
|
||||
|
||||
use std::convert::TryFrom;
|
||||
|
||||
/// Returns a serialized [`DPCRecordValues`] type if the record commitment is valid given the
|
||||
/// system parameters.
|
||||
pub fn verify_record_commitment(
|
||||
system_parameters: &SystemParameters<Components>,
|
||||
record_ast: &RecordAst,
|
||||
ast_record: &AstRecord,
|
||||
) -> Result<DPCRecordValues, RecordVerificationError> {
|
||||
// generate a dpc record from the typed record
|
||||
let record = DPCRecordValues::try_from(record_ast)?;
|
||||
let record = DPCRecordValues::try_from(ast_record)?;
|
||||
|
||||
// verify record commitment
|
||||
let record_commitment_input = to_bytes![
|
||||
|
@ -19,6 +19,8 @@ use leo_ast::{InputValue, Parameter};
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
/// Returns the input parameter with the given name.
|
||||
/// If a parameter with the given name does not exist, then an error is returned.
|
||||
pub fn find_input(
|
||||
name: String,
|
||||
parameters: &HashMap<Parameter, Option<InputValue>>,
|
||||
@ -36,6 +38,8 @@ pub fn find_input(
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the string of the integer input value.
|
||||
/// If the input value is not an integer, then an error is returned.
|
||||
pub fn input_to_integer_string(input: InputValue) -> Result<String, InputValueError> {
|
||||
match input {
|
||||
InputValue::Integer(_type, string) => Ok(string),
|
||||
@ -43,7 +47,9 @@ pub fn input_to_integer_string(input: InputValue) -> Result<String, InputValueEr
|
||||
}
|
||||
}
|
||||
|
||||
pub fn input_to_u8_vec(input: InputValue) -> Result<Vec<u8>, InputValueError> {
|
||||
/// Returns the given input value as u8 bytes.
|
||||
/// If the given input value cannot be serialized into bytes then an error is returned.
|
||||
pub fn input_to_bytes(input: InputValue) -> Result<Vec<u8>, InputValueError> {
|
||||
let input_array = match input {
|
||||
InputValue::Array(values) => values,
|
||||
value => return Err(InputValueError::ExpectedBytes(value.to_string())),
|
||||
@ -61,7 +67,9 @@ pub fn input_to_u8_vec(input: InputValue) -> Result<Vec<u8>, InputValueError> {
|
||||
Ok(result_vec)
|
||||
}
|
||||
|
||||
pub fn input_to_nested_u8_vec(input: InputValue) -> Result<Vec<Vec<u8>>, InputValueError> {
|
||||
/// Returns the given input value as an array of u8 bytes.
|
||||
/// If the given input value cannot be serialized into an array of bytes then an error is returned.
|
||||
pub fn input_to_nested_bytes(input: InputValue) -> Result<Vec<Vec<u8>>, InputValueError> {
|
||||
let inner_arrays = match input {
|
||||
InputValue::Array(arrays) => arrays,
|
||||
value => return Err(InputValueError::ExpectedBytes(value.to_string())),
|
||||
@ -70,7 +78,7 @@ pub fn input_to_nested_u8_vec(input: InputValue) -> Result<Vec<Vec<u8>>, InputVa
|
||||
let mut result_vec = Vec::with_capacity(inner_arrays.len());
|
||||
|
||||
for input_array in inner_arrays {
|
||||
let array = input_to_u8_vec(input_array)?;
|
||||
let array = input_to_bytes(input_array)?;
|
||||
|
||||
result_vec.push(array);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "leo-symbol-table"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
authors = [ "The Aleo Team <hello@aleo.org>" ]
|
||||
description = "Stores user-defined variables during type resolution"
|
||||
homepage = "https://aleo.org"
|
||||
@ -19,19 +19,19 @@ edition = "2018"
|
||||
|
||||
[dependencies.leo-ast]
|
||||
path = "../ast"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
|
||||
[dependencies.leo-core]
|
||||
path = "../core"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
|
||||
[dependencies.leo-grammar]
|
||||
path = "../grammar"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
|
||||
[dependencies.leo-imports]
|
||||
path = "../imports"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
|
||||
[dependencies.serde]
|
||||
version = "1.0"
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "leo-type-inference"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
authors = [ "The Aleo Team <hello@aleo.org>" ]
|
||||
description = "Checks that a program is correct using type inference"
|
||||
homepage = "https://aleo.org"
|
||||
@ -19,19 +19,19 @@ edition = "2018"
|
||||
|
||||
[dependencies.leo-ast]
|
||||
path = "../ast"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
|
||||
[dependencies.leo-imports]
|
||||
path = "../imports"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
|
||||
[dependencies.leo-grammar]
|
||||
path = "../grammar"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
|
||||
[dependencies.leo-symbol-table]
|
||||
path = "../symbol-table"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
|
||||
[dependencies.serde_json]
|
||||
version = "1.0"
|
||||
|
@ -310,7 +310,6 @@ impl Frame {
|
||||
if variables.names.len() == 1 {
|
||||
// Insert variable into symbol table
|
||||
let variable = variables.names[0].clone();
|
||||
|
||||
self.insert_variable(variable.identifier.name, actual_type, span)?;
|
||||
} else {
|
||||
// Expect a tuple type.
|
||||
@ -867,7 +866,7 @@ impl Frame {
|
||||
fn parse_array_access(&mut self, type_: Type, r_or_e: &RangeOrExpression, span: &Span) -> Result<Type, FrameError> {
|
||||
// Check the type is an array.
|
||||
let element_type = match type_ {
|
||||
Type::Array(type_) => type_,
|
||||
Type::Array(type_) => *type_,
|
||||
type_ => return Err(FrameError::array_access(&type_, span)),
|
||||
};
|
||||
|
||||
@ -890,6 +889,9 @@ impl Frame {
|
||||
|
||||
self.assert_index(&type_, span);
|
||||
}
|
||||
|
||||
// Return a new array type.
|
||||
Ok(Type::Array(Box::new(element_type)))
|
||||
}
|
||||
RangeOrExpression::Expression(expression) => {
|
||||
// Parse the expression type.
|
||||
@ -897,10 +899,11 @@ impl Frame {
|
||||
|
||||
// Assert the type is an index.
|
||||
self.assert_index(&type_, span);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(*element_type)
|
||||
// Return the element type.
|
||||
Ok(element_type)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user