@aztec/archiver 0.76.4-devnet-test-rc3 → 0.77.0-testnet-ignition.17

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 (91) hide show
  1. package/README.md +1 -1
  2. package/dest/archiver/archiver.d.ts +19 -9
  3. package/dest/archiver/archiver.d.ts.map +1 -1
  4. package/dest/archiver/archiver.js +758 -713
  5. package/dest/archiver/archiver_store.d.ts +20 -7
  6. package/dest/archiver/archiver_store.d.ts.map +1 -1
  7. package/dest/archiver/archiver_store.js +4 -2
  8. package/dest/archiver/archiver_store_test_suite.d.ts +2 -2
  9. package/dest/archiver/archiver_store_test_suite.d.ts.map +1 -1
  10. package/dest/archiver/archiver_store_test_suite.js +398 -227
  11. package/dest/archiver/config.d.ts +1 -1
  12. package/dest/archiver/config.d.ts.map +1 -1
  13. package/dest/archiver/config.js +10 -12
  14. package/dest/archiver/data_retrieval.d.ts +17 -14
  15. package/dest/archiver/data_retrieval.d.ts.map +1 -1
  16. package/dest/archiver/data_retrieval.js +90 -88
  17. package/dest/archiver/errors.js +1 -2
  18. package/dest/archiver/index.d.ts +1 -1
  19. package/dest/archiver/index.d.ts.map +1 -1
  20. package/dest/archiver/index.js +0 -1
  21. package/dest/archiver/instrumentation.d.ts +3 -1
  22. package/dest/archiver/instrumentation.d.ts.map +1 -1
  23. package/dest/archiver/instrumentation.js +37 -17
  24. package/dest/archiver/kv_archiver_store/block_store.d.ts +5 -3
  25. package/dest/archiver/kv_archiver_store/block_store.d.ts.map +1 -1
  26. package/dest/archiver/kv_archiver_store/block_store.js +125 -130
  27. package/dest/archiver/kv_archiver_store/contract_class_store.d.ts +2 -1
  28. package/dest/archiver/kv_archiver_store/contract_class_store.d.ts.map +1 -1
  29. package/dest/archiver/kv_archiver_store/contract_class_store.js +45 -37
  30. package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts +10 -2
  31. package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts.map +1 -1
  32. package/dest/archiver/kv_archiver_store/contract_instance_store.js +54 -15
  33. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +16 -9
  34. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
  35. package/dest/archiver/kv_archiver_store/kv_archiver_store.js +143 -160
  36. package/dest/archiver/kv_archiver_store/log_store.d.ts +5 -3
  37. package/dest/archiver/kv_archiver_store/log_store.d.ts.map +1 -1
  38. package/dest/archiver/kv_archiver_store/log_store.js +296 -255
  39. package/dest/archiver/kv_archiver_store/message_store.d.ts +3 -3
  40. package/dest/archiver/kv_archiver_store/message_store.d.ts.map +1 -1
  41. package/dest/archiver/kv_archiver_store/message_store.js +45 -50
  42. package/dest/archiver/kv_archiver_store/nullifier_store.d.ts +2 -2
  43. package/dest/archiver/kv_archiver_store/nullifier_store.d.ts.map +1 -1
  44. package/dest/archiver/kv_archiver_store/nullifier_store.js +36 -43
  45. package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts +2 -2
  46. package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts.map +1 -1
  47. package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.js +17 -26
  48. package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts +16 -7
  49. package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts.map +1 -1
  50. package/dest/archiver/memory_archiver_store/memory_archiver_store.js +287 -247
  51. package/dest/archiver/structs/data_retrieval.js +5 -2
  52. package/dest/archiver/structs/published.js +1 -2
  53. package/dest/factory.d.ts +5 -5
  54. package/dest/factory.d.ts.map +1 -1
  55. package/dest/factory.js +36 -25
  56. package/dest/index.js +0 -1
  57. package/dest/rpc/index.d.ts +2 -1
  58. package/dest/rpc/index.d.ts.map +1 -1
  59. package/dest/rpc/index.js +8 -4
  60. package/dest/test/index.js +0 -1
  61. package/dest/test/mock_archiver.d.ts +3 -2
  62. package/dest/test/mock_archiver.d.ts.map +1 -1
  63. package/dest/test/mock_archiver.js +8 -13
  64. package/dest/test/mock_l1_to_l2_message_source.d.ts +2 -2
  65. package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
  66. package/dest/test/mock_l1_to_l2_message_source.js +4 -4
  67. package/dest/test/mock_l2_block_source.d.ts +5 -3
  68. package/dest/test/mock_l2_block_source.d.ts.map +1 -1
  69. package/dest/test/mock_l2_block_source.js +71 -68
  70. package/package.json +15 -16
  71. package/src/archiver/archiver.ts +119 -91
  72. package/src/archiver/archiver_store.ts +27 -27
  73. package/src/archiver/archiver_store_test_suite.ts +22 -15
  74. package/src/archiver/config.ts +1 -1
  75. package/src/archiver/data_retrieval.ts +34 -46
  76. package/src/archiver/index.ts +1 -1
  77. package/src/archiver/instrumentation.ts +11 -1
  78. package/src/archiver/kv_archiver_store/block_store.ts +10 -4
  79. package/src/archiver/kv_archiver_store/contract_class_store.ts +9 -9
  80. package/src/archiver/kv_archiver_store/contract_instance_store.ts +81 -3
  81. package/src/archiver/kv_archiver_store/kv_archiver_store.ts +44 -29
  82. package/src/archiver/kv_archiver_store/log_store.ts +56 -32
  83. package/src/archiver/kv_archiver_store/message_store.ts +4 -3
  84. package/src/archiver/kv_archiver_store/nullifier_store.ts +3 -2
  85. package/src/archiver/memory_archiver_store/l1_to_l2_message_store.ts +3 -3
  86. package/src/archiver/memory_archiver_store/memory_archiver_store.ts +110 -57
  87. package/src/factory.ts +16 -14
  88. package/src/rpc/index.ts +2 -6
  89. package/src/test/mock_archiver.ts +3 -2
  90. package/src/test/mock_l1_to_l2_message_source.ts +2 -2
  91. package/src/test/mock_l2_block_source.ts +4 -12
