Skip to content

Commit 822c8e6

Browse files
committed
wip
1 parent 47887e2 commit 822c8e6

File tree

9 files changed

+14
-118
lines changed

9 files changed

+14
-118
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,10 +1415,8 @@ export class Archiver
14151415
}
14161416

14171417
/**
1418-
* Gets all logs that match any of the received tags (i.e. logs with their first field equal to a tag).
1419-
* @param tags - The tags to filter the logs by.
1420-
* @returns For each received tag, an array of matching logs is returned. An empty array implies no logs match
1421-
* that tag.
1418+
* Gets all logs that match any of the `tags`. For each tag, an array of matching logs is returned. An empty array
1419+
* implies no logs match that tag.
14221420
*/
14231421
getLogsByTags(tags: SiloedTag[]): Promise<TxScopedL2Log[][]> {
14241422
return this.store.getLogsByTags(tags);

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,8 @@ export interface ArchiverDataStore {
206206
getTotalL1ToL2MessageCount(): Promise<bigint>;
207207

208208
/**
209-
* Gets all logs that match any of the received tags (i.e. logs with their first field equal to a tag).
210-
* @param tags - The tags to filter the logs by.
211-
* @returns For each received tag, an array of matching logs is returned. An empty array implies no logs match
212-
* that tag.
213-
* @throws MaxLogsPerTagExceededError if any tag has more than MAX_LOGS_PER_TAG logs.
209+
* Gets all logs that match any of the `tags`. For each tag, an array of matching logs is returned. An empty array
210+
* implies no logs match that tag.
214211
*/
215212
getLogsByTags(tags: SiloedTag[]): Promise<TxScopedL2Log[][]>;
216213

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

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import {
3030
SerializableContractInstance,
3131
computePublicBytecodeCommitment,
3232
} from '@aztec/stdlib/contract';
33-
import { MAX_LOGS_PER_TAG } from '@aztec/stdlib/interfaces/server';
3433
import { ContractClassLog, LogId, PrivateLog, PublicLog, SiloedTag } from '@aztec/stdlib/logs';
3534
import { InboxLeaf } from '@aztec/stdlib/messaging';
3635
import { CheckpointHeader } from '@aztec/stdlib/rollup';
@@ -53,7 +52,6 @@ import {
5352
CheckpointNumberNotSequentialError,
5453
InitialBlockNumberNotSequentialError,
5554
InitialCheckpointNumberNotSequentialError,
56-
MaxLogsPerTagExceededError,
5755
} from './errors.js';
5856
import { MessageStoreError } from './kv_archiver_store/message_store.js';
5957
import type { InboxMessage } from './structs/inbox_message.js';
@@ -2386,68 +2384,6 @@ export function describeArchiverDataStore(
23862384
],
23872385
]);
23882386
});
2389-
2390-
it('throws error when tag has more than MAX_LOGS_PER_TAG logs', async () => {
2391-
const tag = new SiloedTag(Fr.random());
2392-
const numLogsToCreate = MAX_LOGS_PER_TAG + 1;
2393-
2394-
// Create checkpoints with logs that all share the same tag
2395-
const newLogsCheckpoints: PublishedCheckpoint[] = [];
2396-
let previousArchive: AppendOnlyTreeSnapshot | undefined;
2397-
let logCount = 0;
2398-
2399-
// We need to create multiple blocks/checkpoints to get enough logs with the same tag
2400-
// Since each block has numTxsPerBlock (4) txs, and each tx has numPrivateLogsPerTx (3) logs,
2401-
// we need enough blocks to create MAX_LOGS_PER_TAG + 1 logs
2402-
const blocksNeeded = Math.ceil(numLogsToCreate / (numTxsPerBlock * numPrivateLogsPerTx)) + 1;
2403-
const startBlockNumber = numBlocksForLogs + 1;
2404-
2405-
for (
2406-
let blockNum = startBlockNumber;
2407-
blockNum < startBlockNumber + blocksNeeded && logCount < numLogsToCreate;
2408-
blockNum++
2409-
) {
2410-
const block = await L2BlockNew.random(BlockNumber(blockNum), {
2411-
checkpointNumber: CheckpointNumber(blockNum),
2412-
indexWithinCheckpoint: 0,
2413-
state: makeStateForBlock(blockNum, numTxsPerBlock),
2414-
...(previousArchive ? { lastArchive: previousArchive } : {}),
2415-
});
2416-
block.header.globalVariables.blockNumber = BlockNumber(blockNum);
2417-
2418-
block.body.txEffects = await timesParallel(numTxsPerBlock, async (txIndex: number) => {
2419-
const txEffect = await TxEffect.random();
2420-
const privateLogs: PrivateLog[] = [];
2421-
2422-
// Add logs with the same tag until we reach the target count
2423-
for (let logIndex = 0; logIndex < numPrivateLogsPerTx && logCount < numLogsToCreate; logIndex++) {
2424-
const log = makePrivateLog(tag);
2425-
privateLogs.push(log);
2426-
logCount++;
2427-
}
2428-
2429-
txEffect.privateLogs = privateLogs;
2430-
txEffect.publicLogs = mockPublicLogs(blockNum, txIndex);
2431-
return txEffect;
2432-
});
2433-
2434-
const checkpoint = new Checkpoint(
2435-
AppendOnlyTreeSnapshot.random(),
2436-
CheckpointHeader.random(),
2437-
[block],
2438-
CheckpointNumber(blockNum),
2439-
);
2440-
const publishedCheckpoint = makePublishedCheckpoint(checkpoint, blockNum);
2441-
newLogsCheckpoints.push(publishedCheckpoint);
2442-
previousArchive = block.archive;
2443-
}
2444-
2445-
await store.addCheckpoints(newLogsCheckpoints);
2446-
await store.addLogs(newLogsCheckpoints.flatMap(p => p.checkpoint.blocks));
2447-
2448-
// Now try to get logs by tag - should throw error
2449-
await expect(store.getLogsByTags([tag])).rejects.toThrow(MaxLogsPerTagExceededError);
2450-
});
24512387
});
24522388

