Skip to content

Commit 4febe55

Browse files
committed
fix(port): block #24580 — decisions: align aztec-nr + fairies contracts to the v5 tip
#24580 builds on v5 refactors that arrived via UNLABELLED v5 trains this driver never received (notably #24369 'reimplement partial notes on FactStore' — deletes messages/{discovery/partial_notes.nr,processing/message_context.nr}, adds partial_notes/{fsm,mod}.nr and the ResolvedTx processing shape — and #24508 'keep handshake secrets internal to TagSecretSource'). Without them the stack's aztec-nr/contract surfaces were an incoherent mix of eras (obtain_secrets/MessageContext/get_all_discovered_handshakes resolution failures). Aligned byte-identically to the v5 tip a455b9a: - noir-projects/aztec-nr (EXCEPT context/private_context.nr + context/inputs/private_context_inputs.nr, which keep next-only tx_request_salt; verify: git diff a455b9a -- noir-projects/aztec-nr) - contracts/standard/handshake_registry_contract (whole dir) - contracts/test/{onchain_delivery_test_contract,custom_message_contract} aztec-nr + all noir-contracts compile clean.
1 parent 408cfea commit 4febe55

18 files changed

Lines changed: 668 additions & 269 deletions

File tree

noir-projects/aztec-nr/aztec/src/lib.nr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ pub mod transient;
4545
pub mod event;
4646
pub mod facts;
4747
pub mod messages;
48+
pub(crate) mod partial_notes;
4849
pub use protocol_types as protocol;
4950
pub(crate) mod logging;
5051
pub mod utils;

noir-projects/aztec-nr/aztec/src/messages/delivery/tag.nr

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use crate::context::PrivateContext;
66
use crate::messages::delivery::{
7-
constrained_delivery::emit_sequence_nullifier,
87
OnchainDeliveryMode,
98
tag_derivation::{existing_handshake_secrets_or_else, TagDerivation},
109
tag_secret_source::TagSecretSource,
@@ -28,15 +27,17 @@ pub(crate) fn derive_log_tag(
2827
recipient: AztecAddress,
2928
tag_derivation: Option<TagDerivation>,
3029
) -> Field {
31-
let source = tag_derivation.map_or_else(|| default_tag_secret_source(sender, recipient, mode), |derivation| {
32-
derivation.into_tag_secret_source(sender, recipient)
33-
});
30+
let source = tag_derivation.map_or_else(
31+
|| default_tag_secret_source(context, sender, recipient, mode),
32+
|derivation| derivation.into_tag_secret_source(context, sender, recipient),
33+
);
3434
tag_with(source, context, mode, sender, recipient)
3535
}
3636

3737
/// The wallet-resolved default: reuse a handshake already registered for the pair, otherwise let the wallet resolve
3838
/// the tagging secret strategy.
3939
fn default_tag_secret_source(
40+
context: &mut PrivateContext,
4041
sender: AztecAddress,
4142
recipient: AztecAddress,
4243
mode: OnchainDeliveryMode,
@@ -49,7 +50,7 @@ fn default_tag_secret_source(
4950
// secret before a constrained tag is emitted, so an untrusted strategy can't produce a valid unbacked
5051
// constrained tag.
5152
let strategy = unsafe { resolve_tagging_strategy(sender, recipient, mode) };
52-
strategy.into()
53+
strategy.into_tag_secret_source(context, sender, recipient)
5354
},
5455
)
5556
}
@@ -61,19 +62,18 @@ fn tag_with(
6162
sender: AztecAddress,
6263
recipient: AztecAddress,
6364
) -> Field {
64-
let secrets = source.obtain_secrets(context, sender, recipient);
65+
let secret = source.tag_secret();
6566

6667
// Safety: the index is untrusted. Constrained delivery constrains it below before emitting the tag; unconstrained
6768
// discovery tolerates gaps, so a wrong index only yields an undiscoverable tag.
68-
let index = unsafe { get_next_tagging_index(secrets.shared, mode) };
69+
let index = unsafe { get_next_tagging_index(secret, mode) };
6970

7071
if mode == OnchainDeliveryMode::onchain_constrained() {
71-
source.constrain_secrets(context, sender, recipient, secrets, index);
72-
emit_sequence_nullifier(context, sender, recipient, secrets, index);
72+
source.constrain_tag_secret(context, sender, recipient, index);
7373
}
7474

75-
// The discovery tag stays derived from the shared secret only, so the recipient still finds every message.
76-
tag_from_secret_and_index(secrets.shared, index, mode)
75+
// The discovery tag stays derived from the tag secret only, so the recipient still finds every message.
76+
tag_from_secret_and_index(secret, index, mode)
7777
}
7878