@@ -1,77 +1,59 @@
1
- import { type BlobSinkClientInterface } from '@aztec/blob-sink/client';
1
+ import type { BlobSinkClientInterface } from '@aztec/blob-sink/client';
2
+ import { type ViemPublicClient, createEthereumChain } from '@aztec/ethereum';
3
+ import type { EthAddress } from '@aztec/foundation/eth-address';
4
+ import { Fr } from '@aztec/foundation/fields';
5
+ import { type Logger, createLogger } from '@aztec/foundation/log';
6
+ import { RunningPromise, makeLoggingErrorHandler } from '@aztec/foundation/running-promise';
7
+ import { count } from '@aztec/foundation/string';
8
+ import { elapsed } from '@aztec/foundation/timer';
9
+ import { InboxAbi, RollupAbi } from '@aztec/l1-artifacts';
2
10
  import {
3
- type GetContractClassLogsResponse,
4
- type GetPublicLogsResponse,
5
- type InBlock,
6
- type InboxLeaf,
7
- type L1RollupConstants,
8
- type L1ToL2MessageSource,
9
- type L2Block,
10
- type L2BlockId,
11
- type L2BlockSource,
12
- type L2LogsSource,
13
- type L2Tips,
14
- type LogFilter,
15
- type NullifierWithBlockSource,
16
- type TxEffect,
17
- type TxHash,
18
- type TxReceipt,
19
- type TxScopedL2Log,
20
- type UnencryptedL2Log,
21
- getEpochNumberAtTimestamp,
22
- getSlotAtTimestamp,
23
- getSlotRangeForEpoch,
24
- getTimestampRangeForEpoch,
25
- } from '@aztec/circuit-types';
11
+ ContractClassRegisteredEvent,
12
+ PrivateFunctionBroadcastedEvent,
13
+ UnconstrainedFunctionBroadcastedEvent,
14
+ } from '@aztec/protocol-contracts/class-registerer';
15
+ import {
16
+ ContractInstanceDeployedEvent,
17
+ ContractInstanceUpdatedEvent,
18
+ } from '@aztec/protocol-contracts/instance-deployer';
19
+ import type { FunctionSelector } from '@aztec/stdlib/abi';
20
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
21
+ import type { InBlock, L2Block, L2BlockId, L2BlockSource, L2Tips, NullifierWithBlockSource } from '@aztec/stdlib/block';
26
22
  import {
27
- type BlockHeader,
28
23
  type ContractClassPublic,
29
24
  type ContractDataSource,
30
25
  type ContractInstanceWithAddress,
31
26
  type ExecutablePrivateFunctionWithMembershipProof,
32
- type FunctionSelector,
33
- type PrivateLog,
34
27
  type PublicFunction,
35
28
  type UnconstrainedFunctionWithMembershipProof,
36
29
  computePublicBytecodeCommitment,
37
30
  isValidPrivateFunctionMembershipProof,
38
31
  isValidUnconstrainedFunctionMembershipProof,
39
- } from '@aztec/circuits.js';
40
- import { createEthereumChain } from '@aztec/ethereum';
41
- import { type AztecAddress } from '@aztec/foundation/aztec-address';
42
- import { type EthAddress } from '@aztec/foundation/eth-address';
43
- import { Fr } from '@aztec/foundation/fields';
44
- import { type Logger, createLogger } from '@aztec/foundation/log';
45
- import { RunningPromise } from '@aztec/foundation/running-promise';
46
- import { count } from '@aztec/foundation/string';
47
- import { elapsed } from '@aztec/foundation/timer';
48
- import { InboxAbi, RollupAbi } from '@aztec/l1-artifacts';
32
+ } from '@aztec/stdlib/contract';
49
33
  import {
50
- ContractClassRegisteredEvent,
51
- PrivateFunctionBroadcastedEvent,
52
- UnconstrainedFunctionBroadcastedEvent,
53
- } from '@aztec/protocol-contracts/class-registerer';
54
- import { ContractInstanceDeployedEvent } from '@aztec/protocol-contracts/instance-deployer';
34
+ type L1RollupConstants,
35
+ getEpochNumberAtTimestamp,
36
+ getSlotAtTimestamp,
37
+ getSlotRangeForEpoch,
38
+ getTimestampRangeForEpoch,
39
+ } from '@aztec/stdlib/epoch-helpers';
40
+ import type { GetContractClassLogsResponse, GetPublicLogsResponse } from '@aztec/stdlib/interfaces/client';
41
+ import type { L2LogsSource } from '@aztec/stdlib/interfaces/server';
42
+ import { ContractClassLog, type LogFilter, type PrivateLog, type PublicLog, TxScopedL2Log } from '@aztec/stdlib/logs';
43
+ import type { InboxLeaf, L1ToL2MessageSource } from '@aztec/stdlib/messaging';
44
+ import { type BlockHeader, TxEffect, TxHash, TxReceipt } from '@aztec/stdlib/tx';
55
45
  import { Attributes, type TelemetryClient, type Traceable, type Tracer, trackSpan } from '@aztec/telemetry-client';