24532389
describe('getPublicLogs', () => {

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,3 @@ export class BlockNotFoundError extends Error {
8888
super(`Failed to find expected block number ${blockNumber}`);
8989
}
9090
}
91-
92-
export class MaxLogsPerTagExceededError extends Error {
93-
constructor(tag: string, count: number, limit: number) {
94-
super(`Tag ${tag} has ${count} logs, which exceeds the maximum allowed (${limit})`);
95-
this.name = 'MaxLogsPerTagExceededError';
96-
}
97-
}

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,8 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
319319
}
320320

321321
/**
322-
* Gets all logs that match any of the received tags (i.e. logs with their first field equal to a tag).
323-
* @param tags - The tags to filter the logs by.
324-
* @returns For each received tag, an array of matching logs is returned. An empty array implies no logs match
325-
* that tag.
326-
* @throws MaxLogsPerTagExceededError if any tag has more than MAX_LOGS_PER_TAG logs.
322+
* Gets all logs that match any of the `tags`. For each tag, an array of matching logs is returned. An empty array
323+
* implies no logs match that tag.
327324
*/
328325
getLogsByTags(tags: SiloedTag[]): Promise<TxScopedL2Log[][]> {
329326
try {

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

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { BufferReader, numToUInt32BE } from '@aztec/foundation/serialize';
66
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
77
import { L2BlockHash, L2BlockNew } from '@aztec/stdlib/block';
88
import type { GetContractClassLogsResponse, GetPublicLogsResponse } from '@aztec/stdlib/interfaces/client';
9-
import { MAX_LOGS_PER_TAG } from '@aztec/stdlib/interfaces/server';
109
import {
1110
ContractClassLog,
1211
ExtendedContractClassLog,
@@ -18,7 +17,6 @@ import {
1817
TxScopedL2Log,
1918
} from '@aztec/stdlib/logs';
2019

21-
import { MaxLogsPerTagExceededError } from '../errors.js';
2220
import type { BlockStore } from './block_store.js';
2321

2422
/**
@@ -206,24 +204,12 @@ export class LogStore {
206204
}
207205

208206
/**
209-
* Gets all logs that match any of the received tags (i.e. logs with their first field equal to a tag).
210-
* @param tags - The tags to filter the logs by.
211-
* @returns For each received tag, an array of matching logs is returned. An empty array implies no logs match
212-
* that tag.
213-
* @throws MaxLogsPerTagExceededError if any tag has more than MAX_LOGS_PER_TAG logs.
207+
* Gets all logs that match any of the `tags`. For each tag, an array of matching logs is returned. An empty array
208+
* implies no logs match that tag.
214209
*/
215210
async getLogsByTags(tags: SiloedTag[]): Promise<TxScopedL2Log[][]> {
216211
const logs = await Promise.all(tags.map(tag => this.#logsByTag.getAsync(tag.toString())));
217212

218-
// Check each tag's log count against the limit
219-
for (let i = 0; i < tags.length; i++) {
220-
const tag = tags[i];
221-
const logBuffers = logs[i];
222-
if (logBuffers && logBuffers.length > MAX_LOGS_PER_TAG) {
223-
throw new MaxLogsPerTagExceededError(tag.toString(), logBuffers.length, MAX_LOGS_PER_TAG);
224-
}
225-
}
226-
227213
return logs.map(logBuffers => logBuffers?.map(logBuffer => TxScopedL2Log.fromBuffer(logBuffer)) ?? []);
228214
}
229215

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -681,11 +681,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
681681
}
682682

683683
/**
684-
* Gets all logs that match any of the received tags (i.e. logs with their first field equal to a tag).
685-
* @param tags - The tags to filter the logs by.
686-
* @returns For each received tag, an array of matching logs is returned. An empty array implies no logs match
687-
* that tag.
688-
* @throws MaxLogsPerTagExceededError if any tag has more than MAX_LOGS_PER_TAG logs.
684+
* Gets all logs that match any of the `tags`. For each tag, an array of matching logs is returned. An empty array
685+
* implies no logs match that tag.
689686
*/
690687
public getLogsByTags(tags: SiloedTag[]): Promise<TxScopedL2Log[][]> {
691688
return this.logsSource.getLogsByTags(tags);

yarn-project/stdlib/src/interfaces/aztec-node.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -338,12 +338,8 @@ export interface AztecNode
338338
getContractClassLogs(filter: LogFilter): Promise<GetContractClassLogsResponse>;
339339

340340
/**
341-
* Gets all logs that match any of the received tags (i.e. logs with their first field equal to a tag).
342-
* @param tags - The tags to filter the logs by.
343-
* @returns For each received tag, an array of matching logs and metadata (e.g. tx hash) is returned. An empty
344-
* array implies no logs match that tag. There can be multiple logs for 1 tag because tag reuse can happen
345-
* --> e.g. when sending a note from multiple unsynched devices.
346-
* @throws MaxLogsPerTagExceededError if any tag has more than MAX_LOGS_PER_TAG logs.
341+
* Gets all logs that match any of the `tags`. For each tag, an array of matching logs is returned. An empty array
342+
* implies no logs match that tag.
347343
*/
348344
getLogsByTags(tags: SiloedTag[]): Promise<TxScopedL2Log[][]>;
349345

@@ -481,7 +477,6 @@ export interface AztecNode
481477
getAllowedPublicSetup(): Promise<AllowedElement[]>;
482478
}
483479

484-
export const MAX_LOGS_PER_TAG = 10;
485480
const MAX_SIGNATURES_PER_REGISTER_CALL = 100;
486481
const MAX_SIGNATURE_LEN = 10000;
487482

yarn-project/stdlib/src/interfaces/l2_logs_source.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,8 @@ import type { GetContractClassLogsResponse, GetPublicLogsResponse } from './get_
1010
*/
1111
export interface L2LogsSource {
1212
/**
13-
* Gets all logs that match any of the received tags (i.e. logs with their first field equal to a tag).
14-
* @param tags - The tags to filter the logs by.
15-
* @returns For each received tag, an array of matching logs is returned. An empty array implies no logs match
16-
* that tag.
17-
* @throws MaxLogsPerTagExceededError if any tag has more than MAX_LOGS_PER_TAG logs.
13+
* Gets all logs that match any of the `tags`. For each tag, an array of matching logs is returned. An empty array
14+
* implies no logs match that tag.
1815
*/
1916
getLogsByTags(tags: SiloedTag[]): Promise<TxScopedL2Log[][]>;
2017

0 commit comments

Comments
 (0)