Skip to content

Commit a36eb2f

Browse files
committed
refactor: typing tag arg in getLogsByTags
1 parent 02dee1d commit a36eb2f

27 files changed

+157
-145
lines changed

yarn-project/archiver/src/archiver/archiver.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,14 @@ import {
6464
} from '@aztec/stdlib/epoch-helpers';
6565
import type { GetContractClassLogsResponse, GetPublicLogsResponse } from '@aztec/stdlib/interfaces/client';
6666
import type { L2LogsSource } from '@aztec/stdlib/interfaces/server';
67-
import { ContractClassLog, type LogFilter, type PrivateLog, type PublicLog, TxScopedL2Log } from '@aztec/stdlib/logs';
67+
import {
68+
ContractClassLog,
69+
type LogFilter,
70+
type PrivateLog,
71+
type PublicLog,
72+
type SiloedTag,
73+
TxScopedL2Log,
74+
} from '@aztec/stdlib/logs';
6875
import { type L1ToL2MessageSource, computeInHashFromL1ToL2Messages } from '@aztec/stdlib/messaging';
6976
import type { CheckpointHeader } from '@aztec/stdlib/rollup';
7077
import { type BlockHeader, type IndexedTxEffect, TxHash, TxReceipt } from '@aztec/stdlib/tx';
@@ -1413,7 +1420,7 @@ export class Archiver
14131420
* @returns For each received tag, an array of matching logs is returned. An empty array implies no logs match
14141421
* that tag.
14151422
*/
1416-
getLogsByTags(tags: Fr[]): Promise<TxScopedL2Log[][]> {
1423+
getLogsByTags(tags: SiloedTag[]): Promise<TxScopedL2Log[][]> {
14171424
return this.store.getLogsByTags(tags);
14181425
}
14191426

@@ -2072,7 +2079,7 @@ export class ArchiverStoreHelper
20722079
getL1ToL2MessageIndex(l1ToL2Message: Fr): Promise<bigint | undefined> {
20732080
return this.store.getL1ToL2MessageIndex(l1ToL2Message);
20742081
}
2075-
getLogsByTags(tags: Fr[], logsPerTag?: number): Promise<TxScopedL2Log[][]> {
2082+
getLogsByTags(tags: SiloedTag[], logsPerTag?: number): Promise<TxScopedL2Log[][]> {
20762083
return this.store.getLogsByTags(tags, logsPerTag);
20772084
}
20782085
getPublicLogs(filter: LogFilter): Promise<GetPublicLogsResponse> {

yarn-project/archiver/src/archiver/archiver_store.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type {
1414
UtilityFunctionWithMembershipProof,
1515
} from '@aztec/stdlib/contract';
1616
import type { GetContractClassLogsResponse, GetPublicLogsResponse } from '@aztec/stdlib/interfaces/client';
17-
import type { LogFilter, TxScopedL2Log } from '@aztec/stdlib/logs';
17+
import type { LogFilter, SiloedTag, TxScopedL2Log } from '@aztec/stdlib/logs';
1818
import { BlockHeader, type IndexedTxEffect, type TxHash, type TxReceipt } from '@aztec/stdlib/tx';
1919
import type { UInt64 } from '@aztec/stdlib/types';
2020

@@ -212,7 +212,7 @@ export interface ArchiverDataStore {
212212
* @returns For each received tag, an array of matching logs is returned. An empty array implies no logs match
213213
* that tag.
214214
*/
215-
getLogsByTags(tags: Fr[], logsPerTag?: number): Promise<TxScopedL2Log[][]>;
215+
getLogsByTags(tags: SiloedTag[], logsPerTag?: number): Promise<TxScopedL2Log[][]>;
216216

217217
/**
218218
* Gets public logs based on the provided filter.

yarn-project/archiver/src/archiver/archiver_store_test_suite.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import {
3030
SerializableContractInstance,
3131
computePublicBytecodeCommitment,
3232
} from '@aztec/stdlib/contract';
33-
import { ContractClassLog, LogId, PrivateLog, PublicLog } from '@aztec/stdlib/logs';
33+
import { ContractClassLog, LogId, PrivateLog, PublicLog, SiloedTag } from '@aztec/stdlib/logs';
3434
import { InboxLeaf } from '@aztec/stdlib/messaging';
3535
import { CheckpointHeader } from '@aztec/stdlib/rollup';
3636
import {
@@ -2206,22 +2206,22 @@ export function describeArchiverDataStore(
22062206

22072207
let logsCheckpoints: PublishedCheckpoint[];
22082208

2209-
const makeTag = (blockNumber: number, txIndex: number, logIndex: number, isPublic = false) =>
2209+
const makeTag = (blockNumber: number, txIndex: number, logIndex: number, isPublic = false): SiloedTag =>
22102210
blockNumber === 1 && txIndex === 0 && logIndex === 0
2211-
? Fr.ZERO // Shared tag
2212-
: new Fr((blockNumber * 100 + txIndex * 10 + logIndex) * (isPublic ? 123 : 1));
2211+
? new SiloedTag(Fr.ZERO) // Shared tag
2212+
: new SiloedTag(new Fr((blockNumber * 100 + txIndex * 10 + logIndex) * (isPublic ? 123 : 1)));
22132213

2214-
const makePrivateLog = (tag: Fr) =>
2214+
const makePrivateLog = (tag: SiloedTag) =>
22152215
PrivateLog.from({
2216-
fields: makeTuple(PRIVATE_LOG_SIZE_IN_FIELDS, i => (!i ? tag : new Fr(tag.toNumber() + i))),
2216+
fields: makeTuple(PRIVATE_LOG_SIZE_IN_FIELDS, i => (!i ? tag.value : new Fr(tag.value.toNumber() + i))),
22172217
emittedLength: PRIVATE_LOG_SIZE_IN_FIELDS,
22182218
});
22192219

2220-
const makePublicLog = (tag: Fr) =>
2220+
const makePublicLog = (tag: SiloedTag) =>
22212221
PublicLog.from({
22222222
contractAddress: AztecAddress.fromNumber(1),
22232223
// Arbitrary length
2224-
fields: new Array(10).fill(null).map((_, i) => (!i ? tag : new Fr(tag.toNumber() + i))),
2224+
fields: new Array(10).fill(null).map((_, i) => (!i ? tag.value : new Fr(tag.value.toNumber() + i))),
22252225
});
22262226

22272227
const mockPrivateLogs = (blockNumber: number, txIndex: number) => {
@@ -2336,7 +2336,7 @@ export function describeArchiverDataStore(
23362336
const previousArchive = logsCheckpoints[logsCheckpoints.length - 1].checkpoint.blocks[0].archive;
23372337
const newCheckpoint = await mockCheckpointWithLogs(newBlockNumber, previousArchive);
23382338
const newLog = newCheckpoint.checkpoint.blocks[0].body.txEffects[1].privateLogs[1];
2339-
newLog.fields[0] = tags[0];
2339+
newLog.fields[0] = tags[0].value;
23402340
newCheckpoint.checkpoint.blocks[0].body.txEffects[1].privateLogs[1] = newLog;
23412341
await store.addCheckpoints([newCheckpoint]);
23422342
await store.addLogs([newCheckpoint.checkpoint.blocks[0]]);

yarn-project/archiver/src/archiver/kv_archiver_store/kv_archiver_store.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import type {
1717
UtilityFunctionWithMembershipProof,
1818
} from '@aztec/stdlib/contract';
1919
import type { GetContractClassLogsResponse, GetPublicLogsResponse } from '@aztec/stdlib/interfaces/client';
20-
import type { LogFilter, TxScopedL2Log } from '@aztec/stdlib/logs';
20+
import type { LogFilter, SiloedTag, TxScopedL2Log } from '@aztec/stdlib/logs';
2121
import type { BlockHeader, TxHash, TxReceipt } from '@aztec/stdlib/tx';
2222
import type { UInt64 } from '@aztec/stdlib/types';
2323

@@ -325,7 +325,7 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
325325
* @returns For each received tag, an array of matching logs is returned. An empty array implies no logs match
326326
* that tag.
327327
*/
328-
getLogsByTags(tags: Fr[], logsPerTag?: number): Promise<TxScopedL2Log[][]> {
328+
getLogsByTags(tags: SiloedTag[], logsPerTag?: number): Promise<TxScopedL2Log[][]> {
329329
try {
330330
return this.#logStore.getLogsByTags(tags, logsPerTag);
331331
} catch (err) {

yarn-project/archiver/src/archiver/kv_archiver_store/log_store.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
type LogFilter,
1414
LogId,
1515
PublicLog,
16+
type SiloedTag,
1617
TxScopedL2Log,
1718
} from '@aztec/stdlib/logs';
1819

@@ -208,7 +209,7 @@ export class LogStore {
208209
* @returns For each received tag, an array of matching logs is returned. An empty array implies no logs match
209210
* that tag.
210211
*/
211-
async getLogsByTags(tags: Fr[], limitPerTag?: number): Promise<TxScopedL2Log[][]> {
212+
async getLogsByTags(tags: SiloedTag[], limitPerTag?: number): Promise<TxScopedL2Log[][]> {
212213
if (limitPerTag !== undefined && limitPerTag <= 0) {
213214
throw new TypeError('limitPerTag needs to be greater than 0');
214215
}

yarn-project/aztec-node/src/aztec-node/server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ import {
8787
type WorldStateSynchronizer,
8888
tryStop,
8989
} from '@aztec/stdlib/interfaces/server';
90-
import type { LogFilter, TxScopedL2Log } from '@aztec/stdlib/logs';
90+
import type { LogFilter, SiloedTag, TxScopedL2Log } from '@aztec/stdlib/logs';
9191
import { InboxLeaf, type L1ToL2MessageSource } from '@aztec/stdlib/messaging';
9292
import { P2PClientType } from '@aztec/stdlib/p2p';
9393
import type { Offense, SlashPayloadRound } from '@aztec/stdlib/slashing';
@@ -687,7 +687,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
687687
* @returns For each received tag, an array of matching logs is returned. An empty array implies no logs match
688688
* that tag.
689689
*/
690-
public getLogsByTags(tags: Fr[], logsPerTag?: number): Promise<TxScopedL2Log[][]> {
690+
public getLogsByTags(tags: SiloedTag[], logsPerTag?: number): Promise<TxScopedL2Log[][]> {
691691
return this.logsSource.getLogsByTags(tags, logsPerTag);
692692
}
693693

yarn-project/pxe/src/contract_function_simulator/oracle/interfaces.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ import type { FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
66
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
77
import type { CompleteAddress, ContractInstance } from '@aztec/stdlib/contract';
88
import type { KeyValidationRequest } from '@aztec/stdlib/kernel';
9-
import type { ContractClassLog } from '@aztec/stdlib/logs';
9+
import type { ContractClassLog, Tag } from '@aztec/stdlib/logs';
1010
import type { Note, NoteStatus } from '@aztec/stdlib/note';
1111
import { type MerkleTreeId, type NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
1212
import type { BlockHeader } from '@aztec/stdlib/tx';
1313

14-
import type { Tag } from '../../tagging/tag.js';
1514
import type { UtilityContext } from '../noir-structs/utility_context.js';
1615
import type { MessageLoadOracleInputs } from './message_load_oracle_inputs.js';
1716

yarn-project/pxe/src/contract_function_simulator/oracle/private_execution.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import { computeNoteHashNonce, computeSecretHash, computeUniqueNoteHash, siloNot
4343
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
4444
import { KeyValidationRequest } from '@aztec/stdlib/kernel';
4545
import { computeAppNullifierSecretKey, deriveKeys } from '@aztec/stdlib/keys';
46-
import { DirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
46+
import { DirectionalAppTaggingSecret, SiloedTag } from '@aztec/stdlib/logs';
4747
import { L1Actor, L1ToL2Message, L2Actor } from '@aztec/stdlib/messaging';
4848
import { Note } from '@aztec/stdlib/note';
4949
import { makeBlockHeader } from '@aztec/stdlib/testing';
@@ -292,7 +292,7 @@ describe('Private Execution test suite', () => {
292292

293293
// Mock aztec node methods - the return array needs to have the same length as the number of tags
294294
// on the input.
295-
aztecNode.getLogsByTags.mockImplementation((tags: Fr[]) => Promise.resolve(tags.map(() => [])));
295+
aztecNode.getLogsByTags.mockImplementation((tags: SiloedTag[]) => Promise.resolve(tags.map(() => [])));
296296

297297
executionDataProvider.getKeyValidationRequest.mockImplementation(
298298
async (pkMHash: Fr, contractAddress: AztecAddress) => {

yarn-project/pxe/src/contract_function_simulator/oracle/private_execution_oracle.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
1515
import { computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
1616
import { PrivateContextInputs } from '@aztec/stdlib/kernel';
1717
import type { ContractClassLog, DirectionalAppTaggingSecret, PreTag } from '@aztec/stdlib/logs';
18+
import { Tag } from '@aztec/stdlib/logs';
1819
import { Note, type NoteStatus } from '@aztec/stdlib/note';
1920
import {
2021
type BlockHeader,
@@ -27,7 +28,6 @@ import {
2728
} from '@aztec/stdlib/tx';
2829

2930
import { syncSenderTaggingIndexes } from '../../tagging/sync/sync_sender_tagging_indexes.js';
30-
import { Tag } from '../../tagging/tag.js';
3131
import type { ExecutionDataProvider } from '../execution_data_provider.js';
3232
import type { ExecutionNoteCache } from '../execution_note_cache.js';
3333
import { ExecutionTaggingIndexCache } from '../execution_tagging_index_cache.js';

yarn-project/pxe/src/contract_function_simulator/pxe_oracle_interface.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { CompleteAddress } from '@aztec/stdlib/contract';
1111
import { computeUniqueNoteHash, siloNoteHash, siloNullifier, siloPrivateLog } from '@aztec/stdlib/hash';
1212
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
1313
import { computeAddress, deriveKeys } from '@aztec/stdlib/keys';
14-
import { DirectionalAppTaggingSecret, PrivateLog, PublicLog, TxScopedL2Log } from '@aztec/stdlib/logs';
14+
import { DirectionalAppTaggingSecret, PrivateLog, PublicLog, SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
1515
import { NoteDao, NoteStatus } from '@aztec/stdlib/note';
1616
import { MerkleTreeId } from '@aztec/stdlib/trees';
1717
import {
@@ -35,8 +35,6 @@ import { PrivateEventDataProvider } from '../storage/private_event_data_provider
3535
import { RecipientTaggingDataProvider } from '../storage/tagging_data_provider/recipient_tagging_data_provider.js';
3636
import { SenderTaggingDataProvider } from '../storage/tagging_data_provider/sender_tagging_data_provider.js';
3737
import { WINDOW_HALF_SIZE } from '../tagging/constants.js';
38-
import { SiloedTag } from '../tagging/siloed_tag.js';
39-
import { Tag } from '../tagging/tag.js';
4038
import { LogRetrievalRequest } from './noir-structs/log_retrieval_request.js';
4139
import { PXEOracleInterface } from './pxe_oracle_interface.js';
4240

0 commit comments

Comments
 (0)