-
Notifications
You must be signed in to change notification settings - Fork 268
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
feat(aztec-nr): initial work for aztec public vm macro #4400
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -424,6 +424,10 @@ fn transform_module( | |
transform_function("Public", func, storage_defined) | ||
.map_err(|err| (err, crate_graph.root_file_id))?; | ||
has_transformed_module = true; | ||
} else if is_custom_attribute(&secondary_attribute, "aztec(public-vm)") { | ||
transform_vm_function(func, storage_defined) | ||
.map_err(|err| (err, crate_graph.root_file_id))?; | ||
has_transformed_module = true; | ||
} | ||
} | ||
// Add the storage struct to the beginning of the function if it is unconstrained in an aztec contract | ||
|
@@ -585,6 +589,20 @@ fn generate_storage_implementation(module: &mut SortedModule) -> Result<(), Azte | |
Ok(()) | ||
} | ||
|
||
// Transform a function to work with AVM bytecode | ||
fn transform_vm_function( | ||
func: &mut NoirFunction, | ||
_storage_defined: bool, | ||
) -> Result<(), AztecMacroError> { | ||
// We want the function to be seen as a public function | ||
func.def.is_open = true; | ||
|
||
// NOTE: the line below is a temporary hack to trigger external transpilation tools | ||
// It will be removed once the transpiler is integrated into the Noir compiler | ||
func.def.name.0.contents = format!("avm_{}", func.def.name.0.contents); | ||
Ok(()) | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe move this below |
||
/// If it does, it will insert the following things: | ||
/// - A new Input that is provided for a kernel app circuit, named: {Public/Private}ContextInputs | ||
/// - Hashes all of the function input variables | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,7 +56,6 @@ const INSTRUCTION_SET: InstructionSet = new Map<Opcode, DeserializableInstructio | |
[ | ||
[Add.opcode, Add], | ||
[Sub.opcode, Sub], | ||
[Sub.opcode, Sub], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👀 |
||
[Mul.opcode, Mul], | ||
[Div.opcode, Div], | ||
[Eq.opcode, Eq], | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,9 @@ contract AvmTest { | |
#[aztec(private)] | ||
fn constructor() {} | ||
|
||
// Function name prefix "avm_" flags it for transpilation | ||
unconstrained fn avm_addArgsReturn(argA: Field, argB: Field) -> pub Field { | ||
// Public-vm macro will prefix avm to the function name for transpilation | ||
#[aztec(public-vm)] | ||
fn addArgsReturn(argA: Field, argB: Field) -> pub Field { | ||
argA + argB | ||
} | ||
Comment on lines
-12
to
16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! |
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Triple
///
for function description comment i think