@aztec/pxe 0.0.1-commit.f504929 → 0.0.1-commit.f5d02921e
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/block_synchronizer/block_synchronizer.d.ts +1 -1
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +6 -0
- 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/contract_function_simulator/contract_function_simulator.d.ts +9 -3
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +29 -6
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +5 -5
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +17 -9
- package/dest/contract_function_simulator/index.d.ts +2 -1
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +1 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +3 -5
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +7 -9
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +1 -3
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +3 -6
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +5 -10
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +26 -21
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +9 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +38 -0
- package/dest/contract_function_simulator/oracle/oracle.d.ts +39 -19
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +91 -44
- package/dest/contract_function_simulator/oracle/private_execution.js +5 -3
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +11 -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 +12 -44
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +50 -28
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +167 -64
- package/dest/contract_logging.d.ts +9 -4
- package/dest/contract_logging.d.ts.map +1 -1
- package/dest/contract_logging.js +21 -6
- package/dest/contract_sync/contract_sync_service.d.ts +7 -4
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
- package/dest/contract_sync/contract_sync_service.js +59 -32
- package/dest/contract_sync/helpers.d.ts +2 -2
- package/dest/contract_sync/helpers.d.ts.map +1 -1
- package/dest/contract_sync/helpers.js +7 -2
- package/dest/events/event_service.d.ts +3 -2
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +16 -4
- package/dest/logs/log_service.d.ts +6 -7
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +24 -28
- package/dest/messages/message_context_service.d.ts +17 -0
- package/dest/messages/message_context_service.d.ts.map +1 -0
- package/dest/messages/message_context_service.js +36 -0
- 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 +14 -5
- package/dest/oracle_version.d.ts +2 -2
- package/dest/oracle_version.js +2 -2
- package/dest/pxe.d.ts +6 -3
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +37 -21
- package/dest/storage/capsule_store/capsule_service.d.ts +22 -0
- package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -0
- package/dest/storage/capsule_store/capsule_service.js +50 -0
- package/dest/storage/capsule_store/capsule_store.d.ts +9 -9
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
- package/dest/storage/capsule_store/capsule_store.js +33 -28
- package/dest/storage/capsule_store/index.d.ts +2 -1
- package/dest/storage/capsule_store/index.d.ts.map +1 -1
- package/dest/storage/capsule_store/index.js +1 -0
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +26 -25
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +141 -115
- package/dest/tagging/index.d.ts +2 -2
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +10 -1
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +4 -3
- 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 +20 -10
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +2 -1
- 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 +24 -11
- package/package.json +16 -16
- package/src/block_synchronizer/block_synchronizer.ts +6 -0
- package/src/config/index.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +40 -7
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +16 -11
- package/src/contract_function_simulator/index.ts +1 -0
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +8 -8
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +1 -4
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +3 -9
- package/src/contract_function_simulator/oracle/interfaces.ts +38 -29
- package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +98 -0
- package/src/contract_function_simulator/oracle/oracle.ts +120 -64
- package/src/contract_function_simulator/oracle/private_execution.ts +4 -4
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +14 -62
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +290 -77
- package/src/contract_logging.ts +18 -5
- package/src/contract_sync/contract_sync_service.ts +89 -49
- package/src/contract_sync/helpers.ts +3 -2
- package/src/events/event_service.ts +17 -4
- package/src/logs/log_service.ts +51 -46
- package/src/messages/message_context_service.ts +44 -0
- package/src/notes/note_service.ts +16 -5
- package/src/oracle_version.ts +2 -2
- package/src/pxe.ts +55 -19
- package/src/storage/capsule_store/capsule_service.ts +91 -0
- package/src/storage/capsule_store/capsule_store.ts +34 -26
- package/src/storage/capsule_store/index.ts +1 -0
- package/src/storage/metadata.ts +1 -1
- package/src/storage/tagging_store/sender_tagging_store.ts +182 -135
- package/src/tagging/index.ts +1 -1
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +19 -1
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +26 -11
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +19 -9
package/dest/pxe.d.ts
CHANGED
|
@@ -34,7 +34,9 @@ export type SimulateTxOpts = {
|
|
|
34
34
|
skipTxValidation?: boolean;
|
|
35
35
|
/** If false, fees are enforced. */
|
|
36
36
|
skipFeeEnforcement?: boolean;
|
|
37
|
-
/**
|
|
37
|
+
/** If true, kernel logic is emulated in TS for simulation */
|
|
38
|
+
skipKernels?: boolean;
|
|
39
|
+
/** State overrides for the simulation, such as contract instances and artifacts. Requires skipKernels: true */
|
|
38
40
|
overrides?: SimulationOverrides;
|
|
39
41
|
/** Addresses whose private state and keys are accessible during private execution */
|
|
40
42
|
scopes: AccessScopes;
|
|
@@ -83,6 +85,7 @@ export declare class PXE {
|
|
|
83
85
|
private addressStore;
|
|
84
86
|
private privateEventStore;
|
|
85
87
|
private contractSyncService;
|
|
88
|
+
private messageContextService;
|
|
86
89
|
private simulator;
|
|
87
90
|
private proverEnabled;
|
|
88
91
|
private proofCreator;
|
|
@@ -223,7 +226,7 @@ export declare class PXE {
|
|
|
223
226
|
*
|
|
224
227
|
* TODO(#7456) Prevent msgSender being defined here for the first call
|
|
225
228
|
*/
|
|
226
|
-
simulateTx(txRequest: TxExecutionRequest, { simulatePublic, skipTxValidation, skipFeeEnforcement, overrides, scopes }: SimulateTxOpts): Promise<TxSimulationResult>;
|
|
229
|
+
simulateTx(txRequest: TxExecutionRequest, { simulatePublic, skipTxValidation, skipFeeEnforcement, skipKernels, overrides, scopes }: SimulateTxOpts): Promise<TxSimulationResult>;
|
|
227
230
|
/**
|
|
228
231
|
* Executes a contract utility function.
|
|
229
232
|
* @param call - The function call containing the function details, arguments, and target contract address.
|
|
@@ -248,4 +251,4 @@ export declare class PXE {
|
|
|
248
251
|
*/
|
|
249
252
|
stop(): Promise<void>;
|
|
250
253
|
}
|
|
251
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
254
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHhlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvcHhlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLGtCQUFrQixFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFFakUsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BELE9BQU8sRUFBRSxLQUFLLE1BQU0sRUFBcUMsTUFBTSx1QkFBdUIsQ0FBQztBQUl2RixPQUFPLEtBQUssRUFBRSxpQkFBaUIsRUFBRSxNQUFNLGlCQ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SAAS,EAAE,kBAAkB,EAC7B,EACE,cAAc,EACd,gBAAwB,EACxB,kBAA0B,EAC1B,WAAkB,EAClB,SAAS,EACT,MAAM,EACP,EAAE,cAAc,GAChB,OAAO,CAAC,kBAAkB,CAAC,CAuI7B;IAED;;;OAGG;IACI,cAAc,CACnB,IAAI,EAAE,YAAY,EAClB,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAE,kBAA6C,GAClE,OAAO,CAAC,sBAAsB,CAAC,CA6DjC;IAED;;;;;;;;;;;;OAYG;IACU,gBAAgB,CAC3B,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,kBAAkB,EAAE,CAAC,CA8B/B;IAED;;OAEG;IACU,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAGjC;CACF"}
|
package/dest/pxe.js
CHANGED
|
@@ -20,6 +20,7 @@ import { PXEDebugUtils } from './debug/pxe_debug_utils.js';
|
|
|
20
20
|
import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
|
|
21
21
|
import { PrivateEventFilterValidator } from './events/private_event_filter_validator.js';
|
|
22
22
|
import { JobCoordinator } from './job_coordinator/job_coordinator.js';
|
|
23
|
+
import { MessageContextService } from './messages/message_context_service.js';
|
|
23
24
|
import { PrivateKernelExecutionProver } from './private_kernel/private_kernel_execution_prover.js';
|
|
24
25
|
import { PrivateKernelOracle } from './private_kernel/private_kernel_oracle.js';
|
|
25
26
|
import { AddressStore } from './storage/address_store/address_store.js';
|
|
@@ -49,6 +50,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
49
50
|
addressStore;
|
|
50
51
|
privateEventStore;
|
|
51
52
|
contractSyncService;
|
|
53
|
+
messageContextService;
|
|
52
54
|
simulator;
|
|
53
55
|
proverEnabled;
|
|
54
56
|
proofCreator;
|
|
@@ -57,7 +59,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
57
59
|
jobQueue;
|
|
58
60
|
jobCoordinator;
|
|
59
61
|
debug;
|
|
60
|
-
constructor(node, db, blockStateSynchronizer, keyStore, contractStore, noteStore, capsuleStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, addressStore, privateEventStore, contractSyncService, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue, jobCoordinator, debug){
|
|
62
|
+
constructor(node, db, blockStateSynchronizer, keyStore, contractStore, noteStore, capsuleStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, addressStore, privateEventStore, contractSyncService, messageContextService, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue, jobCoordinator, debug){
|
|
61
63
|
this.node = node;
|
|
62
64
|
this.db = db;
|
|
63
65
|
this.blockStateSynchronizer = blockStateSynchronizer;
|
|
@@ -72,6 +74,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
72
74
|
this.addressStore = addressStore;
|
|
73
75
|
this.privateEventStore = privateEventStore;
|
|
74
76
|
this.contractSyncService = contractSyncService;
|
|
77
|
+
this.messageContextService = messageContextService;
|
|
75
78
|
this.simulator = simulator;
|
|
76
79
|
this.proverEnabled = proverEnabled;
|
|
77
80
|
this.proofCreator = proofCreator;
|
|
@@ -104,7 +107,8 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
104
107
|
const capsuleStore = new CapsuleStore(store);
|
|
105
108
|
const keyStore = new KeyStore(store);
|
|
106
109
|
const tipsStore = new L2TipsKVStore(store, 'pxe');
|
|
107
|
-
const contractSyncService = new ContractSyncService(node, contractStore, noteStore, createLogger('pxe:contract_sync', bindings));
|
|
110
|
+
const contractSyncService = new ContractSyncService(node, contractStore, noteStore, ()=>keyStore.getAccounts(), createLogger('pxe:contract_sync', bindings));
|
|
111
|
+
const messageContextService = new MessageContextService(node);
|
|
108
112
|
const synchronizer = new BlockSynchronizer(node, store, anchorBlockStore, noteStore, privateEventStore, tipsStore, contractSyncService, config, bindings);
|
|
109
113
|
const jobCoordinator = new JobCoordinator(store, bindings);
|
|
110
114
|
jobCoordinator.registerStores([
|
|
@@ -117,7 +121,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
117
121
|
]);
|
|
118
122
|
const debugUtils = new PXEDebugUtils(contractSyncService, noteStore, synchronizer, anchorBlockStore);
|
|
119
123
|
const jobQueue = new SerialQueue();
|
|
120
|
-
const pxe = new PXE(node, store, synchronizer, keyStore, contractStore, noteStore, capsuleStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, addressStore, privateEventStore, contractSyncService, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue, jobCoordinator, debugUtils);
|
|
124
|
+
const pxe = new PXE(node, store, synchronizer, keyStore, contractStore, noteStore, capsuleStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, addressStore, privateEventStore, contractSyncService, messageContextService, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue, jobCoordinator, debugUtils);
|
|
121
125
|
debugUtils.setPXEHelpers(pxe.#putInJobQueue.bind(pxe), pxe.#getSimulatorForTx.bind(pxe), pxe.#executeUtility.bind(pxe));
|
|
122
126
|
pxe.jobQueue.start();
|
|
123
127
|
await pxe.#registerProtocolContracts();
|
|
@@ -139,7 +143,8 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
139
143
|
capsuleStore: this.capsuleStore,
|
|
140
144
|
privateEventStore: this.privateEventStore,
|
|
141
145
|
simulator: this.simulator,
|
|
142
|
-
contractSyncService: this.contractSyncService
|
|
146
|
+
contractSyncService: this.contractSyncService,
|
|
147
|
+
messageContextService: this.messageContextService
|
|
143
148
|
});
|
|
144
149
|
}
|
|
145
150
|
#contextualizeError(err, ...context) {
|
|
@@ -225,7 +230,11 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
225
230
|
*/ async #executeUtility(contractFunctionSimulator, call, authWitnesses, scopes, jobId) {
|
|
226
231
|
try {
|
|
227
232
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
228
|
-
|
|
233
|
+
const { result, offchainEffects } = await contractFunctionSimulator.runUtility(call, authWitnesses ?? [], anchorBlockHeader, scopes, jobId);
|
|
234
|
+
return {
|
|
235
|
+
result,
|
|
236
|
+
offchainEffects
|
|
237
|
+
};
|
|
229
238
|
} catch (err) {
|
|
230
239
|
if (err instanceof SimulationError) {
|
|
231
240
|
await enrichSimulationError(err, this.contractStore, this.log);
|
|
@@ -281,7 +290,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
281
290
|
* Returns the block header up to which the PXE has synced.
|
|
282
291
|
* @returns The synced block header
|
|
283
292
|
*/ getSyncedBlockHeader() {
|
|
284
|
-
return this
|
|
293
|
+
return this.#putInJobQueue(()=>{
|
|
294
|
+
return this.anchorBlockStore.getBlockHeader();
|
|
295
|
+
});
|
|
285
296
|
}
|
|
286
297
|
/**
|
|
287
298
|
* Returns the contract instance for a given address, if it's registered in the PXE.
|
|
@@ -337,6 +348,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
337
348
|
const wasAdded = await this.senderAddressBookStore.addSender(sender);
|
|
338
349
|
if (wasAdded) {
|
|
339
350
|
this.log.info(`Added sender:\n ${sender.toString()}`);
|
|
351
|
+
// Wipe the entire sync cache: the new sender's tagged logs could contain notes/events for any contract, so
|
|
352
|
+
// all contracts must re-sync to discover them.
|
|
353
|
+
this.contractSyncService.wipe();
|
|
340
354
|
} else {
|
|
341
355
|
this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
|
|
342
356
|
}
|
|
@@ -500,16 +514,16 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
500
514
|
// transaction before this one is included in a block from this PXE, and that transaction contains a log with
|
|
501
515
|
// a tag derived from the same secret, we would reuse the tag and the transactions would be linked. Hence
|
|
502
516
|
// storing the tags here prevents linkage of txs sent from the same PXE.
|
|
503
|
-
const
|
|
504
|
-
if (
|
|
517
|
+
const taggingIndexRangesUsedInTheTx = privateExecutionResult.entrypoint.taggingIndexRanges;
|
|
518
|
+
if (taggingIndexRangesUsedInTheTx.length > 0) {
|
|
505
519
|
// TODO(benesjan): The following is an expensive operation. Figure out a way to avoid it.
|
|
506
520
|
const txHash = (await txProvingResult.toTx()).txHash;
|
|
507
|
-
await this.senderTaggingStore.storePendingIndexes(
|
|
508
|
-
this.log.debug(`Stored used
|
|
509
|
-
|
|
521
|
+
await this.senderTaggingStore.storePendingIndexes(taggingIndexRangesUsedInTheTx, txHash, jobId);
|
|
522
|
+
this.log.debug(`Stored used tagging index ranges as sender for the tx`, {
|
|
523
|
+
taggingIndexRangesUsedInTheTx
|
|
510
524
|
});
|
|
511
525
|
} else {
|
|
512
|
-
this.log.debug(`No
|
|
526
|
+
this.log.debug(`No tagging index ranges used in the tx`);
|
|
513
527
|
}
|
|
514
528
|
return txProvingResult;
|
|
515
529
|
} catch (err) {
|
|
@@ -591,7 +605,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
591
605
|
* Also throws if simulatePublic is true and public simulation reverts.
|
|
592
606
|
*
|
|
593
607
|
* TODO(#7456) Prevent msgSender being defined here for the first call
|
|
594
|
-
*/ simulateTx(txRequest, { simulatePublic, skipTxValidation = false, skipFeeEnforcement = false, overrides, scopes }) {
|
|
608
|
+
*/ simulateTx(txRequest, { simulatePublic, skipTxValidation = false, skipFeeEnforcement = false, skipKernels = true, overrides, scopes }) {
|
|
595
609
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
596
610
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
597
611
|
// delete the same read value, or reading values that another simulation is currently modifying).
|
|
@@ -610,16 +624,16 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
610
624
|
const syncTimer = new Timer();
|
|
611
625
|
await this.blockStateSynchronizer.sync();
|
|
612
626
|
const syncTime = syncTimer.ms();
|
|
613
|
-
const contractFunctionSimulator = this.#getSimulatorForTx(overrides);
|
|
614
|
-
// Temporary: in case there are overrides, we have to skip the kernels or validations
|
|
615
|
-
// will fail. Consider handing control to the user/wallet on whether they want to run them
|
|
616
|
-
// or not.
|
|
617
627
|
const overriddenContracts = overrides?.contracts ? new Set(Object.keys(overrides.contracts)) : undefined;
|
|
618
628
|
const hasOverriddenContracts = overriddenContracts !== undefined && overriddenContracts.size > 0;
|
|
619
|
-
|
|
620
|
-
|
|
629
|
+
if (hasOverriddenContracts && !skipKernels) {
|
|
630
|
+
throw new Error('Simulating with overridden contracts is not compatible with kernel execution. Please set skipKernels to true when simulating with overridden contracts.');
|
|
631
|
+
}
|
|
632
|
+
const contractFunctionSimulator = this.#getSimulatorForTx(overrides);
|
|
621
633
|
if (hasOverriddenContracts) {
|
|
622
|
-
|
|
634
|
+
// Overridden contracts don't have a sync function, so calling sync on them would fail.
|
|
635
|
+
// We exclude them so the sync service skips them entirely.
|
|
636
|
+
this.contractSyncService.setExcludedFromSync(jobId, overriddenContracts);
|
|
623
637
|
}
|
|
624
638
|
// Execution of private functions only; no proving, and no kernel logic.
|
|
625
639
|
const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
|
|
@@ -713,7 +727,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
713
727
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
714
728
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
715
729
|
await this.contractSyncService.ensureContractSynced(call.to, call.selector, (privateSyncCall, execScopes)=>this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId), anchorBlockHeader, jobId, scopes);
|
|
716
|
-
const executionResult = await this.#executeUtility(contractFunctionSimulator, call, authwits ?? [], scopes, jobId);
|
|
730
|
+
const { result: executionResult, offchainEffects } = await this.#executeUtility(contractFunctionSimulator, call, authwits ?? [], scopes, jobId);
|
|
717
731
|
const functionTime = functionTimer.ms();
|
|
718
732
|
const totalTime = totalTimer.ms();
|
|
719
733
|
const perFunction = [
|
|
@@ -731,6 +745,8 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
731
745
|
const simulationStats = contractFunctionSimulator.getStats();
|
|
732
746
|
return {
|
|
733
747
|
result: executionResult,
|
|
748
|
+
offchainEffects,
|
|
749
|
+
anchorBlockTimestamp: anchorBlockHeader.globalVariables.timestamp,
|
|
734
750
|
stats: {
|
|
735
751
|
timings,
|
|
736
752
|
nodeRPCCalls: simulationStats.nodeRPCCalls
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import type { Capsule } from '@aztec/stdlib/tx';
|
|
4
|
+
import type { AccessScopes } from '../../access_scopes.js';
|
|
5
|
+
import type { CapsuleStore } from './capsule_store.js';
|
|
6
|
+
/**
|
|
7
|
+
* Wraps a CapsuleStore with scope-based access control. Each operation asserts that the requested scope is in the
|
|
8
|
+
* allowed scopes list before delegating to the underlying store.
|
|
9
|
+
*/
|
|
10
|
+
export declare class CapsuleService {
|
|
11
|
+
private readonly capsuleStore;
|
|
12
|
+
private readonly allowedScopes;
|
|
13
|
+
constructor(capsuleStore: CapsuleStore, allowedScopes: AccessScopes);
|
|
14
|
+
setCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[], jobId: string, scope: AztecAddress): void;
|
|
15
|
+
getCapsule(contractAddress: AztecAddress, slot: Fr, jobId: string, scope: AztecAddress, transientCapsules?: Capsule[]): Promise<Fr[] | null>;
|
|
16
|
+
deleteCapsule(contractAddress: AztecAddress, slot: Fr, jobId: string, scope: AztecAddress): void;
|
|
17
|
+
copyCapsule(contractAddress: AztecAddress, srcSlot: Fr, dstSlot: Fr, numEntries: number, jobId: string, scope: AztecAddress): Promise<void>;
|
|
18
|
+
appendToCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][], jobId: string, scope: AztecAddress): Promise<void>;
|
|
19
|
+
readCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, jobId: string, scope: AztecAddress): Promise<Fr[][]>;
|
|
20
|
+
setCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][], jobId: string, scope: AztecAddress): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2Fwc3VsZV9zZXJ2aWNlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvc3RvcmFnZS9jYXBzdWxlX3N0b3JlL2NhcHN1bGVfc2VydmljZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUN6RCxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFDM0QsT0FBTyxLQUFLLEVBQUUsT0FBTyxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFaEQsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFDM0QsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFFdkQ7OztHQUdHO0FBQ0gscUJBQWEsY0FBYztJQUV2QixPQUFPLENBQUMsUUFBUSxDQUFDLFlBQVk7SUFDN0IsT0FBTyxDQUFDLFFBQVEsQ0FBQyxhQUFhO0lBRmhDLFlBQ21CLFlBQVksRUFBRSxZQUFZLEVBQzFCLGFBQWEsRUFBRSxZQUFZLEVBQzFDO0lBRUosVUFBVSxDQUFDLGVBQWUsRUFBRSxZQUFZLEVBQUUsSUFBSSxFQUFFLEVBQUUs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M,EAAE,KAAK,EAAE,YAAY,QAGxF;IAED,WAAW,CACT,eAAe,EAAE,YAAY,EAC7B,OAAO,EAAE,EAAE,EACX,OAAO,EAAE,EAAE,EACX,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,IAAI,CAAC,CAGf;IAED,oBAAoB,CAClB,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,EAAE,EACZ,OAAO,EAAE,EAAE,EAAE,EAAE,EACf,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,IAAI,CAAC,CAGf;IAED,gBAAgB,CAAC,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CAGjH;IAED,eAAe,CAAC,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,iBAG/G;CACF"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
2
|
+
/**
|
|
3
|
+
* Wraps a CapsuleStore with scope-based access control. Each operation asserts that the requested scope is in the
|
|
4
|
+
* allowed scopes list before delegating to the underlying store.
|
|
5
|
+
*/ export class CapsuleService {
|
|
6
|
+
capsuleStore;
|
|
7
|
+
allowedScopes;
|
|
8
|
+
constructor(capsuleStore, allowedScopes){
|
|
9
|
+
this.capsuleStore = capsuleStore;
|
|
10
|
+
this.allowedScopes = allowedScopes;
|
|
11
|
+
}
|
|
12
|
+
setCapsule(contractAddress, slot, capsule, jobId, scope) {
|
|
13
|
+
assertAllowedScope(scope, this.allowedScopes);
|
|
14
|
+
this.capsuleStore.setCapsule(contractAddress, slot, capsule, jobId, scope);
|
|
15
|
+
}
|
|
16
|
+
async getCapsule(contractAddress, slot, jobId, scope, transientCapsules) {
|
|
17
|
+
assertAllowedScope(scope, this.allowedScopes);
|
|
18
|
+
// TODO(#12425): On the following line, the pertinent capsule gets overshadowed by the transient one. Tackle this.
|
|
19
|
+
const maybeTransientCapsule = transientCapsules?.find((c)=>c.contractAddress.equals(contractAddress) && c.storageSlot.equals(slot) && (c.scope ?? AztecAddress.ZERO).equals(scope))?.data;
|
|
20
|
+
return maybeTransientCapsule ?? await this.capsuleStore.getCapsule(contractAddress, slot, jobId, scope);
|
|
21
|
+
}
|
|
22
|
+
deleteCapsule(contractAddress, slot, jobId, scope) {
|
|
23
|
+
assertAllowedScope(scope, this.allowedScopes);
|
|
24
|
+
this.capsuleStore.deleteCapsule(contractAddress, slot, jobId, scope);
|
|
25
|
+
}
|
|
26
|
+
copyCapsule(contractAddress, srcSlot, dstSlot, numEntries, jobId, scope) {
|
|
27
|
+
assertAllowedScope(scope, this.allowedScopes);
|
|
28
|
+
return this.capsuleStore.copyCapsule(contractAddress, srcSlot, dstSlot, numEntries, jobId, scope);
|
|
29
|
+
}
|
|
30
|
+
appendToCapsuleArray(contractAddress, baseSlot, content, jobId, scope) {
|
|
31
|
+
assertAllowedScope(scope, this.allowedScopes);
|
|
32
|
+
return this.capsuleStore.appendToCapsuleArray(contractAddress, baseSlot, content, jobId, scope);
|
|
33
|
+
}
|
|
34
|
+
readCapsuleArray(contractAddress, baseSlot, jobId, scope) {
|
|
35
|
+
assertAllowedScope(scope, this.allowedScopes);
|
|
36
|
+
return this.capsuleStore.readCapsuleArray(contractAddress, baseSlot, jobId, scope);
|
|
37
|
+
}
|
|
38
|
+
setCapsuleArray(contractAddress, baseSlot, content, jobId, scope) {
|
|
39
|
+
assertAllowedScope(scope, this.allowedScopes);
|
|
40
|
+
return this.capsuleStore.setCapsuleArray(contractAddress, baseSlot, content, jobId, scope);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function assertAllowedScope(scope, allowedScopes) {
|
|
44
|
+
if (allowedScopes === 'ALL_SCOPES' || scope.equals(AztecAddress.ZERO)) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (!allowedScopes.some((allowed)=>allowed.equals(scope))) {
|
|
48
|
+
throw new Error(`Scope ${scope.toString()} is not in the allowed scopes list: [${allowedScopes.map((s)=>s.toString()).join(', ')}]. See https://docs.aztec.network/errors/10`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import { type Logger } from '@aztec/foundation/log';
|
|
3
3
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
4
|
-
import
|
|
4
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
5
|
import type { StagedStore } from '../../job_coordinator/job_coordinator.js';
|
|
6
6
|
export declare class CapsuleStore implements StagedStore {
|
|
7
7
|
#private;
|
|
@@ -31,20 +31,20 @@ export declare class CapsuleStore implements StagedStore {
|
|
|
31
31
|
* to public contract storage in that it's indexed by the contract address and storage slot but instead of the global
|
|
32
32
|
* network state it's backed by local PXE db.
|
|
33
33
|
*/
|
|
34
|
-
|
|
34
|
+
setCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[], jobId: string, scope: AztecAddress): void;
|
|
35
35
|
/**
|
|
36
36
|
* Returns data previously stored via `storeCapsule` in the per-contract non-volatile database.
|
|
37
37
|
* @param contractAddress - The contract address under which the data is scoped.
|
|
38
38
|
* @param slot - The slot in the database to read.
|
|
39
39
|
* @returns The stored data or `null` if no data is stored under the slot.
|
|
40
40
|
*/
|
|
41
|
-
|
|
41
|
+
getCapsule(contractAddress: AztecAddress, slot: Fr, jobId: string, scope: AztecAddress): Promise<Fr[] | null>;
|
|
42
42
|
/**
|
|
43
43
|
* Deletes data in the per-contract non-volatile database. Does nothing if no data was present.
|
|
44
44
|
* @param contractAddress - The contract address under which the data is scoped.
|
|
45
45
|
* @param slot - The slot in the database to delete.
|
|
46
46
|
*/
|
|
47
|
-
deleteCapsule(contractAddress: AztecAddress, slot: Fr, jobId: string): void;
|
|
47
|
+
deleteCapsule(contractAddress: AztecAddress, slot: Fr, jobId: string, scope: AztecAddress): void;
|
|
48
48
|
/**
|
|
49
49
|
* Copies a number of contiguous entries in the per-contract non-volatile database. This allows for efficient data
|
|
50
50
|
* structures by avoiding repeated calls to `loadCapsule` and `storeCapsule`.
|
|
@@ -56,7 +56,7 @@ export declare class CapsuleStore implements StagedStore {
|
|
|
56
56
|
* @param dstSlot - The first slot to copy to.
|
|
57
57
|
* @param numEntries - The number of entries to copy.
|
|
58
58
|
*/
|
|
59
|
-
copyCapsule(contractAddress: AztecAddress, srcSlot: Fr, dstSlot: Fr, numEntries: number, jobId: string): Promise<void>;
|
|
59
|
+
copyCapsule(contractAddress: AztecAddress, srcSlot: Fr, dstSlot: Fr, numEntries: number, jobId: string, scope: AztecAddress): Promise<void>;
|
|
60
60
|
/**
|
|
61
61
|
* Appends multiple capsules to a capsule array stored at the base slot.
|
|
62
62
|
* The array length is stored at the base slot, and elements are stored in consecutive slots after it.
|
|
@@ -65,8 +65,8 @@ export declare class CapsuleStore implements StagedStore {
|
|
|
65
65
|
* @param baseSlot - The slot where the array length is stored
|
|
66
66
|
* @param content - Array of capsule data to append
|
|
67
67
|
*/
|
|
68
|
-
appendToCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][], jobId: string): Promise<void>;
|
|
69
|
-
readCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, jobId: string): Promise<Fr[][]>;
|
|
70
|
-
setCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][], jobId: string): Promise<void>;
|
|
68
|
+
appendToCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][], jobId: string, scope: AztecAddress): Promise<void>;
|
|
69
|
+
readCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, jobId: string, scope: AztecAddress): Promise<Fr[][]>;
|
|
70
|
+
setCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][], jobId: string, scope: AztecAddress): Promise<void>;
|
|
71
71
|
}
|
|
72
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
72
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2Fwc3VsZV9zdG9yZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3N0b3JhZ2UvY2Fwc3VsZV9zdG9yZS9jYXBzdWxlX3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUNwRCxPQUFPLEVBQUUsS0FBSyxNQUFNLEVBQWdCLE1BQU0sdUJBQXVCLENBQUM7QUFDbEUsT0FBTyxLQUFLLEVBQUUsaUJBQWlCLEVBQWlCLE1BQU0saUJBQWlCLENBQUM7QUFDeEUsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBRTNELE9BQU8sS0FBSyxFQUFFLFdBQVcsRUFBRSxNQUFNLDBDQUEwQyxDQUFDO0FBRTVFLHFCQUFhLFlBQWEsWUFBVyxXQUFXOztJQUM5QyxRQUFRLENBQUMsU0FBUyxhQUFhO0lBYS9CLE1BQU0sRUFBRSxNQUFNLENBQUM7SUFFZixZQUFZLEtBQUssRUFBRSxpQkFBaUIsRUFRbkM7SUErREQ7Ozs7OztPQU1HO0lBQ0csTUFBTSxDQUFDLEtBQUssRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQWV6QztJQUVEOztPQUVHO0lBQ0gsYUFBYSxDQUFDLEtBQUssRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUcxQztJQUVEOzs7Ozs7Ozs7O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FLFFBQVEsRUFBRSxFQUFFLEVBQUUsS0FBSyxFQUFFLE1BQU0sRUFBRSxLQUFLLEVBQUUsWUFBWSxHQUFHLE9BQU8sQ0FBQyxFQUFFLEVBQUUsRUFBRSxDQUFDLENBMkJqSDtJQUVELGVBQWUsQ0FBQyxlQUFlLEVBQUUsWUFBWSxFQUFFLFFBQVEsRUFBRSxFQUFFLEVBQUUsT0FBTyxFQUFFLEVBQUUsRUFBRSxFQUFFLEVBQUUsS0FBSyxFQUFFLE1BQU0sRUFBRSxLQUFLLEVBQUUsWUFBWSxpQkEyQi9HO0NBQ0YifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capsule_store.d.ts","sourceRoot":"","sources":["../../../src/storage/capsule_store/capsule_store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,
|
|
1
|
+
{"version":3,"file":"capsule_store.d.ts","sourceRoot":"","sources":["../../../src/storage/capsule_store/capsule_store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAE5E,qBAAa,YAAa,YAAW,WAAW;;IAC9C,QAAQ,CAAC,SAAS,aAAa;IAa/B,MAAM,EAAE,MAAM,CAAC;IAEf,YAAY,KAAK,EAAE,iBAAiB,EAQnC;IA+DD;;;;;;OAMG;IACG,MAAM,CAAC,KAAK,EAAE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E,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,iBA2B/G;CACF"}
|
|
@@ -3,10 +3,11 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
3
3
|
export class CapsuleStore {
|
|
4
4
|
storeName = 'capsule';
|
|
5
5
|
#store;
|
|
6
|
-
// Arbitrary data stored by contracts. Key is computed as `${contractAddress}:${key}
|
|
6
|
+
// Arbitrary data stored by contracts. Key is computed as `${contractAddress}:${scope}:${key}`, using the zero
|
|
7
|
+
// address for the global scope.
|
|
7
8
|
#capsules;
|
|
8
|
-
// jobId => `${contractAddress}:${key}` => capsule data
|
|
9
|
-
// when `#stagedCapsules.get('some-job-id').get('${some-contract-address
|
|
9
|
+
// jobId => `${contractAddress}:${scope}:${key}` => capsule data
|
|
10
|
+
// when `#stagedCapsules.get('some-job-id').get('${some-contract-address}:${some-scope}:${some-key}') === null`,
|
|
10
11
|
// it signals that the capsule was deleted during the job, so it needs to be deleted on commit
|
|
11
12
|
#stagedCapsules;
|
|
12
13
|
logger;
|
|
@@ -101,8 +102,8 @@ export class CapsuleStore {
|
|
|
101
102
|
* @remarks A capsule is a "blob" of data that is passed to the contract through an oracle. It works similarly
|
|
102
103
|
* to public contract storage in that it's indexed by the contract address and storage slot but instead of the global
|
|
103
104
|
* network state it's backed by local PXE db.
|
|
104
|
-
*/
|
|
105
|
-
const dbSlotKey = dbSlotToKey(contractAddress, slot);
|
|
105
|
+
*/ setCapsule(contractAddress, slot, capsule, jobId, scope) {
|
|
106
|
+
const dbSlotKey = dbSlotToKey(contractAddress, slot, scope);
|
|
106
107
|
// A store overrides any pre-existing data on the slot
|
|
107
108
|
this.#setOnStage(jobId, dbSlotKey, Buffer.concat(capsule.map((value)=>value.toBuffer())));
|
|
108
109
|
}
|
|
@@ -111,8 +112,8 @@ export class CapsuleStore {
|
|
|
111
112
|
* @param contractAddress - The contract address under which the data is scoped.
|
|
112
113
|
* @param slot - The slot in the database to read.
|
|
113
114
|
* @returns The stored data or `null` if no data is stored under the slot.
|
|
114
|
-
*/ async
|
|
115
|
-
const dataBuffer = await this.#getFromStage(jobId, dbSlotToKey(contractAddress, slot));
|
|
115
|
+
*/ async getCapsule(contractAddress, slot, jobId, scope) {
|
|
116
|
+
const dataBuffer = await this.#getFromStage(jobId, dbSlotToKey(contractAddress, slot, scope));
|
|
116
117
|
if (!dataBuffer) {
|
|
117
118
|
this.logger.trace(`Data not found for contract ${contractAddress.toString()} and slot ${slot.toString()}`);
|
|
118
119
|
return null;
|
|
@@ -127,9 +128,9 @@ export class CapsuleStore {
|
|
|
127
128
|
* Deletes data in the per-contract non-volatile database. Does nothing if no data was present.
|
|
128
129
|
* @param contractAddress - The contract address under which the data is scoped.
|
|
129
130
|
* @param slot - The slot in the database to delete.
|
|
130
|
-
*/ deleteCapsule(contractAddress, slot, jobId) {
|
|
131
|
+
*/ deleteCapsule(contractAddress, slot, jobId, scope) {
|
|
131
132
|
// When we commit this, we will interpret null as a deletion, so we'll propagate the delete to the KV store
|
|
132
|
-
this.#deleteOnStage(jobId, dbSlotToKey(contractAddress, slot));
|
|
133
|
+
this.#deleteOnStage(jobId, dbSlotToKey(contractAddress, slot, scope));
|
|
133
134
|
}
|
|
134
135
|
/**
|
|
135
136
|
* Copies a number of contiguous entries in the per-contract non-volatile database. This allows for efficient data
|
|
@@ -141,7 +142,7 @@ export class CapsuleStore {
|
|
|
141
142
|
* @param srcSlot - The first slot to copy from.
|
|
142
143
|
* @param dstSlot - The first slot to copy to.
|
|
143
144
|
* @param numEntries - The number of entries to copy.
|
|
144
|
-
*/ copyCapsule(contractAddress, srcSlot, dstSlot, numEntries, jobId) {
|
|
145
|
+
*/ copyCapsule(contractAddress, srcSlot, dstSlot, numEntries, jobId, scope) {
|
|
145
146
|
// This transactional context gives us "copy atomicity":
|
|
146
147
|
// there shouldn't be concurrent writes to what's being copied here.
|
|
147
148
|
// Equally important: this in practice is expected to perform thousands of DB operations
|
|
@@ -156,8 +157,8 @@ export class CapsuleStore {
|
|
|
156
157
|
indexes.reverse();
|
|
157
158
|
}
|
|
158
159
|
for (const i of indexes){
|
|
159
|
-
const currentSrcSlot = dbSlotToKey(contractAddress, srcSlot.add(new Fr(i)));
|
|
160
|
-
const currentDstSlot = dbSlotToKey(contractAddress, dstSlot.add(new Fr(i)));
|
|
160
|
+
const currentSrcSlot = dbSlotToKey(contractAddress, srcSlot.add(new Fr(i)), scope);
|
|
161
|
+
const currentDstSlot = dbSlotToKey(contractAddress, dstSlot.add(new Fr(i)), scope);
|
|
161
162
|
const toCopy = await this.#getFromStage(jobId, currentSrcSlot);
|
|
162
163
|
if (!toCopy) {
|
|
163
164
|
throw new Error(`Attempted to copy empty slot ${currentSrcSlot} for contract ${contractAddress.toString()}`);
|
|
@@ -173,7 +174,7 @@ export class CapsuleStore {
|
|
|
173
174
|
* @param contractAddress - The contract address that owns the capsule array
|
|
174
175
|
* @param baseSlot - The slot where the array length is stored
|
|
175
176
|
* @param content - Array of capsule data to append
|
|
176
|
-
*/ appendToCapsuleArray(contractAddress, baseSlot, content, jobId) {
|
|
177
|
+
*/ appendToCapsuleArray(contractAddress, baseSlot, content, jobId, scope) {
|
|
177
178
|
// We wrap this in a transaction to serialize concurrent calls from Promise.all.
|
|
178
179
|
// Without this, concurrent appends to the same array could race: both read length=0,
|
|
179
180
|
// both write at the same slots, one overwrites the other.
|
|
@@ -181,21 +182,21 @@ export class CapsuleStore {
|
|
|
181
182
|
// and not using a transaction here would heavily impact performance.
|
|
182
183
|
return this.#store.transactionAsync(async ()=>{
|
|
183
184
|
// Load current length, defaulting to 0 if not found
|
|
184
|
-
const lengthData = await this.
|
|
185
|
+
const lengthData = await this.getCapsule(contractAddress, baseSlot, jobId, scope);
|
|
185
186
|
const currentLength = lengthData ? lengthData[0].toNumber() : 0;
|
|
186
187
|
// Store each capsule at consecutive slots after baseSlot + 1 + currentLength
|
|
187
188
|
for(let i = 0; i < content.length; i++){
|
|
188
189
|
const nextSlot = arraySlot(baseSlot, currentLength + i);
|
|
189
|
-
this.
|
|
190
|
+
this.setCapsule(contractAddress, nextSlot, content[i], jobId, scope);
|
|
190
191
|
}
|
|
191
192
|
// Update length to include all new capsules
|
|
192
193
|
const newLength = currentLength + content.length;
|
|
193
|
-
this.
|
|
194
|
+
this.setCapsule(contractAddress, baseSlot, [
|
|
194
195
|
new Fr(newLength)
|
|
195
|
-
], jobId);
|
|
196
|
+
], jobId, scope);
|
|
196
197
|
});
|
|
197
198
|
}
|
|
198
|
-
readCapsuleArray(contractAddress, baseSlot, jobId) {
|
|
199
|
+
readCapsuleArray(contractAddress, baseSlot, jobId, scope) {
|
|
199
200
|
// I'm leaving this transactional context here though because I'm assuming this
|
|
200
201
|
// gives us "read array atomicity": there shouldn't be concurrent writes to what's being copied
|
|
201
202
|
// here.
|
|
@@ -203,12 +204,12 @@ export class CapsuleStore {
|
|
|
203
204
|
// of jobs: different calls running concurrently on the same contract may cause trouble.
|
|
204
205
|
return this.#store.transactionAsync(async ()=>{
|
|
205
206
|
// Load length, defaulting to 0 if not found
|
|
206
|
-
const maybeLength = await this.
|
|
207
|
+
const maybeLength = await this.getCapsule(contractAddress, baseSlot, jobId, scope);
|
|
207
208
|
const length = maybeLength ? maybeLength[0].toBigInt() : 0n;
|
|
208
209
|
const values = [];
|
|
209
210
|
// Read each capsule at consecutive slots after baseSlot
|
|
210
211
|
for(let i = 0; i < length; i++){
|
|
211
|
-
const currentValue = await this.
|
|
212
|
+
const currentValue = await this.getCapsule(contractAddress, arraySlot(baseSlot, i), jobId, scope);
|
|
212
213
|
if (currentValue == undefined) {
|
|
213
214
|
throw new Error(`Expected non-empty value at capsule array in base slot ${baseSlot} at index ${i} for contract ${contractAddress}`);
|
|
214
215
|
}
|
|
@@ -217,7 +218,7 @@ export class CapsuleStore {
|
|
|
217
218
|
return values;
|
|
218
219
|
});
|
|
219
220
|
}
|
|
220
|
-
setCapsuleArray(contractAddress, baseSlot, content, jobId) {
|
|
221
|
+
setCapsuleArray(contractAddress, baseSlot, content, jobId, scope) {
|
|
221
222
|
// This transactional context in theory isn't so critical now because we aren't
|
|
222
223
|
// writing to DB so if there's exceptions midway and it blows up, no visible impact
|
|
223
224
|
// to persistent storage will happen.
|
|
@@ -228,25 +229,29 @@ export class CapsuleStore {
|
|
|
228
229
|
// of jobs: different calls running concurrently on the same contract may cause trouble.
|
|
229
230
|
return this.#store.transactionAsync(async ()=>{
|
|
230
231
|
// Load current length, defaulting to 0 if not found
|
|
231
|
-
const maybeLength = await this.
|
|
232
|
+
const maybeLength = await this.getCapsule(contractAddress, baseSlot, jobId, scope);
|
|
232
233
|
const originalLength = maybeLength ? maybeLength[0].toNumber() : 0;
|
|
233
234
|
// Set the new length
|
|
234
|
-
this.
|
|
235
|
+
this.setCapsule(contractAddress, baseSlot, [
|
|
235
236
|
new Fr(content.length)
|
|
236
|
-
], jobId);
|
|
237
|
+
], jobId, scope);
|
|
237
238
|
// Store the new content, possibly overwriting existing values
|
|
238
239
|
for(let i = 0; i < content.length; i++){
|
|
239
|
-
this.
|
|
240
|
+
this.setCapsule(contractAddress, arraySlot(baseSlot, i), content[i], jobId, scope);
|
|
240
241
|
}
|
|
241
242
|
// Clear any stragglers
|
|
242
243
|
for(let i = content.length; i < originalLength; i++){
|
|
243
|
-
this.deleteCapsule(contractAddress, arraySlot(baseSlot, i), jobId);
|
|
244
|
+
this.deleteCapsule(contractAddress, arraySlot(baseSlot, i), jobId, scope);
|
|
244
245
|
}
|
|
245
246
|
});
|
|
246
247
|
}
|
|
247
248
|
}
|
|
248
|
-
function dbSlotToKey(contractAddress, slot) {
|
|
249
|
-
return
|
|
249
|
+
function dbSlotToKey(contractAddress, slot, scope) {
|
|
250
|
+
return [
|
|
251
|
+
contractAddress.toString(),
|
|
252
|
+
scope.toString(),
|
|
253
|
+
slot.toString()
|
|
254
|
+
].join(':');
|
|
250
255
|
}
|
|
251
256
|
function arraySlot(baseSlot, index) {
|
|
252
257
|
return baseSlot.add(new Fr(1)).add(new Fr(index));
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
export { CapsuleService } from './capsule_service.js';
|
|
1
2
|
export { CapsuleStore } from './capsule_store.js';
|
|
2
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zdG9yYWdlL2NhcHN1bGVfc3RvcmUvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLGNBQWMsRUFBRSxNQUFNLHNCQUFzQixDQUFDO0FBQ3RELE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQyJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/capsule_store/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/capsule_store/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const PXE_DATA_SCHEMA_VERSION =
|
|
1
|
+
export declare const PXE_DATA_SCHEMA_VERSION = 5;
|
|
2
2
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWV0YWRhdGEuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zdG9yYWdlL21ldGFkYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGVBQU8sTUFBTSx1QkFBdUIsSUFBSSxDQUFDIn0=
|
package/dest/storage/metadata.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const PXE_DATA_SCHEMA_VERSION =
|
|
1
|
+
export const PXE_DATA_SCHEMA_VERSION = 5;
|