Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.7.3 #878

Merged
merged 7 commits into from
May 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
## [Unreleased]
https://github.com/Zokrates/ZoKrates/compare/latest...develop

## [0.7.3] - 2021-05-19

### Release
- https://github.com/Zokrates/ZoKrates/releases/tag/0.7.3

### Changes
- Remove substitution in `one_liner.sh` script which caused `Bad substitution` error with `sh`/`dash` (#877, @dark64)
- Put branch isolator behind a compilation flag in the static analyzer (#877, @dark64)

## [0.7.2] - 2021-05-18

### Release
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

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

8 changes: 6 additions & 2 deletions scripts/changelog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,13 @@ EOT
for file in $unreleased
do
IFS=$'-' read -ra entry <<< "$file"
contents=$(cat ${CHANGELOG_PATH}/${file} | tr '\n' ' ')
author=$(join '-' ${entry[@]:1})
echo "- ${contents} (#${entry[0]}, @${author})"

IFS=$'\n' rows=$(cat ${CHANGELOG_PATH}/${file})
for row in $rows
do
echo "- ${row} (#${entry[0]}, @${author})"
done
done

echo -e "\nCopy and paste the markdown above to the appropriate CHANGELOG file."
Expand Down
2 changes: 1 addition & 1 deletion scripts/one_liner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ main() {
cp -r $td/* $dest
else
read -p "ZoKrates is already installed, overwrite (y/n)? " answer
case ${answer:0:1} in
case ${answer} in
y|Y )
rm -rf $dest/*
cp -r $td/* $dest
Expand Down
2 changes: 1 addition & 1 deletion zokrates_book/src/language/imports.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ from "../../../mycode" import foo

### Absolute Imports

Absolute imports don't start with `./` or `../` in the path and are used to import components from the ZoKrates standard library. Please check the according [section](./stdlib.html) for more details.
Absolute imports don't start with `./` or `../` in the path and are used to import components from the ZoKrates standard library. Please check the according [section](/toolbox/stdlib.html) for more details.
2 changes: 1 addition & 1 deletion zokrates_book/src/toolbox/stdlib.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Standard library

ZoKrates comes with a number of reusable components in the form of a Standard Library. In order to import it as described in the [imports](./imports.html) section, the `$ZOKRATES_HOME` environment variable must be set to the `stdlib` folder.
ZoKrates comes with a number of reusable components in the form of a Standard Library. In order to import it as described in the [imports](/language/imports.html) section, the `$ZOKRATES_STDLIB` environment variable must be set to the `stdlib` folder.

The full ZoKrates Standard Library can be found [here](https://github.com/Zokrates/ZoKrates/tree/latest/zokrates_stdlib/stdlib).

Expand Down
2 changes: 1 addition & 1 deletion zokrates_cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "zokrates_cli"
version = "0.7.2"
version = "0.7.3"
authors = ["Jacob Eberhardt <jacob.eberhardt@tu-berlin.de>", "Dennis Kuhnert <mail@kyroy.com>", "Thibaut Schaeffer <thibaut@schaeff.fr>"]
repository = "https://github.com/JacobEberhardt/ZoKrates.git"
edition = "2018"
Expand Down
12 changes: 10 additions & 2 deletions zokrates_cli/src/ops/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::convert::TryFrom;
use std::fs::File;
use std::io::{BufReader, Read};
use std::path::{Path, PathBuf};
use zokrates_core::compile::{check, CompileError};
use zokrates_core::compile::{check, CompileConfig, CompileError};
use zokrates_field::{Bls12_377Field, Bls12_381Field, Bn128Field, Bw6_761Field, Field};
use zokrates_fs_resolver::FileSystemResolver;

Expand Down Expand Up @@ -41,6 +41,11 @@ pub fn subcommand() -> App<'static, 'static> {
.possible_values(constants::CURVES)
.default_value(constants::BN128),
)
.arg(Arg::with_name("isolate-branches")
.long("isolate-branches")
.help("Isolate the execution of branches: a panic in a branch only makes the program panic if this branch is being logically executed")
.required(false)
)
}

pub fn exec(sub_matches: &ArgMatches) -> Result<(), String> {
Expand Down Expand Up @@ -84,8 +89,11 @@ fn cli_check<T: Field>(sub_matches: &ArgMatches) -> Result<(), String> {
)),
}?;

let config =
CompileConfig::default().isolate_branches(sub_matches.is_present("isolate-branches"));

let resolver = FileSystemResolver::with_stdlib_root(stdlib_path);
let _ = check::<T, _>(source, path, Some(&resolver)).map_err(|e| {
let _ = check::<T, _>(source, path, Some(&resolver), &config).map_err(|e| {
format!(
"Check failed:\n\n{}",
e.0.iter()
Expand Down
7 changes: 3 additions & 4 deletions zokrates_cli/src/ops/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,9 @@ fn cli_compile<T: Field>(sub_matches: &ArgMatches) -> Result<(), String> {
)),
}?;

let config = CompileConfig {
allow_unconstrained_variables: sub_matches.is_present("allow-unconstrained-variables"),
isolate_branches: sub_matches.is_present("isolate-branches"),
};
let config = CompileConfig::default()
.allow_unconstrained_variables(sub_matches.is_present("allow-unconstrained-variables"))
.isolate_branches(sub_matches.is_present("isolate-branches"));

let resolver = FileSystemResolver::with_stdlib_root(stdlib_path);
let artifacts: CompilationArtifacts<T> = compile(source, path, Some(&resolver), &config)
Expand Down
2 changes: 1 addition & 1 deletion zokrates_core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "zokrates_core"
version = "0.6.2"
version = "0.6.3"
edition = "2018"
authors = ["Jacob Eberhardt <jacob.eberhardt@tu-berlin.de>", "Dennis Kuhnert <mail@kyroy.com>"]
repository = "https://github.com/JacobEberhardt/ZoKrates"
Expand Down
19 changes: 16 additions & 3 deletions zokrates_core/src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,17 @@ pub struct CompileConfig {
pub isolate_branches: bool,
}

impl CompileConfig {
pub fn allow_unconstrained_variables(mut self, flag: bool) -> Self {
self.allow_unconstrained_variables = flag;
self
}
pub fn isolate_branches(mut self, flag: bool) -> Self {
self.isolate_branches = flag;
self
}
}

type FilePath = PathBuf;

pub fn compile<T: Field, E: Into<imports::Error>>(
Expand All @@ -178,7 +189,7 @@ pub fn compile<T: Field, E: Into<imports::Error>>(
) -> Result<CompilationArtifacts<T>, CompileErrors> {
let arena = Arena::new();

let (typed_ast, abi) = check_with_arena(source, location, resolver, &arena)?;
let (typed_ast, abi) = check_with_arena(source, location, resolver, config, &arena)?;

// flatten input program
let program_flattened = Flattener::flatten(typed_ast, config);
Expand All @@ -205,16 +216,18 @@ pub fn check<T: Field, E: Into<imports::Error>>(
source: String,
location: FilePath,
resolver: Option<&dyn Resolver<E>>,
config: &CompileConfig,
) -> Result<(), CompileErrors> {
let arena = Arena::new();

check_with_arena::<T, _>(source, location, resolver, &arena).map(|_| ())
check_with_arena::<T, _>(source, location, resolver, config, &arena).map(|_| ())
}

fn check_with_arena<'ast, T: Field, E: Into<imports::Error>>(
source: String,
location: FilePath,
resolver: Option<&dyn Resolver<E>>,
config: &CompileConfig,
arena: &'ast Arena<String>,
) -> Result<(ZirProgram<'ast, T>, Abi), CompileErrors> {
let source = arena.alloc(source);
Expand All @@ -228,7 +241,7 @@ fn check_with_arena<'ast, T: Field, E: Into<imports::Error>>(

// analyse (unroll and constant propagation)
typed_ast
.analyse()
.analyse(config)
.map_err(|e| CompileErrors(vec![CompileErrorInner::from(e).in_file(&main_module)]))
}

Expand Down
9 changes: 7 additions & 2 deletions zokrates_core/src/static_analysis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use self::uint_optimizer::UintOptimizer;
use self::unconstrained_vars::UnconstrainedVariableDetector;
use self::variable_read_remover::VariableReadRemover;
use self::variable_write_remover::VariableWriteRemover;
use crate::compile::CompileConfig;
use crate::flat_absy::FlatProg;
use crate::ir::Prog;
use crate::static_analysis::constant_inliner::ConstantInliner;
Expand Down Expand Up @@ -74,11 +75,15 @@ impl fmt::Display for Error {
}

impl<'ast, T: Field> TypedProgram<'ast, T> {
pub fn analyse(self) -> Result<(ZirProgram<'ast, T>, Abi), Error> {
pub fn analyse(self, config: &CompileConfig) -> Result<(ZirProgram<'ast, T>, Abi), Error> {
// inline user-defined constants
let r = ConstantInliner::inline(self);
// isolate branches
let r = Isolator::isolate(r);
let r = if config.isolate_branches {
Isolator::isolate(r)
} else {
r
};
// reduce the program to a single function
let r = reduce_program(r).map_err(Error::from)?;
// generate abi
Expand Down
2 changes: 1 addition & 1 deletion zokrates_js/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "zokrates_js"
version = "1.0.31"
version = "1.0.32"
authors = ["Darko Macesic"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion zokrates_js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "zokrates-js",
"main": "index.js",
"author": "Darko Macesic <darem966@gmail.com>",
"version": "1.0.31",
"version": "1.0.32",
"keywords": [
"zokrates",
"wasm-bindgen",
Expand Down