@aztec/txe 0.0.1-commit.03f7ef2 → 0.0.1-commit.08c5969dc

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.
Files changed (73) hide show
  1. package/dest/constants.d.ts +3 -0
  2. package/dest/constants.d.ts.map +1 -0
  3. package/dest/constants.js +2 -0
  4. package/dest/oracle/interfaces.d.ts +3 -3
  5. package/dest/oracle/interfaces.d.ts.map +1 -1
  6. package/dest/oracle/txe_oracle_public_context.d.ts +3 -3
  7. package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
  8. package/dest/oracle/txe_oracle_public_context.js +6 -6
  9. package/dest/oracle/txe_oracle_top_level_context.d.ts +17 -14
  10. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
  11. package/dest/oracle/txe_oracle_top_level_context.js +144 -67
  12. package/dest/rpc_translator.d.ts +19 -13
  13. package/dest/rpc_translator.d.ts.map +1 -1
  14. package/dest/rpc_translator.js +75 -50
  15. package/dest/state_machine/archiver.d.ts +20 -67
  16. package/dest/state_machine/archiver.d.ts.map +1 -1
  17. package/dest/state_machine/archiver.js +59 -178
  18. package/dest/state_machine/dummy_p2p_client.d.ts +16 -12
  19. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
  20. package/dest/state_machine/dummy_p2p_client.js +32 -20
  21. package/dest/state_machine/global_variable_builder.d.ts +2 -2
  22. package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
  23. package/dest/state_machine/global_variable_builder.js +1 -1
  24. package/dest/state_machine/index.d.ts +6 -6
  25. package/dest/state_machine/index.d.ts.map +1 -1
  26. package/dest/state_machine/index.js +36 -13
  27. package/dest/state_machine/mock_epoch_cache.d.ts +9 -6
  28. package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
  29. package/dest/state_machine/mock_epoch_cache.js +14 -7
  30. package/dest/state_machine/synchronizer.d.ts +3 -3
  31. package/dest/state_machine/synchronizer.d.ts.map +1 -1
  32. package/dest/txe_session.d.ts +17 -14
  33. package/dest/txe_session.d.ts.map +1 -1
  34. package/dest/txe_session.js +144 -49
  35. package/dest/util/encoding.d.ts +17 -17
  36. package/dest/util/txe_account_store.d.ts +10 -0
  37. package/dest/util/txe_account_store.d.ts.map +1 -0
  38. package/dest/util/{txe_account_data_provider.js → txe_account_store.js} +1 -1
  39. package/dest/util/txe_contract_store.d.ts +12 -0
  40. package/dest/util/txe_contract_store.d.ts.map +1 -0
  41. package/dest/util/{txe_contract_data_provider.js → txe_contract_store.js} +3 -3
  42. package/dest/util/txe_public_contract_data_source.d.ts +4 -4
  43. package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
  44. package/dest/util/txe_public_contract_data_source.js +10 -10
  45. package/dest/utils/block_creation.d.ts +4 -4
  46. package/dest/utils/block_creation.d.ts.map +1 -1
  47. package/dest/utils/block_creation.js +18 -5
  48. package/dest/utils/tx_effect_creation.d.ts +2 -3
  49. package/dest/utils/tx_effect_creation.d.ts.map +1 -1
  50. package/dest/utils/tx_effect_creation.js +3 -6
  51. package/package.json +16 -16
  52. package/src/constants.ts +3 -0
  53. package/src/index.ts +1 -1
  54. package/src/oracle/interfaces.ts +2 -2
  55. package/src/oracle/txe_oracle_public_context.ts +6 -8
  56. package/src/oracle/txe_oracle_top_level_context.ts +171 -108
  57. package/src/rpc_translator.ts +78 -52
  58. package/src/state_machine/archiver.ts +54 -220
  59. package/src/state_machine/dummy_p2p_client.ts +45 -26
  60. package/src/state_machine/global_variable_builder.ts +1 -1
  61. package/src/state_machine/index.ts +49 -12
  62. package/src/state_machine/mock_epoch_cache.ts +15 -11
  63. package/src/state_machine/synchronizer.ts +2 -2
  64. package/src/txe_session.ts +188 -109
  65. package/src/util/{txe_account_data_provider.ts → txe_account_store.ts} +1 -1
  66. package/src/util/{txe_contract_data_provider.ts → txe_contract_store.ts} +3 -3
  67. package/src/util/txe_public_contract_data_source.ts +9 -9
  68. package/src/utils/block_creation.ts +19 -16
  69. package/src/utils/tx_effect_creation.ts +3 -11
  70. package/dest/util/txe_account_data_provider.d.ts +0 -10
  71. package/dest/util/txe_account_data_provider.d.ts.map +0 -1
  72. package/dest/util/txe_contract_data_provider.d.ts +0 -12
  73. package/dest/util/txe_contract_data_provider.d.ts.map +0 -1
@@ -1,6 +1,5 @@
1
1
  import { BlockNumber } from '@aztec/foundation/branded-types';
2
- import { Fr } from '@aztec/foundation/curves/bn254';
3
2
  import type { ExecutionNoteCache } from '@aztec/pxe/simulator';
