@aztec/simulator 0.60.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 (124) hide show
  1. package/dest/acvm/oracle/oracle.d.ts +2 -0
  2. package/dest/acvm/oracle/oracle.d.ts.map +1 -1
  3. package/dest/acvm/oracle/oracle.js +9 -1
  4. package/dest/acvm/oracle/typed_oracle.d.ts +3 -1
  5. package/dest/acvm/oracle/typed_oracle.d.ts.map +1 -1
  6. package/dest/acvm/oracle/typed_oracle.js +7 -1
  7. package/dest/avm/avm_gas.d.ts.map +1 -1
  8. package/dest/avm/avm_gas.js +6 -3
  9. package/dest/avm/avm_machine_state.d.ts +2 -0
  10. package/dest/avm/avm_machine_state.d.ts.map +1 -1
  11. package/dest/avm/avm_machine_state.js +3 -1
  12. package/dest/avm/avm_simulator.d.ts +15 -0
  13. package/dest/avm/avm_simulator.d.ts.map +1 -1
  14. package/dest/avm/avm_simulator.js +45 -4
  15. package/dest/avm/fixtures/index.d.ts +1 -1
  16. package/dest/avm/fixtures/index.d.ts.map +1 -1
  17. package/dest/avm/fixtures/index.js +7 -7
  18. package/dest/avm/journal/journal.d.ts +5 -6
  19. package/dest/avm/journal/journal.d.ts.map +1 -1
  20. package/dest/avm/journal/journal.js +42 -17
  21. package/dest/avm/opcodes/contract.d.ts +8 -1
  22. package/dest/avm/opcodes/contract.d.ts.map +1 -1
  23. package/dest/avm/opcodes/contract.js +41 -21
  24. package/dest/avm/opcodes/conversion.d.ts +1 -1
  25. package/dest/avm/opcodes/conversion.d.ts.map +1 -1
  26. package/dest/avm/opcodes/conversion.js +12 -9
  27. package/dest/avm/opcodes/environment_getters.d.ts +1 -1
  28. package/dest/avm/opcodes/environment_getters.d.ts.map +1 -1
  29. package/dest/avm/opcodes/environment_getters.js +5 -1
  30. package/dest/avm/opcodes/external_calls.d.ts +3 -6
  31. package/dest/avm/opcodes/external_calls.d.ts.map +1 -1
  32. package/dest/avm/opcodes/external_calls.js +23 -43
  33. package/dest/avm/opcodes/memory.d.ts +20 -0
  34. package/dest/avm/opcodes/memory.d.ts.map +1 -1
  35. package/dest/avm/opcodes/memory.js +59 -3
  36. package/dest/avm/serialization/bytecode_serialization.d.ts.map +1 -1
  37. package/dest/avm/serialization/bytecode_serialization.js +5 -3
  38. package/dest/avm/serialization/instruction_serialization.d.ts +36 -34
  39. package/dest/avm/serialization/instruction_serialization.d.ts.map +1 -1
  40. package/dest/avm/serialization/instruction_serialization.js +37 -35
  41. package/dest/avm/test_utils.d.ts +2 -1
  42. package/dest/avm/test_utils.d.ts.map +1 -1
  43. package/dest/avm/test_utils.js +4 -1
  44. package/dest/client/client_execution_context.d.ts +0 -8
  45. package/dest/client/client_execution_context.d.ts.map +1 -1
  46. package/dest/client/client_execution_context.js +1 -18
  47. package/dest/client/db_oracle.d.ts +17 -1
  48. package/dest/client/db_oracle.d.ts.map +1 -1
  49. package/dest/client/db_oracle.js +1 -1
  50. package/dest/client/view_data_oracle.d.ts +17 -1
  51. package/dest/client/view_data_oracle.d.ts.map +1 -1
  52. package/dest/client/view_data_oracle.js +21 -1
  53. package/dest/common/index.d.ts +0 -1
  54. package/dest/common/index.d.ts.map +1 -1
  55. package/dest/common/index.js +1 -2
  56. package/dest/public/dual_side_effect_trace.d.ts +3 -5
  57. package/dest/public/dual_side_effect_trace.d.ts.map +1 -1
  58. package/dest/public/dual_side_effect_trace.js +8 -4
  59. package/dest/public/enqueued_call_side_effect_trace.d.ts +4 -6
  60. package/dest/public/enqueued_call_side_effect_trace.d.ts.map +1 -1
  61. package/dest/public/enqueued_call_side_effect_trace.js +19 -7
  62. package/dest/public/enqueued_call_simulator.d.ts +2 -2
  63. package/dest/public/enqueued_call_simulator.d.ts.map +1 -1
  64. package/dest/public/enqueued_call_simulator.js +21 -29
  65. package/dest/public/enqueued_calls_processor.d.ts +2 -3
  66. package/dest/public/enqueued_calls_processor.d.ts.map +1 -1
  67. package/dest/public/enqueued_calls_processor.js +18 -25
  68. package/dest/public/public_kernel.d.ts +0 -1
  69. package/dest/public/public_kernel.d.ts.map +1 -1
  70. package/dest/public/public_kernel.js +5 -8
  71. package/dest/public/public_kernel_tail_simulator.d.ts +1 -5
  72. package/dest/public/public_kernel_tail_simulator.d.ts.map +1 -1
  73. package/dest/public/public_kernel_tail_simulator.js +6 -12
  74. package/dest/public/public_processor.js +4 -4
  75. package/dest/public/side_effect_trace.d.ts +4 -3
  76. package/dest/public/side_effect_trace.d.ts.map +1 -1
  77. package/dest/public/side_effect_trace.js +27 -16
  78. package/dest/public/side_effect_trace_interface.d.ts +3 -3
  79. package/dest/public/side_effect_trace_interface.d.ts.map +1 -1
  80. package/package.json +9 -9
  81. package/src/acvm/oracle/oracle.ts +13 -0
  82. package/src/acvm/oracle/typed_oracle.ts +9 -0
  83. package/src/avm/avm_gas.ts +5 -2
  84. package/src/avm/avm_machine_state.ts +2 -0
  85. package/src/avm/avm_simulator.ts +69 -6
  86. package/src/avm/fixtures/index.ts +7 -7
  87. package/src/avm/journal/journal.ts +62 -19
  88. package/src/avm/opcodes/contract.ts +45 -21
  89. package/src/avm/opcodes/conversion.ts +9 -6
  90. package/src/avm/opcodes/environment_getters.ts +7 -2
  91. package/src/avm/opcodes/external_calls.ts +21 -45
  92. package/src/avm/opcodes/memory.ts +69 -2
  93. package/src/avm/serialization/bytecode_serialization.ts +6 -2
  94. package/src/avm/serialization/instruction_serialization.ts +3 -1
  95. package/src/avm/test_utils.ts +5 -1
  96. package/src/client/client_execution_context.ts +0 -27
  97. package/src/client/db_oracle.ts +26 -0
  98. package/src/client/view_data_oracle.ts +31 -1
  99. package/src/common/index.ts +0 -1
  100. package/src/public/dual_side_effect_trace.ts +20 -6
  101. package/src/public/enqueued_call_side_effect_trace.ts +46 -8
  102. package/src/public/enqueued_call_simulator.ts +42 -26
  103. package/src/public/enqueued_calls_processor.ts +26 -38
  104. package/src/public/public_kernel.ts +9 -12
  105. package/src/public/public_kernel_tail_simulator.ts +6 -15
  106. package/src/public/public_processor.ts +3 -3
  107. package/src/public/side_effect_trace.ts +54 -15
  108. package/src/public/side_effect_trace_interface.ts +9 -4
  109. package/dest/client/test_utils.d.ts +0 -9
  110. package/dest/client/test_utils.d.ts.map +0 -1
  111. package/dest/client/test_utils.js +0 -27
  112. package/dest/common/side_effect_counter.d.ts +0 -10
  113. package/dest/common/side_effect_counter.d.ts.map +0 -1
  114. package/dest/common/side_effect_counter.js +0 -18
  115. package/dest/rollup/index.d.ts +0 -2
  116. package/dest/rollup/index.d.ts.map +0 -1
  117. package/dest/rollup/index.js +0 -2
  118. package/dest/rollup/rollup.d.ts +0 -101
  119. package/dest/rollup/rollup.d.ts.map +0 -1
  120. package/dest/rollup/rollup.js +0 -100
  121. package/src/client/test_utils.ts +0 -57
  122. package/src/common/side_effect_counter.ts +0 -17
  123. package/src/rollup/index.ts +0 -1
  124. package/src/rollup/rollup.ts +0 -228
