@aztec/archiver 0.66.0 → 0.67.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dest/archiver/archiver.d.ts +4 -4
  2. package/dest/archiver/archiver.d.ts.map +1 -1
  3. package/dest/archiver/archiver.js +8 -6
  4. package/dest/archiver/archiver_store.d.ts +2 -2
  5. package/dest/archiver/archiver_store.d.ts.map +1 -1
  6. package/dest/archiver/data_retrieval.d.ts +3 -3
  7. package/dest/archiver/data_retrieval.d.ts.map +1 -1
  8. package/dest/archiver/data_retrieval.js +9 -9
  9. package/dest/archiver/instrumentation.d.ts +3 -1
  10. package/dest/archiver/instrumentation.d.ts.map +1 -1
  11. package/dest/archiver/instrumentation.js +16 -18
  12. package/dest/archiver/kv_archiver_store/block_store.d.ts +2 -2
  13. package/dest/archiver/kv_archiver_store/block_store.d.ts.map +1 -1
  14. package/dest/archiver/kv_archiver_store/block_store.js +6 -6
  15. package/dest/archiver/kv_archiver_store/contract_class_store.js +2 -2
  16. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +2 -2
  17. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
  18. package/dest/archiver/kv_archiver_store/kv_archiver_store.js +3 -3
  19. package/dest/archiver/kv_archiver_store/log_store.js +3 -3
  20. package/dest/archiver/kv_archiver_store/message_store.js +3 -3
  21. package/dest/archiver/kv_archiver_store/nullifier_store.js +3 -3
  22. package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts +2 -2
  23. package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts.map +1 -1
  24. package/dest/archiver/memory_archiver_store/memory_archiver_store.js +4 -4
  25. package/dest/factory.js +4 -4
  26. package/dest/index.d.ts +1 -1
  27. package/dest/index.d.ts.map +1 -1
  28. package/dest/index.js +2 -2
  29. package/dest/test/mock_l2_block_source.d.ts +2 -2
  30. package/dest/test/mock_l2_block_source.d.ts.map +1 -1
  31. package/dest/test/mock_l2_block_source.js +3 -3
  32. package/package.json +15 -11
  33. package/src/archiver/archiver.ts +10 -8
  34. package/src/archiver/archiver_store.ts +2 -2
  35. package/src/archiver/data_retrieval.ts +9 -9
  36. package/src/archiver/instrumentation.ts +21 -21
  37. package/src/archiver/kv_archiver_store/block_store.ts +6 -6
  38. package/src/archiver/kv_archiver_store/contract_class_store.ts +1 -1
  39. package/src/archiver/kv_archiver_store/kv_archiver_store.ts +4 -4
  40. package/src/archiver/kv_archiver_store/log_store.ts +2 -2
  41. package/src/archiver/kv_archiver_store/message_store.ts +2 -2
  42. package/src/archiver/kv_archiver_store/nullifier_store.ts +2 -2
  43. package/src/archiver/memory_archiver_store/memory_archiver_store.ts +5 -5
  44. package/src/factory.ts +3 -3
  45. package/src/index.ts +1 -4
  46. package/src/test/mock_l2_block_source.ts +4 -4
@@ -1,6 +1,6 @@
1
1
  import { Body, type InBlock, L2Block, L2BlockHash, type TxEffect, type TxHash, TxReceipt } from '@aztec/circuit-types';
2
- import { AppendOnlyTreeSnapshot, type AztecAddress, Header, INITIAL_L2_BLOCK_NUM } from '@aztec/circuits.js';
3
- import { createDebugLogger } from '@aztec/foundation/log';
2
+ import { AppendOnlyTreeSnapshot, type AztecAddress, BlockHeader, INITIAL_L2_BLOCK_NUM } from '@aztec/circuits.js';
3
+ import { createLogger } from '@aztec/foundation/log';
4
4
  import { type AztecKVStore, type AztecMap, type AztecSingleton, type Range } from '@aztec/kv-store';
5
5
 
6
6
  import { type L1Published, type L1PublishedData } from '../structs/published.js';
