@aztec/archiver 0.0.1-commit.f2ce05ee → 0.0.1-commit.f5a9928
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 +19 -13
- package/dest/archiver.d.ts +76 -18
- package/dest/archiver.d.ts.map +1 -1
- package/dest/archiver.js +329 -162
- package/dest/config.d.ts +7 -3
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +43 -14
- package/dest/errors.d.ts +55 -9
- package/dest/errors.d.ts.map +1 -1
- package/dest/errors.js +81 -14
- package/dest/factory.d.ts +20 -9
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +87 -39
- package/dest/index.d.ts +12 -3
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +11 -2
- package/dest/l1/bin/retrieve-calldata.js +32 -28
- package/dest/l1/calldata_retriever.d.ts +81 -50
- package/dest/l1/calldata_retriever.d.ts.map +1 -1
- package/dest/l1/calldata_retriever.js +202 -260
- package/dest/l1/data_retrieval.d.ts +32 -18
- package/dest/l1/data_retrieval.d.ts.map +1 -1
- package/dest/l1/data_retrieval.js +42 -47
- package/dest/l1/spire_proposer.d.ts +5 -5
- package/dest/l1/spire_proposer.d.ts.map +1 -1
- package/dest/l1/spire_proposer.js +9 -17
- package/dest/l1/trace_tx.d.ts +12 -66
- package/dest/l1/trace_tx.d.ts.map +1 -1
- package/dest/l1/validate_historical_logs.d.ts +23 -0
- package/dest/l1/validate_historical_logs.d.ts.map +1 -0
- package/dest/l1/validate_historical_logs.js +108 -0
- package/dest/modules/contract_data_source_adapter.d.ts +25 -0
- package/dest/modules/contract_data_source_adapter.d.ts.map +1 -0
- package/dest/modules/contract_data_source_adapter.js +32 -0
- package/dest/modules/data_source_base.d.ts +74 -46
- package/dest/modules/data_source_base.d.ts.map +1 -1
- package/dest/modules/data_source_base.js +252 -190
- package/dest/modules/data_store_updater.d.ts +49 -17
- package/dest/modules/data_store_updater.d.ts.map +1 -1
- package/dest/modules/data_store_updater.js +218 -122
- package/dest/modules/instrumentation.d.ts +29 -3
- package/dest/modules/instrumentation.d.ts.map +1 -1
- package/dest/modules/instrumentation.js +67 -11
- package/dest/modules/l1_synchronizer.d.ts +16 -14
- package/dest/modules/l1_synchronizer.d.ts.map +1 -1
- package/dest/modules/l1_synchronizer.js +488 -219
- package/dest/modules/outbox_trees_resolver.d.ts +64 -0
- package/dest/modules/outbox_trees_resolver.d.ts.map +1 -0
- package/dest/modules/outbox_trees_resolver.js +184 -0
- package/dest/modules/validation.d.ts +30 -7
- package/dest/modules/validation.d.ts.map +1 -1
- package/dest/modules/validation.js +35 -17
- package/dest/store/block_store.d.ts +186 -74
- package/dest/store/block_store.d.ts.map +1 -1
- package/dest/store/block_store.js +810 -285
- package/dest/store/contract_class_store.d.ts +17 -4
- package/dest/store/contract_class_store.d.ts.map +1 -1
- package/dest/store/contract_class_store.js +42 -68
- package/dest/store/contract_instance_store.d.ts +28 -1
- package/dest/store/contract_instance_store.d.ts.map +1 -1
- package/dest/store/contract_instance_store.js +58 -6
- package/dest/store/data_stores.d.ts +68 -0
- package/dest/store/data_stores.d.ts.map +1 -0
- package/dest/store/data_stores.js +54 -0
- package/dest/store/function_names_cache.d.ts +17 -0
- package/dest/store/function_names_cache.d.ts.map +1 -0
- package/dest/store/function_names_cache.js +30 -0
- package/dest/store/l2_tips_cache.d.ts +25 -0
- package/dest/store/l2_tips_cache.d.ts.map +1 -0
- package/dest/store/l2_tips_cache.js +26 -0
- package/dest/store/log_store.d.ts +42 -37
- package/dest/store/log_store.d.ts.map +1 -1
- package/dest/store/log_store.js +262 -408
- package/dest/store/log_store_codec.d.ts +78 -0
- package/dest/store/log_store_codec.d.ts.map +1 -0
- package/dest/store/log_store_codec.js +110 -0
- package/dest/store/message_store.d.ts +11 -1
- package/dest/store/message_store.d.ts.map +1 -1
- package/dest/store/message_store.js +51 -9
- package/dest/test/fake_l1_state.d.ts +25 -1
- package/dest/test/fake_l1_state.d.ts.map +1 -1
- package/dest/test/fake_l1_state.js +166 -32
- package/dest/test/mock_archiver.d.ts +1 -1
- package/dest/test/mock_archiver.d.ts.map +1 -1
- package/dest/test/mock_archiver.js +3 -2
- package/dest/test/mock_l2_block_source.d.ts +61 -47
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +306 -211
- package/dest/test/mock_structs.d.ts +4 -1
- package/dest/test/mock_structs.d.ts.map +1 -1
- package/dest/test/mock_structs.js +15 -3
- package/dest/test/noop_l1_archiver.d.ts +17 -6
- package/dest/test/noop_l1_archiver.d.ts.map +1 -1
- package/dest/test/noop_l1_archiver.js +31 -11
- package/package.json +15 -14
- package/src/archiver.ts +427 -185
- package/src/config.ts +51 -13
- package/src/errors.ts +122 -21
- package/src/factory.ts +104 -29
- package/src/index.ts +19 -2
- package/src/l1/README.md +25 -68
- package/src/l1/bin/retrieve-calldata.ts +40 -27
- package/src/l1/calldata_retriever.ts +267 -379
- package/src/l1/data_retrieval.ts +66 -70
- package/src/l1/spire_proposer.ts +7 -15
- package/src/l1/validate_historical_logs.ts +140 -0
- package/src/modules/contract_data_source_adapter.ts +46 -0
- package/src/modules/data_source_base.ts +337 -238
- package/src/modules/data_store_updater.ts +259 -154
- package/src/modules/instrumentation.ts +71 -11
- package/src/modules/l1_synchronizer.ts +659 -269
- package/src/modules/outbox_trees_resolver.ts +220 -0
- package/src/modules/validation.ts +80 -23
- package/src/store/block_store.ts +989 -358
- package/src/store/contract_class_store.ts +49 -103
- package/src/store/contract_instance_store.ts +74 -11
- package/src/store/data_stores.ts +104 -0
- package/src/store/function_names_cache.ts +37 -0
- package/src/store/l2_tips_cache.ts +35 -0
- package/src/store/log_store.ts +302 -559
- package/src/store/log_store_codec.ts +143 -0
- package/src/store/message_store.ts +60 -10
- package/src/structs/inbox_message.ts +1 -1
- package/src/test/fake_l1_state.ts +213 -42
- package/src/test/mock_archiver.ts +3 -2
- package/src/test/mock_l2_block_source.ts +378 -233
- package/src/test/mock_structs.ts +25 -8
- package/src/test/noop_l1_archiver.ts +61 -12
- package/dest/store/kv_archiver_store.d.ts +0 -340
- package/dest/store/kv_archiver_store.d.ts.map +0 -1
- package/dest/store/kv_archiver_store.js +0 -446
- package/src/store/kv_archiver_store.ts +0 -639
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data_store_updater.d.ts","sourceRoot":"","sources":["../../src/modules/data_store_updater.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"data_store_updater.d.ts","sourceRoot":"","sources":["../../src/modules/data_store_updater.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAQhF,OAAO,KAAK,EAAE,oBAAoB,EAAE,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AACnG,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EAEzB,MAAM,0BAA0B,CAAC;AAUlC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAQ7D,6EAA6E;AAC7E,KAAK,0BAA0B,GAAG;IAChC,mEAAmE;IACnE,YAAY,EAAE,OAAO,EAAE,GAAG,SAAS,CAAC;IACpC,iFAAiF;IACjF,8BAA8B,EAAE,WAAW,GAAG,SAAS,CAAC;CACzD,CAAC;AAEF,kEAAkE;AAClE,qBAAa,wBAAwB;IAIjC,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,WAAW,CAAC;IACpB,OAAO,CAAC,IAAI;IALd,OAAO,CAAC,QAAQ,CAAC,GAAG,CAA0C;IAE9D,YACU,MAAM,EAAE,kBAAkB,EAC1B,WAAW,CAAC,yBAAa,EACzB,IAAI,GAAE;QAAE,eAAe,CAAC,EAAE,MAA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@@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import {
|
|
2
|
+
import { filterAsync } from '@aztec/foundation/collection';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import { ContractClassPublishedEvent
|
|
4
|
+
import { ContractClassPublishedEvent } from '@aztec/protocol-contracts/class-registry';
|
|
5
5
|
import { ContractInstancePublishedEvent, ContractInstanceUpdatedEvent } from '@aztec/protocol-contracts/instance-registry';
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
6
|
+
import { validateCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
7
|
+
import { computeContractAddressFromInstance, computeContractClassId } from '@aztec/stdlib/contract';
|
|
8
|
+
import { MAX_CAPACITY_BLOCKS_PER_CHECKPOINT } from '@aztec/stdlib/deserialization';
|
|
8
9
|
/** Operation type for contract data updates. */ var Operation = /*#__PURE__*/ function(Operation) {
|
|
9
10
|
Operation[Operation["Store"] = 0] = "Store";
|
|
10
11
|
Operation[Operation["Delete"] = 1] = "Delete";
|
|
11
12
|
return Operation;
|
|
12
13
|
}(Operation || {});
|
|
13
14
|
/** Archiver helper module to handle updates to the data store. */ export class ArchiverDataStoreUpdater {
|
|
14
|
-
|
|
15
|
+
stores;
|
|
16
|
+
l2TipsCache;
|
|
17
|
+
opts;
|
|
15
18
|
log;
|
|
16
|
-
constructor(
|
|
17
|
-
this.
|
|
19
|
+
constructor(stores, l2TipsCache, opts = {}){
|
|
20
|
+
this.stores = stores;
|
|
21
|
+
this.l2TipsCache = l2TipsCache;
|
|
22
|
+
this.opts = opts;
|
|
18
23
|
this.log = createLogger('archiver:store_updater');
|
|
19
24
|
}
|
|
20
25
|
/**
|
|
21
|
-
* Adds proposed
|
|
22
|
-
*
|
|
23
|
-
* Extracts ContractClassPublished, ContractInstancePublished, ContractInstanceUpdated events
|
|
24
|
-
* and individually broadcasted functions from the block logs.
|
|
26
|
+
* Adds a proposed block to the store with contract class/instance extraction from logs.
|
|
27
|
+
* This is an uncheckpointed block that has been proposed by the sequencer but not yet included in a checkpoint on L1.
|
|
28
|
+
* Extracts ContractClassPublished, ContractInstancePublished, ContractInstanceUpdated events from the block logs.
|
|
25
29
|
*
|
|
26
|
-
* @param
|
|
30
|
+
* @param block - The proposed L2 block to add.
|
|
27
31
|
* @param pendingChainValidationStatus - Optional validation status to set.
|
|
28
32
|
* @returns True if the operation is successful.
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
await this.
|
|
33
|
+
*/ async addProposedBlock(block, pendingChainValidationStatus) {
|
|
34
|
+
const result = await this.stores.db.transactionAsync(async ()=>{
|
|
35
|
+
await this.stores.blocks.addProposedBlock(block);
|
|
32
36
|
const opResults = await Promise.all([
|
|
33
37
|
// Update the pending chain validation status if provided
|
|
34
|
-
pendingChainValidationStatus && this.
|
|
35
|
-
// Add any logs emitted during the retrieved
|
|
36
|
-
this.
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
pendingChainValidationStatus && this.stores.blocks.setPendingChainValidationStatus(pendingChainValidationStatus),
|
|
39
|
+
// Add any logs emitted during the retrieved block
|
|
40
|
+
this.stores.logs.addLogs([
|
|
41
|
+
block
|
|
42
|
+
]),
|
|
43
|
+
// Unroll all logs emitted during the retrieved block and extract any contract classes and instances from it
|
|
44
|
+
this.addContractDataToDb(block)
|
|
39
45
|
]);
|
|
40
46
|
return opResults.every(Boolean);
|
|
41
47
|
});
|
|
48
|
+
await this.l2TipsCache?.refresh();
|
|
49
|
+
return result;
|
|
42
50
|
}
|
|
43
51
|
/**
|
|
44
52
|
* Reconciles local blocks with incoming checkpoints from L1.
|
|
45
53
|
* Adds new checkpoints to the store with contract class/instance extraction from logs.
|
|
46
54
|
* Prunes any local blocks that conflict with checkpoint data (by comparing archive roots).
|
|
47
|
-
* Extracts ContractClassPublished, ContractInstancePublished, ContractInstanceUpdated events
|
|
48
|
-
*
|
|
55
|
+
* Extracts ContractClassPublished, ContractInstancePublished, ContractInstanceUpdated events from the checkpoint block logs.
|
|
56
|
+
* If `promoteProposed` is supplied, the proposed-checkpoint promotion runs inside the same transaction
|
|
57
|
+
* as the added checkpoints so both updates are applied atomically.
|
|
49
58
|
*
|
|
50
|
-
* @param checkpoints - The published checkpoints to add.
|
|
59
|
+
* @param checkpoints - The published checkpoints to add (excluding any being promoted from proposed).
|
|
51
60
|
* @param pendingChainValidationStatus - Optional validation status to set.
|
|
61
|
+
* @param promoteProposed - Optional promotion of the current proposed checkpoint (fast path when blocks are already local).
|
|
52
62
|
* @returns Result with information about any pruned blocks.
|
|
53
|
-
*/ addCheckpoints(checkpoints, pendingChainValidationStatus) {
|
|
54
|
-
|
|
63
|
+
*/ async addCheckpoints(checkpoints, pendingChainValidationStatus, promoteProposed, evictProposedFrom) {
|
|
64
|
+
// These checkpoints are already on L1, so ingest validates against the physical blob capacity rather than
|
|
65
|
+
// the conservative build/attest policy, and tolerates an empty non-first block. Both rules are enforced by
|
|
66
|
+
// proposers and attesters; rejecting an ingest would stall sync rather than undo the checkpoint.
|
|
67
|
+
const validateOpts = {
|
|
68
|
+
rollupManaLimit: this.opts?.rollupManaLimit,
|
|
69
|
+
maxBlocksPerCheckpoint: MAX_CAPACITY_BLOCKS_PER_CHECKPOINT,
|
|
70
|
+
allowEmptyNonFirstBlocks: true
|
|
71
|
+
};
|
|
72
|
+
for (const checkpoint of checkpoints){
|
|
73
|
+
validateCheckpoint(checkpoint.checkpoint, validateOpts);
|
|
74
|
+
}
|
|
75
|
+
if (promoteProposed) {
|
|
76
|
+
validateCheckpoint(promoteProposed.checkpoint.checkpoint, validateOpts);
|
|
77
|
+
}
|
|
78
|
+
const result = await this.stores.db.transactionAsync(async ()=>{
|
|
55
79
|
// Before adding checkpoints, check for conflicts with local blocks if any
|
|
56
80
|
const { prunedBlocks, lastAlreadyInsertedBlockNumber } = await this.pruneMismatchingLocalBlocks(checkpoints);
|
|
57
|
-
await this.
|
|
58
|
-
//
|
|
59
|
-
|
|
81
|
+
const insertedCheckpoints = await this.stores.blocks.addCheckpoints(checkpoints);
|
|
82
|
+
// Skip blocks already inserted via addProposedBlock() and blocks of already-stored checkpoints
|
|
83
|
+
// re-included by an L1 reorg: their logs/contract data were extracted when first inserted.
|
|
84
|
+
const newBlocks = insertedCheckpoints.flatMap((ch)=>ch.checkpoint.blocks).filter((b)=>lastAlreadyInsertedBlockNumber === undefined || b.number > lastAlreadyInsertedBlockNumber);
|
|
60
85
|
await Promise.all([
|
|
61
86
|
// Update the pending chain validation status if provided
|
|
62
|
-
pendingChainValidationStatus && this.
|
|
87
|
+
pendingChainValidationStatus && this.stores.blocks.setPendingChainValidationStatus(pendingChainValidationStatus),
|
|
63
88
|
// Add any logs emitted during the retrieved blocks
|
|
64
|
-
this.
|
|
89
|
+
this.stores.logs.addLogs(newBlocks),
|
|
65
90
|
// Unroll all logs emitted during the retrieved blocks and extract any contract classes and instances from them
|
|
66
|
-
...newBlocks.map((block)=>this.addContractDataToDb(block))
|
|
91
|
+
...newBlocks.map((block)=>this.addContractDataToDb(block)),
|
|
92
|
+
// Promote the proposed checkpoint if requested (uses explicit checkpoint number)
|
|
93
|
+
promoteProposed ? this.stores.blocks.promoteProposedToCheckpointed(promoteProposed.checkpoint.checkpoint.number, promoteProposed.l1, promoteProposed.attestations, promoteProposed.checkpoint.checkpoint.archive.root) : undefined,
|
|
94
|
+
// Evict pending checkpoints that diverged from what L1 mined
|
|
95
|
+
evictProposedFrom !== undefined ? this.stores.blocks.evictProposedCheckpointsFrom(evictProposedFrom) : undefined
|
|
67
96
|
]);
|
|
68
97
|
return {
|
|
69
98
|
prunedBlocks,
|
|
70
99
|
lastAlreadyInsertedBlockNumber
|
|
71
100
|
};
|
|
72
101
|
});
|
|
102
|
+
await this.l2TipsCache?.refresh();
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
async addProposedCheckpoint(proposedCheckpoint) {
|
|
106
|
+
const result = await this.stores.db.transactionAsync(async ()=>{
|
|
107
|
+
await this.stores.blocks.addProposedCheckpoint(proposedCheckpoint);
|
|
108
|
+
});
|
|
109
|
+
await this.l2TipsCache?.refresh();
|
|
110
|
+
return result;
|
|
73
111
|
}
|
|
74
112
|
/**
|
|
75
113
|
* Checks for local proposed blocks that do not match the ones to be checkpointed and prunes them.
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
114
|
+
* Conflict detection is keyed on `blockNumber`: when a local proposed block and an L1
|
|
115
|
+
* checkpointed block share a block number but live at different slots (e.g. a different proposer
|
|
116
|
+
* mined the same block number one slot earlier), we still treat them as a conflict and prune.
|
|
117
|
+
* The trailing per-checkpoint prune that handles "local has extra trailing blocks within the
|
|
118
|
+
* same slot as the published checkpoint" remains scoped by slot to preserve pipelining: local
|
|
119
|
+
* blocks that live at a later slot than the checkpoint being processed represent speculation
|
|
120
|
+
* atop the just-confirmed tip (and may be referenced by a pending proposed checkpoint), so we
|
|
121
|
+
* leave them in place. This method handles multiple checkpoints but returns after pruning the
|
|
122
|
+
* first conflict found. This is correct because pruning from the first conflict point removes
|
|
123
|
+
* all subsequent blocks, and when checkpoints are added afterward, they include all the correct
|
|
124
|
+
* blocks.
|
|
79
125
|
*/ async pruneMismatchingLocalBlocks(checkpoints) {
|
|
80
126
|
const [lastCheckpointedBlockNumber, lastBlockNumber] = await Promise.all([
|
|
81
|
-
this.
|
|
82
|
-
this.
|
|
127
|
+
this.stores.blocks.getCheckpointedL2BlockNumber(),
|
|
128
|
+
this.stores.blocks.getLatestL2BlockNumber()
|
|
83
129
|
]);
|
|
84
130
|
// Exit early if there are no local uncheckpointed blocks
|
|
85
131
|
if (lastBlockNumber === lastCheckpointedBlockNumber) {
|
|
@@ -89,22 +135,25 @@ import groupBy from 'lodash.groupby';
|
|
|
89
135
|
};
|
|
90
136
|
}
|
|
91
137
|
// Get all uncheckpointed local blocks
|
|
92
|
-
const uncheckpointedLocalBlocks = await this.
|
|
138
|
+
const uncheckpointedLocalBlocks = await this.stores.blocks.getBlocksData({
|
|
139
|
+
from: BlockNumber.add(lastCheckpointedBlockNumber, 1),
|
|
140
|
+
limit: lastBlockNumber - lastCheckpointedBlockNumber
|
|
141
|
+
});
|
|
93
142
|
let lastAlreadyInsertedBlockNumber;
|
|
94
143
|
for (const publishedCheckpoint of checkpoints){
|
|
95
144
|
const checkpointBlocks = publishedCheckpoint.checkpoint.blocks;
|
|
96
145
|
const slot = publishedCheckpoint.checkpoint.slot;
|
|
97
|
-
const localBlocksInSlot = uncheckpointedLocalBlocks.filter((b)=>b.slot === slot);
|
|
98
146
|
if (checkpointBlocks.length === 0) {
|
|
99
147
|
this.log.warn(`Checkpoint ${publishedCheckpoint.checkpoint.number} for slot ${slot} has no blocks`);
|
|
100
148
|
continue;
|
|
101
149
|
}
|
|
102
|
-
// Find the first checkpoint block that conflicts with an existing local block and prune local afterwards
|
|
150
|
+
// Find the first checkpoint block that conflicts with an existing local block and prune local afterwards.
|
|
151
|
+
// Conflict detection joins on block number only — same block number at a different slot is still a conflict.
|
|
103
152
|
for (const checkpointBlock of checkpointBlocks){
|
|
104
153
|
const blockNumber = checkpointBlock.number;
|
|
105
|
-
const existingBlock =
|
|
154
|
+
const existingBlock = uncheckpointedLocalBlocks.find((b)=>b.header.getBlockNumber() === blockNumber);
|
|
106
155
|
const blockInfos = {
|
|
107
|
-
existingBlock: existingBlock?.
|
|
156
|
+
existingBlock: existingBlock?.header.toInspect(),
|
|
108
157
|
checkpointBlock: checkpointBlock.toBlockInfo()
|
|
109
158
|
};
|
|
110
159
|
if (!existingBlock) {
|
|
@@ -113,21 +162,25 @@ import groupBy from 'lodash.groupby';
|
|
|
113
162
|
this.log.verbose(`Block number ${blockNumber} already inserted and matches checkpoint`, blockInfos);
|
|
114
163
|
lastAlreadyInsertedBlockNumber = blockNumber;
|
|
115
164
|
} else {
|
|
116
|
-
this.log.
|
|
165
|
+
this.log.info(`Conflict detected at block ${blockNumber} between checkpointed and local block`, blockInfos);
|
|
117
166
|
const prunedBlocks = await this.removeBlocksAfter(BlockNumber(blockNumber - 1));
|
|
167
|
+
await this.evictProposedCheckpointsForPrunedBlocks(prunedBlocks);
|
|
118
168
|
return {
|
|
119
169
|
prunedBlocks,
|
|
120
170
|
lastAlreadyInsertedBlockNumber
|
|
121
171
|
};
|
|
122
172
|
}
|
|
123
173
|
}
|
|
124
|
-
// If
|
|
125
|
-
//
|
|
174
|
+
// If the sequencer locally proposed extra blocks within this checkpoint's slot (e.g. local has
|
|
175
|
+
// [N, N+1] but L1 confirmed just [N]), prune the extras. Scoped to the checkpoint's slot so we
|
|
176
|
+
// do not throw away speculative blocks at later slots that belong to a pending proposed checkpoint.
|
|
126
177
|
const lastCheckpointBlockNumber = checkpointBlocks.at(-1).number;
|
|
127
|
-
const
|
|
178
|
+
const localBlocksInSlot = uncheckpointedLocalBlocks.filter((b)=>b.header.getSlot() === slot);
|
|
179
|
+
const lastLocalBlockNumber = localBlocksInSlot.at(-1)?.header.getBlockNumber();
|
|
128
180
|
if (lastLocalBlockNumber !== undefined && lastLocalBlockNumber > lastCheckpointBlockNumber) {
|
|
129
181
|
this.log.warn(`Local chain for slot ${slot} ends at block ${lastLocalBlockNumber} but checkpoint ends at ${lastCheckpointBlockNumber}. Pruning blocks after block ${lastCheckpointBlockNumber}.`);
|
|
130
182
|
const prunedBlocks = await this.removeBlocksAfter(lastCheckpointBlockNumber);
|
|
183
|
+
await this.evictProposedCheckpointsForPrunedBlocks(prunedBlocks);
|
|
131
184
|
return {
|
|
132
185
|
prunedBlocks,
|
|
133
186
|
lastAlreadyInsertedBlockNumber
|
|
@@ -147,25 +200,61 @@ import groupBy from 'lodash.groupby';
|
|
|
147
200
|
* @param blockNumber - Remove all blocks with number greater than this.
|
|
148
201
|
* @returns The removed blocks.
|
|
149
202
|
* @throws Error if any block to be removed is checkpointed.
|
|
150
|
-
*/ removeUncheckpointedBlocksAfter(blockNumber) {
|
|
151
|
-
|
|
203
|
+
*/ async removeUncheckpointedBlocksAfter(blockNumber) {
|
|
204
|
+
const result = await this.stores.db.transactionAsync(async ()=>{
|
|
152
205
|
// Verify we're only removing uncheckpointed blocks
|
|
153
|
-
const lastCheckpointedBlockNumber = await this.
|
|
206
|
+
const lastCheckpointedBlockNumber = await this.stores.blocks.getCheckpointedL2BlockNumber();
|
|
154
207
|
if (blockNumber < lastCheckpointedBlockNumber) {
|
|
155
208
|
throw new Error(`Cannot remove blocks after ${blockNumber} because checkpointed blocks exist up to ${lastCheckpointedBlockNumber}`);
|
|
156
209
|
}
|
|
210
|
+
const prunedBlocks = await this.removeBlocksAfter(blockNumber);
|
|
211
|
+
await this.evictProposedCheckpointsForPrunedBlocks(prunedBlocks);
|
|
212
|
+
return prunedBlocks;
|
|
213
|
+
});
|
|
214
|
+
await this.l2TipsCache?.refresh();
|
|
215
|
+
return result;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Removes all blocks without a proposed checkpoint strictly after the specified block number and cleans up associated contract data.
|
|
219
|
+
* This handles removal of provisionally added blocks along with their contract classes/instances.
|
|
220
|
+
* Verifies that each block being removed is not part of a stored checkpoint (proposed or not).
|
|
221
|
+
* This differs from `removeUncheckpointedBlocksAfter` in that it also checks proposed checkpoints.
|
|
222
|
+
*
|
|
223
|
+
* @param blockNumber - Remove all blocks with number greater than this.
|
|
224
|
+
* @returns The removed blocks.
|
|
225
|
+
* @throws Error if any block to be removed is checkpointed.
|
|
226
|
+
*/ async removeBlocksWithoutProposedCheckpointAfter(blockNumber) {
|
|
227
|
+
const result = await this.stores.db.transactionAsync(async ()=>{
|
|
228
|
+
// Verify we're only removing uncheckpointed blocks
|
|
229
|
+
const lastCheckpointedBlockNumber = await this.stores.blocks.getProposedCheckpointL2BlockNumber();
|
|
230
|
+
if (blockNumber < lastCheckpointedBlockNumber) {
|
|
231
|
+
throw new Error(`Cannot remove blocks after ${blockNumber} because proposed checkpointed blocks exist up to ${lastCheckpointedBlockNumber}`);
|
|
232
|
+
}
|
|
157
233
|
return await this.removeBlocksAfter(blockNumber);
|
|
158
234
|
});
|
|
235
|
+
await this.l2TipsCache?.refresh();
|
|
236
|
+
return result;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Evicts pending proposed checkpoints that referenced any of the just-pruned blocks. Pruned
|
|
240
|
+
* blocks invalidate all proposed checkpoints from the lowest pruned block's checkpoint number
|
|
241
|
+
* onwards: those checkpoints either reference the pruned blocks directly or chain off them.
|
|
242
|
+
*/ async evictProposedCheckpointsForPrunedBlocks(prunedBlocks) {
|
|
243
|
+
if (prunedBlocks.length === 0) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
const fromCheckpointNumber = prunedBlocks[0].checkpointNumber;
|
|
247
|
+
await this.stores.blocks.evictProposedCheckpointsFrom(fromCheckpointNumber);
|
|
159
248
|
}
|
|
160
249
|
/**
|
|
161
250
|
* Removes all blocks strictly after the given block number along with any logs and contract data.
|
|
162
251
|
* Does not remove their checkpoints.
|
|
163
252
|
*/ async removeBlocksAfter(blockNumber) {
|
|
164
253
|
// First get the blocks to be removed so we can clean up contract data
|
|
165
|
-
const removedBlocks = await this.
|
|
254
|
+
const removedBlocks = await this.stores.blocks.removeBlocksAfter(blockNumber);
|
|
166
255
|
// Clean up contract data and logs for the removed blocks
|
|
167
256
|
await Promise.all([
|
|
168
|
-
this.
|
|
257
|
+
this.stores.logs.deleteLogs(removedBlocks),
|
|
169
258
|
...removedBlocks.map((block)=>this.removeContractDataFromDb(block))
|
|
170
259
|
]);
|
|
171
260
|
return removedBlocks;
|
|
@@ -179,17 +268,39 @@ import groupBy from 'lodash.groupby';
|
|
|
179
268
|
* @param checkpointNumber - Remove all checkpoints strictly after this one.
|
|
180
269
|
* @returns True if the operation is successful.
|
|
181
270
|
*/ async removeCheckpointsAfter(checkpointNumber) {
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
271
|
+
const result = await this.stores.db.transactionAsync(async ()=>{
|
|
272
|
+
const { blocksRemoved = [] } = await this.stores.blocks.removeCheckpointsAfter(checkpointNumber);
|
|
273
|
+
const opResults = await Promise.all([
|
|
274
|
+
// Prune rolls back to the last proven block, which is by definition valid
|
|
275
|
+
this.stores.blocks.setPendingChainValidationStatus({
|
|
276
|
+
valid: true
|
|
277
|
+
}),
|
|
278
|
+
// Remove contract data for all blocks being removed
|
|
279
|
+
...blocksRemoved.map((block)=>this.removeContractDataFromDb(block)),
|
|
280
|
+
this.stores.logs.deleteLogs(blocksRemoved)
|
|
281
|
+
]);
|
|
282
|
+
return opResults.every(Boolean);
|
|
283
|
+
});
|
|
284
|
+
await this.l2TipsCache?.refresh();
|
|
285
|
+
return result;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Updates the proven checkpoint number and refreshes the L2 tips cache.
|
|
289
|
+
* @param checkpointNumber - The checkpoint number to set as proven.
|
|
290
|
+
*/ async setProvenCheckpointNumber(checkpointNumber) {
|
|
291
|
+
await this.stores.db.transactionAsync(async ()=>{
|
|
292
|
+
await this.stores.blocks.setProvenCheckpointNumber(checkpointNumber);
|
|
293
|
+
});
|
|
294
|
+
await this.l2TipsCache?.refresh();
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Updates the finalized checkpoint number and refreshes the L2 tips cache.
|
|
298
|
+
* @param checkpointNumber - The checkpoint number to set as finalized.
|
|
299
|
+
*/ async setFinalizedCheckpointNumber(checkpointNumber) {
|
|
300
|
+
await this.stores.db.transactionAsync(async ()=>{
|
|
301
|
+
await this.stores.blocks.setFinalizedCheckpointNumber(checkpointNumber);
|
|
302
|
+
});
|
|
303
|
+
await this.l2TipsCache?.refresh();
|
|
193
304
|
}
|
|
194
305
|
/** Extracts and stores contract data from a single block. */ addContractDataToDb(block) {
|
|
195
306
|
return this.updateContractDataOnDb(block, 0);
|
|
@@ -204,37 +315,68 @@ import groupBy from 'lodash.groupby';
|
|
|
204
315
|
return (await Promise.all([
|
|
205
316
|
this.updatePublishedContractClasses(contractClassLogs, block.number, operation),
|
|
206
317
|
this.updateDeployedContractInstances(privateLogs, block.number, operation),
|
|
207
|
-
this.updateUpdatedContractInstances(publicLogs, block.header.globalVariables.timestamp, operation)
|
|
208
|
-
operation === 0 ? this.storeBroadcastedIndividualFunctions(contractClassLogs, block.number) : Promise.resolve(true)
|
|
318
|
+
this.updateUpdatedContractInstances(publicLogs, block.header.globalVariables.timestamp, operation)
|
|
209
319
|
])).every(Boolean);
|
|
210
320
|
}
|
|
211
321
|
/**
|
|
212
322
|
* Extracts and stores contract classes out of ContractClassPublished events emitted by the class registry contract.
|
|
213
323
|
*/ async updatePublishedContractClasses(allLogs, blockNum, operation) {
|
|
214
324
|
const contractClassPublishedEvents = allLogs.filter((log)=>ContractClassPublishedEvent.isContractClassPublishedEvent(log)).map((log)=>ContractClassPublishedEvent.fromLog(log));
|
|
215
|
-
|
|
325
|
+
if (operation == 1) {
|
|
326
|
+
const contractClasses = contractClassPublishedEvents.map((e)=>e.toContractClassPublic());
|
|
327
|
+
if (contractClasses.length > 0) {
|
|
328
|
+
contractClasses.forEach((c)=>this.log.verbose(`${Operation[operation]} contract class ${c.id.toString()}`));
|
|
329
|
+
return await this.stores.contractClasses.deleteContractClasses(contractClasses, blockNum);
|
|
330
|
+
}
|
|
331
|
+
return true;
|
|
332
|
+
}
|
|
333
|
+
// Compute bytecode commitments and validate class IDs in a single pass.
|
|
334
|
+
const contractClasses = [];
|
|
335
|
+
for (const event of contractClassPublishedEvents){
|
|
336
|
+
const contractClass = await event.toContractClassPublicWithBytecodeCommitment();
|
|
337
|
+
const computedClassId = await computeContractClassId({
|
|
338
|
+
artifactHash: contractClass.artifactHash,
|
|
339
|
+
privateFunctionsRoot: contractClass.privateFunctionsRoot,
|
|
340
|
+
publicBytecodeCommitment: contractClass.publicBytecodeCommitment
|
|
341
|
+
});
|
|
342
|
+
if (!computedClassId.equals(contractClass.id)) {
|
|
343
|
+
this.log.warn(`Skipping contract class with mismatched id at block ${blockNum}. Claimed ${contractClass.id}, computed ${computedClassId}`, {
|
|
344
|
+
blockNum,
|
|
345
|
+
contractClassId: event.contractClassId.toString()
|
|
346
|
+
});
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
contractClasses.push(contractClass);
|
|
350
|
+
}
|
|
216
351
|
if (contractClasses.length > 0) {
|
|
217
352
|
contractClasses.forEach((c)=>this.log.verbose(`${Operation[operation]} contract class ${c.id.toString()}`));
|
|
218
|
-
|
|
219
|
-
// TODO: Will probably want to create some worker threads to compute these bytecode commitments as they are expensive
|
|
220
|
-
const commitments = await Promise.all(contractClasses.map((c)=>computePublicBytecodeCommitment(c.packedBytecode)));
|
|
221
|
-
return await this.store.addContractClasses(contractClasses, commitments, blockNum);
|
|
222
|
-
} else if (operation == 1) {
|
|
223
|
-
return await this.store.deleteContractClasses(contractClasses, blockNum);
|
|
224
|
-
}
|
|
353
|
+
return await this.stores.contractClasses.addContractClasses(contractClasses, blockNum);
|
|
225
354
|
}
|
|
226
355
|
return true;
|
|
227
356
|
}
|
|
228
357
|
/**
|
|
229
358
|
* Extracts and stores contract instances out of ContractInstancePublished events emitted by the canonical deployer contract.
|
|
230
359
|
*/ async updateDeployedContractInstances(allLogs, blockNum, operation) {
|
|
231
|
-
const
|
|
360
|
+
const allInstances = allLogs.filter((log)=>ContractInstancePublishedEvent.isContractInstancePublishedEvent(log)).map((log)=>ContractInstancePublishedEvent.fromLog(log)).map((e)=>e.toContractInstance());
|
|
361
|
+
// Verify that each instance's address matches the one derived from its fields if we're adding
|
|
362
|
+
const contractInstances = operation === 1 ? allInstances : await filterAsync(allInstances, async (instance)=>{
|
|
363
|
+
const computedAddress = await computeContractAddressFromInstance(instance);
|
|
364
|
+
if (!computedAddress.equals(instance.address)) {
|
|
365
|
+
this.log.warn(`Found contract instance with mismatched address at block ${blockNum}. Claimed ${instance.address} but computed ${computedAddress}.`, {
|
|
366
|
+
instanceAddress: instance.address.toString(),
|
|
367
|
+
computedAddress: computedAddress.toString(),
|
|
368
|
+
blockNum
|
|
369
|
+
});
|
|
370
|
+
return false;
|
|
371
|
+
}
|
|
372
|
+
return true;
|
|
373
|
+
});
|
|
232
374
|
if (contractInstances.length > 0) {
|
|
233
375
|
contractInstances.forEach((c)=>this.log.verbose(`${Operation[operation]} contract instance at ${c.address.toString()}`));
|
|
234
376
|
if (operation == 0) {
|
|
235
|
-
return await this.
|
|
377
|
+
return await this.stores.contractInstances.addContractInstances(contractInstances, blockNum);
|
|
236
378
|
} else if (operation == 1) {
|
|
237
|
-
return await this.
|
|
379
|
+
return await this.stores.contractInstances.deleteContractInstances(contractInstances);
|
|
238
380
|
}
|
|
239
381
|
}
|
|
240
382
|
return true;
|
|
@@ -246,56 +388,10 @@ import groupBy from 'lodash.groupby';
|
|
|
246
388
|
if (contractUpdates.length > 0) {
|
|
247
389
|
contractUpdates.forEach((c)=>this.log.verbose(`${Operation[operation]} contract instance update at ${c.address.toString()}`));
|
|
248
390
|
if (operation == 0) {
|
|
249
|
-
return await this.
|
|
391
|
+
return await this.stores.contractInstances.addContractInstanceUpdates(contractUpdates, timestamp);
|
|
250
392
|
} else if (operation == 1) {
|
|
251
|
-
return await this.
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
return true;
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* Stores the functions that were broadcasted individually.
|
|
258
|
-
*
|
|
259
|
-
* @dev Beware that there is not a delete variant of this, since they are added to contract classes
|
|
260
|
-
* and will be deleted as part of the class if needed.
|
|
261
|
-
*/ async storeBroadcastedIndividualFunctions(allLogs, _blockNum) {
|
|
262
|
-
// Filter out private and utility function broadcast events
|
|
263
|
-
const privateFnEvents = allLogs.filter((log)=>PrivateFunctionBroadcastedEvent.isPrivateFunctionBroadcastedEvent(log)).map((log)=>PrivateFunctionBroadcastedEvent.fromLog(log));
|
|
264
|
-
const utilityFnEvents = allLogs.filter((log)=>UtilityFunctionBroadcastedEvent.isUtilityFunctionBroadcastedEvent(log)).map((log)=>UtilityFunctionBroadcastedEvent.fromLog(log));
|
|
265
|
-
// Group all events by contract class id
|
|
266
|
-
for (const [classIdString, classEvents] of Object.entries(groupBy([
|
|
267
|
-
...privateFnEvents,
|
|
268
|
-
...utilityFnEvents
|
|
269
|
-
], (e)=>e.contractClassId.toString()))){
|
|
270
|
-
const contractClassId = Fr.fromHexString(classIdString);
|
|
271
|
-
const contractClass = await this.store.getContractClass(contractClassId);
|
|
272
|
-
if (!contractClass) {
|
|
273
|
-
this.log.warn(`Skipping broadcasted functions as contract class ${contractClassId.toString()} was not found`);
|
|
274
|
-
continue;
|
|
275
|
-
}
|
|
276
|
-
// Split private and utility functions, and filter out invalid ones
|
|
277
|
-
const allFns = classEvents.map((e)=>e.toFunctionWithMembershipProof());
|
|
278
|
-
const privateFns = allFns.filter((fn)=>'utilityFunctionsTreeRoot' in fn);
|
|
279
|
-
const utilityFns = allFns.filter((fn)=>'privateFunctionsArtifactTreeRoot' in fn);
|
|
280
|
-
const privateFunctionsWithValidity = await Promise.all(privateFns.map(async (fn)=>({
|
|
281
|
-
fn,
|
|
282
|
-
valid: await isValidPrivateFunctionMembershipProof(fn, contractClass)
|
|
283
|
-
})));
|
|
284
|
-
const validPrivateFns = privateFunctionsWithValidity.filter(({ valid })=>valid).map(({ fn })=>fn);
|
|
285
|
-
const utilityFunctionsWithValidity = await Promise.all(utilityFns.map(async (fn)=>({
|
|
286
|
-
fn,
|
|
287
|
-
valid: await isValidUtilityFunctionMembershipProof(fn, contractClass)
|
|
288
|
-
})));
|
|
289
|
-
const validUtilityFns = utilityFunctionsWithValidity.filter(({ valid })=>valid).map(({ fn })=>fn);
|
|
290
|
-
const validFnCount = validPrivateFns.length + validUtilityFns.length;
|
|
291
|
-
if (validFnCount !== allFns.length) {
|
|
292
|
-
this.log.warn(`Skipping ${allFns.length - validFnCount} invalid functions`);
|
|
293
|
-
}
|
|
294
|
-
// Store the functions in the contract class in a single operation
|
|
295
|
-
if (validFnCount > 0) {
|
|
296
|
-
this.log.verbose(`Storing ${validFnCount} functions for contract class ${contractClassId.toString()}`);
|
|
393
|
+
return await this.stores.contractInstances.deleteContractInstanceUpdates(contractUpdates, timestamp);
|
|
297
394
|
}
|
|
298
|
-
return await this.store.addFunctions(contractClassId, validPrivateFns, validUtilityFns);
|
|
299
395
|
}
|
|
300
396
|
return true;
|
|
301
397
|
}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import type { SlotNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import type { L2Block } from '@aztec/stdlib/block';
|
|
3
|
+
import type { CheckpointData } from '@aztec/stdlib/checkpoint';
|
|
4
|
+
import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
2
5
|
import { type LmdbStatsCallback, type TelemetryClient, type Tracer } from '@aztec/telemetry-client';
|
|
3
6
|
export declare class ArchiverInstrumentation {
|
|
4
7
|
private telemetry;
|
|
5
8
|
readonly tracer: Tracer;
|
|
6
9
|
private blockHeight;
|
|
10
|
+
private checkpointHeight;
|
|
7
11
|
private txCount;
|
|
8
12
|
private l1BlockHeight;
|
|
9
13
|
private proofsSubmittedDelay;
|
|
@@ -12,20 +16,32 @@ export declare class ArchiverInstrumentation {
|
|
|
12
16
|
private pruneDuration;
|
|
13
17
|
private pruneCount;
|
|
14
18
|
private syncDurationPerBlock;
|
|
19
|
+
private syncDurationPerCheckpoint;
|
|
15
20
|
private syncBlockCount;
|
|
16
21
|
private manaPerBlock;
|
|
17
22
|
private txsPerBlock;
|
|
18
23
|
private syncDurationPerMessage;
|
|
19
24
|
private syncMessageCount;
|
|
20
25
|
private blockProposalTxTargetCount;
|
|
26
|
+
private checkpointL1InclusionDelay;
|
|
27
|
+
private checkpointPromotedCount;
|
|
21
28
|
private log;
|
|
22
29
|
private constructor();
|
|
23
30
|
static new(telemetry: TelemetryClient, lmdbStats?: LmdbStatsCallback): Promise<ArchiverInstrumentation>;
|
|
24
31
|
isEnabled(): boolean;
|
|
25
|
-
|
|
32
|
+
processNewProposedBlock(syncTimePerBlock: number, block: L2Block): void;
|
|
33
|
+
processNewCheckpointedBlocks(syncTimePerCheckpoint: number, blocks: L2Block[]): void;
|
|
26
34
|
processNewMessages(count: number, syncPerMessageMs: number): void;
|
|
27
35
|
processPrune(duration: number): void;
|
|
28
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Records a pending-chain reorg, where the archiver dropped proposed blocks (and world-state follows by pruning). The
|
|
38
|
+
* type distinguishes the cause: 'uncheckpointed' (slot ended without a checkpoint), 'l1_conflict' (proposed blocks
|
|
39
|
+
* conflicting with an L1 checkpoint), 'orphan' (no matching proposed checkpoint arrived before the deadline), or
|
|
40
|
+
* 'l1_mismatch' (the local checkpointed tip diverged from L1 — an L1 reorg or a pruned/missed-proof checkpoint — so
|
|
41
|
+
* already-checkpointed blocks were rewound).
|
|
42
|
+
*/
|
|
43
|
+
recordPrune(pruneType: 'uncheckpointed' | 'l1_conflict' | 'orphan' | 'l1_mismatch'): void;
|
|
44
|
+
updateLastProvenCheckpoint(checkpoint: CheckpointData): void;
|
|
29
45
|
processProofsVerified(logs: {
|
|
30
46
|
proverId: string;
|
|
31
47
|
l2BlockNumber: bigint;
|
|
@@ -33,5 +49,15 @@ export declare class ArchiverInstrumentation {
|
|
|
33
49
|
}[]): void;
|
|
34
50
|
updateL1BlockHeight(blockNumber: bigint): void;
|
|
35
51
|
recordBlockProposalTxTarget(target: string, usedTrace: boolean): void;
|
|
52
|
+
/** Records a checkpoint promoted from proposed (blob fetch skipped). */
|
|
53
|
+
processCheckpointPromoted(): void;
|
|
54
|
+
/**
|
|
55
|
+
* Records L1 inclusion timing for a checkpoint observed on L1 (seconds into the L2 slot).
|
|
56
|
+
*/
|
|
57
|
+
processCheckpointL1Timing(data: {
|
|
58
|
+
slotNumber: SlotNumber;
|
|
59
|
+
l1Timestamp: bigint;
|
|
60
|
+
l1Constants: Pick<L1RollupConstants, 'l1GenesisTime' | 'slotDuration'>;
|
|
61
|
+
}): void;
|
|
36
62
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7UUFBRSxRQUFRLEVBQUUsTUFBTSxDQUFDO1FBQUMsYUFBYSxFQUFFLE1BQU0sQ0FBQztRQUFDLEtBQUssRUFBRSxNQUFNLENBQUE7S0FBRSxFQUFFLFFBVzlGO0lBRU0sbUJBQW1CLENBQUMsV0FBVyxFQUFFLE1BQU0sUUFFN0M7SUFFTSwyQkFBMkIsQ0FBQyxNQUFNLEVBQUUsTUFBTSxFQUFFLFNBQVMsRUFBRSxPQUFPLFFBS3BFO0lBRUQsd0VBQXdFO0lBQ2pFLHlCQUF5QixTQUUvQjtJQUVEOztPQUVHO0lBQ0kseUJBQXlCLENBQUMsSUFBSSxFQUFFO1FBQ3JDLFVBQVUsRUFBRSxVQUFVLENBQUM7UUFDdkIsV0FBVyxFQUFFLE1BQU0sQ0FBQztRQUNwQixXQUFXLEVBQUUsSUFBSSxDQUFDLGlCQUFpQixFQUFFLGVBQWUsR0FBRyxjQUFjLENBQUMsQ0FBQztLQUN4RSxHQUFHLElBQUksQ0FJUDtDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../src/modules/instrumentation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../src/modules/instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAElE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAErE,OAAO,EAKL,KAAK,iBAAiB,EAEtB,KAAK,eAAe,EACpB,KAAK,MAAM,EAGZ,MAAM,yBAAyB,CAAC;AAEjC,qBAAa,uBAAuB;IA+BhC,OAAO,CAAC,SAAS;IA9BnB,SAAgB,MAAM,EAAE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