4
3
  import { TxEffect } from '@aztec/stdlib/tx';
5
- export declare function makeTxEffect(noteCache: ExecutionNoteCache, protocolNullifier: Fr, txBlockNumber: BlockNumber): Promise<TxEffect>;
6
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhfZWZmZWN0X2NyZWF0aW9uLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbHMvdHhfZWZmZWN0X2NyZWF0aW9uLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUM5RCxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDcEQsT0FBTyxLQUFLLEVBQUUsa0JBQWtCLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUUvRCxPQUFPLEVBQUUsUUFBUSxFQUFVLE1BQU0sa0JBQWtCLENBQUM7QUFFcEQsd0JBQXNCLFlBQVksQ0FDaEMsU0FBUyxFQUFFLGtCQUFrQixFQUM3QixpQkFBaUIsRUFBRSxFQUFFLEVBQ3JCLGFBQWEsRUFBRSxXQUFXLEdBQ3pCLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0EyQm5CIn0=
4
+ export declare function makeTxEffect(noteCache: ExecutionNoteCache, txBlockNumber: BlockNumber): Promise<TxEffect>;
5
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhfZWZmZWN0X2NyZWF0aW9uLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbHMvdHhfZWZmZWN0X2NyZWF0aW9uLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUU5RCxPQUFPLEtBQUssRUFBRSxrQkFBa0IsRUFBRSxNQUFNLHNCQUFzQixDQUFDO0FBRS9ELE9BQU8sRUFBRSxRQUFRLEVBQVUsTUFBTSxrQkFBa0IsQ0FBQztBQUVwRCx3QkFBc0IsWUFBWSxDQUFDLFNBQVMsRUFBRSxrQkFBa0IsRUFBRSxhQUFhLEVBQUUsV0FBVyxHQUFHLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0F1Qi9HIn0=
@@ -1 +1 @@
1
- {"version":3,"file":"tx_effect_creation.d.ts","sourceRoot":"","sources":["../../src/utils/tx_effect_creation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,OAAO,EAAE,QAAQ,EAAU,MAAM,kBAAkB,CAAC;AAEpD,wBAAsB,YAAY,CAChC,SAAS,EAAE,kBAAkB,EAC7B,iBAAiB,EAAE,EAAE,EACrB,aAAa,EAAE,WAAW,GACzB,OAAO,CAAC,QAAQ,CAAC,CA2BnB"}
1
+ {"version":3,"file":"tx_effect_creation.d.ts","sourceRoot":"","sources":["../../src/utils/tx_effect_creation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,OAAO,EAAE,QAAQ,EAAU,MAAM,kBAAkB,CAAC;AAEpD,wBAAsB,YAAY,CAAC,SAAS,EAAE,kBAAkB,EAAE,aAAa,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAuB/G"}
@@ -1,16 +1,13 @@
1
1
  import { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash } from '@aztec/stdlib/hash';
3
3
  import { TxEffect, TxHash } from '@aztec/stdlib/tx';
4
- export async function makeTxEffect(noteCache, protocolNullifier, txBlockNumber) {
4
+ export async function makeTxEffect(noteCache, txBlockNumber) {
5
5
  const txEffect = TxEffect.empty();
6
- const { usedProtocolNullifierForNonces } = noteCache.finish();
7
- const nonceGenerator = usedProtocolNullifierForNonces ? protocolNullifier : noteCache.getAllNullifiers()[0];
6
+ noteCache.finish();
7
+ const nonceGenerator = noteCache.getNonceGenerator();
8
8
  txEffect.noteHashes = await Promise.all(noteCache.getAllNotes().map(async (pendingNote, i)=>computeUniqueNoteHash(await computeNoteHashNonce(nonceGenerator, i), await siloNoteHash(pendingNote.note.contractAddress, pendingNote.noteHashForConsumption))));
9
9
  // Nullifiers are already siloed
10
10
  txEffect.nullifiers = noteCache.getAllNullifiers();
11
- if (usedProtocolNullifierForNonces) {
12
- txEffect.nullifiers.unshift(protocolNullifier);
13
- }
14
11
  txEffect.txHash = new TxHash(new Fr(txBlockNumber));
15
12
  return txEffect;
16
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/txe",
3
- "version": "0.0.1-commit.03f7ef2",
3
+ "version": "0.0.1-commit.08c5969dc",
4
4
  "type": "module",
5
5
  "exports": "./dest/index.js",
6
6
  "bin": "./dest/bin/index.js",
@@ -61,27 +61,27 @@
61
61
  ]
62
62
  },
63
63
  "dependencies": {
64
- "@aztec/accounts": "0.0.1-commit.03f7ef2",
65
- "@aztec/archiver": "0.0.1-commit.03f7ef2",
66
- "@aztec/aztec-node": "0.0.1-commit.03f7ef2",
67
- "@aztec/aztec.js": "0.0.1-commit.03f7ef2",
68
- "@aztec/bb-prover": "0.0.1-commit.03f7ef2",
69
- "@aztec/constants": "0.0.1-commit.03f7ef2",
70
- "@aztec/foundation": "0.0.1-commit.03f7ef2",
71
- "@aztec/key-store": "0.0.1-commit.03f7ef2",
72
- "@aztec/kv-store": "0.0.1-commit.03f7ef2",
73
- "@aztec/protocol-contracts": "0.0.1-commit.03f7ef2",
74
- "@aztec/pxe": "0.0.1-commit.03f7ef2",
75
- "@aztec/simulator": "0.0.1-commit.03f7ef2",
76
- "@aztec/stdlib": "0.0.1-commit.03f7ef2",
77
- "@aztec/world-state": "0.0.1-commit.03f7ef2",
64
+ "@aztec/accounts": "0.0.1-commit.08c5969dc",
65
+ "@aztec/archiver": "0.0.1-commit.08c5969dc",
66
+ "@aztec/aztec-node": "0.0.1-commit.08c5969dc",
67
+ "@aztec/aztec.js": "0.0.1-commit.08c5969dc",
68
+ "@aztec/bb-prover": "0.0.1-commit.08c5969dc",
69
+ "@aztec/constants": "0.0.1-commit.08c5969dc",
70
+ "@aztec/foundation": "0.0.1-commit.08c5969dc",
71
+ "@aztec/key-store": "0.0.1-commit.08c5969dc",
72
+ "@aztec/kv-store": "0.0.1-commit.08c5969dc",
73
+ "@aztec/protocol-contracts": "0.0.1-commit.08c5969dc",
74
+ "@aztec/pxe": "0.0.1-commit.08c5969dc",
75
+ "@aztec/simulator": "0.0.1-commit.08c5969dc",
76
+ "@aztec/stdlib": "0.0.1-commit.08c5969dc",
77
+ "@aztec/world-state": "0.0.1-commit.08c5969dc",
78
78
  "zod": "^3.23.8"
79
79
  },
80
80
  "devDependencies": {
81
81
  "@jest/globals": "^30.0.0",
82
82
  "@types/jest": "^30.0.0",
83
83
  "@types/node": "^22.15.17",
84
- "@typescript/native-preview": "7.0.0-dev.20251126.1",
84
+ "@typescript/native-preview": "7.0.0-dev.20260113.1",
85
85
  "jest": "^30.0.0",
86
86
  "jest-mock-extended": "^4.0.0",
87
87
  "ts-node": "^10.9.1",
@@ -0,0 +1,3 @@
1
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
2
+
3
+ export const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
package/src/index.ts CHANGED
@@ -33,7 +33,7 @@ import {
33
33
  fromSingle,
34
34
  toSingle,
35
35
  } from './util/encoding.js';
36
- import type { ContractArtifactWithHash } from './util/txe_contract_data_provider.js';
36
+ import type { ContractArtifactWithHash } from './util/txe_contract_store.js';
37
37
 
38
38
  const sessions = new Map<number, TXESession>();
39
39
 
@@ -33,9 +33,9 @@ export interface IAvmExecutionOracle {
33
33
  avmOpcodeVersion(): Promise<Fr>;
34
34
  avmOpcodeEmitNullifier(nullifier: Fr): Promise<void>;
35
35
  avmOpcodeEmitNoteHash(noteHash: Fr): Promise<void>;
36
- avmOpcodeNullifierExists(innerNullifier: Fr, targetAddress: AztecAddress): Promise<boolean>;
36
+ avmOpcodeNullifierExists(siloedNullifier: Fr): Promise<boolean>;
37
37
  avmOpcodeStorageWrite(slot: Fr, value: Fr): Promise<void>;
38
- avmOpcodeStorageRead(slot: Fr): Promise<Fr>;
38
+ avmOpcodeStorageRead(slot: Fr, contractAddress: AztecAddress): Promise<Fr>;
39
39
  }
40
40
 
41
41
  /**
@@ -78,13 +78,11 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
78
78
  this.transientUniqueNoteHashes.push(siloedNoteHash);
79
79
  }
80
80
 
81
- async avmOpcodeNullifierExists(innerNullifier: Fr, targetAddress: AztecAddress): Promise<boolean> {
82
- const nullifier = await siloNullifier(targetAddress, innerNullifier!);
83
-
81
+ async avmOpcodeNullifierExists(siloedNullifier: Fr): Promise<boolean> {
84
82
  const treeIndex = (
85
- await this.forkedWorldTrees.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, [nullifier.toBuffer()])
83
+ await this.forkedWorldTrees.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, [siloedNullifier.toBuffer()])
86
84
  )[0];
87
- const transientIndex = this.transientSiloedNullifiers.find(n => n.equals(nullifier));
85
+ const transientIndex = this.transientSiloedNullifiers.find(n => n.equals(siloedNullifier));
88
86
 
89
87
  return treeIndex !== undefined || transientIndex !== undefined;
90
88
  }
@@ -101,8 +99,8 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
101
99
  ]);
102
100
  }
103
101
 
104
- async avmOpcodeStorageRead(slot: Fr): Promise<Fr> {
105
- const leafSlot = await computePublicDataTreeLeafSlot(this.contractAddress, slot);
102
+ async avmOpcodeStorageRead(slot: Fr, contractAddress: AztecAddress): Promise<Fr> {
103
+ const leafSlot = await computePublicDataTreeLeafSlot(contractAddress, slot);
106
104
 
107
105
  const lowLeafResult = await this.forkedWorldTrees.getPreviousValueIndex(
108
106
  MerkleTreeId.PUBLIC_DATA_TREE,
@@ -119,7 +117,7 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
119
117
  )) as PublicDataTreeLeafPreimage
120
118
  ).leaf.value;
121
119
 
122
- this.logger.debug('AVM storage read', { slot, value });
120
+ this.logger.debug('AVM storage read', { slot, contractAddress, value });
123
121
 
124
122
  return value;
125
123
  }
@@ -13,13 +13,14 @@ import { LogLevels, type Logger, applyStringFormatting, createLogger } from '@az
13
13
  import { TestDateProvider } from '@aztec/foundation/timer';
14
14
  import type { KeyStore } from '@aztec/key-store';
15
15
  import {
16
- AddressDataProvider,
17
- CapsuleDataProvider,
18
- NoteDataProvider,
16
+ AddressStore,
17
+ CapsuleStore,
18
+ NoteStore,
19
19
  ORACLE_VERSION,
20
- PrivateEventDataProvider,
21
- RecipientTaggingDataProvider,
22
- SenderTaggingDataProvider,
20
+ PrivateEventStore,
21
+ RecipientTaggingStore,
22
+ SenderAddressBookStore,
23
+ SenderTaggingStore,
23
24
  enrichPublicSimulationError,
24
25
  } from '@aztec/pxe/server';
25
26
  import {
@@ -48,7 +49,7 @@ import {
48
49
  PublicContractsDB,
49
50
  PublicProcessor,
50
51
  } from '@aztec/simulator/server';
51
- import { type ContractArtifact, EventSelector, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
52
+ import { type ContractArtifact, EventSelector, FunctionCall, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
52
53
  import { AuthWitness } from '@aztec/stdlib/auth-witness';
53
54
  import { PublicSimulatorConfig } from '@aztec/stdlib/avm';
54
55
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
@@ -79,10 +80,10 @@ import {
79
80
  import type { UInt64 } from '@aztec/stdlib/types';
80
81
  import { ForkCheckpoint } from '@aztec/world-state';
81
82
 
83
+ import { DEFAULT_ADDRESS } from '../constants.js';
82
84
  import type { TXEStateMachine } from '../state_machine/index.js';
83
- import { DEFAULT_ADDRESS } from '../txe_session.js';
84
- import type { TXEAccountDataProvider } from '../util/txe_account_data_provider.js';
85
- import type { TXEContractDataProvider } from '../util/txe_contract_data_provider.js';
85
+ import type { TXEAccountStore } from '../util/txe_account_store.js';
86
+ import type { TXEContractStore } from '../util/txe_contract_store.js';
86
87
  import { TXEPublicContractDataSource } from '../util/txe_public_contract_data_source.js';
87
88
  import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from '../utils/block_creation.js';
88
89
  import type { ITxeExecutionOracle } from './interfaces.js';
@@ -95,15 +96,17 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
95
96
 
96
97
  constructor(
97
98
  private stateMachine: TXEStateMachine,
98
- private contractDataProvider: TXEContractDataProvider,
99
- private noteDataProvider: NoteDataProvider,
99
+ private contractStore: TXEContractStore,
100
+ private noteStore: NoteStore,
100
101
  private keyStore: KeyStore,
101
- private addressDataProvider: AddressDataProvider,
102
- private accountDataProvider: TXEAccountDataProvider,
103
- private senderTaggingDataProvider: SenderTaggingDataProvider,
104
- private recipientTaggingDataProvider: RecipientTaggingDataProvider,
105
- private capsuleDataProvider: CapsuleDataProvider,
106
- private privateEventDataProvider: PrivateEventDataProvider,
102
+ private addressStore: AddressStore,
103
+ private accountStore: TXEAccountStore,
104
+ private senderTaggingStore: SenderTaggingStore,
105
+ private recipientTaggingStore: RecipientTaggingStore,
106
+ private senderAddressBookStore: SenderAddressBookStore,
107
+ private capsuleStore: CapsuleStore,
108
+ private privateEventStore: PrivateEventStore,
109
+ private jobId: string,
107
110
  private nextBlockTimestamp: bigint,
108
111
  private version: Fr,
109
112
  private chainId: Fr,
@@ -128,13 +131,14 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
128
131
  }
129
132
 
130
133
  // We instruct users to debug contracts via this oracle, so it makes sense that they'd expect it to also work in tests
131
- utilityDebugLog(level: number, message: string, fields: Fr[]): void {
134
+ utilityLog(level: number, message: string, fields: Fr[]): Promise<void> {
132
135
  if (!LogLevels[level]) {
133
- throw new Error(`Invalid debug log level: ${level}`);
136
+ throw new Error(`Invalid log level: ${level}`);
134
137
  }
135
138
  const levelName = LogLevels[level];
136
139
 
137
140
  this.logger[levelName](`${applyStringFormatting(message, fields)}`, { module: `${this.logger.module}:debug_log` });
141
+ return Promise.resolve();
138
142
  }
139
143
 
140
144
  txeGetDefaultAddress(): AztecAddress {
@@ -154,7 +158,8 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
154
158
  }
155
159
 
156
160
  async txeGetLastTxEffects() {
157
- const block = await this.stateMachine.archiver.getL2Block('latest');
161
+ const latestBlockNumber = await this.stateMachine.archiver.getBlockNumber();
162
+ const block = await this.stateMachine.archiver.getBlock(latestBlockNumber);
158
163
 
159
164
  if (block!.body.txEffects.length != 1) {
160
165
  // Note that calls like env.mine() will result in blocks with no transactions, hitting this
@@ -168,7 +173,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
168
173
 
169
174
  async txeGetPrivateEvents(selector: EventSelector, contractAddress: AztecAddress, scope: AztecAddress) {
170
175
  return (
171
- await this.privateEventDataProvider.getPrivateEvents(selector, {
176
+ await this.privateEventStore.getPrivateEvents(selector, {
172
177
  contractAddress,
173
178
  scopes: [scope],
174
179
  fromBlock: 0,
@@ -204,8 +209,8 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
204
209
  if (!secret.equals(Fr.ZERO)) {
205
210
  await this.txeAddAccount(artifact, instance, secret);
206
211
  } else {
207
- await this.contractDataProvider.addContractInstance(instance);
208
- await this.contractDataProvider.addContractArtifact(instance.currentContractClassId, artifact);
212
+ await this.contractStore.addContractInstance(instance);
213
+ await this.contractStore.addContractArtifact(instance.currentContractClassId, artifact);
209
214
  this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
210
215
  }
211
216
  }
@@ -214,12 +219,12 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
214
219
  const partialAddress = await computePartialAddress(instance);
215
220
 
216
221
  this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
217
- await this.contractDataProvider.addContractInstance(instance);
218
- await this.contractDataProvider.addContractArtifact(instance.currentContractClassId, artifact);
222
+ await this.contractStore.addContractInstance(instance);
223
+ await this.contractStore.addContractArtifact(instance.currentContractClassId, artifact);
219
224
 
220
225
  const completeAddress = await this.keyStore.addAccount(secret, partialAddress);
221
- await this.accountDataProvider.setAccount(completeAddress.address, completeAddress);
222
- await this.addressDataProvider.addCompleteAddress(completeAddress);
226
+ await this.accountStore.setAccount(completeAddress.address, completeAddress);
227
+ await this.addressStore.addCompleteAddress(completeAddress);
223
228
  this.logger.debug(`Created account ${completeAddress.address}`);
224
229
 
225
230
  return completeAddress;
@@ -228,15 +233,15 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
228
233
  async txeCreateAccount(secret: Fr) {
229
234
  // This is a foot gun !
230
235
  const completeAddress = await this.keyStore.addAccount(secret, secret);
231
- await this.accountDataProvider.setAccount(completeAddress.address, completeAddress);
232
- await this.addressDataProvider.addCompleteAddress(completeAddress);
236
+ await this.accountStore.setAccount(completeAddress.address, completeAddress);
237
+ await this.addressStore.addCompleteAddress(completeAddress);
233
238
  this.logger.debug(`Created account ${completeAddress.address}`);
234
239
 
235
240
  return completeAddress;
236
241
  }
237
242
 
238
243
  async txeAddAuthWitness(address: AztecAddress, messageHash: Fr) {
239
- const account = await this.accountDataProvider.getAccount(address);
244
+ const account = await this.accountStore.getAccount(address);
240
245
  const privateKey = await this.keyStore.getMasterSecretKey(account.publicKeys.masterIncomingViewingPublicKey);
241
246
 
242
247
  const schnorr = new Schnorr();
@@ -281,10 +286,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
281
286
  isStaticCall: boolean = false,
282
287
  ) {
283
288
  this.logger.verbose(
284
- `Executing external function ${await this.contractDataProvider.getDebugFunctionName(targetContractAddress, functionSelector)}@${targetContractAddress} isStaticCall=${isStaticCall}`,
289
+ `Executing external function ${await this.contractStore.getDebugFunctionName(targetContractAddress, functionSelector)}@${targetContractAddress} isStaticCall=${isStaticCall}`,
285
290
  );
286
291
 
287
- const artifact = await this.contractDataProvider.getFunctionArtifact(targetContractAddress, functionSelector);
292
+ const artifact = await this.contractStore.getFunctionArtifact(targetContractAddress, functionSelector);
288
293
  if (!artifact) {
289
294
  const message = functionSelector.equals(await FunctionSelector.fromSignature('verify_private_authwit(Field)'))
290
295
  ? 'Found no account contract artifact for a private authwit check - use `create_contract_account` instead of `create_light_account` for authwit support.'
@@ -292,60 +297,77 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
292
297
  throw new Error(message);
293
298
  }
294
299
 
300
+ // When `from` is the zero address (e.g. when deploying a new account contract), we return an
301
+ // empty scope list which acts as deny-all: no notes are visible and no keys are accessible.
302
+ const effectiveScopes = from.isZero() ? [] : [from];
303
+
304
+ // Sync notes before executing private function to discover notes from previous transactions
305
+ const utilityExecutor = async (call: FunctionCall, execScopes: undefined | AztecAddress[]) => {
306
+ await this.executeUtilityCall(call, execScopes);
307
+ };
308
+
309
+ const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
310
+ await this.stateMachine.contractSyncService.ensureContractSynced(
311
+ targetContractAddress,
312
+ functionSelector,
313
+ utilityExecutor,
314
+ blockHeader,
315
+ this.jobId,
316
+ effectiveScopes,
317
+ );
318
+
295
319
  const blockNumber = await this.txeGetNextBlockNumber();
296
320
 
297
321
  const callContext = new CallContext(from, targetContractAddress, functionSelector, isStaticCall);
298
322
 
299
323
  const gasLimits = new Gas(DEFAULT_DA_GAS_LIMIT, DEFAULT_L2_GAS_LIMIT);
300
-
301
324
  const teardownGasLimits = new Gas(DEFAULT_TEARDOWN_DA_GAS_LIMIT, DEFAULT_TEARDOWN_L2_GAS_LIMIT);
302
-
303
325
  const gasSettings = new GasSettings(gasLimits, teardownGasLimits, GasFees.empty(), GasFees.empty());
304
326
 
305
327
  const txContext = new TxContext(this.chainId, this.version, gasSettings);
306
328
 
307
- const blockHeader = await this.stateMachine.anchorBlockDataProvider.getBlockHeader();
308
-
309
329
  const protocolNullifier = await computeProtocolNullifier(getSingleTxBlockRequestHash(blockNumber));
310
330
  const noteCache = new ExecutionNoteCache(protocolNullifier);
331
+ // In production, the account contract sets the min revertible counter before calling the app function.
332
+ // Since TXE bypasses the account contract, we simulate this by setting minRevertibleSideEffectCounter to 1,
333
+ // marking all side effects as revertible.
334
+ const minRevertibleSideEffectCounter = 1;
335
+ await noteCache.setMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter);
311
336
  const taggingIndexCache = new ExecutionTaggingIndexCache();
312
337
 
313
338
  const simulator = new WASMSimulator();
314
339
 
315
- const privateExecutionOracle = new PrivateExecutionOracle(
340
+ const privateExecutionOracle = new PrivateExecutionOracle({
316
341
  argsHash,
317
342
  txContext,
318
343
  callContext,
319
- /** Header of a block whose state is used during private execution (not the block the transaction is included in). */
320
- blockHeader,
321
- /** List of transient auth witnesses to be used during this simulation */
322
- Array.from(this.authwits.values()),
323
- /** List of transient auth witnesses to be used during this simulation */
324
- [],
325
- HashedValuesCache.create([new HashedValues(args, argsHash)]),
344
+ anchorBlockHeader: blockHeader,
345
+ utilityExecutor,
346
+ authWitnesses: Array.from(this.authwits.values()),
347
+ capsules: [],
348
+ executionCache: HashedValuesCache.create([new HashedValues(args, argsHash)]),
326
349
  noteCache,
327
350
  taggingIndexCache,
328
- this.contractDataProvider,
329
- this.noteDataProvider,
330
- this.keyStore,
331
- this.addressDataProvider,
332
- this.stateMachine.node,
333
- this.stateMachine.anchorBlockDataProvider,
334
- this.senderTaggingDataProvider,
335
- this.recipientTaggingDataProvider,
336
- this.capsuleDataProvider,
337
- this.privateEventDataProvider,
338
- 0,
339
- 1,
340
- undefined, // log
341
- undefined, // scopes
342
- /**
343
- * In TXE, the typical transaction entrypoint is skipped, so we need to simulate the actions that such a
344
- * contract would perform, including setting senderForTags.
345
- */
346
- from,
351
+ contractStore: this.contractStore,
352
+ noteStore: this.noteStore,
353
+ keyStore: this.keyStore,
354
+ addressStore: this.addressStore,
355
+ aztecNode: this.stateMachine.node,
356
+ senderTaggingStore: this.senderTaggingStore,
357
+ recipientTaggingStore: this.recipientTaggingStore,
358
+ senderAddressBookStore: this.senderAddressBookStore,
359
+ capsuleStore: this.capsuleStore,
360
+ privateEventStore: this.privateEventStore,
361
+ contractSyncService: this.stateMachine.contractSyncService,
362
+ jobId: this.jobId,
363
+ totalPublicCalldataCount: 0,
364
+ sideEffectCounter: minRevertibleSideEffectCounter,
365
+ scopes: effectiveScopes,
366
+ // In TXE, the typical transaction entrypoint is skipped, so we need to simulate the actions that such a
367
+ // contract would perform, including setting senderForTags.
368
+ senderForTags: from,
347
369
  simulator,
348
- );
370
+ });
349
371
 
