@aztec/archiver 0.63.0 → 0.64.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 (45) hide show
  1. package/dest/archiver/archiver.d.ts +12 -3
  2. package/dest/archiver/archiver.d.ts.map +1 -1
  3. package/dest/archiver/archiver.js +37 -10
  4. package/dest/archiver/archiver_store.d.ts +25 -2
  5. package/dest/archiver/archiver_store.d.ts.map +1 -1
  6. package/dest/archiver/archiver_store_test_suite.d.ts.map +1 -1
  7. package/dest/archiver/archiver_store_test_suite.js +79 -19
  8. package/dest/archiver/data_retrieval.d.ts.map +1 -1
  9. package/dest/archiver/data_retrieval.js +4 -4
  10. package/dest/archiver/epoch_helpers.d.ts +12 -7
  11. package/dest/archiver/epoch_helpers.d.ts.map +1 -1
  12. package/dest/archiver/epoch_helpers.js +14 -2
  13. package/dest/archiver/instrumentation.d.ts +6 -0
  14. package/dest/archiver/instrumentation.d.ts.map +1 -1
  15. package/dest/archiver/instrumentation.js +15 -2
  16. package/dest/archiver/kv_archiver_store/block_store.d.ts +2 -2
  17. package/dest/archiver/kv_archiver_store/block_store.d.ts.map +1 -1
  18. package/dest/archiver/kv_archiver_store/block_store.js +18 -8
  19. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +16 -2
  20. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
  21. package/dest/archiver/kv_archiver_store/kv_archiver_store.js +24 -3
  22. package/dest/archiver/kv_archiver_store/nullifier_store.d.ts +12 -0
  23. package/dest/archiver/kv_archiver_store/nullifier_store.d.ts.map +1 -0
  24. package/dest/archiver/kv_archiver_store/nullifier_store.js +71 -0
  25. package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts +11 -2
  26. package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts.map +1 -1
  27. package/dest/archiver/memory_archiver_store/memory_archiver_store.js +51 -6
  28. package/dest/factory.d.ts.map +1 -1
  29. package/dest/factory.js +21 -3
  30. package/dest/test/mock_l2_block_source.d.ts +5 -1
  31. package/dest/test/mock_l2_block_source.d.ts.map +1 -1
  32. package/dest/test/mock_l2_block_source.js +9 -3
  33. package/package.json +12 -11
  34. package/src/archiver/archiver.ts +51 -11
  35. package/src/archiver/archiver_store.ts +24 -1
  36. package/src/archiver/archiver_store_test_suite.ts +92 -17
  37. package/src/archiver/data_retrieval.ts +13 -4
  38. package/src/archiver/epoch_helpers.ts +30 -6
  39. package/src/archiver/instrumentation.ts +22 -0
  40. package/src/archiver/kv_archiver_store/block_store.ts +22 -10
  41. package/src/archiver/kv_archiver_store/kv_archiver_store.ts +27 -3
  42. package/src/archiver/kv_archiver_store/nullifier_store.ts +78 -0
  43. package/src/archiver/memory_archiver_store/memory_archiver_store.ts +59 -5
  44. package/src/factory.ts +21 -3
  45. package/src/test/mock_l2_block_source.ts +8 -2
package/src/factory.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import { type ArchiverApi, type Service } from '@aztec/circuit-types';
2
- import { type ContractClassPublic } from '@aztec/circuits.js';
2
+ import { type ContractClassPublic, getContractClassFromArtifact } from '@aztec/circuits.js';
3
3
  import { createDebugLogger } from '@aztec/foundation/log';
4
4
  import { type Maybe } from '@aztec/foundation/types';
5
5
  import { type DataStoreConfig } from '@aztec/kv-store/config';
6
6
  import { createStore } from '@aztec/kv-store/utils';
7
+ import { TokenBridgeContractArtifact, TokenContractArtifact } from '@aztec/noir-contracts.js';
7
8
  import { getCanonicalProtocolContract, protocolContractNames } from '@aztec/protocol-contracts';
8
9
  import { type TelemetryClient } from '@aztec/telemetry-client';
9
10
  import { NoopTelemetryClient } from '@aztec/telemetry-client/noop';
@@ -21,14 +22,15 @@ export async function createArchiver(
21
22
  if (!config.archiverUrl) {
22
23
  const store = await createStore('archiver', config, createDebugLogger('aztec:archiver:lmdb'));
23
24
  const archiverStore = new KVArchiverDataStore(store, config.maxLogs);
24
- await initWithProtocolContracts(archiverStore);
25
+ await registerProtocolContracts(archiverStore);
26
+ await registerCommonContracts(archiverStore);
25
27
  return Archiver.createAndSync(config, archiverStore, telemetry, opts.blockUntilSync);
26
28
  } else {
27
29
  return createArchiverClient(config.archiverUrl);
28
30
  }
29
31
  }
30
32
 
31
- async function initWithProtocolContracts(store: KVArchiverDataStore) {
33
+ async function registerProtocolContracts(store: KVArchiverDataStore) {
32
34
  const blockNumber = 0;
33
35
  for (const name of protocolContractNames) {
34
36
  const contract = getCanonicalProtocolContract(name);
@@ -42,3 +44,19 @@ async function initWithProtocolContracts(store: KVArchiverDataStore) {
42
44
  await store.addContractInstances([contract.instance], blockNumber);
43
45
  }
44
46
  }
47
+
48
+ // TODO(#10007): Remove this method. We are explicitly registering these contracts
49
+ // here to ensure they are available to all nodes and all prover nodes, since the PXE
50
+ // was tweaked to automatically push contract classes to the node it is registered,
51
+ // but other nodes in the network may require the contract classes to be registered as well.
52
+ // TODO(#10007): Remove the dependency on noir-contracts.js from this package once we remove this.
53
+ async function registerCommonContracts(store: KVArchiverDataStore) {
54
+ const blockNumber = 0;
55
+ const artifacts = [TokenBridgeContractArtifact, TokenContractArtifact];
56
+ const classes = artifacts.map(artifact => ({
57
+ ...getContractClassFromArtifact(artifact),
58
+ privateFunctions: [],
59
+ unconstrainedFunctions: [],
60
+ }));
61
+ await store.addContractClasses(classes, blockNumber);
62
+ }
@@ -119,8 +119,14 @@ export class MockL2BlockSource implements L2BlockSource {
119
119
  * @returns The requested tx effect.
120
120
  */
121
121
  public getTxEffect(txHash: TxHash) {
122
- const txEffect = this.l2Blocks.flatMap(b => b.body.txEffects).find(tx => tx.txHash.equals(txHash));
123
- return Promise.resolve(txEffect);
122
+ const match = this.l2Blocks
123
+ .flatMap(b => b.body.txEffects.map(tx => [tx, b] as const))
124
+ .find(([tx]) => tx.txHash.equals(txHash));
125
+ if (!match) {
126
+ return Promise.resolve(undefined);
127
+ }
128
+ const [txEffect, block] = match;
129
+ return Promise.resolve({ data: txEffect, l2BlockNumber: block.number, l2BlockHash: block.hash().toString() });
124
130
  }
125
131
 
126
132
  /**