@aztec/pxe 0.69.0 → 0.69.1
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/database/kv_pxe_database.d.ts +7 -7
- package/dest/database/kv_pxe_database.d.ts.map +1 -1
- package/dest/database/kv_pxe_database.js +11 -11
- package/dest/database/note_dao.d.ts +105 -0
- package/dest/database/note_dao.d.ts.map +1 -0
- package/dest/database/note_dao.js +123 -0
- package/dest/database/outgoing_note_dao.js +3 -3
- package/dest/database/pxe_database.d.ts +9 -9
- package/dest/database/pxe_database.d.ts.map +1 -1
- package/dest/database/pxe_database_test_suite.js +21 -21
- package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.js +2 -2
- package/dest/note_decryption_utils/produce_note_daos.d.ts +2 -2
- package/dest/note_decryption_utils/produce_note_daos.d.ts.map +1 -1
- package/dest/note_decryption_utils/produce_note_daos.js +5 -5
- package/dest/pxe_service/pxe_service.d.ts +2 -2
- package/dest/pxe_service/pxe_service.d.ts.map +1 -1
- package/dest/pxe_service/pxe_service.js +12 -15
- package/dest/simulator_oracle/index.d.ts.map +1 -1
- package/dest/simulator_oracle/index.js +16 -16
- package/package.json +14 -14
- package/src/database/kv_pxe_database.ts +16 -16
- package/src/database/{incoming_note_dao.ts → note_dao.ts} +65 -48
- package/src/database/outgoing_note_dao.ts +2 -2
- package/src/database/pxe_database.ts +9 -9
- package/src/database/pxe_database_test_suite.ts +25 -25
- package/src/kernel_prover/hints/build_private_kernel_reset_private_inputs.ts +1 -1
- package/src/note_decryption_utils/produce_note_daos.ts +6 -6
- package/src/pxe_service/pxe_service.ts +19 -22
- package/src/simulator_oracle/index.ts +16 -16
- package/dest/database/incoming_note_dao.d.ts +0 -86
- package/dest/database/incoming_note_dao.d.ts.map +0 -1
- package/dest/database/incoming_note_dao.js +0 -110
|
@@ -8,40 +8,57 @@ import { type NoteData } from '@aztec/simulator/acvm';
|
|
|
8
8
|
import { type NoteInfo } from '../note_decryption_utils/index.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* A
|
|
11
|
+
* A Note Data Access Object, representing a note that was comitted to the note hash tree, holding all of the
|
|
12
|
+
* information required to use it during execution and manage its state.
|
|
12
13
|
*/
|
|
13
|
-
export class
|
|
14
|
+
export class NoteDao implements NoteData {
|
|
14
15
|
constructor(
|
|
15
|
-
|
|
16
|
+
// Note information
|
|
17
|
+
|
|
18
|
+
/** The serialized content of the note, as will be returned in the getNotes oracle. */
|
|
16
19
|
public note: Note,
|
|
17
|
-
/** The contract
|
|
20
|
+
/** The address of the contract that created the note (i.e. the address used by the kernel during siloing). */
|
|
18
21
|
public contractAddress: AztecAddress,
|
|
19
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* The storage location of the note. This value is not used for anything in PXE, but we do index by storage slot
|
|
24
|
+
* since contracts typically make queries based on it.
|
|
25
|
+
* */
|
|
20
26
|
public storageSlot: Fr,
|
|
21
|
-
/** The note
|
|
22
|
-
public noteTypeId: NoteSelector,
|
|
23
|
-
/** The hash of the tx the note was created in. */
|
|
24
|
-
public txHash: TxHash,
|
|
25
|
-
/** The L2 block number in which the tx with this note was included. */
|
|
26
|
-
public l2BlockNumber: number,
|
|
27
|
-
/** The L2 block hash in which the tx with this note was included. */
|
|
28
|
-
public l2BlockHash: string,
|
|
29
|
-
/** The nonce of the note. */
|
|
27
|
+
/** The kernel-provided nonce of the note, required to compute the uniqueNoteHash. */
|
|
30
28
|
public nonce: Fr,
|
|
29
|
+
|
|
30
|
+
// Computed values
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
32
|
+
* The inner hash (non-unique, non-siloed) of the note. Each contract determines how the note content is hashed. Can
|
|
33
|
+
* be used alongside contractAddress and nonce to compute the uniqueNoteHash and the siloedNoteHash.
|
|
34
34
|
*/
|
|
35
35
|
public noteHash: Fr,
|
|
36
36
|
/**
|
|
37
|
-
* The nullifier of the note
|
|
37
|
+
* The nullifier of the note, siloed by contract address.
|
|
38
38
|
* Note: Might be set as 0 if the note was added to PXE as nullified.
|
|
39
39
|
*/
|
|
40
40
|
public siloedNullifier: Fr,
|
|
41
|
-
|
|
41
|
+
|
|
42
|
+
// Metadata
|
|
43
|
+
/** The hash of the tx in which this note was created. Knowing the tx hash allows for efficient node queries e.g.
|
|
44
|
+
* when searching for txEffects.
|
|
45
|
+
*/
|
|
46
|
+
public txHash: TxHash,
|
|
47
|
+
/** The L2 block number in which the tx with this note was included. Used for note management while processing
|
|
48
|
+
* reorgs.*/
|
|
49
|
+
public l2BlockNumber: number,
|
|
50
|
+
/** The L2 block hash in which the tx with this note was included. Used for note management while processing
|
|
51
|
+
* reorgs.*/
|
|
52
|
+
public l2BlockHash: string,
|
|
53
|
+
/** The index of the leaf in the global note hash tree the note is stored at */
|
|
42
54
|
public index: bigint,
|
|
43
|
-
/** The public key with which the note was encrypted. */
|
|
55
|
+
/** The public key with which the note content was encrypted during delivery. */
|
|
44
56
|
public addressPoint: PublicKey,
|
|
57
|
+
|
|
58
|
+
/** The note type identifier for the contract.
|
|
59
|
+
* TODO: remove
|
|
60
|
+
*/
|
|
61
|
+
public noteTypeId: NoteSelector,
|
|
45
62
|
) {}
|
|
46
63
|
|
|
47
64
|
static fromPayloadAndNoteInfo(
|
|
@@ -54,19 +71,19 @@ export class IncomingNoteDao implements NoteData {
|
|
|
54
71
|
addressPoint: PublicKey,
|
|
55
72
|
) {
|
|
56
73
|
const noteHashIndexInTheWholeTree = BigInt(dataStartIndexForTx + noteInfo.noteHashIndex);
|
|
57
|
-
return new
|
|
74
|
+
return new NoteDao(
|
|
58
75
|
note,
|
|
59
76
|
payload.contractAddress,
|
|
60
77
|
payload.storageSlot,
|
|
61
|
-
payload.noteTypeId,
|
|
62
|
-
noteInfo.txHash,
|
|
63
|
-
l2BlockNumber,
|
|
64
|
-
l2BlockHash,
|
|
65
78
|
noteInfo.nonce,
|
|
66
79
|
noteInfo.noteHash,
|
|
67
80
|
noteInfo.siloedNullifier,
|
|
81
|
+
noteInfo.txHash,
|
|
82
|
+
l2BlockNumber,
|
|
83
|
+
l2BlockHash,
|
|
68
84
|
noteHashIndexInTheWholeTree,
|
|
69
85
|
addressPoint,
|
|
86
|
+
payload.noteTypeId,
|
|
70
87
|
);
|
|
71
88
|
}
|
|
72
89
|
|
|
@@ -75,15 +92,15 @@ export class IncomingNoteDao implements NoteData {
|
|
|
75
92
|
this.note,
|
|
76
93
|
this.contractAddress,
|
|
77
94
|
this.storageSlot,
|
|
78
|
-
this.noteTypeId,
|
|
79
|
-
this.txHash.buffer,
|
|
80
|
-
this.l2BlockNumber,
|
|
81
|
-
Fr.fromHexString(this.l2BlockHash),
|
|
82
95
|
this.nonce,
|
|
83
96
|
this.noteHash,
|
|
84
97
|
this.siloedNullifier,
|
|
98
|
+
this.txHash,
|
|
99
|
+
this.l2BlockNumber,
|
|
100
|
+
Fr.fromHexString(this.l2BlockHash),
|
|
85
101
|
this.index,
|
|
86
102
|
this.addressPoint,
|
|
103
|
+
this.noteTypeId,
|
|
87
104
|
]);
|
|
88
105
|
}
|
|
89
106
|
|
|
@@ -93,29 +110,29 @@ export class IncomingNoteDao implements NoteData {
|
|
|
93
110
|
const note = Note.fromBuffer(reader);
|
|
94
111
|
const contractAddress = AztecAddress.fromBuffer(reader);
|
|
95
112
|
const storageSlot = Fr.fromBuffer(reader);
|
|
96
|
-
const noteTypeId = reader.readObject(NoteSelector);
|
|
97
|
-
const txHash = reader.readObject(TxHash);
|
|
98
|
-
const l2BlockNumber = reader.readNumber();
|
|
99
|
-
const l2BlockHash = Fr.fromBuffer(reader).toString();
|
|
100
113
|
const nonce = Fr.fromBuffer(reader);
|
|
101
114
|
const noteHash = Fr.fromBuffer(reader);
|
|
102
115
|
const siloedNullifier = Fr.fromBuffer(reader);
|
|
116
|
+
const txHash = reader.readObject(TxHash);
|
|
117
|
+
const l2BlockNumber = reader.readNumber();
|
|
118
|
+
const l2BlockHash = Fr.fromBuffer(reader).toString();
|
|
103
119
|
const index = toBigIntBE(reader.readBytes(32));
|
|
104
120
|
const publicKey = Point.fromBuffer(reader);
|
|
121
|
+
const noteTypeId = reader.readObject(NoteSelector);
|
|
105
122
|
|
|
106
|
-
return new
|
|
123
|
+
return new NoteDao(
|
|
107
124
|
note,
|
|
108
125
|
contractAddress,
|
|
109
126
|
storageSlot,
|
|
110
|
-
noteTypeId,
|
|
111
|
-
txHash,
|
|
112
|
-
l2BlockNumber,
|
|
113
|
-
l2BlockHash,
|
|
114
127
|
nonce,
|
|
115
128
|
noteHash,
|
|
116
129
|
siloedNullifier,
|
|
130
|
+
txHash,
|
|
131
|
+
l2BlockNumber,
|
|
132
|
+
l2BlockHash,
|
|
117
133
|
index,
|
|
118
134
|
publicKey,
|
|
135
|
+
noteTypeId,
|
|
119
136
|
);
|
|
120
137
|
}
|
|
121
138
|
|
|
@@ -125,7 +142,7 @@ export class IncomingNoteDao implements NoteData {
|
|
|
125
142
|
|
|
126
143
|
static fromString(str: string) {
|
|
127
144
|
const hex = str.replace(/^0x/, '');
|
|
128
|
-
return
|
|
145
|
+
return NoteDao.fromBuffer(Buffer.from(hex, 'hex'));
|
|
129
146
|
}
|
|
130
147
|
|
|
131
148
|
/**
|
|
@@ -141,30 +158,30 @@ export class IncomingNoteDao implements NoteData {
|
|
|
141
158
|
static random({
|
|
142
159
|
note = Note.random(),
|
|
143
160
|
contractAddress = AztecAddress.random(),
|
|
144
|
-
txHash = randomTxHash(),
|
|
145
161
|
storageSlot = Fr.random(),
|
|
146
|
-
noteTypeId = NoteSelector.random(),
|
|
147
162
|
nonce = Fr.random(),
|
|
148
|
-
l2BlockNumber = Math.floor(Math.random() * 1000),
|
|
149
|
-
l2BlockHash = Fr.random().toString(),
|
|
150
163
|
noteHash = Fr.random(),
|
|
151
164
|
siloedNullifier = Fr.random(),
|
|
165
|
+
txHash = randomTxHash(),
|
|
166
|
+
l2BlockNumber = Math.floor(Math.random() * 1000),
|
|
167
|
+
l2BlockHash = Fr.random().toString(),
|
|
152
168
|
index = Fr.random().toBigInt(),
|
|
153
169
|
addressPoint = Point.random(),
|
|
154
|
-
|
|
155
|
-
|
|
170
|
+
noteTypeId = NoteSelector.random(),
|
|
171
|
+
}: Partial<NoteDao> = {}) {
|
|
172
|
+
return new NoteDao(
|
|
156
173
|
note,
|
|
157
174
|
contractAddress,
|
|
158
175
|
storageSlot,
|
|
159
|
-
noteTypeId,
|
|
160
|
-
txHash,
|
|
161
|
-
l2BlockNumber,
|
|
162
|
-
l2BlockHash,
|
|
163
176
|
nonce,
|
|
164
177
|
noteHash,
|
|
165
178
|
siloedNullifier,
|
|
179
|
+
txHash,
|
|
180
|
+
l2BlockNumber,
|
|
181
|
+
l2BlockHash,
|
|
166
182
|
index,
|
|
167
183
|
addressPoint,
|
|
184
|
+
noteTypeId,
|
|
168
185
|
);
|
|
169
186
|
}
|
|
170
187
|
}
|
|
@@ -69,7 +69,7 @@ export class OutgoingNoteDao {
|
|
|
69
69
|
this.contractAddress,
|
|
70
70
|
this.storageSlot,
|
|
71
71
|
this.noteTypeId,
|
|
72
|
-
this.txHash
|
|
72
|
+
this.txHash,
|
|
73
73
|
this.l2BlockNumber,
|
|
74
74
|
Fr.fromHexString(this.l2BlockHash),
|
|
75
75
|
this.nonce,
|
|
@@ -85,7 +85,7 @@ export class OutgoingNoteDao {
|
|
|
85
85
|
const contractAddress = AztecAddress.fromBuffer(reader);
|
|
86
86
|
const storageSlot = Fr.fromBuffer(reader);
|
|
87
87
|
const noteTypeId = reader.readObject(NoteSelector);
|
|
88
|
-
const txHash =
|
|
88
|
+
const txHash = reader.readObject(TxHash);
|
|
89
89
|
const l2BlockNumber = reader.readNumber();
|
|
90
90
|
const l2BlockHash = Fr.fromBuffer(reader).toString();
|
|
91
91
|
const nonce = Fr.fromBuffer(reader);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type InBlock, type
|
|
1
|
+
import { type InBlock, type NotesFilter } from '@aztec/circuit-types';
|
|
2
2
|
import {
|
|
3
3
|
type BlockHeader,
|
|
4
4
|
type CompleteAddress,
|
|
@@ -12,7 +12,7 @@ import { type Fr } from '@aztec/foundation/fields';
|
|
|
12
12
|
|
|
13
13
|
import { type ContractArtifactDatabase } from './contracts/contract_artifact_db.js';
|
|
14
14
|
import { type ContractInstanceDatabase } from './contracts/contract_instance_db.js';
|
|
15
|
-
import { type
|
|
15
|
+
import { type NoteDao } from './note_dao.js';
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* A database interface that provides methods for retrieving, adding, and removing transactional data related to Aztec
|
|
@@ -50,11 +50,11 @@ export interface PxeDatabase extends ContractArtifactDatabase, ContractInstanceD
|
|
|
50
50
|
popCapsule(): Promise<Fr[] | undefined>;
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
|
-
* Gets
|
|
53
|
+
* Gets notes based on the provided filter.
|
|
54
54
|
* @param filter - The filter to apply to the notes.
|
|
55
55
|
* @returns The requested notes.
|
|
56
56
|
*/
|
|
57
|
-
|
|
57
|
+
getNotes(filter: NotesFilter): Promise<NoteDao[]>;
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
60
|
* Adds a note to DB.
|
|
@@ -62,24 +62,24 @@ export interface PxeDatabase extends ContractArtifactDatabase, ContractInstanceD
|
|
|
62
62
|
* @param scope - The scope to add the note under. Currently optional.
|
|
63
63
|
* @remark - Will create a database for the scope if it does not already exist.
|
|
64
64
|
*/
|
|
65
|
-
addNote(note:
|
|
65
|
+
addNote(note: NoteDao, scope?: AztecAddress): Promise<void>;
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
68
|
* Adds a nullified note to DB.
|
|
69
69
|
* @param note - The note to add.
|
|
70
70
|
*/
|
|
71
|
-
addNullifiedNote(note:
|
|
71
|
+
addNullifiedNote(note: NoteDao): Promise<void>;
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
74
|
* Adds an array of notes to DB.
|
|
75
75
|
* This function is used to insert multiple notes to the database at once,
|
|
76
76
|
* which can improve performance when dealing with large numbers of transactions.
|
|
77
77
|
*
|
|
78
|
-
* @param
|
|
78
|
+
* @param notes - An array of notes.
|
|
79
79
|
* @param scope - The scope to add the notes under. Currently optional.
|
|
80
80
|
* @remark - Will create a database for the scope if it does not already exist.
|
|
81
81
|
*/
|
|
82
|
-
addNotes(
|
|
82
|
+
addNotes(notes: NoteDao[], scope?: AztecAddress): Promise<void>;
|
|
83
83
|
|
|
84
84
|
/**
|
|
85
85
|
* Remove nullified notes associated with the given account and nullifiers.
|
|
@@ -88,7 +88,7 @@ export interface PxeDatabase extends ContractArtifactDatabase, ContractInstanceD
|
|
|
88
88
|
* @param account - A PublicKey instance representing the account for which the records are being removed.
|
|
89
89
|
* @returns Removed notes.
|
|
90
90
|
*/
|
|
91
|
-
removeNullifiedNotes(nullifiers: InBlock<Fr>[], account: PublicKey): Promise<
|
|
91
|
+
removeNullifiedNotes(nullifiers: InBlock<Fr>[], account: PublicKey): Promise<NoteDao[]>;
|
|
92
92
|
|
|
93
93
|
/**
|
|
94
94
|
* Gets the most recently processed block number.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { NoteStatus, type NotesFilter, randomTxHash } from '@aztec/circuit-types';
|
|
2
2
|
import {
|
|
3
3
|
AztecAddress,
|
|
4
4
|
CompleteAddress,
|
|
@@ -13,7 +13,7 @@ import { Fr, Point } from '@aztec/foundation/fields';
|
|
|
13
13
|
import { BenchmarkingContractArtifact } from '@aztec/noir-contracts.js/Benchmarking';
|
|
14
14
|
import { TestContractArtifact } from '@aztec/noir-contracts.js/Test';
|
|
15
15
|
|
|
16
|
-
import {
|
|
16
|
+
import { NoteDao } from './note_dao.js';
|
|
17
17
|
import { type PxeDatabase } from './pxe_database.js';
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -78,9 +78,9 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
|
|
|
78
78
|
let owners: CompleteAddress[];
|
|
79
79
|
let contractAddresses: AztecAddress[];
|
|
80
80
|
let storageSlots: Fr[];
|
|
81
|
-
let notes:
|
|
81
|
+
let notes: NoteDao[];
|
|
82
82
|
|
|
83
|
-
const filteringTests: [() =>
|
|
83
|
+
const filteringTests: [() => NotesFilter, () => NoteDao[]][] = [
|
|
84
84
|
[() => ({}), () => notes],
|
|
85
85
|
|
|
86
86
|
[
|
|
@@ -119,7 +119,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
|
|
|
119
119
|
storageSlots = Array.from({ length: 2 }).map(() => Fr.random());
|
|
120
120
|
|
|
121
121
|
notes = Array.from({ length: 10 }).map((_, i) =>
|
|
122
|
-
|
|
122
|
+
NoteDao.random({
|
|
123
123
|
contractAddress: contractAddresses[i % contractAddresses.length],
|
|
124
124
|
storageSlot: storageSlots[i % storageSlots.length],
|
|
125
125
|
addressPoint: owners[i % owners.length].address.toAddressPoint(),
|
|
@@ -135,7 +135,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
|
|
|
135
135
|
|
|
136
136
|
it.each(filteringTests)('stores notes in bulk and retrieves notes', async (getFilter, getExpected) => {
|
|
137
137
|
await database.addNotes(notes);
|
|
138
|
-
const returnedNotes = await database.
|
|
138
|
+
const returnedNotes = await database.getNotes(getFilter());
|
|
139
139
|
|
|
140
140
|
expect(returnedNotes.sort()).toEqual(getExpected().sort());
|
|
141
141
|
});
|
|
@@ -145,7 +145,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
|
|
|
145
145
|
await database.addNote(note);
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
const returnedNotes = await database.
|
|
148
|
+
const returnedNotes = await database.getNotes(getFilter());
|
|
149
149
|
|
|
150
150
|
expect(returnedNotes.sort()).toEqual(getExpected().sort());
|
|
151
151
|
});
|
|
@@ -166,9 +166,9 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
|
|
|
166
166
|
);
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
await expect(
|
|
170
|
-
|
|
171
|
-
)
|
|
169
|
+
await expect(database.getNotes({ ...getFilter(), status: NoteStatus.ACTIVE_OR_NULLIFIED })).resolves.toEqual(
|
|
170
|
+
getExpected(),
|
|
171
|
+
);
|
|
172
172
|
});
|
|
173
173
|
|
|
174
174
|
it('skips nullified notes by default or when requesting active', async () => {
|
|
@@ -184,8 +184,8 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
|
|
|
184
184
|
notesToNullify,
|
|
185
185
|
);
|
|
186
186
|
|
|
187
|
-
const actualNotesWithDefault = await database.
|
|
188
|
-
const actualNotesWithActive = await database.
|
|
187
|
+
const actualNotesWithDefault = await database.getNotes({});
|
|
188
|
+
const actualNotesWithActive = await database.getNotes({ status: NoteStatus.ACTIVE });
|
|
189
189
|
|
|
190
190
|
expect(actualNotesWithDefault).toEqual(actualNotesWithActive);
|
|
191
191
|
expect(actualNotesWithActive).toEqual(notes.filter(note => !notesToNullify.includes(note)));
|
|
@@ -206,7 +206,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
|
|
|
206
206
|
);
|
|
207
207
|
await expect(database.unnullifyNotesAfter(98)).resolves.toEqual(undefined);
|
|
208
208
|
|
|
209
|
-
const result = await database.
|
|
209
|
+
const result = await database.getNotes({ status: NoteStatus.ACTIVE, owner: owners[0].address });
|
|
210
210
|
|
|
211
211
|
expect(result.sort()).toEqual([...notesToNullify].sort());
|
|
212
212
|
});
|
|
@@ -224,7 +224,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
|
|
|
224
224
|
notesToNullify,
|
|
225
225
|
);
|
|
226
226
|
|
|
227
|
-
const result = await database.
|
|
227
|
+
const result = await database.getNotes({
|
|
228
228
|
status: NoteStatus.ACTIVE_OR_NULLIFIED,
|
|
229
229
|
});
|
|
230
230
|
|
|
@@ -242,23 +242,23 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
|
|
|
242
242
|
await database.addNote(note, owners[1].address);
|
|
243
243
|
}
|
|
244
244
|
|
|
245
|
-
const
|
|
245
|
+
const owner0Notes = await database.getNotes({
|
|
246
246
|
scopes: [owners[0].address],
|
|
247
247
|
});
|
|
248
248
|
|
|
249
|
-
expect(
|
|
249
|
+
expect(owner0Notes.sort()).toEqual(notes.slice(0, 5).sort());
|
|
250
250
|
|
|
251
|
-
const
|
|
251
|
+
const owner1Notes = await database.getNotes({
|
|
252
252
|
scopes: [owners[1].address],
|
|
253
253
|
});
|
|
254
254
|
|
|
255
|
-
expect(
|
|
255
|
+
expect(owner1Notes.sort()).toEqual(notes.slice(5).sort());
|
|
256
256
|
|
|
257
|
-
const
|
|
257
|
+
const bothOwnerNotes = await database.getNotes({
|
|
258
258
|
scopes: [owners[0].address, owners[1].address],
|
|
259
259
|
});
|
|
260
260
|
|
|
261
|
-
expect(
|
|
261
|
+
expect(bothOwnerNotes.sort()).toEqual(notes.sort());
|
|
262
262
|
});
|
|
263
263
|
|
|
264
264
|
it('a nullified note removes notes from all accounts in the pxe', async () => {
|
|
@@ -266,12 +266,12 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
|
|
|
266
266
|
await database.addNote(notes[0], owners[1].address);
|
|
267
267
|
|
|
268
268
|
await expect(
|
|
269
|
-
database.
|
|
269
|
+
database.getNotes({
|
|
270
270
|
scopes: [owners[0].address],
|
|
271
271
|
}),
|
|
272
272
|
).resolves.toEqual([notes[0]]);
|
|
273
273
|
await expect(
|
|
274
|
-
database.
|
|
274
|
+
database.getNotes({
|
|
275
275
|
scopes: [owners[1].address],
|
|
276
276
|
}),
|
|
277
277
|
).resolves.toEqual([notes[0]]);
|
|
@@ -290,12 +290,12 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
|
|
|
290
290
|
).resolves.toEqual([notes[0]]);
|
|
291
291
|
|
|
292
292
|
await expect(
|
|
293
|
-
database.
|
|
293
|
+
database.getNotes({
|
|
294
294
|
scopes: [owners[0].address],
|
|
295
295
|
}),
|
|
296
296
|
).resolves.toEqual([]);
|
|
297
297
|
await expect(
|
|
298
|
-
database.
|
|
298
|
+
database.getNotes({
|
|
299
299
|
scopes: [owners[1].address],
|
|
300
300
|
}),
|
|
301
301
|
).resolves.toEqual([]);
|
|
@@ -305,7 +305,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
|
|
|
305
305
|
await database.addNotes(notes, owners[0].address);
|
|
306
306
|
|
|
307
307
|
await database.removeNotesAfter(5);
|
|
308
|
-
const result = await database.
|
|
308
|
+
const result = await database.getNotes({ scopes: [owners[0].address] });
|
|
309
309
|
expect(new Set(result)).toEqual(new Set(notes.slice(0, 6)));
|
|
310
310
|
});
|
|
311
311
|
});
|
|
@@ -57,7 +57,7 @@ function getNullifierMembershipWitnessResolver(oracle: ProvingDataOracle) {
|
|
|
57
57
|
return async (nullifier: Fr) => {
|
|
58
58
|
const res = await oracle.getNullifierMembershipWitness(nullifier);
|
|
59
59
|
if (!res) {
|
|
60
|
-
throw new Error(`Cannot find the leaf for nullifier ${nullifier
|
|
60
|
+
throw new Error(`Cannot find the leaf for nullifier ${nullifier}.`);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
const { index, siblingPath, leafPreimage } = res;
|
|
@@ -3,7 +3,7 @@ import { type Fr } from '@aztec/foundation/fields';
|
|
|
3
3
|
import { type Logger } from '@aztec/foundation/log';
|
|
4
4
|
import { type AcirSimulator } from '@aztec/simulator/client';
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { NoteDao } from '../database/note_dao.js';
|
|
7
7
|
import { type PxeDatabase } from '../database/pxe_database.js';
|
|
8
8
|
import { produceNoteDaosForKey } from './produce_note_daos_for_key.js';
|
|
9
9
|
|
|
@@ -37,15 +37,15 @@ export async function produceNoteDaos(
|
|
|
37
37
|
dataStartIndexForTx: number,
|
|
38
38
|
excludedIndices: Set<number>,
|
|
39
39
|
logger: Logger,
|
|
40
|
-
): Promise<{
|
|
40
|
+
): Promise<{ note: NoteDao | undefined }> {
|
|
41
41
|
if (!addressPoint) {
|
|
42
42
|
throw new Error('addressPoint is undefined. Cannot create note.');
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
let
|
|
45
|
+
let note: NoteDao | undefined;
|
|
46
46
|
|
|
47
47
|
if (addressPoint) {
|
|
48
|
-
|
|
48
|
+
note = await produceNoteDaosForKey(
|
|
49
49
|
simulator,
|
|
50
50
|
db,
|
|
51
51
|
addressPoint,
|
|
@@ -57,11 +57,11 @@ export async function produceNoteDaos(
|
|
|
57
57
|
dataStartIndexForTx,
|
|
58
58
|
excludedIndices,
|
|
59
59
|
logger,
|
|
60
|
-
|
|
60
|
+
NoteDao.fromPayloadAndNoteInfo,
|
|
61
61
|
);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
return {
|
|
65
|
-
|
|
65
|
+
note,
|
|
66
66
|
};
|
|
67
67
|
}
|
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
type FunctionCall,
|
|
8
8
|
type GetUnencryptedLogsResponse,
|
|
9
9
|
type InBlock,
|
|
10
|
-
type IncomingNotesFilter,
|
|
11
10
|
L1EventPayload,
|
|
12
11
|
type L2Block,
|
|
13
12
|
type LogFilter,
|
|
14
13
|
MerkleTreeId,
|
|
14
|
+
type NotesFilter,
|
|
15
15
|
type PXE,
|
|
16
16
|
type PXEInfo,
|
|
17
17
|
type PrivateExecutionResult,
|
|
@@ -54,6 +54,7 @@ import {
|
|
|
54
54
|
EventSelector,
|
|
55
55
|
FunctionSelector,
|
|
56
56
|
FunctionType,
|
|
57
|
+
decodeFunctionSignature,
|
|
57
58
|
encodeArguments,
|
|
58
59
|
} from '@aztec/foundation/abi';
|
|
59
60
|
import { type AztecAddress } from '@aztec/foundation/aztec-address';
|
|
@@ -71,8 +72,8 @@ import { inspect } from 'util';
|
|
|
71
72
|
import { type PXEServiceConfig } from '../config/index.js';
|
|
72
73
|
import { getPackageInfo } from '../config/package_info.js';
|
|
73
74
|
import { ContractDataOracle } from '../contract_data_oracle/index.js';
|
|
74
|
-
import { IncomingNoteDao } from '../database/incoming_note_dao.js';
|
|
75
75
|
import { type PxeDatabase } from '../database/index.js';
|
|
76
|
+
import { NoteDao } from '../database/note_dao.js';
|
|
76
77
|
import { KernelOracle } from '../kernel_oracle/index.js';
|
|
77
78
|
import { KernelProver } from '../kernel_prover/kernel_prover.js';
|
|
78
79
|
import { TestPrivateKernelProver } from '../kernel_prover/test/test_circuit_prover.js';
|
|
@@ -237,14 +238,10 @@ export class PXEService implements PXE {
|
|
|
237
238
|
|
|
238
239
|
await this.db.addContractArtifact(contractClassId, artifact);
|
|
239
240
|
|
|
240
|
-
const
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
await this.node.registerContractFunctionNames(instance.address, functionNames);
|
|
241
|
+
const publicFunctionSignatures = artifact.functions
|
|
242
|
+
.filter(fn => fn.functionType === FunctionType.PUBLIC)
|
|
243
|
+
.map(fn => decodeFunctionSignature(fn.name, fn.parameters));
|
|
244
|
+
await this.node.registerContractFunctionSignatures(instance.address, publicFunctionSignatures);
|
|
248
245
|
|
|
249
246
|
// TODO(#10007): Node should get public contract class from the registration event, not from PXE registration
|
|
250
247
|
await this.node.addContractClass({ ...contractClass, privateFunctions: [], unconstrainedFunctions: [] });
|
|
@@ -273,8 +270,8 @@ export class PXEService implements PXE {
|
|
|
273
270
|
return await this.node.getPublicStorageAt(contract, slot, 'latest');
|
|
274
271
|
}
|
|
275
272
|
|
|
276
|
-
public async
|
|
277
|
-
const noteDaos = await this.db.
|
|
273
|
+
public async getNotes(filter: NotesFilter): Promise<UniqueNote[]> {
|
|
274
|
+
const noteDaos = await this.db.getNotes(filter);
|
|
278
275
|
|
|
279
276
|
const extendedNotes = noteDaos.map(async dao => {
|
|
280
277
|
let owner = filter.owner;
|
|
@@ -343,19 +340,19 @@ export class PXEService implements PXE {
|
|
|
343
340
|
}
|
|
344
341
|
|
|
345
342
|
await this.db.addNote(
|
|
346
|
-
new
|
|
343
|
+
new NoteDao(
|
|
347
344
|
note.note,
|
|
348
345
|
note.contractAddress,
|
|
349
346
|
note.storageSlot,
|
|
350
|
-
note.noteTypeId,
|
|
351
|
-
note.txHash,
|
|
352
|
-
l2BlockNumber,
|
|
353
|
-
l2BlockHash,
|
|
354
347
|
nonce,
|
|
355
348
|
noteHash,
|
|
356
349
|
siloedNullifier,
|
|
350
|
+
note.txHash,
|
|
351
|
+
l2BlockNumber,
|
|
352
|
+
l2BlockHash,
|
|
357
353
|
index,
|
|
358
354
|
owner.address.toAddressPoint(),
|
|
355
|
+
note.noteTypeId,
|
|
359
356
|
),
|
|
360
357
|
scope,
|
|
361
358
|
);
|
|
@@ -388,19 +385,19 @@ export class PXEService implements PXE {
|
|
|
388
385
|
}
|
|
389
386
|
|
|
390
387
|
await this.db.addNullifiedNote(
|
|
391
|
-
new
|
|
388
|
+
new NoteDao(
|
|
392
389
|
note.note,
|
|
393
390
|
note.contractAddress,
|
|
394
391
|
note.storageSlot,
|
|
395
|
-
note.noteTypeId,
|
|
396
|
-
note.txHash,
|
|
397
|
-
l2BlockNumber,
|
|
398
|
-
l2BlockHash,
|
|
399
392
|
nonce,
|
|
400
393
|
noteHash,
|
|
401
394
|
Fr.ZERO, // We are not able to derive
|
|
395
|
+
note.txHash,
|
|
396
|
+
l2BlockNumber,
|
|
397
|
+
l2BlockHash,
|
|
402
398
|
index,
|
|
403
399
|
note.owner.toAddressPoint(),
|
|
400
|
+
note.noteTypeId,
|
|
404
401
|
),
|
|
405
402
|
);
|
|
406
403
|
}
|