@aztec/pxe 0.0.1-commit.9ef841308 → 0.0.1-commit.a89ec08
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 +4 -4
- package/dest/config/index.d.ts +2 -2
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +1 -1
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +6 -4
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +7 -3
- package/dest/contract_function_simulator/ephemeral_array_service.d.ts +28 -0
- package/dest/contract_function_simulator/ephemeral_array_service.d.ts.map +1 -0
- package/dest/contract_function_simulator/ephemeral_array_service.js +78 -0
- 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/log_retrieval_request.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.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 +13 -2
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +1 -1
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +10 -1
- package/dest/contract_function_simulator/oracle/oracle.d.ts +13 -2
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +98 -3
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +2 -3
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +12 -2
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +28 -13
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +104 -34
- package/dest/contract_function_simulator/pick_notes.d.ts +1 -1
- package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
- package/dest/contract_function_simulator/pick_notes.js +14 -3
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.js +3 -0
- package/dest/contract_sync/contract_sync_service.d.ts +4 -6
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
- package/dest/contract_sync/contract_sync_service.js +38 -46
- package/dest/contract_sync/helpers.d.ts +2 -3
- package/dest/contract_sync/helpers.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.d.ts +3 -3
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.d.ts +1 -2
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +0 -1
- package/dest/entrypoints/client/bundle/utils.d.ts +2 -2
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +2 -2
- package/dest/entrypoints/client/lazy/index.d.ts +1 -2
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +0 -1
- 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 +2 -2
- package/dest/entrypoints/pxe_creation_options.d.ts +3 -1
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/pxe_creation_options.js +3 -1
- package/dest/entrypoints/server/index.d.ts +2 -3
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +1 -2
- package/dest/entrypoints/server/utils.d.ts +2 -2
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +2 -2
- package/dest/events/private_event_filter_validator.d.ts +3 -2
- package/dest/events/private_event_filter_validator.d.ts.map +1 -1
- package/dest/events/private_event_filter_validator.js +15 -0
- package/dest/logs/log_service.d.ts +6 -6
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +15 -21
- package/dest/notes/note_service.d.ts +3 -4
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes_filter.d.ts +2 -3
- package/dest/notes_filter.d.ts.map +1 -1
- package/dest/oracle_version.d.ts +4 -3
- package/dest/oracle_version.d.ts.map +1 -1
- package/dest/oracle_version.js +20 -10
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +4 -7
- package/dest/pxe.d.ts +6 -7
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +15 -12
- package/dest/storage/anchor_block_store/anchor_block_store.js +1 -1
- package/dest/storage/capsule_store/capsule_service.d.ts +2 -3
- package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -1
- package/dest/storage/capsule_store/capsule_service.js +1 -1
- package/dest/storage/capsule_store/capsule_store.d.ts +1 -1
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
- package/dest/storage/capsule_store/capsule_store.js +8 -5
- package/dest/storage/contract_store/contract_store.d.ts +1 -1
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +4 -2
- package/dest/storage/note_store/note_store.d.ts +1 -1
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +2 -2
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +2 -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 +1 -15
- package/package.json +16 -16
- package/src/bin/check_oracle_version.ts +4 -4
- package/src/config/index.ts +1 -1
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +10 -6
- package/src/contract_function_simulator/ephemeral_array_service.ts +110 -0
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.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 -1
- package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +7 -1
- package/src/contract_function_simulator/oracle/oracle.ts +143 -3
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +14 -4
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +169 -64
- package/src/contract_function_simulator/pick_notes.ts +14 -3
- package/src/contract_function_simulator/proxied_contract_data_source.ts +8 -1
- package/src/contract_sync/contract_sync_service.ts +64 -80
- package/src/contract_sync/helpers.ts +2 -3
- package/src/debug/pxe_debug_utils.ts +3 -3
- package/src/entrypoints/client/bundle/index.ts +0 -1
- package/src/entrypoints/client/bundle/utils.ts +2 -3
- package/src/entrypoints/client/lazy/index.ts +0 -1
- package/src/entrypoints/client/lazy/utils.ts +2 -3
- package/src/entrypoints/pxe_creation_options.ts +7 -0
- package/src/entrypoints/server/index.ts +1 -2
- package/src/entrypoints/server/utils.ts +2 -3
- package/src/events/private_event_filter_validator.ts +21 -1
- package/src/logs/log_service.ts +24 -50
- package/src/notes/note_service.ts +2 -3
- package/src/notes_filter.ts +1 -3
- package/src/oracle_version.ts +20 -10
- package/src/private_kernel/private_kernel_execution_prover.ts +4 -9
- package/src/pxe.ts +21 -16
- package/src/storage/anchor_block_store/anchor_block_store.ts +1 -1
- package/src/storage/capsule_store/capsule_service.ts +5 -6
- package/src/storage/capsule_store/capsule_store.ts +15 -5
- package/src/storage/contract_store/contract_store.ts +8 -6
- package/src/storage/note_store/note_store.ts +2 -5
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +2 -14
- package/dest/access_scopes.d.ts +0 -9
- package/dest/access_scopes.d.ts.map +0 -1
- package/dest/access_scopes.js +0 -6
- package/src/access_scopes.ts +0 -9
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
} from '@aztec/stdlib/tx';
|
|
34
34
|
import { VerificationKeyAsFields, VerificationKeyData, VkData } from '@aztec/stdlib/vks';
|
|
35
35
|
|
|
36
|
+
import { computeTxExpirationTimestamp } from './hints/compute_tx_expiration_timestamp.js';
|
|
36
37
|
import { PrivateKernelResetPrivateInputsBuilder } from './hints/private_kernel_reset_private_inputs_builder.js';
|
|
37
38
|
import type { PrivateKernelOracle } from './private_kernel_oracle.js';
|
|
38
39
|
|
|
@@ -267,15 +268,9 @@ export class PrivateKernelExecutionProver {
|
|
|
267
268
|
// TODO: Enable padding once we better understand the final amounts to pad to.
|
|
268
269
|
const paddedSideEffectAmounts = PaddedSideEffectAmounts.empty();
|
|
269
270
|
|
|
270
|
-
//
|
|
271
|
-
//
|
|
272
|
-
const expirationTimestampUpperBound = previousKernelData.publicInputs
|
|
273
|
-
const anchorBlockTimestamp = previousKernelData.publicInputs.constants.anchorBlockHeader.globalVariables.timestamp;
|
|
274
|
-
if (expirationTimestampUpperBound <= anchorBlockTimestamp) {
|
|
275
|
-
throw new Error(
|
|
276
|
-
`Include-by timestamp must be greater than the anchor block timestamp. Anchor block timestamp: ${anchorBlockTimestamp}. Include-by timestamp: ${expirationTimestampUpperBound}.`,
|
|
277
|
-
);
|
|
278
|
-
}
|
|
271
|
+
// Round the aggregated expirationTimestamp down to reduce precision and avoid leaking which private
|
|
272
|
+
// functions were called via their exact expiration offsets.
|
|
273
|
+
const expirationTimestampUpperBound = computeTxExpirationTimestamp(previousKernelData.publicInputs);
|
|
279
274
|
|
|
280
275
|
const privateInputs = new PrivateKernelTailCircuitPrivateInputs(
|
|
281
276
|
previousKernelData,
|
package/src/pxe.ts
CHANGED
|
@@ -18,6 +18,7 @@ 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 type { L2TipsProvider } from '@aztec/stdlib/block';
|
|
21
22
|
import {
|
|
22
23
|
CompleteAddress,
|
|
23
24
|
type ContractInstanceWithAddress,
|
|
@@ -52,7 +53,6 @@ import {
|
|
|
52
53
|
|
|
53
54
|
import { inspect } from 'util';
|
|
54
55
|
|
|
55
|
-
import type { AccessScopes } from './access_scopes.js';
|
|
56
56
|
import { BlockSynchronizer } from './block_synchronizer/index.js';
|
|
57
57
|
import type { PXEConfig } from './config/index.js';
|
|
58
58
|
import { BenchmarkedNodeFactory } from './contract_function_simulator/benchmarked_node.js';
|
|
@@ -96,7 +96,7 @@ export type ProfileTxOpts = {
|
|
|
96
96
|
/** If true, proof generation is skipped during profiling. Defaults to true. */
|
|
97
97
|
skipProofGeneration?: boolean;
|
|
98
98
|
/** Addresses whose private state and keys are accessible during private execution. */
|
|
99
|
-
scopes:
|
|
99
|
+
scopes: AztecAddress[];
|
|
100
100
|
};
|
|
101
101
|
|
|
102
102
|
/** Options for PXE.simulateTx. */
|
|
@@ -112,7 +112,7 @@ export type SimulateTxOpts = {
|
|
|
112
112
|
/** State overrides for the simulation, such as contract instances and artifacts. Requires skipKernels: true */
|
|
113
113
|
overrides?: SimulationOverrides;
|
|
114
114
|
/** Addresses whose private state and keys are accessible during private execution */
|
|
115
|
-
scopes:
|
|
115
|
+
scopes: AztecAddress[];
|
|
116
116
|
};
|
|
117
117
|
|
|
118
118
|
/** Options for PXE.executeUtility. */
|
|
@@ -120,7 +120,7 @@ export type ExecuteUtilityOpts = {
|
|
|
120
120
|
/** The authentication witnesses required for the function call. */
|
|
121
121
|
authwits?: AuthWitness[];
|
|
122
122
|
/** The accounts whose notes we can access in this call */
|
|
123
|
-
scopes:
|
|
123
|
+
scopes: AztecAddress[];
|
|
124
124
|
};
|
|
125
125
|
|
|
126
126
|
/** Args for PXE.create. */
|
|
@@ -148,7 +148,6 @@ export type PXECreateArgs = {
|
|
|
148
148
|
export class PXE {
|
|
149
149
|
private constructor(
|
|
150
150
|
private node: AztecNode,
|
|
151
|
-
private db: AztecAsyncKVStore,
|
|
152
151
|
private blockStateSynchronizer: BlockSynchronizer,
|
|
153
152
|
private keyStore: KeyStore,
|
|
154
153
|
private contractStore: ContractStore,
|
|
@@ -162,6 +161,7 @@ export class PXE {
|
|
|
162
161
|
private privateEventStore: PrivateEventStore,
|
|
163
162
|
private contractSyncService: ContractSyncService,
|
|
164
163
|
private messageContextService: MessageContextService,
|
|
164
|
+
private l2TipsStore: L2TipsProvider,
|
|
165
165
|
private simulator: CircuitSimulator,
|
|
166
166
|
private proverEnabled: boolean,
|
|
167
167
|
private proofCreator: PrivateKernelProver,
|
|
@@ -215,7 +215,6 @@ export class PXE {
|
|
|
215
215
|
node,
|
|
216
216
|
contractStore,
|
|
217
217
|
noteStore,
|
|
218
|
-
() => keyStore.getAccounts(),
|
|
219
218
|
createLogger('pxe:contract_sync', bindings),
|
|
220
219
|
);
|
|
221
220
|
const messageContextService = new MessageContextService(node);
|
|
@@ -248,7 +247,6 @@ export class PXE {
|
|
|
248
247
|
|
|
249
248
|
const pxe = new PXE(
|
|
250
249
|
node,
|
|
251
|
-
store,
|
|
252
250
|
synchronizer,
|
|
253
251
|
keyStore,
|
|
254
252
|
contractStore,
|
|
@@ -262,6 +260,7 @@ export class PXE {
|
|
|
262
260
|
privateEventStore,
|
|
263
261
|
contractSyncService,
|
|
264
262
|
messageContextService,
|
|
263
|
+
tipsStore,
|
|
265
264
|
simulator,
|
|
266
265
|
proverEnabled,
|
|
267
266
|
proofCreator,
|
|
@@ -296,6 +295,7 @@ export class PXE {
|
|
|
296
295
|
keyStore: this.keyStore,
|
|
297
296
|
addressStore: this.addressStore,
|
|
298
297
|
aztecNode: BenchmarkedNodeFactory.create(this.node),
|
|
298
|
+
l2TipsStore: this.l2TipsStore,
|
|
299
299
|
senderTaggingStore: this.senderTaggingStore,
|
|
300
300
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
301
301
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
@@ -369,7 +369,7 @@ export class PXE {
|
|
|
369
369
|
async #executePrivate(
|
|
370
370
|
contractFunctionSimulator: ContractFunctionSimulator,
|
|
371
371
|
txRequest: TxExecutionRequest,
|
|
372
|
-
scopes:
|
|
372
|
+
scopes: AztecAddress[],
|
|
373
373
|
jobId: string,
|
|
374
374
|
): Promise<PrivateExecutionResult> {
|
|
375
375
|
const { origin: contractAddress, functionSelector } = txRequest;
|
|
@@ -418,7 +418,7 @@ export class PXE {
|
|
|
418
418
|
contractFunctionSimulator: ContractFunctionSimulator,
|
|
419
419
|
call: FunctionCall,
|
|
420
420
|
authWitnesses: AuthWitness[] | undefined,
|
|
421
|
-
scopes:
|
|
421
|
+
scopes: AztecAddress[],
|
|
422
422
|
jobId: string,
|
|
423
423
|
) {
|
|
424
424
|
try {
|
|
@@ -562,6 +562,12 @@ export class PXE {
|
|
|
562
562
|
* TODO: It's strange that we return the address here and I (benesjan) think we should drop the return value.
|
|
563
563
|
*/
|
|
564
564
|
public async registerSender(sender: AztecAddress): Promise<AztecAddress> {
|
|
565
|
+
if (!(await sender.isValid())) {
|
|
566
|
+
throw new Error(
|
|
567
|
+
`Address ${sender} is not valid: it does not correspond to a point on the Grumpkin curve. Cannot register it as a sender.`,
|
|
568
|
+
);
|
|
569
|
+
}
|
|
570
|
+
|
|
565
571
|
const accounts = await this.keyStore.getAccounts();
|
|
566
572
|
if (accounts.includes(sender)) {
|
|
567
573
|
this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
|
|
@@ -1043,7 +1049,7 @@ export class PXE {
|
|
|
1043
1049
|
inspect(txRequest),
|
|
1044
1050
|
`simulatePublic=${simulatePublic}`,
|
|
1045
1051
|
`skipTxValidation=${skipTxValidation}`,
|
|
1046
|
-
`scopes=${scopes
|
|
1052
|
+
`scopes=${scopes.map(s => s.toString()).join(', ')}`,
|
|
1047
1053
|
);
|
|
1048
1054
|
}
|
|
1049
1055
|
});
|
|
@@ -1055,7 +1061,7 @@ export class PXE {
|
|
|
1055
1061
|
*/
|
|
1056
1062
|
public executeUtility(
|
|
1057
1063
|
call: FunctionCall,
|
|
1058
|
-
{ authwits, scopes }: ExecuteUtilityOpts = { scopes:
|
|
1064
|
+
{ authwits, scopes }: ExecuteUtilityOpts = { scopes: [] },
|
|
1059
1065
|
): Promise<UtilityExecutionResult> {
|
|
1060
1066
|
// We disable concurrent executions since those might execute oracles which read and write to the PXE stores (e.g.
|
|
1061
1067
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
@@ -1113,7 +1119,7 @@ export class PXE {
|
|
|
1113
1119
|
throw this.#contextualizeError(
|
|
1114
1120
|
err,
|
|
1115
1121
|
`executeUtility ${to}:${name}(${stringifiedArgs})`,
|
|
1116
|
-
`scopes=${scopes
|
|
1122
|
+
`scopes=${scopes.map(s => s.toString()).join(', ')}`,
|
|
1117
1123
|
);
|
|
1118
1124
|
}
|
|
1119
1125
|
});
|
|
@@ -1168,10 +1174,9 @@ export class PXE {
|
|
|
1168
1174
|
}
|
|
1169
1175
|
|
|
1170
1176
|
/**
|
|
1171
|
-
* Stops the PXE's job queue
|
|
1177
|
+
* Stops the PXE's job queue.
|
|
1172
1178
|
*/
|
|
1173
|
-
public
|
|
1174
|
-
|
|
1175
|
-
await this.db.close();
|
|
1179
|
+
public stop(): Promise<void> {
|
|
1180
|
+
return this.jobQueue.end();
|
|
1176
1181
|
}
|
|
1177
1182
|
}
|
|
@@ -23,7 +23,7 @@ export class AnchorBlockStore {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
async getBlockHeader(): Promise<BlockHeader> {
|
|
26
|
-
const headerBuffer = await this.#synchronizedHeader.getAsync();
|
|
26
|
+
const headerBuffer = await this.#store.transactionAsync(() => this.#synchronizedHeader.getAsync());
|
|
27
27
|
if (!headerBuffer) {
|
|
28
28
|
throw new Error(`Trying to get block header with a not-yet-synchronized PXE - this should never happen`);
|
|
29
29
|
}
|
|
@@ -2,7 +2,6 @@ import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
2
2
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
3
|
import type { Capsule } from '@aztec/stdlib/tx';
|
|
4
4
|
|
|
5
|
-
import type { AccessScopes } from '../../access_scopes.js';
|
|
6
5
|
import type { CapsuleStore } from './capsule_store.js';
|
|
7
6
|
|
|
8
7
|
/**
|
|
@@ -12,7 +11,7 @@ import type { CapsuleStore } from './capsule_store.js';
|
|
|
12
11
|
export class CapsuleService {
|
|
13
12
|
constructor(
|
|
14
13
|
private readonly capsuleStore: CapsuleStore,
|
|
15
|
-
private readonly allowedScopes:
|
|
14
|
+
private readonly allowedScopes: AztecAddress[],
|
|
16
15
|
) {}
|
|
17
16
|
|
|
18
17
|
setCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[], jobId: string, scope: AztecAddress) {
|
|
@@ -79,13 +78,13 @@ export class CapsuleService {
|
|
|
79
78
|
}
|
|
80
79
|
}
|
|
81
80
|
|
|
82
|
-
function assertAllowedScope(scope: AztecAddress, allowedScopes:
|
|
83
|
-
if (
|
|
81
|
+
function assertAllowedScope(scope: AztecAddress, allowedScopes: AztecAddress[]) {
|
|
82
|
+
if (scope.equals(AztecAddress.ZERO)) {
|
|
84
83
|
return;
|
|
85
84
|
}
|
|
86
|
-
if (!allowedScopes.some(allowed => allowed.equals(scope))) {
|
|
85
|
+
if (!allowedScopes.some((allowed: AztecAddress) => allowed.equals(scope))) {
|
|
87
86
|
throw new Error(
|
|
88
|
-
`Scope ${scope.toString()} is not in the allowed scopes list: [${allowedScopes.map(s => s.toString()).join(', ')}]. See https://docs.aztec.network/errors/10`,
|
|
87
|
+
`Scope ${scope.toString()} is not in the allowed scopes list: [${allowedScopes.map((s: AztecAddress) => s.toString()).join(', ')}]. See https://docs.aztec.network/errors/10`,
|
|
89
88
|
);
|
|
90
89
|
}
|
|
91
90
|
}
|
|
@@ -148,7 +148,17 @@ export class CapsuleStore implements StagedStore {
|
|
|
148
148
|
* @param slot - The slot in the database to read.
|
|
149
149
|
* @returns The stored data or `null` if no data is stored under the slot.
|
|
150
150
|
*/
|
|
151
|
-
|
|
151
|
+
getCapsule(contractAddress: AztecAddress, slot: Fr, jobId: string, scope: AztecAddress): Promise<Fr[] | null> {
|
|
152
|
+
return this.#store.transactionAsync(() => this.#getCapsuleInternal(contractAddress, slot, jobId, scope));
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** Same as getCapsule but without its own transaction, for use inside an existing transactionAsync. */
|
|
156
|
+
async #getCapsuleInternal(
|
|
157
|
+
contractAddress: AztecAddress,
|
|
158
|
+
slot: Fr,
|
|
159
|
+
jobId: string,
|
|
160
|
+
scope: AztecAddress,
|
|
161
|
+
): Promise<Fr[] | null> {
|
|
152
162
|
const dataBuffer = await this.#getFromStage(jobId, dbSlotToKey(contractAddress, slot, scope));
|
|
153
163
|
if (!dataBuffer) {
|
|
154
164
|
this.logger.trace(`Data not found for contract ${contractAddress.toString()} and slot ${slot.toString()}`);
|
|
@@ -240,7 +250,7 @@ export class CapsuleStore implements StagedStore {
|
|
|
240
250
|
// and not using a transaction here would heavily impact performance.
|
|
241
251
|
return this.#store.transactionAsync(async () => {
|
|
242
252
|
// Load current length, defaulting to 0 if not found
|
|
243
|
-
const lengthData = await this
|
|
253
|
+
const lengthData = await this.#getCapsuleInternal(contractAddress, baseSlot, jobId, scope);
|
|
244
254
|
const currentLength = lengthData ? lengthData[0].toNumber() : 0;
|
|
245
255
|
|
|
246
256
|
// Store each capsule at consecutive slots after baseSlot + 1 + currentLength
|
|
@@ -263,14 +273,14 @@ export class CapsuleStore implements StagedStore {
|
|
|
263
273
|
// of jobs: different calls running concurrently on the same contract may cause trouble.
|
|
264
274
|
return this.#store.transactionAsync(async () => {
|
|
265
275
|
// Load length, defaulting to 0 if not found
|
|
266
|
-
const maybeLength = await this
|
|
276
|
+
const maybeLength = await this.#getCapsuleInternal(contractAddress, baseSlot, jobId, scope);
|
|
267
277
|
const length = maybeLength ? maybeLength[0].toBigInt() : 0n;
|
|
268
278
|
|
|
269
279
|
const values: Fr[][] = [];
|
|
270
280
|
|
|
271
281
|
// Read each capsule at consecutive slots after baseSlot
|
|
272
282
|
for (let i = 0; i < length; i++) {
|
|
273
|
-
const currentValue = await this
|
|
283
|
+
const currentValue = await this.#getCapsuleInternal(contractAddress, arraySlot(baseSlot, i), jobId, scope);
|
|
274
284
|
if (currentValue == undefined) {
|
|
275
285
|
throw new Error(
|
|
276
286
|
`Expected non-empty value at capsule array in base slot ${baseSlot} at index ${i} for contract ${contractAddress}`,
|
|
@@ -295,7 +305,7 @@ export class CapsuleStore implements StagedStore {
|
|
|
295
305
|
// of jobs: different calls running concurrently on the same contract may cause trouble.
|
|
296
306
|
return this.#store.transactionAsync(async () => {
|
|
297
307
|
// Load current length, defaulting to 0 if not found
|
|
298
|
-
const maybeLength = await this
|
|
308
|
+
const maybeLength = await this.#getCapsuleInternal(contractAddress, baseSlot, jobId, scope);
|
|
299
309
|
const originalLength = maybeLength ? maybeLength[0].toNumber() : 0;
|
|
300
310
|
|
|
301
311
|
// Set the new length
|
|
@@ -168,12 +168,14 @@ export class ContractStore {
|
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
async addContractInstance(contract: ContractInstanceWithAddress): Promise<void> {
|
|
171
|
-
this.#
|
|
171
|
+
await this.#store.transactionAsync(async () => {
|
|
172
|
+
await this.#contractInstances.set(
|
|
173
|
+
contract.address.toString(),
|
|
174
|
+
new SerializableContractInstance(contract).toBuffer(),
|
|
175
|
+
);
|
|
176
|
+
});
|
|
172
177
|
|
|
173
|
-
|
|
174
|
-
contract.address.toString(),
|
|
175
|
-
new SerializableContractInstance(contract).toBuffer(),
|
|
176
|
-
);
|
|
178
|
+
this.#contractClassIdMap.set(contract.address.toString(), contract.currentContractClassId);
|
|
177
179
|
}
|
|
178
180
|
|
|
179
181
|
// Private getters
|
|
@@ -246,7 +248,7 @@ export class ContractStore {
|
|
|
246
248
|
contractClassId: Fr,
|
|
247
249
|
): Promise<(ContractClassWithId & ContractClassIdPreimage) | undefined> {
|
|
248
250
|
const key = contractClassId.toString();
|
|
249
|
-
const buf = await this.#contractClassData.getAsync(key);
|
|
251
|
+
const buf = await this.#store.transactionAsync(() => this.#contractClassData.getAsync(key));
|
|
250
252
|
if (!buf) {
|
|
251
253
|
return undefined;
|
|
252
254
|
}
|
|
@@ -106,7 +106,7 @@ export class NoteStore implements StagedStore {
|
|
|
106
106
|
* returned once if this is the case)
|
|
107
107
|
*/
|
|
108
108
|
getNotes(filter: NotesFilter, jobId: string): Promise<NoteDao[]> {
|
|
109
|
-
if (filter.scopes
|
|
109
|
+
if (filter.scopes.length === 0) {
|
|
110
110
|
return Promise.resolve([]);
|
|
111
111
|
}
|
|
112
112
|
|
|
@@ -180,10 +180,7 @@ export class NoteStore implements StagedStore {
|
|
|
180
180
|
continue;
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
if (
|
|
184
|
-
filter.scopes !== 'ALL_SCOPES' &&
|
|
185
|
-
note.scopes.intersection(new Set(filter.scopes.map(s => s.toString()))).size === 0
|
|
186
|
-
) {
|
|
183
|
+
if (note.scopes.intersection(new Set(filter.scopes.map(s => s.toString()))).size === 0) {
|
|
187
184
|
continue;
|
|
188
185
|
}
|
|
189
186
|
|
|
@@ -21,6 +21,8 @@ export async function loadPrivateLogsForSenderRecipientPair(
|
|
|
21
21
|
taggingStore: RecipientTaggingStore,
|
|
22
22
|
anchorBlockNumber: BlockNumber,
|
|
23
23
|
anchorBlockHash: BlockHash,
|
|
24
|
+
currentTimestamp: bigint,
|
|
25
|
+
finalizedBlockNumber: BlockNumber,
|
|
24
26
|
jobId: string,
|
|
25
27
|
): Promise<TxScopedL2Log[]> {
|
|
26
28
|
// # Explanation of how the algorithm works
|
|
@@ -61,20 +63,6 @@ export async function loadPrivateLogsForSenderRecipientPair(
|
|
|
61
63
|
// the highest finalized index. If that index was already used, they will throw an error. For this reason we
|
|
62
64
|
// don't have to look further than `highestFinalizedIndex + WINDOW_LEN`.
|
|
63
65
|
|
|
64
|
-
let finalizedBlockNumber: number, currentTimestamp: bigint;
|
|
65
|
-
{
|
|
66
|
-
const [l2Tips, latestBlockHeader] = await Promise.all([aztecNode.getL2Tips(), aztecNode.getBlockHeader('latest')]);
|
|
67
|
-
|
|
68
|
-
if (!latestBlockHeader) {
|
|
69
|
-
throw new Error('Node failed to return latest block header when syncing logs');
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
[finalizedBlockNumber, currentTimestamp] = [
|
|
73
|
-
l2Tips.finalized.block.number,
|
|
74
|
-
latestBlockHeader.globalVariables.timestamp,
|
|
75
|
-
];
|
|
76
|
-
}
|
|
77
|
-
|
|
78
66
|
let start: number, end: number;
|
|
79
67
|
{
|
|
80
68
|
const currentHighestAgedIndex = await taggingStore.getHighestAgedIndex(secret, jobId);
|
package/dest/access_scopes.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
2
|
-
/**
|
|
3
|
-
* Controls which accounts' private state and keys are accessible during execution.
|
|
4
|
-
* - `'ALL_SCOPES'`: All registered accounts' private state and keys are accessible.
|
|
5
|
-
* - `AztecAddress[]` with entries: Only the specified accounts' private state and keys are accessible.
|
|
6
|
-
* - `[]` (empty array): Deny-all. No private state is visible and no keys are accessible.
|
|
7
|
-
*/
|
|
8
|
-
export type AccessScopes = 'ALL_SCOPES' | AztecAddress[];
|
|
9
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWNjZXNzX3Njb3Blcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2FjY2Vzc19zY29wZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFFaEU7Ozs7O0dBS0c7QUFDSCxNQUFNLE1BQU0sWUFBWSxHQUFHLFlBQVksR0FBRyxZQUFZLEVBQUUsQ0FBQyJ9
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"access_scopes.d.ts","sourceRoot":"","sources":["../src/access_scopes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,YAAY,EAAE,CAAC"}
|
package/dest/access_scopes.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Controls which accounts' private state and keys are accessible during execution.
|
|
3
|
-
* - `'ALL_SCOPES'`: All registered accounts' private state and keys are accessible.
|
|
4
|
-
* - `AztecAddress[]` with entries: Only the specified accounts' private state and keys are accessible.
|
|
5
|
-
* - `[]` (empty array): Deny-all. No private state is visible and no keys are accessible.
|
|
6
|
-
*/ export { };
|
package/src/access_scopes.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Controls which accounts' private state and keys are accessible during execution.
|
|
5
|
-
* - `'ALL_SCOPES'`: All registered accounts' private state and keys are accessible.
|
|
6
|
-
* - `AztecAddress[]` with entries: Only the specified accounts' private state and keys are accessible.
|
|
7
|
-
* - `[]` (empty array): Deny-all. No private state is visible and no keys are accessible.
|
|
8
|
-
*/
|
|
9
|
-
export type AccessScopes = 'ALL_SCOPES' | AztecAddress[];
|