@aztec/pxe 0.87.7 → 1.0.0-nightly.20250604
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/contract_function_simulator/execution_data_provider.d.ts +20 -16
- package/dest/contract_function_simulator/execution_data_provider.d.ts.map +1 -1
- package/dest/contract_function_simulator/note_validation_request.d.ts +21 -0
- package/dest/contract_function_simulator/note_validation_request.d.ts.map +1 -0
- package/dest/contract_function_simulator/note_validation_request.js +42 -0
- package/dest/contract_function_simulator/oracle/oracle.d.ts +3 -2
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +21 -12
- package/dest/contract_function_simulator/oracle/typed_oracle.d.ts +4 -3
- package/dest/contract_function_simulator/oracle/typed_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/typed_oracle.js +7 -4
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +4 -3
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +8 -5
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +6 -4
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +1 -1
- package/dest/contract_function_simulator/pxe_oracle_interface.js +57 -21
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -1
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.js +30 -30
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +9 -7
- package/dest/pxe_service/pxe_service.d.ts.map +1 -1
- package/dest/pxe_service/pxe_service.js +10 -3
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +4 -2
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +1 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.js +46 -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 +14 -14
- package/package.json +16 -16
- package/src/contract_function_simulator/execution_data_provider.ts +22 -26
- package/src/contract_function_simulator/note_validation_request.ts +52 -0
- package/src/contract_function_simulator/oracle/oracle.ts +24 -25
- package/src/contract_function_simulator/oracle/typed_oracle.ts +14 -14
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +10 -24
- package/src/contract_function_simulator/pxe_oracle_interface.ts +98 -22
- package/src/private_kernel/hints/build_private_kernel_reset_private_inputs.ts +35 -34
- package/src/private_kernel/private_kernel_execution_prover.ts +11 -10
- package/src/pxe_service/pxe_service.ts +10 -3
- package/src/storage/capsule_data_provider/capsule_data_provider.ts +56 -7
- package/src/storage/note_data_provider/note_data_provider.ts +22 -22
|
@@ -4,12 +4,13 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
4
4
|
import { getFunctionArtifact } from '@aztec/stdlib/abi';
|
|
5
5
|
import { computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
|
|
6
6
|
import { computeAddressSecret, computeAppTaggingSecret } from '@aztec/stdlib/keys';
|
|
7
|
-
import { IndexedTaggingSecret,
|
|
7
|
+
import { IndexedTaggingSecret, PendingTaggedLog, PrivateLogWithTxData, PublicLogWithTxData, deriveEcdhSharedSecret } from '@aztec/stdlib/logs';
|
|
8
8
|
import { getNonNullifiedL1ToL2MessageWitness } from '@aztec/stdlib/messaging';
|
|
9
9
|
import { Note } from '@aztec/stdlib/note';
|
|
10
10
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
11
11
|
import { MessageLoadOracleInputs } from '../contract_function_simulator/oracle/message_load_oracle_inputs.js';
|
|
12
12
|
import { NoteDao } from '../storage/note_data_provider/note_dao.js';
|
|
13
|
+
import { NoteValidationRequest } from './note_validation_request.js';
|
|
13
14
|
import { WINDOW_HALF_SIZE, getIndexedTaggingSecretsForTheWindow, getInitialIndexesMap } from './tagging_utils.js';
|
|
14
15
|
/**
|
|
15
16
|
* A data layer that provides and stores information needed for simulating/proving a transaction.
|
|
@@ -284,7 +285,7 @@ import { WINDOW_HALF_SIZE, getIndexedTaggingSecretsForTheWindow, getInitialIndex
|
|
|
284
285
|
return indexedAppTaggingSecret.computeSiloedTag(recipient, contractAddress);
|
|
285
286
|
});
|
|
286
287
|
// We fetch the logs for the tags
|
|
287
|
-
const possibleLogs = await this
|
|
288
|
+
const possibleLogs = await this.#getPrivateLogsByTags(currentTags);
|
|
288
289
|
// We find the index of the last log in the window that is not empty
|
|
289
290
|
const indexOfLastLog = possibleLogs.findLastIndex((possibleLog)=>possibleLog.length !== 0);
|
|
290
291
|
if (indexOfLastLog === -1) {
|
|
@@ -312,8 +313,8 @@ import { WINDOW_HALF_SIZE, getIndexedTaggingSecretsForTheWindow, getInitialIndex
|
|
|
312
313
|
}
|
|
313
314
|
}
|
|
314
315
|
/**
|
|
315
|
-
* Synchronizes the logs tagged with scoped addresses and all the senders in the address book. Stores the found
|
|
316
|
-
* in CapsuleArray ready for a later retrieval in Aztec.nr.
|
|
316
|
+
* Synchronizes the private logs tagged with scoped addresses and all the senders in the address book. Stores the found
|
|
317
|
+
* logs in CapsuleArray ready for a later retrieval in Aztec.nr.
|
|
317
318
|
* @param contractAddress - The address of the contract that the logs are tagged for.
|
|
318
319
|
* @param pendingTaggedLogArrayBaseSlot - The base slot of the pending tagged logs capsule array in which
|
|
319
320
|
* found logs will be stored.
|
|
@@ -359,25 +360,20 @@ import { WINDOW_HALF_SIZE, getIndexedTaggingSecretsForTheWindow, getInitialIndex
|
|
|
359
360
|
// We store the new largest indexes we find in the iteration in the following map to later on construct
|
|
360
361
|
// a new set of secrets and windows to fetch logs for.
|
|
361
362
|
const newLargestIndexMapForIteration = {};
|
|
362
|
-
// Fetch the logs for the tags and iterate over them
|
|
363
|
-
const logsByTags = await this
|
|
363
|
+
// Fetch the private logs for the tags and iterate over them
|
|
364
|
+
const logsByTags = await this.#getPrivateLogsByTags(tagsForTheWholeWindow);
|
|
364
365
|
for(let logIndex = 0; logIndex < logsByTags.length; logIndex++){
|
|
365
366
|
const logsByTag = logsByTags[logIndex];
|
|
366
367
|
if (logsByTag.length > 0) {
|
|
367
|
-
// Discard public logs
|
|
368
|
-
const filteredLogsByTag = logsByTag.filter((l)=>!l.isFromPublic);
|
|
369
|
-
if (filteredLogsByTag.length < logsByTag.length) {
|
|
370
|
-
this.log.warn(`Discarded ${logsByTag.filter((l)=>l.isFromPublic).length} public logs with matching tags`);
|
|
371
|
-
}
|
|
372
368
|
// We filter out the logs that are newer than the historical block number of the tx currently being constructed
|
|
373
|
-
const filteredLogsByBlockNumber =
|
|
369
|
+
const filteredLogsByBlockNumber = logsByTag.filter((l)=>l.blockNumber <= maxBlockNumber);
|
|
374
370
|
// We store the logs in capsules (to later be obtained in Noir)
|
|
375
371
|
await this.#storePendingTaggedLogs(contractAddress, pendingTaggedLogArrayBaseSlot, recipient, filteredLogsByBlockNumber);
|
|
376
372
|
// We retrieve the indexed tagging secret corresponding to the log as I need that to evaluate whether
|
|
377
373
|
// a new largest index have been found.
|
|
378
374
|
const secretCorrespondingToLog = secretsForTheWholeWindow[logIndex];
|
|
379
375
|
const initialIndex = initialIndexesMap[secretCorrespondingToLog.appTaggingSecret.toString()];
|
|
380
|
-
this.log.debug(`Found ${
|
|
376
|
+
this.log.debug(`Found ${logsByTags.length} logs as recipient ${recipient}`, {
|
|
381
377
|
recipient,
|
|
382
378
|
secret: secretCorrespondingToLog.appTaggingSecret,
|
|
383
379
|
contractName,
|
|
@@ -430,6 +426,14 @@ import { WINDOW_HALF_SIZE, getIndexedTaggingSecretsForTheWindow, getInitialIndex
|
|
|
430
426
|
}));
|
|
431
427
|
return this.capsuleDataProvider.appendToCapsuleArray(contractAddress, capsuleArrayBaseSlot, pendingTaggedLogs);
|
|
432
428
|
}
|
|
429
|
+
async validateEnqueuedNotes(contractAddress, noteValidationRequestsArrayBaseSlot) {
|
|
430
|
+
// We read all note validation requests and process them all concurrently. This makes the process much faster as we
|
|
431
|
+
// don't need to wait for the network round-trip.
|
|
432
|
+
const noteValidationRequests = (await this.capsuleDataProvider.readCapsuleArray(contractAddress, noteValidationRequestsArrayBaseSlot)).map(NoteValidationRequest.fromFields);
|
|
433
|
+
await Promise.all(noteValidationRequests.map((request)=>this.deliverNote(request.contractAddress, request.storageSlot, request.nonce, request.content, request.noteHash, request.nullifier, request.txHash, request.recipient)));
|
|
434
|
+
// Requests are cleared once we're done.
|
|
435
|
+
await this.capsuleDataProvider.resetCapsuleArray(contractAddress, noteValidationRequestsArrayBaseSlot, []);
|
|
436
|
+
}
|
|
433
437
|
async deliverNote(contractAddress, storageSlot, nonce, content, noteHash, nullifier, txHash, recipient) {
|
|
434
438
|
// We are going to store the new note in the NoteDataProvider, which will let us later return it via `getNotes`.
|
|
435
439
|
// There's two things we need to check before we do this however:
|
|
@@ -493,17 +497,39 @@ import { WINDOW_HALF_SIZE, getIndexedTaggingSecretsForTheWindow, getInitialIndex
|
|
|
493
497
|
});
|
|
494
498
|
}
|
|
495
499
|
}
|
|
496
|
-
async
|
|
497
|
-
const logs = await this
|
|
500
|
+
async getPublicLogByTag(tag, contractAddress) {
|
|
501
|
+
const logs = await this.#getPublicLogsByTagsFromContract([
|
|
498
502
|
tag
|
|
503
|
+
], contractAddress);
|
|
504
|
+
const logsForTag = logs[0];
|
|
505
|
+
this.log.debug(`Got ${logsForTag.length} public logs for tag ${tag}`);
|
|
506
|
+
if (logsForTag.length == 0) {
|
|
507
|
+
return null;
|
|
508
|
+
} else if (logsForTag.length > 1) {
|
|
509
|
+
// TODO(#11627): handle this case
|
|
510
|
+
throw new Error(`Got ${logsForTag.length} logs for tag ${tag} and contract ${contractAddress.toString()}. getPublicLogByTag currently only supports a single log per tag`);
|
|
511
|
+
}
|
|
512
|
+
const scopedLog = logsForTag[0];
|
|
513
|
+
// getLogsByTag doesn't have all of the information that we need (notably note hashes and the first nullifier), so
|
|
514
|
+
// we need to make a second call to the node for `getTxEffect`.
|
|
515
|
+
// TODO(#9789): bundle this information in the `getLogsByTag` call.
|
|
516
|
+
const txEffect = await this.aztecNode.getTxEffect(scopedLog.txHash);
|
|
517
|
+
if (txEffect == undefined) {
|
|
518
|
+
throw new Error(`Unexpected: failed to retrieve tx effects for tx ${scopedLog.txHash} which is known to exist`);
|
|
519
|
+
}
|
|
520
|
+
return new PublicLogWithTxData(scopedLog.log.getEmittedFieldsWithoutTag(), scopedLog.txHash, txEffect.data.noteHashes, txEffect.data.nullifiers[0]);
|
|
521
|
+
}
|
|
522
|
+
async getPrivateLogByTag(siloedTag) {
|
|
523
|
+
const logs = await this.#getPrivateLogsByTags([
|
|
524
|
+
siloedTag
|
|
499
525
|
]);
|
|
500
526
|
const logsForTag = logs[0];
|
|
501
|
-
this.log.debug(`Got ${logsForTag.length} logs for tag ${
|
|
527
|
+
this.log.debug(`Got ${logsForTag.length} private logs for tag ${siloedTag}`);
|
|
502
528
|
if (logsForTag.length == 0) {
|
|
503
529
|
return null;
|
|
504
530
|
} else if (logsForTag.length > 1) {
|
|
505
531
|
// TODO(#11627): handle this case
|
|
506
|
-
throw new Error(`Got ${logsForTag.length} logs for tag ${
|
|
532
|
+
throw new Error(`Got ${logsForTag.length} logs for tag ${siloedTag}. getPrivateLogByTag currently only supports a single log per tag`);
|
|
507
533
|
}
|
|
508
534
|
const scopedLog = logsForTag[0];
|
|
509
535
|
// getLogsByTag doesn't have all of the information that we need (notably note hashes and the first nullifier), so
|
|
@@ -513,10 +539,7 @@ import { WINDOW_HALF_SIZE, getIndexedTaggingSecretsForTheWindow, getInitialIndex
|
|
|
513
539
|
if (txEffect == undefined) {
|
|
514
540
|
throw new Error(`Unexpected: failed to retrieve tx effects for tx ${scopedLog.txHash} which is known to exist`);
|
|
515
541
|
}
|
|
516
|
-
|
|
517
|
-
scopedLog.log.contractAddress.toField()
|
|
518
|
-
] : []).concat(scopedLog.log.getEmittedFields());
|
|
519
|
-
return new LogWithTxData(logContent, scopedLog.txHash, txEffect.data.noteHashes, txEffect.data.nullifiers[0]);
|
|
542
|
+
return new PrivateLogWithTxData(scopedLog.log.getEmittedFieldsWithoutTag(), scopedLog.txHash, txEffect.data.noteHashes, txEffect.data.nullifiers[0]);
|
|
520
543
|
}
|
|
521
544
|
async removeNullifiedNotes(contractAddress) {
|
|
522
545
|
this.log.verbose('Searching for nullifiers of known notes', {
|
|
@@ -588,6 +611,19 @@ import { WINDOW_HALF_SIZE, getIndexedTaggingSecretsForTheWindow, getInitialIndex
|
|
|
588
611
|
}
|
|
589
612
|
return this.privateEventDataProvider.storePrivateEventLog(contractAddress, recipient, eventSelector, msgContent, txHash, logIndexInTx, txIndexInBlock, blockNumber);
|
|
590
613
|
}
|
|
614
|
+
// TODO(#12656): Make this a public function on the AztecNode interface and remove the original getLogsByTags. This
|
|
615
|
+
// was not done yet as we were unsure about the API and we didn't want to introduce a breaking change.
|
|
616
|
+
async #getPrivateLogsByTags(tags) {
|
|
617
|
+
const allLogs = await this.aztecNode.getLogsByTags(tags);
|
|
618
|
+
return allLogs.map((logs)=>logs.filter((log)=>!log.isFromPublic));
|
|
619
|
+
}
|
|
620
|
+
// TODO(#12656): Make this a public function on the AztecNode interface and remove the original getLogsByTags. This
|
|
621
|
+
// was not done yet as we were unsure about the API and we didn't want to introduce a breaking change.
|
|
622
|
+
async #getPublicLogsByTagsFromContract(tags, contractAddress) {
|
|
623
|
+
const allLogs = await this.aztecNode.getLogsByTags(tags);
|
|
624
|
+
const allPublicLogs = allLogs.map((logs)=>logs.filter((log)=>log.isFromPublic));
|
|
625
|
+
return allPublicLogs.map((logs)=>logs.filter((log)=>log.log.contractAddress.equals(contractAddress)));
|
|
626
|
+
}
|
|
591
627
|
getStats() {
|
|
592
628
|
const nodeRPCCalls = typeof this.aztecNode.getStats === 'function' ? this.aztecNode.getStats() : {};
|
|
593
629
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build_private_kernel_reset_private_inputs.d.ts","sourceRoot":"","sources":["../../../src/private_kernel/hints/build_private_kernel_reset_private_inputs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build_private_kernel_reset_private_inputs.d.ts","sourceRoot":"","sources":["../../../src/private_kernel/hints/build_private_kernel_reset_private_inputs.ts"],"names":[],"mappings":"AAeA,OAAO,EAIL,KAAK,gCAAgC,EAErC,sCAAsC,EAGtC,KAAK,2BAA2B,EAkBjC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,KAAK,0BAA0B,EAAiB,MAAM,kBAAkB,CAAC;AAGlF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AA4CvE,qBAAa,sCAAsC;IAY/C,OAAO,CAAC,oBAAoB;IAC5B,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,2BAA2B;IACnC,OAAO,CAAC,8BAA8B;IAdxC,OAAO,CAAC,cAAc,CAAmC;IAEzD,OAAO,CAAC,aAAa,CAAC,CAA6B;IAEnD,OAAO,CAAC,mBAAmB,CAAoE;IAC/F,OAAO,CAAC,oBAAoB,CAAoE;IAChG,OAAO,CAAC,gBAAgB,CAAC,CAAS;IAClC,OAAO,CAAC,uBAAuB,CAA8D;IAC7F,OAAO,CAAC,mBAAmB,CAA+B;gBAGhD,oBAAoB,EAAE,2BAA2B,CAAC,gCAAgC,CAAC,EACnF,cAAc,EAAE,0BAA0B,EAAE,EAC5C,2BAA2B,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAChD,8BAA8B,EAAE,MAAM;IAahD,UAAU,IAAI,OAAO;IAwBf,KAAK,CAAC,MAAM,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAuElF,OAAO,CAAC,uBAAuB;IA2B/B,OAAO,CAAC,8BAA8B;IAoDtC,OAAO,CAAC,+BAA+B;IAoDvC,OAAO,CAAC,uBAAuB;IAiB/B,OAAO,CAAC,uBAAuB;IA6E/B,OAAO,CAAC,mBAAmB;IAY3B,OAAO,CAAC,mBAAmB;IAgB3B,OAAO,CAAC,oBAAoB;CAmB7B"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { MAX_KEY_VALIDATION_REQUESTS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NOTE_HASH_READ_REQUESTS_PER_TX, MAX_NULLIFIERS_PER_TX, MAX_NULLIFIER_READ_REQUESTS_PER_TX, MAX_PRIVATE_LOGS_PER_TX, NULLIFIER_TREE_HEIGHT
|
|
1
|
+
import { MAX_KEY_VALIDATION_REQUESTS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NOTE_HASH_READ_REQUESTS_PER_TX, MAX_NULLIFIERS_PER_TX, MAX_NULLIFIER_READ_REQUESTS_PER_TX, MAX_PRIVATE_LOGS_PER_TX, NULLIFIER_TREE_HEIGHT } from '@aztec/constants';
|
|
2
2
|
import { makeTuple } from '@aztec/foundation/array';
|
|
3
3
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
4
4
|
import { assertLength } from '@aztec/foundation/serialize';
|
|
5
5
|
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
6
6
|
import { privateKernelResetDimensionsConfig } from '@aztec/noir-protocol-circuits-types/client';
|
|
7
|
-
import { KeyValidationHint, PrivateKernelData, PrivateKernelResetCircuitPrivateInputs, PrivateKernelResetDimensions, PrivateKernelResetHints, ReadRequestResetStates, ReadRequestState, ScopedNoteHash, ScopedNullifier, ScopedReadRequest, TransientDataIndexHint, buildNoteHashReadRequestHintsFromResetStates, buildNullifierReadRequestHintsFromResetStates, buildTransientDataHints, countAccumulatedItems, findPrivateKernelResetDimensions, getNonEmptyItems, getNoteHashReadRequestResetStates, getNullifierReadRequestResetStates, privateKernelResetDimensionNames } from '@aztec/stdlib/kernel';
|
|
7
|
+
import { KeyValidationHint, PaddedSideEffects, PrivateKernelData, PrivateKernelResetCircuitPrivateInputs, PrivateKernelResetDimensions, PrivateKernelResetHints, ReadRequestResetStates, ReadRequestState, ScopedNoteHash, ScopedNullifier, ScopedReadRequest, TransientDataIndexHint, buildNoteHashReadRequestHintsFromResetStates, buildNullifierReadRequestHintsFromResetStates, buildTransientDataHints, countAccumulatedItems, findPrivateKernelResetDimensions, getNonEmptyItems, getNoteHashReadRequestResetStates, getNullifierReadRequestResetStates, privateKernelResetDimensionNames } from '@aztec/stdlib/kernel';
|
|
8
8
|
import { collectNested } from '@aztec/stdlib/tx';
|
|
9
|
+
import { VkData } from '@aztec/stdlib/vks';
|
|
9
10
|
function collectNestedReadRequests(executionStack, extractReadRequests) {
|
|
10
11
|
return collectNested(executionStack, (executionResult)=>{
|
|
11
12
|
const nonEmptyReadRequests = getNonEmptyItems(extractReadRequests(executionResult));
|
|
@@ -25,17 +26,13 @@ function getNullifierMembershipWitnessResolver(oracle) {
|
|
|
25
26
|
};
|
|
26
27
|
};
|
|
27
28
|
}
|
|
28
|
-
async function getMasterSecretKeysAndAppKeyGenerators(keyValidationRequests, oracle) {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
const request = keyValidationRequests[i].request;
|
|
32
|
-
if (request.isEmpty()) {
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
29
|
+
async function getMasterSecretKeysAndAppKeyGenerators(keyValidationRequests, numRequestsToVerify, oracle) {
|
|
30
|
+
const numRequests = countAccumulatedItems(keyValidationRequests);
|
|
31
|
+
const keysHints = await Promise.all(keyValidationRequests.slice(0, Math.min(numRequests, numRequestsToVerify)).map(async ({ request })=>{
|
|
35
32
|
const secretKeys = await oracle.getMasterSecretKey(request.request.pkM);
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
return padArrayEnd(keysHints, KeyValidationHint.
|
|
33
|
+
return new KeyValidationHint(secretKeys);
|
|
34
|
+
}));
|
|
35
|
+
return padArrayEnd(keysHints, KeyValidationHint.empty(), MAX_KEY_VALIDATION_REQUESTS_PER_TX);
|
|
39
36
|
}
|
|
40
37
|
export class PrivateKernelResetPrivateInputsBuilder {
|
|
41
38
|
previousKernelOutput;
|
|
@@ -97,12 +94,15 @@ export class PrivateKernelResetPrivateInputsBuilder {
|
|
|
97
94
|
const allowRemainder = isInner;
|
|
98
95
|
const dimensions = findPrivateKernelResetDimensions(this.requestedDimensions, privateKernelResetDimensionsConfig, isInner, allowRemainder);
|
|
99
96
|
const previousVkMembershipWitness = await oracle.getVkMembershipWitness(this.previousKernelOutput.verificationKey.keyAsFields);
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
this.reduceReadRequestStates(this.
|
|
103
|
-
|
|
97
|
+
const vkData = new VkData(this.previousKernelOutput.verificationKey, Number(previousVkMembershipWitness.leafIndex), previousVkMembershipWitness.siblingPath);
|
|
98
|
+
const previousKernelData = new PrivateKernelData(this.previousKernelOutput.publicInputs, vkData);
|
|
99
|
+
this.reduceReadRequestStates(this.noteHashResetStates, dimensions.NOTE_HASH_PENDING_READ, dimensions.NOTE_HASH_SETTLED_READ);
|
|
100
|
+
this.reduceReadRequestStates(this.nullifierResetStates, dimensions.NULLIFIER_PENDING_READ, dimensions.NULLIFIER_SETTLED_READ);
|
|
101
|
+
// TODO: Enable padding when we have a better idea what are the final amounts we should pad to.
|
|
102
|
+
const paddedSideEffects = PaddedSideEffects.empty();
|
|
103
|
+
return new PrivateKernelResetCircuitPrivateInputs(previousKernelData, paddedSideEffects, new PrivateKernelResetHints(await buildNoteHashReadRequestHintsFromResetStates(oracle, this.previousKernel.validationRequests.noteHashReadRequests, this.previousKernel.end.noteHashes, this.noteHashResetStates, noteHashLeafIndexMap), await buildNullifierReadRequestHintsFromResetStates({
|
|
104
104
|
getNullifierMembershipWitness: getNullifierMembershipWitnessResolver(oracle)
|
|
105
|
-
}, this.previousKernel.validationRequests.nullifierReadRequests, this.nullifierResetStates), await getMasterSecretKeysAndAppKeyGenerators(this.previousKernel.validationRequests.scopedKeyValidationRequestsAndGenerators, oracle), this.transientDataIndexHints, this.validationRequestsSplitCounter), dimensions);
|
|
105
|
+
}, this.previousKernel.validationRequests.nullifierReadRequests, this.nullifierResetStates), await getMasterSecretKeysAndAppKeyGenerators(this.previousKernel.validationRequests.scopedKeyValidationRequestsAndGenerators, dimensions.KEY_VALIDATION, oracle), this.transientDataIndexHints, this.validationRequestsSplitCounter), dimensions);
|
|
106
106
|
}
|
|
107
107
|
reduceReadRequestStates(resetStates, maxPending, maxSettled) {
|
|
108
108
|
let numPending = 0;
|
|
@@ -141,16 +141,16 @@ export class PrivateKernelResetPrivateInputsBuilder {
|
|
|
141
141
|
const numSettledReads = resetStates.states.reduce((accum, state)=>accum + (state === ReadRequestState.SETTLED ? 1 : 0), 0);
|
|
142
142
|
if (!this.nextIteration) {
|
|
143
143
|
this.noteHashResetStates = resetStates;
|
|
144
|
-
this.requestedDimensions.
|
|
145
|
-
this.requestedDimensions.
|
|
144
|
+
this.requestedDimensions.NOTE_HASH_PENDING_READ = numPendingReads;
|
|
145
|
+
this.requestedDimensions.NOTE_HASH_SETTLED_READ = numSettledReads;
|
|
146
146
|
} else {
|
|
147
147
|
// Pick only one dimension to reset if next iteration is not empty.
|
|
148
148
|
if (numPendingReads > numSettledReads) {
|
|
149
|
-
this.requestedDimensions.
|
|
149
|
+
this.requestedDimensions.NOTE_HASH_PENDING_READ = numPendingReads;
|
|
150
150
|
this.noteHashResetStates.states = assertLength(resetStates.states.map((state)=>state === ReadRequestState.PENDING ? state : ReadRequestState.NADA), MAX_NOTE_HASH_READ_REQUESTS_PER_TX);
|
|
151
151
|
this.noteHashResetStates.pendingReadHints = resetStates.pendingReadHints;
|
|
152
152
|
} else {
|
|
153
|
-
this.requestedDimensions.
|
|
153
|
+
this.requestedDimensions.NOTE_HASH_SETTLED_READ = numSettledReads;
|
|
154
154
|
this.noteHashResetStates.states = assertLength(resetStates.states.map((state)=>state === ReadRequestState.SETTLED ? state : ReadRequestState.NADA), MAX_NOTE_HASH_READ_REQUESTS_PER_TX);
|
|
155
155
|
}
|
|
156
156
|
}
|
|
@@ -172,16 +172,16 @@ export class PrivateKernelResetPrivateInputsBuilder {
|
|
|
172
172
|
const numSettledReads = resetStates.states.reduce((accum, state)=>accum + (state === ReadRequestState.SETTLED ? 1 : 0), 0);
|
|
173
173
|
if (!this.nextIteration) {
|
|
174
174
|
this.nullifierResetStates = resetStates;
|
|
175
|
-
this.requestedDimensions.
|
|
176
|
-
this.requestedDimensions.
|
|
175
|
+
this.requestedDimensions.NULLIFIER_PENDING_READ = numPendingReads;
|
|
176
|
+
this.requestedDimensions.NULLIFIER_SETTLED_READ = numSettledReads;
|
|
177
177
|
} else {
|
|
178
178
|
// Pick only one dimension to reset if next iteration is not empty.
|
|
179
179
|
if (numPendingReads > numSettledReads) {
|
|
180
|
-
this.requestedDimensions.
|
|
180
|
+
this.requestedDimensions.NULLIFIER_PENDING_READ = numPendingReads;
|
|
181
181
|
this.nullifierResetStates.states = assertLength(resetStates.states.map((state)=>state === ReadRequestState.PENDING ? state : ReadRequestState.NADA), MAX_NULLIFIER_READ_REQUESTS_PER_TX);
|
|
182
182
|
this.nullifierResetStates.pendingReadHints = resetStates.pendingReadHints;
|
|
183
183
|
} else {
|
|
184
|
-
this.requestedDimensions.
|
|
184
|
+
this.requestedDimensions.NULLIFIER_SETTLED_READ = numSettledReads;
|
|
185
185
|
this.nullifierResetStates.states = assertLength(resetStates.states.map((state)=>state === ReadRequestState.SETTLED ? state : ReadRequestState.NADA), MAX_NULLIFIER_READ_REQUESTS_PER_TX);
|
|
186
186
|
}
|
|
187
187
|
}
|
|
@@ -194,7 +194,7 @@ export class PrivateKernelResetPrivateInputsBuilder {
|
|
|
194
194
|
if (numCurr + numNext <= maxAmountToKeep) {
|
|
195
195
|
return false;
|
|
196
196
|
}
|
|
197
|
-
this.requestedDimensions.
|
|
197
|
+
this.requestedDimensions.KEY_VALIDATION = numCurr;
|
|
198
198
|
return true;
|
|
199
199
|
}
|
|
200
200
|
needsResetTransientData() {
|
|
@@ -231,7 +231,7 @@ export class PrivateKernelResetPrivateInputsBuilder {
|
|
|
231
231
|
}
|
|
232
232
|
this.numTransientData = numTransientData;
|
|
233
233
|
this.transientDataIndexHints = transientDataIndexHints;
|
|
234
|
-
this.requestedDimensions.
|
|
234
|
+
this.requestedDimensions.TRANSIENT_DATA_SQUASHING = numTransientData;
|
|
235
235
|
return numTransientData > 0;
|
|
236
236
|
}
|
|
237
237
|
needsSiloNoteHashes() {
|
|
@@ -240,7 +240,7 @@ export class PrivateKernelResetPrivateInputsBuilder {
|
|
|
240
240
|
}
|
|
241
241
|
const numNoteHashes = this.previousKernel.end.noteHashes.filter((n)=>!n.contractAddress.isZero()).length;
|
|
242
242
|
const numToSilo = Math.max(0, numNoteHashes - this.numTransientData);
|
|
243
|
-
this.requestedDimensions.
|
|
243
|
+
this.requestedDimensions.NOTE_HASH_SILOING = numToSilo;
|
|
244
244
|
return numToSilo > 0;
|
|
245
245
|
}
|
|
246
246
|
needsSiloNullifiers() {
|
|
@@ -253,7 +253,7 @@ export class PrivateKernelResetPrivateInputsBuilder {
|
|
|
253
253
|
// The reset circuit checks that capped_size must be greater than or equal to all non-empty nullifiers.
|
|
254
254
|
// Which includes the first nullifier, even though its contract address is always zero and doesn't need siloing.
|
|
255
255
|
const cappedSize = numToSilo ? numToSilo + 1 : 0;
|
|
256
|
-
this.requestedDimensions.
|
|
256
|
+
this.requestedDimensions.NULLIFIER_SILOING = cappedSize;
|
|
257
257
|
return numToSilo > 0;
|
|
258
258
|
}
|
|
259
259
|
needsSiloPrivateLogs() {
|
|
@@ -266,7 +266,7 @@ export class PrivateKernelResetPrivateInputsBuilder {
|
|
|
266
266
|
const squashedNoteHashCounters = this.transientDataIndexHints.filter((h)=>h.noteHashIndex < noteHashes.length).map((h)=>noteHashes[h.noteHashIndex].counter);
|
|
267
267
|
const numSquashedLogs = privateLogs.filter((l)=>squashedNoteHashCounters.includes(l.inner.noteHashCounter)).length;
|
|
268
268
|
const numToSilo = numLogs - numSquashedLogs;
|
|
269
|
-
this.requestedDimensions.
|
|
269
|
+
this.requestedDimensions.PRIVATE_LOG_SILOING = numToSilo;
|
|
270
270
|
return numToSilo > 0;
|
|
271
271
|
}
|
|
272
272
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"private_kernel_execution_prover.d.ts","sourceRoot":"","sources":["../../src/private_kernel/private_kernel_execution_prover.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"private_kernel_execution_prover.d.ts","sourceRoot":"","sources":["../../src/private_kernel/private_kernel_execution_prover.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAML,KAAK,iCAAiC,EAKtC,KAAK,oCAAoC,EAE1C,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAEL,KAAK,sBAAsB,EAC3B,SAAS,EAIV,MAAM,kBAAkB,CAAC;AAI1B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAStE,MAAM,WAAW,kCAAkC;IACjD,QAAQ,EAAE,OAAO,CAAC;IAClB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,WAAW,EAAE,OAAO,GAAG,iBAAiB,GAAG,MAAM,GAAG,MAAM,CAAC;CAC5D;AAED;;;;;GAKG;AACH,qBAAa,4BAA4B;IAIrC,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,UAAU;IALpB,OAAO,CAAC,GAAG,CAAuD;gBAGxD,MAAM,EAAE,mBAAmB,EAC3B,YAAY,EAAE,mBAAmB,EACjC,UAAU,UAAQ;IAG5B;;;;;;;;;;OAUG;IACG,gBAAgB,CACpB,SAAS,EAAE,SAAS,EACpB,eAAe,EAAE,sBAAsB,EACvC,EAAE,QAAQ,EAAE,kBAAkB,EAAE,WAAW,EAAE,GAAE,kCAI9C,GACA,OAAO,CAAC,iCAAiC,CAAC,oCAAoC,CAAC,CAAC;YAwPrE,qBAAqB;CA2CpC"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { VK_TREE_HEIGHT } from '@aztec/constants';
|
|
2
1
|
import { vkAsFieldsMegaHonk } from '@aztec/foundation/crypto';
|
|
3
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
4
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
5
|
-
import { assertLength } from '@aztec/foundation/serialize';
|
|
6
4
|
import { pushTestData } from '@aztec/foundation/testing';
|
|
7
5
|
import { Timer } from '@aztec/foundation/timer';
|
|
8
6
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
@@ -10,10 +8,10 @@ import { getProtocolContractLeafAndMembershipWitness, protocolContractTreeRoot }
|
|
|
10
8
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
11
9
|
import { computeContractAddressFromInstance } from '@aztec/stdlib/contract';
|
|
12
10
|
import { hashVK } from '@aztec/stdlib/hash';
|
|
13
|
-
import { PrivateCallData, PrivateKernelCircuitPublicInputs, PrivateKernelData, PrivateKernelInitCircuitPrivateInputs, PrivateKernelInnerCircuitPrivateInputs, PrivateKernelTailCircuitPrivateInputs, PrivateVerificationKeyHints } from '@aztec/stdlib/kernel';
|
|
11
|
+
import { PaddedSideEffectAmounts, PrivateCallData, PrivateKernelCircuitPublicInputs, PrivateKernelData, PrivateKernelInitCircuitPrivateInputs, PrivateKernelInnerCircuitPrivateInputs, PrivateKernelTailCircuitPrivateInputs, PrivateVerificationKeyHints } from '@aztec/stdlib/kernel';
|
|
14
12
|
import { ClientIvcProof } from '@aztec/stdlib/proofs';
|
|
15
13
|
import { collectNoteHashLeafIndexMap, collectNoteHashNullifierCounterMap, getFinalMinRevertibleSideEffectCounter } from '@aztec/stdlib/tx';
|
|
16
|
-
import { VerificationKeyAsFields, VerificationKeyData } from '@aztec/stdlib/vks';
|
|
14
|
+
import { VerificationKeyAsFields, VerificationKeyData, VkData } from '@aztec/stdlib/vks';
|
|
17
15
|
import { PrivateKernelResetPrivateInputsBuilder } from './hints/build_private_kernel_reset_private_inputs.js';
|
|
18
16
|
const NULL_SIMULATE_OUTPUT = {
|
|
19
17
|
publicInputs: PrivateKernelCircuitPublicInputs.empty(),
|
|
@@ -118,7 +116,8 @@ const NULL_SIMULATE_OUTPUT = {
|
|
|
118
116
|
} else {
|
|
119
117
|
const witgenTimer = new Timer();
|
|
120
118
|
const previousVkMembershipWitness = await this.oracle.getVkMembershipWitness(output.verificationKey.keyAsFields);
|
|
121
|
-
const
|
|
119
|
+
const vkData = new VkData(output.verificationKey, Number(previousVkMembershipWitness.leafIndex), previousVkMembershipWitness.siblingPath);
|
|
120
|
+
const previousKernelData = new PrivateKernelData(output.publicInputs, vkData);
|
|
122
121
|
const proofInput = new PrivateKernelInnerCircuitPrivateInputs(previousKernelData, privateCallData);
|
|
123
122
|
pushTestData('private-kernel-inputs-inner', proofInput);
|
|
124
123
|
output = generateWitnesses ? await this.proofCreator.generateInnerOutput(proofInput) : await this.proofCreator.simulateInner(proofInput);
|
|
@@ -159,9 +158,12 @@ const NULL_SIMULATE_OUTPUT = {
|
|
|
159
158
|
}
|
|
160
159
|
// Private tail.
|
|
161
160
|
const previousVkMembershipWitness = await this.oracle.getVkMembershipWitness(output.verificationKey.keyAsFields);
|
|
162
|
-
const
|
|
161
|
+
const vkData = new VkData(output.verificationKey, Number(previousVkMembershipWitness.leafIndex), previousVkMembershipWitness.siblingPath);
|
|
162
|
+
const previousKernelData = new PrivateKernelData(output.publicInputs, vkData);
|
|
163
163
|
this.log.debug(`Calling private kernel tail with hwm ${previousKernelData.publicInputs.minRevertibleSideEffectCounter}`);
|
|
164
|
-
|
|
164
|
+
// TODO: Enable padding when we have a better what are the final amounts we should pad to.
|
|
165
|
+
const paddedSideEffectAmounts = PaddedSideEffectAmounts.empty();
|
|
166
|
+
const privateInputs = new PrivateKernelTailCircuitPrivateInputs(previousKernelData, paddedSideEffectAmounts);
|
|
165
167
|
pushTestData('private-kernel-inputs-ordering', privateInputs);
|
|
166
168
|
const witgenTimer = new Timer();
|
|
167
169
|
const tailOutput = generateWitnesses ? await this.proofCreator.generateTailOutput(privateInputs) : await this.proofCreator.simulateTail(privateInputs);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pxe_service.d.ts","sourceRoot":"","sources":["../../src/pxe_service/pxe_service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAGlE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EAEL,KAAK,yBAAyB,EAE/B,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EACL,KAAK,gBAAgB,EAQtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EACL,eAAe,EACf,KAAK,mBAAmB,EACxB,KAAK,2BAA2B,EAChC,KAAK,QAAQ,EACb,KAAK,cAAc,EAGpB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,KAAK,EACV,SAAS,EACT,uBAAuB,EACvB,4BAA4B,EAC5B,qBAAqB,EACrB,GAAG,EACH,OAAO,EACP,mBAAmB,EACpB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,KAAK,WAAW,EAAE,UAAU,EAAE,MAA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EAAE,GACtB,OAAO,CAAC,uBAAuB,CAAC;IA8CtB,WAAW,IAAI,OAAO,CAAC,QAAQ,CAAC;IA4BtC,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;IAYxB,gBAAgB,CAAC,CAAC,EAC7B,eAAe,EAAE,YAAY,EAC7B,gBAAgB,EAAE,uBAAuB,EACzC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,YAAY,EAAE,GACzB,OAAO,CAAC,CAAC,EAAE,CAAC;IAuBT,eAAe,CAAC,CAAC,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC;IA6BxG,iBAAiB;CAGxB"}
|
|
@@ -9,7 +9,7 @@ import { EventSelector, FunctionSelector, FunctionType, decodeFromAbi, decodeFun
|
|
|
9
9
|
import { computeContractAddressFromInstance, getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
10
10
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
11
11
|
import { siloNullifier } from '@aztec/stdlib/hash';
|
|
12
|
-
import { getNonNullifiedL1ToL2MessageWitness } from '@aztec/stdlib/messaging';
|
|
12
|
+
import { computeL2ToL1MembershipWitness, getNonNullifiedL1ToL2MessageWitness } from '@aztec/stdlib/messaging';
|
|
13
13
|
import { UniqueNote } from '@aztec/stdlib/note';
|
|
14
14
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
15
15
|
import { PrivateSimulationResult, TxProfileResult, TxProvingResult, TxSimulationResult } from '@aztec/stdlib/tx';
|
|
@@ -102,8 +102,15 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
102
102
|
isL1ToL2MessageSynced(l1ToL2Message) {
|
|
103
103
|
return this.node.isL1ToL2MessageSynced(l1ToL2Message);
|
|
104
104
|
}
|
|
105
|
-
getL2ToL1MembershipWitness(blockNumber, l2Tol1Message) {
|
|
106
|
-
|
|
105
|
+
async getL2ToL1MembershipWitness(blockNumber, l2Tol1Message) {
|
|
106
|
+
const result = await computeL2ToL1MembershipWitness(this.node, blockNumber, l2Tol1Message);
|
|
107
|
+
if (!result) {
|
|
108
|
+
throw new Error(`L2 to L1 message not found in block ${blockNumber}`);
|
|
109
|
+
}
|
|
110
|
+
return [
|
|
111
|
+
result.l2MessageIndex,
|
|
112
|
+
result.siblingPath
|
|
113
|
+
];
|
|
107
114
|
}
|
|
108
115
|
getTxReceipt(txHash) {
|
|
109
116
|
return this.node.getTxReceipt(txHash);
|
|
@@ -17,9 +17,11 @@ export declare class CapsuleDataProvider implements DataProvider {
|
|
|
17
17
|
* All operations are performed in a single transaction.
|
|
18
18
|
* @param contractAddress - The contract address that owns the capsule array
|
|
19
19
|
* @param baseSlot - The slot where the array length is stored
|
|
20
|
-
* @param
|
|
20
|
+
* @param content - Array of capsule data to append
|
|
21
21
|
*/
|
|
22
|
-
appendToCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr,
|
|
22
|
+
appendToCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][]): Promise<void>;
|
|
23
|
+
readCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr): Promise<Fr[][]>;
|
|
24
|
+
resetCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][]): Promise<void>;
|
|
23
25
|
getSize(): Promise<number>;
|
|
24
26
|
}
|
|
25
27
|
//# sourceMappingURL=capsule_data_provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capsule_data_provider.d.ts","sourceRoot":"","sources":["../../../src/storage/capsule_data_provider/capsule_data_provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACx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,iBAAiB;IAQ9B,YAAY,CAAC,eAAe,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAInF,WAAW,CAAC,eAAe,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC;IAa1E,aAAa,CAAC,eAAe,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAI3E,WAAW,CAAC,eAAe,EAAE,YAAY,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA0BvG;;;;;;;OAOG;IACH,oBAAoB,CAAC,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBjG,gBAAgB,CAAC,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,GAAG,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC;IAwB9E,iBAAiB,CAAC,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE;IAqBjE,OAAO;CAMrB"}
|
|
@@ -56,24 +56,60 @@ export class CapsuleDataProvider {
|
|
|
56
56
|
* All operations are performed in a single transaction.
|
|
57
57
|
* @param contractAddress - The contract address that owns the capsule array
|
|
58
58
|
* @param baseSlot - The slot where the array length is stored
|
|
59
|
-
* @param
|
|
60
|
-
*/ appendToCapsuleArray(contractAddress, baseSlot,
|
|
59
|
+
* @param content - Array of capsule data to append
|
|
60
|
+
*/ appendToCapsuleArray(contractAddress, baseSlot, content) {
|
|
61
61
|
return this.#store.transactionAsync(async ()=>{
|
|
62
62
|
// Load current length, defaulting to 0 if not found
|
|
63
63
|
const lengthData = await this.loadCapsule(contractAddress, baseSlot);
|
|
64
|
-
const currentLength = lengthData ? lengthData[0].
|
|
64
|
+
const currentLength = lengthData ? lengthData[0].toNumber() : 0;
|
|
65
65
|
// Store each capsule at consecutive slots after baseSlot + 1 + currentLength
|
|
66
|
-
for(let i = 0; i <
|
|
67
|
-
const nextSlot = baseSlot
|
|
68
|
-
await this.storeCapsule(contractAddress, nextSlot,
|
|
66
|
+
for(let i = 0; i < content.length; i++){
|
|
67
|
+
const nextSlot = arraySlot(baseSlot, currentLength + i);
|
|
68
|
+
await this.storeCapsule(contractAddress, nextSlot, content[i]);
|
|
69
69
|
}
|
|
70
70
|
// Update length to include all new capsules
|
|
71
|
-
const newLength = currentLength +
|
|
71
|
+
const newLength = currentLength + content.length;
|
|
72
72
|
await this.storeCapsule(contractAddress, baseSlot, [
|
|
73
73
|
new Fr(newLength)
|
|
74
74
|
]);
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
|
+
readCapsuleArray(contractAddress, baseSlot) {
|
|
78
|
+
return this.#store.transactionAsync(async ()=>{
|
|
79
|
+
// Load length, defaulting to 0 if not found
|
|
80
|
+
const maybeLength = await this.loadCapsule(contractAddress, baseSlot);
|
|
81
|
+
const length = maybeLength ? maybeLength[0].toBigInt() : 0n;
|
|
82
|
+
const values = [];
|
|
83
|
+
// Read each capsule at consecutive slots after baseSlot
|
|
84
|
+
for(let i = 0; i < length; i++){
|
|
85
|
+
const currentValue = await this.loadCapsule(contractAddress, arraySlot(baseSlot, i));
|
|
86
|
+
if (currentValue == undefined) {
|
|
87
|
+
throw new Error(`Expected non-empty value at capsule array in base slot ${baseSlot} at index ${i} for contract ${contractAddress}`);
|
|
88
|
+
}
|
|
89
|
+
values.push(currentValue);
|
|
90
|
+
}
|
|
91
|
+
return values;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
resetCapsuleArray(contractAddress, baseSlot, content) {
|
|
95
|
+
return this.#store.transactionAsync(async ()=>{
|
|
96
|
+
// Load current length, defaulting to 0 if not found
|
|
97
|
+
const maybeLength = await this.loadCapsule(contractAddress, baseSlot);
|
|
98
|
+
const originalLength = maybeLength ? maybeLength[0].toNumber() : 0;
|
|
99
|
+
// Set the new length
|
|
100
|
+
await this.storeCapsule(contractAddress, baseSlot, [
|
|
101
|
+
new Fr(content.length)
|
|
102
|
+
]);
|
|
103
|
+
// Store the new content, possibly overwriting existing values
|
|
104
|
+
for(let i = 0; i < content.length; i++){
|
|
105
|
+
await this.storeCapsule(contractAddress, arraySlot(baseSlot, i), content[i]);
|
|
106
|
+
}
|
|
107
|
+
// Clear any stragglers
|
|
108
|
+
for(let i = content.length; i < originalLength; i++){
|
|
109
|
+
await this.deleteCapsule(contractAddress, arraySlot(baseSlot, i));
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
77
113
|
async getSize() {
|
|
78
114
|
return (await toArray(this.#capsules.valuesAsync())).reduce((sum, value)=>sum + value.length * Fr.SIZE_IN_BYTES, 0);
|
|
79
115
|
}
|
|
@@ -81,3 +117,6 @@ export class CapsuleDataProvider {
|
|
|
81
117
|
function dbSlotToKey(contractAddress, slot) {
|
|
82
118
|
return `${contractAddress.toString()}:${slot.toString()}`;
|
|
83
119
|
}
|
|
120
|
+
function arraySlot(baseSlot, index) {
|
|
121
|
+
return baseSlot.add(new Fr(1)).add(new Fr(index));
|
|
122
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"note_data_provider.d.ts","sourceRoot":"","sources":["../../../src/storage/note_data_provider/note_data_provider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,KAAK,EAAE,iBAAiB,EAAqC,MAAM,iBAAiB,CAAC;AAC5F,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAc,KAAK,WAAW,EAA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E,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkD3F,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAkGvD,oBAAoB,CAAC,UAAU,EAAE,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IA2DtF,OAAO;CAGd"}
|
|
@@ -62,11 +62,11 @@ export class NoteDataProvider {
|
|
|
62
62
|
this.#notesByRecipientAndScope.set(scopeString, this.#store.openMultiMap(`${scopeString}:notes_by_recipient`));
|
|
63
63
|
return true;
|
|
64
64
|
}
|
|
65
|
-
|
|
66
|
-
if (!await this.#scopes.hasAsync(scope.toString())) {
|
|
67
|
-
await this.addScope(scope);
|
|
68
|
-
}
|
|
65
|
+
addNotes(notes, scope = AztecAddress.ZERO) {
|
|
69
66
|
return this.#store.transactionAsync(async ()=>{
|
|
67
|
+
if (!await this.#scopes.hasAsync(scope.toString())) {
|
|
68
|
+
await this.addScope(scope);
|
|
69
|
+
}
|
|
70
70
|
for (const dao of notes){
|
|
71
71
|
// store notes by their index in the notes hash tree
|
|
72
72
|
// this provides the uniqueness we need to store individual notes
|
|
@@ -105,17 +105,17 @@ export class NoteDataProvider {
|
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
107
|
async unnullifyNotesAfter(blockNumber, synchedBlockNumber) {
|
|
108
|
-
const nullifiersToUndo = [];
|
|
109
|
-
const currentBlockNumber = blockNumber + 1;
|
|
110
|
-
const maxBlockNumber = synchedBlockNumber ?? currentBlockNumber;
|
|
111
|
-
for(let i = currentBlockNumber; i <= maxBlockNumber; i++){
|
|
112
|
-
nullifiersToUndo.push(...await toArray(this.#nullifiersByBlockNumber.getValuesAsync(i)));
|
|
113
|
-
}
|
|
114
|
-
const notesIndexesToReinsert = await Promise.all(nullifiersToUndo.map((nullifier)=>this.#nullifiedNotesByNullifier.getAsync(nullifier)));
|
|
115
|
-
const notNullNoteIndexes = notesIndexesToReinsert.filter((noteIndex)=>noteIndex != undefined);
|
|
116
|
-
const nullifiedNoteBuffers = await Promise.all(notNullNoteIndexes.map((noteIndex)=>this.#nullifiedNotes.getAsync(noteIndex)));
|
|
117
|
-
const noteDaos = nullifiedNoteBuffers.filter((buffer)=>buffer != undefined).map((buffer)=>NoteDao.fromBuffer(buffer));
|
|
118
108
|
await this.#store.transactionAsync(async ()=>{
|
|
109
|
+
const nullifiersToUndo = [];
|
|
110
|
+
const currentBlockNumber = blockNumber + 1;
|
|
111
|
+
const maxBlockNumber = synchedBlockNumber ?? currentBlockNumber;
|
|
112
|
+
for(let i = currentBlockNumber; i <= maxBlockNumber; i++){
|
|
113
|
+
nullifiersToUndo.push(...await toArray(this.#nullifiersByBlockNumber.getValuesAsync(i)));
|
|
114
|
+
}
|
|
115
|
+
const notesIndexesToReinsert = await Promise.all(nullifiersToUndo.map((nullifier)=>this.#nullifiedNotesByNullifier.getAsync(nullifier)));
|
|
116
|
+
const notNullNoteIndexes = notesIndexesToReinsert.filter((noteIndex)=>noteIndex != undefined);
|
|
117
|
+
const nullifiedNoteBuffers = await Promise.all(notNullNoteIndexes.map((noteIndex)=>this.#nullifiedNotes.getAsync(noteIndex)));
|
|
118
|
+
const noteDaos = nullifiedNoteBuffers.filter((buffer)=>buffer != undefined).map((buffer)=>NoteDao.fromBuffer(buffer));
|
|
119
119
|
for (const dao of noteDaos){
|
|
120
120
|
const noteIndex = toBufferBE(dao.index, 32).toString('hex');
|
|
121
121
|
await this.#notes.set(noteIndex, dao.toBuffer());
|