@aztec/simulator 1.0.0-nightly.20250708 → 1.0.0-nightly.20250710

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 (36) hide show
  1. package/dest/public/avm/fixtures/base_avm_simulation_tester.js +2 -2
  2. package/dest/public/avm/fixtures/utils.js +2 -2
  3. package/dest/public/avm/opcodes/comparators.js +1 -1
  4. package/dest/public/avm/opcodes/misc.js +1 -1
  5. package/dest/public/fixtures/minimal_public_tx.d.ts.map +1 -1
  6. package/dest/public/fixtures/minimal_public_tx.js +1 -1
  7. package/dest/public/fixtures/utils.js +6 -6
  8. package/dest/public/public_db_sources.js +4 -4
  9. package/dest/public/public_processor/public_processor.js +3 -3
  10. package/dest/public/public_processor/public_processor_metrics.d.ts +2 -2
  11. package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -1
  12. package/dest/public/public_processor/public_processor_metrics.js +1 -1
  13. package/dest/public/public_tx_simulator/apps_tests/amm_test.js +4 -4
  14. package/dest/public/public_tx_simulator/apps_tests/token_test.d.ts +1 -1
  15. package/dest/public/public_tx_simulator/apps_tests/token_test.d.ts.map +1 -1
  16. package/dest/public/public_tx_simulator/apps_tests/token_test.js +2 -2
  17. package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
  18. package/dest/public/public_tx_simulator/public_tx_context.js +3 -2
  19. package/dest/public/side_effect_trace.d.ts.map +1 -1
  20. package/dest/public/side_effect_trace.js +17 -11
  21. package/dest/public/state_manager/state_manager.js +4 -4
  22. package/package.json +15 -15
  23. package/src/public/avm/fixtures/base_avm_simulation_tester.ts +2 -2
  24. package/src/public/avm/fixtures/utils.ts +2 -2
  25. package/src/public/avm/opcodes/comparators.ts +1 -1
  26. package/src/public/avm/opcodes/misc.ts +1 -1
  27. package/src/public/fixtures/minimal_public_tx.ts +2 -0
  28. package/src/public/fixtures/utils.ts +8 -8
  29. package/src/public/public_db_sources.ts +7 -7
  30. package/src/public/public_processor/public_processor.ts +7 -7
  31. package/src/public/public_processor/public_processor_metrics.ts +2 -2
  32. package/src/public/public_tx_simulator/apps_tests/amm_test.ts +4 -4
  33. package/src/public/public_tx_simulator/apps_tests/token_test.ts +2 -2
  34. package/src/public/public_tx_simulator/public_tx_context.ts +10 -9
  35. package/src/public/side_effect_trace.ts +29 -23
  36. package/src/public/state_manager/state_manager.ts +6 -6
@@ -1,4 +1,4 @@
1
- import { DEPLOYER_CONTRACT_ADDRESS } from '@aztec/constants';
1
+ import { CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS } from '@aztec/constants';
2
2
  import { Fr } from '@aztec/foundation/fields';
3
3
  import { createLogger } from '@aztec/foundation/log';
4
4
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
@@ -70,7 +70,7 @@ import { createContractClassAndInstance } from './utils.js';
70
70
  await this.contractDataSource.addContractInstance(contractInstance);
71
71
  }
72
72
  async insertContractAddressNullifier(contractAddress) {
73
- const contractAddressNullifier = await siloNullifier(AztecAddress.fromNumber(DEPLOYER_CONTRACT_ADDRESS), contractAddress.toField());
73
+ const contractAddressNullifier = await siloNullifier(AztecAddress.fromNumber(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS), contractAddress.toField());
74
74
  await this.merkleTrees.sequentialInsert(MerkleTreeId.NULLIFIER_TREE, [
75
75
  contractAddressNullifier.toBuffer()
76
76
  ]);
@@ -1,4 +1,4 @@
1
- import { DEPLOYER_CONTRACT_ADDRESS } from '@aztec/constants';
1
+ import { CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS } from '@aztec/constants';
2
2
  import { Fr } from '@aztec/foundation/fields';
3
3
  import { FunctionSelector, getAllFunctionAbis } from '@aztec/stdlib/abi';
4
4
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
@@ -86,7 +86,7 @@ export function resolveContractAssertionMessage(functionName, revertReason, outp
86
86
  currentClassId: contractClass.id,
87
87
  publicKeys
88
88
  });
89
- const contractAddressNullifier = await siloNullifier(AztecAddress.fromNumber(DEPLOYER_CONTRACT_ADDRESS), contractInstance.address.toField());
89
+ const contractAddressNullifier = await siloNullifier(AztecAddress.fromNumber(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS), contractInstance.address.toField());
90
90
  return {
91
91
  contractClass,
92
92
  contractInstance,
@@ -13,7 +13,7 @@ class ComparatorInstruction extends ThreeOperandInstruction {
13
13
  this.dstOffset
14
14
  ];
15
15
  const [aOffset, bOffset, dstOffset] = addressing.resolve(operands, memory);
16
- memory.checkTagsAreSame(aOffset, bOffset);
16
+ memory.checkTagsAreSame(aOffset, bOffset); // Brillig semantic enforces that tags match.
17
17
  const a = memory.get(aOffset);
18
18
  const b = memory.get(bOffset);
19
19
  const dest = new Uint1(this.compare(a, b) ? 1 : 0);
@@ -34,11 +34,11 @@ export class DebugLog extends Instruction {
34
34
  this.fieldsSizeOffset
35
35
  ];
36
36
  const [messageOffset, fieldsOffset, fieldsSizeOffset] = addressing.resolve(operands, memory);
37
- memory.checkTag(TypeTag.UINT32, fieldsSizeOffset);
38
37
  // DebugLog is a no-op except when doing client-initiated simulation with debug logging enabled.
39
38
  // Note that we still do address resolution and basic tag-checking (above)
40
39
  // To avoid a special-case in the witness generator and circuit.
41
40
  if (context.environment.clientInitiatedSimulation && DebugLog.logger.isLevelEnabled('verbose')) {
41
+ memory.checkTag(TypeTag.UINT32, fieldsSizeOffset);
42
42
  const fieldsSize = memory.get(fieldsSizeOffset).toNumber();
43
43
  const rawMessage = memory.getSlice(messageOffset, this.messageSize);
44
44
  const fields = memory.getSlice(fieldsOffset, fieldsSize);
@@ -1 +1 @@
1
- {"version":3,"file":"minimal_public_tx.d.ts","sourceRoot":"","sources":["../../../src/public/fixtures/minimal_public_tx.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAQrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+CAA+C,CAAC;AAGpF,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,cAAc,CAAC,CAoCxE;AAED;;;GAGG;AACH,wBAAgB,oCAAoC,IAAI,gBAAgB,CAEvE"}
1
+ {"version":3,"file":"minimal_public_tx.d.ts","sourceRoot":"","sources":["../../../src/public/fixtures/minimal_public_tx.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAQrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+CAA+C,CAAC;AAGpF,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,cAAc,CAAC,CAsCxE;AAED;;;GAGG;AACH,wBAAgB,oCAAoC,IAAI,gBAAgB,CAEvE"}
@@ -33,7 +33,7 @@ export async function createAvmMinimalPublicTx() {
33
33
  fnName: 'public_dispatch',
34
34
  args: []
35
35
  }
36
- ]);
36
+ ], /*teardownCall=*/ undefined, /*feePayer=*/ deployer);
37
37
  }
