Merge branch 'testnet3' of github.com:AleoHQ/leo into example-auction

This commit is contained in:
collin 2022-08-05 11:56:38 -07:00
commit f7f6cdaef0
23 changed files with 243 additions and 247 deletions

View File

@ -136,124 +136,32 @@ jobs:
paths: project/
- clear_environment:
cache_key: leo-executable-cache
#
# leo-new:
# docker:
# - image: cimg/rust:1.62
# resource_class: xlarge
# steps:
# - attach_workspace:
# at: /home/circleci/project/
# - run:
# name: leo new
# command: |
# export LEO=/home/circleci/project/project/bin/leo
# ./project/.circleci/leo-new.sh
#
# leo-init:
# docker:
# - image: cimg/rust:1.62
# resource_class: xlarge
# steps:
# - attach_workspace:
# at: /home/circleci/project/
# - run:
# name: leo init
# command: |
# export LEO=/home/circleci/project/project/bin/leo
# ./project/.circleci/leo-init.sh
#
# leo-clean:
# docker:
# - image: cimg/rust:1.62
# resource_class: xlarge
# steps:
# - attach_workspace:
# at: /home/circleci/project/
# - run:
# name: leo clean
# command: |
# export LEO=/home/circleci/project/project/bin/leo
# ./project/.circleci/leo-clean.sh
#
# leo-setup:
# docker:
# - image: cimg/rust:1.62
# resource_class: xlarge
# steps:
# - attach_workspace:
# at: /home/circleci/project/
# - run:
# name: leo setup
# command: |
# export LEO=/home/circleci/project/project/bin/leo
# ./project/.circleci/leo-setup.sh
# leo-add-remove:
# docker:
# - image: cimg/rust:1.62
# resource_class: xlarge
# steps:
# - attach_workspace:
# at: /home/circleci/project/
# - run:
# name: leo add & remove
# command: |
# export LEO=/home/circleci/project/project/bin/leo
# ./project/.circleci/leo-add-remove.sh
leo-new:
docker:
- image: cimg/rust:1.62
resource_class: xlarge
steps:
- attach_workspace:
at: /home/circleci/project/
- run:
name: leo new
command: |
export LEO=/home/circleci/project/project/bin/leo
./project/.circleci/leo-new.sh
# todo (collin): uncomment after compiler refactor
# leo-check-constraints:
# docker:
# - image: cimg/rust:1.62
# resource_class: xlarge
# steps:
# - attach_workspace:
# at: /home/circleci/project/
# - run:
# name: leo check constraints for Pedersen Hash
# command: |
# export LEO=/home/circleci/project/project/bin/leo
# ./project/.circleci/leo-check-constraints.sh
#
# leo-login-logout:
# docker:
# - image: cimg/rust:1.62
# resource_class: xlarge
# steps:
# - attach_workspace:
# at: /home/circleci/project/
# - run:
# name: leo login & logout
# command: |
# export LEO=/home/circleci/project/project/bin/leo
# ./project/.circleci/leo-login-logout.sh
#
# leo-clone:
# docker:
# - image: cimg/rust:1.62
# resource_class: xlarge
# steps:
# - attach_workspace:
# at: /home/circleci/project/
# - run:
# name: leo clone
# command: |
# export LEO=/home/circleci/project/project/bin/leo
# ./project/.circleci/leo-clone.sh
#
# leo-publish:
# docker:
# - image: cimg/rust:1.62
# resource_class: xlarge
# steps:
# - attach_workspace:
# at: /home/circleci/project/
# - run:
# name: leo publish
# command: |
# export LEO=/home/circleci/project/project/bin/leo
# ./project/.circleci/leo-publish.sh
leo-clean:
docker:
- image: cimg/rust:1.62
resource_class: xlarge
steps:
- attach_workspace:
at: /home/circleci/project/
- run:
name: leo clean
command: |
export LEO=/home/circleci/project/project/bin/leo
./project/.circleci/leo-clean.sh
workflows:
version: 2
@ -262,30 +170,9 @@ workflows:
- check-style
- clippy
- leo-executable
# - leo-new:
# requires:
# - leo-executable
# - leo-init:
# requires:
# - leo-executable
# - leo-clean:
# requires:
# - leo-executable
# - leo-setup:
# requires:
# - leo-executable
# - leo-add-remove:
# requires:
# - leo-executable
# - leo-check-constraints:
# requires:
# - leo-executable
# - leo-login-logout:
# requires:
# - leo-executable
# - leo-clone:
# requires:
# - leo-executable
# - leo-publish:
# requires:
# - leo-executable
- leo-new:
requires:
- leo-executable
- leo-clean:
requires:
- leo-executable

