@aztec/archiver 0.80.0 → 0.82.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.
- package/dest/archiver/archiver.d.ts +8 -20
- package/dest/archiver/archiver.d.ts.map +1 -1
- package/dest/archiver/archiver.js +72 -102
- package/dest/archiver/archiver_store.d.ts +5 -19
- package/dest/archiver/archiver_store.d.ts.map +1 -1
- package/dest/archiver/archiver_store_test_suite.d.ts.map +1 -1
- package/dest/archiver/archiver_store_test_suite.js +105 -142
- package/dest/archiver/config.d.ts +2 -0
- package/dest/archiver/config.d.ts.map +1 -1
- package/dest/archiver/config.js +5 -0
- package/dest/archiver/data_retrieval.d.ts +3 -4
- package/dest/archiver/data_retrieval.d.ts.map +1 -1
- package/dest/archiver/data_retrieval.js +8 -3
- package/dest/archiver/index.d.ts +1 -2
- package/dest/archiver/index.d.ts.map +1 -1
- package/dest/archiver/index.js +0 -1
- package/dest/archiver/kv_archiver_store/block_store.d.ts +6 -6
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/block_store.js +24 -21
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +6 -14
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.js +2 -19
- package/dest/archiver/kv_archiver_store/log_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/log_store.js +11 -42
- package/dest/archiver/structs/published.d.ts +1 -10
- package/dest/archiver/structs/published.d.ts.map +1 -1
- package/dest/archiver/structs/published.js +1 -1
- package/dest/factory.d.ts +1 -1
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +6 -24
- package/dest/test/mock_l2_block_source.d.ts +10 -0
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +16 -0
- package/package.json +12 -13
- package/src/archiver/archiver.ts +86 -124
- package/src/archiver/archiver_store.ts +5 -21
- package/src/archiver/archiver_store_test_suite.ts +116 -147
- package/src/archiver/config.ts +8 -0
- package/src/archiver/data_retrieval.ts +12 -11
- package/src/archiver/index.ts +1 -2
- package/src/archiver/kv_archiver_store/block_store.ts +28 -27
- package/src/archiver/kv_archiver_store/kv_archiver_store.ts +6 -27
- package/src/archiver/kv_archiver_store/log_store.ts +12 -59
- package/src/archiver/structs/published.ts +1 -11
- package/src/factory.ts +3 -28
- package/src/test/mock_l2_block_source.ts +18 -0
- package/dest/archiver/kv_archiver_store/nullifier_store.d.ts +0 -12
- package/dest/archiver/kv_archiver_store/nullifier_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/nullifier_store.js +0 -73
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts +0 -175
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts.map +0 -1
- package/dest/archiver/memory_archiver_store/memory_archiver_store.js +0 -636
- package/src/archiver/kv_archiver_store/nullifier_store.ts +0 -97
- package/src/archiver/memory_archiver_store/memory_archiver_store.ts +0 -801
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block_store.d.ts","sourceRoot":"","sources":["../../../src/archiver/kv_archiver_store/block_store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"block_store.d.ts","sourceRoot":"","sources":["../../../src/archiver/kv_archiver_store/block_store.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAA6C,MAAM,iBAAiB,CAAC;AACpG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAQ,KAAK,OAAO,EAAwB,MAAM,qBAAqB,CAAC;AAE/E,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE5E,OAAO,KAAK,EAAmB,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEjF,OAAO,EAAE,SAAS,EAAE,KAAK,QA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AI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAItD,uBAAuB,CAAC,aAAa,EAAE,MAAM;IAIvC,sBAAsB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI/C,sBAAsB,CAAC,WAAW,EAAE,MAAM;CAe3C"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
2
|
+
import { Signature } from '@aztec/foundation/eth-signature';
|
|
2
3
|
import { toArray } from '@aztec/foundation/iterable';
|
|
3
4
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
5
|
import { Body, L2Block, L2BlockHash } from '@aztec/stdlib/block';
|
|
@@ -38,19 +39,20 @@ export { TxReceipt } from '@aztec/stdlib/tx';
|
|
|
38
39
|
}
|
|
39
40
|
return await this.db.transactionAsync(async ()=>{
|
|
40
41
|
for (const block of blocks){
|
|
41
|
-
await this.#blocks.set(block.
|
|
42
|
-
header: block.
|
|
43
|
-
archive: block.
|
|
44
|
-
l1: block.l1
|
|
42
|
+
await this.#blocks.set(block.block.number, {
|
|
43
|
+
header: block.block.header.toBuffer(),
|
|
44
|
+
archive: block.block.archive.toBuffer(),
|
|
45
|
+
l1: block.l1,
|
|
46
|
+
signatures: block.signatures.map((sig)=>sig.toBuffer())
|
|
45
47
|
});
|
|
46
|
-
for(let i = 0; i < block.
|
|
47
|
-
const txEffect = block.
|
|
48
|
+
for(let i = 0; i < block.block.body.txEffects.length; i++){
|
|
49
|
+
const txEffect = block.block.body.txEffects[i];
|
|
48
50
|
await this.#txIndex.set(txEffect.txHash.toString(), [
|
|
49
|
-
block.
|
|
51
|
+
block.block.number,
|
|
50
52
|
i
|
|
51
53
|
]);
|
|
52
54
|
}
|
|
53
|
-
await this.#blockBodies.set((await block.
|
|
55
|
+
await this.#blockBodies.set((await block.block.hash()).toString(), block.block.body.toBuffer());
|
|
54
56
|
}
|
|
55
57
|
await this.#lastSynchedL1Block.set(blocks[blocks.length - 1].l1.blockNumber);
|
|
56
58
|
return true;
|
|
@@ -75,9 +77,9 @@ export { TxReceipt } from '@aztec/stdlib/tx';
|
|
|
75
77
|
this.#log.warn(`Cannot remove block ${blockNumber} from the store since we don't have it`);
|
|
76
78
|
continue;
|
|
77
79
|
}
|
|
78
|
-
await this.#blocks.delete(block.
|
|
79
|
-
await Promise.all(block.
|
|
80
|
-
const blockHash = (await block.
|
|
80
|
+
await this.#blocks.delete(block.block.number);
|
|
81
|
+
await Promise.all(block.block.body.txEffects.map((tx)=>this.#txIndex.delete(tx.txHash.toString())));
|
|
82
|
+
const blockHash = (await block.block.hash()).toString();
|
|
81
83
|
await this.#blockBodies.delete(blockHash);
|
|
82
84
|
this.#log.debug(`Unwound block ${blockNumber} ${blockHash}`);
|
|
83
85
|
}
|
|
@@ -91,8 +93,7 @@ export { TxReceipt } from '@aztec/stdlib/tx';
|
|
|
91
93
|
* @returns The requested L2 blocks
|
|
92
94
|
*/ async *getBlocks(start, limit) {
|
|
93
95
|
for await (const blockStorage of this.#blocks.valuesAsync(this.#computeBlockRange(start, limit))){
|
|
94
|
-
|
|
95
|
-
yield block;
|
|
96
|
+
yield await this.getBlockFromBlockStorage(blockStorage);
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
99
|
/**
|
|
@@ -125,10 +126,12 @@ export { TxReceipt } from '@aztec/stdlib/tx';
|
|
|
125
126
|
throw new Error(`Could not retrieve body for block ${header.globalVariables.blockNumber.toNumber()} ${blockHash}`);
|
|
126
127
|
}
|
|
127
128
|
const body = Body.fromBuffer(blockBodyBuffer);
|
|
128
|
-
const
|
|
129
|
+
const block = new L2Block(archive, header, body);
|
|
130
|
+
const signatures = blockStorage.signatures.map(Signature.fromBuffer);
|
|
129
131
|
return {
|
|
130
|
-
|
|
131
|
-
l1: blockStorage.l1
|
|
132
|
+
block,
|
|
133
|
+
l1: blockStorage.l1,
|
|
134
|
+
signatures
|
|
132
135
|
};
|
|
133
136
|
}
|
|
134
137
|
/**
|
|
@@ -145,9 +148,9 @@ export { TxReceipt } from '@aztec/stdlib/tx';
|
|
|
145
148
|
return undefined;
|
|
146
149
|
}
|
|
147
150
|
return {
|
|
148
|
-
data: block.
|
|
149
|
-
l2BlockNumber: block.
|
|
150
|
-
l2BlockHash: (await block.
|
|
151
|
+
data: block.block.body.txEffects[txIndex],
|
|
152
|
+
l2BlockNumber: block.block.number,
|
|
153
|
+
l2BlockHash: (await block.block.hash()).toString()
|
|
151
154
|
};
|
|
152
155
|
}
|
|
153
156
|
/**
|
|
@@ -160,8 +163,8 @@ export { TxReceipt } from '@aztec/stdlib/tx';
|
|
|
160
163
|
return undefined;
|
|
161
164
|
}
|
|
162
165
|
const block = await this.getBlock(blockNumber);
|
|
163
|
-
const tx = block.
|
|
164
|
-
return new TxReceipt(txHash, TxReceipt.statusFromRevertCode(tx.revertCode), '', tx.transactionFee.toBigInt(), L2BlockHash.fromField(await block.
|
|
166
|
+
const tx = block.block.body.txEffects[txIndex];
|
|
167
|
+
return new TxReceipt(txHash, TxReceipt.statusFromRevertCode(tx.revertCode), '', tx.transactionFee.toBigInt(), L2BlockHash.fromField(await block.block.hash()), block.block.number);
|
|
165
168
|
}
|
|
166
169
|
/**
|
|
167
170
|
* Looks up which block included the requested tx effect.
|
|
@@ -2,7 +2,7 @@ import type { Fr } from '@aztec/foundation/fields';
|
|
|
2
2
|
import type { AztecAsyncKVStore, StoreSize } from '@aztec/kv-store';
|
|
3
3
|
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
4
4
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
-
import type {
|
|
5
|
+
import type { L2Block } from '@aztec/stdlib/block';
|
|
6
6
|
import type { ContractClassPublic, ContractInstanceUpdateWithAddress, ContractInstanceWithAddress, ExecutablePrivateFunctionWithMembershipProof, UnconstrainedFunctionWithMembershipProof } from '@aztec/stdlib/contract';
|
|
7
7
|
import type { GetContractClassLogsResponse, GetPublicLogsResponse } from '@aztec/stdlib/interfaces/client';
|
|
8
8
|
import { type LogFilter, PrivateLog, type TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
@@ -10,7 +10,7 @@ import type { InboxLeaf } from '@aztec/stdlib/messaging';
|
|
|
10
10
|
import type { BlockHeader, TxHash, TxReceipt } from '@aztec/stdlib/tx';
|
|
11
11
|
import type { ArchiverDataStore, ArchiverL1SynchPoint } from '../archiver_store.js';
|
|
12
12
|
import type { DataRetrieval } from '../structs/data_retrieval.js';
|
|
13
|
-
import type {
|
|
13
|
+
import type { PublishedL2Block } from '../structs/published.js';
|
|
14
14
|
/**
|
|
15
15
|
* LMDB implementation of the ArchiverDataStore interface.
|
|
16
16
|
*/
|
|
@@ -24,7 +24,7 @@ export declare class KVArchiverDataStore implements ArchiverDataStore {
|
|
|
24
24
|
registerContractFunctionSignatures(_address: AztecAddress, signatures: string[]): Promise<void>;
|
|
25
25
|
getContractClass(id: Fr): Promise<ContractClassPublic | undefined>;
|
|
26
26
|
getContractClassIds(): Promise<Fr[]>;
|
|
27
|
-
getContractInstance(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined>;
|
|
27
|
+
getContractInstance(address: AztecAddress, blockNumber: number): Promise<ContractInstanceWithAddress | undefined>;
|
|
28
28
|
addContractClasses(data: ContractClassPublic[], bytecodeCommitments: Fr[], blockNumber: number): Promise<boolean>;
|
|
29
29
|
deleteContractClasses(data: ContractClassPublic[], blockNumber: number): Promise<boolean>;
|
|
30
30
|
getBytecodeCommitment(contractClassId: Fr): Promise<Fr | undefined>;
|
|
@@ -38,7 +38,7 @@ export declare class KVArchiverDataStore implements ArchiverDataStore {
|
|
|
38
38
|
* @param blocks - The L2 blocks to be added to the store and the last processed L1 block.
|
|
39
39
|
* @returns True if the operation is successful.
|
|
40
40
|
*/
|
|
41
|
-
addBlocks(blocks:
|
|
41
|
+
addBlocks(blocks: PublishedL2Block[]): Promise<boolean>;
|
|
42
42
|
/**
|
|
43
43
|
* Unwinds blocks from the database
|
|
44
44
|
* @param from - The tip of the chain, passed for verification purposes,
|
|
@@ -54,7 +54,7 @@ export declare class KVArchiverDataStore implements ArchiverDataStore {
|
|
|
54
54
|
* @param limit - The number of blocks to return.
|
|
55
55
|
* @returns The requested L2 blocks
|
|
56
56
|
*/
|
|
57
|
-
getBlocks(start: number, limit: number): Promise<
|
|
57
|
+
getBlocks(start: number, limit: number): Promise<PublishedL2Block[]>;
|
|
58
58
|
/**
|
|
59
59
|
* Gets up to `limit` amount of L2 blocks headers starting from `from`.
|
|
60
60
|
*
|
|
@@ -68,7 +68,7 @@ export declare class KVArchiverDataStore implements ArchiverDataStore {
|
|
|
68
68
|
* @param txHash - The txHash of the tx corresponding to the tx effect.
|
|
69
69
|
* @returns The requested tx effect (or undefined if not found).
|
|
70
70
|
*/
|
|
71
|
-
getTxEffect(txHash: TxHash): Promise<InBlock<import("@aztec/stdlib/tx").TxEffect> | undefined>;
|
|
71
|
+
getTxEffect(txHash: TxHash): Promise<import("@aztec/stdlib/block").InBlock<import("@aztec/stdlib/tx").TxEffect> | undefined>;
|
|
72
72
|
/**
|
|
73
73
|
* Gets a receipt of a settled tx.
|
|
74
74
|
* @param txHash - The hash of a tx we try to get the receipt for.
|
|
@@ -82,14 +82,6 @@ export declare class KVArchiverDataStore implements ArchiverDataStore {
|
|
|
82
82
|
*/
|
|
83
83
|
addLogs(blocks: L2Block[]): Promise<boolean>;
|
|
84
84
|
deleteLogs(blocks: L2Block[]): Promise<boolean>;
|
|
85
|
-
/**
|
|
86
|
-
* Append new nullifiers to the store's list.
|
|
87
|
-
* @param blocks - The blocks for which to add the nullifiers.
|
|
88
|
-
* @returns True if the operation is successful.
|
|
89
|
-
*/
|
|
90
|
-
addNullifiers(blocks: L2Block[]): Promise<boolean>;
|
|
91
|
-
deleteNullifiers(blocks: L2Block[]): Promise<boolean>;
|
|
92
|
-
findNullifiersIndexesWithBlock(blockNumber: number, nullifiers: Fr[]): Promise<(InBlock<bigint> | undefined)[]>;
|
|
93
85
|
getTotalL1ToL2MessageCount(): Promise<bigint>;
|
|
94
86
|
/**
|
|
95
87
|
* Append L1 to L2 messages to the store.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kv_archiver_store.d.ts","sourceRoot":"","sources":["../../../src/archiver/kv_archiver_store/kv_archiver_store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAGnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"kv_archiver_store.d.ts","sourceRoot":"","sources":["../../../src/archiver/kv_archiver_store/kv_archiver_store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAGnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EACV,mBAAmB,EACnB,iCAAiC,EACjC,2BAA2B,EAC3B,4CAA4C,EAC5C,wCAAwC,EACzC,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,4BAA4B,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAC3G,OAAO,EAAE,KAAK,SAAS,EAAE,UAAU,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACpF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EA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CAAC;IAI/C,0BAA0B,IAAI,OAAO,CAAC,MAAM,CAAC;IAI7C;;;;OAIG;IACH,iBAAiB,CAAC,QAAQ,EAAE,aAAa,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAIvE;;;;OAIG;IACH,qBAAqB,CAAC,aAAa,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAIrE;;;;OAIG;IACH,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,EAAE,CAAC;IAIrD;;;;;OAKG;IACH,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAIlE;;;;;OAKG;IACH,aAAa,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC;IAQrD;;;;OAIG;IACH,aAAa,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAQhE;;;;OAIG;IACH,oBAAoB,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,4BAA4B,CAAC;IAQ9E;;;OAGG;IACH,uBAAuB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI1C,sBAAsB,IAAI,OAAO,CAAC,MAAM,CAAC;IAInC,sBAAsB,CAAC,WAAW,EAAE,MAAM;IAI1C,4BAA4B,CAAC,aAAa,EAAE,MAAM;IAIlD,8BAA8B,CAAC,aAAa,EAAE,MAAM;IAI1D;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAW7C,YAAY,IAAI,OAAO,CAAC,SAAS,CAAC;CAG1C"}
|
|
@@ -6,7 +6,6 @@ import { ContractClassStore } from './contract_class_store.js';
|
|
|
6
6
|
import { ContractInstanceStore } from './contract_instance_store.js';
|
|
7
7
|
import { LogStore } from './log_store.js';
|
|
8
8
|
import { MessageStore } from './message_store.js';
|
|
9
|
-
import { NullifierStore } from './nullifier_store.js';
|
|
10
9
|
/**
|
|
11
10
|
* LMDB implementation of the ArchiverDataStore interface.
|
|
12
11
|
*/ export class KVArchiverDataStore {
|
|
@@ -14,7 +13,6 @@ import { NullifierStore } from './nullifier_store.js';
|
|
|
14
13
|
static SCHEMA_VERSION = 1;
|
|
15
14
|
#blockStore;
|
|
16
15
|
#logStore;
|
|
17
|
-
#nullifierStore;
|
|
18
16
|
#messageStore;
|
|
19
17
|
#contractClassStore;
|
|
20
18
|
#contractInstanceStore;
|
|
@@ -29,7 +27,6 @@ import { NullifierStore } from './nullifier_store.js';
|
|
|
29
27
|
this.#messageStore = new MessageStore(db);
|
|
30
28
|
this.#contractClassStore = new ContractClassStore(db);
|
|
31
29
|
this.#contractInstanceStore = new ContractInstanceStore(db);
|
|
32
|
-
this.#nullifierStore = new NullifierStore(db);
|
|
33
30
|
}
|
|
34
31
|
// TODO: These function names are in memory only as they are for development/debugging. They require the full contract
|
|
35
32
|
// artifact supplied to the node out of band. This should be reviewed and potentially removed as part of
|
|
@@ -53,9 +50,8 @@ import { NullifierStore } from './nullifier_store.js';
|
|
|
53
50
|
getContractClassIds() {
|
|
54
51
|
return this.#contractClassStore.getContractClassIds();
|
|
55
52
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return contract;
|
|
53
|
+
getContractInstance(address, blockNumber) {
|
|
54
|
+
return this.#contractInstanceStore.getContractInstance(address, blockNumber);
|
|
59
55
|
}
|
|
60
56
|
async addContractClasses(data, bytecodeCommitments, blockNumber) {
|
|
61
57
|
return (await Promise.all(data.map((c, i)=>this.#contractClassStore.addContractClass(c, bytecodeCommitments[i], blockNumber)))).every(Boolean);
|
|
@@ -139,19 +135,6 @@ import { NullifierStore } from './nullifier_store.js';
|
|
|
139
135
|
deleteLogs(blocks) {
|
|
140
136
|
return this.#logStore.deleteLogs(blocks);
|
|
141
137
|
}
|
|
142
|
-
/**
|
|
143
|
-
* Append new nullifiers to the store's list.
|
|
144
|
-
* @param blocks - The blocks for which to add the nullifiers.
|
|
145
|
-
* @returns True if the operation is successful.
|
|
146
|
-
*/ addNullifiers(blocks) {
|
|
147
|
-
return this.#nullifierStore.addNullifiers(blocks);
|
|
148
|
-
}
|
|
149
|
-
deleteNullifiers(blocks) {
|
|
150
|
-
return this.#nullifierStore.deleteNullifiers(blocks);
|
|
151
|
-
}
|
|
152
|
-
findNullifiersIndexesWithBlock(blockNumber, nullifiers) {
|
|
153
|
-
return this.#nullifierStore.findNullifiersIndexesWithBlock(blockNumber, nullifiers);
|
|
154
|
-
}
|
|
155
138
|
getTotalL1ToL2MessageCount() {
|
|
156
139
|
return this.#messageStore.getTotalL1ToL2MessageCount();
|
|
157
140
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log_store.d.ts","sourceRoot":"","sources":["../../../src/archiver/kv_archiver_store/log_store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAGnD,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,4BAA4B,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAC3G,OAAO,EAIL,KAAK,SAAS,EAEd,UAAU,EAEV,aAAa,EACd,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;GAEG;AACH,qBAAa,QAAQ;;IASP,OAAO,CAAC,EAAE;IAAqB,OAAO,CAAC,UAAU;gBAAzC,EAAE,EAAE,iBAAiB,EAAU,UAAU,EAAE,UAAU,EAAE,eAAe,GAAE,MAAa;
|
|
1
|
+
{"version":3,"file":"log_store.d.ts","sourceRoot":"","sources":["../../../src/archiver/kv_archiver_store/log_store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EA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/constants';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { BufferReader, numToUInt32BE } from '@aztec/foundation/serialize';
|
|
4
4
|
import { ContractClassLog, ExtendedContractClassLog, ExtendedPublicLog, LogId, PrivateLog, PublicLog, TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
@@ -25,7 +25,7 @@ import { ContractClassLog, ExtendedContractClassLog, ExtendedPublicLog, LogId, P
|
|
|
25
25
|
this.#contractClassLogsByBlock = db.openMap('archiver_contract_class_logs_by_block');
|
|
26
26
|
this.#logsMaxPageSize = logsMaxPageSize;
|
|
27
27
|
}
|
|
28
|
-
#
|
|
28
|
+
#extractTaggedLogs(block) {
|
|
29
29
|
const taggedLogs = new Map();
|
|
30
30
|
const dataStartIndexForBlock = block.header.state.partial.noteHashTree.nextAvailableLeafIndex - block.body.txEffects.length * MAX_NOTE_HASHES_PER_TX;
|
|
31
31
|
block.body.txEffects.forEach((txEffect, txIndex)=>{
|
|
@@ -33,45 +33,16 @@ import { ContractClassLog, ExtendedContractClassLog, ExtendedPublicLog, LogId, P
|
|
|
33
33
|
const dataStartIndexForTx = dataStartIndexForBlock + txIndex * MAX_NOTE_HASHES_PER_TX;
|
|
34
34
|
txEffect.privateLogs.forEach((log)=>{
|
|
35
35
|
const tag = log.fields[0];
|
|
36
|
+
this.#log.debug(`Found private log with tag ${tag.toString()} in block ${block.number}`);
|
|
36
37
|
const currentLogs = taggedLogs.get(tag.toString()) ?? [];
|
|
37
|
-
currentLogs.push(new TxScopedL2Log(txHash, dataStartIndexForTx, block.number,
|
|
38
|
+
currentLogs.push(new TxScopedL2Log(txHash, dataStartIndexForTx, block.number, log).toBuffer());
|
|
38
39
|
taggedLogs.set(tag.toString(), currentLogs);
|
|
39
40
|
});
|
|
40
|
-
});
|
|
41
|
-
return taggedLogs;
|
|
42
|
-
}
|
|
43
|
-
#extractTaggedLogsFromPublic(block) {
|
|
44
|
-
const taggedLogs = new Map();
|
|
45
|
-
const dataStartIndexForBlock = block.header.state.partial.noteHashTree.nextAvailableLeafIndex - block.body.txEffects.length * MAX_NOTE_HASHES_PER_TX;
|
|
46
|
-
block.body.txEffects.forEach((txEffect, txIndex)=>{
|
|
47
|
-
const txHash = txEffect.txHash;
|
|
48
|
-
const dataStartIndexForTx = dataStartIndexForBlock + txIndex * MAX_NOTE_HASHES_PER_TX;
|
|
49
41
|
txEffect.publicLogs.forEach((log)=>{
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
// See macros/note/mod/ and see how finalization_log[0] is constructed, to understand this monstrosity. (It wasn't me).
|
|
53
|
-
// Search the codebase for "disgusting encoding" to see other hardcoded instances of this encoding, that you might need to change if you ever find yourself here.
|
|
54
|
-
if (!firstFieldBuf.subarray(0, 27).equals(Buffer.alloc(27)) || firstFieldBuf[29] !== 0) {
|
|
55
|
-
// See parseLogFromPublic - the first field of a tagged log is 5 bytes structured:
|
|
56
|
-
// [ publicLen[0], publicLen[1], 0, privateLen[0], privateLen[1]]
|
|
57
|
-
this.#log.warn(`Skipping public log with invalid first field: ${log.log[0]}`);
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
// Check that the length values line up with the log contents
|
|
61
|
-
const publicValuesLength = firstFieldBuf.subarray(-5).readUint16BE();
|
|
62
|
-
const privateValuesLength = firstFieldBuf.subarray(-5).readUint16BE(3);
|
|
63
|
-
// Add 1 for the first field holding lengths
|
|
64
|
-
const totalLogLength = 1 + publicValuesLength + privateValuesLength;
|
|
65
|
-
// Note that zeroes can be valid log values, so we can only assert that we do not go over the given length
|
|
66
|
-
if (totalLogLength > PUBLIC_LOG_DATA_SIZE_IN_FIELDS || log.log.slice(totalLogLength).find((f)=>!f.isZero())) {
|
|
67
|
-
this.#log.warn(`Skipping invalid tagged public log with first field: ${log.log[0]}`);
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
// The first elt stores lengths as above => tag is in fields[1]
|
|
71
|
-
const tag = log.log[1];
|
|
72
|
-
this.#log.debug(`Found tagged public log with tag ${tag.toString()} in block ${block.number}`);
|
|
42
|
+
const tag = log.log[0];
|
|
43
|
+
this.#log.debug(`Found public log with tag ${tag.toString()} in block ${block.number}`);
|
|
73
44
|
const currentLogs = taggedLogs.get(tag.toString()) ?? [];
|
|
74
|
-
currentLogs.push(new TxScopedL2Log(txHash, dataStartIndexForTx, block.number,
|
|
45
|
+
currentLogs.push(new TxScopedL2Log(txHash, dataStartIndexForTx, block.number, log).toBuffer());
|
|
75
46
|
taggedLogs.set(tag.toString(), currentLogs);
|
|
76
47
|
});
|
|
77
48
|
});
|
|
@@ -82,10 +53,7 @@ import { ContractClassLog, ExtendedContractClassLog, ExtendedPublicLog, LogId, P
|
|
|
82
53
|
* @param blocks - The blocks for which to add the logs.
|
|
83
54
|
* @returns True if the operation is successful.
|
|
84
55
|
*/ addLogs(blocks) {
|
|
85
|
-
const taggedLogsToAdd = blocks.
|
|
86
|
-
this.#extractTaggedLogsFromPrivate(block),
|
|
87
|
-
this.#extractTaggedLogsFromPublic(block)
|
|
88
|
-
]).reduce((acc, val)=>{
|
|
56
|
+
const taggedLogsToAdd = blocks.map((block)=>this.#extractTaggedLogs(block)).reduce((acc, val)=>{
|
|
89
57
|
for (const [tag, logs] of val.entries()){
|
|
90
58
|
const currentLogs = acc.get(tag) ?? [];
|
|
91
59
|
acc.set(tag, currentLogs.concat(logs));
|
|
@@ -137,7 +105,8 @@ import { ContractClassLog, ExtendedContractClassLog, ExtendedPublicLog, LogId, P
|
|
|
137
105
|
await Promise.all(blocks.map((block)=>Promise.all([
|
|
138
106
|
this.#privateLogsByBlock.delete(block.number),
|
|
139
107
|
this.#publicLogsByBlock.delete(block.number),
|
|
140
|
-
this.#logTagsByBlock.delete(block.number)
|
|
108
|
+
this.#logTagsByBlock.delete(block.number),
|
|
109
|
+
this.#contractClassLogsByBlock.delete(block.number)
|
|
141
110
|
])));
|
|
142
111
|
await Promise.all(tagsToDelete.map((tag)=>this.#logsByTag.delete(tag.toString())));
|
|
143
112
|
return true;
|
|
@@ -168,7 +137,7 @@ import { ContractClassLog, ExtendedContractClassLog, ExtendedPublicLog, LogId, P
|
|
|
168
137
|
* that tag.
|
|
169
138
|
*/ async getLogsByTags(tags) {
|
|
170
139
|
const logs = await Promise.all(tags.map((tag)=>this.#logsByTag.getAsync(tag.toString())));
|
|
171
|
-
return logs.map((
|
|
140
|
+
return logs.map((logBuffers)=>logBuffers?.map((logBuffer)=>TxScopedL2Log.fromBuffer(logBuffer)) ?? []);
|
|
172
141
|
}
|
|
173
142
|
/**
|
|
174
143
|
* Gets public logs based on the provided filter.
|
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export type L1Published<T> = {
|
|
3
|
-
data: T;
|
|
4
|
-
l1: L1PublishedData;
|
|
5
|
-
};
|
|
6
|
-
export type L1PublishedData = {
|
|
7
|
-
blockNumber: bigint;
|
|
8
|
-
timestamp: bigint;
|
|
9
|
-
blockHash: string;
|
|
10
|
-
};
|
|
1
|
+
export type { PublishedL2Block, L1PublishedData } from '@aztec/stdlib/block';
|
|
11
2
|
//# sourceMappingURL=published.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"published.d.ts","sourceRoot":"","sources":["../../../src/archiver/structs/published.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"published.d.ts","sourceRoot":"","sources":["../../../src/archiver/structs/published.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export { };
|
package/dest/factory.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ import type { ArchiverConfig } from './archiver/config.js';
|
|
|
12
12
|
* @param telemetry - The telemetry client.
|
|
13
13
|
* @returns The local archiver.
|
|
14
14
|
*/
|
|
15
|
-
export declare function createArchiver(
|
|
15
|
+
export declare function createArchiver(_config: ArchiverConfig & DataStoreConfig, blobSinkClient: BlobSinkClientInterface, opts?: {
|
|
16
16
|
blockUntilSync: boolean;
|
|
17
17
|
}, telemetry?: TelemetryClient): Promise<ArchiverApi & Service & L2BlockSourceEventEmitter>;
|
|
18
18
|
/**
|
package/dest/factory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAEvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAEvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAM9D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAErE,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAE5E,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,yBAAyB,CAAC;AAGnF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAI3D;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,cAAc,GAAG,eAAe,EACzC,cAAc,EAAE,uBAAuB,EACvC,IAAI,GAAE;IAAE,cAAc,EAAE,OAAO,CAAA;CAA6B,EAC5D,SAAS,GAAE,eAAsC,GAChD,OAAO,CAAC,WAAW,GAAG,OAAO,GAAG,yBAAyB,CAAC,CAW5D;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,GAAG,WAAW,CASxE"}
|
package/dest/factory.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
2
|
import { createStore } from '@aztec/kv-store/lmdb-v2';
|
|
3
|
-
import { TokenContractArtifact } from '@aztec/noir-contracts.js/Token';
|
|
4
|
-
import { TokenBridgeContractArtifact } from '@aztec/noir-contracts.js/TokenBridge';
|
|
5
3
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
6
4
|
import { protocolContractNames, protocolContractTreeRoot } from '@aztec/protocol-contracts';
|
|
7
5
|
import { BundledProtocolContractsProvider } from '@aztec/protocol-contracts/providers/bundle';
|
|
8
6
|
import { FunctionType, decodeFunctionSignature } from '@aztec/stdlib/abi';
|
|
9
|
-
import { computePublicBytecodeCommitment
|
|
7
|
+
import { computePublicBytecodeCommitment } from '@aztec/stdlib/contract';
|
|
10
8
|
import { getComponentsVersionsFromConfig } from '@aztec/stdlib/versioning';
|
|
11
9
|
import { getTelemetryClient } from '@aztec/telemetry-client';
|
|
12
10
|
import { Archiver } from './archiver/archiver.js';
|
|
@@ -19,13 +17,16 @@ import { createArchiverClient } from './rpc/index.js';
|
|
|
19
17
|
* @param opts - The options.
|
|
20
18
|
* @param telemetry - The telemetry client.
|
|
21
19
|
* @returns The local archiver.
|
|
22
|
-
*/ export async function createArchiver(
|
|
20
|
+
*/ export async function createArchiver(_config, blobSinkClient, opts = {
|
|
23
21
|
blockUntilSync: true
|
|
24
22
|
}, telemetry = getTelemetryClient()) {
|
|
23
|
+
const config = {
|
|
24
|
+
..._config,
|
|
25
|
+
dataStoreMapSizeKB: _config.archiverStoreMapSizeKb ?? _config.dataStoreMapSizeKB
|
|
26
|
+
};
|
|
25
27
|
const store = await createStore('archiver', KVArchiverDataStore.SCHEMA_VERSION, config, createLogger('archiver:lmdb'));
|
|
26
28
|
const archiverStore = new KVArchiverDataStore(store, config.maxLogs);
|
|
27
29
|
await registerProtocolContracts(archiverStore);
|
|
28
|
-
await registerCommonContracts(archiverStore);
|
|
29
30
|
return Archiver.createAndSync(config, archiverStore, {
|
|
30
31
|
telemetry,
|
|
31
32
|
blobSinkClient
|
|
@@ -64,22 +65,3 @@ async function registerProtocolContracts(store) {
|
|
|
64
65
|
], blockNumber);
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
|
-
// TODO(#10007): Remove this method. We are explicitly registering these contracts
|
|
68
|
-
// here to ensure they are available to all nodes and all prover nodes, since the PXE
|
|
69
|
-
// was tweaked to automatically push contract classes to the node it is registered,
|
|
70
|
-
// but other nodes in the network may require the contract classes to be registered as well.
|
|
71
|
-
// TODO(#10007): Remove the dependency on noir-contracts.js from this package once we remove this.
|
|
72
|
-
async function registerCommonContracts(store) {
|
|
73
|
-
const blockNumber = 0;
|
|
74
|
-
const artifacts = [
|
|
75
|
-
TokenBridgeContractArtifact,
|
|
76
|
-
TokenContractArtifact
|
|
77
|
-
];
|
|
78
|
-
const classes = await Promise.all(artifacts.map(async (artifact)=>({
|
|
79
|
-
...await getContractClassFromArtifact(artifact),
|
|
80
|
-
privateFunctions: [],
|
|
81
|
-
unconstrainedFunctions: []
|
|
82
|
-
})));
|
|
83
|
-
const bytecodeCommitments = await Promise.all(classes.map((x)=>computePublicBytecodeCommitment(x.packedBytecode)));
|
|
84
|
-
await store.addContractClasses(classes, bytecodeCommitments, blockNumber);
|
|
85
|
-
}
|
|
@@ -42,8 +42,18 @@ export declare class MockL2BlockSource implements L2BlockSource {
|
|
|
42
42
|
* @returns The requested mocked L2 blocks.
|
|
43
43
|
*/
|
|
44
44
|
getBlocks(from: number, limit: number, proven?: boolean): Promise<L2Block[]>;
|
|
45
|
+
getPublishedBlocks(from: number, limit: number, proven?: boolean): Promise<{
|
|
46
|
+
block: L2Block;
|
|
47
|
+
l1: {
|
|
48
|
+
blockNumber: bigint;
|
|
49
|
+
blockHash: `0x${string}`;
|
|
50
|
+
timestamp: bigint;
|
|
51
|
+
};
|
|
52
|
+
signatures: never[];
|
|
53
|
+
}[]>;
|
|
45
54
|
getBlockHeader(number: number | 'latest'): Promise<BlockHeader | undefined>;
|
|
46
55
|
getBlocksForEpoch(epochNumber: bigint): Promise<L2Block[]>;
|
|
56
|
+
getBlockHeadersForEpoch(epochNumber: bigint): Promise<BlockHeader[]>;
|
|
47
57
|
/**
|
|
48
58
|
* Gets a tx effect.
|
|
49
59
|
* @param txHash - The hash of a transaction which resulted in the returned tx effect.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock_l2_block_source.d.ts","sourceRoot":"","sources":["../../src/test/mock_l2_block_source.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mock_l2_block_source.d.ts","sourceRoot":"","sources":["../../src/test/mock_l2_block_source.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,OAAO,EAAE,OAAO,EAAe,KAAK,aAAa,EAAE,KAAK,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC5F,OAAO,EAAE,KAAK,iBAAiB,EAAwB,MAAM,6BAA6B,CAAC;AAC3F,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,EAAE,SAAS,EAAY,MAAM,kBAAkB,CAAC;AAEjF;;GAEG;AACH,qBAAa,iBAAkB,YAAW,aAAa;IACrD,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAM;IAEnC,OAAO,CAAC,iBAAiB,CAAa;IAEtC,OAAO,CAAC,GAAG,CAAiD;IAE/C,YAAY,CAAC,SAAS,EAAE,MAAM;IAUpC,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE;IAK3B,YAAY,CAAC,SAAS,EAAE,MAAM;IAK9B,oBAAoB,CAAC,iBAAiB,EAAE,MAAM;IAIrD;;;OAGG;IACH,gBAAgB,IAAI,OAAO,CAAC,UAAU,CAAC;IAIvC;;;OAGG;IACH,kBAAkB,IAAI,OAAO,CAAC,UAAU,CAAC;IAIzC;;;OAGG;IACI,cAAc;IAId,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI9C;;;;OAIG;IACI,QAAQ,CAAC,MAAM,EAAE,MAAM;IAI9B;;;;;OAKG;IACI,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO;IAQjD,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO;;;;;;;;;IAa7E,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;IAI3E,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAU1D,uBAAuB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAIpE;;;;OAIG;IACU,WAAW,CAAC,MAAM,EAAE,MAAM;;;;;IAWvC;;;;OAIG;IACU,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAkB1E,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IA2BlC,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC;IAInC,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC;IAIlC,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIvD,cAAc,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAI5C;;;OAGG;IACI,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI7B;;;OAGG;IACI,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DefaultL1ContractsConfig } from '@aztec/ethereum';
|
|
2
|
+
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
4
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
5
|
import { L2Block, L2BlockHash } from '@aztec/stdlib/block';
|
|
@@ -65,6 +66,18 @@ import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
|
65
66
|
*/ getBlocks(from, limit, proven) {
|
|
66
67
|
return Promise.resolve(this.l2Blocks.slice(from - 1, from - 1 + limit).filter((b)=>!proven || this.provenBlockNumber === undefined || b.number <= this.provenBlockNumber));
|
|
67
68
|
}
|
|
69
|
+
async getPublishedBlocks(from, limit, proven) {
|
|
70
|
+
const blocks = await this.getBlocks(from, limit, proven);
|
|
71
|
+
return blocks.map((block)=>({
|
|
72
|
+
block,
|
|
73
|
+
l1: {
|
|
74
|
+
blockNumber: BigInt(block.number),
|
|
75
|
+
blockHash: Buffer32.random().toString(),
|
|
76
|
+
timestamp: BigInt(block.number)
|
|
77
|
+
},
|
|
78
|
+
signatures: []
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
68
81
|
getBlockHeader(number) {
|
|
69
82
|
return Promise.resolve(this.l2Blocks.at(typeof number === 'number' ? number - 1 : -1)?.header);
|
|
70
83
|
}
|
|
@@ -79,6 +92,9 @@ import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
|
79
92
|
});
|
|
80
93
|
return Promise.resolve(blocks);
|
|
81
94
|
}
|
|
95
|
+
getBlockHeadersForEpoch(epochNumber) {
|
|
96
|
+
return this.getBlocksForEpoch(epochNumber).then((blocks)=>blocks.map((b)=>b.header));
|
|
97
|
+
}
|
|
82
98
|
/**
|
|
83
99
|
* Gets a tx effect.
|
|
84
100
|
* @param txHash - The hash of a transaction which resulted in the returned tx effect.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/archiver",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.82.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -64,18 +64,17 @@
|
|
|
64
64
|
]
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@aztec/blob-lib": "0.
|
|
68
|
-
"@aztec/blob-sink": "0.
|
|
69
|
-
"@aztec/constants": "0.
|
|
70
|
-
"@aztec/ethereum": "0.
|
|
71
|
-
"@aztec/foundation": "0.
|
|
72
|
-
"@aztec/kv-store": "0.
|
|
73
|
-
"@aztec/l1-artifacts": "0.
|
|
74
|
-
"@aztec/noir-
|
|
75
|
-
"@aztec/
|
|
76
|
-
"@aztec/
|
|
77
|
-
"@aztec/
|
|
78
|
-
"@aztec/telemetry-client": "0.80.0",
|
|
67
|
+
"@aztec/blob-lib": "0.82.0",
|
|
68
|
+
"@aztec/blob-sink": "0.82.0",
|
|
69
|
+
"@aztec/constants": "0.82.0",
|
|
70
|
+
"@aztec/ethereum": "0.82.0",
|
|
71
|
+
"@aztec/foundation": "0.82.0",
|
|
72
|
+
"@aztec/kv-store": "0.82.0",
|
|
73
|
+
"@aztec/l1-artifacts": "0.82.0",
|
|
74
|
+
"@aztec/noir-protocol-circuits-types": "0.82.0",
|
|
75
|
+
"@aztec/protocol-contracts": "0.82.0",
|
|
76
|
+
"@aztec/stdlib": "0.82.0",
|
|
77
|
+
"@aztec/telemetry-client": "0.82.0",
|
|
79
78
|
"debug": "^4.3.4",
|
|
80
79
|
"lodash.groupby": "^4.6.0",
|
|
81
80
|
"lodash.omit": "^4.5.0",
|