Skip to content

Commit

Permalink
chore: mark all oracles as unconstrained (#7032)
Browse files Browse the repository at this point in the history
Please read [contributing guidelines](CONTRIBUTING.md) and remove this
line.
  • Loading branch information
TomAFrench authored Jun 12, 2024
1 parent 78cd640 commit 7a68be4
Show file tree
Hide file tree
Showing 23 changed files with 59 additions and 59 deletions.
2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/authwit/src/auth_witness.nr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[oracle(getAuthWitness)]
fn get_auth_witness_oracle<N>(_message_hash: Field) -> [Field; N] {}
unconstrained fn get_auth_witness_oracle<N>(_message_hash: Field) -> [Field; N] {}

unconstrained pub fn get_auth_witness<N>(message_hash: Field) -> [Field; N] {
get_auth_witness_oracle(message_hash)
Expand Down
44 changes: 22 additions & 22 deletions noir-projects/aztec-nr/aztec/src/context/public_context.nr
Original file line number Diff line number Diff line change
Expand Up @@ -275,67 +275,67 @@ impl Empty for PublicContext {

// AVM oracles (opcodes) follow, do not use directly.
#[oracle(avmOpcodeAddress)]
fn address_opcode() -> AztecAddress {}
unconstrained fn address_opcode() -> AztecAddress {}

#[oracle(avmOpcodeStorageAddress)]
fn storage_address_opcode() -> AztecAddress {}
unconstrained fn storage_address_opcode() -> AztecAddress {}

#[oracle(avmOpcodeSender)]
fn sender_opcode() -> AztecAddress {}
unconstrained fn sender_opcode() -> AztecAddress {}

#[oracle(avmOpcodePortal)]
fn portal_opcode() -> EthAddress {}
unconstrained fn portal_opcode() -> EthAddress {}

#[oracle(avmOpcodeFeePerL2Gas)]
fn fee_per_l2_gas_opcode() -> Field {}
unconstrained fn fee_per_l2_gas_opcode() -> Field {}

#[oracle(avmOpcodeFeePerDaGas)]
fn fee_per_da_gas_opcode() -> Field {}
unconstrained fn fee_per_da_gas_opcode() -> Field {}

#[oracle(avmOpcodeTransactionFee)]
fn transaction_fee_opcode() -> Field {}
unconstrained fn transaction_fee_opcode() -> Field {}

#[oracle(avmOpcodeChainId)]
fn chain_id_opcode() -> Field {}
unconstrained fn chain_id_opcode() -> Field {}

#[oracle(avmOpcodeVersion)]
fn version_opcode() -> Field {}
unconstrained fn version_opcode() -> Field {}

#[oracle(avmOpcodeBlockNumber)]
fn block_number_opcode() -> Field {}
unconstrained fn block_number_opcode() -> Field {}

#[oracle(avmOpcodeTimestamp)]
fn timestamp_opcode() -> u64 {}
unconstrained fn timestamp_opcode() -> u64 {}

#[oracle(avmOpcodeL2GasLeft)]
fn l2_gas_left_opcode() -> Field {}
unconstrained fn l2_gas_left_opcode() -> Field {}

#[oracle(avmOpcodeDaGasLeft)]
fn da_gas_left_opcode() -> Field {}
unconstrained fn da_gas_left_opcode() -> Field {}

#[oracle(avmOpcodeNoteHashExists)]
fn note_hash_exists_opcode(note_hash: Field, leaf_index: Field) -> u8 {}
unconstrained fn note_hash_exists_opcode(note_hash: Field, leaf_index: Field) -> u8 {}

#[oracle(avmOpcodeEmitNoteHash)]
fn emit_note_hash_opcode(note_hash: Field) {}
unconstrained fn emit_note_hash_opcode(note_hash: Field) {}

#[oracle(avmOpcodeNullifierExists)]
fn nullifier_exists_opcode(nullifier: Field, address: Field) -> u8 {}
unconstrained fn nullifier_exists_opcode(nullifier: Field, address: Field) -> u8 {}

#[oracle(avmOpcodeEmitNullifier)]
fn emit_nullifier_opcode(nullifier: Field) {}
unconstrained fn emit_nullifier_opcode(nullifier: Field) {}

#[oracle(amvOpcodeEmitUnencryptedLog)]
fn emit_unencrypted_log_opcode(event_selector: Field, message: [Field]) {}
unconstrained fn emit_unencrypted_log_opcode(event_selector: Field, message: [Field]) {}

#[oracle(avmOpcodeL1ToL2MsgExists)]
fn l1_to_l2_msg_exists_opcode(msg_hash: Field, msg_leaf_index: Field) -> u8 {}
unconstrained fn l1_to_l2_msg_exists_opcode(msg_hash: Field, msg_leaf_index: Field) -> u8 {}

#[oracle(avmOpcodeSendL2ToL1Msg)]
fn send_l2_to_l1_msg_opcode(recipient: EthAddress, content: Field) {}
unconstrained fn send_l2_to_l1_msg_opcode(recipient: EthAddress, content: Field) {}

#[oracle(avmOpcodeCall)]
fn call_opcode<RET_SIZE>(
unconstrained fn call_opcode<RET_SIZE>(
gas: [Field; 2], // gas allocation: [l2_gas, da_gas]
address: AztecAddress,
args: [Field],
Expand All @@ -345,7 +345,7 @@ fn call_opcode<RET_SIZE>(
// ^ return data ^ success

#[oracle(avmOpcodeStaticCall)]
fn call_static_opcode<RET_SIZE>(
unconstrained fn call_static_opcode<RET_SIZE>(
gas: [Field; 2], // gas allocation: [l2_gas, da_gas]
address: AztecAddress,
args: [Field],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl UnconstrainedContext {
}

#[oracle(getContractAddress)]
fn contract_address_oracle() -> AztecAddress {}
unconstrained fn contract_address_oracle() -> AztecAddress {}

#[oracle(getBlockNumber)]
fn block_number_oracle() -> u32 {}
unconstrained fn block_number_oracle() -> u32 {}
4 changes: 2 additions & 2 deletions noir-projects/aztec-nr/aztec/src/oracle/arguments.nr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#[oracle(packArgumentsArray)]
fn pack_arguments_array_oracle<N>(_args: [Field; N]) -> Field {}
unconstrained fn pack_arguments_array_oracle<N>(_args: [Field; N]) -> Field {}

#[oracle(packArguments)]
fn pack_arguments_oracle(_args: [Field]) -> Field {}
unconstrained fn pack_arguments_oracle(_args: [Field]) -> Field {}

/// - Pack arguments (array version) will notify the simulator that these arguments will be used later at
/// some point in the call.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use dep::protocol_types::{
};

#[oracle(callPrivateFunction)]
fn call_private_function_oracle(
unconstrained fn call_private_function_oracle(
_contract_address: AztecAddress,
_function_selector: FunctionSelector,
_args_hash: Field,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use dep::protocol_types::{
};

#[oracle(enqueuePublicFunctionCall)]
fn enqueue_public_function_call_oracle(
unconstrained fn enqueue_public_function_call_oracle(
_contract_address: AztecAddress,
_function_selector: FunctionSelector,
_args_hash: Field,
Expand Down Expand Up @@ -47,7 +47,7 @@ unconstrained pub fn enqueue_public_function_call_internal(
}

#[oracle(setPublicTeardownFunctionCall)]
fn set_public_teardown_function_call_oracle(
unconstrained fn set_public_teardown_function_call_oracle(
_contract_address: AztecAddress,
_function_selector: FunctionSelector,
_args_hash: Field,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ use dep::protocol_types::{
};

#[oracle(getContractInstance)]
fn get_contract_instance_oracle(_address: AztecAddress) -> [Field; CONTRACT_INSTANCE_LENGTH] {}
unconstrained fn get_contract_instance_oracle(_address: AztecAddress) -> [Field; CONTRACT_INSTANCE_LENGTH] {}

// Returns a ContractInstance plus a boolean indicating whether the instance was found.
#[oracle(avmOpcodeGetContractInstance)]
fn get_contract_instance_oracle_avm(_address: AztecAddress) -> [Field; CONTRACT_INSTANCE_LENGTH + 1] {}
unconstrained fn get_contract_instance_oracle_avm(_address: AztecAddress) -> [Field; CONTRACT_INSTANCE_LENGTH + 1] {}

unconstrained fn get_contract_instance_internal(address: AztecAddress) -> [Field; CONTRACT_INSTANCE_LENGTH] {
get_contract_instance_oracle(address)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ global L1_TO_L2_MESSAGE_ORACLE_CALL_LENGTH: u64 = 17;

// Obtains membership witness (index and sibling path) for a message in the L1 to L2 message tree.
#[oracle(getL1ToL2MembershipWitness)]
fn get_l1_to_l2_membership_witness_oracle(
unconstrained fn get_l1_to_l2_membership_witness_oracle(
_contract_address: AztecAddress,
_message_hash: Field,
_secret: Field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct MembershipWitness<N, M> {
}

#[oracle(getMembershipWitness)]
fn get_membership_witness_oracle<M>(
unconstrained fn get_membership_witness_oracle<M>(
_block_number: u32,
_tree_id: Field,
_leaf_value: Field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl NullifierMembershipWitness {
}

#[oracle(getLowNullifierMembershipWitness)]
fn get_low_nullifier_membership_witness_oracle(
unconstrained fn get_low_nullifier_membership_witness_oracle(
_block_number: u32,
_nullifier: Field
) -> [Field; NULLIFIER_MEMBERSHIP_WITNESS] {}
Expand All @@ -41,7 +41,7 @@ unconstrained pub fn get_low_nullifier_membership_witness(block_number: u32, nul
}

#[oracle(getNullifierMembershipWitness)]
fn get_nullifier_membership_witness_oracle(
unconstrained fn get_nullifier_membership_witness_oracle(
_block_number: u32,
_nullifier: Field
) -> [Field; NULLIFIER_MEMBERSHIP_WITNESS] {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct PublicDataWitness {
}

#[oracle(getPublicDataTreeWitness)]
fn get_public_data_witness_oracle(
unconstrained fn get_public_data_witness_oracle(
_block_number: u32,
_leaf_slot: Field
) -> [Field; PUBLIC_DATA_WITNESS] {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use dep::protocol_types::constants::PUBLIC_DATA_TREE_HEIGHT;

#[oracle(getSiblingPath)]
fn get_sibling_path_oracle<N>(_block_number: u32, _tree_id: Field, _leaf_index: Field) -> [Field; N] {}
unconstrained fn get_sibling_path_oracle<N>(_block_number: u32, _tree_id: Field, _leaf_index: Field) -> [Field; N] {}

unconstrained pub fn get_sibling_path<N>(
block_number: u32,
Expand Down
2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/aztec/src/oracle/header.nr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use dep::protocol_types::{constants::HEADER_LENGTH, header::Header};
use crate::{context::PrivateContext, oracle::get_membership_witness::get_archive_membership_witness};

#[oracle(getHeader)]
fn get_header_at_oracle(_block_number: u32) -> [Field; HEADER_LENGTH] {}
unconstrained fn get_header_at_oracle(_block_number: u32) -> [Field; HEADER_LENGTH] {}

unconstrained pub fn get_header_at_internal(block_number: u32) -> Header {
let header = get_header_at_oracle(block_number);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use dep::protocol_types::{
};

#[oracle(getKeyValidationRequest)]
fn get_key_validation_request_oracle(_pk_m_hash: Field, _key_index: Field) -> [Field; KEY_VALIDATION_REQUEST_LENGTH] {}
unconstrained fn get_key_validation_request_oracle(_pk_m_hash: Field, _key_index: Field) -> [Field; KEY_VALIDATION_REQUEST_LENGTH] {}

unconstrained fn get_key_validation_request_internal(npk_m_hash: Field, key_index: Field) -> KeyValidationRequest {
let result = get_key_validation_request_oracle(npk_m_hash, key_index);
Expand Down
2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/aztec/src/oracle/keys.nr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::keys::PublicKeys;
use dep::protocol_types::{address::{AztecAddress, PartialAddress}, grumpkin_point::GrumpkinPoint};

#[oracle(getPublicKeysAndPartialAddress)]
fn get_public_keys_and_partial_address_oracle(_address: AztecAddress) -> [Field; 9] {}
unconstrained fn get_public_keys_and_partial_address_oracle(_address: AztecAddress) -> [Field; 9] {}

unconstrained fn get_public_keys_and_partial_address_oracle_wrapper(address: AztecAddress) -> [Field; 9] {
get_public_keys_and_partial_address_oracle(address)
Expand Down
12 changes: 6 additions & 6 deletions noir-projects/aztec-nr/aztec/src/oracle/logs.nr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use dep::protocol_types::{address::AztecAddress, grumpkin_point::GrumpkinPoint};

// = 480 + 32 * N bytes
#[oracle(emitEncryptedNoteLog)]
fn emit_encrypted_note_log_oracle<M>(
unconstrained fn emit_encrypted_note_log_oracle<M>(
_note_hash_counter: u32,
_encrypted_note: [u8; M],
_counter: u32
Expand All @@ -17,7 +17,7 @@ unconstrained pub fn emit_encrypted_note_log<M>(
}

#[oracle(emitEncryptedEventLog)]
fn emit_encrypted_event_log_oracle<M>(
unconstrained fn emit_encrypted_event_log_oracle<M>(
_contract_address: AztecAddress,
_randomness: Field,
_encrypted_event: [u8; M],
Expand All @@ -35,7 +35,7 @@ unconstrained pub fn emit_encrypted_event_log<M>(

// = 480 + 32 * N bytes
#[oracle(computeEncryptedNoteLog)]
fn compute_encrypted_note_log_oracle<N, M>(
unconstrained fn compute_encrypted_note_log_oracle<N, M>(
_contract_address: AztecAddress,
_storage_slot: Field,
_note_type_id: Field,
Expand Down Expand Up @@ -67,7 +67,7 @@ unconstrained pub fn compute_encrypted_note_log<N, M>(

// = 480 + 32 * N bytes
#[oracle(computeEncryptedEventLog)]
fn compute_encrypted_event_log_oracle<N, M>(
unconstrained fn compute_encrypted_event_log_oracle<N, M>(
_contract_address: AztecAddress,
_randomness: Field,
_event_type_id: Field,
Expand Down Expand Up @@ -98,7 +98,7 @@ unconstrained pub fn compute_encrypted_event_log<N, M>(
}

#[oracle(emitUnencryptedLog)]
fn emit_unencrypted_log_oracle_private<T>(
unconstrained fn emit_unencrypted_log_oracle_private<T>(
_contract_address: AztecAddress,
_event_selector: Field,
_message: T,
Expand All @@ -115,7 +115,7 @@ unconstrained pub fn emit_unencrypted_log_private_internal<T>(
}

#[oracle(emitContractClassUnencryptedLog)]
fn emit_contract_class_unencrypted_log_private<N>(
unconstrained fn emit_contract_class_unencrypted_log_private<N>(
contract_address: AztecAddress,
event_selector: Field,
message: [Field; N],
Expand Down
8 changes: 4 additions & 4 deletions noir-projects/aztec-nr/aztec/src/oracle/notes.nr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::note::{note_header::NoteHeader, note_interface::NoteInterface};
use dep::protocol_types::{address::AztecAddress, utils::arr_copy_slice};

#[oracle(notifyCreatedNote)]
fn notify_created_note_oracle<N>(
unconstrained fn notify_created_note_oracle<N>(
_storage_slot: Field,
_note_type_id: Field,
_serialized_note: [Field; N],
Expand All @@ -28,7 +28,7 @@ unconstrained pub fn notify_created_note<N>(
}

#[oracle(notifyNullifiedNote)]
fn notify_nullified_note_oracle<N>(
unconstrained fn notify_nullified_note_oracle<N>(
_nullifier: Field,
_inner_note_hash: Field,
_counter: u32
Expand All @@ -43,7 +43,7 @@ unconstrained pub fn notify_nullified_note<N>(
}

#[oracle(getNotes)]
fn get_notes_oracle<N, S>(
unconstrained fn get_notes_oracle<N, S>(
_storage_slot: Field,
_num_selects: u8,
_select_by_indexes: [u8; N],
Expand Down Expand Up @@ -159,7 +159,7 @@ unconstrained pub fn get_notes<Note, N, NB, M, S, NS>(

// Only ever use this in private!
#[oracle(checkNullifierExists)]
fn check_nullifier_exists_oracle(_inner_nullifier: Field) -> Field {}
unconstrained fn check_nullifier_exists_oracle(_inner_nullifier: Field) -> Field {}

// Only ever use this in private!
unconstrained pub fn check_nullifier_exists(inner_nullifier: Field) -> bool {
Expand Down
2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/aztec/src/oracle/public_call.nr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use dep::protocol_types::{abis::function_selector::FunctionSelector, address::AztecAddress};
// TODO(6052): get new side effect counter from this call
#[oracle(callPublicFunction)]
fn call_public_function_oracle<RETURNS_COUNT>(
unconstrained fn call_public_function_oracle<RETURNS_COUNT>(
_contract_address: AztecAddress,
_function_selector: FunctionSelector,
_args_hash: Field,
Expand Down
4 changes: 2 additions & 2 deletions noir-projects/aztec-nr/aztec/src/oracle/returns.nr
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#[oracle(packReturns)]
fn pack_returns_oracle<N>(_returns: [Field]) -> Field {}
unconstrained fn pack_returns_oracle<N>(_returns: [Field]) -> Field {}

unconstrained pub fn pack_returns(returns: [Field]) {
let _unused = pack_returns_oracle(returns);
}

#[oracle(unpackReturns)]
fn unpack_returns_oracle<N>(_return_hash: Field) -> [Field; N] {}
unconstrained fn unpack_returns_oracle<N>(_return_hash: Field) -> [Field; N] {}

unconstrained pub fn unpack_returns<N>(return_hash: Field) -> [Field; N] {
unpack_returns_oracle(return_hash)
Expand Down
4 changes: 2 additions & 2 deletions noir-projects/aztec-nr/aztec/src/oracle/storage.nr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use dep::protocol_types::traits::{Deserialize, Serialize};

#[oracle(storageRead)]
fn storage_read_oracle<N>(_storage_slot: Field, _number_of_elements: Field) -> [Field; N] {}
unconstrained fn storage_read_oracle<N>(_storage_slot: Field, _number_of_elements: Field) -> [Field; N] {}

unconstrained fn storage_read_oracle_wrapper<N>(_storage_slot: Field) -> [Field; N] {
storage_read_oracle(_storage_slot, N)
Expand All @@ -12,7 +12,7 @@ pub fn storage_read<N>(storage_slot: Field) -> [Field; N] {
}

#[oracle(storageWrite)]
fn storage_write_oracle<N>(_storage_slot: Field, _values: [Field; N]) -> [Field; N] {}
unconstrained fn storage_write_oracle<N>(_storage_slot: Field, _values: [Field; N]) -> [Field; N] {}

unconstrained pub fn storage_write<N>(storage_slot: Field, fields: [Field; N]) {
let _hash = storage_write_oracle(storage_slot, fields);
Expand Down
2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/aztec/src/oracle/unsafe_rand.nr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[oracle(getRandomField)]
fn rand_oracle() -> Field {}
unconstrained fn rand_oracle() -> Field {}

// Called `unsafe_rand` because we do not constrain in circuit that we are dealing with an actual random value.
// Instead we just trust our PXE.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// docs:start:pop_capsule
#[oracle(popCapsule)]
fn pop_capsule_oracle<N>() -> [Field; N] {}
unconstrained fn pop_capsule_oracle<N>() -> [Field; N] {}

// A capsule is a "blob" of data that is passed to the contract through an oracle.
unconstrained pub fn pop_capsule<N>() -> [Field; N] {
Expand Down
Loading

0 comments on commit 7a68be4

Please sign in to comment.