@@ -38,7 +38,7 @@ export class BlockStore {
38
38
  /** Index mapping a contract's address (as a string) to its location in a block */
39
39
  #contractIndex: AztecMap<string, BlockIndexValue>;
40
40
 
41
- #log = createDebugLogger('aztec:archiver:block_store');
41
+ #log = createLogger('archiver:block_store');
42
42
 
43
43
  constructor(private db: AztecKVStore) {
44
44
  this.#blocks = db.openMap('archiver_blocks');
@@ -147,14 +147,14 @@ export class BlockStore {
147
147
  * @param limit - The number of blocks to return.
148
148
  * @returns The requested L2 block headers
149
149
  */
150
- *getBlockHeaders(start: number, limit: number): IterableIterator<Header> {
150
+ *getBlockHeaders(start: number, limit: number): IterableIterator<BlockHeader> {
151
151
  for (const blockStorage of this.#blocks.values(this.#computeBlockRange(start, limit))) {
152
- yield Header.fromBuffer(blockStorage.header);
152
+ yield BlockHeader.fromBuffer(blockStorage.header);
153
153
  }
154
154
  }
155
155
 
156
156
  private getBlockFromBlockStorage(blockStorage: BlockStorage) {
157
- const header = Header.fromBuffer(blockStorage.header);
157
+ const header = BlockHeader.fromBuffer(blockStorage.header);
158
158
  const archive = AppendOnlyTreeSnapshot.fromBuffer(blockStorage.archive);
159
159
  const blockHash = header.hash().toString();
160
160
  const blockBodyBuffer = this.#blockBodies.get(blockHash);
@@ -53,7 +53,7 @@ export class ContractClassStore {
53
53
  }
54
54
 
55
55
  getContractClassIds(): Fr[] {
56
- return Array.from(this.#contractClasses.keys()).map(key => Fr.fromString(key));
56
+ return Array.from(this.#contractClasses.keys()).map(key => Fr.fromHexString(key));
57
57
  }
58
58
 
59
59
  async addFunctions(
@@ -9,17 +9,17 @@ import {
9
9
  type TxScopedL2Log,
10
10
  } from '@aztec/circuit-types';
11
11
  import {
12
+ type BlockHeader,
12
13
  type ContractClassPublic,
13
14
  type ContractInstanceWithAddress,
14
15
  type ExecutablePrivateFunctionWithMembershipProof,
15
16
  type Fr,
16
- type Header,
17
17
  type PrivateLog,
18
18
  type UnconstrainedFunctionWithMembershipProof,
19
19
  } from '@aztec/circuits.js';
20
20
  import { type ContractArtifact, FunctionSelector } from '@aztec/foundation/abi';
21
21
  import { type AztecAddress } from '@aztec/foundation/aztec-address';
22
- import { createDebugLogger } from '@aztec/foundation/log';
22
+ import { createLogger } from '@aztec/foundation/log';
23
23
  import { type AztecKVStore } from '@aztec/kv-store';
24
24
 
25
25
  import { type ArchiverDataStore, type ArchiverL1SynchPoint } from '../archiver_store.js';
@@ -46,7 +46,7 @@ export class KVArchiverDataStore implements ArchiverDataStore {
46
46
  #contractArtifactStore: ContractArtifactsStore;
47
47
  private functionNames = new Map<string, string>();
48
48
 
49
- #log = createDebugLogger('aztec:archiver:data-store');
49
+ #log = createLogger('archiver:data-store');
50
50
 
51
51
  constructor(private db: AztecKVStore, logsMaxPageSize: number = 1000) {
52
52
  this.#blockStore = new BlockStore(db);
@@ -171,7 +171,7 @@ export class KVArchiverDataStore implements ArchiverDataStore {
171
171
  * @param limit - The number of blocks to return.
172
172
  * @returns The requested L2 blocks
173
173
  */
174
- getBlockHeaders(start: number, limit: number): Promise<Header[]> {
174
+ getBlockHeaders(start: number, limit: number): Promise<BlockHeader[]> {
175
175
  try {
176
176
  return Promise.resolve(Array.from(this.#blockStore.getBlockHeaders(start, limit)));
177
177
  } catch (err) {
@@ -11,7 +11,7 @@ import {
11
11
  } from '@aztec/circuit-types';
12
12
  import { Fr, PrivateLog } from '@aztec/circuits.js';
13
13
  import { INITIAL_L2_BLOCK_NUM, MAX_NOTE_HASHES_PER_TX } from '@aztec/circuits.js/constants';
14
- import { createDebugLogger } from '@aztec/foundation/log';
14
+ import { createLogger } from '@aztec/foundation/log';
15
15
  import { BufferReader } from '@aztec/foundation/serialize';
16
16
  import { type AztecKVStore, type AztecMap } from '@aztec/kv-store';
17
17
 
@@ -27,7 +27,7 @@ export class LogStore {
27
27
  #unencryptedLogsByBlock: AztecMap<number, Buffer>;
28
28
  #contractClassLogsByBlock: AztecMap<number, Buffer>;
29
29
  #logsMaxPageSize: number;
30
- #log = createDebugLogger('aztec:archiver:log_store');
30
+ #log = createLogger('archiver:log_store');
31
31
 
32
32
  constructor(private db: AztecKVStore, private blockStore: BlockStore, logsMaxPageSize: number = 1000) {
33
33
  this.#logsByTag = db.openMap('archiver_tagged_logs_by_tag');
@@ -1,6 +1,6 @@
1
1
  import { InboxLeaf } from '@aztec/circuit-types';
2
2
  import { Fr, L1_TO_L2_MSG_SUBTREE_HEIGHT } from '@aztec/circuits.js';
3
- import { createDebugLogger } from '@aztec/foundation/log';
3
+ import { createLogger } from '@aztec/foundation/log';
4
4
  import { type AztecKVStore, type AztecMap, type AztecSingleton } from '@aztec/kv-store';
5
5
 
6
6
  import { type DataRetrieval } from '../structs/data_retrieval.js';
@@ -14,7 +14,7 @@ export class MessageStore {
14
14
  #lastSynchedL1Block: AztecSingleton<bigint>;
15
15
  #totalMessageCount: AztecSingleton<bigint>;
16
16
 
17
- #log = createDebugLogger('aztec:archiver:message_store');
17
+ #log = createLogger('archiver:message_store');
18
18
 
19
19
  #l1ToL2MessagesSubtreeSize = 2 ** L1_TO_L2_MSG_SUBTREE_HEIGHT;
20
20
 
@@ -1,13 +1,13 @@
1
1
  import { type InBlock, type L2Block } from '@aztec/circuit-types';
2
2
  import { type Fr, MAX_NULLIFIERS_PER_TX } from '@aztec/circuits.js';
3
- import { createDebugLogger } from '@aztec/foundation/log';
3
+ import { createLogger } from '@aztec/foundation/log';
4
4
  import { type AztecKVStore, type AztecMap } from '@aztec/kv-store';
5
5
 
6
6
  export class NullifierStore {
7
7
  #nullifiersToBlockNumber: AztecMap<string, number>;
8
8
  #nullifiersToBlockHash: AztecMap<string, string>;
9
9
  #nullifiersToIndex: AztecMap<string, number>;
10
- #log = createDebugLogger('aztec:archiver:log_store');
10
+ #log = createLogger('archiver:log_store');
11
11
 
12
12
  constructor(private db: AztecKVStore) {
13
13
  this.#nullifiersToBlockNumber = db.openMap('archiver_nullifiers_to_block_number');
@@ -16,12 +16,12 @@ import {
16
16
  wrapInBlock,
17
17
  } from '@aztec/circuit-types';
18
18
  import {
19
+ type BlockHeader,
19
20
  type ContractClassPublic,
20
21
  type ContractClassPublicWithBlockNumber,
21
22
  type ContractInstanceWithAddress,
22
23
  type ExecutablePrivateFunctionWithMembershipProof,
23
24
  Fr,
24
- type Header,
25
25
  INITIAL_L2_BLOCK_NUM,
26
26
  MAX_NOTE_HASHES_PER_TX,
27
27
  MAX_NULLIFIERS_PER_TX,
@@ -30,7 +30,7 @@ import {
30
30
  } from '@aztec/circuits.js';
31
31
  import { type ContractArtifact, FunctionSelector } from '@aztec/foundation/abi';
32
32
  import { type AztecAddress } from '@aztec/foundation/aztec-address';
33
- import { createDebugLogger } from '@aztec/foundation/log';
33
+ import { createLogger } from '@aztec/foundation/log';
34
34
 
35
35
  import { type ArchiverDataStore, type ArchiverL1SynchPoint } from '../archiver_store.js';
36
36
  import { type DataRetrieval } from '../structs/data_retrieval.js';
@@ -86,7 +86,7 @@ export class MemoryArchiverStore implements ArchiverDataStore {
86
86
  private lastProvenL2BlockNumber: number = 0;
87
87
  private lastProvenL2EpochNumber: number = 0;
88
88
 
89
- #log = createDebugLogger('aztec:archiver:data-store');
89
+ #log = createLogger('archiver:data-store');
90
90
 
91
91
  constructor(
92
92
  /** The max number of logs that can be obtained in 1 "getUnencryptedLogs" call. */
@@ -105,7 +105,7 @@ export class MemoryArchiverStore implements ArchiverDataStore {
105
105
  }
106
106
 
107
107
  public getContractClassIds(): Promise<Fr[]> {
108
- return Promise.resolve(Array.from(this.contractClasses.keys()).map(key => Fr.fromString(key)));
108
+ return Promise.resolve(Array.from(this.contractClasses.keys()).map(key => Fr.fromHexString(key)));
109
109
  }
110
110
 
111
111
  public getContractInstance(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
@@ -427,7 +427,7 @@ export class MemoryArchiverStore implements ArchiverDataStore {
427
427
  return Promise.resolve(this.l2Blocks.slice(fromIndex, toIndex));
428
428
  }
429
429
 
430
- public async getBlockHeaders(from: number, limit: number): Promise<Header[]> {
430
+ public async getBlockHeaders(from: number, limit: number): Promise<BlockHeader[]> {
431
431
  const blocks = await this.getBlocks(from, limit);
432
432
  return blocks.map(block => block.data.header);
433
433
  }
package/src/factory.ts CHANGED
@@ -4,10 +4,10 @@ import {
4
4
  computePublicBytecodeCommitment,
5
5
  getContractClassFromArtifact,
6
6
  } from '@aztec/circuits.js';
7
- import { createDebugLogger } from '@aztec/foundation/log';
7
+ import { createLogger } from '@aztec/foundation/log';
8
8
  import { type Maybe } from '@aztec/foundation/types';
9
9
  import { type DataStoreConfig } from '@aztec/kv-store/config';
10
- import { createStore } from '@aztec/kv-store/utils';
10
+ import { createStore } from '@aztec/kv-store/lmdb';
11
11
  import { TokenBridgeContractArtifact, TokenContractArtifact } from '@aztec/noir-contracts.js';
12
12
  import { getCanonicalProtocolContract, protocolContractNames } from '@aztec/protocol-contracts';
13
13
  import { type TelemetryClient } from '@aztec/telemetry-client';
@@ -24,7 +24,7 @@ export async function createArchiver(
24
24
  opts: { blockUntilSync: boolean } = { blockUntilSync: true },
25
25
  ): Promise<ArchiverApi & Maybe<Service>> {
26
26
  if (!config.archiverUrl) {
27
- const store = await createStore('archiver', config, createDebugLogger('aztec:archiver:lmdb'));
27
+ const store = await createStore('archiver', config, createLogger('archiver:lmdb'));
28
28
  const archiverStore = new KVArchiverDataStore(store, config.maxLogs);
29
29
  await registerProtocolContracts(archiverStore);
30
30
  await registerCommonContracts(archiverStore);
package/src/index.ts CHANGED
@@ -2,7 +2,4 @@ export * from './archiver/index.js';
2
2
  export * from './factory.js';
3
3
  export * from './rpc/index.js';
4
4
 
5
- export {
6
- retrieveBlocksFromRollup as retrieveBlockFromRollup,
7
- retrieveL2ProofVerifiedEvents,
8
- } from './archiver/data_retrieval.js';
5
+ export { retrieveBlocksFromRollup, retrieveL2ProofVerifiedEvents } from './archiver/data_retrieval.js';
@@ -8,9 +8,9 @@ import {
8
8
  TxStatus,
9
9
  } from '@aztec/circuit-types';
10
10
  import { getSlotRangeForEpoch } from '@aztec/circuit-types';
11
- import { EthAddress, type Header } from '@aztec/circuits.js';
11
+ import { type BlockHeader, EthAddress } from '@aztec/circuits.js';
12
12
  import { DefaultL1ContractsConfig } from '@aztec/ethereum';
13
- import { createDebugLogger } from '@aztec/foundation/log';
13
+ import { createLogger } from '@aztec/foundation/log';
14
14
 
15
15
  /**
16
16
  * A mocked implementation of L2BlockSource to be used in tests.
@@ -21,7 +21,7 @@ export class MockL2BlockSource implements L2BlockSource {
21
21
  private provenEpochNumber: number = 0;
22
22
  private provenBlockNumber: number = 0;
23
23
 
24
- private log = createDebugLogger('aztec:archiver:mock_l2_block_source');
24
+ private log = createLogger('archiver:mock_l2_block_source');
25
25
 
26
26
  public createBlocks(numBlocks: number) {
27
27
  for (let i = 0; i < numBlocks; i++) {
@@ -106,7 +106,7 @@ export class MockL2BlockSource implements L2BlockSource {
106
106
  );
107
107
  }
108
108
 
109
- getBlockHeader(number: number | 'latest'): Promise<Header | undefined> {
109
+ getBlockHeader(number: number | 'latest'): Promise<BlockHeader | undefined> {
110
110
  return Promise.resolve(this.l2Blocks.at(typeof number === 'number' ? number - 1 : -1)?.header);
111
111
  }
112
112