@aztec/pxe 0.0.1-commit.d431d1c → 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/bin/check_oracle_version.js +1 -1
- package/dest/block_synchronizer/block_synchronizer.d.ts +9 -5
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +62 -16
- package/dest/config/index.d.ts +3 -1
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +17 -0
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +54 -30
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +175 -74
- 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.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +2 -2
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +3 -3
- 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 +2 -2
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +15 -12
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.d.ts +7 -5
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +51 -29
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -22
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +0 -37
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +44 -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 +86 -30
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +62 -30
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +107 -88
- 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 +43 -0
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
- package/dest/contract_sync/contract_sync_service.js +97 -0
- package/dest/contract_sync/helpers.d.ts +29 -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 +24 -10
- 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/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 +21 -7
- 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 +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 +4 -1
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +3 -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 +5 -6
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +6 -7
- 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 +28 -32
- package/dest/notes/note_service.d.ts +9 -8
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +17 -16
- 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 +3 -3
- package/dest/oracle_version.d.ts.map +1 -1
- package/dest/oracle_version.js +4 -3
- 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 +3 -2
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +21 -13
- package/dest/private_kernel/private_kernel_oracle.d.ts +8 -4
- 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 +69 -23
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +104 -67
- 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.js +6 -8
- package/dest/storage/contract_store/contract_store.d.ts +42 -16
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +157 -84
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/note_store/note_store.d.ts +47 -49
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +278 -252
- 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 +17 -4
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
- package/dest/storage/private_event_store/private_event_store.js +198 -147
- 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 +6 -6
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/recipient_tagging_store.js +31 -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 +5 -5
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +184 -114
- 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 +60 -0
- package/dest/tagging/index.d.ts +3 -2
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +2 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +5 -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 +7 -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 +16 -12
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +5 -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/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 -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 +20 -18
- package/package.json +25 -16
- package/src/access_scopes.ts +9 -0
- package/src/bin/check_oracle_version.ts +1 -0
- package/src/block_synchronizer/block_synchronizer.ts +76 -33
- package/src/config/index.ts +14 -0
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +324 -137
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +5 -5
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +2 -2
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +2 -2
- package/src/contract_function_simulator/oracle/interfaces.ts +20 -11
- package/src/contract_function_simulator/oracle/oracle.ts +56 -26
- package/src/contract_function_simulator/oracle/private_execution.ts +1 -60
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +126 -110
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +172 -95
- package/src/contract_logging.ts +39 -0
- package/src/contract_sync/contract_sync_service.ts +152 -0
- package/src/contract_sync/helpers.ts +98 -0
- package/src/debug/pxe_debug_utils.ts +63 -18
- package/src/entrypoints/client/bundle/index.ts +3 -0
- package/src/entrypoints/client/bundle/utils.ts +16 -15
- package/src/entrypoints/client/lazy/index.ts +3 -0
- package/src/entrypoints/client/lazy/utils.ts +17 -15
- package/src/entrypoints/pxe_creation_options.ts +2 -1
- package/src/entrypoints/server/index.ts +3 -0
- package/src/entrypoints/server/utils.ts +22 -26
- package/src/events/event_service.ts +5 -7
- package/src/job_coordinator/job_coordinator.ts +4 -3
- package/src/logs/log_service.ts +48 -39
- package/src/notes/note_service.ts +24 -22
- package/src/notes_filter.ts +26 -0
- package/src/oracle_version.ts +4 -3
- 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 +25 -15
- package/src/private_kernel/private_kernel_oracle.ts +9 -9
- package/src/pxe.ts +211 -112
- 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 +8 -8
- package/src/storage/contract_store/contract_store.ts +186 -96
- 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 +250 -190
- package/src/storage/private_event_store/stored_private_event.ts +73 -0
- package/src/storage/tagging_store/recipient_tagging_store.ts +38 -24
- package/src/storage/tagging_store/sender_address_book_store.ts +20 -14
- package/src/storage/tagging_store/sender_tagging_store.ts +214 -130
- package/src/tagging/get_all_logs_by_tags.ts +92 -0
- package/src/tagging/index.ts +2 -1
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +17 -10
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +17 -16
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +6 -9
- 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 +23 -23
- 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
- package/dest/tree_membership/tree_membership_service.d.ts +0 -50
- package/dest/tree_membership/tree_membership_service.d.ts.map +0 -1
- package/dest/tree_membership/tree_membership_service.js +0 -75
- package/src/tree_membership/tree_membership_service.ts +0 -97
|
@@ -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 { poseidon2Hash } 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,67 +9,55 @@ 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';
|
|
22
21
|
import { Oracle } from './oracle/oracle.js';
|
|
23
|
-
import { executePrivateFunction
|
|
22
|
+
import { executePrivateFunction } from './oracle/private_execution.js';
|
|
24
23
|
import { PrivateExecutionOracle } from './oracle/private_execution_oracle.js';
|
|
25
24
|
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;
|
|
32
32
|
addressStore;
|
|
33
33
|
aztecNode;
|
|
34
|
-
anchorBlockStore;
|
|
35
34
|
senderTaggingStore;
|
|
36
35
|
recipientTaggingStore;
|
|
37
36
|
senderAddressBookStore;
|
|
38
37
|
capsuleStore;
|
|
39
38
|
privateEventStore;
|
|
40
39
|
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.
|
|
40
|
+
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
|
-
await this.contractStore.syncPrivateState(contractAddress, selector, (privateSyncCall)=>this.runUtility(privateSyncCall, [], anchorBlockHeader, scopes, jobId));
|
|
73
|
-
await verifyCurrentClassId(contractAddress, this.aztecNode, this.contractStore, anchorBlockHeader);
|
|
74
61
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(contractAddress, selector);
|
|
75
62
|
if (entryPointArtifact.functionType !== FunctionType.PRIVATE) {
|
|
76
63
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as private`);
|
|
@@ -84,9 +71,37 @@ import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
|
|
|
84
71
|
const protocolNullifier = await computeProtocolNullifier(await request.toTxRequest().hash());
|
|
85
72
|
const noteCache = new ExecutionNoteCache(protocolNullifier);
|
|
86
73
|
const taggingIndexCache = new ExecutionTaggingIndexCache();
|
|
87
|
-
const privateExecutionOracle = new PrivateExecutionOracle(
|
|
88
|
-
|
|
89
|
-
|
|
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
|
+
});
|
|
90
105
|
const setupTime = simulatorSetupTimer.ms();
|
|
91
106
|
try {
|
|
92
107
|
// Note: any nested private function calls are made recursively within this
|
|
@@ -129,12 +144,27 @@ import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
|
|
|
129
144
|
* accounts if not specified.
|
|
130
145
|
* @returns A return value of the utility function in a form as returned by the simulator (Noir fields)
|
|
131
146
|
*/ async runUtility(call, authwits, anchorBlockHeader, scopes, jobId) {
|
|
132
|
-
await verifyCurrentClassId(call.to, this.aztecNode, this.contractStore, anchorBlockHeader);
|
|
133
147
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
134
148
|
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
135
149
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
136
150
|
}
|
|
137
|
-
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
|
+
});
|
|
138
168
|
try {
|
|
139
169
|
this.log.verbose(`Executing utility function ${entryPointArtifact.name}`, {
|
|
140
170
|
contract: call.to,
|
|
@@ -150,7 +180,7 @@ import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
|
|
|
150
180
|
cause: err
|
|
151
181
|
});
|
|
152
182
|
});
|
|
153
|
-
this.log.verbose(`Utility
|
|
183
|
+
this.log.verbose(`Utility execution for ${call.to}.${call.selector} completed`);
|
|
154
184
|
return witnessMapToFields(acirExecutionResult.returnWitness);
|
|
155
185
|
} catch (err) {
|
|
156
186
|
throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during private execution'));
|
|
@@ -190,18 +220,24 @@ class OrderedSideEffect {
|
|
|
190
220
|
* (allowing state overrides) and is much faster, while still generating a valid
|
|
191
221
|
* output that can be sent to the node for public simulation
|
|
192
222
|
* @param privateExecutionResult - The result of the private execution.
|
|
193
|
-
* @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.
|
|
194
225
|
* @param minRevertibleSideEffectCounterOverride - Optional override for the min revertible side effect counter.
|
|
195
226
|
* Used by TXE to simulate account contract behavior (setting the counter before app execution).
|
|
196
227
|
* @returns The simulated proving result.
|
|
197
|
-
*/ export async function generateSimulatedProvingResult(privateExecutionResult,
|
|
198
|
-
const siloedNoteHashes = [];
|
|
199
|
-
const nullifiers = [];
|
|
228
|
+
*/ export async function generateSimulatedProvingResult(privateExecutionResult, debugFunctionNameGetter, node, minRevertibleSideEffectCounterOverride) {
|
|
200
229
|
const taggedPrivateLogs = [];
|
|
201
230
|
const l2ToL1Messages = [];
|
|
202
231
|
const contractClassLogsHashes = [];
|
|
203
232
|
const publicCallRequests = [];
|
|
204
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 = [];
|
|
205
241
|
let publicTeardownCallRequest;
|
|
206
242
|
const executions = [
|
|
207
243
|
privateExecutionResult.entrypoint
|
|
@@ -210,18 +246,14 @@ class OrderedSideEffect {
|
|
|
210
246
|
const execution = executions.shift();
|
|
211
247
|
executions.unshift(...execution.nestedExecutionResults);
|
|
212
248
|
const { contractAddress } = execution.publicInputs.callContext;
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
metadata.log.fields[0] = await
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}));
|
|
222
|
-
siloedNoteHashes.push(...noteHashesFromExecution);
|
|
223
|
-
taggedPrivateLogs.push(...privateLogsFromExecution);
|
|
224
|
-
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());
|
|
225
257
|
l2ToL1Messages.push(...execution.publicInputs.l2ToL1Msgs.getActiveItems().map((message)=>new OrderedSideEffect(message.message.scope(contractAddress), message.counter)));
|
|
226
258
|
contractClassLogsHashes.push(...execution.publicInputs.contractClassLogsHashes.getActiveItems().map((contractClassLogHash)=>new OrderedSideEffect(contractClassLogHash.logHash.scope(contractAddress), contractClassLogHash.counter)));
|
|
227
259
|
publicCallRequests.push(...execution.publicInputs.publicCallRequests.getActiveItems().map((callRequest)=>new OrderedSideEffect(callRequest.inner, callRequest.counter)));
|
|
@@ -230,7 +262,7 @@ class OrderedSideEffect {
|
|
|
230
262
|
}
|
|
231
263
|
publicTeardownCallRequest = execution.publicInputs.publicTeardownCallRequest.isEmpty() ? publicTeardownCallRequest : execution.publicInputs.publicTeardownCallRequest;
|
|
232
264
|
executionSteps.push({
|
|
233
|
-
functionName: await
|
|
265
|
+
functionName: await debugFunctionNameGetter(execution.publicInputs.callContext.contractAddress, execution.publicInputs.callContext.functionSelector),
|
|
234
266
|
timings: execution.profileResult?.timings ?? {
|
|
235
267
|
witgen: 0,
|
|
236
268
|
oracles: {}
|
|
@@ -240,6 +272,14 @@ class OrderedSideEffect {
|
|
|
240
272
|
witness: execution.partialWitness
|
|
241
273
|
});
|
|
242
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)));
|
|
243
283
|
const constantData = new TxConstantData(privateExecutionResult.entrypoint.publicInputs.anchorBlockHeader, privateExecutionResult.entrypoint.publicInputs.txContext, getVKTreeRoot(), protocolContractsHash);
|
|
244
284
|
const hasPublicCalls = privateExecutionResult.publicFunctionCalldata.length !== 0;
|
|
245
285
|
let inputsForRollup;
|
|
@@ -248,8 +288,7 @@ class OrderedSideEffect {
|
|
|
248
288
|
const sortByCounter = (a, b)=>a.counter - b.counter;
|
|
249
289
|
const getEffect = (orderedSideEffect)=>orderedSideEffect.sideEffect;
|
|
250
290
|
const isPrivateOnlyTx = privateExecutionResult.publicFunctionCalldata.length === 0;
|
|
251
|
-
const
|
|
252
|
-
const [nonRevertibleNullifiers, revertibleNullifiers] = splitOrderedSideEffects(nullifiers.sort(sortByCounter), minRevertibleSideEffectCounter);
|
|
291
|
+
const [nonRevertibleNullifiers, revertibleNullifiers] = splitOrderedSideEffects(siloedNullifiers, minRevertibleSideEffectCounter);
|
|
253
292
|
const nonceGenerator = privateExecutionResult.firstNullifier;
|
|
254
293
|
if (nonRevertibleNullifiers.length === 0) {
|
|
255
294
|
nonRevertibleNullifiers.push(nonceGenerator);
|
|
@@ -259,43 +298,102 @@ class OrderedSideEffect {
|
|
|
259
298
|
if (isPrivateOnlyTx) {
|
|
260
299
|
// We must make the note hashes unique by using the
|
|
261
300
|
// nonce generator and their index in the tx.
|
|
262
|
-
const uniqueNoteHashes = await Promise.all(siloedNoteHashes.
|
|
301
|
+
const uniqueNoteHashes = await Promise.all(siloedNoteHashes.map(async (orderedSideEffect, i)=>{
|
|
263
302
|
const siloedNoteHash = orderedSideEffect.sideEffect;
|
|
264
303
|
const nonce = await computeNoteHashNonce(nonceGenerator, i);
|
|
265
304
|
const uniqueNoteHash = await computeUniqueNoteHash(nonce, siloedNoteHash);
|
|
266
305
|
return uniqueNoteHash;
|
|
267
306
|
}));
|
|
268
|
-
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(
|
|
269
|
-
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);
|
|
270
309
|
inputsForRollup = new PartialPrivateTailPublicInputsForRollup(accumulatedDataForRollup);
|
|
271
310
|
} else {
|
|
272
|
-
const [nonRevertibleNoteHashes, revertibleNoteHashes] = splitOrderedSideEffects(siloedNoteHashes
|
|
311
|
+
const [nonRevertibleNoteHashes, revertibleNoteHashes] = splitOrderedSideEffects(siloedNoteHashes, minRevertibleSideEffectCounter);
|
|
273
312
|
const nonRevertibleUniqueNoteHashes = await Promise.all(nonRevertibleNoteHashes.map(async (noteHash, i)=>{
|
|
274
313
|
const nonce = await computeNoteHashNonce(nonceGenerator, i);
|
|
275
314
|
return await computeUniqueNoteHash(nonce, noteHash);
|
|
276
315
|
}));
|
|
277
316
|
const [nonRevertibleL2ToL1Messages, revertibleL2ToL1Messages] = splitOrderedSideEffects(l2ToL1Messages.sort(sortByCounter), minRevertibleSideEffectCounter);
|
|
278
|
-
const [nonRevertibleTaggedPrivateLogs, revertibleTaggedPrivateLogs] = splitOrderedSideEffects(
|
|
317
|
+
const [nonRevertibleTaggedPrivateLogs, revertibleTaggedPrivateLogs] = splitOrderedSideEffects(filteredPrivateLogs, minRevertibleSideEffectCounter);
|
|
279
318
|
const [nonRevertibleContractClassLogHashes, revertibleContractClassLogHashes] = splitOrderedSideEffects(contractClassLogsHashes.sort(sortByCounter), minRevertibleSideEffectCounter);
|
|
280
319
|
const [nonRevertiblePublicCallRequests, revertiblePublicCallRequests] = splitOrderedSideEffects(publicCallRequests.sort(sortByCounter), minRevertibleSideEffectCounter);
|
|
281
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));
|
|
282
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));
|
|
283
|
-
gasUsed = meterGasUsed(revertibleData).add(meterGasUsed(nonRevertibleData));
|
|
322
|
+
gasUsed = meterGasUsed(revertibleData, isPrivateOnlyTx).add(meterGasUsed(nonRevertibleData, isPrivateOnlyTx));
|
|
284
323
|
if (publicTeardownCallRequest) {
|
|
285
|
-
gasUsed.add(privateExecutionResult.entrypoint.publicInputs.txContext.gasSettings.teardownGasLimits);
|
|
324
|
+
gasUsed = gasUsed.add(privateExecutionResult.entrypoint.publicInputs.txContext.gasSettings.teardownGasLimits);
|
|
286
325
|
}
|
|
287
326
|
inputsForPublic = new PartialPrivateTailPublicInputsForPublic(nonRevertibleData, revertibleData, publicTeardownCallRequest ?? PublicCallRequest.empty());
|
|
288
327
|
}
|
|
289
328
|
const publicInputs = new PrivateKernelTailCircuitPublicInputs(constantData, /*gasUsed=*/ gasUsed.add(Gas.from({
|
|
290
|
-
l2Gas:
|
|
291
|
-
daGas:
|
|
292
|
-
})), /*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);
|
|
293
332
|
return {
|
|
294
333
|
publicInputs,
|
|
295
334
|
chonkProof: ChonkProof.empty(),
|
|
296
335
|
executionSteps
|
|
297
336
|
};
|
|
298
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
|
+
}
|
|
299
397
|
function splitOrderedSideEffects(effects, minRevertibleSideEffectCounter) {
|
|
300
398
|
const revertibleSideEffects = [];
|
|
301
399
|
const nonRevertibleSideEffects = [];
|
|
@@ -311,18 +409,21 @@ function splitOrderedSideEffects(effects, minRevertibleSideEffectCounter) {
|
|
|
311
409
|
revertibleSideEffects
|
|
312
410
|
];
|
|
313
411
|
}
|
|
314
|
-
function meterGasUsed(data) {
|
|
412
|
+
function meterGasUsed(data, isPrivateOnlyTx) {
|
|
315
413
|
let meteredDAFields = 0;
|
|
316
414
|
let meteredL2Gas = 0;
|
|
317
415
|
const numNoteHashes = arrayNonEmptyLength(data.noteHashes, (hash)=>hash.isEmpty());
|
|
318
416
|
meteredDAFields += numNoteHashes;
|
|
319
|
-
|
|
417
|
+
const noteHashBaseGas = isPrivateOnlyTx ? L2_GAS_PER_NOTE_HASH : AVM_EMITNOTEHASH_BASE_L2_GAS;
|
|
418
|
+
meteredL2Gas += numNoteHashes * noteHashBaseGas;
|
|
320
419
|
const numNullifiers = arrayNonEmptyLength(data.nullifiers, (nullifier)=>nullifier.isEmpty());
|
|
321
420
|
meteredDAFields += numNullifiers;
|
|
322
|
-
|
|
421
|
+
const nullifierBaseGas = isPrivateOnlyTx ? L2_GAS_PER_NULLIFIER : AVM_EMITNULLIFIER_BASE_L2_GAS;
|
|
422
|
+
meteredL2Gas += numNullifiers * nullifierBaseGas;
|
|
323
423
|
const numL2toL1Messages = arrayNonEmptyLength(data.l2ToL1Msgs, (msg)=>msg.isEmpty());
|
|
324
424
|
meteredDAFields += numL2toL1Messages;
|
|
325
|
-
|
|
425
|
+
const l2ToL1MessageBaseGas = isPrivateOnlyTx ? L2_GAS_PER_L2_TO_L1_MSG : AVM_SENDL2TOL1MSG_BASE_L2_GAS;
|
|
426
|
+
meteredL2Gas += numL2toL1Messages * l2ToL1MessageBaseGas;
|
|
326
427
|
const numPrivatelogs = arrayNonEmptyLength(data.privateLogs, (log)=>log.isEmpty());
|
|
327
428
|
// Every private log emits its length as an additional field
|
|
328
429
|
meteredDAFields += data.privateLogs.reduce((acc, log)=>!log.isEmpty() ? acc + log.emittedLength + 1 : acc, 0);
|
|
@@ -331,7 +432,7 @@ function meterGasUsed(data) {
|
|
|
331
432
|
// Every contract class log emits its length and contract address as additional fields
|
|
332
433
|
meteredDAFields += data.contractClassLogsHashes.reduce((acc, log)=>!log.isEmpty() ? acc + log.logHash.length + 2 : acc, 0);
|
|
333
434
|
meteredL2Gas += numContractClassLogs * L2_GAS_PER_CONTRACT_CLASS_LOG;
|
|
334
|
-
const meteredDAGas = meteredDAFields *
|
|
435
|
+
const meteredDAGas = meteredDAFields * DA_GAS_PER_FIELD;
|
|
335
436
|
if (data.publicCallRequests) {
|
|
336
437
|
const dataForPublic = data;
|
|
337
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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ExtendedDirectionalAppTaggingSecret } 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
|
*/ export class ExecutionTaggingIndexCache {
|
|
@@ -19,7 +19,7 @@ import { DirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
|
|
|
19
19
|
* Returns the pre-tags that were used in this execution (and that need to be stored in the db).
|
|
20
20
|
*/ getUsedPreTags() {
|
|
21
21
|
return Array.from(this.taggingIndexMap.entries()).map(([secret, index])=>({
|
|
22
|
-
|
|
22
|
+
extendedSecret: ExtendedDirectionalAppTaggingSecret.fromString(secret),
|
|
23
23
|
index
|
|
24
24
|
}));
|
|
25
25
|
}
|
|
@@ -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 {
|
|
@@ -3,9 +3,9 @@ import { EventSelector } from '@aztec/stdlib/abi';
|
|
|
3
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import { TxHash } from '@aztec/stdlib/tx';
|
|
5
5
|
// TODO(#14617): should we compute this from constants? This value is aztec-nr specific.
|
|
6
|
-
const MAX_EVENT_SERIALIZED_LEN =
|
|
6
|
+
const MAX_EVENT_SERIALIZED_LEN = 11;
|
|
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;
|
|
@@ -2,9 +2,9 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
2
2
|
import { FieldReader } from '@aztec/foundation/serialize';
|
|
3
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import { TxHash } from '@aztec/stdlib/tx';
|
|
5
|
-
export declare const MAX_NOTE_PACKED_LEN =
|
|
5
|
+
export declare const MAX_NOTE_PACKED_LEN = 9;
|
|
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 {
|
|
@@ -21,4 +21,4 @@ export declare class NoteValidationRequest {
|
|
|
21
21
|
constructor(contractAddress: AztecAddress, owner: AztecAddress, storageSlot: Fr, randomness: Fr, noteNonce: Fr, content: Fr[], noteHash: Fr, nullifier: Fr, txHash: TxHash, recipient: AztecAddress);
|
|
22
22
|
static fromFields(fields: Fr[] | FieldReader): NoteValidationRequest;
|
|
23
23
|
}
|
|
24
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
24
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibm90ZV92YWxpZGF0aW9uX3JlcXVlc3QuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9jb250cmFjdF9mdW5jdGlvbl9zaW11bGF0b3Ivbm9pci1zdHJ1Y3RzL25vdGVfdmFsaWRhdGlvbl9yZXF1ZXN0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUNwRCxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFDMUQsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBQzNELE9BQU8sRUFBRSxNQUFNLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUcxQyxlQUFPLE1BQU0sbUJBQW1CLElBQUksQ0FBQztBQUVyQzs7O0dBR0c7QUFDSCxxQkFBYSxxQkFBcUI7SUFFdkIsZUFBZSxFQUFFLFlBQVk7SUFDN0IsS0FBSyxFQUFFLFlBQVk7SUFDbkIsV0FBVyxFQUFFLEVBQUU7SUFDZixVQUFVLEVBQUUsRUFBRTtJQUNkLFNBQVMsRUFBRSxFQUFFO0lBQ2IsT0FBTyxFQUFFLEVBQUUsRUFBRTtJQUNiLFFBQVEsRUFBRSxFQUFFO0lBQ1osU0FBUyxFQUFFLEVBQUU7SUFDYixNQUFNLEVBQUUsTUFBTTtJQUNkLFNBQVMsRUFBRSxZQUFZO0lBVmhDLFlBQ1MsZUFBZSxFQUFFLFlBQVksRUFDN0IsS0FBSyxFQUFFLFlBQVksRUFDbkIsV0FBVyxFQUFFLEVBQUUsRUFDZixVQUFVLEVBQUUsRUFBRSxFQUNkLFNBQVMsRUFBRSxFQUFFLEVBQ2IsT0FBTyxFQUFFLEVBQUUsRUFBRSxFQUNiLFFBQVEsRUFBRSxFQUFFLEVBQ1osU0FBUyxFQUFFLEVBQUUsRUFDYixNQUFNLEVBQUUsTUFBTSxFQUNkLFNBQVMsRUFBRSxZQUFZLEVBQzVCO0lBRUosTUFBTSxDQUFDLFVBQVUsQ0FBQyxNQUFNLEVBQUUsRUFBRSxFQUFFLEdBQUcsV0FBVyxHQUFHLHFCQUFxQixDQW9DbkU7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"note_validation_request.d.ts","sourceRoot":"","sources":["../../../src/contract_function_simulator/noir-structs/note_validation_request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG1C,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"note_validation_request.d.ts","sourceRoot":"","sources":["../../../src/contract_function_simulator/noir-structs/note_validation_request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG1C,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC;;;GAGG;AACH,qBAAa,qBAAqB;IAEvB,eAAe,EAAE,YAAY;IAC7B,KAAK,EAAE,YAAY;IACnB,WAAW,EAAE,EAAE;IACf,UAAU,EAAE,EAAE;IACd,SAAS,EAAE,EAAE;IACb,OAAO,EAAE,EAAE,EAAE;IACb,QAAQ,EAAE,EAAE;IACZ,SAAS,EAAE,EAAE;IACb,MAAM,EAAE,MAAM;IACd,SAAS,EAAE,YAAY;IAVhC,YACS,eAAe,EAAE,YAAY,EAC7B,KAAK,EAAE,YAAY,EACnB,WAAW,EAAE,EAAE,EACf,UAAU,EAAE,EAAE,EACd,SAAS,EAAE,EAAE,EACb,OAAO,EAAE,EAAE,EAAE,EACb,QAAQ,EAAE,EAAE,EACZ,SAAS,EAAE,EAAE,EACb,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,YAAY,EAC5B;IAEJ,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,WAAW,GAAG,qBAAqB,CAoCnE;CACF"}
|
|
@@ -2,9 +2,9 @@ import { FieldReader } from '@aztec/foundation/serialize';
|
|
|
2
2
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
3
|
import { TxHash } from '@aztec/stdlib/tx';
|
|
4
4
|
// TODO(#14617): should we compute this from constants? This value is aztec-nr specific.
|
|
5
|
-
export const MAX_NOTE_PACKED_LEN =
|
|
5
|
+
export const MAX_NOTE_PACKED_LEN = 9;
|
|
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;
|