56
46
 
57
47
  import groupBy from 'lodash.groupby';
58
- import {
59
- type Chain,
60
- type GetContractReturnType,
61
- type HttpTransport,
62
- type PublicClient,
63
- createPublicClient,
64
- getContract,
65
- http,
66
- } from 'viem';
67
-
68
- import { type ArchiverDataStore, type ArchiverL1SynchPoint } from './archiver_store.js';
69
- import { type ArchiverConfig } from './config.js';
48
+ import { type GetContractReturnType, createPublicClient, fallback, getContract, http } from 'viem';
49
+
50
+ import type { ArchiverDataStore, ArchiverL1SynchPoint } from './archiver_store.js';
51
+ import type { ArchiverConfig } from './config.js';
70
52
  import { retrieveBlocksFromRollup, retrieveL1ToL2Messages } from './data_retrieval.js';
71
53
  import { NoBlobBodiesFoundError } from './errors.js';
72
54
  import { ArchiverInstrumentation } from './instrumentation.js';
73
- import { type DataRetrieval } from './structs/data_retrieval.js';
74
- import { type L1Published } from './structs/published.js';
55
+ import type { DataRetrieval } from './structs/data_retrieval.js';
56
+ import type { L1Published } from './structs/published.js';
75
57
 
76
58
  /**
77
59
  * Helper interface to combine all sources this archiver implementation provides.
@@ -93,8 +75,8 @@ export class Archiver implements ArchiveSource, Traceable {
93
75
  */
94
76
  private runningPromise?: RunningPromise;
95
77
 
96
- private rollup: GetContractReturnType<typeof RollupAbi, PublicClient<HttpTransport, Chain>>;
97
- private inbox: GetContractReturnType<typeof InboxAbi, PublicClient<HttpTransport, Chain>>;
78
+ private rollup: GetContractReturnType<typeof RollupAbi, ViemPublicClient>;
79
+ private inbox: GetContractReturnType<typeof InboxAbi, ViemPublicClient>;
98
80
 
