@aztec/simulator 0.59.0 → 0.61.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. package/dest/acvm/acvm.d.ts +1 -0
  2. package/dest/acvm/acvm.d.ts.map +1 -1
  3. package/dest/acvm/oracle/oracle.d.ts +5 -3
  4. package/dest/acvm/oracle/oracle.d.ts.map +1 -1
  5. package/dest/acvm/oracle/oracle.js +15 -7
  6. package/dest/acvm/oracle/typed_oracle.d.ts +7 -4
  7. package/dest/acvm/oracle/typed_oracle.d.ts.map +1 -1
  8. package/dest/acvm/oracle/typed_oracle.js +10 -4
  9. package/dest/acvm/serialize.d.ts +1 -0
  10. package/dest/acvm/serialize.d.ts.map +1 -1
  11. package/dest/avm/avm_context.d.ts +1 -1
  12. package/dest/avm/avm_context.js +1 -1
  13. package/dest/avm/avm_execution_environment.d.ts +2 -5
  14. package/dest/avm/avm_execution_environment.d.ts.map +1 -1
  15. package/dest/avm/avm_execution_environment.js +7 -15
  16. package/dest/avm/avm_gas.d.ts.map +1 -1
  17. package/dest/avm/avm_gas.js +6 -10
  18. package/dest/avm/avm_machine_state.d.ts +2 -0
  19. package/dest/avm/avm_machine_state.d.ts.map +1 -1
  20. package/dest/avm/avm_machine_state.js +3 -1
  21. package/dest/avm/avm_memory_types.d.ts +1 -0
  22. package/dest/avm/avm_memory_types.d.ts.map +1 -1
  23. package/dest/avm/avm_simulator.d.ts +16 -0
  24. package/dest/avm/avm_simulator.d.ts.map +1 -1
  25. package/dest/avm/avm_simulator.js +45 -4
  26. package/dest/avm/bytecode_utils.d.ts +1 -0
  27. package/dest/avm/bytecode_utils.d.ts.map +1 -1
  28. package/dest/avm/fixtures/index.d.ts +3 -0
  29. package/dest/avm/fixtures/index.d.ts.map +1 -1
  30. package/dest/avm/fixtures/index.js +8 -2
  31. package/dest/avm/journal/journal.d.ts +19 -19
  32. package/dest/avm/journal/journal.d.ts.map +1 -1
  33. package/dest/avm/journal/journal.js +73 -48
  34. package/dest/avm/journal/nullifiers.d.ts +9 -9
  35. package/dest/avm/journal/nullifiers.d.ts.map +1 -1
  36. package/dest/avm/journal/nullifiers.js +24 -24
  37. package/dest/avm/journal/public_storage.d.ts +10 -10
  38. package/dest/avm/journal/public_storage.d.ts.map +1 -1
  39. package/dest/avm/journal/public_storage.js +21 -21
  40. package/dest/avm/opcodes/accrued_substate.d.ts.map +1 -1
  41. package/dest/avm/opcodes/accrued_substate.js +5 -5
  42. package/dest/avm/opcodes/contract.d.ts +8 -1
  43. package/dest/avm/opcodes/contract.d.ts.map +1 -1
  44. package/dest/avm/opcodes/contract.js +41 -21
  45. package/dest/avm/opcodes/conversion.d.ts +1 -1
  46. package/dest/avm/opcodes/conversion.d.ts.map +1 -1
  47. package/dest/avm/opcodes/conversion.js +12 -9
  48. package/dest/avm/opcodes/environment_getters.d.ts +13 -14
  49. package/dest/avm/opcodes/environment_getters.d.ts.map +1 -1
  50. package/dest/avm/opcodes/environment_getters.js +17 -16
  51. package/dest/avm/opcodes/external_calls.d.ts +3 -6
  52. package/dest/avm/opcodes/external_calls.d.ts.map +1 -1
  53. package/dest/avm/opcodes/external_calls.js +23 -43
  54. package/dest/avm/opcodes/hashing.d.ts +2 -26
  55. package/dest/avm/opcodes/hashing.d.ts.map +1 -1
  56. package/dest/avm/opcodes/hashing.js +11 -95
  57. package/dest/avm/opcodes/index.d.ts +0 -1
  58. package/dest/avm/opcodes/index.d.ts.map +1 -1
  59. package/dest/avm/opcodes/index.js +1 -2
  60. package/dest/avm/opcodes/instruction.d.ts +1 -0
  61. package/dest/avm/opcodes/instruction.d.ts.map +1 -1
  62. package/dest/avm/opcodes/memory.d.ts +20 -0
  63. package/dest/avm/opcodes/memory.d.ts.map +1 -1
  64. package/dest/avm/opcodes/memory.js +59 -3
  65. package/dest/avm/opcodes/storage.js +3 -3
  66. package/dest/avm/serialization/buffer_cursor.d.ts +1 -0
  67. package/dest/avm/serialization/buffer_cursor.d.ts.map +1 -1
  68. package/dest/avm/serialization/bytecode_serialization.d.ts +1 -0
  69. package/dest/avm/serialization/bytecode_serialization.d.ts.map +1 -1
  70. package/dest/avm/serialization/bytecode_serialization.js +5 -7
  71. package/dest/avm/serialization/instruction_serialization.d.ts +34 -35
  72. package/dest/avm/serialization/instruction_serialization.d.ts.map +1 -1
  73. package/dest/avm/serialization/instruction_serialization.js +34 -36
  74. package/dest/avm/test_utils.d.ts +3 -1
  75. package/dest/avm/test_utils.d.ts.map +1 -1
  76. package/dest/avm/test_utils.js +4 -1
  77. package/dest/client/client_execution_context.d.ts +9 -18
  78. package/dest/client/client_execution_context.d.ts.map +1 -1
  79. package/dest/client/client_execution_context.js +30 -50
  80. package/dest/client/db_oracle.d.ts +17 -1
  81. package/dest/client/db_oracle.d.ts.map +1 -1
  82. package/dest/client/db_oracle.js +1 -1
  83. package/dest/client/private_execution.d.ts.map +1 -1
  84. package/dest/client/private_execution.js +3 -4
  85. package/dest/client/simulator.d.ts.map +1 -1
  86. package/dest/client/simulator.js +3 -3
  87. package/dest/client/view_data_oracle.d.ts +17 -1
  88. package/dest/client/view_data_oracle.d.ts.map +1 -1
  89. package/dest/client/view_data_oracle.js +21 -1
  90. package/dest/common/index.d.ts +0 -1
  91. package/dest/common/index.d.ts.map +1 -1
  92. package/dest/common/index.js +1 -2
  93. package/dest/mocks/fixtures.js +2 -2
  94. package/dest/providers/acvm_native.d.ts +1 -0
  95. package/dest/providers/acvm_native.d.ts.map +1 -1
  96. package/dest/public/db_interfaces.d.ts +1 -0
  97. package/dest/public/db_interfaces.d.ts.map +1 -1
  98. package/dest/public/dual_side_effect_trace.d.ts +10 -11
  99. package/dest/public/dual_side_effect_trace.d.ts.map +1 -1
  100. package/dest/public/dual_side_effect_trace.js +26 -22
  101. package/dest/public/enqueued_call_side_effect_trace.d.ts +11 -12
  102. package/dest/public/enqueued_call_side_effect_trace.d.ts.map +1 -1
  103. package/dest/public/enqueued_call_side_effect_trace.js +33 -23
  104. package/dest/public/enqueued_call_simulator.d.ts +3 -3
  105. package/dest/public/enqueued_call_simulator.d.ts.map +1 -1
  106. package/dest/public/enqueued_call_simulator.js +30 -39
  107. package/dest/public/enqueued_calls_processor.d.ts +2 -3
  108. package/dest/public/enqueued_calls_processor.d.ts.map +1 -1
  109. package/dest/public/enqueued_calls_processor.js +19 -26
  110. package/dest/public/execution.d.ts +1 -0
  111. package/dest/public/execution.d.ts.map +1 -1
  112. package/dest/public/execution.js +2 -2
  113. package/dest/public/executor.d.ts.map +1 -1
  114. package/dest/public/executor.js +6 -5
  115. package/dest/public/public_db_sources.d.ts +1 -0
  116. package/dest/public/public_db_sources.d.ts.map +1 -1
  117. package/dest/public/public_kernel.d.ts +0 -1
  118. package/dest/public/public_kernel.d.ts.map +1 -1
  119. package/dest/public/public_kernel.js +5 -8
  120. package/dest/public/public_kernel_tail_simulator.d.ts +1 -5
  121. package/dest/public/public_kernel_tail_simulator.d.ts.map +1 -1
  122. package/dest/public/public_kernel_tail_simulator.js +6 -12
  123. package/dest/public/public_processor.js +4 -4
  124. package/dest/public/side_effect_trace.d.ts +11 -9
  125. package/dest/public/side_effect_trace.d.ts.map +1 -1
  126. package/dest/public/side_effect_trace.js +40 -30
  127. package/dest/public/side_effect_trace_interface.d.ts +10 -9
  128. package/dest/public/side_effect_trace_interface.d.ts.map +1 -1
  129. package/package.json +9 -9
  130. package/src/acvm/oracle/oracle.ts +13 -6
  131. package/src/acvm/oracle/typed_oracle.ts +9 -3
  132. package/src/avm/avm_context.ts +1 -1
  133. package/src/avm/avm_execution_environment.ts +0 -15
  134. package/src/avm/avm_gas.ts +5 -9
  135. package/src/avm/avm_machine_state.ts +2 -0
  136. package/src/avm/avm_simulator.ts +69 -6
  137. package/src/avm/fixtures/index.ts +7 -2
  138. package/src/avm/journal/journal.ts +93 -50
  139. package/src/avm/journal/nullifiers.ts +23 -23
  140. package/src/avm/journal/public_storage.ts +20 -20
  141. package/src/avm/opcodes/accrued_substate.ts +4 -8
  142. package/src/avm/opcodes/contract.ts +45 -21
  143. package/src/avm/opcodes/conversion.ts +9 -6
  144. package/src/avm/opcodes/environment_getters.ts +7 -5
  145. package/src/avm/opcodes/external_calls.ts +21 -45
  146. package/src/avm/opcodes/hashing.ts +9 -122
  147. package/src/avm/opcodes/index.ts +0 -1
  148. package/src/avm/opcodes/memory.ts +69 -2
  149. package/src/avm/opcodes/storage.ts +2 -2
  150. package/src/avm/serialization/bytecode_serialization.ts +6 -9
  151. package/src/avm/serialization/instruction_serialization.ts +3 -5
  152. package/src/avm/test_utils.ts +5 -1
  153. package/src/client/client_execution_context.ts +21 -71
  154. package/src/client/db_oracle.ts +26 -0
  155. package/src/client/private_execution.ts +1 -9
  156. package/src/client/simulator.ts +0 -2
  157. package/src/client/view_data_oracle.ts +31 -1
  158. package/src/common/index.ts +0 -1
  159. package/src/mocks/fixtures.ts +1 -1
  160. package/src/public/dual_side_effect_trace.ts +38 -24
  161. package/src/public/enqueued_call_side_effect_trace.ts +60 -28
  162. package/src/public/enqueued_call_simulator.ts +52 -49
  163. package/src/public/enqueued_calls_processor.ts +27 -41
  164. package/src/public/execution.ts +1 -1
  165. package/src/public/executor.ts +11 -5
  166. package/src/public/public_kernel.ts +9 -12
  167. package/src/public/public_kernel_tail_simulator.ts +6 -15
  168. package/src/public/public_processor.ts +3 -3
  169. package/src/public/side_effect_trace.ts +73 -29
  170. package/src/public/side_effect_trace_interface.ts +15 -10
  171. package/dest/avm/opcodes/commitment.d.ts +0 -16
  172. package/dest/avm/opcodes/commitment.d.ts.map +0 -1
  173. package/dest/avm/opcodes/commitment.js +0 -51
  174. package/dest/client/test_utils.d.ts +0 -9
  175. package/dest/client/test_utils.d.ts.map +0 -1
  176. package/dest/client/test_utils.js +0 -27
  177. package/dest/common/side_effect_counter.d.ts +0 -10
  178. package/dest/common/side_effect_counter.d.ts.map +0 -1
  179. package/dest/common/side_effect_counter.js +0 -18
  180. package/dest/rollup/index.d.ts +0 -2
  181. package/dest/rollup/index.d.ts.map +0 -1
  182. package/dest/rollup/index.js +0 -2
  183. package/dest/rollup/rollup.d.ts +0 -101
  184. package/dest/rollup/rollup.d.ts.map +0 -1
  185. package/dest/rollup/rollup.js +0 -100
  186. package/src/avm/opcodes/commitment.ts +0 -65
  187. package/src/client/test_utils.ts +0 -57
  188. package/src/common/side_effect_counter.ts +0 -17
  189. package/src/rollup/index.ts +0 -1
  190. package/src/rollup/rollup.ts +0 -228
