@aztec/archiver 0.0.1-commit.96bb3f7 → 0.0.1-commit.993d240
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/README.md +164 -22
- package/dest/archiver.d.ts +158 -0
- package/dest/archiver.d.ts.map +1 -0
- package/dest/archiver.js +881 -0
- package/dest/config.d.ts +33 -0
- package/dest/config.d.ts.map +1 -0
- package/dest/{archiver/config.js → config.js} +31 -14
- package/dest/errors.d.ts +87 -0
- package/dest/errors.d.ts.map +1 -0
- package/dest/errors.js +129 -0
- package/dest/factory.d.ts +16 -10
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +112 -20
- package/dest/index.d.ts +19 -4
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +17 -3
- package/dest/interfaces.d.ts +9 -0
- package/dest/interfaces.d.ts.map +1 -0
- package/dest/interfaces.js +3 -0
- package/dest/{archiver/l1 → l1}/bin/retrieve-calldata.d.ts +1 -1
- package/dest/l1/bin/retrieve-calldata.d.ts.map +1 -0
- package/dest/{archiver/l1 → l1}/bin/retrieve-calldata.js +35 -32
- package/dest/l1/calldata_retriever.d.ts +136 -0
- package/dest/l1/calldata_retriever.d.ts.map +1 -0
- package/dest/l1/calldata_retriever.js +412 -0
- package/dest/l1/data_retrieval.d.ts +97 -0
- package/dest/l1/data_retrieval.d.ts.map +1 -0
- package/dest/{archiver/l1 → l1}/data_retrieval.js +65 -89
- package/dest/{archiver/l1 → l1}/debug_tx.d.ts +1 -1
- package/dest/l1/debug_tx.d.ts.map +1 -0
- package/dest/{archiver/l1 → l1}/spire_proposer.d.ts +5 -5
- package/dest/l1/spire_proposer.d.ts.map +1 -0
- package/dest/{archiver/l1 → l1}/spire_proposer.js +9 -17
- package/dest/l1/trace_tx.d.ts +43 -0
- package/dest/l1/trace_tx.d.ts.map +1 -0
- package/dest/l1/types.d.ts +12 -0
- package/dest/l1/types.d.ts.map +1 -0
- 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/{archiver/l1 → l1}/validate_trace.d.ts +6 -3
- package/dest/l1/validate_trace.d.ts.map +1 -0
- package/dest/{archiver/l1 → l1}/validate_trace.js +13 -9
- 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 +40 -0
- package/dest/modules/data_source_base.d.ts +113 -0
- package/dest/modules/data_source_base.d.ts.map +1 -0
- package/dest/modules/data_source_base.js +351 -0
- package/dest/modules/data_store_updater.d.ts +105 -0
- package/dest/modules/data_store_updater.d.ts.map +1 -0
- package/dest/modules/data_store_updater.js +392 -0
- package/dest/modules/instrumentation.d.ts +55 -0
- package/dest/modules/instrumentation.d.ts.map +1 -0
- package/dest/{archiver → modules}/instrumentation.js +61 -19
- package/dest/modules/l1_synchronizer.d.ts +77 -0
- package/dest/modules/l1_synchronizer.d.ts.map +1 -0
- package/dest/modules/l1_synchronizer.js +1344 -0
- package/dest/modules/validation.d.ts +18 -0
- package/dest/modules/validation.d.ts.map +1 -0
- package/dest/{archiver → modules}/validation.js +12 -6
- package/dest/store/block_store.d.ts +300 -0
- package/dest/store/block_store.d.ts.map +1 -0
- package/dest/store/block_store.js +1219 -0
- package/dest/store/contract_class_store.d.ts +31 -0
- package/dest/store/contract_class_store.d.ts.map +1 -0
- package/dest/store/contract_class_store.js +80 -0
- package/dest/store/contract_instance_store.d.ts +51 -0
- package/dest/store/contract_instance_store.d.ts.map +1 -0
- package/dest/{archiver/kv_archiver_store → store}/contract_instance_store.js +38 -3
- 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 +54 -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.d.ts +25 -0
- package/dest/store/l2_tips_cache.d.ts.map +1 -0
- package/dest/store/l2_tips_cache.js +26 -0
- package/dest/store/log_store.d.ts +59 -0
- package/dest/store/log_store.d.ts.map +1 -0
- package/dest/store/log_store.js +310 -0
- package/dest/store/log_store_codec.d.ts +70 -0
- package/dest/store/log_store_codec.d.ts.map +1 -0
- package/dest/store/log_store_codec.js +101 -0
- package/dest/store/message_store.d.ts +50 -0
- package/dest/store/message_store.d.ts.map +1 -0
- package/dest/{archiver/kv_archiver_store → store}/message_store.js +51 -9
- package/dest/{archiver/structs → structs}/data_retrieval.d.ts +1 -1
- package/dest/structs/data_retrieval.d.ts.map +1 -0
- package/dest/structs/inbox_message.d.ts +15 -0
- package/dest/structs/inbox_message.d.ts.map +1 -0
- package/dest/{archiver/structs → structs}/published.d.ts +1 -1
- package/dest/structs/published.d.ts.map +1 -0
- package/dest/test/fake_l1_state.d.ts +214 -0
- package/dest/test/fake_l1_state.d.ts.map +1 -0
- package/dest/test/fake_l1_state.js +517 -0
- package/dest/test/index.d.ts +2 -1
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +4 -1
- package/dest/test/mock_archiver.d.ts +2 -2
- package/dest/test/mock_archiver.d.ts.map +1 -1
- package/dest/test/mock_archiver.js +3 -3
- package/dest/test/mock_l1_to_l2_message_source.d.ts +1 -1
- package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
- package/dest/test/mock_l1_to_l2_message_source.js +2 -1
- package/dest/test/mock_l2_block_source.d.ts +65 -41
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +330 -151
- package/dest/test/mock_structs.d.ts +81 -3
- package/dest/test/mock_structs.d.ts.map +1 -1
- package/dest/test/mock_structs.js +152 -7
- package/dest/test/noop_l1_archiver.d.ts +29 -0
- package/dest/test/noop_l1_archiver.d.ts.map +1 -0
- package/dest/test/noop_l1_archiver.js +85 -0
- package/package.json +17 -18
- package/src/archiver.ts +681 -0
- package/src/{archiver/config.ts → config.ts} +43 -12
- package/src/errors.ts +203 -0
- package/src/factory.ts +175 -22
- package/src/index.ts +27 -3
- package/src/interfaces.ts +9 -0
- package/src/l1/README.md +55 -0
- package/src/{archiver/l1 → l1}/bin/retrieve-calldata.ts +45 -33
- package/src/l1/calldata_retriever.ts +522 -0
- package/src/{archiver/l1 → l1}/data_retrieval.ts +106 -134
- package/src/{archiver/l1 → l1}/spire_proposer.ts +7 -15
- package/src/l1/validate_historical_logs.ts +140 -0
- package/src/{archiver/l1 → l1}/validate_trace.ts +24 -6
- package/src/modules/contract_data_source_adapter.ts +55 -0
- package/src/modules/data_source_base.ts +493 -0
- package/src/modules/data_store_updater.ts +518 -0
- package/src/{archiver → modules}/instrumentation.ts +72 -20
- package/src/modules/l1_synchronizer.ts +1257 -0
- package/src/{archiver → modules}/validation.ts +15 -9
- package/src/store/block_store.ts +1590 -0
- package/src/store/contract_class_store.ts +108 -0
- package/src/{archiver/kv_archiver_store → store}/contract_instance_store.ts +52 -6
- package/src/store/data_stores.ts +104 -0
- package/src/store/function_names_cache.ts +37 -0
- package/src/store/l2_tips_cache.ts +35 -0
- package/src/store/log_store.ts +379 -0
- package/src/store/log_store_codec.ts +132 -0
- package/src/{archiver/kv_archiver_store → store}/message_store.ts +60 -10
- package/src/{archiver/structs → structs}/inbox_message.ts +1 -1
- package/src/test/fake_l1_state.ts +770 -0
- package/src/test/index.ts +4 -0
- package/src/test/mock_archiver.ts +4 -3
- package/src/test/mock_l1_to_l2_message_source.ts +1 -0
- package/src/test/mock_l2_block_source.ts +403 -171
- package/src/test/mock_structs.ts +283 -8
- package/src/test/noop_l1_archiver.ts +139 -0
- package/dest/archiver/archiver.d.ts +0 -307
- package/dest/archiver/archiver.d.ts.map +0 -1
- package/dest/archiver/archiver.js +0 -2102
- package/dest/archiver/archiver_store.d.ts +0 -315
- package/dest/archiver/archiver_store.d.ts.map +0 -1
- package/dest/archiver/archiver_store.js +0 -4
- package/dest/archiver/archiver_store_test_suite.d.ts +0 -8
- package/dest/archiver/archiver_store_test_suite.d.ts.map +0 -1
- package/dest/archiver/archiver_store_test_suite.js +0 -2770
- package/dest/archiver/config.d.ts +0 -22
- package/dest/archiver/config.d.ts.map +0 -1
- package/dest/archiver/errors.d.ts +0 -36
- package/dest/archiver/errors.d.ts.map +0 -1
- package/dest/archiver/errors.js +0 -54
- package/dest/archiver/index.d.ts +0 -7
- package/dest/archiver/index.d.ts.map +0 -1
- package/dest/archiver/index.js +0 -4
- package/dest/archiver/instrumentation.d.ts +0 -37
- package/dest/archiver/instrumentation.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/block_store.d.ts +0 -164
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/block_store.js +0 -626
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts +0 -18
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/contract_class_store.js +0 -120
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts +0 -24
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +0 -159
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.js +0 -316
- package/dest/archiver/kv_archiver_store/log_store.d.ts +0 -45
- package/dest/archiver/kv_archiver_store/log_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/log_store.js +0 -401
- package/dest/archiver/kv_archiver_store/message_store.d.ts +0 -40
- package/dest/archiver/kv_archiver_store/message_store.d.ts.map +0 -1
- package/dest/archiver/l1/bin/retrieve-calldata.d.ts.map +0 -1
- package/dest/archiver/l1/calldata_retriever.d.ts +0 -112
- package/dest/archiver/l1/calldata_retriever.d.ts.map +0 -1
- package/dest/archiver/l1/calldata_retriever.js +0 -471
- package/dest/archiver/l1/data_retrieval.d.ts +0 -90
- package/dest/archiver/l1/data_retrieval.d.ts.map +0 -1
- package/dest/archiver/l1/debug_tx.d.ts.map +0 -1
- package/dest/archiver/l1/spire_proposer.d.ts.map +0 -1
- package/dest/archiver/l1/trace_tx.d.ts +0 -97
- package/dest/archiver/l1/trace_tx.d.ts.map +0 -1
- package/dest/archiver/l1/types.d.ts +0 -12
- package/dest/archiver/l1/types.d.ts.map +0 -1
- package/dest/archiver/l1/validate_trace.d.ts.map +0 -1
- package/dest/archiver/structs/data_retrieval.d.ts.map +0 -1
- package/dest/archiver/structs/inbox_message.d.ts +0 -15
- package/dest/archiver/structs/inbox_message.d.ts.map +0 -1
- package/dest/archiver/structs/published.d.ts.map +0 -1
- package/dest/archiver/validation.d.ts +0 -17
- package/dest/archiver/validation.d.ts.map +0 -1
- package/dest/rpc/index.d.ts +0 -9
- package/dest/rpc/index.d.ts.map +0 -1
- package/dest/rpc/index.js +0 -15
- package/src/archiver/archiver.ts +0 -2265
- package/src/archiver/archiver_store.ts +0 -380
- package/src/archiver/archiver_store_test_suite.ts +0 -2842
- package/src/archiver/errors.ts +0 -90
- package/src/archiver/index.ts +0 -6
- package/src/archiver/kv_archiver_store/block_store.ts +0 -850
- package/src/archiver/kv_archiver_store/contract_class_store.ts +0 -176
- package/src/archiver/kv_archiver_store/kv_archiver_store.ts +0 -442
- package/src/archiver/kv_archiver_store/log_store.ts +0 -516
- package/src/archiver/l1/README.md +0 -98
- package/src/archiver/l1/calldata_retriever.ts +0 -641
- package/src/rpc/index.ts +0 -16
- /package/dest/{archiver/l1 → l1}/debug_tx.js +0 -0
- /package/dest/{archiver/l1 → l1}/trace_tx.js +0 -0
- /package/dest/{archiver/l1 → l1}/types.js +0 -0
- /package/dest/{archiver/structs → structs}/data_retrieval.js +0 -0
- /package/dest/{archiver/structs → structs}/inbox_message.js +0 -0
- /package/dest/{archiver/structs → structs}/published.js +0 -0
- /package/src/{archiver/l1 → l1}/debug_tx.ts +0 -0
- /package/src/{archiver/l1 → l1}/trace_tx.ts +0 -0
- /package/src/{archiver/l1 → l1}/types.ts +0 -0
- /package/src/{archiver/structs → structs}/data_retrieval.ts +0 -0
- /package/src/{archiver/structs → structs}/published.ts +0 -0
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { type BlobClientConfig, blobClientConfigMapping } from '@aztec/blob-client/client/config';
|
|
2
2
|
import { type L1ContractsConfig, l1ContractsConfigMappings } from '@aztec/ethereum/config';
|
|
3
|
-
import { l1ContractAddressesMapping } from '@aztec/ethereum/l1-contract-addresses';
|
|
4
3
|
import { type L1ReaderConfig, l1ReaderConfigMappings } from '@aztec/ethereum/l1-reader';
|
|
5
4
|
import {
|
|
6
5
|
type ConfigMappingsType,
|
|
7
6
|
booleanConfigHelper,
|
|
8
7
|
getConfigFromMappings,
|
|
9
8
|
numberConfigHelper,
|
|
9
|
+
optionalNumberConfigHelper,
|
|
10
10
|
} from '@aztec/foundation/config';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
type ChainConfig,
|
|
13
|
+
type PipelineConfig,
|
|
14
|
+
chainConfigMappings,
|
|
15
|
+
pipelineConfigMappings,
|
|
16
|
+
} from '@aztec/stdlib/config';
|
|
12
17
|
import type { ArchiverSpecificConfig } from '@aztec/stdlib/interfaces/server';
|
|
13
18
|
|
|
14
19
|
/**
|
|
@@ -21,11 +26,13 @@ import type { ArchiverSpecificConfig } from '@aztec/stdlib/interfaces/server';
|
|
|
21
26
|
export type ArchiverConfig = ArchiverSpecificConfig &
|
|
22
27
|
L1ReaderConfig &
|
|
23
28
|
L1ContractsConfig &
|
|
29
|
+
PipelineConfig & // required to pass through to epoch cache
|
|
24
30
|
BlobClientConfig &
|
|
25
31
|
ChainConfig;
|
|
26
32
|
|
|
27
33
|
export const archiverConfigMappings: ConfigMappingsType<ArchiverConfig> = {
|
|
28
34
|
...blobClientConfigMapping,
|
|
35
|
+
...pipelineConfigMappings,
|
|
29
36
|
archiverPollingIntervalMS: {
|
|
30
37
|
env: 'ARCHIVER_POLLING_INTERVAL_MS',
|
|
31
38
|
description: 'The polling interval in ms for retrieving new L2 blocks and encrypted logs.',
|
|
@@ -36,20 +43,19 @@ export const archiverConfigMappings: ConfigMappingsType<ArchiverConfig> = {
|
|
|
36
43
|
description: 'The number of L2 blocks the archiver will attempt to download at a time.',
|
|
37
44
|
...numberConfigHelper(100),
|
|
38
45
|
},
|
|
39
|
-
maxLogs: {
|
|
40
|
-
env: 'ARCHIVER_MAX_LOGS',
|
|
41
|
-
description: 'The max number of logs that can be obtained in 1 "getPublicLogs" call.',
|
|
42
|
-
...numberConfigHelper(1_000),
|
|
43
|
-
},
|
|
44
46
|
archiverStoreMapSizeKb: {
|
|
45
47
|
env: 'ARCHIVER_STORE_MAP_SIZE_KB',
|
|
46
|
-
|
|
48
|
+
...optionalNumberConfigHelper(),
|
|
47
49
|
description: 'The maximum possible size of the archiver DB in KB. Overwrites the general dataStoreMapSizeKb.',
|
|
48
50
|
},
|
|
49
51
|
skipValidateCheckpointAttestations: {
|
|
50
52
|
description: 'Skip validating checkpoint attestations (for testing purposes only)',
|
|
51
53
|
...booleanConfigHelper(false),
|
|
52
54
|
},
|
|
55
|
+
skipPromoteProposedCheckpointDuringL1Sync: {
|
|
56
|
+
description: 'Skip promoting proposed checkpoints during L1 sync (for testing purposes only)',
|
|
57
|
+
...booleanConfigHelper(false),
|
|
58
|
+
},
|
|
53
59
|
maxAllowedEthClientDriftSeconds: {
|
|
54
60
|
env: 'MAX_ALLOWED_ETH_CLIENT_DRIFT_SECONDS',
|
|
55
61
|
description: 'Maximum allowed drift in seconds between the Ethereum client and current time.',
|
|
@@ -60,6 +66,21 @@ export const archiverConfigMappings: ConfigMappingsType<ArchiverConfig> = {
|
|
|
60
66
|
description: 'Whether to allow starting the archiver without debug/trace method support on Ethereum hosts',
|
|
61
67
|
...booleanConfigHelper(true),
|
|
62
68
|
},
|
|
69
|
+
archiverSkipHistoricalLogsCheck: {
|
|
70
|
+
env: 'ARCHIVER_SKIP_HISTORICAL_LOGS_CHECK',
|
|
71
|
+
description:
|
|
72
|
+
'Skip the startup check that probes the L1 RPC for historical Rollup contract logs. ' +
|
|
73
|
+
'Set to true to bypass the check when the connected RPC node is known to prune old logs.',
|
|
74
|
+
...booleanConfigHelper(false),
|
|
75
|
+
},
|
|
76
|
+
orphanProposedBlockPruneGraceSeconds: {
|
|
77
|
+
env: 'ARCHIVER_ORPHAN_PROPOSED_BLOCK_PRUNE_GRACE_SECONDS',
|
|
78
|
+
description:
|
|
79
|
+
'Grace period in seconds, measured from the end of a proposed block build slot, after which a ' +
|
|
80
|
+
'proposed block with no matching proposed checkpoint is pruned as an orphan. Defaults from the ' +
|
|
81
|
+
'sequencer block duration at the node wiring layer when unset.',
|
|
82
|
+
...optionalNumberConfigHelper(),
|
|
83
|
+
},
|
|
63
84
|
...chainConfigMappings,
|
|
64
85
|
...l1ReaderConfigMappings,
|
|
65
86
|
viemPollingIntervalMS: {
|
|
@@ -68,10 +89,6 @@ export const archiverConfigMappings: ConfigMappingsType<ArchiverConfig> = {
|
|
|
68
89
|
...numberConfigHelper(1000),
|
|
69
90
|
},
|
|
70
91
|
...l1ContractsConfigMappings,
|
|
71
|
-
l1Contracts: {
|
|
72
|
-
description: 'The deployed L1 contract addresses',
|
|
73
|
-
nested: l1ContractAddressesMapping,
|
|
74
|
-
},
|
|
75
92
|
};
|
|
76
93
|
|
|
77
94
|
/**
|
|
@@ -82,3 +99,17 @@ export const archiverConfigMappings: ConfigMappingsType<ArchiverConfig> = {
|
|
|
82
99
|
export function getArchiverConfigFromEnv(): ArchiverConfig {
|
|
83
100
|
return getConfigFromMappings<ArchiverConfig>(archiverConfigMappings);
|
|
84
101
|
}
|
|
102
|
+
|
|
103
|
+
/** Extracts the archiver-specific configuration from the full ArchiverConfig */
|
|
104
|
+
export function mapArchiverConfig(config: Partial<ArchiverConfig>) {
|
|
105
|
+
return {
|
|
106
|
+
pollingIntervalMs: config.archiverPollingIntervalMS,
|
|
107
|
+
batchSize: config.archiverBatchSize,
|
|
108
|
+
skipValidateCheckpointAttestations: config.skipValidateCheckpointAttestations,
|
|
109
|
+
skipPromoteProposedCheckpointDuringL1Sync: config.skipPromoteProposedCheckpointDuringL1Sync,
|
|
110
|
+
maxAllowedEthClientDriftSeconds: config.maxAllowedEthClientDriftSeconds,
|
|
111
|
+
ethereumAllowNoDebugHosts: config.ethereumAllowNoDebugHosts,
|
|
112
|
+
skipHistoricalLogsCheck: config.archiverSkipHistoricalLogsCheck,
|
|
113
|
+
orphanProposedBlockPruneGraceSeconds: config.orphanProposedBlockPruneGraceSeconds,
|
|
114
|
+
};
|
|
115
|
+
}
|
package/src/errors.ts
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import type { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import type { Fr } from '@aztec/foundation/schemas';
|
|
3
|
+
|
|
4
|
+
export class NoBlobBodiesFoundError extends Error {
|
|
5
|
+
constructor(l2BlockNum: number) {
|
|
6
|
+
super(`No blob bodies found for block ${l2BlockNum}`);
|
|
7
|
+
this.name = 'NoBlobBodiesFoundError';
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class BlockNumberNotSequentialError extends Error {
|
|
12
|
+
constructor(newBlockNumber: number, previous: number | undefined) {
|
|
13
|
+
super(`Cannot insert new block ${newBlockNumber} given previous block number is ${previous ?? 'undefined'}`);
|
|
14
|
+
this.name = 'BlockNumberNotSequentialError';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class InitialCheckpointNumberNotSequentialError extends Error {
|
|
19
|
+
constructor(
|
|
20
|
+
public readonly newCheckpointNumber: number,
|
|
21
|
+
public readonly previousCheckpointNumber: number | undefined,
|
|
22
|
+
) {
|
|
23
|
+
super(
|
|
24
|
+
`Cannot insert new checkpoint ${newCheckpointNumber} given previous checkpoint number in store is ${
|
|
25
|
+
previousCheckpointNumber ?? 'undefined'
|
|
26
|
+
}`,
|
|
27
|
+
);
|
|
28
|
+
this.name = 'InitialCheckpointNumberNotSequentialError';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export class CheckpointNumberNotSequentialError extends Error {
|
|
33
|
+
constructor(
|
|
34
|
+
public readonly newCheckpointNumber: CheckpointNumber,
|
|
35
|
+
public readonly previousCheckpointNumber: CheckpointNumber | undefined,
|
|
36
|
+
source?: 'proposed' | 'confirmed',
|
|
37
|
+
) {
|
|
38
|
+
const qualifier = source ? `${source} ` : '';
|
|
39
|
+
super(
|
|
40
|
+
`Cannot insert new checkpoint ${newCheckpointNumber} given previous ${qualifier}checkpoint number is ${previousCheckpointNumber ?? 'undefined'}`,
|
|
41
|
+
);
|
|
42
|
+
this.name = 'CheckpointNumberNotSequentialError';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Thrown when a proposed block carries a checkpoint number that does not follow the latest one. */
|
|
47
|
+
export class BlockCheckpointNumberNotSequentialError extends Error {
|
|
48
|
+
constructor(
|
|
49
|
+
blockNumber: BlockNumber,
|
|
50
|
+
blockCheckpointNumber: CheckpointNumber,
|
|
51
|
+
previous: CheckpointNumber | undefined,
|
|
52
|
+
) {
|
|
53
|
+
super(
|
|
54
|
+
`Cannot insert new block ${blockNumber} for checkpoint ${blockCheckpointNumber} given previous checkpoint number is ${previous ?? 'undefined'}`,
|
|
55
|
+
);
|
|
56
|
+
this.name = 'BlockCheckpointNumberNotSequentialError';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export class BlockIndexNotSequentialError extends Error {
|
|
61
|
+
constructor(newBlockIndex: number, previousBlockIndex: number | undefined) {
|
|
62
|
+
super(
|
|
63
|
+
`Cannot insert new block at checkpoint index ${newBlockIndex} given previous block index is ${previousBlockIndex ?? 'undefined'}`,
|
|
64
|
+
);
|
|
65
|
+
this.name = 'BlockIndexNotSequentialError';
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export class BlockArchiveNotConsistentError extends Error {
|
|
70
|
+
constructor(
|
|
71
|
+
newBlockNumber: number,
|
|
72
|
+
previousBlockNumber: number | undefined,
|
|
73
|
+
newBlockArchive: Fr,
|
|
74
|
+
previousBlockArchive: Fr,
|
|
75
|
+
) {
|
|
76
|
+
super(
|
|
77
|
+
`Cannot insert new block number ${newBlockNumber} with archive ${newBlockArchive.toString()} previous block number is ${previousBlockNumber ?? 'undefined'}, previous archive is ${previousBlockArchive?.toString() ?? 'undefined'}`,
|
|
78
|
+
);
|
|
79
|
+
this.name = 'BlockArchiveNotConsistentError';
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export class CheckpointNotFoundError extends Error {
|
|
84
|
+
constructor(checkpointNumber: number) {
|
|
85
|
+
super(`Failed to find expected checkpoint number ${checkpointNumber}`);
|
|
86
|
+
this.name = 'CheckpointNotFoundError';
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export class BlockNotFoundError extends Error {
|
|
91
|
+
constructor(blockNumber: number) {
|
|
92
|
+
super(`Failed to find expected block number ${blockNumber}`);
|
|
93
|
+
this.name = 'BlockNotFoundError';
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Thrown when a proposed block matches a block that was already checkpointed. This is expected for late proposals. */
|
|
98
|
+
export class BlockAlreadyCheckpointedError extends Error {
|
|
99
|
+
constructor(public readonly blockNumber: number) {
|
|
100
|
+
super(`Block ${blockNumber} has already been checkpointed with the same content`);
|
|
101
|
+
this.name = 'BlockAlreadyCheckpointedError';
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Thrown when L1 to L2 messages are requested for a checkpoint whose message tree hasn't been sealed yet. */
|
|
106
|
+
export class L1ToL2MessagesNotReadyError extends Error {
|
|
107
|
+
constructor(
|
|
108
|
+
public readonly checkpointNumber: number,
|
|
109
|
+
public readonly inboxTreeInProgress: bigint,
|
|
110
|
+
) {
|
|
111
|
+
super(
|
|
112
|
+
`Cannot get L1 to L2 messages for checkpoint ${checkpointNumber}: ` +
|
|
113
|
+
`inbox tree in progress is ${inboxTreeInProgress}, messages not yet sealed`,
|
|
114
|
+
);
|
|
115
|
+
this.name = 'L1ToL2MessagesNotReadyError';
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Thrown when a proposed checkpoint number is stale (already processed). */
|
|
120
|
+
export class ProposedCheckpointStaleError extends Error {
|
|
121
|
+
constructor(
|
|
122
|
+
public readonly proposedCheckpointNumber: number,
|
|
123
|
+
public readonly currentProposedNumber: number,
|
|
124
|
+
) {
|
|
125
|
+
super(`Stale proposed checkpoint ${proposedCheckpointNumber}: current proposed is ${currentProposedNumber}`);
|
|
126
|
+
this.name = 'ProposedCheckpointStaleError';
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Thrown when a proposed checkpoint number is not the expected latestTip + 1. */
|
|
131
|
+
export class ProposedCheckpointNotSequentialError extends Error {
|
|
132
|
+
constructor(
|
|
133
|
+
public readonly proposedCheckpointNumber: number,
|
|
134
|
+
public readonly latestTipNumber: number,
|
|
135
|
+
) {
|
|
136
|
+
super(
|
|
137
|
+
`Proposed checkpoint ${proposedCheckpointNumber} is not sequential: expected ${latestTipNumber + 1} (latest tip + 1, where tip is highest of confirmed or pending)`,
|
|
138
|
+
);
|
|
139
|
+
this.name = 'ProposedCheckpointNotSequentialError';
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** Thrown when a proposed checkpoint or block L2 slot has already expired on L1. */
|
|
144
|
+
export class BlockOrCheckpointSlotExpiredError extends Error {
|
|
145
|
+
constructor(
|
|
146
|
+
public readonly slot: number,
|
|
147
|
+
public readonly nextSlotStart: bigint,
|
|
148
|
+
public readonly l1TimestampSynced: bigint | undefined,
|
|
149
|
+
) {
|
|
150
|
+
super(
|
|
151
|
+
`Checkpoint or block for slot ${slot} is expired: L1 synced to ${l1TimestampSynced} which is past the next slot start ${nextSlotStart}. ` +
|
|
152
|
+
`If the checkpoint still lands via a late L1 tx, the archiver will pick it up via normal L1-sync (not the pending-queue shortcut).`,
|
|
153
|
+
);
|
|
154
|
+
this.name = 'BlockOrCheckpointSlotExpiredError';
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** Thrown when attempting to promote a proposed checkpoint but no proposed checkpoint exists in the store. */
|
|
159
|
+
export class NoProposedCheckpointToPromoteError extends Error {
|
|
160
|
+
constructor() {
|
|
161
|
+
super('Cannot promote proposed checkpoint: no proposed checkpoint exists');
|
|
162
|
+
this.name = 'NoProposedCheckpointToPromoteError';
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** Thrown when the archive root of the proposed checkpoint does not match the expected one. */
|
|
167
|
+
export class ProposedCheckpointArchiveRootMismatchError extends Error {
|
|
168
|
+
constructor(
|
|
169
|
+
public readonly expectedArchiveRoot: Fr,
|
|
170
|
+
public readonly actualArchiveRoot: Fr,
|
|
171
|
+
) {
|
|
172
|
+
super(
|
|
173
|
+
`Cannot promote proposed checkpoint: archive root mismatch (expected ${expectedArchiveRoot}, got ${actualArchiveRoot})`,
|
|
174
|
+
);
|
|
175
|
+
this.name = 'ProposedCheckpointArchiveRootMismatchError';
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** Thrown when the proposed checkpoint does not directly follow the latest confirmed checkpoint. */
|
|
180
|
+
export class ProposedCheckpointPromotionNotSequentialError extends Error {
|
|
181
|
+
constructor(
|
|
182
|
+
public readonly proposedCheckpointNumber: number,
|
|
183
|
+
public readonly latestCheckpointNumber: number,
|
|
184
|
+
) {
|
|
185
|
+
super(
|
|
186
|
+
`Cannot promote proposed checkpoint: not sequential (latest ${latestCheckpointNumber}, proposed ${proposedCheckpointNumber})`,
|
|
187
|
+
);
|
|
188
|
+
this.name = 'ProposedCheckpointPromotionNotSequentialError';
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** Thrown when a proposed block conflicts with an already checkpointed block (different content). */
|
|
193
|
+
export class CannotOverwriteCheckpointedBlockError extends Error {
|
|
194
|
+
constructor(
|
|
195
|
+
public readonly blockNumber: number,
|
|
196
|
+
public readonly lastCheckpointedBlock: number,
|
|
197
|
+
) {
|
|
198
|
+
super(
|
|
199
|
+
`Cannot add block ${blockNumber}: would overwrite checkpointed data (checkpointed up to block ${lastCheckpointedBlock})`,
|
|
200
|
+
);
|
|
201
|
+
this.name = 'CannotOverwriteCheckpointedBlockError';
|
|
202
|
+
}
|
|
203
|
+
}
|
package/src/factory.ts
CHANGED
|
@@ -1,66 +1,219 @@
|
|
|
1
|
+
import { EpochCache } from '@aztec/epoch-cache';
|
|
2
|
+
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
3
|
+
import { makeL1HttpTransport } from '@aztec/ethereum/client';
|
|
4
|
+
import { InboxContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
5
|
+
import { pickL1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
6
|
+
import type { ViemPublicDebugClient } from '@aztec/ethereum/types';
|
|
1
7
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
8
|
+
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
9
|
+
import { merge } from '@aztec/foundation/collection';
|
|
10
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
11
|
+
import { DateProvider } from '@aztec/foundation/timer';
|
|
4
12
|
import { createStore } from '@aztec/kv-store/lmdb-v2';
|
|
5
13
|
import { protocolContractNames } from '@aztec/protocol-contracts';
|
|
6
14
|
import { BundledProtocolContractsProvider } from '@aztec/protocol-contracts/providers/bundle';
|
|
7
15
|
import { FunctionType, decodeFunctionSignature } from '@aztec/stdlib/abi';
|
|
8
|
-
import {
|
|
16
|
+
import type { ArchiverEmitter, BlockHash } from '@aztec/stdlib/block';
|
|
17
|
+
import { type ContractClassPublicWithCommitment, computePublicBytecodeCommitment } from '@aztec/stdlib/contract';
|
|
18
|
+
import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
|
|
19
|
+
import { MIN_EXECUTION_TIME } from '@aztec/stdlib/timetable';
|
|
20
|
+
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
21
|
+
import { getTelemetryClient } from '@aztec/telemetry-client';
|
|
9
22
|
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
|
|
23
|
+
import { EventEmitter } from 'events';
|
|
24
|
+
import { createPublicClient } from 'viem';
|
|
25
|
+
|
|
26
|
+
import { Archiver, type ArchiverDeps } from './archiver.js';
|
|
27
|
+
import { type ArchiverConfig, mapArchiverConfig } from './config.js';
|
|
28
|
+
import { ArchiverInstrumentation } from './modules/instrumentation.js';
|
|
29
|
+
import { ArchiverL1Synchronizer } from './modules/l1_synchronizer.js';
|
|
30
|
+
import { ARCHIVER_DB_VERSION, type ArchiverDataStores, createArchiverDataStores } from './store/data_stores.js';
|
|
31
|
+
import { L2TipsCache } from './store/l2_tips_cache.js';
|
|
13
32
|
|
|
14
33
|
export const ARCHIVER_STORE_NAME = 'archiver';
|
|
15
34
|
|
|
16
35
|
/** Creates an archiver store. */
|
|
17
36
|
export async function createArchiverStore(
|
|
18
|
-
userConfig: Pick<ArchiverConfig, 'archiverStoreMapSizeKb'
|
|
19
|
-
|
|
37
|
+
userConfig: Pick<ArchiverConfig, 'archiverStoreMapSizeKb'> & DataStoreConfig,
|
|
38
|
+
genesisBlockHash: BlockHash,
|
|
39
|
+
): Promise<ArchiverDataStores> {
|
|
20
40
|
const config = {
|
|
21
41
|
...userConfig,
|
|
22
42
|
dataStoreMapSizeKb: userConfig.archiverStoreMapSizeKb ?? userConfig.dataStoreMapSizeKb,
|
|
23
43
|
};
|
|
24
|
-
const store = await createStore(ARCHIVER_STORE_NAME, ARCHIVER_DB_VERSION, config
|
|
25
|
-
return
|
|
44
|
+
const store = await createStore(ARCHIVER_STORE_NAME, ARCHIVER_DB_VERSION, config);
|
|
45
|
+
return createArchiverDataStores(store, genesisBlockHash);
|
|
26
46
|
}
|
|
27
47
|
|
|
28
48
|
/**
|
|
29
49
|
* Creates a local archiver.
|
|
30
50
|
* @param config - The archiver configuration.
|
|
31
|
-
* @param
|
|
51
|
+
* @param deps - The archiver dependencies (blobClient, epochCache, dateProvider, telemetry).
|
|
32
52
|
* @param opts - The options.
|
|
33
|
-
* @param
|
|
53
|
+
* @param initialHeader - The genesis block header from world-state, used to answer block-0 queries.
|
|
54
|
+
* @param initialBlockHash - Precomputed hash of `initialHeader`. Hoisted to the caller so the archiver
|
|
55
|
+
* can expose `getGenesisBlockHash()` synchronously.
|
|
34
56
|
* @returns The local archiver.
|
|
35
57
|
*/
|
|
36
58
|
export async function createArchiver(
|
|
37
59
|
config: ArchiverConfig & DataStoreConfig,
|
|
38
60
|
deps: ArchiverDeps,
|
|
39
61
|
opts: { blockUntilSync: boolean } = { blockUntilSync: true },
|
|
62
|
+
initialHeader: BlockHeader,
|
|
63
|
+
initialBlockHash: BlockHash,
|
|
40
64
|
): Promise<Archiver> {
|
|
41
|
-
const archiverStore = await createArchiverStore(config);
|
|
65
|
+
const archiverStore = await createArchiverStore(config, initialBlockHash);
|
|
42
66
|
await registerProtocolContracts(archiverStore);
|
|
43
|
-
|
|
67
|
+
|
|
68
|
+
// Create Ethereum clients
|
|
69
|
+
const chain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
|
|
70
|
+
const httpTimeout = config.l1HttpTimeoutMS;
|
|
71
|
+
const publicClient = createPublicClient({
|
|
72
|
+
chain: chain.chainInfo,
|
|
73
|
+
transport: makeL1HttpTransport(config.l1RpcUrls, { timeout: httpTimeout }),
|
|
74
|
+
pollingInterval: config.viemPollingIntervalMS,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// Create debug client using debug RPC URLs if available, otherwise fall back to regular RPC URLs
|
|
78
|
+
const debugRpcUrls = config.l1DebugRpcUrls.length > 0 ? config.l1DebugRpcUrls : config.l1RpcUrls;
|
|
79
|
+
const debugClient = createPublicClient({
|
|
80
|
+
chain: chain.chainInfo,
|
|
81
|
+
transport: makeL1HttpTransport(debugRpcUrls, { timeout: httpTimeout }),
|
|
82
|
+
pollingInterval: config.viemPollingIntervalMS,
|
|
83
|
+
}) as ViemPublicDebugClient;
|
|
84
|
+
|
|
85
|
+
// Create L1 contract instances
|
|
86
|
+
const rollup = new RollupContract(publicClient, config.rollupAddress);
|
|
87
|
+
const inbox = new InboxContract(publicClient, config.inboxAddress);
|
|
88
|
+
|
|
89
|
+
// Fetch L1 constants from rollup contract
|
|
90
|
+
const [
|
|
91
|
+
l1StartBlock,
|
|
92
|
+
l1GenesisTime,
|
|
93
|
+
proofSubmissionEpochs,
|
|
94
|
+
genesisArchiveRoot,
|
|
95
|
+
slashingProposerAddress,
|
|
96
|
+
targetCommitteeSize,
|
|
97
|
+
rollupManaLimit,
|
|
98
|
+
] = await Promise.all([
|
|
99
|
+
rollup.getL1StartBlock(),
|
|
100
|
+
rollup.getL1GenesisTime(),
|
|
101
|
+
rollup.getProofSubmissionEpochs(),
|
|
102
|
+
rollup.getGenesisArchiveTreeRoot(),
|
|
103
|
+
rollup.getSlashingProposerAddress(),
|
|
104
|
+
rollup.getTargetCommitteeSize(),
|
|
105
|
+
rollup.getManaLimit(),
|
|
106
|
+
] as const);
|
|
107
|
+
|
|
108
|
+
const l1StartBlockHash = await publicClient
|
|
109
|
+
.getBlock({ blockNumber: l1StartBlock, includeTransactions: false })
|
|
110
|
+
.then(block => Buffer32.fromString(block.hash));
|
|
111
|
+
|
|
112
|
+
const { aztecEpochDuration: epochDuration, aztecSlotDuration: slotDuration, ethereumSlotDuration } = config;
|
|
113
|
+
|
|
114
|
+
const l1Constants = {
|
|
115
|
+
l1StartBlockHash,
|
|
116
|
+
l1StartBlock,
|
|
117
|
+
l1GenesisTime,
|
|
118
|
+
epochDuration,
|
|
119
|
+
slotDuration,
|
|
120
|
+
ethereumSlotDuration,
|
|
121
|
+
proofSubmissionEpochs: Number(proofSubmissionEpochs),
|
|
122
|
+
targetCommitteeSize,
|
|
123
|
+
genesisArchiveRoot: Fr.fromString(genesisArchiveRoot.toString()),
|
|
124
|
+
rollupManaLimit: Number(rollupManaLimit),
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const archiverConfig = merge(
|
|
128
|
+
{
|
|
129
|
+
pollingIntervalMs: 10_000,
|
|
130
|
+
batchSize: 100,
|
|
131
|
+
maxAllowedEthClientDriftSeconds: 300,
|
|
132
|
+
ethereumAllowNoDebugHosts: false,
|
|
133
|
+
skipHistoricalLogsCheck: false,
|
|
134
|
+
orphanProposedBlockPruneGraceSeconds: MIN_EXECUTION_TIME,
|
|
135
|
+
},
|
|
136
|
+
mapArchiverConfig(config),
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
const epochCache = deps.epochCache ?? (await EpochCache.create(config.rollupAddress, config, deps));
|
|
140
|
+
const telemetry = deps.telemetry ?? getTelemetryClient();
|
|
141
|
+
const instrumentation = await ArchiverInstrumentation.new(telemetry, () => archiverStore.db.estimateSize());
|
|
142
|
+
|
|
143
|
+
// Create the event emitter that will be shared by archiver and synchronizer
|
|
144
|
+
const events = new EventEmitter() as ArchiverEmitter;
|
|
145
|
+
|
|
146
|
+
// Create L2 tips cache shared by archiver and synchronizer. The genesis block hash is dynamic —
|
|
147
|
+
// it depends on the injected initial header (genesisTimestamp + prefilled state). Hoisted to the
|
|
148
|
+
// caller so we can pass the same value to the archiver and expose it via `getGenesisBlockHash()`.
|
|
149
|
+
const l2TipsCache = new L2TipsCache(archiverStore.blocks, initialBlockHash);
|
|
150
|
+
|
|
151
|
+
// Create the L1 synchronizer
|
|
152
|
+
const synchronizer = new ArchiverL1Synchronizer(
|
|
153
|
+
publicClient,
|
|
154
|
+
debugClient,
|
|
155
|
+
rollup,
|
|
156
|
+
inbox,
|
|
157
|
+
archiverStore,
|
|
158
|
+
archiverConfig,
|
|
159
|
+
deps.blobClient,
|
|
160
|
+
epochCache,
|
|
161
|
+
deps.dateProvider ?? new DateProvider(),
|
|
162
|
+
instrumentation,
|
|
163
|
+
l1Constants,
|
|
164
|
+
events,
|
|
165
|
+
instrumentation.tracer,
|
|
166
|
+
l2TipsCache,
|
|
167
|
+
undefined, // log (use default)
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
const archiver = new Archiver(
|
|
171
|
+
publicClient,
|
|
172
|
+
debugClient,
|
|
173
|
+
rollup,
|
|
174
|
+
{ ...pickL1ContractAddresses(config), slashingProposerAddress },
|
|
175
|
+
archiverStore,
|
|
176
|
+
archiverConfig,
|
|
177
|
+
deps.blobClient,
|
|
178
|
+
instrumentation,
|
|
179
|
+
l1Constants,
|
|
180
|
+
synchronizer,
|
|
181
|
+
events,
|
|
182
|
+
initialHeader,
|
|
183
|
+
initialBlockHash,
|
|
184
|
+
l2TipsCache,
|
|
185
|
+
epochCache,
|
|
186
|
+
deps.dateProvider ?? new DateProvider(),
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
await archiver.start(opts.blockUntilSync);
|
|
190
|
+
return archiver;
|
|
44
191
|
}
|
|
45
192
|
|
|
46
|
-
|
|
193
|
+
/** Registers protocol contracts in the archiver store. Idempotent — skips contracts that already exist (e.g. on node restart). */
|
|
194
|
+
export async function registerProtocolContracts(stores: ArchiverDataStores) {
|
|
47
195
|
const blockNumber = 0;
|
|
48
196
|
for (const name of protocolContractNames) {
|
|
49
197
|
const provider = new BundledProtocolContractsProvider();
|
|
50
198
|
const contract = await provider.getProtocolContractArtifact(name);
|
|
51
|
-
|
|
199
|
+
|
|
200
|
+
// Skip if already registered (happens on node restart with a persisted store).
|
|
201
|
+
if (await stores.contractClasses.getContractClass(contract.contractClass.id)) {
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const publicBytecodeCommitment = await computePublicBytecodeCommitment(contract.contractClass.packedBytecode);
|
|
206
|
+
const contractClassPublic: ContractClassPublicWithCommitment = {
|
|
52
207
|
...contract.contractClass,
|
|
53
|
-
|
|
54
|
-
utilityFunctions: [],
|
|
208
|
+
publicBytecodeCommitment,
|
|
55
209
|
};
|
|
56
210
|
|
|
57
211
|
const publicFunctionSignatures = contract.artifact.functions
|
|
58
212
|
.filter(fn => fn.functionType === FunctionType.PUBLIC)
|
|
59
213
|
.map(fn => decodeFunctionSignature(fn.name, fn.parameters));
|
|
60
214
|
|
|
61
|
-
await
|
|
62
|
-
|
|
63
|
-
await
|
|
64
|
-
await store.addContractInstances([contract.instance], BlockNumber(blockNumber));
|
|
215
|
+
await stores.functionNames.register(publicFunctionSignatures);
|
|
216
|
+
await stores.contractClasses.addContractClasses([contractClassPublic], BlockNumber(blockNumber));
|
|
217
|
+
await stores.contractInstances.addContractInstances([contract.instance], BlockNumber(blockNumber));
|
|
65
218
|
}
|
|
66
219
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
|
-
export * from './archiver/index.js';
|
|
2
1
|
export * from './factory.js';
|
|
3
|
-
export * from './
|
|
2
|
+
export * from './interfaces.js';
|
|
3
|
+
export * from './archiver.js';
|
|
4
|
+
export * from './modules/data_source_base.js';
|
|
5
|
+
export * from './modules/data_store_updater.js';
|
|
6
|
+
export * from './config.js';
|
|
7
|
+
export * from './errors.js';
|
|
4
8
|
|
|
5
|
-
export {
|
|
9
|
+
export { type L1PublishedData } from './structs/published.js';
|
|
10
|
+
export {
|
|
11
|
+
ARCHIVER_DB_VERSION,
|
|
12
|
+
type ArchiverDataStores,
|
|
13
|
+
type ArchiverL1SynchPoint,
|
|
14
|
+
backupArchiverDataStores,
|
|
15
|
+
createArchiverDataStores,
|
|
16
|
+
createContractDataSource,
|
|
17
|
+
getArchiverSynchPoint,
|
|
18
|
+
} from './store/data_stores.js';
|
|
19
|
+
export { FunctionNamesCache } from './store/function_names_cache.js';
|
|
20
|
+
export { ArchiverContractDataSourceAdapter } from './modules/contract_data_source_adapter.js';
|
|
21
|
+
export { BlockStore } from './store/block_store.js';
|
|
22
|
+
export { LogStore } from './store/log_store.js';
|
|
23
|
+
export { MessageStore } from './store/message_store.js';
|
|
24
|
+
export { ContractClassStore } from './store/contract_class_store.js';
|
|
25
|
+
export { ContractInstanceStore } from './store/contract_instance_store.js';
|
|
26
|
+
export { L2TipsCache } from './store/l2_tips_cache.js';
|
|
27
|
+
|
|
28
|
+
export { retrieveL2ProofVerifiedEvents } from './l1/data_retrieval.js';
|
|
29
|
+
export { CalldataRetriever } from './l1/calldata_retriever.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
2
|
+
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
3
|
+
import type { L2LogsSource } from '@aztec/stdlib/interfaces/server';
|
|
4
|
+
import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Helper interface to combine all sources this archiver implementation provides.
|
|
8
|
+
*/
|
|
9
|
+
export type ArchiverDataSource = L2BlockSource & L2LogsSource & ContractDataSource & L1ToL2MessageSource;
|
package/src/l1/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Archiver L1 Data Retrieval
|
|
2
|
+
|
|
3
|
+
Modules and classes to handle data retrieval from L1 for the archiver.
|
|
4
|
+
|
|
5
|
+
## Calldata Retriever
|
|
6
|
+
|
|
7
|
+
The sequencer publisher bundles multiple operations into a single multicall3 transaction for gas
|
|
8
|
+
efficiency. The archiver needs to extract the `propose` calldata from these bundled transactions
|
|
9
|
+
to reconstruct L2 blocks.
|
|
10
|
+
|
|
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.
|
|
14
|
+
|
|
15
|
+
### Multicall3 Decoding with Hash Matching
|
|
16
|
+
|
|
17
|
+
First attempt to decode the transaction as a multicall3 `aggregate3` call:
|
|
18
|
+
|
|
19
|
+
- Check if transaction is to multicall3 address (`0xcA11bde05977b3631167028862bE2a173976CA11`)
|
|
20
|
+
- Decode as `aggregate3(Call3[] calldata calls)`
|
|
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)
|
|
26
|
+
|
|
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.
|
|
29
|
+
|
|
30
|
+
### Direct Propose Call
|
|
31
|
+
|
|
32
|
+
Second attempt to decode the transaction as a direct `propose` call to the rollup contract:
|
|
33
|
+
|
|
34
|
+
- Check if transaction is to the rollup address
|
|
35
|
+
- Decode as `propose` function call
|
|
36
|
+
- Verify against expected hashes
|
|
37
|
+
- Return the transaction input as the propose calldata
|
|
38
|
+
|
|
39
|
+
### Spire Proposer Call
|
|
40
|
+
|
|
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.
|
|
44
|
+
|
|
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.
|
|
47
|
+
|
|
48
|
+
### Debug and Trace Transaction Fallback
|
|
49
|
+
|
|
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.
|
|
53
|
+
|
|
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.
|