@aztec/pxe 0.0.1-commit.fcb71a6 → 0.0.1-commit.fffb133c
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/bin/check_oracle_version.js +1 -1
- package/dest/block_synchronizer/block_synchronizer.d.ts +10 -4
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +66 -18
- package/dest/config/index.d.ts +3 -1
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +17 -0
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/benchmarked_node.d.ts +9 -0
- package/dest/contract_function_simulator/benchmarked_node.d.ts.map +1 -0
- package/dest/contract_function_simulator/benchmarked_node.js +77 -0
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +8 -9
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +32 -21
- package/dest/contract_function_simulator/execution_note_cache.d.ts +18 -9
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.js +45 -28
- package/dest/contract_function_simulator/index.d.ts +2 -2
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +4 -3
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +6 -3
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +1 -1
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +4 -10
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/utility_context.js +7 -18
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +15 -11
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +3 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +6 -6
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +8 -8
- package/dest/contract_function_simulator/oracle/oracle.d.ts +10 -8
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +43 -32
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -26
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +1 -37
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +11 -17
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +23 -39
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +27 -17
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +72 -72
- package/dest/contract_sync/index.d.ts +23 -0
- package/dest/contract_sync/index.d.ts.map +1 -0
- package/dest/contract_sync/index.js +54 -0
- package/dest/debug/pxe_debug_utils.d.ts +1 -1
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +3 -2
- 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 +10 -1
- 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 +10 -1
- package/dest/entrypoints/pxe_creation_options.d.ts +3 -2
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/server/index.d.ts +3 -1
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +2 -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 +11 -7
- package/dest/events/event_service.d.ts +4 -3
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +17 -19
- package/dest/events/private_event_filter_validator.d.ts +5 -5
- package/dest/events/private_event_filter_validator.d.ts.map +1 -1
- package/dest/events/private_event_filter_validator.js +5 -6
- package/dest/job_coordinator/job_coordinator.d.ts +74 -0
- package/dest/job_coordinator/job_coordinator.d.ts.map +1 -0
- package/dest/job_coordinator/job_coordinator.js +93 -0
- package/dest/logs/log_service.d.ts +3 -2
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +21 -13
- package/dest/notes/note_service.d.ts +5 -4
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +30 -34
- package/dest/oracle_version.d.ts +3 -3
- package/dest/oracle_version.d.ts.map +1 -1
- package/dest/oracle_version.js +4 -3
- package/dest/private_kernel/hints/index.d.ts +2 -2
- package/dest/private_kernel/hints/index.d.ts.map +1 -1
- package/dest/private_kernel/hints/index.js +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +28 -0
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -0
- package/dest/private_kernel/hints/{build_private_kernel_reset_private_inputs.js → private_kernel_reset_private_inputs_builder.js} +13 -7
- 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 +4 -5
- package/dest/private_kernel/private_kernel_oracle.d.ts +24 -28
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +90 -2
- package/dest/pxe.d.ts +8 -36
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +70 -93
- package/dest/storage/capsule_store/capsule_store.d.ts +24 -9
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
- package/dest/storage/capsule_store/capsule_store.js +132 -23
- package/dest/storage/contract_store/contract_store.d.ts +1 -2
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +0 -12
- package/dest/storage/note_store/note_store.d.ts +45 -56
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +244 -263
- package/dest/storage/note_store/stored_note.d.ts +16 -0
- package/dest/storage/note_store/stored_note.d.ts.map +1 -0
- package/dest/storage/note_store/stored_note.js +43 -0
- package/dest/storage/private_event_store/private_event_store.d.ts +47 -7
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
- package/dest/storage/private_event_store/private_event_store.js +203 -68
- package/dest/storage/private_event_store/stored_private_event.d.ts +23 -0
- package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -0
- package/dest/storage/private_event_store/stored_private_event.js +56 -0
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts +15 -8
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/recipient_tagging_store.js +69 -12
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +19 -9
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +110 -28
- package/dest/tagging/constants.d.ts +2 -0
- package/dest/tagging/constants.d.ts.map +1 -0
- package/dest/tagging/constants.js +10 -0
- package/dest/tagging/get_all_logs_by_tags.d.ts +24 -0
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -0
- package/dest/tagging/get_all_logs_by_tags.js +46 -0
- package/dest/tagging/index.d.ts +3 -2
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +2 -10
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +3 -2
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +8 -8
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +3 -2
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +5 -2
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +3 -2
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +8 -8
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +1 -1
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +5 -8
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +5 -2
- 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 +10 -5
- package/package.json +18 -18
- package/src/bin/check_oracle_version.ts +1 -0
- package/src/block_synchronizer/block_synchronizer.ts +77 -20
- package/src/config/index.ts +14 -0
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/benchmarked_node.ts +103 -0
- package/src/contract_function_simulator/contract_function_simulator.ts +37 -26
- package/src/contract_function_simulator/execution_note_cache.ts +44 -25
- package/src/contract_function_simulator/index.ts +1 -1
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +5 -1
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/utility_context.ts +6 -25
- package/src/contract_function_simulator/oracle/interfaces.ts +20 -10
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +10 -10
- package/src/contract_function_simulator/oracle/oracle.ts +56 -41
- package/src/contract_function_simulator/oracle/private_execution.ts +1 -69
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +39 -44
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +90 -76
- package/src/contract_sync/index.ts +98 -0
- package/src/debug/pxe_debug_utils.ts +3 -2
- package/src/entrypoints/client/bundle/utils.ts +7 -1
- package/src/entrypoints/client/lazy/utils.ts +7 -2
- package/src/entrypoints/pxe_creation_options.ts +2 -1
- package/src/entrypoints/server/index.ts +2 -0
- package/src/entrypoints/server/utils.ts +11 -15
- package/src/events/event_service.ts +17 -21
- package/src/events/private_event_filter_validator.ts +3 -5
- package/src/job_coordinator/job_coordinator.ts +149 -0
- package/src/logs/log_service.ts +27 -9
- package/src/notes/note_service.ts +37 -40
- package/src/oracle_version.ts +4 -3
- package/src/private_kernel/hints/index.ts +1 -1
- package/src/private_kernel/hints/{build_private_kernel_reset_private_inputs.ts → private_kernel_reset_private_inputs_builder.ts} +33 -22
- package/src/private_kernel/private_kernel_execution_prover.ts +3 -5
- package/src/private_kernel/private_kernel_oracle.ts +116 -36
- package/src/pxe.ts +123 -127
- package/src/storage/capsule_store/capsule_store.ts +159 -23
- package/src/storage/contract_store/contract_store.ts +0 -20
- package/src/storage/note_store/note_store.ts +286 -317
- package/src/storage/note_store/stored_note.ts +48 -0
- package/src/storage/private_event_store/private_event_store.ts +277 -76
- package/src/storage/private_event_store/stored_private_event.ts +73 -0
- package/src/storage/tagging_store/recipient_tagging_store.ts +89 -13
- package/src/storage/tagging_store/sender_tagging_store.ts +129 -28
- package/src/tagging/constants.ts +10 -0
- package/src/tagging/get_all_logs_by_tags.ts +68 -0
- package/src/tagging/index.ts +2 -11
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +21 -7
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +7 -1
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +10 -7
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +5 -13
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +16 -4
- package/dest/contract_function_simulator/proxied_node.d.ts +0 -9
- package/dest/contract_function_simulator/proxied_node.d.ts.map +0 -1
- package/dest/contract_function_simulator/proxied_node.js +0 -27
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +0 -28
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts +0 -46
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +0 -1
- package/dest/private_kernel/private_kernel_oracle_impl.js +0 -86
- package/dest/public_storage/public_storage_service.d.ts +0 -24
- package/dest/public_storage/public_storage_service.d.ts.map +0 -1
- package/dest/public_storage/public_storage_service.js +0 -26
- package/dest/tree_membership/tree_membership_service.d.ts +0 -52
- package/dest/tree_membership/tree_membership_service.d.ts.map +0 -1
- package/dest/tree_membership/tree_membership_service.js +0 -84
- package/src/contract_function_simulator/proxied_node.ts +0 -33
- package/src/private_kernel/private_kernel_oracle_impl.ts +0 -133
- package/src/public_storage/public_storage_service.ts +0 -33
- package/src/tree_membership/tree_membership_service.ts +0 -112
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { keccak256String } from '@aztec/foundation/crypto/keccak';
|
|
1
|
+
/* eslint-disable import-x/no-named-as-default-member */ import { keccak256String } from '@aztec/foundation/crypto/keccak';
|
|
2
2
|
import { readFileSync } from 'fs';
|
|
3
3
|
import { dirname, join } from 'path';
|
|
4
4
|
import ts from 'typescript';
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { type Logger } from '@aztec/foundation/log';
|
|
2
|
+
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
2
3
|
import type { L2TipsKVStore } from '@aztec/kv-store/stores';
|
|
3
4
|
import { L2BlockStream, type L2BlockStreamEvent, type L2BlockStreamEventHandler } from '@aztec/stdlib/block';
|
|
4
5
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
5
|
-
import type {
|
|
6
|
+
import type { BlockSynchronizerConfig } from '../config/index.js';
|
|
6
7
|
import type { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
|
|
7
8
|
import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
9
|
+
import type { PrivateEventStore } from '../storage/private_event_store/private_event_store.js';
|
|
8
10
|
/**
|
|
9
11
|
* The BlockSynchronizer class orchestrates synchronization between PXE and Aztec node, maintaining an up-to-date
|
|
10
12
|
* view of the L2 chain state. It handles block header retrieval, chain reorganizations, and provides an interface
|
|
@@ -12,16 +14,20 @@ import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
|
12
14
|
*/
|
|
13
15
|
export declare class BlockSynchronizer implements L2BlockStreamEventHandler {
|
|
14
16
|
private node;
|
|
17
|
+
private store;
|
|
15
18
|
private anchorBlockStore;
|
|
16
19
|
private noteStore;
|
|
20
|
+
private privateEventStore;
|
|
17
21
|
private l2TipsStore;
|
|
22
|
+
private config;
|
|
18
23
|
private log;
|
|
19
24
|
private isSyncing;
|
|
20
25
|
protected readonly blockStream: L2BlockStream;
|
|
21
|
-
constructor(node: AztecNode, anchorBlockStore: AnchorBlockStore, noteStore: NoteStore, l2TipsStore: L2TipsKVStore, config?: Partial<
|
|
22
|
-
protected createBlockStream(config: Partial<
|
|
26
|
+
constructor(node: AztecNode, store: AztecAsyncKVStore, anchorBlockStore: AnchorBlockStore, noteStore: NoteStore, privateEventStore: PrivateEventStore, l2TipsStore: L2TipsKVStore, config?: Partial<BlockSynchronizerConfig>, loggerOrSuffix?: string | Logger);
|
|
27
|
+
protected createBlockStream(config: Partial<BlockSynchronizerConfig>): L2BlockStream;
|
|
23
28
|
/** Handle events emitted by the block stream. */
|
|
24
29
|
handleBlockStreamEvent(event: L2BlockStreamEvent): Promise<void>;
|
|
30
|
+
private updateAnchorBlockHeader;
|
|
25
31
|
/**
|
|
26
32
|
* Syncs PXE and the node by downloading the metadata of the latest blocks, allowing simulations to use
|
|
27
33
|
* recent data (e.g. notes), and handling any reorgs that might have occurred.
|
|
@@ -34,4 +40,4 @@ export declare class BlockSynchronizer implements L2BlockStreamEventHandler {
|
|
|
34
40
|
sync(): Promise<void>;
|
|
35
41
|
private doSync;
|
|
36
42
|
}
|
|
37
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
43
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmxvY2tfc3luY2hyb25pemVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvYmxvY2tfc3luY2hyb25pemVyL2Jsb2NrX3N5bmNocm9uaXplci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEVBQUUsS0FBSyxNQUFNLEVBQWdCLE1BQU0sdUJBQXVCLENBQUM7QUFDbEUsT0FBTyxLQUFLLEVBQUUsaUJBQWlCLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUN6RCxPQUFPLEtBQUssRUFBRSxhQUFhLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUM1RCxPQUFPLEVBRUwsYUFBYSxFQUNiLEtBQUssa0JBQWtCLEVBQ3ZCLEtBQUsseUJBQXlCLEVBQy9CLE1BQU0scUJBQXFCLENBQUM7QUFDN0IsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFHakUsT0FBTyxLQUFLLEVBQUUsdUJBQXVCLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUNsRSxPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLHFEQUFxRCxDQUFDO0FBQzVGLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLHFDQUFxQyxDQUFDO0FBQ3JFLE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUFFLE1BQU0sdURBQXVELENB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ts","sourceRoot":"","sources":["../../src/block_synchronizer/block_synchronizer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,
|
|
1
|
+
{"version":3,"file":"block_synchronizer.d.ts","sourceRoot":"","sources":["../../src/block_synchronizer/block_synchronizer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAEL,aAAa,EACb,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,EAC/B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAGjE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qDAAqD,CAAC;AAC5F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uDAAuD,CAAC;AAE/F;;;;GAIG;AACH,qBAAa,iBAAkB,YAAW,yBAAyB;IAM/D,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,gBAAgB;IACxB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,iBAAiB;IACzB,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,MAAM;IAXhB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,SAAS,CAA4B;IAC7C,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC;IAE9C,YACU,IAAI,EAAE,SAAS,EACf,KAAK,EAAE,iBAAiB,EACxB,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAE,SAAS,EACpB,iBAAiB,EAAE,iBAAiB,EACpC,WAAW,EAAE,aAAa,EAC1B,MAAM,GAAE,OAAO,CAAC,uBAAuB,CAAM,EACrD,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,EAOjC;IAED,SAAS,CAAC,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,uBAAuB,CAAC,GAAG,aAAa,CAOnF;IAED,iDAAiD;IACpC,sBAAsB,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAsE5E;YAGa,uBAAuB;IAKrC;;;;;;;;OAQG;IACU,IAAI,kBAehB;YAEa,MAAM;CAcrB"}
|
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
-
import { L2BlockStream } from '@aztec/stdlib/block';
|
|
3
|
+
import { L2BlockHash, L2BlockStream } from '@aztec/stdlib/block';
|
|
4
4
|
/**
|
|
5
5
|
* The BlockSynchronizer class orchestrates synchronization between PXE and Aztec node, maintaining an up-to-date
|
|
6
6
|
* view of the L2 chain state. It handles block header retrieval, chain reorganizations, and provides an interface
|
|
7
7
|
* for querying sync status.
|
|
8
8
|
*/ export class BlockSynchronizer {
|
|
9
9
|
node;
|
|
10
|
+
store;
|
|
10
11
|
anchorBlockStore;
|
|
11
12
|
noteStore;
|
|
13
|
+
privateEventStore;
|
|
12
14
|
l2TipsStore;
|
|
15
|
+
config;
|
|
13
16
|
log;
|
|
14
17
|
isSyncing;
|
|
15
18
|
blockStream;
|
|
16
|
-
constructor(node, anchorBlockStore, noteStore, l2TipsStore, config = {}, loggerOrSuffix){
|
|
19
|
+
constructor(node, store, anchorBlockStore, noteStore, privateEventStore, l2TipsStore, config = {}, loggerOrSuffix){
|
|
17
20
|
this.node = node;
|
|
21
|
+
this.store = store;
|
|
18
22
|
this.anchorBlockStore = anchorBlockStore;
|
|
19
23
|
this.noteStore = noteStore;
|
|
24
|
+
this.privateEventStore = privateEventStore;
|
|
20
25
|
this.l2TipsStore = l2TipsStore;
|
|
26
|
+
this.config = config;
|
|
21
27
|
this.log = !loggerOrSuffix || typeof loggerOrSuffix === 'string' ? createLogger(loggerOrSuffix ? `pxe:block_synchronizer:${loggerOrSuffix}` : `pxe:block_synchronizer`) : loggerOrSuffix;
|
|
22
28
|
this.blockStream = this.createBlockStream(config);
|
|
23
29
|
}
|
|
@@ -34,32 +40,74 @@ import { L2BlockStream } from '@aztec/stdlib/block';
|
|
|
34
40
|
switch(event.type){
|
|
35
41
|
case 'blocks-added':
|
|
36
42
|
{
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
if (this.config.syncChainTip === undefined || this.config.syncChainTip === 'proposed') {
|
|
44
|
+
const lastBlock = event.blocks.at(-1);
|
|
45
|
+
await this.updateAnchorBlockHeader(lastBlock.header);
|
|
46
|
+
}
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
case 'chain-checkpointed':
|
|
50
|
+
{
|
|
51
|
+
if (this.config.syncChainTip === 'checkpointed') {
|
|
52
|
+
// Get the last block header from the checkpoint
|
|
53
|
+
const lastBlock = event.checkpoint.checkpoint.blocks.at(-1);
|
|
54
|
+
await this.updateAnchorBlockHeader(lastBlock.header);
|
|
55
|
+
}
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
case 'chain-proven':
|
|
59
|
+
{
|
|
60
|
+
if (this.config.syncChainTip === 'proven') {
|
|
61
|
+
const blockHeader = await this.node.getBlockHeader(BlockNumber(event.block.number));
|
|
62
|
+
if (blockHeader) {
|
|
63
|
+
await this.updateAnchorBlockHeader(blockHeader);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
case 'chain-finalized':
|
|
69
|
+
{
|
|
70
|
+
if (this.config.syncChainTip === 'finalized') {
|
|
71
|
+
const blockHeader = await this.node.getBlockHeader(BlockNumber(event.block.number));
|
|
72
|
+
if (blockHeader) {
|
|
73
|
+
await this.updateAnchorBlockHeader(blockHeader);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
44
76
|
break;
|
|
45
77
|
}
|
|
46
78
|
case 'chain-pruned':
|
|
47
79
|
{
|
|
80
|
+
const currentAnchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
81
|
+
const currentAnchorBlockNumber = currentAnchorBlockHeader.getBlockNumber();
|
|
82
|
+
if (currentAnchorBlockNumber <= event.block.number) {
|
|
83
|
+
this.log.verbose(`Ignoring prune event to block ${event.block.number} greater than current anchor block ${currentAnchorBlockNumber}`, {
|
|
84
|
+
pruneEvent: event,
|
|
85
|
+
currentAnchorBlockHeader: currentAnchorBlockHeader.toInspect()
|
|
86
|
+
});
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
48
89
|
this.log.warn(`Pruning data after block ${event.block.number} due to reorg`);
|
|
49
|
-
//
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
this.log.error(`Block header not found for block number ${event.block.number} during chain prune`);
|
|
56
|
-
} else {
|
|
57
|
-
await this.anchorBlockStore.setHeader(newHeader);
|
|
90
|
+
// Note that the following is not necessarily the anchor block that will be used in the transaction - if
|
|
91
|
+
// the chain has already moved past the reorg, we'll also see blocks-added events that will push the anchor
|
|
92
|
+
// forward.
|
|
93
|
+
const newAnchorBlockHeader = await this.node.getBlockHeader(L2BlockHash.fromString(event.block.hash));
|
|
94
|
+
if (!newAnchorBlockHeader) {
|
|
95
|
+
throw new Error(`Block header for block number ${event.block.number} and hash ${event.block.hash} not found during chain prune. This likely indicates a bug in the node, as we receive block stream events and fetch block headers from the same node.`);
|
|
58
96
|
}
|
|
97
|
+
// Operations are wrapped in a single transaction to ensure atomicity.
|
|
98
|
+
await this.store.transactionAsync(async ()=>{
|
|
99
|
+
await this.noteStore.rollback(event.block.number, currentAnchorBlockNumber);
|
|
100
|
+
await this.privateEventStore.rollback(event.block.number, currentAnchorBlockNumber);
|
|
101
|
+
await this.updateAnchorBlockHeader(newAnchorBlockHeader);
|
|
102
|
+
});
|
|
59
103
|
break;
|
|
60
104
|
}
|
|
61
105
|
}
|
|
62
106
|
}
|
|
107
|
+
/** Updates the anchor block header to the target block */ async updateAnchorBlockHeader(blockHeader) {
|
|
108
|
+
this.log.verbose(`Updated pxe last block to ${blockHeader.getBlockNumber()}`, blockHeader.toInspect());
|
|
109
|
+
await this.anchorBlockStore.setHeader(blockHeader);
|
|
110
|
+
}
|
|
63
111
|
/**
|
|
64
112
|
* Syncs PXE and the node by downloading the metadata of the latest blocks, allowing simulations to use
|
|
65
113
|
* recent data (e.g. notes), and handling any reorgs that might have occurred.
|
package/dest/config/index.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ export interface KernelProverConfig {
|
|
|
15
15
|
export interface BlockSynchronizerConfig {
|
|
16
16
|
/** Maximum amount of blocks to pull from the stream in one request when synchronizing */
|
|
17
17
|
l2BlockBatchSize: number;
|
|
18
|
+
/** Which chain tip to sync to (proposed, checkpointed, proven, finalized) */
|
|
19
|
+
syncChainTip?: 'proposed' | 'checkpointed' | 'proven' | 'finalized';
|
|
18
20
|
}
|
|
19
21
|
export type PXEConfig = KernelProverConfig & DataStoreConfig & ChainConfig & BlockSynchronizerConfig;
|
|
20
22
|
export type CliPXEOptions = {
|
|
@@ -32,4 +34,4 @@ export declare const allPxeConfigMappings: ConfigMappingsType<CliPXEOptions & PX
|
|
|
32
34
|
* Creates an instance of CliPxeOptions out of environment variables
|
|
33
35
|
*/
|
|
34
36
|
export declare function getCliPXEOptions(): CliPXEOptions & PXEConfig;
|
|
35
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
37
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlI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vQkFBb0IsRUFBRSxrQkFBa0IsQ0FBQyxhQUFhLENBS2xFLENBQUM7QUFFRixlQUFPLE1BQU0sb0JBQW9CLEVBQUUsa0JBQWtCLENBQUMsYUFBYSxHQUFHLFNBQVMsQ0FXOUUsQ0FBQztBQUVGOztHQUVHO0FBQ0gsd0JBQWdCLGdCQUFnQixJQUFJLGFBQWEsR0FBRyxTQUFTLENBUTVEIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EAKxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,wBAAwB,CAAC;AAClF,OAAO,EAAE,KAAK,WAAW,EAAuB,MAAM,sBAAsB,CAAC;AAE7E,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,8CAA8C;IAC9C,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,yFAAyF;IACzF,gBAAgB,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EAKxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,wBAAwB,CAAC;AAClF,OAAO,EAAE,KAAK,WAAW,EAAuB,MAAM,sBAAsB,CAAC;AAE7E,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,8CAA8C;IAC9C,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,yFAAyF;IACzF,gBAAgB,EAAE,MAAM,CAAC;IACzB,6EAA6E;IAC7E,YAAY,CAAC,EAAE,UAAU,GAAG,cAAc,GAAG,QAAQ,GAAG,WAAW,CAAC;CACrE;AAED,MAAM,MAAM,SAAS,GAAG,kBAAkB,GAAG,eAAe,GAAG,WAAW,GAAG,uBAAuB,CAAC;AAErG,MAAM,MAAM,aAAa,GAAG;IAC1B,2CAA2C;IAC3C,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,kBAAkB,CAAC,SAAS,CAgC3D,CAAC;AAEF;;GAEG;AACH,wBAAgB,YAAY,IAAI,SAAS,CAExC;AAED,eAAO,MAAM,oBAAoB,EAAE,kBAAkB,CAAC,aAAa,CAKlE,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,kBAAkB,CAAC,aAAa,GAAG,SAAS,CAW9E,CAAC;AAEF;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,aAAa,GAAG,SAAS,CAQ5D"}
|
package/dest/config/index.js
CHANGED
|
@@ -21,6 +21,23 @@ export const pxeConfigMappings = {
|
|
|
21
21
|
env: 'PXE_PROVER_ENABLED',
|
|
22
22
|
description: 'Enable real proofs',
|
|
23
23
|
...booleanConfigHelper(true)
|
|
24
|
+
},
|
|
25
|
+
syncChainTip: {
|
|
26
|
+
env: 'PXE_SYNC_CHAIN_TIP',
|
|
27
|
+
description: 'Which chain tip to sync to (proposed, checkpointed, proven, finalized)',
|
|
28
|
+
defaultValue: 'proposed',
|
|
29
|
+
parseEnv: (val)=>{
|
|
30
|
+
const allowedValues = [
|
|
31
|
+
'proposed',
|
|
32
|
+
'checkpointed',
|
|
33
|
+
'proven',
|
|
34
|
+
'finalized'
|
|
35
|
+
];
|
|
36
|
+
if (allowedValues.includes(val)) {
|
|
37
|
+
return val;
|
|
38
|
+
}
|
|
39
|
+
throw new Error(`Invalid value for PXE_SYNC_CHAIN_TIP: ${val}. Allowed values are: ${allowedValues.join(', ')}`);
|
|
40
|
+
}
|
|
24
41
|
}
|
|
25
42
|
};
|
|
26
43
|
/**
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
2
|
+
import type { NodeStats } from '@aztec/stdlib/tx';
|
|
3
|
+
export type BenchmarkedNode = AztecNode & {
|
|
4
|
+
getStats(): NodeStats;
|
|
5
|
+
};
|
|
6
|
+
export declare class BenchmarkedNodeFactory {
|
|
7
|
+
static create(node: AztecNode): BenchmarkedNode;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmVuY2htYXJrZWRfbm9kZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NvbnRyYWN0X2Z1bmN0aW9uX3NpbXVsYXRvci9iZW5jaG1hcmtlZF9ub2RlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQ2pFLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBa0IsTUFBTSxrQkFBa0IsQ0FBQztBQWlCbEUsTUFBTSxNQUFNLGVBQWUsR0FBRyxTQUFTLEdBQUc7SUFBRSxRQUFRLElBQUksU0FBUyxDQUFBO0NBQUUsQ0FBQztBQUVwRSxxQkFBYSxzQkFBc0I7SUFDakMsTUFBTSxDQUFDLE1BQU0sQ0FBQyxJQUFJLEVBQUUsU0FBUyxHQUFHLGVBQWUsQ0ErRTlDO0NBQ0YifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"benchmarked_node.d.ts","sourceRoot":"","sources":["../../src/contract_function_simulator/benchmarked_node.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAkB,MAAM,kBAAkB,CAAC;AAiBlE,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG;IAAE,QAAQ,IAAI,SAAS,CAAA;CAAE,CAAC;AAEpE,qBAAa,sBAAsB;IACjC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,GAAG,eAAe,CA+E9C;CACF"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
2
|
+
export class BenchmarkedNodeFactory {
|
|
3
|
+
static create(node) {
|
|
4
|
+
// Per-method call stats
|
|
5
|
+
const perMethod = {};
|
|
6
|
+
// Round trip tracking
|
|
7
|
+
let inFlightCount = 0;
|
|
8
|
+
let currentRoundTripTimer = null;
|
|
9
|
+
let currentRoundTripMethods = [];
|
|
10
|
+
const roundTrips = {
|
|
11
|
+
roundTrips: 0,
|
|
12
|
+
totalBlockingTime: 0,
|
|
13
|
+
roundTripDurations: [],
|
|
14
|
+
roundTripMethods: []
|
|
15
|
+
};
|
|
16
|
+
return new Proxy(node, {
|
|
17
|
+
get (target, prop) {
|
|
18
|
+
if (prop === 'getStats') {
|
|
19
|
+
return ()=>{
|
|
20
|
+
return {
|
|
21
|
+
perMethod,
|
|
22
|
+
roundTrips
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
} else {
|
|
26
|
+
return function(...args) {
|
|
27
|
+
// Track per-method stats
|
|
28
|
+
if (!perMethod[prop]) {
|
|
29
|
+
perMethod[prop] = {
|
|
30
|
+
times: []
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
// Start of a new round trip batch?
|
|
34
|
+
if (inFlightCount === 0) {
|
|
35
|
+
roundTrips.roundTrips++;
|
|
36
|
+
currentRoundTripTimer = new Timer();
|
|
37
|
+
currentRoundTripMethods = [];
|
|
38
|
+
}
|
|
39
|
+
inFlightCount++;
|
|
40
|
+
currentRoundTripMethods.push(prop);
|
|
41
|
+
const callTimer = new Timer();
|
|
42
|
+
const result = target[prop].apply(target, args);
|
|
43
|
+
// Handle completion - called when the call finishes (after Promise resolves)
|
|
44
|
+
const handleCompletion = ()=>{
|
|
45
|
+
const callTime = callTimer.ms();
|
|
46
|
+
perMethod[prop].times.push(callTime);
|
|
47
|
+
inFlightCount--;
|
|
48
|
+
// End of round trip batch - all concurrent calls completed
|
|
49
|
+
if (inFlightCount === 0 && currentRoundTripTimer) {
|
|
50
|
+
const roundTripTime = currentRoundTripTimer.ms();
|
|
51
|
+
roundTrips.totalBlockingTime += roundTripTime;
|
|
52
|
+
roundTrips.roundTripDurations.push(roundTripTime);
|
|
53
|
+
roundTrips.roundTripMethods.push(currentRoundTripMethods);
|
|
54
|
+
currentRoundTripTimer = null;
|
|
55
|
+
currentRoundTripMethods = [];
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
// If the result is a Promise, chain the completion handler
|
|
59
|
+
if (result && typeof result.then === 'function') {
|
|
60
|
+
return result.then((value)=>{
|
|
61
|
+
handleCompletion();
|
|
62
|
+
return value;
|
|
63
|
+
}, (error)=>{
|
|
64
|
+
handleCompletion();
|
|
65
|
+
throw error;
|
|
66
|
+
});
|
|
67
|
+
} else {
|
|
68
|
+
// Synchronous method - handle completion immediately
|
|
69
|
+
handleCompletion();
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -46,9 +46,10 @@ export declare class ContractFunctionSimulator {
|
|
|
46
46
|
* @param senderForTags - The address that is used as a tagging sender when emitting private logs. Returned from
|
|
47
47
|
* the `privateGetSenderForTags` oracle.
|
|
48
48
|
* @param scopes - The accounts whose notes we can access in this call. Currently optional and will default to all.
|
|
49
|
+
* @param jobId - The job ID for staged writes.
|
|
49
50
|
* @returns The result of the execution.
|
|
50
51
|
*/
|
|
51
|
-
run(request: TxExecutionRequest, contractAddress: AztecAddress, selector: FunctionSelector, msgSender: AztecAddress | undefined, anchorBlockHeader: BlockHeader, senderForTags
|
|
52
|
+
run(request: TxExecutionRequest, contractAddress: AztecAddress, selector: FunctionSelector, msgSender: AztecAddress | undefined, anchorBlockHeader: BlockHeader, senderForTags: AztecAddress | undefined, scopes: AztecAddress[] | undefined, jobId: string): Promise<PrivateExecutionResult>;
|
|
52
53
|
/**
|
|
53
54
|
* Runs a utility function.
|
|
54
55
|
* @param call - The function call to execute.
|
|
@@ -58,15 +59,13 @@ export declare class ContractFunctionSimulator {
|
|
|
58
59
|
* accounts if not specified.
|
|
59
60
|
* @returns A return value of the utility function in a form as returned by the simulator (Noir fields)
|
|
60
61
|
*/
|
|
61
|
-
runUtility(call: FunctionCall, authwits: AuthWitness[], anchorBlockHeader: BlockHeader, scopes
|
|
62
|
+
runUtility(call: FunctionCall, authwits: AuthWitness[], anchorBlockHeader: BlockHeader, scopes: AztecAddress[] | undefined, jobId: string): Promise<Fr[]>;
|
|
62
63
|
/**
|
|
63
64
|
* Returns the execution statistics collected during the simulator run.
|
|
64
65
|
* @returns The execution statistics.
|
|
65
66
|
*/
|
|
66
67
|
getStats(): {
|
|
67
|
-
nodeRPCCalls:
|
|
68
|
-
times: number[];
|
|
69
|
-
}>>;
|
|
68
|
+
nodeRPCCalls: import("@aztec/stdlib/tx").NodeStats;
|
|
70
69
|
};
|
|
71
70
|
}
|
|
72
71
|
/**
|
|
@@ -76,10 +75,10 @@ export declare class ContractFunctionSimulator {
|
|
|
76
75
|
* (allowing state overrides) and is much faster, while still generating a valid
|
|
77
76
|
* output that can be sent to the node for public simulation
|
|
78
77
|
* @param privateExecutionResult - The result of the private execution.
|
|
79
|
-
* @param nonceGenerator - A nonce generator for note hashes. According to the protocol rules,
|
|
80
|
-
* it can either be the first nullifier in the tx or the hash of the initial tx request if there are none.
|
|
81
78
|
* @param contractStore - A provider for contract data in order to get function names and debug info.
|
|
79
|
+
* @param minRevertibleSideEffectCounterOverride - Optional override for the min revertible side effect counter.
|
|
80
|
+
* Used by TXE to simulate account contract behavior (setting the counter before app execution).
|
|
82
81
|
* @returns The simulated proving result.
|
|
83
82
|
*/
|
|
84
|
-
export declare function generateSimulatedProvingResult(privateExecutionResult: PrivateExecutionResult,
|
|
85
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
83
|
+
export declare function generateSimulatedProvingResult(privateExecutionResult: PrivateExecutionResult, contractStore: ContractStore, minRevertibleSideEffectCounterOverride?: number): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>>;
|
|
84
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udHJhY3RfZnVuY3Rpb25fc2ltdWxhdG9yLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29udHJhY3RfZnVuY3Rpb25fc2ltdWxhdG9yL2NvbnRyYWN0X2Z1bmN0aW9uX3NpbXVsYXRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFvQkEsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBR3BELE9BQU8sS0FBSyxFQUFFLFFBQVEsRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBR2pELE9BQU8sRUFDTCxLQUFLLGdCQUFnQixFQU90QixNQUFNLHlCQUF5QixDQUFDO0FBQ2pDLE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBQ3RELE9BQU8sRUFBRSxnQkFBZ0IsRUFBZ0IsTUFBTSxtQkFBbUIsQ0FBQztBQUNuRSxPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSw0QkFBNEIsQ0FBQztBQUM5RCxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFTM0QsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDakUsT0FBTyxFQUlMLEtBQUssaUNBQWlD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QUFPLENBQUMsRUFBRSxFQUFFLENBQUMsQ0FzRGY7SUFHRDs7O09BR0c7SUFDSCxRQUFROztNQVVQO0NBQ0Y7QUFZRDs7Ozs7Ozs7Ozs7R0FXRztBQUNILHdCQUFzQiw4QkFBOEIsQ0FDbEQsc0JBQXNCLEVBQUUsc0JBQXNCLEVBQzlDLGFBQWEsRUFBRSxhQUFhLEVBQzVCLHNDQUFzQyxDQUFDLEVBQUUsTUFBTSxHQUM5QyxPQUFPLENBQUMsaUNBQWlDLENBQUMsb0NBQW9DLENBQUMsQ0FBQyxDQXdObEYifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract_function_simulator.d.ts","sourceRoot":"","sources":["../../src/contract_function_simulator/contract_function_simulator.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAGpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGjD,OAAO,EACL,KAAK,gBAAgB,EAOtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAgB,MAAM,mBAAmB,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAS3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAIL,KAAK,iCAAiC,EACtC,oCAAoC,EAKrC,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EACL,WAAW,EAGX,sBAAsB,EAEtB,kBAAkB,EAGnB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AAC9E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qDAAqD,CAAC;AAC5F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AAC9E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uDAAuD,CAAC;AAC/F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qDAAqD,CAAC;AACjG,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uDAAuD,CAAC;AACpG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kDAAkD,CAAC;AAU3F;;GAEG;AACH,qBAAa,yBAAyB;IAIlC,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,gBAAgB;IACxB,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,qBAAqB;IAC7B,OAAO,CAAC,sBAAsB;IAC9B,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,iBAAiB;IACzB,OAAO,CAAC,SAAS;IAdnB,OAAO,CAAC,GAAG,CAAS;IAEpB,YACU,aAAa,EAAE,aAAa,EAC5B,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,SAAS,EACpB,gBAAgB,EAAE,gBAAgB,EAClC,kBAAkB,EAAE,kBAAkB,EACtC,qBAAqB,EAAE,qBAAqB,EAC5C,sBAAsB,EAAE,sBAAsB,EAC9C,YAAY,EAAE,YAAY,EAC1B,iBAAiB,EAAE,iBAAiB,EACpC,SAAS,EAAE,gBAAgB,EAGpC;IAED
|
|
1
|
+
{"version":3,"file":"contract_function_simulator.d.ts","sourceRoot":"","sources":["../../src/contract_function_simulator/contract_function_simulator.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,EAAE,EA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,aAAa,EAAE,aAAa,EAC5B,sCAAsC,CAAC,EAAE,MAAM,GAC9C,OAAO,CAAC,iCAAiC,CAAC,oCAAoC,CAAC,CAAC,CAwNlF"}
|
|
@@ -20,7 +20,7 @@ import { ExecutionNoteCache } from './execution_note_cache.js';
|
|
|
20
20
|
import { ExecutionTaggingIndexCache } from './execution_tagging_index_cache.js';
|
|
21
21
|
import { HashedValuesCache } from './hashed_values_cache.js';
|
|
22
22
|
import { Oracle } from './oracle/oracle.js';
|
|
23
|
-
import { executePrivateFunction
|
|
23
|
+
import { executePrivateFunction } from './oracle/private_execution.js';
|
|
24
24
|
import { PrivateExecutionOracle } from './oracle/private_execution_oracle.js';
|
|
25
25
|
import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
|
|
26
26
|
/**
|
|
@@ -65,11 +65,10 @@ import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
|
|
|
65
65
|
* @param senderForTags - The address that is used as a tagging sender when emitting private logs. Returned from
|
|
66
66
|
* the `privateGetSenderForTags` oracle.
|
|
67
67
|
* @param scopes - The accounts whose notes we can access in this call. Currently optional and will default to all.
|
|
68
|
+
* @param jobId - The job ID for staged writes.
|
|
68
69
|
* @returns The result of the execution.
|
|
69
|
-
*/ async run(request, contractAddress, selector, msgSender = AztecAddress.fromField(Fr.MAX_FIELD_VALUE), anchorBlockHeader, senderForTags, scopes) {
|
|
70
|
+
*/ async run(request, contractAddress, selector, msgSender = AztecAddress.fromField(Fr.MAX_FIELD_VALUE), anchorBlockHeader, senderForTags, scopes, jobId) {
|
|
70
71
|
const simulatorSetupTimer = new Timer();
|
|
71
|
-
await this.contractStore.syncPrivateState(contractAddress, selector, (privateSyncCall)=>this.runUtility(privateSyncCall, [], anchorBlockHeader, scopes));
|
|
72
|
-
await verifyCurrentClassId(contractAddress, this.aztecNode, this.contractStore, anchorBlockHeader);
|
|
73
72
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(contractAddress, selector);
|
|
74
73
|
if (entryPointArtifact.functionType !== FunctionType.PRIVATE) {
|
|
75
74
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as private`);
|
|
@@ -84,8 +83,8 @@ import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
|
|
|
84
83
|
const noteCache = new ExecutionNoteCache(protocolNullifier);
|
|
85
84
|
const taggingIndexCache = new ExecutionTaggingIndexCache();
|
|
86
85
|
const privateExecutionOracle = new PrivateExecutionOracle(request.firstCallArgsHash, request.txContext, callContext, anchorBlockHeader, async (call)=>{
|
|
87
|
-
await this.runUtility(call, [], anchorBlockHeader, scopes);
|
|
88
|
-
}, request.authWitnesses, request.capsules, HashedValuesCache.create(request.argsOfCalls), noteCache, taggingIndexCache, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.aztecNode, this.anchorBlockStore, this.senderTaggingStore, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore, 0, startSideEffectCounter, undefined, scopes, senderForTags, this.simulator);
|
|
86
|
+
await this.runUtility(call, [], anchorBlockHeader, scopes, jobId);
|
|
87
|
+
}, request.authWitnesses, request.capsules, HashedValuesCache.create(request.argsOfCalls), noteCache, taggingIndexCache, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.aztecNode, this.anchorBlockStore, this.senderTaggingStore, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore, jobId, 0, startSideEffectCounter, undefined, scopes, senderForTags, this.simulator);
|
|
89
88
|
const setupTime = simulatorSetupTimer.ms();
|
|
90
89
|
try {
|
|
91
90
|
// Note: any nested private function calls are made recursively within this
|
|
@@ -94,8 +93,8 @@ import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
|
|
|
94
93
|
// within executionResult.nestedExecutionResults).
|
|
95
94
|
const executionResult = await executePrivateFunction(this.simulator, privateExecutionOracle, entryPointArtifact, contractAddress, request.functionSelector);
|
|
96
95
|
const simulatorTeardownTimer = new Timer();
|
|
97
|
-
|
|
98
|
-
const firstNullifierHint =
|
|
96
|
+
noteCache.finish();
|
|
97
|
+
const firstNullifierHint = noteCache.getNonceGenerator();
|
|
99
98
|
const publicCallRequests = collectNested([
|
|
100
99
|
executionResult
|
|
101
100
|
], (r)=>r.publicInputs.publicCallRequests.getActiveItems().map((r)=>r.inner).concat(r.publicInputs.publicTeardownCallRequest.isEmpty() ? [] : [
|
|
@@ -127,13 +126,12 @@ import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
|
|
|
127
126
|
* @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
|
|
128
127
|
* accounts if not specified.
|
|
129
128
|
* @returns A return value of the utility function in a form as returned by the simulator (Noir fields)
|
|
130
|
-
*/ async runUtility(call, authwits, anchorBlockHeader, scopes) {
|
|
131
|
-
await verifyCurrentClassId(call.to, this.aztecNode, this.contractStore, anchorBlockHeader);
|
|
129
|
+
*/ async runUtility(call, authwits, anchorBlockHeader, scopes, jobId) {
|
|
132
130
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
133
131
|
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
134
132
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
135
133
|
}
|
|
136
|
-
const oracle = new UtilityExecutionOracle(call.to, authwits, [], anchorBlockHeader, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.aztecNode, this.anchorBlockStore, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore, undefined, scopes);
|
|
134
|
+
const oracle = new UtilityExecutionOracle(call.to, authwits, [], anchorBlockHeader, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.aztecNode, this.anchorBlockStore, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore, jobId, undefined, scopes);
|
|
137
135
|
try {
|
|
138
136
|
this.log.verbose(`Executing utility function ${entryPointArtifact.name}`, {
|
|
139
137
|
contract: call.to,
|
|
@@ -160,7 +158,15 @@ import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
|
|
|
160
158
|
* Returns the execution statistics collected during the simulator run.
|
|
161
159
|
* @returns The execution statistics.
|
|
162
160
|
*/ getStats() {
|
|
163
|
-
const nodeRPCCalls = typeof this.aztecNode.getStats === 'function' ? this.aztecNode.getStats() : {
|
|
161
|
+
const nodeRPCCalls = typeof this.aztecNode.getStats === 'function' ? this.aztecNode.getStats() : {
|
|
162
|
+
perMethod: {},
|
|
163
|
+
roundTrips: {
|
|
164
|
+
roundTrips: 0,
|
|
165
|
+
totalBlockingTime: 0,
|
|
166
|
+
roundTripDurations: [],
|
|
167
|
+
roundTripMethods: []
|
|
168
|
+
}
|
|
169
|
+
};
|
|
164
170
|
return {
|
|
165
171
|
nodeRPCCalls
|
|
166
172
|
};
|
|
@@ -181,11 +187,11 @@ class OrderedSideEffect {
|
|
|
181
187
|
* (allowing state overrides) and is much faster, while still generating a valid
|
|
182
188
|
* output that can be sent to the node for public simulation
|
|
183
189
|
* @param privateExecutionResult - The result of the private execution.
|
|
184
|
-
* @param nonceGenerator - A nonce generator for note hashes. According to the protocol rules,
|
|
185
|
-
* it can either be the first nullifier in the tx or the hash of the initial tx request if there are none.
|
|
186
190
|
* @param contractStore - A provider for contract data in order to get function names and debug info.
|
|
191
|
+
* @param minRevertibleSideEffectCounterOverride - Optional override for the min revertible side effect counter.
|
|
192
|
+
* Used by TXE to simulate account contract behavior (setting the counter before app execution).
|
|
187
193
|
* @returns The simulated proving result.
|
|
188
|
-
*/ export async function generateSimulatedProvingResult(privateExecutionResult,
|
|
194
|
+
*/ export async function generateSimulatedProvingResult(privateExecutionResult, contractStore, minRevertibleSideEffectCounterOverride) {
|
|
189
195
|
const siloedNoteHashes = [];
|
|
190
196
|
const nullifiers = [];
|
|
191
197
|
const taggedPrivateLogs = [];
|
|
@@ -239,12 +245,13 @@ class OrderedSideEffect {
|
|
|
239
245
|
const sortByCounter = (a, b)=>a.counter - b.counter;
|
|
240
246
|
const getEffect = (orderedSideEffect)=>orderedSideEffect.sideEffect;
|
|
241
247
|
const isPrivateOnlyTx = privateExecutionResult.publicFunctionCalldata.length === 0;
|
|
242
|
-
const minRevertibleSideEffectCounter = getFinalMinRevertibleSideEffectCounter(privateExecutionResult);
|
|
248
|
+
const minRevertibleSideEffectCounter = minRevertibleSideEffectCounterOverride ?? getFinalMinRevertibleSideEffectCounter(privateExecutionResult);
|
|
243
249
|
const [nonRevertibleNullifiers, revertibleNullifiers] = splitOrderedSideEffects(nullifiers.sort(sortByCounter), minRevertibleSideEffectCounter);
|
|
244
|
-
|
|
250
|
+
const nonceGenerator = privateExecutionResult.firstNullifier;
|
|
251
|
+
if (nonRevertibleNullifiers.length === 0) {
|
|
252
|
+
nonRevertibleNullifiers.push(nonceGenerator);
|
|
253
|
+
} else if (!nonRevertibleNullifiers[0].equals(nonceGenerator)) {
|
|
245
254
|
throw new Error('The first non revertible nullifier should be equal to the nonce generator. This is a bug!');
|
|
246
|
-
} else {
|
|
247
|
-
nonRevertibleNullifiers.unshift(nonceGenerator);
|
|
248
255
|
}
|
|
249
256
|
if (isPrivateOnlyTx) {
|
|
250
257
|
// We must make the note hashes unique by using the
|
|
@@ -260,11 +267,15 @@ class OrderedSideEffect {
|
|
|
260
267
|
inputsForRollup = new PartialPrivateTailPublicInputsForRollup(accumulatedDataForRollup);
|
|
261
268
|
} else {
|
|
262
269
|
const [nonRevertibleNoteHashes, revertibleNoteHashes] = splitOrderedSideEffects(siloedNoteHashes.sort(sortByCounter), minRevertibleSideEffectCounter);
|
|
270
|
+
const nonRevertibleUniqueNoteHashes = await Promise.all(nonRevertibleNoteHashes.map(async (noteHash, i)=>{
|
|
271
|
+
const nonce = await computeNoteHashNonce(nonceGenerator, i);
|
|
272
|
+
return await computeUniqueNoteHash(nonce, noteHash);
|
|
273
|
+
}));
|
|
263
274
|
const [nonRevertibleL2ToL1Messages, revertibleL2ToL1Messages] = splitOrderedSideEffects(l2ToL1Messages.sort(sortByCounter), minRevertibleSideEffectCounter);
|
|
264
275
|
const [nonRevertibleTaggedPrivateLogs, revertibleTaggedPrivateLogs] = splitOrderedSideEffects(taggedPrivateLogs, minRevertibleSideEffectCounter);
|
|
265
276
|
const [nonRevertibleContractClassLogHashes, revertibleContractClassLogHashes] = splitOrderedSideEffects(contractClassLogsHashes.sort(sortByCounter), minRevertibleSideEffectCounter);
|
|
266
277
|
const [nonRevertiblePublicCallRequests, revertiblePublicCallRequests] = splitOrderedSideEffects(publicCallRequests.sort(sortByCounter), minRevertibleSideEffectCounter);
|
|
267
|
-
const nonRevertibleData = new PrivateToPublicAccumulatedData(padArrayEnd(
|
|
278
|
+
const nonRevertibleData = new PrivateToPublicAccumulatedData(padArrayEnd(nonRevertibleUniqueNoteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX), padArrayEnd(nonRevertibleNullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX), padArrayEnd(nonRevertibleL2ToL1Messages, ScopedL2ToL1Message.empty(), MAX_L2_TO_L1_MSGS_PER_TX), padArrayEnd(nonRevertibleTaggedPrivateLogs, PrivateLog.empty(), MAX_PRIVATE_LOGS_PER_TX), padArrayEnd(nonRevertibleContractClassLogHashes, ScopedLogHash.empty(), MAX_CONTRACT_CLASS_LOGS_PER_TX), padArrayEnd(nonRevertiblePublicCallRequests, PublicCallRequest.empty(), MAX_ENQUEUED_CALLS_PER_TX));
|
|
268
279
|
const revertibleData = new PrivateToPublicAccumulatedData(padArrayEnd(revertibleNoteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX), padArrayEnd(revertibleNullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX), padArrayEnd(revertibleL2ToL1Messages, ScopedL2ToL1Message.empty(), MAX_L2_TO_L1_MSGS_PER_TX), padArrayEnd(revertibleTaggedPrivateLogs, PrivateLog.empty(), MAX_PRIVATE_LOGS_PER_TX), padArrayEnd(revertibleContractClassLogHashes, ScopedLogHash.empty(), MAX_CONTRACT_CLASS_LOGS_PER_TX), padArrayEnd(revertiblePublicCallRequests, PublicCallRequest.empty(), MAX_ENQUEUED_CALLS_PER_TX));
|
|
269
280
|
gasUsed = meterGasUsed(revertibleData).add(meterGasUsed(nonRevertibleData));
|
|
270
281
|
if (publicTeardownCallRequest) {
|
|
@@ -286,7 +297,7 @@ function splitOrderedSideEffects(effects, minRevertibleSideEffectCounter) {
|
|
|
286
297
|
const revertibleSideEffects = [];
|
|
287
298
|
const nonRevertibleSideEffects = [];
|
|
288
299
|
effects.forEach((effect)=>{
|
|
289
|
-
if (effect.counter < minRevertibleSideEffectCounter) {
|
|
300
|
+
if (minRevertibleSideEffectCounter === 0 || effect.counter < minRevertibleSideEffectCounter) {
|
|
290
301
|
nonRevertibleSideEffects.push(effect.sideEffect);
|
|
291
302
|
} else {
|
|
292
303
|
revertibleSideEffects.push(effect.sideEffect);
|
|
@@ -28,14 +28,17 @@ export declare class ExecutionNoteCache {
|
|
|
28
28
|
*/
|
|
29
29
|
private nullifierMap;
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* Nullifiers emitted by private calls in this transaction.
|
|
32
|
+
*/
|
|
33
|
+
private emittedNullifiers;
|
|
34
|
+
/**
|
|
35
|
+
* The counter that separates non-revertible side effects (which persist even if the tx reverts) from revertible ones.
|
|
32
36
|
*/
|
|
33
|
-
private allNullifiers;
|
|
34
37
|
private minRevertibleSideEffectCounter;
|
|
35
38
|
private inRevertiblePhase;
|
|
36
39
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
40
|
+
* Whether the protocol nullifier was used for nonce generation.
|
|
41
|
+
* We don't need to use the protocol nullifier if a non-revertible nullifier is emitted.
|
|
39
42
|
*/
|
|
40
43
|
private usedProtocolNullifierForNonces;
|
|
41
44
|
constructor(protocolNullifier: Fr);
|
|
@@ -45,9 +48,7 @@ export declare class ExecutionNoteCache {
|
|
|
45
48
|
*/
|
|
46
49
|
setMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter: number): Promise<void>;
|
|
47
50
|
isSideEffectCounterRevertible(sideEffectCounter: number): boolean;
|
|
48
|
-
finish():
|
|
49
|
-
usedProtocolNullifierForNonces: boolean;
|
|
50
|
-
};
|
|
51
|
+
finish(): void;
|
|
51
52
|
/**
|
|
52
53
|
* Add a new note to cache.
|
|
53
54
|
* @param note - New note created during execution.
|
|
@@ -88,8 +89,16 @@ export declare class ExecutionNoteCache {
|
|
|
88
89
|
*/
|
|
89
90
|
getNullifiers(contractAddress: AztecAddress): Set<bigint>;
|
|
90
91
|
getAllNotes(): PendingNote[];
|
|
92
|
+
/**
|
|
93
|
+
* @returns All nullifiers emitted by private calls in this transaction.
|
|
94
|
+
*/
|
|
95
|
+
getEmittedNullifiers(): Fr[];
|
|
96
|
+
/**
|
|
97
|
+
* @returns All nullifiers emitted by private calls in this transaction. If the protocol nullifier was used as the
|
|
98
|
+
* nonce generator, it is injected as the first nullifier.
|
|
99
|
+
*/
|
|
91
100
|
getAllNullifiers(): Fr[];
|
|
92
|
-
|
|
101
|
+
getNonceGenerator(): Fr;
|
|
93
102
|
}
|
|
94
103
|
export {};
|
|
95
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
104
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXhlY3V0aW9uX25vdGVfY2FjaGUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb250cmFjdF9mdW5jdGlvbl9zaW11bGF0b3IvZXhlY3V0aW9uX25vdGVfY2FjaGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BELE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBR2hFLE9BQU8sS0FBSyxFQUFFLFFBQVEsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBRXZELF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