@aztec/archiver 0.0.1-commit.e61ad554 → 0.0.1-commit.f146247c

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 (56) hide show
  1. package/dest/archiver.d.ts +3 -2
  2. package/dest/archiver.d.ts.map +1 -1
  3. package/dest/archiver.js +15 -2
  4. package/dest/factory.d.ts +3 -1
  5. package/dest/factory.d.ts.map +1 -1
  6. package/dest/factory.js +2 -3
  7. package/dest/l1/data_retrieval.js +1 -1
  8. package/dest/l1/validate_trace.d.ts +6 -3
  9. package/dest/l1/validate_trace.d.ts.map +1 -1
  10. package/dest/l1/validate_trace.js +13 -9
  11. package/dest/modules/data_source_base.d.ts +5 -5
  12. package/dest/modules/data_source_base.d.ts.map +1 -1
  13. package/dest/modules/instrumentation.d.ts +1 -1
  14. package/dest/modules/instrumentation.d.ts.map +1 -1
  15. package/dest/modules/instrumentation.js +17 -10
  16. package/dest/modules/l1_synchronizer.d.ts +1 -1
  17. package/dest/modules/l1_synchronizer.d.ts.map +1 -1
  18. package/dest/modules/l1_synchronizer.js +2 -3
  19. package/dest/store/block_store.d.ts +5 -5
  20. package/dest/store/block_store.d.ts.map +1 -1
  21. package/dest/store/block_store.js +2 -2
  22. package/dest/store/contract_class_store.d.ts +1 -1
  23. package/dest/store/contract_class_store.d.ts.map +1 -1
  24. package/dest/store/contract_class_store.js +11 -7
  25. package/dest/store/kv_archiver_store.d.ts +5 -5
  26. package/dest/store/kv_archiver_store.d.ts.map +1 -1
  27. package/dest/store/kv_archiver_store.js +2 -3
  28. package/dest/store/log_store.d.ts +1 -1
  29. package/dest/store/log_store.d.ts.map +1 -1
  30. package/dest/store/log_store.js +2 -2
  31. package/dest/test/index.js +3 -1
  32. package/dest/test/mock_l2_block_source.d.ts +6 -6
  33. package/dest/test/mock_l2_block_source.d.ts.map +1 -1
  34. package/dest/test/mock_l2_block_source.js +3 -3
  35. package/dest/test/mock_structs.d.ts +3 -2
  36. package/dest/test/mock_structs.d.ts.map +1 -1
  37. package/dest/test/mock_structs.js +7 -5
  38. package/dest/test/noop_l1_archiver.d.ts +23 -0
  39. package/dest/test/noop_l1_archiver.d.ts.map +1 -0
  40. package/dest/test/noop_l1_archiver.js +68 -0
  41. package/package.json +14 -13
  42. package/src/archiver.ts +22 -2
  43. package/src/factory.ts +3 -3
  44. package/src/l1/data_retrieval.ts +1 -1
  45. package/src/l1/validate_trace.ts +24 -6
  46. package/src/modules/data_source_base.ts +4 -4
  47. package/src/modules/instrumentation.ts +15 -10
  48. package/src/modules/l1_synchronizer.ts +2 -3
  49. package/src/store/block_store.ts +5 -5
  50. package/src/store/contract_class_store.ts +11 -7
  51. package/src/store/kv_archiver_store.ts +6 -6
  52. package/src/store/log_store.ts +5 -5
  53. package/src/test/index.ts +3 -0
  54. package/src/test/mock_l2_block_source.ts +6 -6
  55. package/src/test/mock_structs.ts +22 -6
  56. package/src/test/noop_l1_archiver.ts +109 -0
