@aztec/pxe 0.0.1-commit.08c5969dc → 0.0.1-commit.0c875d939
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/contract_function_simulator/contract_function_simulator.d.ts +5 -4
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +3 -2
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +4 -3
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +1 -1
- package/dest/contract_sync/contract_sync_service.d.ts +4 -3
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
- package/dest/contract_sync/contract_sync_service.js +10 -10
- package/dest/contract_sync/helpers.d.ts +3 -2
- package/dest/contract_sync/helpers.d.ts.map +1 -1
- package/dest/contract_sync/helpers.js +3 -3
- package/dest/debug/pxe_debug_utils.d.ts +5 -4
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.d.ts +3 -1
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +2 -0
- package/dest/entrypoints/client/lazy/index.d.ts +3 -1
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +2 -0
- package/dest/entrypoints/server/index.d.ts +3 -1
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +2 -0
- package/dest/logs/log_service.d.ts +3 -2
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +1 -1
- package/dest/notes/note_service.d.ts +4 -3
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +3 -2
- package/dest/notes_filter.d.ts +25 -0
- package/dest/notes_filter.d.ts.map +1 -0
- package/dest/notes_filter.js +4 -0
- package/dest/pxe.d.ts +7 -6
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +5 -3
- package/dest/storage/note_store/note_store.d.ts +3 -2
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +2 -2
- package/package.json +16 -16
- package/src/access_scopes.ts +9 -0
- package/src/contract_function_simulator/contract_function_simulator.ts +4 -3
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +4 -3
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +4 -3
- package/src/contract_sync/contract_sync_service.ts +19 -12
- package/src/contract_sync/helpers.ts +7 -2
- package/src/debug/pxe_debug_utils.ts +5 -4
- package/src/entrypoints/client/bundle/index.ts +2 -0
- package/src/entrypoints/client/lazy/index.ts +2 -0
- package/src/entrypoints/server/index.ts +2 -0
- package/src/logs/log_service.ts +3 -6
- package/src/notes/note_service.ts +4 -3
- package/src/notes_filter.ts +26 -0
- package/src/pxe.ts +11 -10
- package/src/storage/note_store/note_store.ts +7 -3
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { FunctionCall } from '@aztec/stdlib/abi';
|
|
2
2
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
3
|
-
import type {
|
|
4
|
-
import type { NoteDao, NotesFilter } from '@aztec/stdlib/note';
|
|
3
|
+
import type { NoteDao } from '@aztec/stdlib/note';
|
|
5
4
|
import type { ContractOverrides } from '@aztec/stdlib/tx';
|
|
6
5
|
|
|
6
|
+
import type { AccessScopes } from '../access_scopes.js';
|
|
7
7
|
import type { BlockSynchronizer } from '../block_synchronizer/block_synchronizer.js';
|
|
8
8
|
import type { ContractFunctionSimulator } from '../contract_function_simulator/contract_function_simulator.js';
|
|
9
9
|
import type { ContractSyncService } from '../contract_sync/contract_sync_service.js';
|
|
10
|
+
import type { NotesFilter } from '../notes_filter.js';
|
|
10
11
|
import type { AnchorBlockStore } from '../storage/index.js';
|
|
11
12
|
import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
12
13
|
|
|
@@ -21,7 +22,7 @@ export class PXEDebugUtils {
|
|
|
21
22
|
contractFunctionSimulator: ContractFunctionSimulator,
|
|
22
23
|
call: FunctionCall,
|
|
23
24
|
authWitnesses: AuthWitness[] | undefined,
|
|
24
|
-
scopes:
|
|
25
|
+
scopes: AccessScopes,
|
|
25
26
|
jobId: string,
|
|
26
27
|
) => Promise<any>;
|
|
27
28
|
|
|
@@ -40,7 +41,7 @@ export class PXEDebugUtils {
|
|
|
40
41
|
contractFunctionSimulator: ContractFunctionSimulator,
|
|
41
42
|
call: FunctionCall,
|
|
42
43
|
authWitnesses: AuthWitness[] | undefined,
|
|
43
|
-
scopes:
|
|
44
|
+
scopes: AccessScopes,
|
|
44
45
|
jobId: string,
|
|
45
46
|
) => Promise<any>,
|
|
46
47
|
) {
|
package/src/logs/log_service.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
|
6
6
|
import { DirectionalAppTaggingSecret, PendingTaggedLog, SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
7
7
|
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
8
8
|
|
|
9
|
+
import type { AccessScopes } from '../access_scopes.js';
|
|
9
10
|
import type { LogRetrievalRequest } from '../contract_function_simulator/noir-structs/log_retrieval_request.js';
|
|
10
11
|
import { LogRetrievalResponse } from '../contract_function_simulator/noir-structs/log_retrieval_response.js';
|
|
11
12
|
import { AddressStore } from '../storage/address_store/address_store.js';
|
|
@@ -107,11 +108,7 @@ export class LogService {
|
|
|
107
108
|
);
|
|
108
109
|
}
|
|
109
110
|
|
|
110
|
-
public async fetchTaggedLogs(
|
|
111
|
-
contractAddress: AztecAddress,
|
|
112
|
-
pendingTaggedLogArrayBaseSlot: Fr,
|
|
113
|
-
scopes?: AztecAddress[],
|
|
114
|
-
) {
|
|
111
|
+
public async fetchTaggedLogs(contractAddress: AztecAddress, pendingTaggedLogArrayBaseSlot: Fr, scopes: AccessScopes) {
|
|
115
112
|
this.log.verbose(`Fetching tagged logs for ${contractAddress.toString()}`);
|
|
116
113
|
|
|
117
114
|
// We only load logs from block up to and including the anchor block number
|
|
@@ -119,7 +116,7 @@ export class LogService {
|
|
|
119
116
|
const anchorBlockHash = await this.anchorBlockHeader.hash();
|
|
120
117
|
|
|
121
118
|
// Determine recipients: use scopes if provided, otherwise get all accounts
|
|
122
|
-
const recipients = scopes && scopes.length > 0 ? scopes : await this.keyStore.getAccounts();
|
|
119
|
+
const recipients = scopes !== 'ALL_SCOPES' && scopes.length > 0 ? scopes : await this.keyStore.getAccounts();
|
|
123
120
|
|
|
124
121
|
// For each recipient, fetch secrets, load logs, and store them.
|
|
125
122
|
// We run these per-recipient tasks in parallel so that logs are loaded for all recipients concurrently.
|
|
@@ -7,6 +7,7 @@ import { Note, NoteDao, NoteStatus } from '@aztec/stdlib/note';
|
|
|
7
7
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
8
8
|
import type { BlockHeader, TxHash } from '@aztec/stdlib/tx';
|
|
9
9
|
|
|
10
|
+
import type { AccessScopes } from '../access_scopes.js';
|
|
10
11
|
import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
11
12
|
|
|
12
13
|
export class NoteService {
|
|
@@ -31,7 +32,7 @@ export class NoteService {
|
|
|
31
32
|
owner: AztecAddress | undefined,
|
|
32
33
|
storageSlot: Fr,
|
|
33
34
|
status: NoteStatus,
|
|
34
|
-
scopes
|
|
35
|
+
scopes: AccessScopes,
|
|
35
36
|
) {
|
|
36
37
|
const noteDaos = await this.noteStore.getNotes(
|
|
37
38
|
{
|
|
@@ -70,10 +71,10 @@ export class NoteService {
|
|
|
70
71
|
*
|
|
71
72
|
* @param contractAddress - The contract whose notes should be checked and nullified.
|
|
72
73
|
*/
|
|
73
|
-
public async syncNoteNullifiers(contractAddress: AztecAddress): Promise<void> {
|
|
74
|
+
public async syncNoteNullifiers(contractAddress: AztecAddress, scopes: AccessScopes): Promise<void> {
|
|
74
75
|
const anchorBlockHash = await this.anchorBlockHeader.hash();
|
|
75
76
|
|
|
76
|
-
const contractNotes = await this.noteStore.getNotes({ contractAddress }, this.jobId);
|
|
77
|
+
const contractNotes = await this.noteStore.getNotes({ contractAddress, scopes }, this.jobId);
|
|
77
78
|
|
|
78
79
|
if (contractNotes.length === 0) {
|
|
79
80
|
return;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import type { NoteStatus } from '@aztec/stdlib/note';
|
|
4
|
+
|
|
5
|
+
import type { AccessScopes } from './access_scopes.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A filter used to fetch notes.
|
|
9
|
+
* @remarks This filter is applied as an intersection of all its params.
|
|
10
|
+
*/
|
|
11
|
+
export type NotesFilter = {
|
|
12
|
+
/**
|
|
13
|
+
* The contract address the note belongs to.
|
|
14
|
+
* @remarks Providing a contract address is required as we need that information to trigger private state sync.
|
|
15
|
+
*/
|
|
16
|
+
contractAddress: AztecAddress;
|
|
17
|
+
/** The owner of the note. */
|
|
18
|
+
owner?: AztecAddress;
|
|
19
|
+
/** The specific storage location of the note on the contract. */
|
|
20
|
+
storageSlot?: Fr;
|
|
21
|
+
/** The status of the note. Defaults to 'ACTIVE'. */
|
|
22
|
+
status?: NoteStatus;
|
|
23
|
+
/** The siloed nullifier for the note. */
|
|
24
|
+
siloedNullifier?: Fr;
|
|
25
|
+
scopes: AccessScopes;
|
|
26
|
+
};
|
package/src/pxe.ts
CHANGED
|
@@ -52,6 +52,7 @@ import {
|
|
|
52
52
|
|
|
53
53
|
import { inspect } from 'util';
|
|
54
54
|
|
|
55
|
+
import type { AccessScopes } from './access_scopes.js';
|
|
55
56
|
import { BlockSynchronizer } from './block_synchronizer/index.js';
|
|
56
57
|
import type { PXEConfig } from './config/index.js';
|
|
57
58
|
import { BenchmarkedNodeFactory } from './contract_function_simulator/benchmarked_node.js';
|
|
@@ -93,7 +94,7 @@ export type ProfileTxOpts = {
|
|
|
93
94
|
/** If true, proof generation is skipped during profiling. Defaults to true. */
|
|
94
95
|
skipProofGeneration?: boolean;
|
|
95
96
|
/** Addresses whose private state and keys are accessible during private execution. */
|
|
96
|
-
scopes
|
|
97
|
+
scopes: AccessScopes;
|
|
97
98
|
};
|
|
98
99
|
|
|
99
100
|
/** Options for PXE.simulateTx. */
|
|
@@ -106,16 +107,16 @@ export type SimulateTxOpts = {
|
|
|
106
107
|
skipFeeEnforcement?: boolean;
|
|
107
108
|
/** State overrides for the simulation, such as contract instances and artifacts. */
|
|
108
109
|
overrides?: SimulationOverrides;
|
|
109
|
-
/** Addresses whose private state and keys are accessible during private execution
|
|
110
|
-
scopes
|
|
110
|
+
/** Addresses whose private state and keys are accessible during private execution */
|
|
111
|
+
scopes: AccessScopes;
|
|
111
112
|
};
|
|
112
113
|
|
|
113
114
|
/** Options for PXE.simulateUtility. */
|
|
114
115
|
export type SimulateUtilityOpts = {
|
|
115
116
|
/** The authentication witnesses required for the function call. */
|
|
116
117
|
authwits?: AuthWitness[];
|
|
117
|
-
/** The accounts whose notes we can access in this call
|
|
118
|
-
scopes
|
|
118
|
+
/** The accounts whose notes we can access in this call */
|
|
119
|
+
scopes: AccessScopes;
|
|
119
120
|
};
|
|
120
121
|
|
|
121
122
|
/** Args for PXE.create. */
|
|
@@ -357,7 +358,7 @@ export class PXE {
|
|
|
357
358
|
async #executePrivate(
|
|
358
359
|
contractFunctionSimulator: ContractFunctionSimulator,
|
|
359
360
|
txRequest: TxExecutionRequest,
|
|
360
|
-
scopes:
|
|
361
|
+
scopes: AccessScopes,
|
|
361
362
|
jobId: string,
|
|
362
363
|
): Promise<PrivateExecutionResult> {
|
|
363
364
|
const { origin: contractAddress, functionSelector } = txRequest;
|
|
@@ -406,7 +407,7 @@ export class PXE {
|
|
|
406
407
|
contractFunctionSimulator: ContractFunctionSimulator,
|
|
407
408
|
call: FunctionCall,
|
|
408
409
|
authWitnesses: AuthWitness[] | undefined,
|
|
409
|
-
scopes:
|
|
410
|
+
scopes: AccessScopes,
|
|
410
411
|
jobId: string,
|
|
411
412
|
) {
|
|
412
413
|
try {
|
|
@@ -1005,7 +1006,7 @@ export class PXE {
|
|
|
1005
1006
|
inspect(txRequest),
|
|
1006
1007
|
`simulatePublic=${simulatePublic}`,
|
|
1007
1008
|
`skipTxValidation=${skipTxValidation}`,
|
|
1008
|
-
`scopes=${scopes
|
|
1009
|
+
`scopes=${scopes === 'ALL_SCOPES' ? scopes : scopes.map(s => s.toString()).join(', ')}`,
|
|
1009
1010
|
);
|
|
1010
1011
|
}
|
|
1011
1012
|
});
|
|
@@ -1017,7 +1018,7 @@ export class PXE {
|
|
|
1017
1018
|
*/
|
|
1018
1019
|
public simulateUtility(
|
|
1019
1020
|
call: FunctionCall,
|
|
1020
|
-
{ authwits, scopes }: SimulateUtilityOpts = {},
|
|
1021
|
+
{ authwits, scopes }: SimulateUtilityOpts = { scopes: 'ALL_SCOPES' },
|
|
1021
1022
|
): Promise<UtilitySimulationResult> {
|
|
1022
1023
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
1023
1024
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
@@ -1070,7 +1071,7 @@ export class PXE {
|
|
|
1070
1071
|
throw this.#contextualizeError(
|
|
1071
1072
|
err,
|
|
1072
1073
|
`simulateUtility ${to}:${name}(${stringifiedArgs})`,
|
|
1073
|
-
`scopes=${scopes
|
|
1074
|
+
`scopes=${scopes === 'ALL_SCOPES' ? scopes : scopes.map(s => s.toString()).join(', ')}`,
|
|
1074
1075
|
);
|
|
1075
1076
|
}
|
|
1076
1077
|
});
|
|
@@ -3,9 +3,10 @@ import type { Fr } from '@aztec/foundation/schemas';
|
|
|
3
3
|
import type { AztecAsyncKVStore, AztecAsyncMap, AztecAsyncMultiMap } from '@aztec/kv-store';
|
|
4
4
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
5
|
import type { DataInBlock } from '@aztec/stdlib/block';
|
|
6
|
-
import { NoteDao, NoteStatus
|
|
6
|
+
import { NoteDao, NoteStatus } from '@aztec/stdlib/note';
|
|
7
7
|
|
|
8
8
|
import type { StagedStore } from '../../job_coordinator/job_coordinator.js';
|
|
9
|
+
import type { NotesFilter } from '../../notes_filter.js';
|
|
9
10
|
import { StoredNote } from './stored_note.js';
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -105,7 +106,7 @@ export class NoteStore implements StagedStore {
|
|
|
105
106
|
* returned once if this is the case)
|
|
106
107
|
*/
|
|
107
108
|
getNotes(filter: NotesFilter, jobId: string): Promise<NoteDao[]> {
|
|
108
|
-
if (filter.scopes !==
|
|
109
|
+
if (filter.scopes !== 'ALL_SCOPES' && filter.scopes.length === 0) {
|
|
109
110
|
return Promise.resolve([]);
|
|
110
111
|
}
|
|
111
112
|
|
|
@@ -179,7 +180,10 @@ export class NoteStore implements StagedStore {
|
|
|
179
180
|
continue;
|
|
180
181
|
}
|
|
181
182
|
|
|
182
|
-
if (
|
|
183
|
+
if (
|
|
184
|
+
filter.scopes !== 'ALL_SCOPES' &&
|
|
185
|
+
note.scopes.intersection(new Set(filter.scopes.map(s => s.toString()))).size === 0
|
|
186
|
+
) {
|
|
183
187
|
continue;
|
|
184
188
|
}
|
|
185
189
|
|