@aztec/archiver 0.0.1-commit.2b2662070 → 0.0.1-commit.2c0ee1788
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 +17 -10
- package/dest/archiver.d.ts.map +1 -1
- package/dest/archiver.js +92 -53
- package/dest/config.d.ts +3 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +14 -3
- package/dest/errors.d.ts +32 -5
- package/dest/errors.d.ts.map +1 -1
- package/dest/errors.js +51 -6
- package/dest/factory.d.ts +4 -4
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +13 -10
- package/dest/index.d.ts +10 -3
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +9 -2
- package/dest/l1/calldata_retriever.d.ts +2 -1
- package/dest/l1/calldata_retriever.d.ts.map +1 -1
- package/dest/l1/calldata_retriever.js +9 -4
- package/dest/l1/data_retrieval.d.ts +18 -9
- package/dest/l1/data_retrieval.d.ts.map +1 -1
- package/dest/l1/data_retrieval.js +13 -19
- package/dest/l1/validate_historical_logs.d.ts +23 -0
- package/dest/l1/validate_historical_logs.d.ts.map +1 -0
- package/dest/l1/validate_historical_logs.js +108 -0
- package/dest/modules/contract_data_source_adapter.d.ts +25 -0
- package/dest/modules/contract_data_source_adapter.d.ts.map +1 -0
- package/dest/modules/contract_data_source_adapter.js +42 -0
- package/dest/modules/data_source_base.d.ts +16 -10
- package/dest/modules/data_source_base.d.ts.map +1 -1
- package/dest/modules/data_source_base.js +71 -60
- package/dest/modules/data_store_updater.d.ts +16 -9
- package/dest/modules/data_store_updater.d.ts.map +1 -1
- package/dest/modules/data_store_updater.js +52 -40
- package/dest/modules/instrumentation.d.ts +4 -1
- package/dest/modules/instrumentation.d.ts.map +1 -1
- package/dest/modules/instrumentation.js +5 -0
- package/dest/modules/l1_synchronizer.d.ts +8 -4
- package/dest/modules/l1_synchronizer.d.ts.map +1 -1
- package/dest/modules/l1_synchronizer.js +182 -70
- package/dest/modules/validation.d.ts +4 -3
- package/dest/modules/validation.d.ts.map +1 -1
- package/dest/modules/validation.js +4 -4
- package/dest/store/block_store.d.ts +59 -21
- package/dest/store/block_store.d.ts.map +1 -1
- package/dest/store/block_store.js +181 -66
- package/dest/store/contract_class_store.d.ts +17 -3
- package/dest/store/contract_class_store.d.ts.map +1 -1
- package/dest/store/contract_class_store.js +17 -1
- package/dest/store/contract_instance_store.d.ts +28 -1
- package/dest/store/contract_instance_store.d.ts.map +1 -1
- package/dest/store/contract_instance_store.js +31 -0
- package/dest/store/data_stores.d.ts +68 -0
- package/dest/store/data_stores.d.ts.map +1 -0
- package/dest/store/data_stores.js +50 -0
- package/dest/store/function_names_cache.d.ts +17 -0
- package/dest/store/function_names_cache.d.ts.map +1 -0
- package/dest/store/function_names_cache.js +30 -0
- package/dest/store/l2_tips_cache.js +1 -1
- package/dest/test/fake_l1_state.d.ts +7 -3
- package/dest/test/fake_l1_state.d.ts.map +1 -1
- package/dest/test/fake_l1_state.js +42 -15
- package/dest/test/mock_l2_block_source.d.ts +12 -3
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +24 -2
- package/dest/test/noop_l1_archiver.d.ts +4 -4
- package/dest/test/noop_l1_archiver.d.ts.map +1 -1
- package/dest/test/noop_l1_archiver.js +9 -6
- package/package.json +13 -13
- package/src/archiver.ts +108 -50
- package/src/config.ts +15 -1
- package/src/errors.ts +75 -8
- package/src/factory.ts +11 -10
- package/src/index.ts +17 -2
- package/src/l1/calldata_retriever.ts +15 -4
- package/src/l1/data_retrieval.ts +30 -35
- package/src/l1/validate_historical_logs.ts +140 -0
- package/src/modules/contract_data_source_adapter.ts +59 -0
- package/src/modules/data_source_base.ts +75 -57
- package/src/modules/data_store_updater.ts +71 -39
- package/src/modules/instrumentation.ts +8 -0
- package/src/modules/l1_synchronizer.ts +241 -71
- package/src/modules/validation.ts +8 -7
- package/src/store/block_store.ts +204 -73
- package/src/store/contract_class_store.ts +28 -2
- package/src/store/contract_instance_store.ts +43 -0
- package/src/store/data_stores.ts +108 -0
- package/src/store/function_names_cache.ts +37 -0
- package/src/store/l2_tips_cache.ts +1 -1
- package/src/test/fake_l1_state.ts +47 -24
- package/src/test/mock_l2_block_source.ts +23 -2
- package/src/test/noop_l1_archiver.ts +9 -6
- package/dest/store/kv_archiver_store.d.ts +0 -377
- package/dest/store/kv_archiver_store.d.ts.map +0 -1
- package/dest/store/kv_archiver_store.js +0 -494
- package/src/store/kv_archiver_store.ts +0 -713
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { L1BlockId } from '@aztec/ethereum/l1-types';
|
|
2
|
+
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
3
|
+
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
4
|
+
|
|
5
|
+
import { join } from 'path';
|
|
6
|
+
|
|
7
|
+
import { ArchiverContractDataSourceAdapter } from '../modules/contract_data_source_adapter.js';
|
|
8
|
+
import { BlockStore } from './block_store.js';
|
|
9
|
+
import { ContractClassStore } from './contract_class_store.js';
|
|
10
|
+
import { ContractInstanceStore } from './contract_instance_store.js';
|
|
11
|
+
import { FunctionNamesCache } from './function_names_cache.js';
|
|
12
|
+
import { LogStore } from './log_store.js';
|
|
13
|
+
import { MessageStore } from './message_store.js';
|
|
14
|
+
|
|
15
|
+
export const ARCHIVER_DB_VERSION = 6;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Represents the latest L1 block processed by the archiver for various objects in L2.
|
|
19
|
+
*/
|
|
20
|
+
export type ArchiverL1SynchPoint = {
|
|
21
|
+
/** Number of the last L1 block that added a new L2 checkpoint metadata. */
|
|
22
|
+
blocksSynchedTo?: bigint;
|
|
23
|
+
/** Last L1 block checked for L1 to L2 messages. */
|
|
24
|
+
messagesSynchedTo?: L1BlockId;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Bundle of archiver-owned LMDB substores plus the in-memory caches that span them.
|
|
29
|
+
*
|
|
30
|
+
* Replaces the former `KVArchiverDataStore` pass-through wrapper. Callers reach into
|
|
31
|
+
* the relevant substore directly (e.g. `stores.blocks.getBlock`) and use
|
|
32
|
+
* {@link createArchiverDataStores} to wire them up against a shared KV store.
|
|
33
|
+
*/
|
|
34
|
+
export type ArchiverDataStores = {
|
|
35
|
+
/** The underlying key-value store. Use {@link AztecAsyncKVStore.transactionAsync} to compose updates atomically. */
|
|
36
|
+
db: AztecAsyncKVStore;
|
|
37
|
+
/** Blocks, checkpoints, tx effects, proven/finalized state. */
|
|
38
|
+
blocks: BlockStore;
|
|
39
|
+
/** Public, private and contract class logs. */
|
|
40
|
+
logs: LogStore;
|
|
41
|
+
/** L1 to L2 messages and message sync state. */
|
|
42
|
+
messages: MessageStore;
|
|
43
|
+
/** Contract classes (with bytecode commitments). */
|
|
44
|
+
contractClasses: ContractClassStore;
|
|
45
|
+
/** Contract instances and contract instance updates. */
|
|
46
|
+
contractInstances: ContractInstanceStore;
|
|
47
|
+
/** In-memory cache of public function selectors -> names. */
|
|
48
|
+
functionNames: FunctionNamesCache;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/** Options used by {@link createArchiverDataStores}. */
|
|
52
|
+
export type CreateArchiverDataStoresOptions = {
|
|
53
|
+
/** Maximum number of logs returned per page when paginating tagged log queries. */
|
|
54
|
+
logsMaxPageSize?: number;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Wires up the archiver substores against a shared KV store and returns the
|
|
59
|
+
* {@link ArchiverDataStores} bundle.
|
|
60
|
+
*/
|
|
61
|
+
export function createArchiverDataStores(
|
|
62
|
+
db: AztecAsyncKVStore,
|
|
63
|
+
opts: CreateArchiverDataStoresOptions = {},
|
|
64
|
+
): ArchiverDataStores {
|
|
65
|
+
const blocks = new BlockStore(db);
|
|
66
|
+
return {
|
|
67
|
+
db,
|
|
68
|
+
blocks,
|
|
69
|
+
logs: new LogStore(db, blocks, opts.logsMaxPageSize ?? 1000),
|
|
70
|
+
messages: new MessageStore(db),
|
|
71
|
+
contractClasses: new ContractClassStore(db),
|
|
72
|
+
contractInstances: new ContractInstanceStore(db),
|
|
73
|
+
functionNames: new FunctionNamesCache(),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Returns the L1 sync point of the archiver, combining the block sync point from {@link BlockStore}
|
|
79
|
+
* and the message sync point from {@link MessageStore}.
|
|
80
|
+
*/
|
|
81
|
+
export async function getArchiverSynchPoint(stores: ArchiverDataStores): Promise<ArchiverL1SynchPoint> {
|
|
82
|
+
const [blocksSynchedTo, messagesSynchedTo] = await Promise.all([
|
|
83
|
+
stores.blocks.getSynchedL1BlockNumber(),
|
|
84
|
+
stores.messages.getSynchedL1Block(),
|
|
85
|
+
]);
|
|
86
|
+
return { blocksSynchedTo, messagesSynchedTo };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Backs up the underlying KV store to the given folder. Returns the path to the resulting db file.
|
|
91
|
+
*/
|
|
92
|
+
export async function backupArchiverDataStores(
|
|
93
|
+
stores: ArchiverDataStores,
|
|
94
|
+
path: string,
|
|
95
|
+
compress = true,
|
|
96
|
+
): Promise<string> {
|
|
97
|
+
await stores.db.backupTo(path, compress);
|
|
98
|
+
return join(path, 'data.mdb');
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Returns a {@link ContractDataSource} adapter over {@link ArchiverDataStores}.
|
|
103
|
+
* Used by contexts (e.g. offline epoch re-prover tools) that need a ContractDataSource
|
|
104
|
+
* but do not need a full archiver instance.
|
|
105
|
+
*/
|
|
106
|
+
export function createContractDataSource(stores: ArchiverDataStores): ContractDataSource {
|
|
107
|
+
return new ArchiverContractDataSourceAdapter(stores);
|
|
108
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
3
|
+
|
|
4
|
+
const MAX_FUNCTION_SIGNATURES = 1000;
|
|
5
|
+
const MAX_FUNCTION_NAME_LEN = 256;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* In-memory cache mapping public function selectors to function names.
|
|
9
|
+
*
|
|
10
|
+
* Populated opportunistically (e.g. by PXE registering signatures from artifacts) so the
|
|
11
|
+
* archiver can attach human-readable names to logs and traces. Bounded by
|
|
12
|
+
* {@link MAX_FUNCTION_SIGNATURES} to avoid unbounded growth from untrusted callers.
|
|
13
|
+
*/
|
|
14
|
+
export class FunctionNamesCache {
|
|
15
|
+
private readonly log = createLogger('archiver:data-stores');
|
|
16
|
+
private readonly names: Map<string, string> = new Map();
|
|
17
|
+
|
|
18
|
+
/** Adds the given public function signatures to the cache. */
|
|
19
|
+
public async register(signatures: string[]): Promise<void> {
|
|
20
|
+
for (const sig of signatures) {
|
|
21
|
+
if (this.names.size > MAX_FUNCTION_SIGNATURES) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
const selector = await FunctionSelector.fromSignature(sig);
|
|
26
|
+
this.names.set(selector.toString(), sig.slice(0, sig.indexOf('(')).slice(0, MAX_FUNCTION_NAME_LEN));
|
|
27
|
+
} catch {
|
|
28
|
+
this.log.warn(`Failed to parse signature: ${sig}. Ignoring`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Looks up a function name for the given selector, or returns undefined if not registered. */
|
|
34
|
+
public get(selector: FunctionSelector): string | undefined {
|
|
35
|
+
return this.names.get(selector.toString());
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -108,7 +108,7 @@ export class L2TipsCache {
|
|
|
108
108
|
private async getCheckpointIdForProposedCheckpoint(
|
|
109
109
|
checkpointedBlockData: Pick<BlockData, 'checkpointNumber'>,
|
|
110
110
|
): Promise<CheckpointId> {
|
|
111
|
-
const checkpointData = await this.blockStore.
|
|
111
|
+
const checkpointData = await this.blockStore.getLastProposedCheckpoint();
|
|
112
112
|
if (!checkpointData) {
|
|
113
113
|
return this.getCheckpointIdForBlock(checkpointedBlockData);
|
|
114
114
|
}
|
|
@@ -15,12 +15,8 @@ import { CommitteeAttestation, CommitteeAttestationsAndSigners, L2Block } from '
|
|
|
15
15
|
import { Checkpoint } from '@aztec/stdlib/checkpoint';
|
|
16
16
|
import { getSlotAtTimestamp } from '@aztec/stdlib/epoch-helpers';
|
|
17
17
|
import { InboxLeaf } from '@aztec/stdlib/messaging';
|
|
18
|
-
import { ConsensusPayload,
|
|
19
|
-
import {
|
|
20
|
-
makeAndSignCommitteeAttestationsAndSigners,
|
|
21
|
-
makeCheckpointAttestationFromCheckpoint,
|
|
22
|
-
mockCheckpointAndMessages,
|
|
23
|
-
} from '@aztec/stdlib/testing';
|
|
18
|
+
import { ConsensusPayload, getHashedSignaturePayloadTypedData } from '@aztec/stdlib/p2p';
|
|
19
|
+
import { mockCheckpointAndMessages } from '@aztec/stdlib/testing';
|
|
24
20
|
import { AppendOnlyTreeSnapshot } from '@aztec/stdlib/trees';
|
|
25
21
|
|
|
26
22
|
import { type MockProxy, mock } from 'jest-mock-extended';
|
|
@@ -151,8 +147,10 @@ export class FakeL1State {
|
|
|
151
147
|
// Computed from checkpoints based on L1 block visibility
|
|
152
148
|
private pendingCheckpointNumber: CheckpointNumber = CheckpointNumber(0);
|
|
153
149
|
|
|
154
|
-
// The L1 block number reported as "finalized" (defaults to the start block)
|
|
155
|
-
|
|
150
|
+
// The L1 block number reported as "finalized" (defaults to the start block).
|
|
151
|
+
// `undefined` simulates the startup window on a fresh devnet where
|
|
152
|
+
// `getBlock({ blockTag: 'finalized' })` fails with "finalized block not found".
|
|
153
|
+
private finalizedL1BlockNumber: bigint | undefined;
|
|
156
154
|
|
|
157
155
|
constructor(private readonly config: FakeL1StateConfig) {
|
|
158
156
|
this.l1BlockNumber = config.l1StartBlock;
|
|
@@ -288,8 +286,11 @@ export class FakeL1State {
|
|
|
288
286
|
this.updatePendingCheckpointNumber();
|
|
289
287
|
}
|
|
290
288
|
|
|
291
|
-
/**
|
|
292
|
-
|
|
289
|
+
/**
|
|
290
|
+
* Sets the L1 block number that will be reported as "finalized". Pass `undefined` to
|
|
291
|
+
* simulate a chain that does not yet have a finalized block (devnet startup).
|
|
292
|
+
*/
|
|
293
|
+
setFinalizedL1BlockNumber(blockNumber: bigint | undefined): void {
|
|
293
294
|
this.finalizedL1BlockNumber = blockNumber;
|
|
294
295
|
}
|
|
295
296
|
|
|
@@ -502,8 +503,8 @@ export class FakeL1State {
|
|
|
502
503
|
Promise.resolve(this.getMessageSentLogs(fromBlock, toBlock)),
|
|
503
504
|
);
|
|
504
505
|
|
|
505
|
-
mockInbox.getMessageSentEventByHash.mockImplementation((msgHash: string,
|
|
506
|
-
Promise.resolve(this.getMessageSentLogByHash(msgHash,
|
|
506
|
+
mockInbox.getMessageSentEventByHash.mockImplementation((msgHash: string, aroundL1BlockNumber: bigint) =>
|
|
507
|
+
Promise.resolve(this.getMessageSentLogByHash(msgHash, aroundL1BlockNumber) as MessageSentLog),
|
|
507
508
|
);
|
|
508
509
|
|
|
509
510
|
return mockInbox;
|
|
@@ -514,11 +515,19 @@ export class FakeL1State {
|
|
|
514
515
|
const publicClient = mock<ViemPublicClient>();
|
|
515
516
|
|
|
516
517
|
publicClient.getChainId.mockResolvedValue(1);
|
|
518
|
+
// Several consumers (CalldataRetriever, ArchiverL1Synchronizer) derive the EIP-712 signing
|
|
519
|
+
// context from `publicClient.chain.id`. Pin it so it matches `getSignatureContext()` below.
|
|
520
|
+
(publicClient as unknown as { chain: { id: number } }).chain = { id: 1 };
|
|
517
521
|
publicClient.getBlockNumber.mockImplementation(() => Promise.resolve(this.l1BlockNumber));
|
|
518
522
|
|
|
519
523
|
publicClient.getBlock.mockImplementation((async (args: { blockNumber?: bigint; blockTag?: string } = {}) => {
|
|
520
524
|
let blockNum: bigint;
|
|
521
525
|
if (args.blockTag === 'finalized') {
|
|
526
|
+
if (this.finalizedL1BlockNumber === undefined) {
|
|
527
|
+
throw Object.assign(new Error('finalized block not found'), {
|
|
528
|
+
details: 'finalized block not found',
|
|
529
|
+
});
|
|
530
|
+
}
|
|
522
531
|
blockNum = this.finalizedL1BlockNumber;
|
|
523
532
|
} else {
|
|
524
533
|
blockNum = args.blockNumber ?? (await publicClient.getBlockNumber());
|
|
@@ -544,10 +553,10 @@ export class FakeL1State {
|
|
|
544
553
|
createMockBlobClient(): MockProxy<BlobClientInterface> {
|
|
545
554
|
const blobClient = mock<BlobClientInterface>();
|
|
546
555
|
|
|
547
|
-
// The blockId is the
|
|
556
|
+
// The blockId is the L1 block hash, which we derive from the L1 block number
|
|
548
557
|
blobClient.getBlobSidecar.mockImplementation((blockId: `0x${string}`) =>
|
|
549
558
|
Promise.resolve(
|
|
550
|
-
this.checkpoints.find(cpData => cpData.
|
|
559
|
+
this.checkpoints.find(cpData => Buffer32.fromBigInt(cpData.l1BlockNumber).toString() === blockId)?.blobs ?? [],
|
|
551
560
|
),
|
|
552
561
|
);
|
|
553
562
|
|
|
@@ -623,9 +632,12 @@ export class FakeL1State {
|
|
|
623
632
|
}));
|
|
624
633
|
}
|
|
625
634
|
|
|
626
|
-
private getMessageSentLogByHash(msgHash: string,
|
|
635
|
+
private getMessageSentLogByHash(msgHash: string, aroundL1BlockNumber: bigint): MessageSentLog | undefined {
|
|
627
636
|
const msg = this.messages.find(
|
|
628
|
-
msg =>
|
|
637
|
+
msg =>
|
|
638
|
+
msg.leaf.toString() === msgHash &&
|
|
639
|
+
msg.l1BlockNumber >= aroundL1BlockNumber - 5n &&
|
|
640
|
+
msg.l1BlockNumber <= aroundL1BlockNumber + 5n,
|
|
629
641
|
);
|
|
630
642
|
if (!msg) {
|
|
631
643
|
return undefined;
|
|
@@ -647,9 +659,11 @@ export class FakeL1State {
|
|
|
647
659
|
checkpoint: Checkpoint,
|
|
648
660
|
signers: Secp256k1Signer[],
|
|
649
661
|
): Promise<{ tx: Transaction; attestationsHash: Buffer32; payloadDigest: Buffer32 }> {
|
|
662
|
+
const signatureContext = this.getSignatureContext();
|
|
663
|
+
const consensusPayload = ConsensusPayload.fromCheckpoint(checkpoint, signatureContext);
|
|
664
|
+
const attestationDigest = getHashedSignaturePayloadTypedData(consensusPayload);
|
|
650
665
|
const attestations = signers
|
|
651
|
-
.map(signer =>
|
|
652
|
-
.map(attestation => CommitteeAttestation.fromSignature(attestation.signature))
|
|
666
|
+
.map(signer => CommitteeAttestation.fromSignature(signer.sign(attestationDigest)))
|
|
653
667
|
.map(committeeAttestation => committeeAttestation.toViem());
|
|
654
668
|
|
|
655
669
|
const header = checkpoint.header.toViem();
|
|
@@ -657,11 +671,15 @@ export class FakeL1State {
|
|
|
657
671
|
const archive = toHex(checkpoint.archive.root.toBuffer());
|
|
658
672
|
const attestationsAndSigners = new CommitteeAttestationsAndSigners(
|
|
659
673
|
attestations.map(attestation => CommitteeAttestation.fromViem(attestation)),
|
|
674
|
+
signatureContext,
|
|
660
675
|
);
|
|
661
676
|
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
677
|
+
// Fall back to a random signer when no attesters are provided, so tests that
|
|
678
|
+
// don't care about the proposer identity (e.g. sync tests) still produce a
|
|
679
|
+
// valid-looking signature for the attestationsAndSigners struct.
|
|
680
|
+
const proposerSigner = signers[0] ?? Secp256k1Signer.random();
|
|
681
|
+
const attestationsAndSignersSignature = proposerSigner.sign(
|
|
682
|
+
getHashedSignaturePayloadTypedData(attestationsAndSigners),
|
|
665
683
|
);
|
|
666
684
|
|
|
667
685
|
const packedAttestations = attestationsAndSigners.getPackedAttestations();
|
|
@@ -702,9 +720,7 @@ export class FakeL1State {
|
|
|
702
720
|
);
|
|
703
721
|
|
|
704
722
|
// Compute payloadDigest (same logic as CalldataRetriever)
|
|
705
|
-
const
|
|
706
|
-
const payloadToSign = consensusPayload.getPayloadToSign(SignatureDomainSeparator.checkpointAttestation);
|
|
707
|
-
const payloadDigest = Buffer32.fromString(keccak256(payloadToSign));
|
|
723
|
+
const payloadDigest = getHashedSignaturePayloadTypedData(consensusPayload);
|
|
708
724
|
|
|
709
725
|
const tx = {
|
|
710
726
|
input: multiCallInput,
|
|
@@ -716,6 +732,13 @@ export class FakeL1State {
|
|
|
716
732
|
return { tx, attestationsHash, payloadDigest };
|
|
717
733
|
}
|
|
718
734
|
|
|
735
|
+
private getSignatureContext() {
|
|
736
|
+
return {
|
|
737
|
+
chainId: 1,
|
|
738
|
+
rollupAddress: this.config.rollupAddress,
|
|
739
|
+
};
|
|
740
|
+
}
|
|
741
|
+
|
|
719
742
|
/** Extracts the CommitteeAttestations struct definition from RollupAbi for hash computation. */
|
|
720
743
|
private getCommitteeAttestationsStructDef(): AbiParameter {
|
|
721
744
|
const proposeFunction = RollupAbi.find(item => item.type === 'function' && item.name === 'propose') as
|
|
@@ -321,6 +321,26 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
321
321
|
};
|
|
322
322
|
}
|
|
323
323
|
|
|
324
|
+
public getCheckpointData(_n: CheckpointNumber): Promise<CheckpointData | undefined> {
|
|
325
|
+
return Promise.resolve(undefined);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
public getCheckpointDataRange(_from: CheckpointNumber, _limit: number): Promise<CheckpointData[]> {
|
|
329
|
+
return Promise.resolve([]);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
public getCheckpointNumberBySlot(_slot: SlotNumber): Promise<CheckpointNumber | undefined> {
|
|
333
|
+
return Promise.resolve(undefined);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
public async getBlockDataWithCheckpointContext(number: BlockNumber) {
|
|
337
|
+
const data = await this.getBlockData(number);
|
|
338
|
+
if (!data) {
|
|
339
|
+
return undefined;
|
|
340
|
+
}
|
|
341
|
+
return { data, checkpoint: undefined, l1: undefined, attestations: [] };
|
|
342
|
+
}
|
|
343
|
+
|
|
324
344
|
public async getBlockDataByArchive(archive: Fr): Promise<BlockData | undefined> {
|
|
325
345
|
const block = this.l2Blocks.find(b => b.archive.root.equals(archive));
|
|
326
346
|
if (!block) {
|
|
@@ -356,6 +376,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
356
376
|
),
|
|
357
377
|
startBlock: checkpoint.blocks[0].number,
|
|
358
378
|
blockCount: checkpoint.blocks.length,
|
|
379
|
+
feeAssetPriceModifier: checkpoint.feeAssetPriceModifier,
|
|
359
380
|
attestations: [],
|
|
360
381
|
l1: this.mockL1DataForCheckpoint(checkpoint),
|
|
361
382
|
}),
|
|
@@ -558,11 +579,11 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
558
579
|
return Promise.resolve({ valid: true });
|
|
559
580
|
}
|
|
560
581
|
|
|
561
|
-
|
|
582
|
+
getLastCheckpoint(): Promise<ProposedCheckpointData | undefined> {
|
|
562
583
|
return Promise.resolve(undefined);
|
|
563
584
|
}
|
|
564
585
|
|
|
565
|
-
|
|
586
|
+
getLastProposedCheckpoint(): Promise<ProposedCheckpointData | undefined> {
|
|
566
587
|
return Promise.resolve(undefined);
|
|
567
588
|
}
|
|
568
589
|
|
|
@@ -16,7 +16,7 @@ import { EventEmitter } from 'node:events';
|
|
|
16
16
|
import { Archiver } from '../archiver.js';
|
|
17
17
|
import { ArchiverInstrumentation } from '../modules/instrumentation.js';
|
|
18
18
|
import type { ArchiverL1Synchronizer } from '../modules/l1_synchronizer.js';
|
|
19
|
-
import type {
|
|
19
|
+
import type { ArchiverDataStores } from '../store/data_stores.js';
|
|
20
20
|
|
|
21
21
|
/** Noop L1 synchronizer for testing without L1 connectivity. */
|
|
22
22
|
class NoopL1Synchronizer implements FunctionsOf<ArchiverL1Synchronizer> {
|
|
@@ -48,7 +48,7 @@ class NoopL1Synchronizer implements FunctionsOf<ArchiverL1Synchronizer> {
|
|
|
48
48
|
*/
|
|
49
49
|
export class NoopL1Archiver extends Archiver {
|
|
50
50
|
constructor(
|
|
51
|
-
|
|
51
|
+
dataStores: ArchiverDataStores,
|
|
52
52
|
l1Constants: L1RollupConstants & { genesisArchiveRoot: Fr },
|
|
53
53
|
instrumentation: ArchiverInstrumentation,
|
|
54
54
|
) {
|
|
@@ -70,17 +70,20 @@ export class NoopL1Archiver extends Archiver {
|
|
|
70
70
|
debugClient,
|
|
71
71
|
rollup,
|
|
72
72
|
{
|
|
73
|
+
rollupAddress: EthAddress.ZERO,
|
|
73
74
|
registryAddress: EthAddress.ZERO,
|
|
75
|
+
inboxAddress: EthAddress.ZERO,
|
|
74
76
|
governanceProposerAddress: EthAddress.ZERO,
|
|
75
77
|
slashingProposerAddress: EthAddress.ZERO,
|
|
76
78
|
},
|
|
77
|
-
|
|
79
|
+
dataStores,
|
|
78
80
|
{
|
|
79
81
|
pollingIntervalMs: 1000,
|
|
80
82
|
batchSize: 100,
|
|
81
83
|
skipValidateCheckpointAttestations: true,
|
|
82
84
|
maxAllowedEthClientDriftSeconds: 300,
|
|
83
85
|
ethereumAllowNoDebugHosts: true, // Skip trace validation
|
|
86
|
+
skipHistoricalLogsCheck: true, // Skip historical logs validation
|
|
84
87
|
},
|
|
85
88
|
blobClient,
|
|
86
89
|
instrumentation,
|
|
@@ -105,10 +108,10 @@ export class NoopL1Archiver extends Archiver {
|
|
|
105
108
|
|
|
106
109
|
/** Creates an archiver with mocked L1 connectivity for testing. */
|
|
107
110
|
export async function createNoopL1Archiver(
|
|
108
|
-
|
|
111
|
+
dataStores: ArchiverDataStores,
|
|
109
112
|
l1Constants: L1RollupConstants & { genesisArchiveRoot: Fr },
|
|
110
113
|
telemetry: TelemetryClient = getTelemetryClient(),
|
|
111
114
|
): Promise<NoopL1Archiver> {
|
|
112
|
-
const instrumentation = await ArchiverInstrumentation.new(telemetry, () =>
|
|
113
|
-
return new NoopL1Archiver(
|
|
115
|
+
const instrumentation = await ArchiverInstrumentation.new(telemetry, () => dataStores.db.estimateSize());
|
|
116
|
+
return new NoopL1Archiver(dataStores, l1Constants, instrumentation);
|
|
114
117
|
}
|