Skip to content

Commit

Permalink
feat: Dynamic assertion payloads v2 (#5949)
Browse files Browse the repository at this point in the history
This PR implements this proposal:
noir-lang/noir#4239 (comment)
 - Removes legacy dynamic assertions via calling brillig + oracle
 - Removes legacy oracle handling for assertions
- Frontend adds the HirType in the ConstrainError instead of embedding
metadata about it in the program logic.
 - Constrain instruction in SSA now has `Values` for payload
 - SSA gen generates an error selector from the payload type
- ACIR gen and Brillig gen handle the payload ValueIds and error
selector
 - ABI has now error_types for non-string errors
 - ACVM now resolves the payload for non-constant AssertionPayloads
- Nargo decodes the error for non-string errors using the ABI, allowing
use in nargo tests
 
 Things to do in a followup PR:
- Add an entry point in noirc_abi_wasm that allows decoding a given
`Raw` (non-string) using the ABI in the same way that nargo does.
  • Loading branch information
sirasistant authored Apr 26, 2024
1 parent dfb8704 commit 405bdf6
Show file tree
Hide file tree
Showing 70 changed files with 1,564 additions and 616 deletions.
1 change: 1 addition & 0 deletions avm-transpiler/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 4 additions & 7 deletions avm-transpiler/src/transpile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,19 +251,16 @@ pub fn brillig_to_avm(brillig_bytecode: &[BrilligOpcode]) -> Vec<u8> {
..Default::default()
});
}
BrilligOpcode::Trap {
revert_data_offset,
revert_data_size,
} => {
BrilligOpcode::Trap { revert_data } => {
avm_instrs.push(AvmInstruction {
opcode: AvmOpcode::REVERT,
indirect: Some(ALL_DIRECT),
indirect: Some(ZEROTH_OPERAND_INDIRECT),
operands: vec![
AvmOperand::U32 {
value: *revert_data_offset as u32,
value: revert_data.pointer.0 as u32,
},
AvmOperand::U32 {
value: *revert_data_size as u32,
value: revert_data.size as u32,
},
],
..Default::default()
Expand Down
Loading

0 comments on commit 405bdf6

Please sign in to comment.