Skip to content

Commit afe6213

Browse files
authored
Merge branch 'master' into gd/issue_6394
2 parents b1d908a + 9ae3c6c commit afe6213

File tree

33 files changed

+417
-491
lines changed

33 files changed

+417
-491
lines changed

.aztec-sync-commit

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
a7f8d9670902dfa4856b8514ce5eb4ad031a44fc
1+
b60a39d989b77702a89ebb24047e5b2419915dc3

.github/actions/download-nargo/action.yml

+11-11
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ description: Downloads the nargo binary from an artifact and adds it to the path
44
runs:
55
using: composite
66
steps:
7-
- name: Download nargo binary
8-
uses: actions/download-artifact@v4
9-
with:
10-
name: nargo
11-
path: ./nargo
7+
- name: Download nargo binary
8+
uses: actions/download-artifact@v4
9+
with:
10+
name: nargo
11+
path: ./nargo
1212

13-
- name: Set nargo on PATH
14-
shell: bash
15-
run: |
16-
nargo_binary="${{ github.workspace }}/nargo/nargo"
17-
chmod +x $nargo_binary
18-
echo "$(dirname $nargo_binary)" >> $GITHUB_PATH
13+
- name: Set nargo on PATH
14+
shell: bash
15+
run: |
16+
nargo_binary="${{ github.workspace }}/nargo/nargo"
17+
chmod +x $nargo_binary
18+
echo "$(dirname $nargo_binary)" >> $GITHUB_PATH

.github/scripts/merge-bench-reports.sh

-27
This file was deleted.

.github/scripts/playwright-install.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/bash
22
set -eu
33

4-
npx -y playwright@1.50 install --with-deps
4+
npx -y playwright@1.49 install --with-deps

.github/workflows/reports.yml

+19-16
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ jobs:
292292
sparse-checkout-cone-mode: false
293293

294294
- name: Download nargo binary
295-
uses: scripts/.github/actions/download-nargo
295+
uses: ./scripts/.github/actions/download-nargo
296296

297297
- name: Checkout
298298
uses: actions/checkout@v4
@@ -390,7 +390,7 @@ jobs:
390390
with:
391391
path: scripts
392392
sparse-checkout: |
393-
./.github/actions/download-nargo/action.yml
393+
.github/actions/download-nargo/action.yml
394394
test_programs/memory_report.sh
395395
test_programs/parse_memory.sh
396396
sparse-checkout-cone-mode: false
@@ -477,18 +477,20 @@ jobs:
477477
uses: actions/download-artifact@v4
478478
with:
479479
name: in_progress_compilation_report
480+
path: ./reports
480481

481482
- name: Download matrix compilation reports
482483
uses: actions/download-artifact@v4
483484
with:
484485
pattern: compilation_report_*
485486
path: ./reports
487+
merge-multiple: true
486488

