@aztec/pxe 5.0.0-rc.2 → 5.0.1
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/block_synchronizer/block_synchronizer.d.ts +5 -3
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +7 -1
- package/dest/contract/contract_class_service.d.ts +31 -0
- package/dest/contract/contract_class_service.d.ts.map +1 -0
- package/dest/contract/contract_class_service.js +68 -0
- package/dest/{contract_sync → contract}/contract_sync_service.d.ts +7 -6
- package/dest/contract/contract_sync_service.d.ts.map +1 -0
- package/dest/{contract_sync → contract}/contract_sync_service.js +10 -30
- package/dest/contract/helpers.d.ts +7 -0
- package/dest/contract/helpers.d.ts.map +1 -0
- package/dest/contract/helpers.js +20 -0
- package/dest/contract_function_simulator/anchored_contract_data.d.ts +36 -0
- package/dest/contract_function_simulator/anchored_contract_data.d.ts.map +1 -0
- package/dest/contract_function_simulator/anchored_contract_data.js +54 -0
- package/dest/contract_function_simulator/aztec_node_read_cache.d.ts +39 -0
- package/dest/contract_function_simulator/aztec_node_read_cache.d.ts.map +1 -0
- package/dest/contract_function_simulator/aztec_node_read_cache.js +60 -0
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +9 -3
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +31 -14
- package/dest/contract_function_simulator/execution_note_cache.d.ts +3 -9
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.js +8 -28
- package/dest/contract_function_simulator/index.d.ts +4 -2
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +2 -1
- package/dest/contract_function_simulator/noir-structs/fact.d.ts +5 -5
- package/dest/contract_function_simulator/noir-structs/fact.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/fact.js +2 -2
- package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts +3 -3
- package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/fact_collection.js +3 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +7 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/pending_tagged_log.d.ts +11 -0
- package/dest/contract_function_simulator/noir-structs/pending_tagged_log.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/pending_tagged_log.js +4 -0
- package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts +2 -2
- package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/provided_secret.js +1 -1
- package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts +8 -1
- package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.js +17 -0
- package/dest/contract_function_simulator/oracle/acir_callback.d.ts +7 -2
- package/dest/contract_function_simulator/oracle/acir_callback.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/acir_callback.js +55 -11
- package/dest/contract_function_simulator/oracle/legacy_oracle_registry.d.ts +39 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_registry.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_registry.js +107 -0
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts +11 -7
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle_registry.js +50 -10
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts +48 -9
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.js +51 -30
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +10 -2
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +73 -32
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +23 -16
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +105 -60
- package/dest/debug/pxe_debug_utils.d.ts +2 -2
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.d.ts +2 -1
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +1 -0
- package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +11 -5
- package/dest/entrypoints/client/lazy/index.d.ts +2 -1
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +1 -0
- package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +11 -5
- package/dest/entrypoints/client/store.d.ts +14 -0
- package/dest/entrypoints/client/store.d.ts.map +1 -0
- package/dest/entrypoints/client/store.js +28 -0
- package/dest/entrypoints/server/index.d.ts +6 -2
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +4 -1
- package/dest/entrypoints/server/store.d.ts +18 -0
- package/dest/entrypoints/server/store.d.ts.map +1 -0
- package/dest/entrypoints/server/store.js +28 -0
- package/dest/entrypoints/server/utils.d.ts +1 -1
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +8 -2
- package/dest/error_enriching.d.ts +5 -3
- package/dest/error_enriching.d.ts.map +1 -1
- package/dest/error_enriching.js +12 -10
- package/dest/hooks/execution_hooks.d.ts +15 -4
- package/dest/hooks/execution_hooks.d.ts.map +1 -1
- package/dest/hooks/index.d.ts +3 -2
- package/dest/hooks/index.d.ts.map +1 -1
- package/dest/hooks/index.js +1 -0
- package/dest/hooks/resolve_custom_request.d.ts +23 -0
- package/dest/hooks/resolve_custom_request.d.ts.map +1 -0
- package/dest/hooks/resolve_custom_request.js +3 -0
- package/dest/hooks/resolve_tagging_secret_strategy.d.ts +10 -1
- package/dest/hooks/resolve_tagging_secret_strategy.d.ts.map +1 -1
- package/dest/hooks/resolve_tagging_secret_strategy.js +3 -3
- package/dest/logs/log_service.d.ts +5 -3
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +38 -17
- package/dest/notes/note_service.d.ts +1 -1
- package/dest/notes/note_service.js +1 -1
- package/dest/oracle_version.d.ts +2 -2
- package/dest/oracle_version.js +2 -2
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +6 -2
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +17 -36
- package/dest/private_kernel/private_kernel_oracle.d.ts +4 -2
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +17 -5
- package/dest/pxe.d.ts +81 -46
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +138 -104
- package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts +1 -1
- package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts.map +1 -1
- package/dest/storage/backwards_compatibility_tests/schema_tests.js +31 -7
- package/dest/storage/contract_store/contract_store.d.ts +27 -24
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +63 -74
- package/dest/storage/fact_store/fact_service.d.ts +6 -4
- package/dest/storage/fact_store/fact_service.d.ts.map +1 -1
- package/dest/storage/fact_store/fact_service.js +19 -4
- package/dest/storage/fact_store/fact_store.d.ts +1 -1
- package/dest/storage/fact_store/fact_store.js +1 -1
- package/dest/storage/fact_store/index.d.ts +2 -1
- package/dest/storage/fact_store/index.d.ts.map +1 -1
- package/dest/storage/fact_store/index.js +1 -0
- package/dest/storage/fact_store/origin_state.d.ts +57 -0
- package/dest/storage/fact_store/origin_state.d.ts.map +1 -0
- package/dest/storage/fact_store/origin_state.js +53 -0
- package/dest/storage/metadata.d.ts +2 -2
- package/dest/storage/metadata.d.ts.map +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/store_identity.d.ts +35 -0
- package/dest/storage/store_identity.d.ts.map +1 -0
- package/dest/storage/store_identity.js +44 -0
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +19 -3
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +48 -11
- package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts +17 -6
- package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/tagging_secret_sources_store.js +24 -11
- package/dest/tagging/constants.d.ts +2 -2
- package/dest/tagging/constants.d.ts.map +1 -1
- package/dest/tagging/constants.js +18 -9
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +1 -1
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +1 -1
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +6 -2
- package/package.json +17 -17
- package/src/block_synchronizer/block_synchronizer.ts +9 -1
- package/src/contract/contract_class_service.ts +83 -0
- package/src/{contract_sync → contract}/contract_sync_service.ts +18 -37
- package/src/contract/helpers.ts +35 -0
- package/src/contract_function_simulator/anchored_contract_data.ts +74 -0
- package/src/contract_function_simulator/aztec_node_read_cache.ts +89 -0
- package/src/contract_function_simulator/contract_function_simulator.ts +56 -14
- package/src/contract_function_simulator/execution_note_cache.ts +7 -28
- package/src/contract_function_simulator/index.ts +7 -1
- package/src/contract_function_simulator/noir-structs/fact.ts +4 -4
- package/src/contract_function_simulator/noir-structs/fact_collection.ts +9 -4
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +6 -0
- package/src/contract_function_simulator/noir-structs/pending_tagged_log.ts +12 -0
- package/src/contract_function_simulator/noir-structs/provided_secret.ts +1 -1
- package/src/contract_function_simulator/noir-structs/resolved_tagging_strategy.ts +21 -0
- package/src/contract_function_simulator/oracle/acir_callback.ts +58 -12
- package/src/contract_function_simulator/oracle/legacy_oracle_registry.ts +147 -0
- package/src/contract_function_simulator/oracle/oracle_registry.ts +37 -7
- package/src/contract_function_simulator/oracle/oracle_type_mappings.ts +49 -32
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +92 -41
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +149 -71
- package/src/debug/pxe_debug_utils.ts +1 -1
- package/src/entrypoints/client/bundle/index.ts +1 -0
- package/src/entrypoints/client/bundle/utils.ts +16 -4
- package/src/entrypoints/client/lazy/index.ts +1 -0
- package/src/entrypoints/client/lazy/utils.ts +16 -4
- package/src/entrypoints/client/store.ts +38 -0
- package/src/entrypoints/server/index.ts +6 -1
- package/src/entrypoints/server/store.ts +47 -0
- package/src/entrypoints/server/utils.ts +21 -7
- package/src/error_enriching.ts +26 -10
- package/src/hooks/execution_hooks.ts +14 -3
- package/src/hooks/index.ts +2 -0
- package/src/hooks/resolve_custom_request.ts +24 -0
- package/src/hooks/resolve_tagging_secret_strategy.ts +14 -0
- package/src/logs/log_service.ts +35 -11
- package/src/notes/note_service.ts +1 -1
- package/src/oracle_version.ts +2 -2
- package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +11 -1
- package/src/private_kernel/private_kernel_execution_prover.ts +22 -52
- package/src/private_kernel/private_kernel_oracle.ts +23 -4
- package/src/pxe.ts +212 -143
- package/src/storage/backwards_compatibility_tests/__snapshots__/AddressStore.json +6 -6
- package/src/storage/backwards_compatibility_tests/__snapshots__/ContractStore.json +1 -1
- package/src/storage/backwards_compatibility_tests/__snapshots__/KeyStore.json +12 -12
- package/src/storage/backwards_compatibility_tests/__snapshots__/RecipientTaggingStore.json +11 -3
- package/src/storage/backwards_compatibility_tests/__snapshots__/SenderTaggingStore.json +12 -4
- package/src/storage/backwards_compatibility_tests/__snapshots__/TaggingSecretSourcesStore.json +3 -3
- package/src/storage/backwards_compatibility_tests/__snapshots__/opened_stores.json +1 -1
- package/src/storage/backwards_compatibility_tests/schema_tests.ts +38 -4
- package/src/storage/contract_store/contract_store.ts +85 -92
- package/src/storage/fact_store/fact_service.ts +29 -5
- package/src/storage/fact_store/fact_store.ts +1 -1
- package/src/storage/fact_store/index.ts +10 -0
- package/src/storage/fact_store/origin_state.ts +75 -0
- package/src/storage/metadata.ts +1 -1
- package/src/storage/store_identity.ts +72 -0
- package/src/storage/tagging_store/sender_tagging_store.ts +62 -15
- package/src/storage/tagging_store/tagging_secret_sources_store.ts +36 -15
- package/src/tagging/constants.ts +19 -9
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +1 -1
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +6 -2
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +0 -6
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +0 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.js +0 -51
- package/dest/contract_sync/contract_sync_service.d.ts.map +0 -1
- package/dest/contract_sync/helpers.d.ts +0 -28
- package/dest/contract_sync/helpers.d.ts.map +0 -1
- package/dest/contract_sync/helpers.js +0 -48
- package/src/contract_function_simulator/proxied_contract_data_source.ts +0 -60
- package/src/contract_sync/helpers.ts +0 -79
|
@@ -4,7 +4,8 @@ import type { L2TipsKVStore } from '@aztec/kv-store/stores';
|
|
|
4
4
|
import { L2BlockStream, type L2BlockStreamEvent, type L2BlockStreamEventHandler } from '@aztec/stdlib/block';
|
|
5
5
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
6
6
|
import type { BlockSynchronizerConfig } from '../config/index.js';
|
|
7
|
-
import type {
|
|
7
|
+
import type { ContractClassService } from '../contract/contract_class_service.js';
|
|
8
|
+
import type { ContractSyncService } from '../contract/contract_sync_service.js';
|
|
8
9
|
import type { AnchorBlockStore } from '../storage/anchor_block_store/index.js';
|
|
9
10
|
import type { FactStore } from '../storage/fact_store/fact_store.js';
|
|
10
11
|
import type { NoteStore } from '../storage/note_store/index.js';
|
|
@@ -23,12 +24,13 @@ export declare class BlockSynchronizer implements L2BlockStreamEventHandler {
|
|
|
23
24
|
private readonly factStore;
|
|
24
25
|
private readonly l2TipsStore;
|
|
25
26
|
private readonly contractSyncService;
|
|
27
|
+
private readonly contractClassService;
|
|
26
28
|
private readonly config;
|
|
27
29
|
private log;
|
|
28
30
|
private isSyncing;
|
|
29
31
|
private readonly eventQueue;
|
|
30
32
|
protected readonly blockStream: L2BlockStream;
|
|
31
|
-
constructor(node: AztecNode, store: AztecAsyncKVStore, anchorBlockStore: AnchorBlockStore, noteStore: NoteStore, privateEventStore: PrivateEventStore, factStore: FactStore, l2TipsStore: L2TipsKVStore, contractSyncService: ContractSyncService, config?: Partial<BlockSynchronizerConfig>, bindings?: LoggerBindings);
|
|
33
|
+
constructor(node: AztecNode, store: AztecAsyncKVStore, anchorBlockStore: AnchorBlockStore, noteStore: NoteStore, privateEventStore: PrivateEventStore, factStore: FactStore, l2TipsStore: L2TipsKVStore, contractSyncService: ContractSyncService, contractClassService: ContractClassService, config?: Partial<BlockSynchronizerConfig>, bindings?: LoggerBindings);
|
|
32
34
|
protected createBlockStream(): L2BlockStream;
|
|
33
35
|
/** Handle events emitted by the block stream. Serialized to prevent concurrent mutations to anchor state. */
|
|
34
36
|
handleBlockStreamEvent(event: L2BlockStreamEvent): Promise<void>;
|
|
@@ -48,4 +50,4 @@ export declare class BlockSynchronizer implements L2BlockStreamEventHandler {
|
|
|
48
50
|
stop(): Promise<void>;
|
|
49
51
|
private doSync;
|
|
50
52
|
}
|
|
51
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
53
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmxvY2tfc3luY2hyb25pemVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvYmxvY2tfc3luY2hyb25pemVyL2Jsb2NrX3N5bmNocm9uaXplci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEVBQWUsS0FBSyxjQUFjLEVBQWdCLE1BQU0sdUJBQXVCLENBQUM7QUFFdkYsT0FBTyxLQUFLLEVBQUUsaUJBQWlCLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUN6RCxPQUFPLEtBQUssRUFBRSxhQUFhLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUM1RCxPQUFPLEVBQWEsYUFBYSxFQUFFLEtBQUssa0JBQWtCLEVBQUUsS0FBSyx5QkFBeUIsRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBQ3hILE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBR2pFLE9BQU8sS0FBSyxFQUFFLHVCQUF1QixFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFDbEUsT0FBTyxLQUFLLEVBQUUsb0JBQW9CLEVBQUUsTUFBTSx1Q0FBdUMsQ0FBQztBQUNsRixPQUFPLEtBQUssRUFBRSxtQkFBbUIsRUFBRSxNQUFNLHNDQUFzQyxDQUFDO0FBQ2hGLE9BQU8sS0FBSyxFQUFFLGdCQUFnQixFQUFFLE1BQU0sd0NBQXdDLENBQUM7QUFDL0UsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0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UMxQixtQkFBbUIsRUFBRSxtQkFBbUIsRUFDeEMsb0JBQW9CLEVBQUUsb0JBQW9CLEVBQzFDLE1BQU0sR0FBRSxPQUFPLENBQUMsdUJBQXVCLENBQU0sRUFDOUQsUUFBUSxDQUFDLEVBQUUsY0FBYyxFQUsxQjtJQUVELFNBQVMsQ0FBQyxpQkFBaUIsSUFBSSxhQUFhLENBWTNDO0lBRUQsNkdBQTZHO0lBQ3RHLHNCQUFzQixDQUFDLEtBQUssRUFBRSxrQkFBa0IsR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLENBRXRFO1lBRWEsd0JBQXdCO1lBOEd4Qix1QkFBdUI7SUFlckM7Ozs7Ozs7O09BUUc7SUFDVSxJQUFJLGtCQWlCaEI7SUFFRCxvR0FBb0c7SUFDdkYsSUFBSSxrQkFJaEI7WUFFYSxNQUFNO0NBY3JCIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block_synchronizer.d.ts","sourceRoot":"","sources":["../../src/block_synchronizer/block_synchronizer.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,cAAc,EAAgB,MAAM,uBAAuB,CAAC;AAEvF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAa,aAAa,EAAE,KAAK,kBAAkB,EAAE,KAAK,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACxH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAGjE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"block_synchronizer.d.ts","sourceRoot":"","sources":["../../src/block_synchronizer/block_synchronizer.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,cAAc,EAAgB,MAAM,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AAqB;IAChD,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC;IAE9C,YACmB,IAAI,EAAE,SAAS,EACf,KAAK,EAAE,iBAAiB,EACxB,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAE,SAAS,EACpB,iBAAiB,EAAE,iBAAiB,EACpC,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,aAAa,EAC1B,mBAAmB,EAAE,mBAAmB,EACxC,oBAAoB,EAAE,oBAAoB,EAC1C,MAAM,GAAE,OAAO,CAAC,uBAAuB,CAAM,EAC9D,QAAQ,CAAC,EAAE,cAAc,EAK1B;IAED,SAAS,CAAC,iBAAiB,IAAI,aAAa,CAY3C;IAED,6GAA6G;IACtG,sBAAsB,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAEtE;YAEa,wBAAwB;YA8GxB,uBAAuB;IAerC;;;;;;;;OAQG;IACU,IAAI,kBAiBhB;IAED,oGAAoG;IACvF,IAAI,kBAIhB;YAEa,MAAM;CAcrB"}
|
|
@@ -16,12 +16,13 @@ import { blockStreamSourceFromAztecNode } from './block_stream_source.js';
|
|
|
16
16
|
factStore;
|
|
17
17
|
l2TipsStore;
|
|
18
18
|
contractSyncService;
|
|
19
|
+
contractClassService;
|
|
19
20
|
config;
|
|
20
21
|
log;
|
|
21
22
|
isSyncing;
|
|
22
23
|
eventQueue;
|
|
23
24
|
blockStream;
|
|
24
|
-
constructor(node, store, anchorBlockStore, noteStore, privateEventStore, factStore, l2TipsStore, contractSyncService, config = {}, bindings){
|
|
25
|
+
constructor(node, store, anchorBlockStore, noteStore, privateEventStore, factStore, l2TipsStore, contractSyncService, contractClassService, config = {}, bindings){
|
|
25
26
|
this.node = node;
|
|
26
27
|
this.store = store;
|
|
27
28
|
this.anchorBlockStore = anchorBlockStore;
|
|
@@ -30,6 +31,7 @@ import { blockStreamSourceFromAztecNode } from './block_stream_source.js';
|
|
|
30
31
|
this.factStore = factStore;
|
|
31
32
|
this.l2TipsStore = l2TipsStore;
|
|
32
33
|
this.contractSyncService = contractSyncService;
|
|
34
|
+
this.contractClassService = contractClassService;
|
|
33
35
|
this.config = config;
|
|
34
36
|
this.eventQueue = new SerialQueue();
|
|
35
37
|
this.log = createLogger('pxe:block_synchronizer', bindings);
|
|
@@ -154,6 +156,10 @@ import { blockStreamSourceFromAztecNode } from './block_stream_source.js';
|
|
|
154
156
|
// Therefore, we clear the contract synchronization cache here such that the sync is re-triggered upon new
|
|
155
157
|
// execution.
|
|
156
158
|
this.contractSyncService.wipe();
|
|
159
|
+
// The contract class service keeps a per-block cache - since updating our anchor means it is very unlikely we'd
|
|
160
|
+
// ever re-simulate at past anchors, we wipe its cache to prevent runaway memory growth on very long-lived PXE
|
|
161
|
+
// instances.
|
|
162
|
+
this.contractClassService.wipe();
|
|
157
163
|
this.log.verbose(`Updated pxe last block to ${blockHeader.getBlockNumber()}`, blockHeader.toInspect());
|
|
158
164
|
await this.anchorBlockStore.setHeader(blockHeader);
|
|
159
165
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
4
|
+
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
5
|
+
import type { ContractStore } from '../storage/contract_store/contract_store.js';
|
|
6
|
+
/**
|
|
7
|
+
* Resolves the contract class id that an address runs at a given anchor block, as tracked by the chain.
|
|
8
|
+
*
|
|
9
|
+
* PXE does not store a contract's current class id: it is mutable, chain-derived state that changes when a contract is
|
|
10
|
+
* upgraded and can be undone by a reorg. Instead this service asks the node for the current class at an anchor block,
|
|
11
|
+
* falling back to a local instance if no upgrades were scheduled.
|
|
12
|
+
*/
|
|
13
|
+
export declare class ContractClassService {
|
|
14
|
+
#private;
|
|
15
|
+
private node;
|
|
16
|
+
private contractStore;
|
|
17
|
+
constructor(node: AztecNode, contractStore: ContractStore);
|
|
18
|
+
/**
|
|
19
|
+
* Returns the class id that corresponds to `address` as of `anchorBlockHeader`, or `undefined` if no instance is
|
|
20
|
+
* registered for `address`. A missing instance is an absence the caller decides how to handle, not an error; genuine
|
|
21
|
+
* failures (e.g. the node being unreachable) still throw.
|
|
22
|
+
*/
|
|
23
|
+
getCurrentClassId(address: AztecAddress, anchorBlockHeader: BlockHeader): Promise<Fr | undefined>;
|
|
24
|
+
/**
|
|
25
|
+
* Clears the cache.
|
|
26
|
+
*
|
|
27
|
+
* This is not required for correctness, only to limit how much memory the cache uses. The cache is resilient against
|
|
28
|
+
* reorgs etc. as it is based on block hashes, not block numbers. */
|
|
29
|
+
wipe(): void;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udHJhY3RfY2xhc3Nfc2VydmljZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NvbnRyYWN0L2NvbnRyYWN0X2NsYXNzX3NlcnZpY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFFekQsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFDaEUsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDakUsT0FBTyxLQUFLLEVBQUUsV0FBVyxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFcEQsT0FBTyxLQUFLLEVBQUUsYUFBYSxFQUFFLE1BQU0sNkNBQTZDLENBQUM7QUFFakY7Ozs7OztHQU1HO0FBQ0gscUJBQWEsb0JBQW9COztJQVU3QixPQUFPLENBQUMsSUFBSTtJQUNaLE9BQU8sQ0FBQyxhQUFhO0lBRnZCLFlBQ1UsSUFBSSxFQUFFLFNBQVMsRUFDZixhQUFhLEVBQUUsYUFBYSxFQUNsQztJQUVKOzs7O09BSUc7SUFDRyxpQkFBaUIsQ0FBQyxPQUFPLEVBQUUsWUFBWSxFQUFFLGlCQUFpQixFQUFFLFdBQVcsR0FBRyxPQUFPLENBQUMsRUFBRSxHQUFHLFNBQVMsQ0FBQyxDQXNDdEc7SUFFRDs7Ozt3RUFJb0U7SUFDcEUsSUFBSSxJQUFJLElBQUksQ0FFWDtDQUNGIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract_class_service.d.ts","sourceRoot":"","sources":["../../src/contract/contract_class_service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAEzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAEjF;;;;;;GAMG;AACH,qBAAa,oBAAoB;;IAU7B,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,aAAa;IAFvB,YACU,IAAI,EAAE,SAAS,EACf,aAAa,EAAE,aAAa,EAClC;IAEJ;;;;OAIG;IACG,iBAAiB,CAAC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,WAAW,GAAG,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC,CAsCtG;IAED;;;;wEAIoE;IACpE,IAAI,IAAI,IAAI,CAEX;CACF"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { isProtocolContract } from '@aztec/protocol-contracts';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves the contract class id that an address runs at a given anchor block, as tracked by the chain.
|
|
4
|
+
*
|
|
5
|
+
* PXE does not store a contract's current class id: it is mutable, chain-derived state that changes when a contract is
|
|
6
|
+
* upgraded and can be undone by a reorg. Instead this service asks the node for the current class at an anchor block,
|
|
7
|
+
* falling back to a local instance if no upgrades were scheduled.
|
|
8
|
+
*/ export class ContractClassService {
|
|
9
|
+
node;
|
|
10
|
+
contractStore;
|
|
11
|
+
/**
|
|
12
|
+
* Class ids are cached per `(address, anchorHash)`. This avoid unnecessary network roundtrips in scenarios where
|
|
13
|
+
* multiple executions are done on the same anchor block (e.g. simulation followed by witgen), or when the same
|
|
14
|
+
* contract is invoked multiple times in an execution (e.g. authwit checks).
|
|
15
|
+
* It also means the callers don't need to worry about caching this service's return values, simplifying callsites.
|
|
16
|
+
*/ #cache;
|
|
17
|
+
constructor(node, contractStore){
|
|
18
|
+
this.node = node;
|
|
19
|
+
this.contractStore = contractStore;
|
|
20
|
+
this.#cache = new Map();
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Returns the class id that corresponds to `address` as of `anchorBlockHeader`, or `undefined` if no instance is
|
|
24
|
+
* registered for `address`. A missing instance is an absence the caller decides how to handle, not an error; genuine
|
|
25
|
+
* failures (e.g. the node being unreachable) still throw.
|
|
26
|
+
*/ async getCurrentClassId(address, anchorBlockHeader) {
|
|
27
|
+
// Protocol contracts are not in the registry and cannot be upgraded, so their original class is always current.
|
|
28
|
+
// Short-circuiting avoids a node round-trip.
|
|
29
|
+
if (isProtocolContract(address)) {
|
|
30
|
+
const instance = await this.contractStore.getContractInstance(address);
|
|
31
|
+
return instance?.originalContractClassId;
|
|
32
|
+
}
|
|
33
|
+
const key = `${address.toString()}:${(await anchorBlockHeader.hash()).toString()}`;
|
|
34
|
+
let promise = this.#cache.get(key);
|
|
35
|
+
if (!promise) {
|
|
36
|
+
promise = (async ()=>{
|
|
37
|
+
// The node resolves the current class from the same scheduled value change the AVM enforces against the public
|
|
38
|
+
// data tree. If the contract was upgraded the node returns a non-undefined instance; an undefined result means
|
|
39
|
+
// no upgrade happened (or the node has no record of it, e.g. it was never publicly deployed), so the original
|
|
40
|
+
// class is current.
|
|
41
|
+
const nodeInstance = await this.node.getContract(address, await anchorBlockHeader.hash());
|
|
42
|
+
if (nodeInstance) {
|
|
43
|
+
return nodeInstance.currentContractClassId;
|
|
44
|
+
} else {
|
|
45
|
+
return (await this.contractStore.getContractInstance(address))?.originalContractClassId;
|
|
46
|
+
}
|
|
47
|
+
})().catch((err)=>{
|
|
48
|
+
this.#cache.delete(key);
|
|
49
|
+
throw err;
|
|
50
|
+
});
|
|
51
|
+
this.#cache.set(key, promise);
|
|
52
|
+
}
|
|
53
|
+
const classId = await promise;
|
|
54
|
+
if (classId === undefined) {
|
|
55
|
+
// Don't memoize a missing instance: it may be registered later in this PXE (e.g. via contract sync
|
|
56
|
+
// mid-execution), and a cached miss would then hide it. Only successful resolutions stay cached.
|
|
57
|
+
this.#cache.delete(key);
|
|
58
|
+
}
|
|
59
|
+
return classId;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Clears the cache.
|
|
63
|
+
*
|
|
64
|
+
* This is not required for correctness, only to limit how much memory the cache uses. The cache is resilient against
|
|
65
|
+
* reorgs etc. as it is based on block hashes, not block numbers. */ wipe() {
|
|
66
|
+
this.#cache.clear();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -6,14 +6,15 @@ import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
|
6
6
|
import type { StagedStore } from '../job_coordinator/job_coordinator.js';
|
|
7
7
|
import type { ContractStore } from '../storage/contract_store/contract_store.js';
|
|
8
8
|
import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
9
|
+
import type { ContractClassService } from './contract_class_service.js';
|
|
9
10
|
/**
|
|
10
11
|
* Maximum number of scope syncs running concurrently within a single sync call. Sized to trade off parallelism
|
|
11
12
|
* on non-ACIR work (node RPC, note store reads) against memory pressure from concurrent circuit execution.
|
|
12
13
|
*/
|
|
13
14
|
export declare const MAX_CONCURRENT_SCOPE_SYNCS = 5;
|
|
14
15
|
/**
|
|
15
|
-
* Service for syncing the private state of contracts
|
|
16
|
-
*
|
|
16
|
+
* Service for syncing the private state of contracts. It uses a cache to avoid redundant sync operations - the cache
|
|
17
|
+
* is wiped when the anchor block changes.
|
|
17
18
|
*
|
|
18
19
|
* TODO: The StagedStore naming is broken here. Figure out a better name.
|
|
19
20
|
*/
|
|
@@ -21,14 +22,14 @@ export declare class ContractSyncService implements StagedStore {
|
|
|
21
22
|
#private;
|
|
22
23
|
private aztecNode;
|
|
23
24
|
private contractStore;
|
|
25
|
+
private contractClassService;
|
|
24
26
|
private noteStore;
|
|
25
27
|
private log;
|
|
26
28
|
readonly storeName = "contract_sync";
|
|
27
29
|
private syncedContracts;
|
|
28
|
-
|
|
29
|
-
constructor(aztecNode: AztecNode, contractStore: ContractStore, noteStore: NoteStore, log: Logger);
|
|
30
|
+
constructor(aztecNode: AztecNode, contractStore: ContractStore, contractClassService: ContractClassService, noteStore: NoteStore, log: Logger);
|
|
30
31
|
/**
|
|
31
|
-
* Ensures a contract's private state is synchronized
|
|
32
|
+
* Ensures a contract's private state is synchronized.
|
|
32
33
|
* Uses a cache to avoid redundant sync operations - the cache is wiped when the anchor block changes.
|
|
33
34
|
* @param contractAddress - The address of the contract to sync.
|
|
34
35
|
* @param functionToInvokeAfterSync - The function selector that will be called after sync (used to validate it's
|
|
@@ -44,4 +45,4 @@ export declare class ContractSyncService implements StagedStore {
|
|
|
44
45
|
commit(_jobId: string): Promise<void>;
|
|
45
46
|
discardStaged(_jobId: string): Promise<void>;
|
|
46
47
|
}
|
|
47
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
48
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udHJhY3Rfc3luY19zZXJ2aWNlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29udHJhY3QvY29udHJhY3Rfc3luY19zZXJ2aWNlLnRzIl0sIm5hbWVzIjpb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AGX;IAED,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEpC;IAED,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAK3C;CA+DF"}
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { Semaphore } from '@aztec/foundation/queue';
|
|
2
2
|
import { isProtocolContract } from '@aztec/protocol-contracts';
|
|
3
3
|
import { NoteService } from '../notes/note_service.js';
|
|
4
|
-
import { syncScope
|
|
4
|
+
import { syncScope } from './helpers.js';
|
|
5
5
|
/**
|
|
6
6
|
* Maximum number of scope syncs running concurrently within a single sync call. Sized to trade off parallelism
|
|
7
7
|
* on non-ACIR work (node RPC, note store reads) against memory pressure from concurrent circuit execution.
|
|
8
8
|
*/ export const MAX_CONCURRENT_SCOPE_SYNCS = 5;
|
|
9
9
|
/**
|
|
10
|
-
* Service for syncing the private state of contracts
|
|
11
|
-
*
|
|
10
|
+
* Service for syncing the private state of contracts. It uses a cache to avoid redundant sync operations - the cache
|
|
11
|
+
* is wiped when the anchor block changes.
|
|
12
12
|
*
|
|
13
13
|
* TODO: The StagedStore naming is broken here. Figure out a better name.
|
|
14
14
|
*/ export class ContractSyncService {
|
|
15
15
|
aztecNode;
|
|
16
16
|
contractStore;
|
|
17
|
+
contractClassService;
|
|
17
18
|
noteStore;
|
|
18
19
|
log;
|
|
19
20
|
storeName;
|
|
@@ -21,20 +22,17 @@ import { syncScope, verifyCurrentClassId } from './helpers.js';
|
|
|
21
22
|
// (`contractAddress:scopeAddress`), or `contractAddress:*` for all scopes (all accounts).
|
|
22
23
|
// The value is a promise that resolves when the contract is synced.
|
|
23
24
|
syncedContracts;
|
|
24
|
-
|
|
25
|
-
// class ID verification is scope-independent. Cleared on wipe/discard.
|
|
26
|
-
classIdVerificationCache;
|
|
27
|
-
constructor(aztecNode, contractStore, noteStore, log){
|
|
25
|
+
constructor(aztecNode, contractStore, contractClassService, noteStore, log){
|
|
28
26
|
this.aztecNode = aztecNode;
|
|
29
27
|
this.contractStore = contractStore;
|
|
28
|
+
this.contractClassService = contractClassService;
|
|
30
29
|
this.noteStore = noteStore;
|
|
31
30
|
this.log = log;
|
|
32
31
|
this.storeName = 'contract_sync';
|
|
33
32
|
this.syncedContracts = new Map();
|
|
34
|
-
this.classIdVerificationCache = new Map();
|
|
35
33
|
}
|
|
36
34
|
/**
|
|
37
|
-
* Ensures a contract's private state is synchronized
|
|
35
|
+
* Ensures a contract's private state is synchronized.
|
|
38
36
|
* Uses a cache to avoid redundant sync operations - the cache is wiped when the anchor block changes.
|
|
39
37
|
* @param contractAddress - The address of the contract to sync.
|
|
40
38
|
* @param functionToInvokeAfterSync - The function selector that will be called after sync (used to validate it's
|
|
@@ -42,7 +40,7 @@ import { syncScope, verifyCurrentClassId } from './helpers.js';
|
|
|
42
40
|
* @param utilityExecutor - Executor function for running the sync_state utility function.
|
|
43
41
|
* @param scopes - Access scopes to pass through to the utility executor (affects whose account's private state is discovered).
|
|
44
42
|
*/ async ensureContractSynced(contractAddress, functionToInvokeAfterSync, utilityExecutor, anchorBlockHeader, jobId, scopes) {
|
|
45
|
-
this.#startSyncIfNeeded(contractAddress, scopes, anchorBlockHeader, jobId, (scope)=>syncScope(contractAddress, this.contractStore, functionToInvokeAfterSync, utilityExecutor, scope));
|
|
43
|
+
this.#startSyncIfNeeded(contractAddress, scopes, anchorBlockHeader, jobId, (scope)=>syncScope(contractAddress, this.contractStore, this.contractClassService, anchorBlockHeader, functionToInvokeAfterSync, utilityExecutor, scope));
|
|
46
44
|
await this.#awaitSync(contractAddress, scopes);
|
|
47
45
|
}
|
|
48
46
|
/** Clears sync cache entries for the given scopes of a contract. */ invalidateContractForScopes(contractAddress, scopes) {
|
|
@@ -54,7 +52,6 @@ import { syncScope, verifyCurrentClassId } from './helpers.js';
|
|
|
54
52
|
/** Clears sync cache. Called by BlockSynchronizer when anchor block changes. */ wipe() {
|
|
55
53
|
this.log.debug(`Wiping contract sync cache (${this.syncedContracts.size} entries)`);
|
|
56
54
|
this.syncedContracts.clear();
|
|
57
|
-
this.classIdVerificationCache.clear();
|
|
58
55
|
}
|
|
59
56
|
commit(_jobId) {
|
|
60
57
|
return Promise.resolve();
|
|
@@ -63,21 +60,18 @@ import { syncScope, verifyCurrentClassId } from './helpers.js';
|
|
|
63
60
|
// We clear the synced contracts cache here because, when the job is discarded, any associated database writes from
|
|
64
61
|
// the sync are also undone.
|
|
65
62
|
this.syncedContracts.clear();
|
|
66
|
-
this.classIdVerificationCache.clear();
|
|
67
63
|
return Promise.resolve();
|
|
68
64
|
}
|
|
69
65
|
/**
|
|
70
66
|
* For each unsynced scope, creates a promise that waits on:
|
|
71
|
-
* 1.
|
|
72
|
-
* 2.
|
|
73
|
-
* 3. Per-scope sync (individual, semaphore-bounded).
|
|
67
|
+
* 1. Note nullifier sync (shared, batched across all unsynced scopes).
|
|
68
|
+
* 2. Per-scope sync (individual, semaphore-bounded).
|
|
74
69
|
*/ #startSyncIfNeeded(contractAddress, scopes, anchorBlockHeader, jobId, syncScopeFn) {
|
|
75
70
|
const scopesToSync = scopes.filter((scope)=>!this.syncedContracts.has(toKey(contractAddress, scope)));
|
|
76
71
|
if (scopesToSync.length === 0) {
|
|
77
72
|
return;
|
|
78
73
|
}
|
|
79
74
|
this.log.debug(`Syncing contract ${contractAddress} for ${scopesToSync.length} scope(s)`);
|
|
80
|
-
const verifyPromise = this.#verifyClassId(contractAddress, anchorBlockHeader);
|
|
81
75
|
const syncNullifiersPromise = this.#syncNoteNullifiers(contractAddress, anchorBlockHeader, jobId, scopesToSync);
|
|
82
76
|
// We build a new semaphore for each sync call, so it rate-limits the scopes within that single call. We do
|
|
83
77
|
// this so that if these scope syncs trigger nested syncs, the nested ones can execute without causing a deadlock.
|
|
@@ -85,7 +79,6 @@ import { syncScope, verifyCurrentClassId } from './helpers.js';
|
|
|
85
79
|
for (const scope of scopesToSync){
|
|
86
80
|
const key = toKey(contractAddress, scope);
|
|
87
81
|
const promise = Promise.all([
|
|
88
|
-
verifyPromise,
|
|
89
82
|
syncNullifiersPromise,
|
|
90
83
|
runBounded(syncSlot, ()=>syncScopeFn(scope))
|
|
91
84
|
]).then(()=>{}).catch((err)=>{
|
|
@@ -95,19 +88,6 @@ import { syncScope, verifyCurrentClassId } from './helpers.js';
|
|
|
95
88
|
this.syncedContracts.set(key, promise);
|
|
96
89
|
}
|
|
97
90
|
}
|
|
98
|
-
/** Verifies the local class ID matches the on-chain value (cached, evicts on failure so retries re-verify). */ #verifyClassId(contractAddress, anchorBlockHeader) {
|
|
99
|
-
const contractKey = contractAddress.toString();
|
|
100
|
-
const cached = this.classIdVerificationCache.get(contractKey);
|
|
101
|
-
if (cached) {
|
|
102
|
-
return cached;
|
|
103
|
-
}
|
|
104
|
-
const promise = verifyCurrentClassId(contractAddress, this.aztecNode, this.contractStore, anchorBlockHeader).catch((err)=>{
|
|
105
|
-
this.classIdVerificationCache.delete(contractKey);
|
|
106
|
-
throw err;
|
|
107
|
-
});
|
|
108
|
-
this.classIdVerificationCache.set(contractKey, promise);
|
|
109
|
-
return promise;
|
|
110
|
-
}
|
|
111
91
|
/** Syncs note nullifiers across all unsynced scopes in a single batched call. */ async #syncNoteNullifiers(contractAddress, anchorBlockHeader, jobId, scopes) {
|
|
112
92
|
// Protocol contracts don't have private state to sync
|
|
113
93
|
if (isProtocolContract(contractAddress)) {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FunctionCall, FunctionSelector } from '@aztec/stdlib/abi';
|
|
2
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
4
|
+
import type { ContractStore } from '../storage/contract_store/contract_store.js';
|
|
5
|
+
import type { ContractClassService } from './contract_class_service.js';
|
|
6
|
+
export declare function syncScope(contractAddress: AztecAddress, contractStore: ContractStore, contractClassService: ContractClassService, anchorBlockHeader: BlockHeader, functionToInvokeAfterSync: FunctionSelector | null, utilityExecutor: (privateSyncCall: FunctionCall, scopes: AztecAddress[]) => Promise<any>, scope: AztecAddress): Promise<void>;
|
|
7
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGVscGVycy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NvbnRyYWN0L2hlbHBlcnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLGdCQUFnQixFQUFFLE1BQU0sbUJBQW1CLENBQUM7QUFDeEUsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFDaEUsT0FBTyxLQUFLLEVBQUUsV0FBVyxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFcEQsT0FBTyxLQUFLLEVBQUUsYUFBYSxFQUFFLE1BQU0sNkNBQTZDLENBQUM7QUFDakYsT0FBTyxLQUFLLEVBQUUsb0JBQW9CLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUV4RSx3QkFBc0IsU0FBUyxDQUM3QixlQUFlLEVBQUUsWUFBWSxFQUM3QixhQUFhLEVBQUUsYUFBYSxFQUM1QixvQkFBb0IsRUFBRSxvQkFBb0IsRUFDMUMsaUJBQWlCLEVBQUUsV0FBVyxFQUM5Qix5QkFBeUIsRUFBRSxnQkFBZ0IsR0FBRyxJQUFJLEVBQ2xELGVBQWUsRUFBRSxDQUFDLGVBQWUsRUFBRSxZQUFZLEVBQUUsTUFBTSxFQUFFLFlBQVksRUFBRSxLQUFLLE9BQU8sQ0FBQyxHQUFHLENBQUMsRUFDeEYsS0FBSyxFQUFFLFlBQVksaUJBbUJwQiJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/contract/helpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAExE,wBAAsB,SAAS,CAC7B,eAAe,EAAE,YAAY,EAC7B,aAAa,EAAE,aAAa,EAC5B,oBAAoB,EAAE,oBAAoB,EAC1C,iBAAiB,EAAE,WAAW,EAC9B,yBAAyB,EAAE,gBAAgB,GAAG,IAAI,EAClD,eAAe,EAAE,CAAC,eAAe,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,EACxF,KAAK,EAAE,YAAY,iBAmBpB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { isProtocolContract } from '@aztec/protocol-contracts';
|
|
2
|
+
export async function syncScope(contractAddress, contractStore, contractClassService, anchorBlockHeader, functionToInvokeAfterSync, utilityExecutor, scope) {
|
|
3
|
+
// Protocol contracts don't have private state to sync
|
|
4
|
+
if (isProtocolContract(contractAddress)) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
const classId = await contractClassService.getCurrentClassId(contractAddress, anchorBlockHeader);
|
|
8
|
+
if (!classId) {
|
|
9
|
+
throw new Error(`Cannot sync contract ${contractAddress}: its instance is not registered nor published.`);
|
|
10
|
+
}
|
|
11
|
+
const syncStateFunctionCall = await contractStore.getFunctionCall('sync_state', [
|
|
12
|
+
scope
|
|
13
|
+
], contractAddress, classId);
|
|
14
|
+
if (functionToInvokeAfterSync && functionToInvokeAfterSync.equals(syncStateFunctionCall.selector)) {
|
|
15
|
+
throw new Error('Forbidden `sync_state` invocation. `sync_state` can only be invoked by PXE, manual execution can lead to inconsistencies.');
|
|
16
|
+
}
|
|
17
|
+
await utilityExecutor(syncStateFunctionCall, [
|
|
18
|
+
scope
|
|
19
|
+
]);
|
|
20
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import type { FunctionArtifactWithContractName, FunctionSelector } from '@aztec/stdlib/abi';
|
|
3
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
import type { ContractInstancePreimageWithAddress } from '@aztec/stdlib/contract';
|
|
5
|
+
import type { BlockHeader, ContractOverrides } from '@aztec/stdlib/tx';
|
|
6
|
+
import type { ContractClassService } from '../contract/contract_class_service.js';
|
|
7
|
+
import type { ContractStore } from '../storage/contract_store/contract_store.js';
|
|
8
|
+
/**
|
|
9
|
+
* Per-run view of contract data for a single simulation, bound to its anchor block.
|
|
10
|
+
*
|
|
11
|
+
* The {@link ContractStore} is pure class-id-keyed storage and has no notion of which class an address runs. This
|
|
12
|
+
* class bridges that gap: it resolves an address to its current class id (via the {@link ContractClassService}
|
|
13
|
+
* at the run's anchor block) and then serves artifacts from the store. It is also the single place contract
|
|
14
|
+
* overrides are applied — when an address is overridden, both its instance and its class id come from the override
|
|
15
|
+
* rather than the chain, so a simulation can execute different bytecode at that address. Overrides are only set for
|
|
16
|
+
* `simulateTx` (which skips the kernels), so the override path never reaches proving.
|
|
17
|
+
*/
|
|
18
|
+
export declare class AnchoredContractData {
|
|
19
|
+
private readonly store;
|
|
20
|
+
private readonly contractClassService;
|
|
21
|
+
private readonly anchorBlockHeader;
|
|
22
|
+
private readonly overrides?;
|
|
23
|
+
constructor(store: ContractStore, contractClassService: ContractClassService, anchorBlockHeader: BlockHeader, overrides?: ContractOverrides | undefined);
|
|
24
|
+
/** Returns the address preimage of the instance at `address`, from the override if any, else from storage. */
|
|
25
|
+
getContractInstance(address: AztecAddress): Promise<ContractInstancePreimageWithAddress | undefined>;
|
|
26
|
+
/**
|
|
27
|
+
* Resolves the class id `address` runs in this simulation: the override's class if overridden, else resolved against
|
|
28
|
+
* the chain at the anchor block.
|
|
29
|
+
*/
|
|
30
|
+
getCurrentClassId(address: AztecAddress): Promise<Fr | undefined>;
|
|
31
|
+
getFunctionArtifact(address: AztecAddress, selector: FunctionSelector): Promise<FunctionArtifactWithContractName | undefined>;
|
|
32
|
+
getFunctionArtifactWithDebugMetadata(address: AztecAddress, selector: FunctionSelector): Promise<FunctionArtifactWithContractName | undefined>;
|
|
33
|
+
getDebugContractName(address: AztecAddress): Promise<string | undefined>;
|
|
34
|
+
getDebugFunctionName(address: AztecAddress, selector: FunctionSelector): Promise<string>;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW5jaG9yZWRfY29udHJhY3RfZGF0YS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NvbnRyYWN0X2Z1bmN0aW9uX3NpbXVsYXRvci9hbmNob3JlZF9jb250cmFjdF9kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3pELE9BQU8sS0FBSyxFQUFFLGdDQUFnQyxFQUFFLGdCQUFnQixFQUFFLE1BQU0sbUJBQW1CLENBQUM7QUFDNUYsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFDaEUsT0FBTyxLQUFLLEVBQUUsbUNBQW1DLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUNsRixPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsaUJBQWlCLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUV2RSxPQUFPLEtBQUssRUFBRSxvQkFBb0IsRUFBRSxNQUFNLHVDQUF1QyxDQUFDO0FBQ2xGLE9BQU8sS0FBSyxFQU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,CACvB,OAAO,EAAE,YAAY,EACrB,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,gCAAgC,GAAG,SAAS,CAAC,CAGvD;IAEK,oCAAoC,CACxC,OAAO,EAAE,YAAY,EACrB,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,gCAAgC,GAAG,SAAS,CAAC,CAGvD;IAEK,oBAAoB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAG7E;IAEK,oBAAoB,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CAG7F;CACF"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-run view of contract data for a single simulation, bound to its anchor block.
|
|
3
|
+
*
|
|
4
|
+
* The {@link ContractStore} is pure class-id-keyed storage and has no notion of which class an address runs. This
|
|
5
|
+
* class bridges that gap: it resolves an address to its current class id (via the {@link ContractClassService}
|
|
6
|
+
* at the run's anchor block) and then serves artifacts from the store. It is also the single place contract
|
|
7
|
+
* overrides are applied — when an address is overridden, both its instance and its class id come from the override
|
|
8
|
+
* rather than the chain, so a simulation can execute different bytecode at that address. Overrides are only set for
|
|
9
|
+
* `simulateTx` (which skips the kernels), so the override path never reaches proving.
|
|
10
|
+
*/ export class AnchoredContractData {
|
|
11
|
+
store;
|
|
12
|
+
contractClassService;
|
|
13
|
+
anchorBlockHeader;
|
|
14
|
+
overrides;
|
|
15
|
+
constructor(store, contractClassService, anchorBlockHeader, overrides){
|
|
16
|
+
this.store = store;
|
|
17
|
+
this.contractClassService = contractClassService;
|
|
18
|
+
this.anchorBlockHeader = anchorBlockHeader;
|
|
19
|
+
this.overrides = overrides;
|
|
20
|
+
}
|
|
21
|
+
/** Returns the address preimage of the instance at `address`, from the override if any, else from storage. */ getContractInstance(address) {
|
|
22
|
+
const override = this.overrides?.[address.toString()];
|
|
23
|
+
if (override) {
|
|
24
|
+
return Promise.resolve(override.instance);
|
|
25
|
+
}
|
|
26
|
+
return this.store.getContractInstance(address);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Resolves the class id `address` runs in this simulation: the override's class if overridden, else resolved against
|
|
30
|
+
* the chain at the anchor block.
|
|
31
|
+
*/ getCurrentClassId(address) {
|
|
32
|
+
const override = this.overrides?.[address.toString()];
|
|
33
|
+
if (override) {
|
|
34
|
+
return Promise.resolve(override.instance.currentContractClassId);
|
|
35
|
+
}
|
|
36
|
+
return this.contractClassService.getCurrentClassId(address, this.anchorBlockHeader);
|
|
37
|
+
}
|
|
38
|
+
async getFunctionArtifact(address, selector) {
|
|
39
|
+
const classId = await this.getCurrentClassId(address);
|
|
40
|
+
return classId ? this.store.getFunctionArtifact(classId, selector) : undefined;
|
|
41
|
+
}
|
|
42
|
+
async getFunctionArtifactWithDebugMetadata(address, selector) {
|
|
43
|
+
const classId = await this.getCurrentClassId(address);
|
|
44
|
+
return classId ? this.store.getFunctionArtifactWithDebugMetadata(classId, selector) : undefined;
|
|
45
|
+
}
|
|
46
|
+
async getDebugContractName(address) {
|
|
47
|
+
const classId = await this.getCurrentClassId(address);
|
|
48
|
+
return classId ? this.store.getDebugContractName(classId) : undefined;
|
|
49
|
+
}
|
|
50
|
+
async getDebugFunctionName(address, selector) {
|
|
51
|
+
const classId = await this.getCurrentClassId(address);
|
|
52
|
+
return classId ? this.store.getDebugFunctionName(classId, selector) : `${address}:${selector}`;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import type { BlockHash, BlockParameter } from '@aztec/stdlib/block';
|
|
4
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
5
|
+
import type { TxHash } from '@aztec/stdlib/tx';
|
|
6
|
+
/**
|
|
7
|
+
* Per-execution cache for immutable Aztec node reads.
|
|
8
|
+
*/
|
|
9
|
+
export declare class AztecNodeReadCache {
|
|
10
|
+
#private;
|
|
11
|
+
private readonly aztecNode;
|
|
12
|
+
private readonly cache;
|
|
13
|
+
constructor(aztecNode: AztecNode);
|
|
14
|
+
/** Fetches a block without reissuing the same node request. */
|
|
15
|
+
getBlock(block: BlockParameter): Promise<{
|
|
16
|
+
header: import("@aztec/stdlib/tx").BlockHeader;
|
|
17
|
+
archive: import("@aztec/stdlib/trees").AppendOnlyTreeSnapshot;
|
|
18
|
+
hash: BlockHash;
|
|
19
|
+
checkpointNumber: import("@aztec/foundation/branded-types").CheckpointNumber;
|
|
20
|
+
indexWithinCheckpoint: import("@aztec/foundation/branded-types").IndexWithinCheckpoint;
|
|
21
|
+
number: import("@aztec/foundation/branded-types").BlockNumber;
|
|
22
|
+
body?: import("@aztec/stdlib/block").Body | undefined;
|
|
23
|
+
l1?: import("@aztec/stdlib/interfaces/server").L1PublishInfo | undefined;
|
|
24
|
+
attestations?: import("@aztec/stdlib/block").CommitteeAttestation[] | undefined;
|
|
25
|
+
} | undefined>;
|
|
26
|
+
/** Fetches a transaction receipt with its effect attached. */
|
|
27
|
+
getTxReceiptWithEffect(txHash: TxHash): Promise<import("@aztec/stdlib/tx").TxReceipt<{
|
|
28
|
+
readonly includeTxEffect: true;
|
|
29
|
+
}>>;
|
|
30
|
+
/** Fetches an archive-tree witness for a block hash. */
|
|
31
|
+
getBlockHashMembershipWitness(referenceBlock: BlockParameter, blockHash: BlockHash): Promise<import("@aztec/foundation/trees").MembershipWitness<30> | undefined>;
|
|
32
|
+
/** Fetches a public-data-tree witness for a leaf slot. */
|
|
33
|
+
getPublicDataWitness(referenceBlock: BlockParameter, leafSlot: Fr): Promise<import("@aztec/stdlib/trees").PublicDataWitness | undefined>;
|
|
34
|
+
/** Fetches public storage for a single slot. */
|
|
35
|
+
getPublicStorageAt(referenceBlock: BlockParameter, contractAddress: AztecAddress, storageSlot: Fr): Promise<Fr>;
|
|
36
|
+
/** Fetches a contiguous public storage range, reusing cached reads for overlapping slots. */
|
|
37
|
+
getPublicStorageRange(referenceBlock: BlockParameter, contractAddress: AztecAddress, startStorageSlot: Fr, numberOfElements: number): Promise<Fr[]>;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXp0ZWNfbm9kZV9yZWFkX2NhY2hlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29udHJhY3RfZnVuY3Rpb25fc2ltdWxhdG9yL2F6dGVjX25vZGVfcmVhZF9jYWNoZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDcEQsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFDaEUsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLGNBQWMsRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBQ3JFLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQ2pFLE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBRS9DOztHQUVHO0FBQ0gscUJBQWEsa0JBQWtCOztJQUdqQixPQUFPLENBQUMsUUFBUSxDQUFDLFNBQVM7SUFGdEMsT0FBTyxDQUFDLFFBQVEsQ0FBQyxLQUFLLENBQXVDO0lBRTdELFlBQTZCLFNBQVMsRUFBRSxTQUFTLEVBQUk7SUFFckQsK0RBQStEO0lBQ3hELFFBQVEsQ0FBQyxLQUFLLEVBQUUsY0FBYzs7Ozs7Ozs7OzttQkFFcEM7SUFFRCw4REFBOEQ7SUFDdkQsc0JBQXNCLENBQUMsTUFBTSxFQUFFLE1BQU07O1FBSTNDO0l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AA8D;IACvD,sBAAsB,CAAC,MAAM,EAAE,MAAM;;QAI3C;IAED,wDAAwD;IACjD,6BAA6B,CAAC,cAAc,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,gFAKxF;IAED,0DAA0D;IACnD,oBAAoB,CAAC,cAAc,EAAE,cAAc,EAAE,QAAQ,EAAE,EAAE,wEAIvE;IAED,gDAAgD;IACzC,kBAAkB,CAAC,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,EAAE,eAKvG;IAED,6FAA6F;IACtF,qBAAqB,CAC1B,cAAc,EAAE,cAAc,EAC9B,eAAe,EAAE,YAAY,EAC7B,gBAAgB,EAAE,EAAE,EACpB,gBAAgB,EAAE,MAAM,iBAOzB;CA2BF"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
/**
|
|
3
|
+
* Per-execution cache for immutable Aztec node reads.
|
|
4
|
+
*/ export class AztecNodeReadCache {
|
|
5
|
+
aztecNode;
|
|
6
|
+
cache;
|
|
7
|
+
constructor(aztecNode){
|
|
8
|
+
this.aztecNode = aztecNode;
|
|
9
|
+
this.cache = new Map();
|
|
10
|
+
}
|
|
11
|
+
/** Fetches a block without reissuing the same node request. */ getBlock(block) {
|
|
12
|
+
return this.#cachedRead(`block:${this.#keyPart(block)}`, ()=>this.aztecNode.getBlock(block));
|
|
13
|
+
}
|
|
14
|
+
/** Fetches a transaction receipt with its effect attached. */ getTxReceiptWithEffect(txHash) {
|
|
15
|
+
return this.#cachedRead(`tx-receipt-with-effect:${txHash.toString()}`, ()=>this.aztecNode.getTxReceipt(txHash, {
|
|
16
|
+
includeTxEffect: true
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
/** Fetches an archive-tree witness for a block hash. */ getBlockHashMembershipWitness(referenceBlock, blockHash) {
|
|
20
|
+
return this.#cachedRead(`block-hash-membership-witness:${this.#keyPart(referenceBlock)}:${blockHash.toString()}`, ()=>this.aztecNode.getBlockHashMembershipWitness(referenceBlock, blockHash));
|
|
21
|
+
}
|
|
22
|
+
/** Fetches a public-data-tree witness for a leaf slot. */ getPublicDataWitness(referenceBlock, leafSlot) {
|
|
23
|
+
return this.#cachedRead(`public-data-witness:${this.#keyPart(referenceBlock)}:${leafSlot.toString()}`, ()=>this.aztecNode.getPublicDataWitness(referenceBlock, leafSlot));
|
|
24
|
+
}
|
|
25
|
+
/** Fetches public storage for a single slot. */ getPublicStorageAt(referenceBlock, contractAddress, storageSlot) {
|
|
26
|
+
return this.#cachedRead(`public-storage:${this.#keyPart(referenceBlock)}:${contractAddress.toString()}:${storageSlot.toString()}`, ()=>this.aztecNode.getPublicStorageAt(referenceBlock, contractAddress, storageSlot));
|
|
27
|
+
}
|
|
28
|
+
/** Fetches a contiguous public storage range, reusing cached reads for overlapping slots. */ getPublicStorageRange(referenceBlock, contractAddress, startStorageSlot, numberOfElements) {
|
|
29
|
+
const slots = Array(numberOfElements).fill(0).map((_, i)=>new Fr(startStorageSlot.value + BigInt(i)));
|
|
30
|
+
return Promise.all(slots.map((storageSlot)=>this.getPublicStorageAt(referenceBlock, contractAddress, storageSlot)));
|
|
31
|
+
}
|
|
32
|
+
#cachedRead(key, fetch) {
|
|
33
|
+
const cached = this.cache.get(key);
|
|
34
|
+
if (cached) {
|
|
35
|
+
return cached;
|
|
36
|
+
}
|
|
37
|
+
const promise = fetch();
|
|
38
|
+
promise.catch(()=>this.cache.delete(key));
|
|
39
|
+
this.cache.set(key, promise);
|
|
40
|
+
return promise;
|
|
41
|
+
}
|
|
42
|
+
#keyPart(value) {
|
|
43
|
+
if ([
|
|
44
|
+
'string',
|
|
45
|
+
'number',
|
|
46
|
+
'bigint',
|
|
47
|
+
'boolean'
|
|
48
|
+
].includes(typeof value)) {
|
|
49
|
+
return String(value);
|
|
50
|
+
}
|
|
51
|
+
if (value && typeof value === 'object') {
|
|
52
|
+
const toString = value.toString;
|
|
53
|
+
if (toString && toString !== Object.prototype.toString) {
|
|
54
|
+
return toString.call(value);
|
|
55
|
+
}
|
|
56
|
+
return JSON.stringify(value, (_key, nested)=>typeof nested === 'bigint' ? nested.toString() : nested);
|
|
57
|
+
}
|
|
58
|
+
return String(value);
|
|
59
|
+
}
|
|
60
|
+
}
|