@@ -0,0 +1,109 @@
1
+ import type { BlobClientInterface } from '@aztec/blob-client/client';
2
+ import type { RollupContract } from '@aztec/ethereum/contracts';
3
+ import type { ViemPublicClient, ViemPublicDebugClient } from '@aztec/ethereum/types';
4
+ import { Buffer32 } from '@aztec/foundation/buffer';
5
+ import { Fr } from '@aztec/foundation/curves/bn254';
6
+ import { EthAddress } from '@aztec/foundation/eth-address';
7
+ import type { FunctionsOf } from '@aztec/foundation/types';
8
+ import type { ArchiverEmitter } from '@aztec/stdlib/block';
9
+ import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
10
+ import { type TelemetryClient, type Tracer, getTelemetryClient } from '@aztec/telemetry-client';
11
+
12
+ import { mock } from 'jest-mock-extended';
13
+ import { EventEmitter } from 'node:events';
14
+
15
+ import { Archiver } from '../archiver.js';
16
+ import { ArchiverInstrumentation } from '../modules/instrumentation.js';
17
+ import type { ArchiverL1Synchronizer } from '../modules/l1_synchronizer.js';
18
+ import type { KVArchiverDataStore } from '../store/kv_archiver_store.js';
19
+
20
+ /** Noop L1 synchronizer for testing without L1 connectivity. */
21
+ class NoopL1Synchronizer implements FunctionsOf<ArchiverL1Synchronizer> {
22
+ public readonly tracer: Tracer;
23
+
24
+ constructor(tracer: Tracer) {
25
+ this.tracer = tracer;
26
+ }
27
+
28
+ setConfig(_config: unknown) {}
29
+ getL1BlockNumber(): bigint | undefined {
30
+ return 0n;
31
+ }
32
+ getL1Timestamp(): bigint | undefined {
33
+ return 0n;
34
+ }
35
+ testEthereumNodeSynced(): Promise<void> {
36
+ return Promise.resolve();
37
+ }
38
+ syncFromL1(_initialSyncComplete: boolean): Promise<void> {
39
+ return Promise.resolve();
40
+ }
41
+ }
42
+
43
+ /**
44
+ * Archiver with mocked L1 connectivity for testing.
45
+ * Uses mock L1 clients and a noop synchronizer, enabling tests that
46
+ * don't require real Ethereum connectivity.
47
+ */
48
+ export class NoopL1Archiver extends Archiver {
49
+ constructor(
50
+ dataStore: KVArchiverDataStore,
51
+ l1Constants: L1RollupConstants & { genesisArchiveRoot: Fr },
52
+ instrumentation: ArchiverInstrumentation,
53
+ ) {
54
+ // Create mocks for L1 clients
55
+ const publicClient = mock<ViemPublicClient>();
56
+ const debugClient = mock<ViemPublicDebugClient>();
57
+ const rollup = mock<RollupContract>();
58
+ const blobClient = mock<BlobClientInterface>();
59
+
60
+ // Mock methods called during start()
61
+ blobClient.testSources.mockResolvedValue();
62
+ publicClient.getBlockNumber.mockResolvedValue(1n);
63
+
64
+ const events = new EventEmitter() as ArchiverEmitter;
65
+ const synchronizer = new NoopL1Synchronizer(instrumentation.tracer);
66
+
67
+ super(
68
+ publicClient,
69
+ debugClient,
70
+ rollup,
71
+ {
72
+ registryAddress: EthAddress.ZERO,
73
+ governanceProposerAddress: EthAddress.ZERO,
74
+ slashFactoryAddress: EthAddress.ZERO,
75
+ slashingProposerAddress: EthAddress.ZERO,
76
+ },
77
+ dataStore,
78
+ {
79
+ pollingIntervalMs: 1000,
80
+ batchSize: 100,
81
+ skipValidateCheckpointAttestations: true,
82
+ maxAllowedEthClientDriftSeconds: 300,
83
+ ethereumAllowNoDebugHosts: true, // Skip trace validation
84
+ },
85
+ blobClient,
86
+ instrumentation,
87
+ { ...l1Constants, l1StartBlockHash: Buffer32.random() },
88
+ synchronizer as ArchiverL1Synchronizer,
89
+ events,
90
+ );
91
+ }
92
+
93
+ /** Override start to skip L1 validation checks. */
94
+ public override start(_blockUntilSynced?: boolean): Promise<void> {
95
+ // Just start the running promise without L1 checks
96
+ this.runningPromise.start();
97
+ return Promise.resolve();
98
+ }
99
+ }
100
+
101
+ /** Creates an archiver with mocked L1 connectivity for testing. */
102
+ export async function createNoopL1Archiver(
103
+ dataStore: KVArchiverDataStore,
104
+ l1Constants: L1RollupConstants & { genesisArchiveRoot: Fr },
105
+ telemetry: TelemetryClient = getTelemetryClient(),
106
+ ): Promise<NoopL1Archiver> {
107
+ const instrumentation = await ArchiverInstrumentation.new(telemetry, () => dataStore.estimateSize());
108
+ return new NoopL1Archiver(dataStore, l1Constants, instrumentation);
109
+ }