@aztec/txe 0.80.0 → 0.82.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/txe",
3
- "version": "0.80.0",
3
+ "version": "0.82.0",
4
4
  "type": "module",
5
5
  "exports": "./dest/index.js",
6
6
  "bin": "./dest/bin/index.js",
@@ -59,17 +59,17 @@
59
59
  ]
60
60
  },
61
61
  "dependencies": {
62
- "@aztec/accounts": "0.80.0",
63
- "@aztec/aztec.js": "0.80.0",
64
- "@aztec/constants": "0.80.0",
65
- "@aztec/foundation": "0.80.0",
66
- "@aztec/key-store": "0.80.0",
67
- "@aztec/kv-store": "0.80.0",
68
- "@aztec/protocol-contracts": "0.80.0",
69
- "@aztec/pxe": "0.80.0",
70
- "@aztec/simulator": "0.80.0",
71
- "@aztec/stdlib": "0.80.0",
72
- "@aztec/world-state": "0.80.0",
62
+ "@aztec/accounts": "0.82.0",
63
+ "@aztec/aztec.js": "0.82.0",
64
+ "@aztec/constants": "0.82.0",
65
+ "@aztec/foundation": "0.82.0",
66
+ "@aztec/key-store": "0.82.0",
67
+ "@aztec/kv-store": "0.82.0",
68
+ "@aztec/protocol-contracts": "0.82.0",
69
+ "@aztec/pxe": "0.82.0",
70
+ "@aztec/simulator": "0.82.0",
71
+ "@aztec/stdlib": "0.82.0",
72
+ "@aztec/world-state": "0.82.0",
73
73
  "zod": "^3.23.8"
74
74
  },
