@aztec/pxe 0.0.1-commit.7d4e6cd → 0.0.1-commit.858058eac
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 +11 -5
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +72 -21
- 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/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 +53 -33
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +95 -51
- 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 +1 -1
- 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 +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 +17 -13
- 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 +12 -10
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +67 -44
- 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 +0 -35
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +43 -35
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +82 -25
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +65 -33
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +126 -109
- package/dest/contract_sync/contract_sync_service.d.ts +41 -0
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
- package/dest/contract_sync/contract_sync_service.js +82 -0
- package/dest/contract_sync/helpers.d.ts +28 -0
- package/dest/contract_sync/helpers.d.ts.map +1 -0
- package/dest/contract_sync/helpers.js +55 -0
- package/dest/debug/pxe_debug_utils.d.ts +22 -9
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +28 -17
- 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 +21 -7
- package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +22 -8
- 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 +28 -9
- package/dest/events/event_service.d.ts +6 -6
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +19 -22
- 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 +3 -2
- package/dest/job_coordinator/job_coordinator.d.ts.map +1 -1
- package/dest/job_coordinator/job_coordinator.js +3 -2
- package/dest/logs/log_service.d.ts +7 -5
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +23 -20
- package/dest/notes/note_service.d.ts +7 -7
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +31 -36
- 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} +12 -6
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +3 -2
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +3 -3
- package/dest/private_kernel/private_kernel_oracle.d.ts +23 -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 +70 -57
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +96 -111
- package/dest/storage/address_store/address_store.d.ts +1 -1
- package/dest/storage/address_store/address_store.d.ts.map +1 -1
- package/dest/storage/address_store/address_store.js +12 -11
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -1
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -1
- package/dest/storage/anchor_block_store/anchor_block_store.js +8 -1
- 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 +130 -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 +27 -30
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/note_store/note_store.d.ts +51 -52
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +285 -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 +43 -8
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
- package/dest/storage/private_event_store/private_event_store.js +226 -111
- 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 +88 -19
- package/dest/storage/tagging_store/sender_address_book_store.d.ts +1 -1
- package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_address_book_store.js +20 -14
- 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 +252 -100
- 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 +2 -1
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +1 -0
- 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 +6 -6
- 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 +7 -7
- 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 +27 -18
- package/src/bin/check_oracle_version.ts +1 -0
- package/src/block_synchronizer/block_synchronizer.ts +91 -33
- package/src/config/index.ts +14 -0
- package/src/contract_function_simulator/benchmarked_node.ts +103 -0
- package/src/contract_function_simulator/contract_function_simulator.ts +143 -99
- 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 +1 -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 +22 -12
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +10 -10
- package/src/contract_function_simulator/oracle/oracle.ts +79 -47
- package/src/contract_function_simulator/oracle/private_execution.ts +1 -67
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +116 -104
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +190 -116
- package/src/contract_sync/contract_sync_service.ts +129 -0
- package/src/contract_sync/helpers.ts +93 -0
- package/src/debug/pxe_debug_utils.ts +60 -17
- package/src/entrypoints/client/bundle/utils.ts +16 -15
- package/src/entrypoints/client/lazy/utils.ts +17 -15
- package/src/entrypoints/pxe_creation_options.ts +2 -1
- package/src/entrypoints/server/index.ts +2 -0
- package/src/entrypoints/server/utils.ts +22 -26
- package/src/events/event_service.ts +17 -25
- package/src/events/private_event_filter_validator.ts +3 -5
- package/src/job_coordinator/job_coordinator.ts +4 -3
- package/src/logs/log_service.ts +34 -16
- package/src/notes/note_service.ts +38 -43
- 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} +32 -20
- package/src/private_kernel/private_kernel_execution_prover.ts +7 -4
- package/src/private_kernel/private_kernel_oracle.ts +116 -37
- package/src/pxe.ts +191 -173
- package/src/storage/address_store/address_store.ts +15 -15
- package/src/storage/anchor_block_store/anchor_block_store.ts +8 -0
- package/src/storage/capsule_store/capsule_store.ts +159 -23
- package/src/storage/contract_store/contract_store.ts +26 -35
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/note_store.ts +321 -318
- package/src/storage/note_store/stored_note.ts +48 -0
- package/src/storage/private_event_store/private_event_store.ts +292 -124
- package/src/storage/private_event_store/stored_private_event.ts +73 -0
- package/src/storage/tagging_store/recipient_tagging_store.ts +106 -20
- package/src/storage/tagging_store/sender_address_book_store.ts +20 -14
- package/src/storage/tagging_store/sender_tagging_store.ts +293 -108
- package/src/tagging/get_all_logs_by_tags.ts +68 -0
- package/src/tagging/index.ts +1 -0
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +16 -5
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +7 -1
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +9 -6
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +5 -17
- 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 -85
- 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 -127
- package/src/public_storage/public_storage_service.ts +0 -33
- package/src/tree_membership/tree_membership_service.ts +0 -112
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AVM_EMITNOTEHASH_BASE_L2_GAS, AVM_EMITNULLIFIER_BASE_L2_GAS, AVM_SENDL2TOL1MSG_BASE_L2_GAS, DA_BYTES_PER_FIELD, DA_GAS_PER_BYTE, FIXED_AVM_STARTUP_L2_GAS, FIXED_DA_GAS, FIXED_L2_GAS, L2_GAS_PER_CONTRACT_CLASS_LOG, 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_NULLIFIERS_PER_TX, MAX_PRIVATE_LOGS_PER_TX } from '@aztec/constants';
|
|
1
|
+
import { AVM_EMITNOTEHASH_BASE_L2_GAS, AVM_EMITNULLIFIER_BASE_L2_GAS, AVM_SENDL2TOL1MSG_BASE_L2_GAS, DA_BYTES_PER_FIELD, DA_GAS_PER_BYTE, FIXED_AVM_STARTUP_L2_GAS, FIXED_DA_GAS, FIXED_L2_GAS, GeneratorIndex, L2_GAS_PER_CONTRACT_CLASS_LOG, 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_NULLIFIERS_PER_TX, MAX_PRIVATE_LOGS_PER_TX } from '@aztec/constants';
|
|
2
2
|
import { arrayNonEmptyLength, padArrayEnd } from '@aztec/foundation/collection';
|
|
3
|
-
import {
|
|
3
|
+
import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto/poseidon';
|
|
4
4
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
5
|
import { createLogger } from '@aztec/foundation/log';
|
|
6
6
|
import { Timer } from '@aztec/foundation/timer';
|
|
@@ -20,57 +20,45 @@ 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
|
/**
|
|
27
27
|
* The contract function simulator.
|
|
28
28
|
*/ export class ContractFunctionSimulator {
|
|
29
|
+
log;
|
|
29
30
|
contractStore;
|
|
30
31
|
noteStore;
|
|
31
32
|
keyStore;
|
|
32
33
|
addressStore;
|
|
33
34
|
aztecNode;
|
|
34
|
-
anchorBlockStore;
|
|
35
35
|
senderTaggingStore;
|
|
36
36
|
recipientTaggingStore;
|
|
37
37
|
senderAddressBookStore;
|
|
38
38
|
capsuleStore;
|
|
39
39
|
privateEventStore;
|
|
40
40
|
simulator;
|
|
41
|
-
|
|
42
|
-
constructor(
|
|
43
|
-
this.contractStore = contractStore;
|
|
44
|
-
this.noteStore = noteStore;
|
|
45
|
-
this.keyStore = keyStore;
|
|
46
|
-
this.addressStore = addressStore;
|
|
47
|
-
this.aztecNode = aztecNode;
|
|
48
|
-
this.
|
|
49
|
-
this.
|
|
50
|
-
this.
|
|
51
|
-
this.
|
|
52
|
-
this.
|
|
53
|
-
this.
|
|
54
|
-
this.
|
|
41
|
+
contractSyncService;
|
|
42
|
+
constructor(args){
|
|
43
|
+
this.contractStore = args.contractStore;
|
|
44
|
+
this.noteStore = args.noteStore;
|
|
45
|
+
this.keyStore = args.keyStore;
|
|
46
|
+
this.addressStore = args.addressStore;
|
|
47
|
+
this.aztecNode = args.aztecNode;
|
|
48
|
+
this.senderTaggingStore = args.senderTaggingStore;
|
|
49
|
+
this.recipientTaggingStore = args.recipientTaggingStore;
|
|
50
|
+
this.senderAddressBookStore = args.senderAddressBookStore;
|
|
51
|
+
this.capsuleStore = args.capsuleStore;
|
|
52
|
+
this.privateEventStore = args.privateEventStore;
|
|
53
|
+
this.simulator = args.simulator;
|
|
54
|
+
this.contractSyncService = args.contractSyncService;
|
|
55
55
|
this.log = createLogger('simulator');
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
58
58
|
* Runs a private function.
|
|
59
59
|
* @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) {
|
|
60
|
+
*/ async run(request, { contractAddress, selector, msgSender = AztecAddress.fromField(Fr.MAX_FIELD_VALUE), anchorBlockHeader, senderForTags, scopes, jobId }) {
|
|
71
61
|
const simulatorSetupTimer = new Timer();
|
|
72
|
-
await this.contractStore.syncPrivateState(contractAddress, selector, (privateSyncCall)=>this.runUtility(privateSyncCall, [], anchorBlockHeader, scopes, jobId));
|
|
73
|
-
await verifyCurrentClassId(contractAddress, this.aztecNode, this.contractStore, anchorBlockHeader);
|
|
74
62
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(contractAddress, selector);
|
|
75
63
|
if (entryPointArtifact.functionType !== FunctionType.PRIVATE) {
|
|
76
64
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as private`);
|
|
@@ -84,9 +72,37 @@ import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
|
|
|
84
72
|
const protocolNullifier = await computeProtocolNullifier(await request.toTxRequest().hash());
|
|
85
73
|
const noteCache = new ExecutionNoteCache(protocolNullifier);
|
|
86
74
|
const taggingIndexCache = new ExecutionTaggingIndexCache();
|
|
87
|
-
const privateExecutionOracle = new PrivateExecutionOracle(
|
|
88
|
-
|
|
89
|
-
|
|
75
|
+
const privateExecutionOracle = new PrivateExecutionOracle({
|
|
76
|
+
argsHash: request.firstCallArgsHash,
|
|
77
|
+
txContext: request.txContext,
|
|
78
|
+
callContext,
|
|
79
|
+
anchorBlockHeader,
|
|
80
|
+
utilityExecutor: async (call)=>{
|
|
81
|
+
await this.runUtility(call, [], anchorBlockHeader, scopes, jobId);
|
|
82
|
+
},
|
|
83
|
+
authWitnesses: request.authWitnesses,
|
|
84
|
+
capsules: request.capsules,
|
|
85
|
+
executionCache: HashedValuesCache.create(request.argsOfCalls),
|
|
86
|
+
noteCache,
|
|
87
|
+
taggingIndexCache,
|
|
88
|
+
contractStore: this.contractStore,
|
|
89
|
+
noteStore: this.noteStore,
|
|
90
|
+
keyStore: this.keyStore,
|
|
91
|
+
addressStore: this.addressStore,
|
|
92
|
+
aztecNode: this.aztecNode,
|
|
93
|
+
senderTaggingStore: this.senderTaggingStore,
|
|
94
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
95
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
96
|
+
capsuleStore: this.capsuleStore,
|
|
97
|
+
privateEventStore: this.privateEventStore,
|
|
98
|
+
contractSyncService: this.contractSyncService,
|
|
99
|
+
jobId,
|
|
100
|
+
totalPublicCalldataCount: 0,
|
|
101
|
+
sideEffectCounter: startSideEffectCounter,
|
|
102
|
+
scopes,
|
|
103
|
+
senderForTags,
|
|
104
|
+
simulator: this.simulator
|
|
105
|
+
});
|
|
90
106
|
const setupTime = simulatorSetupTimer.ms();
|
|
91
107
|
try {
|
|
92
108
|
// Note: any nested private function calls are made recursively within this
|
|
@@ -95,8 +111,8 @@ import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
|
|
|
95
111
|
// within executionResult.nestedExecutionResults).
|
|
96
112
|
const executionResult = await executePrivateFunction(this.simulator, privateExecutionOracle, entryPointArtifact, contractAddress, request.functionSelector);
|
|
97
113
|
const simulatorTeardownTimer = new Timer();
|
|
98
|
-
|
|
99
|
-
const firstNullifierHint =
|
|
114
|
+
noteCache.finish();
|
|
115
|
+
const firstNullifierHint = noteCache.getNonceGenerator();
|
|
100
116
|
const publicCallRequests = collectNested([
|
|
101
117
|
executionResult
|
|
102
118
|
], (r)=>r.publicInputs.publicCallRequests.getActiveItems().map((r)=>r.inner).concat(r.publicInputs.publicTeardownCallRequest.isEmpty() ? [] : [
|
|
@@ -129,12 +145,27 @@ import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
|
|
|
129
145
|
* accounts if not specified.
|
|
130
146
|
* @returns A return value of the utility function in a form as returned by the simulator (Noir fields)
|
|
131
147
|
*/ async runUtility(call, authwits, anchorBlockHeader, scopes, jobId) {
|
|
132
|
-
await verifyCurrentClassId(call.to, this.aztecNode, this.contractStore, anchorBlockHeader);
|
|
133
148
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
134
149
|
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
135
150
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
136
151
|
}
|
|
137
|
-
const oracle = new UtilityExecutionOracle(
|
|
152
|
+
const oracle = new UtilityExecutionOracle({
|
|
153
|
+
contractAddress: call.to,
|
|
154
|
+
authWitnesses: authwits,
|
|
155
|
+
capsules: [],
|
|
156
|
+
anchorBlockHeader,
|
|
157
|
+
contractStore: this.contractStore,
|
|
158
|
+
noteStore: this.noteStore,
|
|
159
|
+
keyStore: this.keyStore,
|
|
160
|
+
addressStore: this.addressStore,
|
|
161
|
+
aztecNode: this.aztecNode,
|
|
162
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
163
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
164
|
+
capsuleStore: this.capsuleStore,
|
|
165
|
+
privateEventStore: this.privateEventStore,
|
|
166
|
+
jobId,
|
|
167
|
+
scopes
|
|
168
|
+
});
|
|
138
169
|
try {
|
|
139
170
|
this.log.verbose(`Executing utility function ${entryPointArtifact.name}`, {
|
|
140
171
|
contract: call.to,
|
|
@@ -161,7 +192,15 @@ import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
|
|
|
161
192
|
* Returns the execution statistics collected during the simulator run.
|
|
162
193
|
* @returns The execution statistics.
|
|
163
194
|
*/ getStats() {
|
|
164
|
-
const nodeRPCCalls = typeof this.aztecNode.getStats === 'function' ? this.aztecNode.getStats() : {
|
|
195
|
+
const nodeRPCCalls = typeof this.aztecNode.getStats === 'function' ? this.aztecNode.getStats() : {
|
|
196
|
+
perMethod: {},
|
|
197
|
+
roundTrips: {
|
|
198
|
+
roundTrips: 0,
|
|
199
|
+
totalBlockingTime: 0,
|
|
200
|
+
roundTripDurations: [],
|
|
201
|
+
roundTripMethods: []
|
|
202
|
+
}
|
|
203
|
+
};
|
|
165
204
|
return {
|
|
166
205
|
nodeRPCCalls
|
|
167
206
|
};
|
|
@@ -182,11 +221,11 @@ class OrderedSideEffect {
|
|
|
182
221
|
* (allowing state overrides) and is much faster, while still generating a valid
|
|
183
222
|
* output that can be sent to the node for public simulation
|
|
184
223
|
* @param privateExecutionResult - The result of the private execution.
|
|
185
|
-
* @param nonceGenerator - A nonce generator for note hashes. According to the protocol rules,
|
|
186
|
-
* it can either be the first nullifier in the tx or the hash of the initial tx request if there are none.
|
|
187
224
|
* @param contractStore - A provider for contract data in order to get function names and debug info.
|
|
225
|
+
* @param minRevertibleSideEffectCounterOverride - Optional override for the min revertible side effect counter.
|
|
226
|
+
* Used by TXE to simulate account contract behavior (setting the counter before app execution).
|
|
188
227
|
* @returns The simulated proving result.
|
|
189
|
-
*/ export async function generateSimulatedProvingResult(privateExecutionResult,
|
|
228
|
+
*/ export async function generateSimulatedProvingResult(privateExecutionResult, debugFunctionNameGetter, minRevertibleSideEffectCounterOverride) {
|
|
190
229
|
const siloedNoteHashes = [];
|
|
191
230
|
const nullifiers = [];
|
|
192
231
|
const taggedPrivateLogs = [];
|
|
@@ -205,10 +244,10 @@ class OrderedSideEffect {
|
|
|
205
244
|
const noteHashesFromExecution = await Promise.all(execution.publicInputs.noteHashes.getActiveItems().filter((noteHash)=>!noteHash.isEmpty()).map(async (noteHash)=>new OrderedSideEffect(await siloNoteHash(contractAddress, noteHash.value), noteHash.counter)));
|
|
206
245
|
const nullifiersFromExecution = await Promise.all(execution.publicInputs.nullifiers.getActiveItems().map(async (nullifier)=>new OrderedSideEffect(await siloNullifier(contractAddress, nullifier.value), nullifier.counter)));
|
|
207
246
|
const privateLogsFromExecution = await Promise.all(execution.publicInputs.privateLogs.getActiveItems().map(async (metadata)=>{
|
|
208
|
-
metadata.log.fields[0] = await
|
|
247
|
+
metadata.log.fields[0] = await poseidon2HashWithSeparator([
|
|
209
248
|
contractAddress,
|
|
210
249
|
metadata.log.fields[0]
|
|
211
|
-
]);
|
|
250
|
+
], GeneratorIndex.PRIVATE_LOG_FIRST_FIELD);
|
|
212
251
|
return new OrderedSideEffect(metadata.log, metadata.counter);
|
|
213
252
|
}));
|
|
214
253
|
siloedNoteHashes.push(...noteHashesFromExecution);
|
|
@@ -222,7 +261,7 @@ class OrderedSideEffect {
|
|
|
222
261
|
}
|
|
223
262
|
publicTeardownCallRequest = execution.publicInputs.publicTeardownCallRequest.isEmpty() ? publicTeardownCallRequest : execution.publicInputs.publicTeardownCallRequest;
|
|
224
263
|
executionSteps.push({
|
|
225
|
-
functionName: await
|
|
264
|
+
functionName: await debugFunctionNameGetter(execution.publicInputs.callContext.contractAddress, execution.publicInputs.callContext.functionSelector),
|
|
226
265
|
timings: execution.profileResult?.timings ?? {
|
|
227
266
|
witgen: 0,
|
|
228
267
|
oracles: {}
|
|
@@ -240,12 +279,13 @@ class OrderedSideEffect {
|
|
|
240
279
|
const sortByCounter = (a, b)=>a.counter - b.counter;
|
|
241
280
|
const getEffect = (orderedSideEffect)=>orderedSideEffect.sideEffect;
|
|
242
281
|
const isPrivateOnlyTx = privateExecutionResult.publicFunctionCalldata.length === 0;
|
|
243
|
-
const minRevertibleSideEffectCounter = getFinalMinRevertibleSideEffectCounter(privateExecutionResult);
|
|
282
|
+
const minRevertibleSideEffectCounter = minRevertibleSideEffectCounterOverride ?? getFinalMinRevertibleSideEffectCounter(privateExecutionResult);
|
|
244
283
|
const [nonRevertibleNullifiers, revertibleNullifiers] = splitOrderedSideEffects(nullifiers.sort(sortByCounter), minRevertibleSideEffectCounter);
|
|
245
|
-
|
|
284
|
+
const nonceGenerator = privateExecutionResult.firstNullifier;
|
|
285
|
+
if (nonRevertibleNullifiers.length === 0) {
|
|
286
|
+
nonRevertibleNullifiers.push(nonceGenerator);
|
|
287
|
+
} else if (!nonRevertibleNullifiers[0].equals(nonceGenerator)) {
|
|
246
288
|
throw new Error('The first non revertible nullifier should be equal to the nonce generator. This is a bug!');
|
|
247
|
-
} else {
|
|
248
|
-
nonRevertibleNullifiers.unshift(nonceGenerator);
|
|
249
289
|
}
|
|
250
290
|
if (isPrivateOnlyTx) {
|
|
251
291
|
// We must make the note hashes unique by using the
|
|
@@ -261,11 +301,15 @@ class OrderedSideEffect {
|
|
|
261
301
|
inputsForRollup = new PartialPrivateTailPublicInputsForRollup(accumulatedDataForRollup);
|
|
262
302
|
} else {
|
|
263
303
|
const [nonRevertibleNoteHashes, revertibleNoteHashes] = splitOrderedSideEffects(siloedNoteHashes.sort(sortByCounter), minRevertibleSideEffectCounter);
|
|
304
|
+
const nonRevertibleUniqueNoteHashes = await Promise.all(nonRevertibleNoteHashes.map(async (noteHash, i)=>{
|
|
305
|
+
const nonce = await computeNoteHashNonce(nonceGenerator, i);
|
|
306
|
+
return await computeUniqueNoteHash(nonce, noteHash);
|
|
307
|
+
}));
|
|
264
308
|
const [nonRevertibleL2ToL1Messages, revertibleL2ToL1Messages] = splitOrderedSideEffects(l2ToL1Messages.sort(sortByCounter), minRevertibleSideEffectCounter);
|
|
265
309
|
const [nonRevertibleTaggedPrivateLogs, revertibleTaggedPrivateLogs] = splitOrderedSideEffects(taggedPrivateLogs, minRevertibleSideEffectCounter);
|
|
266
310
|
const [nonRevertibleContractClassLogHashes, revertibleContractClassLogHashes] = splitOrderedSideEffects(contractClassLogsHashes.sort(sortByCounter), minRevertibleSideEffectCounter);
|
|
267
311
|
const [nonRevertiblePublicCallRequests, revertiblePublicCallRequests] = splitOrderedSideEffects(publicCallRequests.sort(sortByCounter), minRevertibleSideEffectCounter);
|
|
268
|
-
const nonRevertibleData = new PrivateToPublicAccumulatedData(padArrayEnd(
|
|
312
|
+
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));
|
|
269
313
|
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));
|
|
270
314
|
gasUsed = meterGasUsed(revertibleData).add(meterGasUsed(nonRevertibleData));
|
|
271
315
|
if (publicTeardownCallRequest) {
|
|
@@ -287,7 +331,7 @@ function splitOrderedSideEffects(effects, minRevertibleSideEffectCounter) {
|
|
|
287
331
|
const revertibleSideEffects = [];
|
|
288
332
|
const nonRevertibleSideEffects = [];
|
|
289
333
|
effects.forEach((effect)=>{
|
|
290
|
-
if (effect.counter < minRevertibleSideEffectCounter) {
|
|
334
|
+
if (minRevertibleSideEffectCounter === 0 || effect.counter < minRevertibleSideEffectCounter) {
|
|
291
335
|
nonRevertibleSideEffects.push(effect.sideEffect);
|
|
292
336
|
} else {
|
|
293
337
|
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXhlY3V0aW9uX25vdGVfY2FjaGUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb250cmFjdF9mdW5jdGlvbl9zaW11bGF0b3IvZXhlY3V0aW9uX25vdGVfY2FjaGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BELE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBR2hFLE9BQU8sS0FBSyxFQUFFLFFBQVEsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBRXZELFVBQVUsV0FBVztJQUNuQixJQUFJLEVBQUUsUUFBUSxDQUFDO0lBQ2YsT0FBTyxFQUFFLE1BQU0sQ0FBQztJQUNoQixzQkFBc0IsRUFBRSxFQUFFLENBQUM7Q0FDNUI7QUFFRDs7R0FFRztBQUNILHFCQUFhLGtCQUFrQjs7SUFvQ2pCLE9BQU8sQ0FBQyxRQUFRLENBQUMsaUJBQWlCO0lBbkM5Qzs7O09BR0c7SUFDSCxPQUFPLENBQUMsS0FBSyxDQUFxQjtJQUNsQzs7T0FFRztJQUNILE9BQU8sQ0FBQyxPQUFPLENBQXlDO0lBRXhEOzs7O09BSUc7SUFDSCxPQUFPLENBQUMsWUFBWSxDQUF1QztJQUUzRDs7T0FFRztJQUNILE9BQU8sQ0FBQyxpQkFBaUIsQ0FBMEI7SUFFbkQ7O09BRUc7SUFDSCxPQUFPLENBQUMsOEJBQThCLENBQUs7SUFFM0MsT0FBTyxDQUFDLGlCQUFpQixDQUFTO0lBRWxDOzs7T0FHRztJQUNILE9BQU8sQ0FBQyw4QkFBOEIsQ0FBc0I7SUFFNUQsWUFBNkIsaUJBQWlCLEVBQUUsRUFBRSxFQUFJO0lBRXREOzs7T0FHRztJQUNVLGlDQUFpQyxDQUFDLDhCQUE4QixFQUFFLE1BQU0saUJBc0NwRjtJQUVNLDZCQUE2QixDQUFDLGlCQUFpQixFQUFFLE1BQU0sR0FBRyxPQUFPLENBS3ZFO0lBRU0sTUFBTSxTQU1aO0lBRUQ7OztPQUdHO0lBQ0ksVUFBVSxDQUFDLElBQUksRUFBRSxRQUFRLEVBQUUsT0FBTyxFQUFFLE1BQU0sUUFTaEQ7SUFFRDs7Ozs7O09BTUc7SUFDVSxXQUFXLENBQUMsZUFBZSxFQUFFLFlBQVksRUFBRSxjQUFjLEVBQUUsRUFBRSxFQUFFLFFBQVEsRUFBRSxFQUFFLCtCQXlCdkY7SUFFRDs7OztPQUlHO0lBQ1UsZ0JBQWdCLENBQUMsZUFBZSxFQUFFLFlBQVksRUFBRSxjQUFjLEVBQUUsRUFBRSxpQkFHOUU7SUFFRDs7Ozs7O1FBTUk7SUFDRyxRQUFRLENBQUMsZUFBZSxFQUFFLFlBQVksRUFBRSxLQUFLLEVBQUUsWUFBWSxHQUFHLFNBQVMsRUFBRSxXQUFXLEVBQUUsRUFBRSxjQU05RjtJQUVEOzs7OztRQUtJO0lBQ0csZUFBZSxDQUFDLGVBQWUsRUFBRSxZQUFZLEVBQUUsUUFBUSxFQUFFLEVBQUUsV0FHakU7SUFFRDs7O09BR0c7SUFDSSxhQUFhLENBQUMsZUFBZSxFQUFFLFlBQVksR0FBRyxHQUFHLENBQUMsTUFBTSxDQUFDLENBRS9EO0lBVUQsV0FBVyxJQUFJLFdBQVcsRUFBRSxDQUUzQjtJQUVEOztPQUVHO0lBQ0gsb0JBQW9CLElBQUksRUFBRSxFQUFFLENBRTNCO0lBRUQ7OztPQUdHO0lBQ0gsZ0JBQWdCLElBQUksRUFBRSxFQUFFLENBTXZCO0lBRUQsaUJBQWlCLElBQUksRUFBRSxDQUV0QjtDQWFGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution_note_cache.d.ts","sourceRoot":"","sources":["../../src/contract_function_simulator/execution_note_cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAEvD,UAAU,WAAW;IACnB,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,sBAAsB,EAAE,EAAE,CAAC;CAC5B;AAED;;GAEG;AACH,qBAAa,kBAAkB;;
|
|
1
|
+
{"version":3,"file":"execution_note_cache.d.ts","sourceRoot":"","sources":["../../src/contract_function_simulator/execution_note_cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAEvD,UAAU,WAAW;IACnB,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,sBAAsB,EAAE,EAAE,CAAC;CAC5B;AAED;;GAEG;AACH,qBAAa,kBAAkB;;IAoCjB,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAnC9C;;;OAGG;IACH,OAAO,CAAC,KAAK,CAAqB;IAClC;;OAEG;IACH,OAAO,CAAC,OAAO,CAAyC;IAExD;;;;OAIG;IACH,OAAO,CAAC,YAAY,CAAuC;IAE3D;;OAEG;IACH,OAAO,CAAC,iBAAiB,CAA0B;IAEnD;;OAEG;IACH,OAAO,CAAC,8BAA8B,CAAK;IAE3C,OAAO,CAAC,iBAAiB,CAAS;IAElC;;;OAGG;IACH,OAAO,CAAC,8BAA8B,CAAsB;IAE5D,YAA6B,iBAAiB,EAAE,EAAE,EAAI;IAEtD;;;OAGG;IACU,iCAAiC,CAAC,8BAA8B,EAAE,MAAM,iBAsCpF;IAEM,6BAA6B,CAAC,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAKvE;IAEM,MAAM,SAMZ;IAED;;;OAGG;IACI,UAAU,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,QAShD;IAED;;;;;;OAMG;IACU,WAAW,CAAC,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,+BAyBvF;IAED;;;;OAIG;IACU,gBAAgB,CAAC,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,EAAE,iBAG9E;IAED;;;;;;QAMI;IACG,QAAQ,CAAC,eAAe,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,GAAG,SAAS,EAAE,WAAW,EAAE,EAAE,cAM9F;IAED;;;;;QAKI;IACG,eAAe,CAAC,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,WAGjE;IAED;;;OAGG;IACI,aAAa,CAAC,eAAe,EAAE,YAAY,GAAG,GAAG,CAAC,MAAM,CAAC,CAE/D;IAUD,WAAW,IAAI,WAAW,EAAE,CAE3B;IAED;;OAEG;IACH,oBAAoB,IAAI,EAAE,EAAE,CAE3B;IAED;;;OAGG;IACH,gBAAgB,IAAI,EAAE,EAAE,CAMvB;IAED,iBAAiB,IAAI,EAAE,CAEtB;CAaF"}
|
|
@@ -17,23 +17,24 @@ import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash, siloNullifie
|
|
|
17
17
|
* Note that their value (bigint representation) is used because Frs cannot be looked up in Sets.
|
|
18
18
|
*/ nullifierMap;
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
21
|
-
*/
|
|
22
|
-
|
|
20
|
+
* Nullifiers emitted by private calls in this transaction.
|
|
21
|
+
*/ emittedNullifiers;
|
|
22
|
+
/**
|
|
23
|
+
* The counter that separates non-revertible side effects (which persist even if the tx reverts) from revertible ones.
|
|
24
|
+
*/ minRevertibleSideEffectCounter;
|
|
23
25
|
inRevertiblePhase;
|
|
24
26
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
+
* Whether the protocol nullifier was used for nonce generation.
|
|
28
|
+
* We don't need to use the protocol nullifier if a non-revertible nullifier is emitted.
|
|
27
29
|
*/ usedProtocolNullifierForNonces;
|
|
28
30
|
constructor(protocolNullifier){
|
|
29
31
|
this.protocolNullifier = protocolNullifier;
|
|
30
32
|
this.notes = [];
|
|
31
33
|
this.noteMap = new Map();
|
|
32
34
|
this.nullifierMap = new Map();
|
|
33
|
-
this.
|
|
35
|
+
this.emittedNullifiers = new Set();
|
|
34
36
|
this.minRevertibleSideEffectCounter = 0;
|
|
35
37
|
this.inRevertiblePhase = false;
|
|
36
|
-
this.usedProtocolNullifierForNonces = true;
|
|
37
38
|
}
|
|
38
39
|
/**
|
|
39
40
|
* Enters the revertible phase of the transaction.
|
|
@@ -44,16 +45,16 @@ import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash, siloNullifie
|
|
|
44
45
|
}
|
|
45
46
|
this.inRevertiblePhase = true;
|
|
46
47
|
this.minRevertibleSideEffectCounter = minRevertibleSideEffectCounter;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
const nullifiers = this.getEmittedNullifiers();
|
|
49
|
+
// If there are no nullifiers emitted by private calls so far, we use the protocol nullifier as the nonce generator.
|
|
50
|
+
// Note: There could still be nullifiers emitted after the counter is set, but those nullifiers are revertible, so
|
|
51
|
+
// we don't want to use them as the nonce generator.
|
|
52
|
+
this.usedProtocolNullifierForNonces = nullifiers.length === 0;
|
|
53
|
+
const nonceGenerator = this.usedProtocolNullifierForNonces ? this.protocolNullifier : new Fr(nullifiers[0]);
|
|
53
54
|
// The existing pending notes are all non-revertible.
|
|
54
55
|
// They cannot be squashed by nullifiers emitted after minRevertibleSideEffectCounter is set.
|
|
55
56
|
// Their indexes in the tx are known at this point and won't change. So we can assign a nonce to each one of them.
|
|
56
|
-
// The nonces will be used to create the "
|
|
57
|
+
// The nonces will be used to create the "unique" note hashes.
|
|
57
58
|
const updatedNotes = await Promise.all(this.notes.map(async ({ note, counter }, i)=>{
|
|
58
59
|
const noteNonce = await computeNoteHashNonce(nonceGenerator, i);
|
|
59
60
|
const uniqueNoteHash = await computeUniqueNoteHash(noteNonce, await siloNoteHash(note.contractAddress, note.noteHash));
|
|
@@ -78,15 +79,11 @@ import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash, siloNullifie
|
|
|
78
79
|
return sideEffectCounter >= this.minRevertibleSideEffectCounter;
|
|
79
80
|
}
|
|
80
81
|
finish() {
|
|
81
|
-
// If we never entered the revertible phase,
|
|
82
|
-
//
|
|
82
|
+
// If we never entered the revertible phase, and there are no nullifiers emitted, we need to use the protocol
|
|
83
|
+
// nullifier as the nonce generator.
|
|
83
84
|
if (!this.inRevertiblePhase) {
|
|
84
|
-
this.usedProtocolNullifierForNonces = this.
|
|
85
|
+
this.usedProtocolNullifierForNonces = this.getEmittedNullifiers().length === 0;
|
|
85
86
|
}
|
|
86
|
-
// If we entered the revertible phase, the nonce generator was decided based on wether or not a nullifier was emitted before entering.
|
|
87
|
-
return {
|
|
88
|
-
usedProtocolNullifierForNonces: this.usedProtocolNullifierForNonces
|
|
89
|
-
};
|
|
90
87
|
}
|
|
91
88
|
/**
|
|
92
89
|
* Add a new note to cache.
|
|
@@ -124,11 +121,11 @@ import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash, siloNullifie
|
|
|
124
121
|
this.notes = this.notes.filter((n)=>n.counter !== note.counter);
|
|
125
122
|
// If the note is non revertible and the nullifier was emitted in the revertible phase, both the note hash and the nullifier will be emitted
|
|
126
123
|
if (this.inRevertiblePhase && note.counter < this.minRevertibleSideEffectCounter) {
|
|
127
|
-
this
|
|
124
|
+
this.#recordNullifier(contractAddress, siloedNullifier);
|
|
128
125
|
}
|
|
129
126
|
} else {
|
|
130
127
|
// If the note being nullified comes from a previous tx the nullifier will be emitted.
|
|
131
|
-
this
|
|
128
|
+
this.#recordNullifier(contractAddress, siloedNullifier);
|
|
132
129
|
}
|
|
133
130
|
return nullifiedNoteHashCounter;
|
|
134
131
|
}
|
|
@@ -138,7 +135,7 @@ import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash, siloNullifie
|
|
|
138
135
|
* @param innerNullifier
|
|
139
136
|
*/ async nullifierCreated(contractAddress, innerNullifier) {
|
|
140
137
|
const siloedNullifier = (await siloNullifier(contractAddress, innerNullifier)).toBigInt();
|
|
141
|
-
this
|
|
138
|
+
this.#recordNullifier(contractAddress, siloedNullifier);
|
|
142
139
|
}
|
|
143
140
|
/**
|
|
144
141
|
* Return notes created up to current point in execution.
|
|
@@ -174,18 +171,38 @@ import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash, siloNullifie
|
|
|
174
171
|
getAllNotes() {
|
|
175
172
|
return this.notes;
|
|
176
173
|
}
|
|
177
|
-
|
|
174
|
+
/**
|
|
175
|
+
* @returns All nullifiers emitted by private calls in this transaction.
|
|
176
|
+
*/ getEmittedNullifiers() {
|
|
178
177
|
return [
|
|
179
|
-
...this.
|
|
178
|
+
...this.emittedNullifiers
|
|
180
179
|
].map((n)=>new Fr(n));
|
|
181
180
|
}
|
|
182
|
-
|
|
181
|
+
/**
|
|
182
|
+
* @returns All nullifiers emitted by private calls in this transaction. If the protocol nullifier was used as the
|
|
183
|
+
* nonce generator, it is injected as the first nullifier.
|
|
184
|
+
*/ getAllNullifiers() {
|
|
185
|
+
if (this.usedProtocolNullifierForNonces === undefined) {
|
|
186
|
+
throw new Error('usedProtocolNullifierForNonces is not set yet. Call finish() to complete the transaction.');
|
|
187
|
+
}
|
|
188
|
+
const allNullifiers = this.getEmittedNullifiers();
|
|
189
|
+
return [
|
|
190
|
+
...this.usedProtocolNullifierForNonces ? [
|
|
191
|
+
this.protocolNullifier
|
|
192
|
+
] : [],
|
|
193
|
+
...allNullifiers
|
|
194
|
+
];
|
|
195
|
+
}
|
|
196
|
+
getNonceGenerator() {
|
|
197
|
+
return this.getAllNullifiers()[0];
|
|
198
|
+
}
|
|
199
|
+
#recordNullifier(contractAddress, siloedNullifier) {
|
|
183
200
|
const nullifiers = this.getNullifiers(contractAddress);
|
|
184
201
|
if (nullifiers.has(siloedNullifier)) {
|
|
185
202
|
throw new Error(`Duplicate siloed nullifier ${siloedNullifier} emitted by contract ${contractAddress}`);
|
|
186
203
|
}
|
|
187
204
|
nullifiers.add(siloedNullifier);
|
|
188
205
|
this.nullifierMap.set(contractAddress.toBigInt(), nullifiers);
|
|
189
|
-
this.
|
|
206
|
+
this.emittedNullifiers.add(siloedNullifier);
|
|
190
207
|
}
|
|
191
208
|
}
|
|
@@ -9,6 +9,6 @@ export { PrivateExecutionOracle } from './oracle/private_execution_oracle.js';
|
|
|
9
9
|
export { Oracle } from './oracle/oracle.js';
|
|
10
10
|
export { executePrivateFunction, extractPrivateCircuitPublicInputs } from './oracle/private_execution.js';
|
|
11
11
|
export { generateSimulatedProvingResult } from './contract_function_simulator.js';
|
|
12
|
-
export {
|
|
12
|
+
export { packAsHintedNote } from './oracle/note_packing_utils.js';
|
|
13
13
|
export { UtilityContext } from './noir-structs/utility_context.js';
|
|
14
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
14
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb250cmFjdF9mdW5jdGlvbl9zaW11bGF0b3IvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLGtCQUFrQixFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFDL0QsT0FBTyxFQUFFLDBCQUEwQixFQUFFLE1BQU0sb0NBQW9DLENBQUM7QUFDaEYsT0FBTyxFQUFFLGlCQUFpQixFQUFFLE1BQU0sMEJBQTBCLENBQUM7QUFDN0QsT0FBTyxFQUFFLFNBQVMsRUFBRSxNQUFNLGlCQUFpQixDQUFDO0FBQzVDLFlBQVksRUFBRSxRQUFRLEVBQUUsV0FBVyxFQUFFLHVCQUF1QixFQUFFLHVCQUF1QixFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFDdEgsT0FBTyxFQUFFLHVCQUF1QixFQUFFLE1BQU0sd0NBQXdDLENBQUM7QUFDakYsT0FBTyxFQUFFLHNCQUFzQixFQUFFLE1BQU0sc0NBQXNDLENBQUM7QUFDOUUsT0FBTyxFQUFFLHNCQUFzQixFQUFFLE1BQU0sc0NBQXNDLENBQUM7QUFDOUUsT0FBTyxFQUFFLE1BQU0sRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBQzVDLE9BQU8sRUFBRSxzQkFBc0IsRUFBRSxpQ0FBaUMsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBQzFHLE9BQU8sRUFBRSw4QkFBOEIsRUFBRSxNQUFNLGtDQUFrQyxDQUFDO0FBQ2xGLE9BQU8sRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ2xFLE9BQU8sRUFBRSxjQUFjLEVBQUUsTUFBTSxtQ0FBbUMsQ0FBQyJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contract_function_simulator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACtH,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,iCAAiC,EAAE,MAAM,+BAA+B,CAAC;AAC1G,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contract_function_simulator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACtH,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,iCAAiC,EAAE,MAAM,+BAA+B,CAAC;AAC1G,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC"}
|
|
@@ -8,5 +8,5 @@ export { PrivateExecutionOracle } from './oracle/private_execution_oracle.js';
|
|
|
8
8
|
export { Oracle } from './oracle/oracle.js';
|
|
9
9
|
export { executePrivateFunction, extractPrivateCircuitPublicInputs } from './oracle/private_execution.js';
|
|
10
10
|
export { generateSimulatedProvingResult } from './contract_function_simulator.js';
|
|
11
|
-
export {
|
|
11
|
+
export { packAsHintedNote } from './oracle/note_packing_utils.js';
|
|
12
12
|
export { UtilityContext } from './noir-structs/utility_context.js';
|
|
@@ -4,7 +4,7 @@ import { EventSelector } from '@aztec/stdlib/abi';
|
|
|
4
4
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
5
|
import { TxHash } from '@aztec/stdlib/tx';
|
|
6
6
|
/**
|
|
7
|
-
* Intermediate struct used to perform batch event validation by PXE. The `
|
|
7
|
+
* Intermediate struct used to perform batch event validation by PXE. The `utilityValidateAndStoreEnqueuedNotesAndEvents` oracle
|
|
8
8
|
* expects for values of this type to be stored in a `CapsuleArray`.
|
|
9
9
|
*/
|
|
10
10
|
export declare class EventValidationRequest {
|
|
@@ -5,7 +5,7 @@ import { TxHash } from '@aztec/stdlib/tx';
|
|
|
5
5
|
// TODO(#14617): should we compute this from constants? This value is aztec-nr specific.
|
|
6
6
|
const MAX_EVENT_SERIALIZED_LEN = 12;
|
|
7
7
|
/**
|
|
8
|
-
* Intermediate struct used to perform batch event validation by PXE. The `
|
|
8
|
+
* Intermediate struct used to perform batch event validation by PXE. The `utilityValidateAndStoreEnqueuedNotesAndEvents` oracle
|
|
9
9
|
* expects for values of this type to be stored in a `CapsuleArray`.
|
|
10
10
|
*/ export class EventValidationRequest {
|
|
11
11
|
contractAddress;
|
|
@@ -4,7 +4,7 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
4
4
|
import { TxHash } from '@aztec/stdlib/tx';
|
|
5
5
|
export declare const MAX_NOTE_PACKED_LEN = 10;
|
|
6
6
|
/**
|
|
7
|
-
* Intermediate struct used to perform batch note validation by PXE. The `
|
|
7
|
+
* Intermediate struct used to perform batch note validation by PXE. The `utilityValidateAndStoreEnqueuedNotesAndEvents` oracle
|
|
8
8
|
* expects for values of this type to be stored in a `CapsuleArray`.
|
|
9
9
|
*/
|
|
10
10
|
export declare class NoteValidationRequest {
|
|
@@ -4,7 +4,7 @@ import { TxHash } from '@aztec/stdlib/tx';
|
|
|
4
4
|
// TODO(#14617): should we compute this from constants? This value is aztec-nr specific.
|
|
5
5
|
export const MAX_NOTE_PACKED_LEN = 10;
|
|
6
6
|
/**
|
|
7
|
-
* Intermediate struct used to perform batch note validation by PXE. The `
|
|
7
|
+
* Intermediate struct used to perform batch note validation by PXE. The `utilityValidateAndStoreEnqueuedNotesAndEvents` oracle
|
|
8
8
|
* expects for values of this type to be stored in a `CapsuleArray`.
|
|
9
9
|
*/ export class NoteValidationRequest {
|
|
10
10
|
contractAddress;
|
|
@@ -1,22 +1,16 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
import type { FieldsOf } from '@aztec/foundation/types';
|
|
3
1
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
-
import type {
|
|
2
|
+
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
5
3
|
/**
|
|
6
4
|
* TypeScript counterpart of utility_context.nr. Used only as a return value for the utilityGetUtilityContext oracle.
|
|
7
5
|
*/
|
|
8
6
|
export declare class UtilityContext {
|
|
9
|
-
readonly
|
|
10
|
-
readonly timestamp: UInt64;
|
|
7
|
+
readonly blockHeader: BlockHeader;
|
|
11
8
|
readonly contractAddress: AztecAddress;
|
|
12
|
-
|
|
13
|
-
readonly chainId: Fr;
|
|
14
|
-
private constructor();
|
|
15
|
-
static from(fields: FieldsOf<UtilityContext>): UtilityContext;
|
|
9
|
+
constructor(blockHeader: BlockHeader, contractAddress: AztecAddress);
|
|
16
10
|
/**
|
|
17
11
|
* Returns a representation of the utility context as expected by intrinsic Noir deserialization.
|
|
18
12
|
* The order of the fields has to be the same as the order of the fields in the utility_context.nr.
|
|
19
13
|
*/
|
|
20
14
|
toNoirRepresentation(): (string | string[])[];
|
|
21
15
|
}
|
|
22
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
16
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbGl0eV9jb250ZXh0LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvY29udHJhY3RfZnVuY3Rpb25fc2ltdWxhdG9yL25vaXItc3RydWN0cy91dGlsaXR5X2NvbnRleHQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFDaEUsT0FBTyxLQUFLLEVBQUUsV0FBVyxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFcEQ7O0dBRUc7QUFDSCxxQkFBYSxjQUFjO2FBRVAsV0FBVyxFQUFFLFdBQVc7YUFDeEIsZUFBZSxFQUFFLFlBQVk7SUFGL0MsWUFDa0IsV0FBVyxFQUFFLFdBQVcsRUFDeEIsZUFBZSxFQUFFLFlBQVksRUFDM0M7SUFFSjs7O09BR0c7SUFDSSxvQkFBb0IsSUFBSSxDQUFDLE1BQU0sR0FBRyxNQUFNLEVBQUUsQ0FBQyxFQUFFLENBSW5EO0NBQ0YifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utility_context.d.ts","sourceRoot":"","sources":["../../../src/contract_function_simulator/noir-structs/utility_context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utility_context.d.ts","sourceRoot":"","sources":["../../../src/contract_function_simulator/noir-structs/utility_context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;GAEG;AACH,qBAAa,cAAc;aAEP,WAAW,EAAE,WAAW;aACxB,eAAe,EAAE,YAAY;IAF/C,YACkB,WAAW,EAAE,WAAW,EACxB,eAAe,EAAE,YAAY,EAC3C;IAEJ;;;OAGG;IACI,oBAAoB,IAAI,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,CAInD;CACF"}
|
|
@@ -1,33 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { toACVMField } from '@aztec/simulator/client';
|
|
2
2
|
/**
|
|
3
3
|
* TypeScript counterpart of utility_context.nr. Used only as a return value for the utilityGetUtilityContext oracle.
|
|
4
4
|
*/ export class UtilityContext {
|
|
5
|
-
|
|
6
|
-
timestamp;
|
|
5
|
+
blockHeader;
|
|
7
6
|
contractAddress;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
constructor(blockNumber, timestamp, contractAddress, version, chainId){
|
|
11
|
-
this.blockNumber = blockNumber;
|
|
12
|
-
this.timestamp = timestamp;
|
|
7
|
+
constructor(blockHeader, contractAddress){
|
|
8
|
+
this.blockHeader = blockHeader;
|
|
13
9
|
this.contractAddress = contractAddress;
|
|
14
|
-
this.version = version;
|
|
15
|
-
this.chainId = chainId;
|
|
16
|
-
}
|
|
17
|
-
static from(fields) {
|
|
18
|
-
return new UtilityContext(fields.blockNumber, fields.timestamp, fields.contractAddress, fields.version, fields.chainId);
|
|
19
10
|
}
|
|
20
11
|
/**
|
|
21
12
|
* Returns a representation of the utility context as expected by intrinsic Noir deserialization.
|
|
22
13
|
* The order of the fields has to be the same as the order of the fields in the utility_context.nr.
|
|
23
14
|
*/ toNoirRepresentation() {
|
|
24
15
|
// TODO(#12874): remove the stupid as string conversion by modifying ForeignCallOutput type in acvm.js
|
|
16
|
+
const blockHeaderFields = this.blockHeader.toFields().map(toACVMField);
|
|
25
17
|
return [
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
this.contractAddress.toString(),
|
|
29
|
-
this.version.toString(),
|
|
30
|
-
this.chainId.toString()
|
|
18
|
+
...blockHeaderFields,
|
|
19
|
+
this.contractAddress.toString()
|
|
31
20
|
];
|
|
32
21
|
}
|
|
33
22
|
}
|