@aztec/pxe 0.76.4 → 0.77.0-testnet-ignition.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/bin/index.js +4 -6
- package/dest/config/index.d.ts +2 -2
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +20 -23
- package/dest/config/package_info.js +4 -2
- package/dest/contract_data_oracle/index.d.ts +10 -10
- package/dest/contract_data_oracle/index.d.ts.map +1 -1
- package/dest/contract_data_oracle/index.js +74 -89
- package/dest/contract_data_oracle/private_functions_tree.d.ts +5 -4
- package/dest/contract_data_oracle/private_functions_tree.d.ts.map +1 -1
- package/dest/contract_data_oracle/private_functions_tree.js +47 -51
- package/dest/database/contracts/contract_artifact_db.d.ts +2 -2
- package/dest/database/contracts/contract_artifact_db.d.ts.map +1 -1
- package/dest/database/contracts/contract_artifact_db.js +3 -2
- package/dest/database/contracts/contract_instance_db.d.ts +2 -1
- package/dest/database/contracts/contract_instance_db.d.ts.map +1 -1
- package/dest/database/contracts/contract_instance_db.js +3 -2
- package/dest/database/index.js +0 -1
- package/dest/database/kv_pxe_database.d.ts +9 -5
- package/dest/database/kv_pxe_database.d.ts.map +1 -1
- package/dest/database/kv_pxe_database.js +244 -257
- package/dest/database/note_dao.d.ts +13 -10
- package/dest/database/note_dao.d.ts.map +1 -1
- package/dest/database/note_dao.js +35 -48
- package/dest/database/outgoing_note_dao.d.ts +6 -3
- package/dest/database/outgoing_note_dao.d.ts.map +1 -1
- package/dest/database/outgoing_note_dao.js +25 -37
- package/dest/database/pxe_database.d.ts +12 -8
- package/dest/database/pxe_database.d.ts.map +1 -1
- package/dest/database/pxe_database.js +4 -2
- package/dest/database/pxe_database_test_suite.d.ts +1 -1
- package/dest/database/pxe_database_test_suite.d.ts.map +1 -1
- package/dest/database/pxe_database_test_suite.js +286 -147
- package/dest/index.d.ts +1 -6
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -7
- package/dest/kernel_oracle/index.d.ts +20 -10
- package/dest/kernel_oracle/index.d.ts.map +1 -1
- package/dest/kernel_oracle/index.js +32 -9
- package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts +3 -3
- package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -1
- package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.js +71 -67
- package/dest/kernel_prover/hints/index.js +0 -1
- package/dest/kernel_prover/index.js +0 -1
- package/dest/kernel_prover/kernel_prover.d.ts +6 -6
- package/dest/kernel_prover/kernel_prover.d.ts.map +1 -1
- package/dest/kernel_prover/kernel_prover.js +98 -81
- package/dest/kernel_prover/proving_data_oracle.d.ts +15 -7
- package/dest/kernel_prover/proving_data_oracle.d.ts.map +1 -1
- package/dest/kernel_prover/proving_data_oracle.js +4 -2
- package/dest/note_decryption_utils/add_public_values_to_payload.d.ts +3 -2
- package/dest/note_decryption_utils/add_public_values_to_payload.d.ts.map +1 -1
- package/dest/note_decryption_utils/add_public_values_to_payload.js +11 -12
- package/dest/pxe_http/index.js +0 -1
- package/dest/pxe_http/pxe_http_server.d.ts +1 -1
- package/dest/pxe_http/pxe_http_server.d.ts.map +1 -1
- package/dest/pxe_http/pxe_http_server.js +9 -7
- package/dest/pxe_service/error_enriching.d.ts +3 -3
- package/dest/pxe_service/error_enriching.d.ts.map +1 -1
- package/dest/pxe_service/error_enriching.js +14 -17
- package/dest/pxe_service/index.d.ts +0 -1
- package/dest/pxe_service/index.d.ts.map +1 -1
- package/dest/pxe_service/index.js +0 -2
- package/dest/pxe_service/pxe_service.d.ts +21 -12
- package/dest/pxe_service/pxe_service.d.ts.map +1 -1
- package/dest/pxe_service/pxe_service.js +279 -333
- package/dest/pxe_service/test/pxe_test_suite.d.ts +1 -1
- package/dest/pxe_service/test/pxe_test_suite.d.ts.map +1 -1
- package/dest/pxe_service/test/pxe_test_suite.js +44 -28
- package/dest/simulator/index.d.ts +3 -3
- package/dest/simulator/index.d.ts.map +1 -1
- package/dest/simulator/index.js +1 -3
- package/dest/simulator_oracle/index.d.ts +18 -6
- package/dest/simulator_oracle/index.d.ts.map +1 -1
- package/dest/simulator_oracle/index.js +307 -235
- package/dest/simulator_oracle/tagging_utils.d.ts +2 -1
- package/dest/simulator_oracle/tagging_utils.d.ts.map +1 -1
- package/dest/simulator_oracle/tagging_utils.js +5 -7
- package/dest/synchronizer/index.js +0 -1
- package/dest/synchronizer/synchronizer.d.ts +7 -4
- package/dest/synchronizer/synchronizer.d.ts.map +1 -1
- package/dest/synchronizer/synchronizer.js +64 -43
- package/dest/utils/create_pxe_service.d.ts +2 -2
- package/dest/utils/create_pxe_service.d.ts.map +1 -1
- package/dest/utils/create_pxe_service.js +13 -11
- package/package.json +18 -19
- package/src/bin/index.ts +1 -1
- package/src/config/index.ts +3 -3
- package/src/contract_data_oracle/index.ts +20 -20
- package/src/contract_data_oracle/private_functions_tree.ts +6 -7
- package/src/database/contracts/contract_artifact_db.ts +2 -2
- package/src/database/contracts/contract_instance_db.ts +2 -1
- package/src/database/kv_pxe_database.ts +33 -32
- package/src/database/note_dao.ts +11 -8
- package/src/database/outgoing_note_dao.ts +7 -4
- package/src/database/pxe_database.ts +13 -15
- package/src/database/pxe_database_test_suite.ts +8 -11
- package/src/index.ts +1 -7
- package/src/kernel_oracle/index.ts +55 -22
- package/src/kernel_prover/hints/build_private_kernel_reset_private_inputs.ts +14 -11
- package/src/kernel_prover/kernel_prover.ts +89 -69
- package/src/kernel_prover/proving_data_oracle.ts +20 -20
- package/src/note_decryption_utils/add_public_values_to_payload.ts +5 -4
- package/src/pxe_http/pxe_http_server.ts +1 -1
- package/src/pxe_service/error_enriching.ts +6 -6
- package/src/pxe_service/index.ts +0 -1
- package/src/pxe_service/pxe_service.ts +121 -224
- package/src/pxe_service/test/pxe_test_suite.ts +6 -3
- package/src/simulator/index.ts +3 -3
- package/src/simulator_oracle/index.ts +77 -47
- package/src/simulator_oracle/tagging_utils.ts +2 -1
- package/src/synchronizer/synchronizer.ts +31 -12
- package/src/utils/create_pxe_service.ts +16 -4
|
@@ -1,30 +1,31 @@
|
|
|
1
|
-
import { type InBlock, MerkleTreeId, NoteStatus, type NotesFilter } from '@aztec/circuit-types';
|
|
2
|
-
import {
|
|
3
|
-
AztecAddress,
|
|
4
|
-
BlockHeader,
|
|
5
|
-
CompleteAddress,
|
|
6
|
-
type ContractInstanceWithAddress,
|
|
7
|
-
type IndexedTaggingSecret,
|
|
8
|
-
type PublicKey,
|
|
9
|
-
SerializableContractInstance,
|
|
10
|
-
} from '@aztec/circuits.js';
|
|
11
|
-
import { type ContractArtifact, FunctionSelector, FunctionType } from '@aztec/foundation/abi';
|
|
12
1
|
import { toBufferBE } from '@aztec/foundation/bigint-buffer';
|
|
13
2
|
import { Fr, type Point } from '@aztec/foundation/fields';
|
|
14
3
|
import { toArray } from '@aztec/foundation/iterable';
|
|
15
4
|
import { type LogFn, createDebugOnlyLogger } from '@aztec/foundation/log';
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
type AztecAsyncSingleton,
|
|
5
|
+
import type {
|
|
6
|
+
AztecAsyncArray,
|
|
7
|
+
AztecAsyncKVStore,
|
|
8
|
+
AztecAsyncMap,
|
|
9
|
+
AztecAsyncMultiMap,
|
|
10
|
+
AztecAsyncSingleton,
|
|
23
11
|
} from '@aztec/kv-store';
|
|
24
|
-
import {
|
|
12
|
+
import { type ContractArtifact, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
13
|
+
import { contractArtifactFromBuffer, contractArtifactToBuffer } from '@aztec/stdlib/abi';
|
|
14
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
15
|
+
import type { InBlock } from '@aztec/stdlib/block';
|
|
16
|
+
import {
|
|
17
|
+
CompleteAddress,
|
|
18
|
+
type ContractInstanceWithAddress,
|
|
19
|
+
SerializableContractInstance,
|
|
20
|
+
} from '@aztec/stdlib/contract';
|
|
21
|
+
import type { PublicKey } from '@aztec/stdlib/keys';
|
|
22
|
+
import type { IndexedTaggingSecret } from '@aztec/stdlib/logs';
|
|
23
|
+
import { NoteStatus, type NotesFilter } from '@aztec/stdlib/note';
|
|
24
|
+
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
25
|
+
import { BlockHeader } from '@aztec/stdlib/tx';
|
|
25
26
|
|
|
26
27
|
import { NoteDao } from './note_dao.js';
|
|
27
|
-
import {
|
|
28
|
+
import type { PxeDatabase } from './pxe_database.js';
|
|
28
29
|
|
|
29
30
|
/**
|
|
30
31
|
* A PXE database backed by LMDB.
|
|
@@ -33,7 +34,7 @@ export class KVPxeDatabase implements PxeDatabase {
|
|
|
33
34
|
#synchronizedBlock: AztecAsyncSingleton<Buffer>;
|
|
34
35
|
#completeAddresses: AztecAsyncArray<Buffer>;
|
|
35
36
|
#completeAddressIndex: AztecAsyncMap<string, number>;
|
|
36
|
-
#addressBook:
|
|
37
|
+
#addressBook: AztecAsyncMap<string, true>;
|
|
37
38
|
#authWitnesses: AztecAsyncMap<string, Buffer[]>;
|
|
38
39
|
#notes: AztecAsyncMap<string, Buffer>;
|
|
39
40
|
#nullifiedNotes: AztecAsyncMap<string, Buffer>;
|
|
@@ -50,7 +51,7 @@ export class KVPxeDatabase implements PxeDatabase {
|
|
|
50
51
|
#contractInstances: AztecAsyncMap<string, Buffer>;
|
|
51
52
|
#db: AztecAsyncKVStore;
|
|
52
53
|
|
|
53
|
-
#scopes:
|
|
54
|
+
#scopes: AztecAsyncMap<string, true>;
|
|
54
55
|
#notesToScope: AztecAsyncMultiMap<string, string>;
|
|
55
56
|
#notesByContractAndScope: Map<string, AztecAsyncMultiMap<string, string>>;
|
|
56
57
|
#notesByStorageSlotAndScope: Map<string, AztecAsyncMultiMap<string, string>>;
|
|
@@ -74,7 +75,7 @@ export class KVPxeDatabase implements PxeDatabase {
|
|
|
74
75
|
this.#completeAddresses = db.openArray('complete_addresses');
|
|
75
76
|
this.#completeAddressIndex = db.openMap('complete_address_index');
|
|
76
77
|
|
|
77
|
-
this.#addressBook = db.
|
|
78
|
+
this.#addressBook = db.openMap('address_book');
|
|
78
79
|
|
|
79
80
|
this.#authWitnesses = db.openMap('auth_witnesses');
|
|
80
81
|
|
|
@@ -95,7 +96,7 @@ export class KVPxeDatabase implements PxeDatabase {
|
|
|
95
96
|
this.#nullifiedNotesByAddressPoint = db.openMultiMap('nullified_notes_by_address_point');
|
|
96
97
|
this.#nullifiedNotesByNullifier = db.openMap('nullified_notes_by_nullifier');
|
|
97
98
|
|
|
98
|
-
this.#scopes = db.
|
|
99
|
+
this.#scopes = db.openMap('scopes');
|
|
99
100
|
this.#notesToScope = db.openMultiMap('notes_to_scope');
|
|
100
101
|
this.#notesByContractAndScope = new Map<string, AztecAsyncMultiMap<string, string>>();
|
|
101
102
|
this.#notesByStorageSlotAndScope = new Map<string, AztecAsyncMultiMap<string, string>>();
|
|
@@ -112,7 +113,7 @@ export class KVPxeDatabase implements PxeDatabase {
|
|
|
112
113
|
|
|
113
114
|
public static async create(db: AztecAsyncKVStore): Promise<KVPxeDatabase> {
|
|
114
115
|
const pxeDB = new KVPxeDatabase(db);
|
|
115
|
-
for await (const scope of pxeDB.#scopes.
|
|
116
|
+
for await (const scope of pxeDB.#scopes.keysAsync()) {
|
|
116
117
|
pxeDB.#notesByContractAndScope.set(scope, db.openMultiMap(`${scope}:notes_by_contract`));
|
|
117
118
|
pxeDB.#notesByStorageSlotAndScope.set(scope, db.openMultiMap(`${scope}:notes_by_storage_slot`));
|
|
118
119
|
pxeDB.#notesByTxHashAndScope.set(scope, db.openMultiMap(`${scope}:notes_by_tx_hash`));
|
|
@@ -125,7 +126,7 @@ export class KVPxeDatabase implements PxeDatabase {
|
|
|
125
126
|
address: AztecAddress,
|
|
126
127
|
): Promise<(ContractInstanceWithAddress & ContractArtifact) | undefined> {
|
|
127
128
|
const instance = await this.getContractInstance(address);
|
|
128
|
-
const artifact = instance && (await this.getContractArtifact(instance?.
|
|
129
|
+
const artifact = instance && (await this.getContractArtifact(instance?.currentContractClassId));
|
|
129
130
|
if (!instance || !artifact) {
|
|
130
131
|
return undefined;
|
|
131
132
|
}
|
|
@@ -225,7 +226,7 @@ export class KVPxeDatabase implements PxeDatabase {
|
|
|
225
226
|
await this.#notes.delete(noteIndex);
|
|
226
227
|
await this.#notesToScope.delete(noteIndex);
|
|
227
228
|
await this.#nullifierToNoteId.delete(noteDao.siloedNullifier.toString());
|
|
228
|
-
const scopes = await toArray(this.#scopes.
|
|
229
|
+
const scopes = await toArray(this.#scopes.keysAsync());
|
|
229
230
|
for (const scope of scopes) {
|
|
230
231
|
await this.#notesByAddressPointAndScope.get(scope)!.deleteValue(noteDao.addressPoint.toString(), noteIndex);
|
|
231
232
|
await this.#notesByTxHashAndScope.get(scope)!.deleteValue(noteDao.txHash.toString(), noteIndex);
|
|
@@ -295,7 +296,7 @@ export class KVPxeDatabase implements PxeDatabase {
|
|
|
295
296
|
|
|
296
297
|
const candidateNoteSources = [];
|
|
297
298
|
|
|
298
|
-
filter.scopes ??= (await toArray(this.#scopes.
|
|
299
|
+
filter.scopes ??= (await toArray(this.#scopes.keysAsync())).map(addressString =>
|
|
299
300
|
AztecAddress.fromString(addressString),
|
|
300
301
|
);
|
|
301
302
|
|
|
@@ -419,7 +420,7 @@ export class KVPxeDatabase implements PxeDatabase {
|
|
|
419
420
|
await this.#notes.delete(noteIndex);
|
|
420
421
|
await this.#notesToScope.delete(noteIndex);
|
|
421
422
|
|
|
422
|
-
const scopes = await toArray(this.#scopes.
|
|
423
|
+
const scopes = await toArray(this.#scopes.keysAsync());
|
|
423
424
|
|
|
424
425
|
for (const scope of scopes) {
|
|
425
426
|
await this.#notesByAddressPointAndScope.get(scope)!.deleteValue(accountAddressPoint.toString(), noteIndex);
|
|
@@ -486,7 +487,7 @@ export class KVPxeDatabase implements PxeDatabase {
|
|
|
486
487
|
return false;
|
|
487
488
|
}
|
|
488
489
|
|
|
489
|
-
await this.#scopes.
|
|
490
|
+
await this.#scopes.set(scopeString, true);
|
|
490
491
|
this.#notesByContractAndScope.set(scopeString, this.#db.openMultiMap(`${scopeString}:notes_by_contract`));
|
|
491
492
|
this.#notesByStorageSlotAndScope.set(scopeString, this.#db.openMultiMap(`${scopeString}:notes_by_storage_slot`));
|
|
492
493
|
this.#notesByTxHashAndScope.set(scopeString, this.#db.openMultiMap(`${scopeString}:notes_by_tx_hash`));
|
|
@@ -547,13 +548,13 @@ export class KVPxeDatabase implements PxeDatabase {
|
|
|
547
548
|
return false;
|
|
548
549
|
}
|
|
549
550
|
|
|
550
|
-
await this.#addressBook.
|
|
551
|
+
await this.#addressBook.set(address.toString(), true);
|
|
551
552
|
|
|
552
553
|
return true;
|
|
553
554
|
}
|
|
554
555
|
|
|
555
556
|
async getSenderAddresses(): Promise<AztecAddress[]> {
|
|
556
|
-
return (await toArray(this.#addressBook.
|
|
557
|
+
return (await toArray(this.#addressBook.keysAsync())).map(AztecAddress.fromString);
|
|
557
558
|
}
|
|
558
559
|
|
|
559
560
|
async removeSenderAddress(address: AztecAddress): Promise<boolean> {
|
package/src/database/note_dao.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { Note, TxHash, randomTxHash } from '@aztec/circuit-types';
|
|
2
|
-
import { AztecAddress, Fr, Point, type PublicKey } from '@aztec/circuits.js';
|
|
3
|
-
import { NoteSelector } from '@aztec/foundation/abi';
|
|
4
1
|
import { toBigIntBE } from '@aztec/foundation/bigint-buffer';
|
|
2
|
+
import { Fr, Point } from '@aztec/foundation/fields';
|
|
5
3
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
6
|
-
import {
|
|
4
|
+
import type { NoteData } from '@aztec/simulator/client';
|
|
5
|
+
import { NoteSelector } from '@aztec/stdlib/abi';
|
|
6
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
|
+
import type { PublicKey } from '@aztec/stdlib/keys';
|
|
8
|
+
import { Note } from '@aztec/stdlib/note';
|
|
9
|
+
import { TxHash } from '@aztec/stdlib/tx';
|
|
7
10
|
|
|
8
11
|
/**
|
|
9
12
|
* A Note Data Access Object, representing a note that was committed to the note hash tree, holding all of the
|
|
@@ -27,7 +30,7 @@ export class NoteDao implements NoteData {
|
|
|
27
30
|
|
|
28
31
|
// Computed values
|
|
29
32
|
/**
|
|
30
|
-
* The inner hash (non-unique, non-siloed) of the note. Each contract determines how the note
|
|
33
|
+
* The inner hash (non-unique, non-siloed) of the note. Each contract determines how the note is hashed. Can
|
|
31
34
|
* be used alongside contractAddress and nonce to compute the uniqueNoteHash and the siloedNoteHash.
|
|
32
35
|
*/
|
|
33
36
|
public noteHash: Fr,
|
|
@@ -50,11 +53,11 @@ export class NoteDao implements NoteData {
|
|
|
50
53
|
public l2BlockHash: string,
|
|
51
54
|
/** The index of the leaf in the global note hash tree the note is stored at */
|
|
52
55
|
public index: bigint,
|
|
53
|
-
/** The public key with which the note
|
|
56
|
+
/** The public key with which the note log was encrypted during delivery. */
|
|
54
57
|
public addressPoint: PublicKey,
|
|
55
58
|
|
|
56
59
|
/** The note type identifier for the contract.
|
|
57
|
-
* TODO: remove
|
|
60
|
+
* TODO(#12013): remove
|
|
58
61
|
*/
|
|
59
62
|
public noteTypeId: NoteSelector,
|
|
60
63
|
) {}
|
|
@@ -134,7 +137,7 @@ export class NoteDao implements NoteData {
|
|
|
134
137
|
nonce = Fr.random(),
|
|
135
138
|
noteHash = Fr.random(),
|
|
136
139
|
siloedNullifier = Fr.random(),
|
|
137
|
-
txHash =
|
|
140
|
+
txHash = TxHash.random(),
|
|
138
141
|
l2BlockNumber = Math.floor(Math.random() * 1000),
|
|
139
142
|
l2BlockHash = Fr.random().toString(),
|
|
140
143
|
index = Fr.random().toBigInt(),
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { Note, TxHash, randomTxHash } from '@aztec/circuit-types';
|
|
2
|
-
import { AztecAddress, Fr, Point, type PublicKey } from '@aztec/circuits.js';
|
|
3
|
-
import { NoteSelector } from '@aztec/foundation/abi';
|
|
4
1
|
import { toBigIntBE } from '@aztec/foundation/bigint-buffer';
|
|
2
|
+
import { Fr, Point } from '@aztec/foundation/fields';
|
|
5
3
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
4
|
+
import { NoteSelector } from '@aztec/stdlib/abi';
|
|
5
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
+
import type { PublicKey } from '@aztec/stdlib/keys';
|
|
7
|
+
import { Note } from '@aztec/stdlib/note';
|
|
8
|
+
import { TxHash } from '@aztec/stdlib/tx';
|
|
6
9
|
|
|
7
10
|
/**
|
|
8
11
|
* A note with contextual data which was decrypted as outgoing.
|
|
@@ -102,7 +105,7 @@ export class OutgoingNoteDao {
|
|
|
102
105
|
static async random({
|
|
103
106
|
note = Note.random(),
|
|
104
107
|
contractAddress = undefined,
|
|
105
|
-
txHash =
|
|
108
|
+
txHash = TxHash.random(),
|
|
106
109
|
storageSlot = Fr.random(),
|
|
107
110
|
noteTypeId = NoteSelector.random(),
|
|
108
111
|
nonce = Fr.random(),
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from '@aztec/
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
import {
|
|
14
|
-
import { type ContractInstanceDatabase } from './contracts/contract_instance_db.js';
|
|
15
|
-
import { type NoteDao } from './note_dao.js';
|
|
1
|
+
import type { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
3
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
import type { InBlock } from '@aztec/stdlib/block';
|
|
5
|
+
import type { CompleteAddress, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
6
|
+
import type { PublicKey } from '@aztec/stdlib/keys';
|
|
7
|
+
import type { IndexedTaggingSecret } from '@aztec/stdlib/logs';
|
|
8
|
+
import type { NotesFilter } from '@aztec/stdlib/note';
|
|
9
|
+
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
10
|
+
|
|
11
|
+
import type { ContractArtifactDatabase } from './contracts/contract_artifact_db.js';
|
|
12
|
+
import type { ContractInstanceDatabase } from './contracts/contract_instance_db.js';
|
|
13
|
+
import type { NoteDao } from './note_dao.js';
|
|
16
14
|
|
|
17
15
|
/**
|
|
18
16
|
* A database interface that provides methods for retrieving, adding, and removing transactional data related to Aztec
|
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
AztecAddress,
|
|
4
|
-
CompleteAddress,
|
|
5
|
-
INITIAL_L2_BLOCK_NUM,
|
|
6
|
-
PublicKeys,
|
|
7
|
-
SerializableContractInstance,
|
|
8
|
-
} from '@aztec/circuits.js';
|
|
9
|
-
import { makeHeader } from '@aztec/circuits.js/testing';
|
|
10
|
-
import { FunctionType } from '@aztec/foundation/abi';
|
|
1
|
+
import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
11
2
|
import { timesParallel } from '@aztec/foundation/collection';
|
|
12
3
|
import { randomInt } from '@aztec/foundation/crypto';
|
|
13
4
|
import { Fr, Point } from '@aztec/foundation/fields';
|
|
14
5
|
import { BenchmarkingContractArtifact } from '@aztec/noir-contracts.js/Benchmarking';
|
|
15
6
|
import { TestContractArtifact } from '@aztec/noir-contracts.js/Test';
|
|
7
|
+
import { FunctionType } from '@aztec/stdlib/abi';
|
|
8
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
9
|
+
import { CompleteAddress, SerializableContractInstance } from '@aztec/stdlib/contract';
|
|
10
|
+
import { PublicKeys } from '@aztec/stdlib/keys';
|
|
11
|
+
import { NoteStatus, type NotesFilter } from '@aztec/stdlib/note';
|
|
12
|
+
import { makeHeader, randomTxHash } from '@aztec/stdlib/testing';
|
|
16
13
|
|
|
17
14
|
import times from 'lodash.times';
|
|
18
15
|
|
|
19
16
|
import { NoteDao } from './note_dao.js';
|
|
20
|
-
import {
|
|
17
|
+
import type { PxeDatabase } from './pxe_database.js';
|
|
21
18
|
|
|
22
19
|
/**
|
|
23
20
|
* A common test suite for a PXE database.
|
package/src/index.ts
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
export * from './pxe_service/index.js';
|
|
2
|
+
export { pxeTestSuite } from './pxe_service/test/pxe_test_suite.js';
|
|
2
3
|
export * from './pxe_http/index.js';
|
|
3
4
|
export * from './config/index.js';
|
|
4
5
|
export * from './utils/create_pxe_service.js';
|
|
5
6
|
|
|
6
|
-
export { Tx, TxHash } from '@aztec/circuit-types';
|
|
7
|
-
|
|
8
|
-
export { TxRequest } from '@aztec/circuits.js';
|
|
9
|
-
export * from '@aztec/foundation/fields';
|
|
10
|
-
export * from '@aztec/foundation/eth-address';
|
|
11
|
-
export * from '@aztec/foundation/aztec-address';
|
|
12
|
-
export * from '@aztec/key-store';
|
|
13
7
|
export * from './database/index.js';
|
|
14
8
|
export { ContractDataOracle } from './contract_data_oracle/index.js';
|
|
15
9
|
export { PrivateFunctionsTree } from './contract_data_oracle/private_functions_tree.js';
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import {
|
|
3
|
-
type AztecAddress,
|
|
4
|
-
type Fr,
|
|
5
|
-
type FunctionSelector,
|
|
6
|
-
type GrumpkinScalar,
|
|
7
|
-
MembershipWitness,
|
|
8
|
-
type NOTE_HASH_TREE_HEIGHT,
|
|
9
|
-
type Point,
|
|
10
|
-
VK_TREE_HEIGHT,
|
|
11
|
-
type VerificationKeyAsFields,
|
|
12
|
-
computeContractClassIdPreimage,
|
|
13
|
-
computeSaltedInitializationHash,
|
|
14
|
-
} from '@aztec/circuits.js';
|
|
1
|
+
import { type NOTE_HASH_TREE_HEIGHT, PUBLIC_DATA_TREE_HEIGHT, VK_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
+
import type { Fr, GrumpkinScalar, Point } from '@aztec/foundation/fields';
|
|
15
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
4
|
+
import type { Tuple } from '@aztec/foundation/serialize';
|
|
5
|
+
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
6
|
+
import type { KeyStore } from '@aztec/key-store';
|
|
7
|
+
import { getVKIndex, getVKSiblingPath } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
8
|
+
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
9
|
+
import type { FunctionSelector } from '@aztec/stdlib/abi';
|
|
10
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
11
|
+
import type { L2BlockNumber } from '@aztec/stdlib/block';
|
|
12
|
+
import { computeContractClassIdPreimage, computeSaltedInitializationHash } from '@aztec/stdlib/contract';
|
|
13
|
+
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
14
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
15
|
+
import { UpdatedClassIdHints } from '@aztec/stdlib/kernel';
|
|
16
|
+
import { SharedMutableValues, SharedMutableValuesWithHash } from '@aztec/stdlib/shared-mutable';
|
|
17
|
+
import type { NullifierMembershipWitness } from '@aztec/stdlib/trees';
|
|
18
|
+
import type { VerificationKeyAsFields } from '@aztec/stdlib/vks';
|
|
19
19
|
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
20
|
+
import type { ContractDataOracle } from '../contract_data_oracle/index.js';
|
|
21
|
+
import type { ProvingDataOracle } from './../kernel_prover/proving_data_oracle.js';
|
|
22
22
|
|
|
23
23
|
// TODO: Block number should not be "latest".
|
|
24
24
|
// It should be fixed at the time the proof is being simulated. I.e., it should be the same as the value defined in the constant data.
|
|
@@ -47,8 +47,8 @@ export class KernelOracle implements ProvingDataOracle {
|
|
|
47
47
|
return computeContractClassIdPreimage(contractClass);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
public async getFunctionMembershipWitness(
|
|
51
|
-
return await this.contractDataOracle.getFunctionMembershipWitness(
|
|
50
|
+
public async getFunctionMembershipWitness(contractClassId: Fr, selector: FunctionSelector) {
|
|
51
|
+
return await this.contractDataOracle.getFunctionMembershipWitness(contractClassId, selector);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
public getVkMembershipWitness(vk: VerificationKeyAsFields) {
|
|
@@ -65,12 +65,15 @@ export class KernelOracle implements ProvingDataOracle {
|
|
|
65
65
|
);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
getNullifierMembershipWitness(nullifier: Fr) {
|
|
68
|
+
getNullifierMembershipWitness(nullifier: Fr): Promise<NullifierMembershipWitness | undefined> {
|
|
69
69
|
return this.node.getNullifierMembershipWitness(this.blockNumber, nullifier);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
async getNoteHashTreeRoot(): Promise<Fr> {
|
|
73
73
|
const header = await this.node.getBlockHeader(this.blockNumber);
|
|
74
|
+
if (!header) {
|
|
75
|
+
throw new Error(`No block header found for block number ${this.blockNumber}`);
|
|
76
|
+
}
|
|
74
77
|
return header.state.partial.noteHashTree.root;
|
|
75
78
|
}
|
|
76
79
|
|
|
@@ -81,4 +84,34 @@ export class KernelOracle implements ProvingDataOracle {
|
|
|
81
84
|
public getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string> {
|
|
82
85
|
return this.contractDataOracle.getDebugFunctionName(contractAddress, selector);
|
|
83
86
|
}
|
|
87
|
+
|
|
88
|
+
public async getUpdatedClassIdHints(contractAddress: AztecAddress): Promise<UpdatedClassIdHints> {
|
|
89
|
+
const { sharedMutableSlot, sharedMutableHashSlot } = await SharedMutableValuesWithHash.getContractUpdateSlots(
|
|
90
|
+
contractAddress,
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
const hashLeafSlot = await computePublicDataTreeLeafSlot(
|
|
94
|
+
ProtocolContractAddress.ContractInstanceDeployer,
|
|
95
|
+
sharedMutableHashSlot,
|
|
96
|
+
);
|
|
97
|
+
const updatedClassIdWitness = await this.node.getPublicDataTreeWitness(this.blockNumber, hashLeafSlot);
|
|
98
|
+
|
|
99
|
+
if (!updatedClassIdWitness) {
|
|
100
|
+
throw new Error(`No public data tree witness found for ${hashLeafSlot}`);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const readStorage = (storageSlot: Fr) =>
|
|
104
|
+
this.node.getPublicStorageAt(ProtocolContractAddress.ContractInstanceDeployer, storageSlot, this.blockNumber);
|
|
105
|
+
const sharedMutableValues = await SharedMutableValues.readFromTree(sharedMutableSlot, readStorage);
|
|
106
|
+
|
|
107
|
+
return new UpdatedClassIdHints(
|
|
108
|
+
new MembershipWitness(
|
|
109
|
+
PUBLIC_DATA_TREE_HEIGHT,
|
|
110
|
+
updatedClassIdWitness.index,
|
|
111
|
+
updatedClassIdWitness.siblingPath.toTuple(),
|
|
112
|
+
),
|
|
113
|
+
updatedClassIdWitness.leafPreimage,
|
|
114
|
+
sharedMutableValues,
|
|
115
|
+
);
|
|
116
|
+
}
|
|
84
117
|
}
|
|
@@ -1,20 +1,27 @@
|
|
|
1
|
-
import { type PrivateCallExecutionResult, type PrivateKernelSimulateOutput, collectNested } from '@aztec/circuit-types';
|
|
2
1
|
import {
|
|
3
|
-
type Fr,
|
|
4
|
-
KeyValidationHint,
|
|
5
2
|
MAX_KEY_VALIDATION_REQUESTS_PER_TX,
|
|
6
3
|
MAX_NOTE_HASHES_PER_TX,
|
|
7
4
|
MAX_NOTE_HASH_READ_REQUESTS_PER_TX,
|
|
8
5
|
MAX_NULLIFIERS_PER_TX,
|
|
9
6
|
MAX_NULLIFIER_READ_REQUESTS_PER_TX,
|
|
10
|
-
MembershipWitness,
|
|
11
7
|
NULLIFIER_TREE_HEIGHT,
|
|
8
|
+
VK_TREE_HEIGHT,
|
|
9
|
+
} from '@aztec/constants';
|
|
10
|
+
import { makeTuple } from '@aztec/foundation/array';
|
|
11
|
+
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
12
|
+
import type { Fr } from '@aztec/foundation/fields';
|
|
13
|
+
import { type Tuple, assertLength } from '@aztec/foundation/serialize';
|
|
14
|
+
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
15
|
+
import { privateKernelResetDimensionsConfig } from '@aztec/noir-protocol-circuits-types/client';
|
|
16
|
+
import {
|
|
17
|
+
KeyValidationHint,
|
|
12
18
|
type PrivateCircuitPublicInputs,
|
|
13
19
|
type PrivateKernelCircuitPublicInputs,
|
|
14
20
|
PrivateKernelData,
|
|
15
21
|
PrivateKernelResetCircuitPrivateInputs,
|
|
16
22
|
PrivateKernelResetDimensions,
|
|
17
23
|
PrivateKernelResetHints,
|
|
24
|
+
type PrivateKernelSimulateOutput,
|
|
18
25
|
type ReadRequest,
|
|
19
26
|
ReadRequestResetStates,
|
|
20
27
|
ReadRequestState,
|
|
@@ -23,7 +30,6 @@ import {
|
|
|
23
30
|
ScopedNullifier,
|
|
24
31
|
ScopedReadRequest,
|
|
25
32
|
TransientDataIndexHint,
|
|
26
|
-
VK_TREE_HEIGHT,
|
|
27
33
|
buildNoteHashReadRequestHintsFromResetStates,
|
|
28
34
|
buildNullifierReadRequestHintsFromResetStates,
|
|
29
35
|
buildTransientDataHints,
|
|
@@ -33,13 +39,10 @@ import {
|
|
|
33
39
|
getNoteHashReadRequestResetStates,
|
|
34
40
|
getNullifierReadRequestResetStates,
|
|
35
41
|
privateKernelResetDimensionNames,
|
|
36
|
-
} from '@aztec/
|
|
37
|
-
import {
|
|
38
|
-
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
39
|
-
import { type Tuple, assertLength } from '@aztec/foundation/serialize';
|
|
40
|
-
import { privateKernelResetDimensionsConfig } from '@aztec/noir-protocol-circuits-types/client';
|
|
42
|
+
} from '@aztec/stdlib/kernel';
|
|
43
|
+
import { type PrivateCallExecutionResult, collectNested } from '@aztec/stdlib/tx';
|
|
41
44
|
|
|
42
|
-
import {
|
|
45
|
+
import type { ProvingDataOracle } from '../proving_data_oracle.js';
|
|
43
46
|
|
|
44
47
|
function collectNestedReadRequests(
|
|
45
48
|
executionStack: PrivateCallExecutionResult[],
|