@aztec/archiver 0.28.0 → 0.29.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 (52) hide show
  1. package/dest/archiver/archiver.d.ts +13 -53
  2. package/dest/archiver/archiver.d.ts.map +1 -1
  3. package/dest/archiver/archiver.js +42 -180
  4. package/dest/archiver/archiver_store.d.ts +17 -63
  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 +26 -168
  8. package/dest/archiver/data_retrieval.d.ts +5 -26
  9. package/dest/archiver/data_retrieval.d.ts.map +1 -1
  10. package/dest/archiver/data_retrieval.js +10 -64
  11. package/dest/archiver/eth_log_handlers.d.ts +5 -36
  12. package/dest/archiver/eth_log_handlers.d.ts.map +1 -1
  13. package/dest/archiver/eth_log_handlers.js +7 -75
  14. package/dest/archiver/kv_archiver_store/block_store.d.ts +2 -2
  15. package/dest/archiver/kv_archiver_store/block_store.d.ts.map +1 -1
  16. package/dest/archiver/kv_archiver_store/block_store.js +3 -3
  17. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +11 -52
  18. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
  19. package/dest/archiver/kv_archiver_store/kv_archiver_store.js +21 -84
  20. package/dest/archiver/kv_archiver_store/message_store.d.ts +10 -41
  21. package/dest/archiver/kv_archiver_store/message_store.d.ts.map +1 -1
  22. package/dest/archiver/kv_archiver_store/message_store.js +31 -136
  23. package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts +8 -41
  24. package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts.map +1 -1
  25. package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.js +22 -79
  26. package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts +14 -76
  27. package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts.map +1 -1
  28. package/dest/archiver/memory_archiver_store/memory_archiver_store.js +22 -134
  29. package/dest/index.d.ts.map +1 -1
  30. package/dest/index.js +3 -15
  31. package/dest/rpc/archiver_client.d.ts.map +1 -1
  32. package/dest/rpc/archiver_client.js +2 -6
  33. package/dest/rpc/archiver_server.d.ts.map +1 -1
  34. package/dest/rpc/archiver_server.js +2 -6
  35. package/package.json +9 -9
  36. package/src/archiver/archiver.ts +47 -230
  37. package/src/archiver/archiver_store.ts +17 -72
  38. package/src/archiver/archiver_store_test_suite.ts +25 -208
  39. package/src/archiver/data_retrieval.ts +11 -93
  40. package/src/archiver/eth_log_handlers.ts +10 -104
  41. package/src/archiver/kv_archiver_store/block_store.ts +2 -2
  42. package/src/archiver/kv_archiver_store/kv_archiver_store.ts +19 -89
  43. package/src/archiver/kv_archiver_store/message_store.ts +36 -165
  44. package/src/archiver/memory_archiver_store/l1_to_l2_message_store.ts +21 -90
  45. package/src/archiver/memory_archiver_store/memory_archiver_store.ts +23 -150
  46. package/src/index.ts +1 -15
  47. package/src/rpc/archiver_client.ts +0 -8
  48. package/src/rpc/archiver_server.ts +0 -8
  49. package/dest/archiver/kv_archiver_store/contract_store.d.ts +0 -26
  50. package/dest/archiver/kv_archiver_store/contract_store.d.ts.map +0 -1
  51. package/dest/archiver/kv_archiver_store/contract_store.js +0 -49
  52. package/src/archiver/kv_archiver_store/contract_store.ts +0 -55
@@ -1,15 +1,11 @@
1
- import { ContractData, EncodedContractFunction, ExtendedContractData, ExtendedUnencryptedL2Log, L1ToL2Message, L2Block, L2BlockL2Logs, NullifierMembershipWitness, TxReceipt, } from '@aztec/circuit-types';
1
+ import { ExtendedUnencryptedL2Log, L2Block, L2BlockL2Logs, NullifierMembershipWitness, TxReceipt, } from '@aztec/circuit-types';
2
2
  import { EthAddress, Fr } from '@aztec/circuits.js';
3
3
  import { createJsonRpcClient, makeFetch } from '@aztec/foundation/json-rpc/client';
4
4
  export const createArchiverClient = (url, fetch = makeFetch([1, 2, 3], true)) => createJsonRpcClient(url, {
5
- ContractData,
6
- EncodedContractFunction,
7
5
  EthAddress,
8
- ExtendedContractData,
9
6
  ExtendedUnencryptedL2Log,
10
7
  Fr,
11
- L1ToL2Message,
12
8
  L2Block,
13
9
  L2BlockL2Logs,
14
10
  }, { TxReceipt, NullifierMembershipWitness }, false, 'archiver', fetch);