@@ -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,CAAC;AAE9E;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACzE;;;;OAI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O,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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicm9sbHVwLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3JvbGx1cC9yb2xsdXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBY0EsT0FBTyxFQUFFLGlCQUFpQixFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFDMUQsT0FBTyxFQUFFLE9BQU8sRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBQ2xELE9BQU8sRUFDTCwrQkFBK0IsRUFDL0IsbUNBQW1DLEVBQ25DLHNDQUFzQyxFQUN0Qyx5Q0FBeUMsRUFDekMsNENBQTRDLEVBQzVDLHdDQUF3QyxFQUN4QywyQ0FBMkMsRUFDM0Msb0NBQW9DLEVBQ3BDLHVDQUF1QyxFQUN2QyxtQ0FBbUMsRUFDbkMsc0NBQXNDLEVBQ3RDLG1DQUFtQyxFQUNuQyxzQ0FBc0MsRUFDdEMsNENBQTRDLEVBQzVDLCtDQUErQyxHQUNoRCxNQUFNLHF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sRUFBRTtZQUM5QyxTQUFTLEVBQUUsb0JBQW9CO1lBQy9CLFdBQVcsRUFBRSxhQUFhO1lBQzFCLFFBQVE7WUFDUixTQUFTLEVBQUUsS0FBSyxDQUFDLFFBQVEsRUFBRSxDQUFDLE1BQU07WUFDbEMsVUFBVSxFQUFFLE1BQU0sQ0FBQyxRQUFRLEVBQUUsQ0FBQyxNQUFNO1NBQ0osQ0FBQyxDQUFDO1FBQ3BDLE9BQU8sTUFBTSxDQUFDO0lBQ2hCLENBQUM7Q0FDRiJ9
@@ -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
- }