@aztec/archiver 3.0.0-devnet.6 → 3.0.0-devnet.6-patch.1
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 +67 -60
- package/dest/archiver/archiver.d.ts.map +1 -1
- package/dest/archiver/archiver.js +391 -262
- package/dest/archiver/archiver_store.d.ts +21 -27
- 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 +125 -140
- package/dest/archiver/config.d.ts +3 -2
- package/dest/archiver/config.d.ts.map +1 -1
- package/dest/archiver/config.js +13 -1
- package/dest/archiver/errors.d.ts +1 -1
- package/dest/archiver/errors.d.ts.map +1 -1
- package/dest/archiver/index.d.ts +1 -1
- package/dest/archiver/instrumentation.d.ts +5 -3
- package/dest/archiver/instrumentation.d.ts.map +1 -1
- package/dest/archiver/instrumentation.js +11 -0
- package/dest/archiver/kv_archiver_store/block_store.d.ts +10 -9
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/block_store.js +9 -8
- 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 +1 -1
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts +2 -2
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +23 -29
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.js +7 -15
- package/dest/archiver/kv_archiver_store/log_store.d.ts +3 -10
- package/dest/archiver/kv_archiver_store/log_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/log_store.js +4 -26
- package/dest/archiver/kv_archiver_store/message_store.d.ts +6 -5
- package/dest/archiver/kv_archiver_store/message_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/message_store.js +15 -14
- 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 +147 -0
- package/dest/archiver/l1/calldata_retriever.d.ts +98 -0
- package/dest/archiver/l1/calldata_retriever.d.ts.map +1 -0
- package/dest/archiver/l1/calldata_retriever.js +403 -0
- package/dest/archiver/l1/data_retrieval.d.ts +87 -0
- package/dest/archiver/l1/data_retrieval.d.ts.map +1 -0
- package/dest/archiver/l1/data_retrieval.js +318 -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 +4 -4
- package/dest/archiver/structs/inbox_message.d.ts.map +1 -1
- package/dest/archiver/structs/inbox_message.js +6 -5
- package/dest/archiver/structs/published.d.ts +3 -2
- package/dest/archiver/structs/published.d.ts.map +1 -1
- package/dest/archiver/validation.d.ts +10 -4
- package/dest/archiver/validation.d.ts.map +1 -1
- package/dest/archiver/validation.js +29 -21
- package/dest/factory.d.ts +3 -5
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +3 -2
- 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 -2
- 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 +7 -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 +10 -9
- package/dest/test/mock_l2_block_source.d.ts +15 -10
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +22 -9
- package/dest/test/mock_structs.d.ts +3 -2
- package/dest/test/mock_structs.d.ts.map +1 -1
- package/dest/test/mock_structs.js +9 -8
- package/package.json +18 -17
- package/src/archiver/archiver.ts +531 -345
- package/src/archiver/archiver_store.ts +24 -27
- package/src/archiver/archiver_store_test_suite.ts +151 -128
- package/src/archiver/config.ts +13 -7
- package/src/archiver/instrumentation.ts +16 -2
- package/src/archiver/kv_archiver_store/block_store.ts +18 -17
- package/src/archiver/kv_archiver_store/contract_class_store.ts +1 -1
- package/src/archiver/kv_archiver_store/contract_instance_store.ts +1 -1
- package/src/archiver/kv_archiver_store/kv_archiver_store.ts +23 -32
- package/src/archiver/kv_archiver_store/log_store.ts +4 -30
- package/src/archiver/kv_archiver_store/message_store.ts +21 -18
- 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 +531 -0
- package/src/archiver/{data_retrieval.ts → l1/data_retrieval.ts} +196 -250
- 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 +8 -8
- package/src/archiver/structs/published.ts +2 -1
- package/src/archiver/validation.ts +52 -27
- package/src/factory.ts +4 -5
- package/src/index.ts +1 -1
- 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 +10 -9
- package/src/test/mock_l2_block_source.ts +32 -15
- package/src/test/mock_structs.ts +10 -9
- package/dest/archiver/data_retrieval.d.ts +0 -79
- package/dest/archiver/data_retrieval.d.ts.map +0 -1
- package/dest/archiver/data_retrieval.js +0 -362
|
@@ -4,10 +4,11 @@ import {
|
|
|
4
4
|
PRIVATE_LOG_SIZE_IN_FIELDS,
|
|
5
5
|
} from '@aztec/constants';
|
|
6
6
|
import { makeTuple } from '@aztec/foundation/array';
|
|
7
|
+
import { BlockNumber, CheckpointNumber, EpochNumber } from '@aztec/foundation/branded-types';
|
|
7
8
|
import { Buffer16, Buffer32 } from '@aztec/foundation/buffer';
|
|
8
9
|
import { times, timesParallel } from '@aztec/foundation/collection';
|
|
9
|
-
import { randomInt } from '@aztec/foundation/crypto';
|
|
10
|
-
import { Fr } from '@aztec/foundation/
|
|
10
|
+
import { randomInt } from '@aztec/foundation/crypto/random';
|
|
11
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
11
12
|
import { toArray } from '@aztec/foundation/iterable';
|
|
12
13
|
import { sleep } from '@aztec/foundation/sleep';
|
|
13
14
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -19,7 +20,7 @@ import {
|
|
|
19
20
|
PublishedL2Block,
|
|
20
21
|
type ValidateBlockResult,
|
|
21
22
|
randomBlockInfo,
|
|
22
|
-
|
|
23
|
+
wrapDataInBlock,
|
|
23
24
|
} from '@aztec/stdlib/block';
|
|
24
25
|
import {
|
|
25
26
|
type ContractClassPublic,
|
|
@@ -89,7 +90,7 @@ export function describeArchiverDataStore(
|
|
|
89
90
|
|
|
90
91
|
beforeEach(async () => {
|
|
91
92
|
store = await getStore();
|
|
92
|
-
blocks = await timesParallel(10, async i => makePublished(await L2Block.random(i + 1), i + 10));
|
|
93
|
+
blocks = await timesParallel(10, async i => makePublished(await L2Block.random(BlockNumber(i + 1)), i + 10));
|
|
93
94
|
});
|
|
94
95
|
|
|
95
96
|
describe('addBlocks', () => {
|
|
@@ -103,15 +104,18 @@ export function describeArchiverDataStore(
|
|
|
103
104
|
});
|
|
104
105
|
|
|
105
106
|
it('throws an error if the previous block does not exist in the store', async () => {
|
|
106
|
-
const block = makePublished(await L2Block.random(2), 2);
|
|
107
|
+
const block = makePublished(await L2Block.random(BlockNumber(2)), 2);
|
|
107
108
|
await expect(store.addBlocks([block])).rejects.toThrow(InitialBlockNumberNotSequentialError);
|
|
108
|
-
await expect(store.getPublishedBlocks(1, 10)).resolves.toEqual([]);
|
|
109
|
+
await expect(store.getPublishedBlocks(BlockNumber(1), 10)).resolves.toEqual([]);
|
|
109
110
|
});
|
|
110
111
|
|
|
111
112
|
it('throws an error if there is a gap in the blocks being added', async () => {
|
|
112
|
-
const blocks = [
|
|
113
|
+
const blocks = [
|
|
114
|
+
makePublished(await L2Block.random(BlockNumber(1)), 1),
|
|
115
|
+
makePublished(await L2Block.random(BlockNumber(3)), 3),
|
|
116
|
+
];
|
|
113
117
|
await expect(store.addBlocks(blocks)).rejects.toThrow(BlockNumberNotSequentialError);
|
|
114
|
-
await expect(store.getPublishedBlocks(1, 10)).resolves.toEqual([]);
|
|
118
|
+
await expect(store.getPublishedBlocks(BlockNumber(1), 10)).resolves.toEqual([]);
|
|
115
119
|
});
|
|
116
120
|
});
|
|
117
121
|
|
|
@@ -129,18 +133,22 @@ export function describeArchiverDataStore(
|
|
|
129
133
|
});
|
|
130
134
|
|
|
131
135
|
it('can unwind multiple empty blocks', async () => {
|
|
132
|
-
const emptyBlocks = await timesParallel(10, async i =>
|
|
136
|
+
const emptyBlocks = await timesParallel(10, async i =>
|
|
137
|
+
makePublished(await L2Block.random(BlockNumber(i + 1), 0), i + 10),
|
|
138
|
+
);
|
|
133
139
|
await store.addBlocks(emptyBlocks);
|
|
134
140
|
expect(await store.getSynchedL2BlockNumber()).toBe(10);
|
|
135
141
|
|
|
136
|
-
await store.unwindBlocks(10, 3);
|
|
142
|
+
await store.unwindBlocks(BlockNumber(10), 3);
|
|
137
143
|
expect(await store.getSynchedL2BlockNumber()).toBe(7);
|
|
138
|
-
expect((await store.getPublishedBlocks(1, 10)).map(b => b.block.number)).toEqual([
|
|
144
|
+
expect((await store.getPublishedBlocks(BlockNumber(1), 10)).map(b => b.block.number)).toEqual([
|
|
145
|
+
1, 2, 3, 4, 5, 6, 7,
|
|
146
|
+
]);
|
|
139
147
|
});
|
|
140
148
|
|
|
141
149
|
it('refuses to unwind blocks if the tip is not the last block', async () => {
|
|
142
150
|
await store.addBlocks(blocks);
|
|
143
|
-
await expect(store.unwindBlocks(5, 1)).rejects.toThrow(/can only unwind blocks from the tip/i);
|
|
151
|
+
await expect(store.unwindBlocks(BlockNumber(5), 1)).rejects.toThrow(/can only unwind blocks from the tip/i);
|
|
144
152
|
});
|
|
145
153
|
|
|
146
154
|
it('unwound blocks and headers cannot be retrieved by hash or archive', async () => {
|
|
@@ -172,32 +180,37 @@ export function describeArchiverDataStore(
|
|
|
172
180
|
});
|
|
173
181
|
|
|
174
182
|
it.each(blockTests)('retrieves previously stored blocks', async (start, limit, getExpectedBlocks) => {
|
|
175
|
-
expectBlocksEqual(await store.getPublishedBlocks(start, limit), getExpectedBlocks());
|
|
183
|
+
expectBlocksEqual(await store.getPublishedBlocks(BlockNumber(start), limit), getExpectedBlocks());
|
|
176
184
|
});
|
|
177
185
|
|
|
178
186
|
it('returns an empty array if no blocks are found', async () => {
|
|
179
|
-
await expect(store.getPublishedBlocks(12, 1)).resolves.toEqual([]);
|
|
187
|
+
await expect(store.getPublishedBlocks(BlockNumber(12), 1)).resolves.toEqual([]);
|
|
180
188
|
});
|
|
181
189
|
|
|
182
190
|
it('throws an error if limit is invalid', async () => {
|
|
183
|
-
await expect(store.getPublishedBlocks(1, 0)).rejects.toThrow('Invalid limit: 0');
|
|
191
|
+
await expect(store.getPublishedBlocks(BlockNumber(1), 0)).rejects.toThrow('Invalid limit: 0');
|
|
184
192
|
});
|
|
185
193
|
|
|
186
194
|
it('throws an error if `from` it is out of range', async () => {
|
|
187
|
-
await expect(store.getPublishedBlocks(INITIAL_L2_BLOCK_NUM - 100, 1)).rejects.toThrow(
|
|
195
|
+
await expect(store.getPublishedBlocks((INITIAL_L2_BLOCK_NUM - 100) as BlockNumber, 1)).rejects.toThrow(
|
|
196
|
+
'Invalid start: -99',
|
|
197
|
+
);
|
|
188
198
|
});
|
|
189
199
|
|
|
190
200
|
it('throws an error if unexpected initial block number is found', async () => {
|
|
191
|
-
await store.addBlocks([makePublished(await L2Block.random(21), 31)], { force: true });
|
|
192
|
-
await expect(store.getPublishedBlocks(20, 1)).rejects.toThrow(`mismatch`);
|
|
201
|
+
await store.addBlocks([makePublished(await L2Block.random(BlockNumber(21)), 31)], { force: true });
|
|
202
|
+
await expect(store.getPublishedBlocks(BlockNumber(20), 1)).rejects.toThrow(`mismatch`);
|
|
193
203
|
});
|
|
194
204
|
|
|
195
205
|
it('throws an error if a gap is found', async () => {
|
|
196
206
|
await store.addBlocks(
|
|
197
|
-
[
|
|
207
|
+
[
|
|
208
|
+
makePublished(await L2Block.random(BlockNumber(20)), 30),
|
|
209
|
+
makePublished(await L2Block.random(BlockNumber(22)), 32),
|
|
210
|
+
],
|
|
198
211
|
{ force: true },
|
|
199
212
|
);
|
|
200
|
-
await expect(store.getPublishedBlocks(20, 2)).rejects.toThrow(`mismatch`);
|
|
213
|
+
await expect(store.getPublishedBlocks(BlockNumber(20), 2)).rejects.toThrow(`mismatch`);
|
|
201
214
|
});
|
|
202
215
|
});
|
|
203
216
|
|
|
@@ -339,36 +352,19 @@ export function describeArchiverDataStore(
|
|
|
339
352
|
});
|
|
340
353
|
});
|
|
341
354
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
await expect(store.addLogs([block])).resolves.toEqual(true);
|
|
347
|
-
|
|
348
|
-
expect((await store.getPrivateLogs(1, 1)).length).toEqual(
|
|
349
|
-
block.body.txEffects.map(txEffect => txEffect.privateLogs).flat().length,
|
|
350
|
-
);
|
|
351
|
-
expect((await store.getPublicLogs({ fromBlock: 1 })).logs.length).toEqual(
|
|
352
|
-
block.body.txEffects.map(txEffect => txEffect.publicLogs).flat().length,
|
|
353
|
-
);
|
|
354
|
-
|
|
355
|
-
// This one is a pain for memory as we would never want to just delete memory in the middle.
|
|
356
|
-
await store.deleteLogs([block]);
|
|
355
|
+
it('deleteLogs', async () => {
|
|
356
|
+
const block = blocks[0].block;
|
|
357
|
+
await store.addBlocks([blocks[0]]);
|
|
358
|
+
await expect(store.addLogs([block])).resolves.toEqual(true);
|
|
357
359
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
});
|
|
360
|
+
expect((await store.getPublicLogs({ fromBlock: BlockNumber(1) })).logs.length).toEqual(
|
|
361
|
+
block.body.txEffects.map(txEffect => txEffect.publicLogs).flat().length,
|
|
362
|
+
);
|
|
362
363
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
const block = blocks[0].block;
|
|
366
|
-
await store.addBlocks([blocks[0]]);
|
|
367
|
-
await store.addLogs([block]);
|
|
364
|
+
// This one is a pain for memory as we would never want to just delete memory in the middle.
|
|
365
|
+
await store.deleteLogs([block]);
|
|
368
366
|
|
|
369
|
-
|
|
370
|
-
expect(privateLogs).toEqual(block.body.txEffects.map(txEffect => txEffect.privateLogs).flat());
|
|
371
|
-
});
|
|
367
|
+
expect((await store.getPublicLogs({ fromBlock: BlockNumber(1) })).logs.length).toEqual(0);
|
|
372
368
|
});
|
|
373
369
|
|
|
374
370
|
describe('getTxEffect', () => {
|
|
@@ -400,13 +396,13 @@ export function describeArchiverDataStore(
|
|
|
400
396
|
});
|
|
401
397
|
|
|
402
398
|
it.each([
|
|
403
|
-
() =>
|
|
404
|
-
() =>
|
|
405
|
-
() =>
|
|
406
|
-
() =>
|
|
407
|
-
() =>
|
|
399
|
+
() => wrapDataInBlock(blocks[0].block.body.txEffects[0], blocks[0].block),
|
|
400
|
+
() => wrapDataInBlock(blocks[9].block.body.txEffects[3], blocks[9].block),
|
|
401
|
+
() => wrapDataInBlock(blocks[3].block.body.txEffects[1], blocks[3].block),
|
|
402
|
+
() => wrapDataInBlock(blocks[5].block.body.txEffects[2], blocks[5].block),
|
|
403
|
+
() => wrapDataInBlock(blocks[1].block.body.txEffects[0], blocks[1].block),
|
|
408
404
|
])('tries to retrieves a previously stored transaction after deleted', async getExpectedTx => {
|
|
409
|
-
await store.unwindBlocks(blocks.length, blocks.length);
|
|
405
|
+
await store.unwindBlocks(BlockNumber(blocks.length), blocks.length);
|
|
410
406
|
|
|
411
407
|
const expectedTx = await getExpectedTx();
|
|
412
408
|
const actualTx = await store.getTxEffect(expectedTx.data.txHash);
|
|
@@ -418,7 +414,7 @@ export function describeArchiverDataStore(
|
|
|
418
414
|
});
|
|
419
415
|
|
|
420
416
|
it('does not fail if the block is unwound while requesting a tx', async () => {
|
|
421
|
-
const expectedTx = await
|
|
417
|
+
const expectedTx = await wrapDataInBlock(blocks[1].block.body.txEffects[0], blocks[1].block);
|
|
422
418
|
let done = false;
|
|
423
419
|
void (async () => {
|
|
424
420
|
while (!done) {
|
|
@@ -426,14 +422,14 @@ export function describeArchiverDataStore(
|
|
|
426
422
|
await sleep(1);
|
|
427
423
|
}
|
|
428
424
|
})();
|
|
429
|
-
await store.unwindBlocks(blocks.length, blocks.length);
|
|
425
|
+
await store.unwindBlocks(BlockNumber(blocks.length), blocks.length);
|
|
430
426
|
done = true;
|
|
431
427
|
expect(await store.getTxEffect(expectedTx.data.txHash)).toEqual(undefined);
|
|
432
428
|
});
|
|
433
429
|
});
|
|
434
430
|
|
|
435
431
|
describe('L1 to L2 Messages', () => {
|
|
436
|
-
const
|
|
432
|
+
const initialCheckpointNumber = CheckpointNumber(13);
|
|
437
433
|
|
|
438
434
|
const checkMessages = async (msgs: InboxMessage[]) => {
|
|
439
435
|
expect(await store.getLastL1ToL2Message()).toEqual(msgs.at(-1));
|
|
@@ -441,43 +437,50 @@ export function describeArchiverDataStore(
|
|
|
441
437
|
expect(await store.getTotalL1ToL2MessageCount()).toEqual(BigInt(msgs.length));
|
|
442
438
|
};
|
|
443
439
|
|
|
444
|
-
const makeInboxMessagesWithFullBlocks = (
|
|
440
|
+
const makeInboxMessagesWithFullBlocks = (
|
|
441
|
+
blockCount: number,
|
|
442
|
+
opts: { initialCheckpointNumber?: CheckpointNumber } = {},
|
|
443
|
+
) =>
|
|
445
444
|
makeInboxMessages(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP * blockCount, {
|
|
446
445
|
overrideFn: (msg, i) => {
|
|
447
|
-
const
|
|
448
|
-
(opts.
|
|
446
|
+
const checkpointNumber = CheckpointNumber(
|
|
447
|
+
(opts.initialCheckpointNumber ?? initialCheckpointNumber) +
|
|
448
|
+
Math.floor(i / NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP),
|
|
449
|
+
);
|
|
449
450
|
const index =
|
|
450
|
-
InboxLeaf.
|
|
451
|
-
return { ...msg,
|
|
451
|
+
InboxLeaf.smallestIndexForCheckpoint(checkpointNumber) + BigInt(i % NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP);
|
|
452
|
+
return { ...msg, checkpointNumber, index };
|
|
452
453
|
},
|
|
453
454
|
});
|
|
454
455
|
|
|
455
456
|
it('stores first message ever', async () => {
|
|
456
|
-
const msg = makeInboxMessage(Buffer16.ZERO, { index: 0n,
|
|
457
|
+
const msg = makeInboxMessage(Buffer16.ZERO, { index: 0n, checkpointNumber: CheckpointNumber(1) });
|
|
457
458
|
await store.addL1ToL2Messages([msg]);
|
|
458
459
|
|
|
459
460
|
await checkMessages([msg]);
|
|
460
|
-
expect(await store.getL1ToL2Messages(1)).toEqual([msg.leaf]);
|
|
461
|
+
expect(await store.getL1ToL2Messages(CheckpointNumber(1))).toEqual([msg.leaf]);
|
|
461
462
|
});
|
|
462
463
|
|
|
463
464
|
it('stores single message', async () => {
|
|
464
|
-
const msg = makeInboxMessage(Buffer16.ZERO, {
|
|
465
|
+
const msg = makeInboxMessage(Buffer16.ZERO, { checkpointNumber: CheckpointNumber(2) });
|
|
465
466
|
await store.addL1ToL2Messages([msg]);
|
|
466
467
|
|
|
467
468
|
await checkMessages([msg]);
|
|
468
|
-
expect(await store.getL1ToL2Messages(2)).toEqual([msg.leaf]);
|
|
469
|
+
expect(await store.getL1ToL2Messages(CheckpointNumber(2))).toEqual([msg.leaf]);
|
|
469
470
|
});
|
|
470
471
|
|
|
471
472
|
it('stores and returns messages across different blocks', async () => {
|
|
472
|
-
const msgs = makeInboxMessages(5, {
|
|
473
|
+
const msgs = makeInboxMessages(5, { initialCheckpointNumber });
|
|
473
474
|
await store.addL1ToL2Messages(msgs);
|
|
474
475
|
|
|
475
476
|
await checkMessages(msgs);
|
|
476
|
-
expect(await store.getL1ToL2Messages(
|
|
477
|
+
expect(await store.getL1ToL2Messages(CheckpointNumber(initialCheckpointNumber + 2))).toEqual(
|
|
478
|
+
[msgs[2]].map(m => m.leaf),
|
|
479
|
+
);
|
|
477
480
|
});
|
|
478
481
|
|
|
479
482
|
it('stores the same messages again', async () => {
|
|
480
|
-
const msgs = makeInboxMessages(5, {
|
|
483
|
+
const msgs = makeInboxMessages(5, { initialCheckpointNumber });
|
|
481
484
|
await store.addL1ToL2Messages(msgs);
|
|
482
485
|
await store.addL1ToL2Messages(msgs.slice(2));
|
|
483
486
|
|
|
@@ -485,26 +488,29 @@ export function describeArchiverDataStore(
|
|
|
485
488
|
});
|
|
486
489
|
|
|
487
490
|
it('stores and returns messages across different blocks with gaps', async () => {
|
|
488
|
-
const msgs1 = makeInboxMessages(3, {
|
|
489
|
-
const msgs2 = makeInboxMessages(3, {
|
|
491
|
+
const msgs1 = makeInboxMessages(3, { initialCheckpointNumber: CheckpointNumber(1) });
|
|
492
|
+
const msgs2 = makeInboxMessages(3, {
|
|
493
|
+
initialCheckpointNumber: CheckpointNumber(20),
|
|
494
|
+
initialHash: msgs1.at(-1)!.rollingHash,
|
|
495
|
+
});
|
|
490
496
|
|
|
491
497
|
await store.addL1ToL2Messages(msgs1);
|
|
492
498
|
await store.addL1ToL2Messages(msgs2);
|
|
493
499
|
|
|
494
500
|
await checkMessages([...msgs1, ...msgs2]);
|
|
495
501
|
|
|
496
|
-
expect(await store.getL1ToL2Messages(1)).toEqual([msgs1[0].leaf]);
|
|
497
|
-
expect(await store.getL1ToL2Messages(4)).toEqual([]);
|
|
498
|
-
expect(await store.getL1ToL2Messages(20)).toEqual([msgs2[0].leaf]);
|
|
499
|
-
expect(await store.getL1ToL2Messages(24)).toEqual([]);
|
|
502
|
+
expect(await store.getL1ToL2Messages(CheckpointNumber(1))).toEqual([msgs1[0].leaf]);
|
|
503
|
+
expect(await store.getL1ToL2Messages(CheckpointNumber(4))).toEqual([]);
|
|
504
|
+
expect(await store.getL1ToL2Messages(CheckpointNumber(20))).toEqual([msgs2[0].leaf]);
|
|
505
|
+
expect(await store.getL1ToL2Messages(CheckpointNumber(24))).toEqual([]);
|
|
500
506
|
});
|
|
501
507
|
|
|
502
508
|
it('stores and returns messages with block numbers larger than a byte', async () => {
|
|
503
|
-
const msgs = makeInboxMessages(5, {
|
|
509
|
+
const msgs = makeInboxMessages(5, { initialCheckpointNumber: CheckpointNumber(1000) });
|
|
504
510
|
await store.addL1ToL2Messages(msgs);
|
|
505
511
|
|
|
506
512
|
await checkMessages(msgs);
|
|
507
|
-
expect(await store.getL1ToL2Messages(1002)).toEqual([msgs[2]].map(m => m.leaf));
|
|
513
|
+
expect(await store.getL1ToL2Messages(CheckpointNumber(1002))).toEqual([msgs[2]].map(m => m.leaf));
|
|
508
514
|
});
|
|
509
515
|
|
|
510
516
|
it('stores and returns multiple messages per block', async () => {
|
|
@@ -512,7 +518,7 @@ export function describeArchiverDataStore(
|
|
|
512
518
|
await store.addL1ToL2Messages(msgs);
|
|
513
519
|
|
|
514
520
|
await checkMessages(msgs);
|
|
515
|
-
const blockMessages = await store.getL1ToL2Messages(
|
|
521
|
+
const blockMessages = await store.getL1ToL2Messages(CheckpointNumber(initialCheckpointNumber + 1));
|
|
516
522
|
expect(blockMessages).toHaveLength(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP);
|
|
517
523
|
expect(blockMessages).toEqual(
|
|
518
524
|
msgs.slice(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP * 2).map(m => m.leaf),
|
|
@@ -520,17 +526,21 @@ export function describeArchiverDataStore(
|
|
|
520
526
|
});
|
|
521
527
|
|
|
522
528
|
it('stores messages in multiple operations', async () => {
|
|
523
|
-
const msgs = makeInboxMessages(20, {
|
|
529
|
+
const msgs = makeInboxMessages(20, { initialCheckpointNumber });
|
|
524
530
|
await store.addL1ToL2Messages(msgs.slice(0, 10));
|
|
525
531
|
await store.addL1ToL2Messages(msgs.slice(10, 20));
|
|
526
532
|
|
|
527
|
-
expect(await store.getL1ToL2Messages(
|
|
528
|
-
|
|
533
|
+
expect(await store.getL1ToL2Messages(CheckpointNumber(initialCheckpointNumber + 2))).toEqual(
|
|
534
|
+
[msgs[2]].map(m => m.leaf),
|
|
535
|
+
);
|
|
536
|
+
expect(await store.getL1ToL2Messages(CheckpointNumber(initialCheckpointNumber + 12))).toEqual(
|
|
537
|
+
[msgs[12]].map(m => m.leaf),
|
|
538
|
+
);
|
|
529
539
|
await checkMessages(msgs);
|
|
530
540
|
});
|
|
531
541
|
|
|
532
542
|
it('iterates over messages from start index', async () => {
|
|
533
|
-
const msgs = makeInboxMessages(10, {
|
|
543
|
+
const msgs = makeInboxMessages(10, { initialCheckpointNumber });
|
|
534
544
|
await store.addL1ToL2Messages(msgs);
|
|
535
545
|
|
|
536
546
|
const iterated = await toArray(store.iterateL1ToL2Messages({ start: msgs[3].index }));
|
|
@@ -538,8 +548,9 @@ export function describeArchiverDataStore(
|
|
|
538
548
|
});
|
|
539
549
|
|
|
540
550
|
it('iterates over messages in reverse', async () => {
|
|
541
|
-
const msgs = makeInboxMessages(10, {
|
|
551
|
+
const msgs = makeInboxMessages(10, { initialCheckpointNumber });
|
|
542
552
|
await store.addL1ToL2Messages(msgs);
|
|
553
|
+
initialCheckpointNumber;
|
|
543
554
|
|
|
544
555
|
const iterated = await toArray(store.iterateL1ToL2Messages({ reverse: true, end: msgs[3].index }));
|
|
545
556
|
expect(iterated).toEqual(msgs.slice(0, 4).reverse());
|
|
@@ -551,8 +562,8 @@ export function describeArchiverDataStore(
|
|
|
551
562
|
});
|
|
552
563
|
|
|
553
564
|
it('throws if block number for the first message is out of order', async () => {
|
|
554
|
-
const msgs = makeInboxMessages(4, {
|
|
555
|
-
msgs[2].
|
|
565
|
+
const msgs = makeInboxMessages(4, { initialCheckpointNumber });
|
|
566
|
+
msgs[2].checkpointNumber = CheckpointNumber(initialCheckpointNumber - 1);
|
|
556
567
|
await store.addL1ToL2Messages(msgs.slice(0, 2));
|
|
557
568
|
await expect(store.addL1ToL2Messages(msgs.slice(2, 4))).rejects.toThrow(MessageStoreError);
|
|
558
569
|
});
|
|
@@ -566,28 +577,28 @@ export function describeArchiverDataStore(
|
|
|
566
577
|
it('throws if rolling hash for first message is not correct', async () => {
|
|
567
578
|
const msgs = makeInboxMessages(4);
|
|
568
579
|
msgs[2].rollingHash = Buffer16.random();
|
|
569
|
-
await store.addL1ToL2Messages(msgs.slice(0, 2));
|
|
580
|
+
await store.addL1ToL2Messages(msgs.slice(0, CheckpointNumber(2)));
|
|
570
581
|
await expect(store.addL1ToL2Messages(msgs.slice(2, 4))).rejects.toThrow(MessageStoreError);
|
|
571
582
|
});
|
|
572
583
|
|
|
573
584
|
it('throws if index is not in the correct range', async () => {
|
|
574
|
-
const msgs = makeInboxMessages(5, {
|
|
585
|
+
const msgs = makeInboxMessages(5, { initialCheckpointNumber });
|
|
575
586
|
msgs.at(-1)!.index += 100n;
|
|
576
587
|
await expect(store.addL1ToL2Messages(msgs)).rejects.toThrow(MessageStoreError);
|
|
577
588
|
});
|
|
578
589
|
|
|
579
590
|
it('throws if first index in block has gaps', async () => {
|
|
580
|
-
const msgs = makeInboxMessages(4, {
|
|
591
|
+
const msgs = makeInboxMessages(4, { initialCheckpointNumber });
|
|
581
592
|
msgs[2].index++;
|
|
582
593
|
await expect(store.addL1ToL2Messages(msgs)).rejects.toThrow(MessageStoreError);
|
|
583
594
|
});
|
|
584
595
|
|
|
585
596
|
it('throws if index does not follow previous one', async () => {
|
|
586
597
|
const msgs = makeInboxMessages(2, {
|
|
587
|
-
|
|
598
|
+
initialCheckpointNumber,
|
|
588
599
|
overrideFn: (msg, i) => ({
|
|
589
600
|
...msg,
|
|
590
|
-
|
|
601
|
+
checkpointNumber: CheckpointNumber(2),
|
|
591
602
|
index: BigInt(i + NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP * 2),
|
|
592
603
|
}),
|
|
593
604
|
});
|
|
@@ -596,28 +607,28 @@ export function describeArchiverDataStore(
|
|
|
596
607
|
});
|
|
597
608
|
|
|
598
609
|
it('removes messages up to the given block number', async () => {
|
|
599
|
-
const msgs = makeInboxMessagesWithFullBlocks(4, {
|
|
610
|
+
const msgs = makeInboxMessagesWithFullBlocks(4, { initialCheckpointNumber: CheckpointNumber(1) });
|
|
600
611
|
|
|
601
612
|
await store.addL1ToL2Messages(msgs);
|
|
602
613
|
await checkMessages(msgs);
|
|
603
614
|
|
|
604
|
-
expect(await store.getL1ToL2Messages(1)).toHaveLength(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP);
|
|
605
|
-
expect(await store.getL1ToL2Messages(2)).toHaveLength(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP);
|
|
606
|
-
expect(await store.getL1ToL2Messages(3)).toHaveLength(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP);
|
|
607
|
-
expect(await store.getL1ToL2Messages(4)).toHaveLength(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP);
|
|
615
|
+
expect(await store.getL1ToL2Messages(CheckpointNumber(1))).toHaveLength(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP);
|
|
616
|
+
expect(await store.getL1ToL2Messages(CheckpointNumber(2))).toHaveLength(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP);
|
|
617
|
+
expect(await store.getL1ToL2Messages(CheckpointNumber(3))).toHaveLength(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP);
|
|
618
|
+
expect(await store.getL1ToL2Messages(CheckpointNumber(4))).toHaveLength(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP);
|
|
608
619
|
|
|
609
|
-
await store.
|
|
620
|
+
await store.rollbackL1ToL2MessagesToCheckpoint(CheckpointNumber(2));
|
|
610
621
|
|
|
611
|
-
expect(await store.getL1ToL2Messages(1)).toHaveLength(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP);
|
|
612
|
-
expect(await store.getL1ToL2Messages(2)).toHaveLength(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP);
|
|
613
|
-
expect(await store.getL1ToL2Messages(3)).toHaveLength(0);
|
|
614
|
-
expect(await store.getL1ToL2Messages(4)).toHaveLength(0);
|
|
622
|
+
expect(await store.getL1ToL2Messages(CheckpointNumber(1))).toHaveLength(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP);
|
|
623
|
+
expect(await store.getL1ToL2Messages(CheckpointNumber(2))).toHaveLength(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP);
|
|
624
|
+
expect(await store.getL1ToL2Messages(CheckpointNumber(3))).toHaveLength(0);
|
|
625
|
+
expect(await store.getL1ToL2Messages(CheckpointNumber(4))).toHaveLength(0);
|
|
615
626
|
|
|
616
627
|
await checkMessages(msgs.slice(0, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP * 2));
|
|
617
628
|
});
|
|
618
629
|
|
|
619
630
|
it('removes messages starting with the given index', async () => {
|
|
620
|
-
const msgs = makeInboxMessagesWithFullBlocks(4, {
|
|
631
|
+
const msgs = makeInboxMessagesWithFullBlocks(4, { initialCheckpointNumber: CheckpointNumber(1) });
|
|
621
632
|
await store.addL1ToL2Messages(msgs);
|
|
622
633
|
|
|
623
634
|
await store.removeL1ToL2Messages(msgs[13].index);
|
|
@@ -637,7 +648,7 @@ export function describeArchiverDataStore(
|
|
|
637
648
|
originalContractClassId: classId,
|
|
638
649
|
});
|
|
639
650
|
contractInstance = { ...randomInstance, address: await AztecAddress.random() };
|
|
640
|
-
await store.addContractInstances([contractInstance], blockNum);
|
|
651
|
+
await store.addContractInstances([contractInstance], BlockNumber(blockNum));
|
|
641
652
|
});
|
|
642
653
|
|
|
643
654
|
it('returns previously stored contract instances', async () => {
|
|
@@ -651,7 +662,7 @@ export function describeArchiverDataStore(
|
|
|
651
662
|
});
|
|
652
663
|
|
|
653
664
|
it('returns undefined if previously stored contract instances was deleted', async () => {
|
|
654
|
-
await store.deleteContractInstances([contractInstance], blockNum);
|
|
665
|
+
await store.deleteContractInstances([contractInstance], BlockNumber(blockNum));
|
|
655
666
|
await expect(store.getContractInstance(contractInstance.address, timestamp)).resolves.toBeUndefined();
|
|
656
667
|
});
|
|
657
668
|
});
|
|
@@ -670,7 +681,7 @@ export function describeArchiverDataStore(
|
|
|
670
681
|
originalContractClassId: classId,
|
|
671
682
|
});
|
|
672
683
|
contractInstance = { ...randomInstance, address: await AztecAddress.random() };
|
|
673
|
-
await store.addContractInstances([contractInstance], 1);
|
|
684
|
+
await store.addContractInstances([contractInstance], BlockNumber(1));
|
|
674
685
|
await store.addContractInstanceUpdates(
|
|
675
686
|
[
|
|
676
687
|
{
|
|
@@ -712,7 +723,7 @@ export function describeArchiverDataStore(
|
|
|
712
723
|
...randomInstance,
|
|
713
724
|
address: await AztecAddress.random(),
|
|
714
725
|
};
|
|
715
|
-
await store.addContractInstances([otherContractInstance], 1);
|
|
726
|
+
await store.addContractInstances([otherContractInstance], BlockNumber(1));
|
|
716
727
|
|
|
717
728
|
const fetchedInstance = await store.getContractInstance(otherContractInstance.address, timestampOfChange + 1n);
|
|
718
729
|
expect(fetchedInstance?.originalContractClassId).toEqual(otherClassId);
|
|
@@ -730,7 +741,7 @@ export function describeArchiverDataStore(
|
|
|
730
741
|
...randomInstance,
|
|
731
742
|
address: await AztecAddress.random(),
|
|
732
743
|
};
|
|
733
|
-
await store.addContractInstances([otherContractInstance], 1);
|
|
744
|
+
await store.addContractInstances([otherContractInstance], BlockNumber(1));
|
|
734
745
|
await store.addContractInstanceUpdates(
|
|
735
746
|
[
|
|
736
747
|
{
|
|
@@ -758,7 +769,7 @@ export function describeArchiverDataStore(
|
|
|
758
769
|
await store.addContractClasses(
|
|
759
770
|
[contractClass],
|
|
760
771
|
[await computePublicBytecodeCommitment(contractClass.packedBytecode)],
|
|
761
|
-
blockNum,
|
|
772
|
+
BlockNumber(blockNum),
|
|
762
773
|
);
|
|
763
774
|
});
|
|
764
775
|
|
|
@@ -767,7 +778,7 @@ export function describeArchiverDataStore(
|
|
|
767
778
|
});
|
|
768
779
|
|
|
769
780
|
it('returns undefined if the initial deployed contract class was deleted', async () => {
|
|
770
|
-
await store.deleteContractClasses([contractClass], blockNum);
|
|
781
|
+
await store.deleteContractClasses([contractClass], BlockNumber(blockNum));
|
|
771
782
|
await expect(store.getContractClass(contractClass.id)).resolves.toBeUndefined();
|
|
772
783
|
});
|
|
773
784
|
|
|
@@ -775,9 +786,9 @@ export function describeArchiverDataStore(
|
|
|
775
786
|
await store.addContractClasses(
|
|
776
787
|
[contractClass],
|
|
777
788
|
[await computePublicBytecodeCommitment(contractClass.packedBytecode)],
|
|
778
|
-
blockNum + 1,
|
|
789
|
+
BlockNumber(blockNum + 1),
|
|
779
790
|
);
|
|
780
|
-
await store.deleteContractClasses([contractClass], blockNum + 1);
|
|
791
|
+
await store.deleteContractClasses([contractClass], BlockNumber(blockNum + 1));
|
|
781
792
|
await expect(store.getContractClass(contractClass.id)).resolves.toMatchObject(contractClass);
|
|
782
793
|
});
|
|
783
794
|
|
|
@@ -857,8 +868,8 @@ export function describeArchiverDataStore(
|
|
|
857
868
|
};
|
|
858
869
|
|
|
859
870
|
const mockBlockWithLogs = async (blockNumber: number): Promise<PublishedL2Block> => {
|
|
860
|
-
const block = await L2Block.random(blockNumber);
|
|
861
|
-
block.header.globalVariables.blockNumber = blockNumber;
|
|
871
|
+
const block = await L2Block.random(BlockNumber(blockNumber));
|
|
872
|
+
block.header.globalVariables.blockNumber = BlockNumber(blockNumber);
|
|
862
873
|
|
|
863
874
|
block.body.txEffects = await timesParallel(numTxsPerBlock, async (txIndex: number) => {
|
|
864
875
|
const txEffect = await TxEffect.random();
|
|
@@ -990,7 +1001,7 @@ export function describeArchiverDataStore(
|
|
|
990
1001
|
beforeEach(async () => {
|
|
991
1002
|
blocks = await timesParallel(numBlocks, async (index: number) =>
|
|
992
1003
|
PublishedL2Block.fromFields({
|
|
993
|
-
block: await L2Block.random(index + 1, txsPerBlock, numPublicFunctionCalls, numPublicLogs),
|
|
1004
|
+
block: await L2Block.random(BlockNumber(index + 1), txsPerBlock, numPublicFunctionCalls, numPublicLogs),
|
|
994
1005
|
l1: { blockNumber: BigInt(index), blockHash: makeBlockHash(index), timestamp: BigInt(index) },
|
|
995
1006
|
attestations: times(3, CommitteeAttestation.random),
|
|
996
1007
|
}),
|
|
@@ -1007,7 +1018,7 @@ export function describeArchiverDataStore(
|
|
|
1007
1018
|
const targetTxHash = blocks[targetBlockIndex].block.body.txEffects[targetTxIndex].txHash;
|
|
1008
1019
|
|
|
1009
1020
|
await Promise.all([
|
|
1010
|
-
store.unwindBlocks(blocks.length, blocks.length),
|
|
1021
|
+
store.unwindBlocks(BlockNumber(blocks.length), blocks.length),
|
|
1011
1022
|
store.deleteLogs(blocks.map(b => b.block)),
|
|
1012
1023
|
]);
|
|
1013
1024
|
|
|
@@ -1082,7 +1093,7 @@ export function describeArchiverDataStore(
|
|
|
1082
1093
|
const targetTxIndex = randomInt(txsPerBlock);
|
|
1083
1094
|
const targetLogIndex = randomInt(numPublicLogs);
|
|
1084
1095
|
|
|
1085
|
-
const afterLog = new LogId(targetBlockIndex + INITIAL_L2_BLOCK_NUM, targetTxIndex, targetLogIndex);
|
|
1096
|
+
const afterLog = new LogId(BlockNumber(targetBlockIndex + INITIAL_L2_BLOCK_NUM), targetTxIndex, targetLogIndex);
|
|
1086
1097
|
|
|
1087
1098
|
const response = await store.getPublicLogs({ afterLog });
|
|
1088
1099
|
const logs = response.logs;
|
|
@@ -1104,42 +1115,54 @@ export function describeArchiverDataStore(
|
|
|
1104
1115
|
it('"txHash" filter param is ignored when "afterLog" is set', async () => {
|
|
1105
1116
|
// Get random txHash
|
|
1106
1117
|
const txHash = TxHash.random();
|
|
1107
|
-
const afterLog = new LogId(1, 0, 0);
|
|
1118
|
+
const afterLog = new LogId(BlockNumber(1), 0, 0);
|
|
1108
1119
|
|
|
1109
1120
|
const response = await store.getPublicLogs({ txHash, afterLog });
|
|
1110
1121
|
expect(response.logs.length).toBeGreaterThan(1);
|
|
1111
1122
|
});
|
|
1112
1123
|
|
|
1113
1124
|
it('intersecting works', async () => {
|
|
1114
|
-
let logs = (await store.getPublicLogs({ fromBlock: -10, toBlock: -5 })).logs;
|
|
1125
|
+
let logs = (await store.getPublicLogs({ fromBlock: -10 as BlockNumber, toBlock: -5 as BlockNumber })).logs;
|
|
1115
1126
|
expect(logs.length).toBe(0);
|
|
1116
1127
|
|
|
1117
1128
|
// "fromBlock" gets correctly trimmed to range and "toBlock" is exclusive
|
|
1118
|
-
logs = (await store.getPublicLogs({ fromBlock: -10, toBlock: 5 })).logs;
|
|
1129
|
+
logs = (await store.getPublicLogs({ fromBlock: -10 as BlockNumber, toBlock: BlockNumber(5) })).logs;
|
|
1119
1130
|
let blockNumbers = new Set(logs.map(log => log.id.blockNumber));
|
|
1120
1131
|
expect(blockNumbers).toEqual(new Set([1, 2, 3, 4]));
|
|
1121
1132
|
|
|
1122
1133
|
// "toBlock" should be exclusive
|
|
1123
|
-
logs = (await store.getPublicLogs({ fromBlock: 1, toBlock: 1 })).logs;
|
|
1134
|
+
logs = (await store.getPublicLogs({ fromBlock: BlockNumber(1), toBlock: BlockNumber(1) })).logs;
|
|
1124
1135
|
expect(logs.length).toBe(0);
|
|
1125
1136
|
|
|
1126
|
-
logs = (await store.getPublicLogs({ fromBlock: 10, toBlock: 5 })).logs;
|
|
1137
|
+
logs = (await store.getPublicLogs({ fromBlock: BlockNumber(10), toBlock: BlockNumber(5) })).logs;
|
|
1127
1138
|
expect(logs.length).toBe(0);
|
|
1128
1139
|
|
|
1129
1140
|
// both "fromBlock" and "toBlock" get correctly capped to range and logs from all blocks are returned
|
|
1130
|
-
logs = (await store.getPublicLogs({ fromBlock: -100, toBlock: +100 })).logs;
|
|
1141
|
+
logs = (await store.getPublicLogs({ fromBlock: -100 as BlockNumber, toBlock: +100 })).logs;
|
|
1131
1142
|
blockNumbers = new Set(logs.map(log => log.id.blockNumber));
|
|
1132
1143
|
expect(blockNumbers.size).toBe(numBlocks);
|
|
1133
1144
|
|
|
1134
1145
|
// intersecting with "afterLog" works
|
|
1135
|
-
logs = (
|
|
1146
|
+
logs = (
|
|
1147
|
+
await store.getPublicLogs({
|
|
1148
|
+
fromBlock: BlockNumber(2),
|
|
1149
|
+
toBlock: BlockNumber(5),
|
|
1150
|
+
afterLog: new LogId(BlockNumber(4), 0, 0),
|
|
1151
|
+
})
|
|
1152
|
+
).logs;
|
|
1136
1153
|
blockNumbers = new Set(logs.map(log => log.id.blockNumber));
|
|
1137
1154
|
expect(blockNumbers).toEqual(new Set([4]));
|
|
1138
1155
|
|
|
1139
|
-
logs = (await store.getPublicLogs({ toBlock: 5, afterLog: new LogId(5, 1, 0) })).logs;
|
|
1156
|
+
logs = (await store.getPublicLogs({ toBlock: BlockNumber(5), afterLog: new LogId(BlockNumber(5), 1, 0) })).logs;
|
|
1140
1157
|
expect(logs.length).toBe(0);
|
|
1141
1158
|
|
|
1142
|
-
logs = (
|
|
1159
|
+
logs = (
|
|
1160
|
+
await store.getPublicLogs({
|
|
1161
|
+
fromBlock: BlockNumber(2),
|
|
1162
|
+
toBlock: BlockNumber(5),
|
|
1163
|
+
afterLog: new LogId(BlockNumber(100), 0, 0),
|
|
1164
|
+
})
|
|
1165
|
+
).logs;
|
|
1143
1166
|
expect(logs.length).toBe(0);
|
|
1144
1167
|
});
|
|
1145
1168
|
|
|
@@ -1149,7 +1172,7 @@ export function describeArchiverDataStore(
|
|
|
1149
1172
|
const targetTxIndex = randomInt(txsPerBlock);
|
|
1150
1173
|
const targetLogIndex = randomInt(numPublicLogs);
|
|
1151
1174
|
|
|
1152
|
-
const afterLog = new LogId(targetBlockIndex + INITIAL_L2_BLOCK_NUM, targetTxIndex, targetLogIndex);
|
|
1175
|
+
const afterLog = new LogId(BlockNumber(targetBlockIndex + INITIAL_L2_BLOCK_NUM), targetTxIndex, targetLogIndex);
|
|
1153
1176
|
|
|
1154
1177
|
const response = await store.getPublicLogs({ afterLog, fromBlock: afterLog.blockNumber });
|
|
1155
1178
|
const logs = response.logs;
|
|
@@ -1189,7 +1212,7 @@ export function describeArchiverDataStore(
|
|
|
1189
1212
|
valid: false,
|
|
1190
1213
|
block: randomBlockInfo(1),
|
|
1191
1214
|
committee: [EthAddress.random(), EthAddress.random()],
|
|
1192
|
-
epoch:
|
|
1215
|
+
epoch: EpochNumber(123),
|
|
1193
1216
|
seed: 456n,
|
|
1194
1217
|
attestors: [EthAddress.random()],
|
|
1195
1218
|
attestations: [CommitteeAttestation.random()],
|
|
@@ -1208,7 +1231,7 @@ export function describeArchiverDataStore(
|
|
|
1208
1231
|
block: randomBlockInfo(2),
|
|
1209
1232
|
committee: [EthAddress.random()],
|
|
1210
1233
|
attestors: [EthAddress.random()],
|
|
1211
|
-
epoch:
|
|
1234
|
+
epoch: EpochNumber(789),
|
|
1212
1235
|
seed: 101n,
|
|
1213
1236
|
attestations: [CommitteeAttestation.random()],
|
|
1214
1237
|
reason: 'invalid-attestation',
|
|
@@ -1227,7 +1250,7 @@ export function describeArchiverDataStore(
|
|
|
1227
1250
|
valid: false,
|
|
1228
1251
|
block: randomBlockInfo(3),
|
|
1229
1252
|
committee: [EthAddress.random()],
|
|
1230
|
-
epoch:
|
|
1253
|
+
epoch: EpochNumber(999),
|
|
1231
1254
|
seed: 888n,
|
|
1232
1255
|
attestors: [EthAddress.random()],
|
|
1233
1256
|
attestations: [CommitteeAttestation.random()],
|
|
@@ -1246,7 +1269,7 @@ export function describeArchiverDataStore(
|
|
|
1246
1269
|
valid: false,
|
|
1247
1270
|
block: randomBlockInfo(4),
|
|
1248
1271
|
committee: [],
|
|
1249
|
-
epoch:
|
|
1272
|
+
epoch: EpochNumber(0),
|
|
1250
1273
|
seed: 0n,
|
|
1251
1274
|
attestors: [],
|
|
1252
1275
|
attestations: [],
|