487489
- name: Merge compilation reports using jq
488490
run: |
489-
mv ./.github/scripts/merge-bench-reports.sh merge-bench-reports.sh
490-
./merge-bench-reports.sh compilation_report
491-
jq ".compilation_reports | map({name: .artifact_name, value: (.time[:-1] | tonumber), unit: \"s\"}) " ./compilation_report.json > time_bench.json
491+
# Github actions seems to not expand "**" in globs by default.
492+
shopt -s globstar
493+
jq --slurp '. | flatten' ./reports/* | tee time_bench.json
492494
493495
- name: Store benchmark result
494496
continue-on-error: true
@@ -532,12 +534,13 @@ jobs:
532534
with:
533535
pattern: compilation_mem_report_*
534536
path: ./reports
537+
merge-multiple: true
535538

536539
- name: Merge memory reports using jq
537540
run: |
538-
mv ./.github/scripts/merge-bench-reports.sh merge-bench-reports.sh
539-
./merge-bench-reports.sh memory_report
540-
jq ".memory_reports | map({name: .artifact_name, value: (.peak_memory | tonumber), unit: \"MB\"}) " ./memory_report.json > memory_bench.json
541+
# Github actions seems to not expand "**" in globs by default.
542+
shopt -s globstar
543+
jq --slurp '. | flatten' ./reports/* | tee memory_bench.json
541544
542545
- name: Store benchmark result
543546
continue-on-error: true
@@ -581,14 +584,13 @@ jobs:
581584
with:
582585
pattern: execution_mem_report_*
583586
path: ./reports
587+
merge-multiple: true
584588

585589
- name: Merge memory reports using jq
586590
run: |
587-
mv ./.github/scripts/merge-bench-reports.sh merge-bench-reports.sh
588-
./merge-bench-reports.sh memory_report
589-
# Rename the memory report as to not clash with the compilation memory report file name
590-
cp memory_report.json execution_memory_report.json
591-
jq ".memory_reports | map({name: .artifact_name, value: (.peak_memory | tonumber), unit: \"MB\"}) " ./execution_memory_report.json > memory_bench.json
591+
# Github actions seems to not expand "**" in globs by default.
592+
shopt -s globstar
593+
jq --slurp '. | flatten' ./reports/* | tee memory_bench.json
592594
593595
- name: Store benchmark result
594596
continue-on-error: true
@@ -633,12 +635,13 @@ jobs:
633635
with:
634636
pattern: execution_report_*
635637
path: ./reports
638+
merge-multiple: true
636639

637640
- name: Merge execution reports using jq
638641
run: |
639-
mv ./.github/scripts/merge-bench-reports.sh merge-bench-reports.sh
640-
./merge-bench-reports.sh execution_report
641-
jq ".execution_reports | map({name: .artifact_name, value: (.time[:-1] | tonumber), unit: \"s\"}) " ./execution_report.json > time_bench.json
642+
# Github actions seems to not expand "**" in globs by default.
643+
shopt -s globstar
644+
jq --slurp '. | flatten' ./reports/* | tee time_bench.json
642645
643646
- name: Store benchmark result
644647
continue-on-error: true

.github/workflows/test-js-packages.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ jobs:
539539
TEST_REPORT_NAME=test_report_$NAME
540540
echo "test_report_name=$TEST_REPORT_NAME" >> $GITHUB_OUTPUT
541541
542-
jq --null-input "{ test_reports: [{ name: \"$NAME\", value: (\"$TIME\" | tonumber), unit: \"s\" }]}" > $TEST_REPORT_NAME.json
542+
jq --null-input "[{ name: \"$NAME\", value: (\"$TIME\" | tonumber), unit: \"s\" }]" > $TEST_REPORT_NAME.json
543543
544544
if [ ! -s $output_file ]; then
545545
# The file is empty so we delete it to signal that `nargo test` failed before it could run any tests
@@ -613,13 +613,13 @@ jobs:
613613
with:
614614
pattern: test_report_*
615615
path: ./reports
616+
merge-multiple: true
616617

617618
- name: Merge test reports using jq
618619
run: |
619-
jq --null-input "{ test_reports: [] }" > test_report.json
620-
mv ./.github/scripts/merge-bench-reports.sh merge-bench-reports.sh
621-
./merge-bench-reports.sh test_report
622-
jq ".test_reports" < ./test_report.json > test_bench.json
620+
# Github actions seems to not expand "**" in globs by default.
621+
shopt -s globstar
622+
jq --slurp '. | flatten' ./reports/* | tee test_bench.json
623623
624624
- name: Store benchmark result
625625
continue-on-error: true

compiler/integration-tests/web-test-runner.config.mjs

+3-4
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ export default {
2626
// playwrightLauncher({ product: "webkit" }),
2727
// playwrightLauncher({ product: "firefox" }),
2828
],
29-
middleware: [async function setGzHeader(ctx, next) {
30-
if (ctx.url.endsWith('.gz')) {
31-
ctx.set('Content-Encoding', 'gzip');
32-
ctx.res.removeHeader('Content-Length');
29+
middleware: [async (ctx, next) => {
30+
if (ctx.url.endsWith('.wasm.gz')) {
31+
ctx.url = ctx.url.replace('/', "/node_modules/@aztec/bb.js/dest/browser/");
3332
}
3433
await next();
3534
}],

compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_globals.rs

+19-11
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ impl BrilligGlobals {
9292
);
9393
}
9494

95+
// NB: Temporary fix to override entry point analysis
96+
let merged_set =
97+
used_globals.values().flat_map(|set| set.iter().copied()).collect::<HashSet<_>>();
98+
for set in used_globals.values_mut() {
99+
*set = merged_set.clone();
100+
}
101+
95102
Self { used_globals, brillig_entry_points, ..Default::default() }
96103
}
97104

@@ -303,10 +310,11 @@ mod tests {
303310
if func_id.to_u32() == 1 {
304311
assert_eq!(
305312
artifact.byte_code.len(),
306-
1,
313+
2,
307314
"Expected just a `Return`, but got more than a single opcode"
308315
);
309-
assert!(matches!(&artifact.byte_code[0], Opcode::Return));
316+
// TODO: Bring this back (https://github.com/noir-lang/noir/issues/7306)
317+
// assert!(matches!(&artifact.byte_code[0], Opcode::Return));
310318
} else if func_id.to_u32() == 2 {
311319
assert_eq!(
312320
artifact.byte_code.len(),
@@ -420,17 +428,17 @@ mod tests {
420428
if func_id.to_u32() == 1 {
421429
assert_eq!(
422430
artifact.byte_code.len(),
423-
2,
431+
30,
424432
"Expected enough opcodes to initialize the globals"
425433
);
426-
let Opcode::Const { destination, bit_size, value } = &artifact.byte_code[0] else {
427-
panic!("First opcode is expected to be `Const`");
428-
};
429-
assert_eq!(destination.unwrap_direct(), GlobalSpace::start());
430-
assert!(matches!(bit_size, BitSize::Field));
431-
assert_eq!(*value, FieldElement::from(1u128));
432-
433-
assert!(matches!(&artifact.byte_code[1], Opcode::Return));
434+
// TODO: Bring this back (https://github.com/noir-lang/noir/issues/7306)
435+
// let Opcode::Const { destination, bit_size, value } = &artifact.byte_code[0] else {
436+
// panic!("First opcode is expected to be `Const`");
437+
// };
438+
// assert_eq!(destination.unwrap_direct(), GlobalSpace::start());
439+
// assert!(matches!(bit_size, BitSize::Field));
440+
// assert_eq!(*value, FieldElement::from(1u128));
441+
// assert!(matches!(&artifact.byte_code[1], Opcode::Return));
434442
} else if func_id.to_u32() == 2 || func_id.to_u32() == 3 {
435443
// We want the entry point which uses globals (f2) and the entry point which calls f2 function internally (f3 through f4)
436444
// to have the same globals initialized.

compiler/noirc_frontend/src/ast/expression.rs

+53-20
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use std::fmt::Display;
44
use thiserror::Error;
55

66
use crate::ast::{
7-
Ident, ItemVisibility, Path, Pattern, Recoverable, Statement, StatementKind,
8-
UnresolvedTraitConstraint, UnresolvedType, UnresolvedTypeData, Visibility,
7+
Ident, ItemVisibility, Path, Pattern, Statement, StatementKind, UnresolvedTraitConstraint,
8+
UnresolvedType, UnresolvedTypeData, Visibility,
99
};
1010
use crate::node_interner::{
1111
ExprId, InternedExpressionKind, InternedStatementKind, QuotedTypeId, TypeId,
@@ -26,6 +26,7 @@ pub enum ExpressionKind {
2626
Index(Box<IndexExpression>),
2727
Call(Box<CallExpression>),
2828
MethodCall(Box<MethodCallExpression>),
29+
Constrain(ConstrainExpression),
2930
Constructor(Box<ConstructorExpression>),
3031
MemberAccess(Box<MemberAccessExpression>),
3132
Cast(Box<CastExpression>),
@@ -226,24 +227,6 @@ impl ExpressionKind {
226227
}
227228
}
228229

229-
impl Recoverable for ExpressionKind {
230-
fn error(_: Span) -> Self {
231-
ExpressionKind::Error
232-
}
233-
}
234-
235-
impl Recoverable for Expression {
236-
fn error(span: Span) -> Self {
237-
Expression::new(ExpressionKind::Error, span)
238-
}
239-
}
240-
241-
impl Recoverable for Option<Expression> {
242-
fn error(span: Span) -> Self {
243-
Some(Expression::new(ExpressionKind::Error, span))
244-
}
245-
}
246-
247230
#[derive(Debug, Eq, Clone)]
248231
pub struct Expression {
249232
pub kind: ExpressionKind,
@@ -600,6 +583,55 @@ impl BlockExpression {
600583
}
601584
}
602585

586+
#[derive(Debug, PartialEq, Eq, Clone)]
587+
pub struct ConstrainExpression {
588+
pub kind: ConstrainKind,
589+
pub arguments: Vec<Expression>,
590+
pub span: Span,
591+
}
592+
593+
impl Display for ConstrainExpression {
594+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
595+
match self.kind {
596+
ConstrainKind::Assert | ConstrainKind::AssertEq => write!(
597+
f,
598+
"{}({})",
599+
self.kind,
600+
vecmap(&self.arguments, |arg| arg.to_string()).join(", ")
601+
),
602+
ConstrainKind::Constrain => {
603+
write!(f, "constrain {}", &self.arguments[0])
604+
}
605+
}
606+
}
607+
}
608+
609+
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
610+
pub enum ConstrainKind {
611+
Assert,
612+
AssertEq,
613+
Constrain,
614+
}
615+
616+
impl ConstrainKind {
617+
pub fn required_arguments_count(&self) -> usize {
618+
match self {
619+
ConstrainKind::Assert | ConstrainKind::Constrain => 1,
620+
ConstrainKind::AssertEq => 2,
621+
}
622+
}
623+
}
624+
625+
impl Display for ConstrainKind {
626+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
627+
match self {
628+
ConstrainKind::Assert => write!(f, "assert"),
629+
ConstrainKind::AssertEq => write!(f, "assert_eq"),
630+
ConstrainKind::Constrain => write!(f, "constrain"),
631+
}
632+
}
633+
}
634+
603635
impl Display for Expression {
604636
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
605637
self.kind.fmt(f)
@@ -616,6 +648,7 @@ impl Display for ExpressionKind {
616648
Index(index) => index.fmt(f),
617649
Call(call) => call.fmt(f),
618650
MethodCall(call) => call.fmt(f),
651+
Constrain(constrain) => constrain.fmt(f),
619652
Cast(cast) => cast.fmt(f),
620653
Infix(infix) => infix.fmt(f),
621654
If(if_expr) => if_expr.fmt(f),

compiler/noirc_frontend/src/ast/mod.rs

-6
Original file line numberDiff line numberDiff line change
@@ -253,12 +253,6 @@ pub enum UnresolvedTypeExpression {
253253
AsTraitPath(Box<AsTraitPath>),
254254
}
255255

256-
impl Recoverable for UnresolvedType {
257-
fn error(span: Span) -> Self {
258-
UnresolvedType { typ: UnresolvedTypeData::Error, span }
259-
}
260-
}
261-
262256
impl std::fmt::Display for GenericTypeArg {
263257
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
264258
match self {

0 commit comments

Comments
 (0)