@aztec/archiver 0.65.2 → 0.66.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/archiver/archiver.d.ts +18 -22
- package/dest/archiver/archiver.d.ts.map +1 -1
- package/dest/archiver/archiver.js +143 -99
- package/dest/archiver/archiver_store.d.ts +7 -8
- 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 +126 -150
- package/dest/archiver/config.d.ts +6 -12
- package/dest/archiver/config.d.ts.map +1 -1
- package/dest/archiver/config.js +6 -1
- package/dest/archiver/data_retrieval.d.ts +2 -3
- package/dest/archiver/data_retrieval.d.ts.map +1 -1
- package/dest/archiver/data_retrieval.js +14 -15
- package/dest/archiver/instrumentation.d.ts +2 -7
- package/dest/archiver/instrumentation.d.ts.map +1 -1
- package/dest/archiver/instrumentation.js +3 -6
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +7 -8
- 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 -8
- package/dest/archiver/kv_archiver_store/log_store.d.ts +7 -8
- package/dest/archiver/kv_archiver_store/log_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/log_store.js +55 -95
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts +8 -10
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts.map +1 -1
- package/dest/archiver/memory_archiver_store/memory_archiver_store.js +50 -57
- package/dest/index.d.ts +2 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +3 -42
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +2 -2
- package/package.json +11 -13
- package/src/archiver/archiver.ts +199 -191
- package/src/archiver/archiver_store.ts +6 -13
- package/src/archiver/archiver_store_test_suite.ts +160 -186
- package/src/archiver/config.ts +12 -12
- package/src/archiver/data_retrieval.ts +12 -17
- package/src/archiver/instrumentation.ts +3 -5
- package/src/archiver/kv_archiver_store/kv_archiver_store.ts +7 -14
- package/src/archiver/kv_archiver_store/log_store.ts +68 -118
- package/src/archiver/memory_archiver_store/memory_archiver_store.ts +51 -65
- package/src/index.ts +5 -59
- package/src/test/mock_l2_block_source.ts +1 -2
- package/dest/archiver/epoch_helpers.d.ts +0 -20
- package/dest/archiver/epoch_helpers.d.ts.map +0 -1
- package/dest/archiver/epoch_helpers.js +0 -34
- package/src/archiver/epoch_helpers.ts +0 -54
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// REFACTOR: This file should go in a package lower in the dependency graph.
|
|
2
|
-
/** Returns the slot number for a given timestamp. */
|
|
3
|
-
export function getSlotAtTimestamp(ts, constants) {
|
|
4
|
-
return ts < constants.l1GenesisTime ? 0n : (ts - constants.l1GenesisTime) / BigInt(constants.slotDuration);
|
|
5
|
-
}
|
|
6
|
-
/** Returns the epoch number for a given timestamp. */
|
|
7
|
-
export function getEpochNumberAtTimestamp(ts, constants) {
|
|
8
|
-
return getSlotAtTimestamp(ts, constants) / BigInt(constants.epochDuration);
|
|
9
|
-
}
|
|
10
|
-
/** Returns the range of L2 slots (inclusive) for a given epoch number. */
|
|
11
|
-
export function getSlotRangeForEpoch(epochNumber, constants) {
|
|
12
|
-
const startSlot = epochNumber * BigInt(constants.epochDuration);
|
|
13
|
-
return [startSlot, startSlot + BigInt(constants.epochDuration) - 1n];
|
|
14
|
-
}
|
|
15
|
-
/** Returns the range of L1 timestamps (inclusive) for a given epoch number. */
|
|
16
|
-
export function getTimestampRangeForEpoch(epochNumber, constants) {
|
|
17
|
-
const [startSlot, endSlot] = getSlotRangeForEpoch(epochNumber, constants);
|
|
18
|
-
return [
|
|
19
|
-
constants.l1GenesisTime + startSlot * BigInt(constants.slotDuration),
|
|
20
|
-
constants.l1GenesisTime + endSlot * BigInt(constants.slotDuration),
|
|
21
|
-
];
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Returns the range of L1 blocks (inclusive) for a given epoch number.
|
|
25
|
-
* @remarks This assumes no time warp has happened.
|
|
26
|
-
*/
|
|
27
|
-
export function getL1BlockRangeForEpoch(epochNumber, constants) {
|
|
28
|
-
const epochDurationInL1Blocks = BigInt(constants.epochDuration) * BigInt(constants.slotDuration);
|
|
29
|
-
return [
|
|
30
|
-
epochNumber * epochDurationInL1Blocks + constants.l1GenesisBlock,
|
|
31
|
-
(epochNumber + 1n) * epochDurationInL1Blocks + constants.l1GenesisBlock - 1n,
|
|
32
|
-
];
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXBvY2hfaGVscGVycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9hcmNoaXZlci9lcG9jaF9oZWxwZXJzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDRFQUE0RTtBQVM1RSxxREFBcUQ7QUFDckQsTUFBTSxVQUFVLGtCQUFrQixDQUFDLEVBQVUsRUFBRSxTQUFpRTtJQUM5RyxPQUFPLEVBQUUsR0FBRyxTQUFTLENBQUMsYUFBYSxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUMsQ0FBQyxDQUFDLENBQUMsRUFBRSxHQUFHLFNBQVMsQ0FBQyxhQUFhLENBQUMsR0FBRyxNQUFNLENBQUMsU0FBUyxDQUFDLFlBQVksQ0FBQyxDQUFDO0FBQzdHLENBQUM7QUFFRCxzREFBc0Q7QUFDdEQsTUFBTSxVQUFVLHlCQUF5QixDQUN2QyxFQUFVLEVBQ1YsU0FBbUY7SUFFbkYsT0FBTyxrQkFBa0IsQ0FBQyxFQUFFLEVBQUUsU0FBUyxDQUFDLEdBQUcsTUFBTSxDQUFDLFNBQVMsQ0FBQyxhQUFhLENBQUMsQ0FBQztBQUM3RSxDQUFDO0FBRUQ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0FBYyxHQUFHLEVBQUU7S0FDN0UsQ0FBQztBQUNKLENBQUMifQ==
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
// REFACTOR: This file should go in a package lower in the dependency graph.
|
|
2
|
-
|
|
3
|
-
export type EpochConstants = {
|
|
4
|
-
l1GenesisBlock: bigint;
|
|
5
|
-
l1GenesisTime: bigint;
|
|
6
|
-
epochDuration: number;
|
|
7
|
-
slotDuration: number;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
/** Returns the slot number for a given timestamp. */
|
|
11
|
-
export function getSlotAtTimestamp(ts: bigint, constants: Pick<EpochConstants, 'l1GenesisTime' | 'slotDuration'>) {
|
|
12
|
-
return ts < constants.l1GenesisTime ? 0n : (ts - constants.l1GenesisTime) / BigInt(constants.slotDuration);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/** Returns the epoch number for a given timestamp. */
|
|
16
|
-
export function getEpochNumberAtTimestamp(
|
|
17
|
-
ts: bigint,
|
|
18
|
-
constants: Pick<EpochConstants, 'epochDuration' | 'slotDuration' | 'l1GenesisTime'>,
|
|
19
|
-
) {
|
|
20
|
-
return getSlotAtTimestamp(ts, constants) / BigInt(constants.epochDuration);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/** Returns the range of L2 slots (inclusive) for a given epoch number. */
|
|
24
|
-
export function getSlotRangeForEpoch(epochNumber: bigint, constants: Pick<EpochConstants, 'epochDuration'>) {
|
|
25
|
-
const startSlot = epochNumber * BigInt(constants.epochDuration);
|
|
26
|
-
return [startSlot, startSlot + BigInt(constants.epochDuration) - 1n];
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** Returns the range of L1 timestamps (inclusive) for a given epoch number. */
|
|
30
|
-
export function getTimestampRangeForEpoch(
|
|
31
|
-
epochNumber: bigint,
|
|
32
|
-
constants: Pick<EpochConstants, 'l1GenesisTime' | 'slotDuration' | 'epochDuration'>,
|
|
33
|
-
) {
|
|
34
|
-
const [startSlot, endSlot] = getSlotRangeForEpoch(epochNumber, constants);
|
|
35
|
-
return [
|
|
36
|
-
constants.l1GenesisTime + startSlot * BigInt(constants.slotDuration),
|
|
37
|
-
constants.l1GenesisTime + endSlot * BigInt(constants.slotDuration),
|
|
38
|
-
];
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Returns the range of L1 blocks (inclusive) for a given epoch number.
|
|
43
|
-
* @remarks This assumes no time warp has happened.
|
|
44
|
-
*/
|
|
45
|
-
export function getL1BlockRangeForEpoch(
|
|
46
|
-
epochNumber: bigint,
|
|
47
|
-
constants: Pick<EpochConstants, 'l1GenesisBlock' | 'epochDuration' | 'slotDuration'>,
|
|
48
|
-
) {
|
|
49
|
-
const epochDurationInL1Blocks = BigInt(constants.epochDuration) * BigInt(constants.slotDuration);
|
|
50
|
-
return [
|
|
51
|
-
epochNumber * epochDurationInL1Blocks + constants.l1GenesisBlock,
|
|
52
|
-
(epochNumber + 1n) * epochDurationInL1Blocks + constants.l1GenesisBlock - 1n,
|
|
53
|
-
];
|
|
54
|
-
}
|