@@ -1,2 +0,0 @@
1
- export * from './rollup.js';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rollup/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
@@ -1,2 +0,0 @@
1
- export * from './rollup.js';
2
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvcm9sbHVwL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsYUFBYSxDQUFDIn0=
@@ -1,101 +0,0 @@
1
- import { type BaseOrMergeRollupPublicInputs, type BaseParityInputs, type BaseRollupInputs, type BlockMergeRollupInputs, type BlockRootOrBlockMergePublicInputs, type BlockRootRollupInputs, type MergeRollupInputs, type ParityPublicInputs, type RootParityInputs, type RootRollupInputs, type RootRollupPublicInputs } from '@aztec/circuits.js';
2
- import { type SimulationProvider } from '../providers/simulation_provider.js';
3
- /**
4
- * Circuit simulator for the rollup circuits.
5
- */
6
- export interface RollupSimulator {
7
- /**
8
- * Simulates the base parity circuit from its inputs.
9
- * @param inputs - Inputs to the circuit.
10
- * @returns The public inputs of the parity circuit.
11
- */
12
- baseParityCircuit(inputs: BaseParityInputs): Promise<ParityPublicInputs>;
13
- /**
14
- * Simulates the root parity circuit from its inputs.
15
- * @param inputs - Inputs to the circuit.
16
- * @returns The public inputs of the parity circuit.
17
- */
18
- rootParityCircuit(inputs: RootParityInputs): Promise<ParityPublicInputs>;
19
- /**
20
- * Simulates the base rollup circuit from its inputs.
21
- * @param input - Inputs to the circuit.
22
- * @returns The public inputs as outputs of the simulation.
23
- */
24
- baseRollupCircuit(input: BaseRollupInputs): Promise<BaseOrMergeRollupPublicInputs>;
25
- /**
26
- * Simulates the merge rollup circuit from its inputs.
27
- * @param input - Inputs to the circuit.
28
- * @returns The public inputs as outputs of the simulation.
29
- */
30
- mergeRollupCircuit(input: MergeRollupInputs): Promise<BaseOrMergeRollupPublicInputs>;
31
- /**
32
- * Simulates the block root rollup circuit from its inputs.
33
- * @param input - Inputs to the circuit.
34
- * @returns The public inputs as outputs of the simulation.
35
- */
36
- blockRootRollupCircuit(input: BlockRootRollupInputs): Promise<BlockRootOrBlockMergePublicInputs>;
37
- /**
38
- * Simulates the block merge rollup circuit from its inputs.
39
- * @param input - Inputs to the circuit.
40
- * @returns The public inputs as outputs of the simulation.
41
- */
42
- blockMergeRollupCircuit(input: BlockMergeRollupInputs): Promise<BlockRootOrBlockMergePublicInputs>;
43
- /**
44
- * Simulates the root rollup circuit from its inputs.
45
- * @param input - Inputs to the circuit.
46
- * @returns The public inputs as outputs of the simulation.
47
- */
48
- rootRollupCircuit(input: RootRollupInputs): Promise<RootRollupPublicInputs>;
49
- }
50
- /**
51
- * Implements the rollup circuit simulator.
52
- */
53
- export declare class RealRollupCircuitSimulator implements RollupSimulator {
54
- private simulationProvider;
55
- private log;
56
- private wasmSimulator;
57
- constructor(simulationProvider: SimulationProvider);
58
- /**
59
- * Simulates the base parity circuit from its inputs.
60
- * @param inputs - Inputs to the circuit.
61
- * @returns The public inputs of the parity circuit.
62
- */
63
- baseParityCircuit(inputs: BaseParityInputs): Promise<ParityPublicInputs>;
64
- /**
65
- * Simulates the root parity circuit from its inputs.
66
- * @param inputs - Inputs to the circuit.
67
- * @returns The public inputs of the parity circuit.
68
- */
69
- rootParityCircuit(inputs: RootParityInputs): Promise<ParityPublicInputs>;
70
- /**
71
- * Simulates the base rollup circuit from its inputs.
72
- * @param input - Inputs to the circuit.
73
- * @returns The public inputs as outputs of the simulation.
74
- */
75
- baseRollupCircuit(input: BaseRollupInputs): Promise<BaseOrMergeRollupPublicInputs>;
76
- /**
77
- * Simulates the merge rollup circuit from its inputs.
78
- * @param input - Inputs to the circuit.
79
- * @returns The public inputs as outputs of the simulation.
80
- */
81
- mergeRollupCircuit(input: MergeRollupInputs): Promise<BaseOrMergeRollupPublicInputs>;
82
- /**
83
- * Simulates the block root rollup circuit from its inputs.
84
- * @param input - Inputs to the circuit.
85
- * @returns The public inputs as outputs of the simulation.
86
- */
87
- blockRootRollupCircuit(input: BlockRootRollupInputs): Promise<BlockRootOrBlockMergePublicInputs>;
88
- /**
89
- * Simulates the block merge rollup circuit from its inputs.
90
- * @param input - Inputs to the circuit.
91
- * @returns The public inputs as outputs of the simulation.
92
- */
93
- blockMergeRollupCircuit(input: BlockMergeRollupInputs): Promise<BlockRootOrBlockMergePublicInputs>;
94
- /**
95
- * Simulates the root rollup circuit from its inputs.
96
- * @param input - Inputs to the circuit.
97
- * @returns The public inputs as outputs of the simulation.
98
- */
99
- rootRollupCircuit(input: RootRollupInputs): Promise<RootRollupPublicInputs>;
100
- }
101
- //# sourceMappingURL=rollup.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rollup.d.ts","sourceRoot":"","sources":["../../src/rollup/rollup.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,6BAA6B,EAClC,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,iCAAiC,EACtC,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC5B,MAAM,oBAAoB,CAAC;AAsB5B,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,qCAAqC,CA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;;;;OAIG;IACU,sBAAsB,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,iCAAiC,CAAC;IAa7G;;;;OAIG;IACU,uBAAuB,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,iCAAiC,CAAC;IAa/G;;;;OAIG;IACU,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,sBAAsB,CAAC;CAkBzF"}
@@ -1,100 +0,0 @@
1
- import { createDebugLogger } from '@aztec/foundation/log';
2
- import { elapsed } from '@aztec/foundation/timer';
3
- import { SimulatedServerCircuitArtifacts, convertBaseParityInputsToWitnessMap, convertBaseParityOutputsFromWitnessMap, convertBlockMergeRollupInputsToWitnessMap, convertBlockMergeRollupOutputsFromWitnessMap, convertBlockRootRollupInputsToWitnessMap, convertBlockRootRollupOutputsFromWitnessMap, convertMergeRollupInputsToWitnessMap, convertMergeRollupOutputsFromWitnessMap, convertRootParityInputsToWitnessMap, convertRootParityOutputsFromWitnessMap, convertRootRollupInputsToWitnessMap, convertRootRollupOutputsFromWitnessMap, convertSimulatedBaseRollupInputsToWitnessMap, convertSimulatedBaseRollupOutputsFromWitnessMap, } from '@aztec/noir-protocol-circuits-types';
4
- import { WASMSimulator } from '../providers/acvm_wasm.js';
5
- /**
6
- * Implements the rollup circuit simulator.
7
- */
8
- export class RealRollupCircuitSimulator {
9
- constructor(simulationProvider) {
10
- this.simulationProvider = simulationProvider;
11
- this.log = createDebugLogger('aztec:rollup-simulator');
12
- // Some circuits are so small it is faster to use WASM
13
- this.wasmSimulator = new WASMSimulator();
14
- }
15
- /**
16
- * Simulates the base parity circuit from its inputs.
17
- * @param inputs - Inputs to the circuit.
18
- * @returns The public inputs of the parity circuit.
19
- */
20
- async baseParityCircuit(inputs) {
21
- const witnessMap = convertBaseParityInputsToWitnessMap(inputs);
22
- const witness = await this.simulationProvider.simulateCircuit(witnessMap, SimulatedServerCircuitArtifacts.BaseParityArtifact);
23
- const result = convertBaseParityOutputsFromWitnessMap(witness);
24
- return Promise.resolve(result);
25
- }
26
- /**
27
- * Simulates the root parity circuit from its inputs.
28
- * @param inputs - Inputs to the circuit.
29
- * @returns The public inputs of the parity circuit.
30
- */
31
- async rootParityCircuit(inputs) {
32
- const witnessMap = convertRootParityInputsToWitnessMap(inputs);
33
- const witness = await this.simulationProvider.simulateCircuit(witnessMap, SimulatedServerCircuitArtifacts.RootParityArtifact);
34
- const result = convertRootParityOutputsFromWitnessMap(witness);
35
- return Promise.resolve(result);
36
- }
37
- /**
38
- * Simulates the base rollup circuit from its inputs.
39
- * @param input - Inputs to the circuit.
40
- * @returns The public inputs as outputs of the simulation.
41
- */
42
- async baseRollupCircuit(input) {
43
- const witnessMap = convertSimulatedBaseRollupInputsToWitnessMap(input);
44
- const witness = await this.simulationProvider.simulateCircuit(witnessMap, SimulatedServerCircuitArtifacts.BaseRollupArtifact);
45
- const result = convertSimulatedBaseRollupOutputsFromWitnessMap(witness);
46
- return Promise.resolve(result);
47
- }
48
- /**
49
- * Simulates the merge rollup circuit from its inputs.
50
- * @param input - Inputs to the circuit.
51
- * @returns The public inputs as outputs of the simulation.
52
- */
53
- async mergeRollupCircuit(input) {
54
- const witnessMap = convertMergeRollupInputsToWitnessMap(input);
55
- const witness = await this.wasmSimulator.simulateCircuit(witnessMap, SimulatedServerCircuitArtifacts.MergeRollupArtifact);
56
- const result = convertMergeRollupOutputsFromWitnessMap(witness);
57
- return result;
58
- }
59
- /**
60
- * Simulates the block root rollup circuit from its inputs.
61
- * @param input - Inputs to the circuit.
62
- * @returns The public inputs as outputs of the simulation.
63
- */
64
- async blockRootRollupCircuit(input) {
65
- const witnessMap = convertBlockRootRollupInputsToWitnessMap(input);
66
- const witness = await this.wasmSimulator.simulateCircuit(witnessMap, SimulatedServerCircuitArtifacts.BlockRootRollupArtifact);
67
- const result = convertBlockRootRollupOutputsFromWitnessMap(witness);
68
- return Promise.resolve(result);
69
- }
70
- /**
71
- * Simulates the block merge rollup circuit from its inputs.
72
- * @param input - Inputs to the circuit.
73
- * @returns The public inputs as outputs of the simulation.
74
- */
75
- async blockMergeRollupCircuit(input) {
76
- const witnessMap = convertBlockMergeRollupInputsToWitnessMap(input);
77
- const witness = await this.wasmSimulator.simulateCircuit(witnessMap, SimulatedServerCircuitArtifacts.BlockMergeRollupArtifact);
78
- const result = convertBlockMergeRollupOutputsFromWitnessMap(witness);
79
- return Promise.resolve(result);
80
- }
81
- /**
82
- * Simulates the root rollup circuit from its inputs.
83
- * @param input - Inputs to the circuit.
84
- * @returns The public inputs as outputs of the simulation.
85
- */
86
- async rootRollupCircuit(input) {
87
- const witnessMap = convertRootRollupInputsToWitnessMap(input);
88
- const [duration, witness] = await elapsed(() => this.wasmSimulator.simulateCircuit(witnessMap, SimulatedServerCircuitArtifacts.RootRollupArtifact));
89
- const result = convertRootRollupOutputsFromWitnessMap(witness);
90
- this.log.debug(`Simulated root rollup circuit`, {
91
- eventName: 'circuit-simulation',
92
- circuitName: 'root-rollup',
93
- duration,
94
- inputSize: input.toBuffer().length,
95
- outputSize: result.toBuffer().length,
96
- });
97
- return result;
98
- }
99
- }
100
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicm9sbHVwLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3JvbGx1cC9yb2xsdXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBY0EsT0FBTyxFQUFFLGlCQUFpQixFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFDMUQsT0FBTyxFQUFFLE9BQU8sRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBQ2xELE9BQU8sRUFDTCwrQkFBK0IsRUFDL0IsbUNBQW1DLEVBQ25DLHNDQUFzQyxFQUN0Qyx5Q0FBeUMsRUFDekMsNENBQTRDLEVBQzVDLHdDQUF3QyxFQUN4QywyQ0FBMkMsRUFDM0Msb0NBQW9DLEVBQ3BDLHVDQUF1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LENBQUM7UUFFRixNQUFNLE1BQU0sR0FBRyxzQ0FBc0MsQ0FBQyxPQUFPLENBQUMsQ0FBQztRQUUvRCxJQUFJLENBQUMsR0FBRyxDQUFDLEtBQUssQ0FBQywrQkFBK0IsRUFBRTtZQUM5QyxTQUFTLEVBQUUsb0JBQW9CO1lBQy9CLFdBQVcsRUFBRSxhQUFhO1lBQzFCLFFBQVE7WUFDUixTQUFTLEVBQUUsS0FBSyxDQUFDLFFBQVEsRUFBRSxDQUFDLE1BQU07WUFDbEMsVUFBVSxFQUFFLE1BQU0sQ0FBQyxRQUFRLEVBQUUsQ0FBQyxNQUFNO1NBQ0osQ0FBQyxDQUFDO1FBQ3BDLE9BQU8sTUFBTSxDQUFDO0lBQ2hCLENBQUM7Q0FDRiJ9
@@ -1,65 +0,0 @@
1
- import { pedersenCommit } from '@aztec/foundation/crypto';
2
-
3
- import { type AvmContext } from '../avm_context.js';
4
- import { Field, TypeTag, Uint8 } from '../avm_memory_types.js';
5
- import { Opcode, OperandType } from '../serialization/instruction_serialization.js';
6
- import { Addressing } from './addressing_mode.js';
7
- import { Instruction } from './instruction.js';
8
-
9
- export class PedersenCommitment extends Instruction {
10
- static type: string = 'PEDERSENCOMMITMENT';
11
- static readonly opcode: Opcode = Opcode.PEDERSENCOMMITMENT;
12
-
13
- // Informs (de)serialization. See Instruction.deserialize.
14
- static readonly wireFormat: OperandType[] = [
15
- OperandType.UINT8 /* Opcode */,
16
- OperandType.UINT8 /* Indirect */,
17
- OperandType.UINT32 /* Input Offset*/,
18
- OperandType.UINT32 /* Dst Offset */,
19
- OperandType.UINT32 /* Input Size Offset */,
20
- OperandType.UINT32 /* Generator Index Offset */,
21
- ];
22
-
23
- constructor(
24
- private indirect: number,
25
- private inputOffset: number,
26
- private outputOffset: number,
27
- private inputSizeOffset: number,
28
- private genIndexOffset: number,
29
- ) {
30
- super();
31
- }
32
-
33
- public async execute(context: AvmContext): Promise<void> {
34
- const memory = context.machineState.memory.track(this.type);
35
-
36
- const operands = [this.inputOffset, this.outputOffset, this.inputSizeOffset, this.genIndexOffset];
37
- const addressing = Addressing.fromWire(this.indirect, operands.length);
38
- const [inputOffset, outputOffset, inputSizeOffset, genIndexOffset] = addressing.resolve(operands, memory);
39
-
40
- const inputSize = memory.get(inputSizeOffset).toNumber();
41
- memory.checkTag(TypeTag.UINT32, inputSizeOffset);
42
-
43
- const inputs = memory.getSlice(inputOffset, inputSize);
44
- memory.checkTagsRange(TypeTag.FIELD, inputOffset, inputSize);
45
-
46
- const generatorIndex = memory.get(genIndexOffset).toNumber();
47
- memory.checkTag(TypeTag.UINT32, genIndexOffset);
48
-
49
- context.machineState.consumeGas(this.gasCost(inputSize));
50
-
51
- const inputBuffer: Buffer[] = inputs.map(input => input.toBuffer());
52
- // TODO: Add the generate index to the pedersenCommit function
53
- const commitment = pedersenCommit(inputBuffer, generatorIndex).map(f => new Field(f));
54
- // The function doesnt include a flag if the output point is infinity, come back to this
55
- // for now we just check if theyre zero - until we know how bb encodes them
56
- const isInfinity = commitment[0].equals(new Field(0)) && commitment[1].equals(new Field(0));
57
-
58
- memory.set(outputOffset, commitment[0]); // Field typed
59
- memory.set(outputOffset + 1, commitment[1]); // Field typed
60
- memory.set(outputOffset + 2, new Uint8(isInfinity ? 1 : 0)); // U8 typed
61
-
62
- memory.assert({ reads: inputSize + 2, writes: 3, addressing });
63
- context.machineState.incrementPc();
64
- }
65
- }
@@ -1,57 +0,0 @@
1
- import { Fq, Fr, Point } from '@aztec/circuits.js';
2
- import { Grumpkin } from '@aztec/circuits.js/barretenberg';
3
-
4
- // Copied over from `noir-projects/aztec-nr/aztec/src/generators.nr`
5
- const GENERATORS = [
6
- new Point(
7
- new Fr(0x30426e64aee30e998c13c8ceecda3a77807dbead52bc2f3bf0eae851b4b710c1n),
8
- new Fr(0x113156a068f603023240c96b4da5474667db3b8711c521c748212a15bc034ea6n),
9
- false,
10
- ),
11
- new Point(
12
- new Fr(0x2825c79cc6a5cbbeef7d6a8f1b6a12b312aa338440aefeb4396148c89147c049n),
13
- new Fr(0x129bfd1da54b7062d6b544e7e36b90736350f6fba01228c41c72099509f5701en),
14
- false,
15
- ),
16
- new Point(
17
- new Fr(0x0edb1e293c3ce91bfc04e3ceaa50d2c541fa9d091c72eb403efb1cfa2cb3357fn),
18
- new Fr(0x1341d675fa030ece3113ad53ca34fd13b19b6e9762046734f414824c4d6ade35n),
19
- false,
20
- ),
21
- new Point(
22
- new Fr(0x0e0dad2250583f2a9f0acb04ededf1701b85b0393cae753fe7e14b88af81cb52n),
23
- new Fr(0x0973b02c5caac339ee4ad5dab51329920f7bf1b6a07e1dabe5df67040b300962n),
24
- false,
25
- ),
26
- new Point(
27
- new Fr(0x2f3342e900e8c488a28931aae68970738fdc68afde2910de7b320c00c902087dn),
28
- new Fr(0x1bf958dc63cb09d59230603a0269ae86d6f92494da244910351f1132df20fc08n),
29
- false,
30
- ),
31
- ];
32
-
33
- const G_SLOT = new Point(
34
- new Fr(0x041223147b680850dc82e8a55a952d4df20256fe0593d949a9541ca00f0abf15n),
35
- new Fr(0x0a8c72e60d0e60f5d804549d48f3044d06140b98ed717a9b532af630c1530791n),
36
- false,
37
- );
38
-
39
- /**
40
- * Computes a note hiding point as is done by the default implementation injected by macros.
41
- * @param storageSlot - The slot to which the note was inserted.
42
- * @param noteContent - The note content (e.g. note.items).
43
- * @returns A note hash.
44
- */
45
- export function computeNoteHash(storageSlot: Fr, noteContent: Fr[]): Fr {
46
- const grumpkin = new Grumpkin();
47
- const noteHidingPointBeforeSlotting = noteContent
48
- .slice(1)
49
- .reduce(
50
- (acc, item, i) => grumpkin.add(acc, grumpkin.mul(GENERATORS[i + 1], new Fq(item.toBigInt()))),
51
- grumpkin.mul(GENERATORS[0], new Fq(noteContent[0].toBigInt())),
52
- );
53
-
54
- const slotPoint = grumpkin.mul(G_SLOT, new Fq(storageSlot.toBigInt()));
55
- const noteHidingPoint = grumpkin.add(noteHidingPointBeforeSlotting, slotPoint);
56
- return noteHidingPoint.x;
57
- }
@@ -1,17 +0,0 @@
1
- /**
2
- * Keep track of the number of side effects across execution contexts.
3
- */
4
- export class SideEffectCounter {
5
- constructor(private value = 0) {}
6
-
7
- // TODO(alexg) remove this once public side effect counters is fully accounted for on Noir side
8
- current() {
9
- return this.value;
10
- }
11
-
12
- count() {
13
- const value = this.value;
14
- this.value++;
15
- return value;
16
- }
17
- }
@@ -1 +0,0 @@
1
- export * from './rollup.js';
@@ -1,228 +0,0 @@
1
- import { type CircuitSimulationStats } from '@aztec/circuit-types/stats';
2
- import {
3
- type BaseOrMergeRollupPublicInputs,
4
- type BaseParityInputs,
5
- type BaseRollupInputs,
6
- type BlockMergeRollupInputs,
7
- type BlockRootOrBlockMergePublicInputs,
8
- type BlockRootRollupInputs,
9
- type MergeRollupInputs,
10
- type ParityPublicInputs,
11
- type RootParityInputs,
12
- type RootRollupInputs,
13
- type RootRollupPublicInputs,
14
- } from '@aztec/circuits.js';
15
- import { createDebugLogger } from '@aztec/foundation/log';
16
- import { elapsed } from '@aztec/foundation/timer';
17
- import {
18
- SimulatedServerCircuitArtifacts,
19
- convertBaseParityInputsToWitnessMap,
20
- convertBaseParityOutputsFromWitnessMap,
21
- convertBlockMergeRollupInputsToWitnessMap,
22
- convertBlockMergeRollupOutputsFromWitnessMap,
23
- convertBlockRootRollupInputsToWitnessMap,
24
- convertBlockRootRollupOutputsFromWitnessMap,
25
- convertMergeRollupInputsToWitnessMap,
26
- convertMergeRollupOutputsFromWitnessMap,
27
- convertRootParityInputsToWitnessMap,
28
- convertRootParityOutputsFromWitnessMap,
29
- convertRootRollupInputsToWitnessMap,
30
- convertRootRollupOutputsFromWitnessMap,
31
- convertSimulatedBaseRollupInputsToWitnessMap,
32
- convertSimulatedBaseRollupOutputsFromWitnessMap,
33
- } from '@aztec/noir-protocol-circuits-types';
34
-
35
- import { WASMSimulator } from '../providers/acvm_wasm.js';
36
- import { type SimulationProvider } from '../providers/simulation_provider.js';
37
-
38
- /**
39
- * Circuit simulator for the rollup circuits.
40
- */
41
- export interface RollupSimulator {
42
- /**
43
- * Simulates the base parity circuit from its inputs.
44
- * @param inputs - Inputs to the circuit.
45
- * @returns The public inputs of the parity circuit.
46
- */
47
- baseParityCircuit(inputs: BaseParityInputs): Promise<ParityPublicInputs>;
48
- /**
49
- * Simulates the root parity circuit from its inputs.
50
- * @param inputs - Inputs to the circuit.
51
- * @returns The public inputs of the parity circuit.
52
- */
53
- rootParityCircuit(inputs: RootParityInputs): Promise<ParityPublicInputs>;
54
- /**
55
- * Simulates the base rollup circuit from its inputs.
56
- * @param input - Inputs to the circuit.
57
- * @returns The public inputs as outputs of the simulation.
58
- */
59
- baseRollupCircuit(input: BaseRollupInputs): Promise<BaseOrMergeRollupPublicInputs>;
60
- /**
61
- * Simulates the merge rollup circuit from its inputs.
62
- * @param input - Inputs to the circuit.
63
- * @returns The public inputs as outputs of the simulation.
64
- */
65
- mergeRollupCircuit(input: MergeRollupInputs): Promise<BaseOrMergeRollupPublicInputs>;
66
- /**
67
- * Simulates the block root rollup circuit from its inputs.
68
- * @param input - Inputs to the circuit.
69
- * @returns The public inputs as outputs of the simulation.
70
- */
71
- blockRootRollupCircuit(input: BlockRootRollupInputs): Promise<BlockRootOrBlockMergePublicInputs>;
72
- /**
73
- * Simulates the block merge rollup circuit from its inputs.
74
- * @param input - Inputs to the circuit.
75
- * @returns The public inputs as outputs of the simulation.
76
- */
77
- blockMergeRollupCircuit(input: BlockMergeRollupInputs): Promise<BlockRootOrBlockMergePublicInputs>;
78
- /**
79
- * Simulates the root rollup circuit from its inputs.
80
- * @param input - Inputs to the circuit.
81
- * @returns The public inputs as outputs of the simulation.
82
- */
83
- rootRollupCircuit(input: RootRollupInputs): Promise<RootRollupPublicInputs>;
84
- }
85
-
86
- /**
87
- * Implements the rollup circuit simulator.
88
- */
89
- export class RealRollupCircuitSimulator implements RollupSimulator {
90
- private log = createDebugLogger('aztec:rollup-simulator');
91
-
92
- // Some circuits are so small it is faster to use WASM
93
- private wasmSimulator: WASMSimulator = new WASMSimulator();
94
-
95
- constructor(private simulationProvider: SimulationProvider) {}
96
-
97
- /**
98
- * Simulates the base parity circuit from its inputs.
99
- * @param inputs - Inputs to the circuit.
100
- * @returns The public inputs of the parity circuit.
101
- */
102
- public async baseParityCircuit(inputs: BaseParityInputs): Promise<ParityPublicInputs> {
103
- const witnessMap = convertBaseParityInputsToWitnessMap(inputs);
104
-
105
- const witness = await this.simulationProvider.simulateCircuit(
106
- witnessMap,
107
- SimulatedServerCircuitArtifacts.BaseParityArtifact,
108
- );
109
-
110
- const result = convertBaseParityOutputsFromWitnessMap(witness);
111
-
112
- return Promise.resolve(result);
113
- }
114
-
115
- /**
116
- * Simulates the root parity circuit from its inputs.
117
- * @param inputs - Inputs to the circuit.
118
- * @returns The public inputs of the parity circuit.
119
- */
120
- public async rootParityCircuit(inputs: RootParityInputs): Promise<ParityPublicInputs> {
121
- const witnessMap = convertRootParityInputsToWitnessMap(inputs);
122
-
123
- const witness = await this.simulationProvider.simulateCircuit(
124
- witnessMap,
125
- SimulatedServerCircuitArtifacts.RootParityArtifact,
126
- );
127
-
128
- const result = convertRootParityOutputsFromWitnessMap(witness);
129
-
130
- return Promise.resolve(result);
131
- }
132
-
133
- /**
134
- * Simulates the base rollup circuit from its inputs.
135
- * @param input - Inputs to the circuit.
136
- * @returns The public inputs as outputs of the simulation.
137
- */
138
- public async baseRollupCircuit(input: BaseRollupInputs): Promise<BaseOrMergeRollupPublicInputs> {
139
- const witnessMap = convertSimulatedBaseRollupInputsToWitnessMap(input);
140
-
141
- const witness = await this.simulationProvider.simulateCircuit(
142
- witnessMap,
143
- SimulatedServerCircuitArtifacts.BaseRollupArtifact,
144
- );
145
-
146
- const result = convertSimulatedBaseRollupOutputsFromWitnessMap(witness);
147
-
148
- return Promise.resolve(result);
149
- }
150
-
151
- /**
152
- * Simulates the merge rollup circuit from its inputs.
153
- * @param input - Inputs to the circuit.
154
- * @returns The public inputs as outputs of the simulation.
155
- */
156
- public async mergeRollupCircuit(input: MergeRollupInputs): Promise<BaseOrMergeRollupPublicInputs> {
157
- const witnessMap = convertMergeRollupInputsToWitnessMap(input);
158
-
159
- const witness = await this.wasmSimulator.simulateCircuit(
160
- witnessMap,
161
- SimulatedServerCircuitArtifacts.MergeRollupArtifact,
162
- );
163
-
164
- const result = convertMergeRollupOutputsFromWitnessMap(witness);
165
-
166
- return result;
167
- }
168
-
169
- /**
170
- * Simulates the block root rollup circuit from its inputs.
171
- * @param input - Inputs to the circuit.
172
- * @returns The public inputs as outputs of the simulation.
173
- */
174
- public async blockRootRollupCircuit(input: BlockRootRollupInputs): Promise<BlockRootOrBlockMergePublicInputs> {
175
- const witnessMap = convertBlockRootRollupInputsToWitnessMap(input);
176
-
177
- const witness = await this.wasmSimulator.simulateCircuit(
178
- witnessMap,
179
- SimulatedServerCircuitArtifacts.BlockRootRollupArtifact,
180
- );
181
-
182
- const result = convertBlockRootRollupOutputsFromWitnessMap(witness);
183
-
184
- return Promise.resolve(result);
185
- }
186
-
187
- /**
188
- * Simulates the block merge rollup circuit from its inputs.
189
- * @param input - Inputs to the circuit.
190
- * @returns The public inputs as outputs of the simulation.
191
- */
192
- public async blockMergeRollupCircuit(input: BlockMergeRollupInputs): Promise<BlockRootOrBlockMergePublicInputs> {
193
- const witnessMap = convertBlockMergeRollupInputsToWitnessMap(input);
194
-
195
- const witness = await this.wasmSimulator.simulateCircuit(
196
- witnessMap,
197
- SimulatedServerCircuitArtifacts.BlockMergeRollupArtifact,
198
- );
199
-
200
- const result = convertBlockMergeRollupOutputsFromWitnessMap(witness);
201
-
202
- return Promise.resolve(result);
203
- }
204
-
205
- /**
206
- * Simulates the root rollup circuit from its inputs.
207
- * @param input - Inputs to the circuit.
208
- * @returns The public inputs as outputs of the simulation.
209
- */
210
- public async rootRollupCircuit(input: RootRollupInputs): Promise<RootRollupPublicInputs> {
211
- const witnessMap = convertRootRollupInputsToWitnessMap(input);
212
-
213
- const [duration, witness] = await elapsed(() =>
214
- this.wasmSimulator.simulateCircuit(witnessMap, SimulatedServerCircuitArtifacts.RootRollupArtifact),
215
- );
216
-
217
- const result = convertRootRollupOutputsFromWitnessMap(witness);
218
-
219
- this.log.debug(`Simulated root rollup circuit`, {
220
- eventName: 'circuit-simulation',
221
- circuitName: 'root-rollup',
222
- duration,
223
- inputSize: input.toBuffer().length,
224
- outputSize: result.toBuffer().length,
225
- } satisfies CircuitSimulationStats);
226
- return result;
227
- }
228
- }