@aztec/pxe 0.0.1-commit.d431d1c → 0.0.1-commit.e2b2873ed
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 +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/contract_function_simulator/contract_function_simulator.d.ts +50 -28
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +71 -40
- 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/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 +43 -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 +87 -23
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +61 -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 +108 -86
- package/dest/contract_sync/contract_sync_service.d.ts +42 -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 +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 +2 -1
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +1 -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 +6 -5
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +24 -28
- package/dest/notes/note_service.d.ts +6 -6
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +14 -14
- 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/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 +2 -2
- package/dest/private_kernel/private_kernel_oracle.d.ts +3 -3
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/pxe.d.ts +68 -23
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +78 -48
- 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 +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 +47 -50
- 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 +1 -1
- 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 +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +183 -113
- 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 +2 -2
- 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 +2 -2
- 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 +3 -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 +7 -4
- package/package.json +25 -16
- 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/contract_function_simulator/contract_function_simulator.ts +117 -87
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -1
- package/src/contract_function_simulator/oracle/interfaces.ts +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 +122 -101
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +170 -95
- package/src/contract_sync/contract_sync_service.ts +145 -0
- package/src/contract_sync/helpers.ts +93 -0
- package/src/debug/pxe_debug_utils.ts +61 -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 +1 -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 +35 -28
- package/src/notes/note_service.ts +21 -20
- package/src/oracle_version.ts +4 -3
- package/src/private_kernel/private_kernel_execution_prover.ts +6 -3
- package/src/private_kernel/private_kernel_oracle.ts +2 -2
- package/src/pxe.ts +178 -85
- 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 +26 -35
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/note_store.ts +317 -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 +31 -21
- package/src/storage/tagging_store/sender_address_book_store.ts +20 -14
- package/src/storage/tagging_store/sender_tagging_store.ts +210 -126
- 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 +11 -1
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +7 -1
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +3 -1
- 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 +12 -3
- 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
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
FIXED_AVM_STARTUP_L2_GAS,
|
|
8
8
|
FIXED_DA_GAS,
|
|
9
9
|
FIXED_L2_GAS,
|
|
10
|
+
GeneratorIndex,
|
|
10
11
|
L2_GAS_PER_CONTRACT_CLASS_LOG,
|
|
11
12
|
L2_GAS_PER_PRIVATE_LOG,
|
|
12
13
|
MAX_CONTRACT_CLASS_LOGS_PER_TX,
|
|
@@ -17,7 +18,7 @@ import {
|
|
|
17
18
|
MAX_PRIVATE_LOGS_PER_TX,
|
|
18
19
|
} from '@aztec/constants';
|
|
19
20
|
import { arrayNonEmptyLength, padArrayEnd } from '@aztec/foundation/collection';
|
|
20
|
-
import {
|
|
21
|
+
import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto/poseidon';
|
|
21
22
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
22
23
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
23
24
|
import { Timer } from '@aztec/foundation/timer';
|
|
@@ -71,8 +72,8 @@ import {
|
|
|
71
72
|
getFinalMinRevertibleSideEffectCounter,
|
|
72
73
|
} from '@aztec/stdlib/tx';
|
|
73
74
|
|
|
75
|
+
import type { ContractSyncService } from '../contract_sync/contract_sync_service.js';
|
|
74
76
|
import type { AddressStore } from '../storage/address_store/address_store.js';
|
|
75
|
-
import type { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
|
|
76
77
|
import type { CapsuleStore } from '../storage/capsule_store/capsule_store.js';
|
|
77
78
|
import type { ContractStore } from '../storage/contract_store/contract_store.js';
|
|
78
79
|
import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
@@ -85,65 +86,96 @@ import { ExecutionNoteCache } from './execution_note_cache.js';
|
|
|
85
86
|
import { ExecutionTaggingIndexCache } from './execution_tagging_index_cache.js';
|
|
86
87
|
import { HashedValuesCache } from './hashed_values_cache.js';
|
|
87
88
|
import { Oracle } from './oracle/oracle.js';
|
|
88
|
-
import { executePrivateFunction
|
|
89
|
+
import { executePrivateFunction } from './oracle/private_execution.js';
|
|
89
90
|
import { PrivateExecutionOracle } from './oracle/private_execution_oracle.js';
|
|
90
91
|
import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
|
|
91
92
|
|
|
93
|
+
/** Options for ContractFunctionSimulator.run. */
|
|
94
|
+
export type ContractSimulatorRunOpts = {
|
|
95
|
+
/** The address of the contract (should match request.origin). */
|
|
96
|
+
contractAddress: AztecAddress;
|
|
97
|
+
/** The function selector of the entry point. */
|
|
98
|
+
selector: FunctionSelector;
|
|
99
|
+
/** The address calling the function. Can be replaced to simulate a call from another contract or account. */
|
|
100
|
+
msgSender?: AztecAddress;
|
|
101
|
+
/** The block header to use as base state for this run. */
|
|
102
|
+
anchorBlockHeader: BlockHeader;
|
|
103
|
+
/** The address used as a tagging sender when emitting private logs. */
|
|
104
|
+
senderForTags?: AztecAddress;
|
|
105
|
+
/** The accounts whose notes we can access in this call. Defaults to all. */
|
|
106
|
+
scopes?: AztecAddress[];
|
|
107
|
+
/** The job ID for staged writes. */
|
|
108
|
+
jobId: string;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/** Args for ContractFunctionSimulator constructor. */
|
|
112
|
+
export type ContractFunctionSimulatorArgs = {
|
|
113
|
+
contractStore: ContractStore;
|
|
114
|
+
noteStore: NoteStore;
|
|
115
|
+
keyStore: KeyStore;
|
|
116
|
+
addressStore: AddressStore;
|
|
117
|
+
aztecNode: AztecNode;
|
|
118
|
+
senderTaggingStore: SenderTaggingStore;
|
|
119
|
+
recipientTaggingStore: RecipientTaggingStore;
|
|
120
|
+
senderAddressBookStore: SenderAddressBookStore;
|
|
121
|
+
capsuleStore: CapsuleStore;
|
|
122
|
+
privateEventStore: PrivateEventStore;
|
|
123
|
+
simulator: CircuitSimulator;
|
|
124
|
+
contractSyncService: ContractSyncService;
|
|
125
|
+
};
|
|
126
|
+
|
|
92
127
|
/**
|
|
93
128
|
* The contract function simulator.
|
|
94
129
|
*/
|
|
95
130
|
export class ContractFunctionSimulator {
|
|
96
|
-
private log: Logger;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
131
|
+
private readonly log: Logger;
|
|
132
|
+
private readonly contractStore: ContractStore;
|
|
133
|
+
private readonly noteStore: NoteStore;
|
|
134
|
+
private readonly keyStore: KeyStore;
|
|
135
|
+
private readonly addressStore: AddressStore;
|
|
136
|
+
private readonly aztecNode: AztecNode;
|
|
137
|
+
private readonly senderTaggingStore: SenderTaggingStore;
|
|
138
|
+
private readonly recipientTaggingStore: RecipientTaggingStore;
|
|
139
|
+
private readonly senderAddressBookStore: SenderAddressBookStore;
|
|
140
|
+
private readonly capsuleStore: CapsuleStore;
|
|
141
|
+
private readonly privateEventStore: PrivateEventStore;
|
|
142
|
+
private readonly simulator: CircuitSimulator;
|
|
143
|
+
private readonly contractSyncService: ContractSyncService;
|
|
144
|
+
|
|
145
|
+
constructor(args: ContractFunctionSimulatorArgs) {
|
|
146
|
+
this.contractStore = args.contractStore;
|
|
147
|
+
this.noteStore = args.noteStore;
|
|
148
|
+
this.keyStore = args.keyStore;
|
|
149
|
+
this.addressStore = args.addressStore;
|
|
150
|
+
this.aztecNode = args.aztecNode;
|
|
151
|
+
this.senderTaggingStore = args.senderTaggingStore;
|
|
152
|
+
this.recipientTaggingStore = args.recipientTaggingStore;
|
|
153
|
+
this.senderAddressBookStore = args.senderAddressBookStore;
|
|
154
|
+
this.capsuleStore = args.capsuleStore;
|
|
155
|
+
this.privateEventStore = args.privateEventStore;
|
|
156
|
+
this.simulator = args.simulator;
|
|
157
|
+
this.contractSyncService = args.contractSyncService;
|
|
112
158
|
this.log = createLogger('simulator');
|
|
113
159
|
}
|
|
114
160
|
|
|
115
161
|
/**
|
|
116
162
|
* Runs a private function.
|
|
117
163
|
* @param request - The transaction request.
|
|
118
|
-
* @param entryPointArtifact - The artifact of the entry point function.
|
|
119
|
-
* @param contractAddress - The address of the contract (should match request.origin)
|
|
120
|
-
* @param msgSender - The address calling the function. This can be replaced to simulate a call from another contract
|
|
121
|
-
* or a specific account.
|
|
122
|
-
* @param anchorBlockHeader - The block header to use as base state for this run.
|
|
123
|
-
* @param senderForTags - The address that is used as a tagging sender when emitting private logs. Returned from
|
|
124
|
-
* the `privateGetSenderForTags` oracle.
|
|
125
|
-
* @param scopes - The accounts whose notes we can access in this call. Currently optional and will default to all.
|
|
126
|
-
* @param jobId - The job ID for staged writes.
|
|
127
|
-
* @returns The result of the execution.
|
|
128
164
|
*/
|
|
129
165
|
public async run(
|
|
130
166
|
request: TxExecutionRequest,
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
167
|
+
{
|
|
168
|
+
contractAddress,
|
|
169
|
+
selector,
|
|
170
|
+
msgSender = AztecAddress.fromField(Fr.MAX_FIELD_VALUE),
|
|
171
|
+
anchorBlockHeader,
|
|
172
|
+
senderForTags,
|
|
173
|
+
scopes,
|
|
174
|
+
jobId,
|
|
175
|
+
}: ContractSimulatorRunOpts,
|
|
138
176
|
): Promise<PrivateExecutionResult> {
|
|
139
177
|
const simulatorSetupTimer = new Timer();
|
|
140
178
|
|
|
141
|
-
await this.contractStore.syncPrivateState(contractAddress, selector, privateSyncCall =>
|
|
142
|
-
this.runUtility(privateSyncCall, [], anchorBlockHeader, scopes, jobId),
|
|
143
|
-
);
|
|
144
|
-
|
|
145
|
-
await verifyCurrentClassId(contractAddress, this.aztecNode, this.contractStore, anchorBlockHeader);
|
|
146
|
-
|
|
147
179
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(contractAddress, selector);
|
|
148
180
|
|
|
149
181
|
if (entryPointArtifact.functionType !== FunctionType.PRIVATE) {
|
|
@@ -170,38 +202,37 @@ export class ContractFunctionSimulator {
|
|
|
170
202
|
const noteCache = new ExecutionNoteCache(protocolNullifier);
|
|
171
203
|
const taggingIndexCache = new ExecutionTaggingIndexCache();
|
|
172
204
|
|
|
173
|
-
const privateExecutionOracle = new PrivateExecutionOracle(
|
|
174
|
-
request.firstCallArgsHash,
|
|
175
|
-
request.txContext,
|
|
205
|
+
const privateExecutionOracle = new PrivateExecutionOracle({
|
|
206
|
+
argsHash: request.firstCallArgsHash,
|
|
207
|
+
txContext: request.txContext,
|
|
176
208
|
callContext,
|
|
177
209
|
anchorBlockHeader,
|
|
178
|
-
async call => {
|
|
179
|
-
await this.runUtility(call, [], anchorBlockHeader,
|
|
210
|
+
utilityExecutor: async (call, execScopes) => {
|
|
211
|
+
await this.runUtility(call, [], anchorBlockHeader, execScopes, jobId);
|
|
180
212
|
},
|
|
181
|
-
request.authWitnesses,
|
|
182
|
-
request.capsules,
|
|
183
|
-
HashedValuesCache.create(request.argsOfCalls),
|
|
213
|
+
authWitnesses: request.authWitnesses,
|
|
214
|
+
capsules: request.capsules,
|
|
215
|
+
executionCache: HashedValuesCache.create(request.argsOfCalls),
|
|
184
216
|
noteCache,
|
|
185
217
|
taggingIndexCache,
|
|
186
|
-
this.contractStore,
|
|
187
|
-
this.noteStore,
|
|
188
|
-
this.keyStore,
|
|
189
|
-
this.addressStore,
|
|
190
|
-
this.aztecNode,
|
|
191
|
-
this.
|
|
192
|
-
this.
|
|
193
|
-
this.
|
|
194
|
-
this.
|
|
195
|
-
this.
|
|
196
|
-
this.
|
|
218
|
+
contractStore: this.contractStore,
|
|
219
|
+
noteStore: this.noteStore,
|
|
220
|
+
keyStore: this.keyStore,
|
|
221
|
+
addressStore: this.addressStore,
|
|
222
|
+
aztecNode: this.aztecNode,
|
|
223
|
+
senderTaggingStore: this.senderTaggingStore,
|
|
224
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
225
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
226
|
+
capsuleStore: this.capsuleStore,
|
|
227
|
+
privateEventStore: this.privateEventStore,
|
|
228
|
+
contractSyncService: this.contractSyncService,
|
|
197
229
|
jobId,
|
|
198
|
-
0,
|
|
199
|
-
startSideEffectCounter,
|
|
200
|
-
undefined, // log
|
|
230
|
+
totalPublicCalldataCount: 0,
|
|
231
|
+
sideEffectCounter: startSideEffectCounter,
|
|
201
232
|
scopes,
|
|
202
233
|
senderForTags,
|
|
203
|
-
this.simulator,
|
|
204
|
-
);
|
|
234
|
+
simulator: this.simulator,
|
|
235
|
+
});
|
|
205
236
|
|
|
206
237
|
const setupTime = simulatorSetupTimer.ms();
|
|
207
238
|
|
|
@@ -268,33 +299,29 @@ export class ContractFunctionSimulator {
|
|
|
268
299
|
scopes: AztecAddress[] | undefined,
|
|
269
300
|
jobId: string,
|
|
270
301
|
): Promise<Fr[]> {
|
|
271
|
-
await verifyCurrentClassId(call.to, this.aztecNode, this.contractStore, anchorBlockHeader);
|
|
272
|
-
|
|
273
302
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
274
303
|
|
|
275
304
|
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
276
305
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
277
306
|
}
|
|
278
307
|
|
|
279
|
-
const oracle = new UtilityExecutionOracle(
|
|
280
|
-
call.to,
|
|
281
|
-
authwits,
|
|
282
|
-
[],
|
|
308
|
+
const oracle = new UtilityExecutionOracle({
|
|
309
|
+
contractAddress: call.to,
|
|
310
|
+
authWitnesses: authwits,
|
|
311
|
+
capsules: [],
|
|
283
312
|
anchorBlockHeader,
|
|
284
|
-
this.contractStore,
|
|
285
|
-
this.noteStore,
|
|
286
|
-
this.keyStore,
|
|
287
|
-
this.addressStore,
|
|
288
|
-
this.aztecNode,
|
|
289
|
-
this.
|
|
290
|
-
this.
|
|
291
|
-
this.
|
|
292
|
-
this.
|
|
293
|
-
this.privateEventStore,
|
|
313
|
+
contractStore: this.contractStore,
|
|
314
|
+
noteStore: this.noteStore,
|
|
315
|
+
keyStore: this.keyStore,
|
|
316
|
+
addressStore: this.addressStore,
|
|
317
|
+
aztecNode: this.aztecNode,
|
|
318
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
319
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
320
|
+
capsuleStore: this.capsuleStore,
|
|
321
|
+
privateEventStore: this.privateEventStore,
|
|
294
322
|
jobId,
|
|
295
|
-
undefined,
|
|
296
323
|
scopes,
|
|
297
|
-
);
|
|
324
|
+
});
|
|
298
325
|
|
|
299
326
|
try {
|
|
300
327
|
this.log.verbose(`Executing utility function ${entryPointArtifact.name}`, {
|
|
@@ -367,7 +394,7 @@ class OrderedSideEffect<T> {
|
|
|
367
394
|
*/
|
|
368
395
|
export async function generateSimulatedProvingResult(
|
|
369
396
|
privateExecutionResult: PrivateExecutionResult,
|
|
370
|
-
|
|
397
|
+
debugFunctionNameGetter: (contractAddress: AztecAddress, functionSelector: FunctionSelector) => Promise<string>,
|
|
371
398
|
minRevertibleSideEffectCounterOverride?: number,
|
|
372
399
|
): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>> {
|
|
373
400
|
const siloedNoteHashes: OrderedSideEffect<Fr>[] = [];
|
|
@@ -409,7 +436,10 @@ export async function generateSimulatedProvingResult(
|
|
|
409
436
|
|
|
410
437
|
const privateLogsFromExecution = await Promise.all(
|
|
411
438
|
execution.publicInputs.privateLogs.getActiveItems().map(async metadata => {
|
|
412
|
-
metadata.log.fields[0] = await
|
|
439
|
+
metadata.log.fields[0] = await poseidon2HashWithSeparator(
|
|
440
|
+
[contractAddress, metadata.log.fields[0]],
|
|
441
|
+
GeneratorIndex.PRIVATE_LOG_FIRST_FIELD,
|
|
442
|
+
);
|
|
413
443
|
return new OrderedSideEffect(metadata.log, metadata.counter);
|
|
414
444
|
}),
|
|
415
445
|
);
|
|
@@ -445,7 +475,7 @@ export async function generateSimulatedProvingResult(
|
|
|
445
475
|
: execution.publicInputs.publicTeardownCallRequest;
|
|
446
476
|
|
|
447
477
|
executionSteps.push({
|
|
448
|
-
functionName: await
|
|
478
|
+
functionName: await debugFunctionNameGetter(
|
|
449
479
|
execution.publicInputs.callContext.contractAddress,
|
|
450
480
|
execution.publicInputs.callContext.functionSelector,
|
|
451
481
|
),
|
|
@@ -8,7 +8,7 @@ import { TxHash } from '@aztec/stdlib/tx';
|
|
|
8
8
|
const MAX_EVENT_SERIALIZED_LEN = 12;
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* Intermediate struct used to perform batch event validation by PXE. The `
|
|
11
|
+
* Intermediate struct used to perform batch event validation by PXE. The `utilityValidateAndStoreEnqueuedNotesAndEvents` oracle
|
|
12
12
|
* expects for values of this type to be stored in a `CapsuleArray`.
|
|
13
13
|
*/
|
|
14
14
|
export class EventValidationRequest {
|
|
@@ -7,7 +7,7 @@ import { TxHash } from '@aztec/stdlib/tx';
|
|
|
7
7
|
export const MAX_NOTE_PACKED_LEN = 10;
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* Intermediate struct used to perform batch note validation by PXE. The `
|
|
10
|
+
* Intermediate struct used to perform batch note validation by PXE. The `utilityValidateAndStoreEnqueuedNotesAndEvents` oracle
|
|
11
11
|
* expects for values of this type to be stored in a `CapsuleArray`.
|
|
12
12
|
*/
|
|
13
13
|
export class NoteValidationRequest {
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import type { L1_TO_L2_MSG_TREE_HEIGHT } from '@aztec/constants';
|
|
1
|
+
import type { ARCHIVE_HEIGHT, L1_TO_L2_MSG_TREE_HEIGHT, NOTE_HASH_TREE_HEIGHT } from '@aztec/constants';
|
|
2
2
|
import type { BlockNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
4
|
import { Point } from '@aztec/foundation/curves/grumpkin';
|
|
5
|
+
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
5
6
|
import type { FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
|
|
6
7
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
|
-
import {
|
|
8
|
+
import { BlockHash } from '@aztec/stdlib/block';
|
|
8
9
|
import type { CompleteAddress, ContractInstance } from '@aztec/stdlib/contract';
|
|
9
10
|
import type { KeyValidationRequest } from '@aztec/stdlib/kernel';
|
|
10
11
|
import type { ContractClassLog, Tag } from '@aztec/stdlib/logs';
|
|
11
12
|
import type { Note, NoteStatus } from '@aztec/stdlib/note';
|
|
12
|
-
import { type
|
|
13
|
+
import { type NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
13
14
|
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
14
15
|
|
|
15
16
|
import type { UtilityContext } from '../noir-structs/utility_context.js';
|
|
@@ -53,7 +54,7 @@ export interface IMiscOracle {
|
|
|
53
54
|
|
|
54
55
|
utilityGetRandomField(): Fr;
|
|
55
56
|
utilityAssertCompatibleOracleVersion(version: number): void;
|
|
56
|
-
|
|
57
|
+
utilityLog(level: number, message: string, fields: Fr[]): Promise<void>;
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
/**
|
|
@@ -66,18 +67,25 @@ export interface IUtilityExecutionOracle {
|
|
|
66
67
|
utilityGetUtilityContext(): UtilityContext;
|
|
67
68
|
utilityGetKeyValidationRequest(pkMHash: Fr): Promise<KeyValidationRequest>;
|
|
68
69
|
utilityGetContractInstance(address: AztecAddress): Promise<ContractInstance>;
|
|
69
|
-
|
|
70
|
+
utilityGetNoteHashMembershipWitness(
|
|
71
|
+
anchorBlockHash: BlockHash,
|
|
72
|
+
noteHash: Fr,
|
|
73
|
+
): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined>;
|
|
74
|
+
utilityGetBlockHashMembershipWitness(
|
|
75
|
+
anchorBlockHash: BlockHash,
|
|
76
|
+
blockHash: BlockHash,
|
|
77
|
+
): Promise<MembershipWitness<typeof ARCHIVE_HEIGHT> | undefined>;
|
|
70
78
|
utilityGetNullifierMembershipWitness(
|
|
71
|
-
|
|
79
|
+
anchorBlockHash: BlockHash,
|
|
72
80
|
nullifier: Fr,
|
|
73
81
|
): Promise<NullifierMembershipWitness | undefined>;
|
|
74
|
-
utilityGetPublicDataWitness(
|
|
82
|
+
utilityGetPublicDataWitness(anchorBlockHash: BlockHash, leafSlot: Fr): Promise<PublicDataWitness | undefined>;
|
|
75
83
|
utilityGetLowNullifierMembershipWitness(
|
|
76
|
-
|
|
84
|
+
anchorBlockHash: BlockHash,
|
|
77
85
|
nullifier: Fr,
|
|
78
86
|
): Promise<NullifierMembershipWitness | undefined>;
|
|
79
87
|
utilityGetBlockHeader(blockNumber: BlockNumber): Promise<BlockHeader | undefined>;
|
|
80
|
-
|
|
88
|
+
utilityTryGetPublicKeysAndPartialAddress(account: AztecAddress): Promise<CompleteAddress | undefined>;
|
|
81
89
|
utilityGetAuthWitness(messageHash: Fr): Promise<Fr[] | undefined>;
|
|
82
90
|
utilityGetNotes(
|
|
83
91
|
owner: AztecAddress | undefined,
|
|
@@ -103,13 +111,13 @@ export interface IUtilityExecutionOracle {
|
|
|
103
111
|
secret: Fr,
|
|
104
112
|
): Promise<MessageLoadOracleInputs<typeof L1_TO_L2_MSG_TREE_HEIGHT>>;
|
|
105
113
|
utilityStorageRead(
|
|
106
|
-
|
|
114
|
+
anchorBlockHash: BlockHash,
|
|
107
115
|
contractAddress: AztecAddress,
|
|
108
116
|
startStorageSlot: Fr,
|
|
109
117
|
numberOfElements: number,
|
|
110
118
|
): Promise<Fr[]>;
|
|
111
119
|
utilityFetchTaggedLogs(pendingTaggedLogArrayBaseSlot: Fr): Promise<void>;
|
|
112
|
-
|
|
120
|
+
utilityValidateAndStoreEnqueuedNotesAndEvents(
|
|
113
121
|
contractAddress: AztecAddress,
|
|
114
122
|
noteValidationRequestsArrayBaseSlot: Fr,
|
|
115
123
|
eventValidationRequestsArrayBaseSlot: Fr,
|
|
@@ -147,6 +155,7 @@ export interface IPrivateExecutionOracle {
|
|
|
147
155
|
): void;
|
|
148
156
|
privateNotifyNullifiedNote(innerNullifier: Fr, noteHash: Fr, counter: number): Promise<void>;
|
|
149
157
|
privateNotifyCreatedNullifier(innerNullifier: Fr): Promise<void>;
|
|
158
|
+
privateIsNullifierPending(innerNullifier: Fr, contractAddress: AztecAddress): Promise<boolean>;
|
|
150
159
|
privateNotifyCreatedContractClassLog(log: ContractClassLog, counter: number): void;
|
|
151
160
|
privateCallPrivateFunction(
|
|
152
161
|
targetContractAddress: AztecAddress,
|
|
@@ -12,9 +12,8 @@ import {
|
|
|
12
12
|
} from '@aztec/simulator/client';
|
|
13
13
|
import { FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
|
|
14
14
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
15
|
-
import {
|
|
15
|
+
import { BlockHash } from '@aztec/stdlib/block';
|
|
16
16
|
import { ContractClassLog, ContractClassLogFields } from '@aztec/stdlib/logs';
|
|
17
|
-
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
18
17
|
|
|
19
18
|
import type { IMiscOracle, IPrivateExecutionOracle, IUtilityExecutionOracle } from './interfaces.js';
|
|
20
19
|
import { packAsHintedNote } from './note_packing_utils.js';
|
|
@@ -138,33 +137,49 @@ export class Oracle {
|
|
|
138
137
|
].map(toACVMField);
|
|
139
138
|
}
|
|
140
139
|
|
|
141
|
-
async
|
|
140
|
+
async utilityGetNoteHashMembershipWitness(
|
|
141
|
+
[anchorBlockHash]: ACVMField[],
|
|
142
|
+
[noteHash]: ACVMField[],
|
|
143
|
+
): Promise<(ACVMField | ACVMField[])[]> {
|
|
144
|
+
const parsedAnchorBlockHash = BlockHash.fromString(anchorBlockHash);
|
|
145
|
+
const parsedNoteHash = Fr.fromString(noteHash);
|
|
146
|
+
|
|
147
|
+
const witness = await this.handlerAsUtility().utilityGetNoteHashMembershipWitness(
|
|
148
|
+
parsedAnchorBlockHash,
|
|
149
|
+
parsedNoteHash,
|
|
150
|
+
);
|
|
151
|
+
if (!witness) {
|
|
152
|
+
throw new Error(
|
|
153
|
+
`Note hash ${noteHash} not found in the note hash tree at anchor block hash ${parsedAnchorBlockHash.toString()}.`,
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
return witness.toNoirRepresentation();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
async utilityGetBlockHashMembershipWitness(
|
|
160
|
+
[anchorBlockHash]: ACVMField[],
|
|
142
161
|
[blockHash]: ACVMField[],
|
|
143
|
-
[treeId]: ACVMField[],
|
|
144
|
-
[leafValue]: ACVMField[],
|
|
145
162
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
146
|
-
const
|
|
147
|
-
const
|
|
148
|
-
const parsedLeafValue = Fr.fromString(leafValue);
|
|
163
|
+
const parsedAnchorBlockHash = BlockHash.fromString(anchorBlockHash);
|
|
164
|
+
const parsedBlockHash = BlockHash.fromString(blockHash);
|
|
149
165
|
|
|
150
|
-
const witness = await this.handlerAsUtility().
|
|
166
|
+
const witness = await this.handlerAsUtility().utilityGetBlockHashMembershipWitness(
|
|
167
|
+
parsedAnchorBlockHash,
|
|
151
168
|
parsedBlockHash,
|
|
152
|
-
parsedTreeId,
|
|
153
|
-
parsedLeafValue,
|
|
154
169
|
);
|
|
155
170
|
if (!witness) {
|
|
156
171
|
throw new Error(
|
|
157
|
-
`
|
|
172
|
+
`Block hash ${parsedBlockHash.toString()} not found in the archive tree at anchor block ${parsedAnchorBlockHash.toString()}.`,
|
|
158
173
|
);
|
|
159
174
|
}
|
|
160
|
-
return
|
|
175
|
+
return witness.toNoirRepresentation();
|
|
161
176
|
}
|
|
162
177
|
|
|
163
178
|
async utilityGetNullifierMembershipWitness(
|
|
164
179
|
[blockHash]: ACVMField[],
|
|
165
180
|
[nullifier]: ACVMField[], // nullifier, we try to find the witness for (to prove inclusion)
|
|
166
181
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
167
|
-
const parsedBlockHash =
|
|
182
|
+
const parsedBlockHash = BlockHash.fromString(blockHash);
|
|
168
183
|
const parsedNullifier = Fr.fromString(nullifier);
|
|
169
184
|
|
|
170
185
|
const witness = await this.handlerAsUtility().utilityGetNullifierMembershipWitness(
|
|
@@ -183,7 +198,7 @@ export class Oracle {
|
|
|
183
198
|
[blockHash]: ACVMField[],
|
|
184
199
|
[nullifier]: ACVMField[], // nullifier, we try to find the low nullifier witness for (to prove non-inclusion)
|
|
185
200
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
186
|
-
const parsedBlockHash =
|
|
201
|
+
const parsedBlockHash = BlockHash.fromString(blockHash);
|
|
187
202
|
const parsedNullifier = Fr.fromString(nullifier);
|
|
188
203
|
|
|
189
204
|
const witness = await this.handlerAsUtility().utilityGetLowNullifierMembershipWitness(
|
|
@@ -202,7 +217,7 @@ export class Oracle {
|
|
|
202
217
|
[blockHash]: ACVMField[],
|
|
203
218
|
[leafSlot]: ACVMField[],
|
|
204
219
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
205
|
-
const parsedBlockHash =
|
|
220
|
+
const parsedBlockHash = BlockHash.fromString(blockHash);
|
|
206
221
|
const parsedLeafSlot = Fr.fromString(leafSlot);
|
|
207
222
|
|
|
208
223
|
const witness = await this.handlerAsUtility().utilityGetPublicDataWitness(parsedBlockHash, parsedLeafSlot);
|
|
@@ -233,12 +248,19 @@ export class Oracle {
|
|
|
233
248
|
return [witness.map(toACVMField)];
|
|
234
249
|
}
|
|
235
250
|
|
|
236
|
-
async
|
|
251
|
+
async utilityTryGetPublicKeysAndPartialAddress([address]: ACVMField[]): Promise<(ACVMField | ACVMField[])[]> {
|
|
237
252
|
const parsedAddress = AztecAddress.fromField(Fr.fromString(address));
|
|
238
|
-
const
|
|
239
|
-
await this.handlerAsUtility().utilityGetPublicKeysAndPartialAddress(parsedAddress);
|
|
253
|
+
const result = await this.handlerAsUtility().utilityTryGetPublicKeysAndPartialAddress(parsedAddress);
|
|
240
254
|
|
|
241
|
-
return
|
|
255
|
+
// We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
|
|
256
|
+
// with two fields: `some` (a boolean) and `value` (a field array in this case).
|
|
257
|
+
if (result === undefined) {
|
|
258
|
+
// No data was found so we set `some` to 0 and pad `value` with zeros get the correct return size.
|
|
259
|
+
return [toACVMField(0), Array(13).fill(toACVMField(0))];
|
|
260
|
+
} else {
|
|
261
|
+
// Data was found so we set `some` to 1 and return it along with `value`.
|
|
262
|
+
return [toACVMField(1), [...result.publicKeys.toFields(), result.partialAddress].map(toACVMField)];
|
|
263
|
+
}
|
|
242
264
|
}
|
|
243
265
|
|
|
244
266
|
async utilityGetNotes(
|
|
@@ -341,6 +363,14 @@ export class Oracle {
|
|
|
341
363
|
return [];
|
|
342
364
|
}
|
|
343
365
|
|
|
366
|
+
async privateIsNullifierPending([innerNullifier]: ACVMField[], [contractAddress]: ACVMField[]): Promise<ACVMField[]> {
|
|
367
|
+
const isPending = await this.handlerAsPrivate().privateIsNullifierPending(
|
|
368
|
+
Fr.fromString(innerNullifier),
|
|
369
|
+
AztecAddress.fromString(contractAddress),
|
|
370
|
+
);
|
|
371
|
+
return [toACVMField(isPending)];
|
|
372
|
+
}
|
|
373
|
+
|
|
344
374
|
async utilityCheckNullifierExists([innerNullifier]: ACVMField[]): Promise<ACVMField[]> {
|
|
345
375
|
const exists = await this.handlerAsUtility().utilityCheckNullifierExists(Fr.fromString(innerNullifier));
|
|
346
376
|
return [toACVMField(exists)];
|
|
@@ -366,7 +396,7 @@ export class Oracle {
|
|
|
366
396
|
[numberOfElements]: ACVMField[],
|
|
367
397
|
): Promise<ACVMField[][]> {
|
|
368
398
|
const values = await this.handlerAsUtility().utilityStorageRead(
|
|
369
|
-
|
|
399
|
+
BlockHash.fromString(blockHash),
|
|
370
400
|
new AztecAddress(Fr.fromString(contractAddress)),
|
|
371
401
|
Fr.fromString(startStorageSlot),
|
|
372
402
|
+numberOfElements,
|
|
@@ -387,7 +417,7 @@ export class Oracle {
|
|
|
387
417
|
return Promise.resolve([]);
|
|
388
418
|
}
|
|
389
419
|
|
|
390
|
-
|
|
420
|
+
async utilityLog(
|
|
391
421
|
level: ACVMField[],
|
|
392
422
|
message: ACVMField[],
|
|
393
423
|
_ignoredFieldsSize: ACVMField[],
|
|
@@ -396,8 +426,8 @@ export class Oracle {
|
|
|
396
426
|
const levelFr = Fr.fromString(level[0]);
|
|
397
427
|
const messageStr = message.map(acvmField => String.fromCharCode(Fr.fromString(acvmField).toNumber())).join('');
|
|
398
428
|
const fieldsFr = fields.map(Fr.fromString);
|
|
399
|
-
this.handlerAsMisc().
|
|
400
|
-
return
|
|
429
|
+
await this.handlerAsMisc().utilityLog(levelFr.toNumber(), messageStr, fieldsFr);
|
|
430
|
+
return [];
|
|
401
431
|
}
|
|
402
432
|
|
|
403
433
|
// This function's name is directly hardcoded in `circuit_recorder.ts`. Don't forget to update it there if you
|
|
@@ -478,12 +508,12 @@ export class Oracle {
|
|
|
478
508
|
return [];
|
|
479
509
|
}
|
|
480
510
|
|
|
481
|
-
async
|
|
511
|
+
async utilityValidateAndStoreEnqueuedNotesAndEvents(
|
|
482
512
|
[contractAddress]: ACVMField[],
|
|
483
513
|
[noteValidationRequestsArrayBaseSlot]: ACVMField[],
|
|
484
514
|
[eventValidationRequestsArrayBaseSlot]: ACVMField[],
|
|
485
515
|
): Promise<ACVMField[]> {
|
|
486
|
-
await this.handlerAsUtility().
|
|
516
|
+
await this.handlerAsUtility().utilityValidateAndStoreEnqueuedNotesAndEvents(
|
|
487
517
|
AztecAddress.fromString(contractAddress),
|
|
488
518
|
Fr.fromString(noteValidationRequestsArrayBaseSlot),
|
|
489
519
|
Fr.fromString(eventValidationRequestsArrayBaseSlot),
|
|
@@ -2,7 +2,6 @@ import { PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH, PRIVATE_CONTEXT_INPUTS_LENGTH } f
|
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { Timer } from '@aztec/foundation/timer';
|
|
5
|
-
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
6
5
|
import {
|
|
7
6
|
type ACVMWitness,
|
|
8
7
|
type CircuitSimulator,
|
|
@@ -18,15 +17,10 @@ import {
|
|
|
18
17
|
countArgumentsSize,
|
|
19
18
|
} from '@aztec/stdlib/abi';
|
|
20
19
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
21
|
-
import { L2BlockHash } from '@aztec/stdlib/block';
|
|
22
|
-
import type { ContractInstance } from '@aztec/stdlib/contract';
|
|
23
|
-
import { DelayedPublicMutableValues, DelayedPublicMutableValuesWithHash } from '@aztec/stdlib/delayed-public-mutable';
|
|
24
|
-
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
25
20
|
import { PrivateCircuitPublicInputs } from '@aztec/stdlib/kernel';
|
|
26
21
|
import type { CircuitWitnessGenerationStats } from '@aztec/stdlib/stats';
|
|
27
|
-
import {
|
|
22
|
+
import { PrivateCallExecutionResult } from '@aztec/stdlib/tx';
|
|
28
23
|
|
|
29
|
-
import { ContractStore } from '../../storage/contract_store/index.js';
|
|
30
24
|
import { Oracle } from './oracle.js';
|
|
31
25
|
import type { PrivateExecutionOracle } from './private_execution_oracle.js';
|
|
32
26
|
|
|
@@ -145,56 +139,3 @@ export function extractPrivateCircuitPublicInputs(
|
|
|
145
139
|
}
|
|
146
140
|
return PrivateCircuitPublicInputs.fromFields(returnData);
|
|
147
141
|
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Read the current class id of a contract from the execution data provider or AztecNode. If not found, class id
|
|
151
|
-
* from the instance is used.
|
|
152
|
-
* @param contractAddress - The address of the contract to read the class id for.
|
|
153
|
-
* @param instance - The instance of the contract.
|
|
154
|
-
* @param aztecNode - The Aztec node to query for storage.
|
|
155
|
-
* @param header - The header of the block at which to load the DelayedPublicMutable storing the class id.
|
|
156
|
-
* @returns The current class id.
|
|
157
|
-
*/
|
|
158
|
-
export async function readCurrentClassId(
|
|
159
|
-
contractAddress: AztecAddress,
|
|
160
|
-
instance: ContractInstance,
|
|
161
|
-
aztecNode: AztecNode,
|
|
162
|
-
header: BlockHeader,
|
|
163
|
-
) {
|
|
164
|
-
const blockHashFr = await header.hash();
|
|
165
|
-
const blockHash = L2BlockHash.fromField(blockHashFr);
|
|
166
|
-
const timestamp = header.globalVariables.timestamp;
|
|
167
|
-
const { delayedPublicMutableSlot } = await DelayedPublicMutableValuesWithHash.getContractUpdateSlots(contractAddress);
|
|
168
|
-
const delayedPublicMutableValues = await DelayedPublicMutableValues.readFromTree(delayedPublicMutableSlot, slot =>
|
|
169
|
-
aztecNode.getPublicStorageAt(blockHash, ProtocolContractAddress.ContractInstanceRegistry, slot),
|
|
170
|
-
);
|
|
171
|
-
let currentClassId = delayedPublicMutableValues.svc.getCurrentAt(timestamp)[0];
|
|
172
|
-
if (currentClassId.isZero()) {
|
|
173
|
-
currentClassId = instance.originalContractClassId;
|
|
174
|
-
}
|
|
175
|
-
return currentClassId;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Verify that the current class id of a contract obtained from AztecNode is the same as the one in contract data
|
|
180
|
-
* provider (i.e. PXE's own storage).
|
|
181
|
-
* @param header - The header of the block at which to verify the current class id.
|
|
182
|
-
*/
|
|
183
|
-
export async function verifyCurrentClassId(
|
|
184
|
-
contractAddress: AztecAddress,
|
|
185
|
-
aztecNode: AztecNode,
|
|
186
|
-
contractStore: ContractStore,
|
|
187
|
-
header: BlockHeader,
|
|
188
|
-
) {
|
|
189
|
-
const instance = await contractStore.getContractInstance(contractAddress);
|
|
190
|
-
if (!instance) {
|
|
191
|
-
throw new Error(`No contract instance found for address ${contractAddress.toString()}`);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
const currentClassId = await readCurrentClassId(contractAddress, instance, aztecNode, header);
|
|
195
|
-
if (!instance.currentContractClassId.equals(currentClassId)) {
|
|
196
|
-
throw new Error(
|
|
197
|
-
`Contract ${contractAddress} is outdated, current class id is ${currentClassId}, local class id is ${instance.currentContractClassId}`,
|
|
198
|
-
);
|
|
199
|
-
}
|
|
200
|
-
}
|