-
Notifications
You must be signed in to change notification settings - Fork 599
feat: remove event selector in logs from public context #7192
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
Changes from all 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 |
|---|---|---|
|
|
@@ -247,7 +247,7 @@ fn handle_foreign_call( | |
| "avmOpcodeStaticCall" => { | ||
| handle_external_call(avm_instrs, destinations, inputs, AvmOpcode::STATICCALL); | ||
| } | ||
| "amvOpcodeEmitUnencryptedLog" => { | ||
| "avmOpcodeEmitUnencryptedLog" => { | ||
|
Contributor
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. Thanks for the fix! |
||
| handle_emit_unencrypted_log(avm_instrs, destinations, inputs); | ||
| } | ||
| "avmOpcodeNoteHashExists" => handle_note_hash_exists(avm_instrs, destinations, inputs), | ||
|
|
@@ -435,32 +435,25 @@ fn handle_emit_unencrypted_log( | |
| destinations: &Vec<ValueOrArray>, | ||
| inputs: &Vec<ValueOrArray>, | ||
| ) { | ||
| if !destinations.is_empty() || inputs.len() != 3 { | ||
| if !destinations.is_empty() || inputs.len() != 2 { | ||
| panic!( | ||
| "Transpiler expects ForeignCall::EMITUNENCRYPTEDLOG to have 0 destinations and 3 inputs, got {} and {}", | ||
| "Transpiler expects ForeignCall::EMITUNENCRYPTEDLOG to have 0 destinations and 2 inputs, got {} and {}", | ||
| destinations.len(), | ||
| inputs.len() | ||
| ); | ||
| } | ||
| let event_offset = match &inputs[0] { | ||
| ValueOrArray::MemoryAddress(offset) => offset.to_usize() as u32, | ||
| _ => panic!( | ||
| "Unexpected inputs[0] (event) for ForeignCall::EMITUNENCRYPTEDLOG: {:?}", | ||
| inputs[0] | ||
| ), | ||
| }; | ||
|
|
||
| // The fields are a slice, and this is represented as a (length: Field, slice: HeapVector). | ||
| // The length field is redundant and we skipt it. | ||
| let (message_offset, message_size_offset) = match &inputs[2] { | ||
| let (message_offset, message_size_offset) = match &inputs[1] { | ||
| ValueOrArray::HeapVector(vec) => (vec.pointer.to_usize() as u32, vec.size.0 as u32), | ||
| _ => panic!("Unexpected inputs for ForeignCall::EMITUNENCRYPTEDLOG: {:?}", inputs), | ||
| }; | ||
| avm_instrs.push(AvmInstruction { | ||
| opcode: AvmOpcode::EMITUNENCRYPTEDLOG, | ||
| // The message array from Brillig is indirect. | ||
| indirect: Some(FIRST_OPERAND_INDIRECT), | ||
| indirect: Some(ZEROTH_OPERAND_INDIRECT), | ||
| operands: vec![ | ||
| AvmOperand::U32 { value: event_offset }, | ||
| AvmOperand::U32 { value: message_offset }, | ||
| AvmOperand::U32 { value: message_size_offset }, | ||
| ], | ||
|
|
||
|
Contributor
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. To know if your changes here are correct, I recommend running the unit tests for the opcodes. LMK if you run into anything weird. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -162,11 +162,12 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface { | |
| this.incrementSideEffectCounter(); | ||
| } | ||
|
|
||
| public traceUnencryptedLog(contractAddress: Fr, event: Fr, log: Fr[]) { | ||
| public traceUnencryptedLog(contractAddress: Fr, log: Fr[]) { | ||
| // TODO(4805): check if some threshold is reached for max logs | ||
| const ulog = new UnencryptedL2Log( | ||
| AztecAddress.fromField(contractAddress), | ||
| EventSelector.fromField(event), | ||
| // TODO(#7198): Remove event selector from UnencryptedL2Log | ||
| EventSelector.fromField(new Fr(0)), | ||
|
Contributor
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. You can do it in a separate PR, but I guess if event selector is being dropped (ie not enshrined) then it would make sense to remove it from UnencryptedL2Log as well (which is I think what the kernel uses).
Contributor
Author
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. Have made #7198 to deal with this ! |
||
| Buffer.concat(log.map(f => f.toBuffer())), | ||
| ); | ||
| const basicLogHash = Fr.fromBuffer(ulog.hash()); | ||
|
|
||
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.
To know if the changes here (and in the public context) are correct, I recommend recompiling and retranspiling avm_test_contract, then running the avm_simulator.test.ts in yarn-packages. That test runs the simulator on compiled Noir contracts, so you'd be exercising this.