@aztec/archiver 0.0.1-commit.0dc957cde → 0.0.1-commit.0ec55a70b
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 +15 -9
- package/dest/archiver.d.ts.map +1 -1
- package/dest/archiver.js +85 -53
- package/dest/config.d.ts +1 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +2 -2
- package/dest/errors.d.ts +16 -5
- package/dest/errors.d.ts.map +1 -1
- package/dest/errors.js +29 -6
- package/dest/factory.d.ts +4 -4
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +11 -9
- package/dest/index.d.ts +8 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +7 -1
- 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/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 +6 -6
- package/dest/modules/data_store_updater.d.ts.map +1 -1
- package/dest/modules/data_store_updater.js +42 -40
- package/dest/modules/l1_synchronizer.d.ts +5 -4
- package/dest/modules/l1_synchronizer.d.ts.map +1 -1
- package/dest/modules/l1_synchronizer.js +79 -54
- 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 +58 -27
- package/dest/store/block_store.d.ts.map +1 -1
- package/dest/store/block_store.js +152 -75
- 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 +2 -1
- package/dest/test/fake_l1_state.d.ts.map +1 -1
- package/dest/test/fake_l1_state.js +25 -8
- 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 +5 -5
- package/package.json +13 -13
- package/src/archiver.ts +91 -49
- package/src/config.ts +2 -1
- package/src/errors.ts +41 -8
- package/src/factory.ts +10 -10
- package/src/index.ts +15 -1
- package/src/l1/calldata_retriever.ts +15 -4
- 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 +46 -38
- package/src/modules/l1_synchronizer.ts +92 -60
- package/src/modules/validation.ts +8 -7
- package/src/store/block_store.ts +159 -80
- 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 +24 -14
- package/src/test/mock_l2_block_source.ts +23 -2
- package/src/test/noop_l1_archiver.ts +6 -6
- package/dest/store/kv_archiver_store.d.ts +0 -383
- package/dest/store/kv_archiver_store.d.ts.map +0 -1
- package/dest/store/kv_archiver_store.js +0 -501
- package/src/store/kv_archiver_store.ts +0 -728
package/src/factory.ts
CHANGED
|
@@ -24,7 +24,7 @@ import { Archiver, type ArchiverDeps } from './archiver.js';
|
|
|
24
24
|
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
|
-
import { ARCHIVER_DB_VERSION,
|
|
27
|
+
import { ARCHIVER_DB_VERSION, type ArchiverDataStores, createArchiverDataStores } from './store/data_stores.js';
|
|
28
28
|
import { L2TipsCache } from './store/l2_tips_cache.js';
|
|
29
29
|
|
|
30
30
|
export const ARCHIVER_STORE_NAME = 'archiver';
|
|
@@ -32,13 +32,13 @@ export const ARCHIVER_STORE_NAME = 'archiver';
|
|
|
32
32
|
/** Creates an archiver store. */
|
|
33
33
|
export async function createArchiverStore(
|
|
34
34
|
userConfig: Pick<ArchiverConfig, 'archiverStoreMapSizeKb' | 'maxLogs'> & DataStoreConfig,
|
|
35
|
-
) {
|
|
35
|
+
): Promise<ArchiverDataStores> {
|
|
36
36
|
const config = {
|
|
37
37
|
...userConfig,
|
|
38
38
|
dataStoreMapSizeKb: userConfig.archiverStoreMapSizeKb ?? userConfig.dataStoreMapSizeKb,
|
|
39
39
|
};
|
|
40
40
|
const store = await createStore(ARCHIVER_STORE_NAME, ARCHIVER_DB_VERSION, config);
|
|
41
|
-
return
|
|
41
|
+
return createArchiverDataStores(store, { logsMaxPageSize: config.maxLogs });
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/**
|
|
@@ -128,13 +128,13 @@ export async function createArchiver(
|
|
|
128
128
|
|
|
129
129
|
const epochCache = deps.epochCache ?? (await EpochCache.create(config.l1Contracts.rollupAddress, config, deps));
|
|
130
130
|
const telemetry = deps.telemetry ?? getTelemetryClient();
|
|
131
|
-
const instrumentation = await ArchiverInstrumentation.new(telemetry, () => archiverStore.estimateSize());
|
|
131
|
+
const instrumentation = await ArchiverInstrumentation.new(telemetry, () => archiverStore.db.estimateSize());
|
|
132
132
|
|
|
133
133
|
// Create the event emitter that will be shared by archiver and synchronizer
|
|
134
134
|
const events = new EventEmitter() as ArchiverEmitter;
|
|
135
135
|
|
|
136
136
|
// Create L2 tips cache shared by archiver and synchronizer
|
|
137
|
-
const l2TipsCache = new L2TipsCache(archiverStore.
|
|
137
|
+
const l2TipsCache = new L2TipsCache(archiverStore.blocks);
|
|
138
138
|
|
|
139
139
|
// Create the L1 synchronizer
|
|
140
140
|
const synchronizer = new ArchiverL1Synchronizer(
|
|
@@ -175,14 +175,14 @@ export async function createArchiver(
|
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
/** Registers protocol contracts in the archiver store. Idempotent — skips contracts that already exist (e.g. on node restart). */
|
|
178
|
-
export async function registerProtocolContracts(
|
|
178
|
+
export async function registerProtocolContracts(stores: ArchiverDataStores) {
|
|
179
179
|
const blockNumber = 0;
|
|
180
180
|
for (const name of protocolContractNames) {
|
|
181
181
|
const provider = new BundledProtocolContractsProvider();
|
|
182
182
|
const contract = await provider.getProtocolContractArtifact(name);
|
|
183
183
|
|
|
184
184
|
// Skip if already registered (happens on node restart with a persisted store).
|
|
185
|
-
if (await
|
|
185
|
+
if (await stores.contractClasses.getContractClass(contract.contractClass.id)) {
|
|
186
186
|
continue;
|
|
187
187
|
}
|
|
188
188
|
|
|
@@ -196,8 +196,8 @@ export async function registerProtocolContracts(store: KVArchiverDataStore) {
|
|
|
196
196
|
.filter(fn => fn.functionType === FunctionType.PUBLIC)
|
|
197
197
|
.map(fn => decodeFunctionSignature(fn.name, fn.parameters));
|
|
198
198
|
|
|
199
|
-
await
|
|
200
|
-
await
|
|
201
|
-
await
|
|
199
|
+
await stores.functionNames.register(publicFunctionSignatures);
|
|
200
|
+
await stores.contractClasses.addContractClasses([contractClassPublic], BlockNumber(blockNumber));
|
|
201
|
+
await stores.contractInstances.addContractInstances([contract.instance], BlockNumber(blockNumber));
|
|
202
202
|
}
|
|
203
203
|
}
|
package/src/index.ts
CHANGED
|
@@ -6,7 +6,21 @@ export * from './modules/data_store_updater.js';
|
|
|
6
6
|
export * from './config.js';
|
|
7
7
|
|
|
8
8
|
export { type L1PublishedData } from './structs/published.js';
|
|
9
|
-
export {
|
|
9
|
+
export {
|
|
10
|
+
ARCHIVER_DB_VERSION,
|
|
11
|
+
type ArchiverDataStores,
|
|
12
|
+
type ArchiverL1SynchPoint,
|
|
13
|
+
backupArchiverDataStores,
|
|
14
|
+
createArchiverDataStores,
|
|
15
|
+
createContractDataSource,
|
|
16
|
+
getArchiverSynchPoint,
|
|
17
|
+
} from './store/data_stores.js';
|
|
18
|
+
export { FunctionNamesCache } from './store/function_names_cache.js';
|
|
19
|
+
export { ArchiverContractDataSourceAdapter } from './modules/contract_data_source_adapter.js';
|
|
20
|
+
export { BlockStore } from './store/block_store.js';
|
|
21
|
+
export { LogStore } from './store/log_store.js';
|
|
22
|
+
export { MessageStore } from './store/message_store.js';
|
|
23
|
+
export { ContractClassStore } from './store/contract_class_store.js';
|
|
10
24
|
export { ContractInstanceStore } from './store/contract_instance_store.js';
|
|
11
25
|
export { L2TipsCache } from './store/l2_tips_cache.js';
|
|
12
26
|
|
|
@@ -7,7 +7,7 @@ import { EthAddress } from '@aztec/foundation/eth-address';
|
|
|
7
7
|
import type { Logger } from '@aztec/foundation/log';
|
|
8
8
|
import { RollupAbi } from '@aztec/l1-artifacts';
|
|
9
9
|
import { CommitteeAttestation } from '@aztec/stdlib/block';
|
|
10
|
-
import { ConsensusPayload,
|
|
10
|
+
import { ConsensusPayload, getHashedSignaturePayloadTypedData } from '@aztec/stdlib/p2p';
|
|
11
11
|
import { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
12
12
|
|
|
13
13
|
import {
|
|
@@ -61,6 +61,13 @@ export class CalldataRetriever {
|
|
|
61
61
|
private readonly rollupAddress: EthAddress,
|
|
62
62
|
) {}
|
|
63
63
|
|
|
64
|
+
private getSignatureContext() {
|
|
65
|
+
return {
|
|
66
|
+
chainId: this.publicClient.chain.id,
|
|
67
|
+
rollupAddress: this.rollupAddress,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
64
71
|
/**
|
|
65
72
|
* Gets checkpoint header and metadata from the calldata of an L1 transaction.
|
|
66
73
|
* Tries multicall3 decoding, falls back to trace-based extraction.
|
|
@@ -466,9 +473,13 @@ export class CalldataRetriever {
|
|
|
466
473
|
|
|
467
474
|
/** Computes the keccak256 payload digest from the checkpoint header, archive root, and fee asset price modifier. */
|
|
468
475
|
private computePayloadDigest(header: CheckpointHeader, archiveRoot: Fr, feeAssetPriceModifier: bigint): Hex {
|
|
469
|
-
const consensusPayload = new ConsensusPayload(
|
|
470
|
-
|
|
471
|
-
|
|
476
|
+
const consensusPayload = new ConsensusPayload(
|
|
477
|
+
header,
|
|
478
|
+
archiveRoot,
|
|
479
|
+
feeAssetPriceModifier,
|
|
480
|
+
this.getSignatureContext(),
|
|
481
|
+
);
|
|
482
|
+
return getHashedSignaturePayloadTypedData(consensusPayload).toString();
|
|
472
483
|
}
|
|
473
484
|
|
|
474
485
|
/**
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
+
import type { FunctionSelector } from '@aztec/stdlib/abi';
|
|
4
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
+
import type { ContractClassPublic, ContractDataSource, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
6
|
+
import type { UInt64 } from '@aztec/stdlib/types';
|
|
7
|
+
|
|
8
|
+
import type { ArchiverDataStores } from '../store/data_stores.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Thin {@link ContractDataSource} adapter over {@link ArchiverDataStores}.
|
|
12
|
+
*
|
|
13
|
+
* Used by contexts (e.g. offline epoch re-prover tools) that need a ContractDataSource
|
|
14
|
+
* but do not need a full archiver instance.
|
|
15
|
+
*/
|
|
16
|
+
export class ArchiverContractDataSourceAdapter implements ContractDataSource {
|
|
17
|
+
constructor(private readonly stores: ArchiverDataStores) {}
|
|
18
|
+
|
|
19
|
+
public getBlockNumber(): Promise<BlockNumber> {
|
|
20
|
+
return this.stores.blocks.getLatestL2BlockNumber();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public getContractClass(id: Fr): Promise<ContractClassPublic | undefined> {
|
|
24
|
+
return this.stores.contractClasses.getContractClass(id);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public getBytecodeCommitment(id: Fr): Promise<Fr | undefined> {
|
|
28
|
+
return this.stores.contractClasses.getBytecodeCommitment(id);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public async getContract(
|
|
32
|
+
address: AztecAddress,
|
|
33
|
+
maybeTimestamp?: UInt64,
|
|
34
|
+
): Promise<ContractInstanceWithAddress | undefined> {
|
|
35
|
+
let timestamp = maybeTimestamp;
|
|
36
|
+
if (timestamp === undefined) {
|
|
37
|
+
const latest = await this.stores.blocks.getLatestL2BlockNumber();
|
|
38
|
+
if ((latest as BlockNumber) === 0) {
|
|
39
|
+
timestamp = 0n;
|
|
40
|
+
} else {
|
|
41
|
+
const [header] = await this.stores.blocks.getBlockHeaders(latest, 1);
|
|
42
|
+
timestamp = header ? header.globalVariables.timestamp : 0n;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return this.stores.contractInstances.getContractInstance(address, timestamp);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public getContractClassIds(): Promise<Fr[]> {
|
|
49
|
+
return this.stores.contractClasses.getContractClassIds();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public getDebugFunctionName(_address: AztecAddress, selector: FunctionSelector): Promise<string | undefined> {
|
|
53
|
+
return Promise.resolve(this.stores.functionNames.get(selector));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public registerContractFunctionSignatures(signatures: string[]): Promise<void> {
|
|
57
|
+
return this.stores.functionNames.register(signatures);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -24,19 +24,19 @@ import type { BlockHeader, IndexedTxEffect, TxHash, TxReceipt } from '@aztec/std
|
|
|
24
24
|
import type { UInt64 } from '@aztec/stdlib/types';
|
|
25
25
|
|
|
26
26
|
import type { ArchiverDataSource } from '../interfaces.js';
|
|
27
|
-
import type {
|
|
27
|
+
import type { ArchiverDataStores } from '../store/data_stores.js';
|
|
28
28
|
import type { ValidateCheckpointResult } from './validation.js';
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
|
-
* Abstract base class implementing ArchiverDataSource using a
|
|
32
|
-
* Provides implementations for all
|
|
33
|
-
*
|
|
31
|
+
* Abstract base class implementing ArchiverDataSource using a bundle of archiver substores.
|
|
32
|
+
* Provides implementations for all read-side methods and declares abstract methods for
|
|
33
|
+
* L1-dependent functionality that subclasses must implement.
|
|
34
34
|
*/
|
|
35
35
|
export abstract class ArchiverDataSourceBase
|
|
36
36
|
implements ArchiverDataSource, L2LogsSource, ContractDataSource, L1ToL2MessageSource
|
|
37
37
|
{
|
|
38
38
|
constructor(
|
|
39
|
-
protected readonly
|
|
39
|
+
protected readonly stores: ArchiverDataStores,
|
|
40
40
|
protected readonly l1Constants?: L1RollupConstants,
|
|
41
41
|
) {}
|
|
42
42
|
|
|
@@ -61,54 +61,54 @@ export abstract class ArchiverDataSourceBase
|
|
|
61
61
|
abstract syncImmediate(): Promise<void>;
|
|
62
62
|
|
|
63
63
|
public getCheckpointNumber(): Promise<CheckpointNumber> {
|
|
64
|
-
return this.
|
|
64
|
+
return this.stores.blocks.getLatestCheckpointNumber();
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
public getSynchedCheckpointNumber(): Promise<CheckpointNumber> {
|
|
68
|
-
return this.
|
|
68
|
+
return this.stores.blocks.getLatestCheckpointNumber();
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
public getProvenCheckpointNumber(): Promise<CheckpointNumber> {
|
|
72
|
-
return this.
|
|
72
|
+
return this.stores.blocks.getProvenCheckpointNumber();
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
public getBlockNumber(): Promise<BlockNumber> {
|
|
76
|
-
return this.
|
|
76
|
+
return this.stores.blocks.getLatestL2BlockNumber();
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
public getProvenBlockNumber(): Promise<BlockNumber> {
|
|
80
|
-
return this.
|
|
80
|
+
return this.stores.blocks.getProvenBlockNumber();
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
public async getBlockHeader(number: BlockNumber | 'latest'): Promise<BlockHeader | undefined> {
|
|
84
|
-
const blockNumber = number === 'latest' ? await this.
|
|
84
|
+
const blockNumber = number === 'latest' ? await this.stores.blocks.getLatestL2BlockNumber() : number;
|
|
85
85
|
if (blockNumber === 0) {
|
|
86
86
|
return undefined;
|
|
87
87
|
}
|
|
88
|
-
const headers = await this.
|
|
88
|
+
const headers = await this.stores.blocks.getBlockHeaders(blockNumber, 1);
|
|
89
89
|
return headers.length === 0 ? undefined : headers[0];
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
public getCheckpointedBlock(number: BlockNumber): Promise<CheckpointedL2Block | undefined> {
|
|
93
|
-
return this.
|
|
93
|
+
return this.stores.blocks.getCheckpointedBlock(number);
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
public getCheckpointedL2BlockNumber(): Promise<BlockNumber> {
|
|
97
|
-
return this.
|
|
97
|
+
return this.stores.blocks.getCheckpointedL2BlockNumber();
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
public getFinalizedL2BlockNumber(): Promise<BlockNumber> {
|
|
101
|
-
return this.
|
|
101
|
+
return this.stores.blocks.getFinalizedL2BlockNumber();
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
public async getCheckpointHeader(number: CheckpointNumber | 'latest'): Promise<CheckpointHeader | undefined> {
|
|
105
105
|
if (number === 'latest') {
|
|
106
|
-
number = await this.
|
|
106
|
+
number = await this.stores.blocks.getLatestCheckpointNumber();
|
|
107
107
|
}
|
|
108
108
|
if (number === 0) {
|
|
109
109
|
return undefined;
|
|
110
110
|
}
|
|
111
|
-
const checkpoint = await this.
|
|
111
|
+
const checkpoint = await this.stores.blocks.getCheckpointData(number);
|
|
112
112
|
if (!checkpoint) {
|
|
113
113
|
return undefined;
|
|
114
114
|
}
|
|
@@ -116,7 +116,7 @@ export abstract class ArchiverDataSourceBase
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
public async getLastBlockNumberInCheckpoint(checkpointNumber: CheckpointNumber): Promise<BlockNumber | undefined> {
|
|
119
|
-
const checkpointData = await this.
|
|
119
|
+
const checkpointData = await this.stores.blocks.getCheckpointData(checkpointNumber);
|
|
120
120
|
if (!checkpointData) {
|
|
121
121
|
return undefined;
|
|
122
122
|
}
|
|
@@ -124,51 +124,66 @@ export abstract class ArchiverDataSourceBase
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
public getCheckpointedBlocks(from: BlockNumber, limit: number): Promise<CheckpointedL2Block[]> {
|
|
127
|
-
return this.
|
|
127
|
+
return this.stores.blocks.getCheckpointedBlocks(from, limit);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
public getCheckpointData(checkpointNumber: CheckpointNumber): Promise<CheckpointData | undefined> {
|
|
131
|
+
return this.stores.blocks.getCheckpointData(checkpointNumber);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
public getCheckpointDataRange(from: CheckpointNumber, limit: number): Promise<CheckpointData[]> {
|
|
135
|
+
return this.stores.blocks.getRangeOfCheckpoints(from, limit);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
public getCheckpointNumberBySlot(slot: SlotNumber): Promise<CheckpointNumber | undefined> {
|
|
139
|
+
return this.stores.blocks.getCheckpointNumberBySlot(slot);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
public getBlockDataWithCheckpointContext(blockNumber: BlockNumber) {
|
|
143
|
+
return this.stores.blocks.getBlockDataWithCheckpointContext(blockNumber);
|
|
128
144
|
}
|
|
129
145
|
|
|
130
146
|
public getBlockHeaderByHash(blockHash: BlockHash): Promise<BlockHeader | undefined> {
|
|
131
|
-
return this.
|
|
147
|
+
return this.stores.blocks.getBlockHeaderByHash(blockHash);
|
|
132
148
|
}
|
|
133
149
|
|
|
134
150
|
public getBlockHeaderByArchive(archive: Fr): Promise<BlockHeader | undefined> {
|
|
135
|
-
return this.
|
|
151
|
+
return this.stores.blocks.getBlockHeaderByArchive(archive);
|
|
136
152
|
}
|
|
137
153
|
|
|
138
154
|
public getBlockData(number: BlockNumber): Promise<BlockData | undefined> {
|
|
139
|
-
return this.
|
|
155
|
+
return this.stores.blocks.getBlockData(number);
|
|
140
156
|
}
|
|
141
157
|
|
|
142
158
|
public getBlockDataByArchive(archive: Fr): Promise<BlockData | undefined> {
|
|
143
|
-
return this.
|
|
159
|
+
return this.stores.blocks.getBlockDataByArchive(archive);
|
|
144
160
|
}
|
|
145
161
|
|
|
146
162
|
public async getL2Block(number: BlockNumber): Promise<L2Block | undefined> {
|
|
147
163
|
// If the number provided is -ve, then return the latest block.
|
|
148
164
|
if (number < 0) {
|
|
149
|
-
number = await this.
|
|
165
|
+
number = await this.stores.blocks.getLatestL2BlockNumber();
|
|
150
166
|
}
|
|
151
167
|
if (number === 0) {
|
|
152
168
|
return undefined;
|
|
153
169
|
}
|
|
154
|
-
|
|
155
|
-
return publishedBlock;
|
|
170
|
+
return this.stores.blocks.getBlock(number);
|
|
156
171
|
}
|
|
157
172
|
|
|
158
173
|
public getTxEffect(txHash: TxHash): Promise<IndexedTxEffect | undefined> {
|
|
159
|
-
return this.
|
|
174
|
+
return this.stores.blocks.getTxEffect(txHash);
|
|
160
175
|
}
|
|
161
176
|
|
|
162
177
|
public getSettledTxReceipt(txHash: TxHash): Promise<TxReceipt | undefined> {
|
|
163
|
-
return this.
|
|
178
|
+
return this.stores.blocks.getSettledTxReceipt(txHash, this.l1Constants);
|
|
164
179
|
}
|
|
165
180
|
|
|
166
|
-
public
|
|
167
|
-
return this.
|
|
181
|
+
public getLastCheckpoint(): Promise<CommonCheckpointData | undefined> {
|
|
182
|
+
return this.stores.blocks.getLastCheckpoint();
|
|
168
183
|
}
|
|
169
184
|
|
|
170
|
-
public
|
|
171
|
-
return this.
|
|
185
|
+
public getLastProposedCheckpoint(): Promise<ProposedCheckpointData | undefined> {
|
|
186
|
+
return this.stores.blocks.getLastProposedCheckpoint();
|
|
172
187
|
}
|
|
173
188
|
|
|
174
189
|
public isPendingChainInvalid(): Promise<boolean> {
|
|
@@ -176,7 +191,7 @@ export abstract class ArchiverDataSourceBase
|
|
|
176
191
|
}
|
|
177
192
|
|
|
178
193
|
public async getPendingChainValidationStatus(): Promise<ValidateCheckpointResult> {
|
|
179
|
-
return (await this.
|
|
194
|
+
return (await this.stores.blocks.getPendingChainValidationStatus()) ?? { valid: true };
|
|
180
195
|
}
|
|
181
196
|
|
|
182
197
|
public getPrivateLogsByTags(
|
|
@@ -184,7 +199,7 @@ export abstract class ArchiverDataSourceBase
|
|
|
184
199
|
page?: number,
|
|
185
200
|
upToBlockNumber?: BlockNumber,
|
|
186
201
|
): Promise<TxScopedL2Log[][]> {
|
|
187
|
-
return this.
|
|
202
|
+
return this.stores.logs.getPrivateLogsByTags(tags, page, upToBlockNumber);
|
|
188
203
|
}
|
|
189
204
|
|
|
190
205
|
public getPublicLogsByTagsFromContract(
|
|
@@ -193,23 +208,23 @@ export abstract class ArchiverDataSourceBase
|
|
|
193
208
|
page?: number,
|
|
194
209
|
upToBlockNumber?: BlockNumber,
|
|
195
210
|
): Promise<TxScopedL2Log[][]> {
|
|
196
|
-
return this.
|
|
211
|
+
return this.stores.logs.getPublicLogsByTagsFromContract(contractAddress, tags, page, upToBlockNumber);
|
|
197
212
|
}
|
|
198
213
|
|
|
199
214
|
public getPublicLogs(filter: LogFilter): Promise<GetPublicLogsResponse> {
|
|
200
|
-
return this.
|
|
215
|
+
return this.stores.logs.getPublicLogs(filter);
|
|
201
216
|
}
|
|
202
217
|
|
|
203
218
|
public getContractClassLogs(filter: LogFilter): Promise<GetContractClassLogsResponse> {
|
|
204
|
-
return this.
|
|
219
|
+
return this.stores.logs.getContractClassLogs(filter);
|
|
205
220
|
}
|
|
206
221
|
|
|
207
222
|
public getContractClass(id: Fr): Promise<ContractClassPublic | undefined> {
|
|
208
|
-
return this.
|
|
223
|
+
return this.stores.contractClasses.getContractClass(id);
|
|
209
224
|
}
|
|
210
225
|
|
|
211
226
|
public getBytecodeCommitment(id: Fr): Promise<Fr | undefined> {
|
|
212
|
-
return this.
|
|
227
|
+
return this.stores.contractClasses.getBytecodeCommitment(id);
|
|
213
228
|
}
|
|
214
229
|
|
|
215
230
|
public async getContract(
|
|
@@ -225,36 +240,38 @@ export abstract class ArchiverDataSourceBase
|
|
|
225
240
|
timestamp = maybeTimestamp;
|
|
226
241
|
}
|
|
227
242
|
|
|
228
|
-
return this.
|
|
243
|
+
return this.stores.contractInstances.getContractInstance(address, timestamp);
|
|
229
244
|
}
|
|
230
245
|
|
|
231
246
|
public getContractClassIds(): Promise<Fr[]> {
|
|
232
|
-
return this.
|
|
247
|
+
return this.stores.contractClasses.getContractClassIds();
|
|
233
248
|
}
|
|
234
249
|
|
|
235
|
-
|
|
236
|
-
|
|
250
|
+
/** Looks up a public function name given a selector. */
|
|
251
|
+
public getDebugFunctionName(_address: AztecAddress, selector: FunctionSelector): Promise<string | undefined> {
|
|
252
|
+
return Promise.resolve(this.stores.functionNames.get(selector));
|
|
237
253
|
}
|
|
238
254
|
|
|
255
|
+
/** Register public function signatures so they can be looked up by selector. */
|
|
239
256
|
public registerContractFunctionSignatures(signatures: string[]): Promise<void> {
|
|
240
|
-
return this.
|
|
257
|
+
return this.stores.functionNames.register(signatures);
|
|
241
258
|
}
|
|
242
259
|
|
|
243
260
|
public getL1ToL2Messages(checkpointNumber: CheckpointNumber): Promise<Fr[]> {
|
|
244
|
-
return this.
|
|
261
|
+
return this.stores.messages.getL1ToL2Messages(checkpointNumber);
|
|
245
262
|
}
|
|
246
263
|
|
|
247
264
|
public getL1ToL2MessageIndex(l1ToL2Message: Fr): Promise<bigint | undefined> {
|
|
248
|
-
return this.
|
|
265
|
+
return this.stores.messages.getL1ToL2MessageIndex(l1ToL2Message);
|
|
249
266
|
}
|
|
250
267
|
|
|
251
268
|
public async getCheckpoints(checkpointNumber: CheckpointNumber, limit: number): Promise<PublishedCheckpoint[]> {
|
|
252
|
-
const checkpoints = await this.
|
|
269
|
+
const checkpoints = await this.stores.blocks.getRangeOfCheckpoints(checkpointNumber, limit);
|
|
253
270
|
return Promise.all(checkpoints.map(ch => this.getPublishedCheckpointFromCheckpointData(ch)));
|
|
254
271
|
}
|
|
255
272
|
|
|
256
273
|
private async getPublishedCheckpointFromCheckpointData(checkpoint: CheckpointData): Promise<PublishedCheckpoint> {
|
|
257
|
-
const blocksForCheckpoint = await this.
|
|
274
|
+
const blocksForCheckpoint = await this.stores.blocks.getBlocksForCheckpoint(checkpoint.checkpointNumber);
|
|
258
275
|
if (!blocksForCheckpoint) {
|
|
259
276
|
throw new Error(`Blocks for checkpoint ${checkpoint.checkpointNumber} not found`);
|
|
260
277
|
}
|
|
@@ -263,12 +280,13 @@ export abstract class ArchiverDataSourceBase
|
|
|
263
280
|
checkpoint.header,
|
|
264
281
|
blocksForCheckpoint,
|
|
265
282
|
checkpoint.checkpointNumber,
|
|
283
|
+
checkpoint.feeAssetPriceModifier,
|
|
266
284
|
);
|
|
267
285
|
return new PublishedCheckpoint(fullCheckpoint, checkpoint.l1, checkpoint.attestations);
|
|
268
286
|
}
|
|
269
287
|
|
|
270
288
|
public getBlocksForSlot(slotNumber: SlotNumber): Promise<L2Block[]> {
|
|
271
|
-
return this.
|
|
289
|
+
return this.stores.blocks.getBlocksForSlot(slotNumber);
|
|
272
290
|
}
|
|
273
291
|
|
|
274
292
|
public async getCheckpointedBlocksForEpoch(epochNumber: EpochNumber): Promise<CheckpointedL2Block[]> {
|
|
@@ -309,39 +327,39 @@ export abstract class ArchiverDataSourceBase
|
|
|
309
327
|
}
|
|
310
328
|
|
|
311
329
|
const [start, end] = getSlotRangeForEpoch(epochNumber, this.l1Constants);
|
|
312
|
-
return this.
|
|
330
|
+
return this.stores.blocks.getCheckpointDataForSlotRange(start, end);
|
|
313
331
|
}
|
|
314
332
|
|
|
315
333
|
public async getBlock(number: BlockNumber): Promise<L2Block | undefined> {
|
|
316
334
|
// If the number provided is -ve, then return the latest block.
|
|
317
335
|
if (number < 0) {
|
|
318
|
-
number = await this.
|
|
336
|
+
number = await this.stores.blocks.getLatestL2BlockNumber();
|
|
319
337
|
}
|
|
320
338
|
if (number === 0) {
|
|
321
339
|
return undefined;
|
|
322
340
|
}
|
|
323
|
-
return this.
|
|
341
|
+
return this.stores.blocks.getBlock(number);
|
|
324
342
|
}
|
|
325
343
|
|
|
326
344
|
public getBlocks(from: BlockNumber, limit: number): Promise<L2Block[]> {
|
|
327
|
-
return this.
|
|
345
|
+
return this.stores.blocks.getBlocks(from, limit);
|
|
328
346
|
}
|
|
329
347
|
|
|
330
348
|
public getCheckpointedBlockByHash(blockHash: BlockHash): Promise<CheckpointedL2Block | undefined> {
|
|
331
|
-
return this.
|
|
349
|
+
return this.stores.blocks.getCheckpointedBlockByHash(blockHash);
|
|
332
350
|
}
|
|
333
351
|
|
|
334
352
|
public getCheckpointedBlockByArchive(archive: Fr): Promise<CheckpointedL2Block | undefined> {
|
|
335
|
-
return this.
|
|
353
|
+
return this.stores.blocks.getCheckpointedBlockByArchive(archive);
|
|
336
354
|
}
|
|
337
355
|
|
|
338
356
|
public async getL2BlockByHash(blockHash: BlockHash): Promise<L2Block | undefined> {
|
|
339
|
-
const checkpointedBlock = await this.
|
|
357
|
+
const checkpointedBlock = await this.stores.blocks.getCheckpointedBlockByHash(blockHash);
|
|
340
358
|
return checkpointedBlock?.block;
|
|
341
359
|
}
|
|
342
360
|
|
|
343
361
|
public async getL2BlockByArchive(archive: Fr): Promise<L2Block | undefined> {
|
|
344
|
-
const checkpointedBlock = await this.
|
|
362
|
+
const checkpointedBlock = await this.stores.blocks.getCheckpointedBlockByArchive(archive);
|
|
345
363
|
return checkpointedBlock?.block;
|
|
346
364
|
}
|
|
347
365
|
}
|