@aztec/pxe 0.0.1-commit.d1f2d6c → 0.0.1-commit.e61ad554
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/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 +2 -2
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.d.ts +2 -2
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +2 -2
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +3 -22
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +0 -46
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +3 -4
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +2 -2
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +3 -3
- package/dest/contract_sync/index.d.ts +23 -0
- package/dest/contract_sync/index.d.ts.map +1 -0
- package/dest/contract_sync/index.js +54 -0
- package/dest/debug/pxe_debug_utils.js +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/events/event_service.d.ts +2 -2
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +1 -1
- package/dest/logs/log_service.d.ts +1 -1
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +3 -4
- package/dest/notes/note_service.d.ts +2 -2
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +3 -4
- package/dest/oracle_version.d.ts +2 -2
- package/dest/oracle_version.js +2 -2
- package/dest/pxe.d.ts +1 -1
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +2 -3
- package/dest/storage/contract_store/contract_store.d.ts +1 -2
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +0 -12
- package/dest/storage/note_store/note_store.d.ts +1 -1
- package/dest/storage/note_store/note_store.js +2 -2
- package/package.json +16 -16
- package/src/bin/check_oracle_version.ts +1 -0
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -1
- package/src/contract_function_simulator/oracle/interfaces.ts +1 -1
- package/src/contract_function_simulator/oracle/oracle.ts +2 -2
- package/src/contract_function_simulator/oracle/private_execution.ts +1 -79
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +3 -4
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +3 -3
- package/src/contract_sync/index.ts +98 -0
- package/src/debug/pxe_debug_utils.ts +1 -1
- package/src/entrypoints/server/index.ts +1 -0
- package/src/events/event_service.ts +1 -1
- package/src/logs/log_service.ts +3 -4
- package/src/notes/note_service.ts +3 -4
- package/src/oracle_version.ts +2 -2
- package/src/pxe.ts +2 -3
- package/src/storage/contract_store/contract_store.ts +0 -20
- package/src/storage/note_store/note_store.ts +2 -2
|
@@ -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,
|
|
@@ -14,20 +13,14 @@ import {
|
|
|
14
13
|
import {
|
|
15
14
|
type FunctionArtifact,
|
|
16
15
|
type FunctionArtifactWithContractName,
|
|
17
|
-
type FunctionCall,
|
|
18
16
|
type FunctionSelector,
|
|
19
17
|
countArgumentsSize,
|
|
20
18
|
} from '@aztec/stdlib/abi';
|
|
21
19
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
22
|
-
import { L2BlockHash } from '@aztec/stdlib/block';
|
|
23
|
-
import type { ContractInstance } from '@aztec/stdlib/contract';
|
|
24
|
-
import { DelayedPublicMutableValues, DelayedPublicMutableValuesWithHash } from '@aztec/stdlib/delayed-public-mutable';
|
|
25
|
-
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
26
20
|
import { PrivateCircuitPublicInputs } from '@aztec/stdlib/kernel';
|
|
27
21
|
import type { CircuitWitnessGenerationStats } from '@aztec/stdlib/stats';
|
|
28
|
-
import {
|
|
22
|
+
import { PrivateCallExecutionResult } from '@aztec/stdlib/tx';
|
|
29
23
|
|
|
30
|
-
import { ContractStore } from '../../storage/contract_store/index.js';
|
|
31
24
|
import { Oracle } from './oracle.js';
|
|
32
25
|
import type { PrivateExecutionOracle } from './private_execution_oracle.js';
|
|
33
26
|
|
|
@@ -146,74 +139,3 @@ export function extractPrivateCircuitPublicInputs(
|
|
|
146
139
|
}
|
|
147
140
|
return PrivateCircuitPublicInputs.fromFields(returnData);
|
|
148
141
|
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Read the current class id of a contract from the execution data provider or AztecNode. If not found, class id
|
|
152
|
-
* from the instance is used.
|
|
153
|
-
* @param contractAddress - The address of the contract to read the class id for.
|
|
154
|
-
* @param instance - The instance of the contract.
|
|
155
|
-
* @param aztecNode - The Aztec node to query for storage.
|
|
156
|
-
* @param header - The header of the block at which to load the DelayedPublicMutable storing the class id.
|
|
157
|
-
* @returns The current class id.
|
|
158
|
-
*/
|
|
159
|
-
export async function readCurrentClassId(
|
|
160
|
-
contractAddress: AztecAddress,
|
|
161
|
-
instance: ContractInstance,
|
|
162
|
-
aztecNode: AztecNode,
|
|
163
|
-
header: BlockHeader,
|
|
164
|
-
) {
|
|
165
|
-
const blockHashFr = await header.hash();
|
|
166
|
-
const blockHash = L2BlockHash.fromField(blockHashFr);
|
|
167
|
-
const timestamp = header.globalVariables.timestamp;
|
|
168
|
-
const { delayedPublicMutableSlot } = await DelayedPublicMutableValuesWithHash.getContractUpdateSlots(contractAddress);
|
|
169
|
-
const delayedPublicMutableValues = await DelayedPublicMutableValues.readFromTree(delayedPublicMutableSlot, slot =>
|
|
170
|
-
aztecNode.getPublicStorageAt(blockHash, ProtocolContractAddress.ContractInstanceRegistry, slot),
|
|
171
|
-
);
|
|
172
|
-
let currentClassId = delayedPublicMutableValues.svc.getCurrentAt(timestamp)[0];
|
|
173
|
-
if (currentClassId.isZero()) {
|
|
174
|
-
currentClassId = instance.originalContractClassId;
|
|
175
|
-
}
|
|
176
|
-
return currentClassId;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Verify that the current class id of a contract obtained from AztecNode is the same as the one in contract data
|
|
181
|
-
* provider (i.e. PXE's own storage).
|
|
182
|
-
* @param header - The header of the block at which to verify the current class id.
|
|
183
|
-
*/
|
|
184
|
-
async function verifyCurrentClassId(
|
|
185
|
-
contractAddress: AztecAddress,
|
|
186
|
-
aztecNode: AztecNode,
|
|
187
|
-
contractStore: ContractStore,
|
|
188
|
-
header: BlockHeader,
|
|
189
|
-
) {
|
|
190
|
-
const instance = await contractStore.getContractInstance(contractAddress);
|
|
191
|
-
if (!instance) {
|
|
192
|
-
throw new Error(`No contract instance found for address ${contractAddress.toString()}`);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
const currentClassId = await readCurrentClassId(contractAddress, instance, aztecNode, header);
|
|
196
|
-
if (!instance.currentContractClassId.equals(currentClassId)) {
|
|
197
|
-
throw new Error(
|
|
198
|
-
`Contract ${contractAddress} is outdated, current class id is ${currentClassId}, local class id is ${instance.currentContractClassId}`,
|
|
199
|
-
);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Ensures the contract's private state is synchronized and that the PXE holds the current class artifact for
|
|
205
|
-
* the contract.
|
|
206
|
-
*/
|
|
207
|
-
export async function ensureContractSynced(
|
|
208
|
-
contractAddress: AztecAddress,
|
|
209
|
-
functionToInvokeAfterSync: FunctionSelector | null,
|
|
210
|
-
utilityExecutor: (call: FunctionCall) => Promise<any>,
|
|
211
|
-
aztecNode: AztecNode,
|
|
212
|
-
contractStore: ContractStore,
|
|
213
|
-
header: BlockHeader,
|
|
214
|
-
): Promise<void> {
|
|
215
|
-
await Promise.all([
|
|
216
|
-
contractStore.syncPrivateState(contractAddress, functionToInvokeAfterSync, utilityExecutor),
|
|
217
|
-
verifyCurrentClassId(contractAddress, aztecNode, contractStore, header),
|
|
218
|
-
]);
|
|
219
|
-
}
|
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
} from '@aztec/stdlib/abi';
|
|
15
15
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
16
16
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
17
|
-
import { L2BlockHash } from '@aztec/stdlib/block';
|
|
18
17
|
import { siloNullifier } from '@aztec/stdlib/hash';
|
|
19
18
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
20
19
|
import { PrivateContextInputs } from '@aztec/stdlib/kernel';
|
|
@@ -31,6 +30,7 @@ import {
|
|
|
31
30
|
type TxContext,
|
|
32
31
|
} from '@aztec/stdlib/tx';
|
|
33
32
|
|
|
33
|
+
import { ensureContractSynced } from '../../contract_sync/index.js';
|
|
34
34
|
import { NoteService } from '../../notes/note_service.js';
|
|
35
35
|
import type { AddressStore } from '../../storage/address_store/address_store.js';
|
|
36
36
|
import type { AnchorBlockStore } from '../../storage/anchor_block_store/anchor_block_store.js';
|
|
@@ -47,7 +47,7 @@ import { ExecutionTaggingIndexCache } from '../execution_tagging_index_cache.js'
|
|
|
47
47
|
import type { HashedValuesCache } from '../hashed_values_cache.js';
|
|
48
48
|
import { pickNotes } from '../pick_notes.js';
|
|
49
49
|
import type { IPrivateExecutionOracle, NoteData } from './interfaces.js';
|
|
50
|
-
import {
|
|
50
|
+
import { executePrivateFunction } from './private_execution.js';
|
|
51
51
|
import { UtilityExecutionOracle } from './utility_execution_oracle.js';
|
|
52
52
|
|
|
53
53
|
/**
|
|
@@ -266,13 +266,12 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
266
266
|
// This is a tagging secret we've not yet used in this tx, so first sync our store to make sure its indices
|
|
267
267
|
// are up to date. We do this here because this store is not synced as part of the global sync because
|
|
268
268
|
// that'd be wasteful as most tagging secrets are not used in each tx.
|
|
269
|
-
const anchorBlockHash = L2BlockHash.fromField(await this.anchorBlockHeader.hash());
|
|
270
269
|
await syncSenderTaggingIndexes(
|
|
271
270
|
secret,
|
|
272
271
|
this.contractAddress,
|
|
273
272
|
this.aztecNode,
|
|
274
273
|
this.senderTaggingStore,
|
|
275
|
-
|
|
274
|
+
await this.anchorBlockHeader.hash(),
|
|
276
275
|
this.jobId,
|
|
277
276
|
);
|
|
278
277
|
|
|
@@ -380,7 +380,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
|
|
|
380
380
|
* @param noteValidationRequestsArrayBaseSlot - The base slot of capsule array containing note validation requests.
|
|
381
381
|
* @param eventValidationRequestsArrayBaseSlot - The base slot of capsule array containing event validation requests.
|
|
382
382
|
*/
|
|
383
|
-
public async
|
|
383
|
+
public async utilityValidateAndStoreEnqueuedNotesAndEvents(
|
|
384
384
|
contractAddress: AztecAddress,
|
|
385
385
|
noteValidationRequestsArrayBaseSlot: Fr,
|
|
386
386
|
eventValidationRequestsArrayBaseSlot: Fr,
|
|
@@ -402,7 +402,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
|
|
|
402
402
|
|
|
403
403
|
const noteService = new NoteService(this.noteStore, this.aztecNode, this.anchorBlockStore, this.jobId);
|
|
404
404
|
const noteStorePromises = noteValidationRequests.map(request =>
|
|
405
|
-
noteService.
|
|
405
|
+
noteService.validateAndStoreNote(
|
|
406
406
|
request.contractAddress,
|
|
407
407
|
request.owner,
|
|
408
408
|
request.storageSlot,
|
|
@@ -418,7 +418,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
|
|
|
418
418
|
|
|
419
419
|
const eventService = new EventService(this.anchorBlockStore, this.aztecNode, this.privateEventStore, this.jobId);
|
|
420
420
|
const eventStorePromises = eventValidationRequests.map(request =>
|
|
421
|
-
eventService.
|
|
421
|
+
eventService.validateAndStoreEvent(
|
|
422
422
|
request.contractAddress,
|
|
423
423
|
request.eventTypeId,
|
|
424
424
|
request.randomness,
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ProtocolContractAddress, isProtocolContract } from '@aztec/protocol-contracts';
|
|
2
|
+
import type { FunctionCall, FunctionSelector } from '@aztec/stdlib/abi';
|
|
3
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
import type { ContractInstance } from '@aztec/stdlib/contract';
|
|
5
|
+
import { DelayedPublicMutableValues, DelayedPublicMutableValuesWithHash } from '@aztec/stdlib/delayed-public-mutable';
|
|
6
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
7
|
+
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
8
|
+
|
|
9
|
+
import type { ContractStore } from '../storage/contract_store/contract_store.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Read the current class id of a contract from the execution data provider or AztecNode. If not found, class id
|
|
13
|
+
* from the instance is used.
|
|
14
|
+
* @param contractAddress - The address of the contract to read the class id for.
|
|
15
|
+
* @param instance - The instance of the contract.
|
|
16
|
+
* @param aztecNode - The Aztec node to query for storage.
|
|
17
|
+
* @param header - The header of the block at which to load the DelayedPublicMutable storing the class id.
|
|
18
|
+
* @returns The current class id.
|
|
19
|
+
*/
|
|
20
|
+
export async function readCurrentClassId(
|
|
21
|
+
contractAddress: AztecAddress,
|
|
22
|
+
instance: ContractInstance,
|
|
23
|
+
aztecNode: AztecNode,
|
|
24
|
+
header: BlockHeader,
|
|
25
|
+
) {
|
|
26
|
+
const blockHash = await header.hash();
|
|
27
|
+
const timestamp = header.globalVariables.timestamp;
|
|
28
|
+
const { delayedPublicMutableSlot } = await DelayedPublicMutableValuesWithHash.getContractUpdateSlots(contractAddress);
|
|
29
|
+
const delayedPublicMutableValues = await DelayedPublicMutableValues.readFromTree(delayedPublicMutableSlot, slot =>
|
|
30
|
+
aztecNode.getPublicStorageAt(blockHash, ProtocolContractAddress.ContractInstanceRegistry, slot),
|
|
31
|
+
);
|
|
32
|
+
let currentClassId = delayedPublicMutableValues.svc.getCurrentAt(timestamp)[0];
|
|
33
|
+
if (currentClassId.isZero()) {
|
|
34
|
+
currentClassId = instance.originalContractClassId;
|
|
35
|
+
}
|
|
36
|
+
return currentClassId;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export async function syncState(
|
|
40
|
+
contractAddress: AztecAddress,
|
|
41
|
+
contractStore: ContractStore,
|
|
42
|
+
functionToInvokeAfterSync: FunctionSelector | null,
|
|
43
|
+
utilityExecutor: (privateSyncCall: FunctionCall) => Promise<any>,
|
|
44
|
+
) {
|
|
45
|
+
// Protocol contracts don't have private state to sync
|
|
46
|
+
if (!isProtocolContract(contractAddress)) {
|
|
47
|
+
const syncStateFunctionCall = await contractStore.getFunctionCall('sync_state', [], contractAddress);
|
|
48
|
+
if (functionToInvokeAfterSync && functionToInvokeAfterSync.equals(syncStateFunctionCall.selector)) {
|
|
49
|
+
throw new Error(
|
|
50
|
+
'Forbidden `sync_state` invocation. `sync_state` can only be invoked by PXE, manual execution can lead to inconsistencies.',
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return utilityExecutor(syncStateFunctionCall);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Verify that the current class id of a contract obtained from AztecNode is the same as the one in contract data
|
|
60
|
+
* provider (i.e. PXE's own storage).
|
|
61
|
+
* @param header - The header of the block at which to verify the current class id.
|
|
62
|
+
*/
|
|
63
|
+
async function verifyCurrentClassId(
|
|
64
|
+
contractAddress: AztecAddress,
|
|
65
|
+
aztecNode: AztecNode,
|
|
66
|
+
contractStore: ContractStore,
|
|
67
|
+
header: BlockHeader,
|
|
68
|
+
) {
|
|
69
|
+
const instance = await contractStore.getContractInstance(contractAddress);
|
|
70
|
+
if (!instance) {
|
|
71
|
+
throw new Error(`No contract instance found for address ${contractAddress.toString()}`);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const currentClassId = await readCurrentClassId(contractAddress, instance, aztecNode, header);
|
|
75
|
+
if (!instance.currentContractClassId.equals(currentClassId)) {
|
|
76
|
+
throw new Error(
|
|
77
|
+
`Contract ${contractAddress} is outdated, current class id is ${currentClassId}, local class id is ${instance.currentContractClassId}`,
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Ensures the contract's private state is synchronized and that the PXE holds the current class artifact for
|
|
84
|
+
* the contract.
|
|
85
|
+
*/
|
|
86
|
+
export async function ensureContractSynced(
|
|
87
|
+
contractAddress: AztecAddress,
|
|
88
|
+
functionToInvokeAfterSync: FunctionSelector | null,
|
|
89
|
+
utilityExecutor: (call: FunctionCall) => Promise<any>,
|
|
90
|
+
aztecNode: AztecNode,
|
|
91
|
+
contractStore: ContractStore,
|
|
92
|
+
header: BlockHeader,
|
|
93
|
+
): Promise<void> {
|
|
94
|
+
await Promise.all([
|
|
95
|
+
syncState(contractAddress, contractStore, functionToInvokeAfterSync, utilityExecutor),
|
|
96
|
+
verifyCurrentClassId(contractAddress, aztecNode, contractStore, header),
|
|
97
|
+
]);
|
|
98
|
+
}
|
|
@@ -41,7 +41,7 @@ export class PXEDebugUtils {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
// We need to manually trigger private state sync to have a guarantee that all the notes are available.
|
|
44
|
-
const call = await this.contractStore.getFunctionCall('
|
|
44
|
+
const call = await this.contractStore.getFunctionCall('sync_state', [], filter.contractAddress);
|
|
45
45
|
await this.#pxe.simulateUtility(call);
|
|
46
46
|
|
|
47
47
|
return this.noteStore.getNotes(filter, randomBytes(8).toString('hex'));
|
|
@@ -7,3 +7,4 @@ export { NoteService } from '../../notes/note_service.js';
|
|
|
7
7
|
export { ORACLE_VERSION } from '../../oracle_version.js';
|
|
8
8
|
export { type PXECreationOptions } from '../pxe_creation_options.js';
|
|
9
9
|
export { JobCoordinator } from '../../job_coordinator/job_coordinator.js';
|
|
10
|
+
export { syncState } from '../../contract_sync/index.js';
|
package/src/logs/log_service.ts
CHANGED
|
@@ -2,7 +2,6 @@ import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import type { KeyStore } from '@aztec/key-store';
|
|
4
4
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
-
import { L2BlockHash } from '@aztec/stdlib/block';
|
|
6
5
|
import type { CompleteAddress } from '@aztec/stdlib/contract';
|
|
7
6
|
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
8
7
|
import { DirectionalAppTaggingSecret, PendingTaggedLog, SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
@@ -55,7 +54,7 @@ export class LogService {
|
|
|
55
54
|
|
|
56
55
|
async #getPublicLogByTag(tag: Tag, contractAddress: AztecAddress): Promise<LogRetrievalResponse | null> {
|
|
57
56
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
58
|
-
const anchorBlockHash =
|
|
57
|
+
const anchorBlockHash = await anchorBlockHeader.hash();
|
|
59
58
|
const allLogsPerTag = await getAllPublicLogsByTagsFromContract(
|
|
60
59
|
this.aztecNode,
|
|
61
60
|
contractAddress,
|
|
@@ -85,7 +84,7 @@ export class LogService {
|
|
|
85
84
|
|
|
86
85
|
async #getPrivateLogByTag(siloedTag: SiloedTag): Promise<LogRetrievalResponse | null> {
|
|
87
86
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
88
|
-
const anchorBlockHash =
|
|
87
|
+
const anchorBlockHash = await anchorBlockHeader.hash();
|
|
89
88
|
const allLogsPerTag = await getAllPrivateLogsByTags(this.aztecNode, [siloedTag], anchorBlockHash);
|
|
90
89
|
const logsForTag = allLogsPerTag[0];
|
|
91
90
|
|
|
@@ -118,7 +117,7 @@ export class LogService {
|
|
|
118
117
|
// We only load logs from block up to and including the anchor block number
|
|
119
118
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
120
119
|
const anchorBlockNumber = anchorBlockHeader.getBlockNumber();
|
|
121
|
-
const anchorBlockHash =
|
|
120
|
+
const anchorBlockHash = await anchorBlockHeader.hash();
|
|
122
121
|
|
|
123
122
|
// Determine recipients: use scopes if provided, otherwise get all accounts
|
|
124
123
|
const recipients = scopes && scopes.length > 0 ? scopes : await this.keyStore.getAccounts();
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
3
|
import type { DataInBlock } from '@aztec/stdlib/block';
|
|
4
|
-
import { L2BlockHash } from '@aztec/stdlib/block';
|
|
5
4
|
import { computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
|
|
6
5
|
import { type AztecNode, MAX_RPC_LEN } from '@aztec/stdlib/interfaces/client';
|
|
7
6
|
import { Note, NoteDao, NoteStatus } from '@aztec/stdlib/note';
|
|
@@ -73,7 +72,7 @@ export class NoteService {
|
|
|
73
72
|
* @param contractAddress - The contract whose notes should be checked and nullified.
|
|
74
73
|
*/
|
|
75
74
|
public async syncNoteNullifiers(contractAddress: AztecAddress): Promise<void> {
|
|
76
|
-
const anchorBlockHash =
|
|
75
|
+
const anchorBlockHash = await (await this.anchorBlockStore.getBlockHeader()).hash();
|
|
77
76
|
|
|
78
77
|
const contractNotes = await this.noteStore.getNotes({ contractAddress }, this.jobId);
|
|
79
78
|
|
|
@@ -112,7 +111,7 @@ export class NoteService {
|
|
|
112
111
|
await this.noteStore.applyNullifiers(foundNullifiers, this.jobId);
|
|
113
112
|
}
|
|
114
113
|
|
|
115
|
-
public async
|
|
114
|
+
public async validateAndStoreNote(
|
|
116
115
|
contractAddress: AztecAddress,
|
|
117
116
|
owner: AztecAddress,
|
|
118
117
|
storageSlot: Fr,
|
|
@@ -145,7 +144,7 @@ export class NoteService {
|
|
|
145
144
|
// logs up to the synced block making this only an additional safety check.
|
|
146
145
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
147
146
|
const anchorBlockNumber = anchorBlockHeader.getBlockNumber();
|
|
148
|
-
const anchorBlockHash =
|
|
147
|
+
const anchorBlockHash = await anchorBlockHeader.hash();
|
|
149
148
|
|
|
150
149
|
// By computing siloed and unique note hashes ourselves we prevent contracts from interfering with the note storage
|
|
151
150
|
// of other contracts, which would constitute a security breach.
|
package/src/oracle_version.ts
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
///
|
|
5
5
|
/// @dev Whenever a contract function or Noir test is run, the `utilityAssertCompatibleOracleVersion` oracle is called
|
|
6
6
|
/// and if the oracle version is incompatible an error is thrown.
|
|
7
|
-
export const ORACLE_VERSION =
|
|
7
|
+
export const ORACLE_VERSION = 9;
|
|
8
8
|
|
|
9
9
|
/// This hash is computed as by hashing the Oracle interface and it is used to detect when the Oracle interface changes,
|
|
10
10
|
/// which in turn implies that you need to update the ORACLE_VERSION constant in this file and in
|
|
11
11
|
/// `noir-projects/aztec-nr/aztec/src/oracle/version.nr`.
|
|
12
|
-
export const ORACLE_INTERFACE_HASH = '
|
|
12
|
+
export const ORACLE_INTERFACE_HASH = '9866cc52510acaef75a3d47a0ed501fd9ff92b9d53b2c8a88c8a3ffd04ced81f';
|
package/src/pxe.ts
CHANGED
|
@@ -18,7 +18,6 @@ import {
|
|
|
18
18
|
} from '@aztec/stdlib/abi';
|
|
19
19
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
20
20
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
21
|
-
import { L2BlockHash } from '@aztec/stdlib/block';
|
|
22
21
|
import {
|
|
23
22
|
CompleteAddress,
|
|
24
23
|
type ContractInstanceWithAddress,
|
|
@@ -59,8 +58,8 @@ import {
|
|
|
59
58
|
ContractFunctionSimulator,
|
|
60
59
|
generateSimulatedProvingResult,
|
|
61
60
|
} from './contract_function_simulator/contract_function_simulator.js';
|
|
62
|
-
import { ensureContractSynced, readCurrentClassId } from './contract_function_simulator/oracle/private_execution.js';
|
|
63
61
|
import { ProxiedContractStoreFactory } from './contract_function_simulator/proxied_contract_data_source.js';
|
|
62
|
+
import { ensureContractSynced, readCurrentClassId } from './contract_sync/index.js';
|
|
64
63
|
import { PXEDebugUtils } from './debug/pxe_debug_utils.js';
|
|
65
64
|
import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
|
|
66
65
|
import { PrivateEventFilterValidator } from './events/private_event_filter_validator.js';
|
|
@@ -399,7 +398,7 @@ export class PXE {
|
|
|
399
398
|
config: PrivateKernelExecutionProverConfig,
|
|
400
399
|
): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>> {
|
|
401
400
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
402
|
-
const anchorBlockHash =
|
|
401
|
+
const anchorBlockHash = await anchorBlockHeader.hash();
|
|
403
402
|
const kernelOracle = new PrivateKernelOracle(this.contractStore, this.keyStore, this.node, anchorBlockHash);
|
|
404
403
|
const kernelTraceProver = new PrivateKernelExecutionProver(kernelOracle, proofCreator, !this.proverEnabled);
|
|
405
404
|
this.log.debug(`Executing kernel trace prover (${JSON.stringify(config)})...`);
|
|
@@ -3,7 +3,6 @@ import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
3
3
|
import { toArray } from '@aztec/foundation/iterable';
|
|
4
4
|
import type { MembershipWitness } from '@aztec/foundation/trees';
|
|
5
5
|
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
6
|
-
import { isProtocolContract } from '@aztec/protocol-contracts';
|
|
7
6
|
import {
|
|
8
7
|
type ContractArtifact,
|
|
9
8
|
type FunctionAbi,
|
|
@@ -317,23 +316,4 @@ export class ContractStore {
|
|
|
317
316
|
returnTypes: functionDao.returnTypes,
|
|
318
317
|
};
|
|
319
318
|
}
|
|
320
|
-
|
|
321
|
-
// Synchronize target contract data
|
|
322
|
-
public async syncPrivateState(
|
|
323
|
-
contractAddress: AztecAddress,
|
|
324
|
-
functionToInvokeAfterSync: FunctionSelector | null,
|
|
325
|
-
utilityExecutor: (privateSyncCall: FunctionCall) => Promise<any>,
|
|
326
|
-
) {
|
|
327
|
-
// Protocol contracts don't have private state to sync
|
|
328
|
-
if (!isProtocolContract(contractAddress)) {
|
|
329
|
-
const syncPrivateStateFunctionCall = await this.getFunctionCall('sync_private_state', [], contractAddress);
|
|
330
|
-
if (functionToInvokeAfterSync && functionToInvokeAfterSync.equals(syncPrivateStateFunctionCall.selector)) {
|
|
331
|
-
throw new Error(
|
|
332
|
-
'Forbidden `sync_private_state` invocation. `sync_private_state` can only be invoked by PXE, manual execution can lead to inconsistencies.',
|
|
333
|
-
);
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
return utilityExecutor(syncPrivateStateFunctionCall);
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
319
|
}
|
|
@@ -173,7 +173,7 @@ export class NoteStore implements StagedStore {
|
|
|
173
173
|
* The operation is atomic - if any nullifier is not found, the entire operation fails and no notes are modified.
|
|
174
174
|
*
|
|
175
175
|
* applyNullifiers is idempotent: the same nullifier can be applied multiple times without error.
|
|
176
|
-
* This relaxes constraints on usage of NoteService#
|
|
176
|
+
* This relaxes constraints on usage of NoteService#validateAndStoreNote, which can then be run concurrently in a Promise.all
|
|
177
177
|
* context without risking unnecessarily defensive checks failing.
|
|
178
178
|
*
|
|
179
179
|
* @param nullifiers - Array of nullifiers with their block numbers to process
|
|
@@ -339,7 +339,7 @@ export class NoteStore implements StagedStore {
|
|
|
339
339
|
/**
|
|
340
340
|
* Functions run withJobLock are forced to wait for each other, i.e. if they share a `jobId`, they run serially
|
|
341
341
|
* instead of concurrently. This is needed because staged data is stored in memory, and concurrent async operations
|
|
342
|
-
* (e.g., Promise.all in `
|
|
342
|
+
* (e.g., Promise.all in `validateAndStoreNote`) could otherwise interleave and corrupt state.
|
|
343
343
|
*/
|
|
344
344
|
async #withJobLock<T>(jobId: string, fn: () => Promise<T>): Promise<T> {
|
|
345
345
|
let lock = this.#jobLocks.get(jobId);
|