Skip to content

Commit 5e9bde1

Browse files
committed
chore: debug info to debug duplicate nullifier
1 parent ae4bc46 commit 5e9bde1

File tree

2 files changed

+60
-3
lines changed
  • noir-projects/noir-contracts/contracts/app

2 files changed

+60
-3
lines changed

noir-projects/noir-contracts/contracts/app/amm_contract/src/main.nr

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub contract AMM {
4141
};
4242
use dep::aztec::{
4343
macros::{functions::{initializer, internal, private, public, utility}, storage::storage},
44-
protocol_types::address::AztecAddress,
44+
protocol_types::{address::AztecAddress, traits::ToField},
4545
state_vars::PublicImmutable,
4646
};
4747

@@ -331,6 +331,18 @@ pub contract AMM {
331331
amount_out_min: u128,
332332
authwit_nonce: Field,
333333
) {
334+
// TODO(DUPLICATE_NULLIFIER_ISSUE): Nuke this log once the issue is resolved.
335+
aztec::oracle::debug_log::debug_log_format(
336+
"swap_exact_tokens_for_tokens: token_in {0}, token_out {1}, amount_in {2}, amount_out_min {3}",
337+
[
338+
token_in.to_field(),
339+
token_out.to_field(),
340+
amount_in as Field,
341+
amount_out_min as Field,
342+
],
343+
);
344+
// NUKE_END
345+
334346
let config = storage.config.read();
335347

336348
assert((token_in == config.token0) | (token_in == config.token1), "TOKEN_IN_IS_INVALID");
@@ -356,6 +368,10 @@ pub contract AMM {
356368
token_out_partial_note,
357369
)
358370
.enqueue(&mut context);
371+
372+
// TODO(DUPLICATE_NULLIFIER_ISSUE): Nuke this log once the issue is resolved.
373+
aztec::oracle::debug_log::debug_log_format("swap_exact_tokens_for_tokens end", []);
374+
// NUKE_END
359375
}
360376

361377
#[public]

noir-projects/noir-contracts/contracts/app/token_contract/src/main.nr

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ pub contract Token {
3131
};
3232

3333
use dep::uint_note::uint_note::{PartialUintNote, UintNote};
34-
use aztec::protocol_types::{address::AztecAddress, traits::ToField};
34+
use aztec::protocol_types::{
35+
abis::side_effect::OrderedValue, address::AztecAddress, traits::ToField,
36+
};
3537

3638
// docs:start:import_authwit
3739
use aztec::authwit::auth::compute_authwit_nullifier;
@@ -235,7 +237,26 @@ pub contract Token {
235237
amount: u128,
236238
authwit_nonce: Field,
237239
) {
240+
// TODO(DUPLICATE_NULLIFIER_ISSUE): Nuke this log once the issue is resolved.
241+
aztec::oracle::debug_log::debug_log_format(
242+
"transfer_to_public: from {0}, to {1}, amount {2}",
243+
[from.to_field(), to.to_field(), amount.to_field()],
244+
);
245+
aztec::oracle::debug_log::debug_log_format(
246+
"nullifiers in context before emission transfer_to_public: {}",
247+
context.nullifiers.storage().map(|n| n.value()),
248+
);
249+
// NUKE_END
250+
238251
storage.balances.at(from).sub(from, amount).emit(encode_and_encrypt_note(&mut context, from));
252+
253+
// TODO(DUPLICATE_NULLIFIER_ISSUE): Nuke this log once the issue is resolved.
254+
aztec::oracle::debug_log::debug_log_format(
255+
"nullifiers in context after emission transfer_to_public: {}",
256+
context.nullifiers.storage().map(|n| n.value()),
257+
);
258+
// NUKE_END
259+
239260
Token::at(context.this_address())._increase_public_balance(to, amount).enqueue(&mut context);
240261
}
241262
// docs:end:transfer_to_public
@@ -423,7 +444,27 @@ pub contract Token {
423444
/// returned partial note.
424445
#[private]
425446
fn prepare_private_balance_increase(to: AztecAddress) -> PartialUintNote {
426-
_prepare_private_balance_increase(to, &mut context, storage)
447+
// TODO(DUPLICATE_NULLIFIER_ISSUE): Nuke this log once the issue is resolved.
448+
aztec::oracle::debug_log::debug_log_format(
449+
"prepare_private_balance_increase, to: {0}",
450+
[to.to_field()],
451+
);
452+
aztec::oracle::debug_log::debug_log_format(
453+
"nullifiers in context before emission prepare_private_balance_increase: {}",
454+
context.nullifiers.storage().map(|n| n.value()),
455+
);
456+
// NUKE_END
457+
458+
let partial_note = _prepare_private_balance_increase(to, &mut context, storage);
459+
460+
// TODO(DUPLICATE_NULLIFIER_ISSUE): Nuke this log once the issue is resolved.
461+
aztec::oracle::debug_log::debug_log_format(
462+
"nullifiers in context after emission transfer_to_public: {}",
463+
context.nullifiers.storage().map(|n| n.value()),
464+
);
465+
// NUKE_END
466+
467+
partial_note
427468
}
428469
// docs:end:prepare_private_balance_increase
429470

0 commit comments

Comments
 (0)