Skip to content

Commit

Permalink
chore(aztec-nr): minor public interface changes (#5776)
Browse files Browse the repository at this point in the history
The purpose of this PR is to minimize the possible change surface on public interfaces, so that moving to the AVM simulator is easier.

* Removed `get_header()` from PublicContext(Interface). It's currently unused, and the AVM does not support it as is. It CAN be added to the AvmContext if needed. However, as we are not using it now, and the AVM form is not clear (HEADERMEMBER? or whole header?) then it's better to discourage its use.
* Moved `push_*_read_request` from PublicContextInterface to the PublicContext iself, as PRIVATE methods: These methods are currently unused, and IIUC, will not be used in the AVM. The only use case for these in current public would be to push read request in `PublicContext::nullifier_exists`.
* Remove unused `createCommitment` oracle.
  • Loading branch information
fcarreiro committed Apr 16, 2024
1 parent f50b180 commit 91b8110
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 43 deletions.
12 changes: 0 additions & 12 deletions noir-projects/aztec-nr/aztec/src/context/avm_context.nr
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,6 @@ impl PublicContextInterface for AvmContext {
nullifier_exists(unsiloed_nullifier, address.to_field()) == 1
}

fn push_nullifier_read_request(&mut self, nullifier: Field) {
assert(false, "'push_nullifier_read_request' not implemented!");
}

fn push_nullifier_non_existent_read_request(&mut self, nullifier: Field) {
assert(false, "'push_nullifier_non_existent_read_request' not implemented!");
}

fn accumulate_encrypted_logs<N>(&mut self, log: [Field; N]) {
assert(false, "'accumulate_encrypted_logs' not implemented!");
}
Expand Down Expand Up @@ -222,10 +214,6 @@ impl ContextInterface for AvmContext {
fn selector(self) -> FunctionSelector {
FunctionSelector::from_field(self.inputs.selector)
}
fn get_header(self) -> Header {
assert(false, "'get_header' not implemented!");
Header::empty()
}
fn get_args_hash(self) -> Field {
self.inputs.args_hash
}
Expand Down
3 changes: 0 additions & 3 deletions noir-projects/aztec-nr/aztec/src/context/interface.nr
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ trait ContextInterface {
fn version(self) -> Field;
fn selector(self) -> FunctionSelector;
fn get_args_hash(self) -> Field;
fn get_header(self) -> Header;
}

// TEMPORARY: This trait is to promote sharing of the current public context
Expand All @@ -27,8 +26,6 @@ trait PublicContextInterface {
fn fee_per_da_gas(self) -> Field;
fn fee_per_l1_gas(self) -> Field;
fn fee_per_l2_gas(self) -> Field;
fn push_nullifier_read_request(&mut self, nullifier: Field);
fn push_nullifier_non_existent_read_request(&mut self, nullifier: Field);
fn message_portal(&mut self, recipient: EthAddress, content: Field);
fn consume_l1_to_l2_message(&mut self, content: Field, secret: Field, sender: EthAddress);
fn accumulate_encrypted_logs<N>(&mut self, log: [Field; N]);
Expand Down
12 changes: 6 additions & 6 deletions noir-projects/aztec-nr/aztec/src/context/private_context.nr
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,6 @@ impl ContextInterface for PrivateContext {
self.args_hash
}

// Returns the header of a block whose state is used during private execution (not the block the transaction is
// included in).
fn get_header(self) -> Header {
self.historical_header
}

fn push_new_note_hash(&mut self, note_hash: Field) {
let side_effect = SideEffect { value: note_hash, counter: self.side_effect_counter };
self.new_note_hashes.push(side_effect);
Expand Down Expand Up @@ -149,6 +143,12 @@ impl PrivateContext {
}
}

// Returns the header of a block whose state is used during private execution (not the block the transaction is
// included in).
fn get_header(self) -> Header {
self.historical_header
}

// Returns the header of an arbitrary block whose block number is less than or equal to the block number
// of historical header.
pub fn get_header_at(self, block_number: u32) -> Header {
Expand Down
30 changes: 14 additions & 16 deletions noir-projects/aztec-nr/aztec/src/context/public_context.nr
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,20 @@ impl PublicContext {
self.return_hash = returns_hasher.hash();
}

// Keep private or ask the AVM team if you want to change it.
fn push_nullifier_read_request(&mut self, nullifier: Field) {
let request = ReadRequest { value: nullifier, counter: self.side_effect_counter };
self.nullifier_read_requests.push(request);
self.side_effect_counter = self.side_effect_counter + 1;
}

// Keep private or ask the AVM team if you want to change it.
fn push_nullifier_non_existent_read_request(&mut self, nullifier: Field) {
let request = ReadRequest { value: nullifier, counter: self.side_effect_counter };
self.nullifier_non_existent_read_requests.push(request);
self.side_effect_counter = self.side_effect_counter + 1;
}

pub fn finish(self) -> PublicCircuitPublicInputs {
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/1165)
let unencrypted_logs_hash = 0;
Expand Down Expand Up @@ -190,10 +204,6 @@ impl ContextInterface for PublicContext {
self.args_hash
}

fn get_header(self) -> Header {
self.historical_header
}

fn push_new_note_hash(&mut self, note_hash: Field) {
let side_effect = SideEffect { value: note_hash, counter: self.side_effect_counter };
self.new_note_hashes.push(side_effect);
Expand Down Expand Up @@ -246,18 +256,6 @@ impl PublicContextInterface for PublicContext {
nullifier_exists_oracle(siloed_nullifier) == 1
}

fn push_nullifier_read_request(&mut self, nullifier: Field) {
let request = ReadRequest { value: nullifier, counter: self.side_effect_counter };
self.nullifier_read_requests.push(request);
self.side_effect_counter = self.side_effect_counter + 1;
}

fn push_nullifier_non_existent_read_request(&mut self, nullifier: Field) {
let request = ReadRequest { value: nullifier, counter: self.side_effect_counter };
self.nullifier_non_existent_read_requests.push(request);
self.side_effect_counter = self.side_effect_counter + 1;
}

fn message_portal(&mut self, recipient: EthAddress, content: Field) {
let message = L2ToL1Message { recipient, content };
self.new_l2_to_l1_msgs.push(message);
Expand Down
6 changes: 0 additions & 6 deletions noir-projects/aztec-nr/aztec/src/oracle/create_commitment.nr

This file was deleted.

0 comments on commit 91b8110

Please sign in to comment.