Skip to content

Commit

Permalink
fix(wasm): Avoid requesting stdlib paths from the source-resolver (#2650
Browse files Browse the repository at this point in the history
)

Co-authored-by: Koby <kobyhall@proton.me>
  • Loading branch information
phated and kobyhallx authored Sep 12, 2023
1 parent 29142f4 commit aebab34
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 59 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/test-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
schedule:
- cron: "0 2 * * *" # Run nightly at 2 AM UTC

jobs:
wasm-packages-build-test:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -100,8 +100,8 @@ jobs:
working-directory: ./compiler/integration-tests
run: |
yarn test:browser
- name: Alert on nightly test failure
- name: Alert on nightly test failure
uses: JasonEtco/create-an-issue@v2
if: ${{ failure() && github.event_name == 'schedule' }}
env:
Expand All @@ -110,4 +110,4 @@ jobs:
WORKFLOW_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
with:
update_existing: true
filename: .github/NIGHTLY_TEST_FAILURE.md
filename: .github/NIGHTLY_TEST_FAILURE.md
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"mkhl.direnv",
"jnoortheen.nix-ide",
"rust-lang.rust-analyzer",
"redhat.vscode-yaml"
"redhat.vscode-yaml",
"esbenp.prettier-vscode"
],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": []
Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@
"yaml.schemas": {
"https://json.schemastore.org/github-workflow.json": "${workspaceRoot}/.github/workflows/*.yml"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
12 changes: 9 additions & 3 deletions compiler/fm/src/file_reader.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use rust_embed::RustEmbed;
use std::io::Error;
use std::io::{Error, ErrorKind};
use std::path::Path;

// Based on the environment, we either read files using the rust standard library or we
Expand Down Expand Up @@ -34,15 +34,17 @@ cfg_if::cfg_if! {
}

pub(crate) fn read_file_to_string(path_to_file: &Path) -> Result<String, Error> {
use std::io::ErrorKind;

let path_str = path_to_file.to_str().unwrap();
match StdLibAssets::get(path_str) {

Some(std_lib_asset) => {
Ok(std::str::from_utf8(std_lib_asset.data.as_ref()).unwrap().to_string())
},

None if is_stdlib_asset(path_to_file) => {
Err(Error::new(ErrorKind::NotFound, "invalid stdlib path"))
}

None => match read_file(path_str) {
Ok(buffer) => Ok(buffer),
Err(_) => Err(Error::new(ErrorKind::Other, "could not read file using wasm")),
Expand All @@ -60,6 +62,10 @@ cfg_if::cfg_if! {
Ok(std::str::from_utf8(std_lib_asset.data.as_ref()).unwrap().to_string())
},

None if is_stdlib_asset(path_to_file) => {
Err(Error::new(ErrorKind::NotFound, "invalid stdlib path"))
}

None => std::fs::read_to_string(path_to_file)

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import initACVM, {
compressWitness,
} from "@noir-lang/acvm_js";

// @ts-ignore
// @ts-ignore
import { Barretenberg, RawBuffer, Crs } from '@aztec/bb.js';

import * as TOML from 'smol-toml'
Expand Down Expand Up @@ -49,11 +49,11 @@ const numberOfThreads = navigator.hardwareConcurrency || 1;

let suite = Mocha.Suite.create(mocha.suite, "Noir end to end test");

suite.timeout(60*10e3);//10mins
suite.timeout(60*20e3);//20mins

test_cases.forEach((testInfo) => {
const test_name = testInfo.case.split("/").pop();
const mochaTest = new Mocha.Test(`${test_name} (Compile, Execute, Proove, Verify)`, async () => {
const mochaTest = new Mocha.Test(`${test_name} (Compile, Execute, Prove, Verify)`, async () => {

const base_relative_path = "../../../../..";
const test_case = testInfo.case;
Expand All @@ -67,7 +67,7 @@ test_cases.forEach((testInfo) => {
expect(noir_source).to.be.a.string;

initialiseResolver((id: String) => {
console.log("Resoving:", id);
console.log("Resolving:", id);
return noir_source;
});

Expand Down Expand Up @@ -132,14 +132,15 @@ test_cases.forEach((testInfo) => {

const acirComposer = await api.acirNewAcirComposer(CIRCUIT_SIZE);

// This took ~6.5 minutes!
const proof = await api.acirCreateProof(
acirComposer,
acirUint8Array,
witnessUint8Array,
isRecursive
);


// And this took ~5 minutes!
const verified = await api.acirVerifyProof(acirComposer, proof, isRecursive);

expect(verified).to.be.true;
Expand Down
19 changes: 9 additions & 10 deletions compiler/integration-tests/web-test-runner.config.mjs
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import { fileURLToPath } from 'url';
import { fileURLToPath } from "url";
import { esbuildPlugin } from "@web/dev-server-esbuild";
import { webdriverLauncher } from '@web/test-runner-webdriver';
import { webdriverLauncher } from "@web/test-runner-webdriver";

export default {
browsers: [
webdriverLauncher({
automationProtocol: 'webdriver',
automationProtocol: "webdriver",
capabilities: {
browserName: 'firefox',
'moz:firefoxOptions': {
args: ['-headless'],
browserName: "firefox",
"moz:firefoxOptions": {
args: ["-headless"],
},
},
}),

],
],
plugins: [
esbuildPlugin({
ts: true,
Expand All @@ -27,6 +26,6 @@ export default {
ui: "bdd",
},
},
rootDir: fileURLToPath(new URL('./../..', import.meta.url)),

rootDir: fileURLToPath(new URL("./../..", import.meta.url)),
testsFinishTimeout: 60 * 20e3, // 20 minutes
};
38 changes: 3 additions & 35 deletions compiler/integration-tests/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,15 @@
fastq "^1.6.0"

"@noir-lang/acvm_js@./../../.packages/acvm_js":
version "0.25.0"
version "0.26.0"

"@noir-lang/noir-source-resolver@^1.1.4":
version "1.1.4"
resolved "https://registry.yarnpkg.com/@noir-lang/noir-source-resolver/-/noir-source-resolver-1.1.4.tgz#ed18247c8c30ac45d71f115c0834c1276a4b106f"
integrity sha512-jmUcEoRXRSyhPyOqeDGi3E/7rYRVyqiNR0YQkwqH2G/WyvlHL2o2Ltk2N9iYKMNm1la0ri35Nz9OvIeeXjI4wA==

"@noir-lang/noir_wasm@./../../.packages/noir_wasm":
version "0.10.5"
version "0.11.1"

"@noir-lang/noirc_abi@./../../.packages/noirc_abi_wasm":
version "0.8.0"
Expand Down Expand Up @@ -832,7 +832,7 @@
picomatch "^2.2.2"
source-map "^0.7.3"

"@web/test-runner-core@^0.11.0", "@web/test-runner-core@^0.11.1":
"@web/test-runner-core@^0.11.1":
version "0.11.4"
resolved "https://registry.yarnpkg.com/@web/test-runner-core/-/test-runner-core-0.11.4.tgz#590994c3fc69337e2c5411bf11c293dd061cc07a"
integrity sha512-E7BsKAP8FAAEsfj4viASjmuaYfOw4UlKP9IFqo4W20eVyd1nbUWU3Amq4Jksh7W/j811qh3VaFNjDfCwklQXMg==
Expand Down Expand Up @@ -874,17 +874,6 @@
picomatch "^2.2.2"
v8-to-istanbul "^9.0.1"

"@web/test-runner-coverage-v8@^0.7.0":
version "0.7.1"
resolved "https://registry.yarnpkg.com/@web/test-runner-coverage-v8/-/test-runner-coverage-v8-0.7.1.tgz#b09c73f3e49ef6256cb589a5d7b09d1e28aef9b2"
integrity sha512-R0laTOxbLg7kVKHCBILEmja3w1ihlwkB+eRc7J06/ByyZoQVWxkM9SrTAUx7qCFI6o738Jj24a6TfIDbu3CwSA==
dependencies:
"@web/test-runner-core" "^0.11.0"
istanbul-lib-coverage "^3.0.0"
lru-cache "^8.0.4"
picomatch "^2.2.2"
v8-to-istanbul "^9.0.1"

"@web/test-runner-mocha@^0.7.5":
version "0.7.5"
resolved "https://registry.yarnpkg.com/@web/test-runner-mocha/-/test-runner-mocha-0.7.5.tgz#696f8cb7f5118a72bd7ac5778367ae3bd3fb92cd"
Expand All @@ -893,15 +882,6 @@
"@types/mocha" "^8.2.0"
"@web/test-runner-core" "^0.10.20"

"@web/test-runner-playwright@^0.10.0":
version "0.10.1"
resolved "https://registry.yarnpkg.com/@web/test-runner-playwright/-/test-runner-playwright-0.10.1.tgz#f9fc29dbd771bcb65dcebe826b257d10fb8a8ec5"
integrity sha512-/sEfuKc60UT0gXdn7M6lFddh+nCepO73gLPe2Og7jfoFv2tDkkk41RYBG75jx11RMVOJ6+i1peluLZSVxLlcEg==
dependencies:
"@web/test-runner-core" "^0.11.0"
"@web/test-runner-coverage-v8" "^0.7.0"
playwright "^1.22.2"

"@web/test-runner-webdriver@^0.7.0":
version "0.7.0"
resolved "https://registry.yarnpkg.com/@web/test-runner-webdriver/-/test-runner-webdriver-0.7.0.tgz#cbe64cddbc84e4a7739f2211b3aa85bbe83bf9cd"
Expand Down Expand Up @@ -3189,18 +3169,6 @@ picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.2.2, picomatch@^2.3.1:
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42"
integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==

playwright-core@1.37.1:
version "1.37.1"
resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.37.1.tgz#cb517d52e2e8cb4fa71957639f1cd105d1683126"
integrity sha512-17EuQxlSIYCmEMwzMqusJ2ztDgJePjrbttaefgdsiqeLWidjYz9BxXaTaZWxH1J95SHGk6tjE+dwgWILJoUZfA==

playwright@^1.22.2:
version "1.37.1"
resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.37.1.tgz#6e488d82d7d98b9127c5db9c701f9c956ab47e76"
integrity sha512-bgUXRrQKhT48zHdxDYQTpf//0xDfDd5hLeEhjuSw8rXEGoT9YeElpfvs/izonTNY21IQZ7d3s22jLxYaAnubbQ==
dependencies:
playwright-core "1.37.1"

portfinder@^1.0.32:
version "1.0.32"
resolved "https://registry.yarnpkg.com/portfinder/-/portfinder-1.0.32.tgz#2fe1b9e58389712429dc2bea5beb2146146c7f81"
Expand Down
2 changes: 1 addition & 1 deletion compiler/wasm/test/browser/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ describe("noir wasm compilation", () => {


expect(wasmCircuitBase64).to.equal(cliCircuitBase64);
}).timeout(10e3);
}).timeout(20e3); // 20 seconds
});

0 comments on commit aebab34

Please sign in to comment.