@aztec/archiver 0.0.0-test.1 → 0.0.1-commit.017a351
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 +172 -9
- package/dest/archiver.d.ts +176 -0
- package/dest/archiver.d.ts.map +1 -0
- package/dest/archiver.js +905 -0
- package/dest/config.d.ts +33 -0
- package/dest/config.d.ts.map +1 -0
- package/dest/config.js +78 -0
- 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 +19 -17
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +125 -61
- 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/l1/bin/retrieve-calldata.d.ts +3 -0
- package/dest/l1/bin/retrieve-calldata.d.ts.map +1 -0
- package/dest/l1/bin/retrieve-calldata.js +152 -0
- 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/l1/data_retrieval.js +307 -0
- package/dest/l1/debug_tx.d.ts +19 -0
- package/dest/l1/debug_tx.d.ts.map +1 -0
- package/dest/l1/debug_tx.js +73 -0
- package/dest/l1/spire_proposer.d.ts +70 -0
- package/dest/l1/spire_proposer.d.ts.map +1 -0
- package/dest/l1/spire_proposer.js +149 -0
- package/dest/l1/trace_tx.d.ts +43 -0
- package/dest/l1/trace_tx.d.ts.map +1 -0
- package/dest/l1/trace_tx.js +91 -0
- package/dest/l1/types.d.ts +12 -0
- package/dest/l1/types.d.ts.map +1 -0
- package/dest/l1/types.js +3 -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/l1/validate_trace.d.ts +32 -0
- package/dest/l1/validate_trace.d.ts.map +1 -0
- package/dest/l1/validate_trace.js +154 -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 +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 +348 -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/modules/instrumentation.js +145 -0
- 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/outbox_trees_resolver.d.ts +62 -0
- package/dest/modules/outbox_trees_resolver.d.ts.map +1 -0
- package/dest/modules/outbox_trees_resolver.js +162 -0
- package/dest/modules/validation.d.ts +18 -0
- package/dest/modules/validation.d.ts.map +1 -0
- package/dest/modules/validation.js +104 -0
- package/dest/store/block_store.d.ts +294 -0
- package/dest/store/block_store.d.ts.map +1 -0
- package/dest/store/block_store.js +1188 -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/store/contract_instance_store.js +112 -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 +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/store/message_store.js +230 -0
- package/dest/structs/data_retrieval.d.ts +27 -0
- 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/structs/inbox_message.js +39 -0
- package/dest/structs/published.d.ts +2 -0
- package/dest/structs/published.d.ts.map +1 -0
- package/dest/structs/published.js +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 +16 -8
- package/dest/test/mock_archiver.d.ts.map +1 -1
- package/dest/test/mock_archiver.js +19 -14
- package/dest/test/mock_l1_to_l2_message_source.d.ts +9 -6
- package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
- package/dest/test/mock_l1_to_l2_message_source.js +31 -7
- package/dest/test/mock_l2_block_source.d.ts +98 -35
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +416 -76
- package/dest/test/mock_structs.d.ts +88 -0
- package/dest/test/mock_structs.d.ts.map +1 -0
- package/dest/test/mock_structs.js +183 -0
- package/dest/test/noop_l1_archiver.d.ts +30 -0
- package/dest/test/noop_l1_archiver.d.ts.map +1 -0
- package/dest/test/noop_l1_archiver.js +85 -0
- package/package.json +31 -33
- package/src/archiver.ts +719 -0
- package/src/config.ts +108 -0
- package/src/errors.ts +203 -0
- package/src/factory.ts +190 -76
- package/src/index.ts +27 -3
- package/src/interfaces.ts +9 -0
- package/src/l1/README.md +55 -0
- package/src/l1/bin/retrieve-calldata.ts +194 -0
- package/src/l1/calldata_retriever.ts +522 -0
- package/src/l1/data_retrieval.ts +484 -0
- package/src/l1/debug_tx.ts +99 -0
- package/src/l1/spire_proposer.ts +152 -0
- package/src/l1/trace_tx.ts +128 -0
- package/src/l1/types.ts +13 -0
- package/src/l1/validate_historical_logs.ts +140 -0
- package/src/l1/validate_trace.ts +229 -0
- package/src/modules/contract_data_source_adapter.ts +55 -0
- package/src/modules/data_source_base.ts +495 -0
- package/src/modules/data_store_updater.ts +518 -0
- package/src/modules/instrumentation.ts +204 -0
- package/src/modules/l1_synchronizer.ts +1257 -0
- package/src/modules/outbox_trees_resolver.ts +199 -0
- package/src/modules/validation.ts +130 -0
- package/src/store/block_store.ts +1540 -0
- package/src/store/contract_class_store.ts +108 -0
- package/src/store/contract_instance_store.ts +161 -0
- 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/store/message_store.ts +311 -0
- package/src/structs/inbox_message.ts +41 -0
- package/src/structs/published.ts +1 -0
- package/src/test/fake_l1_state.ts +770 -0
- package/src/test/fixtures/debug_traceTransaction-multicall3.json +88 -0
- package/src/test/fixtures/debug_traceTransaction-multiplePropose.json +153 -0
- package/src/test/fixtures/debug_traceTransaction-proxied.json +122 -0
- package/src/test/fixtures/trace_transaction-multicall3.json +65 -0
- package/src/test/fixtures/trace_transaction-multiplePropose.json +319 -0
- package/src/test/fixtures/trace_transaction-proxied.json +128 -0
- package/src/test/fixtures/trace_transaction-randomRevert.json +216 -0
- package/src/test/index.ts +4 -0
- package/src/test/mock_archiver.ts +23 -16
- package/src/test/mock_l1_to_l2_message_source.ts +27 -8
- package/src/test/mock_l2_block_source.ts +514 -84
- package/src/test/mock_structs.ts +325 -0
- package/src/test/noop_l1_archiver.ts +148 -0
- package/dest/archiver/archiver.d.ts +0 -197
- package/dest/archiver/archiver.d.ts.map +0 -1
- package/dest/archiver/archiver.js +0 -900
- package/dest/archiver/archiver_store.d.ts +0 -220
- 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 -794
- package/dest/archiver/config.d.ts +0 -37
- package/dest/archiver/config.d.ts.map +0 -1
- package/dest/archiver/config.js +0 -46
- package/dest/archiver/data_retrieval.d.ts +0 -74
- package/dest/archiver/data_retrieval.d.ts.map +0 -1
- package/dest/archiver/data_retrieval.js +0 -283
- package/dest/archiver/errors.d.ts +0 -4
- package/dest/archiver/errors.d.ts.map +0 -1
- package/dest/archiver/errors.js +0 -5
- package/dest/archiver/index.d.ts +0 -8
- package/dest/archiver/index.d.ts.map +0 -1
- package/dest/archiver/index.js +0 -5
- package/dest/archiver/instrumentation.d.ts +0 -29
- package/dest/archiver/instrumentation.d.ts.map +0 -1
- package/dest/archiver/instrumentation.js +0 -99
- package/dest/archiver/kv_archiver_store/block_store.d.ts +0 -87
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/block_store.js +0 -217
- 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 -126
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts +0 -21
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/contract_instance_store.js +0 -63
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +0 -153
- 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 -254
- package/dest/archiver/kv_archiver_store/log_store.d.ts +0 -49
- package/dest/archiver/kv_archiver_store/log_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/log_store.js +0 -364
- package/dest/archiver/kv_archiver_store/message_store.d.ts +0 -33
- package/dest/archiver/kv_archiver_store/message_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/message_store.js +0 -85
- package/dest/archiver/kv_archiver_store/nullifier_store.d.ts +0 -12
- package/dest/archiver/kv_archiver_store/nullifier_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/nullifier_store.js +0 -73
- package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts +0 -23
- package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts.map +0 -1
- package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.js +0 -49
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts +0 -175
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts.map +0 -1
- package/dest/archiver/memory_archiver_store/memory_archiver_store.js +0 -636
- package/dest/archiver/structs/data_retrieval.d.ts +0 -27
- package/dest/archiver/structs/data_retrieval.d.ts.map +0 -1
- package/dest/archiver/structs/published.d.ts +0 -11
- package/dest/archiver/structs/published.d.ts.map +0 -1
- package/dest/archiver/structs/published.js +0 -1
- package/dest/rpc/index.d.ts +0 -10
- package/dest/rpc/index.d.ts.map +0 -1
- package/dest/rpc/index.js +0 -18
- package/src/archiver/archiver.ts +0 -1181
- package/src/archiver/archiver_store.ts +0 -263
- package/src/archiver/archiver_store_test_suite.ts +0 -810
- package/src/archiver/config.ts +0 -92
- package/src/archiver/data_retrieval.ts +0 -422
- package/src/archiver/errors.ts +0 -5
- package/src/archiver/index.ts +0 -7
- package/src/archiver/instrumentation.ts +0 -132
- package/src/archiver/kv_archiver_store/block_store.ts +0 -283
- package/src/archiver/kv_archiver_store/contract_class_store.ts +0 -186
- package/src/archiver/kv_archiver_store/contract_instance_store.ts +0 -107
- package/src/archiver/kv_archiver_store/kv_archiver_store.ts +0 -358
- package/src/archiver/kv_archiver_store/log_store.ts +0 -444
- package/src/archiver/kv_archiver_store/message_store.ts +0 -102
- package/src/archiver/kv_archiver_store/nullifier_store.ts +0 -97
- package/src/archiver/memory_archiver_store/l1_to_l2_message_store.ts +0 -61
- package/src/archiver/memory_archiver_store/memory_archiver_store.ts +0 -801
- package/src/archiver/structs/published.ts +0 -11
- package/src/rpc/index.ts +0 -20
- /package/dest/{archiver/structs → structs}/data_retrieval.js +0 -0
- /package/src/{archiver/structs → structs}/data_retrieval.ts +0 -0
package/src/config.ts
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { type BlobClientConfig, blobClientConfigMapping } from '@aztec/blob-client/client/config';
|
|
2
|
+
import { type L1ContractsConfig, l1ContractsConfigMappings } from '@aztec/ethereum/config';
|
|
3
|
+
import { type L1ReaderConfig, l1ReaderConfigMappings } from '@aztec/ethereum/l1-reader';
|
|
4
|
+
import {
|
|
5
|
+
type ConfigMappingsType,
|
|
6
|
+
booleanConfigHelper,
|
|
7
|
+
getConfigFromMappings,
|
|
8
|
+
numberConfigHelper,
|
|
9
|
+
optionalNumberConfigHelper,
|
|
10
|
+
} from '@aztec/foundation/config';
|
|
11
|
+
import { type ChainConfig, chainConfigMappings } from '@aztec/stdlib/config';
|
|
12
|
+
import type { ArchiverSpecificConfig } from '@aztec/stdlib/interfaces/server';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The archiver configuration.
|
|
16
|
+
* There are 2 polling intervals used in this configuration. The first is the archiver polling interval, archiverPollingIntervalMS.
|
|
17
|
+
* This is the interval between successive calls to eth_blockNumber via viem.
|
|
18
|
+
* Results of calls to eth_blockNumber are cached by viem with this cache being updated periodically at the interval specified by viemPollingIntervalMS.
|
|
19
|
+
* As a result the maximum observed polling time for new blocks will be viemPollingIntervalMS + archiverPollingIntervalMS.
|
|
20
|
+
*/
|
|
21
|
+
export type ArchiverConfig = ArchiverSpecificConfig &
|
|
22
|
+
L1ReaderConfig &
|
|
23
|
+
L1ContractsConfig &
|
|
24
|
+
BlobClientConfig &
|
|
25
|
+
ChainConfig;
|
|
26
|
+
|
|
27
|
+
export const archiverConfigMappings: ConfigMappingsType<ArchiverConfig> = {
|
|
28
|
+
...blobClientConfigMapping,
|
|
29
|
+
archiverPollingIntervalMS: {
|
|
30
|
+
env: 'ARCHIVER_POLLING_INTERVAL_MS',
|
|
31
|
+
description: 'The polling interval in ms for retrieving new L2 blocks and encrypted logs.',
|
|
32
|
+
...numberConfigHelper(500),
|
|
33
|
+
},
|
|
34
|
+
archiverBatchSize: {
|
|
35
|
+
env: 'ARCHIVER_BATCH_SIZE',
|
|
36
|
+
description: 'The number of L2 blocks the archiver will attempt to download at a time.',
|
|
37
|
+
...numberConfigHelper(100),
|
|
38
|
+
},
|
|
39
|
+
archiverStoreMapSizeKb: {
|
|
40
|
+
env: 'ARCHIVER_STORE_MAP_SIZE_KB',
|
|
41
|
+
...optionalNumberConfigHelper(),
|
|
42
|
+
description: 'The maximum possible size of the archiver DB in KB. Overwrites the general dataStoreMapSizeKb.',
|
|
43
|
+
},
|
|
44
|
+
skipValidateCheckpointAttestations: {
|
|
45
|
+
description: 'Skip validating checkpoint attestations (for testing purposes only)',
|
|
46
|
+
...booleanConfigHelper(false),
|
|
47
|
+
},
|
|
48
|
+
skipPromoteProposedCheckpointDuringL1Sync: {
|
|
49
|
+
description: 'Skip promoting proposed checkpoints during L1 sync (for testing purposes only)',
|
|
50
|
+
...booleanConfigHelper(false),
|
|
51
|
+
},
|
|
52
|
+
maxAllowedEthClientDriftSeconds: {
|
|
53
|
+
env: 'MAX_ALLOWED_ETH_CLIENT_DRIFT_SECONDS',
|
|
54
|
+
description: 'Maximum allowed drift in seconds between the Ethereum client and current time.',
|
|
55
|
+
...numberConfigHelper(300),
|
|
56
|
+
},
|
|
57
|
+
ethereumAllowNoDebugHosts: {
|
|
58
|
+
env: 'ETHEREUM_ALLOW_NO_DEBUG_HOSTS',
|
|
59
|
+
description: 'Whether to allow starting the archiver without debug/trace method support on Ethereum hosts',
|
|
60
|
+
...booleanConfigHelper(true),
|
|
61
|
+
},
|
|
62
|
+
archiverSkipHistoricalLogsCheck: {
|
|
63
|
+
env: 'ARCHIVER_SKIP_HISTORICAL_LOGS_CHECK',
|
|
64
|
+
description:
|
|
65
|
+
'Skip the startup check that probes the L1 RPC for historical Rollup contract logs. ' +
|
|
66
|
+
'Set to true to bypass the check when the connected RPC node is known to prune old logs.',
|
|
67
|
+
...booleanConfigHelper(false),
|
|
68
|
+
},
|
|
69
|
+
orphanProposedBlockPruneGraceSeconds: {
|
|
70
|
+
env: 'ARCHIVER_ORPHAN_PROPOSED_BLOCK_PRUNE_GRACE_SECONDS',
|
|
71
|
+
description:
|
|
72
|
+
'Grace period in seconds, measured from the end of a proposed block build slot, after which a ' +
|
|
73
|
+
'proposed block with no matching proposed checkpoint is pruned as an orphan. Defaults from the ' +
|
|
74
|
+
'sequencer block duration at the node wiring layer when unset.',
|
|
75
|
+
...optionalNumberConfigHelper(),
|
|
76
|
+
},
|
|
77
|
+
...chainConfigMappings,
|
|
78
|
+
...l1ReaderConfigMappings,
|
|
79
|
+
viemPollingIntervalMS: {
|
|
80
|
+
env: 'ARCHIVER_VIEM_POLLING_INTERVAL_MS',
|
|
81
|
+
description: 'The polling interval viem uses in ms',
|
|
82
|
+
...numberConfigHelper(1000),
|
|
83
|
+
},
|
|
84
|
+
...l1ContractsConfigMappings,
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Returns the archiver configuration from the environment variables.
|
|
89
|
+
* Note: If an environment variable is not set, the default value is used.
|
|
90
|
+
* @returns The archiver configuration.
|
|
91
|
+
*/
|
|
92
|
+
export function getArchiverConfigFromEnv(): ArchiverConfig {
|
|
93
|
+
return getConfigFromMappings<ArchiverConfig>(archiverConfigMappings);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Extracts the archiver-specific configuration from the full ArchiverConfig */
|
|
97
|
+
export function mapArchiverConfig(config: Partial<ArchiverConfig>) {
|
|
98
|
+
return {
|
|
99
|
+
pollingIntervalMs: config.archiverPollingIntervalMS,
|
|
100
|
+
batchSize: config.archiverBatchSize,
|
|
101
|
+
skipValidateCheckpointAttestations: config.skipValidateCheckpointAttestations,
|
|
102
|
+
skipPromoteProposedCheckpointDuringL1Sync: config.skipPromoteProposedCheckpointDuringL1Sync,
|
|
103
|
+
maxAllowedEthClientDriftSeconds: config.maxAllowedEthClientDriftSeconds,
|
|
104
|
+
ethereumAllowNoDebugHosts: config.ethereumAllowNoDebugHosts,
|
|
105
|
+
skipHistoricalLogsCheck: config.archiverSkipHistoricalLogsCheck,
|
|
106
|
+
orphanProposedBlockPruneGraceSeconds: config.orphanProposedBlockPruneGraceSeconds,
|
|
107
|
+
};
|
|
108
|
+
}
|
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,107 +1,221 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { EpochCache } from '@aztec/epoch-cache';
|
|
2
|
+
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
3
|
+
import { makeL1HttpTransport } from '@aztec/ethereum/client';
|
|
4
|
+
import { InboxContract, OutboxContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
5
|
+
import { pickL1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
6
|
+
import type { ViemPublicDebugClient } from '@aztec/ethereum/types';
|
|
7
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
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
|
-
import {
|
|
6
|
-
import { TokenBridgeContractArtifact } from '@aztec/noir-contracts.js/TokenBridge';
|
|
7
|
-
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
8
|
-
import { protocolContractNames, protocolContractTreeRoot } from '@aztec/protocol-contracts';
|
|
13
|
+
import { protocolContractNames } from '@aztec/protocol-contracts';
|
|
9
14
|
import { BundledProtocolContractsProvider } from '@aztec/protocol-contracts/providers/bundle';
|
|
10
15
|
import { FunctionType, decodeFunctionSignature } from '@aztec/stdlib/abi';
|
|
11
|
-
import type {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} from '@aztec/
|
|
17
|
-
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
import { Archiver } from './archiver
|
|
22
|
-
import type
|
|
23
|
-
import {
|
|
24
|
-
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';
|
|
22
|
+
|
|
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';
|
|
32
|
+
|
|
33
|
+
export const ARCHIVER_STORE_NAME = 'archiver';
|
|
34
|
+
|
|
35
|
+
/** Creates an archiver store. */
|
|
36
|
+
export async function createArchiverStore(
|
|
37
|
+
userConfig: Pick<ArchiverConfig, 'archiverStoreMapSizeKb'> & DataStoreConfig,
|
|
38
|
+
genesisBlockHash: BlockHash,
|
|
39
|
+
): Promise<ArchiverDataStores> {
|
|
40
|
+
const config = {
|
|
41
|
+
...userConfig,
|
|
42
|
+
dataStoreMapSizeKb: userConfig.archiverStoreMapSizeKb ?? userConfig.dataStoreMapSizeKb,
|
|
43
|
+
};
|
|
44
|
+
const store = await createStore(ARCHIVER_STORE_NAME, ARCHIVER_DB_VERSION, config);
|
|
45
|
+
return createArchiverDataStores(store, genesisBlockHash);
|
|
46
|
+
}
|
|
25
47
|
|
|
26
48
|
/**
|
|
27
49
|
* Creates a local archiver.
|
|
28
50
|
* @param config - The archiver configuration.
|
|
29
|
-
* @param
|
|
51
|
+
* @param deps - The archiver dependencies (blobClient, epochCache, dateProvider, telemetry).
|
|
30
52
|
* @param opts - The options.
|
|
31
|
-
* @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.
|
|
32
56
|
* @returns The local archiver.
|
|
33
57
|
*/
|
|
34
58
|
export async function createArchiver(
|
|
35
59
|
config: ArchiverConfig & DataStoreConfig,
|
|
36
|
-
|
|
37
|
-
opts: { blockUntilSync: boolean } = { blockUntilSync: true },
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
KVArchiverDataStore.SCHEMA_VERSION,
|
|
43
|
-
config,
|
|
44
|
-
createLogger('archiver:lmdb'),
|
|
45
|
-
);
|
|
46
|
-
const archiverStore = new KVArchiverDataStore(store, config.maxLogs);
|
|
60
|
+
deps: ArchiverDeps,
|
|
61
|
+
opts: { blockUntilSync: boolean; enableOrphanProposedBlockPruning?: boolean } = { blockUntilSync: true },
|
|
62
|
+
initialHeader: BlockHeader,
|
|
63
|
+
initialBlockHash: BlockHash,
|
|
64
|
+
): Promise<Archiver> {
|
|
65
|
+
const archiverStore = await createArchiverStore(config, initialBlockHash);
|
|
47
66
|
await registerProtocolContracts(archiverStore);
|
|
48
|
-
await registerCommonContracts(archiverStore);
|
|
49
|
-
return Archiver.createAndSync(config, archiverStore, { telemetry, blobSinkClient }, opts.blockUntilSync);
|
|
50
|
-
}
|
|
51
67
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
+
const outbox = new OutboxContract(publicClient, config.outboxAddress);
|
|
89
|
+
|
|
90
|
+
// Fetch L1 constants from rollup contract
|
|
91
|
+
const [
|
|
92
|
+
l1StartBlock,
|
|
93
|
+
l1GenesisTime,
|
|
94
|
+
proofSubmissionEpochs,
|
|
95
|
+
genesisArchiveRoot,
|
|
96
|
+
slashingProposerAddress,
|
|
97
|
+
targetCommitteeSize,
|
|
98
|
+
rollupManaLimit,
|
|
99
|
+
] = await Promise.all([
|
|
100
|
+
rollup.getL1StartBlock(),
|
|
101
|
+
rollup.getL1GenesisTime(),
|
|
102
|
+
rollup.getProofSubmissionEpochs(),
|
|
103
|
+
rollup.getGenesisArchiveTreeRoot(),
|
|
104
|
+
rollup.getSlashingProposerAddress(),
|
|
105
|
+
rollup.getTargetCommitteeSize(),
|
|
106
|
+
rollup.getManaLimit(),
|
|
107
|
+
] as const);
|
|
108
|
+
|
|
109
|
+
const l1StartBlockHash = await publicClient
|
|
110
|
+
.getBlock({ blockNumber: l1StartBlock, includeTransactions: false })
|
|
111
|
+
.then(block => Buffer32.fromString(block.hash));
|
|
112
|
+
|
|
113
|
+
const { aztecEpochDuration: epochDuration, aztecSlotDuration: slotDuration, ethereumSlotDuration } = config;
|
|
61
114
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
115
|
+
const l1Constants = {
|
|
116
|
+
l1StartBlockHash,
|
|
117
|
+
l1StartBlock,
|
|
118
|
+
l1GenesisTime,
|
|
119
|
+
epochDuration,
|
|
120
|
+
slotDuration,
|
|
121
|
+
ethereumSlotDuration,
|
|
122
|
+
proofSubmissionEpochs: Number(proofSubmissionEpochs),
|
|
123
|
+
targetCommitteeSize,
|
|
124
|
+
genesisArchiveRoot: Fr.fromString(genesisArchiveRoot.toString()),
|
|
125
|
+
rollupManaLimit: Number(rollupManaLimit),
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const archiverConfig = merge(
|
|
129
|
+
{
|
|
130
|
+
pollingIntervalMs: 10_000,
|
|
131
|
+
batchSize: 100,
|
|
132
|
+
maxAllowedEthClientDriftSeconds: 300,
|
|
133
|
+
ethereumAllowNoDebugHosts: false,
|
|
134
|
+
skipHistoricalLogsCheck: false,
|
|
135
|
+
orphanProposedBlockPruneGraceSeconds: MIN_EXECUTION_TIME,
|
|
136
|
+
enableOrphanProposedBlockPruning: opts.enableOrphanProposedBlockPruning ?? true,
|
|
137
|
+
},
|
|
138
|
+
mapArchiverConfig(config),
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
const epochCache = deps.epochCache ?? (await EpochCache.create(config.rollupAddress, config, deps));
|
|
142
|
+
const telemetry = deps.telemetry ?? getTelemetryClient();
|
|
143
|
+
const instrumentation = await ArchiverInstrumentation.new(telemetry, () => archiverStore.db.estimateSize());
|
|
144
|
+
|
|
145
|
+
// Create the event emitter that will be shared by archiver and synchronizer
|
|
146
|
+
const events = new EventEmitter() as ArchiverEmitter;
|
|
147
|
+
|
|
148
|
+
// Create L2 tips cache shared by archiver and synchronizer. The genesis block hash is dynamic —
|
|
149
|
+
// it depends on the injected initial header (genesisTimestamp + prefilled state). Hoisted to the
|
|
150
|
+
// caller so we can pass the same value to the archiver and expose it via `getGenesisBlockHash()`.
|
|
151
|
+
const l2TipsCache = new L2TipsCache(archiverStore.blocks, initialBlockHash);
|
|
152
|
+
|
|
153
|
+
// Create the L1 synchronizer
|
|
154
|
+
const synchronizer = new ArchiverL1Synchronizer(
|
|
155
|
+
publicClient,
|
|
156
|
+
debugClient,
|
|
157
|
+
rollup,
|
|
158
|
+
inbox,
|
|
159
|
+
archiverStore,
|
|
160
|
+
archiverConfig,
|
|
161
|
+
deps.blobClient,
|
|
162
|
+
epochCache,
|
|
163
|
+
deps.dateProvider ?? new DateProvider(),
|
|
164
|
+
instrumentation,
|
|
165
|
+
l1Constants,
|
|
166
|
+
events,
|
|
167
|
+
instrumentation.tracer,
|
|
168
|
+
l2TipsCache,
|
|
169
|
+
undefined, // log (use default)
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
const archiver = new Archiver(
|
|
173
|
+
publicClient,
|
|
174
|
+
debugClient,
|
|
175
|
+
rollup,
|
|
176
|
+
outbox,
|
|
177
|
+
{ ...pickL1ContractAddresses(config), slashingProposerAddress },
|
|
178
|
+
archiverStore,
|
|
179
|
+
archiverConfig,
|
|
180
|
+
deps.blobClient,
|
|
181
|
+
instrumentation,
|
|
182
|
+
l1Constants,
|
|
183
|
+
synchronizer,
|
|
184
|
+
events,
|
|
185
|
+
initialHeader,
|
|
186
|
+
initialBlockHash,
|
|
187
|
+
l2TipsCache,
|
|
188
|
+
deps.dateProvider ?? new DateProvider(),
|
|
65
189
|
);
|
|
190
|
+
|
|
191
|
+
await archiver.start(opts.blockUntilSync);
|
|
192
|
+
return archiver;
|
|
66
193
|
}
|
|
67
194
|
|
|
68
|
-
|
|
195
|
+
/** Registers protocol contracts in the archiver store. Idempotent — skips contracts that already exist (e.g. on node restart). */
|
|
196
|
+
export async function registerProtocolContracts(stores: ArchiverDataStores) {
|
|
69
197
|
const blockNumber = 0;
|
|
70
198
|
for (const name of protocolContractNames) {
|
|
71
199
|
const provider = new BundledProtocolContractsProvider();
|
|
72
200
|
const contract = await provider.getProtocolContractArtifact(name);
|
|
73
|
-
|
|
201
|
+
|
|
202
|
+
// Skip if already registered (happens on node restart with a persisted store).
|
|
203
|
+
if (await stores.contractClasses.getContractClass(contract.contractClass.id)) {
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const publicBytecodeCommitment = await computePublicBytecodeCommitment(contract.contractClass.packedBytecode);
|
|
208
|
+
const contractClassPublic: ContractClassPublicWithCommitment = {
|
|
74
209
|
...contract.contractClass,
|
|
75
|
-
|
|
76
|
-
unconstrainedFunctions: [],
|
|
210
|
+
publicBytecodeCommitment,
|
|
77
211
|
};
|
|
78
212
|
|
|
79
213
|
const publicFunctionSignatures = contract.artifact.functions
|
|
80
214
|
.filter(fn => fn.functionType === FunctionType.PUBLIC)
|
|
81
215
|
.map(fn => decodeFunctionSignature(fn.name, fn.parameters));
|
|
82
216
|
|
|
83
|
-
await
|
|
84
|
-
|
|
85
|
-
await
|
|
86
|
-
await store.addContractInstances([contract.instance], blockNumber);
|
|
217
|
+
await stores.functionNames.register(publicFunctionSignatures);
|
|
218
|
+
await stores.contractClasses.addContractClasses([contractClassPublic], BlockNumber(blockNumber));
|
|
219
|
+
await stores.contractInstances.addContractInstances([contract.instance], BlockNumber(blockNumber));
|
|
87
220
|
}
|
|
88
221
|
}
|
|
89
|
-
|
|
90
|
-
// TODO(#10007): Remove this method. We are explicitly registering these contracts
|
|
91
|
-
// here to ensure they are available to all nodes and all prover nodes, since the PXE
|
|
92
|
-
// was tweaked to automatically push contract classes to the node it is registered,
|
|
93
|
-
// but other nodes in the network may require the contract classes to be registered as well.
|
|
94
|
-
// TODO(#10007): Remove the dependency on noir-contracts.js from this package once we remove this.
|
|
95
|
-
async function registerCommonContracts(store: KVArchiverDataStore) {
|
|
96
|
-
const blockNumber = 0;
|
|
97
|
-
const artifacts = [TokenBridgeContractArtifact, TokenContractArtifact];
|
|
98
|
-
const classes = await Promise.all(
|
|
99
|
-
artifacts.map(async artifact => ({
|
|
100
|
-
...(await getContractClassFromArtifact(artifact)),
|
|
101
|
-
privateFunctions: [],
|
|
102
|
-
unconstrainedFunctions: [],
|
|
103
|
-
})),
|
|
104
|
-
);
|
|
105
|
-
const bytecodeCommitments = await Promise.all(classes.map(x => computePublicBytecodeCommitment(x.packedBytecode)));
|
|
106
|
-
await store.addContractClasses(classes, bytecodeCommitments, blockNumber);
|
|
107
|
-
}
|
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;
|