@aztec/pxe 3.0.0-canary.a9708bd → 3.0.0-devnet.2
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/README.md +5 -5
- package/dest/bin/check_oracle_version.js +18 -8
- package/dest/config/index.d.ts +8 -8
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +3 -3
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +82 -26
- package/dest/contract_function_simulator/execution_data_provider.d.ts +27 -38
- package/dest/contract_function_simulator/execution_data_provider.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.d.ts +2 -2
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.js +7 -4
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +16 -0
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -0
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +26 -0
- package/dest/contract_function_simulator/index.d.ts +3 -1
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +2 -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 +7 -3
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +1 -0
- 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 +1 -1
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +22 -0
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/utility_context.js +33 -0
- package/dest/contract_function_simulator/oracle/index.d.ts +1 -1
- package/dest/contract_function_simulator/oracle/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/index.js +1 -1
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +97 -0
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/interfaces.js +4 -0
- package/dest/contract_function_simulator/oracle/oracle.d.ts +12 -11
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +79 -76
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -2
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +6 -15
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +26 -10
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +69 -18
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +10 -22
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +33 -38
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +19 -55
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +1 -1
- package/dest/contract_function_simulator/pxe_oracle_interface.js +174 -187
- 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 -1
- package/dest/entrypoints/client/bundle/utils.d.ts +8 -8
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +8 -8
- 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 -1
- package/dest/entrypoints/client/lazy/utils.d.ts +7 -7
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +7 -7
- package/dest/entrypoints/server/index.d.ts +3 -1
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +2 -1
- package/dest/entrypoints/server/utils.d.ts +4 -23
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +4 -25
- package/dest/{pxe_service/error_enriching.d.ts → error_enriching.d.ts} +1 -1
- package/dest/error_enriching.d.ts.map +1 -0
- package/dest/{pxe_service/error_enriching.js → error_enriching.js} +3 -0
- package/dest/oracle_version.d.ts +2 -2
- package/dest/oracle_version.js +2 -2
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.js +6 -6
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +7 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +23 -18
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts +2 -2
- package/dest/pxe.d.ts +233 -0
- package/dest/pxe.d.ts.map +1 -0
- package/dest/{pxe_service/pxe_service.js → pxe.js} +215 -214
- package/dest/storage/address_data_provider/address_data_provider.d.ts +1 -3
- package/dest/storage/address_data_provider/address_data_provider.d.ts.map +1 -1
- package/dest/storage/address_data_provider/address_data_provider.js +0 -3
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +1 -3
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +1 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.js +0 -4
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts +3 -4
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +1 -1
- package/dest/storage/contract_data_provider/contract_data_provider.js +0 -3
- package/dest/storage/index.d.ts +0 -1
- package/dest/storage/index.d.ts.map +1 -1
- package/dest/storage/index.js +0 -1
- package/dest/storage/note_data_provider/note_dao.d.ts +1 -1
- package/dest/storage/note_data_provider/note_dao.d.ts.map +1 -1
- package/dest/storage/note_data_provider/note_data_provider.d.ts +70 -7
- package/dest/storage/note_data_provider/note_data_provider.d.ts.map +1 -1
- package/dest/storage/note_data_provider/note_data_provider.js +120 -72
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +1 -3
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +1 -1
- package/dest/storage/private_event_data_provider/private_event_data_provider.js +0 -3
- package/dest/storage/sync_data_provider/sync_data_provider.d.ts +1 -3
- package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +1 -1
- package/dest/storage/sync_data_provider/sync_data_provider.js +0 -3
- package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +28 -6
- package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +1 -1
- package/dest/storage/tagging_data_provider/tagging_data_provider.js +46 -39
- package/dest/synchronizer/synchronizer.d.ts.map +1 -1
- package/dest/synchronizer/synchronizer.js +2 -3
- package/dest/tagging/constants.d.ts +2 -0
- package/dest/tagging/constants.d.ts.map +1 -0
- package/dest/tagging/constants.js +2 -0
- package/dest/tagging/index.d.ts +7 -0
- package/dest/tagging/index.d.ts.map +1 -0
- package/dest/tagging/index.js +5 -0
- package/dest/tagging/siloed_tag.d.ts +14 -0
- package/dest/tagging/siloed_tag.d.ts.map +1 -0
- package/dest/tagging/siloed_tag.js +20 -0
- package/dest/tagging/tag.d.ts +12 -0
- package/dest/tagging/tag.d.ts.map +1 -0
- package/dest/tagging/tag.js +17 -0
- package/dest/tagging/utils.d.ts +18 -0
- package/dest/tagging/utils.d.ts.map +1 -0
- package/dest/tagging/utils.js +24 -0
- package/package.json +19 -22
- package/src/bin/check_oracle_version.ts +23 -9
- package/src/config/index.ts +11 -10
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +128 -44
- package/src/contract_function_simulator/execution_data_provider.ts +29 -47
- package/src/contract_function_simulator/execution_note_cache.ts +11 -6
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +32 -0
- package/src/contract_function_simulator/index.ts +3 -1
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +8 -3
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/utility_context.ts +42 -0
- package/src/contract_function_simulator/oracle/index.ts +1 -1
- package/src/contract_function_simulator/oracle/interfaces.ts +160 -0
- package/src/contract_function_simulator/oracle/oracle.ts +102 -77
- package/src/contract_function_simulator/oracle/private_execution.ts +7 -15
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +106 -45
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +51 -76
- package/src/contract_function_simulator/pxe_oracle_interface.ts +199 -218
- package/src/entrypoints/client/bundle/index.ts +3 -1
- package/src/entrypoints/client/bundle/utils.ts +11 -19
- package/src/entrypoints/client/lazy/index.ts +3 -1
- package/src/entrypoints/client/lazy/utils.ts +10 -18
- package/src/entrypoints/server/index.ts +3 -1
- package/src/entrypoints/server/utils.ts +9 -39
- package/src/{pxe_service/error_enriching.ts → error_enriching.ts} +5 -1
- package/src/oracle_version.ts +2 -2
- package/src/private_kernel/hints/compute_tx_include_by_timestamp.ts +6 -6
- package/src/private_kernel/private_kernel_execution_prover.ts +35 -23
- package/src/{pxe_service/pxe_service.ts → pxe.ts} +230 -257
- package/src/storage/address_data_provider/address_data_provider.ts +1 -7
- package/src/storage/capsule_data_provider/capsule_data_provider.ts +1 -11
- package/src/storage/contract_data_provider/contract_data_provider.ts +3 -9
- package/src/storage/index.ts +0 -1
- package/src/storage/note_data_provider/note_dao.ts +1 -1
- package/src/storage/note_data_provider/note_data_provider.ts +142 -99
- package/src/storage/private_event_data_provider/private_event_data_provider.ts +1 -7
- package/src/storage/sync_data_provider/sync_data_provider.ts +1 -7
- package/src/storage/tagging_data_provider/tagging_data_provider.ts +52 -55
- package/src/synchronizer/synchronizer.ts +2 -3
- package/src/tagging/constants.ts +2 -0
- package/src/tagging/index.ts +6 -0
- package/src/tagging/siloed_tag.ts +22 -0
- package/src/tagging/tag.ts +16 -0
- package/src/tagging/utils.ts +31 -0
- package/dest/bin/index.d.ts +0 -3
- package/dest/bin/index.d.ts.map +0 -1
- package/dest/bin/index.js +0 -48
- package/dest/contract_function_simulator/oracle/typed_oracle.d.ts +0 -87
- package/dest/contract_function_simulator/oracle/typed_oracle.d.ts.map +0 -1
- package/dest/contract_function_simulator/oracle/typed_oracle.js +0 -146
- package/dest/contract_function_simulator/tagging_utils.d.ts +0 -17
- package/dest/contract_function_simulator/tagging_utils.d.ts.map +0 -1
- package/dest/contract_function_simulator/tagging_utils.js +0 -23
- package/dest/pxe_service/error_enriching.d.ts.map +0 -1
- package/dest/pxe_service/index.d.ts +0 -3
- package/dest/pxe_service/index.d.ts.map +0 -1
- package/dest/pxe_service/index.js +0 -2
- package/dest/pxe_service/pxe_service.d.ts +0 -100
- package/dest/pxe_service/pxe_service.d.ts.map +0 -1
- package/dest/storage/data_provider.d.ts +0 -4
- package/dest/storage/data_provider.d.ts.map +0 -1
- package/dest/storage/data_provider.js +0 -1
- package/dest/test/pxe_test_suite.d.ts +0 -3
- package/dest/test/pxe_test_suite.d.ts.map +0 -1
- package/dest/test/pxe_test_suite.js +0 -97
- package/src/bin/index.ts +0 -62
- package/src/contract_function_simulator/oracle/typed_oracle.ts +0 -289
- package/src/contract_function_simulator/tagging_utils.ts +0 -32
- package/src/pxe_service/index.ts +0 -2
- package/src/storage/data_provider.ts +0 -3
- package/src/test/pxe_test_suite.ts +0 -113
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
import { timesParallel } from '@aztec/foundation/collection';
|
|
2
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
3
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
3
|
import { getFunctionArtifact } from '@aztec/stdlib/abi';
|
|
5
4
|
import { computeUniqueNoteHash, siloNoteHash, siloNullifier, siloPrivateLog } from '@aztec/stdlib/hash';
|
|
6
5
|
import { MAX_RPC_LEN } from '@aztec/stdlib/interfaces/client';
|
|
7
|
-
import { computeAddressSecret
|
|
8
|
-
import {
|
|
6
|
+
import { computeAddressSecret } from '@aztec/stdlib/keys';
|
|
7
|
+
import { PendingTaggedLog, PrivateLogWithTxData, PublicLogWithTxData, deriveEcdhSharedSecret } from '@aztec/stdlib/logs';
|
|
9
8
|
import { getNonNullifiedL1ToL2MessageWitness } from '@aztec/stdlib/messaging';
|
|
10
9
|
import { Note } from '@aztec/stdlib/note';
|
|
11
10
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
12
11
|
import { MessageLoadOracleInputs } from '../contract_function_simulator/oracle/message_load_oracle_inputs.js';
|
|
13
12
|
import { ORACLE_VERSION } from '../oracle_version.js';
|
|
14
13
|
import { NoteDao } from '../storage/note_data_provider/note_dao.js';
|
|
14
|
+
import { DirectionalAppTaggingSecret, SiloedTag, Tag, WINDOW_HALF_SIZE, getInitialIndexesMap, getPreTagsForTheWindow } from '../tagging/index.js';
|
|
15
15
|
import { EventValidationRequest } from './noir-structs/event_validation_request.js';
|
|
16
16
|
import { LogRetrievalRequest } from './noir-structs/log_retrieval_request.js';
|
|
17
17
|
import { LogRetrievalResponse } from './noir-structs/log_retrieval_response.js';
|
|
18
18
|
import { NoteValidationRequest } from './noir-structs/note_validation_request.js';
|
|
19
|
-
import { WINDOW_HALF_SIZE, getIndexedTaggingSecretsForTheWindow, getInitialIndexesMap } from './tagging_utils.js';
|
|
20
19
|
/**
|
|
21
20
|
* A data layer that provides and stores information needed for simulating/proving a transaction.
|
|
22
21
|
*/ export class PXEOracleInterface {
|
|
@@ -140,30 +139,41 @@ import { WINDOW_HALF_SIZE, getIndexedTaggingSecretsForTheWindow, getInitialIndex
|
|
|
140
139
|
}
|
|
141
140
|
}
|
|
142
141
|
async getNullifierMembershipWitnessAtLatestBlock(nullifier) {
|
|
143
|
-
|
|
142
|
+
const blockNumber = (await this.getAnchorBlockHeader()).globalVariables.blockNumber;
|
|
143
|
+
return this.getNullifierMembershipWitness(blockNumber, nullifier);
|
|
144
144
|
}
|
|
145
145
|
getNullifierMembershipWitness(blockNumber, nullifier) {
|
|
146
146
|
return this.aztecNode.getNullifierMembershipWitness(blockNumber, nullifier);
|
|
147
147
|
}
|
|
148
|
-
getLowNullifierMembershipWitness(blockNumber, nullifier) {
|
|
148
|
+
async getLowNullifierMembershipWitness(blockNumber, nullifier) {
|
|
149
|
+
const header = await this.getAnchorBlockHeader();
|
|
150
|
+
if (blockNumber > header.globalVariables.blockNumber) {
|
|
151
|
+
throw new Error(`Block number ${blockNumber} is higher than current block ${header.globalVariables.blockNumber}`);
|
|
152
|
+
}
|
|
149
153
|
return this.aztecNode.getLowNullifierMembershipWitness(blockNumber, nullifier);
|
|
150
154
|
}
|
|
151
155
|
async getBlock(blockNumber) {
|
|
156
|
+
const header = await this.getAnchorBlockHeader();
|
|
157
|
+
if (blockNumber > header.globalVariables.blockNumber) {
|
|
158
|
+
throw new Error(`Block number ${blockNumber} is higher than current block ${header.globalVariables.blockNumber}`);
|
|
159
|
+
}
|
|
152
160
|
return await this.aztecNode.getBlock(blockNumber);
|
|
153
161
|
}
|
|
154
162
|
async getPublicDataWitness(blockNumber, leafSlot) {
|
|
163
|
+
const header = await this.getAnchorBlockHeader();
|
|
164
|
+
if (blockNumber > header.globalVariables.blockNumber) {
|
|
165
|
+
throw new Error(`Block number ${blockNumber} is higher than current block ${header.globalVariables.blockNumber}`);
|
|
166
|
+
}
|
|
155
167
|
return await this.aztecNode.getPublicDataWitness(blockNumber, leafSlot);
|
|
156
168
|
}
|
|
157
169
|
async getPublicStorageAt(blockNumber, contract, slot) {
|
|
170
|
+
const header = await this.getAnchorBlockHeader();
|
|
171
|
+
if (blockNumber > header.globalVariables.blockNumber) {
|
|
172
|
+
throw new Error(`Block number ${blockNumber} is higher than current block ${header.globalVariables.blockNumber}`);
|
|
173
|
+
}
|
|
158
174
|
return await this.aztecNode.getPublicStorageAt(blockNumber, contract, slot);
|
|
159
175
|
}
|
|
160
|
-
|
|
161
|
-
* Retrieve the latest block header synchronized by the PXE.
|
|
162
|
-
* @dev This structure is fed into the circuits simulator and is used to prove against certain historical roots.
|
|
163
|
-
* @returns The BlockHeader object.
|
|
164
|
-
* TODO: I think this naming is bad as it's not the latest block header synched by the node, but the latest block
|
|
165
|
-
* header synchronized by the PXE. Would rename this to something like getSynchronizedBlockHeader().
|
|
166
|
-
*/ getBlockHeader() {
|
|
176
|
+
getAnchorBlockHeader() {
|
|
167
177
|
return this.syncDataProvider.getBlockHeader();
|
|
168
178
|
}
|
|
169
179
|
assertCompatibleOracleVersion(version) {
|
|
@@ -171,34 +181,6 @@ import { WINDOW_HALF_SIZE, getIndexedTaggingSecretsForTheWindow, getInitialIndex
|
|
|
171
181
|
throw new Error(`Incompatible oracle version. Expected version ${ORACLE_VERSION}, got ${version}.`);
|
|
172
182
|
}
|
|
173
183
|
}
|
|
174
|
-
/**
|
|
175
|
-
* Fetches the latest block number synchronized by the node.
|
|
176
|
-
* @returns The block number.
|
|
177
|
-
*/ async getBlockNumber() {
|
|
178
|
-
return await this.aztecNode.getBlockNumber();
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Fetches the timestamp of the latest block synchronized by the node.
|
|
182
|
-
* @returns The timestamp.
|
|
183
|
-
*/ async getTimestamp() {
|
|
184
|
-
const latestBlockHeader = await this.aztecNode.getBlockHeader();
|
|
185
|
-
if (!latestBlockHeader) {
|
|
186
|
-
throw new Error('Latest block header not found when getting timestamp');
|
|
187
|
-
}
|
|
188
|
-
return latestBlockHeader.globalVariables.timestamp;
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Fetches the current chain id.
|
|
192
|
-
* @returns The chain id.
|
|
193
|
-
*/ async getChainId() {
|
|
194
|
-
return await this.aztecNode.getChainId();
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Fetches the current version.
|
|
198
|
-
* @returns The version.
|
|
199
|
-
*/ async getVersion() {
|
|
200
|
-
return await this.aztecNode.getVersion();
|
|
201
|
-
}
|
|
202
184
|
getDebugFunctionName(contractAddress, selector) {
|
|
203
185
|
return this.contractDataProvider.getDebugFunctionName(contractAddress, selector);
|
|
204
186
|
}
|
|
@@ -210,57 +192,27 @@ import { WINDOW_HALF_SIZE, getIndexedTaggingSecretsForTheWindow, getInitialIndex
|
|
|
210
192
|
*/ getSenders() {
|
|
211
193
|
return this.taggingDataProvider.getSenderAddresses();
|
|
212
194
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
* Includes the next index to be used used for tagging with this secret.
|
|
216
|
-
* @param contractAddress - The contract address to silo the secret for
|
|
217
|
-
* @param sender - The address sending the note
|
|
218
|
-
* @param recipient - The address receiving the note
|
|
219
|
-
* @returns An indexed tagging secret that can be used to tag notes.
|
|
220
|
-
*/ async getIndexedTaggingSecretAsSender(contractAddress, sender, recipient) {
|
|
221
|
-
await this.syncTaggedLogsAsSender(contractAddress, sender, recipient);
|
|
222
|
-
const appTaggingSecret = await this.#calculateAppTaggingSecret(contractAddress, sender, recipient);
|
|
223
|
-
const [index] = await this.taggingDataProvider.getTaggingSecretsIndexesAsSender([
|
|
224
|
-
appTaggingSecret
|
|
225
|
-
], sender);
|
|
226
|
-
return new IndexedTaggingSecret(appTaggingSecret, index);
|
|
195
|
+
getLastUsedIndexAsSender(secret) {
|
|
196
|
+
return this.taggingDataProvider.getLastUsedIndexesAsSender(secret);
|
|
227
197
|
}
|
|
228
|
-
|
|
229
|
-
* Increments the tagging secret for a given sender and recipient pair. For this to work, the ivsk_m of the sender must be known.
|
|
230
|
-
* @param contractAddress - The contract address to silo the secret for
|
|
231
|
-
* @param sender - The address sending the note
|
|
232
|
-
* @param recipient - The address receiving the note
|
|
233
|
-
*/ async incrementAppTaggingSecretIndexAsSender(contractAddress, sender, recipient) {
|
|
234
|
-
const secret = await this.#calculateAppTaggingSecret(contractAddress, sender, recipient);
|
|
235
|
-
const contractName = await this.contractDataProvider.getDebugContractName(contractAddress);
|
|
236
|
-
this.log.debug(`Incrementing app tagging secret at ${contractName}(${contractAddress})`, {
|
|
237
|
-
secret,
|
|
238
|
-
sender,
|
|
239
|
-
recipient,
|
|
240
|
-
contractName,
|
|
241
|
-
contractAddress
|
|
242
|
-
});
|
|
243
|
-
const [index] = await this.taggingDataProvider.getTaggingSecretsIndexesAsSender([
|
|
244
|
-
secret
|
|
245
|
-
], sender);
|
|
246
|
-
await this.taggingDataProvider.setTaggingSecretsIndexesAsSender([
|
|
247
|
-
new IndexedTaggingSecret(secret, index + 1)
|
|
248
|
-
], sender);
|
|
249
|
-
}
|
|
250
|
-
async #calculateAppTaggingSecret(contractAddress, sender, recipient) {
|
|
198
|
+
async calculateDirectionalAppTaggingSecret(contractAddress, sender, recipient) {
|
|
251
199
|
const senderCompleteAddress = await this.getCompleteAddress(sender);
|
|
252
200
|
const senderIvsk = await this.keyStore.getMasterIncomingViewingSecretKey(sender);
|
|
253
|
-
return
|
|
201
|
+
return DirectionalAppTaggingSecret.compute(senderCompleteAddress, senderIvsk, recipient, contractAddress, recipient);
|
|
254
202
|
}
|
|
255
203
|
/**
|
|
256
|
-
* Returns the
|
|
204
|
+
* Returns the last used tagging indexes along with the directional app tagging secrets for a given recipient and all
|
|
205
|
+
* the senders in the address book.
|
|
257
206
|
* This method should be exposed as an oracle call to allow aztec.nr to perform the orchestration
|
|
258
207
|
* of the syncTaggedLogs and processTaggedLogs methods. However, it is not possible to do so at the moment,
|
|
259
208
|
* so we're keeping it private for now.
|
|
260
209
|
* @param contractAddress - The contract address to silo the secret for
|
|
261
210
|
* @param recipient - The address receiving the notes
|
|
262
|
-
* @returns A list of
|
|
263
|
-
|
|
211
|
+
* @returns A list of directional app tagging secrets along with the last used tagging indexes. If the corresponding
|
|
212
|
+
* secret was never used, the index is undefined.
|
|
213
|
+
* TODO(benesjan): The naming here is broken as the function name does not reflect the return type. Fix when associating
|
|
214
|
+
* indexes with tx hash.
|
|
215
|
+
*/ async #getLastUsedTaggingIndexesForSenders(contractAddress, recipient) {
|
|
264
216
|
const recipientCompleteAddress = await this.getCompleteAddress(recipient);
|
|
265
217
|
const recipientIvsk = await this.keyStore.getMasterIncomingViewingSecretKey(recipient);
|
|
266
218
|
// We implicitly add all PXE accounts as senders, this helps us decrypt tags on notes that we send to ourselves
|
|
@@ -269,21 +221,23 @@ import { WINDOW_HALF_SIZE, getIndexedTaggingSecretsForTheWindow, getInitialIndex
|
|
|
269
221
|
...await this.taggingDataProvider.getSenderAddresses(),
|
|
270
222
|
...await this.keyStore.getAccounts()
|
|
271
223
|
].filter((address, index, self)=>index === self.findIndex((otherAddress)=>otherAddress.equals(address)));
|
|
272
|
-
const
|
|
273
|
-
|
|
274
|
-
|
|
224
|
+
const secrets = await Promise.all(senders.map((contact)=>{
|
|
225
|
+
return DirectionalAppTaggingSecret.compute(recipientCompleteAddress, recipientIvsk, contact, contractAddress, recipient);
|
|
226
|
+
}));
|
|
227
|
+
const indexes = await this.taggingDataProvider.getLastUsedIndexesAsRecipient(secrets);
|
|
228
|
+
if (indexes.length !== secrets.length) {
|
|
229
|
+
throw new Error('Indexes and directional app tagging secrets have different lengths');
|
|
230
|
+
}
|
|
231
|
+
return secrets.map((secret, i)=>({
|
|
232
|
+
secret,
|
|
233
|
+
index: indexes[i]
|
|
234
|
+
}));
|
|
275
235
|
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
* @param recipient - The address of the recipient.
|
|
282
|
-
*/ async syncTaggedLogsAsSender(contractAddress, sender, recipient) {
|
|
283
|
-
const appTaggingSecret = await this.#calculateAppTaggingSecret(contractAddress, sender, recipient);
|
|
284
|
-
const [oldIndex] = await this.taggingDataProvider.getTaggingSecretsIndexesAsSender([
|
|
285
|
-
appTaggingSecret
|
|
286
|
-
], sender);
|
|
236
|
+
async syncTaggedLogsAsSender(secret, contractAddress) {
|
|
237
|
+
const lastUsedIndex = await this.taggingDataProvider.getLastUsedIndexesAsSender(secret);
|
|
238
|
+
// If lastUsedIndex is undefined, we've never used this secret, so start from 0
|
|
239
|
+
// Otherwise, start from one past the last used index
|
|
240
|
+
const startIndex = lastUsedIndex === undefined ? 0 : lastUsedIndex + 1;
|
|
287
241
|
// This algorithm works such that:
|
|
288
242
|
// 1. If we find minimum consecutive empty logs in a window of logs we set the index to the index of the last log
|
|
289
243
|
// we found and quit.
|
|
@@ -293,40 +247,50 @@ import { WINDOW_HALF_SIZE, getIndexedTaggingSecretsForTheWindow, getInitialIndex
|
|
|
293
247
|
const WINDOW_SIZE = MIN_CONSECUTIVE_EMPTY_LOGS * 2;
|
|
294
248
|
let [numConsecutiveEmptyLogs, currentIndex] = [
|
|
295
249
|
0,
|
|
296
|
-
|
|
250
|
+
startIndex
|
|
297
251
|
];
|
|
252
|
+
let lastFoundLogIndex = undefined;
|
|
298
253
|
do {
|
|
299
254
|
// We compute the tags for the current window of indexes
|
|
300
|
-
const currentTags = await timesParallel(WINDOW_SIZE, (i)=>{
|
|
301
|
-
|
|
302
|
-
|
|
255
|
+
const currentTags = await timesParallel(WINDOW_SIZE, async (i)=>{
|
|
256
|
+
return SiloedTag.compute(await Tag.compute({
|
|
257
|
+
secret,
|
|
258
|
+
index: currentIndex + i
|
|
259
|
+
}), contractAddress);
|
|
303
260
|
});
|
|
304
261
|
// We fetch the logs for the tags
|
|
305
|
-
|
|
262
|
+
// TODO: The following conversion is unfortunate and we should most likely just type the #getPrivateLogsByTags
|
|
263
|
+
// to accept SiloedTag[] instead of Fr[]. That would result in a large change so I didn't do it yet.
|
|
264
|
+
const tagsAsFr = currentTags.map((tag)=>tag.value);
|
|
265
|
+
const possibleLogs = await this.#getPrivateLogsByTags(tagsAsFr);
|
|
306
266
|
// We find the index of the last log in the window that is not empty
|
|
307
|
-
const
|
|
308
|
-
if (
|
|
267
|
+
const indexOfLastLogWithinArray = possibleLogs.findLastIndex((possibleLog)=>possibleLog.length !== 0);
|
|
268
|
+
if (indexOfLastLogWithinArray === -1) {
|
|
309
269
|
break;
|
|
310
270
|
}
|
|
311
|
-
// We
|
|
312
|
-
|
|
271
|
+
// We've found logs so we update the last found log index
|
|
272
|
+
lastFoundLogIndex = (lastFoundLogIndex ?? 0) + indexOfLastLogWithinArray;
|
|
273
|
+
// We move the current index to that of the log right after the last found log
|
|
274
|
+
currentIndex = lastFoundLogIndex + 1;
|
|
313
275
|
// We compute the number of consecutive empty logs we found and repeat the process if we haven't found enough.
|
|
314
|
-
numConsecutiveEmptyLogs = WINDOW_SIZE -
|
|
276
|
+
numConsecutiveEmptyLogs = WINDOW_SIZE - indexOfLastLogWithinArray - 1;
|
|
315
277
|
}while (numConsecutiveEmptyLogs < MIN_CONSECUTIVE_EMPTY_LOGS)
|
|
316
278
|
const contractName = await this.contractDataProvider.getDebugContractName(contractAddress);
|
|
317
|
-
if (
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
279
|
+
if (lastFoundLogIndex !== undefined) {
|
|
280
|
+
// Last found index is defined meaning we have actually found logs so we update the last used index
|
|
281
|
+
await this.taggingDataProvider.setLastUsedIndexesAsSender([
|
|
282
|
+
{
|
|
283
|
+
secret,
|
|
284
|
+
index: lastFoundLogIndex
|
|
285
|
+
}
|
|
286
|
+
]);
|
|
287
|
+
this.log.debug(`Syncing logs for secret ${secret.toString()} at contract ${contractName}(${contractAddress})`, {
|
|
324
288
|
index: currentIndex,
|
|
325
289
|
contractName,
|
|
326
290
|
contractAddress
|
|
327
291
|
});
|
|
328
292
|
} else {
|
|
329
|
-
this.log.debug(`No new logs found for
|
|
293
|
+
this.log.debug(`No new logs found for secret ${secret.toString()} at contract ${contractName}(${contractAddress})`);
|
|
330
294
|
}
|
|
331
295
|
}
|
|
332
296
|
/**
|
|
@@ -351,7 +315,7 @@ import { WINDOW_HALF_SIZE, getIndexedTaggingSecretsForTheWindow, getInitialIndex
|
|
|
351
315
|
const contractName = await this.contractDataProvider.getDebugContractName(contractAddress);
|
|
352
316
|
for (const recipient of recipients){
|
|
353
317
|
// Get all the secrets for the recipient and sender pairs (#9365)
|
|
354
|
-
const
|
|
318
|
+
const indexedSecrets = await this.#getLastUsedTaggingIndexesForSenders(contractAddress, recipient);
|
|
355
319
|
// We fetch logs for a window of indexes in a range:
|
|
356
320
|
// <latest_log_index - WINDOW_HALF_SIZE, latest_log_index + WINDOW_HALF_SIZE>.
|
|
357
321
|
//
|
|
@@ -360,25 +324,39 @@ import { WINDOW_HALF_SIZE, getIndexedTaggingSecretsForTheWindow, getInitialIndex
|
|
|
360
324
|
// for logs the first time we don't receive any logs for a tag, we might never receive anything from that sender again.
|
|
361
325
|
// Also there's a possibility that we have advanced our index, but the sender has reused it, so we might have missed
|
|
362
326
|
// some logs. For these reasons, we have to look both back and ahead of the stored index.
|
|
363
|
-
let secretsAndWindows =
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
327
|
+
let secretsAndWindows = indexedSecrets.map((indexedSecret)=>{
|
|
328
|
+
if (indexedSecret.index === undefined) {
|
|
329
|
+
return {
|
|
330
|
+
secret: indexedSecret.secret,
|
|
331
|
+
leftMostIndex: 0,
|
|
332
|
+
rightMostIndex: WINDOW_HALF_SIZE
|
|
333
|
+
};
|
|
334
|
+
} else {
|
|
335
|
+
return {
|
|
336
|
+
secret: indexedSecret.secret,
|
|
337
|
+
leftMostIndex: Math.max(0, indexedSecret.index - WINDOW_HALF_SIZE),
|
|
338
|
+
rightMostIndex: indexedSecret.index + WINDOW_HALF_SIZE
|
|
339
|
+
};
|
|
340
|
+
}
|
|
369
341
|
});
|
|
370
342
|
// As we iterate we store the largest index we have seen for a given secret to later on store it in the db.
|
|
371
343
|
const newLargestIndexMapToStore = {};
|
|
372
|
-
// The initial/unmodified indexes of the secrets stored in a key-value map where key is the app
|
|
373
|
-
|
|
344
|
+
// The initial/unmodified indexes of the secrets stored in a key-value map where key is the directional app
|
|
345
|
+
// tagging secret.
|
|
346
|
+
const initialIndexesMap = getInitialIndexesMap(indexedSecrets);
|
|
374
347
|
while(secretsAndWindows.length > 0){
|
|
375
|
-
const
|
|
376
|
-
const tagsForTheWholeWindow = await Promise.all(
|
|
348
|
+
const preTagsForTheWholeWindow = getPreTagsForTheWindow(secretsAndWindows);
|
|
349
|
+
const tagsForTheWholeWindow = await Promise.all(preTagsForTheWholeWindow.map(async (preTag)=>{
|
|
350
|
+
return SiloedTag.compute(await Tag.compute(preTag), contractAddress);
|
|
351
|
+
}));
|
|
377
352
|
// We store the new largest indexes we find in the iteration in the following map to later on construct
|
|
378
353
|
// a new set of secrets and windows to fetch logs for.
|
|
379
354
|
const newLargestIndexMapForIteration = {};
|
|
380
355
|
// Fetch the private logs for the tags and iterate over them
|
|
381
|
-
|
|
356
|
+
// TODO: The following conversion is unfortunate and we should most likely just type the #getPrivateLogsByTags
|
|
357
|
+
// to accept SiloedTag[] instead of Fr[]. That would result in a large change so I didn't do it yet.
|
|
358
|
+
const tagsForTheWholeWindowAsFr = tagsForTheWholeWindow.map((tag)=>tag.value);
|
|
359
|
+
const logsByTags = await this.#getPrivateLogsByTags(tagsForTheWholeWindowAsFr);
|
|
382
360
|
this.log.debug(`Found ${logsByTags.filter((logs)=>logs.length > 0).length} logs as recipient ${recipient}`, {
|
|
383
361
|
recipient,
|
|
384
362
|
contractName,
|
|
@@ -387,19 +365,19 @@ import { WINDOW_HALF_SIZE, getIndexedTaggingSecretsForTheWindow, getInitialIndex
|
|
|
387
365
|
for(let logIndex = 0; logIndex < logsByTags.length; logIndex++){
|
|
388
366
|
const logsByTag = logsByTags[logIndex];
|
|
389
367
|
if (logsByTag.length > 0) {
|
|
390
|
-
// We filter out the logs that are newer than the
|
|
368
|
+
// We filter out the logs that are newer than the anchor block number of the tx currently being constructed
|
|
391
369
|
const filteredLogsByBlockNumber = logsByTag.filter((l)=>l.blockNumber <= maxBlockNumber);
|
|
392
370
|
// We store the logs in capsules (to later be obtained in Noir)
|
|
393
371
|
await this.#storePendingTaggedLogs(contractAddress, pendingTaggedLogArrayBaseSlot, recipient, filteredLogsByBlockNumber);
|
|
394
|
-
// We retrieve the
|
|
372
|
+
// We retrieve the pre tag corresponding to the log as I need that to evaluate whether
|
|
395
373
|
// a new largest index have been found.
|
|
396
|
-
const
|
|
397
|
-
const initialIndex = initialIndexesMap[
|
|
398
|
-
if (
|
|
374
|
+
const preTagCorrespondingToLog = preTagsForTheWholeWindow[logIndex];
|
|
375
|
+
const initialIndex = initialIndexesMap[preTagCorrespondingToLog.secret.toString()];
|
|
376
|
+
if (preTagCorrespondingToLog.index >= initialIndex && (newLargestIndexMapForIteration[preTagCorrespondingToLog.secret.toString()] === undefined || preTagCorrespondingToLog.index >= newLargestIndexMapForIteration[preTagCorrespondingToLog.secret.toString()])) {
|
|
399
377
|
// We have found a new largest index so we store it for later processing (storing it in the db + fetching
|
|
400
378
|
// the difference of the window sets of current and the next iteration)
|
|
401
|
-
newLargestIndexMapForIteration[
|
|
402
|
-
this.log.debug(`Incrementing index to ${
|
|
379
|
+
newLargestIndexMapForIteration[preTagCorrespondingToLog.secret.toString()] = preTagCorrespondingToLog.index + 1;
|
|
380
|
+
this.log.debug(`Incrementing index to ${preTagCorrespondingToLog.index + 1} at contract ${contractName}(${contractAddress})`);
|
|
403
381
|
}
|
|
404
382
|
}
|
|
405
383
|
}
|
|
@@ -407,26 +385,31 @@ import { WINDOW_HALF_SIZE, getIndexedTaggingSecretsForTheWindow, getInitialIndex
|
|
|
407
385
|
// for. Note that it's very unlikely that a new log from the current window would appear between the iterations
|
|
408
386
|
// so we fetch the logs only for the difference of the window sets.
|
|
409
387
|
const newSecretsAndWindows = [];
|
|
410
|
-
for (const [
|
|
411
|
-
const
|
|
412
|
-
if (
|
|
388
|
+
for (const [directionalAppTaggingSecret, newIndex] of Object.entries(newLargestIndexMapForIteration)){
|
|
389
|
+
const maybeIndexedSecret = indexedSecrets.find((indexedSecret)=>indexedSecret.secret.toString() === directionalAppTaggingSecret);
|
|
390
|
+
if (maybeIndexedSecret) {
|
|
413
391
|
newSecretsAndWindows.push({
|
|
414
|
-
|
|
392
|
+
secret: maybeIndexedSecret.secret,
|
|
415
393
|
// We set the left most index to the new index to avoid fetching the same logs again
|
|
416
394
|
leftMostIndex: newIndex,
|
|
417
395
|
rightMostIndex: newIndex + WINDOW_HALF_SIZE
|
|
418
396
|
});
|
|
419
397
|
// We store the new largest index in the map to later store it in the db.
|
|
420
|
-
newLargestIndexMapToStore[
|
|
398
|
+
newLargestIndexMapToStore[directionalAppTaggingSecret] = newIndex;
|
|
421
399
|
} else {
|
|
422
|
-
throw new Error(`Secret not found for
|
|
400
|
+
throw new Error(`Secret not found for directionalAppTaggingSecret ${directionalAppTaggingSecret}. This is a bug as it should never happen!`);
|
|
423
401
|
}
|
|
424
402
|
}
|
|
425
403
|
// Now we set the new secrets and windows and proceed to the next iteration.
|
|
426
404
|
secretsAndWindows = newSecretsAndWindows;
|
|
427
405
|
}
|
|
428
|
-
// At this point we have processed all the logs for the recipient so we store the
|
|
429
|
-
|
|
406
|
+
// At this point we have processed all the logs for the recipient so we store the last used indexes in the db.
|
|
407
|
+
// newLargestIndexMapToStore contains "next" indexes to look for (one past the last found), so subtract 1 to get
|
|
408
|
+
// last used.
|
|
409
|
+
await this.taggingDataProvider.setLastUsedIndexesAsRecipient(Object.entries(newLargestIndexMapToStore).map(([directionalAppTaggingSecret, index])=>({
|
|
410
|
+
secret: DirectionalAppTaggingSecret.fromString(directionalAppTaggingSecret),
|
|
411
|
+
index: index - 1
|
|
412
|
+
})));
|
|
430
413
|
}
|
|
431
414
|
}
|
|
432
415
|
async #storePendingTaggedLogs(contractAddress, capsuleArrayBaseSlot, recipient, privateLogs) {
|
|
@@ -508,12 +491,12 @@ import { WINDOW_HALF_SIZE, getIndexedTaggingSecretsForTheWindow, getInitialIndex
|
|
|
508
491
|
});
|
|
509
492
|
if (nullifierIndex !== undefined) {
|
|
510
493
|
const { data: _, ...blockHashAndNum } = nullifierIndex;
|
|
511
|
-
await this.noteDataProvider.
|
|
494
|
+
await this.noteDataProvider.applyNullifiers([
|
|
512
495
|
{
|
|
513
496
|
data: siloedNullifier,
|
|
514
497
|
...blockHashAndNum
|
|
515
498
|
}
|
|
516
|
-
]
|
|
499
|
+
]);
|
|
517
500
|
this.log.verbose(`Removed just-added note`, {
|
|
518
501
|
contract: contractAddress,
|
|
519
502
|
slot: storageSlot,
|
|
@@ -609,56 +592,60 @@ import { WINDOW_HALF_SIZE, getIndexedTaggingSecretsForTheWindow, getInitialIndex
|
|
|
609
592
|
}
|
|
610
593
|
return new PrivateLogWithTxData(scopedLog.log.getEmittedFieldsWithoutTag(), scopedLog.txHash, txEffect.data.noteHashes, txEffect.data.nullifiers[0]);
|
|
611
594
|
}
|
|
612
|
-
|
|
595
|
+
/**
|
|
596
|
+
* Looks for nullifiers of active contract notes and marks them as nullified if a nullifier is found.
|
|
597
|
+
*
|
|
598
|
+
* Fetches notes from the NoteDataProvider and checks which nullifiers are present in the
|
|
599
|
+
* onchain nullifier Merkle tree - up to the latest locally synced block. We use the
|
|
600
|
+
* locally synced block instead of querying the chain's 'latest' block to ensure correctness:
|
|
601
|
+
* notes are only marked nullified once their corresponding nullifier has been included in a
|
|
602
|
+
* block up to which the PXE has synced.
|
|
603
|
+
* This allows recent nullifications to be processed even if the node is not an archive node.
|
|
604
|
+
*
|
|
605
|
+
* @param contractAddress - The contract whose notes should be checked and nullified.
|
|
606
|
+
*/ async syncNoteNullifiers(contractAddress) {
|
|
613
607
|
this.log.verbose('Searching for nullifiers of known notes', {
|
|
614
608
|
contract: contractAddress
|
|
615
609
|
});
|
|
616
|
-
// We avoid making node queries at 'latest' since we mark notes as nullified only if the corresponding nullifier
|
|
617
|
-
// has been included in a block up to which PXE has synced. Note that while this technically results in historical
|
|
618
|
-
// queries, we perform it at the latest locally synced block number which *should* be recent enough to be
|
|
619
|
-
// available, even for non-archive nodes.
|
|
620
610
|
const syncedBlockNumber = await this.syncDataProvider.getBlockNumber();
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
611
|
+
const contractNotes = await this.noteDataProvider.getNotes({
|
|
612
|
+
contractAddress
|
|
613
|
+
});
|
|
614
|
+
if (contractNotes.length === 0) {
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
const nullifiersToCheck = contractNotes.map((note)=>note.siloedNullifier);
|
|
618
|
+
const nullifierBatches = nullifiersToCheck.reduce((acc, nullifier)=>{
|
|
619
|
+
if (acc[acc.length - 1].length < MAX_RPC_LEN) {
|
|
620
|
+
acc[acc.length - 1].push(nullifier);
|
|
621
|
+
} else {
|
|
622
|
+
acc.push([
|
|
623
|
+
nullifier
|
|
624
|
+
]);
|
|
628
625
|
}
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
};
|
|
651
|
-
}
|
|
652
|
-
}).filter((nullifier)=>nullifier !== undefined);
|
|
653
|
-
const nullifiedNotes = await this.noteDataProvider.removeNullifiedNotes(foundNullifiers, recipient);
|
|
654
|
-
nullifiedNotes.forEach((noteDao)=>{
|
|
655
|
-
this.log.verbose(`Removed note for contract ${noteDao.contractAddress} at slot ${noteDao.storageSlot}`, {
|
|
656
|
-
contract: noteDao.contractAddress,
|
|
657
|
-
slot: noteDao.storageSlot,
|
|
658
|
-
nullifier: noteDao.siloedNullifier.toString()
|
|
659
|
-
});
|
|
626
|
+
return acc;
|
|
627
|
+
}, [
|
|
628
|
+
[]
|
|
629
|
+
]);
|
|
630
|
+
const nullifierIndexes = (await Promise.all(nullifierBatches.map((batch)=>this.aztecNode.findLeavesIndexes(syncedBlockNumber, MerkleTreeId.NULLIFIER_TREE, batch)))).flat();
|
|
631
|
+
const foundNullifiers = nullifiersToCheck.map((nullifier, i)=>{
|
|
632
|
+
if (nullifierIndexes[i] !== undefined) {
|
|
633
|
+
return {
|
|
634
|
+
...nullifierIndexes[i],
|
|
635
|
+
...{
|
|
636
|
+
data: nullifier
|
|
637
|
+
}
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
}).filter((nullifier)=>nullifier !== undefined);
|
|
641
|
+
const nullifiedNotes = await this.noteDataProvider.applyNullifiers(foundNullifiers);
|
|
642
|
+
nullifiedNotes.forEach((noteDao)=>{
|
|
643
|
+
this.log.verbose(`Removed note for contract ${noteDao.contractAddress} at slot ${noteDao.storageSlot}`, {
|
|
644
|
+
contract: noteDao.contractAddress,
|
|
645
|
+
slot: noteDao.storageSlot,
|
|
646
|
+
nullifier: noteDao.siloedNullifier.toString()
|
|
660
647
|
});
|
|
661
|
-
}
|
|
648
|
+
});
|
|
662
649
|
}
|
|
663
650
|
storeCapsule(contractAddress, slot, capsule) {
|
|
664
651
|
return this.capsuleDataProvider.storeCapsule(contractAddress, slot, capsule);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
export * from '../../../
|
|
1
|
+
export * from '../../../pxe.js';
|
|
2
2
|
export * from '../../../config/index.js';
|
|
3
|
+
export * from '../../../error_enriching.js';
|
|
3
4
|
export * from '../../../storage/index.js';
|
|
4
5
|
export * from './utils.js';
|
|
5
6
|
export { PXEOracleInterface } from '../../../contract_function_simulator/pxe_oracle_interface.js';
|
|
7
|
+
export type { PXECreationOptions } from '../../pxe_creation_options.js';
|
|
6
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/entrypoints/client/bundle/index.ts"],"names":[],"mappings":"AAAA,cAAc
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/entrypoints/client/bundle/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,8DAA8D,CAAC;AAClG,YAAY,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export * from '../../../
|
|
1
|
+
export * from '../../../pxe.js';
|
|
2
2
|
export * from '../../../config/index.js';
|
|
3
|
+
export * from '../../../error_enriching.js';
|
|
3
4
|
export * from '../../../storage/index.js';
|
|
4
5
|
export * from './utils.js';
|
|
5
6
|
export { PXEOracleInterface } from '../../../contract_function_simulator/pxe_oracle_interface.js';
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
2
|
-
import type {
|
|
3
|
-
import {
|
|
2
|
+
import type { PXEConfig } from '../../../config/index.js';
|
|
3
|
+
import { PXE } from '../../../pxe.js';
|
|
4
4
|
import type { PXECreationOptions } from '../../pxe_creation_options.js';
|
|
5
5
|
/**
|
|
6
|
-
* Create and start an
|
|
6
|
+
* Create and start an PXE instance with the given AztecNode.
|
|
7
7
|
* If no keyStore or database is provided, it will use KeyStore and MemoryDB as default values.
|
|
8
|
-
* Returns a Promise that resolves to the started
|
|
8
|
+
* Returns a Promise that resolves to the started PXE instance.
|
|
9
9
|
*
|
|
10
10
|
* @param aztecNode - The AztecNode instance to be used by the server.
|
|
11
|
-
* @param config - The PXE
|
|
12
|
-
* @param options - (Optional) Optional information for creating an
|
|
13
|
-
* @returns A Promise that resolves to the started
|
|
11
|
+
* @param config - The PXE Config to use
|
|
12
|
+
* @param options - (Optional) Optional information for creating an PXE.
|
|
13
|
+
* @returns A Promise that resolves to the started PXE instance.
|
|
14
14
|
*/
|
|
15
|
-
export declare function
|
|
15
|
+
export declare function createPXE(aztecNode: AztecNode, config: PXEConfig, options?: PXECreationOptions): Promise<PXE>;
|
|
16
16
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/entrypoints/client/bundle/utils.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAEjE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/entrypoints/client/bundle/utils.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAEjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAExE;;;;;;;;;GASG;AACH,wBAAsB,SAAS,CAC7B,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,SAAS,EACjB,OAAO,GAAE,kBAAoC,gBAgC9C"}
|
|
@@ -4,17 +4,17 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
4
4
|
import { createStore } from '@aztec/kv-store/indexeddb';
|
|
5
5
|
import { BundledProtocolContractsProvider } from '@aztec/protocol-contracts/providers/bundle';
|
|
6
6
|
import { WASMSimulator } from '@aztec/simulator/client';
|
|
7
|
-
import {
|
|
7
|
+
import { PXE } from '../../../pxe.js';
|
|
8
8
|
/**
|
|
9
|
-
* Create and start an
|
|
9
|
+
* Create and start an PXE instance with the given AztecNode.
|
|
10
10
|
* If no keyStore or database is provided, it will use KeyStore and MemoryDB as default values.
|
|
11
|
-
* Returns a Promise that resolves to the started
|
|
11
|
+
* Returns a Promise that resolves to the started PXE instance.
|
|
12
12
|
*
|
|
13
13
|
* @param aztecNode - The AztecNode instance to be used by the server.
|
|
14
|
-
* @param config - The PXE
|
|
15
|
-
* @param options - (Optional) Optional information for creating an
|
|
16
|
-
* @returns A Promise that resolves to the started
|
|
17
|
-
*/ export async function
|
|
14
|
+
* @param config - The PXE Config to use
|
|
15
|
+
* @param options - (Optional) Optional information for creating an PXE.
|
|
16
|
+
* @returns A Promise that resolves to the started PXE instance.
|
|
17
|
+
*/ export async function createPXE(aztecNode, config, options = {
|
|
18
18
|
loggers: {}
|
|
19
19
|
}) {
|
|
20
20
|
const logSuffix = typeof options.useLogSuffix === 'boolean' ? options.useLogSuffix ? randomBytes(3).toString('hex') : undefined : options.useLogSuffix;
|
|
@@ -31,6 +31,6 @@ import { PXEService } from '../../../pxe_service/pxe_service.js';
|
|
|
31
31
|
const prover = options.prover ?? new BBWASMBundlePrivateKernelProver(simulator, 16, proverLogger);
|
|
32
32
|
const protocolContractsProvider = new BundledProtocolContractsProvider();
|
|
33
33
|
const pxeLogger = loggers.pxe ? loggers.pxe : createLogger('pxe:service' + (logSuffix ? `:${logSuffix}` : ''));
|
|
34
|
-
const pxe = await
|
|
34
|
+
const pxe = await PXE.create(aztecNode, store, prover, simulator, protocolContractsProvider, config, pxeLogger);
|
|
35
35
|
return pxe;
|
|
36
36
|
}
|