View File

@ -1,38 +1,23 @@
# leo new hello-world
$LEO new hello-world
# Create a new Leo program named `foo`.
$LEO new foo
ls -la
cd hello-world && ls -la
cd foo && ls -la
# Run `leo build`.
$LEO build
# Assert that the 'outputs' folder is not empty
cd outputs || exit 1
if [ "$(ls -A $DIR)" ]; then
echo "$DIR is not empty"
# Assert that the 'build' folder exists.
if [ "$(ls -A build)" ]; then
echo "build is not empty"
else
echo "$DIR is empty"
echo "build is empty"
exit 1
fi
cd ..
# leo clean
# Run `leo clean`
$LEO clean
cd outputs && ls -la
cd ..
# Assert that the 'outputs' folder is empty
if [ "$(ls -A outputs)" ]; then
echo "outputs is not empty"
exit 1
else
echo "outputs is empty"
fi
# Assert that the 'build' folder is empty
# Assert that the 'build' folder is empty.
if [ "$(ls -A build)" ]; then
echo "build is not empty"
exit 1

View File

@ -1,7 +1,7 @@
# Create a new foo project.
# Create a new Leo program named `foo`.
$LEO new foo
ls -la
cd foo && ls -la
# Try to compile and run the template project.
# Try to run `leo build`.
$LEO run

82
Cargo.lock generated
View File