75
75
  "devDependencies": {
package/src/bin/index.ts CHANGED
@@ -25,6 +25,7 @@ async function main() {
25
25
 
26
26
  const txeServer = createTXERpcServer(logger);
27
27
  const { port } = await startHttpRpcServer(txeServer, {
28
+ host: '0.0.0.0',
28
29
  port: TXE_PORT,
29
30
  timeoutMs: 1e3 * 60 * 5,
30
31
  });
@@ -1,10 +1,9 @@
1
- import {
2
- type ARCHIVE_HEIGHT,
3
- type L1_TO_L2_MSG_TREE_HEIGHT,
4
- type NOTE_HASH_TREE_HEIGHT,
5
- type NULLIFIER_TREE_HEIGHT,
6
- type PUBLIC_DATA_TREE_HEIGHT,
7
- PUBLIC_LOG_DATA_SIZE_IN_FIELDS,
1
+ import type {
2
+ ARCHIVE_HEIGHT,
3
+ L1_TO_L2_MSG_TREE_HEIGHT,
4
+ NOTE_HASH_TREE_HEIGHT,
5
+ NULLIFIER_TREE_HEIGHT,
6
+ PUBLIC_DATA_TREE_HEIGHT,
8
7
  } from '@aztec/constants';
9
8
  import type { L1ContractAddresses } from '@aztec/ethereum';
10
9
  import { poseidon2Hash } from '@aztec/foundation/crypto';
@@ -12,7 +11,14 @@ import { Fr } from '@aztec/foundation/fields';
12
11
  import { createLogger } from '@aztec/foundation/log';
13
12
  import type { SiblingPath } from '@aztec/foundation/trees';
14
13
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
15
- import { type InBlock, L2Block, L2BlockHash, type L2BlockNumber, type L2Tips } from '@aztec/stdlib/block';
14
+ import {
15
+ type InBlock,
16
+ L2Block,
17
+ L2BlockHash,
18
+ type L2BlockNumber,
19
+ type L2Tips,
20
+ type PublishedL2Block,
21
+ } from '@aztec/stdlib/block';
16
22
  import type {
17
23
  ContractClassPublic,
18
24
  ContractInstanceWithAddress,
@@ -51,7 +57,6 @@ export class TXENode implements AztecNode {
51
57
  #logsByTags = new Map<string, TxScopedL2Log[]>();
52
58
  #txEffectsByTxHash = new Map<string, InBlock<TxEffect>>();
53
59
  #txReceiptsByTxHash = new Map<string, TxReceipt>();
54
- #blockNumberToNullifiers = new Map<number, Fr[]>();
55
60
  #noteIndex = 0;
56
61
 
57
62
  #logger = createLogger('aztec:txe_node');
@@ -119,77 +124,26 @@ export class TXENode implements AztecNode {
119
124
  undefined,
120
125
  new L2BlockHash(blockHash.toBuffer()),
121
126
  blockNumber,
122
- undefined,
123
127
  ),
124
128
  );
125
129
  }
126
130
 
127
131
  /**
128
- * Returns the indexes of the given nullifiers in the nullifier tree,
129
- * scoped to the block they were included in.
130
- * @param blockNumber - The block number at which to get the data.
131
- * @param nullifiers - The nullifiers to search for.
132
- * @returns The block scoped indexes of the given nullifiers in the nullifier tree, or undefined if not found.
133
- */
134
- async findNullifiersIndexesWithBlock(
135
- blockNumber: L2BlockNumber,
136
- nullifiers: Fr[],
137
- ): Promise<(InBlock<bigint> | undefined)[]> {
138
- const parsedBlockNumber = blockNumber === 'latest' ? await this.getBlockNumber() : blockNumber;
139
-
140
- const nullifiersInBlock: Fr[] = [];
141
- for (const [key, val] of this.#blockNumberToNullifiers.entries()) {
142
- if (key < parsedBlockNumber) {
143
- nullifiersInBlock.push(...val);
144
- }
145
- }
146
-
147
- return nullifiers.map(nullifier => {
148
- const possibleNullifierIndex = nullifiersInBlock.findIndex(nullifierInBlock =>
149
- nullifierInBlock.equals(nullifier),
150
- );
151
- return possibleNullifierIndex === -1
152
- ? undefined
153
- : {
154
- l2BlockNumber: parsedBlockNumber,
155
- l2BlockHash: new Fr(parsedBlockNumber).toString(),
156
- data: BigInt(possibleNullifierIndex),
157
- };
158
- });
159
- }
160
-
161
- /**
162
- * Returns the indexes of the given nullifiers in the nullifier tree,
163
- * scoped to the block they were included in.
164
- * @param blockNumber - The block number at which to get the data.
165
- * @param nullifiers - The nullifiers to search for.
166
- * @returns The block scoped indexes of the given nullifiers in the nullifier tree, or undefined if not found.
167
- */
168
- setNullifiersIndexesWithBlock(blockNumber: number, nullifiers: Fr[]) {
169
- this.#blockNumberToNullifiers.set(blockNumber, nullifiers);
170
- }
171
-
172
- /**
173
- * Adds note logs to the txe node, given a block
174
- * @param blockNumber - The block number at which to add the note logs.
175
- * @param privateLogs - The privateLogs that contain the note logs to be added.
132
+ * Adds private logs to the txe node, given a block
133
+ * @param blockNumber - The block number at which to add the private logs.
134
+ * @param privateLogs - The privateLogs that contain the private logs to be added.
176
135
  */
177
- addNoteLogsByTags(blockNumber: number, privateLogs: PrivateLog[]) {
136
+ addPrivateLogsByTags(blockNumber: number, privateLogs: PrivateLog[]) {
178
137
  privateLogs.forEach(log => {
179
138
  const tag = log.fields[0];
139
+ this.#logger.verbose(`Found private log with tag ${tag.toString()} in block ${this.getBlockNumber()}`);
140
+
180
141
  const currentLogs = this.#logsByTags.get(tag.toString()) ?? [];
181
- const scopedLog = new TxScopedL2Log(
182
- new TxHash(new Fr(blockNumber)),
183
- this.#noteIndex,
184
- blockNumber,
185
- false,
186
- log.toBuffer(),
187
- );
142
+ const scopedLog = new TxScopedL2Log(new TxHash(new Fr(blockNumber)), this.#noteIndex, blockNumber, log);
188
143
  currentLogs.push(scopedLog);
189
144
  this.#logsByTags.set(tag.toString(), currentLogs);
190
145
  });
191
146
 
192
- // TODO: DISTINGUISH BETWEEN EVENT LOGS AND NOTE LOGS ?
193
147
  this.#noteIndex += privateLogs.length;
194
148
  }
195
149
 
@@ -200,39 +154,11 @@ export class TXENode implements AztecNode {
200
154
  */
201
155
  addPublicLogsByTags(blockNumber: number, publicLogs: PublicLog[]) {
202
156
  publicLogs.forEach(log => {
203
- // Check that each log stores 3 lengths in its first field. If not, it's not a tagged log:
204
- const firstFieldBuf = log.log[0].toBuffer();
205
- // See macros/note/mod/ and see how finalization_log[0] is constructed, to understand this monstrosity. (It wasn't me).
206
- // Search the codebase for "disgusting encoding" to see other hardcoded instances of this encoding, that you might need to change if you ever find yourself here.
207
- if (!firstFieldBuf.subarray(0, 27).equals(Buffer.alloc(27)) || firstFieldBuf[29] !== 0) {
208
- // See parseLogFromPublic - the first field of a tagged log is 5 bytes structured:
209
- // [ publicLen[0], publicLen[1], 0, privateLen[0], privateLen[1]]
210
- this.#logger.warn(`Skipping public log with invalid first field: ${log.log[0]}`);
211
- return;
212
- }
213
- // Check that the length values line up with the log contents
214
- const publicValuesLength = firstFieldBuf.subarray(-5).readUint16BE();
215
- const privateValuesLength = firstFieldBuf.subarray(-5).readUint16BE(3);
216
- // Add 1 for the first field holding lengths
217
- const totalLogLength = 1 + publicValuesLength + privateValuesLength;
218
- // Note that zeroes can be valid log values, so we can only assert that we do not go over the given length
219
- if (totalLogLength > PUBLIC_LOG_DATA_SIZE_IN_FIELDS || log.log.slice(totalLogLength).find(f => !f.isZero())) {
220
- this.#logger.warn(`Skipping invalid tagged public log with first field: ${log.log[0]}`);
221
- return;
222
- }
223
- // The first elt stores lengths => tag is in fields[1]
224
- const tag = log.log[1];
225
-
226
- this.#logger.verbose(`Found tagged public log with tag ${tag.toString()} in block ${this.getBlockNumber()}`);
157
+ const tag = log.log[0];
158
+ this.#logger.verbose(`Found public log with tag ${tag.toString()} in block ${this.getBlockNumber()}`);
227
159
 
228
160
  const currentLogs = this.#logsByTags.get(tag.toString()) ?? [];
229
- const scopedLog = new TxScopedL2Log(
230
- new TxHash(new Fr(blockNumber)),
231
- this.#noteIndex,
232
- blockNumber,
233
- true,
234
- log.toBuffer(),
235
- );
161
+ const scopedLog = new TxScopedL2Log(new TxHash(new Fr(blockNumber)), this.#noteIndex, blockNumber, log);
236
162
 
237
163
  currentLogs.push(scopedLog);
238
164
  this.#logsByTags.set(tag.toString(), currentLogs);
@@ -245,9 +171,9 @@ export class TXENode implements AztecNode {
245
171
  array implies no logs match that tag.
246
172
  */
247
173
  getLogsByTags(tags: Fr[]): Promise<TxScopedL2Log[][]> {
248
- const noteLogs = tags.map(tag => this.#logsByTags.get(tag.toString()) ?? []);
174
+ const logs = tags.map(tag => this.#logsByTags.get(tag.toString()) ?? []);
249
175
 
250
- return Promise.resolve(noteLogs);
176
+ return Promise.resolve(logs);
251
177
  }
252
178
 
253
179
  /**
@@ -262,13 +188,13 @@ export class TXENode implements AztecNode {
262
188
  * @param blockNumber - The block number at which to get the data or 'latest' for latest data
263
189
  * @param treeId - The tree to search in.
264
190
  * @param leafValue - The values to search for
265
- * @returns The indexes of the given leaves in the given tree or undefined if not found.
191
+ * @returns The indices of leaves and the block metadata of a block in which the leaf was inserted.
266
192
  */
267
193
  async findLeavesIndexes(
268
194
  blockNumber: L2BlockNumber,
269
195
  treeId: MerkleTreeId,
270
196
  leafValues: Fr[],
271
- ): Promise<(bigint | undefined)[]> {
197
+ ): Promise<(InBlock<bigint> | undefined)[]> {
272
198
  // Temporary workaround to be able to respond this query: the trees are currently stored in the TXE oracle, but we
273
199
  // hold a reference to them.
274
200
  // We should likely migrate this so that the trees are owned by the node.
@@ -279,10 +205,61 @@ export class TXENode implements AztecNode {
279
205
  ? this.baseFork
280
206
  : this.nativeWorldStateService.getSnapshot(blockNumber);
281
207
 
282
- return await db.findLeafIndices(
208
+ const maybeIndices = await db.findLeafIndices(
283
209
  treeId,
284
210
  leafValues.map(x => x.toBuffer()),
285
211
  );
212
+
213
+ // We filter out undefined values
214
+ const indices = maybeIndices.filter(x => x !== undefined) as bigint[];
215
+
216
+ // Now we find the block numbers for the indices
217
+ const blockNumbers = await db.getBlockNumbersForLeafIndices(treeId, indices);
218
+
219
+ // If any of the block numbers are undefined, we throw an error.
220
+ for (let i = 0; i < indices.length; i++) {
221
+ if (blockNumbers[i] === undefined) {
222
+ throw new Error(`Block number is undefined for leaf index ${indices[i]} in tree ${MerkleTreeId[treeId]}`);
223
+ }
224
+ }
225
+ // Get unique block numbers in order to optimize num calls to getLeafValue function.
226
+ const uniqueBlockNumbers = [...new Set(blockNumbers.filter(x => x !== undefined))];
227
+
228
+ // Now we obtain the block hashes from the archive tree by calling await `committedDb.getLeafValue(treeId, index)`
229
+ // (note that block number corresponds to the leaf index in the archive tree).
230
+ const blockHashes = await Promise.all(
231
+ uniqueBlockNumbers.map(blockNumber => {
232
+ return db.getLeafValue(MerkleTreeId.ARCHIVE, blockNumber!);
233
+ }),
234
+ );
235
+
236
+ // If any of the block hashes are undefined, we throw an error.
237
+ for (let i = 0; i < uniqueBlockNumbers.length; i++) {
238
+ if (blockHashes[i] === undefined) {
239
+ throw new Error(`Block hash is undefined for block number ${uniqueBlockNumbers[i]}`);
240
+ }
241
+ }
242
+
243
+ // Create InBlock objects by combining indices, blockNumbers and blockHashes
244
+ return maybeIndices.map((index, i) => {
245
+ if (index === undefined) {
246
+ return undefined;
247
+ }
248
+ const blockNumber = blockNumbers[i];
249
+ if (blockNumber === undefined) {
250
+ return undefined;
251
+ }
252
+ const blockHashIndex = uniqueBlockNumbers.indexOf(blockNumber);
253
+ const blockHash = blockHashes[blockHashIndex]?.toString();
254
+ if (!blockHash) {
255
+ return undefined;
256
+ }
257
+ return {
258
+ l2BlockNumber: Number(blockNumber),
259
+ l2BlockHash: blockHash,
260
+ data: index,
261
+ };
262
+ });
286
263
  }
287
264
 
288
265
  /**
@@ -411,8 +388,8 @@ export class TXENode implements AztecNode {
411
388
  * "in range" slot, means that the slot doesn't exist and the value is 0. If the low leaf preimage corresponds to the exact slot, the current value
412
389
  * is contained in the leaf preimage.
413
390
  */
414
- getPublicDataTreeWitness(_blockNumber: L2BlockNumber, _leafSlot: Fr): Promise<PublicDataWitness | undefined> {
415
- throw new Error('TXE Node method getPublicDataTreeWitness not implemented');
391
+ getPublicDataWitness(_blockNumber: L2BlockNumber, _leafSlot: Fr): Promise<PublicDataWitness | undefined> {
392
+ throw new Error('TXE Node method getPublicDataWitness not implemented');
416
393
  }
417
394
 
418
395
  /**
@@ -450,6 +427,10 @@ export class TXENode implements AztecNode {
450
427
  throw new Error('TXE Node method getBlocks not implemented');
451
428
  }
452
429
 
430
+ getPublishedBlocks(_from: number, _limit: number): Promise<PublishedL2Block[]> {
431
+ throw new Error('TXE Node method getPublishedBlocks not implemented');
432
+ }
433
+
453
434
  /**
454
435
  * Method to fetch the version of the package.
455
436
  * @returns The node package version
@@ -665,15 +646,6 @@ export class TXENode implements AztecNode {
665
646
  throw new Error('TXE Node method getEncodedEnr not implemented');
666
647
  }
667
648
 
668
- /**
669
- * Adds a contract class bypassing the registerer.
670
- * TODO(#10007): Remove this method.
671
- * @param contractClass - The class to register.
672
- */
673
- addContractClass(_contractClass: ContractClassPublic): Promise<void> {
674
- throw new Error('TXE Node method addContractClass not implemented');
675
- }
676
-
677
649
  /**
678
650
  * Method to fetch the current base fees.
679
651
  * @returns The current base fees.
@@ -692,21 +664,6 @@ export class TXENode implements AztecNode {
692
664
  throw new Error('TXE Node method getPrivateLogs not implemented');
693
665
  }
694
666
 
695
- /**
696
- * Find the block numbers of the given leaf indices in the given tree.
697
- * @param blockNumber - The block number at which to get the data or 'latest' for latest data
698
- * @param treeId - The tree to search in.
699
- * @param leafIndices - The values to search for
700
- * @returns The indexes of the given leaves in the given tree or undefined if not found.
701
- */
702
- findBlockNumbersForIndexes(
703
- _blockNumber: L2BlockNumber,
704
- _treeId: MerkleTreeId,
705
- _leafIndices: bigint[],
706
- ): Promise<(bigint | undefined)[]> {
707
- throw new Error('TXE Node method findBlockNumbersForIndexes not implemented');
708
- }
709
-
710
667
  /**
711
668
  * Returns the information about the server's node. Includes current Node version, compatible Noir version,
712
669
  * L1 chain identifier, protocol version, and L1 address of the rollup contract.
@@ -12,7 +12,7 @@ import {
12
12
  } from '@aztec/constants';
13
13
  import { padArrayEnd } from '@aztec/foundation/collection';
14
14
  import { Aes128, Schnorr, poseidon2Hash } from '@aztec/foundation/crypto';
15
- import { Fr } from '@aztec/foundation/fields';
15
+ import { Fr, Point } from '@aztec/foundation/fields';
16
16
  import { type Logger, applyStringFormatting } from '@aztec/foundation/log';
17
17
  import { Timer } from '@aztec/foundation/timer';
18
18
  import { KeyStore } from '@aztec/key-store';
@@ -20,7 +20,6 @@ import type { AztecAsyncKVStore } from '@aztec/kv-store';
20
20
  import type { ProtocolContract } from '@aztec/protocol-contracts';
21
21
  import {
22
22
  AddressDataProvider,
23
- AuthWitnessDataProvider,
24
23
  CapsuleDataProvider,
25
24
  ContractDataProvider,
26
25
  NoteDataProvider,
@@ -46,6 +45,7 @@ import {
46
45
  import { createTxForPublicCalls } from '@aztec/simulator/public/fixtures';
47
46
  import {
48
47
  ExecutionError,
48
+ PublicContractsDB,
49
49
  type PublicTxResult,
50
50
  PublicTxSimulator,
51
51
  createSimulationError,
@@ -74,8 +74,13 @@ import {
74
74
  import type { MerkleTreeReadOperations, MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
75
75
  import { type KeyValidationRequest, PrivateContextInputs } from '@aztec/stdlib/kernel';
76
76
  import { deriveKeys } from '@aztec/stdlib/keys';
77
- import { ContractClassLog, LogWithTxData } from '@aztec/stdlib/logs';
78
- import { IndexedTaggingSecret, type PrivateLog, type PublicLog } from '@aztec/stdlib/logs';
77
+ import {
78
+ ContractClassLog,
79
+ IndexedTaggingSecret,
80
+ LogWithTxData,
81
+ type PrivateLog,
82
+ type PublicLog,
83
+ } from '@aztec/stdlib/logs';
79
84
  import type { NoteStatus } from '@aztec/stdlib/note';
80
85
  import type { CircuitWitnessGenerationStats } from '@aztec/stdlib/stats';
81
86
  import {
@@ -99,7 +104,7 @@ import { ForkCheckpoint, NativeWorldStateService } from '@aztec/world-state/nati
99
104
  import { TXENode } from '../node/txe_node.js';
100
105
  import { TXEAccountDataProvider } from '../util/txe_account_data_provider.js';
101
106
  import { TXEPublicContractDataSource } from '../util/txe_public_contract_data_source.js';
102
- import { TXEWorldStateDB } from '../util/txe_world_state_db.js';
107
+ import { TXEPublicTreesDB } from '../util/txe_public_dbs.js';
103
108
 
104
109
  export class TXE implements TypedOracle {
105
110
  private blockNumber = 1;
@@ -130,6 +135,8 @@ export class TXE implements TypedOracle {
130
135
 
131
136
  private noteCache: ExecutionNoteCache;
132
137
 
138
+ private authwits: Map<string, AuthWitness> = new Map();
139
+
133
140
  private constructor(
134
141
  private logger: Logger,
135
142
  private keyStore: KeyStore,
@@ -139,7 +146,6 @@ export class TXE implements TypedOracle {
139
146
  private syncDataProvider: SyncDataProvider,
140
147
  private taggingDataProvider: TaggingDataProvider,
141
148
  private addressDataProvider: AddressDataProvider,
142
- private authWitnessDataProvider: AuthWitnessDataProvider,
143
149
  private accountDataProvider: TXEAccountDataProvider,
144
150
  private executionCache: HashedValuesCache,
145
151
  private contractAddress: AztecAddress,
@@ -162,7 +168,6 @@ export class TXE implements TypedOracle {
162
168
  this.syncDataProvider,
163
169
  this.taggingDataProvider,
164
170
  this.addressDataProvider,
165
- this.authWitnessDataProvider,
166
171
  this.logger,
167
172
  );
168
173
  }
@@ -173,7 +178,6 @@ export class TXE implements TypedOracle {
173
178
  const baseFork = await nativeWorldStateService.fork();
174
179
 
175
180
  const addressDataProvider = new AddressDataProvider(store);
176
- const authWitnessDataProvider = new AuthWitnessDataProvider(store);
177
181
  const contractDataProvider = new ContractDataProvider(store);
178
182
  const noteDataProvider = await NoteDataProvider.create(store);
179
183
  const syncDataProvider = new SyncDataProvider(store);
@@ -198,7 +202,6 @@ export class TXE implements TypedOracle {
198
202
  syncDataProvider,
199
203
  taggingDataProvider,
200
204
  addressDataProvider,
201
- authWitnessDataProvider,
202
205
  accountDataProvider,
203
206
  executionCache,
204
207
  await AztecAddress.random(),
@@ -325,7 +328,7 @@ export class TXE implements TypedOracle {
325
328
  const schnorr = new Schnorr();
326
329
  const signature = await schnorr.constructSignature(messageHash.toBuffer(), privateKey);
327
330
  const authWitness = new AuthWitness(messageHash, [...signature.toBuffer()]);
328
- return this.authWitnessDataProvider.addAuthWitness(authWitness.requestHash, authWitness.witness);
331
+ return this.authwits.set(authWitness.requestHash.toString(), authWitness);
329
332
  }
330
333
 
331
334
  async addPublicDataWrites(writes: PublicDataWrite[]) {
@@ -465,7 +468,7 @@ export class TXE implements TypedOracle {
465
468
  return new NullifierMembershipWitness(BigInt(index), leafPreimage as NullifierLeafPreimage, siblingPath);
466
469
  }
467
470
 
468
- async getPublicDataTreeWitness(blockNumber: number, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
471
+ async getPublicDataWitness(blockNumber: number, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
469
472
  const snap = this.nativeWorldStateService.getSnapshot(blockNumber);
470
473
 
471
474
  const lowLeafResult = await snap.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
@@ -538,7 +541,8 @@ export class TXE implements TypedOracle {
538
541
  }
539
542
 
540
543
  getAuthWitness(messageHash: Fr) {
541
- return this.pxeOracleInterface.getAuthWitness(messageHash);
544
+ const authwit = this.authwits.get(messageHash.toString());
545
+ return Promise.resolve(authwit?.witness);
542
546
  }
543
547
 
544
548
  async getNotes(
@@ -752,8 +756,7 @@ export class TXE implements TypedOracle {
752
756
  }
753
757
 
754
758
  await this.node.setTxEffect(blockNumber, new TxHash(new Fr(blockNumber)), txEffect);
755
- this.node.setNullifiersIndexesWithBlock(blockNumber, txEffect.nullifiers);
756
- this.node.addNoteLogsByTags(this.blockNumber, this.privateLogs);
759
+ this.node.addPrivateLogsByTags(this.blockNumber, this.privateLogs);
757
760
  this.node.addPublicLogsByTags(this.blockNumber, this.publicLogs);
758
761
 
759
762
  const stateReference = await fork.getStateReference();
@@ -823,12 +826,11 @@ export class TXE implements TypedOracle {
823
826
 
824
827
  const artifact = await this.contractDataProvider.getFunctionArtifact(targetContractAddress, functionSelector);
825
828
 
826
- const acir = artifact.bytecode;
827
829
  const initialWitness = await this.getInitialWitness(artifact, argsHash, sideEffectCounter, isStaticCall);
828
830
  const acvmCallback = new Oracle(this);
829
831
  const timer = new Timer();
830
832
  const acirExecutionResult = await this.simulationProvider
831
- .executeUserCircuit(acir, initialWitness, acvmCallback)
833
+ .executeUserCircuit(initialWitness, artifact, acvmCallback)
832
834
  .catch((err: Error) => {
833
835
  err.message = resolveAssertionMessageFromError(err, artifact);
834
836
 
@@ -935,12 +937,9 @@ export class TXE implements TypedOracle {
935
937
  // See note at revert below.
936
938
  const checkpoint = await ForkCheckpoint.new(db);
937
939
  try {
938
- const simulator = new PublicTxSimulator(
939
- db,
940
- new TXEWorldStateDB(db, new TXEPublicContractDataSource(this), this),
941
- globalVariables,
942
- /*doMerkleOperations=*/ true,
943
- );
940
+ const treesDB = new TXEPublicTreesDB(db, this);
941
+ const contractsDB = new PublicContractsDB(new TXEPublicContractDataSource(this));
942
+ const simulator = new PublicTxSimulator(treesDB, contractsDB, globalVariables, /*doMerkleOperations=*/ true);
944
943
 
945
944
  const { usedTxRequestHashForNonces } = this.noteCache.finish();
946
945
  const firstNullifier = usedTxRequestHashForNonces
@@ -1088,7 +1087,11 @@ export class TXE implements TypedOracle {
1088
1087
  );
1089
1088
 
1090
1089
  for (const [recipient, taggedLogs] of taggedLogsByRecipient.entries()) {
1091
- await this.pxeOracleInterface.processTaggedLogs(taggedLogs, AztecAddress.fromString(recipient));
1090
+ await this.pxeOracleInterface.processTaggedLogs(
1091
+ this.contractAddress,
1092
+ taggedLogs,
1093
+ AztecAddress.fromString(recipient),
1094
+ );
1092
1095
  }
1093
1096
 
1094
1097
  await this.pxeOracleInterface.removeNullifiedNotes(this.contractAddress);
@@ -1096,17 +1099,26 @@ export class TXE implements TypedOracle {
1096
1099
  return Promise.resolve();
1097
1100
  }
1098
1101
 
1099
- deliverNote(
1100
- _contractAddress: AztecAddress,
1101
- _storageSlot: Fr,
1102
- _nonce: Fr,
1103
- _content: Fr[],
1104
- _noteHash: Fr,
1105
- _nullifier: Fr,
1106
- _txHash: Fr,
1107
- _recipient: AztecAddress,
1102
+ public async deliverNote(
1103
+ contractAddress: AztecAddress,
1104
+ storageSlot: Fr,
1105
+ nonce: Fr,
1106
+ content: Fr[],
1107
+ noteHash: Fr,
1108
+ nullifier: Fr,
1109
+ txHash: Fr,
1110
+ recipient: AztecAddress,
1108
1111
  ): Promise<void> {
1109
- throw new Error('deliverNote');
1112
+ await this.pxeOracleInterface.deliverNote(
1113
+ contractAddress,
1114
+ storageSlot,
1115
+ nonce,
1116
+ content,
1117
+ noteHash,
1118
+ nullifier,
1119
+ txHash,
1120
+ recipient,
1121
+ );
1110
1122
  }
1111
1123
 
1112
1124
  async getLogByTag(tag: Fr): Promise<LogWithTxData | null> {
@@ -1240,4 +1252,8 @@ export class TXE implements TypedOracle {
1240
1252
  const aes128 = new Aes128();
1241
1253
  return aes128.decryptBufferCBC(ciphertext, iv, symKey);
1242
1254
  }
1255
+
1256
+ getSharedSecret(address: AztecAddress, ephPk: Point): Promise<Point> {
1257
+ return this.pxeOracleInterface.getSharedSecret(address, ephPk);
1258
+ }
1243
1259
  }