@aztec/archiver 0.76.4 → 0.77.0-testnet-ignition.21
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.
- package/README.md +1 -1
- package/dest/archiver/archiver.d.ts +22 -10
- package/dest/archiver/archiver.d.ts.map +1 -1
- package/dest/archiver/archiver.js +762 -713
- package/dest/archiver/archiver_store.d.ts +20 -7
- package/dest/archiver/archiver_store.d.ts.map +1 -1
- package/dest/archiver/archiver_store.js +4 -2
- package/dest/archiver/archiver_store_test_suite.d.ts +2 -2
- package/dest/archiver/archiver_store_test_suite.d.ts.map +1 -1
- package/dest/archiver/archiver_store_test_suite.js +398 -227
- package/dest/archiver/config.d.ts +1 -1
- package/dest/archiver/config.d.ts.map +1 -1
- package/dest/archiver/config.js +10 -12
- package/dest/archiver/data_retrieval.d.ts +17 -14
- package/dest/archiver/data_retrieval.d.ts.map +1 -1
- package/dest/archiver/data_retrieval.js +90 -88
- package/dest/archiver/errors.js +1 -2
- package/dest/archiver/index.d.ts +1 -1
- package/dest/archiver/index.d.ts.map +1 -1
- package/dest/archiver/index.js +0 -1
- package/dest/archiver/instrumentation.d.ts +3 -1
- package/dest/archiver/instrumentation.d.ts.map +1 -1
- package/dest/archiver/instrumentation.js +37 -17
- package/dest/archiver/kv_archiver_store/block_store.d.ts +5 -3
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/block_store.js +125 -130
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts +2 -1
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/contract_class_store.js +45 -37
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts +10 -2
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/contract_instance_store.js +54 -15
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +16 -9
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.js +143 -160
- package/dest/archiver/kv_archiver_store/log_store.d.ts +5 -3
- package/dest/archiver/kv_archiver_store/log_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/log_store.js +296 -255
- package/dest/archiver/kv_archiver_store/message_store.d.ts +3 -3
- package/dest/archiver/kv_archiver_store/message_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/message_store.js +45 -50
- package/dest/archiver/kv_archiver_store/nullifier_store.d.ts +2 -2
- package/dest/archiver/kv_archiver_store/nullifier_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/nullifier_store.js +36 -43
- package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts +2 -2
- package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts.map +1 -1
- package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.js +17 -26
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts +16 -7
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts.map +1 -1
- package/dest/archiver/memory_archiver_store/memory_archiver_store.js +287 -247
- package/dest/archiver/structs/data_retrieval.js +5 -2
- package/dest/archiver/structs/published.js +1 -2
- package/dest/factory.d.ts +20 -6
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +54 -30
- package/dest/index.js +0 -1
- package/dest/rpc/index.d.ts +2 -1
- package/dest/rpc/index.d.ts.map +1 -1
- package/dest/rpc/index.js +8 -4
- package/dest/test/index.js +0 -1
- package/dest/test/mock_archiver.d.ts +3 -2
- package/dest/test/mock_archiver.d.ts.map +1 -1
- package/dest/test/mock_archiver.js +8 -13
- package/dest/test/mock_l1_to_l2_message_source.d.ts +2 -2
- package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
- package/dest/test/mock_l1_to_l2_message_source.js +4 -4
- package/dest/test/mock_l2_block_source.d.ts +5 -3
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +71 -68
- package/package.json +15 -16
- package/src/archiver/archiver.ts +149 -89
- package/src/archiver/archiver_store.ts +27 -27
- package/src/archiver/archiver_store_test_suite.ts +22 -15
- package/src/archiver/config.ts +1 -1
- package/src/archiver/data_retrieval.ts +32 -44
- package/src/archiver/index.ts +1 -1
- package/src/archiver/instrumentation.ts +11 -1
- package/src/archiver/kv_archiver_store/block_store.ts +10 -4
- package/src/archiver/kv_archiver_store/contract_class_store.ts +9 -9
- package/src/archiver/kv_archiver_store/contract_instance_store.ts +81 -3
- package/src/archiver/kv_archiver_store/kv_archiver_store.ts +44 -29
- package/src/archiver/kv_archiver_store/log_store.ts +56 -32
- package/src/archiver/kv_archiver_store/message_store.ts +4 -3
- package/src/archiver/kv_archiver_store/nullifier_store.ts +3 -2
- package/src/archiver/memory_archiver_store/l1_to_l2_message_store.ts +3 -3
- package/src/archiver/memory_archiver_store/memory_archiver_store.ts +110 -57
- package/src/factory.ts +44 -25
- package/src/rpc/index.ts +2 -6
- package/src/test/mock_archiver.ts +3 -2
- package/src/test/mock_l1_to_l2_message_source.ts +2 -2
- package/src/test/mock_l2_block_source.ts +16 -15
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { L1_TO_L2_MSG_SUBTREE_HEIGHT } from '@aztec/constants';
|
|
2
|
+
import type { Fr } from '@aztec/foundation/fields';
|
|
3
|
+
import { InboxLeaf } from '@aztec/stdlib/messaging';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* A simple in-memory implementation of an L1 to L2 message store.
|
|
@@ -1,45 +1,43 @@
|
|
|
1
1
|
import {
|
|
2
|
-
type ContractClass2BlockL2Logs,
|
|
3
|
-
ExtendedPublicLog,
|
|
4
|
-
ExtendedUnencryptedL2Log,
|
|
5
|
-
type GetContractClassLogsResponse,
|
|
6
|
-
type GetPublicLogsResponse,
|
|
7
|
-
type InBlock,
|
|
8
|
-
type InboxLeaf,
|
|
9
|
-
type L2Block,
|
|
10
|
-
L2BlockHash,
|
|
11
|
-
type LogFilter,
|
|
12
|
-
LogId,
|
|
13
|
-
type TxEffect,
|
|
14
|
-
type TxHash,
|
|
15
|
-
TxReceipt,
|
|
16
|
-
TxScopedL2Log,
|
|
17
|
-
wrapInBlock,
|
|
18
|
-
} from '@aztec/circuit-types';
|
|
19
|
-
import {
|
|
20
|
-
type BlockHeader,
|
|
21
|
-
type ContractClassPublic,
|
|
22
|
-
type ContractClassPublicWithBlockNumber,
|
|
23
|
-
type ContractInstanceWithAddress,
|
|
24
|
-
type ExecutablePrivateFunctionWithMembershipProof,
|
|
25
|
-
Fr,
|
|
26
2
|
INITIAL_L2_BLOCK_NUM,
|
|
27
3
|
MAX_NOTE_HASHES_PER_TX,
|
|
28
4
|
MAX_NULLIFIERS_PER_TX,
|
|
29
5
|
PUBLIC_LOG_DATA_SIZE_IN_FIELDS,
|
|
6
|
+
} from '@aztec/constants';
|
|
7
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
8
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
9
|
+
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
10
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
11
|
+
import { type InBlock, type L2Block, L2BlockHash, wrapInBlock } from '@aztec/stdlib/block';
|
|
12
|
+
import type {
|
|
13
|
+
ContractClassPublic,
|
|
14
|
+
ContractClassPublicWithBlockNumber,
|
|
15
|
+
ContractInstanceUpdateWithAddress,
|
|
16
|
+
ContractInstanceWithAddress,
|
|
17
|
+
ExecutablePrivateFunctionWithMembershipProof,
|
|
18
|
+
UnconstrainedFunctionWithMembershipProof,
|
|
19
|
+
} from '@aztec/stdlib/contract';
|
|
20
|
+
import type { GetContractClassLogsResponse, GetPublicLogsResponse } from '@aztec/stdlib/interfaces/client';
|
|
21
|
+
import {
|
|
22
|
+
ContractClassLog,
|
|
23
|
+
ExtendedContractClassLog,
|
|
24
|
+
ExtendedPublicLog,
|
|
25
|
+
type LogFilter,
|
|
26
|
+
LogId,
|
|
30
27
|
type PrivateLog,
|
|
31
28
|
type PublicLog,
|
|
32
|
-
|
|
33
|
-
} from '@aztec/
|
|
34
|
-
import {
|
|
35
|
-
import { type
|
|
36
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
29
|
+
TxScopedL2Log,
|
|
30
|
+
} from '@aztec/stdlib/logs';
|
|
31
|
+
import type { InboxLeaf } from '@aztec/stdlib/messaging';
|
|
32
|
+
import { type BlockHeader, TxEffect, TxHash, TxReceipt } from '@aztec/stdlib/tx';
|
|
37
33
|
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
34
|
+
import type { ArchiverDataStore, ArchiverL1SynchPoint } from '../archiver_store.js';
|
|
35
|
+
import type { DataRetrieval } from '../structs/data_retrieval.js';
|
|
36
|
+
import type { L1Published } from '../structs/published.js';
|
|
41
37
|
import { L1ToL2MessageStore } from './l1_to_l2_message_store.js';
|
|
42
38
|
|
|
39
|
+
type StoredContractInstanceUpdate = ContractInstanceUpdateWithAddress & { blockNumber: number; logIndex: number };
|
|
40
|
+
|
|
43
41
|
/**
|
|
44
42
|
* Simple, in-memory implementation of an archiver data store.
|
|
45
43
|
*/
|
|
@@ -62,7 +60,7 @@ export class MemoryArchiverStore implements ArchiverDataStore {
|
|
|
62
60
|
|
|
63
61
|
private publicLogsPerBlock: Map<number, PublicLog[]> = new Map();
|
|
64
62
|
|
|
65
|
-
private contractClassLogsPerBlock: Map<number,
|
|
63
|
+
private contractClassLogsPerBlock: Map<number, ContractClassLog[]> = new Map();
|
|
66
64
|
|
|
67
65
|
private blockScopedNullifiers: Map<string, { blockNumber: number; blockHash: string; index: bigint }> = new Map();
|
|
68
66
|
|
|
@@ -81,7 +79,10 @@ export class MemoryArchiverStore implements ArchiverDataStore {
|
|
|
81
79
|
|
|
82
80
|
private contractInstances: Map<string, ContractInstanceWithAddress> = new Map();
|
|
83
81
|
|
|
82
|
+
private contractInstanceUpdates: Map<string, StoredContractInstanceUpdate[]> = new Map();
|
|
83
|
+
|
|
84
84
|
private lastL1BlockNewBlocks: bigint | undefined = undefined;
|
|
85
|
+
|
|
85
86
|
private lastL1BlockNewMessages: bigint | undefined = undefined;
|
|
86
87
|
|
|
87
88
|
private lastProvenL2BlockNumber: number = 0;
|
|
@@ -112,7 +113,23 @@ export class MemoryArchiverStore implements ArchiverDataStore {
|
|
|
112
113
|
}
|
|
113
114
|
|
|
114
115
|
public getContractInstance(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
|
|
115
|
-
|
|
116
|
+
const instance = this.contractInstances.get(address.toString());
|
|
117
|
+
if (!instance) {
|
|
118
|
+
return Promise.resolve(undefined);
|
|
119
|
+
}
|
|
120
|
+
const updates = this.contractInstanceUpdates.get(address.toString()) || [];
|
|
121
|
+
if (updates.length > 0) {
|
|
122
|
+
const lastUpdate = updates[0];
|
|
123
|
+
const currentBlockNumber = this.getLastBlockNumber();
|
|
124
|
+
if (currentBlockNumber >= lastUpdate.blockOfChange) {
|
|
125
|
+
instance.currentContractClassId = lastUpdate.newContractClassId;
|
|
126
|
+
} else if (!lastUpdate.prevContractClassId.isZero()) {
|
|
127
|
+
instance.currentContractClassId = lastUpdate.prevContractClassId;
|
|
128
|
+
} else {
|
|
129
|
+
instance.currentContractClassId = instance.originalContractClassId;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return Promise.resolve(instance);
|
|
116
133
|
}
|
|
117
134
|
|
|
118
135
|
public getBytecodeCommitment(contractClassId: Fr): Promise<Fr | undefined> {
|
|
@@ -186,6 +203,33 @@ export class MemoryArchiverStore implements ArchiverDataStore {
|
|
|
186
203
|
return Promise.resolve(true);
|
|
187
204
|
}
|
|
188
205
|
|
|
206
|
+
public addContractInstanceUpdates(data: ContractInstanceUpdateWithAddress[], blockNumber: number): Promise<boolean> {
|
|
207
|
+
for (let logIndex = 0; logIndex < data.length; logIndex++) {
|
|
208
|
+
const contractInstanceUpdate = data[logIndex];
|
|
209
|
+
const updates = this.contractInstanceUpdates.get(contractInstanceUpdate.address.toString()) || [];
|
|
210
|
+
updates.unshift({
|
|
211
|
+
...contractInstanceUpdate,
|
|
212
|
+
blockNumber,
|
|
213
|
+
logIndex,
|
|
214
|
+
});
|
|
215
|
+
this.contractInstanceUpdates.set(contractInstanceUpdate.address.toString(), updates);
|
|
216
|
+
}
|
|
217
|
+
return Promise.resolve(true);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
public deleteContractInstanceUpdates(
|
|
221
|
+
data: ContractInstanceUpdateWithAddress[],
|
|
222
|
+
blockNumber: number,
|
|
223
|
+
): Promise<boolean> {
|
|
224
|
+
for (let logIndex = 0; logIndex < data.length; logIndex++) {
|
|
225
|
+
const contractInstanceUpdate = data[logIndex];
|
|
226
|
+
let updates = this.contractInstanceUpdates.get(contractInstanceUpdate.address.toString()) || [];
|
|
227
|
+
updates = updates.filter(update => !(update.blockNumber === blockNumber && update.logIndex === logIndex));
|
|
228
|
+
this.contractInstanceUpdates.set(contractInstanceUpdate.address.toString(), updates);
|
|
229
|
+
}
|
|
230
|
+
return Promise.resolve(true);
|
|
231
|
+
}
|
|
232
|
+
|
|
189
233
|
/**
|
|
190
234
|
* Append new blocks to the store's list.
|
|
191
235
|
* @param blocks - The L2 blocks to be added to the store and the last processed L1 block.
|
|
@@ -306,7 +350,10 @@ export class MemoryArchiverStore implements ArchiverDataStore {
|
|
|
306
350
|
this.#storeTaggedLogsFromPublic(block);
|
|
307
351
|
this.privateLogsPerBlock.set(block.number, block.body.txEffects.map(txEffect => txEffect.privateLogs).flat());
|
|
308
352
|
this.publicLogsPerBlock.set(block.number, block.body.txEffects.map(txEffect => txEffect.publicLogs).flat());
|
|
309
|
-
this.contractClassLogsPerBlock.set(
|
|
353
|
+
this.contractClassLogsPerBlock.set(
|
|
354
|
+
block.number,
|
|
355
|
+
block.body.txEffects.map(txEffect => txEffect.contractClassLogs).flat(),
|
|
356
|
+
);
|
|
310
357
|
});
|
|
311
358
|
return Promise.resolve(true);
|
|
312
359
|
}
|
|
@@ -654,34 +701,36 @@ export class MemoryArchiverStore implements ArchiverDataStore {
|
|
|
654
701
|
|
|
655
702
|
const contractAddress = filter.contractAddress;
|
|
656
703
|
|
|
657
|
-
const logs:
|
|
704
|
+
const logs: ExtendedContractClassLog[] = [];
|
|
658
705
|
|
|
659
706
|
for (; fromBlock < toBlock; fromBlock++) {
|
|
660
707
|
const block = this.l2Blocks[fromBlock - INITIAL_L2_BLOCK_NUM];
|
|
661
708
|
const blockLogs = this.contractClassLogsPerBlock.get(fromBlock);
|
|
662
709
|
|
|
663
710
|
if (blockLogs) {
|
|
664
|
-
for (;
|
|
665
|
-
const
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
)
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
711
|
+
for (let logIndex = 0; logIndex < blockLogs.length; logIndex++) {
|
|
712
|
+
const log = blockLogs[logIndex];
|
|
713
|
+
const thisTxEffect = block.data.body.txEffects.filter(effect => effect.contractClassLogs.includes(log))[0];
|
|
714
|
+
const thisTxIndexInBlock = block.data.body.txEffects.indexOf(thisTxEffect);
|
|
715
|
+
const thisLogIndexInTx = thisTxEffect.contractClassLogs.indexOf(log);
|
|
716
|
+
if (
|
|
717
|
+
(!txHash || thisTxEffect.txHash.equals(txHash)) &&
|
|
718
|
+
(!contractAddress || log.contractAddress.equals(contractAddress)) &&
|
|
719
|
+
thisTxIndexInBlock >= txIndexInBlock &&
|
|
720
|
+
thisLogIndexInTx >= logIndexInTx
|
|
721
|
+
) {
|
|
722
|
+
logs.push(
|
|
723
|
+
new ExtendedContractClassLog(new LogId(block.data.number, thisTxIndexInBlock, thisLogIndexInTx), log),
|
|
724
|
+
);
|
|
725
|
+
if (logs.length === this.maxLogs) {
|
|
726
|
+
return Promise.resolve({
|
|
727
|
+
logs,
|
|
728
|
+
maxLogsHit: true,
|
|
729
|
+
});
|
|
679
730
|
}
|
|
680
731
|
}
|
|
681
|
-
logIndexInTx = 0;
|
|
682
732
|
}
|
|
683
733
|
}
|
|
684
|
-
txIndexInBlock = 0;
|
|
685
734
|
}
|
|
686
735
|
|
|
687
736
|
return Promise.resolve({
|
|
@@ -690,15 +739,19 @@ export class MemoryArchiverStore implements ArchiverDataStore {
|
|
|
690
739
|
});
|
|
691
740
|
}
|
|
692
741
|
|
|
742
|
+
getLastBlockNumber(): number {
|
|
743
|
+
if (this.l2Blocks.length === 0) {
|
|
744
|
+
return INITIAL_L2_BLOCK_NUM - 1;
|
|
745
|
+
}
|
|
746
|
+
return this.l2Blocks[this.l2Blocks.length - 1].data.number;
|
|
747
|
+
}
|
|
748
|
+
|
|
693
749
|
/**
|
|
694
750
|
* Gets the number of the latest L2 block processed.
|
|
695
751
|
* @returns The number of the latest L2 block processed.
|
|
696
752
|
*/
|
|
697
753
|
public getSynchedL2BlockNumber(): Promise<number> {
|
|
698
|
-
|
|
699
|
-
return Promise.resolve(INITIAL_L2_BLOCK_NUM - 1);
|
|
700
|
-
}
|
|
701
|
-
return Promise.resolve(this.l2Blocks[this.l2Blocks.length - 1].data.number);
|
|
754
|
+
return Promise.resolve(this.getLastBlockNumber());
|
|
702
755
|
}
|
|
703
756
|
|
|
704
757
|
public getProvenL2BlockNumber(): Promise<number> {
|
package/src/factory.ts
CHANGED
|
@@ -1,51 +1,70 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type ArchiverApi, type Service, getComponentsVersionsFromConfig } from '@aztec/circuit-types';
|
|
3
|
-
import {
|
|
4
|
-
type ContractClassPublic,
|
|
5
|
-
computePublicBytecodeCommitment,
|
|
6
|
-
getContractClassFromArtifact,
|
|
7
|
-
} from '@aztec/circuits.js';
|
|
8
|
-
import { FunctionType, decodeFunctionSignature } from '@aztec/foundation/abi';
|
|
1
|
+
import type { BlobSinkClientInterface } from '@aztec/blob-sink/client';
|
|
9
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
10
|
-
import {
|
|
11
|
-
import { type DataStoreConfig } from '@aztec/kv-store/config';
|
|
3
|
+
import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
12
4
|
import { createStore } from '@aztec/kv-store/lmdb-v2';
|
|
13
5
|
import { TokenContractArtifact } from '@aztec/noir-contracts.js/Token';
|
|
14
6
|
import { TokenBridgeContractArtifact } from '@aztec/noir-contracts.js/TokenBridge';
|
|
15
|
-
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/
|
|
7
|
+
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
16
8
|
import { protocolContractNames, protocolContractTreeRoot } from '@aztec/protocol-contracts';
|
|
17
|
-
import {
|
|
9
|
+
import { BundledProtocolContractsProvider } from '@aztec/protocol-contracts/providers/bundle';
|
|
10
|
+
import { FunctionType, decodeFunctionSignature } from '@aztec/stdlib/abi';
|
|
11
|
+
import type { L2BlockSourceEventEmitter } from '@aztec/stdlib/block';
|
|
12
|
+
import {
|
|
13
|
+
type ContractClassPublic,
|
|
14
|
+
computePublicBytecodeCommitment,
|
|
15
|
+
getContractClassFromArtifact,
|
|
16
|
+
} from '@aztec/stdlib/contract';
|
|
17
|
+
import type { ArchiverApi, Service } from '@aztec/stdlib/interfaces/server';
|
|
18
|
+
import { getComponentsVersionsFromConfig } from '@aztec/stdlib/versioning';
|
|
18
19
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
19
20
|
|
|
20
21
|
import { Archiver } from './archiver/archiver.js';
|
|
21
|
-
import {
|
|
22
|
+
import type { ArchiverConfig } from './archiver/config.js';
|
|
22
23
|
import { KVArchiverDataStore } from './archiver/index.js';
|
|
23
24
|
import { createArchiverClient } from './rpc/index.js';
|
|
24
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Creates a local archiver.
|
|
28
|
+
* @param config - The archiver configuration.
|
|
29
|
+
* @param blobSinkClient - The blob sink client.
|
|
30
|
+
* @param opts - The options.
|
|
31
|
+
* @param telemetry - The telemetry client.
|
|
32
|
+
* @returns The local archiver.
|
|
33
|
+
*/
|
|
25
34
|
export async function createArchiver(
|
|
26
35
|
config: ArchiverConfig & DataStoreConfig,
|
|
27
36
|
blobSinkClient: BlobSinkClientInterface,
|
|
28
37
|
opts: { blockUntilSync: boolean } = { blockUntilSync: true },
|
|
29
38
|
telemetry: TelemetryClient = getTelemetryClient(),
|
|
30
|
-
): Promise<ArchiverApi &
|
|
39
|
+
): Promise<ArchiverApi & Service & L2BlockSourceEventEmitter> {
|
|
40
|
+
const store = await createStore('archiver', config, createLogger('archiver:lmdb'));
|
|
41
|
+
const archiverStore = new KVArchiverDataStore(store, config.maxLogs);
|
|
42
|
+
await registerProtocolContracts(archiverStore);
|
|
43
|
+
await registerCommonContracts(archiverStore);
|
|
44
|
+
return Archiver.createAndSync(config, archiverStore, { telemetry, blobSinkClient }, opts.blockUntilSync);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Creates a remote archiver client.
|
|
49
|
+
* @param config - The archiver configuration.
|
|
50
|
+
* @returns The remote archiver client.
|
|
51
|
+
*/
|
|
52
|
+
export function createRemoteArchiver(config: ArchiverConfig): ArchiverApi {
|
|
31
53
|
if (!config.archiverUrl) {
|
|
32
|
-
|
|
33
|
-
const archiverStore = new KVArchiverDataStore(store, config.maxLogs);
|
|
34
|
-
await registerProtocolContracts(archiverStore);
|
|
35
|
-
await registerCommonContracts(archiverStore);
|
|
36
|
-
return Archiver.createAndSync(config, archiverStore, { telemetry, blobSinkClient }, opts.blockUntilSync);
|
|
37
|
-
} else {
|
|
38
|
-
return createArchiverClient(
|
|
39
|
-
config.archiverUrl,
|
|
40
|
-
getComponentsVersionsFromConfig(config, protocolContractTreeRoot, getVKTreeRoot()),
|
|
41
|
-
);
|
|
54
|
+
throw new Error('Archiver URL is required');
|
|
42
55
|
}
|
|
56
|
+
|
|
57
|
+
return createArchiverClient(
|
|
58
|
+
config.archiverUrl,
|
|
59
|
+
getComponentsVersionsFromConfig(config, protocolContractTreeRoot, getVKTreeRoot()),
|
|
60
|
+
);
|
|
43
61
|
}
|
|
44
62
|
|
|
45
63
|
async function registerProtocolContracts(store: KVArchiverDataStore) {
|
|
46
64
|
const blockNumber = 0;
|
|
47
65
|
for (const name of protocolContractNames) {
|
|
48
|
-
const
|
|
66
|
+
const provider = new BundledProtocolContractsProvider();
|
|
67
|
+
const contract = await provider.getProtocolContractArtifact(name);
|
|
49
68
|
const contractClassPublic: ContractClassPublic = {
|
|
50
69
|
...contract.contractClass,
|
|
51
70
|
privateFunctions: [],
|
package/src/rpc/index.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type ArchiverApi,
|
|
3
|
-
ArchiverApiSchema,
|
|
4
|
-
type ComponentsVersions,
|
|
5
|
-
getVersioningResponseHandler,
|
|
6
|
-
} from '@aztec/circuit-types';
|
|
7
1
|
import { createSafeJsonRpcClient } from '@aztec/foundation/json-rpc/client';
|
|
2
|
+
import { type ArchiverApi, ArchiverApiSchema } from '@aztec/stdlib/interfaces/server';
|
|
3
|
+
import { type ComponentsVersions, getVersioningResponseHandler } from '@aztec/stdlib/versioning';
|
|
8
4
|
import { createTracedJsonRpcServer, makeTracedFetch } from '@aztec/telemetry-client';
|
|
9
5
|
|
|
10
6
|
export function createArchiverClient(
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import type { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import type { L2Block, L2BlockSource } from '@aztec/stdlib/block';
|
|
3
|
+
import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
3
4
|
|
|
4
5
|
import { MockL1ToL2MessageSource } from './mock_l1_to_l2_message_source.js';
|
|
5
6
|
import { MockL2BlockSource } from './mock_l2_block_source.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* A mocked implementation of L1ToL2MessageSource to be used in tests.
|
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type L1RollupConstants,
|
|
3
|
-
L2Block,
|
|
4
|
-
L2BlockHash,
|
|
5
|
-
type L2BlockSource,
|
|
6
|
-
type L2Tips,
|
|
7
|
-
type TxHash,
|
|
8
|
-
TxReceipt,
|
|
9
|
-
TxStatus,
|
|
10
|
-
getSlotRangeForEpoch,
|
|
11
|
-
} from '@aztec/circuit-types';
|
|
12
|
-
import { type BlockHeader, EthAddress } from '@aztec/circuits.js';
|
|
13
1
|
import { DefaultL1ContractsConfig } from '@aztec/ethereum';
|
|
2
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
14
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
+
import { L2Block, L2BlockHash, type L2BlockSource, type L2Tips } from '@aztec/stdlib/block';
|
|
5
|
+
import { type L1RollupConstants, getSlotRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
|
6
|
+
import { type BlockHeader, TxHash, TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
15
7
|
|
|
16
8
|
/**
|
|
17
9
|
* A mocked implementation of L2BlockSource to be used in tests.
|
|
@@ -172,9 +164,18 @@ export class MockL2BlockSource implements L2BlockSource {
|
|
|
172
164
|
const finalizedBlock = this.l2Blocks[finalized - 1];
|
|
173
165
|
|
|
174
166
|
return {
|
|
175
|
-
latest: {
|
|
176
|
-
|
|
177
|
-
|
|
167
|
+
latest: {
|
|
168
|
+
number: latest,
|
|
169
|
+
hash: (await latestBlock?.hash())?.toString(),
|
|
170
|
+
},
|
|
171
|
+
proven: {
|
|
172
|
+
number: proven,
|
|
173
|
+
hash: (await provenBlock?.hash())?.toString(),
|
|
174
|
+
},
|
|
175
|
+
finalized: {
|
|
176
|
+
number: finalized,
|
|
177
|
+
hash: (await finalizedBlock?.hash())?.toString(),
|
|
178
|
+
},
|
|
178
179
|
};
|
|
179
180
|
}
|
|
180
181
|
|