350
372
  // Note: This is a slight modification of simulator.run without any of the checks. Maybe we should modify simulator.run with a boolean value to skip checks.
351
373
  let result: PrivateExecutionResult;
@@ -372,19 +394,22 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
372
394
  }),
373
395
  );
374
396
 
375
- // TXE's top level context does not track side effect counters, and as such, minRevertibleSideEffectCounter is always 0.
376
- // This has the unfortunate consequence of always producing revertible nullifiers, which means we
377
- // must set the firstNullifierHint to Fr.ZERO so the txRequestHash is always used as nonce generator
378
- result = new PrivateExecutionResult(executionResult, Fr.ZERO, publicFunctionsCalldata);
397
+ noteCache.finish();
398
+ const nonceGenerator = noteCache.getNonceGenerator();
399
+ result = new PrivateExecutionResult(executionResult, nonceGenerator, publicFunctionsCalldata);
379
400
  } catch (err) {
380
401
  throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during private execution'));
381
402
  }
382
403
 
383
- // According to the protocol rules, the nonce generator for the note hashes
384
- // can either be the first nullifier in the tx or the hash of the initial tx request
385
- // if there are none.
386
- const nonceGenerator = result.firstNullifier.equals(Fr.ZERO) ? protocolNullifier : result.firstNullifier;
387
- const { publicInputs } = await generateSimulatedProvingResult(result, nonceGenerator, this.contractDataProvider);
404
+ // According to the protocol rules, there must be at least one nullifier in the tx. The first nullifier is used as
405
+ // the nonce generator for the note hashes.
406
+ // We pass the non-zero minRevertibleSideEffectCounter to make sure the side effects are split correctly.
407
+ const { publicInputs } = await generateSimulatedProvingResult(
408
+ result,
409
+ (addr, sel) => this.contractStore.getDebugFunctionName(addr, sel),
410
+ this.stateMachine.node,
411
+ minRevertibleSideEffectCounter,
412
+ );
388
413
 
