@aztec/archiver 0.7.10 → 0.8.7
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 +4 -1
- package/dest/archiver/archiver.d.ts.map +1 -1
- package/dest/archiver/archiver.js +38 -7
- package/dest/archiver/config.d.ts +10 -2
- package/dest/archiver/config.d.ts.map +1 -1
- package/dest/archiver/config.js +15 -7
- package/dest/archiver/data_retrieval.d.ts +8 -8
- package/dest/archiver/data_retrieval.d.ts.map +1 -1
- package/dest/archiver/data_retrieval.js +21 -21
- package/dest/archiver/eth_log_handlers.d.ts +8 -4
- package/dest/archiver/eth_log_handlers.d.ts.map +1 -1
- package/dest/archiver/eth_log_handlers.js +13 -5
- package/dest/index.js +3 -3
- package/package.json +60 -7
- package/src/archiver/archiver.ts +41 -7
- package/src/archiver/config.ts +27 -7
- package/src/archiver/data_retrieval.ts +30 -18
- package/src/archiver/eth_log_handlers.ts +12 -0
- package/src/index.ts +5 -4
- package/.eslintrc.cjs +0 -1
- package/.tsbuildinfo +0 -1
- package/dest/archiver/archiver.test.d.ts +0 -2
- package/dest/archiver/archiver.test.d.ts.map +0 -1
- package/dest/archiver/archiver.test.js +0 -184
- package/dest/archiver/archiver_store.test.d.ts +0 -2
- package/dest/archiver/archiver_store.test.d.ts.map +0 -1
- package/dest/archiver/archiver_store.test.js +0 -61
- package/dest/archiver/l1_to_l2_message_store.test.d.ts +0 -2
- package/dest/archiver/l1_to_l2_message_store.test.d.ts.map +0 -1
- package/dest/archiver/l1_to_l2_message_store.test.js +0 -77
- package/src/archiver/archiver.test.ts +0 -223
- package/src/archiver/archiver_store.test.ts +0 -74
- package/src/archiver/l1_to_l2_message_store.test.ts +0 -98
- package/tsconfig.json +0 -26
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { INITIAL_L2_BLOCK_NUM, L2Block, L2BlockL2Logs, LogType } from '@aztec/types';
|
|
2
|
-
|
|
3
|
-
import { ArchiverDataStore, MemoryArchiverStore } from './archiver_store.js';
|
|
4
|
-
|
|
5
|
-
describe('Archiver Memory Store', () => {
|
|
6
|
-
let archiverStore: ArchiverDataStore;
|
|
7
|
-
|
|
8
|
-
beforeEach(() => {
|
|
9
|
-
archiverStore = new MemoryArchiverStore();
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('can store and retrieve blocks', async () => {
|
|
13
|
-
const blocks = Array(10)
|
|
14
|
-
.fill(0)
|
|
15
|
-
.map((_, index) => L2Block.random(index));
|
|
16
|
-
await archiverStore.addL2Blocks(blocks);
|
|
17
|
-
// Offset indices by INTIAL_L2_BLOCK_NUM to ensure we are correctly aligned
|
|
18
|
-
for (const [from, limit] of [
|
|
19
|
-
[0 + INITIAL_L2_BLOCK_NUM, 10],
|
|
20
|
-
[3 + INITIAL_L2_BLOCK_NUM, 3],
|
|
21
|
-
[1 + INITIAL_L2_BLOCK_NUM, 7],
|
|
22
|
-
[5 + INITIAL_L2_BLOCK_NUM, 8],
|
|
23
|
-
[10 + INITIAL_L2_BLOCK_NUM, 1],
|
|
24
|
-
[11 + INITIAL_L2_BLOCK_NUM, 1],
|
|
25
|
-
]) {
|
|
26
|
-
const expected = blocks.slice(from - INITIAL_L2_BLOCK_NUM, from - INITIAL_L2_BLOCK_NUM + limit);
|
|
27
|
-
const actual = await archiverStore.getL2Blocks(from, limit);
|
|
28
|
-
expect(expected).toEqual(actual);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test.each([LogType.ENCRYPTED, LogType.UNENCRYPTED])('can store and retrieve logs', async (logType: LogType) => {
|
|
33
|
-
const logs = Array(10)
|
|
34
|
-
.fill(0)
|
|
35
|
-
.map(_ => L2BlockL2Logs.random(6, 3, 2));
|
|
36
|
-
await archiverStore.addLogs(logs, logType);
|
|
37
|
-
// Offset indices by INTIAL_L2_BLOCK_NUM to ensure we are correctly aligned
|
|
38
|
-
for (const [from, limit] of [
|
|
39
|
-
[0 + INITIAL_L2_BLOCK_NUM, 10],
|
|
40
|
-
[3 + INITIAL_L2_BLOCK_NUM, 3],
|
|
41
|
-
[1 + INITIAL_L2_BLOCK_NUM, 7],
|
|
42
|
-
[5 + INITIAL_L2_BLOCK_NUM, 8],
|
|
43
|
-
[10 + INITIAL_L2_BLOCK_NUM, 1],
|
|
44
|
-
[11 + INITIAL_L2_BLOCK_NUM, 1],
|
|
45
|
-
]) {
|
|
46
|
-
const expected = logs.slice(from - INITIAL_L2_BLOCK_NUM, from - INITIAL_L2_BLOCK_NUM + limit);
|
|
47
|
-
const actual = await archiverStore.getLogs(from, limit, logType);
|
|
48
|
-
expect(expected).toEqual(actual);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('throws if we try and request less than 1 block', async () => {
|
|
53
|
-
const blocks = Array(10)
|
|
54
|
-
.fill(0)
|
|
55
|
-
.map((_, index) => L2Block.random(index));
|
|
56
|
-
await archiverStore.addL2Blocks(blocks);
|
|
57
|
-
await expect(async () => await archiverStore.getL2Blocks(1, 0)).rejects.toThrow(
|
|
58
|
-
`Invalid block range from: 1, limit: 0`,
|
|
59
|
-
);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
test.each([LogType.ENCRYPTED, LogType.UNENCRYPTED])(
|
|
63
|
-
'throws if we try and request less than 1 log',
|
|
64
|
-
async (logType: LogType) => {
|
|
65
|
-
const logs = Array(10)
|
|
66
|
-
.fill(0)
|
|
67
|
-
.map(_ => L2BlockL2Logs.random(6, 3, 2));
|
|
68
|
-
await archiverStore.addLogs(logs, logType);
|
|
69
|
-
await expect(async () => await archiverStore.getLogs(1, 0, logType)).rejects.toThrow(
|
|
70
|
-
`Invalid block range from: 1, limit: 0`,
|
|
71
|
-
);
|
|
72
|
-
},
|
|
73
|
-
);
|
|
74
|
-
});
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
-
import { L1Actor, L1ToL2Message, L2Actor } from '@aztec/types';
|
|
3
|
-
|
|
4
|
-
import { L1ToL2MessageStore, PendingL1ToL2MessageStore } from './l1_to_l2_message_store.js';
|
|
5
|
-
|
|
6
|
-
describe('l1_to_l2_message_store', () => {
|
|
7
|
-
let store: L1ToL2MessageStore;
|
|
8
|
-
let entryKey: Fr;
|
|
9
|
-
let msg: L1ToL2Message;
|
|
10
|
-
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
// already adds a message to the store
|
|
13
|
-
store = new L1ToL2MessageStore();
|
|
14
|
-
entryKey = Fr.random();
|
|
15
|
-
msg = L1ToL2Message.random();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('addMessage adds a message', () => {
|
|
19
|
-
store.addMessage(entryKey, msg);
|
|
20
|
-
expect(store.getMessage(entryKey)).toEqual(msg);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('addMessage increments the count if the message is already in the store', () => {
|
|
24
|
-
store.addMessage(entryKey, msg);
|
|
25
|
-
store.addMessage(entryKey, msg);
|
|
26
|
-
expect(store.getMessageAndCount(entryKey)).toEqual({ message: msg, count: 2 });
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
describe('pending_l1_to_l2_message_store', () => {
|
|
31
|
-
let store: PendingL1ToL2MessageStore;
|
|
32
|
-
let entryKey: Fr;
|
|
33
|
-
let msg: L1ToL2Message;
|
|
34
|
-
|
|
35
|
-
beforeEach(() => {
|
|
36
|
-
// already adds a message to the store
|
|
37
|
-
store = new PendingL1ToL2MessageStore();
|
|
38
|
-
entryKey = Fr.random();
|
|
39
|
-
msg = L1ToL2Message.random();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('removeMessage removes the message if the count is 1', () => {
|
|
43
|
-
store.addMessage(entryKey, msg);
|
|
44
|
-
store.removeMessage(entryKey);
|
|
45
|
-
expect(store.getMessage(entryKey)).toBeUndefined();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it("handles case when removing a message that doesn't exist", () => {
|
|
49
|
-
expect(() => store.removeMessage(new Fr(0))).not.toThrow();
|
|
50
|
-
const one = new Fr(1);
|
|
51
|
-
expect(() => store.removeMessage(one)).toThrow(`Message with key ${one.value} not found in store`);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('removeMessage decrements the count if the message is already in the store', () => {
|
|
55
|
-
store.addMessage(entryKey, msg);
|
|
56
|
-
store.addMessage(entryKey, msg);
|
|
57
|
-
store.addMessage(entryKey, msg);
|
|
58
|
-
store.removeMessage(entryKey);
|
|
59
|
-
expect(store.getMessageAndCount(entryKey)).toEqual({ message: msg, count: 2 });
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('get messages for an empty store', () => {
|
|
63
|
-
expect(store.getMessageKeys(10)).toEqual([]);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it('getMessageKeys returns an empty array if limit is 0', () => {
|
|
67
|
-
store.addMessage(entryKey, msg);
|
|
68
|
-
expect(store.getMessageKeys(0)).toEqual([]);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it('get messages for a non-empty store when limit > number of messages in store', () => {
|
|
72
|
-
const entryKeys = [1, 2, 3, 4, 5].map(x => new Fr(x));
|
|
73
|
-
entryKeys.forEach(entryKey => {
|
|
74
|
-
store.addMessage(entryKey, L1ToL2Message.random());
|
|
75
|
-
});
|
|
76
|
-
expect(store.getMessageKeys(10).length).toEqual(5);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('get messages returns messages sorted by fees and also includes multiple of the same message', () => {
|
|
80
|
-
const entryKeys = [1, 2, 3, 3, 3, 4].map(x => new Fr(x));
|
|
81
|
-
entryKeys.forEach(entryKey => {
|
|
82
|
-
// set msg.fee to entryKey to test the sort.
|
|
83
|
-
const msg = new L1ToL2Message(
|
|
84
|
-
L1Actor.random(),
|
|
85
|
-
L2Actor.random(),
|
|
86
|
-
Fr.random(),
|
|
87
|
-
Fr.random(),
|
|
88
|
-
100,
|
|
89
|
-
Number(entryKey.value),
|
|
90
|
-
entryKey,
|
|
91
|
-
);
|
|
92
|
-
store.addMessage(entryKey, msg);
|
|
93
|
-
});
|
|
94
|
-
const expectedMessgeFees = [4n, 3n, 3n, 3n]; // the top 4.
|
|
95
|
-
const receivedMessageFees = store.getMessageKeys(4).map(key => key.value);
|
|
96
|
-
expect(receivedMessageFees).toEqual(expectedMessgeFees);
|
|
97
|
-
});
|
|
98
|
-
});
|
package/tsconfig.json
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "..",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "dest",
|
|
5
|
-
"rootDir": "src",
|
|
6
|
-
"tsBuildInfoFile": ".tsbuildinfo"
|
|
7
|
-
},
|
|
8
|
-
"references": [
|
|
9
|
-
{
|
|
10
|
-
"path": "../circuits.js"
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"path": "../ethereum"
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
"path": "../foundation"
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
"path": "../l1-artifacts"
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
"path": "../types"
|
|
23
|
-
}
|
|
24
|
-
],
|
|
25
|
-
"include": ["src"]
|
|
26
|
-
}
|