Conversation
Benchmark Comparison
Contract: token
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Transfer Event CoverageFull coverage table for all Legend:
Token Tests (
|
| Test | Transaction | Contract | Expected Events | Line |
|---|---|---|---|---|
| mint in public, prepare partial note and finalize it | mint_to_public(alice, AMOUNT) |
Token | Transfer(0x0, alice, AMOUNT) |
119 |
transfer_public_to_commitment(alice, commitment, AMOUNT) |
Token | Transfer(alice, PRIV, AMOUNT) |
145 | |
| public transfer with authwitness | mint_to_public(alice, AMOUNT) |
Token | Transfer(0x0, alice, AMOUNT) |
163 |
transfer_public_to_public(alice, bob, AMOUNT) |
Token | Transfer(alice, bob, AMOUNT) |
192 | |
| private transfer with authwitness | mint_to_public(alice, AMOUNT) |
Token | Transfer(0x0, alice, AMOUNT) |
207 |
transfer_public_to_private(alice, alice, AMOUNT) |
Token | Transfer(alice, PRIV, AMOUNT) |
217 | |
transfer_private_to_private(alice, bob, AMOUNT) |
Token | (none — purely private) | 243 |
Tokenized Vault Tests — No Authwits (tokenized_vault.test.ts)
Public Assets, Public Shares
| Transaction | Contract | Expected Events | Line |
|---|---|---|---|
mint_to_public(alice, 100) |
Asset | Transfer(0x0, alice, 100) |
89 |
mint_to_public(bob, 100) |
Asset | Transfer(0x0, bob, 100) |
93 |
deposit_public_to_public(alice, alice, 9) |
Asset | Transfer(alice, vault, 9) |
104 |
| Vault | Transfer(0x0, alice, 9) |
107 | |
mint_to_public(vault, 5) (yield) |
Asset | Transfer(0x0, vault, 5) |
113 |
issue_public_to_public(bob, bob, 10, 15) |
Vault | Transfer(0x0, bob, 10) |
124 |
withdraw_public_to_public(alice, alice, maxWithdraw) |
Vault | Transfer(alice, 0x0, 9) |
144 |
| Asset | Transfer(vault, alice, maxWithdraw) |
147 | |
redeem_public_to_public(bob, bob, 10) |
Vault | Transfer(bob, 0x0, 10) |
154 |
| Asset | Transfer(vault, bob, 15) |
157 |
Private Assets, Public Shares
| Transaction | Contract | Expected Events | Line |
|---|---|---|---|
mint_to_private(alice, 100) |
Asset | Transfer(0x0, PRIV, 100) |
179 |
mint_to_private(bob, 100) |
Asset | Transfer(0x0, PRIV, 100) |
183 |
deposit_private_to_public(alice, alice, 9) |
Asset | Transfer(PRIV, vault, 9) |
194 |
| Vault | Transfer(0x0, alice, 9) |
197 | |
issue_private_to_public_exact(bob, bob, 10, 15) |
Vault | Transfer(0x0, bob, 10) |
212 |
withdraw_public_to_private(alice, alice, maxWithdraw) |
Vault | Transfer(alice, 0x0, 9) |
231 |
| Asset | Transfer(vault, PRIV, maxWithdraw) |
234 | |
redeem_public_to_private_exact(bob, bob, 10, 15) |
Vault | Transfer(bob, 0x0, 10) |
245 |
| Asset | Transfer(vault, PRIV, 15) |
248 |
Public Assets, Private Shares
| Transaction | Contract | Expected Events | Line |
|---|---|---|---|
deposit_public_to_private(alice, alice, 9, 9) |
Asset | Transfer(alice, vault, 9) |
278 |
| Vault | Transfer(0x0, PRIV, 9) |
281 | |
issue_public_to_private(bob, bob, 10, 15) |
Vault | Transfer(0x0, PRIV, 10) |
296 |
withdraw_private_to_public_exact(alice, alice, maxWithdraw, 9) |
Vault | Transfer(PRIV, 0x0, 9) |
317 |
| Asset | Transfer(vault, alice, maxWithdraw) |
320 | |
redeem_private_to_public(bob, bob, 10) |
Vault | Transfer(PRIV, 0x0, 10) |
327 |
| Asset | Transfer(vault, bob, 15) |
330 |
Private Assets, Private Shares
| Transaction | Contract | Expected Events | Line |
|---|---|---|---|
mint_to_private(alice, 100) |
Asset | Transfer(0x0, PRIV, 100) |
351 |
mint_to_private(bob, 100) |
Asset | Transfer(0x0, PRIV, 100) |
355 |
deposit_private_to_private(alice, alice, 9, 9) |
Asset | Transfer(PRIV, vault, 9) |
366 |
| Vault | Transfer(0x0, PRIV, 9) |
369 | |
issue_private_to_private_exact(bob, bob, 10, 15) |
Vault | Transfer(0x0, PRIV, 10) |
384 |
withdraw_private_to_private(alice, alice, maxWithdraw, 9) |
Vault | Transfer(PRIV, 0x0, 9) |
404 |
| Asset | Transfer(vault, PRIV, maxWithdraw) |
407 | |
redeem_private_to_private_exact(bob, bob, 10, 15) |
Vault | Transfer(PRIV, 0x0, 10) |
417 |
Exact Methods, Mixed Assets, Private Shares
| Transaction | Contract | Expected Events | Line |
|---|---|---|---|
deposit_private_to_private_exact(alice, alice, 9, 9) |
Asset | Transfer(PRIV, vault, 9) |
447 |
| Vault | Transfer(0x0, PRIV, 9) |
451 | |
deposit_public_to_private_exact(bob, bob, 15, 10) |
Asset | Transfer(bob, vault, 15) |
465 |
withdraw_private_to_private_exact(alice, alice, maxWithdraw, 9) |
Vault | Transfer(PRIV, 0x0, 9) |
488 |
| Asset | Transfer(vault, PRIV, maxWithdraw) |
491 | |
withdraw_private_to_public_exact(bob, bob, 15, 10) |
Vault | Transfer(PRIV, 0x0, 10) |
501 |
| Asset | Transfer(vault, bob, 15) |
504 |
Tokenized Vault Tests — With Authwits (tokenized_vault.test.ts)
The authwit test suite mirrors the no-authwit suite above but uses Carl as the transaction submitter with authorization witnesses. The same Transfer event patterns apply — authwits do not change which events are emitted, only who is authorized to submit the transaction.
Public Assets, Public Shares (authwit)
| Transaction | Contract | Expected Events | Line |
|---|---|---|---|
deposit_public_to_public (carl submits) |
Asset | Transfer(alice, vault, 9) |
535 |
| Vault | Transfer(0x0, alice, 9) |
538 | |
issue_public_to_public (carl submits) |
Vault | Transfer(0x0, bob, 10) |
549 |
withdraw_public_to_public (carl submits) |
Vault | Transfer(alice, 0x0, 9) |
569 |
| Asset | Transfer(vault, alice, maxWithdraw) |
572 | |
redeem_public_to_public (carl submits) |
Vault | Transfer(bob, 0x0, 10) |
580 |
| Asset | Transfer(vault, bob, 15) |
583 |
Private Assets, Public Shares (authwit)
| Transaction | Contract | Expected Events | Line |
|---|---|---|---|
deposit_private_to_public (carl submits) |
Asset | Transfer(PRIV, vault, 9) |
617 |
| Vault | Transfer(0x0, alice, 9) |
620 | |
issue_private_to_public_exact (carl submits) |
Vault | Transfer(0x0, bob, 10) |
636 |
withdraw_public_to_private |
Vault | Transfer(alice, 0x0, 9) |
656 |
| Asset | Transfer(vault, PRIV, maxWithdraw) |
659 | |
redeem_public_to_private_exact |
Vault | Transfer(bob, 0x0, 10) |
668 |
| Asset | Transfer(vault, PRIV, 15) |
671 |
Public Assets, Private Shares (authwit)
| Transaction | Contract | Expected Events | Line |
|---|---|---|---|
deposit_public_to_private (carl submits) |
Asset | Transfer(alice, vault, 9) |
705 |
| Vault | Transfer(0x0, PRIV, 9) |
708 | |
issue_public_to_private (carl submits) |
Vault | Transfer(0x0, PRIV, 10) |
724 |
withdraw_private_to_public_exact (carl submits) |
Vault | Transfer(PRIV, 0x0, 9) |
753 |
| Asset | Transfer(vault, alice, maxWithdraw) |
756 | |
redeem_private_to_public (carl submits) |
Vault | Transfer(PRIV, 0x0, 10) |
764 |
| Asset | Transfer(vault, bob, 15) |
767 |
Private Assets, Private Shares (authwit)
| Transaction | Contract | Expected Events | Line |
|---|---|---|---|
deposit_private_to_private (carl submits) |
Asset | Transfer(PRIV, vault, 9) |
801 |
| Vault | Transfer(0x0, PRIV, 9) |
804 | |
issue_private_to_private_exact (carl submits) |
Vault | Transfer(0x0, PRIV, 10) |
820 |
withdraw_private_to_private (carl submits) |
Vault | Transfer(PRIV, 0x0, 9) |
843 |
| Asset | Transfer(vault, PRIV, maxWithdraw) |
846 | |
redeem_private_to_private_exact (carl submits) |
Vault | Transfer(PRIV, 0x0, 10) |
854 |
Exact Methods, Mixed Assets, Private Shares (authwit)
| Transaction | Contract | Expected Events | Line |
|---|---|---|---|
deposit_private_to_private_exact (carl submits) |
Asset | Transfer(PRIV, vault, 9) |
888 |
| Vault | Transfer(0x0, PRIV, 9) |
891 | |
deposit_public_to_private_exact (carl submits) |
Asset | Transfer(bob, vault, 15) |
907 |
withdraw_private_to_private_exact (carl submits) |
Vault | Transfer(PRIV, 0x0, 9) |
930 |
| Asset | Transfer(vault, PRIV, maxWithdraw) |
933 | |
withdraw_private_to_public_exact (carl submits) |
Vault | Transfer(PRIV, 0x0, 10) |
943 |
| Asset | Transfer(vault, bob, 15) |
946 |
Coverage Summary
| Category | Flows Covered | Event Assertions |
|---|---|---|
| Token (mint, public transfer, commitment, public-to-private, private-to-private) | 7 transactions | 7 assertions (incl. 1 empty) |
| Vault — No Authwits (5 asset/share combos x deposit+issue+withdraw+redeem) | ~40 transactions | ~40 assertions |
| Vault — With Authwits (5 asset/share combos x deposit+issue+withdraw+redeem) | ~40 transactions | ~40 assertions |
| Total | ~87 transactions | ~87 event assertions |
Event Patterns Verified
- Mint to public:
Transfer(0x0, recipient, amount) - Mint to private:
Transfer(0x0, PRIV, amount) - Public-to-public transfer:
Transfer(from, to, amount) - Public-to-private transfer:
Transfer(from, PRIV, amount) - Private-to-public transfer:
Transfer(PRIV, to, amount) - Private-to-private transfer: (no public events)
- Burn from public:
Transfer(from, 0x0, amount) - Burn from private:
Transfer(PRIV, 0x0, amount) - Vault deposit (dual-contract): Asset
Transfer(from, vault, assets)+ VaultTransfer(0x0, to, shares) - Vault withdraw (dual-contract): Vault
Transfer(from, 0x0, shares)+ AssetTransfer(vault, to, assets) - Vault issue (dual-contract): Asset
Transfer(from, vault, max_assets)+ VaultTransfer(0x0, to, shares) - Vault redeem (dual-contract): Vault
Transfer(from, 0x0, shares)+ AssetTransfer(vault, to, assets)
Private vs Public Event TestingPrivate Events
Public Events
This asymmetry means that public event assertions must be done in TypeScript integration tests, not in Noir. Public Log Field LayoutWhen a public event is emitted and retrieved via
The
Sentinel AddressesThe contract uses two sentinel addresses in Transfer events to represent non-standard balance sources/destinations:
Why
|
| // Sentinel address used in Transfer events to represent the private side of a balance change. | ||
| // sha224sum 'PRIVATE_ADDRESS' | ||
| global PRIVATE_ADDRESS_MAGIC_VALUE: AztecAddress = | ||
| AztecAddress::from_field(0x1ea7e01501975545617c2e694d931cb576b691a4a867fed81ebd3264); |
There was a problem hiding this comment.
nit: We should be able compute these in comptime
There was a problem hiding this comment.
i looked at packages on how they declare *_MAGIC_VALUES and they just comment it on top and declare the hex or number, are we ok with letting it this way?
Benchmark Comparison
Contract: token
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Benchmark Comparison
Contract: token
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# 🤖 Linear Closes AZT-XXX ## Description
# 🤖 Linear Closes AZT-XXX ## Description still WIP --------- Co-authored-by: Weißer Hase <84595958+wei3erHase@users.noreply.github.com>
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughAdds Transfer event logging to token contract for indexer support. Introduces PRIVATE_ADDRESS_MAGIC_VALUE sentinel constant to represent private balance operations, emits Transfer events at mint, burn, and transfer points, and extends test suite with event assertion utilities to verify transfers across public/private boundaries. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Benchmark Comparison
Contract: escrow
Contract: logic
Contract: nft
Contract: token
Contract: tokenized_vault
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Benchmark Comparison
Contract: escrow
Contract: logic
Contract: nft
Contract: token
Contract: tokenized_vault
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
zkfrov
left a comment
There was a problem hiding this comment.
Niceee, lgtm! I would add some reference of how events are implemented in the docs (specially considering the magic value), update the forum post and/or update natspec of functions that emit events.
🤖 Linear
Closes AZT-224
Description
Add Transfer events to the Token contract
Introduces a
Transfer { from, to, amount }event emitted on every balance-changing operation in the Token (and Tokenized Vault), including mints, burns, public transfers, and cross-domain (private <-> public) moves.A sentinel
PRIVATE_ADDRESS_MAGIC_VALUEis used as thefromortofield whenever the counterpart of a balance change is a private note (since the actual address cannot be revealed).address(0)is used for mints (from = 0) and burns (to = 0), following the ERC-20 convention.Invariant: for every
Transferevent, the sum of all amounts wherefrom == address(0)minus the sum of all amounts whereto == address(0)must equal the currenttotal_supply. This ensures full accountability of supply changes through public event data, even when individual balances are shielded.Summary by CodeRabbit
Release Notes
New Features
Tests