Skip to content

Commit

Permalink
chore(ssa refactor): SSA refactor main (#1628)
Browse files Browse the repository at this point in the history
* disable mac tests

* feat: added support for modulo ops on brillig (#1621)

* feat: added support for modulo ops

* chore: use ACVM 0.14.3

* revert change as its unrelated

* small comment refactor

---------

Co-authored-by: kevaundray <[email protected]>

* feat(brillig): foreign call/oracle compilation (#1600)

* remove mac runner

* chore: generate brillig opcode for simple identity unconstrained function (#1536)

* feat(brillig): added arithmetic operations on brillig (#1565)

Co-authored-by: kevaundray <[email protected]>

* make ranges be polymorphic integers

* chore(brillig): Clean up handling of Binary operations (#1571)

* chore(ssa refactor): Rename Brillig example (#1563)

* chore(brillig): added tests for all field binary operations (#1586)

* chore(brillig): added tests for brillig integer operations (#1590)

* feat: process blocks and jumps when compiling brillig (#1591)

* process jumps between blocks

* fix jumps

* add doc comments

* cargo fmt

* code refactor

* update code comment

---------

Co-authored-by: kevaundray <[email protected]>

* feat: process blocks and jumps when compiling brillig (#1591)

* process jumps between blocks

* fix jumps

* add doc comments

* cargo fmt

* code refactor

* update code comment

---------

Co-authored-by: kevaundray <[email protected]>

* feat(brillig): start of oracles/foreign calls

* fix: broken tests

* feat(brillig): parsing oracles/foreign calls (#1596)

* feat(brillig): start of oracles/foreign calls

* fix: broken tests

* Update execute.rs

* feat: more foreign call work

* self.data -> self.vars

* chore(brillig): Add handling of the not instruction (#1609)

* test: brillig oracle

* Reinstate option

* make behavior consistent

* remove closure

* change index_type

* Update crates/noirc_frontend/src/hir/type_check/expr.rs

* feat(brillig): loops (#1610)

* make ranges be polymorphic integers

* feat: brillig loop support

* fix: fixed brillig returns and stop

* fix: do not apply constants folding to brillig fns

* chore: update acvm pointer, cleanup

* style: newline on cargo toml

* make behavior consistent

* remove closure

* change index_type

* Update crates/noirc_frontend/src/hir/type_check/expr.rs

* better debug information for unsupported instruction

* remove edge case for optimizations

* clippy fix

* patch infinite loop

---------

Co-authored-by: kevaundray <[email protected]>
Co-authored-by: jfecher <[email protected]>

* feat: Foreign calls compiling and basic print executed in nargo (#1612)

* get foreign calls compiling and basic print executed in nargo

* cargo clipy and cargo fmt

* missing

* Update crates/noirc_evaluator/src/brillig/brillig_gen.rs

* add issue num for logging

---------

Co-authored-by: kevaundray <[email protected]>

* chore: resolve immutable array merge differences (#1617)

* chore(ssa refactor): Switch to immutable arrays (#1578)

* Represent SSA arrays with im::Vector

* Get tests passing

* Implement assign with immutable arrays

* Add constant folding pass

* Update comments

* Clippy

* Update comment

* Update type of array

* Update crates/noirc_evaluator/src/ssa_refactor/ir/instruction.rs

Co-authored-by: Tom French <[email protected]>

* Undo formatting changes in instruction.rs

* Massive acir_gen update

* Refactor acir array operations into a shared function

* Appease clippy

* Update to_radix and to_bits in acir_gen to return arrays

* Disable assert

* Fix convert_type for arrays

* Include AcirType in AcirValue::Var variant

* Fix black box functions

* Appease clippy

* Fix simple_radix

* Add doc comments

---------

Co-authored-by: Tom French <[email protected]>

* feat: Make for-loop range be a polymorphic integer instead of just Field in unconstrained functions (#1583)

* make ranges be polymorphic integers

* make behavior consistent

* remove closure

* change index_type

* Update crates/noirc_frontend/src/hir/type_check/expr.rs

---------

Co-authored-by: jfecher <[email protected]>

* chore(ssa refactor): fix brillig post master merge

* chore(ssa refactor): accidental merge undelete

---------

Co-authored-by: jfecher <[email protected]>
Co-authored-by: Tom French <[email protected]>
Co-authored-by: kevaundray <[email protected]>

* chore(ssa refactor): Add more documentation for truncation  (#1607)

* add more documentation

* small change

* Update crates/noirc_evaluator/src/ssa_refactor/acir_gen/acir_ir/generated_acir.rs

* Update .github/workflows/test.yml

* Update .github/workflows/test.yml

* remove dbg

* change printer for foreign call

* Update crates/noirc_evaluator/src/ssa_refactor/ir/function.rs

* Update crates/noirc_evaluator/src/ssa_refactor/ir/instruction.rs

Co-authored-by: kevaundray <[email protected]>

* Update crates/noirc_evaluator/src/ssa_refactor/acir_gen/acir_ir/acir_variable.rs

---------

Co-authored-by: kevaundray <[email protected]>
Co-authored-by: guipublic <[email protected]>
Co-authored-by: Álvaro Rodríguez <[email protected]>
Co-authored-by: jfecher <[email protected]>
Co-authored-by: Maxim Vezenov <[email protected]>
Co-authored-by: joss-aztec <[email protected]>
Co-authored-by: Tom French <[email protected]>

* feat: add support for assert in brillig (#1603)

* remove mac runner

* chore: generate brillig opcode for simple identity unconstrained function (#1536)

* feat(brillig): added arithmetic operations on brillig (#1565)

Co-authored-by: kevaundray <[email protected]>

* make ranges be polymorphic integers

* chore(brillig): Clean up handling of Binary operations (#1571)

* chore(ssa refactor): Rename Brillig example (#1563)

* chore(brillig): added tests for all field binary operations (#1586)

* chore(brillig): added tests for brillig integer operations (#1590)

* feat: process blocks and jumps when compiling brillig (#1591)

* process jumps between blocks

* fix jumps

* add doc comments

* cargo fmt

* code refactor

* update code comment

---------

Co-authored-by: kevaundray <[email protected]>

* feat: process blocks and jumps when compiling brillig (#1591)

* process jumps between blocks

* fix jumps

* add doc comments

* cargo fmt

* code refactor

* update code comment

---------

Co-authored-by: kevaundray <[email protected]>

* feat(brillig): parsing oracles/foreign calls (#1596)

* feat(brillig): start of oracles/foreign calls

* fix: broken tests

* Update execute.rs

* support assert in brillig

* self.data -> self.vars

* Avoid not in the test

* chore(brillig): Add handling of the not instruction (#1609)

* make behavior consistent

* remove closure

* change index_type

* Update crates/noirc_frontend/src/hir/type_check/expr.rs

* feat(brillig): loops (#1610)

* make ranges be polymorphic integers

* feat: brillig loop support

* fix: fixed brillig returns and stop

* fix: do not apply constants folding to brillig fns

* chore: update acvm pointer, cleanup

* style: newline on cargo toml

* make behavior consistent

* remove closure

* change index_type

* Update crates/noirc_frontend/src/hir/type_check/expr.rs

* better debug information for unsupported instruction

* remove edge case for optimizations

* clippy fix

* patch infinite loop

---------

Co-authored-by: kevaundray <[email protected]>
Co-authored-by: jfecher <[email protected]>

* chore: resolve immutable array merge differences (#1617)

* chore(ssa refactor): Switch to immutable arrays (#1578)

* Represent SSA arrays with im::Vector

* Get tests passing

* Implement assign with immutable arrays

* Add constant folding pass

* Update comments

* Clippy

* Update comment

* Update type of array

* Update crates/noirc_evaluator/src/ssa_refactor/ir/instruction.rs

Co-authored-by: Tom French <[email protected]>

* Undo formatting changes in instruction.rs

* Massive acir_gen update

* Refactor acir array operations into a shared function

* Appease clippy

* Update to_radix and to_bits in acir_gen to return arrays

* Disable assert

* Fix convert_type for arrays

* Include AcirType in AcirValue::Var variant

* Fix black box functions

* Appease clippy

* Fix simple_radix

* Add doc comments

---------

Co-authored-by: Tom French <[email protected]>

* feat: Make for-loop range be a polymorphic integer instead of just Field in unconstrained functions (#1583)

* make ranges be polymorphic integers

* make behavior consistent

* remove closure

* change index_type

* Update crates/noirc_frontend/src/hir/type_check/expr.rs

---------

Co-authored-by: jfecher <[email protected]>

* chore(ssa refactor): fix brillig post master merge

* chore(ssa refactor): accidental merge undelete

---------

Co-authored-by: jfecher <[email protected]>
Co-authored-by: Tom French <[email protected]>
Co-authored-by: kevaundray <[email protected]>

* chore(ssa refactor): Add more documentation for truncation  (#1607)

* add more documentation

* small change

* Update crates/noirc_evaluator/src/ssa_refactor/acir_gen/acir_ir/generated_acir.rs

* Update .github/workflows/test.yml

* Update .github/workflows/test.yml

* Remove optimisation for handling assert

* add the assert jump to the list of jumps to fix

* add doc comment

---------

Co-authored-by: kevaundray <[email protected]>
Co-authored-by: Álvaro Rodríguez <[email protected]>
Co-authored-by: ludamad <[email protected]>
Co-authored-by: jfecher <[email protected]>
Co-authored-by: joss-aztec <[email protected]>
Co-authored-by: Tom French <[email protected]>

* chore(ssa refactor): Separate Brillig only logic from Brillig-SSA generation logic (#1631)

* separate brillig only logic from logic that combines both brillig and ssa

* move operations related to brillig-ssa conversion to brillig_gen

* intermediate step -- make build work by leaking the abstraction

* refactor return instruction -- all of the implementation details about brillig are no longer in brillig_gen

* fix clippy

* add TODO

* move `convert_integer_mod` into BrilligIr

* encapsulate modulo operation in brillig_gen

* process binary instruction

* refactor const instruction

* make code surrounding jumps satisfy the abstraction

* move not instruction

* add foreign call instruction

* move load and store instructions to brillig_ir

* move truncate instruction

* move `mov`, `stop` and `allocate_array` methods

* fix clippy

* remove push_code method in brillig_gen

* move jump and jmpif instructions to brillig_ir

* clean up terminator instruction

* remove allow(deprecated) lint

* refactor document for link and link_with

* use .into so we can get rid of Value import

* add docs

* Update crates/noirc_evaluator/src/brillig/brillig_ir/artifact.rs

Co-authored-by: Álvaro Rodríguez <[email protected]>

* Update crates/noirc_evaluator/src/brillig/brillig_gen.rs

* make code a bit clearer

* fix clippy

---------

Co-authored-by: Álvaro Rodríguez <[email protected]>

* chore(ssa_refactor): Improve foreign call compilation (#1644)

* remove ForeignCall instruction from SSA

* remove unnecessary Oracle RuntimeType

* remove old comment

* feat: Brillig array inputs and outputs (#1630)

* first attempt at brillig multiple array inptus

* working array identity function for brillig

* cleanup dbgs

* remove unused imports

* remove dbg

* a little cleanup

* fix up foreign calls for array inputs and outputs

* fix outputs clippy err

* move conversion to RegisterValueOrArray to its own method

* missing &mut and TODO link

* PR comment for brillig output array types

* cleanup comment

* enable struct inputs/outputs

* cargo clippy

* chore(brillig): master into brillig main (#1663)

* fix(ssa refactor): resolve replaced value ids for printing (#1535)

* fix(ssa refactor): resolve replaced value ids for printing

* fix(ssa refactor): Expand PR #1535 to resolve ValueIds in all SSA passes (#1642)

* Expand PR

* chore(ssa refactor): more value id resolving

* chore(ssa refactor): another value id resolve

---------

Co-authored-by: Joss <[email protected]>

---------

Co-authored-by: jfecher <[email protected]>

* chore(ssa refactor): enable_side_effects instruction (#1547)

* chore(ssa refactor): enable_side_effects instruction

* chore(ssa refactor): fix and document enable_side_effects insertions

* chore(ssa refactor): rm comments

* fix(ssa refactor): redundant EnableSideEffects

* chore(ssa refactor): cp working tests (#1619)

* chore(ssa gen): ssa gen truncate instruction

* chore(ssa refactor): max bit size for subtract

* Update crates/noirc_evaluator/src/ssa_refactor/ssa_gen/context.rs

Co-authored-by: jfecher <[email protected]>

* chore(ssa refactor): truncate shift left

* chore(ssa refactor): Add integer modulus when truncating subtraction

* chore(ssa refactor): clippy

* chore(ssa refactor): fix left shift max bit size

* chore(ssa refactor): cp xor test

* chore(ssa refactor): cp working tests

* chore(ssa refactor): more working tests

* chore(ssa refactor): cp working test

---------

Co-authored-by: kevaundray <[email protected]>
Co-authored-by: jfecher <[email protected]>

* chore(ssa refactor): Remove unit values from SSA IR (#1646)

* Remove unit values

* Fix test

* Fix comment

* chore: Upgrade codespan dependencies (#1647)

* chore(ssa refactor): Implement dead instruction elimination pass (#1595)

* Add dead instruction elimination pass

* Enable the pass

* chore(ssa refactor): simple mut test

* chore(ssa refactor): fixup and add doc comments

* chore(ssa refactor): post merge fix

---------

Co-authored-by: Joss <[email protected]>

* chore(brillig): Update acvm dependency (#1653)

chore: update acvm dep

* refactor: remove unused assign

---------

Co-authored-by: joss-aztec <[email protected]>
Co-authored-by: jfecher <[email protected]>
Co-authored-by: kevaundray <[email protected]>
Co-authored-by: Blaine Bublitz <[email protected]>
Co-authored-by: Joss <[email protected]>

* feat(brillig): Added cast instruction (#1649)

* feat: added cast instruction

* docs: add comment on cast

* docs: added comment on cast instruction

* simplify convert_cast

* Alvaro to review

* feat: do casts as no ops instead

---------

Co-authored-by: kevaundray <[email protected]>

* feat(brillig): Add unique labeling and remove relative jumps (#1652)

* feat: added unique labeling

* refactor: remove relative jumps

* feat: add section/global labeling

* pr review

* Update crates/noirc_evaluator/src/brillig/brillig_gen/brillig_block.rs

* style: clippy

---------

Co-authored-by: kevaundray <[email protected]>

* fix `is_signed` method

* feat(brillig): added basic array operations (#1716)

* feat: added array operations

* docs: commented functions a bit

* Update crates/noirc_evaluator/src/brillig/brillig_ir.rs

* refactor: rename method

* refactor: simplify size calculations

* style: fmt

* feat(brillig): runtime memory allocation (#1732)

* feat: use dynamic memory allocation

* docs: update comments

* refactor: rename allocation methods

* docs: updated comment

* refactor: changes from peer review

* chore(brillig): Add a register abstraction/optimization (#1737)

* chore: brillig register abstraction

* chore: small refactor

* fix: latest_register starting value

* fix: comments

* chore: remove unused method

* fix: reintroduce a safety register alloc check

* merge fix: AcirType is now an enum

* merge fix: foreign calls

* fix: Oracle output resolution (#1740)

silly fix until we use enums for foreign call results

---------

Co-authored-by: Álvaro Rodríguez <[email protected]>
Co-authored-by: ludamad <[email protected]>
Co-authored-by: guipublic <[email protected]>
Co-authored-by: jfecher <[email protected]>
Co-authored-by: Maxim Vezenov <[email protected]>
Co-authored-by: joss-aztec <[email protected]>
Co-authored-by: Tom French <[email protected]>
Co-authored-by: Blaine Bublitz <[email protected]>
Co-authored-by: Joss <[email protected]>
  • Loading branch information
10 people authored Jun 17, 2023
1 parent cfbd182 commit 3467aab
Show file tree
Hide file tree
Showing 49 changed files with 1,777 additions and 608 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ result
*.pk
*.vk
**/Verifier.toml
**/target
54 changes: 51 additions & 3 deletions crates/nargo/src/ops/execute.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use acvm::pwg::{solve, Blocks, PartialWitnessGeneratorStatus};
use acvm::acir::brillig_vm::ForeignCallResult;
use acvm::acir::circuit::Opcode;
use acvm::pwg::{solve, Blocks, PartialWitnessGeneratorStatus, UnresolvedBrilligCall};
use acvm::PartialWitnessGenerator;
use acvm::{acir::circuit::Circuit, acir::native_types::WitnessMap};

Expand All @@ -11,8 +13,54 @@ pub fn execute_circuit(
) -> Result<WitnessMap, NargoError> {
let mut blocks = Blocks::default();
let solver_status = solve(backend, &mut initial_witness, &mut blocks, circuit.opcodes)?;
if matches!(solver_status, PartialWitnessGeneratorStatus::RequiresOracleData { .. }) {
todo!("Add oracle support to nargo execute")

// TODO(#1615): Nargo only supports "oracle_print_**_impl" functions that print a singular value or an array and nothing else
// This should be expanded in a general logging refactor
if let PartialWitnessGeneratorStatus::RequiresOracleData {
unresolved_brillig_calls,
required_oracle_data,
unsolved_opcodes,
} = solver_status
{
if !required_oracle_data.is_empty() {
unreachable!("oracles are not supported by nargo execute")
}
for unresolved_brillig_call in unresolved_brillig_calls {
let UnresolvedBrilligCall { foreign_call_wait_info, mut brillig } =
unresolved_brillig_call;

// Execute foreign calls
// TODO(#1615): "oracle_print_impl" and "oracle_print_array_impl" are just identity funcs
if foreign_call_wait_info.function == "oracle_print_impl" {
let values = &foreign_call_wait_info.inputs[0];
println!("{:?}", values[0].to_field().to_hex());
brillig.foreign_call_results.push(ForeignCallResult {
values: vec![vec![foreign_call_wait_info.inputs[0][0]]],
});
} else if foreign_call_wait_info.function == "oracle_print_array_impl" {
let mut outputs_hex = Vec::new();
for value in foreign_call_wait_info.inputs.clone() {
outputs_hex.push(value[0].to_field().to_hex());
}
// Join all of the hex strings using a comma
let comma_separated_elements = outputs_hex.join(", ");
let output_witnesses_string = "[".to_owned() + &comma_separated_elements + "]";
println!("{output_witnesses_string}");
brillig.foreign_call_results.push(ForeignCallResult {
values: vec![vec![foreign_call_wait_info.inputs[0][0]]],
});
}

let mut next_opcodes_for_solving = vec![Opcode::Brillig(brillig)];
next_opcodes_for_solving.extend_from_slice(&unsolved_opcodes[..]);

let solver_status =
solve(backend, &mut initial_witness, &mut blocks, next_opcodes_for_solving)?;
if matches!(solver_status, PartialWitnessGeneratorStatus::RequiresOracleData { .. }) {
todo!("Add multiple foreign call support to nargo execute")
// TODO 1557
}
}
}

Ok(initial_witness)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
authors = [""]
compiler_version = "0.1"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x = ["1", "2", "3"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Tests a very simple program.
//
// The features being tested are array reads and writes

fn main(x: [Field; 3]) {
read_array(x);
read_write_array(x);
}

unconstrained fn read_array(x: [Field; 3]) {
assert(x[0] == 1);
let y = [1, 5, 27];

assert(y[x[0]] == 5);
}

unconstrained fn read_write_array(x: [Field; 3]) {
let mut y = x;

y[0] = 5;

assert(y[0] == 5);
assert(y[1] == 2);
assert(y[2] == 3);

assert(x[0] == 1);
assert(x[1] == 2);
assert(x[2] == 3);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
authors = [""]
compiler_version = "0.1"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x = "1"
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Tests a very simple program.
//
// The features being tested is using assert on brillig
fn main(x: Field) {
assert(1 == conditional(x as bool));
}

unconstrained fn conditional(x : bool) -> Field {
assert(x);
1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
authors = [""]
compiler_version = "0.1"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x = "0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Tests a very simple program.
//
// The features being tested is using assert on brillig
fn main(x: Field) {
assert(1 == conditional(x as bool));
}

unconstrained fn conditional(x : bool) -> Field {
assert(x);
1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
authors = [""]
compiler_version = "0.1"

[dependencies]
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Tests a very simple Brillig function.
//
// The features being tested are cast operations on brillig
fn main() {
bool_casts();
field_casts();
uint_casts();
int_casts();
mixed_casts();
}

unconstrained fn bool_casts() {
assert(false == 0 as bool);
assert(true == 1 as bool);
assert(true == 3 as bool);
}

unconstrained fn field_casts() {
assert(5 as u8 as Field == 5);
assert(16 as u4 as Field == 0);
}

unconstrained fn uint_casts() {
let x: u32 = 100;
assert(x as u2 == 0);
assert(x as u4 == 4);
assert(x as u6 == 36);
assert(x as u8 == 100);
assert(x as u64 == 100);
assert(x as u126 == 100);
}

unconstrained fn int_casts() {
let x: i32 = 100;
assert(x as i2 == 0);
assert(x as i4 == 4);
assert(x as i6 == -28 as i6);
assert(x as i8 == 100);
assert(x as i8 == 100);
assert(x as i8 == 100);
}


unconstrained fn mixed_casts() {
assert(100 as u32 as i32 as u32 == 100);
assert(13 as u4 as i2 as u32 == 1);
assert(15 as u4 as i2 as u32 == 3);
assert(1 as u8 as bool == true);
assert(true as i8 == 1);
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,35 @@
use dep::std;

struct myStruct {
foo: Field,
foo_arr: [Field; 2],
}

// Tests a very simple program.
//
// The features being tested is the identity function in Brillig
fn main(x : Field) {
assert(x == identity(x));
// TODO: add support for array comparison
let arr = identity_array([x, x]);
assert(x == arr[0]);
assert(x == arr[1]);

let s = myStruct { foo: x, foo_arr: [x, x] };
let identity_struct = identity_struct(s);
assert(x == identity_struct.foo);
assert(x == identity_struct.foo_arr[0]);
assert(x == identity_struct.foo_arr[1]);
}

unconstrained fn identity(x : Field) -> Field {
x
}

unconstrained fn identity_array(arr : [Field; 2]) -> [Field; 2] {
arr
}

unconstrained fn identity_struct(s : myStruct) -> myStruct {
s
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
authors = [""]
compiler_version = "0.1"

[dependencies]
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Tests a very simple program.
//
// The features being tested is modulo operations on brillig
fn main() {
assert(modulo(47, 3) == 2);
assert(modulo(2, 3) == 2);
assert(signed_modulo(5, 3) == 2);
assert(signed_modulo(2, 3) == 2);

let minus_two: i4 = 14;
let minus_three: i4 = 13;
let minus_five: i4 = 11;

// (5 / -3) * -3 + 2 = -1 * -3 + 2 = 3 + 2 = 5
assert(signed_modulo(5, minus_three) == 2);
// (-5 / 3) * 3 - 2 = -1 * 3 - 2 = -3 - 2 = -5
assert(signed_modulo(minus_five, 3) == minus_two);
// (-5 / -3) * -3 - 2 = 1 * -3 - 2 = -3 - 2 = -5
assert(signed_modulo(minus_five, minus_three) == minus_two);
}

unconstrained fn modulo(x: u32, y: u32) -> u32 {
x % y
}

unconstrained fn signed_modulo(x: i4, y: i4) -> i4 {
x % y
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
authors = [""]
compiler_version = "0.1"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
x = "10"

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Tests oracle usage in brillig/unconstrained functions
fn main(x: Field) {
// call through a brillig wrapper
oracle_print_array_wrapper([x, x]);

// TODO(#1615) Nargo currently only supports resolving one foreign call
// oracle_print_wrapper(x);
}

#[oracle(oracle_print_impl)]
unconstrained fn oracle_print(_x : Field) -> Field {}

unconstrained fn oracle_print_wrapper(x: Field) {
oracle_print(x);
}

#[oracle(oracle_print_array_impl)]
unconstrained fn oracle_print_array(_arr : [Field; 2]) -> Field {}

unconstrained fn oracle_print_array_wrapper(arr: [Field; 2]) {
oracle_print_array(arr);
}


2 changes: 1 addition & 1 deletion crates/nargo_cli/tests/test_data_ssa_refactor/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ exclude = []


# List of tests (as their directory name) expecting to fail: if the test pass, we report an error.
fail = [""]
fail = ["brillig_assert_fail"]
Loading

0 comments on commit 3467aab

Please sign in to comment.