Skip to content
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

chore(noir): remove oracle hacks in light of stepwise ACIR execution #1243

Merged
merged 5 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions yarn-project/noir-contracts/src/artifacts/lending_contract.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,8 @@ contract PendingCommitments {
// Insert note and emit encrypted note preimage via oracle call
context = owner_balance.insert(context, note);

// Hack: we add the return value from `notifyCreatedNote` oracle call
// to the sort option to `getNotes` oracle call to force a dependency
// and therefore ordering between these two oracles
// TODO(https://github.com/noir-lang/noir/pull/1729): remove when stepwise execution of acir is complete
// replace with `let options = NoteGetterOptions::with_filter(get_2_notes, 0);`
let mut sorting = [Sort::nada(); VALUE_NOTE_LEN];
sorting[0] = Sort::new(0, context.oracle_connector as u8);
let options = NoteGetterOptions::new(get_2_notes, 0, sorting , 0);

let options = NoteGetterOptions::with_filter(get_2_notes, 0);
// get note inserted above
let (context_tmp, got_notes) = owner_balance.get_notes(context, options);
context = context_tmp;

Expand Down Expand Up @@ -102,15 +95,7 @@ contract PendingCommitments {

let owner_balance = storage.balances.at(owner);

// Hack: we add the return value from `notifyCreatedNote` oracle call
// to the sort option to `getNotes` oracle call to force a dependency
// and therefore ordering between these two oracles
// TODO(https://github.com/noir-lang/noir/pull/1729): remove when stepwise execution of acir is complete
// replace with `let options = NoteGetterOptions::with_filter(get_2_notes, 0);`
let mut sorting = [Sort::nada(); VALUE_NOTE_LEN];
sorting[0] = Sort::new(0, context.oracle_connector as u8);
let options = NoteGetterOptions::new(get_2_notes, 0, sorting , 0);

let options = NoteGetterOptions::with_filter(get_2_notes, 0);
// get note (note inserted at bottom of function shouldn't exist yet)
let (context_tmp, got_notes) = owner_balance.get_notes(context, options);
context = context_tmp;
Expand Down Expand Up @@ -163,15 +148,7 @@ contract PendingCommitments {

let owner_balance = storage.balances.at(owner);

// Hack: we add the return value from `notifyCreatedNote` oracle call
// to the sort option to `getNotes` oracle call to force a dependency
// and therefore ordering between these two oracles
// TODO(https://github.com/noir-lang/noir/pull/1729): remove when stepwise execution of acir is complete
// replace with `let options = NoteGetterOptions::with_filter(get_2_notes, 0);`
let mut sorting = [Sort::nada(); VALUE_NOTE_LEN];
sorting[0] = Sort::new(0, context.oracle_connector as u8);
let options = NoteGetterOptions::new(get_2_notes, 0, sorting , 0);

let options = NoteGetterOptions::with_filter(get_2_notes, 0);
let (context_tmp, got_notes) = owner_balance.get_notes(context, options);
context = context_tmp;

Expand Down
4 changes: 0 additions & 4 deletions yarn-project/noir-libs/noir-aztec/src/context.nr
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ use crate::messaging::process_l1_to_l2_message;
// When finished, one can call .finish() to convert back to the abi
struct Context {
inputs: abi::PrivateContextInputs,
// TODO(https://github.com/noir-lang/noir/pull/1729): remove when stepwise execution of acir is complete
oracle_connector: Field, // for forcing dependencies between oracle calls

args_hash : Field,
return_values : BoundedVec<Field, RETURN_VALUES_LENGTH>,
Expand All @@ -46,8 +44,6 @@ impl Context {
fn new(inputs: abi::PrivateContextInputs, args_hash: Field) -> Context {
Context {
inputs: inputs,
// TODO(https://github.com/noir-lang/noir/pull/1729): remove when stepwise execution of acir is complete
oracle_connector: 0,

args_hash: args_hash,
return_values: BoundedVec::new(0),
Expand Down
8 changes: 1 addition & 7 deletions yarn-project/noir-libs/noir-aztec/src/note/lifecycle.nr
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ fn create_note<Note, N>(
) -> Context {
let mut inner_note_hash = 0;
let is_dummy = note_interface.is_dummy;
let mut notify_result = 0; // TODO(https://github.com/noir-lang/noir/pull/1729): remove me (more below)
if is_dummy(note) == false {
let contract_address = context.inputs.call_context.storage_contract_address;
let header = NoteHeader { contract_address, storage_slot, nonce: 0 };
Expand All @@ -25,13 +24,8 @@ fn create_note<Note, N>(

let serialise = note_interface.serialise;
let preimage = serialise(note);

notify_result = notify_created_note(storage_slot, preimage, inner_note_hash);
assert(notify_result == 0); // TODO(https://github.com/noir-lang/noir/pull/1729): combine with above line (more below)
assert(notify_created_note(storage_slot, preimage, inner_note_hash) == 0);
}
// TODO(https://github.com/noir-lang/noir/pull/1729): remove when stepwise execution of acir is complete
// replace with: `assert(notify_created_note(storage_slot, preimage) == 0);`
context.oracle_connector = notify_result; // to force dependency/ordering between oracle calls

context.push_new_note_hash(inner_note_hash)
}
Expand Down