Skip to content

Commit c28beec

Browse files
feat!: rm outgoing logs (#10486)
Remove outgoing logs from aztec.nr. Remove outgoing note discovery flows from typescript-land. Outgoing viewing keys are retained, but now aren't used anywhere. 2 weird problems encountered on this journey: - #10546 <-- an inexplicable blow-up in the debug_symbols field of two functions in the StateFulTestContract, despite features only being removed from that contract. - #10558 <-- a debug log keeping the NFT contract from breaking --------- Co-authored-by: Jan Beneš <janbenes1234@gmail.com>
1 parent d194cdf commit c28beec

File tree

70 files changed

+417
-1523
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+417
-1523
lines changed

boxes/boxes/react/src/contracts/src/main.nr

+2-4
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ contract BoxReact {
2525
let numbers = storage.numbers;
2626
let mut new_number = ValueNote::new(number, owner);
2727

28-
let owner_ovpk_m = get_public_keys(owner).ovpk_m;
29-
numbers.at(owner).initialize(&mut new_number).emit(encode_and_encrypt_note(&mut context, owner_ovpk_m, owner, context.msg_sender()));
28+
numbers.at(owner).initialize(&mut new_number).emit(encode_and_encrypt_note(&mut context, owner, context.msg_sender()));
3029
}
3130

3231
#[private]
@@ -37,8 +36,7 @@ contract BoxReact {
3736
let numbers = storage.numbers;
3837
let mut new_number = ValueNote::new(number, owner);
3938

40-
let owner_ovpk_m = get_public_keys(owner).ovpk_m;
41-
numbers.at(owner).replace(&mut new_number).emit(encode_and_encrypt_note(&mut context, owner_ovpk_m, owner, context.msg_sender()));
39+
numbers.at(owner).replace(&mut new_number).emit(encode_and_encrypt_note(&mut context, owner, context.msg_sender()));
4240
}
4341

4442
unconstrained fn getNumber(owner: AztecAddress) -> pub ValueNote {

boxes/boxes/vanilla/src/contracts/src/main.nr

+2-4
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ contract Vanilla {
2525
let numbers = storage.numbers;
2626
let mut new_number = ValueNote::new(number, owner);
2727

28-
let owner_ovpk_m = get_public_keys(owner).ovpk_m;
29-
numbers.at(owner).initialize(&mut new_number).emit(encode_and_encrypt_note(&mut context, owner_ovpk_m, owner, context.msg_sender()));
28+
numbers.at(owner).initialize(&mut new_number).emit(encode_and_encrypt_note(&mut context, owner, context.msg_sender()));
3029
}
3130

3231
#[private]
@@ -37,8 +36,7 @@ contract Vanilla {
3736
let numbers = storage.numbers;
3837
let mut new_number = ValueNote::new(number, owner);
3938

40-
let owner_ovpk_m = get_public_keys(owner).ovpk_m;
41-
numbers.at(owner).replace(&mut new_number).emit(encode_and_encrypt_note(&mut context, owner_ovpk_m, owner, context.msg_sender()));
39+
numbers.at(owner).replace(&mut new_number).emit(encode_and_encrypt_note(&mut context, owner, context.msg_sender()));
4240
}
4341

4442
unconstrained fn getNumber(owner: AztecAddress) -> pub ValueNote {

docs/docs/migration_notes.md

+25
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,31 @@ The `Header` struct has been renamed to `BlockHeader`, and the `get_header()` fa
1717
+ let header = context.get_block_header_at(block_number);
1818
```
1919

20+
### Outgoing Events removed
21+
22+
Previously, every event which was emitted included:
23+
- Incoming Header (to convey the app contract address to the recipient)
24+
- Incoming Ciphertext (to convey the note contents to the recipient)
25+
- Outgoing Header (served as a backup, to convey the app contract address to the "outgoing viewer" - most likely the sender)
26+
- Outgoing Ciphertext (served as a backup, encrypting the summetric key of the incoming ciphertext to the "outgoing viewer" - most likely the sender)
27+
28+
The latter two have been removed from the `.emit()` functions, so now only an Incoming Header and Incoming Ciphertext will be emitted.
29+
30+
The interface for emitting a note has therefore changed, slightly. No more ovpk's need to be derived and passed into `.emit()` functions.
31+
32+
```diff
33+
- nfts.at(to).insert(&mut new_note).emit(encode_and_encrypt_note(&mut context, from_ovpk_m, to, from));
34+
+ nfts.at(to).insert(&mut new_note).emit(encode_and_encrypt_note(&mut context, to, from));
35+
```
36+
37+
The `getOutgoingNotes` function is removed from the PXE interface.
38+
39+
Some aztec.nr library methods' arguments are simplified to remove an `outgoing_viewer` parameter. E.g. `ValueNote::increment`, `ValueNote::decrement`, `ValueNote::decrement_by_at_most`, `EasyPrivateUint::add`, `EasyPrivateUint::sub`.
40+
41+
Further changes are planned, so that:
42+
- Outgoing ciphertexts (or any kind of abstract ciphertext) can be emitted by a contract, and on the other side discovered and then processed by the contract.
43+
- Headers will be removed, due to the new tagging scheme.
44+
2045
## 0.66
2146

2247
### DEBUG env var is removed

noir-projects/aztec-nr/aztec/src/context/private_context.nr

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use dep::protocol_types::debug_log::debug_log_format;
2+
13
use crate::{
24
context::{inputs::PrivateContextInputs, packed_returns::PackedReturns},
35
hash::{ArgsHasher, hash_args_array},
@@ -137,6 +139,12 @@ impl PrivateContext {
137139

138140
pub fn push_note_hash(&mut self, note_hash: Field) {
139141
self.note_hashes.push(NoteHash { value: note_hash, counter: self.next_counter() });
142+
143+
// WARNING(https://github.com/AztecProtocol/aztec-packages/issues/10558): if you delete this debug_log_format line, some tests fail.
144+
debug_log_format(
145+
"Context.note_hashes, after pushing new note hash: {0}",
146+
self.note_hashes.storage().map(|nh: NoteHash| nh.value),
147+
);
140148
}
141149

142150
pub fn push_nullifier(&mut self, nullifier: Field) {
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
use crate::{
22
context::PrivateContext, encrypted_logs::payload::compute_private_log_payload,
3-
event::event_interface::EventInterface, keys::getters::get_ovsk_app,
4-
};
5-
use dep::protocol_types::{
6-
address::AztecAddress, constants::PRIVATE_LOG_SIZE_IN_FIELDS, public_keys::OvpkM,
3+
event::event_interface::EventInterface,
74
};
5+
use dep::protocol_types::{address::AztecAddress, constants::PRIVATE_LOG_SIZE_IN_FIELDS};
86

97
/// Computes private event log payload and a log hash
108
fn compute_payload<Event, let N: u32>(
119
context: PrivateContext,
1210
event: Event,
13-
ovsk_app: Field,
14-
ovpk: OvpkM,
1511
recipient: AztecAddress,
1612
sender: AztecAddress,
1713
) -> [Field; PRIVATE_LOG_SIZE_IN_FIELDS]
@@ -21,60 +17,48 @@ where
2117
let contract_address: AztecAddress = context.this_address();
2218
let plaintext = event.to_be_bytes();
2319

24-
compute_private_log_payload(
25-
contract_address,
26-
ovsk_app,
27-
ovpk,
28-
recipient,
29-
sender,
30-
plaintext,
31-
)
20+
compute_private_log_payload(contract_address, recipient, sender, plaintext)
3221
}
3322

3423
unconstrained fn compute_payload_unconstrained<Event, let N: u32>(
3524
context: PrivateContext,
3625
event: Event,
37-
ovpk: OvpkM,
3826
recipient: AztecAddress,
3927
sender: AztecAddress,
4028
) -> [Field; PRIVATE_LOG_SIZE_IN_FIELDS]
4129
where
4230
Event: EventInterface<N>,
4331
{
44-
let ovsk_app = get_ovsk_app(ovpk.hash());
45-
compute_payload(context, event, ovsk_app, ovpk, recipient, sender)
32+
compute_payload(context, event, recipient, sender)
4633
}
4734

4835
pub fn encode_and_encrypt_event<Event, let N: u32>(
4936
context: &mut PrivateContext,
50-
ovpk: OvpkM,
5137
recipient: AztecAddress,
5238
sender: AztecAddress,
53-
) -> fn[(&mut PrivateContext, OvpkM, AztecAddress, AztecAddress)](Event) -> ()
39+
) -> fn[(&mut PrivateContext, AztecAddress, AztecAddress)](Event) -> ()
5440
where
5541
Event: EventInterface<N>,
5642
{
5743
|e: Event| {
58-
let ovsk_app: Field = context.request_ovsk_app(ovpk.hash());
59-
let encrypted_log = compute_payload(*context, e, ovsk_app, ovpk, recipient, sender);
44+
let encrypted_log = compute_payload(*context, e, recipient, sender);
6045
context.emit_private_log(encrypted_log);
6146
}
6247
}
6348

6449
pub fn encode_and_encrypt_event_unconstrained<Event, let N: u32>(
6550
context: &mut PrivateContext,
66-
ovpk: OvpkM,
6751
recipient: AztecAddress,
6852
sender: AztecAddress,
69-
) -> fn[(&mut PrivateContext, OvpkM, AztecAddress, AztecAddress)](Event) -> ()
53+
) -> fn[(&mut PrivateContext, AztecAddress, AztecAddress)](Event) -> ()
7054
where
7155
Event: EventInterface<N>,
7256
{
7357
|e: Event| {
7458
// Unconstrained logs have both their content and encryption unconstrained - it could occur that the
7559
// recipient is unable to decrypt the payload.
7660
let encrypted_log =
77-
unsafe { compute_payload_unconstrained(*context, e, ovpk, recipient, sender) };
61+
unsafe { compute_payload_unconstrained(*context, e, recipient, sender) };
7862
context.emit_private_log(encrypted_log);
7963
}
8064
}
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
use crate::{
22
context::PrivateContext,
33
encrypted_logs::payload::compute_private_log_payload,
4-
keys::getters::get_ovsk_app,
54
note::{note_emission::NoteEmission, note_interface::NoteInterface},
65
};
76
use dep::protocol_types::{
87
abis::note_hash::NoteHash, address::AztecAddress, constants::PRIVATE_LOG_SIZE_IN_FIELDS,
9-
public_keys::OvpkM,
108
};
119

1210
/// Computes private note log payload
1311
fn compute_payload<Note, let N: u32>(
1412
context: PrivateContext,
1513
note: Note,
16-
ovsk_app: Field,
17-
ovpk: OvpkM,
1814
recipient: AztecAddress,
1915
sender: AztecAddress,
2016
) -> ([Field; PRIVATE_LOG_SIZE_IN_FIELDS], u32)
@@ -34,61 +30,48 @@ where
3430

3531
let plaintext = note.to_be_bytes(storage_slot);
3632

37-
let payload = compute_private_log_payload(
38-
contract_address,
39-
ovsk_app,
40-
ovpk,
41-
recipient,
42-
sender,
43-
plaintext,
44-
);
33+
let payload = compute_private_log_payload(contract_address, recipient, sender, plaintext);
4534

4635
(payload, note_hash_counter)
4736
}
4837

4938
unconstrained fn compute_payload_unconstrained<Note, let N: u32>(
5039
context: PrivateContext,
5140
note: Note,
52-
ovpk: OvpkM,
5341
recipient: AztecAddress,
5442
sender: AztecAddress,
5543
) -> ([Field; PRIVATE_LOG_SIZE_IN_FIELDS], u32)
5644
where
5745
Note: NoteInterface<N>,
5846
{
59-
let ovsk_app = get_ovsk_app(ovpk.hash());
60-
compute_payload(context, note, ovsk_app, ovpk, recipient, sender)
47+
compute_payload(context, note, recipient, sender)
6148
}
6249

6350
// This function seems to be affected by the following Noir bug:
6451
// https://github.com/noir-lang/noir/issues/5771
6552
// If you get weird behavior it might be because of it.
6653
pub fn encode_and_encrypt_note<Note, let N: u32>(
6754
context: &mut PrivateContext,
68-
ovpk: OvpkM,
6955
recipient: AztecAddress,
70-
// TODO: We need this because to compute a tagging secret, we require a sender. Should we have the tagging secret oracle take a ovpk_m as input instead of the address?
56+
// We need this because to compute a tagging secret, we require a sender:
7157
sender: AztecAddress,
72-
) -> fn[(&mut PrivateContext, OvpkM, AztecAddress, AztecAddress)](NoteEmission<Note>) -> ()
58+
) -> fn[(&mut PrivateContext, AztecAddress, AztecAddress)](NoteEmission<Note>) -> ()
7359
where
7460
Note: NoteInterface<N>,
7561
{
7662
|e: NoteEmission<Note>| {
77-
let ovsk_app: Field = context.request_ovsk_app(ovpk.hash());
78-
7963
let (encrypted_log, note_hash_counter) =
80-
compute_payload(*context, e.note, ovsk_app, ovpk, recipient, sender);
64+
compute_payload(*context, e.note, recipient, sender);
8165
context.emit_raw_note_log(encrypted_log, note_hash_counter);
8266
}
8367
}
8468

8569
pub fn encode_and_encrypt_note_unconstrained<Note, let N: u32>(
8670
context: &mut PrivateContext,
87-
ovpk: OvpkM,
8871
recipient: AztecAddress,
89-
// TODO: We need this because to compute a tagging secret, we require a sender. Should we have the tagging secret oracle take a ovpk_m as input instead of the address?
72+
// We need this because to compute a tagging secret, we require a sender:
9073
sender: AztecAddress,
91-
) -> fn[(&mut PrivateContext, OvpkM, AztecAddress, AztecAddress)](NoteEmission<Note>) -> ()
74+
) -> fn[(&mut PrivateContext, AztecAddress, AztecAddress)](NoteEmission<Note>) -> ()
9275
where
9376
Note: NoteInterface<N>,
9477
{
@@ -104,7 +87,7 @@ where
10487
// return the log from this function to the app, otherwise it could try to do stuff with it and then that might
10588
// be wrong.
10689
let (encrypted_log, note_hash_counter) =
107-
unsafe { compute_payload_unconstrained(*context, e.note, ovpk, recipient, sender) };
90+
unsafe { compute_payload_unconstrained(*context, e.note, recipient, sender) };
10891
context.emit_raw_note_log(encrypted_log, note_hash_counter);
10992
}
11093
}

0 commit comments

Comments
 (0)