Skip to content

Commit

Permalink
Merge #692 #741 #743 #744
Browse files Browse the repository at this point in the history
692: [CLI] Changes compiler error message for console.assert r=collinc97 a=damirka

Closes #580

- changes error message for console.assert inside main()
- small rewrite of setup command
- adds some auto-formatting 

## Motivation

Current error message causes confusion. 

## Test Plan

Does not require additional testing.

741: Bump serde from 1.0.123 to 1.0.124 r=collinc97 a=dependabot-preview[bot]

Bumps [serde](https://github.com/serde-rs/serde) from 1.0.123 to 1.0.124.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/serde-rs/serde/releases">serde's releases</a>.</em></p>
<blockquote>
<h2>v1.0.124</h2>
<ul>
<li>Fix possible panic deserializing invalid data as <code>SystemTime</code> (<a href="https://github-redirect.dependabot.com/serde-rs/serde/issues/1997">#1997</a>, thanks <a href="https://github.com/cyang1"><code>@cyang1</code></a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/serde-rs/serde/commit/5a8dcac2ed1407fab3f7fd23f2d56af42dcd448f"><code>5a8dcac</code></a> Release 1.0.124</li>
<li><a href="https://github.com/serde-rs/serde/commit/697b082e90ea4c8204786d74d7271b0c27a63bd6"><code>697b082</code></a> Touch up PR 1997</li>
<li><a href="https://github.com/serde-rs/serde/commit/d91075c8d53a1bfc839441c410718e5b7d565bc5"><code>d91075c</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/serde-rs/serde/issues/1997">#1997</a> from cyang1/systemtime-panics</li>
<li><a href="https://github.com/serde-rs/serde/commit/4118cec731f2a9fa2b32de7234b0becfea6788f8"><code>4118cec</code></a> Prevent various panics when deserializing malformed SystemTime</li>
<li><a href="https://github.com/serde-rs/serde/commit/c26101532509477132721a8c56b7024891aaf1b4"><code>c261015</code></a> Ignore incorrect suggestion from manual_map lint</li>
<li><a href="https://github.com/serde-rs/serde/commit/6b5e5a83d062495669ca06fac2da36daac4f1733"><code>6b5e5a8</code></a> Ignore let_underscore_drop pedantic clippy lint</li>
<li><a href="https://github.com/serde-rs/serde/commit/bc6b2b1deef5755e1ef8b5c2926c0b27bdbf9753"><code>bc6b2b1</code></a> Make json5 description capitalization consistent with other links</li>
<li><a href="https://github.com/serde-rs/serde/commit/beb21cb640e8280bb853bdbe7b4c194e5fa34a33"><code>beb21cb</code></a> Ignore new missing_panics_doc pedantic clippy lint</li>
<li><a href="https://github.com/serde-rs/serde/commit/7cfebbcd72837744c480439ca3b2af02f4c599ff"><code>7cfebbc</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/serde-rs/serde/issues/1974">#1974</a> from Mingun/new-internally-tagged-tests</li>
<li><a href="https://github.com/serde-rs/serde/commit/b60c03ec3f406ce2466c4de0d5df5fbe67102f2f"><code>b60c03e</code></a> Extend test_internally_tagged_newtype_variant_containing_unit_struct to cover...</li>
<li>Additional commits viewable in <a href="https://github.com/serde-rs/serde/compare/v1.0.123...v1.0.124">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://api.dependabot.com/badges/compatibility_score?dependency-name=serde&package-manager=cargo&previous-version=1.0.123&new-version=1.0.124)](https://dependabot.com/compatibility-score/?dependency-name=serde&package-manager=cargo&previous-version=1.0.123&new-version=1.0.124)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language
- `@dependabot badge me` will comment on this PR with code to add a "Dependabot enabled" badge to your readme

Additionally, you can set the following in your Dependabot [dashboard](https://app.dependabot.com):
- Update frequency (including time of day and day of week)
- Pull request limits (per update run and/or open at any time)
- Out-of-range updates (receive only lockfile updates, if desired)
- Security updates (receive only security updates, if desired)



</details>

743: Bump self_update from 0.25.0 to 0.26.0 r=collinc97 a=dependabot-preview[bot]

Bumps [self_update](https://github.com/jaemk/self_update) from 0.25.0 to 0.26.0.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/jaemk/self_update/blob/master/CHANGELOG.md">self_update's changelog</a>.</em></p>
<blockquote>
<h2>[0.26.0]</h2>
<h3>Added</h3>
<h3>Changed</h3>
<ul>
<li>Clean up dangling temporary directories on Windows.</li>
</ul>
<h3>Removed</h3>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li>See full diff in <a href="https://github.com/jaemk/self_update/commits">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://api.dependabot.com/badges/compatibility_score?dependency-name=self_update&package-manager=cargo&previous-version=0.25.0&new-version=0.26.0)](https://dependabot.com/compatibility-score/?dependency-name=self_update&package-manager=cargo&previous-version=0.25.0&new-version=0.26.0)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language
- `@dependabot badge me` will comment on this PR with code to add a "Dependabot enabled" badge to your readme

Additionally, you can set the following in your Dependabot [dashboard](https://app.dependabot.com):
- Update frequency (including time of day and day of week)
- Pull request limits (per update run and/or open at any time)
- Out-of-range updates (receive only lockfile updates, if desired)
- Security updates (receive only security updates, if desired)



</details>

744: Bump indexmap from 1.6.1 to 1.6.2 r=collinc97 a=dependabot-preview[bot]

Bumps [indexmap](https://github.com/bluss/indexmap) from 1.6.1 to 1.6.2.
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/bluss/indexmap/commit/4a9e8872fc2b806f4dbb1ee1cf6d690b0d029490"><code>4a9e887</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/bluss/indexmap/issues/178">#178</a> from cuviper/release-1.6.2</li>
<li><a href="https://github.com/bluss/indexmap/commit/6b54fded902f9d0d10a8a15ff3addf09eccd9380"><code>6b54fde</code></a> Release 1.6.2</li>
<li><a href="https://github.com/bluss/indexmap/commit/0dc0c7b73de03a56f68f4de1f5d8896985572454"><code>0dc0c7b</code></a> cargo fmt</li>
<li><a href="https://github.com/bluss/indexmap/commit/c7da2199f88a2903e3e1d4e35d0a0f3875f8e846"><code>c7da219</code></a> Continue <a href="https://github-redirect.dependabot.com/bluss/indexmap/issues/167">#167</a> with more &quot;postion&quot; typos</li>
<li><a href="https://github.com/bluss/indexmap/commit/1f1e049fa664af6ab45e83e235d4eb230d8c59bd"><code>1f1e049</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/bluss/indexmap/issues/175">#175</a> from cuviper/or_insert_with_key</li>
<li><a href="https://github.com/bluss/indexmap/commit/eebb54cefe4d0062d08d0c7430f5b04894bd0704"><code>eebb54c</code></a> add Entry::or_insert_with_key like Rust 1.50</li>
<li><a href="https://github.com/bluss/indexmap/commit/ddc20888df85221143e9bdde946f3e6c85712b8f"><code>ddc2088</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/bluss/indexmap/issues/170">#170</a> from cuviper/entry-key</li>
<li><a href="https://github.com/bluss/indexmap/commit/0d801a6c24195099c73612cfedeb96db3bead30f"><code>0d801a6</code></a> Document all entry methods</li>
<li><a href="https://github.com/bluss/indexmap/commit/29a4f1904efce0b44b14e891e3600adaf0944318"><code>29a4f19</code></a> Change OccupiedEntry::key() to return the existing key in the map</li>
<li><a href="https://github.com/bluss/indexmap/commit/015eeea4a2026dd6e1026762969dc88d16538e74"><code>015eeea</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/bluss/indexmap/issues/167">#167</a> from avl/patch-1</li>
<li>Additional commits viewable in <a href="https://github.com/bluss/indexmap/compare/1.6.1...1.6.2">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://api.dependabot.com/badges/compatibility_score?dependency-name=indexmap&package-manager=cargo&previous-version=1.6.1&new-version=1.6.2)](https://dependabot.com/compatibility-score/?dependency-name=indexmap&package-manager=cargo&previous-version=1.6.1&new-version=1.6.2)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language
- `@dependabot badge me` will comment on this PR with code to add a "Dependabot enabled" badge to your readme

Additionally, you can set the following in your Dependabot [dashboard](https://app.dependabot.com):
- Update frequency (including time of day and day of week)
- Pull request limits (per update run and/or open at any time)
- Out-of-range updates (receive only lockfile updates, if desired)
- Security updates (receive only security updates, if desired)



</details>

Co-authored-by: damirka <damirka.ru@gmail.com>
Co-authored-by: collin <collin.chin@berkeley.edu>
Co-authored-by: Collin Chin <collin.chin@berkeley.edu>
Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
  • Loading branch information
4 people committed Mar 9, 2021
5 parents c243491 + a18b757 + 12c8c6b + 2ffdd83 + 96eea74 commit ef3d278
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 86 deletions.
16 changes: 8 additions & 8 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ version = "0.11.1"
features = [ "blocking", "json", "multipart" ]

[dependencies.self_update]
version = "0.25.0"
version = "0.26.0"
features = [ "archive-zip" ]

[dependencies.serde]
Expand Down
2 changes: 1 addition & 1 deletion ast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ path = "../input"
version = "1.2.3"

[dependencies.indexmap]
version = "1.6.1"
version = "1.6.2"
features = [ "serde-1" ]

[dependencies.pest]
Expand Down
2 changes: 1 addition & 1 deletion compiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ version = "1.3"
version = "0.4.2"

[dependencies.indexmap]
version = "1.6.1"
version = "1.6.2"
features = [ "serde-1" ]

[dependencies.pest]
Expand Down
5 changes: 3 additions & 2 deletions compiler/src/errors/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ impl ConsoleError {
}

pub fn assertion_depends_on_input(span: &Span) -> Self {
let message =
"console.assert() failed to evaluate. This error is caused by empty input file values".to_string();
let message = "console.assert() does not produce constraints and cannot use inputs. \
Assertions should only be used in @test functions"
.to_string();

Self::new_from_span(message, span)
}
Expand Down
2 changes: 1 addition & 1 deletion imports/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ path = "../parser"
version = "1.2.3"

[dependencies.indexmap]
version = "1.6.1"
version = "1.6.2"
features = [ "serde-1" ]

[dependencies.thiserror]
Expand Down
131 changes: 60 additions & 71 deletions leo/commands/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@
use super::build::Build;
use crate::{commands::Command, context::Context};
use leo_compiler::{compiler::Compiler, group::targets::edwards_bls12::EdwardsGroupType};
use leo_package::{
outputs::{ProvingKeyFile, VerificationKeyFile},
source::{MAIN_FILENAME, SOURCE_DIRECTORY_NAME},
};
use leo_package::outputs::{ProvingKeyFile, VerificationKeyFile};

use anyhow::{anyhow, Result};
use rand::thread_rng;
Expand Down Expand Up @@ -60,74 +57,66 @@ impl Command for Setup {
let path = context.dir()?;
let package_name = context.manifest()?.get_package_name();

match input {
Some((program, checksum_differs)) => {
// Check if a proving key and verification key already exists
let keys_exist = ProvingKeyFile::new(&package_name).exists_at(&path)
&& VerificationKeyFile::new(&package_name).exists_at(&path);

// If keys do not exist or the checksum differs, run the program setup
let (proving_key, prepared_verifying_key) = if !keys_exist || checksum_differs {
tracing::info!("Starting...");

// Run the program setup operation
let rng = &mut thread_rng();
let (proving_key, prepared_verifying_key) =
Groth16::<Bls12_377, Compiler<Fr, _>, Vec<Fr>>::setup(&program, rng)?;

// TODO (howardwu): Convert parameters to a 'proving key' struct for serialization.
// Write the proving key file to the output directory
let proving_key_file = ProvingKeyFile::new(&package_name);
tracing::info!("Saving proving key ({:?})", proving_key_file.full_path(&path));
let mut proving_key_bytes = vec![];
proving_key.write(&mut proving_key_bytes)?;
let _ = proving_key_file.write_to(&path, &proving_key_bytes)?;
tracing::info!("Complete");

// Write the verification key file to the output directory
let verification_key_file = VerificationKeyFile::new(&package_name);
tracing::info!("Saving verification key ({:?})", verification_key_file.full_path(&path));
let mut verification_key = vec![];
proving_key.vk.write(&mut verification_key)?;
let _ = verification_key_file.write_to(&path, &verification_key)?;
tracing::info!("Complete");

(proving_key, prepared_verifying_key)
} else {
tracing::info!("Detected saved setup");

// Read the proving key file from the output directory
tracing::info!("Loading proving key...");

if self.skip_key_check {
tracing::info!("Skipping curve check");
}
let proving_key_bytes = ProvingKeyFile::new(&package_name).read_from(&path)?;
let proving_key =
Parameters::<Bls12_377>::read(proving_key_bytes.as_slice(), !self.skip_key_check)?;
tracing::info!("Complete");

// Read the verification key file from the output directory
tracing::info!("Loading verification key...");
let verifying_key_bytes = VerificationKeyFile::new(&package_name).read_from(&path)?;
let verifying_key = VerifyingKey::<Bls12_377>::read(verifying_key_bytes.as_slice())?;

// Derive the prepared verifying key file from the verifying key
let prepared_verifying_key = PreparedVerifyingKey::<Bls12_377>::from(verifying_key);
tracing::info!("Complete");

(proving_key, prepared_verifying_key)
};

Ok((program, proving_key, prepared_verifying_key))
// Check if leo build failed
let (program, checksum_differs) = input.ok_or(anyhow!("Unable to build, check that main file exists"))?;

// Check if a proving key and verification key already exists
let keys_exist = ProvingKeyFile::new(&package_name).exists_at(&path)
&& VerificationKeyFile::new(&package_name).exists_at(&path);

// If keys do not exist or the checksum differs, run the program setup
let (proving_key, prepared_verifying_key) = if !keys_exist || checksum_differs {
tracing::info!("Starting...");

// Run the program setup operation
let rng = &mut thread_rng();
let (proving_key, prepared_verifying_key) =
Groth16::<Bls12_377, Compiler<Fr, _>, Vec<Fr>>::setup(&program, rng)
.map_err(|_| anyhow!("{}", "Unable to setup, see command output for more details"))?;

// TODO (howardwu): Convert parameters to a 'proving key' struct for serialization.
// Write the proving key file to the output directory
let proving_key_file = ProvingKeyFile::new(&package_name);
tracing::info!("Saving proving key ({:?})", proving_key_file.full_path(&path));
let mut proving_key_bytes = vec![];
proving_key.write(&mut proving_key_bytes)?;
let _ = proving_key_file.write_to(&path, &proving_key_bytes)?;
tracing::info!("Complete");

// Write the verification key file to the output directory
let verification_key_file = VerificationKeyFile::new(&package_name);
tracing::info!("Saving verification key ({:?})", verification_key_file.full_path(&path));
let mut verification_key = vec![];
proving_key.vk.write(&mut verification_key)?;
let _ = verification_key_file.write_to(&path, &verification_key)?;
tracing::info!("Complete");

(proving_key, prepared_verifying_key)
} else {
tracing::info!("Detected saved setup");

// Read the proving key file from the output directory
tracing::info!("Loading proving key...");

if self.skip_key_check {
tracing::info!("Skipping curve check");
}
None => {
let mut main_file_path = path;
main_file_path.push(SOURCE_DIRECTORY_NAME);
main_file_path.push(MAIN_FILENAME);
let proving_key_bytes = ProvingKeyFile::new(&package_name).read_from(&path)?;
let proving_key = Parameters::<Bls12_377>::read(proving_key_bytes.as_slice(), !self.skip_key_check)?;
tracing::info!("Complete");

Err(anyhow!("Unable to build, check that main file exists"))
}
}
// Read the verification key file from the output directory
tracing::info!("Loading verification key...");
let verifying_key_bytes = VerificationKeyFile::new(&package_name).read_from(&path)?;
let verifying_key = VerifyingKey::<Bls12_377>::read(verifying_key_bytes.as_slice())?;

// Derive the prepared verifying key file from the verifying key
let prepared_verifying_key = PreparedVerifyingKey::<Bls12_377>::from(verifying_key);
tracing::info!("Complete");

(proving_key, prepared_verifying_key)
};

Ok((program, proving_key, prepared_verifying_key))
}
}
2 changes: 1 addition & 1 deletion state/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ default-features = false
version = "0.2.0"

[dependencies.indexmap]
version = "1.6.1"
version = "1.6.2"
features = [ "serde-1" ]

[dependencies.rand]
Expand Down

0 comments on commit ef3d278

Please sign in to comment.