@aztec/simulator 0.24.0 → 0.26.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/dest/acvm/deserialize.d.ts +5 -0
  2. package/dest/acvm/deserialize.d.ts.map +1 -1
  3. package/dest/acvm/deserialize.js +8 -1
  4. package/dest/acvm/oracle/oracle.d.ts +5 -4
  5. package/dest/acvm/oracle/oracle.d.ts.map +1 -1
  6. package/dest/acvm/oracle/oracle.js +24 -11
  7. package/dest/acvm/oracle/typed_oracle.d.ts +7 -9
  8. package/dest/acvm/oracle/typed_oracle.d.ts.map +1 -1
  9. package/dest/acvm/oracle/typed_oracle.js +9 -9
  10. package/dest/avm/avm_context.d.ts +4 -4
  11. package/dest/avm/avm_context.d.ts.map +1 -1
  12. package/dest/avm/avm_context.js +6 -6
  13. package/dest/avm/avm_memory_types.d.ts +11 -2
  14. package/dest/avm/avm_memory_types.d.ts.map +1 -1
  15. package/dest/avm/avm_memory_types.js +11 -1
  16. package/dest/avm/avm_simulator.d.ts +6 -4
  17. package/dest/avm/avm_simulator.d.ts.map +1 -1
  18. package/dest/avm/avm_simulator.js +17 -18
  19. package/dest/avm/fixtures/index.d.ts +17 -5
  20. package/dest/avm/fixtures/index.d.ts.map +1 -1
  21. package/dest/avm/fixtures/index.js +19 -8
  22. package/dest/avm/journal/host_storage.d.ts.map +1 -1
  23. package/dest/avm/journal/host_storage.js +1 -1
  24. package/dest/avm/journal/journal.d.ts +78 -50
  25. package/dest/avm/journal/journal.d.ts.map +1 -1
  26. package/dest/avm/journal/journal.js +125 -169
  27. package/dest/avm/journal/nullifiers.d.ts +85 -0
  28. package/dest/avm/journal/nullifiers.d.ts.map +1 -0
  29. package/dest/avm/journal/nullifiers.js +147 -0
  30. package/dest/avm/journal/public_storage.d.ts +88 -0
  31. package/dest/avm/journal/public_storage.d.ts.map +1 -0
  32. package/dest/avm/journal/public_storage.js +135 -0
  33. package/dest/avm/journal/trace.d.ts +43 -0
  34. package/dest/avm/journal/trace.d.ts.map +1 -0
  35. package/dest/avm/journal/trace.js +204 -0
  36. package/dest/avm/journal/trace_types.d.ts +26 -0
  37. package/dest/avm/journal/trace_types.d.ts.map +1 -0
  38. package/dest/avm/journal/trace_types.js +6 -0
  39. package/dest/avm/opcodes/accrued_substate.d.ts +37 -4
  40. package/dest/avm/opcodes/accrued_substate.d.ts.map +1 -1
  41. package/dest/avm/opcodes/accrued_substate.js +109 -12
  42. package/dest/avm/opcodes/comparators.d.ts.map +1 -1
  43. package/dest/avm/opcodes/comparators.js +5 -8
  44. package/dest/avm/opcodes/environment_getters.d.ts +14 -13
  45. package/dest/avm/opcodes/environment_getters.d.ts.map +1 -1
  46. package/dest/avm/opcodes/environment_getters.js +1 -1
  47. package/dest/avm/opcodes/external_calls.js +5 -5
  48. package/dest/avm/opcodes/hashing.d.ts +48 -0
  49. package/dest/avm/opcodes/hashing.d.ts.map +1 -0
  50. package/dest/avm/opcodes/hashing.js +127 -0
  51. package/dest/avm/opcodes/memory.d.ts.map +1 -1
  52. package/dest/avm/opcodes/memory.js +1 -1
  53. package/dest/avm/opcodes/storage.d.ts.map +1 -1
  54. package/dest/avm/opcodes/storage.js +3 -3
  55. package/dest/avm/serialization/bytecode_serialization.d.ts.map +1 -1
  56. package/dest/avm/serialization/bytecode_serialization.js +12 -8
  57. package/dest/avm/serialization/instruction_serialization.d.ts +10 -7
  58. package/dest/avm/serialization/instruction_serialization.d.ts.map +1 -1
  59. package/dest/avm/serialization/instruction_serialization.js +12 -9
  60. package/dest/avm/temporary_executor_migration.d.ts.map +1 -1
  61. package/dest/avm/temporary_executor_migration.js +5 -5
  62. package/dest/client/client_execution_context.d.ts +9 -5
  63. package/dest/client/client_execution_context.d.ts.map +1 -1
  64. package/dest/client/client_execution_context.js +46 -24
  65. package/dest/client/db_oracle.d.ts +7 -0
  66. package/dest/client/db_oracle.d.ts.map +1 -1
  67. package/dest/client/db_oracle.js +1 -1
  68. package/dest/client/execution_note_cache.js +1 -1
  69. package/dest/client/execution_result.d.ts +2 -2
  70. package/dest/client/execution_result.d.ts.map +1 -1
  71. package/dest/client/private_execution.d.ts.map +1 -1
  72. package/dest/client/private_execution.js +4 -4
  73. package/dest/client/simulator.d.ts +1 -1
  74. package/dest/client/simulator.d.ts.map +1 -1
  75. package/dest/client/simulator.js +3 -2
  76. package/dest/client/view_data_oracle.d.ts +9 -2
  77. package/dest/client/view_data_oracle.d.ts.map +1 -1
  78. package/dest/client/view_data_oracle.js +13 -5
  79. package/dest/public/db.d.ts +17 -4
  80. package/dest/public/db.d.ts.map +1 -1
  81. package/dest/public/execution.d.ts +9 -4
  82. package/dest/public/execution.d.ts.map +1 -1
  83. package/dest/public/execution.js +17 -4
  84. package/dest/public/executor.d.ts.map +1 -1
  85. package/dest/public/executor.js +18 -9
  86. package/dest/public/public_execution_context.d.ts +5 -4
  87. package/dest/public/public_execution_context.d.ts.map +1 -1
  88. package/dest/public/public_execution_context.js +23 -12
  89. package/dest/public/state_actions.js +2 -2
  90. package/dest/test/utils.js +4 -4
  91. package/dest/utils.js +2 -3
  92. package/package.json +6 -5
  93. package/src/acvm/deserialize.ts +8 -0
  94. package/src/acvm/oracle/oracle.ts +30 -6
  95. package/src/acvm/oracle/typed_oracle.ts +13 -5
  96. package/src/avm/avm_context.ts +5 -5
  97. package/src/avm/avm_memory_types.ts +18 -3
  98. package/src/avm/avm_simulator.ts +22 -24
  99. package/src/avm/fixtures/index.ts +34 -9
  100. package/src/avm/journal/host_storage.ts +5 -11
  101. package/src/avm/journal/journal.ts +147 -182
  102. package/src/avm/journal/nullifiers.ts +170 -0
  103. package/src/avm/journal/public_storage.ts +149 -0
  104. package/src/avm/journal/trace.ts +223 -0
  105. package/src/avm/journal/trace_types.ts +79 -0
  106. package/src/avm/opcodes/accrued_substate.ts +132 -10
  107. package/src/avm/opcodes/comparators.ts +4 -7
  108. package/src/avm/opcodes/environment_getters.ts +15 -13
  109. package/src/avm/opcodes/external_calls.ts +4 -4
  110. package/src/avm/opcodes/hashing.ts +170 -0
  111. package/src/avm/opcodes/memory.ts +1 -0
  112. package/src/avm/opcodes/storage.ts +5 -2
  113. package/src/avm/serialization/bytecode_serialization.ts +13 -6
  114. package/src/avm/serialization/instruction_serialization.ts +6 -3
  115. package/src/avm/temporary_executor_migration.ts +4 -3
  116. package/src/client/client_execution_context.ts +53 -23
  117. package/src/client/db_oracle.ts +8 -0
  118. package/src/client/execution_note_cache.ts +1 -1
  119. package/src/client/execution_result.ts +2 -2
  120. package/src/client/private_execution.ts +5 -4
  121. package/src/client/simulator.ts +2 -1
  122. package/src/client/view_data_oracle.ts +14 -4
  123. package/src/public/db.ts +19 -4
  124. package/src/public/execution.ts +30 -6
  125. package/src/public/executor.ts +29 -9
  126. package/src/public/public_execution_context.ts +36 -12
  127. package/src/public/state_actions.ts +1 -1
  128. package/src/test/utils.ts +3 -3
  129. package/src/utils.ts +1 -1
