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

fix(wasm): Avoid requesting stdlib paths from the source-resolver #2650

Merged
merged 19 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from 16 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
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
kevaundray marked this conversation as resolved.
Show resolved Hide resolved

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(
phated marked this conversation as resolved.
Show resolved Hide resolved
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
};