@aztec/pxe 0.0.1-commit.1bea0213 → 0.0.1-commit.21ecf947b
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/block_synchronizer/block_synchronizer.d.ts +5 -3
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +9 -3
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +54 -30
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +170 -66
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +9 -9
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.d.ts +5 -5
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +32 -20
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +36 -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 +74 -21
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +48 -24
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +85 -61
- package/dest/contract_sync/contract_sync_service.d.ts +43 -0
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
- package/dest/contract_sync/contract_sync_service.js +97 -0
- package/dest/contract_sync/helpers.d.ts +29 -0
- package/dest/contract_sync/helpers.d.ts.map +1 -0
- package/dest/contract_sync/{index.js → helpers.js} +13 -12
- package/dest/debug/pxe_debug_utils.d.ts +24 -10
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +28 -18
- 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/bundle/utils.d.ts +1 -1
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +21 -7
- package/dest/entrypoints/client/lazy/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/client/lazy/utils.d.ts +2 -2
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +22 -8
- package/dest/entrypoints/pxe_creation_options.d.ts +3 -2
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/server/index.d.ts +4 -2
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +3 -1
- package/dest/entrypoints/server/utils.d.ts +1 -1
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +28 -9
- package/dest/events/event_service.d.ts +4 -5
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +5 -6
- package/dest/job_coordinator/job_coordinator.d.ts +3 -2
- package/dest/job_coordinator/job_coordinator.d.ts.map +1 -1
- package/dest/job_coordinator/job_coordinator.js +3 -2
- package/dest/logs/log_service.d.ts +7 -5
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +15 -25
- package/dest/notes/note_service.d.ts +7 -7
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +9 -9
- 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/oracle_version.d.ts +3 -3
- package/dest/oracle_version.d.ts.map +1 -1
- package/dest/oracle_version.js +2 -2
- package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
- package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
- package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
- package/dest/private_kernel/hints/index.d.ts +1 -1
- package/dest/private_kernel/hints/index.js +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +4 -4
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +3 -2
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +8 -8
- package/dest/pxe.d.ts +69 -23
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +76 -46
- package/dest/storage/address_store/address_store.d.ts +1 -1
- package/dest/storage/address_store/address_store.d.ts.map +1 -1
- package/dest/storage/address_store/address_store.js +12 -11
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -1
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -1
- package/dest/storage/anchor_block_store/anchor_block_store.js +8 -1
- package/dest/storage/capsule_store/capsule_store.js +6 -8
- package/dest/storage/contract_store/contract_store.d.ts +1 -1
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +27 -18
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/note_store/note_store.d.ts +13 -3
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +147 -107
- package/dest/storage/private_event_store/private_event_store.d.ts +1 -1
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
- package/dest/storage/private_event_store/private_event_store.js +84 -61
- package/dest/storage/private_event_store/stored_private_event.js +1 -1
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts +1 -1
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/recipient_tagging_store.js +31 -19
- package/dest/storage/tagging_store/sender_address_book_store.d.ts +1 -1
- package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_address_book_store.js +20 -14
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +183 -113
- package/dest/tagging/get_all_logs_by_tags.d.ts +1 -1
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
- package/dest/tagging/get_all_logs_by_tags.js +17 -3
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +4 -4
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
- package/package.json +25 -16
- package/src/access_scopes.ts +9 -0
- package/src/block_synchronizer/block_synchronizer.ts +21 -12
- package/src/contract_function_simulator/contract_function_simulator.ts +318 -121
- package/src/contract_function_simulator/oracle/interfaces.ts +10 -10
- package/src/contract_function_simulator/oracle/oracle.ts +35 -18
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +97 -101
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +131 -63
- package/src/contract_sync/contract_sync_service.ts +152 -0
- package/src/contract_sync/{index.ts → helpers.ts} +21 -21
- package/src/debug/pxe_debug_utils.ts +63 -19
- package/src/entrypoints/client/bundle/index.ts +2 -0
- package/src/entrypoints/client/bundle/utils.ts +16 -15
- package/src/entrypoints/client/lazy/index.ts +2 -0
- package/src/entrypoints/client/lazy/utils.ts +17 -15
- package/src/entrypoints/pxe_creation_options.ts +2 -1
- package/src/entrypoints/server/index.ts +3 -1
- package/src/entrypoints/server/utils.ts +22 -26
- package/src/events/event_service.ts +4 -6
- package/src/job_coordinator/job_coordinator.ts +4 -3
- package/src/logs/log_service.ts +20 -32
- package/src/notes/note_service.ts +9 -10
- package/src/notes_filter.ts +26 -0
- package/src/oracle_version.ts +2 -2
- package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
- package/src/private_kernel/hints/index.ts +1 -1
- package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +7 -7
- package/src/private_kernel/private_kernel_execution_prover.ts +12 -9
- package/src/pxe.ts +164 -92
- package/src/storage/address_store/address_store.ts +15 -15
- package/src/storage/anchor_block_store/anchor_block_store.ts +8 -0
- package/src/storage/capsule_store/capsule_store.ts +8 -8
- package/src/storage/contract_store/contract_store.ts +26 -15
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/note_store.ts +169 -132
- package/src/storage/private_event_store/private_event_store.ts +102 -81
- package/src/storage/private_event_store/stored_private_event.ts +1 -1
- package/src/storage/tagging_store/recipient_tagging_store.ts +31 -21
- package/src/storage/tagging_store/sender_address_book_store.ts +20 -14
- package/src/storage/tagging_store/sender_tagging_store.ts +210 -126
- package/src/tagging/get_all_logs_by_tags.ts +28 -4
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +4 -4
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
- package/dest/contract_sync/index.d.ts +0 -23
- package/dest/contract_sync/index.d.ts.map +0 -1
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { vkAsFieldsMegaHonk } from '@aztec/foundation/crypto/keys';
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { pushTestData } from '@aztec/foundation/testing';
|
|
5
5
|
import { Timer } from '@aztec/foundation/timer';
|
|
6
6
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
@@ -56,13 +56,16 @@ export interface PrivateKernelExecutionProverConfig {
|
|
|
56
56
|
* inform state tree updates.
|
|
57
57
|
*/
|
|
58
58
|
export class PrivateKernelExecutionProver {
|
|
59
|
-
private log
|
|
59
|
+
private log: Logger;
|
|
60
60
|
|
|
61
61
|
constructor(
|
|
62
62
|
private oracle: PrivateKernelOracle,
|
|
63
63
|
private proofCreator: PrivateKernelProver,
|
|
64
64
|
private fakeProofs = false,
|
|
65
|
-
|
|
65
|
+
bindings?: LoggerBindings,
|
|
66
|
+
) {
|
|
67
|
+
this.log = createLogger('pxe:private-kernel-execution-prover', bindings);
|
|
68
|
+
}
|
|
66
69
|
|
|
67
70
|
/**
|
|
68
71
|
* Generate a proof for a given transaction request and execution result.
|
|
@@ -257,20 +260,20 @@ export class PrivateKernelExecutionProver {
|
|
|
257
260
|
// TODO: Enable padding once we better understand the final amounts to pad to.
|
|
258
261
|
const paddedSideEffectAmounts = PaddedSideEffectAmounts.empty();
|
|
259
262
|
|
|
260
|
-
// Use the aggregated
|
|
261
|
-
// TODO: Call `
|
|
262
|
-
const
|
|
263
|
+
// Use the aggregated expirationTimestamp set throughout the tx execution.
|
|
264
|
+
// TODO: Call `computeTxExpirationTimestamp` to round the value down and reduce precision, improving privacy.
|
|
265
|
+
const expirationTimestampUpperBound = previousKernelData.publicInputs.expirationTimestamp;
|
|
263
266
|
const anchorBlockTimestamp = previousKernelData.publicInputs.constants.anchorBlockHeader.globalVariables.timestamp;
|
|
264
|
-
if (
|
|
267
|
+
if (expirationTimestampUpperBound <= anchorBlockTimestamp) {
|
|
265
268
|
throw new Error(
|
|
266
|
-
`Include-by timestamp must be greater than the anchor block timestamp. Anchor block timestamp: ${anchorBlockTimestamp}. Include-by timestamp: ${
|
|
269
|
+
`Include-by timestamp must be greater than the anchor block timestamp. Anchor block timestamp: ${anchorBlockTimestamp}. Include-by timestamp: ${expirationTimestampUpperBound}.`,
|
|
267
270
|
);
|
|
268
271
|
}
|
|
269
272
|
|
|
270
273
|
const privateInputs = new PrivateKernelTailCircuitPrivateInputs(
|
|
271
274
|
previousKernelData,
|
|
272
275
|
paddedSideEffectAmounts,
|
|
273
|
-
|
|
276
|
+
expirationTimestampUpperBound,
|
|
274
277
|
);
|
|
275
278
|
|
|
276
279
|
const witgenTimer = new Timer();
|
package/src/pxe.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PrivateEventFilter } from '@aztec/aztec.js/wallet';
|
|
2
2
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
-
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
4
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
5
5
|
import { SerialQueue } from '@aztec/foundation/queue';
|
|
6
6
|
import { Timer } from '@aztec/foundation/timer';
|
|
7
7
|
import { KeyStore } from '@aztec/key-store';
|
|
@@ -33,6 +33,7 @@ import type {
|
|
|
33
33
|
PrivateKernelTailCircuitPublicInputs,
|
|
34
34
|
} from '@aztec/stdlib/kernel';
|
|
35
35
|
import {
|
|
36
|
+
BlockHeader,
|
|
36
37
|
type ContractOverrides,
|
|
37
38
|
type InTx,
|
|
38
39
|
PrivateExecutionResult,
|
|
@@ -51,6 +52,7 @@ import {
|
|
|
51
52
|
|
|
52
53
|
import { inspect } from 'util';
|
|
53
54
|
|
|
55
|
+
import type { AccessScopes } from './access_scopes.js';
|
|
54
56
|
import { BlockSynchronizer } from './block_synchronizer/index.js';
|
|
55
57
|
import type { PXEConfig } from './config/index.js';
|
|
56
58
|
import { BenchmarkedNodeFactory } from './contract_function_simulator/benchmarked_node.js';
|
|
@@ -59,7 +61,8 @@ import {
|
|
|
59
61
|
generateSimulatedProvingResult,
|
|
60
62
|
} from './contract_function_simulator/contract_function_simulator.js';
|
|
61
63
|
import { ProxiedContractStoreFactory } from './contract_function_simulator/proxied_contract_data_source.js';
|
|
62
|
-
import {
|
|
64
|
+
import { ContractSyncService } from './contract_sync/contract_sync_service.js';
|
|
65
|
+
import { readCurrentClassId } from './contract_sync/helpers.js';
|
|
63
66
|
import { PXEDebugUtils } from './debug/pxe_debug_utils.js';
|
|
64
67
|
import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
|
|
65
68
|
import { PrivateEventFilterValidator } from './events/private_event_filter_validator.js';
|
|
@@ -84,6 +87,56 @@ export type PackedPrivateEvent = InTx & {
|
|
|
84
87
|
eventSelector: EventSelector;
|
|
85
88
|
};
|
|
86
89
|
|
|
90
|
+
/** Options for PXE.profileTx. */
|
|
91
|
+
export type ProfileTxOpts = {
|
|
92
|
+
/** The profiling mode to use. */
|
|
93
|
+
profileMode: 'full' | 'execution-steps' | 'gates';
|
|
94
|
+
/** If true, proof generation is skipped during profiling. Defaults to true. */
|
|
95
|
+
skipProofGeneration?: boolean;
|
|
96
|
+
/** Addresses whose private state and keys are accessible during private execution. */
|
|
97
|
+
scopes: AccessScopes;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/** Options for PXE.simulateTx. */
|
|
101
|
+
export type SimulateTxOpts = {
|
|
102
|
+
/** Whether to simulate the public part of the transaction. */
|
|
103
|
+
simulatePublic: boolean;
|
|
104
|
+
/** If false, this function throws if the transaction is unable to be included in a block at the current state. */
|
|
105
|
+
skipTxValidation?: boolean;
|
|
106
|
+
/** If false, fees are enforced. */
|
|
107
|
+
skipFeeEnforcement?: boolean;
|
|
108
|
+
/** State overrides for the simulation, such as contract instances and artifacts. */
|
|
109
|
+
overrides?: SimulationOverrides;
|
|
110
|
+
/** Addresses whose private state and keys are accessible during private execution */
|
|
111
|
+
scopes: AccessScopes;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
/** Options for PXE.simulateUtility. */
|
|
115
|
+
export type SimulateUtilityOpts = {
|
|
116
|
+
/** The authentication witnesses required for the function call. */
|
|
117
|
+
authwits?: AuthWitness[];
|
|
118
|
+
/** The accounts whose notes we can access in this call */
|
|
119
|
+
scopes: AccessScopes;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
/** Args for PXE.create. */
|
|
123
|
+
export type PXECreateArgs = {
|
|
124
|
+
/** The Aztec node to connect to. */
|
|
125
|
+
node: AztecNode;
|
|
126
|
+
/** The key-value store for persisting PXE state. */
|
|
127
|
+
store: AztecAsyncKVStore;
|
|
128
|
+
/** The prover for generating private kernel proofs. */
|
|
129
|
+
proofCreator: PrivateKernelProver;
|
|
130
|
+
/** The circuit simulator for executing ACIR circuits. */
|
|
131
|
+
simulator: CircuitSimulator;
|
|
132
|
+
/** Provider for protocol contract artifacts and instances. */
|
|
133
|
+
protocolContractsProvider: ProtocolContractsProvider;
|
|
134
|
+
/** PXE configuration options. */
|
|
135
|
+
config: PXEConfig;
|
|
136
|
+
/** Optional logger instance or string suffix for the logger name. */
|
|
137
|
+
loggerOrSuffix?: string | Logger;
|
|
138
|
+
};
|
|
139
|
+
|
|
87
140
|
/**
|
|
88
141
|
* Private eXecution Environment (PXE) is a library used by wallets to simulate private phase of transactions and to
|
|
89
142
|
* manage private state of users.
|
|
@@ -102,6 +155,7 @@ export class PXE {
|
|
|
102
155
|
private recipientTaggingStore: RecipientTaggingStore,
|
|
103
156
|
private addressStore: AddressStore,
|
|
104
157
|
private privateEventStore: PrivateEventStore,
|
|
158
|
+
private contractSyncService: ContractSyncService,
|
|
105
159
|
private simulator: CircuitSimulator,
|
|
106
160
|
private proverEnabled: boolean,
|
|
107
161
|
private proofCreator: PrivateKernelProver,
|
|
@@ -119,21 +173,27 @@ export class PXE {
|
|
|
119
173
|
*
|
|
120
174
|
* @returns A promise that resolves PXE is ready to be used.
|
|
121
175
|
*/
|
|
122
|
-
public static async create(
|
|
123
|
-
node
|
|
124
|
-
store
|
|
125
|
-
proofCreator
|
|
126
|
-
simulator
|
|
127
|
-
protocolContractsProvider
|
|
128
|
-
config
|
|
129
|
-
loggerOrSuffix
|
|
130
|
-
) {
|
|
176
|
+
public static async create({
|
|
177
|
+
node,
|
|
178
|
+
store,
|
|
179
|
+
proofCreator,
|
|
180
|
+
simulator,
|
|
181
|
+
protocolContractsProvider,
|
|
182
|
+
config,
|
|
183
|
+
loggerOrSuffix,
|
|
184
|
+
}: PXECreateArgs) {
|
|
185
|
+
// Extract bindings from the logger, or use empty bindings if a string suffix is provided.
|
|
186
|
+
const bindings: LoggerBindings | undefined =
|
|
187
|
+
loggerOrSuffix && typeof loggerOrSuffix !== 'string' ? loggerOrSuffix.getBindings() : undefined;
|
|
188
|
+
|
|
131
189
|
const log =
|
|
132
190
|
!loggerOrSuffix || typeof loggerOrSuffix === 'string'
|
|
133
191
|
? createLogger(loggerOrSuffix ? `pxe:service:${loggerOrSuffix}` : `pxe:service`)
|
|
134
192
|
: loggerOrSuffix;
|
|
135
193
|
|
|
136
|
-
const
|
|
194
|
+
const info = await node.getNodeInfo();
|
|
195
|
+
|
|
196
|
+
const proverEnabled = config.proverEnabled !== undefined ? config.proverEnabled : info.realProofs;
|
|
137
197
|
const addressStore = new AddressStore(store);
|
|
138
198
|
const privateEventStore = new PrivateEventStore(store);
|
|
139
199
|
const contractStore = new ContractStore(store);
|
|
@@ -145,6 +205,12 @@ export class PXE {
|
|
|
145
205
|
const capsuleStore = new CapsuleStore(store);
|
|
146
206
|
const keyStore = new KeyStore(store);
|
|
147
207
|
const tipsStore = new L2TipsKVStore(store, 'pxe');
|
|
208
|
+
const contractSyncService = new ContractSyncService(
|
|
209
|
+
node,
|
|
210
|
+
contractStore,
|
|
211
|
+
noteStore,
|
|
212
|
+
createLogger('pxe:contract_sync', bindings),
|
|
213
|
+
);
|
|
148
214
|
const synchronizer = new BlockSynchronizer(
|
|
149
215
|
node,
|
|
150
216
|
store,
|
|
@@ -152,20 +218,22 @@ export class PXE {
|
|
|
152
218
|
noteStore,
|
|
153
219
|
privateEventStore,
|
|
154
220
|
tipsStore,
|
|
221
|
+
contractSyncService,
|
|
155
222
|
config,
|
|
156
|
-
|
|
223
|
+
bindings,
|
|
157
224
|
);
|
|
158
225
|
|
|
159
|
-
const jobCoordinator = new JobCoordinator(store);
|
|
226
|
+
const jobCoordinator = new JobCoordinator(store, bindings);
|
|
160
227
|
jobCoordinator.registerStores([
|
|
161
228
|
capsuleStore,
|
|
162
229
|
senderTaggingStore,
|
|
163
230
|
recipientTaggingStore,
|
|
164
231
|
privateEventStore,
|
|
165
232
|
noteStore,
|
|
233
|
+
contractSyncService,
|
|
166
234
|
]);
|
|
167
235
|
|
|
168
|
-
const debugUtils = new PXEDebugUtils(
|
|
236
|
+
const debugUtils = new PXEDebugUtils(contractSyncService, noteStore, synchronizer, anchorBlockStore);
|
|
169
237
|
|
|
170
238
|
const jobQueue = new SerialQueue();
|
|
171
239
|
|
|
@@ -182,6 +250,7 @@ export class PXE {
|
|
|
182
250
|
recipientTaggingStore,
|
|
183
251
|
addressStore,
|
|
184
252
|
privateEventStore,
|
|
253
|
+
contractSyncService,
|
|
185
254
|
simulator,
|
|
186
255
|
proverEnabled,
|
|
187
256
|
proofCreator,
|
|
@@ -192,12 +261,15 @@ export class PXE {
|
|
|
192
261
|
debugUtils,
|
|
193
262
|
);
|
|
194
263
|
|
|
195
|
-
debugUtils.
|
|
264
|
+
debugUtils.setPXEHelpers(
|
|
265
|
+
pxe.#putInJobQueue.bind(pxe),
|
|
266
|
+
pxe.#getSimulatorForTx.bind(pxe),
|
|
267
|
+
pxe.#simulateUtility.bind(pxe),
|
|
268
|
+
);
|
|
196
269
|
|
|
197
270
|
pxe.jobQueue.start();
|
|
198
271
|
|
|
199
272
|
await pxe.#registerProtocolContracts();
|
|
200
|
-
const info = await node.getNodeInfo();
|
|
201
273
|
log.info(`Started PXE connected to chain ${info.l1ChainId} version ${info.rollupVersion}`);
|
|
202
274
|
return pxe;
|
|
203
275
|
}
|
|
@@ -207,20 +279,20 @@ export class PXE {
|
|
|
207
279
|
#getSimulatorForTx(overrides?: { contracts?: ContractOverrides }) {
|
|
208
280
|
const proxyContractStore = ProxiedContractStoreFactory.create(this.contractStore, overrides?.contracts);
|
|
209
281
|
|
|
210
|
-
return new ContractFunctionSimulator(
|
|
211
|
-
proxyContractStore,
|
|
212
|
-
this.noteStore,
|
|
213
|
-
this.keyStore,
|
|
214
|
-
this.addressStore,
|
|
215
|
-
BenchmarkedNodeFactory.create(this.node),
|
|
216
|
-
this.
|
|
217
|
-
this.
|
|
218
|
-
this.
|
|
219
|
-
this.
|
|
220
|
-
this.
|
|
221
|
-
this.
|
|
222
|
-
this.
|
|
223
|
-
);
|
|
282
|
+
return new ContractFunctionSimulator({
|
|
283
|
+
contractStore: proxyContractStore,
|
|
284
|
+
noteStore: this.noteStore,
|
|
285
|
+
keyStore: this.keyStore,
|
|
286
|
+
addressStore: this.addressStore,
|
|
287
|
+
aztecNode: BenchmarkedNodeFactory.create(this.node),
|
|
288
|
+
senderTaggingStore: this.senderTaggingStore,
|
|
289
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
290
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
291
|
+
capsuleStore: this.capsuleStore,
|
|
292
|
+
privateEventStore: this.privateEventStore,
|
|
293
|
+
simulator: this.simulator,
|
|
294
|
+
contractSyncService: this.contractSyncService,
|
|
295
|
+
});
|
|
224
296
|
}
|
|
225
297
|
|
|
226
298
|
#contextualizeError(err: Error, ...context: string[]): Error {
|
|
@@ -286,7 +358,7 @@ export class PXE {
|
|
|
286
358
|
async #executePrivate(
|
|
287
359
|
contractFunctionSimulator: ContractFunctionSimulator,
|
|
288
360
|
txRequest: TxExecutionRequest,
|
|
289
|
-
scopes:
|
|
361
|
+
scopes: AccessScopes,
|
|
290
362
|
jobId: string,
|
|
291
363
|
): Promise<PrivateExecutionResult> {
|
|
292
364
|
const { origin: contractAddress, functionSelector } = txRequest;
|
|
@@ -294,27 +366,23 @@ export class PXE {
|
|
|
294
366
|
try {
|
|
295
367
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
296
368
|
|
|
297
|
-
await ensureContractSynced(
|
|
369
|
+
await this.contractSyncService.ensureContractSynced(
|
|
298
370
|
contractAddress,
|
|
299
371
|
functionSelector,
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
this.contractStore,
|
|
372
|
+
(privateSyncCall, execScopes) =>
|
|
373
|
+
this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
|
|
303
374
|
anchorBlockHeader,
|
|
375
|
+
jobId,
|
|
376
|
+
scopes,
|
|
304
377
|
);
|
|
305
378
|
|
|
306
|
-
const result = await contractFunctionSimulator.run(
|
|
307
|
-
txRequest,
|
|
379
|
+
const result = await contractFunctionSimulator.run(txRequest, {
|
|
308
380
|
contractAddress,
|
|
309
|
-
functionSelector,
|
|
310
|
-
undefined,
|
|
381
|
+
selector: functionSelector,
|
|
311
382
|
anchorBlockHeader,
|
|
312
|
-
// The sender for tags is set by contracts, typically by an account
|
|
313
|
-
// contract entrypoint
|
|
314
|
-
undefined, // senderForTags
|
|
315
383
|
scopes,
|
|
316
384
|
jobId,
|
|
317
|
-
);
|
|
385
|
+
});
|
|
318
386
|
this.log.debug(`Private simulation completed for ${contractAddress.toString()}:${functionSelector}`);
|
|
319
387
|
return result;
|
|
320
388
|
} catch (err) {
|
|
@@ -339,7 +407,7 @@ export class PXE {
|
|
|
339
407
|
contractFunctionSimulator: ContractFunctionSimulator,
|
|
340
408
|
call: FunctionCall,
|
|
341
409
|
authWitnesses: AuthWitness[] | undefined,
|
|
342
|
-
scopes:
|
|
410
|
+
scopes: AccessScopes,
|
|
343
411
|
jobId: string,
|
|
344
412
|
) {
|
|
345
413
|
try {
|
|
@@ -400,13 +468,31 @@ export class PXE {
|
|
|
400
468
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
401
469
|
const anchorBlockHash = await anchorBlockHeader.hash();
|
|
402
470
|
const kernelOracle = new PrivateKernelOracle(this.contractStore, this.keyStore, this.node, anchorBlockHash);
|
|
403
|
-
const kernelTraceProver = new PrivateKernelExecutionProver(
|
|
471
|
+
const kernelTraceProver = new PrivateKernelExecutionProver(
|
|
472
|
+
kernelOracle,
|
|
473
|
+
proofCreator,
|
|
474
|
+
!this.proverEnabled,
|
|
475
|
+
this.log.getBindings(),
|
|
476
|
+
);
|
|
404
477
|
this.log.debug(`Executing kernel trace prover (${JSON.stringify(config)})...`);
|
|
405
478
|
return await kernelTraceProver.proveWithKernels(txExecutionRequest.toTxRequest(), privateExecutionResult, config);
|
|
406
479
|
}
|
|
407
480
|
|
|
408
481
|
// Public API
|
|
409
482
|
|
|
483
|
+
/**
|
|
484
|
+
* Returns the block header up to which the PXE has synced.
|
|
485
|
+
* @returns The synced block header
|
|
486
|
+
*/
|
|
487
|
+
public getSyncedBlockHeader(): Promise<BlockHeader> {
|
|
488
|
+
return this.anchorBlockStore.getBlockHeader();
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* Returns the contract instance for a given address, if it's registered in the PXE.
|
|
493
|
+
* @param address - The contract address.
|
|
494
|
+
* @returns The contract instance if found, undefined otherwise.
|
|
495
|
+
*/
|
|
410
496
|
public getContractInstance(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
|
|
411
497
|
return this.contractStore.getContractInstance(address);
|
|
412
498
|
}
|
|
@@ -620,11 +706,12 @@ export class PXE {
|
|
|
620
706
|
* (where validators prove the public portion).
|
|
621
707
|
*
|
|
622
708
|
* @param txRequest - An authenticated tx request ready for proving
|
|
709
|
+
* @param scopes - Addresses whose private state and keys are accessible during private execution.
|
|
623
710
|
* @returns A result containing the proof and public inputs of the tail circuit.
|
|
624
711
|
* @throws If contract code not found, or public simulation reverts.
|
|
625
712
|
* Also throws if simulatePublic is true and public simulation reverts.
|
|
626
713
|
*/
|
|
627
|
-
public proveTx(txRequest: TxExecutionRequest): Promise<TxProvingResult> {
|
|
714
|
+
public proveTx(txRequest: TxExecutionRequest, scopes: AztecAddress[]): Promise<TxProvingResult> {
|
|
628
715
|
let privateExecutionResult: PrivateExecutionResult;
|
|
629
716
|
// We disable proving concurrently mostly out of caution, since it accesses some of our stores. Proving is so
|
|
630
717
|
// computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
|
|
@@ -635,7 +722,7 @@ export class PXE {
|
|
|
635
722
|
await this.blockStateSynchronizer.sync();
|
|
636
723
|
const syncTime = syncTimer.ms();
|
|
637
724
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
638
|
-
privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest,
|
|
725
|
+
privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
|
|
639
726
|
|
|
640
727
|
const {
|
|
641
728
|
publicInputs,
|
|
@@ -699,17 +786,13 @@ export class PXE {
|
|
|
699
786
|
|
|
700
787
|
/**
|
|
701
788
|
* Profiles a transaction, reporting gate counts (unless disabled) and returns an execution trace.
|
|
702
|
-
*
|
|
703
|
-
* @param txRequest - An authenticated tx request ready for simulation
|
|
704
|
-
* @param msgSender - (Optional) The message sender to use for the simulation.
|
|
705
|
-
* @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
|
|
789
|
+
* @param txRequest - An authenticated tx request ready for simulation.
|
|
706
790
|
* @returns A trace of the program execution with gate counts.
|
|
707
791
|
* @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
|
|
708
792
|
*/
|
|
709
793
|
public profileTx(
|
|
710
794
|
txRequest: TxExecutionRequest,
|
|
711
|
-
profileMode
|
|
712
|
-
skipProofGeneration: boolean = true,
|
|
795
|
+
{ profileMode, skipProofGeneration = true, scopes }: ProfileTxOpts,
|
|
713
796
|
): Promise<TxProfileResult> {
|
|
714
797
|
// We disable concurrent profiles for consistency with simulateTx.
|
|
715
798
|
return this.#putInJobQueue(async jobId => {
|
|
@@ -732,12 +815,7 @@ export class PXE {
|
|
|
732
815
|
const syncTime = syncTimer.ms();
|
|
733
816
|
|
|
734
817
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
735
|
-
const privateExecutionResult = await this.#executePrivate(
|
|
736
|
-
contractFunctionSimulator,
|
|
737
|
-
txRequest,
|
|
738
|
-
undefined,
|
|
739
|
-
jobId,
|
|
740
|
-
);
|
|
818
|
+
const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
|
|
741
819
|
|
|
742
820
|
const { executionSteps, timings: { proving } = {} } = await this.#prove(
|
|
743
821
|
txRequest,
|
|
@@ -794,12 +872,7 @@ export class PXE {
|
|
|
794
872
|
* In that case, the transaction returned is only potentially ready to be sent to the network for execution.
|
|
795
873
|
*
|
|
796
874
|
*
|
|
797
|
-
* @param txRequest - An authenticated tx request ready for simulation
|
|
798
|
-
* @param simulatePublic - Whether to simulate the public part of the transaction.
|
|
799
|
-
* @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
|
|
800
|
-
* @param skipFeeEnforcement - (Optional) If false, fees are enforced.
|
|
801
|
-
* @param overrides - (Optional) State overrides for the simulation, such as msgSender, contract instances and artifacts.
|
|
802
|
-
* @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will default to all.
|
|
875
|
+
* @param txRequest - An authenticated tx request ready for simulation.
|
|
803
876
|
* @returns A simulated transaction result object that includes public and private return values.
|
|
804
877
|
* @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
|
|
805
878
|
* Also throws if simulatePublic is true and public simulation reverts.
|
|
@@ -808,11 +881,7 @@ export class PXE {
|
|
|
808
881
|
*/
|
|
809
882
|
public simulateTx(
|
|
810
883
|
txRequest: TxExecutionRequest,
|
|
811
|
-
simulatePublic:
|
|
812
|
-
skipTxValidation: boolean = false,
|
|
813
|
-
skipFeeEnforcement: boolean = false,
|
|
814
|
-
overrides?: SimulationOverrides,
|
|
815
|
-
scopes?: AztecAddress[],
|
|
884
|
+
{ simulatePublic, skipTxValidation = false, skipFeeEnforcement = false, overrides, scopes }: SimulateTxOpts,
|
|
816
885
|
): Promise<TxSimulationResult> {
|
|
817
886
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
818
887
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
@@ -840,7 +909,14 @@ export class PXE {
|
|
|
840
909
|
// Temporary: in case there are overrides, we have to skip the kernels or validations
|
|
841
910
|
// will fail. Consider handing control to the user/wallet on whether they want to run them
|
|
842
911
|
// or not.
|
|
843
|
-
const
|
|
912
|
+
const overriddenContracts = overrides?.contracts ? new Set(Object.keys(overrides.contracts)) : undefined;
|
|
913
|
+
const hasOverriddenContracts = overriddenContracts !== undefined && overriddenContracts.size > 0;
|
|
914
|
+
const skipKernels = hasOverriddenContracts;
|
|
915
|
+
|
|
916
|
+
// Set overridden contracts on the sync service so it knows to skip syncing them
|
|
917
|
+
if (hasOverriddenContracts) {
|
|
918
|
+
this.contractSyncService.setOverriddenContracts(jobId, overriddenContracts);
|
|
919
|
+
}
|
|
844
920
|
|
|
845
921
|
// Execution of private functions only; no proving, and no kernel logic.
|
|
846
922
|
const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
|
|
@@ -851,7 +927,8 @@ export class PXE {
|
|
|
851
927
|
if (skipKernels) {
|
|
852
928
|
({ publicInputs, executionSteps } = await generateSimulatedProvingResult(
|
|
853
929
|
privateExecutionResult,
|
|
854
|
-
this.contractStore,
|
|
930
|
+
(addr, sel) => this.contractStore.getDebugFunctionName(addr, sel),
|
|
931
|
+
this.node,
|
|
855
932
|
));
|
|
856
933
|
} else {
|
|
857
934
|
// Kernel logic, plus proving of all private functions and kernels.
|
|
@@ -929,25 +1006,19 @@ export class PXE {
|
|
|
929
1006
|
inspect(txRequest),
|
|
930
1007
|
`simulatePublic=${simulatePublic}`,
|
|
931
1008
|
`skipTxValidation=${skipTxValidation}`,
|
|
932
|
-
`scopes=${scopes
|
|
1009
|
+
`scopes=${scopes === 'ALL_SCOPES' ? scopes : scopes.map(s => s.toString()).join(', ')}`,
|
|
933
1010
|
);
|
|
934
1011
|
}
|
|
935
1012
|
});
|
|
936
1013
|
}
|
|
937
1014
|
|
|
938
1015
|
/**
|
|
939
|
-
*
|
|
940
|
-
*
|
|
1016
|
+
* Simulates the execution of a contract utility function.
|
|
941
1017
|
* @param call - The function call containing the function details, arguments, and target contract address.
|
|
942
|
-
* @param authwits - (Optional) The authentication witnesses required for the function call.
|
|
943
|
-
* @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will
|
|
944
|
-
* default to all.
|
|
945
|
-
* @returns The result of the utility function call, structured based on the function ABI.
|
|
946
1018
|
*/
|
|
947
1019
|
public simulateUtility(
|
|
948
1020
|
call: FunctionCall,
|
|
949
|
-
authwits
|
|
950
|
-
scopes?: AztecAddress[],
|
|
1021
|
+
{ authwits, scopes }: SimulateUtilityOpts = { scopes: 'ALL_SCOPES' },
|
|
951
1022
|
): Promise<UtilitySimulationResult> {
|
|
952
1023
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
953
1024
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
@@ -962,13 +1033,14 @@ export class PXE {
|
|
|
962
1033
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
963
1034
|
|
|
964
1035
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
965
|
-
await ensureContractSynced(
|
|
1036
|
+
await this.contractSyncService.ensureContractSynced(
|
|
966
1037
|
call.to,
|
|
967
1038
|
call.selector,
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
this.contractStore,
|
|
1039
|
+
(privateSyncCall, execScopes) =>
|
|
1040
|
+
this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
|
|
971
1041
|
anchorBlockHeader,
|
|
1042
|
+
jobId,
|
|
1043
|
+
scopes,
|
|
972
1044
|
);
|
|
973
1045
|
|
|
974
1046
|
const executionResult = await this.#simulateUtility(
|
|
@@ -999,7 +1071,7 @@ export class PXE {
|
|
|
999
1071
|
throw this.#contextualizeError(
|
|
1000
1072
|
err,
|
|
1001
1073
|
`simulateUtility ${to}:${name}(${stringifiedArgs})`,
|
|
1002
|
-
`scopes=${scopes
|
|
1074
|
+
`scopes=${scopes === 'ALL_SCOPES' ? scopes : scopes.map(s => s.toString()).join(', ')}`,
|
|
1003
1075
|
);
|
|
1004
1076
|
}
|
|
1005
1077
|
});
|
|
@@ -1032,14 +1104,14 @@ export class PXE {
|
|
|
1032
1104
|
|
|
1033
1105
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
1034
1106
|
|
|
1035
|
-
await ensureContractSynced(
|
|
1107
|
+
await this.contractSyncService.ensureContractSynced(
|
|
1036
1108
|
filter.contractAddress,
|
|
1037
1109
|
null,
|
|
1038
|
-
async privateSyncCall =>
|
|
1039
|
-
await this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [],
|
|
1040
|
-
this.node,
|
|
1041
|
-
this.contractStore,
|
|
1110
|
+
async (privateSyncCall, execScopes) =>
|
|
1111
|
+
await this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
|
|
1042
1112
|
anchorBlockHeader,
|
|
1113
|
+
jobId,
|
|
1114
|
+
filter.scopes,
|
|
1043
1115
|
);
|
|
1044
1116
|
});
|
|
1045
1117
|
|
|
@@ -43,23 +43,23 @@ export class AddressStore {
|
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
async #getCompleteAddress(address: AztecAddress): Promise<CompleteAddress | undefined> {
|
|
47
|
-
const index = await this.#completeAddressIndex.getAsync(address.toString());
|
|
48
|
-
if (index === undefined) {
|
|
49
|
-
return undefined;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const value = await this.#completeAddresses.atAsync(index);
|
|
53
|
-
return value ? await CompleteAddress.fromBuffer(value) : undefined;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
46
|
getCompleteAddress(account: AztecAddress): Promise<CompleteAddress | undefined> {
|
|
57
|
-
return this.#
|
|
47
|
+
return this.#store.transactionAsync(async () => {
|
|
48
|
+
const index = await this.#completeAddressIndex.getAsync(account.toString());
|
|
49
|
+
if (index === undefined) {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const value = await this.#completeAddresses.atAsync(index);
|
|
54
|
+
return value ? await CompleteAddress.fromBuffer(value) : undefined;
|
|
55
|
+
});
|
|
58
56
|
}
|
|
59
57
|
|
|
60
|
-
|
|
61
|
-
return
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
getCompleteAddresses(): Promise<CompleteAddress[]> {
|
|
59
|
+
return this.#store.transactionAsync(async () => {
|
|
60
|
+
return await Promise.all(
|
|
61
|
+
(await toArray(this.#completeAddresses.valuesAsync())).map(v => CompleteAddress.fromBuffer(v)),
|
|
62
|
+
);
|
|
63
|
+
});
|
|
64
64
|
}
|
|
65
65
|
}
|
|
@@ -10,6 +10,14 @@ export class AnchorBlockStore {
|
|
|
10
10
|
this.#synchronizedHeader = this.#store.openSingleton('header');
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Sets the currently synchronized block
|
|
15
|
+
*
|
|
16
|
+
* Important: this method is only called from BlockSynchronizer, and since we need it to run atomically with other
|
|
17
|
+
* stores in the case of a reorg, it MUST NOT be wrapped in a `transactionAsync` call. Doing so would result in a
|
|
18
|
+
* deadlock when the backend is IndexedDB, because `transactionAsync` is not designed to support reentrancy.
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
13
21
|
async setHeader(header: BlockHeader): Promise<void> {
|
|
14
22
|
await this.#synchronizedHeader.set(header.toBuffer());
|
|
15
23
|
}
|
|
@@ -57,14 +57,14 @@ export class CapsuleStore implements StagedStore {
|
|
|
57
57
|
*/
|
|
58
58
|
async #getFromStage(jobId: string, dbSlotKey: string): Promise<Buffer | null | undefined> {
|
|
59
59
|
const jobStagedCapsules = this.#getJobStagedCapsules(jobId);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
//
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return staged;
|
|
60
|
+
const staged: Buffer | null | undefined = jobStagedCapsules.get(dbSlotKey);
|
|
61
|
+
|
|
62
|
+
// Always issue DB read to keep IndexedDB transaction alive, even if the value is in the job staged data. This
|
|
63
|
+
// keeps IndexedDB transactions alive (they auto-commit when a new micro-task starts and there are no pending read
|
|
64
|
+
// requests). The staged value still takes precedence if it exists (including null for deletions).
|
|
65
|
+
const dbValue = await this.#loadCapsuleFromDb(dbSlotKey);
|
|
66
|
+
|
|
67
|
+
return staged !== undefined ? staged : dbValue;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
/**
|