7979
fn tag_domain_separator(mode: OnchainDeliveryMode) -> u32 {

noir-projects/aztec-nr/aztec/src/messages/discovery/mod.nr

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ use crate::messages::{
44
delivery::handshake::{get_handshake_secrets, PROVIDED_SECRETS_ARRAY_BASE_SLOT},
55
processing::provided_secret::ProvidedSecret,
66
};
7+
use crate::partial_notes;
78
use crate::protocol::address::AztecAddress;
89

910
pub(crate) mod nonce_discovery;
10-
pub(crate) mod partial_notes;
1111
pub(crate) mod private_events;
1212
pub mod private_notes;
1313
pub mod process_message;
@@ -18,8 +18,8 @@ use crate::{
1818
encoding::MAX_MESSAGE_CONTENT_LEN,
1919
logs::note::MAX_NOTE_PACKED_LEN,
2020
processing::{
21-
MessageContext, offchain::OffchainInboxSync, OffchainMessageWithContext,
22-
pending_tagged_log::PendingTaggedLog, validate_and_store_enqueued_notes_and_events,
21+
offchain::OffchainInboxSync, OffchainMessageWithTx, pending_tagged_log::PendingTaggedLog, ResolvedTx,
22+
validate_and_store_enqueued_notes_and_events,
2323
},
2424
},
2525
oracle::message_processing,
@@ -108,7 +108,7 @@ pub type CustomMessageHandler = unconstrained fn(
108108
/* msg_type_id */ u64,
109109
/* msg_metadata */ u64,
110110
/* msg_content */ BoundedVec<Field, MAX_MESSAGE_CONTENT_LEN>,
111-
/* message_context */ MessageContext,
111+
/* resolved_tx */ ResolvedTx,
112112
/* scope */ AztecAddress);
113113

114114
/// Custom state synchronization handler.
@@ -209,22 +209,22 @@ unconstrained fn sync_state_with_secrets(
209209

210210
if offchain_inbox_sync.is_some() {
211211
let msgs = offchain_inbox_sync.unwrap()(contract_address, scope);
212-
msgs.for_each(|_i, msg: OffchainMessageWithContext| {
212+
msgs.for_each(|_i, msg: OffchainMessageWithTx| {
213213
process_message_ciphertext(
214214
contract_address,
215215
compute_note_hash,
216216
compute_note_nullifier,
217217
process_custom_message,
218218
msg.message_ciphertext,
219-
msg.message_context,
219+
msg.resolved_tx,
220220
scope,
221221
);
222222
});
223223
}
224224

225225
// Then we process all pending partial notes, regardless of whether they were found in the current or previous
226226
// executions.
227-
partial_notes::fetch_and_process_partial_note_completion_logs(
227+
partial_notes::sync(
228228
contract_address,
229229
compute_note_hash,
230230
compute_note_nullifier,
@@ -264,7 +264,7 @@ mod test {
264264
// Mock the oracle call to return a known base slot, then populate an ephemeral
265265
// array at that slot so do_sync_state processes a non-empty log list.
266266
let base_slot = 42;
267-
let mock = std::test::OracleMock::mock("aztec_utl_getPendingTaggedLogs");
267+
let mock = std::test::OracleMock::mock("aztec_utl_getPendingTaggedLogsV2");
268268
let _ = mock.returns(base_slot);
269269

270270
let logs: EphemeralArray<PendingTaggedLog> = EphemeralArray::at(base_slot);
@@ -281,6 +281,10 @@ mod test {
281281
no_inbox_sync,
282282
scope,
283283
);
284+
285+
// Guards against the mocked oracle name going stale: if sync stops calling it, the crafted empty log
286+
// above is never consumed and the test silently stops covering the empty-payload path.
287+
assert_eq(mock.times_called(), 1);
284288
});
285289
}
286290

noir-projects/aztec-nr/aztec/src/messages/discovery/partial_notes.nr

Lines changed: 0 additions & 182 deletions
This file was deleted.

0 commit comments

Comments
 (0)