@aztec/simulator 3.0.0-nightly.20251217 → 3.0.0-nightly.20251219

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.
@@ -60,6 +60,7 @@ async function execute(base64Line) {
60
60
  });
61
61
  writeSync(process.stdout.fd, resultBuffer.toString('base64') + '\n');
62
62
  } catch (error) {
63
+ // If we error, treat as reverted
63
64
  const errorResult = serializeWithMessagePack({
64
65
  reverted: true,
65
66
  output: [],
@@ -13,7 +13,7 @@ export class ContractProviderForCpp {
13
13
  this.globalVariables = globalVariables;
14
14
  this.log = createLogger('simulator:contract_provider_for_cpp');
15
15
  this.getContractInstance = async (address)=>{
16
- this.log.debug(`Contract provider callback: getContractInstance(${address})`);
16
+ this.log.trace(`Contract provider callback: getContractInstance(${address})`);
17
17
  const aztecAddr = AztecAddress.fromString(address);
18
18
  const instance = await this.contractsDB.getContractInstance(aztecAddr, this.globalVariables.timestamp);
19
19
  if (!instance) {
@@ -23,7 +23,7 @@ export class ContractProviderForCpp {
23
23
  return serializeWithMessagePack(instance);
24
24
  };
25
25
  this.getContractClass = async (classId)=>{
26
- this.log.debug(`Contract provider callback: getContractClass(${classId})`);
26
+ this.log.trace(`Contract provider callback: getContractClass(${classId})`);
27
27
  // Parse classId string to Fr
28
28
  const classIdFr = Fr.fromString(classId);
29
29
  // Fetch contract class from the contracts DB
@@ -35,16 +35,16 @@ export class ContractProviderForCpp {
35
35
  return serializeWithMessagePack(contractClass);
36
36
  };
37
37
  this.addContracts = async (contractDeploymentDataBuffer)=>{
38
- this.log.debug(`Contract provider callback: addContracts`);
38
+ this.log.trace(`Contract provider callback: addContracts`);
39
39
  const rawData = deserializeFromMessagePack(contractDeploymentDataBuffer);
40
40
  // Construct ContractDeploymentData from plain object.
41
41
  const contractDeploymentData = ContractDeploymentData.fromPlainObject(rawData);
42
42
  // Add contracts to the contracts DB
43
- this.log.debug(`Calling contractsDB.addContracts`);
43
+ this.log.trace(`Calling contractsDB.addContracts`);
44
44
  await this.contractsDB.addContracts(contractDeploymentData);
45
45
  };
46
46
  this.getBytecodeCommitment = async (classId)=>{
47
- this.log.debug(`Contract provider callback: getBytecodeCommitment(${classId})`);
47
+ this.log.trace(`Contract provider callback: getBytecodeCommitment(${classId})`);
48
48
  // Parse classId string to Fr
49
49
  const classIdFr = Fr.fromString(classId);
50
50
  // Fetch bytecode commitment from the contracts DB
@@ -57,33 +57,33 @@ export class ContractProviderForCpp {
57
57
  return serializeWithMessagePack(commitment);
58
58
  };
59
59
  this.getDebugFunctionName = async (address, selector)=>{
60
- this.log.debug(`Contract provider callback: getDebugFunctionName(${address}, ${selector})`);
60
+ this.log.trace(`Contract provider callback: getDebugFunctionName(${address}, ${selector})`);
61
61
  // Parse address and selector strings
62
62
  const aztecAddr = AztecAddress.fromString(address);
63
63
  const selectorFr = Fr.fromString(selector);
64
64
  const functionSelector = FunctionSelector.fromFieldOrUndefined(selectorFr);
65
65
  if (!functionSelector) {
66
- this.log.debug(`calldata[0] is not a function selector: ${selector}`);
66
+ this.log.trace(`calldata[0] is not a function selector: ${selector}`);
67
67
  return undefined;
68
68
  }
69
69
  // Fetch debug function name from the contracts DB
70
70
  const name = await this.contractsDB.getDebugFunctionName(aztecAddr, functionSelector);
71
71
  if (!name) {
72
- this.log.debug(`Debug function name not found for ${address}:${selector}`);
72
+ this.log.trace(`Debug function name not found for ${address}:${selector}`);
73
73
  return undefined;
74
74
  }
75
75
  return name;
76
76
  };
77
77
  this.createCheckpoint = ()=>{
78
- this.log.debug(`Contract provider callback: createCheckpoint`);
78
+ this.log.trace(`Contract provider callback: createCheckpoint`);
79
79
  return Promise.resolve(this.contractsDB.createCheckpoint());
80
80
  };
81
81
  this.commitCheckpoint = ()=>{
82
- this.log.debug(`Contract provider callback: commitCheckpoint`);
82
+ this.log.trace(`Contract provider callback: commitCheckpoint`);
83
83
  return Promise.resolve(this.contractsDB.commitCheckpoint());
84
84
  };
85
85
  this.revertCheckpoint = ()=>{
86
- this.log.debug(`Contract provider callback: revertCheckpoint`);
86
+ this.log.trace(`Contract provider callback: revertCheckpoint`);
87
87
  return Promise.resolve(this.contractsDB.revertCheckpoint());
88
88
  };
89
89
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/simulator",
3
- "version": "3.0.0-nightly.20251217",
3
+ "version": "3.0.0-nightly.20251219",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./server": "./dest/server.js",
@@ -64,26 +64,26 @@
64
64
  ]
65
65
  },
66
66
  "dependencies": {
67
- "@aztec/constants": "3.0.0-nightly.20251217",
68
- "@aztec/foundation": "3.0.0-nightly.20251217",
69
- "@aztec/native": "3.0.0-nightly.20251217",
70
- "@aztec/noir-acvm_js": "3.0.0-nightly.20251217",
71
- "@aztec/noir-noirc_abi": "3.0.0-nightly.20251217",
72
- "@aztec/noir-protocol-circuits-types": "3.0.0-nightly.20251217",
73
- "@aztec/noir-types": "3.0.0-nightly.20251217",
74
- "@aztec/protocol-contracts": "3.0.0-nightly.20251217",
75
- "@aztec/stdlib": "3.0.0-nightly.20251217",
76
- "@aztec/telemetry-client": "3.0.0-nightly.20251217",
77
- "@aztec/world-state": "3.0.0-nightly.20251217",
67
+ "@aztec/constants": "3.0.0-nightly.20251219",
68
+ "@aztec/foundation": "3.0.0-nightly.20251219",
69
+ "@aztec/native": "3.0.0-nightly.20251219",
70
+ "@aztec/noir-acvm_js": "3.0.0-nightly.20251219",
71
+ "@aztec/noir-noirc_abi": "3.0.0-nightly.20251219",
72
+ "@aztec/noir-protocol-circuits-types": "3.0.0-nightly.20251219",
73
+ "@aztec/noir-types": "3.0.0-nightly.20251219",
74
+ "@aztec/protocol-contracts": "3.0.0-nightly.20251219",
75
+ "@aztec/stdlib": "3.0.0-nightly.20251219",
76
+ "@aztec/telemetry-client": "3.0.0-nightly.20251219",
77
+ "@aztec/world-state": "3.0.0-nightly.20251219",
78
78
  "lodash.clonedeep": "^4.5.0",
79
79
  "lodash.merge": "^4.6.2",
80
80
  "tslib": "^2.4.0"
81
81
  },
82
82
  "devDependencies": {
83
- "@aztec/kv-store": "3.0.0-nightly.20251217",
84
- "@aztec/merkle-tree": "3.0.0-nightly.20251217",
85
- "@aztec/noir-contracts.js": "3.0.0-nightly.20251217",
86
- "@aztec/noir-test-contracts.js": "3.0.0-nightly.20251217",
83
+ "@aztec/kv-store": "3.0.0-nightly.20251219",
84
+ "@aztec/merkle-tree": "3.0.0-nightly.20251219",
85
+ "@aztec/noir-contracts.js": "3.0.0-nightly.20251219",
86
+ "@aztec/noir-test-contracts.js": "3.0.0-nightly.20251219",
87
87
  "@jest/globals": "^30.0.0",
88
88
  "@types/jest": "^30.0.0",
89
89
  "@types/lodash.clonedeep": "^4.5.7",
@@ -416,7 +416,7 @@ const TAG_FOR_MEM_VAL = new Map<string, TypeTag>([
416
416
  ['Uint128', TypeTag.UINT128],
417
417
  ]);
418
418
 
419
- export const VALID_TAGS = new Set([
419
+ const VALID_TAGS = new Set([
420
420
  TypeTag.FIELD,
421
421
  TypeTag.UINT1,
422
422
  TypeTag.UINT8,
@@ -426,7 +426,7 @@ export const VALID_TAGS = new Set([
426
426
  TypeTag.UINT128,
427
427
  ]);
428
428
 
429
- export const INTEGRAL_TAGS = new Set([
429
+ const INTEGRAL_TAGS = new Set([
430
430
  TypeTag.UINT1,
431
431
  TypeTag.UINT8,
432
432
  TypeTag.UINT16,
@@ -2,7 +2,7 @@ import { strict as assert } from 'assert';
2
2
 
3
3
  import { TypeTag } from '../avm/avm_memory_types.js';
4
4
  import { Addressing, AddressingMode } from '../avm/opcodes/addressing_mode.js';
5
- import { CalldataCopy, Jump, Return, Set } from '../avm/opcodes/index.js';
5
+ import { Add, CalldataCopy, Jump, Return, Set } from '../avm/opcodes/index.js';
6
6
  import { encodeToBytecode } from '../avm/serialization/bytecode_serialization.js';
7
7
  import {
8
8
  MAX_OPCODE_VALUE,
@@ -55,6 +55,66 @@ export async function addressingWithIndirectTagIssueTest(tester: PublicTxSimulat
55
55
  return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
56
56
  }
57
57
 
58
+ // First instruction sets a value 10 with tag U32 at offset 1 (direct, no relative).
59
+ // Then an ADD_16 instruction uses INDIRECT addressing for the first operand (offset 1)
60
+ // and RELATIVE addressing for the second operand (offset 2). The indirect addressing
61
+ // succeeds (reads U32 value 10 from offset 1, uses it as address), but the relative
62
+ // addressing fails because the base address at offset 0 has the wrong tag (uninitialized/invalid).
63
+ export async function addressingWithIndirectThenRelativeTagIssueTest(tester: PublicTxSimulationTester) {
64
+ const addressingMode = Addressing.fromModes([
65
+ AddressingMode.INDIRECT, // First operand (aOffset) uses indirect addressing, no relative
66
+ AddressingMode.RELATIVE, // Second operand (bOffset) uses relative addressing
67
+ AddressingMode.DIRECT, // Third operand (dstOffset) uses direct addressing
68
+ ]);
69
+
70
+ const bytecode = encodeToBytecode([
71
+ // Set a U32 value 10 at offset 1 - this will be used as an indirect address
72
+ new Set(/*indirect=*/ 0, /*dstOffset=*/ 1, TypeTag.UINT32, /*value=*/ 10).as(Opcode.SET_32, Set.wireFormat32),
73
+ // ADD_16: first operand uses indirect addressing (reads from offset 1, gets value 10, uses as address - succeeds)
74
+ // second operand uses relative addressing (tries to read base from offset 0, but offset 0 has wrong tag - fails)
75
+ new Add(/*indirect=*/ addressingMode.toWire(), /*aOffset=*/ 1, /*bOffset=*/ 2, /*dstOffset=*/ 3).as(
76
+ Opcode.ADD_16,
77
+ Add.wireFormat16,
78
+ ),
79
+ new Return(/*indirect=*/ 0, /*copySizeOffset=*/ 0, /*returnOffset=*/ 0),
80
+ ]);
81
+
82
+ const txLabel = 'AddressingWithIndirectThenRelativeTagInvalid';
83
+ return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
84
+ }
85
+
86
+ // First instruction sets UINT32_MAX at offset 0 (base address) with tag U32.
87
+ // Then an ADD_8 instruction uses INDIRECT_RELATIVE addressing for the first operand (offset 1)
88
+ // and INDIRECT addressing for the second operand (offset 2). The relative addressing
89
+ // for the first operand will overflow (UINT32_MAX + 1 >= MAX_MEMORY_SIZE), causing the instruction to fail.
90
+ // The second operand will also fail (indirect addressing from offset 2 which is uninitialized with tag FF).
91
+ export async function addressingWithRelativeOverflowAndIndirectTagIssueTest(tester: PublicTxSimulationTester) {
92
+ const addressingMode = Addressing.fromModes([
93
+ AddressingMode.INDIRECT_RELATIVE, // First operand (aOffset) uses both indirect and relative addressing
94
+ AddressingMode.INDIRECT, // Second operand (bOffset) uses indirect addressing only
95
+ AddressingMode.DIRECT, // Third operand (dstOffset) uses direct addressing
96
+ ]);
97
+
98
+ // UINT32_MAX = 2^32 - 1 = 4294967295
99
+ const UINT32_MAX = 0xffffffff;
100
+
101
+ const bytecode = encodeToBytecode([
102
+ // Set UINT32_MAX at offset 0 as base address - this will cause overflow when adding relative offset 1
103
+ new Set(/*indirect=*/ 0, /*dstOffset=*/ 0, TypeTag.UINT32, /*value=*/ UINT32_MAX).as(
104
+ Opcode.SET_32,
105
+ Set.wireFormat32,
106
+ ),
107
+ new Add(/*indirect=*/ addressingMode.toWire(), /*aOffset=*/ 1, /*bOffset=*/ 2, /*dstOffset=*/ 3).as(
108
+ Opcode.ADD_8,
109
+ Add.wireFormat8,
110
+ ),
111
+ new Return(/*indirect=*/ 0, /*copySizeOffset=*/ 0, /*returnOffset=*/ 0),
112
+ ]);
113
+
114
+ const txLabel = 'AddressingWithRelativeOverflowAndIndirectTagInvalid';
115
+ return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
116
+ }
117
+
58
118
  export async function pcOutOfRangeTest(tester: PublicTxSimulationTester) {
59
119
  const bytecode = encodeToBytecode([
60
120
  new Jump(/*jumpOffset=*/ 123), // Jump to out-of-range pc offset.