From e76dd9a535cddec630d85e4a5ae4d34783661e26 Mon Sep 17 00:00:00 2001 From: benesjan Date: Mon, 17 Mar 2025 22:50:52 +0000 Subject: [PATCH 1/5] refactor: nuking TxHash from NoteFilter --- docs/docs/migration_notes.md | 4 ++ yarn-project/cli/src/utils/inspect.ts | 20 +++------ yarn-project/constants/src/constants.gen.ts | 17 +++++--- .../minting.test.ts | 9 +--- .../src/e2e_crowdfunding_and_claim.test.ts | 38 +++++----------- .../e2e_pending_note_hashes_contract.test.ts | 6 +-- .../pxe_oracle_interface.ts | 3 +- .../pxe/src/pxe_service/pxe_service.ts | 2 +- .../storage/note_data_provider/note_dao.ts | 9 ---- .../note_data_provider.test.ts | 4 -- .../note_data_provider/note_data_provider.ts | 22 ---------- yarn-project/stdlib/src/note/extended_note.ts | 43 +++++-------------- yarn-project/stdlib/src/note/notes_filter.ts | 4 -- yarn-project/stdlib/src/tests/mocks.ts | 4 -- 14 files changed, 45 insertions(+), 140 deletions(-) diff --git a/docs/docs/migration_notes.md b/docs/docs/migration_notes.md index 665a741c42ef..5622bc2c65eb 100644 --- a/docs/docs/migration_notes.md +++ b/docs/docs/migration_notes.md @@ -8,6 +8,10 @@ Aztec is in full-speed development. Literally every version breaks compatibility ## TBD +### [aztec.js] Dropping note filtration by `TxHash` +It's no longer possible to filter notes by `TxHash`. +The utility of this feature has been low and it made the code less efficient. + ### [PXE] Concurrent contract function simulation disabled PXE is no longer be able to execute contract functions concurrently (e.g. by collecting calls to `simulateTx` and then using `await Promise.all`). They will instead be put in a job queue and executed sequentially in order of arrival. diff --git a/yarn-project/cli/src/utils/inspect.ts b/yarn-project/cli/src/utils/inspect.ts index d3646de9dc53..ac3454ef8f94 100644 --- a/yarn-project/cli/src/utils/inspect.ts +++ b/yarn-project/cli/src/utils/inspect.ts @@ -3,7 +3,7 @@ import type { LogFn } from '@aztec/foundation/log'; import { ProtocolContractAddress } from '@aztec/protocol-contracts'; import { siloNullifier } from '@aztec/stdlib/hash'; import type { PXE } from '@aztec/stdlib/interfaces/client'; -import { type ExtendedNote, NoteStatus } from '@aztec/stdlib/note'; +import type { ExtendedNote } from '@aztec/stdlib/note'; import type { TxHash } from '@aztec/stdlib/tx'; export async function inspectBlock(pxe: PXE, blockNumber: number, log: LogFn, opts: { showTxs?: boolean } = {}) { @@ -40,11 +40,7 @@ export async function inspectTx( log: LogFn, opts: { includeBlockInfo?: boolean; artifactMap?: ArtifactMap } = {}, ) { - const [receipt, effectsInBlock, getNotes] = await Promise.all([ - pxe.getTxReceipt(txHash), - pxe.getTxEffect(txHash), - pxe.getNotes({ txHash, status: NoteStatus.ACTIVE_OR_NULLIFIED }), - ]); + const [receipt, effectsInBlock] = await Promise.all([pxe.getTxReceipt(txHash), pxe.getTxEffect(txHash)]); // Base tx data log(`Tx ${txHash.toString()}`); log(` Status: ${receipt.status} ${effectsInBlock ? `(${effectsInBlock.data.revertCode.getDescription()})` : ''}`); @@ -85,16 +81,10 @@ export async function inspectTx( } // Created notes - const notes = effects.noteHashes; - if (notes.length > 0) { + const noteHashes = effects.noteHashes; + if (noteHashes.length > 0) { log(' Created notes:'); - log(` Total: ${notes.length}. Found: ${getNotes.length}.`); - if (getNotes.length) { - log(' Found notes:'); - for (const note of getNotes) { - inspectNote(note, artifactMap, log); - } - } + log(` Total: ${noteHashes.length}.`); } // Nullifiers diff --git a/yarn-project/constants/src/constants.gen.ts b/yarn-project/constants/src/constants.gen.ts index 037a0aa4e2cd..95be108b37d3 100644 --- a/yarn-project/constants/src/constants.gen.ts +++ b/yarn-project/constants/src/constants.gen.ts @@ -92,11 +92,16 @@ export const MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS = 3000; export const MAX_PACKED_BYTECODE_SIZE_PER_UNCONSTRAINED_FUNCTION_IN_FIELDS = 3000; export const REGISTERER_PRIVATE_FUNCTION_BROADCASTED_ADDITIONAL_FIELDS = 19; export const REGISTERER_UNCONSTRAINED_FUNCTION_BROADCASTED_ADDITIONAL_FIELDS = 12; -export const REGISTERER_CONTRACT_CLASS_REGISTERED_MAGIC_VALUE = 11121068431693264234253912047066709627593769337094408533543930778360n; -export const REGISTERER_PRIVATE_FUNCTION_BROADCASTED_MAGIC_VALUE = 2889881020989534926461066592611988634597302675057895885580456197069n; -export const REGISTERER_UNCONSTRAINED_FUNCTION_BROADCASTED_MAGIC_VALUE = 24399338136397901754495080759185489776044879232766421623673792970137n; -export const DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_MAGIC_VALUE = 14061769416655647708490531650437236735160113654556896985372298487345n; -export const DEPLOYER_CONTRACT_INSTANCE_UPDATED_MAGIC_VALUE = 1534834688047131268740281708431107902615560100979874281215533519862n; +export const REGISTERER_CONTRACT_CLASS_REGISTERED_MAGIC_VALUE = + 11121068431693264234253912047066709627593769337094408533543930778360n; +export const REGISTERER_PRIVATE_FUNCTION_BROADCASTED_MAGIC_VALUE = + 2889881020989534926461066592611988634597302675057895885580456197069n; +export const REGISTERER_UNCONSTRAINED_FUNCTION_BROADCASTED_MAGIC_VALUE = + 24399338136397901754495080759185489776044879232766421623673792970137n; +export const DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_MAGIC_VALUE = + 14061769416655647708490531650437236735160113654556896985372298487345n; +export const DEPLOYER_CONTRACT_INSTANCE_UPDATED_MAGIC_VALUE = + 1534834688047131268740281708431107902615560100979874281215533519862n; export const MAX_PROTOCOL_CONTRACTS = 7; export const CANONICAL_AUTH_REGISTRY_ADDRESS = 1; export const DEPLOYER_CONTRACT_ADDRESS = 2; @@ -411,4 +416,4 @@ export enum GeneratorIndex { SYMMETRIC_KEY_2 = 55, PUBLIC_TX_HASH = 56, PRIVATE_TX_HASH = 57, -} \ No newline at end of file +} diff --git a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/minting.test.ts b/yarn-project/end-to-end/src/e2e_blacklist_token_contract/minting.test.ts index af941a30432a..c2a07bcdc267 100644 --- a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/minting.test.ts +++ b/yarn-project/end-to-end/src/e2e_blacklist_token_contract/minting.test.ts @@ -90,18 +90,11 @@ describe('e2e_blacklist_token_contract mint', () => { await t.addPendingShieldNoteToPXE(asset, wallets[0], amount, secretHash, txHash); - const receiptClaim = await asset.methods - .redeem_shield(wallets[0].getAddress(), amount, secret) - .send() - .wait({ debug: true }); + await asset.methods.redeem_shield(wallets[0].getAddress(), amount, secret).send().wait(); tokenSim.mintPrivate(wallets[0].getAddress(), amount); // Trigger a note sync await asset.methods.sync_notes().simulate(); - // 1 note should have been created containing `amount` of tokens - const visibleNotes = await wallets[0].getNotes({ txHash: receiptClaim.txHash }); - expect(visibleNotes.length).toBe(1); - expect(visibleNotes[0].note.items[0].toBigInt()).toBe(amount); }); }); diff --git a/yarn-project/end-to-end/src/e2e_crowdfunding_and_claim.test.ts b/yarn-project/end-to-end/src/e2e_crowdfunding_and_claim.test.ts index 2b91bf94cc1e..05d8f9435299 100644 --- a/yarn-project/end-to-end/src/e2e_crowdfunding_and_claim.test.ts +++ b/yarn-project/end-to-end/src/e2e_crowdfunding_and_claim.test.ts @@ -159,22 +159,15 @@ describe('e2e_crowdfunding_and_claim', () => { // 2) We donate to the crowdfunding contract { - const donateTxReceipt = await crowdfundingContract - .withWallet(donorWallets[0]) - .methods.donate(donationAmount) - .send() - .wait({ - debug: true, - }); + await crowdfundingContract.withWallet(donorWallets[0]).methods.donate(donationAmount).send().wait(); // Get the notes emitted by the Crowdfunding contract and check that only 1 was emitted (the UintNote) await crowdfundingContract.withWallet(donorWallets[0]).methods.sync_notes().simulate(); - const notes = await donorWallets[0].getNotes({ txHash: donateTxReceipt.txHash }); - const filteredNotes = notes.filter(x => x.contractAddress.equals(crowdfundingContract.address)); - expect(filteredNotes!.length).toEqual(1); + const notes = await donorWallets[0].getNotes({ contractAddress: crowdfundingContract.address }); + expect(notes.length).toEqual(1); // Set the UintNote in a format which can be passed to claim function - uintNote = processUniqueNote(filteredNotes![0]); + uintNote = processUniqueNote(notes[0]); } // 3) We claim the reward token via the Claim contract @@ -234,22 +227,14 @@ describe('e2e_crowdfunding_and_claim', () => { } // 2) We donate to the crowdfunding contract - const donateTxReceipt = await crowdfundingContract - .withWallet(donorWallet) - .methods.donate(donationAmount) - .send() - .wait({ - debug: true, - }); + await crowdfundingContract.withWallet(donorWallet).methods.donate(donationAmount).send().wait(); - // Get the notes emitted by the Crowdfunding contract and check that only 1 was emitted (the UintNote) + // Get the latest note emitted by the Crowdfunding contract await crowdfundingContract.withWallet(unrelatedWallet).methods.sync_notes().simulate(); - const notes = await unrelatedWallet.getNotes({ txHash: donateTxReceipt.txHash }); - const filtered = notes.filter(x => x.contractAddress.equals(crowdfundingContract.address)); - expect(filtered!.length).toEqual(1); + const notes = await unrelatedWallet.getNotes({ contractAddress: crowdfundingContract.address }); // Set the UintNote in a format which can be passed to claim function - const anotherDonationNote = processUniqueNote(filtered![0]); + const anotherDonationNote = processUniqueNote(notes[notes.length - 1]); // 3) We try to claim the reward token via the Claim contract with the unrelated wallet { @@ -288,12 +273,9 @@ describe('e2e_crowdfunding_and_claim', () => { const arbitraryStorageSlot = 69; { const [arbitraryValue, sender] = [5n, owner]; - const receipt = await testContract.methods - .call_create_note(arbitraryValue, owner, sender, arbitraryStorageSlot) - .send() - .wait({ debug: true }); + await testContract.methods.call_create_note(arbitraryValue, owner, sender, arbitraryStorageSlot).send().wait(); await testContract.methods.sync_notes().simulate(); - const notes = await wallets[0].getNotes({ txHash: receipt.txHash }); + const notes = await wallets[0].getNotes({ contractAddress: testContract.address }); expect(notes.length).toEqual(1); note = processUniqueNote(notes[0]); } diff --git a/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts b/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts index ff202bf2477e..3498dc5c9c6c 100644 --- a/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts @@ -290,12 +290,10 @@ describe('e2e_pending_note_hashes_contract', () => { const sender = owner; // Add a note of value 10, with a note log // Then emit another note log with the same counter as the one above, but with value 5 - const txReceipt = await deployedContract.methods.test_emit_bad_note_log(owner, sender).send().wait(); + const txReceipt = await deployedContract.methods.test_emit_bad_note_log(owner, sender).send().wait({ debug: true }); await deployedContract.methods.sync_notes().simulate(); - const notes = await wallet.getNotes({ txHash: txReceipt.txHash }); - - expect(notes.length).toBe(1); + expect(txReceipt.debugInfo?.noteHashes.length).toBe(1); }); }); diff --git a/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.ts b/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.ts index f2b8591899ae..1ea5b1c3c01d 100644 --- a/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.ts +++ b/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.ts @@ -626,7 +626,7 @@ export class PXEOracleInterface implements ExecutionDataProvider { content: Fr[], noteHash: Fr, nullifier: Fr, - txHash: Fr, + txHash: Fr, // TODO (#12550): remove this parameter recipient: AztecAddress, ): Promise { // We are going to store the new note in the NoteDataProvider, which will let us later return it via `getNotes`. @@ -685,7 +685,6 @@ export class PXEOracleInterface implements ExecutionDataProvider { nonce, noteHash, siloedNullifier, - new TxHash(txHash), txReceipt.blockNumber!, txReceipt.blockHash!.toString(), uniqueNoteHashTreeIndex, diff --git a/yarn-project/pxe/src/pxe_service/pxe_service.ts b/yarn-project/pxe/src/pxe_service/pxe_service.ts index a2ba436e4ee2..b386b9580d3c 100644 --- a/yarn-project/pxe/src/pxe_service/pxe_service.ts +++ b/yarn-project/pxe/src/pxe_service/pxe_service.ts @@ -453,7 +453,7 @@ export class PXEService implements PXE { } recipient = completeAddress.address; } - return new UniqueNote(dao.note, recipient, dao.contractAddress, dao.storageSlot, dao.txHash, dao.nonce); + return new UniqueNote(dao.note, recipient, dao.contractAddress, dao.storageSlot, dao.nonce); }); return Promise.all(extendedNotes); } diff --git a/yarn-project/pxe/src/storage/note_data_provider/note_dao.ts b/yarn-project/pxe/src/storage/note_data_provider/note_dao.ts index 3784dea73ec6..398f4cf29f4b 100644 --- a/yarn-project/pxe/src/storage/note_data_provider/note_dao.ts +++ b/yarn-project/pxe/src/storage/note_data_provider/note_dao.ts @@ -39,10 +39,6 @@ export class NoteDao implements NoteData { public siloedNullifier: Fr, // Metadata - /** The hash of the tx in which this note was created. Knowing the tx hash allows for efficient node queries e.g. - * when searching for txEffects. - */ - public txHash: TxHash, /** The L2 block number in which the tx with this note was included. Used for note management while processing * reorgs.*/ public l2BlockNumber: number, @@ -66,7 +62,6 @@ export class NoteDao implements NoteData { this.nonce, this.noteHash, this.siloedNullifier, - this.txHash, this.l2BlockNumber, Fr.fromHexString(this.l2BlockHash), this.index, @@ -83,7 +78,6 @@ export class NoteDao implements NoteData { const nonce = Fr.fromBuffer(reader); const noteHash = Fr.fromBuffer(reader); const siloedNullifier = Fr.fromBuffer(reader); - const txHash = reader.readObject(TxHash); const l2BlockNumber = reader.readNumber(); const l2BlockHash = Fr.fromBuffer(reader).toString(); const index = toBigIntBE(reader.readBytes(32)); @@ -96,7 +90,6 @@ export class NoteDao implements NoteData { nonce, noteHash, siloedNullifier, - txHash, l2BlockNumber, l2BlockHash, index, @@ -130,7 +123,6 @@ export class NoteDao implements NoteData { nonce = Fr.random(), noteHash = Fr.random(), siloedNullifier = Fr.random(), - txHash = TxHash.random(), l2BlockNumber = Math.floor(Math.random() * 1000), l2BlockHash = Fr.random().toString(), index = Fr.random().toBigInt(), @@ -143,7 +135,6 @@ export class NoteDao implements NoteData { nonce, noteHash, siloedNullifier, - txHash, l2BlockNumber, l2BlockHash, index, diff --git a/yarn-project/pxe/src/storage/note_data_provider/note_data_provider.test.ts b/yarn-project/pxe/src/storage/note_data_provider/note_data_provider.test.ts index 3877b5192370..829b0664e5fa 100644 --- a/yarn-project/pxe/src/storage/note_data_provider/note_data_provider.test.ts +++ b/yarn-project/pxe/src/storage/note_data_provider/note_data_provider.test.ts @@ -3,7 +3,6 @@ import { Fr } from '@aztec/foundation/fields'; import { openTmpStore } from '@aztec/kv-store/lmdb-v2'; import { AztecAddress } from '@aztec/stdlib/aztec-address'; import { NoteStatus, type NotesFilter } from '@aztec/stdlib/note'; -import { randomTxHash } from '@aztec/stdlib/testing'; import times from 'lodash.times'; @@ -37,9 +36,6 @@ describe('NoteDataProvider', () => { ], [() => Promise.resolve({ storageSlot: Fr.random() }), () => Promise.resolve([])], - [() => Promise.resolve({ txHash: notes[0].txHash }), () => Promise.resolve([notes[0]])], - [() => Promise.resolve({ txHash: randomTxHash() }), () => Promise.resolve([])], - [ () => Promise.resolve({ recipient: recipients[0] }), () => Promise.resolve(notes.filter(note => note.recipient.equals(recipients[0]))), diff --git a/yarn-project/pxe/src/storage/note_data_provider/note_data_provider.ts b/yarn-project/pxe/src/storage/note_data_provider/note_data_provider.ts index 8368a612ebb3..bc939c437add 100644 --- a/yarn-project/pxe/src/storage/note_data_provider/note_data_provider.ts +++ b/yarn-project/pxe/src/storage/note_data_provider/note_data_provider.ts @@ -20,7 +20,6 @@ export class NoteDataProvider implements DataProvider { #nullifiedNotesToScope: AztecAsyncMultiMap; #nullifiedNotesByContract: AztecAsyncMultiMap; #nullifiedNotesByStorageSlot: AztecAsyncMultiMap; - #nullifiedNotesByTxHash: AztecAsyncMultiMap; #nullifiedNotesByRecipient: AztecAsyncMultiMap; #nullifiedNotesByNullifier: AztecAsyncMap; @@ -28,7 +27,6 @@ export class NoteDataProvider implements DataProvider { #notesToScope: AztecAsyncMultiMap; #notesByContractAndScope: Map>; #notesByStorageSlotAndScope: Map>; - #notesByTxHashAndScope: Map>; #notesByRecipientAndScope: Map>; private constructor(store: AztecAsyncKVStore) { @@ -41,7 +39,6 @@ export class NoteDataProvider implements DataProvider { this.#nullifiedNotesToScope = store.openMultiMap('nullified_notes_to_scope'); this.#nullifiedNotesByContract = store.openMultiMap('nullified_notes_by_contract'); this.#nullifiedNotesByStorageSlot = store.openMultiMap('nullified_notes_by_storage_slot'); - this.#nullifiedNotesByTxHash = store.openMultiMap('nullified_notes_by_tx_hash'); this.#nullifiedNotesByRecipient = store.openMultiMap('nullified_notes_by_recipient'); this.#nullifiedNotesByNullifier = store.openMap('nullified_notes_by_nullifier'); @@ -49,7 +46,6 @@ export class NoteDataProvider implements DataProvider { this.#notesToScope = store.openMultiMap('notes_to_scope'); this.#notesByContractAndScope = new Map>(); this.#notesByStorageSlotAndScope = new Map>(); - this.#notesByTxHashAndScope = new Map>(); this.#notesByRecipientAndScope = new Map>(); } @@ -58,7 +54,6 @@ export class NoteDataProvider implements DataProvider { for await (const scope of pxeDB.#scopes.keysAsync()) { pxeDB.#notesByContractAndScope.set(scope, store.openMultiMap(`${scope}:notes_by_contract`)); pxeDB.#notesByStorageSlotAndScope.set(scope, store.openMultiMap(`${scope}:notes_by_storage_slot`)); - pxeDB.#notesByTxHashAndScope.set(scope, store.openMultiMap(`${scope}:notes_by_tx_hash`)); pxeDB.#notesByRecipientAndScope.set(scope, store.openMultiMap(`${scope}:notes_by_recipient`)); } return pxeDB; @@ -74,7 +69,6 @@ export class NoteDataProvider implements DataProvider { await this.#scopes.set(scopeString, true); this.#notesByContractAndScope.set(scopeString, this.#store.openMultiMap(`${scopeString}:notes_by_contract`)); this.#notesByStorageSlotAndScope.set(scopeString, this.#store.openMultiMap(`${scopeString}:notes_by_storage_slot`)); - this.#notesByTxHashAndScope.set(scopeString, this.#store.openMultiMap(`${scopeString}:notes_by_tx_hash`)); this.#notesByRecipientAndScope.set(scopeString, this.#store.openMultiMap(`${scopeString}:notes_by_recipient`)); return true; @@ -98,7 +92,6 @@ export class NoteDataProvider implements DataProvider { await this.#notesByContractAndScope.get(scope.toString())!.set(dao.contractAddress.toString(), noteIndex); await this.#notesByStorageSlotAndScope.get(scope.toString())!.set(dao.storageSlot.toString(), noteIndex); - await this.#notesByTxHashAndScope.get(scope.toString())!.set(dao.txHash.toString(), noteIndex); await this.#notesByRecipientAndScope.get(scope.toString())!.set(dao.recipient.toString(), noteIndex); } }); @@ -117,7 +110,6 @@ export class NoteDataProvider implements DataProvider { const scopes = await toArray(this.#scopes.keysAsync()); for (const scope of scopes) { await this.#notesByRecipientAndScope.get(scope)!.deleteValue(noteDao.recipient.toString(), noteIndex); - await this.#notesByTxHashAndScope.get(scope)!.deleteValue(noteDao.txHash.toString(), noteIndex); await this.#notesByContractAndScope.get(scope)!.deleteValue(noteDao.contractAddress.toString(), noteIndex); await this.#notesByStorageSlotAndScope.get(scope)!.deleteValue(noteDao.storageSlot.toString(), noteIndex); } @@ -159,7 +151,6 @@ export class NoteDataProvider implements DataProvider { for (const scope of scopes) { await this.#notesByContractAndScope.get(scope.toString())!.set(dao.contractAddress.toString(), noteIndex); await this.#notesByStorageSlotAndScope.get(scope.toString())!.set(dao.storageSlot.toString(), noteIndex); - await this.#notesByTxHashAndScope.get(scope.toString())!.set(dao.txHash.toString(), noteIndex); await this.#notesByRecipientAndScope.get(scope.toString())!.set(dao.recipient.toString(), noteIndex); await this.#notesToScope.set(noteIndex, scope); } @@ -169,7 +160,6 @@ export class NoteDataProvider implements DataProvider { await this.#nullifiersByBlockNumber.deleteValue(dao.l2BlockNumber, dao.siloedNullifier.toString()); await this.#nullifiedNotesByContract.deleteValue(dao.contractAddress.toString(), noteIndex); await this.#nullifiedNotesByStorageSlot.deleteValue(dao.storageSlot.toString(), noteIndex); - await this.#nullifiedNotesByTxHash.deleteValue(dao.txHash.toString(), noteIndex); await this.#nullifiedNotesByRecipient.deleteValue(dao.recipient.toString(), noteIndex); await this.#nullifiedNotesByNullifier.delete(dao.siloedNullifier.toString()); } @@ -198,10 +188,6 @@ export class NoteDataProvider implements DataProvider { ? await toArray( this.#notesByRecipientAndScope.get(formattedScopeString)!.getValuesAsync(filter.recipient.toString()), ) - : filter.txHash - ? await toArray( - this.#notesByTxHashAndScope.get(formattedScopeString)!.getValuesAsync(filter.txHash.toString()), - ) : filter.contractAddress ? await toArray( this.#notesByContractAndScope @@ -225,8 +211,6 @@ export class NoteDataProvider implements DataProvider { candidateNoteSources.push({ ids: filter.recipient ? await toArray(this.#nullifiedNotesByRecipient.getValuesAsync(filter.recipient.toString())) - : filter.txHash - ? await toArray(this.#nullifiedNotesByTxHash.getValuesAsync(filter.txHash.toString())) : filter.contractAddress ? await toArray(this.#nullifiedNotesByContract.getValuesAsync(filter.contractAddress.toString())) : filter.storageSlot @@ -249,10 +233,6 @@ export class NoteDataProvider implements DataProvider { continue; } - if (filter.txHash && !note.txHash.equals(filter.txHash)) { - continue; - } - if (filter.storageSlot && !note.storageSlot.equals(filter.storageSlot!)) { continue; } @@ -309,7 +289,6 @@ export class NoteDataProvider implements DataProvider { for (const scope of scopes) { await this.#notesByRecipientAndScope.get(scope)!.deleteValue(note.recipient.toString(), noteIndex); - await this.#notesByTxHashAndScope.get(scope)!.deleteValue(note.txHash.toString(), noteIndex); await this.#notesByContractAndScope.get(scope)!.deleteValue(note.contractAddress.toString(), noteIndex); await this.#notesByStorageSlotAndScope.get(scope)!.deleteValue(note.storageSlot.toString(), noteIndex); } @@ -323,7 +302,6 @@ export class NoteDataProvider implements DataProvider { await this.#nullifiersByBlockNumber.set(blockNumber, nullifier.toString()); await this.#nullifiedNotesByContract.set(note.contractAddress.toString(), noteIndex); await this.#nullifiedNotesByStorageSlot.set(note.storageSlot.toString(), noteIndex); - await this.#nullifiedNotesByTxHash.set(note.txHash.toString(), noteIndex); await this.#nullifiedNotesByRecipient.set(note.recipient.toString(), noteIndex); await this.#nullifiedNotesByNullifier.set(nullifier.toString(), noteIndex); diff --git a/yarn-project/stdlib/src/note/extended_note.ts b/yarn-project/stdlib/src/note/extended_note.ts index 37617523da2f..f7236f9cedb9 100644 --- a/yarn-project/stdlib/src/note/extended_note.ts +++ b/yarn-project/stdlib/src/note/extended_note.ts @@ -6,7 +6,6 @@ import { z } from 'zod'; import { AztecAddress } from '../aztec-address/index.js'; import { type ZodFor, schemas } from '../schemas/index.js'; -import { TxHash } from '../tx/tx_hash.js'; import { Note } from './note.js'; /** @@ -22,12 +21,10 @@ export class ExtendedNote { public contractAddress: AztecAddress, /** The specific storage location of the note on the contract. */ public storageSlot: Fr, - /** The hash of the tx the note was created in. */ - public txHash: TxHash, ) {} toBuffer(): Buffer { - return serializeToBuffer([this.note, this.recipient, this.contractAddress, this.storageSlot, this.txHash]); + return serializeToBuffer([this.note, this.recipient, this.contractAddress, this.storageSlot]); } static fromBuffer(buffer: Buffer | BufferReader) { @@ -37,9 +34,8 @@ export class ExtendedNote { const recipient = reader.readObject(AztecAddress); const contractAddress = reader.readObject(AztecAddress); const storageSlot = reader.readObject(Fr); - const txHash = reader.readObject(TxHash); - return new this(note, recipient, contractAddress, storageSlot, txHash); + return new this(note, recipient, contractAddress, storageSlot); } static get schema(): ZodFor { @@ -49,10 +45,9 @@ export class ExtendedNote { recipient: schemas.AztecAddress, contractAddress: schemas.AztecAddress, storageSlot: schemas.Fr, - txHash: TxHash.schema, }) - .transform(({ note, recipient, contractAddress, storageSlot, txHash }) => { - return new ExtendedNote(note, recipient, contractAddress, storageSlot, txHash); + .transform(({ note, recipient, contractAddress, storageSlot }) => { + return new ExtendedNote(note, recipient, contractAddress, storageSlot); }); } @@ -65,13 +60,7 @@ export class ExtendedNote { } static async random() { - return new ExtendedNote( - Note.random(), - await AztecAddress.random(), - await AztecAddress.random(), - Fr.random(), - TxHash.random(), - ); + return new ExtendedNote(Note.random(), await AztecAddress.random(), await AztecAddress.random(), Fr.random()); } } @@ -85,12 +74,10 @@ export class UniqueNote extends ExtendedNote { contractAddress: AztecAddress, /** The specific storage location of the note on the contract. */ storageSlot: Fr, - /** The hash of the tx the note was created in. */ - txHash: TxHash, /** The nonce of the note. */ public nonce: Fr, ) { - super(note, recipient, contractAddress, storageSlot, txHash); + super(note, recipient, contractAddress, storageSlot); } static override get schema() { @@ -100,23 +87,15 @@ export class UniqueNote extends ExtendedNote { recipient: schemas.AztecAddress, contractAddress: schemas.AztecAddress, storageSlot: schemas.Fr, - txHash: TxHash.schema, nonce: schemas.Fr, }) - .transform(({ note, recipient, contractAddress, storageSlot, txHash, nonce }) => { - return new UniqueNote(note, recipient, contractAddress, storageSlot, txHash, nonce); + .transform(({ note, recipient, contractAddress, storageSlot, nonce }) => { + return new UniqueNote(note, recipient, contractAddress, storageSlot, nonce); }); } override toBuffer(): Buffer { - return serializeToBuffer([ - this.note, - this.recipient, - this.contractAddress, - this.storageSlot, - this.txHash, - this.nonce, - ]); + return serializeToBuffer([this.note, this.recipient, this.contractAddress, this.storageSlot, this.nonce]); } static override async random() { @@ -125,7 +104,6 @@ export class UniqueNote extends ExtendedNote { await AztecAddress.random(), await AztecAddress.random(), Fr.random(), - TxHash.random(), Fr.random(), ); } @@ -137,10 +115,9 @@ export class UniqueNote extends ExtendedNote { const recipient = reader.readObject(AztecAddress); const contractAddress = reader.readObject(AztecAddress); const storageSlot = reader.readObject(Fr); - const txHash = reader.readObject(TxHash); const nonce = reader.readObject(Fr); - return new this(note, recipient, contractAddress, storageSlot, txHash, nonce); + return new this(note, recipient, contractAddress, storageSlot, nonce); } static override fromString(str: string) { diff --git a/yarn-project/stdlib/src/note/notes_filter.ts b/yarn-project/stdlib/src/note/notes_filter.ts index d354bc81f846..29cc790f65cc 100644 --- a/yarn-project/stdlib/src/note/notes_filter.ts +++ b/yarn-project/stdlib/src/note/notes_filter.ts @@ -4,7 +4,6 @@ import { z } from 'zod'; import type { AztecAddress } from '../aztec-address/index.js'; import { type ZodFor, schemas } from '../schemas/index.js'; -import { TxHash } from '../tx/tx_hash.js'; import { NoteStatus } from './note_status.js'; /** @@ -12,8 +11,6 @@ import { NoteStatus } from './note_status.js'; * @remarks This filter is applied as an intersection of all its params. */ export type NotesFilter = { - /** Hash of a transaction from which to fetch the notes. */ - txHash?: TxHash; /** The contract address the note belongs to. */ contractAddress?: AztecAddress; /** The specific storage location of the note on the contract. */ @@ -29,7 +26,6 @@ export type NotesFilter = { }; export const NotesFilterSchema: ZodFor = z.object({ - txHash: TxHash.schema.optional(), contractAddress: schemas.AztecAddress.optional(), storageSlot: schemas.Fr.optional(), recipient: schemas.AztecAddress.optional(), diff --git a/yarn-project/stdlib/src/tests/mocks.ts b/yarn-project/stdlib/src/tests/mocks.ts index b38d53df3a49..a2ed910b193d 100644 --- a/yarn-project/stdlib/src/tests/mocks.ts +++ b/yarn-project/stdlib/src/tests/mocks.ts @@ -47,7 +47,6 @@ export const randomExtendedNote = async ({ note = Note.random(), recipient = undefined, contractAddress = undefined, - txHash = randomTxHash(), storageSlot = Fr.random(), }: Partial = {}) => { return new ExtendedNote( @@ -55,7 +54,6 @@ export const randomExtendedNote = async ({ recipient ?? (await AztecAddress.random()), contractAddress ?? (await AztecAddress.random()), storageSlot, - txHash, ); }; @@ -63,7 +61,6 @@ export const randomUniqueNote = async ({ note = Note.random(), recipient = undefined, contractAddress = undefined, - txHash = randomTxHash(), storageSlot = Fr.random(), nonce = Fr.random(), }: Partial = {}) => { @@ -72,7 +69,6 @@ export const randomUniqueNote = async ({ recipient ?? (await AztecAddress.random()), contractAddress ?? (await AztecAddress.random()), storageSlot, - txHash, nonce, ); }; From 8310883f7a9e902f073b1e38566175b0b7496eb9 Mon Sep 17 00:00:00 2001 From: benesjan Date: Tue, 18 Mar 2025 00:31:24 +0000 Subject: [PATCH 2/5] fix --- .../src/e2e_crowdfunding_and_claim.test.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/yarn-project/end-to-end/src/e2e_crowdfunding_and_claim.test.ts b/yarn-project/end-to-end/src/e2e_crowdfunding_and_claim.test.ts index 05d8f9435299..72bb4394d44c 100644 --- a/yarn-project/end-to-end/src/e2e_crowdfunding_and_claim.test.ts +++ b/yarn-project/end-to-end/src/e2e_crowdfunding_and_claim.test.ts @@ -163,7 +163,10 @@ describe('e2e_crowdfunding_and_claim', () => { // Get the notes emitted by the Crowdfunding contract and check that only 1 was emitted (the UintNote) await crowdfundingContract.withWallet(donorWallets[0]).methods.sync_notes().simulate(); - const notes = await donorWallets[0].getNotes({ contractAddress: crowdfundingContract.address }); + const notes = await donorWallets[0].getNotes({ + contractAddress: crowdfundingContract.address, + recipient: donorWallets[0].getAddress(), + }); expect(notes.length).toEqual(1); // Set the UintNote in a format which can be passed to claim function @@ -231,10 +234,14 @@ describe('e2e_crowdfunding_and_claim', () => { // Get the latest note emitted by the Crowdfunding contract await crowdfundingContract.withWallet(unrelatedWallet).methods.sync_notes().simulate(); - const notes = await unrelatedWallet.getNotes({ contractAddress: crowdfundingContract.address }); + const notes = await unrelatedWallet.getNotes({ + contractAddress: crowdfundingContract.address, + recipient: donorWallet.getAddress(), + }); + expect(notes.length).toEqual(1); // Set the UintNote in a format which can be passed to claim function - const anotherDonationNote = processUniqueNote(notes[notes.length - 1]); + const anotherDonationNote = processUniqueNote(notes[0]); // 3) We try to claim the reward token via the Claim contract with the unrelated wallet { From 2262cc712efcf72c1fe3c345fafc092a037fa746 Mon Sep 17 00:00:00 2001 From: benesjan Date: Tue, 18 Mar 2025 03:48:11 +0000 Subject: [PATCH 3/5] diff cleanup --- yarn-project/constants/src/constants.gen.ts | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/yarn-project/constants/src/constants.gen.ts b/yarn-project/constants/src/constants.gen.ts index 95be108b37d3..78bc3259ceda 100644 --- a/yarn-project/constants/src/constants.gen.ts +++ b/yarn-project/constants/src/constants.gen.ts @@ -92,16 +92,11 @@ export const MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS = 3000; export const MAX_PACKED_BYTECODE_SIZE_PER_UNCONSTRAINED_FUNCTION_IN_FIELDS = 3000; export const REGISTERER_PRIVATE_FUNCTION_BROADCASTED_ADDITIONAL_FIELDS = 19; export const REGISTERER_UNCONSTRAINED_FUNCTION_BROADCASTED_ADDITIONAL_FIELDS = 12; -export const REGISTERER_CONTRACT_CLASS_REGISTERED_MAGIC_VALUE = - 11121068431693264234253912047066709627593769337094408533543930778360n; -export const REGISTERER_PRIVATE_FUNCTION_BROADCASTED_MAGIC_VALUE = - 2889881020989534926461066592611988634597302675057895885580456197069n; -export const REGISTERER_UNCONSTRAINED_FUNCTION_BROADCASTED_MAGIC_VALUE = - 24399338136397901754495080759185489776044879232766421623673792970137n; -export const DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_MAGIC_VALUE = - 14061769416655647708490531650437236735160113654556896985372298487345n; -export const DEPLOYER_CONTRACT_INSTANCE_UPDATED_MAGIC_VALUE = - 1534834688047131268740281708431107902615560100979874281215533519862n; +export const REGISTERER_CONTRACT_CLASS_REGISTERED_MAGIC_VALUE = 11121068431693264234253912047066709627593769337094408533543930778360n; +export const REGISTERER_PRIVATE_FUNCTION_BROADCASTED_MAGIC_VALUE = 2889881020989534926461066592611988634597302675057895885580456197069n; +export const REGISTERER_UNCONSTRAINED_FUNCTION_BROADCASTED_MAGIC_VALUE = 24399338136397901754495080759185489776044879232766421623673792970137n; +export const DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_MAGIC_VALUE = 14061769416655647708490531650437236735160113654556896985372298487345n; +export const DEPLOYER_CONTRACT_INSTANCE_UPDATED_MAGIC_VALUE = 1534834688047131268740281708431107902615560100979874281215533519862n; export const MAX_PROTOCOL_CONTRACTS = 7; export const CANONICAL_AUTH_REGISTRY_ADDRESS = 1; export const DEPLOYER_CONTRACT_ADDRESS = 2; From 8e0487ef3b10aff39b86e978b16cc4058a6fa5aa Mon Sep 17 00:00:00 2001 From: benesjan Date: Tue, 18 Mar 2025 03:49:23 +0000 Subject: [PATCH 4/5] wat --- yarn-project/constants/src/constants.gen.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/yarn-project/constants/src/constants.gen.ts b/yarn-project/constants/src/constants.gen.ts index 78bc3259ceda..0960a724e54e 100644 --- a/yarn-project/constants/src/constants.gen.ts +++ b/yarn-project/constants/src/constants.gen.ts @@ -412,3 +412,4 @@ export enum GeneratorIndex { PUBLIC_TX_HASH = 56, PRIVATE_TX_HASH = 57, } + From 468730df8a2b27aea635220af6056ad8481e2b65 Mon Sep 17 00:00:00 2001 From: benesjan Date: Tue, 18 Mar 2025 03:49:53 +0000 Subject: [PATCH 5/5] wat 2 --- yarn-project/constants/src/constants.gen.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/yarn-project/constants/src/constants.gen.ts b/yarn-project/constants/src/constants.gen.ts index 0960a724e54e..78bc3259ceda 100644 --- a/yarn-project/constants/src/constants.gen.ts +++ b/yarn-project/constants/src/constants.gen.ts @@ -412,4 +412,3 @@ export enum GeneratorIndex { PUBLIC_TX_HASH = 56, PRIVATE_TX_HASH = 57, } -