38
38
  /**
39
39
  * Reads the AVM circuit inputs for the minimal public tx from a pre-generated JSON file.
@@ -1,7 +1,7 @@
1
- import { DEFAULT_GAS_LIMIT, DEPLOYER_CONTRACT_ADDRESS, MAX_L2_GAS_PER_TX_PUBLIC_PORTION, PRIVATE_LOG_SIZE_IN_FIELDS, REGISTERER_CONTRACT_ADDRESS, REGISTERER_CONTRACT_CLASS_REGISTERED_MAGIC_VALUE } from '@aztec/constants';
1
+ import { CONTRACT_CLASS_PUBLISHED_MAGIC_VALUE, CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS, CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS, DEFAULT_GAS_LIMIT, MAX_L2_GAS_PER_TX_PUBLIC_PORTION, PRIVATE_LOG_SIZE_IN_FIELDS } from '@aztec/constants';
2
2
  import { padArrayEnd } from '@aztec/foundation/collection';
3
3
  import { Fr } from '@aztec/foundation/fields';
4
- import { DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_TAG } from '@aztec/protocol-contracts';
4
+ import { CONTRACT_INSTANCE_PUBLISHED_EVENT_TAG } from '@aztec/protocol-contracts';
5
5
  import { bufferAsFields } from '@aztec/stdlib/abi';
6
6
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
7
7
  import { Gas, GasFees, GasSettings } from '@aztec/stdlib/gas';
@@ -88,14 +88,14 @@ export function createTxForPrivateOnly(feePayer = AztecAddress.zero(), gasUsedBy
88
88
  }
89
89
  export async function addNewContractClassToTx(tx, contractClass, skipNullifierInsertion = false) {
90
90
  const contractClassLogFields = [
91
- new Fr(REGISTERER_CONTRACT_CLASS_REGISTERED_MAGIC_VALUE),
91
+ new Fr(CONTRACT_CLASS_PUBLISHED_MAGIC_VALUE),
92
92
  contractClass.id,
93
93
  new Fr(contractClass.version),
94
94
  new Fr(contractClass.artifactHash),
95
95
  new Fr(contractClass.privateFunctionsRoot),
96
96
  ...bufferAsFields(contractClass.packedBytecode, Math.ceil(contractClass.packedBytecode.length / 31) + 1)
97
97
  ];
98
- const contractAddress = new AztecAddress(new Fr(REGISTERER_CONTRACT_ADDRESS));
98
+ const contractAddress = new AztecAddress(new Fr(CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS));
99
99
  const emittedLength = contractClassLogFields.length;
100
100
  const logFields = ContractClassLogFields.fromEmittedFields(contractClassLogFields);
101
101
  const contractClassLogHash = LogHash.from({
@@ -125,7 +125,7 @@ export async function addNewContractInstanceToTx(tx, contractInstance, skipNulli
125
125
  contractInstance.publicKeys.masterTaggingPublicKey.y
126
126
  ];
127
127
  const logFields = [
128
- DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_TAG,
128
+ CONTRACT_INSTANCE_PUBLISHED_EVENT_TAG,
129
129
  contractInstance.address.toField(),
130
130
  new Fr(contractInstance.version),
131
131
  new Fr(contractInstance.salt),
@@ -135,7 +135,7 @@ export async function addNewContractInstanceToTx(tx, contractInstance, skipNulli
135
135
  contractInstance.deployer.toField()
136
136
  ];
137
137
  const contractInstanceLog = new PrivateLog(padArrayEnd(logFields, Fr.ZERO, PRIVATE_LOG_SIZE_IN_FIELDS), logFields.length);
138
- const contractAddressNullifier = await siloNullifier(AztecAddress.fromNumber(DEPLOYER_CONTRACT_ADDRESS), contractInstance.address.toField());
138
+ const contractAddressNullifier = await siloNullifier(AztecAddress.fromNumber(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS), contractInstance.address.toField());
139
139
  const accumulatedData = tx.data.forPublic ? tx.data.forPublic.revertibleAccumulatedData : tx.data.forRollup.end;
140
140
  if (!skipNullifierInsertion) {
141
141
  const nextNullifierIndex = countAccumulatedItems(accumulatedData.nullifiers);
@@ -2,8 +2,8 @@ import { NULLIFIER_SUBTREE_HEIGHT, PUBLIC_DATA_SUBTREE_HEIGHT } from '@aztec/con
2
2
  import { Fr } from '@aztec/foundation/fields';
3
3
  import { createLogger } from '@aztec/foundation/log';
4
4
  import { Timer } from '@aztec/foundation/timer';
5
- import { ContractClassRegisteredEvent } from '@aztec/protocol-contracts/class-registerer';
6
- import { ContractInstanceDeployedEvent } from '@aztec/protocol-contracts/instance-deployer';
5
+ import { ContractClassPublishedEvent } from '@aztec/protocol-contracts/class-registry';
6
+ import { ContractInstancePublishedEvent } from '@aztec/protocol-contracts/instance-registry';
7
7
  import { PublicDataWrite } from '@aztec/stdlib/avm';
8
8
  import { computePublicBytecodeCommitment } from '@aztec/stdlib/contract';
9
9
  import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
@@ -99,7 +99,7 @@ import { TxContractCache } from './tx_contract_cache.js';
99
99
  * @param cache - The cache to store the contract classes in
100
100
  * @param cacheType - Type of cache (for logging)
101
101
  */ async addContractClassesFromLogs(siloedContractClassLogs, cache, cacheType) {
102
- const contractClassEvents = siloedContractClassLogs.filter((log)=>ContractClassRegisteredEvent.isContractClassRegisteredEvent(log)).map((log)=>ContractClassRegisteredEvent.fromLog(log));
102
+ const contractClassEvents = siloedContractClassLogs.filter((log)=>ContractClassPublishedEvent.isContractClassPublishedEvent(log)).map((log)=>ContractClassPublishedEvent.fromLog(log));
103
103
  // Cache contract classes
104
104
  await Promise.all(contractClassEvents.map(async (event)=>{
105
105
  this.log.debug(`Adding class ${event.contractClassId.toString()} to contract's ${cacheType} tx cache`);
@@ -113,7 +113,7 @@ import { TxContractCache } from './tx_contract_cache.js';
113
113
  * @param cache - The cache to store the contract instances in
114
114
  * @param cacheType - Type of cache (for logging)
115
115
  */ addContractInstancesFromLogs(contractInstanceLogs, cache, cacheType) {
116
- const contractInstanceEvents = contractInstanceLogs.filter((log)=>ContractInstanceDeployedEvent.isContractInstanceDeployedEvent(log)).map((log)=>ContractInstanceDeployedEvent.fromLog(log));
116
+ const contractInstanceEvents = contractInstanceLogs.filter((log)=>ContractInstancePublishedEvent.isContractInstancePublishedEvent(log)).map((log)=>ContractInstancePublishedEvent.fromLog(log));
117
117
  // Cache contract instances
118
118
  contractInstanceEvents.forEach((e)=>{
119
119
  this.log.debug(`Adding instance ${e.address.toString()} with class ${e.contractClassId.toString()} to ${cacheType} tx contract cache`);
@@ -11,7 +11,7 @@ import { createLogger } from '@aztec/foundation/log';
11
11
  import { sleep } from '@aztec/foundation/sleep';
12
12
  import { DateProvider, Timer, elapsed, executeTimeout } from '@aztec/foundation/timer';
13
13
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
14
- import { ContractClassRegisteredEvent } from '@aztec/protocol-contracts/class-registerer';
14
+ import { ContractClassPublishedEvent } from '@aztec/protocol-contracts/class-registry';
15
15
  import { computeFeePayerBalanceLeafSlot, computeFeePayerBalanceStorageSlot } from '@aztec/protocol-contracts/fee-juice';
16
16
  import { PublicDataWrite } from '@aztec/stdlib/avm';
17
17
  import { Gas } from '@aztec/stdlib/gas';
@@ -331,7 +331,7 @@ class PublicProcessorTimeoutError extends Error {
331
331
  const transactionFee = tx.data.gasUsed.computeFee(gasFees);
332
332
  const feePaymentPublicDataWrite = await this.performFeePaymentPublicDataWrite(transactionFee, tx.data.feePayer);
333
333
  const processedTx = await makeProcessedTxFromPrivateOnlyTx(tx, transactionFee, feePaymentPublicDataWrite, this.globalVariables);
334
- this.metrics.recordClassRegistration(...tx.getContractClassLogs().filter((log)=>ContractClassRegisteredEvent.isContractClassRegisteredEvent(log)).map((log)=>ContractClassRegisteredEvent.fromLog(log)));
334
+ this.metrics.recordClassPublication(...tx.getContractClassLogs().filter((log)=>ContractClassPublishedEvent.isContractClassPublishedEvent(log)).map((log)=>ContractClassPublishedEvent.fromLog(log)));
335
335
  // Fee payment insertion has already been done. Do the rest.
336
336
  await this.doTreeInsertionsForPrivateOnlyTx(processedTx);
337
337
  // Add any contracts registered/deployed in this private-only tx to the block-level cache
@@ -358,7 +358,7 @@ class PublicProcessorTimeoutError extends Error {
358
358
  }
359
359
  });
360
360
  const contractClassLogs = revertCode.isOK() ? tx.getContractClassLogs() : tx.getSplitContractClassLogs(false);
361
- this.metrics.recordClassRegistration(...contractClassLogs.filter((log)=>ContractClassRegisteredEvent.isContractClassRegisteredEvent(log)).map((log)=>ContractClassRegisteredEvent.fromLog(log)));
361
+ this.metrics.recordClassPublication(...contractClassLogs.filter((log)=>ContractClassPublishedEvent.isContractClassPublishedEvent(log)).map((log)=>ContractClassPublishedEvent.fromLog(log)));
362
362
  const phaseCount = processedPhases.length;
363
363
  const durationMs = timer.ms();
364
364
  this.metrics.recordTx(phaseCount, durationMs, gasUsed.publicGas);
@@ -1,4 +1,4 @@
1
- import type { ContractClassRegisteredEvent } from '@aztec/protocol-contracts/class-registerer';
1
+ import type { ContractClassPublishedEvent } from '@aztec/protocol-contracts/class-registry';
2
2
  import type { Gas } from '@aztec/stdlib/gas';
3
3
  import type { TxExecutionPhase } from '@aztec/stdlib/tx';
4
4
  import { type TelemetryClient, type Tracer } from '@aztec/telemetry-client';
@@ -21,7 +21,7 @@ export declare class PublicProcessorMetrics {
21
21
  recordAllTxs(totalGas: Gas, gasRate: number): void;
22
22
  recordFailedTx(): void;
23
23
  recordRevertedPhase(phaseName: TxExecutionPhase): void;
24
- recordClassRegistration(...events: ContractClassRegisteredEvent[]): void;
24
+ recordClassPublication(...events: ContractClassPublishedEvent[]): void;
25
25
  recordTreeInsertions(durationUs: number): void;
26
26
  }
27
27
  //# sourceMappingURL=public_processor_metrics.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"public_processor_metrics.d.ts","sourceRoot":"","sources":["../../../src/public/public_processor/public_processor_metrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,4CAA4C,CAAC;AAC/F,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAKL,KAAK,eAAe,EACpB,KAAK,MAAM,EAGZ,MAAM,yBAAyB,CAAC;AAEjC,qBAAa,sBAAsB;IACjC,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B,OAAO,CAAC,UAAU,CAAY;IAC9B,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,YAAY,CAAgB;IAEpC,OAAO,CAAC,aAAa,CAAY;IACjC,OAAO,CAAC,UAAU,CAAgB;IAElC,OAAO,CAAC,gBAAgB,CAAY;IACpC,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,iBAAiB,CAAY;IACrC,OAAO,CAAC,OAAO,CAAY;IAC3B,OAAO,CAAC,KAAK,CAAY;IAEzB,OAAO,CAAC,qBAAqB,CAAY;gBAE7B,MAAM,EAAE,eAAe,EAAE,IAAI,SAAoB;IA4D7D,mBAAmB,CAAC,SAAS,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM;IAKnE,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG;IAc7D,YAAY,CAAC,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM;IAkB3C,cAAc;IAMd,mBAAmB,CAAC,SAAS,EAAE,gBAAgB;IAI/C,uBAAuB,CAAC,GAAG,MAAM,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MAAM;CAGxC"}
@@ -110,7 +110,7 @@ export class PublicProcessorMetrics {
110
110
  [Attributes.OK]: false
111
111
  });
112
112
  }
113
- recordClassRegistration(...events) {
113
+ recordClassPublication(...events) {
114
114
  let totalBytecode = 0;
115
115
  for (const event of events){
116
116
  totalBytecode += event.packedPublicBytecode.length;
@@ -3,7 +3,7 @@ import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto';
3
3
  import { Fr } from '@aztec/foundation/fields';
4
4
  import { AMMContractArtifact } from '@aztec/noir-contracts.js/AMM';
5
5
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
6
- import { deployToken } from './token_test.js';
6
+ import { setUpToken } from './token_test.js';
7
7
  const INITIAL_TOKEN_BALANCE = 1_000_000_000n;
8
8
  /**
9
9
  * THIS TEST IS BRITTLE! If it breaks, don't try fixing it.
@@ -14,9 +14,9 @@ const INITIAL_TOKEN_BALANCE = 1_000_000_000n;
14
14
  const admin = AztecAddress.fromNumber(42);
15
15
  const sender = AztecAddress.fromNumber(111);
16
16
  logger.debug(`Deploying tokens`);
17
- const token0 = await deployToken(tester, admin, /*seed=*/ 0);
18
- const token1 = await deployToken(tester, admin, /*seed=*/ 1);
19
- const liquidityToken = await deployToken(tester, admin, /*seed=*/ 2);
17
+ const token0 = await setUpToken(tester, admin, /*seed=*/ 0);
18
+ const token1 = await setUpToken(tester, admin, /*seed=*/ 1);
19
+ const liquidityToken = await setUpToken(tester, admin, /*seed=*/ 2);
20
20
  logger.debug(`Deploying AMM`);
21
21
  const constructorArgs = [
22
22
  token0,
@@ -3,5 +3,5 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
3
3
  import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
4
4
  import { PublicTxSimulationTester } from '../../fixtures/public_tx_simulation_tester.js';
5
5
  export declare function tokenTest(tester: PublicTxSimulationTester, logger: Logger): Promise<void>;
6
- export declare function deployToken(tester: PublicTxSimulationTester, admin: AztecAddress, seed?: number): Promise<ContractInstanceWithAddress>;
6
+ export declare function setUpToken(tester: PublicTxSimulationTester, admin: AztecAddress, seed?: number): Promise<ContractInstanceWithAddress>;
7
7
  //# sourceMappingURL=token_test.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"token_test.d.ts","sourceRoot":"","sources":["../../../../src/public/public_tx_simulator/apps_tests/token_test.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAE1E,OAAO,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AAEzF,wBAAsB,SAAS,CAAC,MAAM,EAAE,wBAAwB,EAAE,MAAM,EAAE,MAAM,iBA4E/E;AAED,wBAAsB,WAAW,CAAC,MAAM,EAAE,wBAAwB,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,SAAI,wCAwBhG"}
1
+ {"version":3,"file":"token_test.d.ts","sourceRoot":"","sources":["../../../../src/public/public_tx_simulator/apps_tests/token_test.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAE1E,OAAO,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AAEzF,wBAAsB,SAAS,CAAC,MAAM,EAAE,wBAAwB,EAAE,MAAM,EAAE,MAAM,iBA4E/E;AAED,wBAAsB,UAAU,CAAC,MAAM,EAAE,wBAAwB,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,SAAI,wCAwB/F"}
@@ -6,7 +6,7 @@ export async function tokenTest(tester, logger) {
6
6
  const admin = AztecAddress.fromNumber(42);
7
7
  const sender = AztecAddress.fromNumber(111);
8
8
  const receiver = AztecAddress.fromNumber(222);
9
- const token = await deployToken(tester, admin);
9
+ const token = await setUpToken(tester, admin);
10
10
  const mintAmount = 100n;
11
11
  const mintResult = await tester.simulateTxWithLabel(/*txLabel=*/ 'Token/mint_to_public', /*sender=*/ admin, /*setupCalls=*/ [], /*appCalls=*/ [
12
12
  {
@@ -64,7 +64,7 @@ export async function tokenTest(tester, logger) {
64
64
  const endTime = performance.now();
65
65
  logger.info(`TokenContract public tx simulator test took ${endTime - startTime}ms\n`);
66
66
  }
67
- export async function deployToken(tester, admin, seed = 0) {
67
+ export async function setUpToken(tester, admin, seed = 0) {
68
68
  const constructorArgs = [
69
69
  admin,
70
70
  /*name=*/ 'Token',
@@ -1 +1 @@
1
- {"version":3,"file":"public_tx_context.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/public_tx_context.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EAGL,sBAAsB,EAEtB,UAAU,EAEX,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EAAE,GAAG,EAAe,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAGL,8BAA8B,EAI/B,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EACL,KAAK,eAAe,EACpB,6BAA6B,EAE7B,KAAK,EAAE,EACP,gBAAgB,EAChB,KAAK,MAAM,EACZ,MAAM,kBAAkB,CAAC;AAK1B,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,6BAA6B,EAAE,MAAM,mCAAmC,CAAC;AAGlF;;GAEG;AACH,qBAAa,eAAe;aAeR,MAAM,EAAE,MAAM;aACd,KAAK,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SAAK;IA0BnG;;;OAGG;IACH,kBAAkB,IAAI,UAAU;IAKhC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO;IAW1C;;OAEG;IACH,uBAAuB,CAAC,KAAK,EAAE,gBAAgB,GAAG,6BAA6B,EAAE;IAWjF;;OAEG;IACH,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,GAAG,GAAG;IAU/C;;OAEG;IACH,UAAU,CAAC,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,GAAG;IAQ5C;;;OAGG;IACH,eAAe,IAAI,GAAG;IAItB;;;;;OAKG;IACH,gBAAgB,IAAI,GAAG;IAOvB;;;OAGG;IACH,sBAAsB,IAAI,GAAG;IAK7B;;;OAGG;IACH,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,GAAG,EAAE;IAQ9C;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAa/B;;OAEG;IACU,8BAA8B,IAAI,OAAO,CAAC,sBAAsB,CAAC;CAuH/E;AAED;;;;;;;;;GASG;AACH,cAAM,iBAAiB;IAKT,OAAO,CAAC,QAAQ,CAAC,cAAc;IAJ3C,OAAO,CAAC,GAAG,CAAS;IAEpB,OAAO,CAAC,2BAA2B,CAA4C;gBAElD,cAAc,EAAE,6BAA6B;IAIpE,IAAI;IAMV,qBAAqB;IAIrB,QAAQ;IAIF,gBAAgB;IAQhB,kBAAkB;CAOzB"}
@@ -237,6 +237,8 @@ import { getCallRequestsWithCalldataByPhase } from '../utils.js';
237
237
  }
238
238
  return Array.from(squashedPublicDataWrites.entries()).map(([slot, value])=>new PublicDataWrite(new Fr(slot), value));
239
239
  })();
240
+ // Count before padding.
241
+ const accumulatedDataArrayLengths = new AvmAccumulatedDataArrayLengths(avmNoteHashes.length, avmNullifiers.length, avmL2ToL1Msgs.length, finalPublicLogs.length, finalPublicDataWrites.length);
240
242
  const accumulatedData = new AvmAccumulatedData(/*noteHashes=*/ padArrayEnd(avmNoteHashes.map((n)=>n.value), Fr.zero(), MAX_NOTE_HASHES_PER_TX), /*nullifiers=*/ padArrayEnd(avmNullifiers.map((n)=>n.value), Fr.zero(), MAX_NULLIFIERS_PER_TX), /*l2ToL1Msgs=*/ padArrayEnd(avmL2ToL1Msgs, ScopedL2ToL1Message.empty(), MAX_L2_TO_L1_MSGS_PER_TX), /*publicLogs=*/ padArrayEnd(finalPublicLogs, PublicLog.empty(), MAX_PUBLIC_LOGS_PER_TX), /*publicDataWrites=*/ padArrayEnd(finalPublicDataWrites, PublicDataWrite.empty(), MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX));
241
243
  // Now we finally have enough information to pad the trees.
242
244
  // NOTE(fcarreiro): a bit weird that a method that generates the PIs does this,
@@ -249,8 +251,7 @@ import { getCallRequestsWithCalldataByPhase } from '../utils.js';
249
251
  // This converts the private accumulated data to the avm accumulated data format.
250
252
  const convertAccumulatedData = (from)=>new PrivateToAvmAccumulatedData(from.noteHashes, from.nullifiers, from.l2ToL1Msgs);
251
253
  const getPreviousAccumulatedDataArrayLengths = (from)=>new PrivateToAvmAccumulatedDataArrayLengths(countAccumulatedItems(from.noteHashes), countAccumulatedItems(from.nullifiers), countAccumulatedItems(from.l2ToL1Msgs));
252
- const getAvmAccumulatedDataArrayLengths = (from)=>new AvmAccumulatedDataArrayLengths(from.noteHashes.length, from.nullifiers.length, from.l2ToL1Msgs.length, from.publicLogs.length, from.publicDataWrites.length);
253
- return new AvmCircuitPublicInputs(this.globalVariables, this.startTreeSnapshots, /*startGasUsed=*/ this.gasUsedByPrivate, this.clampedGasSettings, computeEffectiveGasFees(this.globalVariables.gasFees, this.gasSettings), this.feePayer, /*publicCallRequestArrayLengths=*/ new PublicCallRequestArrayLengths(this.setupCallRequests.length, this.appLogicCallRequests.length, this.teardownCallRequests.length > 0), /*publicSetupCallRequests=*/ padArrayEnd(this.setupCallRequests.map((r)=>r.request), PublicCallRequest.empty(), MAX_ENQUEUED_CALLS_PER_TX), /*publicAppLogicCallRequests=*/ padArrayEnd(this.appLogicCallRequests.map((r)=>r.request), PublicCallRequest.empty(), MAX_ENQUEUED_CALLS_PER_TX), /*publicTeardownCallRequests=*/ this.teardownCallRequests.length > 0 ? this.teardownCallRequests[0].request : PublicCallRequest.empty(), getPreviousAccumulatedDataArrayLengths(this.nonRevertibleAccumulatedDataFromPrivate), getPreviousAccumulatedDataArrayLengths(this.revertibleAccumulatedDataFromPrivate), convertAccumulatedData(this.nonRevertibleAccumulatedDataFromPrivate), convertAccumulatedData(this.revertibleAccumulatedDataFromPrivate), endTreeSnapshots, this.getTotalGasUsed(), getAvmAccumulatedDataArrayLengths(accumulatedData), accumulatedData, /*transactionFee=*/ this.getTransactionFeeUnsafe(), /*isReverted=*/ !this.revertCode.isOK());
254
+ return new AvmCircuitPublicInputs(this.globalVariables, this.startTreeSnapshots, /*startGasUsed=*/ this.gasUsedByPrivate, this.clampedGasSettings, computeEffectiveGasFees(this.globalVariables.gasFees, this.gasSettings), this.feePayer, /*publicCallRequestArrayLengths=*/ new PublicCallRequestArrayLengths(this.setupCallRequests.length, this.appLogicCallRequests.length, this.teardownCallRequests.length > 0), /*publicSetupCallRequests=*/ padArrayEnd(this.setupCallRequests.map((r)=>r.request), PublicCallRequest.empty(), MAX_ENQUEUED_CALLS_PER_TX), /*publicAppLogicCallRequests=*/ padArrayEnd(this.appLogicCallRequests.map((r)=>r.request), PublicCallRequest.empty(), MAX_ENQUEUED_CALLS_PER_TX), /*publicTeardownCallRequests=*/ this.teardownCallRequests.length > 0 ? this.teardownCallRequests[0].request : PublicCallRequest.empty(), getPreviousAccumulatedDataArrayLengths(this.nonRevertibleAccumulatedDataFromPrivate), getPreviousAccumulatedDataArrayLengths(this.revertibleAccumulatedDataFromPrivate), convertAccumulatedData(this.nonRevertibleAccumulatedDataFromPrivate), convertAccumulatedData(this.revertibleAccumulatedDataFromPrivate), endTreeSnapshots, this.getTotalGasUsed(), accumulatedDataArrayLengths, accumulatedData, /*transactionFee=*/ this.getTransactionFeeUnsafe(), /*isReverted=*/ !this.revertCode.isOK());
254
255
  }
255
256
  }
256
257
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"side_effect_trace.d.ts","sourceRoot":"","sources":["../../src/public/side_effect_trace.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAiB,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAK7E,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AACvF,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD;;;;IAII;AACJ,MAAM,MAAM,WAAW,GAAG;IACxB,gBAAgB,EAAE,uBAAuB,EAAE,CAAC;IAC5C,UAAU,EAAE,QAAQ,EAAE,CAAC;IACvB,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,UAAU,EAAE,mBAAmB,EAAE,CAAC;IAClC,UAAU,EAAE,SAAS,EAAE,CAAC;CACzB,CAAC;AAEF,qBAAa,sBAAsB;aAEf,gBAAgB,EAAE,MAAM;aACxB,wBAAwB,EAAE,MAAM;aAChC,UAAU,EAAE,MAAM;aAClB,UAAU,EAAE,MAAM;aAClB,UAAU,EAAE,MAAM;aAClB,UAAU,EAAE,MAAM;gBALlB,gBAAgB,EAAE,MAAM,EACxB,wBAAwB,EAAE,MAAM,EAChC,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM;IAGpC,MAAM,CAAC,KAAK;CAGb;AAED;;GAEG;AACH,qBAAa,e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e,EAAE,EAAE;IAWrC,qBAAqB,CAAC,eAAe,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE;IAW/E,cAAc,CAAC,eAAe,EAAE,YAAY,EAAE,GAAG,EAAE,EAAE,EAAE;IAcvD,qBAAqB,CAAC,eAAe,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO;IAgB1D,cAAc,IAAI,WAAW;CASrC"}
@@ -74,14 +74,17 @@ export class SideEffectArrayLengths {
74
74
  forkedTrace.alreadyMergedIntoParent = true;
75
75
  this.sideEffectCounter = forkedTrace.sideEffectCounter;
76
76
  this.uniqueClassIds.acceptAndMerge(forkedTrace.uniqueClassIds);
77
- // Accept even if reverted, since the user already paid for the writes
78
- this.writtenPublicDataSlots = new Set(forkedTrace.writtenPublicDataSlots);
79
77
  if (!reverted) {
80
78
  this.publicDataWrites.push(...forkedTrace.publicDataWrites);
81
79
  this.noteHashes.push(...forkedTrace.noteHashes);
82
80
  this.nullifiers.push(...forkedTrace.nullifiers);
83
81
  this.l2ToL1Messages.push(...forkedTrace.l2ToL1Messages);
84
82
  this.publicLogs.push(...forkedTrace.publicLogs);
83
+ this.userPublicDataWritesLength += forkedTrace.userPublicDataWritesLength;
84
+ this.protocolPublicDataWritesLength += forkedTrace.protocolPublicDataWritesLength;
85
+ for (const slot of forkedTrace.writtenPublicDataSlots){
86
+ this.writtenPublicDataSlots.add(slot);
87
+ }
85
88
  }
86
89
  }
87
90
  getCounter() {
@@ -94,16 +97,19 @@ export class SideEffectArrayLengths {
94
97
  return this.previousSideEffectArrayLengths.noteHashes + this.noteHashes.length;
95
98
  }
96
99
  async tracePublicStorageWrite(contractAddress, slot, value, protocolWrite) {
97
- if (protocolWrite) {
98
- if (this.protocolPublicDataWritesLength + this.previousSideEffectArrayLengths.protocolPublicDataWrites >= PROTOCOL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX) {
99
- throw new SideEffectLimitReachedError('protocol public data (contract storage) write', PROTOCOL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX);
100
- }
101
- this.protocolPublicDataWritesLength++;
102
- } else {
103
- if (this.userPublicDataWritesLength + this.previousSideEffectArrayLengths.publicDataWrites >= MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX) {
104
- throw new SideEffectLimitReachedError('public data (contract storage) write', MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX);
100
+ // Only increment counts if the storage slot has not been written to before.
101
+ if (this.isStorageCold(contractAddress, slot)) {
102
+ if (protocolWrite) {
103
+ if (this.protocolPublicDataWritesLength + this.previousSideEffectArrayLengths.protocolPublicDataWrites >= PROTOCOL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX) {
104
+ throw new SideEffectLimitReachedError('protocol public data (contract storage) write', PROTOCOL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX);
105
+ }
106
+ this.protocolPublicDataWritesLength++;
107
+ } else {
108
+ if (this.userPublicDataWritesLength + this.previousSideEffectArrayLengths.publicDataWrites >= MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX) {
109
+ throw new SideEffectLimitReachedError('public data (contract storage) write', MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX);
110
+ }
111
+ this.userPublicDataWritesLength++;
105
112
  }
106
- this.userPublicDataWritesLength++;
107
113
  }
108
114
  const leafSlot = await computePublicDataTreeLeafSlot(contractAddress, slot);
109
115
  this.publicDataWrites.push(new PublicDataUpdateRequest(leafSlot, value, this.sideEffectCounter));
@@ -1,4 +1,4 @@
1
- import { CANONICAL_AUTH_REGISTRY_ADDRESS, DEPLOYER_CONTRACT_ADDRESS, FEE_JUICE_ADDRESS, MULTI_CALL_ENTRYPOINT_ADDRESS, REGISTERER_CONTRACT_ADDRESS, ROUTER_ADDRESS } from '@aztec/constants';
1
+ import { CANONICAL_AUTH_REGISTRY_ADDRESS, CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS, CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS, FEE_JUICE_ADDRESS, MULTI_CALL_ENTRYPOINT_ADDRESS, ROUTER_ADDRESS } from '@aztec/constants';
2
2
  import { poseidon2Hash } from '@aztec/foundation/crypto';
3
3
  import { jsonStringify } from '@aztec/foundation/json-rpc';
4
4
  import { createLogger } from '@aztec/foundation/log';
@@ -253,7 +253,7 @@ import { PublicStorage } from './public_storage.js';
253
253
  return instance;
254
254
  }
255
255
  // This will decide internally whether to check the nullifier tree or not depending on doMerkleOperations.
256
- const nullifierExistsInTree = await this.checkNullifierExists(AztecAddress.fromNumber(DEPLOYER_CONTRACT_ADDRESS), contractAddress.toField());
256
+ const nullifierExistsInTree = await this.checkNullifierExists(AztecAddress.fromNumber(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS), contractAddress.toField());
257
257
  assert(exists == nullifierExistsInTree, `Contract instance for address ${contractAddress} in DB: ${exists} != nullifier tree: ${nullifierExistsInTree}. This is a bug!`);
258
258
  // All that is left is tocheck that the contract updatability information is correct.
259
259
  // That is, that the current and original contract class ids are correct.
@@ -276,7 +276,7 @@ import { PublicStorage } from './public_storage.js';
276
276
  // This is a bit of a leak of information, since the circuit will use it to prove
277
277
  // one public read insted of N of the shared mutable values.
278
278
  const { sharedMutableSlot, sharedMutableHashSlot } = await SharedMutableValuesWithHash.getContractUpdateSlots(instance.address);
279
- const readDeployerStorage = async (storageSlot)=>await this.readStorage(ProtocolContractAddress.ContractInstanceDeployer, storageSlot);
279
+ const readDeployerStorage = async (storageSlot)=>await this.readStorage(ProtocolContractAddress.ContractInstanceRegistry, storageSlot);
280
280
  const hash = await readDeployerStorage(sharedMutableHashSlot);
281
281
  const sharedMutableValues = await SharedMutableValues.readFromTree(sharedMutableSlot, readDeployerStorage);
282
282
  const preImage = sharedMutableValues.toFields();
@@ -345,5 +345,5 @@ import { PublicStorage } from './public_storage.js';
345
345
  }
346
346
  }
347
347
  function contractAddressIsCanonical(contractAddress) {
348
- return contractAddress.equals(AztecAddress.fromNumber(CANONICAL_AUTH_REGISTRY_ADDRESS)) || contractAddress.equals(AztecAddress.fromNumber(DEPLOYER_CONTRACT_ADDRESS)) || contractAddress.equals(AztecAddress.fromNumber(REGISTERER_CONTRACT_ADDRESS)) || contractAddress.equals(AztecAddress.fromNumber(MULTI_CALL_ENTRYPOINT_ADDRESS)) || contractAddress.equals(AztecAddress.fromNumber(FEE_JUICE_ADDRESS)) || contractAddress.equals(AztecAddress.fromNumber(ROUTER_ADDRESS));
348
+ return contractAddress.equals(AztecAddress.fromNumber(CANONICAL_AUTH_REGISTRY_ADDRESS)) || contractAddress.equals(AztecAddress.fromNumber(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS)) || contractAddress.equals(AztecAddress.fromNumber(CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS)) || contractAddress.equals(AztecAddress.fromNumber(MULTI_CALL_ENTRYPOINT_ADDRESS)) || contractAddress.equals(AztecAddress.fromNumber(FEE_JUICE_ADDRESS)) || contractAddress.equals(AztecAddress.fromNumber(ROUTER_ADDRESS));
349
349
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/simulator",
3
- "version": "1.0.0-nightly.20250708",
3
+ "version": "1.0.0-nightly.20250710",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./server": "./dest/server.js",
@@ -62,25 +62,25 @@
62
62
  ]
63
63
  },
64
64
  "dependencies": {
65
- "@aztec/constants": "1.0.0-nightly.20250708",
66
- "@aztec/foundation": "1.0.0-nightly.20250708",
67
- "@aztec/noir-acvm_js": "1.0.0-nightly.20250708",
68
- "@aztec/noir-noirc_abi": "1.0.0-nightly.20250708",
69
- "@aztec/noir-protocol-circuits-types": "1.0.0-nightly.20250708",
70
- "@aztec/noir-types": "1.0.0-nightly.20250708",
71
- "@aztec/protocol-contracts": "1.0.0-nightly.20250708",
72
- "@aztec/stdlib": "1.0.0-nightly.20250708",
73
- "@aztec/telemetry-client": "1.0.0-nightly.20250708",
74
- "@aztec/world-state": "1.0.0-nightly.20250708",
65
+ "@aztec/constants": "1.0.0-nightly.20250710",
66
+ "@aztec/foundation": "1.0.0-nightly.20250710",
67
+ "@aztec/noir-acvm_js": "1.0.0-nightly.20250710",
68
+ "@aztec/noir-noirc_abi": "1.0.0-nightly.20250710",
69
+ "@aztec/noir-protocol-circuits-types": "1.0.0-nightly.20250710",
70
+ "@aztec/noir-types": "1.0.0-nightly.20250710",
71
+ "@aztec/protocol-contracts": "1.0.0-nightly.20250710",
72
+ "@aztec/stdlib": "1.0.0-nightly.20250710",
73
+ "@aztec/telemetry-client": "1.0.0-nightly.20250710",
74
+ "@aztec/world-state": "1.0.0-nightly.20250710",
75
75
  "lodash.clonedeep": "^4.5.0",
76
76
  "lodash.merge": "^4.6.2",
77
77
  "tslib": "^2.4.0"
78
78
  },
79
79
  "devDependencies": {
80
- "@aztec/kv-store": "1.0.0-nightly.20250708",
81
- "@aztec/merkle-tree": "1.0.0-nightly.20250708",
82
- "@aztec/noir-contracts.js": "1.0.0-nightly.20250708",
83
- "@aztec/noir-test-contracts.js": "1.0.0-nightly.20250708",
80
+ "@aztec/kv-store": "1.0.0-nightly.20250710",
81
+ "@aztec/merkle-tree": "1.0.0-nightly.20250710",
82
+ "@aztec/noir-contracts.js": "1.0.0-nightly.20250710",
83
+ "@aztec/noir-test-contracts.js": "1.0.0-nightly.20250710",
84
84
  "@jest/globals": "^30.0.0",
85
85
  "@types/jest": "^30.0.0",
86
86
  "@types/lodash.clonedeep": "^4.5.7",
@@ -1,4 +1,4 @@
1
- import { DEPLOYER_CONTRACT_ADDRESS } from '@aztec/constants';
1
+ import { CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS } from '@aztec/constants';
2
2
  import { Fr } from '@aztec/foundation/fields';
3
3
  import { createLogger } from '@aztec/foundation/log';
4
4
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
@@ -95,7 +95,7 @@ export abstract class BaseAvmSimulationTester {
95
95
 
96
96
  private async insertContractAddressNullifier(contractAddress: AztecAddress) {
97
97
  const contractAddressNullifier = await siloNullifier(
98
- AztecAddress.fromNumber(DEPLOYER_CONTRACT_ADDRESS),
98
+ AztecAddress.fromNumber(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS),
99
99
  contractAddress.toField(),
100
100
  );
101
101
  await this.merkleTrees.sequentialInsert(MerkleTreeId.NULLIFIER_TREE, [contractAddressNullifier.toBuffer()]);
@@ -1,4 +1,4 @@
1
- import { DEPLOYER_CONTRACT_ADDRESS } from '@aztec/constants';
1
+ import { CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS } from '@aztec/constants';
2
2
  import { Fr } from '@aztec/foundation/fields';
3
3
  import {
4
4
  type ContractArtifact,
@@ -141,7 +141,7 @@ export async function createContractClassAndInstance(
141
141
  });
142
142
 
143
143
  const contractAddressNullifier = await siloNullifier(
144
- AztecAddress.fromNumber(DEPLOYER_CONTRACT_ADDRESS),
144
+ AztecAddress.fromNumber(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS),
145
145
  contractInstance.address.toField(),
146
146
  );
147
147
 
@@ -15,7 +15,7 @@ abstract class ComparatorInstruction extends ThreeOperandInstruction {
15
15
 
16
16
  const operands = [this.aOffset, this.bOffset, this.dstOffset];
17
17
  const [aOffset, bOffset, dstOffset] = addressing.resolve(operands, memory);
18
- memory.checkTagsAreSame(aOffset, bOffset);
18
+ memory.checkTagsAreSame(aOffset, bOffset); // Brillig semantic enforces that tags match.
19
19
 
20
20
  const a = memory.get(aOffset);
21
21
  const b = memory.get(bOffset);
@@ -41,12 +41,12 @@ export class DebugLog extends Instruction {
41
41
 
42
42
  const operands = [this.messageOffset, this.fieldsOffset, this.fieldsSizeOffset];
43
43
  const [messageOffset, fieldsOffset, fieldsSizeOffset] = addressing.resolve(operands, memory);
44
- memory.checkTag(TypeTag.UINT32, fieldsSizeOffset);
45
44
 
46
45
  // DebugLog is a no-op except when doing client-initiated simulation with debug logging enabled.
47
46
  // Note that we still do address resolution and basic tag-checking (above)
48
47
  // To avoid a special-case in the witness generator and circuit.
49
48
  if (context.environment.clientInitiatedSimulation && DebugLog.logger.isLevelEnabled('verbose')) {
49
+ memory.checkTag(TypeTag.UINT32, fieldsSizeOffset);
50
50
  const fieldsSize = memory.get(fieldsSizeOffset).toNumber();
51
51
 
52
52
  const rawMessage = memory.getSlice(messageOffset, this.messageSize);
@@ -45,6 +45,8 @@ export async function createAvmMinimalPublicTx(): Promise<PublicTxResult> {
45
45
  args: [],
46
46
  },
47
47
  ],
48
+ /*teardownCall=*/ undefined,
49
+ /*feePayer=*/ deployer,
48
50
  );
49
51
  }
50
52
 
@@ -1,14 +1,14 @@
1
1
  import {
2
+ CONTRACT_CLASS_PUBLISHED_MAGIC_VALUE,
3
+ CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS,
4
+ CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS,
2
5
  DEFAULT_GAS_LIMIT,
3
- DEPLOYER_CONTRACT_ADDRESS,
4
6
  MAX_L2_GAS_PER_TX_PUBLIC_PORTION,
5
7
  PRIVATE_LOG_SIZE_IN_FIELDS,
6
- REGISTERER_CONTRACT_ADDRESS,
7
- REGISTERER_CONTRACT_CLASS_REGISTERED_MAGIC_VALUE,
8
8
  } from '@aztec/constants';
9
9
  import { padArrayEnd } from '@aztec/foundation/collection';
10
10
  import { Fr } from '@aztec/foundation/fields';
11
- import { DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_TAG } from '@aztec/protocol-contracts';
11
+ import { CONTRACT_INSTANCE_PUBLISHED_EVENT_TAG } from '@aztec/protocol-contracts';
12
12
  import { bufferAsFields } from '@aztec/stdlib/abi';
13
13
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
14
14
  import type { ContractClassPublic, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
@@ -164,14 +164,14 @@ export async function addNewContractClassToTx(
164
164
  skipNullifierInsertion = false,
165
165
  ) {
166
166
  const contractClassLogFields = [
167
- new Fr(REGISTERER_CONTRACT_CLASS_REGISTERED_MAGIC_VALUE),
167
+ new Fr(CONTRACT_CLASS_PUBLISHED_MAGIC_VALUE),
168
168
  contractClass.id,
169
169
  new Fr(contractClass.version),
170
170
  new Fr(contractClass.artifactHash),
171
171
  new Fr(contractClass.privateFunctionsRoot),
172
172
  ...bufferAsFields(contractClass.packedBytecode, Math.ceil(contractClass.packedBytecode.length / 31) + 1),
173
173
  ];
174
- const contractAddress = new AztecAddress(new Fr(REGISTERER_CONTRACT_ADDRESS));
174
+ const contractAddress = new AztecAddress(new Fr(CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS));
175
175
  const emittedLength = contractClassLogFields.length;
176
176
  const logFields = ContractClassLogFields.fromEmittedFields(contractClassLogFields);
177
177
 
@@ -210,7 +210,7 @@ export async function addNewContractInstanceToTx(
210
210
  contractInstance.publicKeys.masterTaggingPublicKey.y,
211
211
  ];
212
212
  const logFields = [
213
- DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_TAG,
213
+ CONTRACT_INSTANCE_PUBLISHED_EVENT_TAG,
214
214
  contractInstance.address.toField(),
215
215
  new Fr(contractInstance.version),
216
216
  new Fr(contractInstance.salt),
@@ -225,7 +225,7 @@ export async function addNewContractInstanceToTx(
225
225
  );
226
226
 
227
227
  const contractAddressNullifier = await siloNullifier(
228
- AztecAddress.fromNumber(DEPLOYER_CONTRACT_ADDRESS),
228
+ AztecAddress.fromNumber(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS),
229
229
  contractInstance.address.toField(),
230
230
  );
231
231
 
@@ -2,8 +2,8 @@ import { NULLIFIER_SUBTREE_HEIGHT, PUBLIC_DATA_SUBTREE_HEIGHT } from '@aztec/con
2
2
  import { Fr } from '@aztec/foundation/fields';
3
3
  import { createLogger } from '@aztec/foundation/log';
4
4
  import { Timer } from '@aztec/foundation/timer';
5
- import { ContractClassRegisteredEvent } from '@aztec/protocol-contracts/class-registerer';
6
- import { ContractInstanceDeployedEvent } from '@aztec/protocol-contracts/instance-deployer';
5
+ import { ContractClassPublishedEvent } from '@aztec/protocol-contracts/class-registry';
6
+ import { ContractInstancePublishedEvent } from '@aztec/protocol-contracts/instance-registry';
7
7
  import type { FunctionSelector } from '@aztec/stdlib/abi';
8
8
  import { PublicDataWrite } from '@aztec/stdlib/avm';
9
9
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
@@ -143,12 +143,12 @@ export class PublicContractsDB implements PublicContractsDBInterface {
143
143
  cacheType: string,
144
144
  ) {
145
145
  const contractClassEvents = siloedContractClassLogs
146
- .filter((log: ContractClassLog) => ContractClassRegisteredEvent.isContractClassRegisteredEvent(log))
147
- .map((log: ContractClassLog) => ContractClassRegisteredEvent.fromLog(log));
146
+ .filter((log: ContractClassLog) => ContractClassPublishedEvent.isContractClassPublishedEvent(log))
147
+ .map((log: ContractClassLog) => ContractClassPublishedEvent.fromLog(log));
148
148
 
149
149
  // Cache contract classes
150
150
  await Promise.all(
151
- contractClassEvents.map(async (event: ContractClassRegisteredEvent) => {
151
+ contractClassEvents.map(async (event: ContractClassPublishedEvent) => {
152
152
  this.log.debug(`Adding class ${event.contractClassId.toString()} to contract's ${cacheType} tx cache`);
153
153
  const contractClass = await event.toContractClassPublic();
154
154
 
@@ -165,8 +165,8 @@ export class PublicContractsDB implements PublicContractsDBInterface {
165
165
  */
166
166
  private addContractInstancesFromLogs(contractInstanceLogs: PrivateLog[], cache: TxContractCache, cacheType: string) {
167
167
  const contractInstanceEvents = contractInstanceLogs
168
- .filter(log => ContractInstanceDeployedEvent.isContractInstanceDeployedEvent(log))
169
- .map(log => ContractInstanceDeployedEvent.fromLog(log));
168
+ .filter(log => ContractInstancePublishedEvent.isContractInstancePublishedEvent(log))
169
+ .map(log => ContractInstancePublishedEvent.fromLog(log));
170
170
 
171
171
  // Cache contract instances
172
172
  contractInstanceEvents.forEach(e => {
@@ -5,7 +5,7 @@ import { createLogger } from '@aztec/foundation/log';
5
5
  import { sleep } from '@aztec/foundation/sleep';
6
6
  import { DateProvider, Timer, elapsed, executeTimeout } from '@aztec/foundation/timer';
7
7
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
8
- import { ContractClassRegisteredEvent } from '@aztec/protocol-contracts/class-registerer';
8
+ import { ContractClassPublishedEvent } from '@aztec/protocol-contracts/class-registry';
9
9
  import { computeFeePayerBalanceLeafSlot, computeFeePayerBalanceStorageSlot } from '@aztec/protocol-contracts/fee-juice';
10
10
  import { PublicDataWrite } from '@aztec/stdlib/avm';
11
11
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
@@ -464,11 +464,11 @@ export class PublicProcessor implements Traceable {
464
464
  this.globalVariables,
465
465
  );
466
466
 
467
- this.metrics.recordClassRegistration(
467
+ this.metrics.recordClassPublication(
468
468
  ...tx
469
469
  .getContractClassLogs()
470
- .filter(log => ContractClassRegisteredEvent.isContractClassRegisteredEvent(log))
471
- .map(log => ContractClassRegisteredEvent.fromLog(log)),
470
+ .filter(log => ContractClassPublishedEvent.isContractClassPublishedEvent(log))
471
+ .map(log => ContractClassPublishedEvent.fromLog(log)),
472
472
  );
473
473
 
474
474
  // Fee payment insertion has already been done. Do the rest.
@@ -507,10 +507,10 @@ export class PublicProcessor implements Traceable {
507
507
  const contractClassLogs = revertCode.isOK()
508
508
  ? tx.getContractClassLogs()
509
509
  : tx.getSplitContractClassLogs(false /* revertible */);
510
- this.metrics.recordClassRegistration(
510
+ this.metrics.recordClassPublication(
511
511
  ...contractClassLogs
512
- .filter(log => ContractClassRegisteredEvent.isContractClassRegisteredEvent(log))
513
- .map(log => ContractClassRegisteredEvent.fromLog(log)),
512
+ .filter(log => ContractClassPublishedEvent.isContractClassPublishedEvent(log))
513
+ .map(log => ContractClassPublishedEvent.fromLog(log)),
514
514
  );
515
515
 
516
516
  const phaseCount = processedPhases.length;
@@ -1,4 +1,4 @@
1
- import type { ContractClassRegisteredEvent } from '@aztec/protocol-contracts/class-registerer';
1
+ import type { ContractClassPublishedEvent } from '@aztec/protocol-contracts/class-registry';
2
2
  import type { Gas } from '@aztec/stdlib/gas';
3
3
  import type { TxExecutionPhase } from '@aztec/stdlib/tx';
4
4
  import {
@@ -137,7 +137,7 @@ export class PublicProcessorMetrics {
137
137
  this.phaseCount.add(1, { [Attributes.TX_PHASE_NAME]: phaseName, [Attributes.OK]: false });
138
138
  }
139
139
 
140
- recordClassRegistration(...events: ContractClassRegisteredEvent[]) {
140
+ recordClassPublication(...events: ContractClassPublishedEvent[]) {
141
141
  let totalBytecode = 0;
142
142
  for (const event of events) {
143
143
  totalBytecode += event.packedPublicBytecode.length;
@@ -7,7 +7,7 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
7
7
  import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
8
8
 
9
9
  import { PublicTxSimulationTester } from '../../fixtures/public_tx_simulation_tester.js';
10
- import { deployToken } from './token_test.js';
10
+ import { setUpToken } from './token_test.js';
11
11
 
12
12
  const INITIAL_TOKEN_BALANCE = 1_000_000_000n;
13
13
  /**
@@ -22,9 +22,9 @@ export async function ammTest(tester: PublicTxSimulationTester, logger: Logger)
22
22
  const sender = AztecAddress.fromNumber(111);
23
23
 
24
24
  logger.debug(`Deploying tokens`);
25
- const token0 = await deployToken(tester, admin, /*seed=*/ 0);
26
- const token1 = await deployToken(tester, admin, /*seed=*/ 1);
27
- const liquidityToken = await deployToken(tester, admin, /*seed=*/ 2);
25
+ const token0 = await setUpToken(tester, admin, /*seed=*/ 0);
26
+ const token1 = await setUpToken(tester, admin, /*seed=*/ 1);
27
+ const liquidityToken = await setUpToken(tester, admin, /*seed=*/ 2);
28
28
  logger.debug(`Deploying AMM`);
29
29
  const constructorArgs = [token0, token1, liquidityToken];
30
30
  const amm = await tester.registerAndDeployContract(
@@ -13,7 +13,7 @@ export async function tokenTest(tester: PublicTxSimulationTester, logger: Logger
13
13
  const sender = AztecAddress.fromNumber(111);
14
14
  const receiver = AztecAddress.fromNumber(222);
15
15
 
16
- const token = await deployToken(tester, admin);
16
+ const token = await setUpToken(tester, admin);
17
17
 
18
18
  const mintAmount = 100n;
19
19
  const mintResult = await tester.simulateTxWithLabel(
@@ -84,7 +84,7 @@ export async function tokenTest(tester: PublicTxSimulationTester, logger: Logger
84
84
  logger.info(`TokenContract public tx simulator test took ${endTime - startTime}ms\n`);
85
85
  }
86
86
 
87
- export async function deployToken(tester: PublicTxSimulationTester, admin: AztecAddress, seed = 0) {
87
+ export async function setUpToken(tester: PublicTxSimulationTester, admin: AztecAddress, seed = 0) {
88
88
  const constructorArgs = [admin, /*name=*/ 'Token', /*symbol=*/ 'TOK', /*decimals=*/ new Fr(18)];
89
89
  const token = await tester.registerAndDeployContract(
90
90
  constructorArgs,
@@ -338,6 +338,15 @@ export class PublicTxContext {
338
338
  );
339
339
  })();
340
340
 
341
+ // Count before padding.
342
+ const accumulatedDataArrayLengths = new AvmAccumulatedDataArrayLengths(
343
+ avmNoteHashes.length,
344
+ avmNullifiers.length,
345
+ avmL2ToL1Msgs.length,
346
+ finalPublicLogs.length,
347
+ finalPublicDataWrites.length,
348
+ );
349
+
341
350
  const accumulatedData = new AvmAccumulatedData(
342
351
  /*noteHashes=*/ padArrayEnd(
343
352
  avmNoteHashes.map(n => n.value),
@@ -376,14 +385,6 @@ export class PublicTxContext {
376
385
  countAccumulatedItems(from.nullifiers),
377
386
  countAccumulatedItems(from.l2ToL1Msgs),
378
387
  );
379
- const getAvmAccumulatedDataArrayLengths = (from: AvmAccumulatedData) =>
380
- new AvmAccumulatedDataArrayLengths(
381
- from.noteHashes.length,
382
- from.nullifiers.length,
383
- from.l2ToL1Msgs.length,
384
- from.publicLogs.length,
385
- from.publicDataWrites.length,
386
- );
387
388
 
388
389
  return new AvmCircuitPublicInputs(
389
390
  this.globalVariables,
@@ -416,7 +417,7 @@ export class PublicTxContext {
416
417
  convertAccumulatedData(this.revertibleAccumulatedDataFromPrivate),
417
418
  endTreeSnapshots,
418
419
  this.getTotalGasUsed(),
419
- getAvmAccumulatedDataArrayLengths(accumulatedData),
420
+ accumulatedDataArrayLengths,
420
421
  accumulatedData,
421
422
  /*transactionFee=*/ this.getTransactionFeeUnsafe(),
422
423
  /*isReverted=*/ !this.revertCode.isOK(),
@@ -113,8 +113,6 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
113
113
 
114
114
  this.sideEffectCounter = forkedTrace.sideEffectCounter;
115
115
  this.uniqueClassIds.acceptAndMerge(forkedTrace.uniqueClassIds);
116
- // Accept even if reverted, since the user already paid for the writes
117
- this.writtenPublicDataSlots = new Set(forkedTrace.writtenPublicDataSlots);
118
116
 
119
117
  if (!reverted) {
120
118
  this.publicDataWrites.push(...forkedTrace.publicDataWrites);
@@ -122,6 +120,11 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
122
120
  this.nullifiers.push(...forkedTrace.nullifiers);
123
121
  this.l2ToL1Messages.push(...forkedTrace.l2ToL1Messages);
124
122
  this.publicLogs.push(...forkedTrace.publicLogs);
123
+ this.userPublicDataWritesLength += forkedTrace.userPublicDataWritesLength;
124
+ this.protocolPublicDataWritesLength += forkedTrace.protocolPublicDataWritesLength;
125
+ for (const slot of forkedTrace.writtenPublicDataSlots) {
126
+ this.writtenPublicDataSlots.add(slot);
127
+ }
125
128
  }
126
129
  }
127
130
 
@@ -143,28 +146,31 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
143
146
  value: Fr,
144
147
  protocolWrite: boolean,
145
148
  ): Promise<void> {
146
- if (protocolWrite) {
147
- if (
148
- this.protocolPublicDataWritesLength + this.previousSideEffectArrayLengths.protocolPublicDataWrites >=
149
- PROTOCOL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX
150
- ) {
151
- throw new SideEffectLimitReachedError(
152
- 'protocol public data (contract storage) write',
153
- PROTOCOL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
154
- );
155
- }
156
- this.protocolPublicDataWritesLength++;
157
- } else {
158
- if (
159
- this.userPublicDataWritesLength + this.previousSideEffectArrayLengths.publicDataWrites >=
160
- MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX
161
- ) {
162
- throw new SideEffectLimitReachedError(
163
- 'public data (contract storage) write',
164
- MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
165
- );
149
+ // Only increment counts if the storage slot has not been written to before.
150
+ if (this.isStorageCold(contractAddress, slot)) {
151
+ if (protocolWrite) {
152
+ if (
153
+ this.protocolPublicDataWritesLength + this.previousSideEffectArrayLengths.protocolPublicDataWrites >=
154
+ PROTOCOL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX
155
+ ) {
156
+ throw new SideEffectLimitReachedError(
157
+ 'protocol public data (contract storage) write',
158
+ PROTOCOL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
159
+ );
160
+ }
161
+ this.protocolPublicDataWritesLength++;
162
+ } else {
163
+ if (
164
+ this.userPublicDataWritesLength + this.previousSideEffectArrayLengths.publicDataWrites >=
165
+ MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX
166
+ ) {
167
+ throw new SideEffectLimitReachedError(
168
+ 'public data (contract storage) write',
169
+ MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
170
+ );
171
+ }
172
+ this.userPublicDataWritesLength++;
166
173
  }
167
- this.userPublicDataWritesLength++;
168
174
  }
169
175
 
170
176
  const leafSlot = await computePublicDataTreeLeafSlot(contractAddress, slot);
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  CANONICAL_AUTH_REGISTRY_ADDRESS,
3
- DEPLOYER_CONTRACT_ADDRESS,
3
+ CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS,
4
+ CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS,
4
5
  FEE_JUICE_ADDRESS,
5
6
  MULTI_CALL_ENTRYPOINT_ADDRESS,
6
- REGISTERER_CONTRACT_ADDRESS,
7
7
  ROUTER_ADDRESS,
8
8
  } from '@aztec/constants';
9
9
  import { poseidon2Hash } from '@aztec/foundation/crypto';
@@ -353,7 +353,7 @@ export class PublicPersistableStateManager {
353
353
 
354
354
  // This will decide internally whether to check the nullifier tree or not depending on doMerkleOperations.
355
355
  const nullifierExistsInTree = await this.checkNullifierExists(
356
- AztecAddress.fromNumber(DEPLOYER_CONTRACT_ADDRESS),
356
+ AztecAddress.fromNumber(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS),
357
357
  contractAddress.toField(),
358
358
  );
359
359
  assert(
@@ -387,7 +387,7 @@ export class PublicPersistableStateManager {
387
387
  instance.address,
388
388
  );
389
389
  const readDeployerStorage = async (storageSlot: Fr) =>
390
- await this.readStorage(ProtocolContractAddress.ContractInstanceDeployer, storageSlot);
390
+ await this.readStorage(ProtocolContractAddress.ContractInstanceRegistry, storageSlot);
391
391
 
392
392
  const hash = await readDeployerStorage(sharedMutableHashSlot);
393
393
  const sharedMutableValues = await SharedMutableValues.readFromTree(sharedMutableSlot, readDeployerStorage);
@@ -493,8 +493,8 @@ export class PublicPersistableStateManager {
493
493
  function contractAddressIsCanonical(contractAddress: AztecAddress): boolean {
494
494
  return (
495
495
  contractAddress.equals(AztecAddress.fromNumber(CANONICAL_AUTH_REGISTRY_ADDRESS)) ||
496
- contractAddress.equals(AztecAddress.fromNumber(DEPLOYER_CONTRACT_ADDRESS)) ||
497
- contractAddress.equals(AztecAddress.fromNumber(REGISTERER_CONTRACT_ADDRESS)) ||
496
+ contractAddress.equals(AztecAddress.fromNumber(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS)) ||
497
+ contractAddress.equals(AztecAddress.fromNumber(CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS)) ||
498
498
  contractAddress.equals(AztecAddress.fromNumber(MULTI_CALL_ENTRYPOINT_ADDRESS)) ||
499
499
  contractAddress.equals(AztecAddress.fromNumber(FEE_JUICE_ADDRESS)) ||
500
500
  contractAddress.equals(AztecAddress.fromNumber(ROUTER_ADDRESS))