@aztec/archiver 0.0.1-commit.64b6bbb → 0.0.1-commit.684755437
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 +7 -2
- package/dest/archiver.d.ts.map +1 -1
- package/dest/archiver.js +25 -96
- package/dest/factory.d.ts +2 -2
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +10 -8
- package/dest/index.d.ts +2 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -0
- package/dest/l1/bin/retrieve-calldata.js +32 -28
- package/dest/l1/calldata_retriever.d.ts +73 -50
- package/dest/l1/calldata_retriever.d.ts.map +1 -1
- package/dest/l1/calldata_retriever.js +190 -259
- package/dest/l1/data_retrieval.d.ts +9 -9
- package/dest/l1/data_retrieval.d.ts.map +1 -1
- package/dest/l1/data_retrieval.js +21 -19
- 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/modules/data_source_base.d.ts +8 -3
- package/dest/modules/data_source_base.d.ts.map +1 -1
- package/dest/modules/data_source_base.js +28 -72
- package/dest/modules/data_store_updater.d.ts +13 -3
- package/dest/modules/data_store_updater.d.ts.map +1 -1
- package/dest/modules/data_store_updater.js +48 -19
- package/dest/modules/instrumentation.d.ts +15 -2
- package/dest/modules/instrumentation.d.ts.map +1 -1
- package/dest/modules/instrumentation.js +19 -2
- package/dest/modules/l1_synchronizer.d.ts +5 -8
- package/dest/modules/l1_synchronizer.d.ts.map +1 -1
- package/dest/modules/l1_synchronizer.js +16 -9
- package/dest/store/block_store.d.ts +18 -14
- package/dest/store/block_store.d.ts.map +1 -1
- package/dest/store/block_store.js +69 -17
- package/dest/store/kv_archiver_store.d.ts +18 -4
- package/dest/store/kv_archiver_store.d.ts.map +1 -1
- package/dest/store/kv_archiver_store.js +18 -0
- package/dest/store/l2_tips_cache.d.ts +19 -0
- package/dest/store/l2_tips_cache.d.ts.map +1 -0
- package/dest/store/l2_tips_cache.js +89 -0
- package/dest/store/message_store.js +1 -1
- package/dest/test/fake_l1_state.d.ts +6 -1
- package/dest/test/fake_l1_state.d.ts.map +1 -1
- package/dest/test/fake_l1_state.js +56 -18
- 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 +19 -3
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +128 -82
- 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 +13 -1
- package/package.json +13 -13
- package/src/archiver.ts +39 -116
- package/src/factory.ts +11 -2
- package/src/index.ts +1 -0
- package/src/l1/README.md +25 -68
- package/src/l1/bin/retrieve-calldata.ts +40 -27
- package/src/l1/calldata_retriever.ts +249 -379
- package/src/l1/data_retrieval.ts +23 -25
- package/src/l1/spire_proposer.ts +7 -15
- package/src/modules/data_source_base.ts +53 -92
- package/src/modules/data_store_updater.ts +49 -19
- package/src/modules/instrumentation.ts +29 -2
- package/src/modules/l1_synchronizer.ts +22 -13
- package/src/store/block_store.ts +85 -36
- package/src/store/kv_archiver_store.ts +35 -3
- package/src/store/l2_tips_cache.ts +89 -0
- package/src/store/message_store.ts +1 -1
- package/src/test/fake_l1_state.ts +75 -17
- package/src/test/mock_archiver.ts +3 -2
- package/src/test/mock_l2_block_source.ts +164 -78
- package/src/test/mock_structs.ts +20 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock_structs.d.ts","sourceRoot":"","sources":["../../src/test/mock_structs.ts"],"names":[],"mappings":"AAMA,OAAO,EAAe,gBAAgB,EAAyB,MAAM,iCAAiC,CAAC;AACvG,OAAO,EAAE,QAAQ,EAAY,MAAM,0BAA0B,CAAC;AAG9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAA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,eAAe,CAAC,EAAE,YAAY,CAAA;KAAE,CAAC;CACvE;AAED,kEAAkE;AAClE,wBAAsB,sBAAsB,CAC1C,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,6BAAkC,GAC1C,OAAO,CAAC,mBAAmB,CAAC,CAsB9B"}
|
|
@@ -77,6 +77,18 @@ export function makeInboxMessages(totalCount, opts = {}) {
|
|
|
77
77
|
/** Creates L1PublishedData with deterministic values based on l1BlockNumber. */ export function makeL1PublishedData(l1BlockNumber) {
|
|
78
78
|
return new L1PublishedData(BigInt(l1BlockNumber), BigInt(l1BlockNumber * 1000), makeBlockHash(l1BlockNumber));
|
|
79
79
|
}
|
|
80
|
+
/** Creates a Checkpoint from a list of blocks with a header that matches the blocks' structure. */ export function makeCheckpoint(blocks, checkpointNumber = CheckpointNumber(1)) {
|
|
81
|
+
const firstBlock = blocks[0];
|
|
82
|
+
const { slotNumber, timestamp, coinbase, feeRecipient, gasFees } = firstBlock.header.globalVariables;
|
|
83
|
+
return new Checkpoint(blocks.at(-1).archive, CheckpointHeader.random({
|
|
84
|
+
lastArchiveRoot: firstBlock.header.lastArchive.root,
|
|
85
|
+
slotNumber,
|
|
86
|
+
timestamp,
|
|
87
|
+
coinbase,
|
|
88
|
+
feeRecipient,
|
|
89
|
+
gasFees
|
|
90
|
+
}), blocks, checkpointNumber);
|
|
91
|
+
}
|
|
80
92
|
/** Wraps a Checkpoint with L1 published data and random attestations. */ export function makePublishedCheckpoint(checkpoint, l1BlockNumber, attestationCount = 3) {
|
|
81
93
|
return new PublishedCheckpoint(checkpoint, makeL1PublishedData(l1BlockNumber), times(attestationCount, CommitteeAttestation.random));
|
|
82
94
|
}
|
|
@@ -164,7 +176,7 @@ export function makeInboxMessages(totalCount, opts = {}) {
|
|
|
164
176
|
txEffect.publicLogs = publicLogs ? makePublicLogs(blockNumber, txIndex, publicLogs.numLogsPerTx, publicLogs.contractAddress) : [];
|
|
165
177
|
return txEffect;
|
|
166
178
|
});
|
|
167
|
-
const checkpoint =
|
|
179
|
+
const checkpoint = makeCheckpoint([
|
|
168
180
|
block
|
|
169
181
|
], CheckpointNumber.fromBlockNumber(BlockNumber(blockNumber)));
|
|
170
182
|
return makePublishedCheckpoint(checkpoint, blockNumber);
|
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.684755437",
|
|
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.684755437",
|
|
69
|
+
"@aztec/blob-lib": "0.0.1-commit.684755437",
|
|
70
|
+
"@aztec/constants": "0.0.1-commit.684755437",
|
|
71
|
+
"@aztec/epoch-cache": "0.0.1-commit.684755437",
|
|
72
|
+
"@aztec/ethereum": "0.0.1-commit.684755437",
|
|
73
|
+
"@aztec/foundation": "0.0.1-commit.684755437",
|
|
74
|
+
"@aztec/kv-store": "0.0.1-commit.684755437",
|
|
75
|
+
"@aztec/l1-artifacts": "0.0.1-commit.684755437",
|
|
76
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.684755437",
|
|
77
|
+
"@aztec/protocol-contracts": "0.0.1-commit.684755437",
|
|
78
|
+
"@aztec/stdlib": "0.0.1-commit.684755437",
|
|
79
|
+
"@aztec/telemetry-client": "0.0.1-commit.684755437",
|
|
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
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { BlobClientInterface } from '@aztec/blob-client/client';
|
|
2
|
-
import { GENESIS_BLOCK_HEADER_HASH, INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
3
2
|
import { EpochCache } from '@aztec/epoch-cache';
|
|
4
3
|
import { BlockTagTooOldError, RollupContract } from '@aztec/ethereum/contracts';
|
|
5
4
|
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
@@ -15,8 +14,6 @@ import { RunningPromise, makeLoggingErrorHandler } from '@aztec/foundation/runni
|
|
|
15
14
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
16
15
|
import {
|
|
17
16
|
type ArchiverEmitter,
|
|
18
|
-
type CheckpointId,
|
|
19
|
-
GENESIS_CHECKPOINT_HEADER_HASH,
|
|
20
17
|
L2Block,
|
|
21
18
|
type L2BlockSink,
|
|
22
19
|
type L2Tips,
|
|
@@ -41,6 +38,7 @@ import { ArchiverDataStoreUpdater } from './modules/data_store_updater.js';
|
|
|
41
38
|
import type { ArchiverInstrumentation } from './modules/instrumentation.js';
|
|
42
39
|
import type { ArchiverL1Synchronizer } from './modules/l1_synchronizer.js';
|
|
43
40
|
import type { KVArchiverDataStore } from './store/kv_archiver_store.js';
|
|
41
|
+
import { L2TipsCache } from './store/l2_tips_cache.js';
|
|
44
42
|
|
|
45
43
|
/** Export ArchiverEmitter for use in factory and tests. */
|
|
46
44
|
export type { ArchiverEmitter };
|
|
@@ -83,6 +81,9 @@ export class Archiver extends ArchiverDataSourceBase implements L2BlockSink, Tra
|
|
|
83
81
|
/** Helper to handle updates to the store */
|
|
84
82
|
private readonly updater: ArchiverDataStoreUpdater;
|
|
85
83
|
|
|
84
|
+
/** In-memory cache for L2 chain tips. */
|
|
85
|
+
private readonly l2TipsCache: L2TipsCache;
|
|
86
|
+
|
|
86
87
|
public readonly tracer: Tracer;
|
|
87
88
|
|
|
88
89
|
/**
|
|
@@ -119,9 +120,14 @@ export class Archiver extends ArchiverDataSourceBase implements L2BlockSink, Tra
|
|
|
119
120
|
},
|
|
120
121
|
private readonly blobClient: BlobClientInterface,
|
|
121
122
|
instrumentation: ArchiverInstrumentation,
|
|
122
|
-
protected override readonly l1Constants: L1RollupConstants & {
|
|
123
|
+
protected override readonly l1Constants: L1RollupConstants & {
|
|
124
|
+
l1StartBlockHash: Buffer32;
|
|
125
|
+
genesisArchiveRoot: Fr;
|
|
126
|
+
rollupManaLimit?: number;
|
|
127
|
+
},
|
|
123
128
|
synchronizer: ArchiverL1Synchronizer,
|
|
124
129
|
events: ArchiverEmitter,
|
|
130
|
+
l2TipsCache?: L2TipsCache,
|
|
125
131
|
private readonly log: Logger = createLogger('archiver'),
|
|
126
132
|
) {
|
|
127
133
|
super(dataStore, l1Constants);
|
|
@@ -130,7 +136,10 @@ export class Archiver extends ArchiverDataSourceBase implements L2BlockSink, Tra
|
|
|
130
136
|
this.initialSyncPromise = promiseWithResolvers();
|
|
131
137
|
this.synchronizer = synchronizer;
|
|
132
138
|
this.events = events;
|
|
133
|
-
this.
|
|
139
|
+
this.l2TipsCache = l2TipsCache ?? new L2TipsCache(this.dataStore.blockStore);
|
|
140
|
+
this.updater = new ArchiverDataStoreUpdater(this.dataStore, this.l2TipsCache, {
|
|
141
|
+
rollupManaLimit: l1Constants.rollupManaLimit,
|
|
142
|
+
});
|
|
134
143
|
|
|
135
144
|
// Running promise starts with a small interval inbetween runs, so all iterations needed for the initial sync
|
|
136
145
|
// are done as fast as possible. This then gets updated once the initial sync completes.
|
|
@@ -391,115 +400,11 @@ export class Archiver extends ArchiverDataSourceBase implements L2BlockSink, Tra
|
|
|
391
400
|
return true;
|
|
392
401
|
}
|
|
393
402
|
|
|
394
|
-
public
|
|
395
|
-
|
|
396
|
-
this.getBlockNumber(),
|
|
397
|
-
this.getProvenBlockNumber(),
|
|
398
|
-
this.getCheckpointedL2BlockNumber(),
|
|
399
|
-
this.getFinalizedL2BlockNumber(),
|
|
400
|
-
] as const);
|
|
401
|
-
|
|
402
|
-
const beforeInitialblockNumber = BlockNumber(INITIAL_L2_BLOCK_NUM - 1);
|
|
403
|
-
|
|
404
|
-
// Get the latest block header and checkpointed blocks for proven, finalised and checkpointed blocks
|
|
405
|
-
const [latestBlockHeader, provenCheckpointedBlock, finalizedCheckpointedBlock, checkpointedBlock] =
|
|
406
|
-
await Promise.all([
|
|
407
|
-
latestBlockNumber > beforeInitialblockNumber ? this.getBlockHeader(latestBlockNumber) : undefined,
|
|
408
|
-
provenBlockNumber > beforeInitialblockNumber ? this.getCheckpointedBlock(provenBlockNumber) : undefined,
|
|
409
|
-
finalizedBlockNumber > beforeInitialblockNumber ? this.getCheckpointedBlock(finalizedBlockNumber) : undefined,
|
|
410
|
-
checkpointedBlockNumber > beforeInitialblockNumber
|
|
411
|
-
? this.getCheckpointedBlock(checkpointedBlockNumber)
|
|
412
|
-
: undefined,
|
|
413
|
-
] as const);
|
|
414
|
-
|
|
415
|
-
if (latestBlockNumber > beforeInitialblockNumber && !latestBlockHeader) {
|
|
416
|
-
throw new Error(`Failed to retrieve latest block header for block ${latestBlockNumber}`);
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
// Checkpointed blocks must exist for proven, finalized and checkpointed tips if they are beyond the initial block number.
|
|
420
|
-
if (checkpointedBlockNumber > beforeInitialblockNumber && !checkpointedBlock?.block.header) {
|
|
421
|
-
throw new Error(
|
|
422
|
-
`Failed to retrieve checkpointed block header for block ${checkpointedBlockNumber} (latest block is ${latestBlockNumber})`,
|
|
423
|
-
);
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
if (provenBlockNumber > beforeInitialblockNumber && !provenCheckpointedBlock?.block.header) {
|
|
427
|
-
throw new Error(
|
|
428
|
-
`Failed to retrieve proven checkpointed for block ${provenBlockNumber} (latest block is ${latestBlockNumber})`,
|
|
429
|
-
);
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
if (finalizedBlockNumber > beforeInitialblockNumber && !finalizedCheckpointedBlock?.block.header) {
|
|
433
|
-
throw new Error(
|
|
434
|
-
`Failed to retrieve finalized block header for block ${finalizedBlockNumber} (latest block is ${latestBlockNumber})`,
|
|
435
|
-
);
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
const latestBlockHeaderHash = (await latestBlockHeader?.hash()) ?? GENESIS_BLOCK_HEADER_HASH;
|
|
439
|
-
const provenBlockHeaderHash = (await provenCheckpointedBlock?.block.header?.hash()) ?? GENESIS_BLOCK_HEADER_HASH;
|
|
440
|
-
const finalizedBlockHeaderHash =
|
|
441
|
-
(await finalizedCheckpointedBlock?.block.header?.hash()) ?? GENESIS_BLOCK_HEADER_HASH;
|
|
442
|
-
const checkpointedBlockHeaderHash = (await checkpointedBlock?.block.header?.hash()) ?? GENESIS_BLOCK_HEADER_HASH;
|
|
443
|
-
|
|
444
|
-
// Now attempt to retrieve checkpoints for proven, finalised and checkpointed blocks
|
|
445
|
-
const [[provenBlockCheckpoint], [finalizedBlockCheckpoint], [checkpointedBlockCheckpoint]] = await Promise.all([
|
|
446
|
-
provenCheckpointedBlock !== undefined
|
|
447
|
-
? await this.getCheckpoints(provenCheckpointedBlock?.checkpointNumber, 1)
|
|
448
|
-
: [undefined],
|
|
449
|
-
finalizedCheckpointedBlock !== undefined
|
|
450
|
-
? await this.getCheckpoints(finalizedCheckpointedBlock?.checkpointNumber, 1)
|
|
451
|
-
: [undefined],
|
|
452
|
-
checkpointedBlock !== undefined ? await this.getCheckpoints(checkpointedBlock?.checkpointNumber, 1) : [undefined],
|
|
453
|
-
]);
|
|
454
|
-
|
|
455
|
-
const initialcheckpointId: CheckpointId = {
|
|
456
|
-
number: CheckpointNumber.ZERO,
|
|
457
|
-
hash: GENESIS_CHECKPOINT_HEADER_HASH.toString(),
|
|
458
|
-
};
|
|
459
|
-
|
|
460
|
-
const makeCheckpointId = (checkpoint: PublishedCheckpoint | undefined) => {
|
|
461
|
-
if (checkpoint === undefined) {
|
|
462
|
-
return initialcheckpointId;
|
|
463
|
-
}
|
|
464
|
-
return {
|
|
465
|
-
number: checkpoint.checkpoint.number,
|
|
466
|
-
hash: checkpoint.checkpoint.hash().toString(),
|
|
467
|
-
};
|
|
468
|
-
};
|
|
469
|
-
|
|
470
|
-
const l2Tips: L2Tips = {
|
|
471
|
-
proposed: {
|
|
472
|
-
number: latestBlockNumber,
|
|
473
|
-
hash: latestBlockHeaderHash.toString(),
|
|
474
|
-
},
|
|
475
|
-
proven: {
|
|
476
|
-
block: {
|
|
477
|
-
number: provenBlockNumber,
|
|
478
|
-
hash: provenBlockHeaderHash.toString(),
|
|
479
|
-
},
|
|
480
|
-
checkpoint: makeCheckpointId(provenBlockCheckpoint),
|
|
481
|
-
},
|
|
482
|
-
finalized: {
|
|
483
|
-
block: {
|
|
484
|
-
number: finalizedBlockNumber,
|
|
485
|
-
hash: finalizedBlockHeaderHash.toString(),
|
|
486
|
-
},
|
|
487
|
-
checkpoint: makeCheckpointId(finalizedBlockCheckpoint),
|
|
488
|
-
},
|
|
489
|
-
checkpointed: {
|
|
490
|
-
block: {
|
|
491
|
-
number: checkpointedBlockNumber,
|
|
492
|
-
hash: checkpointedBlockHeaderHash.toString(),
|
|
493
|
-
},
|
|
494
|
-
checkpoint: makeCheckpointId(checkpointedBlockCheckpoint),
|
|
495
|
-
},
|
|
496
|
-
};
|
|
497
|
-
|
|
498
|
-
return l2Tips;
|
|
403
|
+
public getL2Tips(): Promise<L2Tips> {
|
|
404
|
+
return this.l2TipsCache.getL2Tips();
|
|
499
405
|
}
|
|
500
406
|
|
|
501
407
|
public async rollbackTo(targetL2BlockNumber: BlockNumber): Promise<void> {
|
|
502
|
-
// TODO(pw/mbps): This still assumes 1 block per checkpoint
|
|
503
408
|
const currentBlocks = await this.getL2Tips();
|
|
504
409
|
const currentL2Block = currentBlocks.proposed.number;
|
|
505
410
|
const currentProvenBlock = currentBlocks.proven.block.number;
|
|
@@ -511,8 +416,25 @@ export class Archiver extends ArchiverDataSourceBase implements L2BlockSink, Tra
|
|
|
511
416
|
if (!targetL2Block) {
|
|
512
417
|
throw new Error(`Target L2 block ${targetL2BlockNumber} not found`);
|
|
513
418
|
}
|
|
514
|
-
const targetL1BlockNumber = targetL2Block.l1.blockNumber;
|
|
515
419
|
const targetCheckpointNumber = targetL2Block.checkpointNumber;
|
|
420
|
+
|
|
421
|
+
// Rollback operates at checkpoint granularity: the target block must be the last block of its checkpoint.
|
|
422
|
+
const checkpointData = await this.store.getCheckpointData(targetCheckpointNumber);
|
|
423
|
+
if (checkpointData) {
|
|
424
|
+
const lastBlockInCheckpoint = BlockNumber(checkpointData.startBlock + checkpointData.blockCount - 1);
|
|
425
|
+
if (targetL2BlockNumber !== lastBlockInCheckpoint) {
|
|
426
|
+
const previousCheckpointBoundary =
|
|
427
|
+
checkpointData.startBlock > 1 ? BlockNumber(checkpointData.startBlock - 1) : BlockNumber(0);
|
|
428
|
+
throw new Error(
|
|
429
|
+
`Target L2 block ${targetL2BlockNumber} is not at a checkpoint boundary. ` +
|
|
430
|
+
`Checkpoint ${targetCheckpointNumber} spans blocks ${checkpointData.startBlock} to ${lastBlockInCheckpoint}. ` +
|
|
431
|
+
`Use block ${lastBlockInCheckpoint} to roll back to this checkpoint, ` +
|
|
432
|
+
`or block ${previousCheckpointBoundary} to roll back to the previous one.`,
|
|
433
|
+
);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
const targetL1BlockNumber = targetL2Block.l1.blockNumber;
|
|
516
438
|
const targetL1Block = await this.publicClient.getBlock({
|
|
517
439
|
blockNumber: targetL1BlockNumber,
|
|
518
440
|
includeTransactions: false,
|
|
@@ -531,13 +453,14 @@ export class Archiver extends ArchiverDataSourceBase implements L2BlockSink, Tra
|
|
|
531
453
|
await this.store.setCheckpointSynchedL1BlockNumber(targetL1BlockNumber);
|
|
532
454
|
await this.store.setMessageSynchedL1Block({ l1BlockNumber: targetL1BlockNumber, l1BlockHash: targetL1BlockHash });
|
|
533
455
|
if (targetL2BlockNumber < currentProvenBlock) {
|
|
534
|
-
this.log.info(`
|
|
535
|
-
await this.
|
|
456
|
+
this.log.info(`Rolling back proven L2 checkpoint to ${targetCheckpointNumber}`);
|
|
457
|
+
await this.updater.setProvenCheckpointNumber(targetCheckpointNumber);
|
|
536
458
|
}
|
|
537
459
|
// TODO(palla/reorg): Set the finalized block when we add support for it.
|
|
460
|
+
// const currentFinalizedBlock = currentBlocks.finalized.block.number;
|
|
538
461
|
// if (targetL2BlockNumber < currentFinalizedBlock) {
|
|
539
|
-
// this.log.info(`
|
|
540
|
-
// await this.
|
|
462
|
+
// this.log.info(`Rolling back finalized L2 checkpoint to ${targetCheckpointNumber}`);
|
|
463
|
+
// await this.updater.setFinalizedCheckpointNumber(targetCheckpointNumber);
|
|
541
464
|
// }
|
|
542
465
|
}
|
|
543
466
|
}
|
package/src/factory.ts
CHANGED
|
@@ -7,7 +7,6 @@ import { Buffer32 } from '@aztec/foundation/buffer';
|
|
|
7
7
|
import { merge } from '@aztec/foundation/collection';
|
|
8
8
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
9
9
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
10
|
-
import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
11
10
|
import { createStore } from '@aztec/kv-store/lmdb-v2';
|
|
12
11
|
import { protocolContractNames } from '@aztec/protocol-contracts';
|
|
13
12
|
import { BundledProtocolContractsProvider } from '@aztec/protocol-contracts/providers/bundle';
|
|
@@ -15,6 +14,7 @@ import { FunctionType, decodeFunctionSignature } from '@aztec/stdlib/abi';
|
|
|
15
14
|
import type { ArchiverEmitter } from '@aztec/stdlib/block';
|
|
16
15
|
import { type ContractClassPublic, computePublicBytecodeCommitment } from '@aztec/stdlib/contract';
|
|
17
16
|
import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
17
|
+
import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
|
|
18
18
|
import { getTelemetryClient } from '@aztec/telemetry-client';
|
|
19
19
|
|
|
20
20
|
import { EventEmitter } from 'events';
|
|
@@ -25,6 +25,7 @@ import { type ArchiverConfig, mapArchiverConfig } from './config.js';
|
|
|
25
25
|
import { ArchiverInstrumentation } from './modules/instrumentation.js';
|
|
26
26
|
import { ArchiverL1Synchronizer } from './modules/l1_synchronizer.js';
|
|
27
27
|
import { ARCHIVER_DB_VERSION, KVArchiverDataStore } from './store/kv_archiver_store.js';
|
|
28
|
+
import { L2TipsCache } from './store/l2_tips_cache.js';
|
|
28
29
|
|
|
29
30
|
export const ARCHIVER_STORE_NAME = 'archiver';
|
|
30
31
|
|
|
@@ -84,6 +85,7 @@ export async function createArchiver(
|
|
|
84
85
|
genesisArchiveRoot,
|
|
85
86
|
slashingProposerAddress,
|
|
86
87
|
targetCommitteeSize,
|
|
88
|
+
rollupManaLimit,
|
|
87
89
|
] = await Promise.all([
|
|
88
90
|
rollup.getL1StartBlock(),
|
|
89
91
|
rollup.getL1GenesisTime(),
|
|
@@ -91,6 +93,7 @@ export async function createArchiver(
|
|
|
91
93
|
rollup.getGenesisArchiveTreeRoot(),
|
|
92
94
|
rollup.getSlashingProposerAddress(),
|
|
93
95
|
rollup.getTargetCommitteeSize(),
|
|
96
|
+
rollup.getManaLimit(),
|
|
94
97
|
] as const);
|
|
95
98
|
|
|
96
99
|
const l1StartBlockHash = await publicClient
|
|
@@ -109,6 +112,7 @@ export async function createArchiver(
|
|
|
109
112
|
proofSubmissionEpochs: Number(proofSubmissionEpochs),
|
|
110
113
|
targetCommitteeSize,
|
|
111
114
|
genesisArchiveRoot: Fr.fromString(genesisArchiveRoot.toString()),
|
|
115
|
+
rollupManaLimit: Number(rollupManaLimit),
|
|
112
116
|
};
|
|
113
117
|
|
|
114
118
|
const archiverConfig = merge(
|
|
@@ -128,13 +132,15 @@ export async function createArchiver(
|
|
|
128
132
|
// Create the event emitter that will be shared by archiver and synchronizer
|
|
129
133
|
const events = new EventEmitter() as ArchiverEmitter;
|
|
130
134
|
|
|
135
|
+
// Create L2 tips cache shared by archiver and synchronizer
|
|
136
|
+
const l2TipsCache = new L2TipsCache(archiverStore.blockStore);
|
|
137
|
+
|
|
131
138
|
// Create the L1 synchronizer
|
|
132
139
|
const synchronizer = new ArchiverL1Synchronizer(
|
|
133
140
|
publicClient,
|
|
134
141
|
debugClient,
|
|
135
142
|
rollup,
|
|
136
143
|
inbox,
|
|
137
|
-
{ ...config.l1Contracts, slashingProposerAddress },
|
|
138
144
|
archiverStore,
|
|
139
145
|
archiverConfig,
|
|
140
146
|
deps.blobClient,
|
|
@@ -144,6 +150,8 @@ export async function createArchiver(
|
|
|
144
150
|
l1Constants,
|
|
145
151
|
events,
|
|
146
152
|
instrumentation.tracer,
|
|
153
|
+
l2TipsCache,
|
|
154
|
+
undefined, // log (use default)
|
|
147
155
|
);
|
|
148
156
|
|
|
149
157
|
const archiver = new Archiver(
|
|
@@ -158,6 +166,7 @@ export async function createArchiver(
|
|
|
158
166
|
l1Constants,
|
|
159
167
|
synchronizer,
|
|
160
168
|
events,
|
|
169
|
+
l2TipsCache,
|
|
161
170
|
);
|
|
162
171
|
|
|
163
172
|
await archiver.start(opts.blockUntilSync);
|
package/src/index.ts
CHANGED
|
@@ -8,5 +8,6 @@ export * from './config.js';
|
|
|
8
8
|
export { type L1PublishedData } from './structs/published.js';
|
|
9
9
|
export { KVArchiverDataStore, ARCHIVER_DB_VERSION } from './store/kv_archiver_store.js';
|
|
10
10
|
export { ContractInstanceStore } from './store/contract_instance_store.js';
|
|
11
|
+
export { L2TipsCache } from './store/l2_tips_cache.js';
|
|
11
12
|
|
|
12
13
|
export { retrieveCheckpointsFromRollup, retrieveL2ProofVerifiedEvents } from './l1/data_retrieval.js';
|
package/src/l1/README.md
CHANGED
|
@@ -5,29 +5,27 @@ Modules and classes to handle data retrieval from L1 for the archiver.
|
|
|
5
5
|
## Calldata Retriever
|
|
6
6
|
|
|
7
7
|
The sequencer publisher bundles multiple operations into a single multicall3 transaction for gas
|
|
8
|
-
efficiency.
|
|
8
|
+
efficiency. The archiver needs to extract the `propose` calldata from these bundled transactions
|
|
9
|
+
to reconstruct L2 blocks.
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
The retriever uses hash matching against `attestationsHash` and `payloadDigest` from the
|
|
12
|
+
`CheckpointProposed` L1 event to verify it has found the correct propose calldata. These hashes
|
|
13
|
+
are always required.
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
L2 blocks. This class needs to handle scenarios where the transaction was submitted via multicall3,
|
|
16
|
-
as well as alternative ways for submitting the `propose` call that other clients might use.
|
|
15
|
+
### Multicall3 Decoding with Hash Matching
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
First attempt to decode the transaction as a multicall3 `aggregate3` call with validation:
|
|
17
|
+
First attempt to decode the transaction as a multicall3 `aggregate3` call:
|
|
21
18
|
|
|
22
19
|
- Check if transaction is to multicall3 address (`0xcA11bde05977b3631167028862bE2a173976CA11`)
|
|
23
20
|
- Decode as `aggregate3(Call3[] calldata calls)`
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
- Find all calls matching the rollup contract address and the `propose` function selector
|
|
22
|
+
- Verify each candidate by computing `attestationsHash` (keccak256 of ABI-encoded attestations)
|
|
23
|
+
and `payloadDigest` (keccak256 of the consensus payload signing hash) and comparing against
|
|
24
|
+
expected values from the `CheckpointProposed` event
|
|
25
|
+
- Return the verified candidate (if multiple verify, return the first with a warning)
|
|
28
26
|
|
|
29
|
-
This
|
|
30
|
-
|
|
27
|
+
This approach works regardless of what other calls are in the multicall3 bundle, because hash
|
|
28
|
+
matching identifies the correct propose call without needing an allowlist.
|
|
31
29
|
|
|
32
30
|
### Direct Propose Call
|
|
33
31
|
|
|
@@ -35,64 +33,23 @@ Second attempt to decode the transaction as a direct `propose` call to the rollu
|
|
|
35
33
|
|
|
36
34
|
- Check if transaction is to the rollup address
|
|
37
35
|
- Decode as `propose` function call
|
|
38
|
-
- Verify
|
|
36
|
+
- Verify against expected hashes
|
|
39
37
|
- Return the transaction input as the propose calldata
|
|
40
38
|
|
|
41
|
-
This handles scenarios where clients submit transactions directly to the rollup contract without
|
|
42
|
-
using multicall3 for bundling. Any validation failure triggers fallback to the next step.
|
|
43
|
-
|
|
44
39
|
### Spire Proposer Call
|
|
45
40
|
|
|
46
|
-
Given existing attempts to route the call via the Spire proposer, we also check if the tx is
|
|
47
|
-
proposer known address
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
Similar as with the multicall3 check, we check that there are no other calls in the Spire proposer, so
|
|
51
|
-
we are absolutely sure that the only call is the successful one to the rollup. Any extraneous call would
|
|
52
|
-
imply an unexpected path to calling `propose` in the rollup contract, and since we cannot verify if the
|
|
53
|
-
calldata arguments we extracted are the correct ones (see the section below), we cannot know for sure which
|
|
54
|
-
one is the call that succeeded, so we don't know which calldata to process.
|
|
55
|
-
|
|
56
|
-
Furthermore, since the Spire proposer is upgradeable, we check if the implementation has not changed in
|
|
57
|
-
order to decode. As usual, any validation failure triggers fallback to the next step.
|
|
58
|
-
|
|
59
|
-
### Verifying Multicall3 Arguments
|
|
60
|
-
|
|
61
|
-
**This is NOT implemented for simplicity's sake**
|
|
62
|
-
|
|
63
|
-
If the checks above don't hold, such as when there are multiple calls to `propose`, then we cannot
|
|
64
|
-
reliably extract the `propose` calldata from the multicall3 arguments alone. We can try a best-effort
|
|
65
|
-
where we try all `propose` calls we see and validate them against on-chain data. Note that we can use these
|
|
66
|
-
same strategies if we were to obtain the calldata from another source.
|
|
67
|
-
|
|
68
|
-
#### TempBlockLog Verification
|
|
69
|
-
|
|
70
|
-
Read the stored `TempBlockLog` for the L2 block number from L1 and verify it matches our decoded header hash,
|
|
71
|
-
since the `TempBlockLog` stores the hash of the proposed block header, the payload commitment, and the attestations.
|
|
72
|
-
|
|
73
|
-
However, `TempBlockLog` is only stored temporarily and deleted after proven, so this method only works for recent
|
|
74
|
-
blocks, not for historical data syncing.
|
|
75
|
-
|
|
76
|
-
#### Archive Verification
|
|
77
|
-
|
|
78
|
-
Verify that the archive root in the decoded propose is correct with regard to the block header. This requires
|
|
79
|
-
hashing the block header we have retrieved, inserting it into the archive tree, and checking the resulting root
|
|
80
|
-
against the one we got from L1.
|
|
81
|
-
|
|
82
|
-
However, this requires that the archive keeps a reference to world-state, which is not the case in the current
|
|
83
|
-
system.
|
|
84
|
-
|
|
85
|
-
#### Emit Commitments in Rollup Contract
|
|
86
|
-
|
|
87
|
-
Modify rollup contract to emit commitments to the block header in the `L2BlockProposed` event, allowing us to easily
|
|
88
|
-
verify the calldata we obtained vs the emitted event.
|
|
41
|
+
Given existing attempts to route the call via the Spire proposer, we also check if the tx is
|
|
42
|
+
`to` the proposer known address. If so, we extract all wrapped calls and try each as either
|
|
43
|
+
a multicall3 or direct propose call, using hash matching to find and verify the correct one.
|
|
89
44
|
|
|
90
|
-
|
|
45
|
+
Since the Spire proposer is upgradeable, we check that the implementation has not changed in
|
|
46
|
+
order to decode. Any validation failure triggers fallback to the next step.
|
|
91
47
|
|
|
92
48
|
### Debug and Trace Transaction Fallback
|
|
93
49
|
|
|
94
|
-
Last, we use L1 node's trace/debug RPC methods to definitively identify the one successful
|
|
95
|
-
We can then extract the exact calldata that hit the `propose`
|
|
50
|
+
Last, we use L1 node's trace/debug RPC methods to definitively identify the one successful
|
|
51
|
+
`propose` call within the tx. We can then extract the exact calldata that hit the `propose`
|
|
52
|
+
function in the rollup contract.
|
|
96
53
|
|
|
97
|
-
This approach requires access to a debug-enabled L1 node, which may be more resource-intensive,
|
|
98
|
-
use it as a fallback when
|
|
54
|
+
This approach requires access to a debug-enabled L1 node, which may be more resource-intensive,
|
|
55
|
+
so we only use it as a fallback when earlier steps fail, which should be rare in practice.
|
|
@@ -5,7 +5,7 @@ import { EthAddress } from '@aztec/foundation/eth-address';
|
|
|
5
5
|
import { createLogger } from '@aztec/foundation/log';
|
|
6
6
|
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
7
7
|
|
|
8
|
-
import { type Hex, createPublicClient, getAbiItem, http, toEventSelector } from 'viem';
|
|
8
|
+
import { type Hex, createPublicClient, decodeEventLog, getAbiItem, http, toEventSelector } from 'viem';
|
|
9
9
|
import { mainnet } from 'viem/chains';
|
|
10
10
|
|
|
11
11
|
import { CalldataRetriever } from '../calldata_retriever.js';
|
|
@@ -89,14 +89,6 @@ async function main() {
|
|
|
89
89
|
|
|
90
90
|
logger.info(`Transaction found in block ${tx.blockNumber}`);
|
|
91
91
|
|
|
92
|
-
// For simplicity, use zero addresses for optional contract addresses
|
|
93
|
-
// In production, these would be fetched from the rollup contract or configuration
|
|
94
|
-
const slashingProposerAddress = EthAddress.ZERO;
|
|
95
|
-
const governanceProposerAddress = EthAddress.ZERO;
|
|
96
|
-
const slashFactoryAddress = undefined;
|
|
97
|
-
|
|
98
|
-
logger.info('Using zero addresses for governance/slashing (can be configured if needed)');
|
|
99
|
-
|
|
100
92
|
// Create CalldataRetriever
|
|
101
93
|
const retriever = new CalldataRetriever(
|
|
102
94
|
publicClient as unknown as ViemPublicClient,
|
|
@@ -104,46 +96,67 @@ async function main() {
|
|
|
104
96
|
targetCommitteeSize,
|
|
105
97
|
undefined,
|
|
106
98
|
logger,
|
|
107
|
-
|
|
108
|
-
rollupAddress,
|
|
109
|
-
governanceProposerAddress,
|
|
110
|
-
slashingProposerAddress,
|
|
111
|
-
slashFactoryAddress,
|
|
112
|
-
},
|
|
99
|
+
rollupAddress,
|
|
113
100
|
);
|
|
114
101
|
|
|
115
|
-
// Extract checkpoint number from transaction logs
|
|
116
|
-
logger.info('Decoding transaction to extract checkpoint number...');
|
|
102
|
+
// Extract checkpoint number and hashes from transaction logs
|
|
103
|
+
logger.info('Decoding transaction to extract checkpoint number and hashes...');
|
|
117
104
|
const receipt = await publicClient.getTransactionReceipt({ hash: txHash });
|
|
118
105
|
|
|
119
|
-
// Look for CheckpointProposed event
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const checkpointProposedEvent = receipt.logs.find(log => {
|
|
106
|
+
// Look for CheckpointProposed event
|
|
107
|
+
const checkpointProposedEventAbi = getAbiItem({ abi: RollupAbi, name: 'CheckpointProposed' });
|
|
108
|
+
const checkpointProposedLog = receipt.logs.find(log => {
|
|
123
109
|
try {
|
|
124
110
|
return (
|
|
125
111
|
log.address.toLowerCase() === rollupAddress.toString().toLowerCase() &&
|
|
126
|
-
log.topics[0] === toEventSelector(
|
|
112
|
+
log.topics[0] === toEventSelector(checkpointProposedEventAbi)
|
|
127
113
|
);
|
|
128
114
|
} catch {
|
|
129
115
|
return false;
|
|
130
116
|
}
|
|
131
117
|
});
|
|
132
118
|
|
|
133
|
-
if (!
|
|
119
|
+
if (!checkpointProposedLog || checkpointProposedLog.topics[1] === undefined) {
|
|
134
120
|
throw new Error(`Checkpoint proposed event not found`);
|
|
135
121
|
}
|
|
136
122
|
|
|
137
|
-
const checkpointNumber = CheckpointNumber.fromBigInt(BigInt(
|
|
123
|
+
const checkpointNumber = CheckpointNumber.fromBigInt(BigInt(checkpointProposedLog.topics[1]));
|
|
124
|
+
|
|
125
|
+
// Decode the full event to extract attestationsHash and payloadDigest
|
|
126
|
+
const decodedEvent = decodeEventLog({
|
|
127
|
+
abi: RollupAbi,
|
|
128
|
+
data: checkpointProposedLog.data,
|
|
129
|
+
topics: checkpointProposedLog.topics,
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
const eventArgs = decodedEvent.args as {
|
|
133
|
+
checkpointNumber: bigint;
|
|
134
|
+
archive: Hex;
|
|
135
|
+
versionedBlobHashes: Hex[];
|
|
136
|
+
attestationsHash: Hex;
|
|
137
|
+
payloadDigest: Hex;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
if (!eventArgs.attestationsHash || !eventArgs.payloadDigest) {
|
|
141
|
+
throw new Error(`CheckpointProposed event missing attestationsHash or payloadDigest`);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const expectedHashes = {
|
|
145
|
+
attestationsHash: eventArgs.attestationsHash,
|
|
146
|
+
payloadDigest: eventArgs.payloadDigest,
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
logger.info(`Checkpoint Number: ${checkpointNumber}`);
|
|
150
|
+
logger.info(`Attestations Hash: ${expectedHashes.attestationsHash}`);
|
|
151
|
+
logger.info(`Payload Digest: ${expectedHashes.payloadDigest}`);
|
|
138
152
|
|
|
139
153
|
logger.info('');
|
|
140
154
|
logger.info('Retrieving checkpoint from rollup transaction...');
|
|
141
155
|
logger.info('');
|
|
142
156
|
|
|
143
|
-
|
|
144
|
-
const result = await retriever.getCheckpointFromRollupTx(txHash, [], checkpointNumber, {});
|
|
157
|
+
const result = await retriever.getCheckpointFromRollupTx(txHash, [], checkpointNumber, expectedHashes);
|
|
145
158
|
|
|
146
|
-
logger.info('
|
|
159
|
+
logger.info(' Successfully retrieved block header!');
|
|
147
160
|
logger.info('');
|
|
148
161
|
logger.info('Block Header Details:');
|
|
149
162
|
logger.info('====================');
|