@aztec/stdlib 5.0.0-rc.1 → 5.0.0
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/abi/buffer.d.ts +6 -2
- package/dest/abi/buffer.d.ts.map +1 -1
- package/dest/abi/buffer.js +13 -1
- package/dest/avm/avm.js +1 -1
- package/dest/aztec-address/index.d.ts +35 -5
- package/dest/aztec-address/index.d.ts.map +1 -1
- package/dest/aztec-address/index.js +32 -8
- package/dest/block/attestation_info.d.ts +1 -1
- package/dest/block/attestation_info.d.ts.map +1 -1
- package/dest/block/attestation_info.js +7 -4
- package/dest/block/l2_block_source.d.ts +44 -27
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/block/l2_block_source.js +15 -1
- package/dest/block/l2_block_stream/event_driven_l2_block_stream.d.ts +39 -0
- package/dest/block/l2_block_stream/event_driven_l2_block_stream.d.ts.map +1 -0
- package/dest/block/l2_block_stream/event_driven_l2_block_stream.js +165 -0
- package/dest/block/l2_block_stream/index.d.ts +2 -1
- package/dest/block/l2_block_stream/index.d.ts.map +1 -1
- package/dest/block/l2_block_stream/index.js +1 -0
- package/dest/block/l2_block_stream/interfaces.d.ts +40 -6
- package/dest/block/l2_block_stream/interfaces.d.ts.map +1 -1
- package/dest/block/l2_block_stream/interfaces.js +25 -1
- package/dest/block/l2_block_stream/l2_block_stream.d.ts +23 -15
- package/dest/block/l2_block_stream/l2_block_stream.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_block_stream.js +140 -152
- package/dest/block/l2_block_stream/l2_tips_store_base.d.ts +10 -2
- package/dest/block/l2_block_stream/l2_tips_store_base.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_tips_store_base.js +33 -15
- package/dest/block/proposal/attestations_and_signers.d.ts +19 -1
- package/dest/block/proposal/attestations_and_signers.d.ts.map +1 -1
- package/dest/block/proposal/attestations_and_signers.js +47 -7
- package/dest/block/test/l2_tips_store_test_suite.d.ts +1 -1
- package/dest/block/test/l2_tips_store_test_suite.d.ts.map +1 -1
- package/dest/block/test/l2_tips_store_test_suite.js +94 -3
- package/dest/block/validate_block_result.d.ts +16 -1
- package/dest/block/validate_block_result.d.ts.map +1 -1
- package/dest/block/validate_block_result.js +18 -3
- package/dest/checkpoint/index.d.ts +2 -1
- package/dest/checkpoint/index.d.ts.map +1 -1
- package/dest/checkpoint/index.js +1 -0
- package/dest/checkpoint/simulation_overrides.d.ts +61 -0
- package/dest/checkpoint/simulation_overrides.d.ts.map +1 -0
- package/dest/checkpoint/simulation_overrides.js +98 -0
- package/dest/config/network-consensus-config.d.ts +1 -1
- package/dest/config/network-consensus-config.d.ts.map +1 -1
- package/dest/config/network-consensus-config.js +2 -10
- package/dest/contract/contract_address.d.ts +5 -4
- package/dest/contract/contract_address.d.ts.map +1 -1
- package/dest/contract/contract_instance.d.ts +16 -2
- package/dest/contract/contract_instance.d.ts.map +1 -1
- package/dest/contract/contract_instance.js +45 -0
- package/dest/contract/interfaces/contract_data_source.d.ts +3 -5
- package/dest/contract/interfaces/contract_data_source.d.ts.map +1 -1
- package/dest/contract/interfaces/contract_instance.d.ts +71 -10
- package/dest/contract/interfaces/contract_instance.d.ts.map +1 -1
- package/dest/contract/interfaces/contract_instance.js +7 -2
- package/dest/contract/partial_address.d.ts +9 -3
- package/dest/contract/partial_address.d.ts.map +1 -1
- package/dest/contract/partial_address.js +8 -2
- package/dest/database-version/version_manager.d.ts +18 -4
- package/dest/database-version/version_manager.d.ts.map +1 -1
- package/dest/database-version/version_manager.js +76 -6
- package/dest/file-store/factory.d.ts +1 -1
- package/dest/file-store/factory.d.ts.map +1 -1
- package/dest/file-store/factory.js +7 -0
- package/dest/file-store/index.d.ts +2 -1
- package/dest/file-store/index.d.ts.map +1 -1
- package/dest/file-store/index.js +1 -0
- package/dest/file-store/memory.d.ts +24 -0
- package/dest/file-store/memory.d.ts.map +1 -0
- package/dest/file-store/memory.js +80 -0
- package/dest/ha-signing/config.d.ts +19 -5
- package/dest/ha-signing/config.d.ts.map +1 -1
- package/dest/ha-signing/config.js +9 -3
- package/dest/ha-signing/local_config.d.ts +10 -2
- package/dest/ha-signing/local_config.d.ts.map +1 -1
- package/dest/ha-signing/local_config.js +8 -2
- package/dest/hash/hash.d.ts +1 -2
- package/dest/hash/hash.d.ts.map +1 -1
- package/dest/hash/hash.js +0 -7
- package/dest/interfaces/archiver.d.ts +8 -1
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +3 -2
- package/dest/interfaces/aztec-node-admin.d.ts +5 -2
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/aztec-node-debug.d.ts +26 -1
- package/dest/interfaces/aztec-node-debug.d.ts.map +1 -1
- package/dest/interfaces/aztec-node-debug.js +20 -0
- package/dest/interfaces/aztec-node.d.ts +20 -20
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +8 -15
- package/dest/interfaces/chain_tips.d.ts +8 -47
- package/dest/interfaces/chain_tips.d.ts.map +1 -1
- package/dest/interfaces/chain_tips.js +1 -6
- package/dest/interfaces/checkpoint_parameter.d.ts +3 -3
- package/dest/interfaces/checkpoint_parameter.d.ts.map +1 -1
- package/dest/interfaces/checkpoint_parameter.js +3 -3
- package/dest/interfaces/configs.d.ts +4 -1
- package/dest/interfaces/configs.d.ts.map +1 -1
- package/dest/interfaces/configs.js +1 -0
- package/dest/interfaces/private_kernel_prover.d.ts +9 -11
- package/dest/interfaces/private_kernel_prover.d.ts.map +1 -1
- package/dest/interfaces/prover-node.d.ts +6 -7
- package/dest/interfaces/prover-node.d.ts.map +1 -1
- package/dest/interfaces/prover-node.js +15 -10
- package/dest/interfaces/proving-job.d.ts +87 -74
- package/dest/interfaces/proving-job.d.ts.map +1 -1
- package/dest/interfaces/proving-job.js +13 -4
- package/dest/interfaces/server_circuit_prover.d.ts +3 -3
- package/dest/interfaces/server_circuit_prover.d.ts.map +1 -1
- package/dest/interfaces/validator.d.ts +7 -3
- package/dest/interfaces/validator.d.ts.map +1 -1
- package/dest/interfaces/world_state.d.ts +14 -1
- package/dest/interfaces/world_state.d.ts.map +1 -1
- package/dest/kernel/hints/find_private_kernel_reset_dimensions.d.ts +8 -2
- package/dest/kernel/hints/find_private_kernel_reset_dimensions.d.ts.map +1 -1
- package/dest/kernel/hints/find_private_kernel_reset_dimensions.js +12 -74
- package/dest/kernel/hints/read_request.js +1 -1
- package/dest/kernel/index.d.ts +2 -2
- package/dest/kernel/index.d.ts.map +1 -1
- package/dest/kernel/index.js +1 -1
- package/dest/kernel/log_hash.d.ts +1 -1
- package/dest/kernel/log_hash.d.ts.map +1 -1
- package/dest/kernel/log_hash.js +2 -2
- package/dest/kernel/note_hash.js +1 -1
- package/dest/kernel/nullifier.js +1 -1
- package/dest/kernel/private_circuit_public_inputs.d.ts +13 -3
- package/dest/kernel/private_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_circuit_public_inputs.js +14 -7
- package/dest/kernel/private_context_inputs.d.ts +4 -3
- package/dest/kernel/private_context_inputs.d.ts.map +1 -1
- package/dest/kernel/private_context_inputs.js +7 -3
- package/dest/kernel/private_kernel_circuit_public_inputs.d.ts +7 -1
- package/dest/kernel/private_kernel_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_kernel_circuit_public_inputs.js +7 -0
- package/dest/kernel/private_kernel_init_2_circuit_private_inputs.d.ts +2 -3
- package/dest/kernel/private_kernel_init_2_circuit_private_inputs.d.ts.map +1 -1
- package/dest/kernel/private_kernel_init_2_circuit_private_inputs.js +3 -5
- package/dest/kernel/private_kernel_init_3_circuit_private_inputs.d.ts +2 -3
- package/dest/kernel/private_kernel_init_3_circuit_private_inputs.d.ts.map +1 -1
- package/dest/kernel/private_kernel_init_3_circuit_private_inputs.js +3 -5
- package/dest/kernel/private_kernel_init_circuit_private_inputs.d.ts +1 -9
- package/dest/kernel/private_kernel_init_circuit_private_inputs.d.ts.map +1 -1
- package/dest/kernel/private_kernel_init_circuit_private_inputs.js +2 -6
- package/dest/kernel/private_kernel_reset_dimensions.d.ts +7 -8
- package/dest/kernel/private_kernel_reset_dimensions.d.ts.map +1 -1
- package/dest/kernel/private_kernel_reset_tail_circuit_private_inputs.d.ts +29 -0
- package/dest/kernel/private_kernel_reset_tail_circuit_private_inputs.d.ts.map +1 -0
- package/dest/kernel/private_kernel_reset_tail_circuit_private_inputs.js +36 -0
- package/dest/kernel/private_log_data.d.ts +1 -1
- package/dest/kernel/private_log_data.d.ts.map +1 -1
- package/dest/kernel/private_log_data.js +1 -1
- package/dest/keys/derivation.d.ts +41 -6
- package/dest/keys/derivation.d.ts.map +1 -1
- package/dest/keys/derivation.js +49 -26
- package/dest/logs/app_tagging_secret.d.ts +30 -7
- package/dest/logs/app_tagging_secret.d.ts.map +1 -1
- package/dest/logs/app_tagging_secret.js +46 -39
- package/dest/logs/contract_class_log.d.ts +1 -2
- package/dest/logs/contract_class_log.d.ts.map +1 -1
- package/dest/logs/contract_class_log.js +0 -4
- package/dest/logs/index.d.ts +1 -3
- package/dest/logs/index.d.ts.map +1 -1
- package/dest/logs/index.js +0 -2
- package/dest/logs/shared_secret_derivation.d.ts +19 -6
- package/dest/logs/shared_secret_derivation.d.ts.map +1 -1
- package/dest/logs/shared_secret_derivation.js +26 -11
- package/dest/messaging/l1_to_l2_message.d.ts +23 -2
- package/dest/messaging/l1_to_l2_message.d.ts.map +1 -1
- package/dest/messaging/l1_to_l2_message.js +36 -11
- package/dest/p2p/attestation_utils.d.ts +1 -1
- package/dest/p2p/attestation_utils.d.ts.map +1 -1
- package/dest/p2p/attestation_utils.js +8 -1
- package/dest/p2p/checkpoint_attestation.d.ts +10 -1
- package/dest/p2p/checkpoint_attestation.d.ts.map +1 -1
- package/dest/p2p/checkpoint_attestation.js +10 -0
- package/dest/p2p/checkpoint_proposal.d.ts +2 -1
- package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
- package/dest/p2p/consensus_payload.d.ts +2 -1
- package/dest/p2p/consensus_payload.d.ts.map +1 -1
- package/dest/p2p/signature_utils.d.ts +10 -1
- package/dest/p2p/signature_utils.d.ts.map +1 -1
- package/dest/p2p/signature_utils.js +9 -1
- package/dest/rollup/avm_proof_data.d.ts +3 -3
- package/dest/rollup/avm_proof_data.d.ts.map +1 -1
- package/dest/rollup/checkpoint_header.d.ts +8 -3
- package/dest/rollup/checkpoint_header.d.ts.map +1 -1
- package/dest/rollup/checkpoint_header.js +20 -10
- package/dest/stats/stats.d.ts +2 -2
- package/dest/stats/stats.d.ts.map +1 -1
- package/dest/tests/factories.d.ts +1 -1
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +7 -15
- package/dest/trees/nullifier_membership_witness.d.ts +5 -8
- package/dest/trees/nullifier_membership_witness.d.ts.map +1 -1
- package/dest/trees/nullifier_membership_witness.js +0 -9
- package/dest/trees/public_data_witness.d.ts +7 -17
- package/dest/trees/public_data_witness.d.ts.map +1 -1
- package/dest/trees/public_data_witness.js +0 -27
- package/dest/tx/execution_payload.d.ts +1 -1
- package/dest/tx/execution_payload.d.ts.map +1 -1
- package/dest/tx/execution_payload.js +1 -1
- package/dest/tx/global_variable_builder.d.ts +2 -12
- package/dest/tx/global_variable_builder.d.ts.map +1 -1
- package/dest/tx/global_variables.js +2 -2
- package/dest/tx/private_tx_constant_data.d.ts +18 -2
- package/dest/tx/private_tx_constant_data.d.ts.map +1 -1
- package/dest/tx/private_tx_constant_data.js +13 -4
- package/dest/tx/simulated_tx.d.ts +10 -6
- package/dest/tx/simulated_tx.d.ts.map +1 -1
- package/dest/world-state/genesis_data.d.ts +9 -1
- package/dest/world-state/genesis_data.d.ts.map +1 -1
- package/dest/world-state/genesis_data.js +1 -0
- package/package.json +8 -8
- package/src/abi/buffer.ts +13 -1
- package/src/avm/avm.ts +1 -1
- package/src/aztec-address/index.ts +36 -6
- package/src/block/attestation_info.ts +7 -2
- package/src/block/l2_block_source.ts +64 -17
- package/src/block/l2_block_stream/event_driven_l2_block_stream.ts +207 -0
- package/src/block/l2_block_stream/index.ts +1 -0
- package/src/block/l2_block_stream/interfaces.ts +60 -6
- package/src/block/l2_block_stream/l2_block_stream.ts +201 -178
- package/src/block/l2_block_stream/l2_tips_store_base.ts +36 -15
- package/src/block/proposal/attestations_and_signers.ts +53 -7
- package/src/block/test/l2_tips_store_test_suite.ts +73 -4
- package/src/block/validate_block_result.ts +48 -2
- package/src/checkpoint/index.ts +1 -0
- package/src/checkpoint/simulation_overrides.ts +171 -0
- package/src/config/network-consensus-config.ts +2 -13
- package/src/contract/contract_address.ts +4 -3
- package/src/contract/contract_instance.ts +62 -1
- package/src/contract/interfaces/contract_data_source.ts +2 -4
- package/src/contract/interfaces/contract_instance.ts +26 -8
- package/src/contract/partial_address.ts +8 -2
- package/src/database-version/version_manager.ts +96 -6
- package/src/file-store/factory.ts +7 -0
- package/src/file-store/index.ts +1 -0
- package/src/file-store/memory.ts +94 -0
- package/src/ha-signing/config.ts +23 -5
- package/src/ha-signing/local_config.ts +20 -1
- package/src/hash/hash.ts +0 -8
- package/src/interfaces/archiver.ts +9 -1
- package/src/interfaces/aztec-node-debug.ts +37 -0
- package/src/interfaces/aztec-node.ts +30 -33
- package/src/interfaces/chain_tips.ts +8 -16
- package/src/interfaces/checkpoint_parameter.ts +3 -3
- package/src/interfaces/configs.ts +3 -0
- package/src/interfaces/private_kernel_prover.ts +10 -12
- package/src/interfaces/prover-node.ts +19 -11
- package/src/interfaces/proving-job.ts +15 -3
- package/src/interfaces/server_circuit_prover.ts +2 -2
- package/src/interfaces/world_state.ts +14 -0
- package/src/kernel/hints/find_private_kernel_reset_dimensions.ts +22 -112
- package/src/kernel/hints/read_request.ts +1 -1
- package/src/kernel/index.ts +1 -1
- package/src/kernel/log_hash.ts +5 -2
- package/src/kernel/note_hash.ts +1 -1
- package/src/kernel/nullifier.ts +1 -1
- package/src/kernel/private_circuit_public_inputs.ts +12 -1
- package/src/kernel/private_context_inputs.ts +10 -3
- package/src/kernel/private_kernel_circuit_public_inputs.ts +9 -0
- package/src/kernel/private_kernel_init_2_circuit_private_inputs.ts +0 -3
- package/src/kernel/private_kernel_init_3_circuit_private_inputs.ts +0 -3
- package/src/kernel/private_kernel_init_circuit_private_inputs.ts +0 -6
- package/src/kernel/private_kernel_reset_dimensions.ts +15 -5
- package/src/kernel/private_kernel_reset_tail_circuit_private_inputs.ts +69 -0
- package/src/kernel/private_log_data.ts +4 -1
- package/src/keys/derivation.ts +69 -24
- package/src/logs/app_tagging_secret.ts +62 -39
- package/src/logs/contract_class_log.ts +0 -9
- package/src/logs/index.ts +0 -2
- package/src/logs/shared_secret_derivation.ts +31 -15
- package/src/messaging/l1_to_l2_message.ts +51 -13
- package/src/p2p/attestation_utils.ts +8 -1
- package/src/p2p/checkpoint_attestation.ts +12 -0
- package/src/p2p/signature_utils.ts +9 -0
- package/src/rollup/avm_proof_data.ts +2 -2
- package/src/rollup/checkpoint_header.ts +16 -2
- package/src/stats/stats.ts +2 -2
- package/src/tests/factories.ts +6 -12
- package/src/trees/nullifier_membership_witness.ts +0 -11
- package/src/trees/public_data_witness.ts +0 -31
- package/src/tx/execution_payload.ts +2 -1
- package/src/tx/global_variable_builder.ts +1 -17
- package/src/tx/global_variables.ts +2 -2
- package/src/tx/private_tx_constant_data.ts +25 -2
- package/src/world-state/genesis_data.ts +10 -0
- package/dest/kernel/private_kernel_tail_circuit_private_inputs.d.ts +0 -47
- package/dest/kernel/private_kernel_tail_circuit_private_inputs.d.ts.map +0 -1
- package/dest/kernel/private_kernel_tail_circuit_private_inputs.js +0 -38
- package/dest/logs/message_context.d.ts +0 -27
- package/dest/logs/message_context.d.ts.map +0 -1
- package/dest/logs/message_context.js +0 -74
- package/dest/logs/pending_tagged_log.d.ts +0 -13
- package/dest/logs/pending_tagged_log.d.ts.map +0 -1
- package/dest/logs/pending_tagged_log.js +0 -34
- package/src/kernel/private_kernel_tail_circuit_private_inputs.ts +0 -58
- package/src/logs/message_context.ts +0 -76
- package/src/logs/pending_tagged_log.ts +0 -39
|
@@ -6,11 +6,20 @@ import { join } from 'path';
|
|
|
6
6
|
|
|
7
7
|
import { DatabaseVersion } from './database_version.js';
|
|
8
8
|
|
|
9
|
-
export type DatabaseVersionManagerFs = Pick<typeof fs, 'readFile' | '
|
|
9
|
+
export type DatabaseVersionManagerFs = Pick<typeof fs, 'readFile' | 'rm' | 'mkdir' | 'rename' | 'open'>;
|
|
10
10
|
|
|
11
11
|
export const DATABASE_VERSION_FILE_NAME = 'db_version';
|
|
12
12
|
export type SchemaVersionMismatchPolicy = 'reset' | 'throw';
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* How to react when the version file exists but cannot be read (permissions, IO error, truncation).
|
|
16
|
+
* `'reset'` (default) treats the store as unversioned and lets the reset path run — safe for stores
|
|
17
|
+
* where an empty state is legitimate. `'throw'` refuses to open, leaving data untouched — required
|
|
18
|
+
* for protection stores (e.g. signing protection) that must never be silently wiped by a transient
|
|
19
|
+
* filesystem error. A genuinely missing file (ENOENT) is a first boot and is never affected by this.
|
|
20
|
+
*/
|
|
21
|
+
export type VersionFileReadFailurePolicy = 'reset' | 'throw';
|
|
22
|
+
|
|
14
23
|
export type DatabaseVersionManagerOptions<T> = {
|
|
15
24
|
schemaVersion: number;
|
|
16
25
|
rollupAddress: EthAddress;
|
|
@@ -18,6 +27,7 @@ export type DatabaseVersionManagerOptions<T> = {
|
|
|
18
27
|
onOpen: (dataDir: string) => Promise<T>;
|
|
19
28
|
onUpgrade?: (dataDir: string, currentVersion: number, latestVersion: number) => Promise<void>;
|
|
20
29
|
schemaVersionMismatchPolicy?: SchemaVersionMismatchPolicy;
|
|
30
|
+
versionFileReadFailurePolicy?: VersionFileReadFailurePolicy;
|
|
21
31
|
fileSystem?: DatabaseVersionManagerFs;
|
|
22
32
|
log?: Logger;
|
|
23
33
|
};
|
|
@@ -37,6 +47,7 @@ export class DatabaseVersionManager<T> {
|
|
|
37
47
|
private onOpen: (dataDir: string) => Promise<T>;
|
|
38
48
|
private onUpgrade?: (dataDir: string, currentVersion: number, latestVersion: number) => Promise<void>;
|
|
39
49
|
private schemaVersionMismatchPolicy: SchemaVersionMismatchPolicy;
|
|
50
|
+
private versionFileReadFailurePolicy: VersionFileReadFailurePolicy;
|
|
40
51
|
private fileSystem: DatabaseVersionManagerFs;
|
|
41
52
|
private log: Logger;
|
|
42
53
|
|
|
@@ -47,8 +58,11 @@ export class DatabaseVersionManager<T> {
|
|
|
47
58
|
* @param rollupAddress - The rollup contract address
|
|
48
59
|
* @param dataDirectory - The directory where version information will be stored
|
|
49
60
|
* @param onOpen - A callback to the open the database at the given location
|
|
50
|
-
* @param onUpgrade - An optional callback to upgrade the database before opening. If not provided it will reset the
|
|
61
|
+
* @param onUpgrade - An optional callback to upgrade the database before opening. If not provided it will reset the
|
|
62
|
+
* database. Must be idempotent: since the version marker is written only after a successful open, a crash after
|
|
63
|
+
* onUpgrade but before the marker is written re-runs onUpgrade on the next start.
|
|
51
64
|
* @param schemaVersionMismatchPolicy - Whether schema mismatches should reset data or throw
|
|
65
|
+
* @param versionFileReadFailurePolicy - Whether an unreadable (non-missing) version file should reset data or throw
|
|
52
66
|
* @param fileSystem - An interface to access the filesystem
|
|
53
67
|
* @param log - Optional custom logger
|
|
54
68
|
* @param options - Configuration options
|
|
@@ -60,6 +74,7 @@ export class DatabaseVersionManager<T> {
|
|
|
60
74
|
onOpen,
|
|
61
75
|
onUpgrade,
|
|
62
76
|
schemaVersionMismatchPolicy = 'reset',
|
|
77
|
+
versionFileReadFailurePolicy = 'reset',
|
|
63
78
|
fileSystem = fs,
|
|
64
79
|
log = createLogger(`foundation:version-manager`),
|
|
65
80
|
}: DatabaseVersionManagerOptions<T>) {
|
|
@@ -74,13 +89,40 @@ export class DatabaseVersionManager<T> {
|
|
|
74
89
|
this.onOpen = onOpen;
|
|
75
90
|
this.onUpgrade = onUpgrade;
|
|
76
91
|
this.schemaVersionMismatchPolicy = schemaVersionMismatchPolicy;
|
|
92
|
+
this.versionFileReadFailurePolicy = versionFileReadFailurePolicy;
|
|
77
93
|
this.fileSystem = fileSystem;
|
|
78
94
|
this.log = log;
|
|
79
95
|
}
|
|
80
96
|
|
|
81
97
|
static async writeVersion(version: DatabaseVersion, dataDir: string, fileSystem: DatabaseVersionManagerFs = fs) {
|
|
82
98
|
await fileSystem.mkdir(dataDir, { recursive: true });
|
|
83
|
-
|
|
99
|
+
const finalPath = join(dataDir, DatabaseVersionManager.VERSION_FILE);
|
|
100
|
+
const tmpPath = `${finalPath}.tmp`;
|
|
101
|
+
|
|
102
|
+
// Atomic durable write: fill a temp file, fsync it, then rename it into place. The marker only
|
|
103
|
+
// becomes visible under its final name once its bytes are durably on disk, so a crash mid-write
|
|
104
|
+
// can never leave a "valid" version file sitting over an empty or partially-populated data dir.
|
|
105
|
+
const handle = await fileSystem.open(tmpPath, 'w');
|
|
106
|
+
try {
|
|
107
|
+
await handle.writeFile(version.toBuffer());
|
|
108
|
+
await handle.sync();
|
|
109
|
+
} finally {
|
|
110
|
+
await handle.close();
|
|
111
|
+
}
|
|
112
|
+
await fileSystem.rename(tmpPath, finalPath);
|
|
113
|
+
|
|
114
|
+
// Best-effort fsync of the containing directory so the rename itself survives a crash. Not all
|
|
115
|
+
// filesystems support directory fsync, so a failure here is non-fatal.
|
|
116
|
+
try {
|
|
117
|
+
const dirHandle = await fileSystem.open(dataDir, 'r');
|
|
118
|
+
try {
|
|
119
|
+
await dirHandle.sync();
|
|
120
|
+
} finally {
|
|
121
|
+
await dirHandle.close();
|
|
122
|
+
}
|
|
123
|
+
} catch {
|
|
124
|
+
// directory fsync is best-effort
|
|
125
|
+
}
|
|
84
126
|
}
|
|
85
127
|
|
|
86
128
|
/**
|
|
@@ -105,6 +147,17 @@ export class DatabaseVersionManager<T> {
|
|
|
105
147
|
storedVersion = DatabaseVersion.empty();
|
|
106
148
|
// only turn off these logs if the data dir didn't exist before
|
|
107
149
|
shouldLogDataReset = false;
|
|
150
|
+
} else if (this.versionFileReadFailurePolicy === 'throw') {
|
|
151
|
+
// The version file exists but could not be read/parsed (permissions, IO error, truncation).
|
|
152
|
+
// Treating this as "unversioned" would reset the data directory, silently wiping a store that
|
|
153
|
+
// must fail closed. Refuse to open instead, leaving the data untouched for the operator.
|
|
154
|
+
const code = (err as Error & { code?: string })?.code;
|
|
155
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
156
|
+
throw new Error(
|
|
157
|
+
`Failed to read database version file at ${this.versionFile} (${code ?? 'unknown error'}: ${message}). ` +
|
|
158
|
+
`Refusing to open the database; data was NOT reset. Resolve the underlying filesystem error and retry.`,
|
|
159
|
+
{ cause: err },
|
|
160
|
+
);
|
|
108
161
|
} else {
|
|
109
162
|
this.log.warn(`Failed to read stored version information: ${err}. Defaulting to empty version`);
|
|
110
163
|
storedVersion = DatabaseVersion.empty();
|
|
@@ -159,10 +212,47 @@ export class DatabaseVersionManager<T> {
|
|
|
159
212
|
await this.resetDataDirectory();
|
|
160
213
|
}
|
|
161
214
|
|
|
162
|
-
//
|
|
163
|
-
|
|
215
|
+
// Open the database first, then record the version marker. Writing the marker only after a
|
|
216
|
+
// successful open makes it a post-commit record: if the process crashes between the reset and a
|
|
217
|
+
// durable open, no marker is left behind, so the next startup re-runs the reset instead of
|
|
218
|
+
// trusting a marker that sits over empty or partially-initialized data.
|
|
219
|
+
const instance = await this.onOpen(this.dataDirectory);
|
|
164
220
|
|
|
165
|
-
|
|
221
|
+
// Only (re)write the marker when it would actually change — first boot, reset, or upgrade. On a
|
|
222
|
+
// normal boot it already matches, so skipping avoids an unnecessary fsync (and the directory
|
|
223
|
+
// write permission the temp-file+rename needs) and, more importantly, any window where a
|
|
224
|
+
// marker-write failure would orphan the database we just opened.
|
|
225
|
+
if (!storedVersion.equals(this.currentVersion)) {
|
|
226
|
+
try {
|
|
227
|
+
await this.writeVersion();
|
|
228
|
+
} catch (err) {
|
|
229
|
+
// The database opened but recording the marker failed; close the freshly opened instance so
|
|
230
|
+
// we do not leak its file handles / locks before propagating the failure.
|
|
231
|
+
await this.closeQuietly(instance);
|
|
232
|
+
throw err;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return [instance, needsReset];
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Best-effort close of a just-opened database instance, used to avoid leaking handles/locks when a
|
|
241
|
+
* post-open step fails. Swallows close errors so the original failure is the one that propagates.
|
|
242
|
+
*/
|
|
243
|
+
private async closeQuietly(instance: T): Promise<void> {
|
|
244
|
+
const closable = instance as
|
|
245
|
+
| { close?: () => Promise<void> | void; [Symbol.asyncDispose]?: () => Promise<void> }
|
|
246
|
+
| undefined;
|
|
247
|
+
const dispose = closable?.close ?? closable?.[Symbol.asyncDispose];
|
|
248
|
+
if (typeof dispose !== 'function') {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
try {
|
|
252
|
+
await dispose.call(closable);
|
|
253
|
+
} catch (err) {
|
|
254
|
+
this.log.warn(`Failed to close database after version-write failure: ${err}`);
|
|
255
|
+
}
|
|
166
256
|
}
|
|
167
257
|
|
|
168
258
|
/**
|
|
@@ -4,6 +4,7 @@ import { GoogleCloudFileStore } from './gcs.js';
|
|
|
4
4
|
import { HttpFileStore, type HttpFileStoreOptions } from './http.js';
|
|
5
5
|
import type { FileStore, ReadOnlyFileStore } from './interface.js';
|
|
6
6
|
import { LocalFileStore } from './local.js';
|
|
7
|
+
import { InMemoryFileStore } from './memory.js';
|
|
7
8
|
import { S3FileStore } from './s3.js';
|
|
8
9
|
|
|
9
10
|
const supportedExamples = [
|
|
@@ -21,6 +22,12 @@ export async function createFileStore(
|
|
|
21
22
|
): Promise<FileStore | undefined> {
|
|
22
23
|
if (config === undefined) {
|
|
23
24
|
return undefined;
|
|
25
|
+
} else if (config.startsWith('mem://')) {
|
|
26
|
+
// In-memory store for tests (see InMemoryFileStore). The namespace is everything after the
|
|
27
|
+
// scheme, so `mem://X` and a later `mem://X` share data, like two file:// stores over one dir.
|
|
28
|
+
const namespace = config.slice('mem://'.length).replace(/\/+$/, '');
|
|
29
|
+
logger.info(`Creating in-memory file store at ${namespace}`);
|
|
30
|
+
return new InMemoryFileStore(namespace);
|
|
24
31
|
} else if (config.startsWith('file://')) {
|
|
25
32
|
const url = new URL(config);
|
|
26
33
|
if (url.host) {
|
package/src/file-store/index.ts
CHANGED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { writeFile } from 'fs/promises';
|
|
2
|
+
import { promisify } from 'util';
|
|
3
|
+
import { gunzip as gunzipCb, gzip as gzipCb } from 'zlib';
|
|
4
|
+
|
|
5
|
+
import type { FileStore, FileStoreSaveOptions } from './interface.js';
|
|
6
|
+
|
|
7
|
+
const gzip = promisify(gzipCb);
|
|
8
|
+
const gunzip = promisify(gunzipCb);
|
|
9
|
+
|
|
10
|
+
// Backing data is shared per namespace so that a store created for writing and a (read-only) store
|
|
11
|
+
// created later from the same `mem://` URL observe the same files — mirroring how two `file://`
|
|
12
|
+
// stores over the same directory share state on disk. Without this, `FileStoreTxSource`, which
|
|
13
|
+
// builds its own store from the URL, would never see what a test wrote through a different instance.
|
|
14
|
+
const namespaces = new Map<string, Map<string, Buffer>>();
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* In-memory {@link FileStore}, addressed via `mem://<namespace>/...`. Reads and writes are synchronous
|
|
18
|
+
* map operations with no disk I/O, so it is deterministic — useful for tests that exercise consumers
|
|
19
|
+
* of a file store (e.g. the tx file store) rather than the on-disk store itself, where a real
|
|
20
|
+
* filesystem can introduce timing flakes.
|
|
21
|
+
*/
|
|
22
|
+
export class InMemoryFileStore implements FileStore {
|
|
23
|
+
private readonly files: Map<string, Buffer>;
|
|
24
|
+
|
|
25
|
+
constructor(private readonly namespace: string) {
|
|
26
|
+
let files = namespaces.get(namespace);
|
|
27
|
+
if (!files) {
|
|
28
|
+
files = new Map();
|
|
29
|
+
namespaces.set(namespace, files);
|
|
30
|
+
}
|
|
31
|
+
this.files = files;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Clears all in-memory file store data, or a single namespace. Intended for test isolation. */
|
|
35
|
+
static clear(namespace?: string): void {
|
|
36
|
+
if (namespace === undefined) {
|
|
37
|
+
namespaces.clear();
|
|
38
|
+
} else {
|
|
39
|
+
namespaces.delete(namespace);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public async save(path: string, data: Buffer, opts?: FileStoreSaveOptions): Promise<string> {
|
|
44
|
+
const toStore = opts?.compress ? await gzip(data) : data;
|
|
45
|
+
const key = this.key(path);
|
|
46
|
+
this.files.set(key, Buffer.from(toStore));
|
|
47
|
+
return `mem://${this.namespace}/${key}`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public async upload(destPath: string, srcPath: string, opts?: FileStoreSaveOptions): Promise<string> {
|
|
51
|
+
const { readFile } = await import('fs/promises');
|
|
52
|
+
return this.save(destPath, await readFile(srcPath), opts);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public async read(pathOrUrl: string): Promise<Buffer> {
|
|
56
|
+
const data = this.files.get(this.key(pathOrUrl));
|
|
57
|
+
if (data === undefined) {
|
|
58
|
+
throw new Error(`File not found in memory store: ${pathOrUrl}`);
|
|
59
|
+
}
|
|
60
|
+
// Match LocalFileStore: transparently gunzip content that was stored compressed.
|
|
61
|
+
if (data.length >= 2 && data[0] === 0x1f && data[1] === 0x8b) {
|
|
62
|
+
return await gunzip(data);
|
|
63
|
+
}
|
|
64
|
+
return data;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public async download(pathOrUrl: string, destPath: string): Promise<void> {
|
|
68
|
+
await writeFile(destPath, await this.read(pathOrUrl));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public exists(pathOrUrl: string): Promise<boolean> {
|
|
72
|
+
return Promise.resolve(this.files.has(this.key(pathOrUrl)));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Lists stored file keys, optionally restricted to those under `prefix`. Not part of {@link FileStore}. */
|
|
76
|
+
public listFiles(prefix = ''): string[] {
|
|
77
|
+
const keys = [...this.files.keys()];
|
|
78
|
+
const normalizedPrefix = prefix.replace(/^\/+/, '');
|
|
79
|
+
return normalizedPrefix ? keys.filter(k => k.startsWith(normalizedPrefix)) : keys;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Resolves a relative path or a `mem://` URI (as returned by `save`) to the registry key. */
|
|
83
|
+
private key(pathOrUrl: string): string {
|
|
84
|
+
const ownPrefix = `mem://${this.namespace}/`;
|
|
85
|
+
if (pathOrUrl.startsWith(ownPrefix)) {
|
|
86
|
+
return pathOrUrl.slice(ownPrefix.length);
|
|
87
|
+
}
|
|
88
|
+
if (pathOrUrl.startsWith('mem://')) {
|
|
89
|
+
// A mem:// URI for some namespace: drop the scheme and the leading namespace segment.
|
|
90
|
+
return pathOrUrl.slice('mem://'.length).replace(/^[^/]*\//, '');
|
|
91
|
+
}
|
|
92
|
+
return pathOrUrl.replace(/^\/+/, '');
|
|
93
|
+
}
|
|
94
|
+
}
|
package/src/ha-signing/config.ts
CHANGED
|
@@ -25,8 +25,20 @@ export type BaseSignerConfig = {
|
|
|
25
25
|
nodeId: string;
|
|
26
26
|
/** How long to wait between polls when a duty is being signed (ms) */
|
|
27
27
|
pollingIntervalMs: number;
|
|
28
|
-
/**
|
|
29
|
-
|
|
28
|
+
/**
|
|
29
|
+
* How long (ms) to wait for a peer node's in-progress signing before giving up and treating the
|
|
30
|
+
* duty as already handled. This is the cross-node wait/poll timeout, distinct from
|
|
31
|
+
* signerCallTimeoutMs (the hard upper bound on this node's own signer call).
|
|
32
|
+
*/
|
|
33
|
+
peerSigningTimeoutMs: number;
|
|
34
|
+
/**
|
|
35
|
+
* Hard upper bound (ms) on a single signer call made by this node. If the (possibly remote)
|
|
36
|
+
* signer does not return within this time, the call is aborted, the duty lock is released, and
|
|
37
|
+
* signing fails so it can be safely retried. The effective value is clamped to
|
|
38
|
+
* maxStuckDutiesAgeMs / 2 at construction, so a slow signer's lock is always released before
|
|
39
|
+
* stuck-duty cleanup could reclaim it. Defaults to 30_000 when unset.
|
|
40
|
+
*/
|
|
41
|
+
signerCallTimeoutMs?: number;
|
|
30
42
|
/** Maximum age of a stuck duty in ms (defaults to 2x hardcoded Aztec slot duration if not set) */
|
|
31
43
|
maxStuckDutiesAgeMs?: number;
|
|
32
44
|
/** Optional: clean up old duties after this many hours (disabled if not set) */
|
|
@@ -44,11 +56,16 @@ export const baseSignerConfigMappings: ConfigMappingsType<BaseSignerConfig> = {
|
|
|
44
56
|
description: 'The number of ms to wait between polls when a duty is being signed',
|
|
45
57
|
...numberConfigHelper(100),
|
|
46
58
|
},
|
|
47
|
-
|
|
59
|
+
peerSigningTimeoutMs: {
|
|
48
60
|
env: 'VALIDATOR_HA_SIGNING_TIMEOUT_MS',
|
|
49
|
-
description:
|
|
61
|
+
description: "How long to wait for a peer node's in-progress signing before giving up",
|
|
50
62
|
...numberConfigHelper(3_000),
|
|
51
63
|
},
|
|
64
|
+
signerCallTimeoutMs: {
|
|
65
|
+
env: 'VALIDATOR_SIGNER_CALL_TIMEOUT_MS',
|
|
66
|
+
description: 'Hard upper bound in ms on a single signer call before it is aborted (default 30000)',
|
|
67
|
+
...numberConfigHelper(30_000),
|
|
68
|
+
},
|
|
52
69
|
maxStuckDutiesAgeMs: {
|
|
53
70
|
env: 'VALIDATOR_HA_MAX_STUCK_DUTIES_AGE_MS',
|
|
54
71
|
description: 'The maximum age of a stuck duty in ms (defaults to 2x Aztec slot duration)',
|
|
@@ -65,7 +82,8 @@ export const baseSignerConfigMappings: ConfigMappingsType<BaseSignerConfig> = {
|
|
|
65
82
|
export const BaseSignerConfigSchema = z.object({
|
|
66
83
|
nodeId: z.string(),
|
|
67
84
|
pollingIntervalMs: z.number().min(0),
|
|
68
|
-
|
|
85
|
+
peerSigningTimeoutMs: z.number().min(0),
|
|
86
|
+
signerCallTimeoutMs: z.number().min(0).optional(),
|
|
69
87
|
maxStuckDutiesAgeMs: z.number().min(0).optional(),
|
|
70
88
|
cleanupOldDutiesAfterHours: z.number().min(0).optional(),
|
|
71
89
|
...pickL1ContractAddressesSchema('rollupAddress'),
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type ConfigMappingsType,
|
|
3
|
+
booleanConfigHelper,
|
|
4
|
+
getConfigFromMappings,
|
|
5
|
+
optionalNumberConfigHelper,
|
|
6
|
+
} from '@aztec/foundation/config';
|
|
2
7
|
import { zodFor } from '@aztec/foundation/schemas';
|
|
3
8
|
import { type DataStoreConfig, dataConfigMappings } from '@aztec/stdlib/kv-store';
|
|
4
9
|
|
|
@@ -17,6 +22,12 @@ export type LocalSignerConfig = BaseSignerConfig &
|
|
|
17
22
|
DataStoreConfig & {
|
|
18
23
|
/** Maximum size of the local signing-protection LMDB store in KB. Overwrites the general dataStoreMapSizeKb. */
|
|
19
24
|
signingProtectionMapSizeKb?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Allow local signing protection to run against an ephemeral store when no data directory is set.
|
|
27
|
+
* Without this, a missing data directory fails startup, since ephemeral protection does not survive
|
|
28
|
+
* restarts. Intended for dev/test networks only; production validators must persist to disk.
|
|
29
|
+
*/
|
|
30
|
+
allowEphemeralSigningProtection?: boolean;
|
|
20
31
|
};
|
|
21
32
|
|
|
22
33
|
export const localSignerConfigMappings: ConfigMappingsType<LocalSignerConfig> = {
|
|
@@ -28,6 +39,13 @@ export const localSignerConfigMappings: ConfigMappingsType<LocalSignerConfig> =
|
|
|
28
39
|
'Maximum size of the local signing-protection LMDB store in KB. Overwrites the general dataStoreMapSizeKb.',
|
|
29
40
|
...optionalNumberConfigHelper(),
|
|
30
41
|
},
|
|
42
|
+
allowEphemeralSigningProtection: {
|
|
43
|
+
env: 'VALIDATOR_ALLOW_EPHEMERAL_SIGNING_PROTECTION',
|
|
44
|
+
description:
|
|
45
|
+
'Allow local signing protection to run against an ephemeral store when no data directory is set (dev/test only). ' +
|
|
46
|
+
'Ephemeral protection does not survive restarts, so this is unsafe for production validators.',
|
|
47
|
+
...booleanConfigHelper(false),
|
|
48
|
+
},
|
|
31
49
|
};
|
|
32
50
|
|
|
33
51
|
export const LocalSignerConfigSchema = zodFor<LocalSignerConfig>()(
|
|
@@ -35,6 +53,7 @@ export const LocalSignerConfigSchema = zodFor<LocalSignerConfig>()(
|
|
|
35
53
|
dataDirectory: z.string().optional(),
|
|
36
54
|
dataStoreMapSizeKb: z.number(),
|
|
37
55
|
signingProtectionMapSizeKb: z.number().optional(),
|
|
56
|
+
allowEphemeralSigningProtection: z.boolean().optional(),
|
|
38
57
|
}),
|
|
39
58
|
);
|
|
40
59
|
|
package/src/hash/hash.ts
CHANGED
|
@@ -188,14 +188,6 @@ export function computeSecretHash(secret: Fr): Promise<Fr> {
|
|
|
188
188
|
return poseidon2HashWithSeparator([secret], DomainSeparator.SECRET_HASH);
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
-
export async function computeL1ToL2MessageNullifier(contract: AztecAddress, messageHash: Fr, secret: Fr) {
|
|
192
|
-
const innerMessageNullifier = await poseidon2HashWithSeparator(
|
|
193
|
-
[messageHash, secret],
|
|
194
|
-
DomainSeparator.MESSAGE_NULLIFIER,
|
|
195
|
-
);
|
|
196
|
-
return siloNullifier(contract, innerMessageNullifier);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
191
|
/**
|
|
200
192
|
* Calculates a siloed hash of a scoped l2 to l1 message.
|
|
201
193
|
* @returns Fr containing 248 bits of information of sha256 hash.
|
|
@@ -68,6 +68,13 @@ export type ArchiverSpecificConfig = {
|
|
|
68
68
|
|
|
69
69
|
/** Skip pruning orphan proposed blocks that have no matching proposed checkpoint. */
|
|
70
70
|
skipOrphanProposedBlockPruning?: boolean;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Preload the standard contracts (AuthRegistry, PublicChecks, HandshakeRegistry) into the contract store at block 0.
|
|
74
|
+
* For test environments only: it must only be set when genesis also seeds the matching registration/deployment
|
|
75
|
+
* nullifiers, otherwise a later on-chain publish of a preloaded class would collide with the block-0 preload.
|
|
76
|
+
*/
|
|
77
|
+
testPreloadStandardContracts?: boolean;
|
|
71
78
|
};
|
|
72
79
|
|
|
73
80
|
export const ArchiverSpecificConfigSchema = z.object({
|
|
@@ -82,6 +89,7 @@ export const ArchiverSpecificConfigSchema = z.object({
|
|
|
82
89
|
skipPromoteProposedCheckpointDuringL1Sync: z.boolean().optional(),
|
|
83
90
|
orphanPruneNoProposalTolerance: schemas.Integer.optional(),
|
|
84
91
|
skipOrphanProposedBlockPruning: z.boolean().optional(),
|
|
92
|
+
testPreloadStandardContracts: z.boolean().optional(),
|
|
85
93
|
});
|
|
86
94
|
|
|
87
95
|
export type ArchiverApi = Omit<
|
|
@@ -122,7 +130,7 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
|
|
|
122
130
|
getContractClass: z.function({ input: z.tuple([schemas.Fr]), output: ContractClassPublicSchema.optional() }),
|
|
123
131
|
getBytecodeCommitment: z.function({ input: z.tuple([schemas.Fr]), output: schemas.Fr }),
|
|
124
132
|
getContract: z.function({
|
|
125
|
-
input: z.tuple([schemas.AztecAddress,
|
|
133
|
+
input: z.tuple([schemas.AztecAddress, schemas.BigInt]),
|
|
126
134
|
output: ContractInstanceWithAddressSchema.optional(),
|
|
127
135
|
}),
|
|
128
136
|
getContractClassIds: z.function({ input: z.tuple([]), output: z.array(schemas.Fr) }),
|
|
@@ -6,6 +6,9 @@ import { z } from 'zod';
|
|
|
6
6
|
import { type ApiSchemaFor, optional } from '../schemas/schemas.js';
|
|
7
7
|
import { type ComponentsVersions, getVersioningResponseHandler } from '../versioning/index.js';
|
|
8
8
|
|
|
9
|
+
const MAX_SIGNATURES_PER_REGISTER_CALL = 100;
|
|
10
|
+
const MAX_SIGNATURE_LEN = 10000;
|
|
11
|
+
|
|
9
12
|
/**
|
|
10
13
|
* Debug interface for Aztec node available in sandbox/local-network mode.
|
|
11
14
|
*/
|
|
@@ -33,11 +36,45 @@ export interface AztecNodeDebug {
|
|
|
33
36
|
* @throws If no automine sequencer is running (only the automine sequencer supports synthetic proving).
|
|
34
37
|
*/
|
|
35
38
|
prove(upToCheckpoint?: CheckpointNumber): Promise<CheckpointNumber>;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Warps L1 time forward to at least `targetTimestamp` and builds an empty L2 checkpoint at the next slot boundary,
|
|
42
|
+
* advancing the L2 timestamp to at least the target. The warp is serialized with block building, so it never
|
|
43
|
+
* interleaves with an in-flight build. A no-op when `targetTimestamp` is already at or behind the current L1 time.
|
|
44
|
+
*
|
|
45
|
+
* @param targetTimestamp - Target L1 timestamp, in seconds.
|
|
46
|
+
* @throws If no automine sequencer is running (only the automine sequencer supports time warps).
|
|
47
|
+
*/
|
|
48
|
+
warpL2TimeAtLeastTo(targetTimestamp: number): Promise<void>;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Warps L1 time forward by at least `duration` seconds from the current L1 time and builds an empty L2 checkpoint
|
|
52
|
+
* at the next slot boundary. The warp is serialized with block building, so it never interleaves with an in-flight
|
|
53
|
+
* build.
|
|
54
|
+
*
|
|
55
|
+
* @param duration - Number of seconds to advance; must be positive.
|
|
56
|
+
* @throws If no automine sequencer is running, or if `duration` is not positive.
|
|
57
|
+
*/
|
|
58
|
+
warpL2TimeAtLeastBy(duration: number): Promise<void>;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Registers public function signatures so the node can resolve selectors to names in public-execution stack
|
|
62
|
+
* traces. The mapping lives only in unpersisted node memory, is not gossiped, and is exposed here (rather than on
|
|
63
|
+
* the main node API) because it is a debug-only, unauthenticated write that should not be reachable on prod nodes.
|
|
64
|
+
* @param functionSignatures - Decoded `name(paramTypes)` signatures to register by selector.
|
|
65
|
+
*/
|
|
66
|
+
registerContractFunctionSignatures(functionSignatures: string[]): Promise<void>;
|
|
36
67
|
}
|
|
37
68
|
|
|
38
69
|
export const AztecNodeDebugApiSchema: ApiSchemaFor<AztecNodeDebug> = {
|
|
39
70
|
mineBlock: z.function({ input: z.tuple([]), output: z.void() }),
|
|
40
71
|
prove: z.function({ input: z.tuple([optional(CheckpointNumberSchema)]), output: CheckpointNumberSchema }),
|
|
72
|
+
warpL2TimeAtLeastTo: z.function({ input: z.tuple([z.number()]), output: z.void() }),
|
|
73
|
+
warpL2TimeAtLeastBy: z.function({ input: z.tuple([z.number()]), output: z.void() }),
|
|
74
|
+
registerContractFunctionSignatures: z.function({
|
|
75
|
+
input: z.tuple([z.array(z.string().max(MAX_SIGNATURE_LEN)).max(MAX_SIGNATURES_PER_REGISTER_CALL)]),
|
|
76
|
+
output: z.void(),
|
|
77
|
+
}),
|
|
41
78
|
};
|
|
42
79
|
|
|
43
80
|
export function createAztecNodeDebugClient(
|
|
@@ -23,9 +23,15 @@ import { z } from 'zod';
|
|
|
23
23
|
import type { AztecAddress } from '../aztec-address/index.js';
|
|
24
24
|
import { type BlockData, BlockDataSchema } from '../block/block_data.js';
|
|
25
25
|
import { BlockHash } from '../block/block_hash.js';
|
|
26
|
-
import { type BlockParameter, BlockParameterSchema } from '../block/block_parameter.js';
|
|
26
|
+
import { type BlockParameter, BlockParameterSchema, BlockTagWithoutLatestSchema } from '../block/block_parameter.js';
|
|
27
27
|
import { type DataInBlock, dataInBlockSchemaFor } from '../block/in_block.js';
|
|
28
|
-
import {
|
|
28
|
+
import {
|
|
29
|
+
type CheckpointsQuery,
|
|
30
|
+
CheckpointsQuerySchema,
|
|
31
|
+
type L2BlockTag,
|
|
32
|
+
type L2Tips,
|
|
33
|
+
L2TipsSchema,
|
|
34
|
+
} from '../block/l2_block_source.js';
|
|
29
35
|
import { type CheckpointData, CheckpointDataSchema } from '../checkpoint/checkpoint_data.js';
|
|
30
36
|
import {
|
|
31
37
|
type ContractClassPublic,
|
|
@@ -80,7 +86,7 @@ import {
|
|
|
80
86
|
type BlocksIncludeOptions,
|
|
81
87
|
BlocksIncludeOptionsSchema,
|
|
82
88
|
} from './block_response.js';
|
|
83
|
-
import { type
|
|
89
|
+
import { type CheckpointTag, CheckpointTagSchema } from './chain_tips.js';
|
|
84
90
|
import { type CheckpointParameter, CheckpointParameterSchema } from './checkpoint_parameter.js';
|
|
85
91
|
import {
|
|
86
92
|
type CheckpointIncludeOptions,
|
|
@@ -232,23 +238,20 @@ export interface AztecNode {
|
|
|
232
238
|
): Promise<L2ToL1MembershipWitness | undefined>;
|
|
233
239
|
|
|
234
240
|
/**
|
|
235
|
-
* Returns the block number at a given
|
|
241
|
+
* Returns the block number at a given block tag, or the latest proposed block number when
|
|
236
242
|
* `tip` is omitted.
|
|
237
243
|
*/
|
|
238
|
-
getBlockNumber(tip?:
|
|
244
|
+
getBlockNumber(tip?: L2BlockTag): Promise<BlockNumber>;
|
|
239
245
|
|
|
240
246
|
/**
|
|
241
|
-
* Returns the checkpoint number at a given
|
|
242
|
-
* `tip` is omitted.
|
|
243
|
-
*
|
|
244
|
-
* @remarks **Semantic foot-gun**: block-side `'proposed'` means "latest proposed block" (chain
|
|
245
|
-
* head), but checkpoint-side `'proposed'` means "latest confirmed checkpoint" — pre-L1-confirm
|
|
246
|
-
* checkpoints are not exposed over RPC. `'checkpointed'` on the checkpoint side is equivalent.
|
|
247
|
+
* Returns the checkpoint number at a given checkpoint tag, or the latest checkpointed number when
|
|
248
|
+
* `tip` is omitted. The proposed-but-unconfirmed checkpoint frontier is archiver-internal and not
|
|
249
|
+
* exposed over RPC, so `'proposed'` is not a valid checkpoint tag (see {@link CheckpointTag}).
|
|
247
250
|
*/
|
|
248
|
-
getCheckpointNumber(tip?:
|
|
251
|
+
getCheckpointNumber(tip?: CheckpointTag): Promise<CheckpointNumber>;
|
|
249
252
|
|
|
250
253
|
/** Returns the tips of the L2 chain. */
|
|
251
|
-
getChainTips(): Promise<
|
|
254
|
+
getChainTips(): Promise<L2Tips>;
|
|
252
255
|
|
|
253
256
|
/** Returns the rollup constants for the current chain. */
|
|
254
257
|
getL1Constants(): Promise<L1RollupConstants>;
|
|
@@ -382,12 +385,6 @@ export interface AztecNode {
|
|
|
382
385
|
*/
|
|
383
386
|
getProtocolContractAddresses(): Promise<ProtocolContractAddresses>;
|
|
384
387
|
|
|
385
|
-
/**
|
|
386
|
-
* Registers contract function signatures for debugging purposes.
|
|
387
|
-
* @param functionSignatures - An array of function signatures to register by selector.
|
|
388
|
-
*/
|
|
389
|
-
registerContractFunctionSignatures(functionSignatures: string[]): Promise<void>;
|
|
390
|
-
|
|
391
388
|
/**
|
|
392
389
|
* Gets private logs matching the given tags. Returns one inner array per element of `query.tags`, in
|
|
393
390
|
* input order. An empty inner array means no logs matched that tag. Set `query.includeEffects` to also
|
|
@@ -525,10 +522,18 @@ export interface AztecNode {
|
|
|
525
522
|
getContractClass(id: Fr): Promise<ContractClassPublic | undefined>;
|
|
526
523
|
|
|
527
524
|
/**
|
|
528
|
-
* Returns a publicly deployed contract instance given its address.
|
|
525
|
+
* Returns a publicly deployed contract instance given its address. Its current class id is resolved as of the given
|
|
526
|
+
* reference block.
|
|
527
|
+
*
|
|
528
|
+
* Returns `undefined` if the instance has not been published (i.e. `publish_for_public_execution` was never called
|
|
529
|
+
* on the `ContractInstanceRegistry`). A contract whose class has been updated will never return `undefined`:
|
|
530
|
+
* scheduling an update requires the contract's deployment nullifier, which is only emitted by publishing, so any
|
|
531
|
+
* updatable contract has necessarily been published.
|
|
529
532
|
* @param address - Address of the deployed contract.
|
|
533
|
+
* @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
534
|
+
* Defaults to 'latest'.
|
|
530
535
|
*/
|
|
531
|
-
getContract(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined>;
|
|
536
|
+
getContract(address: AztecAddress, referenceBlock?: BlockParameter): Promise<ContractInstanceWithAddress | undefined>;
|
|
532
537
|
|
|
533
538
|
/**
|
|
534
539
|
* Returns the ENR of this node for peer discovery, if available.
|
|
@@ -566,9 +571,6 @@ export interface AztecNode {
|
|
|
566
571
|
getProposalsForSlot(slot: SlotNumber): Promise<ProposalsForSlot>;
|
|
567
572
|
}
|
|
568
573
|
|
|
569
|
-
const MAX_SIGNATURES_PER_REGISTER_CALL = 100;
|
|
570
|
-
const MAX_SIGNATURE_LEN = 10000;
|
|
571
|
-
|
|
572
574
|
export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
|
|
573
575
|
getWorldStateSyncStatus: z.function({ input: z.tuple([]), output: WorldStateSyncStatusSchema }),
|
|
574
576
|
|
|
@@ -622,11 +624,11 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
|
|
|
622
624
|
output: L2ToL1MembershipWitnessSchema.optional(),
|
|
623
625
|
}),
|
|
624
626
|
|
|
625
|
-
getBlockNumber: z.function({ input: z.tuple([optional(
|
|
627
|
+
getBlockNumber: z.function({ input: z.tuple([optional(BlockTagWithoutLatestSchema)]), output: BlockNumberSchema }),
|
|
626
628
|
|
|
627
|
-
getCheckpointNumber: z.function({ input: z.tuple([optional(
|
|
629
|
+
getCheckpointNumber: z.function({ input: z.tuple([optional(CheckpointTagSchema)]), output: CheckpointNumberSchema }),
|
|
628
630
|
|
|
629
|
-
getChainTips: z.function({ input: z.tuple([]), output:
|
|
631
|
+
getChainTips: z.function({ input: z.tuple([]), output: L2TipsSchema }),
|
|
630
632
|
|
|
631
633
|
getL1Constants: z.function({ input: z.tuple([]), output: L1RollupConstantsSchema }),
|
|
632
634
|
|
|
@@ -691,11 +693,6 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
|
|
|
691
693
|
|
|
692
694
|
getProtocolContractAddresses: z.function({ input: z.tuple([]), output: ProtocolContractAddressesSchema }),
|
|
693
695
|
|
|
694
|
-
registerContractFunctionSignatures: z.function({
|
|
695
|
-
input: z.tuple([z.array(z.string().max(MAX_SIGNATURE_LEN)).max(MAX_SIGNATURES_PER_REGISTER_CALL)]),
|
|
696
|
-
output: z.void(),
|
|
697
|
-
}),
|
|
698
|
-
|
|
699
696
|
getPrivateLogsByTags: z.function({
|
|
700
697
|
input: z.tuple([PrivateLogsQuerySchema]),
|
|
701
698
|
output: z.array(z.array(LogResultSchema)),
|
|
@@ -769,7 +766,7 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
|
|
|
769
766
|
getContractClass: z.function({ input: z.tuple([schemas.Fr]), output: ContractClassPublicSchema.optional() }),
|
|
770
767
|
|
|
771
768
|
getContract: z.function({
|
|
772
|
-
input: z.tuple([schemas.AztecAddress]),
|
|
769
|
+
input: z.tuple([schemas.AztecAddress, optional(BlockParameterSchema)]),
|
|
773
770
|
output: ContractInstanceWithAddressSchema.optional(),
|
|
774
771
|
}),
|
|
775
772
|
|
|
@@ -1,24 +1,16 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
-
import { type L2BlockTag, type L2Tips, L2TipsSchema } from '../block/l2_block_source.js';
|
|
4
|
-
|
|
5
3
|
/**
|
|
6
|
-
* Public
|
|
7
|
-
*
|
|
4
|
+
* Public checkpoint-tip selectors usable in RPC requests.
|
|
5
|
+
*
|
|
6
|
+
* `'proposed'` is intentionally excluded: the proposed-but-unconfirmed checkpoint frontier is an
|
|
7
|
+
* archiver-internal pipelining concept, not part of the public chain-tip surface. Select the
|
|
8
|
+
* proposed *block* tip with a block tag (`L2BlockTag`) instead.
|
|
8
9
|
*/
|
|
9
|
-
export type
|
|
10
|
+
export type CheckpointTag = 'checkpointed' | 'proven' | 'finalized';
|
|
10
11
|
|
|
11
|
-
export const
|
|
12
|
-
z.literal('proposed'),
|
|
12
|
+
export const CheckpointTagSchema = z.union([
|
|
13
13
|
z.literal('checkpointed'),
|
|
14
14
|
z.literal('proven'),
|
|
15
15
|
z.literal('finalized'),
|
|
16
|
-
]) satisfies z.ZodType<
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Tips of the L2 chain.
|
|
20
|
-
* Omits the sequencer-internal `proposedCheckpoint` from the public RPC surface.
|
|
21
|
-
*/
|
|
22
|
-
export type ChainTips = Omit<L2Tips, 'proposedCheckpoint'>;
|
|
23
|
-
|
|
24
|
-
export const ChainTipsSchema = L2TipsSchema.omit({ proposedCheckpoint: true });
|
|
16
|
+
]) satisfies z.ZodType<CheckpointTag>;
|