@aztec/archiver 0.0.0-test.1 → 0.0.1-commit.1142ef1
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 +204 -94
- package/dest/archiver/archiver.d.ts.map +1 -1
- package/dest/archiver/archiver.js +1616 -414
- package/dest/archiver/archiver_store.d.ts +178 -83
- package/dest/archiver/archiver_store.d.ts.map +1 -1
- package/dest/archiver/archiver_store_test_suite.d.ts +1 -1
- package/dest/archiver/archiver_store_test_suite.d.ts.map +1 -1
- package/dest/archiver/archiver_store_test_suite.js +2373 -397
- package/dest/archiver/config.d.ts +7 -22
- package/dest/archiver/config.d.ts.map +1 -1
- package/dest/archiver/config.js +30 -14
- package/dest/archiver/errors.d.ts +33 -1
- package/dest/archiver/errors.d.ts.map +1 -1
- package/dest/archiver/errors.js +49 -0
- package/dest/archiver/index.d.ts +3 -4
- package/dest/archiver/index.d.ts.map +1 -1
- package/dest/archiver/index.js +1 -2
- package/dest/archiver/instrumentation.d.ts +14 -6
- package/dest/archiver/instrumentation.d.ts.map +1 -1
- package/dest/archiver/instrumentation.js +45 -41
- package/dest/archiver/kv_archiver_store/block_store.d.ts +98 -21
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/block_store.js +495 -86
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts +4 -4
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/contract_class_store.js +13 -19
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts +12 -9
- 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 +81 -75
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.js +145 -83
- package/dest/archiver/kv_archiver_store/log_store.d.ts +12 -16
- package/dest/archiver/kv_archiver_store/log_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/log_store.js +151 -114
- package/dest/archiver/kv_archiver_store/message_store.d.ts +25 -18
- package/dest/archiver/kv_archiver_store/message_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/message_store.js +152 -49
- package/dest/archiver/l1/bin/retrieve-calldata.d.ts +3 -0
- package/dest/archiver/l1/bin/retrieve-calldata.d.ts.map +1 -0
- package/dest/archiver/l1/bin/retrieve-calldata.js +149 -0
- package/dest/archiver/l1/calldata_retriever.d.ts +112 -0
- package/dest/archiver/l1/calldata_retriever.d.ts.map +1 -0
- package/dest/archiver/l1/calldata_retriever.js +471 -0
- package/dest/archiver/l1/data_retrieval.d.ts +90 -0
- package/dest/archiver/l1/data_retrieval.d.ts.map +1 -0
- package/dest/archiver/l1/data_retrieval.js +331 -0
- package/dest/archiver/l1/debug_tx.d.ts +19 -0
- package/dest/archiver/l1/debug_tx.d.ts.map +1 -0
- package/dest/archiver/l1/debug_tx.js +73 -0
- package/dest/archiver/l1/spire_proposer.d.ts +70 -0
- package/dest/archiver/l1/spire_proposer.d.ts.map +1 -0
- package/dest/archiver/l1/spire_proposer.js +157 -0
- package/dest/archiver/l1/trace_tx.d.ts +97 -0
- package/dest/archiver/l1/trace_tx.d.ts.map +1 -0
- package/dest/archiver/l1/trace_tx.js +91 -0
- package/dest/archiver/l1/types.d.ts +12 -0
- package/dest/archiver/l1/types.d.ts.map +1 -0
- package/dest/archiver/l1/types.js +3 -0
- package/dest/archiver/l1/validate_trace.d.ts +29 -0
- package/dest/archiver/l1/validate_trace.d.ts.map +1 -0
- package/dest/archiver/l1/validate_trace.js +150 -0
- package/dest/archiver/structs/data_retrieval.d.ts +1 -1
- 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 +39 -0
- package/dest/archiver/structs/published.d.ts +2 -11
- package/dest/archiver/structs/published.d.ts.map +1 -1
- package/dest/archiver/structs/published.js +1 -1
- package/dest/archiver/validation.d.ts +17 -0
- package/dest/archiver/validation.d.ts.map +1 -0
- package/dest/archiver/validation.js +98 -0
- package/dest/factory.d.ts +9 -14
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +22 -52
- package/dest/index.d.ts +2 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- package/dest/rpc/index.d.ts +2 -3
- package/dest/rpc/index.d.ts.map +1 -1
- package/dest/rpc/index.js +1 -4
- package/dest/test/index.d.ts +1 -1
- package/dest/test/mock_archiver.d.ts +16 -8
- package/dest/test/mock_archiver.d.ts.map +1 -1
- package/dest/test/mock_archiver.js +19 -14
- package/dest/test/mock_l1_to_l2_message_source.d.ts +9 -6
- package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
- package/dest/test/mock_l1_to_l2_message_source.js +30 -7
- package/dest/test/mock_l2_block_source.d.ts +56 -13
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +196 -25
- package/dest/test/mock_structs.d.ts +10 -0
- package/dest/test/mock_structs.d.ts.map +1 -0
- package/dest/test/mock_structs.js +38 -0
- package/package.json +29 -30
- package/src/archiver/archiver.ts +1596 -512
- package/src/archiver/archiver_store.ts +205 -88
- package/src/archiver/archiver_store_test_suite.ts +2386 -354
- package/src/archiver/config.ts +38 -46
- package/src/archiver/errors.ts +85 -0
- package/src/archiver/index.ts +2 -3
- package/src/archiver/instrumentation.ts +65 -45
- package/src/archiver/kv_archiver_store/block_store.ts +668 -101
- package/src/archiver/kv_archiver_store/contract_class_store.ts +14 -24
- package/src/archiver/kv_archiver_store/contract_instance_store.ts +36 -28
- package/src/archiver/kv_archiver_store/kv_archiver_store.ts +197 -113
- package/src/archiver/kv_archiver_store/log_store.ts +204 -132
- package/src/archiver/kv_archiver_store/message_store.ts +213 -54
- package/src/archiver/l1/README.md +98 -0
- package/src/archiver/l1/bin/retrieve-calldata.ts +182 -0
- package/src/archiver/l1/calldata_retriever.ts +641 -0
- package/src/archiver/l1/data_retrieval.ts +512 -0
- package/src/archiver/l1/debug_tx.ts +99 -0
- package/src/archiver/l1/spire_proposer.ts +160 -0
- package/src/archiver/l1/trace_tx.ts +128 -0
- package/src/archiver/l1/types.ts +13 -0
- package/src/archiver/l1/validate_trace.ts +211 -0
- package/src/archiver/structs/inbox_message.ts +41 -0
- package/src/archiver/structs/published.ts +1 -11
- package/src/archiver/validation.ts +124 -0
- package/src/factory.ts +28 -69
- package/src/index.ts +1 -1
- package/src/rpc/index.ts +1 -5
- package/src/test/fixtures/debug_traceTransaction-multicall3.json +88 -0
- package/src/test/fixtures/debug_traceTransaction-multiplePropose.json +153 -0
- package/src/test/fixtures/debug_traceTransaction-proxied.json +122 -0
- package/src/test/fixtures/trace_transaction-multicall3.json +65 -0
- package/src/test/fixtures/trace_transaction-multiplePropose.json +319 -0
- package/src/test/fixtures/trace_transaction-proxied.json +128 -0
- package/src/test/fixtures/trace_transaction-randomRevert.json +216 -0
- package/src/test/mock_archiver.ts +22 -16
- package/src/test/mock_l1_to_l2_message_source.ts +26 -8
- package/src/test/mock_l2_block_source.ts +254 -31
- package/src/test/mock_structs.ts +50 -0
- package/dest/archiver/data_retrieval.d.ts +0 -74
- package/dest/archiver/data_retrieval.d.ts.map +0 -1
- package/dest/archiver/data_retrieval.js +0 -283
- 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/data_retrieval.ts +0 -422
- 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,19 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
|
|
2
|
+
import { DefaultL1ContractsConfig } from '@aztec/ethereum/config';
|
|
3
|
+
import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
4
|
+
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
5
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
6
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
7
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import { L2Block, L2BlockHash } from '@aztec/stdlib/block';
|
|
5
|
-
import {
|
|
8
|
+
import { CheckpointedL2Block, L2Block, L2BlockHash, PublishedL2Block } from '@aztec/stdlib/block';
|
|
9
|
+
import { L1PublishedData } from '@aztec/stdlib/checkpoint';
|
|
10
|
+
import { EmptyL1RollupConstants, getSlotRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
|
6
11
|
import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
7
12
|
/**
|
|
8
13
|
* A mocked implementation of L2BlockSource to be used in tests.
|
|
9
14
|
*/ export class MockL2BlockSource {
|
|
10
15
|
l2Blocks = [];
|
|
11
16
|
provenBlockNumber = 0;
|
|
17
|
+
finalizedBlockNumber = 0;
|
|
18
|
+
checkpointedBlockNumber = 0;
|
|
12
19
|
log = createLogger('archiver:mock_l2_block_source');
|
|
13
20
|
async createBlocks(numBlocks) {
|
|
14
21
|
for(let i = 0; i < numBlocks; i++){
|
|
15
22
|
const blockNum = this.l2Blocks.length + 1;
|
|
16
|
-
const block = await L2Block.random(blockNum);
|
|
23
|
+
const block = await L2Block.random(BlockNumber(blockNum));
|
|
17
24
|
this.l2Blocks.push(block);
|
|
18
25
|
}
|
|
19
26
|
this.log.verbose(`Created ${numBlocks} blocks in the mock L2 block source`);
|
|
@@ -29,6 +36,15 @@ import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
|
29
36
|
setProvenBlockNumber(provenBlockNumber) {
|
|
30
37
|
this.provenBlockNumber = provenBlockNumber;
|
|
31
38
|
}
|
|
39
|
+
setFinalizedBlockNumber(finalizedBlockNumber) {
|
|
40
|
+
if (finalizedBlockNumber > this.provenBlockNumber) {
|
|
41
|
+
this.provenBlockNumber = finalizedBlockNumber;
|
|
42
|
+
}
|
|
43
|
+
this.finalizedBlockNumber = finalizedBlockNumber;
|
|
44
|
+
}
|
|
45
|
+
setCheckpointedBlockNumber(checkpointedBlockNumber) {
|
|
46
|
+
this.checkpointedBlockNumber = checkpointedBlockNumber;
|
|
47
|
+
}
|
|
32
48
|
/**
|
|
33
49
|
* Method to fetch the rollup contract address at the base-layer.
|
|
34
50
|
* @returns The rollup address.
|
|
@@ -45,10 +61,35 @@ import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
|
45
61
|
* Gets the number of the latest L2 block processed by the block source implementation.
|
|
46
62
|
* @returns In this mock instance, returns the number of L2 blocks that we've mocked.
|
|
47
63
|
*/ getBlockNumber() {
|
|
48
|
-
return Promise.resolve(this.l2Blocks.length);
|
|
64
|
+
return Promise.resolve(BlockNumber(this.l2Blocks.length));
|
|
49
65
|
}
|
|
50
66
|
getProvenBlockNumber() {
|
|
51
|
-
return Promise.resolve(this.provenBlockNumber);
|
|
67
|
+
return Promise.resolve(BlockNumber(this.provenBlockNumber));
|
|
68
|
+
}
|
|
69
|
+
getCheckpointedBlock(number) {
|
|
70
|
+
if (number > this.checkpointedBlockNumber) {
|
|
71
|
+
return Promise.resolve(undefined);
|
|
72
|
+
}
|
|
73
|
+
const block = this.l2Blocks[number - 1];
|
|
74
|
+
if (!block) {
|
|
75
|
+
return Promise.resolve(undefined);
|
|
76
|
+
}
|
|
77
|
+
const checkpointedBlock = new CheckpointedL2Block(CheckpointNumber(number), block.toL2Block(), new L1PublishedData(BigInt(number), BigInt(number), `0x${number.toString(16).padStart(64, '0')}`), []);
|
|
78
|
+
return Promise.resolve(checkpointedBlock);
|
|
79
|
+
}
|
|
80
|
+
async getCheckpointedBlocks(from, limit, _proven) {
|
|
81
|
+
const result = [];
|
|
82
|
+
for(let i = 0; i < limit; i++){
|
|
83
|
+
const blockNum = from + i;
|
|
84
|
+
if (blockNum > this.checkpointedBlockNumber) {
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
const block = await this.getCheckpointedBlock(BlockNumber(blockNum));
|
|
88
|
+
if (block) {
|
|
89
|
+
result.push(block);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return result;
|
|
52
93
|
}
|
|
53
94
|
/**
|
|
54
95
|
* Gets an l2 block.
|
|
@@ -58,6 +99,14 @@ import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
|
58
99
|
return Promise.resolve(this.l2Blocks[number - 1]);
|
|
59
100
|
}
|
|
60
101
|
/**
|
|
102
|
+
* Gets an L2 block (new format).
|
|
103
|
+
* @param number - The block number to return.
|
|
104
|
+
* @returns The requested L2 block.
|
|
105
|
+
*/ getL2BlockNew(number) {
|
|
106
|
+
const block = this.l2Blocks[number - 1];
|
|
107
|
+
return Promise.resolve(block?.toL2Block());
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
61
110
|
* Gets up to `limit` amount of L2 blocks starting from `from`.
|
|
62
111
|
* @param from - Number of the first block to return (inclusive).
|
|
63
112
|
* @param limit - The maximum number of blocks to return.
|
|
@@ -65,8 +114,69 @@ import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
|
65
114
|
*/ getBlocks(from, limit, proven) {
|
|
66
115
|
return Promise.resolve(this.l2Blocks.slice(from - 1, from - 1 + limit).filter((b)=>!proven || this.provenBlockNumber === undefined || b.number <= this.provenBlockNumber));
|
|
67
116
|
}
|
|
117
|
+
async getPublishedCheckpoints(from, limit) {
|
|
118
|
+
// TODO: Implement this properly. This only works when we have one block per checkpoint.
|
|
119
|
+
return (await this.getPublishedBlocks(from, limit)).map((block)=>block.toPublishedCheckpoint());
|
|
120
|
+
}
|
|
121
|
+
async getCheckpointByArchive(archive) {
|
|
122
|
+
// TODO: Implement this properly. This only works when we have one block per checkpoint.
|
|
123
|
+
return (await this.getPublishedBlockByArchive(archive))?.block.toCheckpoint();
|
|
124
|
+
}
|
|
125
|
+
async getPublishedBlocks(from, limit, proven) {
|
|
126
|
+
const blocks = await this.getBlocks(from, limit, proven);
|
|
127
|
+
return blocks.map((block)=>PublishedL2Block.fromFields({
|
|
128
|
+
block,
|
|
129
|
+
l1: new L1PublishedData(BigInt(block.number), BigInt(block.number), Buffer32.random().toString()),
|
|
130
|
+
attestations: []
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
133
|
+
async getL2BlocksNew(from, limit, proven) {
|
|
134
|
+
const blocks = await this.getBlocks(from, limit, proven);
|
|
135
|
+
return blocks.map((x)=>x.toL2Block());
|
|
136
|
+
}
|
|
137
|
+
async getPublishedBlockByHash(blockHash) {
|
|
138
|
+
for (const block of this.l2Blocks){
|
|
139
|
+
const hash = await block.hash();
|
|
140
|
+
if (hash.equals(blockHash)) {
|
|
141
|
+
return PublishedL2Block.fromFields({
|
|
142
|
+
block,
|
|
143
|
+
l1: new L1PublishedData(BigInt(block.number), BigInt(block.number), Buffer32.random().toString()),
|
|
144
|
+
attestations: []
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return undefined;
|
|
149
|
+
}
|
|
150
|
+
getPublishedBlockByArchive(archive) {
|
|
151
|
+
const block = this.l2Blocks.find((b)=>b.archive.root.equals(archive));
|
|
152
|
+
if (!block) {
|
|
153
|
+
return Promise.resolve(undefined);
|
|
154
|
+
}
|
|
155
|
+
return Promise.resolve(PublishedL2Block.fromFields({
|
|
156
|
+
block,
|
|
157
|
+
l1: new L1PublishedData(BigInt(block.number), BigInt(block.number), Buffer32.random().toString()),
|
|
158
|
+
attestations: []
|
|
159
|
+
}));
|
|
160
|
+
}
|
|
161
|
+
async getBlockHeaderByHash(blockHash) {
|
|
162
|
+
for (const block of this.l2Blocks){
|
|
163
|
+
const hash = await block.hash();
|
|
164
|
+
if (hash.equals(blockHash)) {
|
|
165
|
+
return block.getBlockHeader();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return undefined;
|
|
169
|
+
}
|
|
170
|
+
getBlockHeaderByArchive(archive) {
|
|
171
|
+
const block = this.l2Blocks.find((b)=>b.archive.root.equals(archive));
|
|
172
|
+
return Promise.resolve(block?.getBlockHeader());
|
|
173
|
+
}
|
|
68
174
|
getBlockHeader(number) {
|
|
69
|
-
return Promise.resolve(this.l2Blocks.at(typeof number === 'number' ? number - 1 : -1)?.
|
|
175
|
+
return Promise.resolve(this.l2Blocks.at(typeof number === 'number' ? number - 1 : -1)?.getBlockHeader());
|
|
176
|
+
}
|
|
177
|
+
getCheckpointsForEpoch(epochNumber) {
|
|
178
|
+
// TODO: Implement this properly. This only works when we have one block per checkpoint.
|
|
179
|
+
return this.getBlocksForEpoch(epochNumber).then((blocks)=>blocks.map((b)=>b.toCheckpoint()));
|
|
70
180
|
}
|
|
71
181
|
getBlocksForEpoch(epochNumber) {
|
|
72
182
|
const epochDuration = DefaultL1ContractsConfig.aztecEpochDuration;
|
|
@@ -74,15 +184,19 @@ import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
|
74
184
|
epochDuration
|
|
75
185
|
});
|
|
76
186
|
const blocks = this.l2Blocks.filter((b)=>{
|
|
77
|
-
const slot = b.header.globalVariables.slotNumber
|
|
187
|
+
const slot = b.header.globalVariables.slotNumber;
|
|
78
188
|
return slot >= start && slot <= end;
|
|
79
189
|
});
|
|
80
190
|
return Promise.resolve(blocks);
|
|
81
191
|
}
|
|
192
|
+
async getBlockHeadersForEpoch(epochNumber) {
|
|
193
|
+
const blocks = await this.getBlocksForEpoch(epochNumber);
|
|
194
|
+
return blocks.map((b)=>b.getBlockHeader());
|
|
195
|
+
}
|
|
82
196
|
/**
|
|
83
197
|
* Gets a tx effect.
|
|
84
|
-
* @param txHash - The hash of
|
|
85
|
-
* @returns The requested tx effect.
|
|
198
|
+
* @param txHash - The hash of the tx corresponding to the tx effect.
|
|
199
|
+
* @returns The requested tx effect with block info (or undefined if not found).
|
|
86
200
|
*/ async getTxEffect(txHash) {
|
|
87
201
|
const match = this.l2Blocks.flatMap((b)=>b.body.txEffects.map((tx)=>[
|
|
88
202
|
tx,
|
|
@@ -95,7 +209,8 @@ import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
|
95
209
|
return {
|
|
96
210
|
data: txEffect,
|
|
97
211
|
l2BlockNumber: block.number,
|
|
98
|
-
l2BlockHash: (await block.hash())
|
|
212
|
+
l2BlockHash: L2BlockHash.fromField(await block.hash()),
|
|
213
|
+
txIndexInBlock: block.body.txEffects.indexOf(txEffect)
|
|
99
214
|
};
|
|
100
215
|
}
|
|
101
216
|
/**
|
|
@@ -113,27 +228,44 @@ import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
|
113
228
|
return undefined;
|
|
114
229
|
}
|
|
115
230
|
async getL2Tips() {
|
|
116
|
-
const [latest, proven, finalized] = [
|
|
231
|
+
const [latest, proven, finalized, checkpointed] = [
|
|
117
232
|
await this.getBlockNumber(),
|
|
118
233
|
await this.getProvenBlockNumber(),
|
|
119
|
-
|
|
234
|
+
this.finalizedBlockNumber,
|
|
235
|
+
this.checkpointedBlockNumber
|
|
120
236
|
];
|
|
121
237
|
const latestBlock = this.l2Blocks[latest - 1];
|
|
122
238
|
const provenBlock = this.l2Blocks[proven - 1];
|
|
123
239
|
const finalizedBlock = this.l2Blocks[finalized - 1];
|
|
240
|
+
const checkpointedBlock = this.l2Blocks[checkpointed - 1];
|
|
241
|
+
const latestBlockId = {
|
|
242
|
+
number: BlockNumber(latest),
|
|
243
|
+
hash: (await latestBlock?.hash())?.toString()
|
|
244
|
+
};
|
|
245
|
+
const provenBlockId = {
|
|
246
|
+
number: BlockNumber(proven),
|
|
247
|
+
hash: (await provenBlock?.hash())?.toString()
|
|
248
|
+
};
|
|
249
|
+
const finalizedBlockId = {
|
|
250
|
+
number: BlockNumber(finalized),
|
|
251
|
+
hash: (await finalizedBlock?.hash())?.toString()
|
|
252
|
+
};
|
|
253
|
+
const checkpointedBlockId = {
|
|
254
|
+
number: BlockNumber(checkpointed),
|
|
255
|
+
hash: (await checkpointedBlock?.hash())?.toString()
|
|
256
|
+
};
|
|
257
|
+
const makeTipId = (blockId)=>({
|
|
258
|
+
block: blockId,
|
|
259
|
+
checkpoint: {
|
|
260
|
+
number: CheckpointNumber(blockId.number),
|
|
261
|
+
hash: blockId.hash
|
|
262
|
+
}
|
|
263
|
+
});
|
|
124
264
|
return {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
proven: {
|
|
130
|
-
number: proven,
|
|
131
|
-
hash: (await provenBlock?.hash())?.toString()
|
|
132
|
-
},
|
|
133
|
-
finalized: {
|
|
134
|
-
number: finalized,
|
|
135
|
-
hash: (await finalizedBlock?.hash())?.toString()
|
|
136
|
-
}
|
|
265
|
+
proposed: latestBlockId,
|
|
266
|
+
checkpointed: makeTipId(checkpointedBlockId),
|
|
267
|
+
proven: makeTipId(provenBlockId),
|
|
268
|
+
finalized: makeTipId(finalizedBlockId)
|
|
137
269
|
};
|
|
138
270
|
}
|
|
139
271
|
getL2EpochNumber() {
|
|
@@ -146,18 +278,57 @@ import { TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
|
146
278
|
throw new Error('Method not implemented.');
|
|
147
279
|
}
|
|
148
280
|
getL1Constants() {
|
|
281
|
+
return Promise.resolve(EmptyL1RollupConstants);
|
|
282
|
+
}
|
|
283
|
+
getGenesisValues() {
|
|
284
|
+
return Promise.resolve({
|
|
285
|
+
genesisArchiveRoot: new Fr(GENESIS_ARCHIVE_ROOT)
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
getL1Timestamp() {
|
|
149
289
|
throw new Error('Method not implemented.');
|
|
150
290
|
}
|
|
151
291
|
/**
|
|
152
292
|
* Starts the block source. In this mock implementation, this is a noop.
|
|
153
293
|
* @returns A promise that signals the initialization of the l2 block source on completion.
|
|
154
294
|
*/ start() {
|
|
295
|
+
this.log.verbose('Starting mock L2 block source');
|
|
155
296
|
return Promise.resolve();
|
|
156
297
|
}
|
|
157
298
|
/**
|
|
158
299
|
* Stops the block source. In this mock implementation, this is a noop.
|
|
159
300
|
* @returns A promise that signals the l2 block source is now stopped.
|
|
160
301
|
*/ stop() {
|
|
302
|
+
this.log.verbose('Stopping mock L2 block source');
|
|
303
|
+
return Promise.resolve();
|
|
304
|
+
}
|
|
305
|
+
getContractClass(_id) {
|
|
306
|
+
return Promise.resolve(undefined);
|
|
307
|
+
}
|
|
308
|
+
getBytecodeCommitment(_id) {
|
|
309
|
+
return Promise.resolve(undefined);
|
|
310
|
+
}
|
|
311
|
+
getContract(_address, _timestamp) {
|
|
312
|
+
return Promise.resolve(undefined);
|
|
313
|
+
}
|
|
314
|
+
getContractClassIds() {
|
|
315
|
+
return Promise.resolve([]);
|
|
316
|
+
}
|
|
317
|
+
getDebugFunctionName(_address, _selector) {
|
|
318
|
+
return Promise.resolve(undefined);
|
|
319
|
+
}
|
|
320
|
+
registerContractFunctionSignatures(_signatures) {
|
|
321
|
+
return Promise.resolve();
|
|
322
|
+
}
|
|
323
|
+
syncImmediate() {
|
|
161
324
|
return Promise.resolve();
|
|
162
325
|
}
|
|
326
|
+
isPendingChainInvalid() {
|
|
327
|
+
return Promise.resolve(false);
|
|
328
|
+
}
|
|
329
|
+
getPendingChainValidationStatus() {
|
|
330
|
+
return Promise.resolve({
|
|
331
|
+
valid: true
|
|
332
|
+
});
|
|
333
|
+
}
|
|
163
334
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { Buffer16 } from '@aztec/foundation/buffer';
|
|
3
|
+
import { type InboxMessage } from '../archiver/structs/inbox_message.js';
|
|
4
|
+
export declare function makeInboxMessage(previousRollingHash?: Buffer16, overrides?: Partial<InboxMessage>): InboxMessage;
|
|
5
|
+
export declare function makeInboxMessages(count: number, opts?: {
|
|
6
|
+
initialHash?: Buffer16;
|
|
7
|
+
initialCheckpointNumber?: CheckpointNumber;
|
|
8
|
+
overrideFn?: (msg: InboxMessage, index: number) => InboxMessage;
|
|
9
|
+
}): InboxMessage[];
|
|
10
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW9ja19zdHJ1Y3RzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdGVzdC9tb2NrX3N0cnVjdHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLGdCQUFnQixFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDbkUsT0FBTyxFQUFFLFFBQVEsRUFBWSxNQUFNLDBCQUEwQixDQUFDO0FBSzlELE9BQU8sRUFBRSxLQUFLLFlBQVksRUFBcUIsTUFBTSxzQ0FBc0MsQ0FBQztBQUU1Rix3QkFBZ0IsZ0JBQWdCLENBQzlCLG1CQUFtQixXQUFnQixFQUNuQyxTQUFTLEdBQUUsT0FBTyxDQUFDLFlBQVksQ0FBTSxHQUNwQyxZQUFZLENBZ0JkO0FBRUQsd0JBQWdCLGlCQUFpQixDQUMvQixLQUFLLEVBQUUsTUFBTSxFQUNiLElBQUksR0FBRTtJQUNKLFdBQVcsQ0FBQyxFQUFFLFFBQVEsQ0FBQztJQUN2Qix1QkFBdUIsQ0FBQyxFQUFFLGdCQUFnQixDQUFDO0lBQzNDLFVBQVUsQ0FBQyxFQUFFLENBQUMsR0FBRyxFQUFFLFlBQVksRUFBRSxLQUFLLEVBQUUsTUFBTSxLQUFLLFlBQVksQ0FBQztDQUM1RCxHQUNMLFlBQVksRUFBRSxDQWFoQiJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock_structs.d.ts","sourceRoot":"","sources":["../../src/test/mock_structs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,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,uBAAuB,CAAC,EAAE,gBAAgB,CAAC;IAC3C,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,KAAK,YAAY,CAAC;CAC5D,GACL,YAAY,EAAE,CAahB"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { Buffer16, Buffer32 } from '@aztec/foundation/buffer';
|
|
3
|
+
import { randomBigInt, randomInt } from '@aztec/foundation/crypto/random';
|
|
4
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
|
+
import { InboxLeaf } from '@aztec/stdlib/messaging';
|
|
6
|
+
import { updateRollingHash } from '../archiver/structs/inbox_message.js';
|
|
7
|
+
export function makeInboxMessage(previousRollingHash = Buffer16.ZERO, overrides = {}) {
|
|
8
|
+
const { checkpointNumber = CheckpointNumber(randomInt(100) + 1) } = overrides;
|
|
9
|
+
const { l1BlockNumber = randomBigInt(100n) + 1n } = overrides;
|
|
10
|
+
const { l1BlockHash = Buffer32.random() } = overrides;
|
|
11
|
+
const { leaf = Fr.random() } = overrides;
|
|
12
|
+
const { rollingHash = updateRollingHash(previousRollingHash, leaf) } = overrides;
|
|
13
|
+
const { index = InboxLeaf.smallestIndexForCheckpoint(checkpointNumber) } = overrides;
|
|
14
|
+
return {
|
|
15
|
+
index,
|
|
16
|
+
leaf,
|
|
17
|
+
checkpointNumber,
|
|
18
|
+
l1BlockNumber,
|
|
19
|
+
l1BlockHash,
|
|
20
|
+
rollingHash
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export function makeInboxMessages(count, opts = {}) {
|
|
24
|
+
const { initialHash = Buffer16.ZERO, overrideFn = (msg)=>msg, initialCheckpointNumber = 1 } = opts;
|
|
25
|
+
const messages = [];
|
|
26
|
+
let rollingHash = initialHash;
|
|
27
|
+
for(let i = 0; i < count; i++){
|
|
28
|
+
const leaf = Fr.random();
|
|
29
|
+
const checkpointNumber = CheckpointNumber(i + initialCheckpointNumber);
|
|
30
|
+
const message = overrideFn(makeInboxMessage(rollingHash, {
|
|
31
|
+
leaf,
|
|
32
|
+
checkpointNumber
|
|
33
|
+
}), i);
|
|
34
|
+
rollingHash = message.rollingHash;
|
|
35
|
+
messages.push(message);
|
|
36
|
+
}
|
|
37
|
+
return messages;
|
|
38
|
+
}
|
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.1142ef1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -17,11 +17,9 @@
|
|
|
17
17
|
"tsconfig": "./tsconfig.json"
|
|
18
18
|
},
|
|
19
19
|
"scripts": {
|
|
20
|
-
"build": "yarn clean && tsc
|
|
21
|
-
"build:dev": "tsc
|
|
20
|
+
"build": "yarn clean && ../scripts/tsc.sh",
|
|
21
|
+
"build:dev": "../scripts/tsc.sh --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,43 @@
|
|
|
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-
|
|
68
|
-
"@aztec/blob-
|
|
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-client": "0.0.1-commit.1142ef1",
|
|
70
|
+
"@aztec/blob-lib": "0.0.1-commit.1142ef1",
|
|
71
|
+
"@aztec/constants": "0.0.1-commit.1142ef1",
|
|
72
|
+
"@aztec/epoch-cache": "0.0.1-commit.1142ef1",
|
|
73
|
+
"@aztec/ethereum": "0.0.1-commit.1142ef1",
|
|
74
|
+
"@aztec/foundation": "0.0.1-commit.1142ef1",
|
|
75
|
+
"@aztec/kv-store": "0.0.1-commit.1142ef1",
|
|
76
|
+
"@aztec/l1-artifacts": "0.0.1-commit.1142ef1",
|
|
77
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.1142ef1",
|
|
78
|
+
"@aztec/protocol-contracts": "0.0.1-commit.1142ef1",
|
|
79
|
+
"@aztec/stdlib": "0.0.1-commit.1142ef1",
|
|
80
|
+
"@aztec/telemetry-client": "0.0.1-commit.1142ef1",
|
|
80
81
|
"lodash.groupby": "^4.6.0",
|
|
81
82
|
"lodash.omit": "^4.5.0",
|
|
82
|
-
"tsc-watch": "^6.0.0",
|
|
83
83
|
"tslib": "^2.5.0",
|
|
84
|
-
"viem": "2.
|
|
85
|
-
"
|
|
84
|
+
"viem": "npm:@aztec/viem@2.38.2",
|
|
85
|
+
"zod": "^3.23.8"
|
|
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
|
-
"@
|
|
92
|
+
"@types/node": "^22.15.17",
|
|
93
|
+
"@typescript/native-preview": "7.0.0-dev.20251126.1",
|
|
95
94
|
"concurrently": "^8.0.1",
|
|
96
|
-
"jest": "^
|
|
97
|
-
"jest-mock-extended": "^
|
|
95
|
+
"jest": "^30.0.0",
|
|
96
|
+
"jest-mock-extended": "^4.0.0",
|
|
98
97
|
"ts-node": "^10.9.1",
|
|
99
|
-
"typescript": "^5.
|
|
98
|
+
"typescript": "^5.3.3"
|
|
100
99
|
},
|
|
101
100
|
"files": [
|
|
102
101
|
"dest",
|
|
@@ -105,6 +104,6 @@
|
|
|
105
104
|
],
|
|
106
105
|
"types": "./dest/index.d.ts",
|
|
107
106
|
"engines": {
|
|
108
|
-
"node": ">=
|
|
107
|
+
"node": ">=20.10"
|
|
109
108
|
}
|
|
110
109
|
}
|