15
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXJjaGl2ZXJfY2xpZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3JwYy9hcmNoaXZlcl9jbGllbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUNMLFlBQVksRUFDWix1QkFBdUIsRUFDdkIsb0JBQW9CLEVBQ3BCLHdCQUF3QixFQUN4QixhQUFhLEVBQ2IsT0FBTyxFQUNQLGFBQWEsRUFDYiwwQkFBMEIsRUFDMUIsU0FBUyxHQUNWLE1BQU0sc0JBQXNCLENBQUM7QUFDOUIsT0FBTyxFQUFFLFVBQVUsRUFBRSxFQUFFLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUNwRCxPQUFPLEVBQUUsbUJBQW1CLEVBQUUsU0FBUyxFQUFFLE1BQU0sbUNBQW1DLENBQUM7QUFJbkYsTUFBTSxDQUFDLE1BQU0sb0JBQW9CLEdBQUcsQ0FBQyxHQUFXLEVBQUUsS0FBSyxHQUFHLFNBQVMsQ0FBQyxDQUFDLENBQUMsRUFBRSxDQUFDLEVBQUUsQ0FBQyxDQUFDLEVBQUUsSUFBSSxDQUFDLEVBQWlCLEVBQUUsQ0FDckcsbUJBQW1CLENBQ2pCLEdBQUcsRUFDSDtJQUNFLFlBQVk7SUFDWix1QkFBdUI7SUFDdkIsVUFBVTtJQUNWLG9CQUFvQjtJQUNwQix3QkFBd0I7SUFDeEIsRUFBRTtJQUNGLGFBQWE7SUFDYixPQUFPO0lBQ1AsYUFBYTtDQUNkLEVBQ0QsRUFBRSxTQUFTLEVBQUUsMEJBQTBCLEVBQUUsRUFDekMsS0FBSyxFQUNMLFVBQVUsRUFDVixLQUFLLENBQ04sQ0FBQyJ9
11
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXJjaGl2ZXJfY2xpZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3JwYy9hcmNoaXZlcl9jbGllbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUNMLHdCQUF3QixFQUN4QixPQUFPLEVBQ1AsYUFBYSxFQUNiLDBCQUEwQixFQUMxQixTQUFTLEdBQ1YsTUFBTSxzQkFBc0IsQ0FBQztBQUM5QixPQUFPLEVBQUUsVUFBVSxFQUFFLEVBQUUsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBQ3BELE9BQU8sRUFBRSxtQkFBbUIsRUFBRSxTQUFTLEVBQUUsTUFBTSxtQ0FBbUMsQ0FBQztBQUluRixNQUFNLENBQUMsTUFBTSxvQkFBb0IsR0FBRyxDQUFDLEdBQVcsRUFBRSxLQUFLLEdBQUcsU0FBUyxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUMsRUFBRSxDQUFDLENBQUMsRUFBRSxJQUFJLENBQUMsRUFBaUIsRUFBRSxDQUNyRyxtQkFBbUIsQ0FDakIsR0FBRyxFQUNIO0lBQ0UsVUFBVTtJQUNWLHdCQUF3QjtJQUN4QixFQUFFO0lBQ0YsT0FBTztJQUNQLGFBQWE7Q0FDZCxFQUNELEVBQUUsU0FBUyxFQUFFLDBCQUEwQixFQUFFLEVBQ3pDLEtBQUssRUFDTCxVQUFVLEVBQ1YsS0FBSyxDQUNOLENBQUMifQ==
@@ -1 +1 @@
1
- {"version":3,"file":"archiver_server.d.ts","sourceRoot":"","sources":["../../src/rpc/archiver_server.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAElE,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEnD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,eAAe,EAAE,QAAQ,GAAG,aAAa,CAkBhF"}
1
+ {"version":3,"file":"archiver_server.d.ts","sourceRoot":"","sources":["../../src/rpc/archiver_server.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAElE,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEnD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,eAAe,EAAE,QAAQ,GAAG,aAAa,CAchF"}
@@ -1,4 +1,4 @@
1
- import { ContractData, EncodedContractFunction, ExtendedContractData, ExtendedUnencryptedL2Log, L1ToL2Message, L2Block, L2BlockL2Logs, NullifierMembershipWitness, TxEffect, TxReceipt, } from '@aztec/circuit-types';
1
+ import { ExtendedUnencryptedL2Log, L2Block, L2BlockL2Logs, NullifierMembershipWitness, TxEffect, TxReceipt, } from '@aztec/circuit-types';
2
2
  import { EthAddress, Fr } from '@aztec/circuits.js';
3
3
  import { JsonRpcServer } from '@aztec/foundation/json-rpc/server';
4
4
  /**
@@ -8,16 +8,12 @@ import { JsonRpcServer } from '@aztec/foundation/json-rpc/server';
8
8
  */
9
9
  export function createArchiverRpcServer(archiverService) {
10
10
  return new JsonRpcServer(archiverService, {
11
- ContractData,
12
- EncodedContractFunction,
13
11
  EthAddress,
14
- ExtendedContractData,
15
12
  ExtendedUnencryptedL2Log,
16
13
  Fr,
17
- L1ToL2Message,
18
14
  L2Block,
19
15
  L2BlockL2Logs,
20
16
  TxEffect,
21
17
  }, { TxReceipt, NullifierMembershipWitness }, ['start', 'stop']);
22
18
  }
23
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXJjaGl2ZXJfc2VydmVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3JwYy9hcmNoaXZlcl9zZXJ2ZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUNMLFlBQVksRUFDWix1QkFBdUIsRUFDdkIsb0JBQW9CLEVBQ3BCLHdCQUF3QixFQUN4QixhQUFhLEVBQ2IsT0FBTyxFQUNQLGFBQWEsRUFDYiwwQkFBMEIsRUFDMUIsUUFBUSxFQUNSLFNBQVMsR0FDVixNQUFNLHNCQUFzQixDQUFDO0FBQzlCLE9BQU8sRUFBRSxVQUFVLEVBQUUsRUFBRSxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFDcEQsT0FBTyxFQUFFLGFBQWEsRUFBRSxNQUFNLG1DQUFtQyxDQUFDO0FBSWxFOzs7O0dBSUc7QUFDSCxNQUFNLFVBQVUsdUJBQXVCLENBQUMsZUFBeUI7SUFDL0QsT0FBTyxJQUFJLGFBQWEsQ0FDdEIsZUFBZSxFQUNmO1FBQ0UsWUFBWTtRQUNaLHVCQUF1QjtRQUN2QixVQUFVO1FBQ1Ysb0JBQW9CO1FBQ3BCLHdCQUF3QjtRQUN4QixFQUFFO1FBQ0YsYUFBYTtRQUNiLE9BQU87UUFDUCxhQUFhO1FBQ2IsUUFBUTtLQUNULEVBQ0QsRUFBRSxTQUFTLEVBQUUsMEJBQTBCLEVBQUUsRUFDekMsQ0FBQyxPQUFPLEVBQUUsTUFBTSxDQUFDLENBQ2xCLENBQUM7QUFDSixDQUFDIn0=
19
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXJjaGl2ZXJfc2VydmVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3JwYy9hcmNoaXZlcl9zZXJ2ZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUNMLHdCQUF3QixFQUN4QixPQUFPLEVBQ1AsYUFBYSxFQUNiLDBCQUEwQixFQUMxQixRQUFRLEVBQ1IsU0FBUyxHQUNWLE1BQU0sc0JBQXNCLENBQUM7QUFDOUIsT0FBTyxFQUFFLFVBQVUsRUFBRSxFQUFFLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUNwRCxPQUFPLEVBQUUsYUFBYSxFQUFFLE1BQU0sbUNBQW1DLENBQUM7QUFJbEU7Ozs7R0FJRztBQUNILE1BQU0sVUFBVSx1QkFBdUIsQ0FBQyxlQUF5QjtJQUMvRCxPQUFPLElBQUksYUFBYSxDQUN0QixlQUFlLEVBQ2Y7UUFDRSxVQUFVO1FBQ1Ysd0JBQXdCO1FBQ3hCLEVBQUU7UUFDRixPQUFPO1FBQ1AsYUFBYTtRQUNiLFFBQVE7S0FDVCxFQUNELEVBQUUsU0FBUyxFQUFFLDBCQUEwQixFQUFFLEVBQ3pDLENBQUMsT0FBTyxFQUFFLE1BQU0sQ0FBQyxDQUNsQixDQUFDO0FBQ0osQ0FBQyJ9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/archiver",
3
- "version": "0.28.0",
3
+ "version": "0.29.0",
4
4
  "type": "module",
5
5
  "exports": "./dest/index.js",
6
6
  "typedocOptions": {
@@ -35,14 +35,14 @@
35
35
  "workerThreads": true
36
36
  },
37
37
  "dependencies": {
38
- "@aztec/circuit-types": "0.28.0",
39
- "@aztec/circuits.js": "0.28.0",
40
- "@aztec/ethereum": "0.28.0",
41
- "@aztec/foundation": "0.28.0",
42
- "@aztec/kv-store": "0.28.0",
43
- "@aztec/l1-artifacts": "0.28.0",
44
- "@aztec/protocol-contracts": "0.28.0",
45
- "@aztec/types": "0.28.0",
38
+ "@aztec/circuit-types": "0.29.0",
39
+ "@aztec/circuits.js": "0.29.0",
40
+ "@aztec/ethereum": "0.29.0",
41
+ "@aztec/foundation": "0.29.0",
42
+ "@aztec/kv-store": "0.29.0",
43
+ "@aztec/l1-artifacts": "0.29.0",
44
+ "@aztec/protocol-contracts": "0.29.0",
45
+ "@aztec/types": "0.29.0",
46
46
  "debug": "^4.3.4",
47
47
  "lmdb": "^2.9.2",
48
48
  "lodash.omit": "^4.5.0",
@@ -1,10 +1,5 @@
1
1
  import {
2
- ContractData,
3
- ContractDataSource,
4
- EncodedContractFunction,
5
- ExtendedContractData,
6
2
  GetUnencryptedLogsResponse,
7
- L1ToL2Message,
8
3
  L1ToL2MessageSource,
9
4
  L2Block,
10
5
  L2BlockL2Logs,
@@ -25,26 +20,22 @@ import { EthAddress } from '@aztec/foundation/eth-address';
25
20
  import { Fr } from '@aztec/foundation/fields';
26
21
  import { DebugLogger, createDebugLogger } from '@aztec/foundation/log';
27
22
  import { RunningPromise } from '@aztec/foundation/running-promise';
28
- import { RollupAbi } from '@aztec/l1-artifacts';
29
23
  import { ClassRegistererAddress } from '@aztec/protocol-contracts/class-registerer';
30
- import { InstanceDeployerAddress } from '@aztec/protocol-contracts/instance-deployer';
31
24
  import {
32
- ContractClass,
33
25
  ContractClassPublic,
34
- ContractInstance,
26
+ ContractDataSource,
35
27
  ContractInstanceWithAddress,
28
+ PublicFunction,
36
29
  } from '@aztec/types/contracts';
37
30
 
38
- import { Chain, HttpTransport, PublicClient, createPublicClient, getAddress, getContract, http } from 'viem';
31
+ import { Chain, HttpTransport, PublicClient, createPublicClient, http } from 'viem';
39
32
 
40
33
  import { ArchiverDataStore } from './archiver_store.js';
41
34
  import { ArchiverConfig } from './config.js';
42
35
  import {
43
36
  retrieveBlockBodiesFromAvailabilityOracle,
44
37
  retrieveBlockMetadataFromRollup,
45
- retrieveNewCancelledL1ToL2Messages,
46
- retrieveNewL1ToL2Messages,
47
- retrieveNewPendingL1ToL2Messages,
38
+ retrieveL1ToL2Messages,
48
39
  } from './data_retrieval.js';
49
40
 
50
41
  /**
@@ -73,7 +64,6 @@ export class Archiver implements ArchiveSource {
73
64
  * @param publicClient - A client for interacting with the Ethereum node.
74
65
  * @param rollupAddress - Ethereum address of the rollup contract.
75
66
  * @param inboxAddress - Ethereum address of the inbox contract.
76
- * @param newInboxAddress - Ethereum address of the new inbox contract.
77
67
  * @param registryAddress - Ethereum address of the registry contract.
78
68
  * @param pollingIntervalMs - The interval for polling for L1 logs (in milliseconds).
79
69
  * @param store - An archiver data store for storage & retrieval of blocks, encrypted logs & contract data.
@@ -84,7 +74,6 @@ export class Archiver implements ArchiveSource {
84
74
  private readonly rollupAddress: EthAddress,
85
75
  private readonly availabilityOracleAddress: EthAddress,
86
76
  private readonly inboxAddress: EthAddress,
87
- private readonly newInboxAddress: EthAddress,
88
77
  private readonly registryAddress: EthAddress,
89
78
  private readonly store: ArchiverDataStore,
90
79
  private readonly pollingIntervalMs = 10_000,
@@ -110,23 +99,11 @@ export class Archiver implements ArchiveSource {
110
99
  pollingInterval: config.viemPollingIntervalMS,
111
100
  });
112
101
 
113
- // TODO(#4492): Nuke this once the old inbox is purged
114
- let newInboxAddress!: EthAddress;
115
- {
116
- const rollup = getContract({
117
- address: getAddress(config.l1Contracts.rollupAddress.toString()),
118
- abi: RollupAbi,
119
- client: publicClient,
120
- });
121
- newInboxAddress = EthAddress.fromString(await rollup.read.NEW_INBOX());
122
- }
123
-
124
102
  const archiver = new Archiver(
125
103
  publicClient,
126
104
  config.l1Contracts.rollupAddress,
127
105
  config.l1Contracts.availabilityOracleAddress,
128
106
  config.l1Contracts.inboxAddress,
129
- newInboxAddress,
130
107
  config.l1Contracts.registryAddress,
131
108
  archiverStore,
132
109
  config.archiverPollingIntervalMS,
@@ -170,15 +147,10 @@ export class Archiver implements ArchiveSource {
170
147
  *
171
148
  * This code does not handle reorgs.
172
149
  */
173
- const lastL1Blocks = await this.store.getL1BlockNumber();
150
+ const lastL1Blocks = await this.store.getSynchedL1BlockNumbers();
174
151
  const currentL1BlockNumber = await this.publicClient.getBlockNumber();
175
152
 
176
- if (
177
- currentL1BlockNumber <= lastL1Blocks.addedBlock &&
178
- currentL1BlockNumber <= lastL1Blocks.newMessages &&
179
- currentL1BlockNumber <= lastL1Blocks.addedMessages &&
180
- currentL1BlockNumber <= lastL1Blocks.cancelledMessages
181
- ) {
153
+ if (currentL1BlockNumber <= lastL1Blocks.blocks && currentL1BlockNumber <= lastL1Blocks.messages) {
182
154
  // chain hasn't moved forward
183
155
  // or it's been rolled back
184
156
  return;
@@ -205,72 +177,39 @@ export class Archiver implements ArchiveSource {
205
177
 
206
178
  // ********** Events that are processed per L1 block **********
207
179
 
208
- // TODO(#4492): Nuke the following when purging the old inbox
209
- // Process l1ToL2Messages, these are consumed as time passes, not each block
210
- const retrievedPendingL1ToL2Messages = await retrieveNewPendingL1ToL2Messages(
211
- this.publicClient,
212
- this.inboxAddress,
213
- blockUntilSynced,
214
- lastL1Blocks.addedMessages + 1n,
215
- currentL1BlockNumber,
216
- );
217
- const retrievedCancelledL1ToL2Messages = await retrieveNewCancelledL1ToL2Messages(
180
+ // ********** Events that are processed per L2 block **********
181
+
182
+ const retrievedL1ToL2Messages = await retrieveL1ToL2Messages(
218
183
  this.publicClient,
219
184
  this.inboxAddress,
220
185
  blockUntilSynced,
221
- lastL1Blocks.cancelledMessages + 1n,
186
+ lastL1Blocks.messages + 1n,
222
187
  currentL1BlockNumber,
223
188
  );
224
189
 
225
- // group pending messages and cancelled messages by their L1 block number
226
- const messagesByBlock = new Map<bigint, [L1ToL2Message[], Fr[]]>();
227
- for (const [message, blockNumber] of retrievedPendingL1ToL2Messages.retrievedData) {
228
- const messages = messagesByBlock.get(blockNumber) || [[], []];
229
- messages[0].push(message);
230
- messagesByBlock.set(blockNumber, messages);
231
- }
232
-
233
- for (const [entryKey, blockNumber] of retrievedCancelledL1ToL2Messages.retrievedData) {
234
- const messages = messagesByBlock.get(blockNumber) || [[], []];
235
- messages[1].push(entryKey);
236
- messagesByBlock.set(blockNumber, messages);
237
- }
238
-
239
- // process messages from each L1 block in sequence
240
- const l1BlocksWithMessages = Array.from(messagesByBlock.keys()).sort((a, b) => (a < b ? -1 : a === b ? 0 : 1));
241
- for (const l1Block of l1BlocksWithMessages) {
242
- const [newMessages, cancelledMessages] = messagesByBlock.get(l1Block)!;
190
+ if (retrievedL1ToL2Messages.retrievedData.length !== 0) {
243
191
  this.log(
244
- `Adding ${newMessages.length} new messages and ${cancelledMessages.length} cancelled messages in L1 block ${l1Block}`,
192
+ `Retrieved ${retrievedL1ToL2Messages.retrievedData.length} new L1 -> L2 messages between L1 blocks ${
193
+ lastL1Blocks.messages + 1n
194
+ } and ${currentL1BlockNumber}.`,
245
195
  );
246
- await this.store.addPendingL1ToL2Messages(newMessages, l1Block);
247
- await this.store.cancelPendingL1ToL2EntryKeys(cancelledMessages, l1Block);
248
196
  }
249
197
 
250
- // ********** Events that are processed per L2 block **********
251
-
252
- const retrievedNewL1ToL2Messages = await retrieveNewL1ToL2Messages(
253
- this.publicClient,
254
- this.newInboxAddress,
255
- blockUntilSynced,
256
- lastL1Blocks.newMessages + 1n,
257
- currentL1BlockNumber,
258
- );
259
- await this.store.addNewL1ToL2Messages(
260
- retrievedNewL1ToL2Messages.retrievedData,
198
+ await this.store.addL1ToL2Messages(
199
+ retrievedL1ToL2Messages.retrievedData,
261
200
  // -1n because the function expects the last block in which the message was emitted and not the one after next
262
- // TODO(#4492): Check whether this could be cleaned up - `nextEthBlockNumber` value doesn't seem to be used much
263
- retrievedNewL1ToL2Messages.nextEthBlockNumber - 1n,
201
+ // TODO(#5264): Check whether this could be cleaned up - `nextEthBlockNumber` value doesn't seem to be used much
202
+ retrievedL1ToL2Messages.nextEthBlockNumber - 1n,
264
203
  );
265
204
 
266
205
  // Read all data from chain and then write to our stores at the end
267
- const nextExpectedL2BlockNum = BigInt((await this.store.getBlockNumber()) + 1);
206
+ const nextExpectedL2BlockNum = BigInt((await this.store.getSynchedL2BlockNumber()) + 1);
268
207
 
269
208
  const retrievedBlockBodies = await retrieveBlockBodiesFromAvailabilityOracle(
270
209
  this.publicClient,
271
210
  this.availabilityOracleAddress,
272
211
  blockUntilSynced,
273
- lastL1Blocks.addedBlock + 1n,
212
+ lastL1Blocks.blocks + 1n,
274
213
  currentL1BlockNumber,
275
214
  );
276
215
 
@@ -282,7 +221,7 @@ export class Archiver implements ArchiveSource {
282
221
  this.publicClient,
283
222
  this.rollupAddress,
284
223
  blockUntilSynced,
285
- lastL1Blocks.addedBlock + 1n,
224
+ lastL1Blocks.blocks + 1n,
286
225
  currentL1BlockNumber,
287
226
  nextExpectedL2BlockNum,
288
227
  );
@@ -309,7 +248,7 @@ export class Archiver implements ArchiveSource {
309
248
  } else {
310
249
  this.log(
311
250
  `Retrieved ${retrievedBlocks.retrievedData.length} new L2 blocks between L1 blocks ${
312
- lastL1Blocks.addedBlock + 1n
251
+ lastL1Blocks.blocks + 1n
313
252
  } and ${currentL1BlockNumber}.`,
314
253
  );
315
254
  }
@@ -320,8 +259,6 @@ export class Archiver implements ArchiveSource {
320
259
  blockNumberToBodyHash[block.number] = block.header.contentCommitment.txsEffectsHash;
321
260
  });
322
261
 
323
- this.log(`Retrieved ${retrievedBlocks.retrievedData.length} block(s) from chain`);
324
-
325
262
  await Promise.all(
326
263
  retrievedBlocks.retrievedData.map(block => {
327
264
  const encryptedLogs = block.body.encryptedLogs;
@@ -343,13 +280,6 @@ export class Archiver implements ArchiveSource {
343
280
  }),
344
281
  );
345
282
 
346
- // from retrieved L2Blocks, confirm L1 to L2 messages that have been published
347
- // from each l2block fetch all entryKeys in a flattened array:
348
- this.log(`Confirming l1 to l2 messages in store`);
349
- for (const block of retrievedBlocks.retrievedData) {
350
- await this.store.confirmL1ToL2EntryKeys(block.body.l1ToL2Messages);
351
- }
352
-
353
283
  await this.store.addBlocks(retrievedBlocks.retrievedData);
354
284
  }
355
285
 
@@ -372,34 +302,13 @@ export class Archiver implements ArchiveSource {
372
302
  * @param allLogs - All logs emitted in a bunch of blocks.
373
303
  */
374
304
  private async storeDeployedContractInstances(allLogs: UnencryptedL2Log[], blockNum: number) {
375
- const contractInstances = ContractInstanceDeployedEvent.fromLogs(allLogs, InstanceDeployerAddress).map(e =>
376
- e.toContractInstance(),
377
- );
305
+ const contractInstances = ContractInstanceDeployedEvent.fromLogs(allLogs).map(e => e.toContractInstance());
378
306
  if (contractInstances.length > 0) {
379
307
  contractInstances.forEach(c => this.log(`Storing contract instance at ${c.address.toString()}`));
380
308
  await this.store.addContractInstances(contractInstances, blockNum);
381
309
  }
382
310
  }
383
311
 
384
- /**
385
- * Stores extended contract data as classes and instances.
386
- * Temporary solution until we source this data from the contract class registerer and instance deployer.
387
- * @param contracts - The extended contract data to be stored.
388
- * @param l2BlockNum - The L2 block number to which the contract data corresponds.
389
- * TODO(palla/purge-old-contract-deploy): Delete this method
390
- */
391
- async storeContractDataAsClassesAndInstances(contracts: ExtendedContractData[], l2BlockNum: number) {
392
- const classesAndInstances = contracts.map(extendedContractDataToContractClassAndInstance);
393
- await this.store.addContractClasses(
394
- classesAndInstances.map(([c, _]) => c),
395
- l2BlockNum,
396
- );
397
- await this.store.addContractInstances(
398
- classesAndInstances.map(([_, i]) => i),
399
- l2BlockNum,
400
- );
401
- }
402
-
403
312
  /**
404
313
  * Stops the archiver.
405
314
  * @returns A promise signalling completion of the stop process.
@@ -438,7 +347,7 @@ export class Archiver implements ArchiveSource {
438
347
  public async getBlock(number: number): Promise<L2Block | undefined> {
439
348
  // If the number provided is -ve, then return the latest block.
440
349
  if (number < 0) {
441
- number = await this.store.getBlockNumber();
350
+ number = await this.store.getSynchedL2BlockNumber();
442
351
  }
443
352
  const blocks = await this.store.getBlocks(number, 1);
444
353
  return blocks.length === 0 ? undefined : blocks[0];
@@ -452,72 +361,25 @@ export class Archiver implements ArchiveSource {
452
361
  return this.store.getSettledTxReceipt(txHash);
453
362
  }
454
363
 
455
- /**
456
- * Get the extended contract data for this contract.
457
- * @param contractAddress - The contract data address.
458
- * @returns The extended contract data or undefined if not found.
459
- */
460
- public async getExtendedContractData(contractAddress: AztecAddress): Promise<ExtendedContractData | undefined> {
461
- return (
462
- (await this.store.getExtendedContractData(contractAddress)) ?? this.makeExtendedContractDataFor(contractAddress)
463
- );
464
- }
465
-
466
- /**
467
- * Temporary method for creating a fake extended contract data out of classes and instances registered in the node.
468
- * Used as a fallback if the extended contract data is not found.
469
- * TODO(palla/purge-old-contract-deploy): Use proper classes
470
- */
471
- private async makeExtendedContractDataFor(address: AztecAddress): Promise<ExtendedContractData | undefined> {
472
- const instance = await this.store.getContractInstance(address);
473
- if (!instance) {
474
- return undefined;
475
- }
476
-
477
- const contractClass = await this.store.getContractClass(instance.contractClassId);
478
- if (!contractClass) {
479
- this.log.warn(`Class ${instance.contractClassId.toString()} for address ${address.toString()} not found`);
480
- return undefined;
481
- }
482
-
483
- return ExtendedContractData.fromClassAndInstance(contractClass, instance);
484
- }
485
-
486
- /**
487
- * Lookup the contract data for this contract.
488
- * Contains contract address & the ethereum portal address.
489
- * @param contractAddress - The contract data address.
490
- * @returns ContractData with the portal address (if we didn't throw an error).
491
- */
492
- public getContractData(contractAddress: AztecAddress): Promise<ContractData | undefined> {
493
- return this.makeContractDataFor(contractAddress);
494
- }
495
-
496
- /**
497
- * Temporary method for creating a fake contract data out of classes and instances registered in the node.
498
- * Used as a fallback if the extended contract data is not found.
499
- */
500
- private async makeContractDataFor(address: AztecAddress): Promise<ContractData | undefined> {
501
- const instance = await this.store.getContractInstance(address);
502
- if (!instance) {
503
- return undefined;
504
- }
505
-
506
- return new ContractData(address, instance.portalContractAddress);
507
- }
508
-
509
364
  /**
510
365
  * Gets the public function data for a contract.
511
- * @param contractAddress - The contract address containing the function to fetch.
366
+ * @param address - The contract address containing the function to fetch.
512
367
  * @param selector - The function selector of the function to fetch.
513
368
  * @returns The public function data (if found).
514
369
  */
515
370
  public async getPublicFunction(
516
- contractAddress: AztecAddress,
371
+ address: AztecAddress,
517
372
  selector: FunctionSelector,
518
- ): Promise<EncodedContractFunction | undefined> {
519
- const contractData = await this.getExtendedContractData(contractAddress);
520
- return contractData?.getPublicFunction(selector);
373
+ ): Promise<PublicFunction | undefined> {
374
+ const instance = await this.getContract(address);
375
+ if (!instance) {
376
+ throw new Error(`Contract ${address.toString()} not found`);
377
+ }
378
+ const contractClass = await this.getContractClass(instance.contractClassId);
379
+ if (!contractClass) {
380
+ throw new Error(`Contract class ${instance.contractClassId.toString()} for ${address.toString()} not found`);
381
+ }
382
+ return contractClass.publicFunctions.find(f => f.selector.equals(selector));
521
383
  }
522
384
 
523
385
  /**
@@ -545,7 +407,7 @@ export class Archiver implements ArchiveSource {
545
407
  * @returns The number of the latest L2 block processed by the block source implementation.
546
408
  */
547
409
  public getBlockNumber(): Promise<number> {
548
- return this.store.getBlockNumber();
410
+ return this.store.getSynchedL2BlockNumber();
549
411
  }
550
412
 
551
413
  public getContractClass(id: Fr): Promise<ContractClassPublic | undefined> {
@@ -557,69 +419,24 @@ export class Archiver implements ArchiveSource {
557
419
  }
558
420
 
559
421
  /**
560
- * Gets up to `limit` amount of pending L1 to L2 messages.
561
- * @param limit - The number of messages to return.
562
- * @returns The requested L1 to L2 messages' keys.
563
- */
564
- getPendingL1ToL2EntryKeys(limit: number): Promise<Fr[]> {
565
- return this.store.getPendingL1ToL2EntryKeys(limit);
566
- }
567
-
568
- /**
569
- * Gets the confirmed/consumed L1 to L2 message associated with the given entry key
570
- * @param entryKey - The entry key.
571
- * @returns The L1 to L2 message (throws if not found).
422
+ * Gets L1 to L2 message (to be) included in a given block.
423
+ * @param blockNumber - L2 block number to get messages for.
424
+ * @returns The L1 to L2 messages/leaves of the messages subtree (throws if not found).
572
425
  */
573
- getConfirmedL1ToL2Message(entryKey: Fr): Promise<L1ToL2Message> {
574
- return this.store.getConfirmedL1ToL2Message(entryKey);
426
+ getL1ToL2Messages(blockNumber: bigint): Promise<Fr[]> {
427
+ return this.store.getL1ToL2Messages(blockNumber);
575
428
  }
576
429
 
577
430
  /**
578
- * Gets new L1 to L2 message (to be) included in a given block.
579
- * @param blockNumber - L2 block number to get messages for.
580
- * @returns The L1 to L2 messages/leaves of the messages subtree (throws if not found).
431
+ * Gets the L1 to L2 message index in the L1 to L2 message tree.
432
+ * @param l1ToL2Message - The L1 to L2 message.
433
+ * @returns The index of the L1 to L2 message in the L1 to L2 message tree.
581
434
  */
582
- getNewL1ToL2Messages(blockNumber: bigint): Promise<Fr[]> {
583
- return this.store.getNewL1ToL2Messages(blockNumber);
435
+ getL1ToL2MessageIndex(l1ToL2Message: Fr): Promise<bigint> {
436
+ return this.store.getL1ToL2MessageIndex(l1ToL2Message);
584
437
  }
585
438
 
586
439
  getContractClassIds(): Promise<Fr[]> {
587
440
  return this.store.getContractClassIds();
588
441
  }
589
442
  }
590
-
591
- /**
592
- * Converts ExtendedContractData into contract classes and instances.
593
- * Note that the conversion is not correct, since there is some data missing from the broadcasted ExtendedContractData.
594
- * The archiver will trust the ids broadcasted instead of trying to recompute them.
595
- * Eventually this function and ExtendedContractData altogether will be removed.
596
- */
597
- function extendedContractDataToContractClassAndInstance(
598
- data: ExtendedContractData,
599
- ): [ContractClassPublic, ContractInstanceWithAddress] {
600
- const contractClass: ContractClass = {
601
- version: 1,
602
- artifactHash: Fr.ZERO,
603
- publicFunctions: data.publicFunctions.map(f => ({
604
- selector: f.selector,
605
- bytecode: f.bytecode,
606
- isInternal: f.isInternal,
607
- })),
608
- privateFunctions: [],
609
- packedBytecode: data.bytecode,
610
- };
611
- const contractClassId = data.contractClassId;
612
- const contractInstance: ContractInstance = {
613
- version: 1,
614
- salt: data.saltedInitializationHash,
615
- contractClassId,
616
- initializationHash: data.saltedInitializationHash,
617
- portalContractAddress: data.contractData.portalContractAddress,
618
- publicKeysHash: data.publicKeyHash,
619
- };
620
- const address = data.contractData.contractAddress;
621
- return [
622
- { ...contractClass, id: contractClassId, privateFunctionsRoot: Fr.ZERO },
623
- { ...contractInstance, address },
624
- ];
625
- }
@@ -1,13 +1,11 @@
1
1
  import {
2
2
  Body,
3
- ExtendedContractData,
4
3
  GetUnencryptedLogsResponse,
5
- L1ToL2Message,
4
+ InboxLeaf,
6
5
  L2Block,
7
6
  L2BlockL2Logs,
8
7
  LogFilter,
9
8
  LogType,
10
- NewInboxLeaf,
11
9
  TxEffect,
12
10
  TxHash,
13
11
  TxReceipt,
@@ -21,14 +19,9 @@ import { ContractClassPublic, ContractInstanceWithAddress } from '@aztec/types/c
21
19
  */
22
20
  export type ArchiverL1SynchPoint = {
23
21
  /** The last L1 block that added a new L2 block. */
24
- addedBlock: bigint;
25
- /** The last L1 block that added messages from the new inbox. */
26
- // TODO(#4492): Clean this up and fix the naming
27
- newMessages: bigint;
28
- /** The last L1 block that added pending messages */
29
- addedMessages: bigint;
30
- /** The last L1 block that cancelled messages */
31
- cancelledMessages: bigint;
22
+ blocks: bigint;
23
+ /** The last L1 block that added L1 -> L2 messages from the Inbox. */
24
+ messages: bigint;
32
25
  };
33
26
 
34
27
  /**
@@ -94,59 +87,26 @@ export interface ArchiverDataStore {
94
87
  ): Promise<boolean>;
95
88
 
96
89
  /**
97
- * Append new L1 to L2 messages to the store.
90
+ * Append L1 to L2 messages to the store.
98
91
  * @param messages - The L1 to L2 messages to be added to the store.
99
92
  * @param lastMessageL1BlockNumber - The L1 block number in which the last message was emitted.
100
93
  * @returns True if the operation is successful.
101
94
  */
102
- addNewL1ToL2Messages(messages: NewInboxLeaf[], lastMessageL1BlockNumber: bigint): Promise<boolean>;
95
+ addL1ToL2Messages(messages: InboxLeaf[], lastMessageL1BlockNumber: bigint): Promise<boolean>;
103
96
 
104
97
  /**
105
- * Append new pending L1 to L2 messages to the store.
106
- * @param messages - The L1 to L2 messages to be added to the store.
107
- * @param l1BlockNumber - The block number of the L1 block that added the messages.
108
- * @returns True if the operation is successful.
109
- * TODO(#4492): Nuke the following when purging the old inbox
110
- */
111
- addPendingL1ToL2Messages(messages: L1ToL2Message[], l1BlockNumber: bigint): Promise<boolean>;
112
-
113
- /**
114
- * Remove pending L1 to L2 messages from the store (if they were cancelled).
115
- * @param entryKeys - The entry keys to be removed from the store.
116
- * @param l1BlockNumber - The block number of the L1 block that cancelled the messages.
117
- * @returns True if the operation is successful.
118
- * TODO(#4492): Nuke the following when purging the old inbox
119
- */
120
- cancelPendingL1ToL2EntryKeys(entryKeys: Fr[], l1BlockNumber: bigint): Promise<boolean>;
121
-
122
- /**
123
- * Messages that have been published in an L2 block are confirmed.
124
- * Add them to the confirmed store, also remove them from the pending store.
125
- * @param entryKeys - The entry keys to be removed from the store.
126
- * @returns True if the operation is successful.
127
- */
128
- confirmL1ToL2EntryKeys(entryKeys: Fr[]): Promise<boolean>;
129
-
130
- /**
131
- * Gets up to `limit` amount of pending L1 to L2 messages, sorted by fee
132
- * @param limit - The number of entries to return (by default NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP).
133
- * @returns The requested L1 to L2 entry keys.
134
- */
135
- getPendingL1ToL2EntryKeys(limit: number): Promise<Fr[]>;
136
-
137
- /**
138
- * Gets the confirmed L1 to L2 message corresponding to the given entry key.
139
- * @param entryKey - The entry key to look up.
140
- * @returns The requested L1 to L2 message or throws if not found.
98
+ * Gets L1 to L2 message (to be) included in a given block.
99
+ * @param blockNumber - L2 block number to get messages for.
100
+ * @returns The L1 to L2 messages/leaves of the messages subtree (throws if not found).
141
101
  */
142
- getConfirmedL1ToL2Message(entryKey: Fr): Promise<L1ToL2Message>;
102
+ getL1ToL2Messages(blockNumber: bigint): Promise<Fr[]>;
143
103
 
144
104
  /**
145
- * Gets new L1 to L2 message (to be) included in a given block.
146
- * @param blockNumber - L2 block number to get messages for.
147
- * @returns The L1 to L2 messages/leaves of the messages subtree (throws if not found).
105
+ * Gets the L1 to L2 message index in the L1 to L2 message tree.
106
+ * @param l1ToL2Message - The L1 to L2 message.
107
+ * @returns The index of the L1 to L2 message in the L1 to L2 message tree.
148
108
  */
149
- getNewL1ToL2Messages(blockNumber: bigint): Promise<Fr[]>;
109
+ getL1ToL2MessageIndex(l1ToL2Message: Fr): Promise<bigint>;
150
110
 
151
111
  /**
152
112
  * Gets up to `limit` amount of logs starting from `from`.
@@ -164,31 +124,16 @@ export interface ArchiverDataStore {
164
124
  */
165
125
  getUnencryptedLogs(filter: LogFilter): Promise<GetUnencryptedLogsResponse>;
166
126
 
167
- /**
168
- * Add new extended contract data from an L2 block to the store's list.
169
- * @param data - List of contracts' data to be added.
170
- * @param blockNum - Number of the L2 block the contract data was deployed in.
171
- * @returns True if the operation is successful.
172
- */
173
- addExtendedContractData(data: ExtendedContractData[], blockNum: number): Promise<boolean>;
174
-
175
- /**
176
- * Get the extended contract data for this contract.
177
- * @param contractAddress - The contract data address.
178
- * @returns The extended contract data or undefined if not found.
179
- */
180
- getExtendedContractData(contractAddress: AztecAddress): Promise<ExtendedContractData | undefined>;
181
-
182
127
  /**
183
128
  * Gets the number of the latest L2 block processed.
184
129
  * @returns The number of the latest L2 block processed.
185
130
  */
186
- getBlockNumber(): Promise<number>;
131
+ getSynchedL2BlockNumber(): Promise<number>;
187
132
 
188
133
  /**
189
- * Gets the last L1 block number processed by the archiver
134
+ * Gets the synch point of the archiver
190
135
  */
191
- getL1BlockNumber(): Promise<ArchiverL1SynchPoint>;
136
+ getSynchedL1BlockNumbers(): Promise<ArchiverL1SynchPoint>;
192
137
 
193
138
  /**
194
139
  * Add new contract classes from an L2 block to the store's list.