@ -71,7 +71,7 @@ dependencies = [
[[package]]
name = "aleo"
version = "0.2.0"
source = "git+https://github.com/AleoHQ/aleo.git?rev=8f752ce#8f752ceb5b2508dd5c29b831177097c570481d40"
source = "git+https://github.com/AleoHQ/aleo.git?rev=f3cad52#f3cad526706b54b5665a84aef0a109f8c43ec75a"
dependencies = [
"anyhow",
"clap 3.2.16",
@ -2278,7 +2278,7 @@ dependencies = [
[[package]]
name = "snarkvm"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"anyhow",
"clap 3.2.16",
@ -2304,7 +2304,7 @@ dependencies = [
[[package]]
name = "snarkvm-algorithms"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"aleo-std",
"anyhow",
@ -2338,7 +2338,7 @@ dependencies = [
[[package]]
name = "snarkvm-circuit"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"snarkvm-circuit-account",
"snarkvm-circuit-algorithms",
@ -2352,7 +2352,7 @@ dependencies = [
[[package]]
name = "snarkvm-circuit-account"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"snarkvm-circuit-algorithms",
"snarkvm-circuit-network",
@ -2363,7 +2363,7 @@ dependencies = [
[[package]]
name = "snarkvm-circuit-algorithms"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"snarkvm-circuit-types",
"snarkvm-console-algorithms",
@ -2373,7 +2373,7 @@ dependencies = [
[[package]]
name = "snarkvm-circuit-collections"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"snarkvm-circuit-algorithms",
"snarkvm-circuit-types",
@ -2383,7 +2383,7 @@ dependencies = [
[[package]]
name = "snarkvm-circuit-environment"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"indexmap",
"itertools",
@ -2401,12 +2401,12 @@ dependencies = [
[[package]]
name = "snarkvm-circuit-environment-witness"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
[[package]]
name = "snarkvm-circuit-network"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"snarkvm-circuit-algorithms",
"snarkvm-circuit-collections",
@ -2418,7 +2418,7 @@ dependencies = [
[[package]]
name = "snarkvm-circuit-program"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"snarkvm-circuit-account",
"snarkvm-circuit-network",
@ -2430,7 +2430,7 @@ dependencies = [
[[package]]
name = "snarkvm-circuit-types"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"snarkvm-circuit-environment",
"snarkvm-circuit-types-address",
@ -2445,7 +2445,7 @@ dependencies = [
[[package]]
name = "snarkvm-circuit-types-address"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"snarkvm-circuit-environment",
"snarkvm-circuit-types-boolean",
@ -2458,7 +2458,7 @@ dependencies = [
[[package]]
name = "snarkvm-circuit-types-boolean"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"snarkvm-circuit-environment",
"snarkvm-console-types-boolean",
@ -2467,7 +2467,7 @@ dependencies = [
[[package]]
name = "snarkvm-circuit-types-field"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"snarkvm-circuit-environment",
"snarkvm-circuit-types-boolean",
@ -2477,7 +2477,7 @@ dependencies = [
[[package]]
name = "snarkvm-circuit-types-group"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"snarkvm-circuit-environment",
"snarkvm-circuit-types-boolean",
@ -2490,7 +2490,7 @@ dependencies = [
[[package]]
name = "snarkvm-circuit-types-integers"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"snarkvm-circuit-environment",
"snarkvm-circuit-types-boolean",
@ -2501,7 +2501,7 @@ dependencies = [
[[package]]
name = "snarkvm-circuit-types-scalar"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"snarkvm-circuit-environment",
"snarkvm-circuit-types-boolean",
@ -2512,7 +2512,7 @@ dependencies = [
[[package]]
name = "snarkvm-circuit-types-string"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"snarkvm-circuit-environment",
"snarkvm-circuit-types-boolean",
@ -2524,7 +2524,7 @@ dependencies = [
[[package]]
name = "snarkvm-compiler"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"anyhow",
"colored",
@ -2549,7 +2549,7 @@ dependencies = [
[[package]]
name = "snarkvm-console"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"snarkvm-console-account",
"snarkvm-console-algorithms",
@ -2562,7 +2562,7 @@ dependencies = [
[[package]]
name = "snarkvm-console-account"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"base58",
"snarkvm-console-network",
@ -2572,7 +2572,7 @@ dependencies = [
[[package]]
name = "snarkvm-console-algorithms"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"blake2s_simd",
"smallvec",
@ -2584,7 +2584,7 @@ dependencies = [
[[package]]
name = "snarkvm-console-collections"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"aleo-std",
"rayon",
@ -2595,7 +2595,7 @@ dependencies = [
[[package]]
name = "snarkvm-console-network"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"anyhow",
"itertools",
@ -2613,7 +2613,7 @@ dependencies = [
[[package]]
name = "snarkvm-console-network-environment"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"anyhow",
"bech32",
@ -2631,7 +2631,7 @@ dependencies = [
[[package]]
name = "snarkvm-console-program"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"enum_index",
"enum_index_derive",
@ -2648,7 +2648,7 @@ dependencies = [
[[package]]
name = "snarkvm-console-types"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"snarkvm-console-network-environment",
"snarkvm-console-types-address",
@ -2663,7 +2663,7 @@ dependencies = [
[[package]]
name = "snarkvm-console-types-address"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"snarkvm-console-network-environment",
"snarkvm-console-types-boolean",
@ -2674,7 +2674,7 @@ dependencies = [
[[package]]
name = "snarkvm-console-types-boolean"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"snarkvm-console-network-environment",
]
@ -2682,7 +2682,7 @@ dependencies = [
[[package]]
name = "snarkvm-console-types-field"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"snarkvm-console-network-environment",
"snarkvm-console-types-boolean",
@ -2691,7 +2691,7 @@ dependencies = [
[[package]]
name = "snarkvm-console-types-group"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"snarkvm-console-network-environment",
"snarkvm-console-types-boolean",
@ -2702,7 +2702,7 @@ dependencies = [
[[package]]
name = "snarkvm-console-types-integers"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"snarkvm-console-network-environment",
"snarkvm-console-types-boolean",
@ -2712,7 +2712,7 @@ dependencies = [
[[package]]
name = "snarkvm-console-types-scalar"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"snarkvm-console-network-environment",
"snarkvm-console-types-boolean",
@ -2722,7 +2722,7 @@ dependencies = [
[[package]]
name = "snarkvm-console-types-string"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"snarkvm-console-network-environment",
"snarkvm-console-types-boolean",
@ -2733,7 +2733,7 @@ dependencies = [
[[package]]
name = "snarkvm-curves"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"derivative",
"rand",
@ -2747,7 +2747,7 @@ dependencies = [
[[package]]
name = "snarkvm-fields"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"anyhow",
"derivative",
@ -2762,7 +2762,7 @@ dependencies = [
[[package]]
name = "snarkvm-parameters"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"aleo-std",
"anyhow",
@ -2785,7 +2785,7 @@ dependencies = [
[[package]]
name = "snarkvm-r1cs"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"anyhow",
"cfg-if",
@ -2801,7 +2801,7 @@ dependencies = [
[[package]]
name = "snarkvm-utilities"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"aleo-std",
"anyhow",
@ -2819,7 +2819,7 @@ dependencies = [
[[package]]
name = "snarkvm-utilities-derives"
version = "0.7.5"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=4576d44#4576d44373e537c737dfcc8aad6378fa1337c563"
source = "git+https://github.com/AleoHQ/snarkVM.git?rev=5770366#57703667bb15a0cff5ea1887fe55134a90bd5b44"
dependencies = [
"proc-macro-crate",
"proc-macro-error",

View File

@ -62,11 +62,11 @@ version = "1.5.3"
[dependencies.aleo]
git = "https://github.com/AleoHQ/aleo.git"
rev = "8f752ce"
rev = "f3cad52"
[dependencies.snarkvm]
git = "https://github.com/AleoHQ/snarkVM.git"
rev = "4576d44"
rev = "5770366"
features = ["circuit", "console", "parallel"]
[dependencies.backtrace]

View File

@ -13,7 +13,9 @@
// 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 super::*;
use leo_span::sym;
/// An initializer for a single field / variable of a circuit initializer expression.
/// That is, in `Foo { bar: 42, baz }`, this is either `bar: 42`, or `baz`.
@ -50,6 +52,34 @@ pub struct CircuitExpression {
pub span: Span,
}
impl CircuitExpression {
/// Returns true if the record has all required fields and visibility.
pub fn check_record(&self) -> bool {
let has_member = |symbol| self.members.iter().any(|variable| variable.identifier.name == symbol);
has_member(sym::owner) && has_member(sym::gates) && has_member(sym::_nonce)
}
/// Returns the circuit as a record interface with visibility.
pub fn to_record_string(&self) -> String {
format!(
"{{{}}}",
self.members
.iter()
.map(|variable| {
// Write default visibility.
if variable.identifier.name == sym::_nonce {
format!("{}.public", variable)
} else {
format!("{}.private", variable)
}
})
.collect::<Vec<_>>()
.join(", ")
)
}
}
impl fmt::Display for CircuitExpression {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(

View File

@ -58,17 +58,8 @@ impl InputAst {
Some(circuit) => match circuit.is_record {
false => definition.value.to_string(),
true => match &definition.value {
Expression::Circuit(circuit_expression) => {
format!(
"{{{}}}",
circuit_expression
.members
.iter()
.map(|x| format!("{}.private", x))
.collect::<Vec<_>>()
.join(", ")
)
}
// Print out the record interface with visibility.
Expression::Circuit(circuit_expression) => circuit_expression.to_record_string(),
_ => panic!("Input error: Expected a circuit expression."),
},
},

View File

@ -47,7 +47,7 @@ version = "1.4.0"
[dev-dependencies.snarkvm]
git = "https://github.com/AleoHQ/snarkVM.git"
rev = "4576d44"
rev = "5770366"
features = ["circuit", "console", "parallel"]
[dev-dependencies.serde]

View File

@ -32,7 +32,7 @@ version = "1.5.3"
[dependencies.snarkvm-console]
git = "https://github.com/AleoHQ/snarkVM.git"
rev = "4576d44"
rev = "5770366"
features = ["account", "network"]
[dependencies.clap]

View File

@ -39,6 +39,8 @@ pub(crate) struct ParserContext<'a> {
pub(crate) prev_token: SpannedToken,
/// true if parsing an expression for if and loop statements -- means circuit inits are not legal
pub(crate) disallow_circuit_construction: bool,
/// true if parsing an identifier inside an input file.
pub(crate) allow_identifier_underscores: bool,
}
/// Dummy span used to appease borrow checker.
@ -59,6 +61,7 @@ impl<'a> ParserContext<'a> {
let mut p = Self {
handler,
disallow_circuit_construction: false,
allow_identifier_underscores: false,
prev_token: token.clone(),
token,
tokens,

View File

@ -17,6 +17,7 @@
use super::*;
use leo_errors::{ParserError, Result};
use leo_span::Symbol;
use snarkvm_console::{account::Address, network::Testnet3};
const INT_TYPES: &[Token] = &[
@ -463,7 +464,14 @@ impl ParserContext<'_> {
}
fn parse_circuit_member(&mut self) -> Result<CircuitVariableInitializer> {
let identifier = self.expect_identifier()?;
let identifier = if self.allow_identifier_underscores && self.eat(&Token::Underscore) {
// Allow `_nonce` for circuit records.
let identifier_without_underscore = self.expect_identifier()?;
Identifier::new(Symbol::intern(&format!("_{}", identifier_without_underscore.name)))
} else {
self.expect_identifier()?
};
let expression = if self.eat(&Token::Colon) {
// Parse individual circuit variable declarations.
Some(self.parse_expression()?)
@ -547,11 +555,11 @@ impl ParserContext<'_> {
}
Token::True => Expression::Literal(Literal::Boolean(true, span)),
Token::False => Expression::Literal(Literal::Boolean(false, span)),
Token::AddressLit(addr) => {
if addr.parse::<Address<Testnet3>>().is_err() {
self.emit_err(ParserError::invalid_address_lit(&addr, span));
Token::AddressLit(address_string) => {
if address_string.parse::<Address<Testnet3>>().is_err() {
self.emit_err(ParserError::invalid_address_lit(&address_string, span));
}
Expression::Literal(Literal::Address(addr, span))
Expression::Literal(Literal::Address(address_string, span))
}
Token::StaticString(value) => Expression::Literal(Literal::String(value, span)),
Token::Identifier(name) => {

View File

@ -21,6 +21,8 @@ use leo_errors::{ParserError, Result};
impl ParserContext<'_> {
/// Returns a [`ParsedInputFile`] struct filled with the data acquired in the file.
pub(crate) fn parse_input(&mut self) -> Result<InputAst> {
// Allow underscores in identifiers for input record declarations.
self.allow_identifier_underscores = true;
let mut sections = Vec::new();
while self.has_next() {
@ -31,6 +33,9 @@ impl ParserContext<'_> {
}
}
// Do not allow underscores in identifiers outside of input files.
self.allow_identifier_underscores = false;
Ok(InputAst { sections })
}

View File

@ -386,12 +386,12 @@ impl Token {
'^' => return match_two(&mut input, Token::BitXor, '=', Token::BitXorAssign),
_ => (),
}
if let Some(ident) = eat_identifier(&mut input) {
if let Some(identifier) = eat_identifier(&mut input) {
return Ok((
ident.len(),
identifier.len(),
// todo: match on symbols instead of hard-coded &str's
match &*ident {
x if x.starts_with("aleo1") => Token::AddressLit(ident),
match &*identifier {
x if x.starts_with("aleo1") => Token::AddressLit(identifier),
"address" => Token::Address,
"bool" => Token::Bool,
"circuit" => Token::Circuit,
@ -424,7 +424,7 @@ impl Token {
"u32" => Token::U32,
"u64" => Token::U64,
"u128" => Token::U128,
_ => Token::Identifier(Symbol::intern(&ident)),
_ => Token::Identifier(Symbol::intern(&identifier)),
},
));
}

View File

@ -217,6 +217,7 @@ symbols! {
private,
owner,
gates,
_nonce,
// input file
registers,

View File

@ -184,13 +184,18 @@ atomic-literal = numeric-literal
/ address-literal
/ string-literal
symbol = "!" / "&&" / "||"
symbol = "!"
/ "&&" / "||"
/ "==" / "!="
/ "<" / "<=" / ">" / ">="
/ "&" / "|" / "^"
/ "<<" / ">>"
/ "+" / "-" / "*" / "/" / "%" / "**"
/ "="
/ "+=" / "-=" / "*=" / "/=" / "%=" / "**="
/ "<<=" / ">>="
/ "&=" / "|=" / "^="
/ "&&=" / "||="
/ "(" / ")"
/ "[" / "]"
/ "{" / "}"
@ -375,6 +380,19 @@ loop-statement = %s"for" identifier ":" type
block
assignment-operator = "="
/ "+="
/ "-="
/ "*="
/ "/="
/ "%="
/ "**="
/ "<<="
/ ">>="
/ "&="
/ "|="
/ "^="
/ "&&="
/ "||="
assignment-statement = expression assignment-operator expression ";"

25
examples/README.md Normal file
View File

@ -0,0 +1,25 @@
# Leo Examples
This directory includes the following Leo code examples:
1. Hello World -> Basic Sum of two u32
2. Groups -> Basic operations over groups
3. Core -> Core circuits functions over a field type
4. Bubblesort -> Sorting algorithms over a tuple
5. Import point -> Import code from an other file
6. Message -> Initialization of a circuit type
7. Token -> Record example
## Build Guide
To compile each example, run:
```bash
leo build
```
When you run this command for the first time the snarkvm parameters (universal setup) will be downloaded, these are necessary to run the circuits.
To run each program, run:
```bash
leo run main
```
This command will look in the input file inputs/*.in where should find a section [main] and use the variables as inputs to the program.

View File

@ -9,5 +9,11 @@ leo build
To run this program, run:
```bash
leo run
```
leo run main
```
## Overview
This example shows how to sort an array.
It takes the input data from inputs/bubblesort.in

View File

@ -9,5 +9,27 @@ leo build
To run this program, run:
```bash
leo run
```
leo run main
```
## Overview
This example shows how to do basic operations over groups.
It takes the input data from inputs/groups.in
## Documentation Group Element
The set of affine points on the elliptic curve passed into the Leo compiler forms a group. Leo supports this set as a primitive data type. Group elements are special since their values can be defined as coordinate pairs ```(x, y)group```. The group type keyword group must be used when specifying a pair of group coordinates since implicit syntax would collide with normal tuple (a, b) values.
```
let b = 0group; // the zero of the group
let a = 1group; // the group generator
let c = 2group; // 2 * the group generator
let d = (0, 1)group; // coordinate notation
```

View File

@ -9,5 +9,10 @@ leo build
To run this program, run:
```bash
leo run
```
leo run main
```
## Overview
This example shows how to sum two u32 numbers.
It takes the input data from inputs/helloworld.in

View File

@ -8,6 +8,7 @@ token: Token = Token {
owner: aleo1ht2a9q0gsd38j0se4t9lsfulxgqrens2vgzgry3pkvs93xrrzu8s892zn7,
gates: 0u64,
amount: 100u64,
_nonce: 0group,
};
to: address = aleo1mgfq6g40l6zkhsm063n3uhr43qk5e0zsua5aszeq5080dsvlcvxsn0rrau;
amount: u64 = 50u64;

View File

@ -42,6 +42,8 @@ use tracing::span::Span;
/// require Build command output as their input.
#[derive(StructOpt, Clone, Debug, Default)]
pub struct BuildOptions {
#[structopt(long, help = "Enables offline mode.")]
pub offline: bool,
#[structopt(long, help = "Enable spans in AST snapshots.")]
pub enable_spans: bool,
#[structopt(long, help = "Writes all AST snapshots for the different compiler phases.")]
@ -115,7 +117,7 @@ impl Command for Build {
let build_directory = BuildDirectory::open(&package_path)?;
// Initialize error handler
let handler = leo_errors::emitter::Handler::default();
let handler = Handler::default();
// Fetch paths to all .leo files in the source directory.
let source_files = SourceDirectory::files(&package_path)?;
@ -178,8 +180,12 @@ impl Command for Build {
std::env::set_current_dir(&build_directory)
.map_err(|err| PackageError::failed_to_set_cwd(build_directory.display(), err))?;
// Call the `aleo build` command from the Aleo SDK.
let command = AleoBuild::try_parse_from(&[ALEO_CLI_COMMAND]).map_err(CliError::failed_to_execute_aleo_build)?;
// Call the `aleo build` command with the appropriate from the Aleo SDK.
let mut args = vec![ALEO_CLI_COMMAND];
if self.compiler_options.offline {
args.push("--offline");
}
let command = AleoBuild::try_parse_from(&args).map_err(CliError::failed_to_execute_aleo_build)?;
let result = command.parse().map_err(CliError::failed_to_execute_aleo_build)?;
// Log the result of the build

View File

@ -76,6 +76,9 @@ impl Command for Run {
.map_err(|err| PackageError::failed_to_set_cwd(build_directory.display(), err))?;
// Call the `aleo run` command from the Aleo SDK.
if self.compiler_options.offline {
arguments.push(String::from("--offline"));
}
let command = AleoRun::try_parse_from(&arguments).map_err(CliError::failed_to_parse_aleo_run)?;
let res = command.parse().map_err(CliError::failed_to_execute_aleo_run)?;