@aztec/pxe 0.0.1-commit.d6f2b3f94 → 0.0.1-commit.dbf9cec
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/access_scopes.d.ts +9 -0
- package/dest/access_scopes.d.ts.map +1 -0
- package/dest/access_scopes.js +6 -0
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +53 -29
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +172 -68
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +5 -5
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +3 -3
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +2 -2
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +1 -1
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +2 -2
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.d.ts +2 -2
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +2 -2
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +35 -36
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +71 -26
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +30 -12
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +36 -36
- package/dest/contract_logging.d.ts +22 -0
- package/dest/contract_logging.d.ts.map +1 -0
- package/dest/contract_logging.js +23 -0
- package/dest/contract_sync/contract_sync_service.d.ts +4 -2
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
- package/dest/contract_sync/contract_sync_service.js +34 -19
- package/dest/contract_sync/helpers.d.ts +3 -2
- package/dest/contract_sync/helpers.d.ts.map +1 -1
- package/dest/contract_sync/helpers.js +3 -3
- package/dest/debug/pxe_debug_utils.d.ts +5 -4
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +4 -4
- package/dest/entrypoints/client/bundle/index.d.ts +4 -1
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +3 -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 +9 -1
- package/dest/entrypoints/client/lazy/index.d.ts +4 -1
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +3 -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 +9 -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.js +9 -1
- 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 +9 -14
- package/dest/notes/note_service.d.ts +4 -3
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +3 -2
- package/dest/notes_filter.d.ts +25 -0
- package/dest/notes_filter.d.ts.map +1 -0
- package/dest/notes_filter.js +4 -0
- package/dest/oracle_version.d.ts +2 -2
- package/dest/oracle_version.js +2 -2
- package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
- package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
- package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
- package/dest/private_kernel/hints/index.d.ts +1 -1
- package/dest/private_kernel/hints/index.js +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +4 -3
- 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 +129 -68
- package/dest/private_kernel/hints/test_utils.d.ts +122 -0
- package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
- package/dest/private_kernel/hints/test_utils.js +203 -0
- 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 +19 -11
- package/dest/private_kernel/private_kernel_oracle.d.ts +6 -2
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +7 -3
- package/dest/pxe.d.ts +58 -23
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +65 -53
- package/dest/storage/contract_store/contract_store.d.ts +42 -15
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +140 -64
- package/dest/storage/note_store/note_store.d.ts +3 -3
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +3 -4
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +5 -5
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +4 -4
- package/dest/tagging/get_all_logs_by_tags.d.ts +1 -1
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
- package/dest/tagging/get_all_logs_by_tags.js +17 -3
- package/dest/tagging/index.d.ts +2 -2
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +1 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +4 -5
- 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 +7 -7
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +6 -7
- 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 +12 -11
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +4 -8
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +3 -6
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +4 -7
- 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 +14 -15
- package/package.json +16 -16
- package/src/access_scopes.ts +9 -0
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +320 -128
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +5 -5
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -1
- package/src/contract_function_simulator/oracle/interfaces.ts +1 -1
- package/src/contract_function_simulator/oracle/oracle.ts +2 -2
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +95 -102
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +77 -33
- package/src/contract_logging.ts +39 -0
- package/src/contract_sync/contract_sync_service.ts +49 -26
- package/src/contract_sync/helpers.ts +7 -2
- package/src/debug/pxe_debug_utils.ts +11 -9
- package/src/entrypoints/client/bundle/index.ts +3 -0
- package/src/entrypoints/client/bundle/utils.ts +9 -1
- package/src/entrypoints/client/lazy/index.ts +3 -0
- package/src/entrypoints/client/lazy/utils.ts +9 -1
- package/src/entrypoints/server/index.ts +2 -0
- package/src/entrypoints/server/utils.ts +7 -7
- package/src/logs/log_service.ts +17 -24
- package/src/notes/note_service.ts +4 -3
- package/src/notes_filter.ts +26 -0
- package/src/oracle_version.ts +2 -2
- package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
- package/src/private_kernel/hints/index.ts +1 -1
- package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +164 -117
- package/src/private_kernel/hints/test_utils.ts +325 -0
- package/src/private_kernel/private_kernel_execution_prover.ts +19 -12
- package/src/private_kernel/private_kernel_oracle.ts +7 -7
- package/src/pxe.ts +132 -98
- package/src/storage/contract_store/contract_store.ts +170 -71
- package/src/storage/note_store/note_store.ts +8 -5
- package/src/storage/tagging_store/recipient_tagging_store.ts +9 -5
- package/src/storage/tagging_store/sender_tagging_store.ts +8 -8
- package/src/tagging/get_all_logs_by_tags.ts +28 -4
- package/src/tagging/index.ts +1 -1
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +7 -10
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +10 -15
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +4 -9
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +11 -20
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
2
|
+
/**
|
|
3
|
+
* Controls which accounts' private state and keys are accessible during execution.
|
|
4
|
+
* - `'ALL_SCOPES'`: All registered accounts' private state and keys are accessible.
|
|
5
|
+
* - `AztecAddress[]` with entries: Only the specified accounts' private state and keys are accessible.
|
|
6
|
+
* - `[]` (empty array): Deny-all. No private state is visible and no keys are accessible.
|
|
7
|
+
*/
|
|
8
|
+
export type AccessScopes = 'ALL_SCOPES' | AztecAddress[];
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWNjZXNzX3Njb3Blcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2FjY2Vzc19zY29wZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFFaEU7Ozs7O0dBS0c7QUFDSCxNQUFNLE1BQU0sWUFBWSxHQUFHLFlBQVksR0FBRyxZQUFZLEVBQUUsQ0FBQyJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"access_scopes.d.ts","sourceRoot":"","sources":["../src/access_scopes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Controls which accounts' private state and keys are accessible during execution.
|
|
3
|
+
* - `'ALL_SCOPES'`: All registered accounts' private state and keys are accessible.
|
|
4
|
+
* - `AztecAddress[]` with entries: Only the specified accounts' private state and keys are accessible.
|
|
5
|
+
* - `[]` (empty array): Deny-all. No private state is visible and no keys are accessible.
|
|
6
|
+
*/ export { };
|
|
@@ -8,6 +8,7 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
8
8
|
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
9
9
|
import { type PrivateKernelExecutionProofOutput, PrivateKernelTailCircuitPublicInputs } from '@aztec/stdlib/kernel';
|
|
10
10
|
import { BlockHeader, PrivateExecutionResult, TxExecutionRequest } from '@aztec/stdlib/tx';
|
|
11
|
+
import type { AccessScopes } from '../access_scopes.js';
|
|
11
12
|
import type { ContractSyncService } from '../contract_sync/contract_sync_service.js';
|
|
12
13
|
import type { AddressStore } from '../storage/address_store/address_store.js';
|
|
13
14
|
import type { CapsuleStore } from '../storage/capsule_store/capsule_store.js';
|
|
@@ -17,39 +18,61 @@ import type { PrivateEventStore } from '../storage/private_event_store/private_e
|
|
|
17
18
|
import type { RecipientTaggingStore } from '../storage/tagging_store/recipient_tagging_store.js';
|
|
18
19
|
import type { SenderAddressBookStore } from '../storage/tagging_store/sender_address_book_store.js';
|
|
19
20
|
import type { SenderTaggingStore } from '../storage/tagging_store/sender_tagging_store.js';
|
|
21
|
+
/** Options for ContractFunctionSimulator.run. */
|
|
22
|
+
export type ContractSimulatorRunOpts = {
|
|
23
|
+
/** The address of the contract (should match request.origin). */
|
|
24
|
+
contractAddress: AztecAddress;
|
|
25
|
+
/** The function selector of the entry point. */
|
|
26
|
+
selector: FunctionSelector;
|
|
27
|
+
/** The address calling the function. Can be replaced to simulate a call from another contract or account. */
|
|
28
|
+
msgSender?: AztecAddress;
|
|
29
|
+
/** The block header to use as base state for this run. */
|
|
30
|
+
anchorBlockHeader: BlockHeader;
|
|
31
|
+
/** The address used as a tagging sender when emitting private logs. */
|
|
32
|
+
senderForTags?: AztecAddress;
|
|
33
|
+
/** The accounts whose notes we can access in this call. */
|
|
34
|
+
scopes: AccessScopes;
|
|
35
|
+
/** The job ID for staged writes. */
|
|
36
|
+
jobId: string;
|
|
37
|
+
};
|
|
38
|
+
/** Args for ContractFunctionSimulator constructor. */
|
|
39
|
+
export type ContractFunctionSimulatorArgs = {
|
|
40
|
+
contractStore: ContractStore;
|
|
41
|
+
noteStore: NoteStore;
|
|
42
|
+
keyStore: KeyStore;
|
|
43
|
+
addressStore: AddressStore;
|
|
44
|
+
aztecNode: AztecNode;
|
|
45
|
+
senderTaggingStore: SenderTaggingStore;
|
|
46
|
+
recipientTaggingStore: RecipientTaggingStore;
|
|
47
|
+
senderAddressBookStore: SenderAddressBookStore;
|
|
48
|
+
capsuleStore: CapsuleStore;
|
|
49
|
+
privateEventStore: PrivateEventStore;
|
|
50
|
+
simulator: CircuitSimulator;
|
|
51
|
+
contractSyncService: ContractSyncService;
|
|
52
|
+
};
|
|
20
53
|
/**
|
|
21
54
|
* The contract function simulator.
|
|
22
55
|
*/
|
|
23
56
|
export declare class ContractFunctionSimulator {
|
|
24
|
-
private
|
|
25
|
-
private
|
|
26
|
-
private
|
|
27
|
-
private
|
|
28
|
-
private
|
|
29
|
-
private
|
|
30
|
-
private
|
|
31
|
-
private
|
|
32
|
-
private
|
|
33
|
-
private
|
|
34
|
-
private
|
|
35
|
-
private
|
|
36
|
-
private
|
|
37
|
-
constructor(
|
|
57
|
+
private readonly log;
|
|
58
|
+
private readonly contractStore;
|
|
59
|
+
private readonly noteStore;
|
|
60
|
+
private readonly keyStore;
|
|
61
|
+
private readonly addressStore;
|
|
62
|
+
private readonly aztecNode;
|
|
63
|
+
private readonly senderTaggingStore;
|
|
64
|
+
private readonly recipientTaggingStore;
|
|
65
|
+
private readonly senderAddressBookStore;
|
|
66
|
+
private readonly capsuleStore;
|
|
67
|
+
private readonly privateEventStore;
|
|
68
|
+
private readonly simulator;
|
|
69
|
+
private readonly contractSyncService;
|
|
70
|
+
constructor(args: ContractFunctionSimulatorArgs);
|
|
38
71
|
/**
|
|
39
72
|
* Runs a private function.
|
|
40
73
|
* @param request - The transaction request.
|
|
41
|
-
* @param entryPointArtifact - The artifact of the entry point function.
|
|
42
|
-
* @param contractAddress - The address of the contract (should match request.origin)
|
|
43
|
-
* @param msgSender - The address calling the function. This can be replaced to simulate a call from another contract
|
|
44
|
-
* or a specific account.
|
|
45
|
-
* @param anchorBlockHeader - The block header to use as base state for this run.
|
|
46
|
-
* @param senderForTags - The address that is used as a tagging sender when emitting private logs. Returned from
|
|
47
|
-
* the `privateGetSenderForTags` oracle.
|
|
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.
|
|
50
|
-
* @returns The result of the execution.
|
|
51
74
|
*/
|
|
52
|
-
run(request: TxExecutionRequest, contractAddress
|
|
75
|
+
run(request: TxExecutionRequest, { contractAddress, selector, msgSender, anchorBlockHeader, senderForTags, scopes, jobId }: ContractSimulatorRunOpts): Promise<PrivateExecutionResult>;
|
|
53
76
|
/**
|
|
54
77
|
* Runs a utility function.
|
|
55
78
|
* @param call - The function call to execute.
|
|
@@ -59,7 +82,7 @@ export declare class ContractFunctionSimulator {
|
|
|
59
82
|
* accounts if not specified.
|
|
60
83
|
* @returns A return value of the utility function in a form as returned by the simulator (Noir fields)
|
|
61
84
|
*/
|
|
62
|
-
runUtility(call: FunctionCall, authwits: AuthWitness[], anchorBlockHeader: BlockHeader, scopes:
|
|
85
|
+
runUtility(call: FunctionCall, authwits: AuthWitness[], anchorBlockHeader: BlockHeader, scopes: AccessScopes, jobId: string): Promise<Fr[]>;
|
|
63
86
|
/**
|
|
64
87
|
* Returns the execution statistics collected during the simulator run.
|
|
65
88
|
* @returns The execution statistics.
|
|
@@ -75,10 +98,11 @@ export declare class ContractFunctionSimulator {
|
|
|
75
98
|
* (allowing state overrides) and is much faster, while still generating a valid
|
|
76
99
|
* output that can be sent to the node for public simulation
|
|
77
100
|
* @param privateExecutionResult - The result of the private execution.
|
|
78
|
-
* @param
|
|
101
|
+
* @param debugFunctionNameGetter - A provider for contract data in order to get function names and debug info.
|
|
102
|
+
* @param node - AztecNode for verifying settled read requests against the note hash and nullifier trees.
|
|
79
103
|
* @param minRevertibleSideEffectCounterOverride - Optional override for the min revertible side effect counter.
|
|
80
104
|
* Used by TXE to simulate account contract behavior (setting the counter before app execution).
|
|
81
105
|
* @returns The simulated proving result.
|
|
82
106
|
*/
|
|
83
|
-
export declare function generateSimulatedProvingResult(privateExecutionResult: PrivateExecutionResult, debugFunctionNameGetter: (contractAddress: AztecAddress, functionSelector: FunctionSelector) => Promise<string>, minRevertibleSideEffectCounterOverride?: number): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>>;
|
|
84
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
107
|
+
export declare function generateSimulatedProvingResult(privateExecutionResult: PrivateExecutionResult, debugFunctionNameGetter: (contractAddress: AztecAddress, functionSelector: FunctionSelector) => Promise<string>, node: AztecNode, minRevertibleSideEffectCounterOverride?: number): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>>;
|
|
108
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udHJhY3RfZnVuY3Rpb25fc2ltdWxhdG9yLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29udHJhY3RfZnVuY3Rpb25fc2ltdWxhdG9yL2NvbnRyYWN0X2Z1bmN0aW9uX3NpbXVsYXRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUF3QkEsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBR3BELE9BQU8sS0FBSyxFQUFFLFFBQVEsRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBR2pELE9BQU8sRUFDTCxLQUFLLGdCQUFnQixFQU90QixNQUFNLHlCQUF5QixDQUFDO0FBQ2pDLE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBQ3RELE9BQU8sRUFBRSxnQkFBZ0IsRUFBZ0IsTUFBTSxtQkFBbUIsQ0FBQztBQUNuRSxPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSw0QkFBNEIsQ0FBQztBQUM5RCxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sNk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ozs7R0FZRztBQUNILHdCQUFzQiw4QkFBOEIsQ0FDbEQsc0JBQXNCLEVBQUUsc0JBQXNCLEVBQzlDLHVCQUF1QixFQUFFLENBQUMsZUFBZSxFQUFFLFlBQVksRUFBRSxnQkFBZ0IsRUFBRSxnQkFBZ0IsS0FBSyxPQUFPLENBQUMsTUFBTSxDQUFDLEVBQy9HLElBQUksRUFBRSxTQUFTLEVBQ2Ysc0NBQXNDLENBQUMsRUFBRSxNQUFNLEdBQzlDLE9BQU8sQ0FBQyxpQ0FBaUMsQ0FBQyxvQ0FBb0MsQ0FBQyxDQUFDLENBaVFsRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract_function_simulator.d.ts","sourceRoot":"","sources":["../../src/contract_function_simulator/contract_function_simulator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"contract_function_simulator.d.ts","sourceRoot":"","sources":["../../src/contract_function_simulator/contract_function_simulator.ts"],"names":[],"mappings":"AAwBA,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;AAW3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAKL,KAAK,iCAAiC,EACtC,oCAAoC,EAarC,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EACL,WAAW,EAGX,sBAAsB,EAEtB,kBAAkB,EAInB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK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AC,EAAE,EAAE,CAAC,CAoDf;IAGD;;;OAGG;IACH,QAAQ;;MAUP;CACF;AAYD;;;;;;;;;;;;GAYG;AACH,wBAAsB,8BAA8B,CAClD,sBAAsB,EAAE,sBAAsB,EAC9C,uBAAuB,EAAE,CAAC,eAAe,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,KAAK,OAAO,CAAC,MAAM,CAAC,EAC/G,IAAI,EAAE,SAAS,EACf,sCAAsC,CAAC,EAAE,MAAM,GAC9C,OAAO,CAAC,iCAAiC,CAAC,oCAAoC,CAAC,CAAC,CAiQlF"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { AVM_EMITNOTEHASH_BASE_L2_GAS, AVM_EMITNULLIFIER_BASE_L2_GAS, AVM_SENDL2TOL1MSG_BASE_L2_GAS,
|
|
1
|
+
import { AVM_EMITNOTEHASH_BASE_L2_GAS, AVM_EMITNULLIFIER_BASE_L2_GAS, AVM_SENDL2TOL1MSG_BASE_L2_GAS, DA_GAS_PER_FIELD, FIXED_AVM_STARTUP_L2_GAS, L2_GAS_PER_CONTRACT_CLASS_LOG, L2_GAS_PER_L2_TO_L1_MSG, L2_GAS_PER_NOTE_HASH, L2_GAS_PER_NULLIFIER, L2_GAS_PER_PRIVATE_LOG, MAX_CONTRACT_CLASS_LOGS_PER_TX, MAX_ENQUEUED_CALLS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NOTE_HASH_READ_REQUESTS_PER_TX, MAX_NULLIFIERS_PER_TX, MAX_NULLIFIER_READ_REQUESTS_PER_TX, MAX_PRIVATE_LOGS_PER_TX, PRIVATE_TX_L2_GAS_OVERHEAD, PUBLIC_TX_L2_GAS_OVERHEAD, TX_DA_GAS_OVERHEAD } from '@aztec/constants';
|
|
2
2
|
import { arrayNonEmptyLength, padArrayEnd } from '@aztec/foundation/collection';
|
|
3
|
-
import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto/poseidon';
|
|
4
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
4
|
import { createLogger } from '@aztec/foundation/log';
|
|
6
5
|
import { Timer } from '@aztec/foundation/timer';
|
|
@@ -10,12 +9,12 @@ import { ExecutionError, createSimulationError, extractCallStack, resolveAsserti
|
|
|
10
9
|
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
11
10
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
12
11
|
import { Gas } from '@aztec/stdlib/gas';
|
|
13
|
-
import { computeNoteHashNonce, computeProtocolNullifier, computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
|
|
14
|
-
import { PartialPrivateTailPublicInputsForPublic, PartialPrivateTailPublicInputsForRollup, PrivateKernelTailCircuitPublicInputs, PrivateToPublicAccumulatedData, PrivateToRollupAccumulatedData, PublicCallRequest, ScopedLogHash } from '@aztec/stdlib/kernel';
|
|
12
|
+
import { computeNoteHashNonce, computeProtocolNullifier, computeSiloedPrivateLogFirstField, computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
|
|
13
|
+
import { ClaimedLengthArray, PartialPrivateTailPublicInputsForPublic, PartialPrivateTailPublicInputsForRollup, PrivateKernelTailCircuitPublicInputs, PrivateToPublicAccumulatedData, PrivateToRollupAccumulatedData, PublicCallRequest, ReadRequestActionEnum, ScopedLogHash, ScopedNoteHash, ScopedNullifier, ScopedReadRequest, buildTransientDataHints, getNoteHashReadRequestResetActions, getNullifierReadRequestResetActions } from '@aztec/stdlib/kernel';
|
|
15
14
|
import { PrivateLog } from '@aztec/stdlib/logs';
|
|
16
15
|
import { ScopedL2ToL1Message } from '@aztec/stdlib/messaging';
|
|
17
16
|
import { ChonkProof } from '@aztec/stdlib/proofs';
|
|
18
|
-
import { CallContext, HashedValues, PrivateExecutionResult, TxConstantData, collectNested, getFinalMinRevertibleSideEffectCounter } from '@aztec/stdlib/tx';
|
|
17
|
+
import { CallContext, HashedValues, PrivateExecutionResult, TxConstantData, collectNested, collectNoteHashNullifierCounterMap, getFinalMinRevertibleSideEffectCounter } from '@aztec/stdlib/tx';
|
|
19
18
|
import { ExecutionNoteCache } from './execution_note_cache.js';
|
|
20
19
|
import { ExecutionTaggingIndexCache } from './execution_tagging_index_cache.js';
|
|
21
20
|
import { HashedValuesCache } from './hashed_values_cache.js';
|
|
@@ -26,6 +25,7 @@ import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
|
|
|
26
25
|
/**
|
|
27
26
|
* The contract function simulator.
|
|
28
27
|
*/ export class ContractFunctionSimulator {
|
|
28
|
+
log;
|
|
29
29
|
contractStore;
|
|
30
30
|
noteStore;
|
|
31
31
|
keyStore;
|
|
@@ -38,36 +38,25 @@ import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
|
|
|
38
38
|
privateEventStore;
|
|
39
39
|
simulator;
|
|
40
40
|
contractSyncService;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
this.
|
|
44
|
-
this.
|
|
45
|
-
this.
|
|
46
|
-
this.
|
|
47
|
-
this.
|
|
48
|
-
this.
|
|
49
|
-
this.
|
|
50
|
-
this.
|
|
51
|
-
this.
|
|
52
|
-
this.
|
|
53
|
-
this.
|
|
54
|
-
this.contractSyncService = contractSyncService;
|
|
41
|
+
constructor(args){
|
|
42
|
+
this.contractStore = args.contractStore;
|
|
43
|
+
this.noteStore = args.noteStore;
|
|
44
|
+
this.keyStore = args.keyStore;
|
|
45
|
+
this.addressStore = args.addressStore;
|
|
46
|
+
this.aztecNode = args.aztecNode;
|
|
47
|
+
this.senderTaggingStore = args.senderTaggingStore;
|
|
48
|
+
this.recipientTaggingStore = args.recipientTaggingStore;
|
|
49
|
+
this.senderAddressBookStore = args.senderAddressBookStore;
|
|
50
|
+
this.capsuleStore = args.capsuleStore;
|
|
51
|
+
this.privateEventStore = args.privateEventStore;
|
|
52
|
+
this.simulator = args.simulator;
|
|
53
|
+
this.contractSyncService = args.contractSyncService;
|
|
55
54
|
this.log = createLogger('simulator');
|
|
56
55
|
}
|
|
57
56
|
/**
|
|
58
57
|
* Runs a private function.
|
|
59
58
|
* @param request - The transaction request.
|
|
60
|
-
|
|
61
|
-
* @param contractAddress - The address of the contract (should match request.origin)
|
|
62
|
-
* @param msgSender - The address calling the function. This can be replaced to simulate a call from another contract
|
|
63
|
-
* or a specific account.
|
|
64
|
-
* @param anchorBlockHeader - The block header to use as base state for this run.
|
|
65
|
-
* @param senderForTags - The address that is used as a tagging sender when emitting private logs. Returned from
|
|
66
|
-
* the `privateGetSenderForTags` oracle.
|
|
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.
|
|
69
|
-
* @returns The result of the execution.
|
|
70
|
-
*/ async run(request, contractAddress, selector, msgSender = AztecAddress.fromField(Fr.MAX_FIELD_VALUE), anchorBlockHeader, senderForTags, scopes, jobId) {
|
|
59
|
+
*/ async run(request, { contractAddress, selector, msgSender = AztecAddress.fromField(Fr.MAX_FIELD_VALUE), anchorBlockHeader, senderForTags, scopes, jobId }) {
|
|
71
60
|
const simulatorSetupTimer = new Timer();
|
|
72
61
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(contractAddress, selector);
|
|
73
62
|
if (entryPointArtifact.functionType !== FunctionType.PRIVATE) {
|
|
@@ -82,9 +71,37 @@ import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
|
|
|
82
71
|
const protocolNullifier = await computeProtocolNullifier(await request.toTxRequest().hash());
|
|
83
72
|
const noteCache = new ExecutionNoteCache(protocolNullifier);
|
|
84
73
|
const taggingIndexCache = new ExecutionTaggingIndexCache();
|
|
85
|
-
const privateExecutionOracle = new PrivateExecutionOracle(
|
|
86
|
-
|
|
87
|
-
|
|
74
|
+
const privateExecutionOracle = new PrivateExecutionOracle({
|
|
75
|
+
argsHash: request.firstCallArgsHash,
|
|
76
|
+
txContext: request.txContext,
|
|
77
|
+
callContext,
|
|
78
|
+
anchorBlockHeader,
|
|
79
|
+
utilityExecutor: async (call, execScopes)=>{
|
|
80
|
+
await this.runUtility(call, [], anchorBlockHeader, execScopes, jobId);
|
|
81
|
+
},
|
|
82
|
+
authWitnesses: request.authWitnesses,
|
|
83
|
+
capsules: request.capsules,
|
|
84
|
+
executionCache: HashedValuesCache.create(request.argsOfCalls),
|
|
85
|
+
noteCache,
|
|
86
|
+
taggingIndexCache,
|
|
87
|
+
contractStore: this.contractStore,
|
|
88
|
+
noteStore: this.noteStore,
|
|
89
|
+
keyStore: this.keyStore,
|
|
90
|
+
addressStore: this.addressStore,
|
|
91
|
+
aztecNode: this.aztecNode,
|
|
92
|
+
senderTaggingStore: this.senderTaggingStore,
|
|
93
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
94
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
95
|
+
capsuleStore: this.capsuleStore,
|
|
96
|
+
privateEventStore: this.privateEventStore,
|
|
97
|
+
contractSyncService: this.contractSyncService,
|
|
98
|
+
jobId,
|
|
99
|
+
totalPublicCalldataCount: 0,
|
|
100
|
+
sideEffectCounter: startSideEffectCounter,
|
|
101
|
+
scopes,
|
|
102
|
+
senderForTags,
|
|
103
|
+
simulator: this.simulator
|
|
104
|
+
});
|
|
88
105
|
const setupTime = simulatorSetupTimer.ms();
|
|
89
106
|
try {
|
|
90
107
|
// Note: any nested private function calls are made recursively within this
|
|
@@ -131,7 +148,23 @@ import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
|
|
|
131
148
|
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
132
149
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
133
150
|
}
|
|
134
|
-
const oracle = new UtilityExecutionOracle(
|
|
151
|
+
const oracle = new UtilityExecutionOracle({
|
|
152
|
+
contractAddress: call.to,
|
|
153
|
+
authWitnesses: authwits,
|
|
154
|
+
capsules: [],
|
|
155
|
+
anchorBlockHeader,
|
|
156
|
+
contractStore: this.contractStore,
|
|
157
|
+
noteStore: this.noteStore,
|
|
158
|
+
keyStore: this.keyStore,
|
|
159
|
+
addressStore: this.addressStore,
|
|
160
|
+
aztecNode: this.aztecNode,
|
|
161
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
162
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
163
|
+
capsuleStore: this.capsuleStore,
|
|
164
|
+
privateEventStore: this.privateEventStore,
|
|
165
|
+
jobId,
|
|
166
|
+
scopes
|
|
167
|
+
});
|
|
135
168
|
try {
|
|
136
169
|
this.log.verbose(`Executing utility function ${entryPointArtifact.name}`, {
|
|
137
170
|
contract: call.to,
|
|
@@ -147,7 +180,7 @@ import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
|
|
|
147
180
|
cause: err
|
|
148
181
|
});
|
|
149
182
|
});
|
|
150
|
-
this.log.verbose(`Utility
|
|
183
|
+
this.log.verbose(`Utility execution for ${call.to}.${call.selector} completed`);
|
|
151
184
|
return witnessMapToFields(acirExecutionResult.returnWitness);
|
|
152
185
|
} catch (err) {
|
|
153
186
|
throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during private execution'));
|
|
@@ -187,18 +220,24 @@ class OrderedSideEffect {
|
|
|
187
220
|
* (allowing state overrides) and is much faster, while still generating a valid
|
|
188
221
|
* output that can be sent to the node for public simulation
|
|
189
222
|
* @param privateExecutionResult - The result of the private execution.
|
|
190
|
-
* @param
|
|
223
|
+
* @param debugFunctionNameGetter - A provider for contract data in order to get function names and debug info.
|
|
224
|
+
* @param node - AztecNode for verifying settled read requests against the note hash and nullifier trees.
|
|
191
225
|
* @param minRevertibleSideEffectCounterOverride - Optional override for the min revertible side effect counter.
|
|
192
226
|
* Used by TXE to simulate account contract behavior (setting the counter before app execution).
|
|
193
227
|
* @returns The simulated proving result.
|
|
194
|
-
*/ export async function generateSimulatedProvingResult(privateExecutionResult, debugFunctionNameGetter, minRevertibleSideEffectCounterOverride) {
|
|
195
|
-
const siloedNoteHashes = [];
|
|
196
|
-
const nullifiers = [];
|
|
228
|
+
*/ export async function generateSimulatedProvingResult(privateExecutionResult, debugFunctionNameGetter, node, minRevertibleSideEffectCounterOverride) {
|
|
197
229
|
const taggedPrivateLogs = [];
|
|
198
230
|
const l2ToL1Messages = [];
|
|
199
231
|
const contractClassLogsHashes = [];
|
|
200
232
|
const publicCallRequests = [];
|
|
201
233
|
const executionSteps = [];
|
|
234
|
+
// Unsiloed scoped arrays — used for squashing, read request verification,
|
|
235
|
+
// and siloed at the end only for the surviving items
|
|
236
|
+
const scopedNoteHashes = [];
|
|
237
|
+
const scopedNullifiers = [];
|
|
238
|
+
// Read requests for verification
|
|
239
|
+
const noteHashReadRequests = [];
|
|
240
|
+
const nullifierReadRequests = [];
|
|
202
241
|
let publicTeardownCallRequest;
|
|
203
242
|
const executions = [
|
|
204
243
|
privateExecutionResult.entrypoint
|
|
@@ -207,18 +246,14 @@ class OrderedSideEffect {
|
|
|
207
246
|
const execution = executions.shift();
|
|
208
247
|
executions.unshift(...execution.nestedExecutionResults);
|
|
209
248
|
const { contractAddress } = execution.publicInputs.callContext;
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
metadata.log.fields[0] = await
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}));
|
|
219
|
-
siloedNoteHashes.push(...noteHashesFromExecution);
|
|
220
|
-
taggedPrivateLogs.push(...privateLogsFromExecution);
|
|
221
|
-
nullifiers.push(...nullifiersFromExecution);
|
|
249
|
+
scopedNoteHashes.push(...execution.publicInputs.noteHashes.getActiveItems().filter((nh)=>!nh.isEmpty()).map((nh)=>nh.scope(contractAddress)));
|
|
250
|
+
scopedNullifiers.push(...execution.publicInputs.nullifiers.getActiveItems().map((n)=>n.scope(contractAddress)));
|
|
251
|
+
taggedPrivateLogs.push(...await Promise.all(execution.publicInputs.privateLogs.getActiveItems().map(async (metadata)=>{
|
|
252
|
+
metadata.log.fields[0] = await computeSiloedPrivateLogFirstField(contractAddress, metadata.log.fields[0]);
|
|
253
|
+
return new OrderedSideEffect(metadata, metadata.counter);
|
|
254
|
+
})));
|
|
255
|
+
noteHashReadRequests.push(...execution.publicInputs.noteHashReadRequests.getActiveItems());
|
|
256
|
+
nullifierReadRequests.push(...execution.publicInputs.nullifierReadRequests.getActiveItems());
|
|
222
257
|
l2ToL1Messages.push(...execution.publicInputs.l2ToL1Msgs.getActiveItems().map((message)=>new OrderedSideEffect(message.message.scope(contractAddress), message.counter)));
|
|
223
258
|
contractClassLogsHashes.push(...execution.publicInputs.contractClassLogsHashes.getActiveItems().map((contractClassLogHash)=>new OrderedSideEffect(contractClassLogHash.logHash.scope(contractAddress), contractClassLogHash.counter)));
|
|
224
259
|
publicCallRequests.push(...execution.publicInputs.publicCallRequests.getActiveItems().map((callRequest)=>new OrderedSideEffect(callRequest.inner, callRequest.counter)));
|
|
@@ -237,6 +272,14 @@ class OrderedSideEffect {
|
|
|
237
272
|
witness: execution.partialWitness
|
|
238
273
|
});
|
|
239
274
|
}
|
|
275
|
+
const noteHashNullifierCounterMap = collectNoteHashNullifierCounterMap(privateExecutionResult);
|
|
276
|
+
const minRevertibleSideEffectCounter = minRevertibleSideEffectCounterOverride ?? getFinalMinRevertibleSideEffectCounter(privateExecutionResult);
|
|
277
|
+
const scopedNoteHashesCLA = new ClaimedLengthArray(padArrayEnd(scopedNoteHashes, ScopedNoteHash.empty(), MAX_NOTE_HASHES_PER_TX), scopedNoteHashes.length);
|
|
278
|
+
const scopedNullifiersCLA = new ClaimedLengthArray(padArrayEnd(scopedNullifiers, ScopedNullifier.empty(), MAX_NULLIFIERS_PER_TX), scopedNullifiers.length);
|
|
279
|
+
const { filteredNoteHashes, filteredNullifiers, filteredPrivateLogs } = squashTransientSideEffects(taggedPrivateLogs, scopedNoteHashesCLA, scopedNullifiersCLA, noteHashNullifierCounterMap, minRevertibleSideEffectCounter);
|
|
280
|
+
await verifyReadRequests(node, await privateExecutionResult.entrypoint.publicInputs.anchorBlockHeader.hash(), noteHashReadRequests, nullifierReadRequests, scopedNoteHashesCLA, scopedNullifiersCLA);
|
|
281
|
+
const siloedNoteHashes = await Promise.all(filteredNoteHashes.sort((a, b)=>a.counter - b.counter).map(async (nh)=>new OrderedSideEffect(await siloNoteHash(nh.contractAddress, nh.value), nh.counter)));
|
|
282
|
+
const siloedNullifiers = await Promise.all(filteredNullifiers.sort((a, b)=>a.counter - b.counter).map(async (n)=>new OrderedSideEffect(await siloNullifier(n.contractAddress, n.value), n.counter)));
|
|
240
283
|
const constantData = new TxConstantData(privateExecutionResult.entrypoint.publicInputs.anchorBlockHeader, privateExecutionResult.entrypoint.publicInputs.txContext, getVKTreeRoot(), protocolContractsHash);
|
|
241
284
|
const hasPublicCalls = privateExecutionResult.publicFunctionCalldata.length !== 0;
|
|
242
285
|
let inputsForRollup;
|
|
@@ -245,8 +288,7 @@ class OrderedSideEffect {
|
|
|
245
288
|
const sortByCounter = (a, b)=>a.counter - b.counter;
|
|
246
289
|
const getEffect = (orderedSideEffect)=>orderedSideEffect.sideEffect;
|
|
247
290
|
const isPrivateOnlyTx = privateExecutionResult.publicFunctionCalldata.length === 0;
|
|
248
|
-
const
|
|
249
|
-
const [nonRevertibleNullifiers, revertibleNullifiers] = splitOrderedSideEffects(nullifiers.sort(sortByCounter), minRevertibleSideEffectCounter);
|
|
291
|
+
const [nonRevertibleNullifiers, revertibleNullifiers] = splitOrderedSideEffects(siloedNullifiers, minRevertibleSideEffectCounter);
|
|
250
292
|
const nonceGenerator = privateExecutionResult.firstNullifier;
|
|
251
293
|
if (nonRevertibleNullifiers.length === 0) {
|
|
252
294
|
nonRevertibleNullifiers.push(nonceGenerator);
|
|
@@ -256,43 +298,102 @@ class OrderedSideEffect {
|
|
|
256
298
|
if (isPrivateOnlyTx) {
|
|
257
299
|
// We must make the note hashes unique by using the
|
|
258
300
|
// nonce generator and their index in the tx.
|
|
259
|
-
const uniqueNoteHashes = await Promise.all(siloedNoteHashes.
|
|
301
|
+
const uniqueNoteHashes = await Promise.all(siloedNoteHashes.map(async (orderedSideEffect, i)=>{
|
|
260
302
|
const siloedNoteHash = orderedSideEffect.sideEffect;
|
|
261
303
|
const nonce = await computeNoteHashNonce(nonceGenerator, i);
|
|
262
304
|
const uniqueNoteHash = await computeUniqueNoteHash(nonce, siloedNoteHash);
|
|
263
305
|
return uniqueNoteHash;
|
|
264
306
|
}));
|
|
265
|
-
const accumulatedDataForRollup = new PrivateToRollupAccumulatedData(padArrayEnd(uniqueNoteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX), padArrayEnd(nonRevertibleNullifiers.concat(revertibleNullifiers), Fr.ZERO, MAX_NULLIFIERS_PER_TX), padArrayEnd(l2ToL1Messages.sort(sortByCounter).map(getEffect), ScopedL2ToL1Message.empty(), MAX_L2_TO_L1_MSGS_PER_TX), padArrayEnd(
|
|
266
|
-
gasUsed = meterGasUsed(accumulatedDataForRollup);
|
|
307
|
+
const accumulatedDataForRollup = new PrivateToRollupAccumulatedData(padArrayEnd(uniqueNoteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX), padArrayEnd(nonRevertibleNullifiers.concat(revertibleNullifiers), Fr.ZERO, MAX_NULLIFIERS_PER_TX), padArrayEnd(l2ToL1Messages.sort(sortByCounter).map(getEffect), ScopedL2ToL1Message.empty(), MAX_L2_TO_L1_MSGS_PER_TX), padArrayEnd(filteredPrivateLogs.sort(sortByCounter).map(getEffect), PrivateLog.empty(), MAX_PRIVATE_LOGS_PER_TX), padArrayEnd(contractClassLogsHashes.sort(sortByCounter).map(getEffect), ScopedLogHash.empty(), MAX_CONTRACT_CLASS_LOGS_PER_TX));
|
|
308
|
+
gasUsed = meterGasUsed(accumulatedDataForRollup, isPrivateOnlyTx);
|
|
267
309
|
inputsForRollup = new PartialPrivateTailPublicInputsForRollup(accumulatedDataForRollup);
|
|
268
310
|
} else {
|
|
269
|
-
const [nonRevertibleNoteHashes, revertibleNoteHashes] = splitOrderedSideEffects(siloedNoteHashes
|
|
311
|
+
const [nonRevertibleNoteHashes, revertibleNoteHashes] = splitOrderedSideEffects(siloedNoteHashes, minRevertibleSideEffectCounter);
|
|
270
312
|
const nonRevertibleUniqueNoteHashes = await Promise.all(nonRevertibleNoteHashes.map(async (noteHash, i)=>{
|
|
271
313
|
const nonce = await computeNoteHashNonce(nonceGenerator, i);
|
|
272
314
|
return await computeUniqueNoteHash(nonce, noteHash);
|
|
273
315
|
}));
|
|
274
316
|
const [nonRevertibleL2ToL1Messages, revertibleL2ToL1Messages] = splitOrderedSideEffects(l2ToL1Messages.sort(sortByCounter), minRevertibleSideEffectCounter);
|
|
275
|
-
const [nonRevertibleTaggedPrivateLogs, revertibleTaggedPrivateLogs] = splitOrderedSideEffects(
|
|
317
|
+
const [nonRevertibleTaggedPrivateLogs, revertibleTaggedPrivateLogs] = splitOrderedSideEffects(filteredPrivateLogs, minRevertibleSideEffectCounter);
|
|
276
318
|
const [nonRevertibleContractClassLogHashes, revertibleContractClassLogHashes] = splitOrderedSideEffects(contractClassLogsHashes.sort(sortByCounter), minRevertibleSideEffectCounter);
|
|
277
319
|
const [nonRevertiblePublicCallRequests, revertiblePublicCallRequests] = splitOrderedSideEffects(publicCallRequests.sort(sortByCounter), minRevertibleSideEffectCounter);
|
|
278
320
|
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));
|
|
279
321
|
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));
|
|
280
|
-
gasUsed = meterGasUsed(revertibleData).add(meterGasUsed(nonRevertibleData));
|
|
322
|
+
gasUsed = meterGasUsed(revertibleData, isPrivateOnlyTx).add(meterGasUsed(nonRevertibleData, isPrivateOnlyTx));
|
|
281
323
|
if (publicTeardownCallRequest) {
|
|
282
|
-
gasUsed.add(privateExecutionResult.entrypoint.publicInputs.txContext.gasSettings.teardownGasLimits);
|
|
324
|
+
gasUsed = gasUsed.add(privateExecutionResult.entrypoint.publicInputs.txContext.gasSettings.teardownGasLimits);
|
|
283
325
|
}
|
|
284
326
|
inputsForPublic = new PartialPrivateTailPublicInputsForPublic(nonRevertibleData, revertibleData, publicTeardownCallRequest ?? PublicCallRequest.empty());
|
|
285
327
|
}
|
|
286
328
|
const publicInputs = new PrivateKernelTailCircuitPublicInputs(constantData, /*gasUsed=*/ gasUsed.add(Gas.from({
|
|
287
|
-
l2Gas:
|
|
288
|
-
daGas:
|
|
289
|
-
})), /*feePayer=*/ AztecAddress.zero(), /*
|
|
329
|
+
l2Gas: isPrivateOnlyTx ? PRIVATE_TX_L2_GAS_OVERHEAD : PUBLIC_TX_L2_GAS_OVERHEAD,
|
|
330
|
+
daGas: TX_DA_GAS_OVERHEAD
|
|
331
|
+
})), /*feePayer=*/ AztecAddress.zero(), /*expirationTimestamp=*/ 0n, hasPublicCalls ? inputsForPublic : undefined, !hasPublicCalls ? inputsForRollup : undefined);
|
|
290
332
|
return {
|
|
291
333
|
publicInputs,
|
|
292
334
|
chonkProof: ChonkProof.empty(),
|
|
293
335
|
executionSteps
|
|
294
336
|
};
|
|
295
337
|
}
|
|
338
|
+
/**
|
|
339
|
+
* Squashes transient note hashes and nullifiers, mimicking the behavior
|
|
340
|
+
* of the reset kernels. Returns the filtered (surviving) scoped items and private logs.
|
|
341
|
+
*/ function squashTransientSideEffects(taggedPrivateLogs, scopedNoteHashesCLA, scopedNullifiersCLA, noteHashNullifierCounterMap, minRevertibleSideEffectCounter) {
|
|
342
|
+
const { numTransientData, hints: transientDataHints } = buildTransientDataHints(scopedNoteHashesCLA, scopedNullifiersCLA, /*futureNoteHashReads=*/ [], /*futureNullifierReads=*/ [], /*futureLogs=*/ [], noteHashNullifierCounterMap, minRevertibleSideEffectCounter);
|
|
343
|
+
const squashedNoteHashCounters = new Set();
|
|
344
|
+
const squashedNullifierCounters = new Set();
|
|
345
|
+
for(let i = 0; i < numTransientData; i++){
|
|
346
|
+
const hint = transientDataHints[i];
|
|
347
|
+
squashedNoteHashCounters.add(scopedNoteHashesCLA.array[hint.noteHashIndex].counter);
|
|
348
|
+
squashedNullifierCounters.add(scopedNullifiersCLA.array[hint.nullifierIndex].counter);
|
|
349
|
+
}
|
|
350
|
+
return {
|
|
351
|
+
filteredNoteHashes: scopedNoteHashesCLA.getActiveItems().filter((nh)=>!squashedNoteHashCounters.has(nh.counter)),
|
|
352
|
+
filteredNullifiers: scopedNullifiersCLA.getActiveItems().filter((n)=>!squashedNullifierCounters.has(n.counter)),
|
|
353
|
+
filteredPrivateLogs: taggedPrivateLogs.filter((item)=>!squashedNoteHashCounters.has(item.sideEffect.noteHashCounter)).map((item)=>new OrderedSideEffect(item.sideEffect.log, item.counter))
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Verifies settled read requests by checking membership in the note hash and nullifier trees
|
|
358
|
+
* at the tx's anchor block, mimicking the behavior of the kernels
|
|
359
|
+
*/ async function verifyReadRequests(node, anchorBlockHash, noteHashReadRequests, nullifierReadRequests, scopedNoteHashesCLA, scopedNullifiersCLA) {
|
|
360
|
+
const noteHashReadRequestsCLA = new ClaimedLengthArray(padArrayEnd(noteHashReadRequests, ScopedReadRequest.empty(), MAX_NOTE_HASH_READ_REQUESTS_PER_TX), noteHashReadRequests.length);
|
|
361
|
+
const nullifierReadRequestsCLA = new ClaimedLengthArray(padArrayEnd(nullifierReadRequests, ScopedReadRequest.empty(), MAX_NULLIFIER_READ_REQUESTS_PER_TX), nullifierReadRequests.length);
|
|
362
|
+
const noteHashResetActions = getNoteHashReadRequestResetActions(noteHashReadRequestsCLA, scopedNoteHashesCLA);
|
|
363
|
+
const nullifierResetActions = getNullifierReadRequestResetActions(nullifierReadRequestsCLA, scopedNullifiersCLA);
|
|
364
|
+
const settledNoteHashReads = [];
|
|
365
|
+
for(let i = 0; i < noteHashResetActions.actions.length; i++){
|
|
366
|
+
if (noteHashResetActions.actions[i] === ReadRequestActionEnum.READ_AS_SETTLED) {
|
|
367
|
+
settledNoteHashReads.push({
|
|
368
|
+
index: i,
|
|
369
|
+
value: noteHashReadRequests[i].value
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
const settledNullifierReads = [];
|
|
374
|
+
for(let i = 0; i < nullifierResetActions.actions.length; i++){
|
|
375
|
+
if (nullifierResetActions.actions[i] === ReadRequestActionEnum.READ_AS_SETTLED) {
|
|
376
|
+
settledNullifierReads.push({
|
|
377
|
+
index: i,
|
|
378
|
+
value: nullifierReadRequests[i].value
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
const [noteHashWitnesses, nullifierWitnesses] = await Promise.all([
|
|
383
|
+
Promise.all(settledNoteHashReads.map(({ value })=>node.getNoteHashMembershipWitness(anchorBlockHash, value))),
|
|
384
|
+
Promise.all(settledNullifierReads.map(({ value })=>node.getNullifierMembershipWitness(anchorBlockHash, value)))
|
|
385
|
+
]);
|
|
386
|
+
for(let i = 0; i < settledNoteHashReads.length; i++){
|
|
387
|
+
if (!noteHashWitnesses[i]) {
|
|
388
|
+
throw new Error(`Note hash read request at index ${settledNoteHashReads[i].index} is reading an unknown note hash: ${settledNoteHashReads[i].value}`);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
for(let i = 0; i < settledNullifierReads.length; i++){
|
|
392
|
+
if (!nullifierWitnesses[i]) {
|
|
393
|
+
throw new Error(`Nullifier read request at index ${settledNullifierReads[i].index} is reading an unknown nullifier: ${settledNullifierReads[i].value}`);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
296
397
|
function splitOrderedSideEffects(effects, minRevertibleSideEffectCounter) {
|
|
297
398
|
const revertibleSideEffects = [];
|
|
298
399
|
const nonRevertibleSideEffects = [];
|
|
@@ -308,18 +409,21 @@ function splitOrderedSideEffects(effects, minRevertibleSideEffectCounter) {
|
|
|
308
409
|
revertibleSideEffects
|
|
309
410
|
];
|
|
310
411
|
}
|
|
311
|
-
function meterGasUsed(data) {
|
|
412
|
+
function meterGasUsed(data, isPrivateOnlyTx) {
|
|
312
413
|
let meteredDAFields = 0;
|
|
313
414
|
let meteredL2Gas = 0;
|
|
314
415
|
const numNoteHashes = arrayNonEmptyLength(data.noteHashes, (hash)=>hash.isEmpty());
|
|
315
416
|
meteredDAFields += numNoteHashes;
|
|
316
|
-
|
|
417
|
+
const noteHashBaseGas = isPrivateOnlyTx ? L2_GAS_PER_NOTE_HASH : AVM_EMITNOTEHASH_BASE_L2_GAS;
|
|
418
|
+
meteredL2Gas += numNoteHashes * noteHashBaseGas;
|
|
317
419
|
const numNullifiers = arrayNonEmptyLength(data.nullifiers, (nullifier)=>nullifier.isEmpty());
|
|
318
420
|
meteredDAFields += numNullifiers;
|
|
319
|
-
|
|
421
|
+
const nullifierBaseGas = isPrivateOnlyTx ? L2_GAS_PER_NULLIFIER : AVM_EMITNULLIFIER_BASE_L2_GAS;
|
|
422
|
+
meteredL2Gas += numNullifiers * nullifierBaseGas;
|
|
320
423
|
const numL2toL1Messages = arrayNonEmptyLength(data.l2ToL1Msgs, (msg)=>msg.isEmpty());
|
|
321
424
|
meteredDAFields += numL2toL1Messages;
|
|
322
|
-
|
|
425
|
+
const l2ToL1MessageBaseGas = isPrivateOnlyTx ? L2_GAS_PER_L2_TO_L1_MSG : AVM_SENDL2TOL1MSG_BASE_L2_GAS;
|
|
426
|
+
meteredL2Gas += numL2toL1Messages * l2ToL1MessageBaseGas;
|
|
323
427
|
const numPrivatelogs = arrayNonEmptyLength(data.privateLogs, (log)=>log.isEmpty());
|
|
324
428
|
// Every private log emits its length as an additional field
|
|
325
429
|
meteredDAFields += data.privateLogs.reduce((acc, log)=>!log.isEmpty() ? acc + log.emittedLength + 1 : acc, 0);
|
|
@@ -328,7 +432,7 @@ function meterGasUsed(data) {
|
|
|
328
432
|
// Every contract class log emits its length and contract address as additional fields
|
|
329
433
|
meteredDAFields += data.contractClassLogsHashes.reduce((acc, log)=>!log.isEmpty() ? acc + log.logHash.length + 2 : acc, 0);
|
|
330
434
|
meteredL2Gas += numContractClassLogs * L2_GAS_PER_CONTRACT_CLASS_LOG;
|
|
331
|
-
const meteredDAGas = meteredDAFields *
|
|
435
|
+
const meteredDAGas = meteredDAFields * DA_GAS_PER_FIELD;
|
|
332
436
|
if (data.publicCallRequests) {
|
|
333
437
|
const dataForPublic = data;
|
|
334
438
|
const numPublicCallRequests = arrayNonEmptyLength(dataForPublic.publicCallRequests, (req)=>req.isEmpty());
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ExtendedDirectionalAppTaggingSecret, type PreTag } from '@aztec/stdlib/logs';
|
|
2
2
|
/**
|
|
3
|
-
* A map that stores the tagging index for a given directional app tagging secret.
|
|
3
|
+
* A map that stores the tagging index for a given extended directional app tagging secret.
|
|
4
4
|
* Note: The directional app tagging secret is unique for a (sender, recipient, contract) tuple while the direction
|
|
5
5
|
* of sender -> recipient matters.
|
|
6
6
|
*/
|
|
7
7
|
export declare class ExecutionTaggingIndexCache {
|
|
8
8
|
private taggingIndexMap;
|
|
9
|
-
getLastUsedIndex(secret:
|
|
10
|
-
setLastUsedIndex(secret:
|
|
9
|
+
getLastUsedIndex(secret: ExtendedDirectionalAppTaggingSecret): number | undefined;
|
|
10
|
+
setLastUsedIndex(secret: ExtendedDirectionalAppTaggingSecret, index: number): void;
|
|
11
11
|
/**
|
|
12
12
|
* Returns the pre-tags that were used in this execution (and that need to be stored in the db).
|
|
13
13
|
*/
|
|
14
14
|
getUsedPreTags(): PreTag[];
|
|
15
15
|
}
|
|
16
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
16
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXhlY3V0aW9uX3RhZ2dpbmdfaW5kZXhfY2FjaGUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb250cmFjdF9mdW5jdGlvbl9zaW11bGF0b3IvZXhlY3V0aW9uX3RhZ2dpbmdfaW5kZXhfY2FjaGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLG1DQUFtQyxFQUFFLEtBQUssTUFBTSxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFFdEY7Ozs7R0FJRztBQUNILHFCQUFhLDBCQUEwQjtJQUNyQyxPQUFPLENBQUMsZUFBZSxDQUFrQztJQUVsRCxnQkFBZ0IsQ0FBQyxNQUFNLEVBQUUsbUNBQW1DLEdBQUcsTUFBTSxHQUFHLFNBQVMsQ0FFdkY7SUFFTSxnQkFBZ0IsQ0FBQyxNQUFNLEVBQUUsbUNBQW1DLEVBQUUsS0FBSyxFQUFFLE1BQU0sUUFNakY7SUFFRDs7T0FFRztJQUNJLGNBQWMsSUFBSSxNQUFNLEVBQUUsQ0FLaEM7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution_tagging_index_cache.d.ts","sourceRoot":"","sources":["../../src/contract_function_simulator/execution_tagging_index_cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"execution_tagging_index_cache.d.ts","sourceRoot":"","sources":["../../src/contract_function_simulator/execution_tagging_index_cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mCAAmC,EAAE,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEtF;;;;GAIG;AACH,qBAAa,0BAA0B;IACrC,OAAO,CAAC,eAAe,CAAkC;IAElD,gBAAgB,CAAC,MAAM,EAAE,mCAAmC,GAAG,MAAM,GAAG,SAAS,CAEvF;IAEM,gBAAgB,CAAC,MAAM,EAAE,mCAAmC,EAAE,KAAK,EAAE,MAAM,QAMjF;IAED;;OAEG;IACI,cAAc,IAAI,MAAM,EAAE,CAKhC;CACF"}
|