99
81
  private store: ArchiverStoreHelper;
100
82
 
@@ -114,7 +96,7 @@ export class Archiver implements ArchiveSource, Traceable {
114
96
  * @param log - A logger.
115
97
  */
116
98
  constructor(
117
- private readonly publicClient: PublicClient<HttpTransport, Chain>,
99
+ private readonly publicClient: ViemPublicClient,
118
100
  private readonly l1Addresses: { rollupAddress: EthAddress; inboxAddress: EthAddress; registryAddress: EthAddress },
119
101
  readonly dataStore: ArchiverDataStore,
120
102
  private readonly config: { pollingIntervalMs: number; batchSize: number },
@@ -152,10 +134,10 @@ export class Archiver implements ArchiveSource, Traceable {
152
134
  deps: { telemetry: TelemetryClient; blobSinkClient: BlobSinkClientInterface },
153
135
  blockUntilSynced = true,
154
136
  ): Promise<Archiver> {
155
- const chain = createEthereumChain(config.l1RpcUrl, config.l1ChainId);
137
+ const chain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
156
138
  const publicClient = createPublicClient({
157
139
  chain: chain.chainInfo,
158
- transport: http(chain.rpcUrl),
140
+ transport: fallback(config.l1RpcUrls.map(url => http(url))),
159
141
  pollingInterval: config.viemPollingIntervalMS,
160
142
  });
161
143
 
@@ -198,18 +180,32 @@ export class Archiver implements ArchiveSource, Traceable {
198
180
  }
199
181
 
200
182
  if (blockUntilSynced) {
201
- await this.sync(blockUntilSynced);
183
+ await this.syncSafe(blockUntilSynced);
202
184
  }
203
185
 
204
- this.runningPromise = new RunningPromise(() => this.sync(false), this.log, this.config.pollingIntervalMs, [
205
- // Ignored errors will not log to the console
206
- // We ignore NoBlobBodiesFound as the message may not have been passed to the blob sink yet
207
- NoBlobBodiesFoundError,
208
- ]);
186
+ this.runningPromise = new RunningPromise(
187
+ () => this.sync(false),
188
+ this.log,
189
+ this.config.pollingIntervalMs,
190
+ makeLoggingErrorHandler(
191
+ this.log,
192
+ // Ignored errors will not log to the console
193
+ // We ignore NoBlobBodiesFound as the message may not have been passed to the blob sink yet
194
+ NoBlobBodiesFoundError,
195
+ ),
196
+ );
209
197
 
210
198
  this.runningPromise.start();
211
199
  }
212
200
 
201
+ private async syncSafe(initialRun: boolean) {
202
+ try {
203
+ await this.sync(initialRun);
204
+ } catch (error) {
205
+ this.log.error('Error during sync', { error });
206
+ }
207
+ }
208
+
213
209
  /**
214
210
  * Fetches logs from L1 contracts and processes them.
215
211
  */
@@ -278,29 +274,35 @@ export class Archiver implements ArchiveSource, Traceable {
278
274
  // the chain locally before we start unwinding stuff. This can be optimized by figuring out
279
275
  // up to which point we're pruning, and then requesting L2 blocks up to that point only.
280
276
  await this.handleEpochPrune(provenBlockNumber, currentL1BlockNumber);
277
+
278
+ this.instrumentation.updateL1BlockHeight(currentL1BlockNumber);
281
279
  }
282
280
 
283
281
  if (initialRun) {
284
282
  this.log.info(`Initial archiver sync to L1 block ${currentL1BlockNumber} complete.`, {
285
283
  l1BlockNumber: currentL1BlockNumber,
284
+ syncPoint: await this.store.getSynchPoint(),
286
285
  ...(await this.getL2Tips()),
287
286
  });
288
287
  }
289
288
  }
290
289
 
290
+ /** Queries the rollup contract on whether a prune can be executed on the immediatenext L1 block. */
291
+ private async canPrune(currentL1BlockNumber: bigint) {
292
+ const time = (this.l1Timestamp ?? 0n) + BigInt(this.l1constants.ethereumSlotDuration);
293
+ return await this.rollup.read.canPruneAtTime([time], { blockNumber: currentL1BlockNumber });
294
+ }
295
+
291
296
  /** Checks if there'd be a reorg for the next block submission and start pruning now. */
292
297
  private async handleEpochPrune(provenBlockNumber: bigint, currentL1BlockNumber: bigint) {
293
298
  const localPendingBlockNumber = BigInt(await this.getBlockNumber());
294
-
295
- const time = (this.l1Timestamp ?? 0n) + BigInt(this.l1constants.ethereumSlotDuration);
296
-
297
- const canPrune =
298
- localPendingBlockNumber > provenBlockNumber &&
299
- (await this.rollup.read.canPruneAtTime([time], { blockNumber: currentL1BlockNumber }));
299
+ const canPrune = localPendingBlockNumber > provenBlockNumber && (await this.canPrune(currentL1BlockNumber));
300
300
 
301
301
  if (canPrune) {
302
302
  const blocksToUnwind = localPendingBlockNumber - provenBlockNumber;
303
- this.log.debug(`L2 prune will occur on next block submission.`);
303
+ this.log.debug(
304
+ `L2 prune from ${provenBlockNumber + 1n} to ${localPendingBlockNumber} will occur on next block submission.`,
305
+ );
304
306
  await this.store.unwindBlocks(Number(localPendingBlockNumber), Number(blocksToUnwind));
305
307
  this.log.warn(
306
308
  `Unwound ${count(blocksToUnwind, 'block')} from L2 block ${localPendingBlockNumber} ` +
@@ -688,9 +690,11 @@ export class Archiver implements ArchiveSource, Traceable {
688
690
  if (!instance) {
689
691
  throw new Error(`Contract ${address.toString()} not found`);
690
692
  }
691
- const contractClass = await this.getContractClass(instance.contractClassId);
693
+ const contractClass = await this.getContractClass(instance.currentContractClassId);
692
694
  if (!contractClass) {
693
- throw new Error(`Contract class ${instance.contractClassId.toString()} for ${address.toString()} not found`);
695
+ throw new Error(
696
+ `Contract class ${instance.currentContractClassId.toString()} for ${address.toString()} not found`,
697
+ );
694
698
  }
695
699
  return contractClass.publicFunctions.find(f => f.selector.equals(selector));
696
700
  }
@@ -872,6 +876,8 @@ class ArchiverStoreHelper
872
876
  | 'deleteContractClasses'
873
877
  | 'addContractInstances'
874
878
  | 'deleteContractInstances'
879
+ | 'addContractInstanceUpdates'
880
+ | 'deleteContractInstanceUpdates'
875
881
  | 'addFunctions'
876
882
  >
877
883
  {
@@ -892,10 +898,10 @@ class ArchiverStoreHelper
892
898
  * Extracts and stores contract classes out of ContractClassRegistered events emitted by the class registerer contract.
893
899
  * @param allLogs - All logs emitted in a bunch of blocks.
894
900
  */
895
- async #updateRegisteredContractClasses(allLogs: UnencryptedL2Log[], blockNum: number, operation: Operation) {
901
+ async #updateRegisteredContractClasses(allLogs: ContractClassLog[], blockNum: number, operation: Operation) {
896
902
  const contractClassRegisteredEvents = allLogs
897
- .filter(log => ContractClassRegisteredEvent.isContractClassRegisteredEvent(log.data))
898
- .map(log => ContractClassRegisteredEvent.fromLog(log.data));
903
+ .filter(log => ContractClassRegisteredEvent.isContractClassRegisteredEvent(log))
904
+ .map(log => ContractClassRegisteredEvent.fromLog(log));
899
905
 
900
906
  const contractClasses = await Promise.all(contractClassRegisteredEvents.map(e => e.toContractClassPublic()));
901
907
  if (contractClasses.length > 0) {
@@ -935,6 +941,29 @@ class ArchiverStoreHelper
935
941
  return true;
936
942
  }
937
943
 
944
+ /**
945
+ * Extracts and stores contract instances out of ContractInstanceDeployed events emitted by the canonical deployer contract.
946
+ * @param allLogs - All logs emitted in a bunch of blocks.
947
+ */
948
+ async #updateUpdatedContractInstances(allLogs: PublicLog[], blockNum: number, operation: Operation) {
949
+ const contractUpdates = allLogs
950
+ .filter(log => ContractInstanceUpdatedEvent.isContractInstanceUpdatedEvent(log))
951
+ .map(log => ContractInstanceUpdatedEvent.fromLog(log))
952
+ .map(e => e.toContractInstanceUpdate());
953
+
954
+ if (contractUpdates.length > 0) {
955
+ contractUpdates.forEach(c =>
956
+ this.#log.verbose(`${Operation[operation]} contract instance update at ${c.address.toString()}`),
957
+ );
958
+ if (operation == Operation.Store) {
959
+ return await this.store.addContractInstanceUpdates(contractUpdates, blockNum);
960
+ } else if (operation == Operation.Delete) {
961
+ return await this.store.deleteContractInstanceUpdates(contractUpdates, blockNum);
962
+ }
963
+ }
964
+ return true;
965
+ }
966
+
938
967
  /**
939
968
  * Stores the functions that was broadcasted individually
940
969
  *
@@ -945,14 +974,14 @@ class ArchiverStoreHelper
945
974
  * @param _blockNum - The block number
946
975
  * @returns
947
976
  */
948
- async #storeBroadcastedIndividualFunctions(allLogs: UnencryptedL2Log[], _blockNum: number) {
977
+ async #storeBroadcastedIndividualFunctions(allLogs: ContractClassLog[], _blockNum: number) {
949
978
  // Filter out private and unconstrained function broadcast events
950
979
  const privateFnEvents = allLogs
951
- .filter(log => PrivateFunctionBroadcastedEvent.isPrivateFunctionBroadcastedEvent(log.data))
952
- .map(log => PrivateFunctionBroadcastedEvent.fromLog(log.data));
980
+ .filter(log => PrivateFunctionBroadcastedEvent.isPrivateFunctionBroadcastedEvent(log))
981
+ .map(log => PrivateFunctionBroadcastedEvent.fromLog(log));
953
982
  const unconstrainedFnEvents = allLogs
954
- .filter(log => UnconstrainedFunctionBroadcastedEvent.isUnconstrainedFunctionBroadcastedEvent(log.data))
955
- .map(log => UnconstrainedFunctionBroadcastedEvent.fromLog(log.data));
983
+ .filter(log => UnconstrainedFunctionBroadcastedEvent.isUnconstrainedFunctionBroadcastedEvent(log))
984
+ .map(log => UnconstrainedFunctionBroadcastedEvent.fromLog(log));
956
985
 
957
986
  // Group all events by contract class id
958
987
  for (const [classIdString, classEvents] of Object.entries(
@@ -1004,15 +1033,15 @@ class ArchiverStoreHelper
1004
1033
  this.store.addLogs(blocks.map(block => block.data)),
1005
1034
  // Unroll all logs emitted during the retrieved blocks and extract any contract classes and instances from them
1006
1035
  ...blocks.map(async block => {
1007
- const contractClassLogs = block.data.body.txEffects
1008
- .flatMap(txEffect => (txEffect ? [txEffect.contractClassLogs] : []))
1009
- .flatMap(txLog => txLog.unrollLogs());
1036
+ const contractClassLogs = block.data.body.txEffects.flatMap(txEffect => txEffect.contractClassLogs);
1010
1037
  // ContractInstanceDeployed event logs are broadcast in privateLogs.
1011
1038
  const privateLogs = block.data.body.txEffects.flatMap(txEffect => txEffect.privateLogs);
1039
+ const publicLogs = block.data.body.txEffects.flatMap(txEffect => txEffect.publicLogs);
1012
1040
  return (
1013
1041
  await Promise.all([
1014
1042
  this.#updateRegisteredContractClasses(contractClassLogs, block.data.number, Operation.Store),
1015
1043
  this.#updateDeployedContractInstances(privateLogs, block.data.number, Operation.Store),
1044
+ this.#updateUpdatedContractInstances(publicLogs, block.data.number, Operation.Store),
1016
1045
  this.#storeBroadcastedIndividualFunctions(contractClassLogs, block.data.number),
1017
1046
  ])
1018
1047
  ).every(Boolean);
@@ -1036,17 +1065,16 @@ class ArchiverStoreHelper
1036
1065
  const opResults = await Promise.all([
1037
1066
  // Unroll all logs emitted during the retrieved blocks and extract any contract classes and instances from them
1038
1067
  ...blocks.map(async block => {
1039
- const contractClassLogs = block.data.body.txEffects
1040
- .flatMap(txEffect => (txEffect ? [txEffect.contractClassLogs] : []))
1041
- .flatMap(txLog => txLog.unrollLogs());
1042
-
1068
+ const contractClassLogs = block.data.body.txEffects.flatMap(txEffect => txEffect.contractClassLogs);
1043
1069
  // ContractInstanceDeployed event logs are broadcast in privateLogs.
1044
1070
  const privateLogs = block.data.body.txEffects.flatMap(txEffect => txEffect.privateLogs);
1071
+ const publicLogs = block.data.body.txEffects.flatMap(txEffect => txEffect.publicLogs);
1045
1072
 
1046
1073
  return (
1047
1074
  await Promise.all([
1048
1075
  this.#updateRegisteredContractClasses(contractClassLogs, block.data.number, Operation.Delete),
1049
1076
  this.#updateDeployedContractInstances(privateLogs, block.data.number, Operation.Delete),
1077
+ this.#updateUpdatedContractInstances(publicLogs, block.data.number, Operation.Delete),
1050
1078
  ])
1051
1079
  ).every(Boolean);
1052
1080
  }),
@@ -1,29 +1,21 @@
1
- import {
2
- type GetContractClassLogsResponse,
3
- type GetPublicLogsResponse,
4
- type InBlock,
5
- type InboxLeaf,
6
- type L2Block,
7
- type LogFilter,
8
- type TxEffect,
9
- type TxHash,
10
- type TxReceipt,
11
- type TxScopedL2Log,
12
- } from '@aztec/circuit-types';
13
- import {
14
- type BlockHeader,
15
- type ContractClassPublic,
16
- type ContractInstanceWithAddress,
17
- type ExecutablePrivateFunctionWithMembershipProof,
18
- type Fr,
19
- type PrivateLog,
20
- type UnconstrainedFunctionWithMembershipProof,
21
- } from '@aztec/circuits.js';
22
- import { type FunctionSelector } from '@aztec/foundation/abi';
23
- import { type AztecAddress } from '@aztec/foundation/aztec-address';
24
-
25
- import { type DataRetrieval } from './structs/data_retrieval.js';
26
- import { type L1Published } from './structs/published.js';
1
+ import type { Fr } from '@aztec/foundation/fields';
2
+ import type { FunctionSelector } from '@aztec/stdlib/abi';
3
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
4
+ import type { InBlock, L2Block } from '@aztec/stdlib/block';
5
+ import type {
6
+ ContractClassPublic,
7
+ ContractInstanceUpdateWithAddress,
8
+ ContractInstanceWithAddress,
9
+ ExecutablePrivateFunctionWithMembershipProof,
10
+ UnconstrainedFunctionWithMembershipProof,
11
+ } from '@aztec/stdlib/contract';
12
+ import type { GetContractClassLogsResponse, GetPublicLogsResponse } from '@aztec/stdlib/interfaces/client';
13
+ import type { LogFilter, PrivateLog, TxScopedL2Log } from '@aztec/stdlib/logs';
14
+ import type { InboxLeaf } from '@aztec/stdlib/messaging';
15
+ import { BlockHeader, type TxEffect, type TxHash, type TxReceipt } from '@aztec/stdlib/tx';
16
+
17
+ import type { DataRetrieval } from './structs/data_retrieval.js';
18
+ import type { L1Published } from './structs/published.js';
27
19
 
28
20
  /**
29
21
  * Represents the latest L1 block processed by the archiver for various objects in L2.
@@ -244,6 +236,14 @@ export interface ArchiverDataStore {
244
236
  addContractInstances(data: ContractInstanceWithAddress[], blockNumber: number): Promise<boolean>;
245
237
  deleteContractInstances(data: ContractInstanceWithAddress[], blockNumber: number): Promise<boolean>;
246
238
 
239
+ /**
240
+ * Add new contract instance updates
241
+ * @param data - List of contract updates to be added.
242
+ * @param blockNumber - Number of the L2 block the updates were scheduled in.
243
+ * @returns True if the operation is successful.
244
+ */
245
+ addContractInstanceUpdates(data: ContractInstanceUpdateWithAddress[], blockNumber: number): Promise<boolean>;
246
+ deleteContractInstanceUpdates(data: ContractInstanceUpdateWithAddress[], blockNumber: number): Promise<boolean>;
247
247
  /**
248
248
  * Adds private functions to a contract class.
249
249
  */
@@ -254,7 +254,7 @@ export interface ArchiverDataStore {
254
254
  ): Promise<boolean>;
255
255
 
256
256
  /**
257
- * Returns a contract instance given its address, or undefined if not exists.
257
+ * Returns a contract instance given its address and the given block number, or undefined if not exists.
258
258
  * @param address - Address of the contract.
259
259
  */
260
260
  getContractInstance(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined>;
@@ -1,30 +1,33 @@
1
- import { InboxLeaf, L2Block, LogId, TxEffect, TxHash, wrapInBlock } from '@aztec/circuit-types';
2
- import '@aztec/circuit-types/jest';
3
1
  import {
4
- AztecAddress,
5
- type ContractClassPublic,
6
- type ContractInstanceWithAddress,
7
- Fr,
8
2
  INITIAL_L2_BLOCK_NUM,
9
3
  L1_TO_L2_MSG_SUBTREE_HEIGHT,
10
4
  MAX_NULLIFIERS_PER_TX,
11
5
  PRIVATE_LOG_SIZE_IN_FIELDS,
12
6
  PUBLIC_LOG_DATA_SIZE_IN_FIELDS,
13
- PrivateLog,
14
- PublicLog,
7
+ } from '@aztec/constants';
8
+ import { times, timesParallel } from '@aztec/foundation/collection';
9
+ import { randomInt } from '@aztec/foundation/crypto';
10
+ import { Fr } from '@aztec/foundation/fields';
11
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
12
+ import { L2Block, wrapInBlock } from '@aztec/stdlib/block';
13
+ import {
14
+ type ContractClassPublic,
15
+ type ContractInstanceWithAddress,
15
16
  SerializableContractInstance,
16
17
  computePublicBytecodeCommitment,
17
- } from '@aztec/circuits.js';
18
+ } from '@aztec/stdlib/contract';
19
+ import { LogId, PrivateLog, PublicLog } from '@aztec/stdlib/logs';
20
+ import { InboxLeaf } from '@aztec/stdlib/messaging';
18
21
  import {
19
22
  makeContractClassPublic,
20
23
  makeExecutablePrivateFunctionWithMembershipProof,
21
24
  makeUnconstrainedFunctionWithMembershipProof,
22
- } from '@aztec/circuits.js/testing';
23
- import { times, timesParallel } from '@aztec/foundation/collection';
24
- import { randomInt } from '@aztec/foundation/crypto';
25
+ } from '@aztec/stdlib/testing';
26
+ import '@aztec/stdlib/testing/jest';
27
+ import { TxEffect, TxHash } from '@aztec/stdlib/tx';
25
28
 
26
- import { type ArchiverDataStore, type ArchiverL1SynchPoint } from './archiver_store.js';
27
- import { type L1Published } from './structs/published.js';
29
+ import type { ArchiverDataStore, ArchiverL1SynchPoint } from './archiver_store.js';
30
+ import type { L1Published } from './structs/published.js';
28
31
 
29
32
  /**
30
33
  * @param testName - The name of the test suite.
@@ -279,7 +282,11 @@ export function describeArchiverDataStore(
279
282
  const blockNum = 10;
280
283
 
281
284
  beforeEach(async () => {
282
- const randomInstance = await SerializableContractInstance.random();
285
+ const classId = Fr.random();
286
+ const randomInstance = await SerializableContractInstance.random({
287
+ currentContractClassId: classId,
288
+ originalContractClassId: classId,
289
+ });
283
290
  contractInstance = { ...randomInstance, address: await AztecAddress.random() };
284
291
  await store.addContractInstances([contractInstance], blockNum);
285
292
  });
@@ -1,5 +1,4 @@
1
1
  import { type BlobSinkConfig, blobSinkConfigMapping } from '@aztec/blob-sink/client';
2
- import { type ChainConfig, chainConfigMappings } from '@aztec/circuit-types/config';
3
2
  import {
4
3
  type L1ContractAddresses,
5
4
  type L1ContractsConfig,
@@ -8,6 +7,7 @@ import {
8
7
  l1ReaderConfigMappings,
9
8
  } from '@aztec/ethereum';
10
9
  import { type ConfigMappingsType, getConfigFromMappings, numberConfigHelper } from '@aztec/foundation/config';
10
+ import { type ChainConfig, chainConfigMappings } from '@aztec/stdlib/config';
11
11
 
12
12
  /**
13
13
  * There are 2 polling intervals used in this configuration. The first is the archiver polling interval, archiverPollingIntervalMS.