Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

feat: Add Brillig opcode to introduce custom non-determinism to ACVM #152

Merged
merged 131 commits into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
131 commits
Select commit Hold shift + click to select a range
3c71368
cargo.toml
kevaundray Mar 24, 2023
7ce1431
add initial code for non deterministic vm
kevaundray Mar 24, 2023
5218be7
fix clippy
kevaundray Mar 24, 2023
87c28d1
remove unary op -- can be simulated with binary op
kevaundray Mar 27, 2023
7dfa344
refactor API:
kevaundray Mar 27, 2023
e93ae96
re-export brillig bytecode
kevaundray Mar 27, 2023
a8f553e
add brillig
kevaundray Mar 28, 2023
0c32dcb
brillig is now re-exported from acir
kevaundray Mar 28, 2023
0229519
use acir_field instead of acir
kevaundray Mar 28, 2023
12b7f51
wip
kevaundray Mar 28, 2023
a2acde2
Merge remote-tracking branch 'origin/master' into kw/bytecode-vm
kevaundray Mar 28, 2023
327fe75
add directive todo
kevaundray Mar 28, 2023
5cb9f3a
feat: Add serialization for brillig bytecode (#158)
kevaundray Mar 28, 2023
ca4fe1a
feat: Solve Brillig Directive (#159)
vezenovm Mar 28, 2023
5f2ebf1
RegisterIndex -> RegisterMemIndex
kevaundray Mar 28, 2023
92a8f77
- use `Label`
kevaundray Mar 28, 2023
b57bf11
export RegisterMemIndex
kevaundray Mar 28, 2023
12a53df
conversion func for registerIndex
kevaundray Mar 28, 2023
824ccc4
add jmpifnot
kevaundray Mar 28, 2023
0b7bd3d
feat: Add trap opcode (#161)
vezenovm Mar 28, 2023
cb70b7d
feat: Brillig JMP and JMPIF (#162)
vezenovm Mar 28, 2023
59eb20a
fix to stop VM on Trap opcode (#163)
vezenovm Mar 28, 2023
3a197aa
feat: JMPIFNOT (#165)
vezenovm Mar 28, 2023
01d21c6
feat: Mov Opcode in Brillig (#166)
vezenovm Mar 28, 2023
dcae6b3
feat: Comparison Binary Ops (#167)
vezenovm Mar 28, 2023
d1e9c59
move Brillig from being a directive to an Opcode (#169)
vezenovm Mar 29, 2023
2ca6648
bootstrap register allocation
kevaundray Mar 29, 2023
404721e
add bootstrap hack
kevaundray Mar 29, 2023
d3bdeec
increment program counter
kevaundray Mar 29, 2023
a9b00f4
feat: Brillig oracle opcode (#170)
vezenovm Mar 29, 2023
b2f3ff2
feat: Reduce brillig bytecodes sent to VM after oracle wait (#173)
vezenovm Mar 30, 2023
620fff0
feat: Brillig Stop opcode (#174)
vezenovm Mar 30, 2023
99f3ceb
feat: Brillig Call Opcode (#175)
vezenovm Mar 30, 2023
45d4ca4
feat: Brillig Oracle Predicate (#176)
vezenovm Mar 30, 2023
4d77130
feat: Brillig Memory (#178)
vezenovm Apr 11, 2023
608201f
switch store load index field to RegisterMemIndex (#193)
vezenovm Apr 11, 2023
7daf334
return whole unresolved brillig opcode instead of just the oracle for…
vezenovm Apr 12, 2023
1f37025
feat: Brillig oracle array outputs (#195)
vezenovm Apr 13, 2023
7a1336e
chore(acvm): couple unresolved brillig and brillig oracle to make res…
joss-aztec Apr 13, 2023
6e1b9f7
Merge pull request #194 from noir-lang/mv/return-unres-brillig
joss-aztec Apr 13, 2023
27cdadd
add OracleInput struct and handle them in brillig solver (#199)
vezenovm Apr 17, 2023
7ba98fc
fix: Change OracleInput to an enum (#200)
jfecher Apr 17, 2023
69a0798
feat!: Use OracleOutput enum in OracleData (#201)
vezenovm Apr 18, 2023
1547d44
update array start to registermemindex as it can be a constant (#205)
vezenovm Apr 18, 2023
ea5b5db
handle unresolved brillig data when stalled correctly (#208)
vezenovm Apr 18, 2023
c2e3d03
feat!: Handle result type of Binary Ops in Brillig (#202)
vezenovm Apr 19, 2023
836a1b1
initial call stack opcodes and their impl in VM (#215)
vezenovm Apr 20, 2023
77857eb
fix reference to old Opcode::Call (#217)
vezenovm Apr 20, 2023
b23bcc1
change id_as_value typ for brillig inputs (#222)
vezenovm Apr 21, 2023
b8345c1
bitwise operators, shifts, and cleanup for BinaryOp.evaluate (#224)
vezenovm Apr 21, 2023
61eefe5
move insertion of array input to brillig only if entire array is solv…
vezenovm Apr 24, 2023
3142c0e
small fix for comparison
guipublic Apr 25, 2023
9197eb3
Merge branch 'kw/bytecode-vm' of https://github.com/noir-lang/acvm in…
guipublic Apr 25, 2023
dd86dc5
Return failure on trap (#229)
guipublic Apr 25, 2023
ad9c33f
feat(brillig): experiments
ludamad May 4, 2023
65c0775
Low level pointer machine
ludamad May 8, 2023
f7c5013
chore: additional testing
ludamad May 9, 2023
a52e2e8
chore: additional testing
ludamad May 10, 2023
2eafb94
comment non-working oracle tests
ludamad May 10, 2023
2753229
Clippy and test fixes
ludamad May 10, 2023
2fab89a
Rework Brillig oracles, rename ForeignCall
ludamad May 17, 2023
f5b6e2f
Fix: test reorder issue
ludamad May 17, 2023
a5ea7cb
cargo format
ludamad May 17, 2023
59f0e8d
chore: align tests
ludamad May 17, 2023
6ab600c
added double oracle in one brillig gen
vezenovm May 18, 2023
9987625
Remove MIN_REGISTER_VALUES
ludamad May 18, 2023
96f6949
Remove register_allocation_indices hack
ludamad May 18, 2023
58d4fd8
cargo fmt
ludamad May 18, 2023
5638127
Merge pull request #262 from ludamad/ad/brillig-bytecode-vm
ludamad May 19, 2023
e96443e
resolve heavy merge conflcits with breaking changes from acvm 0.12.0
vezenovm May 19, 2023
2a54a1a
cargo fmt and cargo clippy missing usage of solved_brillig_data
vezenovm May 19, 2023
73aceee
Add Brillig to cspell
kevaundray May 19, 2023
300ac3e
Update acir/src/circuit/opcodes.rs
kevaundray May 19, 2023
2926363
Update acvm/src/compiler/transformers/fallback.rs
kevaundray May 19, 2023
f3e1317
Update acvm/src/pwg.rs
kevaundray May 19, 2023
61d136d
Update brillig_bytecode/src/opcodes.rs
kevaundray May 19, 2023
49cc50a
Update brillig_bytecode/src/lib.rs
kevaundray May 19, 2023
ee15a74
Update brillig_bytecode/src/opcodes.rs
kevaundray May 19, 2023
67396aa
cargo fmt
kevaundray May 19, 2023
ee0b8c3
chore: comment updates
TomAFrench May 22, 2023
25de758
Update brillig_bytecode/src/lib.rs
kevaundray May 22, 2023
388367d
Merge branch 'master' into kw/bytecode-vm
kevaundray May 22, 2023
3896add
rename `Simple` to `Single` and add a comment for Inputs and Outputs
kevaundray May 22, 2023
0fd44d7
Update acvm/src/pwg.rs
kevaundray May 22, 2023
8ad2713
Update brillig_bytecode/src/opcodes.rs
kevaundray May 22, 2023
8e1335c
Update brillig_bytecode/src/opcodes.rs
kevaundray May 22, 2023
c28c7fd
Update brillig_bytecode/src/opcodes.rs
kevaundray May 22, 2023
e2d2ae1
Update brillig_bytecode/src/opcodes.rs
kevaundray May 22, 2023
6e26e23
Update brillig_bytecode/src/opcodes.rs
kevaundray May 22, 2023
7783b5a
Update brillig_bytecode/src/value.rs
kevaundray May 22, 2023
ea164bc
Update brillig_bytecode/src/lib.rs
kevaundray May 22, 2023
2e3506e
Update brillig_bytecode/src/lib.rs
kevaundray May 22, 2023
c900428
Update brillig_bytecode/src/lib.rs
kevaundray May 22, 2023
8c619f8
Update brillig_bytecode/src/lib.rs
kevaundray May 22, 2023
d7a685c
Update brillig_bytecode/src/value.rs
kevaundray May 22, 2023
6960c2e
Update brillig_bytecode/src/registers.rs
kevaundray May 22, 2023
32495c4
Update brillig_bytecode/src/value.rs
kevaundray May 22, 2023
8ec304a
Update brillig_bytecode/src/opcodes.rs
kevaundray May 22, 2023
26eddd9
Update brillig_bytecode/src/opcodes.rs
kevaundray May 22, 2023
0f9f92a
Update brillig_bytecode/src/lib.rs
kevaundray May 22, 2023
de659d9
Update brillig_bytecode/src/lib.rs
kevaundray May 22, 2023
209d2a5
Update brillig_bytecode/src/lib.rs
kevaundray May 22, 2023
0cafa26
Update brillig_bytecode/src/lib.rs
kevaundray May 22, 2023
9950387
Update acvm/src/pwg.rs
kevaundray May 22, 2023
0a99959
add `RegisterIndex` comment as doc comment
kevaundray May 22, 2023
3a95c22
cargo fmt
kevaundray May 22, 2023
eeb47d5
Update acvm/src/pwg.rs
kevaundray May 22, 2023
3d314db
move brillig constructs into ACIR into its own module -- This will re…
kevaundray May 22, 2023
8819da1
modify rest of the codebase to match this
kevaundray May 22, 2023
92adb2f
Update brillig_bytecode/src/opcodes.rs
kevaundray May 22, 2023
93b987b
Update brillig_bytecode/src/opcodes.rs
kevaundray May 22, 2023
8c6614c
remove unused UnresolvedData struct
vezenovm May 22, 2023
9607af3
chore: move process binary int op to more appropriate part of file
vezenovm May 22, 2023
6a1262f
chore: fix comment on wait_for_foreign_call
vezenovm May 22, 2023
bd80c69
now waiting
vezenovm May 23, 2023
35d81e4
chore: whitespace changes
TomAFrench May 23, 2023
4bec449
chore: whitespace changes
TomAFrench May 23, 2023
342c389
Apply suggestions from code review
TomAFrench May 23, 2023
3002f99
fix: properly handle `brillig_bytecode` default feature
TomAFrench May 23, 2023
a166a50
Update acvm/src/pwg.rs
TomAFrench May 23, 2023
f7574af
Apply suggestions from code review
TomAFrench May 23, 2023
f23f1c8
chore: add `brillig_bytecode` to `publish.yml`
TomAFrench May 23, 2023
4e99d0b
chore: make `Value` and `RegisterIndex` fields private (#308)
TomAFrench May 23, 2023
aba2d1a
Update brillig_bytecode/src/lib.rs
kevaundray May 23, 2023
69bdf4f
Update brillig_bytecode/Cargo.toml
kevaundray May 23, 2023
cc2a096
Update acvm/src/pwg.rs
kevaundray May 23, 2023
6bb622d
Update acir/src/circuit/brillig.rs
kevaundray May 23, 2023
fc5b3c0
rename brillig_bytecode to brillig_vm
kevaundray May 23, 2023
bde7784
change UnresolvedBrillig to UnresolvedBrilligCall
kevaundray May 23, 2023
5af7637
Update brillig_vm/src/value.rs
TomAFrench May 23, 2023
85c9eb0
chore: rename `unresolved_brilligs` to unresolved_brillig_calls
TomAFrench May 23, 2023
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
7 changes: 6 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ jobs:
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.ACVM_CRATES_IO_TOKEN }}

- name: Publish brillig_vm
run: |
cargo publish --package brillig_vm
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.ACVM_CRATES_IO_TOKEN }}

- name: Publish acir
run: |
cargo publish --package acir
Expand All @@ -46,4 +52,3 @@ jobs:
cargo publish --package acvm
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.ACVM_CRATES_IO_TOKEN }}

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]

members = ["acir_field", "acir", "acvm", "stdlib"]
members = ["acir_field", "acir", "acvm", "stdlib", "brillig_vm"]

[workspace.package]
authors = ["The Noir Team <[email protected]>"]
Expand Down
5 changes: 3 additions & 2 deletions acir/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ rust-version.workspace = true
[dependencies]
acir_field.workspace = true
serde.workspace = true
brillig_vm = { version = "0.1.0", path = "../brillig_vm", default-features = false }
thiserror.workspace = true

rmp-serde = "1.1.0"
Expand All @@ -24,5 +25,5 @@ strum_macros = "0.24"

[features]
default = ["bn254"]
bn254 = ["acir_field/bn254"]
bls12_381 = ["acir_field/bls12_381"]
bn254 = ["acir_field/bn254", "brillig_vm/bn254"]
bls12_381 = ["acir_field/bls12_381", "brillig_vm/bls12_381"]
30 changes: 30 additions & 0 deletions acir/src/circuit/brillig.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
use crate::native_types::{Expression, Witness};
use brillig_vm::ForeignCallResult;
use serde::{Deserialize, Serialize};

/// Inputs for the Brillig VM. These are the initial inputs
/// that the Brillig VM will use to start.
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
pub enum BrilligInputs {
Single(Expression),
Array(Vec<Expression>),
}

/// Outputs for the Brillig VM. Once the VM has completed
/// execution, this will be the object that is returned.
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
pub enum BrilligOutputs {
Simple(Witness),
Array(Vec<Witness>),
}

#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
pub struct Brillig {
pub inputs: Vec<BrilligInputs>,
pub outputs: Vec<BrilligOutputs>,
/// Results of oracles/functions external to brillig like a database read
pub foreign_call_results: Vec<ForeignCallResult>,
pub bytecode: Vec<brillig_vm::Opcode>,
/// Predicate of the Brillig execution - indicates if it should be skipped
pub predicate: Option<Expression>,
}
1 change: 1 addition & 0 deletions acir/src/circuit/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod black_box_functions;
pub mod brillig;
pub mod directives;
pub mod opcodes;

Expand Down
14 changes: 12 additions & 2 deletions acir/src/circuit/opcodes.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use super::directives::{Directive, LogInfo, QuotientDirective};
use super::{
brillig::Brillig,
directives::{Directive, LogInfo, QuotientDirective},
};
use crate::native_types::Expression;

use serde::{Deserialize, Serialize};

mod black_box_function_call;
Expand Down Expand Up @@ -31,6 +33,7 @@ pub enum Opcode {
/// RAM is required for Aztec Backend as dynamic memory implementation in Barrentenberg requires an intialisation phase and can only handle constant values for operations.
RAM(MemoryBlock),
Oracle(OracleData),
Brillig(Brillig),
}

impl Opcode {
Expand All @@ -45,6 +48,7 @@ impl Opcode {
Opcode::RAM(_) => "ram",
Opcode::ROM(_) => "rom",
Opcode::Oracle(data) => &data.name,
Opcode::Brillig(_) => "brillig",
}
}

Expand Down Expand Up @@ -145,6 +149,12 @@ impl std::fmt::Display for Opcode {
write!(f, "ORACLE: ")?;
write!(f, "{data}")
}
Opcode::Brillig(brillig) => {
write!(f, "BRILLIG: ")?;
writeln!(f, "inputs: {:?}", brillig.inputs)?;
writeln!(f, "outputs: {:?}", brillig.outputs)?;
writeln!(f, "{:?}", brillig.bytecode)
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions acir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ pub mod native_types;

pub use acir_field;
pub use acir_field::FieldElement;
pub use brillig_vm;
pub use circuit::black_box_functions::BlackBoxFunc;
3 changes: 3 additions & 0 deletions acvm/src/compiler/transformers/fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ impl FallbackTransformer {
acir_supported_opcodes.extend(opcodes_fallback);
}
}
Opcode::Brillig(_) => unreachable!(
"Brillig is not required by the backend and so there is nothing to support"
),
}
}
}
Expand Down
Loading