@aztec/archiver 0.0.1-commit.343b43af6 → 0.0.1-commit.35158ae7e
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.d.ts +1 -2
- package/dest/archiver.d.ts.map +1 -1
- package/dest/archiver.js +21 -11
- package/dest/config.d.ts +3 -3
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +2 -1
- package/dest/errors.d.ts +15 -1
- package/dest/errors.d.ts.map +1 -1
- package/dest/errors.js +18 -0
- package/dest/factory.d.ts +2 -2
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +16 -13
- package/dest/modules/data_source_base.d.ts +3 -3
- package/dest/modules/data_source_base.d.ts.map +1 -1
- package/dest/modules/data_source_base.js +5 -5
- package/dest/modules/data_store_updater.d.ts +3 -6
- package/dest/modules/data_store_updater.d.ts.map +1 -1
- package/dest/modules/data_store_updater.js +47 -65
- package/dest/modules/l1_synchronizer.d.ts +1 -1
- package/dest/modules/l1_synchronizer.d.ts.map +1 -1
- package/dest/modules/l1_synchronizer.js +9 -5
- package/dest/store/block_store.d.ts +3 -2
- package/dest/store/block_store.d.ts.map +1 -1
- package/dest/store/block_store.js +7 -4
- package/dest/store/contract_class_store.d.ts +2 -3
- package/dest/store/contract_class_store.d.ts.map +1 -1
- package/dest/store/contract_class_store.js +7 -67
- package/dest/store/contract_instance_store.d.ts +1 -1
- package/dest/store/contract_instance_store.d.ts.map +1 -1
- package/dest/store/contract_instance_store.js +6 -2
- package/dest/store/kv_archiver_store.d.ts +14 -12
- package/dest/store/kv_archiver_store.d.ts.map +1 -1
- package/dest/store/kv_archiver_store.js +15 -14
- package/dest/store/log_store.d.ts +6 -3
- package/dest/store/log_store.d.ts.map +1 -1
- package/dest/store/log_store.js +93 -16
- package/dest/store/message_store.d.ts +5 -1
- package/dest/store/message_store.d.ts.map +1 -1
- package/dest/store/message_store.js +13 -0
- package/dest/test/fake_l1_state.d.ts +1 -1
- package/dest/test/fake_l1_state.d.ts.map +1 -1
- package/dest/test/fake_l1_state.js +11 -3
- package/dest/test/mock_l2_block_source.d.ts +1 -1
- 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 +13 -13
- package/src/archiver.ts +24 -11
- package/src/config.ts +8 -1
- package/src/errors.ts +30 -0
- package/src/factory.ts +17 -10
- package/src/modules/data_source_base.ts +9 -4
- package/src/modules/data_store_updater.ts +54 -94
- package/src/modules/l1_synchronizer.ts +15 -10
- package/src/store/block_store.ts +11 -2
- package/src/store/contract_class_store.ts +8 -106
- package/src/store/contract_instance_store.ts +8 -5
- package/src/store/kv_archiver_store.ts +22 -25
- package/src/store/log_store.ts +126 -27
- package/src/store/message_store.ts +19 -0
- package/src/test/fake_l1_state.ts +15 -5
- package/src/test/mock_l2_block_source.ts +7 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fake_l1_state.d.ts","sourceRoot":"","sources":["../../src/test/fake_l1_state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,KAAK,IAAI,EAAqD,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"fake_l1_state.d.ts","sourceRoot":"","sources":["../../src/test/fake_l1_state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,KAAK,IAAI,EAAqD,MAAM,iBAAiB,CAAC;AAE/F,OAAO,KAAK,EAAyB,aAAa,EAAkB,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEtH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAoB,gBAAgB,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAEjG,OAAO,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAC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AG,SAAS,CAExE;IAED,sCAAsC;IACtC,WAAW,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,EAAE,EAAE,CAEpD;IAED,uCAAuC;IACvC,kBAAkB,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,IAAI,EAAE,CAE7D;IAED,mEAAmE;IACnE,wBAAwB,CAAC,aAAa,EAAE,SAAS,CAAC,gBAAgB,CAAC,GAAG,SAAS,CAAC,cAAc,CAAC,CAgC9F;IAED,kEAAkE;IAClE,uBAAuB,CAAC,aAAa,EAAE,SAAS,CAAC,gBAAgB,CAAC,GAAG,SAAS,CAAC,aAAa,CAAC,CA8B5F;IAED,iEAAiE;IACjE,sBAAsB,IAAI,SAAS,CAAC,gBAAgB,CAAC,CA4BpD;IAED,+DAA+D;IAC/D,oBAAoB,IAAI,SAAS,CAAC,mBAAmB,CAAC,CAarD;IAED,OAAO,CAAC,6BAA6B;IAMrC,OAAO,CAAC,YAAY;IAepB,OAAO,CAAC,kBAAkB;IAQ1B,OAAO,CAAC,yBAAyB;IAiBjC,OAAO,CAAC,kBAAkB;YAqBZ,YAAY;IAyE1B,gGAAgG;IAChG,OAAO,CAAC,iCAAiC;YAkB3B,uBAAuB;YAMvB,uBAAuB;CAGtC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getBlobsPerL1Block, getPrefixedEthBlobCommitments } from '@aztec/blob-lib';
|
|
2
|
+
import { INITIAL_CHECKPOINT_NUMBER } from '@aztec/constants';
|
|
2
3
|
import { MULTI_CALL_3_ADDRESS } from '@aztec/ethereum/contracts';
|
|
3
4
|
import { CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
4
5
|
import { Buffer16, Buffer32 } from '@aztec/foundation/buffer';
|
|
@@ -278,11 +279,18 @@ import { updateRollingHash } from '../structs/inbox_message.js';
|
|
|
278
279
|
}
|
|
279
280
|
/** Creates mock InboxContract that reads from this fake state. */ createMockInboxContract(_publicClient) {
|
|
280
281
|
const mockInbox = mock();
|
|
281
|
-
mockInbox.getState.mockImplementation(()=>
|
|
282
|
+
mockInbox.getState.mockImplementation(()=>{
|
|
283
|
+
// treeInProgress must be > any sealed checkpoint. On L1, a checkpoint can only be proposed
|
|
284
|
+
// after its messages are sealed, so treeInProgress > checkpointNumber for all published checkpoints.
|
|
285
|
+
const maxFromMessages = this.messages.length > 0 ? Math.max(...this.messages.map((m)=>Number(m.checkpointNumber))) + 1 : 0;
|
|
286
|
+
const maxFromCheckpoints = this.checkpoints.length > 0 ? Math.max(...this.checkpoints.filter((cp)=>!cp.pruned).map((cp)=>Number(cp.checkpointNumber))) + 1 : 0;
|
|
287
|
+
const treeInProgress = Math.max(maxFromMessages, maxFromCheckpoints, INITIAL_CHECKPOINT_NUMBER);
|
|
288
|
+
return Promise.resolve({
|
|
282
289
|
messagesRollingHash: this.messagesRollingHash,
|
|
283
290
|
totalMessagesInserted: BigInt(this.messages.length),
|
|
284
|
-
treeInProgress:
|
|
285
|
-
})
|
|
291
|
+
treeInProgress: BigInt(treeInProgress)
|
|
292
|
+
});
|
|
293
|
+
});
|
|
286
294
|
// Mock the wrapper methods for fetching message events
|
|
287
295
|
mockInbox.getMessageSentEvents.mockImplementation((fromBlock, toBlock)=>Promise.resolve(this.getMessageSentLogs(fromBlock, toBlock)));
|
|
288
296
|
mockInbox.getMessageSentEventByHash.mockImplementation((hash, fromBlock, toBlock)=>Promise.resolve(this.getMessageSentLogs(fromBlock, toBlock, hash)));
|
|
@@ -138,4 +138,4 @@ export declare class MockL2BlockSource implements L2BlockSource, ContractDataSou
|
|
|
138
138
|
/** Finds the checkpoint number for a block, or undefined if the block is not in any checkpoint. */
|
|
139
139
|
private findCheckpointNumberForBlock;
|
|
140
140
|
}
|
|
141
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
141
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW9ja19sMl9ibG9ja19zb3VyY2UuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3Vy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ED,gBAAgB,CAAC,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAElE;IAED,qBAAqB,CAAC,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC,CAEtD;IAED,WAAW,CAAC,QAAQ,EAAE,YAAY,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,2BAA2B,GAAG,SAAS,CAAC,CAEzG;IAED,mBAAmB,IAAI,OAAO,CAAC,EAAE,EAAE,CAAC,CAEnC;IAED,oBAAoB,CAAC,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAErG;IAED,kCAAkC,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAEvE;IAED,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAE7B;IAED,qBAAqB,IAAI,OAAO,CAAC,OAAO,CAAC,CAExC;IAED,+BAA+B,IAAI,OAAO,CAAC,wBAAwB,CAAC,CAEnE;IAED,mEAAmE;IACnE,OAAO,CAAC,qBAAqB;IAM7B,uDAAuD;IACvD,OAAO,CAAC,uBAAuB;IAI/B,+EAA+E;IAC/E,OAAO,CAAC,mBAAmB;IAe3B,mGAAmG;IACnG,OAAO,CAAC,4BAA4B;CAIrC"}
|
|
@@ -7,7 +7,7 @@ import { EthAddress } from '@aztec/foundation/eth-address';
|
|
|
7
7
|
import { createLogger } from '@aztec/foundation/log';
|
|
8
8
|
import { CheckpointedL2Block } from '@aztec/stdlib/block';
|
|
9
9
|
import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
10
|
-
import { EmptyL1RollupConstants, getSlotRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
|
10
|
+
import { EmptyL1RollupConstants, getEpochAtSlot, getSlotRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
|
11
11
|
import { computeCheckpointOutHash } from '@aztec/stdlib/messaging';
|
|
12
12
|
import { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
13
13
|
import { TxExecutionResult, TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
@@ -308,7 +308,7 @@ import { TxExecutionResult, TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
|
308
308
|
for (const txEffect of block.body.txEffects){
|
|
309
309
|
if (txEffect.txHash.equals(txHash)) {
|
|
310
310
|
// In mock, assume all txs are checkpointed with successful execution
|
|
311
|
-
return new TxReceipt(txHash, TxStatus.CHECKPOINTED, TxExecutionResult.SUCCESS, undefined, txEffect.transactionFee.toBigInt(), await block.hash(), block.number);
|
|
311
|
+
return new TxReceipt(txHash, TxStatus.CHECKPOINTED, TxExecutionResult.SUCCESS, undefined, txEffect.transactionFee.toBigInt(), await block.hash(), block.number, getEpochAtSlot(block.slot, EmptyL1RollupConstants));
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
314
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/archiver",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.35158ae7e",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -65,18 +65,18 @@
|
|
|
65
65
|
]
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@aztec/blob-client": "0.0.1-commit.
|
|
69
|
-
"@aztec/blob-lib": "0.0.1-commit.
|
|
70
|
-
"@aztec/constants": "0.0.1-commit.
|
|
71
|
-
"@aztec/epoch-cache": "0.0.1-commit.
|
|
72
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
73
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
74
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
75
|
-
"@aztec/l1-artifacts": "0.0.1-commit.
|
|
76
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
77
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
78
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
79
|
-
"@aztec/telemetry-client": "0.0.1-commit.
|
|
68
|
+
"@aztec/blob-client": "0.0.1-commit.35158ae7e",
|
|
69
|
+
"@aztec/blob-lib": "0.0.1-commit.35158ae7e",
|
|
70
|
+
"@aztec/constants": "0.0.1-commit.35158ae7e",
|
|
71
|
+
"@aztec/epoch-cache": "0.0.1-commit.35158ae7e",
|
|
72
|
+
"@aztec/ethereum": "0.0.1-commit.35158ae7e",
|
|
73
|
+
"@aztec/foundation": "0.0.1-commit.35158ae7e",
|
|
74
|
+
"@aztec/kv-store": "0.0.1-commit.35158ae7e",
|
|
75
|
+
"@aztec/l1-artifacts": "0.0.1-commit.35158ae7e",
|
|
76
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.35158ae7e",
|
|
77
|
+
"@aztec/protocol-contracts": "0.0.1-commit.35158ae7e",
|
|
78
|
+
"@aztec/stdlib": "0.0.1-commit.35158ae7e",
|
|
79
|
+
"@aztec/telemetry-client": "0.0.1-commit.35158ae7e",
|
|
80
80
|
"lodash.groupby": "^4.6.0",
|
|
81
81
|
"lodash.omit": "^4.5.0",
|
|
82
82
|
"tslib": "^2.5.0",
|
package/src/archiver.ts
CHANGED
|
@@ -95,7 +95,6 @@ export class Archiver extends ArchiverDataSourceBase implements L2BlockSink, Tra
|
|
|
95
95
|
* @param dataStore - An archiver data store for storage & retrieval of blocks, encrypted logs & contract data.
|
|
96
96
|
* @param config - Archiver configuration options.
|
|
97
97
|
* @param blobClient - Client for retrieving blob data.
|
|
98
|
-
* @param epochCache - Cache for epoch-related data.
|
|
99
98
|
* @param dateProvider - Provider for current date/time.
|
|
100
99
|
* @param instrumentation - Instrumentation for metrics and tracing.
|
|
101
100
|
* @param l1Constants - L1 rollup constants.
|
|
@@ -342,19 +341,33 @@ export class Archiver extends ArchiverDataSourceBase implements L2BlockSink, Tra
|
|
|
342
341
|
return Promise.resolve(this.synchronizer.getL1Timestamp());
|
|
343
342
|
}
|
|
344
343
|
|
|
345
|
-
public getSyncedL2SlotNumber(): Promise<SlotNumber | undefined> {
|
|
344
|
+
public async getSyncedL2SlotNumber(): Promise<SlotNumber | undefined> {
|
|
345
|
+
// The synced L2 slot is the latest slot for which we have all L1 data,
|
|
346
|
+
// either because we have seen all L1 blocks for that slot, or because
|
|
347
|
+
// we have seen the corresponding checkpoint.
|
|
348
|
+
|
|
349
|
+
let slotFromL1Sync: SlotNumber | undefined;
|
|
346
350
|
const l1Timestamp = this.synchronizer.getL1Timestamp();
|
|
347
|
-
if (l1Timestamp
|
|
348
|
-
|
|
351
|
+
if (l1Timestamp !== undefined) {
|
|
352
|
+
const nextL1BlockSlot = getSlotAtNextL1Block(l1Timestamp, this.l1Constants);
|
|
353
|
+
if (Number(nextL1BlockSlot) > 0) {
|
|
354
|
+
slotFromL1Sync = SlotNumber.add(nextL1BlockSlot, -1);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
let slotFromCheckpoint: SlotNumber | undefined;
|
|
359
|
+
const latestCheckpointNumber = await this.store.getSynchedCheckpointNumber();
|
|
360
|
+
if (latestCheckpointNumber > 0) {
|
|
361
|
+
const checkpointData = await this.store.getCheckpointData(latestCheckpointNumber);
|
|
362
|
+
if (checkpointData) {
|
|
363
|
+
slotFromCheckpoint = checkpointData.header.slotNumber;
|
|
364
|
+
}
|
|
349
365
|
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
const nextL1BlockSlot = getSlotAtNextL1Block(l1Timestamp, this.l1Constants);
|
|
354
|
-
if (Number(nextL1BlockSlot) === 0) {
|
|
355
|
-
return Promise.resolve(undefined);
|
|
366
|
+
|
|
367
|
+
if (slotFromL1Sync === undefined && slotFromCheckpoint === undefined) {
|
|
368
|
+
return undefined;
|
|
356
369
|
}
|
|
357
|
-
return
|
|
370
|
+
return SlotNumber(Math.max(slotFromL1Sync ?? 0, slotFromCheckpoint ?? 0));
|
|
358
371
|
}
|
|
359
372
|
|
|
360
373
|
public async getSyncedL2EpochNumber(): Promise<EpochNumber | undefined> {
|
package/src/config.ts
CHANGED
|
@@ -8,7 +8,12 @@ import {
|
|
|
8
8
|
getConfigFromMappings,
|
|
9
9
|
numberConfigHelper,
|
|
10
10
|
} from '@aztec/foundation/config';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
type ChainConfig,
|
|
13
|
+
type PipelineConfig,
|
|
14
|
+
chainConfigMappings,
|
|
15
|
+
pipelineConfigMappings,
|
|
16
|
+
} from '@aztec/stdlib/config';
|
|
12
17
|
import type { ArchiverSpecificConfig } from '@aztec/stdlib/interfaces/server';
|
|
13
18
|
|
|
14
19
|
/**
|
|
@@ -21,11 +26,13 @@ import type { ArchiverSpecificConfig } from '@aztec/stdlib/interfaces/server';
|
|
|
21
26
|
export type ArchiverConfig = ArchiverSpecificConfig &
|
|
22
27
|
L1ReaderConfig &
|
|
23
28
|
L1ContractsConfig &
|
|
29
|
+
PipelineConfig & // required to pass through to epoch cache
|
|
24
30
|
BlobClientConfig &
|
|
25
31
|
ChainConfig;
|
|
26
32
|
|
|
27
33
|
export const archiverConfigMappings: ConfigMappingsType<ArchiverConfig> = {
|
|
28
34
|
...blobClientConfigMapping,
|
|
35
|
+
...pipelineConfigMappings,
|
|
29
36
|
archiverPollingIntervalMS: {
|
|
30
37
|
env: 'ARCHIVER_POLLING_INTERVAL_MS',
|
|
31
38
|
description: 'The polling interval in ms for retrieving new L2 blocks and encrypted logs.',
|
package/src/errors.ts
CHANGED
|
@@ -74,6 +74,36 @@ export class BlockAlreadyCheckpointedError extends Error {
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
/** Thrown when logs are added for a tag whose last stored log has a higher block number than the new log. */
|
|
78
|
+
export class OutOfOrderLogInsertionError extends Error {
|
|
79
|
+
constructor(
|
|
80
|
+
public readonly logType: 'private' | 'public',
|
|
81
|
+
public readonly tag: string,
|
|
82
|
+
public readonly lastBlockNumber: number,
|
|
83
|
+
public readonly newBlockNumber: number,
|
|
84
|
+
) {
|
|
85
|
+
super(
|
|
86
|
+
`Out-of-order ${logType} log insertion for tag ${tag}: ` +
|
|
87
|
+
`last existing log is from block ${lastBlockNumber} but new log is from block ${newBlockNumber}`,
|
|
88
|
+
);
|
|
89
|
+
this.name = 'OutOfOrderLogInsertionError';
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Thrown when L1 to L2 messages are requested for a checkpoint whose message tree hasn't been sealed yet. */
|
|
94
|
+
export class L1ToL2MessagesNotReadyError extends Error {
|
|
95
|
+
constructor(
|
|
96
|
+
public readonly checkpointNumber: number,
|
|
97
|
+
public readonly inboxTreeInProgress: bigint,
|
|
98
|
+
) {
|
|
99
|
+
super(
|
|
100
|
+
`Cannot get L1 to L2 messages for checkpoint ${checkpointNumber}: ` +
|
|
101
|
+
`inbox tree in progress is ${inboxTreeInProgress}, messages not yet sealed`,
|
|
102
|
+
);
|
|
103
|
+
this.name = 'L1ToL2MessagesNotReadyError';
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
77
107
|
/** Thrown when a proposed block conflicts with an already checkpointed block (different content). */
|
|
78
108
|
export class CannotOverwriteCheckpointedBlockError extends Error {
|
|
79
109
|
constructor(
|
package/src/factory.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EpochCache } from '@aztec/epoch-cache';
|
|
2
2
|
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
3
|
+
import { makeL1HttpTransport } from '@aztec/ethereum/client';
|
|
3
4
|
import { InboxContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
4
5
|
import type { ViemPublicDebugClient } from '@aztec/ethereum/types';
|
|
5
6
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
@@ -12,12 +13,12 @@ import { protocolContractNames } from '@aztec/protocol-contracts';
|
|
|
12
13
|
import { BundledProtocolContractsProvider } from '@aztec/protocol-contracts/providers/bundle';
|
|
13
14
|
import { FunctionType, decodeFunctionSignature } from '@aztec/stdlib/abi';
|
|
14
15
|
import type { ArchiverEmitter } from '@aztec/stdlib/block';
|
|
15
|
-
import { type
|
|
16
|
+
import { type ContractClassPublicWithCommitment, computePublicBytecodeCommitment } from '@aztec/stdlib/contract';
|
|
16
17
|
import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
|
|
17
18
|
import { getTelemetryClient } from '@aztec/telemetry-client';
|
|
18
19
|
|
|
19
20
|
import { EventEmitter } from 'events';
|
|
20
|
-
import { createPublicClient
|
|
21
|
+
import { createPublicClient } from 'viem';
|
|
21
22
|
|
|
22
23
|
import { Archiver, type ArchiverDeps } from './archiver.js';
|
|
23
24
|
import { type ArchiverConfig, mapArchiverConfig } from './config.js';
|
|
@@ -57,9 +58,10 @@ export async function createArchiver(
|
|
|
57
58
|
|
|
58
59
|
// Create Ethereum clients
|
|
59
60
|
const chain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
|
|
61
|
+
const httpTimeout = config.l1HttpTimeoutMS;
|
|
60
62
|
const publicClient = createPublicClient({
|
|
61
63
|
chain: chain.chainInfo,
|
|
62
|
-
transport:
|
|
64
|
+
transport: makeL1HttpTransport(config.l1RpcUrls, { timeout: httpTimeout }),
|
|
63
65
|
pollingInterval: config.viemPollingIntervalMS,
|
|
64
66
|
});
|
|
65
67
|
|
|
@@ -67,7 +69,7 @@ export async function createArchiver(
|
|
|
67
69
|
const debugRpcUrls = config.l1DebugRpcUrls.length > 0 ? config.l1DebugRpcUrls : config.l1RpcUrls;
|
|
68
70
|
const debugClient = createPublicClient({
|
|
69
71
|
chain: chain.chainInfo,
|
|
70
|
-
transport:
|
|
72
|
+
transport: makeL1HttpTransport(debugRpcUrls, { timeout: httpTimeout }),
|
|
71
73
|
pollingInterval: config.viemPollingIntervalMS,
|
|
72
74
|
}) as ViemPublicDebugClient;
|
|
73
75
|
|
|
@@ -171,16 +173,22 @@ export async function createArchiver(
|
|
|
171
173
|
return archiver;
|
|
172
174
|
}
|
|
173
175
|
|
|
174
|
-
/** Registers protocol contracts in the archiver store. */
|
|
176
|
+
/** Registers protocol contracts in the archiver store. Idempotent — skips contracts that already exist (e.g. on node restart). */
|
|
175
177
|
export async function registerProtocolContracts(store: KVArchiverDataStore) {
|
|
176
178
|
const blockNumber = 0;
|
|
177
179
|
for (const name of protocolContractNames) {
|
|
178
180
|
const provider = new BundledProtocolContractsProvider();
|
|
179
181
|
const contract = await provider.getProtocolContractArtifact(name);
|
|
180
|
-
|
|
182
|
+
|
|
183
|
+
// Skip if already registered (happens on node restart with a persisted store).
|
|
184
|
+
if (await store.getContractClass(contract.contractClass.id)) {
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const publicBytecodeCommitment = await computePublicBytecodeCommitment(contract.contractClass.packedBytecode);
|
|
189
|
+
const contractClassPublic: ContractClassPublicWithCommitment = {
|
|
181
190
|
...contract.contractClass,
|
|
182
|
-
|
|
183
|
-
utilityFunctions: [],
|
|
191
|
+
publicBytecodeCommitment,
|
|
184
192
|
};
|
|
185
193
|
|
|
186
194
|
const publicFunctionSignatures = contract.artifact.functions
|
|
@@ -188,8 +196,7 @@ export async function registerProtocolContracts(store: KVArchiverDataStore) {
|
|
|
188
196
|
.map(fn => decodeFunctionSignature(fn.name, fn.parameters));
|
|
189
197
|
|
|
190
198
|
await store.registerContractFunctionSignatures(publicFunctionSignatures);
|
|
191
|
-
|
|
192
|
-
await store.addContractClasses([contractClassPublic], [bytecodeCommitment], BlockNumber(blockNumber));
|
|
199
|
+
await store.addContractClasses([contractClassPublic], BlockNumber(blockNumber));
|
|
193
200
|
await store.addContractInstances([contract.instance], BlockNumber(blockNumber));
|
|
194
201
|
}
|
|
195
202
|
}
|
|
@@ -154,7 +154,7 @@ export abstract class ArchiverDataSourceBase
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
public getSettledTxReceipt(txHash: TxHash): Promise<TxReceipt | undefined> {
|
|
157
|
-
return this.store.getSettledTxReceipt(txHash);
|
|
157
|
+
return this.store.getSettledTxReceipt(txHash, this.l1Constants);
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
public isPendingChainInvalid(): Promise<boolean> {
|
|
@@ -165,16 +165,21 @@ export abstract class ArchiverDataSourceBase
|
|
|
165
165
|
return (await this.store.getPendingChainValidationStatus()) ?? { valid: true };
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
public getPrivateLogsByTags(
|
|
169
|
-
|
|
168
|
+
public getPrivateLogsByTags(
|
|
169
|
+
tags: SiloedTag[],
|
|
170
|
+
page?: number,
|
|
171
|
+
upToBlockNumber?: BlockNumber,
|
|
172
|
+
): Promise<TxScopedL2Log[][]> {
|
|
173
|
+
return this.store.getPrivateLogsByTags(tags, page, upToBlockNumber);
|
|
170
174
|
}
|
|
171
175
|
|
|
172
176
|
public getPublicLogsByTagsFromContract(
|
|
173
177
|
contractAddress: AztecAddress,
|
|
174
178
|
tags: Tag[],
|
|
175
179
|
page?: number,
|
|
180
|
+
upToBlockNumber?: BlockNumber,
|
|
176
181
|
): Promise<TxScopedL2Log[][]> {
|
|
177
|
-
return this.store.getPublicLogsByTagsFromContract(contractAddress, tags, page);
|
|
182
|
+
return this.store.getPublicLogsByTagsFromContract(contractAddress, tags, page, upToBlockNumber);
|
|
178
183
|
}
|
|
179
184
|
|
|
180
185
|
public getPublicLogs(filter: LogFilter): Promise<GetPublicLogsResponse> {
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import {
|
|
2
|
+
import { filterAsync } from '@aztec/foundation/collection';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import {
|
|
5
|
-
ContractClassPublishedEvent,
|
|
6
|
-
PrivateFunctionBroadcastedEvent,
|
|
7
|
-
UtilityFunctionBroadcastedEvent,
|
|
8
|
-
} from '@aztec/protocol-contracts/class-registry';
|
|
4
|
+
import { ContractClassPublishedEvent } from '@aztec/protocol-contracts/class-registry';
|
|
9
5
|
import {
|
|
10
6
|
ContractInstancePublishedEvent,
|
|
11
7
|
ContractInstanceUpdatedEvent,
|
|
@@ -13,17 +9,13 @@ import {
|
|
|
13
9
|
import type { L2Block, ValidateCheckpointResult } from '@aztec/stdlib/block';
|
|
14
10
|
import { type PublishedCheckpoint, validateCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
15
11
|
import {
|
|
16
|
-
type
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
isValidPrivateFunctionMembershipProof,
|
|
20
|
-
isValidUtilityFunctionMembershipProof,
|
|
12
|
+
type ContractClassPublicWithCommitment,
|
|
13
|
+
computeContractAddressFromInstance,
|
|
14
|
+
computeContractClassId,
|
|
21
15
|
} from '@aztec/stdlib/contract';
|
|
22
16
|
import type { ContractClassLog, PrivateLog, PublicLog } from '@aztec/stdlib/logs';
|
|
23
17
|
import type { UInt64 } from '@aztec/stdlib/types';
|
|
24
18
|
|
|
25
|
-
import groupBy from 'lodash.groupby';
|
|
26
|
-
|
|
27
19
|
import type { KVArchiverDataStore } from '../store/kv_archiver_store.js';
|
|
28
20
|
import type { L2TipsCache } from '../store/l2_tips_cache.js';
|
|
29
21
|
|
|
@@ -54,8 +46,7 @@ export class ArchiverDataStoreUpdater {
|
|
|
54
46
|
/**
|
|
55
47
|
* Adds a proposed block to the store with contract class/instance extraction from logs.
|
|
56
48
|
* This is an uncheckpointed block that has been proposed by the sequencer but not yet included in a checkpoint on L1.
|
|
57
|
-
* Extracts ContractClassPublished, ContractInstancePublished, ContractInstanceUpdated events
|
|
58
|
-
* and individually broadcasted functions from the block logs.
|
|
49
|
+
* Extracts ContractClassPublished, ContractInstancePublished, ContractInstanceUpdated events from the block logs.
|
|
59
50
|
*
|
|
60
51
|
* @param block - The proposed L2 block to add.
|
|
61
52
|
* @param pendingChainValidationStatus - Optional validation status to set.
|
|
@@ -87,8 +78,7 @@ export class ArchiverDataStoreUpdater {
|
|
|
87
78
|
* Reconciles local blocks with incoming checkpoints from L1.
|
|
88
79
|
* Adds new checkpoints to the store with contract class/instance extraction from logs.
|
|
89
80
|
* Prunes any local blocks that conflict with checkpoint data (by comparing archive roots).
|
|
90
|
-
* Extracts ContractClassPublished, ContractInstancePublished, ContractInstanceUpdated events
|
|
91
|
-
* and individually broadcasted functions from the checkpoint block logs.
|
|
81
|
+
* Extracts ContractClassPublished, ContractInstancePublished, ContractInstanceUpdated events from the checkpoint block logs.
|
|
92
82
|
*
|
|
93
83
|
* @param checkpoints - The published checkpoints to add.
|
|
94
84
|
* @param pendingChainValidationStatus - Optional validation status to set.
|
|
@@ -313,9 +303,6 @@ export class ArchiverDataStoreUpdater {
|
|
|
313
303
|
this.updatePublishedContractClasses(contractClassLogs, block.number, operation),
|
|
314
304
|
this.updateDeployedContractInstances(privateLogs, block.number, operation),
|
|
315
305
|
this.updateUpdatedContractInstances(publicLogs, block.header.globalVariables.timestamp, operation),
|
|
316
|
-
operation === Operation.Store
|
|
317
|
-
? this.storeBroadcastedIndividualFunctions(contractClassLogs, block.number)
|
|
318
|
-
: Promise.resolve(true),
|
|
319
306
|
])
|
|
320
307
|
).every(Boolean);
|
|
321
308
|
}
|
|
@@ -332,18 +319,37 @@ export class ArchiverDataStoreUpdater {
|
|
|
332
319
|
.filter(log => ContractClassPublishedEvent.isContractClassPublishedEvent(log))
|
|
333
320
|
.map(log => ContractClassPublishedEvent.fromLog(log));
|
|
334
321
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
contractClasses.
|
|
338
|
-
|
|
339
|
-
// TODO: Will probably want to create some worker threads to compute these bytecode commitments as they are expensive
|
|
340
|
-
const commitments = await Promise.all(
|
|
341
|
-
contractClasses.map(c => computePublicBytecodeCommitment(c.packedBytecode)),
|
|
342
|
-
);
|
|
343
|
-
return await this.store.addContractClasses(contractClasses, commitments, blockNum);
|
|
344
|
-
} else if (operation == Operation.Delete) {
|
|
322
|
+
if (operation == Operation.Delete) {
|
|
323
|
+
const contractClasses = contractClassPublishedEvents.map(e => e.toContractClassPublic());
|
|
324
|
+
if (contractClasses.length > 0) {
|
|
325
|
+
contractClasses.forEach(c => this.log.verbose(`${Operation[operation]} contract class ${c.id.toString()}`));
|
|
345
326
|
return await this.store.deleteContractClasses(contractClasses, blockNum);
|
|
346
327
|
}
|
|
328
|
+
return true;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// Compute bytecode commitments and validate class IDs in a single pass.
|
|
332
|
+
const contractClasses: ContractClassPublicWithCommitment[] = [];
|
|
333
|
+
for (const event of contractClassPublishedEvents) {
|
|
334
|
+
const contractClass = await event.toContractClassPublicWithBytecodeCommitment();
|
|
335
|
+
const computedClassId = await computeContractClassId({
|
|
336
|
+
artifactHash: contractClass.artifactHash,
|
|
337
|
+
privateFunctionsRoot: contractClass.privateFunctionsRoot,
|
|
338
|
+
publicBytecodeCommitment: contractClass.publicBytecodeCommitment,
|
|
339
|
+
});
|
|
340
|
+
if (!computedClassId.equals(contractClass.id)) {
|
|
341
|
+
this.log.warn(
|
|
342
|
+
`Skipping contract class with mismatched id at block ${blockNum}. Claimed ${contractClass.id}, computed ${computedClassId}`,
|
|
343
|
+
{ blockNum, contractClassId: event.contractClassId.toString() },
|
|
344
|
+
);
|
|
345
|
+
continue;
|
|
346
|
+
}
|
|
347
|
+
contractClasses.push(contractClass);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
if (contractClasses.length > 0) {
|
|
351
|
+
contractClasses.forEach(c => this.log.verbose(`${Operation[operation]} contract class ${c.id.toString()}`));
|
|
352
|
+
return await this.store.addContractClasses(contractClasses, blockNum);
|
|
347
353
|
}
|
|
348
354
|
return true;
|
|
349
355
|
}
|
|
@@ -356,10 +362,27 @@ export class ArchiverDataStoreUpdater {
|
|
|
356
362
|
blockNum: BlockNumber,
|
|
357
363
|
operation: Operation,
|
|
358
364
|
): Promise<boolean> {
|
|
359
|
-
const
|
|
365
|
+
const allInstances = allLogs
|
|
360
366
|
.filter(log => ContractInstancePublishedEvent.isContractInstancePublishedEvent(log))
|
|
361
367
|
.map(log => ContractInstancePublishedEvent.fromLog(log))
|
|
362
368
|
.map(e => e.toContractInstance());
|
|
369
|
+
|
|
370
|
+
// Verify that each instance's address matches the one derived from its fields if we're adding
|
|
371
|
+
const contractInstances =
|
|
372
|
+
operation === Operation.Delete
|
|
373
|
+
? allInstances
|
|
374
|
+
: await filterAsync(allInstances, async instance => {
|
|
375
|
+
const computedAddress = await computeContractAddressFromInstance(instance);
|
|
376
|
+
if (!computedAddress.equals(instance.address)) {
|
|
377
|
+
this.log.warn(
|
|
378
|
+
`Found contract instance with mismatched address at block ${blockNum}. Claimed ${instance.address} but computed ${computedAddress}.`,
|
|
379
|
+
{ instanceAddress: instance.address.toString(), computedAddress: computedAddress.toString(), blockNum },
|
|
380
|
+
);
|
|
381
|
+
return false;
|
|
382
|
+
}
|
|
383
|
+
return true;
|
|
384
|
+
});
|
|
385
|
+
|
|
363
386
|
if (contractInstances.length > 0) {
|
|
364
387
|
contractInstances.forEach(c =>
|
|
365
388
|
this.log.verbose(`${Operation[operation]} contract instance at ${c.address.toString()}`),
|
|
@@ -398,67 +421,4 @@ export class ArchiverDataStoreUpdater {
|
|
|
398
421
|
}
|
|
399
422
|
return true;
|
|
400
423
|
}
|
|
401
|
-
|
|
402
|
-
/**
|
|
403
|
-
* Stores the functions that were broadcasted individually.
|
|
404
|
-
*
|
|
405
|
-
* @dev Beware that there is not a delete variant of this, since they are added to contract classes
|
|
406
|
-
* and will be deleted as part of the class if needed.
|
|
407
|
-
*/
|
|
408
|
-
private async storeBroadcastedIndividualFunctions(
|
|
409
|
-
allLogs: ContractClassLog[],
|
|
410
|
-
_blockNum: BlockNumber,
|
|
411
|
-
): Promise<boolean> {
|
|
412
|
-
// Filter out private and utility function broadcast events
|
|
413
|
-
const privateFnEvents = allLogs
|
|
414
|
-
.filter(log => PrivateFunctionBroadcastedEvent.isPrivateFunctionBroadcastedEvent(log))
|
|
415
|
-
.map(log => PrivateFunctionBroadcastedEvent.fromLog(log));
|
|
416
|
-
const utilityFnEvents = allLogs
|
|
417
|
-
.filter(log => UtilityFunctionBroadcastedEvent.isUtilityFunctionBroadcastedEvent(log))
|
|
418
|
-
.map(log => UtilityFunctionBroadcastedEvent.fromLog(log));
|
|
419
|
-
|
|
420
|
-
// Group all events by contract class id
|
|
421
|
-
for (const [classIdString, classEvents] of Object.entries(
|
|
422
|
-
groupBy([...privateFnEvents, ...utilityFnEvents], e => e.contractClassId.toString()),
|
|
423
|
-
)) {
|
|
424
|
-
const contractClassId = Fr.fromHexString(classIdString);
|
|
425
|
-
const contractClass = await this.store.getContractClass(contractClassId);
|
|
426
|
-
if (!contractClass) {
|
|
427
|
-
this.log.warn(`Skipping broadcasted functions as contract class ${contractClassId.toString()} was not found`);
|
|
428
|
-
continue;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
// Split private and utility functions, and filter out invalid ones
|
|
432
|
-
const allFns = classEvents.map(e => e.toFunctionWithMembershipProof());
|
|
433
|
-
const privateFns = allFns.filter(
|
|
434
|
-
(fn): fn is ExecutablePrivateFunctionWithMembershipProof => 'utilityFunctionsTreeRoot' in fn,
|
|
435
|
-
);
|
|
436
|
-
const utilityFns = allFns.filter(
|
|
437
|
-
(fn): fn is UtilityFunctionWithMembershipProof => 'privateFunctionsArtifactTreeRoot' in fn,
|
|
438
|
-
);
|
|
439
|
-
|
|
440
|
-
const privateFunctionsWithValidity = await Promise.all(
|
|
441
|
-
privateFns.map(async fn => ({ fn, valid: await isValidPrivateFunctionMembershipProof(fn, contractClass) })),
|
|
442
|
-
);
|
|
443
|
-
const validPrivateFns = privateFunctionsWithValidity.filter(({ valid }) => valid).map(({ fn }) => fn);
|
|
444
|
-
const utilityFunctionsWithValidity = await Promise.all(
|
|
445
|
-
utilityFns.map(async fn => ({
|
|
446
|
-
fn,
|
|
447
|
-
valid: await isValidUtilityFunctionMembershipProof(fn, contractClass),
|
|
448
|
-
})),
|
|
449
|
-
);
|
|
450
|
-
const validUtilityFns = utilityFunctionsWithValidity.filter(({ valid }) => valid).map(({ fn }) => fn);
|
|
451
|
-
const validFnCount = validPrivateFns.length + validUtilityFns.length;
|
|
452
|
-
if (validFnCount !== allFns.length) {
|
|
453
|
-
this.log.warn(`Skipping ${allFns.length - validFnCount} invalid functions`);
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
// Store the functions in the contract class in a single operation
|
|
457
|
-
if (validFnCount > 0) {
|
|
458
|
-
this.log.verbose(`Storing ${validFnCount} functions for contract class ${contractClassId.toString()}`);
|
|
459
|
-
}
|
|
460
|
-
return await this.store.addFunctions(contractClassId, validPrivateFns, validUtilityFns);
|
|
461
|
-
}
|
|
462
|
-
return true;
|
|
463
|
-
}
|
|
464
424
|
}
|