Skip to content

Commit

Permalink
chore: minor public interface changes
Browse files Browse the repository at this point in the history
  • Loading branch information
fcarreiro committed Apr 16, 2024
1 parent f849575 commit a5d54e8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 37 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 @@ -99,12 +99,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 @@ -148,6 +142,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 @@ -189,10 +203,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 @@ -245,18 +255,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

0 comments on commit a5d54e8

Please sign in to comment.