389
414
  const globals = makeGlobalVariables();
390
415
  globals.blockNumber = blockNumber;
@@ -395,7 +420,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
395
420
 
396
421
  const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
397
422
 
398
- const contractsDB = new PublicContractsDB(new TXEPublicContractDataSource(blockNumber, this.contractDataProvider));
423
+ const bindings = this.logger.getBindings();
424
+ const contractsDB = new PublicContractsDB(
425
+ new TXEPublicContractDataSource(blockNumber, this.contractStore),
426
+ bindings,
427
+ );
399
428
  const guardedMerkleTrees = new GuardedMerkleTreeOperations(forkedWorldTrees);
400
429
  const config = PublicSimulatorConfig.from({
401
430
  skipFeeEnforcement: true,
@@ -408,8 +437,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
408
437
  globals,
409
438
  guardedMerkleTrees,
410
439
  contractsDB,
411
- new CppPublicTxSimulator(guardedMerkleTrees, contractsDB, globals, config),
440
+ new CppPublicTxSimulator(guardedMerkleTrees, contractsDB, globals, config, bindings),
412
441
  new TestDateProvider(),
442
+ undefined,
443
+ createLogger('simulator:public-processor', bindings),
413
444
  );
414
445
 
415
446
  const tx = await Tx.create({
@@ -434,7 +465,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
434
465
  } else if (!processedTx.revertCode.isOK()) {
435
466
  if (processedTx.revertReason) {
436
467
  try {
437
- await enrichPublicSimulationError(processedTx.revertReason, this.contractDataProvider, this.logger);
468
+ await enrichPublicSimulationError(processedTx.revertReason, this.contractStore, this.logger);
438
469
  // eslint-disable-next-line no-empty
439
470
  } catch {}
440
471
  throw new Error(`Contract execution has reverted: ${processedTx.revertReason.getMessage()}`);
@@ -479,7 +510,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
479
510
  isStaticCall: boolean,
480
511
  ) {
481
512
  this.logger.verbose(
482
- `Executing public function ${await this.contractDataProvider.getDebugFunctionName(targetContractAddress, FunctionSelector.fromField(calldata[0]))}@${targetContractAddress} isStaticCall=${isStaticCall}`,
513
+ `Executing public function ${await this.contractStore.getDebugFunctionName(targetContractAddress, FunctionSelector.fromField(calldata[0]))}@${targetContractAddress} isStaticCall=${isStaticCall}`,
483
514
  );
484
515
 
485
516
  const blockNumber = await this.txeGetNextBlockNumber();
@@ -492,7 +523,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
492
523
 
493
524
  const txContext = new TxContext(this.chainId, this.version, gasSettings);
494
525
 
495
- const anchorBlockHeader = await this.stateMachine.anchorBlockDataProvider.getBlockHeader();
526
+ const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
496
527
 
497
528
  const calldataHash = await computeCalldataHash(calldata);
498
529
  const calldataHashedValues = new HashedValues(calldata, calldataHash);
@@ -506,7 +537,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
506
537
 
507
538
  const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
508
539
 
509
- const contractsDB = new PublicContractsDB(new TXEPublicContractDataSource(blockNumber, this.contractDataProvider));
540
+ const bindings2 = this.logger.getBindings();
541
+ const contractsDB = new PublicContractsDB(
542
+ new TXEPublicContractDataSource(blockNumber, this.contractStore),
543
+ bindings2,
544
+ );
510
545
  const guardedMerkleTrees = new GuardedMerkleTreeOperations(forkedWorldTrees);
511
546
  const config = PublicSimulatorConfig.from({
512
547
  skipFeeEnforcement: true,
@@ -515,8 +550,16 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
515
550
  collectStatistics: false,
516
551
  collectCallMetadata: true,
517
552
  });
518
- const simulator = new CppPublicTxSimulator(guardedMerkleTrees, contractsDB, globals, config);
519
- const processor = new PublicProcessor(globals, guardedMerkleTrees, contractsDB, simulator, new TestDateProvider());
553
+ const simulator = new CppPublicTxSimulator(guardedMerkleTrees, contractsDB, globals, config, bindings2);
554
+ const processor = new PublicProcessor(
555
+ globals,
556
+ guardedMerkleTrees,
557
+ contractsDB,
558
+ simulator,
559
+ new TestDateProvider(),
560
+ undefined,
561
+ createLogger('simulator:public-processor', bindings2),
562
+ );
520
563
 
521
564
  // We're simulating a scenario in which private execution immediately enqueues a public call and halts. The private
522
565
  // kernel init would in this case inject a nullifier with the transaction request hash as a non-revertible
@@ -574,7 +617,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
574
617
  } else if (!processedTx.revertCode.isOK()) {
575
618
  if (processedTx.revertReason) {
576
619
  try {
577
- await enrichPublicSimulationError(processedTx.revertReason, this.contractDataProvider, this.logger);
620
+ await enrichPublicSimulationError(processedTx.revertReason, this.contractStore, this.logger);
578
621
  // eslint-disable-next-line no-empty
579
622
  } catch {}
580
623
  throw new Error(`Contract execution has reverted: ${processedTx.revertReason.getMessage()}`);
@@ -620,21 +663,40 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
620
663
  functionSelector: FunctionSelector,
621
664
  args: Fr[],
622
665
  ) {
623
- const artifact = await this.contractDataProvider.getFunctionArtifact(targetContractAddress, functionSelector);
666
+ const artifact = await this.contractStore.getFunctionArtifact(targetContractAddress, functionSelector);
624
667
  if (!artifact) {
625
668
  throw new Error(`Cannot call ${functionSelector} as there is no artifact found at ${targetContractAddress}.`);
626
669
  }
627
670
 
628
- const call = {
671
+ // Sync notes before executing utility function to discover notes from previous transactions
672
+ const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
673
+ await this.stateMachine.contractSyncService.ensureContractSynced(
674
+ targetContractAddress,
675
+ functionSelector,
676
+ async (call, execScopes) => {
677
+ await this.executeUtilityCall(call, execScopes);
678
+ },
679
+ blockHeader,
680
+ this.jobId,
681
+ undefined,
682
+ );
683
+
684
+ const call = FunctionCall.from({
629
685
  name: artifact.name,
630
- selector: functionSelector,
631
686
  to: targetContractAddress,
632
- };
687
+ selector: functionSelector,
688
+ type: FunctionType.UTILITY,
689
+ hideMsgSender: false,
690
+ isStatic: false,
691
+ args,
692
+ returnTypes: [],
693
+ });
633
694
 
634
- const entryPointArtifact = await this.contractDataProvider.getFunctionArtifactWithDebugMetadata(
635
- call.to,
636
- call.selector,
637
- );
695
+ return this.executeUtilityCall(call, undefined);
696
+ }
697
+
698
+ private async executeUtilityCall(call: FunctionCall, scopes: undefined | AztecAddress[]): Promise<Fr[]> {
699
+ const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
638
700
  if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
639
701
  throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
640
702
  }
@@ -645,25 +707,26 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
645
707
  });
646
708
 
647
709
  try {
648
- const anchorBlockHeader = await this.stateMachine.anchorBlockDataProvider.getBlockHeader();
649
- const oracle = new UtilityExecutionOracle(
650
- call.to,
651
- [],
652
- [],
710
+ const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
711
+ const oracle = new UtilityExecutionOracle({
712
+ contractAddress: call.to,
713
+ authWitnesses: [],
714
+ capsules: [],
653
715
  anchorBlockHeader,
654
- this.contractDataProvider,
655
- this.noteDataProvider,
656
- this.keyStore,
657
- this.addressDataProvider,
658
- this.stateMachine.node,
659
- this.stateMachine.anchorBlockDataProvider,
660
- this.senderTaggingDataProvider,
661
- this.recipientTaggingDataProvider,
662
- this.capsuleDataProvider,
663
- this.privateEventDataProvider,
664
- );
716
+ contractStore: this.contractStore,
717
+ noteStore: this.noteStore,
718
+ keyStore: this.keyStore,
719
+ addressStore: this.addressStore,
720
+ aztecNode: this.stateMachine.node,
721
+ recipientTaggingStore: this.recipientTaggingStore,
722
+ senderAddressBookStore: this.senderAddressBookStore,
723
+ capsuleStore: this.capsuleStore,
724
+ privateEventStore: this.privateEventStore,
725
+ jobId: this.jobId,
726
+ scopes,
727
+ });
665
728
  const acirExecutionResult = await new WASMSimulator()
666
- .executeUserCircuit(toACVMWitness(0, args), entryPointArtifact, new Oracle(oracle).toACIRCallback())
729
+ .executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback())
667
730
  .catch((err: Error) => {
668
731
  err.message = resolveAssertionMessageFromError(err, entryPointArtifact);
669
732
  throw new ExecutionError(