@aztec/archiver 0.0.0-test.0 → 0.0.1-commit.24de95ac
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 +27 -6
- package/dest/archiver/archiver.d.ts +126 -46
- package/dest/archiver/archiver.d.ts.map +1 -1
- package/dest/archiver/archiver.js +683 -261
- package/dest/archiver/archiver_store.d.ts +84 -49
- 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 +707 -213
- package/dest/archiver/config.d.ts +4 -20
- package/dest/archiver/config.d.ts.map +1 -1
- package/dest/archiver/config.js +16 -12
- package/dest/archiver/data_retrieval.d.ts +25 -20
- package/dest/archiver/data_retrieval.d.ts.map +1 -1
- package/dest/archiver/data_retrieval.js +147 -68
- package/dest/archiver/errors.d.ts +8 -0
- package/dest/archiver/errors.d.ts.map +1 -1
- package/dest/archiver/errors.js +12 -0
- package/dest/archiver/index.d.ts +2 -3
- package/dest/archiver/index.d.ts.map +1 -1
- package/dest/archiver/index.js +1 -2
- package/dest/archiver/instrumentation.d.ts +9 -3
- package/dest/archiver/instrumentation.d.ts.map +1 -1
- package/dest/archiver/instrumentation.js +58 -17
- package/dest/archiver/kv_archiver_store/block_store.d.ts +47 -10
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/block_store.js +216 -63
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts +2 -2
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/contract_class_store.js +12 -18
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts +10 -7
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/contract_instance_store.js +30 -16
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +49 -34
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.js +88 -46
- package/dest/archiver/kv_archiver_store/log_store.d.ts +1 -1
- package/dest/archiver/kv_archiver_store/log_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/log_store.js +18 -46
- package/dest/archiver/kv_archiver_store/message_store.d.ts +22 -16
- package/dest/archiver/kv_archiver_store/message_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/message_store.js +150 -48
- package/dest/archiver/structs/inbox_message.d.ts +15 -0
- package/dest/archiver/structs/inbox_message.d.ts.map +1 -0
- package/dest/archiver/structs/inbox_message.js +38 -0
- 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/archiver/validation.d.ts +11 -0
- package/dest/archiver/validation.d.ts.map +1 -0
- package/dest/archiver/validation.js +90 -0
- package/dest/factory.d.ts +7 -12
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +18 -49
- package/dest/rpc/index.d.ts +1 -2
- package/dest/rpc/index.d.ts.map +1 -1
- package/dest/rpc/index.js +1 -4
- package/dest/test/mock_archiver.d.ts +1 -1
- package/dest/test/mock_l1_to_l2_message_source.d.ts +4 -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 +14 -1
- package/dest/test/mock_l2_block_source.d.ts +32 -5
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +118 -7
- package/dest/test/mock_structs.d.ts +9 -0
- package/dest/test/mock_structs.d.ts.map +1 -0
- package/dest/test/mock_structs.js +37 -0
- package/package.json +25 -27
- package/src/archiver/archiver.ts +858 -317
- package/src/archiver/archiver_store.ts +97 -55
- package/src/archiver/archiver_store_test_suite.ts +663 -210
- package/src/archiver/config.ts +23 -41
- package/src/archiver/data_retrieval.ts +215 -92
- package/src/archiver/errors.ts +21 -0
- package/src/archiver/index.ts +2 -3
- package/src/archiver/instrumentation.ts +75 -20
- package/src/archiver/kv_archiver_store/block_store.ts +270 -72
- package/src/archiver/kv_archiver_store/contract_class_store.ts +13 -23
- package/src/archiver/kv_archiver_store/contract_instance_store.ts +35 -27
- package/src/archiver/kv_archiver_store/kv_archiver_store.ts +127 -63
- package/src/archiver/kv_archiver_store/log_store.ts +24 -62
- package/src/archiver/kv_archiver_store/message_store.ts +209 -53
- package/src/archiver/structs/inbox_message.ts +41 -0
- package/src/archiver/structs/published.ts +1 -11
- package/src/archiver/validation.ts +99 -0
- package/src/factory.ts +24 -66
- package/src/rpc/index.ts +1 -5
- package/src/test/mock_archiver.ts +1 -1
- package/src/test/mock_l1_to_l2_message_source.ts +14 -3
- package/src/test/mock_l2_block_source.ts +152 -8
- package/src/test/mock_structs.ts +49 -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/l1_to_l2_message_store.d.ts +0 -23
- package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts.map +0 -1
- package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.js +0 -49
- 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/l1_to_l2_message_store.ts +0 -61
- package/src/archiver/memory_archiver_store/memory_archiver_store.ts +0 -801
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
1
2
|
/**
|
|
2
3
|
* A mocked implementation of L1ToL2MessageSource to be used in tests.
|
|
3
4
|
*/ export class MockL1ToL2MessageSource {
|
|
@@ -14,7 +15,7 @@
|
|
|
14
15
|
this.blockNumber = blockNumber;
|
|
15
16
|
}
|
|
16
17
|
getL1ToL2Messages(blockNumber) {
|
|
17
|
-
return Promise.resolve(this.messagesPerBlock.get(
|
|
18
|
+
return Promise.resolve(this.messagesPerBlock.get(blockNumber) ?? []);
|
|
18
19
|
}
|
|
19
20
|
getL1ToL2MessageIndex(_l1ToL2Message) {
|
|
20
21
|
throw new Error('Method not implemented.');
|
|
@@ -22,4 +23,16 @@
|
|
|
22
23
|
getBlockNumber() {
|
|
23
24
|
return Promise.resolve(this.blockNumber);
|
|
24
25
|
}
|
|
26
|
+
getL2Tips() {
|
|
27
|
+
const number = this.blockNumber;
|
|
28
|
+
const tip = {
|
|
29
|
+
number,
|
|
30
|
+
hash: new Fr(number).toString()
|
|
31
|
+
};
|
|
32
|
+
return Promise.resolve({
|
|
33
|
+
latest: tip,
|
|
34
|
+
proven: tip,
|
|
35
|
+
finalized: tip
|
|
36
|
+
});
|
|
37
|
+
}
|
|
25
38
|
}
|
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
-
import {
|
|
2
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
3
|
+
import type { FunctionSelector } from '@aztec/stdlib/abi';
|
|
4
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
+
import { L2Block, L2BlockHash, type L2BlockSource, type L2Tips, PublishedL2Block, type ValidateBlockResult } from '@aztec/stdlib/block';
|
|
6
|
+
import type { ContractClassPublic, ContractDataSource, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
3
7
|
import { type L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
4
8
|
import { type BlockHeader, TxHash, TxReceipt } from '@aztec/stdlib/tx';
|
|
9
|
+
import type { UInt64 } from '@aztec/stdlib/types';
|
|
5
10
|
/**
|
|
6
11
|
* A mocked implementation of L2BlockSource to be used in tests.
|
|
7
12
|
*/
|
|
8
|
-
export declare class MockL2BlockSource implements L2BlockSource {
|
|
13
|
+
export declare class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
9
14
|
protected l2Blocks: L2Block[];
|
|
10
15
|
private provenBlockNumber;
|
|
16
|
+
private finalizedBlockNumber;
|
|
11
17
|
private log;
|
|
12
18
|
createBlocks(numBlocks: number): Promise<void>;
|
|
13
19
|
addBlocks(blocks: L2Block[]): void;
|
|
14
20
|
removeBlocks(numBlocks: number): void;
|
|
15
21
|
setProvenBlockNumber(provenBlockNumber: number): void;
|
|
22
|
+
setFinalizedBlockNumber(finalizedBlockNumber: number): void;
|
|
16
23
|
/**
|
|
17
24
|
* Method to fetch the rollup contract address at the base-layer.
|
|
18
25
|
* @returns The rollup address.
|
|
@@ -42,17 +49,24 @@ export declare class MockL2BlockSource implements L2BlockSource {
|
|
|
42
49
|
* @returns The requested mocked L2 blocks.
|
|
43
50
|
*/
|
|
44
51
|
getBlocks(from: number, limit: number, proven?: boolean): Promise<L2Block[]>;
|
|
52
|
+
getPublishedBlocks(from: number, limit: number, proven?: boolean): Promise<PublishedL2Block[]>;
|
|
53
|
+
getPublishedBlockByHash(blockHash: Fr): Promise<PublishedL2Block | undefined>;
|
|
54
|
+
getPublishedBlockByArchive(archive: Fr): Promise<PublishedL2Block | undefined>;
|
|
55
|
+
getBlockHeaderByHash(blockHash: Fr): Promise<BlockHeader | undefined>;
|
|
56
|
+
getBlockHeaderByArchive(archive: Fr): Promise<BlockHeader | undefined>;
|
|
45
57
|
getBlockHeader(number: number | 'latest'): Promise<BlockHeader | undefined>;
|
|
46
58
|
getBlocksForEpoch(epochNumber: bigint): Promise<L2Block[]>;
|
|
59
|
+
getBlockHeadersForEpoch(epochNumber: bigint): Promise<BlockHeader[]>;
|
|
47
60
|
/**
|
|
48
61
|
* Gets a tx effect.
|
|
49
|
-
* @param txHash - The hash of
|
|
50
|
-
* @returns The requested tx effect.
|
|
62
|
+
* @param txHash - The hash of the tx corresponding to the tx effect.
|
|
63
|
+
* @returns The requested tx effect with block info (or undefined if not found).
|
|
51
64
|
*/
|
|
52
65
|
getTxEffect(txHash: TxHash): Promise<{
|
|
53
66
|
data: import("@aztec/stdlib/tx").TxEffect;
|
|
54
67
|
l2BlockNumber: number;
|
|
55
|
-
l2BlockHash:
|
|
68
|
+
l2BlockHash: L2BlockHash;
|
|
69
|
+
txIndexInBlock: number;
|
|
56
70
|
} | undefined>;
|
|
57
71
|
/**
|
|
58
72
|
* Gets a receipt of a settled tx.
|
|
@@ -65,6 +79,10 @@ export declare class MockL2BlockSource implements L2BlockSource {
|
|
|
65
79
|
getL2SlotNumber(): Promise<bigint>;
|
|
66
80
|
isEpochComplete(_epochNumber: bigint): Promise<boolean>;
|
|
67
81
|
getL1Constants(): Promise<L1RollupConstants>;
|
|
82
|
+
getGenesisValues(): Promise<{
|
|
83
|
+
genesisArchiveRoot: Fr;
|
|
84
|
+
}>;
|
|
85
|
+
getL1Timestamp(): Promise<bigint>;
|
|
68
86
|
/**
|
|
69
87
|
* Starts the block source. In this mock implementation, this is a noop.
|
|
70
88
|
* @returns A promise that signals the initialization of the l2 block source on completion.
|
|
@@ -75,5 +93,14 @@ export declare class MockL2BlockSource implements L2BlockSource {
|
|
|
75
93
|
* @returns A promise that signals the l2 block source is now stopped.
|
|
76
94
|
*/
|
|
77
95
|
stop(): Promise<void>;
|
|
96
|
+
getContractClass(_id: Fr): Promise<ContractClassPublic | undefined>;
|
|
97
|
+
getBytecodeCommitment(_id: Fr): Promise<Fr | undefined>;
|
|
98
|
+
getContract(_address: AztecAddress, _timestamp?: UInt64): Promise<ContractInstanceWithAddress | undefined>;
|
|
99
|
+
getContractClassIds(): Promise<Fr[]>;
|
|
100
|
+
getDebugFunctionName(_address: AztecAddress, _selector: FunctionSelector): Promise<string | undefined>;
|
|
101
|
+
registerContractFunctionSignatures(_signatures: string[]): Promise<void>;
|
|
102
|
+
syncImmediate(): Promise<void>;
|
|
103
|
+
isPendingChainInvalid(): Promise<boolean>;
|
|
104
|
+
getPendingChainValidationStatus(): Promise<ValidateBlockResult>;
|
|
78
105
|
}
|
|
79
106
|
//# sourceMappingURL=mock_l2_block_source.d.ts.map
|
|
@@ -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":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EACL,OAAO,EACP,WAAW,EACX,KAAK,aAAa,EAClB,KAAK,MAAM,EACX,gBAAgB,EAChB,KAAK,mBAAmB,EACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AACnH,OAAO,EAA0B,KAAK,iBAAiB,EAAwB,MAAM,6BAA6B,CAAC;AACnH,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,EAAE,SAAS,EAAY,MAAM,kBAAkB,CAAC;AACjF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD;;GAEG;AACH,qBAAa,iBAAkB,YAAW,aAAa,EAAE,kBAAkB;IACzE,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAM;IAEnC,OAAO,CAAC,iBAAiB,CAAa;IACtC,OAAO,CAAC,oBAAoB,CAAa;IAEzC,OAAO,CAAC,GAAG,CAAiD;IAE/C,YAAY,CAAC,SAAS,EAAE,MAAM;IAUpC,SAAS,CAAC,MA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@@ -1,14 +1,18 @@
|
|
|
1
|
+
import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
|
|
1
2
|
import { DefaultL1ContractsConfig } from '@aztec/ethereum';
|
|
3
|
+
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
4
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
5
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
3
6
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import { L2Block, L2BlockHash } from '@aztec/stdlib/block';
|
|
5
|
-
import { getSlotRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
|
7
|
+
import { L2Block, L2BlockHash, PublishedL2Block } from '@aztec/stdlib/block';
|
|
8
|
+
import { EmptyL1RollupConstants, getSlotRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
|
6
9
|
import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
7
10
|
/**
|
|
8
11
|
* A mocked implementation of L2BlockSource to be used in tests.
|
|
9
12
|
*/ export class MockL2BlockSource {
|
|
10
13
|
l2Blocks = [];
|
|
11
14
|
provenBlockNumber = 0;
|
|
15
|
+
finalizedBlockNumber = 0;
|
|
12
16
|
log = createLogger('archiver:mock_l2_block_source');
|
|
13
17
|
async createBlocks(numBlocks) {
|
|
14
18
|
for(let i = 0; i < numBlocks; i++){
|
|
@@ -29,6 +33,12 @@ import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
|
29
33
|
setProvenBlockNumber(provenBlockNumber) {
|
|
30
34
|
this.provenBlockNumber = provenBlockNumber;
|
|
31
35
|
}
|
|
36
|
+
setFinalizedBlockNumber(finalizedBlockNumber) {
|
|
37
|
+
if (finalizedBlockNumber > this.provenBlockNumber) {
|
|
38
|
+
this.provenBlockNumber = finalizedBlockNumber;
|
|
39
|
+
}
|
|
40
|
+
this.finalizedBlockNumber = finalizedBlockNumber;
|
|
41
|
+
}
|
|
32
42
|
/**
|
|
33
43
|
* Method to fetch the rollup contract address at the base-layer.
|
|
34
44
|
* @returns The rollup address.
|
|
@@ -65,8 +75,65 @@ import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
|
65
75
|
*/ getBlocks(from, limit, proven) {
|
|
66
76
|
return Promise.resolve(this.l2Blocks.slice(from - 1, from - 1 + limit).filter((b)=>!proven || this.provenBlockNumber === undefined || b.number <= this.provenBlockNumber));
|
|
67
77
|
}
|
|
78
|
+
async getPublishedBlocks(from, limit, proven) {
|
|
79
|
+
const blocks = await this.getBlocks(from, limit, proven);
|
|
80
|
+
return blocks.map((block)=>PublishedL2Block.fromFields({
|
|
81
|
+
block,
|
|
82
|
+
l1: {
|
|
83
|
+
blockNumber: BigInt(block.number),
|
|
84
|
+
blockHash: Buffer32.random().toString(),
|
|
85
|
+
timestamp: BigInt(block.number)
|
|
86
|
+
},
|
|
87
|
+
attestations: []
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
async getPublishedBlockByHash(blockHash) {
|
|
91
|
+
for (const block of this.l2Blocks){
|
|
92
|
+
const hash = await block.hash();
|
|
93
|
+
if (hash.equals(blockHash)) {
|
|
94
|
+
return PublishedL2Block.fromFields({
|
|
95
|
+
block,
|
|
96
|
+
l1: {
|
|
97
|
+
blockNumber: BigInt(block.number),
|
|
98
|
+
blockHash: Buffer32.random().toString(),
|
|
99
|
+
timestamp: BigInt(block.number)
|
|
100
|
+
},
|
|
101
|
+
attestations: []
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
getPublishedBlockByArchive(archive) {
|
|
108
|
+
const block = this.l2Blocks.find((b)=>b.archive.root.equals(archive));
|
|
109
|
+
if (!block) {
|
|
110
|
+
return Promise.resolve(undefined);
|
|
111
|
+
}
|
|
112
|
+
return Promise.resolve(PublishedL2Block.fromFields({
|
|
113
|
+
block,
|
|
114
|
+
l1: {
|
|
115
|
+
blockNumber: BigInt(block.number),
|
|
116
|
+
blockHash: Buffer32.random().toString(),
|
|
117
|
+
timestamp: BigInt(block.number)
|
|
118
|
+
},
|
|
119
|
+
attestations: []
|
|
120
|
+
}));
|
|
121
|
+
}
|
|
122
|
+
async getBlockHeaderByHash(blockHash) {
|
|
123
|
+
for (const block of this.l2Blocks){
|
|
124
|
+
const hash = await block.hash();
|
|
125
|
+
if (hash.equals(blockHash)) {
|
|
126
|
+
return block.getBlockHeader();
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return undefined;
|
|
130
|
+
}
|
|
131
|
+
getBlockHeaderByArchive(archive) {
|
|
132
|
+
const block = this.l2Blocks.find((b)=>b.archive.root.equals(archive));
|
|
133
|
+
return Promise.resolve(block?.getBlockHeader());
|
|
134
|
+
}
|
|
68
135
|
getBlockHeader(number) {
|
|
69
|
-
return Promise.resolve(this.l2Blocks.at(typeof number === 'number' ? number - 1 : -1)?.
|
|
136
|
+
return Promise.resolve(this.l2Blocks.at(typeof number === 'number' ? number - 1 : -1)?.getBlockHeader());
|
|
70
137
|
}
|
|
71
138
|
getBlocksForEpoch(epochNumber) {
|
|
72
139
|
const epochDuration = DefaultL1ContractsConfig.aztecEpochDuration;
|
|
@@ -79,10 +146,14 @@ import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
|
79
146
|
});
|
|
80
147
|
return Promise.resolve(blocks);
|
|
81
148
|
}
|
|
149
|
+
async getBlockHeadersForEpoch(epochNumber) {
|
|
150
|
+
const blocks = await this.getBlocksForEpoch(epochNumber);
|
|
151
|
+
return blocks.map((b)=>b.getBlockHeader());
|
|
152
|
+
}
|
|
82
153
|
/**
|
|
83
154
|
* Gets a tx effect.
|
|
84
|
-
* @param txHash - The hash of
|
|
85
|
-
* @returns The requested tx effect.
|
|
155
|
+
* @param txHash - The hash of the tx corresponding to the tx effect.
|
|
156
|
+
* @returns The requested tx effect with block info (or undefined if not found).
|
|
86
157
|
*/ async getTxEffect(txHash) {
|
|
87
158
|
const match = this.l2Blocks.flatMap((b)=>b.body.txEffects.map((tx)=>[
|
|
88
159
|
tx,
|
|
@@ -95,7 +166,8 @@ import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
|
95
166
|
return {
|
|
96
167
|
data: txEffect,
|
|
97
168
|
l2BlockNumber: block.number,
|
|
98
|
-
l2BlockHash: (await block.hash())
|
|
169
|
+
l2BlockHash: L2BlockHash.fromField(await block.hash()),
|
|
170
|
+
txIndexInBlock: block.body.txEffects.indexOf(txEffect)
|
|
99
171
|
};
|
|
100
172
|
}
|
|
101
173
|
/**
|
|
@@ -116,7 +188,7 @@ import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
|
116
188
|
const [latest, proven, finalized] = [
|
|
117
189
|
await this.getBlockNumber(),
|
|
118
190
|
await this.getProvenBlockNumber(),
|
|
119
|
-
|
|
191
|
+
this.finalizedBlockNumber
|
|
120
192
|
];
|
|
121
193
|
const latestBlock = this.l2Blocks[latest - 1];
|
|
122
194
|
const provenBlock = this.l2Blocks[proven - 1];
|
|
@@ -146,18 +218,57 @@ import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
|
146
218
|
throw new Error('Method not implemented.');
|
|
147
219
|
}
|
|
148
220
|
getL1Constants() {
|
|
221
|
+
return Promise.resolve(EmptyL1RollupConstants);
|
|
222
|
+
}
|
|
223
|
+
getGenesisValues() {
|
|
224
|
+
return Promise.resolve({
|
|
225
|
+
genesisArchiveRoot: new Fr(GENESIS_ARCHIVE_ROOT)
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
getL1Timestamp() {
|
|
149
229
|
throw new Error('Method not implemented.');
|
|
150
230
|
}
|
|
151
231
|
/**
|
|
152
232
|
* Starts the block source. In this mock implementation, this is a noop.
|
|
153
233
|
* @returns A promise that signals the initialization of the l2 block source on completion.
|
|
154
234
|
*/ start() {
|
|
235
|
+
this.log.verbose('Starting mock L2 block source');
|
|
155
236
|
return Promise.resolve();
|
|
156
237
|
}
|
|
157
238
|
/**
|
|
158
239
|
* Stops the block source. In this mock implementation, this is a noop.
|
|
159
240
|
* @returns A promise that signals the l2 block source is now stopped.
|
|
160
241
|
*/ stop() {
|
|
242
|
+
this.log.verbose('Stopping mock L2 block source');
|
|
161
243
|
return Promise.resolve();
|
|
162
244
|
}
|
|
245
|
+
getContractClass(_id) {
|
|
246
|
+
return Promise.resolve(undefined);
|
|
247
|
+
}
|
|
248
|
+
getBytecodeCommitment(_id) {
|
|
249
|
+
return Promise.resolve(undefined);
|
|
250
|
+
}
|
|
251
|
+
getContract(_address, _timestamp) {
|
|
252
|
+
return Promise.resolve(undefined);
|
|
253
|
+
}
|
|
254
|
+
getContractClassIds() {
|
|
255
|
+
return Promise.resolve([]);
|
|
256
|
+
}
|
|
257
|
+
getDebugFunctionName(_address, _selector) {
|
|
258
|
+
return Promise.resolve(undefined);
|
|
259
|
+
}
|
|
260
|
+
registerContractFunctionSignatures(_signatures) {
|
|
261
|
+
return Promise.resolve();
|
|
262
|
+
}
|
|
263
|
+
syncImmediate() {
|
|
264
|
+
return Promise.resolve();
|
|
265
|
+
}
|
|
266
|
+
isPendingChainInvalid() {
|
|
267
|
+
return Promise.resolve(false);
|
|
268
|
+
}
|
|
269
|
+
getPendingChainValidationStatus() {
|
|
270
|
+
return Promise.resolve({
|
|
271
|
+
valid: true
|
|
272
|
+
});
|
|
273
|
+
}
|
|
163
274
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Buffer16 } from '@aztec/foundation/buffer';
|
|
2
|
+
import { type InboxMessage } from '../archiver/structs/inbox_message.js';
|
|
3
|
+
export declare function makeInboxMessage(previousRollingHash?: Buffer16, overrides?: Partial<InboxMessage>): InboxMessage;
|
|
4
|
+
export declare function makeInboxMessages(count: number, opts?: {
|
|
5
|
+
initialHash?: Buffer16;
|
|
6
|
+
initialL2BlockNumber?: number;
|
|
7
|
+
overrideFn?: (msg: InboxMessage, index: number) => InboxMessage;
|
|
8
|
+
}): InboxMessage[];
|
|
9
|
+
//# sourceMappingURL=mock_structs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock_structs.d.ts","sourceRoot":"","sources":["../../src/test/mock_structs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAY,MAAM,0BAA0B,CAAC;AAK9D,OAAO,EAAE,KAAK,YAAY,EAAqB,MAAM,sCAAsC,CAAC;AAE5F,wBAAgB,gBAAgB,CAC9B,mBAAmB,WAAgB,EACnC,SAAS,GAAE,OAAO,CAAC,YAAY,CAAM,GACpC,YAAY,CAgBd;AAED,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,EACb,IAAI,GAAE;IACJ,WAAW,CAAC,EAAE,QAAQ,CAAC;IACvB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,KAAK,YAAY,CAAC;CAC5D,GACL,YAAY,EAAE,CAahB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Buffer16, Buffer32 } from '@aztec/foundation/buffer';
|
|
2
|
+
import { randomBigInt, randomInt } from '@aztec/foundation/crypto';
|
|
3
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
4
|
+
import { InboxLeaf } from '@aztec/stdlib/messaging';
|
|
5
|
+
import { updateRollingHash } from '../archiver/structs/inbox_message.js';
|
|
6
|
+
export function makeInboxMessage(previousRollingHash = Buffer16.ZERO, overrides = {}) {
|
|
7
|
+
const { l2BlockNumber = randomInt(100) + 1 } = overrides;
|
|
8
|
+
const { l1BlockNumber = randomBigInt(100n) + 1n } = overrides;
|
|
9
|
+
const { l1BlockHash = Buffer32.random() } = overrides;
|
|
10
|
+
const { leaf = Fr.random() } = overrides;
|
|
11
|
+
const { rollingHash = updateRollingHash(previousRollingHash, leaf) } = overrides;
|
|
12
|
+
const { index = InboxLeaf.smallestIndexFromL2Block(l2BlockNumber) } = overrides;
|
|
13
|
+
return {
|
|
14
|
+
index,
|
|
15
|
+
leaf,
|
|
16
|
+
l2BlockNumber,
|
|
17
|
+
l1BlockNumber,
|
|
18
|
+
l1BlockHash,
|
|
19
|
+
rollingHash
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export function makeInboxMessages(count, opts = {}) {
|
|
23
|
+
const { initialHash = Buffer16.ZERO, overrideFn = (msg)=>msg, initialL2BlockNumber = 1 } = opts;
|
|
24
|
+
const messages = [];
|
|
25
|
+
let rollingHash = initialHash;
|
|
26
|
+
for(let i = 0; i < count; i++){
|
|
27
|
+
const leaf = Fr.random();
|
|
28
|
+
const l2BlockNumber = i + initialL2BlockNumber;
|
|
29
|
+
const message = overrideFn(makeInboxMessage(rollingHash, {
|
|
30
|
+
leaf,
|
|
31
|
+
l2BlockNumber
|
|
32
|
+
}), i);
|
|
33
|
+
rollingHash = message.rollingHash;
|
|
34
|
+
messages.push(message);
|
|
35
|
+
}
|
|
36
|
+
return messages;
|
|
37
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/archiver",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.1-commit.24de95ac",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -20,8 +20,6 @@
|
|
|
20
20
|
"build": "yarn clean && tsc -b",
|
|
21
21
|
"build:dev": "tsc -b --watch",
|
|
22
22
|
"clean": "rm -rf ./dest .tsbuildinfo",
|
|
23
|
-
"formatting": "run -T prettier --check ./src && run -T eslint ./src",
|
|
24
|
-
"formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src",
|
|
25
23
|
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}",
|
|
26
24
|
"test:integration": "concurrently -k -s first -c reset,dim -n test,anvil \"yarn test:integration:run\" \"anvil\"",
|
|
27
25
|
"test:integration:run": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --config jest.integration.config.json"
|
|
@@ -61,42 +59,42 @@
|
|
|
61
59
|
"testTimeout": 120000,
|
|
62
60
|
"setupFiles": [
|
|
63
61
|
"../../foundation/src/jest/setup.mjs"
|
|
62
|
+
],
|
|
63
|
+
"testEnvironment": "../../foundation/src/jest/env.mjs",
|
|
64
|
+
"setupFilesAfterEnv": [
|
|
65
|
+
"../../foundation/src/jest/setupAfterEnv.mjs"
|
|
64
66
|
]
|
|
65
67
|
},
|
|
66
68
|
"dependencies": {
|
|
67
|
-
"@aztec/blob-lib": "0.0.
|
|
68
|
-
"@aztec/blob-sink": "0.0.
|
|
69
|
-
"@aztec/constants": "0.0.
|
|
70
|
-
"@aztec/
|
|
71
|
-
"@aztec/
|
|
72
|
-
"@aztec/
|
|
73
|
-
"@aztec/
|
|
74
|
-
"@aztec/
|
|
75
|
-
"@aztec/noir-protocol-circuits-types": "0.0.
|
|
76
|
-
"@aztec/protocol-contracts": "0.0.
|
|
77
|
-
"@aztec/stdlib": "0.0.
|
|
78
|
-
"@aztec/telemetry-client": "0.0.
|
|
79
|
-
"debug": "^4.3.4",
|
|
69
|
+
"@aztec/blob-lib": "0.0.1-commit.24de95ac",
|
|
70
|
+
"@aztec/blob-sink": "0.0.1-commit.24de95ac",
|
|
71
|
+
"@aztec/constants": "0.0.1-commit.24de95ac",
|
|
72
|
+
"@aztec/epoch-cache": "0.0.1-commit.24de95ac",
|
|
73
|
+
"@aztec/ethereum": "0.0.1-commit.24de95ac",
|
|
74
|
+
"@aztec/foundation": "0.0.1-commit.24de95ac",
|
|
75
|
+
"@aztec/kv-store": "0.0.1-commit.24de95ac",
|
|
76
|
+
"@aztec/l1-artifacts": "0.0.1-commit.24de95ac",
|
|
77
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.24de95ac",
|
|
78
|
+
"@aztec/protocol-contracts": "0.0.1-commit.24de95ac",
|
|
79
|
+
"@aztec/stdlib": "0.0.1-commit.24de95ac",
|
|
80
|
+
"@aztec/telemetry-client": "0.0.1-commit.24de95ac",
|
|
80
81
|
"lodash.groupby": "^4.6.0",
|
|
81
82
|
"lodash.omit": "^4.5.0",
|
|
82
83
|
"tsc-watch": "^6.0.0",
|
|
83
84
|
"tslib": "^2.5.0",
|
|
84
|
-
"viem": "2.
|
|
85
|
-
"ws": "^8.13.0"
|
|
85
|
+
"viem": "npm:@spalladino/viem@2.38.2-eip7594.0"
|
|
86
86
|
},
|
|
87
87
|
"devDependencies": {
|
|
88
|
-
"@jest/globals": "^
|
|
89
|
-
"@types/
|
|
90
|
-
"@types/jest": "^29.5.0",
|
|
88
|
+
"@jest/globals": "^30.0.0",
|
|
89
|
+
"@types/jest": "^30.0.0",
|
|
91
90
|
"@types/lodash.groupby": "^4.6.9",
|
|
92
91
|
"@types/lodash.omit": "^4.5.7",
|
|
93
|
-
"@types/node": "^
|
|
94
|
-
"@types/ws": "^8.5.4",
|
|
92
|
+
"@types/node": "^22.15.17",
|
|
95
93
|
"concurrently": "^8.0.1",
|
|
96
|
-
"jest": "^
|
|
97
|
-
"jest-mock-extended": "^
|
|
94
|
+
"jest": "^30.0.0",
|
|
95
|
+
"jest-mock-extended": "^4.0.0",
|
|
98
96
|
"ts-node": "^10.9.1",
|
|
99
|
-
"typescript": "^5.
|
|
97
|
+
"typescript": "^5.3.3"
|
|
100
98
|
},
|
|
101
99
|
"files": [
|
|
102
100
|
"dest",
|
|
@@ -105,6 +103,6 @@
|
|
|
105
103
|
],
|
|
106
104
|
"types": "./dest/index.d.ts",
|
|
107
105
|
"engines": {
|
|
108
|
-
"node": ">=
|
|
106
|
+
"node": ">=20.10"
|
|
109
107
|
}
|
|
110
108
|
}
|