@@ -1,3 +1,5 @@
1
+ import { Fr } from '@aztec/circuits.js';
2
+
1
3
  import type { AvmContext } from '../avm_context.js';
2
4
  import type { AvmExecutionEnvironment } from '../avm_execution_environment.js';
3
5
  import { Field } from '../avm_memory_types.js';
@@ -18,14 +20,14 @@ abstract class GetterInstruction extends Instruction {
18
20
  context.machineState.incrementPc();
19
21
  }
20
22
 
21
- protected abstract getIt(env: AvmExecutionEnvironment): any;
23
+ protected abstract getIt(env: AvmExecutionEnvironment): Fr | number | bigint;
22
24
  }
23
25
 
24
26
  export class Address extends GetterInstruction {
25
27
  static type: string = 'ADDRESS';
26
28
  static readonly opcode: Opcode = Opcode.ADDRESS;
27
29
 
28
- protected getIt(env: AvmExecutionEnvironment): any {
30
+ protected getIt(env: AvmExecutionEnvironment) {
29
31
  return env.address;
30
32
  }
31
33
  }
@@ -34,7 +36,7 @@ export class StorageAddress extends GetterInstruction {
34
36
  static type: string = 'STORAGEADDRESS';
35
37
  static readonly opcode: Opcode = Opcode.STORAGEADDRESS;
36
38
 
37
- protected getIt(env: AvmExecutionEnvironment): any {
39
+ protected getIt(env: AvmExecutionEnvironment) {
38
40
  return env.storageAddress;
39
41
  }
40
42
  }
@@ -43,7 +45,7 @@ export class Sender extends GetterInstruction {
43
45
  static type: string = 'SENDER';
44
46
  static readonly opcode: Opcode = Opcode.SENDER;
45
47
 
46
- protected getIt(env: AvmExecutionEnvironment): any {
48
+ protected getIt(env: AvmExecutionEnvironment) {
47
49
  return env.sender;
48
50
  }
49
51
  }
@@ -52,7 +54,7 @@ export class Origin extends GetterInstruction {
52
54
  static type: string = 'ORIGIN';
53
55
  static readonly opcode: Opcode = Opcode.ORIGIN;
54
56
 
55
- protected getIt(env: AvmExecutionEnvironment): any {
57
+ protected getIt(env: AvmExecutionEnvironment) {
56
58
  return env.origin;
57
59
  }
58
60
  }
@@ -61,7 +63,7 @@ export class FeePerL1Gas extends GetterInstruction {
61
63
  static type: string = 'FEEPERL1GAS';
62
64
  static readonly opcode: Opcode = Opcode.FEEPERL1GAS;
63
65
 
64
- protected getIt(env: AvmExecutionEnvironment): any {
66
+ protected getIt(env: AvmExecutionEnvironment) {
65
67
  return env.feePerL1Gas;
66
68
  }
67
69
  }
@@ -70,7 +72,7 @@ export class FeePerL2Gas extends GetterInstruction {
70
72
  static type: string = 'FEEPERL2GAS';
71
73
  static readonly opcode: Opcode = Opcode.FEEPERL2GAS;
72
74
 
73
- protected getIt(env: AvmExecutionEnvironment): any {
75
+ protected getIt(env: AvmExecutionEnvironment) {
74
76
  return env.feePerL2Gas;
75
77
  }
76
78
  }
@@ -79,7 +81,7 @@ export class FeePerDAGas extends GetterInstruction {
79
81
  static type: string = 'FEEPERDAGAS';
80
82
  static readonly opcode: Opcode = Opcode.FEEPERDAGAS;
81
83
 
82
- protected getIt(env: AvmExecutionEnvironment): any {
84
+ protected getIt(env: AvmExecutionEnvironment) {
83
85
  return env.feePerDaGas;
84
86
  }
85
87
  }
@@ -88,7 +90,7 @@ export class Portal extends GetterInstruction {
88
90
  static type: string = 'PORTAL';
89
91
  static readonly opcode: Opcode = Opcode.PORTAL;
90
92
 
91
- protected getIt(env: AvmExecutionEnvironment): any {
93
+ protected getIt(env: AvmExecutionEnvironment) {
92
94
  return env.portal.toField();
93
95
  }
94
96
  }
@@ -97,7 +99,7 @@ export class ChainId extends GetterInstruction {
97
99
  static type: string = 'CHAINID';
98
100
  static readonly opcode: Opcode = Opcode.CHAINID;
99
101
 
100
- protected getIt(env: AvmExecutionEnvironment): any {
102
+ protected getIt(env: AvmExecutionEnvironment) {
101
103
  return env.globals.chainId;
102
104
  }
103
105
  }
@@ -106,7 +108,7 @@ export class Version extends GetterInstruction {
106
108
  static type: string = 'VERSION';
107
109
  static readonly opcode: Opcode = Opcode.VERSION;
108
110
 
109
- protected getIt(env: AvmExecutionEnvironment): any {
111
+ protected getIt(env: AvmExecutionEnvironment) {
110
112
  return env.globals.version;
111
113
  }
112
114
  }
@@ -115,7 +117,7 @@ export class BlockNumber extends GetterInstruction {
115
117
  static type: string = 'BLOCKNUMBER';
116
118
  static readonly opcode: Opcode = Opcode.BLOCKNUMBER;
117
119
 
118
- protected getIt(env: AvmExecutionEnvironment): any {
120
+ protected getIt(env: AvmExecutionEnvironment) {
119
121
  return env.globals.blockNumber;
120
122
  }
121
123
  }
@@ -124,7 +126,7 @@ export class Timestamp extends GetterInstruction {
124
126
  static type: string = 'TIMESTAMP';
125
127
  static readonly opcode: Opcode = Opcode.TIMESTAMP;
126
128
 
127
- protected getIt(env: AvmExecutionEnvironment): any {
129
+ protected getIt(env: AvmExecutionEnvironment) {
128
130
  return env.globals.timestamp;
129
131
  }
130
132
  }
@@ -54,9 +54,9 @@ export class Call extends Instruction {
54
54
  context.machineState.memory.setSlice(this.retOffset, convertedReturnData);
55
55
 
56
56
  if (success) {
57
- context.worldState.acceptNestedWorldState(nestedContext.worldState);
57
+ context.persistableState.acceptNestedCallState(nestedContext.persistableState);
58
58
  } else {
59
- context.worldState.rejectNestedWorldState(nestedContext.worldState);
59
+ context.persistableState.rejectNestedCallState(nestedContext.persistableState);
60
60
  }
61
61
 
62
62
  context.machineState.incrementPc();
@@ -112,9 +112,9 @@ export class StaticCall extends Instruction {
112
112
  context.machineState.memory.setSlice(this.retOffset, convertedReturnData);
113
113
 
114
114
  if (success) {
115
- context.worldState.acceptNestedWorldState(nestedContext.worldState);
115
+ context.persistableState.acceptNestedCallState(nestedContext.persistableState);
116
116
  } else {
117
- context.worldState.rejectNestedWorldState(nestedContext.worldState);
117
+ context.persistableState.rejectNestedCallState(nestedContext.persistableState);
118
118
  }
119
119
 
120
120
  context.machineState.incrementPc();
@@ -0,0 +1,170 @@
1
+ import { toBigIntBE } from '@aztec/foundation/bigint-buffer';
2
+ import { keccak, pedersenHash, poseidonHash, sha256 } from '@aztec/foundation/crypto';
3
+
4
+ import { AvmContext } from '../avm_context.js';
5
+ import { Field } from '../avm_memory_types.js';
6
+ import { Opcode, OperandType } from '../serialization/instruction_serialization.js';
7
+ import { Addressing } from './addressing_mode.js';
8
+ import { Instruction } from './instruction.js';
9
+
10
+ export class Poseidon2 extends Instruction {
11
+ static type: string = 'POSEIDON2';
12
+ static readonly opcode: Opcode = Opcode.POSEIDON;
13
+
14
+ // Informs (de)serialization. See Instruction.deserialize.
15
+ static readonly wireFormat: OperandType[] = [
16
+ OperandType.UINT8,
17
+ OperandType.UINT8,
18
+ OperandType.UINT32,
19
+ OperandType.UINT32,
20
+ OperandType.UINT32,
21
+ ];
22
+
23
+ constructor(
24
+ private indirect: number,
25
+ private dstOffset: number,
26
+ private hashOffset: number,
27
+ private hashSize: number,
28
+ ) {
29
+ super();
30
+ }
31
+
32
+ async execute(context: AvmContext): Promise<void> {
33
+ // We hash a set of field elements
34
+ const [hashOffset] = Addressing.fromWire(this.indirect).resolve([this.hashOffset], context.machineState.memory);
35
+
36
+ // Memory pointer will be indirect
37
+ const hashData = context.machineState.memory.getSlice(hashOffset, this.hashSize).map(word => word.toBuffer());
38
+
39
+ const hash = poseidonHash(hashData);
40
+ context.machineState.memory.set(this.dstOffset, new Field(hash));
41
+
42
+ context.machineState.incrementPc();
43
+ }
44
+ }
45
+
46
+ export class Keccak extends Instruction {
47
+ static type: string = 'KECCAK';
48
+ static readonly opcode: Opcode = Opcode.KECCAK;
49
+
50
+ // Informs (de)serialization. See Instruction.deserialize.
51
+ static readonly wireFormat: OperandType[] = [
52
+ OperandType.UINT8,
53
+ OperandType.UINT8,
54
+ OperandType.UINT32,
55
+ OperandType.UINT32,
56
+ OperandType.UINT32,
57
+ ];
58
+
59
+ constructor(
60
+ private indirect: number,
61
+ private dstOffset: number,
62
+ private hashOffset: number,
63
+ private hashSize: number,
64
+ ) {
65
+ super();
66
+ }
67
+
68
+ // Note hash output is 32 bytes, so takes up two fields
69
+ async execute(context: AvmContext): Promise<void> {
70
+ // We hash a set of field elements
71
+ const [hashOffset, dstOffset] = Addressing.fromWire(this.indirect).resolve(
72
+ [this.hashOffset, this.dstOffset],
73
+ context.machineState.memory,
74
+ );
75
+
76
+ const hashData = context.machineState.memory.getSlice(hashOffset, this.hashSize).map(word => word.toBuffer());
77
+
78
+ const hash = keccak(Buffer.concat(hashData));
79
+
80
+ // Split output into two fields
81
+ const high = new Field(toBigIntBE(hash.subarray(0, 16)));
82
+ const low = new Field(toBigIntBE(hash.subarray(16, 32)));
83
+
84
+ context.machineState.memory.set(dstOffset, high);
85
+ context.machineState.memory.set(dstOffset + 1, low);
86
+
87
+ context.machineState.incrementPc();
88
+ }
89
+ }
90
+
91
+ export class Sha256 extends Instruction {
92
+ static type: string = 'SHA256';
93
+ static readonly opcode: Opcode = Opcode.SHA256;
94
+
95
+ // Informs (de)serialization. See Instruction.deserialize.
96
+ static readonly wireFormat: OperandType[] = [
97
+ OperandType.UINT8,
98
+ OperandType.UINT8,
99
+ OperandType.UINT32,
100
+ OperandType.UINT32,
101
+ OperandType.UINT32,
102
+ ];
103
+
104
+ constructor(
105
+ private indirect: number,
106
+ private dstOffset: number,
107
+ private hashOffset: number,
108
+ private hashSize: number,
109
+ ) {
110
+ super();
111
+ }
112
+
113
+ // Note hash output is 32 bytes, so takes up two fields
114
+ async execute(context: AvmContext): Promise<void> {
115
+ const [hashOffset, dstOffset] = Addressing.fromWire(this.indirect).resolve(
116
+ [this.hashOffset, this.dstOffset],
117
+ context.machineState.memory,
118
+ );
119
+
120
+ // We hash a set of field elements
121
+ const hashData = context.machineState.memory.getSlice(hashOffset, this.hashSize).map(word => word.toBuffer());
122
+
123
+ const hash = sha256(Buffer.concat(hashData));
124
+
125
+ // Split output into two fields
126
+ const high = new Field(toBigIntBE(hash.subarray(0, 16)));
127
+ const low = new Field(toBigIntBE(hash.subarray(16, 32)));
128
+
129
+ context.machineState.memory.set(dstOffset, high);
130
+ context.machineState.memory.set(dstOffset + 1, low);
131
+
132
+ context.machineState.incrementPc();
133
+ }
134
+ }
135
+
136
+ export class Pedersen extends Instruction {
137
+ static type: string = 'PEDERSEN';
138
+ static readonly opcode: Opcode = Opcode.PEDERSEN;
139
+
140
+ // Informs (de)serialization. See Instruction.deserialize.
141
+ static readonly wireFormat: OperandType[] = [
142
+ OperandType.UINT8,
143
+ OperandType.UINT8,
144
+ OperandType.UINT32,
145
+ OperandType.UINT32,
146
+ OperandType.UINT32,
147
+ ];
148
+
149
+ constructor(
150
+ private indirect: number,
151
+ private dstOffset: number,
152
+ private hashOffset: number,
153
+ private hashSize: number,
154
+ ) {
155
+ super();
156
+ }
157
+
158
+ async execute(context: AvmContext): Promise<void> {
159
+ const [hashOffset] = Addressing.fromWire(this.indirect).resolve([this.hashOffset], context.machineState.memory);
160
+
161
+ // We hash a set of field elements
162
+ const hashData = context.machineState.memory.getSlice(hashOffset, this.hashSize).map(word => word.toBuffer());
163
+
164
+ // No domain sep for now
165
+ const hash = pedersenHash(hashData);
166
+ context.machineState.memory.set(this.dstOffset, new Field(hash));
167
+
168
+ context.machineState.incrementPc();
169
+ }
170
+ }
@@ -186,6 +186,7 @@ export class CalldataCopy extends Instruction {
186
186
  const transformedData = context.environment.calldata
187
187
  .slice(this.cdOffset, this.cdOffset + this.copySize)
188
188
  .map(f => new Field(f));
189
+
189
190
  context.machineState.memory.setSlice(this.dstOffset, transformedData);
190
191
 
191
192
  context.machineState.incrementPc();
@@ -36,7 +36,7 @@ export class SStore extends BaseStorageInstruction {
36
36
  const slot = context.machineState.memory.get(this.aOffset);
37
37
  const data = context.machineState.memory.get(this.bOffset);
38
38
 
39
- context.worldState.writeStorage(
39
+ context.persistableState.writeStorage(
40
40
  context.environment.storageAddress,
41
41
  new Fr(slot.toBigInt()),
42
42
  new Fr(data.toBigInt()),
@@ -57,7 +57,10 @@ export class SLoad extends BaseStorageInstruction {
57
57
  async execute(context: AvmContext): Promise<void> {
58
58
  const slot = context.machineState.memory.get(this.aOffset);
59
59
 
60
- const data: Fr = await context.worldState.readStorage(context.environment.storageAddress, new Fr(slot.toBigInt()));
60
+ const data: Fr = await context.persistableState.readStorage(
61
+ context.environment.storageAddress,
62
+ new Fr(slot.toBigInt()),
63
+ );
61
64
 
62
65
  context.machineState.memory.set(this.bOffset, new Field(data));
63
66
 
@@ -1,3 +1,4 @@
1
+ import { Keccak, Pedersen, Poseidon2, Sha256 } from '../opcodes/hashing.js';
1
2
  import {
2
3
  Add,
3
4
  Address,
@@ -20,11 +21,14 @@ import {
20
21
  InternalReturn,
21
22
  Jump,
22
23
  JumpI,
24
+ L1ToL2MessageExists,
23
25
  Lt,
24
26
  Lte,
25
27
  Mov,
26
28
  Mul,
27
29
  Not,
30
+ NoteHashExists,
31
+ NullifierExists,
28
32
  Or,
29
33
  Origin,
30
34
  Portal,
@@ -110,11 +114,11 @@ const INSTRUCTION_SET = () =>
110
114
  // World State
111
115
  [SLoad.opcode, SLoad], // Public Storage
112
116
  [SStore.opcode, SStore], // Public Storage
113
- //[NoteHashExists.opcode, NoteHashExists], // Notes & Nullifiers
117
+ [NoteHashExists.opcode, NoteHashExists], // Notes & Nullifiers
114
118
  [EmitNoteHash.opcode, EmitNoteHash], // Notes & Nullifiers
115
- //[NullifierExists.opcode, NullifierExists], // Notes & Nullifiers
119
+ [NullifierExists.opcode, NullifierExists], // Notes & Nullifiers
116
120
  [EmitNullifier.opcode, EmitNullifier], // Notes & Nullifiers
117
- //[Readl1tol2msg.opcode, Readl1tol2msg], // Messages
121
+ [L1ToL2MessageExists.opcode, L1ToL2MessageExists], // Messages
118
122
  //[HeaderMember.opcode, HeaderMember], // Header
119
123
 
120
124
  // Accrued Substate
@@ -124,12 +128,15 @@ const INSTRUCTION_SET = () =>
124
128
  // Control Flow - Contract Calls
125
129
  [Call.opcode, Call],
126
130
  [StaticCall.opcode, StaticCall],
131
+ //[DelegateCall.opcode, DelegateCall],
127
132
  [Return.opcode, Return],
128
133
  [Revert.opcode, Revert],
129
134
 
130
- // Gadgets
131
- //[Keccak.opcode, Keccak],
132
- //[Poseidon.opcode, Poseidon],
135
+ // //// Gadgets
136
+ [Keccak.opcode, Keccak],
137
+ [Poseidon2.opcode, Poseidon2],
138
+ [Sha256.opcode, Sha256],
139
+ [Pedersen.opcode, Pedersen],
133
140
  ]);
134
141
 
135
142
  interface Serializable {
@@ -3,7 +3,7 @@ import { strict as assert } from 'assert';
3
3
  import { BufferCursor } from './buffer_cursor.js';
4
4
 
5
5
  /**
6
- * All AVM opcodes. (Keep in sync with cpp counterpart code AvmMini_opcode.hpp).
6
+ * All AVM opcodes. (Keep in sync with cpp counterpart code avm_opcode.hpp).
7
7
  * Source: https://yp-aztec.netlify.app/docs/public-vm/instruction-set
8
8
  */
9
9
  export enum Opcode {
@@ -55,22 +55,25 @@ export enum Opcode {
55
55
  EMITNOTEHASH,
56
56
  NULLIFIEREXISTS,
57
57
  EMITNULLIFIER,
58
- READL1TOL2MSG,
58
+ L1TOL2MSGEXISTS,
59
59
  HEADERMEMBER,
60
60
  EMITUNENCRYPTEDLOG,
61
61
  SENDL2TOL1MSG,
62
62
  CALL,
63
63
  STATICCALL,
64
+ DELEGATECALL,
64
65
  RETURN,
65
66
  REVERT,
66
67
  KECCAK,
67
68
  POSEIDON,
68
69
  // Add new opcodes before this
70
+ SHA256, // temp - may be removed, but alot of contracts rely on it
71
+ PEDERSEN, // temp - may be removed, but alot of contracts rely on it
69
72
  TOTAL_OPCODES_NUMBER,
70
73
  }
71
74
 
72
75
  // Possible types for an instruction's operand in its wire format. (Keep in sync with CPP code.
73
- // See vm/avm_trace/AvmMini_deserialization.cpp)
76
+ // See vm/avm_trace/avm_deserialization.cpp)
74
77
  // Note that cpp code introduced an additional enum value TAG to express the instruction tag. In TS,
75
78
  // this one is parsed as UINT8.
76
79
  export enum OperandType {
@@ -4,6 +4,7 @@ import {
4
4
  ContractStorageRead,
5
5
  ContractStorageUpdateRequest,
6
6
  GlobalVariables,
7
+ L2ToL1Message,
7
8
  SideEffect,
8
9
  SideEffectLinkedToNoteHash,
9
10
  } from '@aztec/circuits.js';
@@ -59,7 +60,7 @@ export function temporaryConvertAvmResults(
59
60
  newWorldState: JournalData,
60
61
  result: AvmContractCallResults,
61
62
  ): PublicExecutionResult {
62
- const newCommitments = newWorldState.newNoteHashes.map(noteHash => new SideEffect(noteHash, Fr.zero()));
63
+ const newNoteHashes = newWorldState.newNoteHashes.map(noteHash => new SideEffect(noteHash, Fr.zero()));
63
64
 
64
65
  const contractStorageReads: ContractStorageRead[] = [];
65
66
  const reduceStorageReadRequests = (contractAddress: bigint, storageReads: Map<bigint, Fr[]>) => {
@@ -92,11 +93,11 @@ export function temporaryConvertAvmResults(
92
93
  const nestedExecutions: PublicExecutionResult[] = [];
93
94
  const newNullifiers: SideEffectLinkedToNoteHash[] = [];
94
95
  const unencryptedLogs = FunctionL2Logs.empty();
95
- const newL2ToL1Messages = newWorldState.newL1Messages.map(() => Fr.zero());
96
+ const newL2ToL1Messages = newWorldState.newL1Messages.map(() => L2ToL1Message.empty());
96
97
 
97
98
  return {
98
99
  execution,
99
- newCommitments,
100
+ newNoteHashes,
100
101
  newL2ToL1Messages,
101
102
  newNullifiers,
102
103
  contractStorageReads,