@aztec/archiver 0.0.1-commit.cf93bcc56 → 0.0.1-commit.d0fcfb7f
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 +3 -3
- package/dest/archiver.d.ts.map +1 -1
- package/dest/archiver.js +46 -14
- package/dest/factory.d.ts +1 -1
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +6 -7
- package/dest/l1/bin/retrieve-calldata.js +32 -28
- package/dest/l1/calldata_retriever.d.ts +70 -53
- package/dest/l1/calldata_retriever.d.ts.map +1 -1
- package/dest/l1/calldata_retriever.js +178 -260
- package/dest/l1/data_retrieval.d.ts +2 -6
- package/dest/l1/data_retrieval.d.ts.map +1 -1
- package/dest/l1/data_retrieval.js +6 -11
- 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 +3 -3
- package/dest/modules/data_source_base.d.ts.map +1 -1
- package/dest/modules/data_source_base.js +1 -1
- package/dest/modules/data_store_updater.d.ts +6 -3
- package/dest/modules/data_store_updater.d.ts.map +1 -1
- package/dest/modules/data_store_updater.js +10 -2
- package/dest/modules/l1_synchronizer.d.ts +2 -7
- package/dest/modules/l1_synchronizer.d.ts.map +1 -1
- package/dest/modules/l1_synchronizer.js +6 -6
- package/dest/store/block_store.d.ts +5 -5
- package/dest/store/block_store.d.ts.map +1 -1
- package/dest/store/block_store.js +10 -7
- package/dest/store/kv_archiver_store.d.ts +2 -2
- package/dest/store/kv_archiver_store.d.ts.map +1 -1
- package/dest/store/kv_archiver_store.js +2 -2
- package/dest/store/log_store.d.ts +1 -1
- package/dest/store/log_store.d.ts.map +1 -1
- package/dest/store/log_store.js +19 -1
- package/dest/store/message_store.js +1 -1
- package/dest/test/fake_l1_state.d.ts +3 -1
- package/dest/test/fake_l1_state.d.ts.map +1 -1
- package/dest/test/fake_l1_state.js +42 -10
- package/dest/test/mock_l2_block_source.d.ts +4 -3
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +7 -4
- 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/dest/test/noop_l1_archiver.d.ts +4 -1
- package/dest/test/noop_l1_archiver.d.ts.map +1 -1
- package/dest/test/noop_l1_archiver.js +5 -1
- package/package.json +13 -13
- package/src/archiver.ts +57 -17
- package/src/factory.ts +3 -1
- package/src/l1/README.md +25 -68
- package/src/l1/bin/retrieve-calldata.ts +40 -27
- package/src/l1/calldata_retriever.ts +231 -383
- package/src/l1/data_retrieval.ts +3 -16
- package/src/l1/spire_proposer.ts +7 -15
- package/src/modules/data_source_base.ts +3 -3
- package/src/modules/data_store_updater.ts +7 -2
- package/src/modules/l1_synchronizer.ts +8 -10
- package/src/store/block_store.ts +14 -6
- package/src/store/kv_archiver_store.ts +5 -2
- package/src/store/log_store.ts +24 -1
- package/src/store/message_store.ts +1 -1
- package/src/test/fake_l1_state.ts +60 -10
- package/src/test/mock_l2_block_source.ts +15 -3
- package/src/test/mock_structs.ts +20 -6
- package/src/test/noop_l1_archiver.ts +7 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
4
|
import { getTelemetryClient } from '@aztec/telemetry-client';
|
|
@@ -15,7 +16,7 @@ import { ArchiverInstrumentation } from '../modules/instrumentation.js';
|
|
|
15
16
|
return 0n;
|
|
16
17
|
}
|
|
17
18
|
getL1Timestamp() {
|
|
18
|
-
return
|
|
19
|
+
return undefined;
|
|
19
20
|
}
|
|
20
21
|
testEthereumNodeSynced() {
|
|
21
22
|
return Promise.resolve();
|
|
@@ -61,6 +62,9 @@ import { ArchiverInstrumentation } from '../modules/instrumentation.js';
|
|
|
61
62
|
this.runningPromise.start();
|
|
62
63
|
return Promise.resolve();
|
|
63
64
|
}
|
|
65
|
+
/** Always reports as fully synced since there is no real L1 to sync from. */ getSyncedL2SlotNumber() {
|
|
66
|
+
return Promise.resolve(SlotNumber(Number.MAX_SAFE_INTEGER));
|
|
67
|
+
}
|
|
64
68
|
}
|
|
65
69
|
/** Creates an archiver with mocked L1 connectivity for testing. */ export async function createNoopL1Archiver(dataStore, l1Constants, telemetry = getTelemetryClient()) {
|
|
66
70
|
const instrumentation = await ArchiverInstrumentation.new(telemetry, ()=>dataStore.estimateSize());
|
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.d0fcfb7f",
|
|
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.d0fcfb7f",
|
|
69
|
+
"@aztec/blob-lib": "0.0.1-commit.d0fcfb7f",
|
|
70
|
+
"@aztec/constants": "0.0.1-commit.d0fcfb7f",
|
|
71
|
+
"@aztec/epoch-cache": "0.0.1-commit.d0fcfb7f",
|
|
72
|
+
"@aztec/ethereum": "0.0.1-commit.d0fcfb7f",
|
|
73
|
+
"@aztec/foundation": "0.0.1-commit.d0fcfb7f",
|
|
74
|
+
"@aztec/kv-store": "0.0.1-commit.d0fcfb7f",
|
|
75
|
+
"@aztec/l1-artifacts": "0.0.1-commit.d0fcfb7f",
|
|
76
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.d0fcfb7f",
|
|
77
|
+
"@aztec/protocol-contracts": "0.0.1-commit.d0fcfb7f",
|
|
78
|
+
"@aztec/stdlib": "0.0.1-commit.d0fcfb7f",
|
|
79
|
+
"@aztec/telemetry-client": "0.0.1-commit.d0fcfb7f",
|
|
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
|
@@ -22,9 +22,8 @@ import {
|
|
|
22
22
|
import { PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
23
23
|
import {
|
|
24
24
|
type L1RollupConstants,
|
|
25
|
-
|
|
25
|
+
getEpochAtSlot,
|
|
26
26
|
getSlotAtNextL1Block,
|
|
27
|
-
getSlotAtTimestamp,
|
|
28
27
|
getSlotRangeForEpoch,
|
|
29
28
|
getTimestampRangeForEpoch,
|
|
30
29
|
} from '@aztec/stdlib/epoch-helpers';
|
|
@@ -120,7 +119,10 @@ export class Archiver extends ArchiverDataSourceBase implements L2BlockSink, Tra
|
|
|
120
119
|
},
|
|
121
120
|
private readonly blobClient: BlobClientInterface,
|
|
122
121
|
instrumentation: ArchiverInstrumentation,
|
|
123
|
-
protected override readonly l1Constants: L1RollupConstants & {
|
|
122
|
+
protected override readonly l1Constants: L1RollupConstants & {
|
|
123
|
+
l1StartBlockHash: Buffer32;
|
|
124
|
+
genesisArchiveRoot: Fr;
|
|
125
|
+
},
|
|
124
126
|
synchronizer: ArchiverL1Synchronizer,
|
|
125
127
|
events: ArchiverEmitter,
|
|
126
128
|
l2TipsCache?: L2TipsCache,
|
|
@@ -133,7 +135,9 @@ export class Archiver extends ArchiverDataSourceBase implements L2BlockSink, Tra
|
|
|
133
135
|
this.synchronizer = synchronizer;
|
|
134
136
|
this.events = events;
|
|
135
137
|
this.l2TipsCache = l2TipsCache ?? new L2TipsCache(this.dataStore.blockStore);
|
|
136
|
-
this.updater = new ArchiverDataStoreUpdater(this.dataStore, this.l2TipsCache
|
|
138
|
+
this.updater = new ArchiverDataStoreUpdater(this.dataStore, this.l2TipsCache, {
|
|
139
|
+
rollupManaLimit: l1Constants.rollupManaLimit,
|
|
140
|
+
});
|
|
137
141
|
|
|
138
142
|
// Running promise starts with a small interval inbetween runs, so all iterations needed for the initial sync
|
|
139
143
|
// are done as fast as possible. This then gets updated once the initial sync completes.
|
|
@@ -333,16 +337,35 @@ export class Archiver extends ArchiverDataSourceBase implements L2BlockSink, Tra
|
|
|
333
337
|
return Promise.resolve(this.synchronizer.getL1Timestamp());
|
|
334
338
|
}
|
|
335
339
|
|
|
336
|
-
public
|
|
340
|
+
public getSyncedL2SlotNumber(): Promise<SlotNumber | undefined> {
|
|
337
341
|
const l1Timestamp = this.synchronizer.getL1Timestamp();
|
|
338
|
-
|
|
342
|
+
if (l1Timestamp === undefined) {
|
|
343
|
+
return Promise.resolve(undefined);
|
|
344
|
+
}
|
|
345
|
+
// The synced slot is the last L2 slot whose all L1 blocks have been processed.
|
|
346
|
+
// If the next L1 block (at l1Timestamp + ethereumSlotDuration) falls in slot N,
|
|
347
|
+
// then we've fully synced slot N-1.
|
|
348
|
+
const nextL1BlockSlot = getSlotAtNextL1Block(l1Timestamp, this.l1Constants);
|
|
349
|
+
if (Number(nextL1BlockSlot) === 0) {
|
|
350
|
+
return Promise.resolve(undefined);
|
|
351
|
+
}
|
|
352
|
+
return Promise.resolve(SlotNumber(nextL1BlockSlot - 1));
|
|
339
353
|
}
|
|
340
354
|
|
|
341
|
-
public
|
|
342
|
-
const
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
355
|
+
public async getSyncedL2EpochNumber(): Promise<EpochNumber | undefined> {
|
|
356
|
+
const syncedSlot = await this.getSyncedL2SlotNumber();
|
|
357
|
+
if (syncedSlot === undefined) {
|
|
358
|
+
return undefined;
|
|
359
|
+
}
|
|
360
|
+
// An epoch is fully synced when all its slots are synced.
|
|
361
|
+
// We check if syncedSlot is the last slot of its epoch; if so, that epoch is fully synced.
|
|
362
|
+
// Otherwise, only the previous epoch is fully synced.
|
|
363
|
+
const epoch = getEpochAtSlot(syncedSlot, this.l1Constants);
|
|
364
|
+
const [, endSlot] = getSlotRangeForEpoch(epoch, this.l1Constants);
|
|
365
|
+
if (syncedSlot >= endSlot) {
|
|
366
|
+
return epoch;
|
|
367
|
+
}
|
|
368
|
+
return Number(epoch) > 0 ? EpochNumber(Number(epoch) - 1) : undefined;
|
|
346
369
|
}
|
|
347
370
|
|
|
348
371
|
public async isEpochComplete(epochNumber: EpochNumber): Promise<boolean> {
|
|
@@ -399,7 +422,6 @@ export class Archiver extends ArchiverDataSourceBase implements L2BlockSink, Tra
|
|
|
399
422
|
}
|
|
400
423
|
|
|
401
424
|
public async rollbackTo(targetL2BlockNumber: BlockNumber): Promise<void> {
|
|
402
|
-
// TODO(pw/mbps): This still assumes 1 block per checkpoint
|
|
403
425
|
const currentBlocks = await this.getL2Tips();
|
|
404
426
|
const currentL2Block = currentBlocks.proposed.number;
|
|
405
427
|
const currentProvenBlock = currentBlocks.proven.block.number;
|
|
@@ -411,8 +433,25 @@ export class Archiver extends ArchiverDataSourceBase implements L2BlockSink, Tra
|
|
|
411
433
|
if (!targetL2Block) {
|
|
412
434
|
throw new Error(`Target L2 block ${targetL2BlockNumber} not found`);
|
|
413
435
|
}
|
|
414
|
-
const targetL1BlockNumber = targetL2Block.l1.blockNumber;
|
|
415
436
|
const targetCheckpointNumber = targetL2Block.checkpointNumber;
|
|
437
|
+
|
|
438
|
+
// Rollback operates at checkpoint granularity: the target block must be the last block of its checkpoint.
|
|
439
|
+
const checkpointData = await this.store.getCheckpointData(targetCheckpointNumber);
|
|
440
|
+
if (checkpointData) {
|
|
441
|
+
const lastBlockInCheckpoint = BlockNumber(checkpointData.startBlock + checkpointData.blockCount - 1);
|
|
442
|
+
if (targetL2BlockNumber !== lastBlockInCheckpoint) {
|
|
443
|
+
const previousCheckpointBoundary =
|
|
444
|
+
checkpointData.startBlock > 1 ? BlockNumber(checkpointData.startBlock - 1) : BlockNumber(0);
|
|
445
|
+
throw new Error(
|
|
446
|
+
`Target L2 block ${targetL2BlockNumber} is not at a checkpoint boundary. ` +
|
|
447
|
+
`Checkpoint ${targetCheckpointNumber} spans blocks ${checkpointData.startBlock} to ${lastBlockInCheckpoint}. ` +
|
|
448
|
+
`Use block ${lastBlockInCheckpoint} to roll back to this checkpoint, ` +
|
|
449
|
+
`or block ${previousCheckpointBoundary} to roll back to the previous one.`,
|
|
450
|
+
);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
const targetL1BlockNumber = targetL2Block.l1.blockNumber;
|
|
416
455
|
const targetL1Block = await this.publicClient.getBlock({
|
|
417
456
|
blockNumber: targetL1BlockNumber,
|
|
418
457
|
includeTransactions: false,
|
|
@@ -431,13 +470,14 @@ export class Archiver extends ArchiverDataSourceBase implements L2BlockSink, Tra
|
|
|
431
470
|
await this.store.setCheckpointSynchedL1BlockNumber(targetL1BlockNumber);
|
|
432
471
|
await this.store.setMessageSynchedL1Block({ l1BlockNumber: targetL1BlockNumber, l1BlockHash: targetL1BlockHash });
|
|
433
472
|
if (targetL2BlockNumber < currentProvenBlock) {
|
|
434
|
-
this.log.info(`
|
|
435
|
-
await this.updater.setProvenCheckpointNumber(
|
|
473
|
+
this.log.info(`Rolling back proven L2 checkpoint to ${targetCheckpointNumber}`);
|
|
474
|
+
await this.updater.setProvenCheckpointNumber(targetCheckpointNumber);
|
|
436
475
|
}
|
|
437
476
|
// TODO(palla/reorg): Set the finalized block when we add support for it.
|
|
477
|
+
// const currentFinalizedBlock = currentBlocks.finalized.block.number;
|
|
438
478
|
// if (targetL2BlockNumber < currentFinalizedBlock) {
|
|
439
|
-
// this.log.info(`
|
|
440
|
-
// await this.
|
|
479
|
+
// this.log.info(`Rolling back finalized L2 checkpoint to ${targetCheckpointNumber}`);
|
|
480
|
+
// await this.updater.setFinalizedCheckpointNumber(targetCheckpointNumber);
|
|
441
481
|
// }
|
|
442
482
|
}
|
|
443
483
|
}
|
package/src/factory.ts
CHANGED
|
@@ -85,6 +85,7 @@ export async function createArchiver(
|
|
|
85
85
|
genesisArchiveRoot,
|
|
86
86
|
slashingProposerAddress,
|
|
87
87
|
targetCommitteeSize,
|
|
88
|
+
rollupManaLimit,
|
|
88
89
|
] = await Promise.all([
|
|
89
90
|
rollup.getL1StartBlock(),
|
|
90
91
|
rollup.getL1GenesisTime(),
|
|
@@ -92,6 +93,7 @@ export async function createArchiver(
|
|
|
92
93
|
rollup.getGenesisArchiveTreeRoot(),
|
|
93
94
|
rollup.getSlashingProposerAddress(),
|
|
94
95
|
rollup.getTargetCommitteeSize(),
|
|
96
|
+
rollup.getManaLimit(),
|
|
95
97
|
] as const);
|
|
96
98
|
|
|
97
99
|
const l1StartBlockHash = await publicClient
|
|
@@ -110,6 +112,7 @@ export async function createArchiver(
|
|
|
110
112
|
proofSubmissionEpochs: Number(proofSubmissionEpochs),
|
|
111
113
|
targetCommitteeSize,
|
|
112
114
|
genesisArchiveRoot: Fr.fromString(genesisArchiveRoot.toString()),
|
|
115
|
+
rollupManaLimit: Number(rollupManaLimit),
|
|
113
116
|
};
|
|
114
117
|
|
|
115
118
|
const archiverConfig = merge(
|
|
@@ -138,7 +141,6 @@ export async function createArchiver(
|
|
|
138
141
|
debugClient,
|
|
139
142
|
rollup,
|
|
140
143
|
inbox,
|
|
141
|
-
{ ...config.l1Contracts, slashingProposerAddress },
|
|
142
144
|
archiverStore,
|
|
143
145
|
archiverConfig,
|
|
144
146
|
deps.blobClient,
|
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('====================');
|