@aztec/sequencer-client 0.30.0 → 0.31.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 (104) hide show
  1. package/dest/client/sequencer-client.d.ts +5 -1
  2. package/dest/client/sequencer-client.d.ts.map +1 -1
  3. package/dest/client/sequencer-client.js +5 -34
  4. package/dest/index.d.ts +0 -7
  5. package/dest/index.d.ts.map +1 -1
  6. package/dest/index.js +1 -8
  7. package/dest/publisher/viem-tx-sender.d.ts.map +1 -1
  8. package/dest/publisher/viem-tx-sender.js +2 -3
  9. package/dest/sequencer/abstract_phase_manager.d.ts +1 -3
  10. package/dest/sequencer/abstract_phase_manager.d.ts.map +1 -1
  11. package/dest/sequencer/abstract_phase_manager.js +13 -17
  12. package/dest/sequencer/app_logic_phase_manager.d.ts +1 -3
  13. package/dest/sequencer/app_logic_phase_manager.d.ts.map +1 -1
  14. package/dest/sequencer/app_logic_phase_manager.js +3 -4
  15. package/dest/sequencer/phase_manager_factory.d.ts +2 -3
  16. package/dest/sequencer/phase_manager_factory.d.ts.map +1 -1
  17. package/dest/sequencer/phase_manager_factory.js +9 -9
  18. package/dest/sequencer/public_processor.d.ts +3 -7
  19. package/dest/sequencer/public_processor.d.ts.map +1 -1
  20. package/dest/sequencer/public_processor.js +6 -9
  21. package/dest/sequencer/sequencer.d.ts +4 -5
  22. package/dest/sequencer/sequencer.d.ts.map +1 -1
  23. package/dest/sequencer/sequencer.js +13 -12
  24. package/dest/sequencer/setup_phase_manager.d.ts +1 -3
  25. package/dest/sequencer/setup_phase_manager.d.ts.map +1 -1
  26. package/dest/sequencer/setup_phase_manager.js +3 -4
  27. package/dest/sequencer/tail_phase_manager.d.ts +1 -3
  28. package/dest/sequencer/tail_phase_manager.d.ts.map +1 -1
  29. package/dest/sequencer/tail_phase_manager.js +3 -4
  30. package/dest/sequencer/teardown_phase_manager.d.ts +1 -3
  31. package/dest/sequencer/teardown_phase_manager.d.ts.map +1 -1
  32. package/dest/sequencer/teardown_phase_manager.js +3 -4
  33. package/dest/sequencer/tx_validator.d.ts +1 -2
  34. package/dest/sequencer/tx_validator.d.ts.map +1 -1
  35. package/dest/sequencer/tx_validator.js +15 -2
  36. package/dest/simulator/index.d.ts +1 -37
  37. package/dest/simulator/index.d.ts.map +1 -1
  38. package/dest/simulator/index.js +2 -2
  39. package/dest/simulator/public_executor.d.ts +1 -1
  40. package/dest/simulator/public_executor.d.ts.map +1 -1
  41. package/dest/simulator/public_executor.js +22 -12
  42. package/dest/simulator/public_kernel.d.ts +1 -1
  43. package/dest/simulator/public_kernel.d.ts.map +1 -1
  44. package/dest/simulator/public_kernel.js +2 -2
  45. package/package.json +13 -13
  46. package/src/client/sequencer-client.ts +7 -42
  47. package/src/index.ts +0 -9
  48. package/src/publisher/viem-tx-sender.ts +1 -2
  49. package/src/sequencer/abstract_phase_manager.ts +14 -16
  50. package/src/sequencer/app_logic_phase_manager.ts +1 -3
  51. package/src/sequencer/phase_manager_factory.ts +0 -9
  52. package/src/sequencer/public_processor.ts +12 -17
  53. package/src/sequencer/sequencer.ts +12 -13
  54. package/src/sequencer/setup_phase_manager.ts +1 -3
  55. package/src/sequencer/tail_phase_manager.ts +1 -3
  56. package/src/sequencer/teardown_phase_manager.ts +1 -3
  57. package/src/sequencer/tx_validator.ts +17 -2
  58. package/src/simulator/index.ts +0 -45
  59. package/src/simulator/public_executor.ts +32 -11
  60. package/src/simulator/public_kernel.ts +2 -2
  61. package/dest/block_builder/index.d.ts +0 -19
  62. package/dest/block_builder/index.d.ts.map +0 -1
  63. package/dest/block_builder/index.js +0 -2
  64. package/dest/block_builder/solo_block_builder.d.ts +0 -78
  65. package/dest/block_builder/solo_block_builder.d.ts.map +0 -1
  66. package/dest/block_builder/solo_block_builder.js +0 -489
  67. package/dest/block_builder/types.d.ts +0 -10
  68. package/dest/block_builder/types.d.ts.map +0 -1
  69. package/dest/block_builder/types.js +0 -2
  70. package/dest/mocks/verification_keys.d.ts +0 -28
  71. package/dest/mocks/verification_keys.d.ts.map +0 -1
  72. package/dest/mocks/verification_keys.js +0 -14
  73. package/dest/prover/empty.d.ts +0 -53
  74. package/dest/prover/empty.d.ts.map +0 -1
  75. package/dest/prover/empty.js +0 -75
  76. package/dest/prover/index.d.ts +0 -52
  77. package/dest/prover/index.d.ts.map +0 -1
  78. package/dest/prover/index.js +0 -2
  79. package/dest/sequencer/processed_tx.d.ts +0 -81
  80. package/dest/sequencer/processed_tx.d.ts.map +0 -1
  81. package/dest/sequencer/processed_tx.js +0 -98
  82. package/dest/simulator/acvm_native.d.ts +0 -20
  83. package/dest/simulator/acvm_native.d.ts.map +0 -1
  84. package/dest/simulator/acvm_native.js +0 -96
  85. package/dest/simulator/acvm_wasm.d.ts +0 -7
  86. package/dest/simulator/acvm_wasm.d.ts.map +0 -1
  87. package/dest/simulator/acvm_wasm.js +0 -23
  88. package/dest/simulator/rollup.d.ts +0 -43
  89. package/dest/simulator/rollup.d.ts.map +0 -1
  90. package/dest/simulator/rollup.js +0 -78
  91. package/dest/simulator/simulation_provider.d.ts +0 -9
  92. package/dest/simulator/simulation_provider.d.ts.map +0 -1
  93. package/dest/simulator/simulation_provider.js +0 -2
  94. package/src/block_builder/index.ts +0 -20
  95. package/src/block_builder/solo_block_builder.ts +0 -812
  96. package/src/block_builder/types.ts +0 -8
  97. package/src/mocks/verification_keys.ts +0 -36
  98. package/src/prover/empty.ts +0 -97
  99. package/src/prover/index.ts +0 -70
  100. package/src/sequencer/processed_tx.ts +0 -210
  101. package/src/simulator/acvm_native.ts +0 -112
  102. package/src/simulator/acvm_wasm.ts +0 -31
  103. package/src/simulator/rollup.ts +0 -127
  104. package/src/simulator/simulation_provider.ts +0 -10
@@ -1,8 +0,0 @@
1
- /**
2
- * Type representing the names of the trees for the base rollup.
3
- */
4
- type BaseTreeNames = 'NoteHashTree' | 'ContractTree' | 'NullifierTree' | 'PublicDataTree';
5
- /**
6
- * Type representing the names of the trees.
7
- */
8
- export type TreeNames = BaseTreeNames | 'L1ToL2MessageTree' | 'Archive';
@@ -1,36 +0,0 @@
1
- import { VerificationKey } from '@aztec/circuits.js';
2
-
3
- /**
4
- * Well-known verification keys.
5
- */
6
- export interface VerificationKeys {
7
- /**
8
- * Verification key for the default public kernel circuit.
9
- */
10
- publicKernelCircuit: VerificationKey;
11
- /**
12
- * Verification key for the default private kernel circuit.
13
- */
14
- privateKernelCircuit: VerificationKey;
15
- /**
16
- * Verification key for the default base rollup circuit.
17
- */
18
- baseRollupCircuit: VerificationKey;
19
- /**
20
- * Verification key for the default merge rollup circuit.
21
- */
22
- mergeRollupCircuit: VerificationKey;
23
- }
24
-
25
- /**
26
- * Returns mock verification keys for each well known circuit.
27
- * @returns A VerificationKeys object with fake values.
28
- */
29
- export function getVerificationKeys(): VerificationKeys {
30
- return {
31
- privateKernelCircuit: VerificationKey.makeFake(),
32
- baseRollupCircuit: VerificationKey.makeFake(),
33
- mergeRollupCircuit: VerificationKey.makeFake(),
34
- publicKernelCircuit: VerificationKey.makeFake(),
35
- };
36
- }
@@ -1,97 +0,0 @@
1
- /* eslint-disable require-await */
2
- import {
3
- AggregationObject,
4
- BaseOrMergeRollupPublicInputs,
5
- BaseParityInputs,
6
- BaseRollupInputs,
7
- MergeRollupInputs,
8
- ParityPublicInputs,
9
- Proof,
10
- PublicCircuitPublicInputs,
11
- PublicKernelCircuitPublicInputs,
12
- RootParityInputs,
13
- RootRollupInputs,
14
- RootRollupPublicInputs,
15
- } from '@aztec/circuits.js';
16
-
17
- import { PublicProver, RollupProver } from './index.js';
18
-
19
- const EMPTY_PROOF_SIZE = 42;
20
-
21
- // TODO: Silently modifying one of the inputs to inject the aggregation object is horrible.
22
- // We should rethink these interfaces.
23
-
24
- /**
25
- * Prover implementation that returns empty proofs and overrides aggregation objects.
26
- */
27
- export class EmptyRollupProver implements RollupProver {
28
- /**
29
- * Creates an empty proof for the given input.
30
- * @param inputs - Inputs to the circuit.
31
- * @param publicInputs - Public inputs of the circuit obtained via simulation, modified by this call.
32
- */
33
- async getBaseParityProof(inputs: BaseParityInputs, publicInputs: ParityPublicInputs): Promise<Proof> {
34
- publicInputs.aggregationObject = AggregationObject.makeFake();
35
- return new Proof(Buffer.alloc(EMPTY_PROOF_SIZE, 0));
36
- }
37
-
38
- /**
39
- * Creates an empty proof for the given input.
40
- * @param inputs - Inputs to the circuit.
41
- * @param publicInputs - Public inputs of the circuit obtained via simulation, modified by this call.
42
- */
43
- async getRootParityProof(inputs: RootParityInputs, publicInputs: ParityPublicInputs): Promise<Proof> {
44
- publicInputs.aggregationObject = AggregationObject.makeFake();
45
- return new Proof(Buffer.alloc(EMPTY_PROOF_SIZE, 0));
46
- }
47
-
48
- /**
49
- * Creates an empty proof for the given input.
50
- * @param _input - Input to the circuit.
51
- * @param publicInputs - Public inputs of the circuit obtained via simulation, modified by this call.
52
- */
53
- async getBaseRollupProof(_input: BaseRollupInputs, publicInputs: BaseOrMergeRollupPublicInputs): Promise<Proof> {
54
- publicInputs.aggregationObject = AggregationObject.makeFake();
55
- return new Proof(Buffer.alloc(EMPTY_PROOF_SIZE, 0));
56
- }
57
-
58
- /**
59
- * Creates an empty proof for the given input.
60
- * @param _input - Input to the circuit.
61
- * @param publicInputs - Public inputs of the circuit obtained via simulation, modified by this call.
62
- */
63
- async getMergeRollupProof(_input: MergeRollupInputs, publicInputs: BaseOrMergeRollupPublicInputs): Promise<Proof> {
64
- publicInputs.aggregationObject = AggregationObject.makeFake();
65
- return new Proof(Buffer.alloc(EMPTY_PROOF_SIZE, 0));
66
- }
67
- /**
68
- * Creates an empty proof for the given input.
69
- * @param _input - Input to the circuit.
70
- * @param publicInputs - Public inputs of the circuit obtained via simulation, modified by this call.
71
- */
72
- async getRootRollupProof(_input: RootRollupInputs, publicInputs: RootRollupPublicInputs): Promise<Proof> {
73
- publicInputs.aggregationObject = AggregationObject.makeFake();
74
- return new Proof(Buffer.alloc(EMPTY_PROOF_SIZE, 0));
75
- }
76
- }
77
-
78
- /**
79
- * Prover implementation that returns empty proofs.
80
- */
81
- export class EmptyPublicProver implements PublicProver {
82
- /**
83
- * Creates an empty proof for the given input.
84
- * @param _publicInputs - Public inputs obtained via simulation.
85
- */
86
- async getPublicCircuitProof(_publicInputs: PublicCircuitPublicInputs): Promise<Proof> {
87
- return new Proof(Buffer.alloc(EMPTY_PROOF_SIZE, 0));
88
- }
89
-
90
- /**
91
- * Creates an empty proof for the given input.
92
- * @param _publicInputs - Public inputs obtained via simulation.
93
- */
94
- async getPublicKernelCircuitProof(_publicInputs: PublicKernelCircuitPublicInputs): Promise<Proof> {
95
- return new Proof(Buffer.alloc(EMPTY_PROOF_SIZE, 0));
96
- }
97
- }
@@ -1,70 +0,0 @@
1
- import {
2
- BaseOrMergeRollupPublicInputs,
3
- BaseParityInputs,
4
- BaseRollupInputs,
5
- MergeRollupInputs,
6
- ParityPublicInputs,
7
- Proof,
8
- PublicCircuitPublicInputs,
9
- PublicKernelCircuitPublicInputs,
10
- RootParityInputs,
11
- RootRollupInputs,
12
- RootRollupPublicInputs,
13
- } from '@aztec/circuits.js';
14
-
15
- /**
16
- * Generates proofs for parity and rollup circuits.
17
- */
18
- export interface RollupProver {
19
- /**
20
- * Creates a proof for the given input.
21
- * @param input - Input to the circuit.
22
- * @param publicInputs - Public inputs of the circuit obtained via simulation, modified by this call.
23
- */
24
- getBaseParityProof(inputs: BaseParityInputs, publicInputs: ParityPublicInputs): Promise<Proof>;
25
-
26
- /**
27
- * Creates a proof for the given input.
28
- * @param input - Input to the circuit.
29
- * @param publicInputs - Public inputs of the circuit obtained via simulation, modified by this call.
30
- */
31
- getRootParityProof(inputs: RootParityInputs, publicInputs: ParityPublicInputs): Promise<Proof>;
32
-
33
- /**
34
- * Creates a proof for the given input.
35
- * @param input - Input to the circuit.
36
- * @param publicInputs - Public inputs of the circuit obtained via simulation, modified by this call.
37
- */
38
- getBaseRollupProof(input: BaseRollupInputs, publicInputs: BaseOrMergeRollupPublicInputs): Promise<Proof>;
39
-
40
- /**
41
- * Creates a proof for the given input.
42
- * @param input - Input to the circuit.
43
- * @param publicInputs - Public inputs of the circuit obtained via simulation, modified by this call.
44
- */
45
- getMergeRollupProof(input: MergeRollupInputs, publicInputs: BaseOrMergeRollupPublicInputs): Promise<Proof>;
46
-
47
- /**
48
- * Creates a proof for the given input.
49
- * @param input - Input to the circuit.
50
- * @param publicInputs - Public inputs of the circuit obtained via simulation, modified by this call.
51
- */
52
- getRootRollupProof(input: RootRollupInputs, publicInputs: RootRollupPublicInputs): Promise<Proof>;
53
- }
54
-
55
- /**
56
- * Generates proofs for the public and public kernel circuits.
57
- */
58
- export interface PublicProver {
59
- /**
60
- * Creates a proof for the given input.
61
- * @param publicInputs - Public inputs obtained via simulation.
62
- */
63
- getPublicCircuitProof(publicInputs: PublicCircuitPublicInputs): Promise<Proof>;
64
-
65
- /**
66
- * Creates a proof for the given input.
67
- * @param publicInputs - Public inputs obtained via simulation.
68
- */
69
- getPublicKernelCircuitProof(publicInputs: PublicKernelCircuitPublicInputs): Promise<Proof>;
70
- }
@@ -1,210 +0,0 @@
1
- import { PublicDataWrite, SimulationError, Tx, TxEffect, TxHash, TxL2Logs } from '@aztec/circuit-types';
2
- import {
3
- Fr,
4
- Header,
5
- MAX_NEW_NOTE_HASHES_PER_TX,
6
- MAX_NEW_NULLIFIERS_PER_TX,
7
- MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
8
- Proof,
9
- PublicAccumulatedNonRevertibleData,
10
- PublicAccumulatedRevertibleData,
11
- PublicKernelCircuitPublicInputs,
12
- SideEffect,
13
- SideEffectLinkedToNoteHash,
14
- ValidationRequests,
15
- makeEmptyProof,
16
- } from '@aztec/circuits.js';
17
- import { Tuple, fromFieldsTuple } from '@aztec/foundation/serialize';
18
-
19
- /**
20
- * Represents a tx that has been processed by the sequencer public processor,
21
- * so its kernel circuit public inputs are filled in.
22
- */
23
- export type ProcessedTx = Pick<Tx, 'proof' | 'encryptedLogs' | 'unencryptedLogs'> & {
24
- /**
25
- * Output of the public kernel circuit for this tx.
26
- */
27
- data: PublicKernelCircuitPublicInputs;
28
- /**
29
- * Hash of the transaction.
30
- */
31
- hash: TxHash;
32
- /**
33
- * Flag indicating the tx is 'empty' meaning it's a padding tx to take us to a power of 2.
34
- */
35
- isEmpty: boolean;
36
-
37
- /**
38
- * Reason the tx was reverted.
39
- */
40
- revertReason: SimulationError | undefined;
41
- };
42
-
43
- export type RevertedTx = ProcessedTx & {
44
- data: PublicKernelCircuitPublicInputs & {
45
- reverted: true;
46
- };
47
-
48
- revertReason: SimulationError;
49
- };
50
-
51
- export function isRevertedTx(tx: ProcessedTx): tx is RevertedTx {
52
- return tx.data.reverted;
53
- }
54
-
55
- export function partitionReverts(txs: ProcessedTx[]): { reverted: RevertedTx[]; nonReverted: ProcessedTx[] } {
56
- return txs.reduce(
57
- ({ reverted, nonReverted }, tx) => {
58
- if (isRevertedTx(tx)) {
59
- reverted.push(tx);
60
- } else {
61
- nonReverted.push(tx);
62
- }
63
- return { reverted, nonReverted };
64
- },
65
- { reverted: [], nonReverted: [] } as ReturnType<typeof partitionReverts>,
66
- );
67
- }
68
-
69
- /**
70
- * Represents a tx that failed to be processed by the sequencer public processor.
71
- */
72
- export type FailedTx = {
73
- /**
74
- * The failing transaction.
75
- */
76
- tx: Tx;
77
- /**
78
- * The error that caused the tx to fail.
79
- */
80
- error: Error;
81
- };
82
-
83
- /**
84
- *
85
- * @param tx - the TX being procesed
86
- * @param publicKernelPublicInput - the output of the public kernel circuit, unless we just came from private
87
- * @param publicKernelProof - the proof of the public kernel circuit, unless we just came from private
88
- * @returns PublicKernelCircuitPublicInputs, either passed through from the input or converted from the output of the TX,
89
- * and Proof, either passed through from the input or the proof of the TX
90
- */
91
- export function getPreviousOutputAndProof(
92
- tx: Tx,
93
- publicKernelPublicInput?: PublicKernelCircuitPublicInputs,
94
- publicKernelProof?: Proof,
95
- ): {
96
- /**
97
- * the output of the public kernel circuit for this phase
98
- */
99
- publicKernelPublicInput: PublicKernelCircuitPublicInputs;
100
- /**
101
- * the proof of the public kernel circuit for this phase
102
- */
103
- previousProof: Proof;
104
- } {
105
- if (publicKernelPublicInput && publicKernelProof) {
106
- return {
107
- publicKernelPublicInput,
108
- previousProof: publicKernelProof,
109
- };
110
- } else {
111
- const publicKernelPublicInput = new PublicKernelCircuitPublicInputs(
112
- tx.data.aggregationObject,
113
- ValidationRequests.empty(),
114
- PublicAccumulatedNonRevertibleData.fromPrivateAccumulatedNonRevertibleData(tx.data.endNonRevertibleData),
115
- PublicAccumulatedRevertibleData.fromPrivateAccumulatedRevertibleData(tx.data.end),
116
- tx.data.constants,
117
- tx.data.needsSetup,
118
- tx.data.needsAppLogic,
119
- tx.data.needsTeardown,
120
- false, // reverted
121
- );
122
- return {
123
- publicKernelPublicInput,
124
- previousProof: publicKernelProof || tx.proof,
125
- };
126
- }
127
- }
128
-
129
- /**
130
- * Makes a processed tx out of source tx.
131
- * @param tx - Source tx.
132
- * @param kernelOutput - Output of the kernel circuit simulation for this tx.
133
- * @param proof - Proof of the kernel circuit for this tx.
134
- */
135
- export function makeProcessedTx(
136
- tx: Tx,
137
- kernelOutput?: PublicKernelCircuitPublicInputs,
138
- proof?: Proof,
139
- revertReason?: SimulationError,
140
- ): ProcessedTx {
141
- const { publicKernelPublicInput, previousProof } = getPreviousOutputAndProof(tx, kernelOutput, proof);
142
- return {
143
- hash: tx.getTxHash(),
144
- data: publicKernelPublicInput,
145
- proof: previousProof,
146
- encryptedLogs: revertReason ? new TxL2Logs([]) : tx.encryptedLogs,
147
- unencryptedLogs: revertReason ? new TxL2Logs([]) : tx.unencryptedLogs,
148
- isEmpty: false,
149
- revertReason,
150
- };
151
- }
152
-
153
- /**
154
- * Makes an empty tx from an empty kernel circuit public inputs.
155
- * @returns A processed empty tx.
156
- */
157
- export function makeEmptyProcessedTx(header: Header, chainId: Fr, version: Fr): ProcessedTx {
158
- const emptyKernelOutput = PublicKernelCircuitPublicInputs.empty();
159
- emptyKernelOutput.constants.historicalHeader = header;
160
- emptyKernelOutput.constants.txContext.chainId = chainId;
161
- emptyKernelOutput.constants.txContext.version = version;
162
- const emptyProof = makeEmptyProof();
163
-
164
- const hash = new TxHash(Fr.ZERO.toBuffer());
165
- return {
166
- hash,
167
- encryptedLogs: new TxL2Logs([]),
168
- unencryptedLogs: new TxL2Logs([]),
169
- data: emptyKernelOutput,
170
- proof: emptyProof,
171
- isEmpty: true,
172
- revertReason: undefined,
173
- };
174
- }
175
-
176
- export function toTxEffect(tx: ProcessedTx): TxEffect {
177
- return new TxEffect(
178
- tx.data.combinedData.newNoteHashes.map((c: SideEffect) => c.value) as Tuple<Fr, typeof MAX_NEW_NOTE_HASHES_PER_TX>,
179
- tx.data.combinedData.newNullifiers.map((n: SideEffectLinkedToNoteHash) => n.value) as Tuple<
180
- Fr,
181
- typeof MAX_NEW_NULLIFIERS_PER_TX
182
- >,
183
- tx.data.combinedData.newL2ToL1Msgs,
184
- tx.data.combinedData.publicDataUpdateRequests.map(t => new PublicDataWrite(t.leafSlot, t.newValue)) as Tuple<
185
- PublicDataWrite,
186
- typeof MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX
187
- >,
188
- tx.encryptedLogs || new TxL2Logs([]),
189
- tx.unencryptedLogs || new TxL2Logs([]),
190
- );
191
- }
192
-
193
- function validateProcessedTxLogs(tx: ProcessedTx): void {
194
- const unencryptedLogs = tx.unencryptedLogs || new TxL2Logs([]);
195
- const kernelUnencryptedLogsHash = fromFieldsTuple(tx.data.combinedData.unencryptedLogsHash);
196
- if (!unencryptedLogs.hash().equals(kernelUnencryptedLogsHash)) {
197
- throw new Error(
198
- `Unencrypted logs hash mismatch. Expected ${unencryptedLogs
199
- .hash()
200
- .toString('hex')}, got ${kernelUnencryptedLogsHash.toString('hex')}.
201
- Processed: ${JSON.stringify(unencryptedLogs.toJSON())}
202
- Kernel Length: ${tx.data.combinedData.unencryptedLogPreimagesLength}`,
203
- );
204
- }
205
- }
206
-
207
- export function validateProcessedTx(tx: ProcessedTx): void {
208
- validateProcessedTxLogs(tx);
209
- // TODO: validate other fields
210
- }
@@ -1,112 +0,0 @@
1
- import { randomBytes } from '@aztec/foundation/crypto';
2
- import { NoirCompiledCircuit } from '@aztec/types/noir';
3
-
4
- import { WitnessMap } from '@noir-lang/types';
5
- import * as proc from 'child_process';
6
- import fs from 'fs/promises';
7
-
8
- import { SimulationProvider } from './simulation_provider.js';
9
-
10
- /**
11
- * Parses a TOML format witness map string into a Map structure
12
- * @param outputString - The witness map in TOML format
13
- * @returns The parsed witness map
14
- */
15
- function parseIntoWitnessMap(outputString: string) {
16
- const lines = outputString.split('\n');
17
- return new Map<number, string>(
18
- lines
19
- .filter((line: string) => line.length)
20
- .map((line: string) => {
21
- const pair = line.replaceAll(' ', '').split('=');
22
- return [Number(pair[0]), pair[1].replaceAll('"', '')];
23
- }),
24
- );
25
- }
26
-
27
- /**
28
- *
29
- * @param inputWitness - The circuit's input witness
30
- * @param bytecode - The circuit buytecode
31
- * @param workingDirectory - A directory to use for temporary files by the ACVM
32
- * @param pathToAcvm - The path to the ACVm binary
33
- * @returns The completed partial witness outputted from the circuit
34
- */
35
- export async function executeNativeCircuit(
36
- inputWitness: WitnessMap,
37
- bytecode: Buffer,
38
- workingDirectory: string,
39
- pathToAcvm: string,
40
- ) {
41
- const bytecodeFilename = 'bytecode';
42
- const witnessFilename = 'input_witness.toml';
43
-
44
- // convert the witness map to TOML format
45
- let witnessMap = '';
46
- inputWitness.forEach((value: string, key: number) => {
47
- witnessMap = witnessMap.concat(`${key} = '${value}'\n`);
48
- });
49
-
50
- // In case the directory is still around from some time previously, remove it
51
- await fs.rm(workingDirectory, { recursive: true, force: true });
52
- // Create the new working directory
53
- await fs.mkdir(workingDirectory, { recursive: true });
54
- // Write the bytecode and input witness to the working directory
55
- await fs.writeFile(`${workingDirectory}/${bytecodeFilename}`, bytecode);
56
- await fs.writeFile(`${workingDirectory}/${witnessFilename}`, witnessMap);
57
-
58
- // Execute the ACVM using the given args
59
- const args = [
60
- `execute`,
61
- `--working-directory`,
62
- `${workingDirectory}`,
63
- `--bytecode`,
64
- `${bytecodeFilename}`,
65
- `--input-witness`,
66
- `${witnessFilename}`,
67
- `--print`,
68
- ];
69
- const processPromise = new Promise<string>((resolve, reject) => {
70
- let outputWitness = Buffer.alloc(0);
71
- let errorBuffer = Buffer.alloc(0);
72
- const acvm = proc.spawn(pathToAcvm, args);
73
- acvm.stdout.on('data', data => {
74
- outputWitness = Buffer.concat([outputWitness, data]);
75
- });
76
- acvm.stderr.on('data', data => {
77
- errorBuffer = Buffer.concat([errorBuffer, data]);
78
- });
79
- acvm.on('close', code => {
80
- if (code === 0) {
81
- resolve(outputWitness.toString('utf-8'));
82
- } else {
83
- reject(errorBuffer.toString('utf-8'));
84
- }
85
- });
86
- });
87
-
88
- try {
89
- const output = await processPromise;
90
- return parseIntoWitnessMap(output);
91
- } finally {
92
- // Clean up the working directory before we leave
93
- await fs.rm(workingDirectory, { recursive: true, force: true });
94
- }
95
- }
96
-
97
- export class NativeACVMSimulator implements SimulationProvider {
98
- constructor(private workingDirectory: string, private pathToAcvm: string) {}
99
- async simulateCircuit(input: WitnessMap, compiledCircuit: NoirCompiledCircuit): Promise<WitnessMap> {
100
- // Execute the circuit on those initial witness values
101
-
102
- // Decode the bytecode from base64 since the acvm does not know about base64 encoding
103
- const decodedBytecode = Buffer.from(compiledCircuit.bytecode, 'base64');
104
-
105
- // Provide a unique working directory so we don't get clashes with parallel executions
106
- const directory = `${this.workingDirectory}/${randomBytes(32).toString('hex')}`;
107
- // Execute the circuit
108
- const _witnessMap = await executeNativeCircuit(input, decodedBytecode, directory, this.pathToAcvm);
109
-
110
- return _witnessMap;
111
- }
112
- }
@@ -1,31 +0,0 @@
1
- import { NoirCompiledCircuit } from '@aztec/types/noir';
2
-
3
- import { WasmBlackBoxFunctionSolver, createBlackBoxSolver, executeCircuitWithBlackBoxSolver } from '@noir-lang/acvm_js';
4
- import { WitnessMap } from '@noir-lang/types';
5
-
6
- import { SimulationProvider } from './simulation_provider.js';
7
-
8
- let solver: Promise<WasmBlackBoxFunctionSolver>;
9
-
10
- const getSolver = (): Promise<WasmBlackBoxFunctionSolver> => {
11
- if (!solver) {
12
- solver = createBlackBoxSolver();
13
- }
14
- return solver;
15
- };
16
-
17
- export class WASMSimulator implements SimulationProvider {
18
- async simulateCircuit(input: WitnessMap, compiledCircuit: NoirCompiledCircuit): Promise<WitnessMap> {
19
- // Execute the circuit on those initial witness values
20
- //
21
- // Decode the bytecode from base64 since the acvm does not know about base64 encoding
22
- const decodedBytecode = Buffer.from(compiledCircuit.bytecode, 'base64');
23
- //
24
- // Execute the circuit
25
- const _witnessMap = await executeCircuitWithBlackBoxSolver(await getSolver(), decodedBytecode, input, () => {
26
- throw Error('unexpected oracle during execution');
27
- });
28
-
29
- return _witnessMap;
30
- }
31
- }
@@ -1,127 +0,0 @@
1
- import { CircuitSimulationStats } from '@aztec/circuit-types/stats';
2
- import {
3
- BaseOrMergeRollupPublicInputs,
4
- BaseParityInputs,
5
- BaseRollupInputs,
6
- MergeRollupInputs,
7
- ParityPublicInputs,
8
- RootParityInputs,
9
- RootRollupInputs,
10
- RootRollupPublicInputs,
11
- } from '@aztec/circuits.js';
12
- import { createDebugLogger } from '@aztec/foundation/log';
13
- import { elapsed } from '@aztec/foundation/timer';
14
- import {
15
- BaseParityArtifact,
16
- BaseRollupArtifact,
17
- MergeRollupArtifact,
18
- RootParityArtifact,
19
- RootRollupArtifact,
20
- convertBaseParityInputsToWitnessMap,
21
- convertBaseParityOutputsFromWitnessMap,
22
- convertBaseRollupInputsToWitnessMap,
23
- convertBaseRollupOutputsFromWitnessMap,
24
- convertMergeRollupInputsToWitnessMap,
25
- convertMergeRollupOutputsFromWitnessMap,
26
- convertRootParityInputsToWitnessMap,
27
- convertRootParityOutputsFromWitnessMap,
28
- convertRootRollupInputsToWitnessMap,
29
- convertRootRollupOutputsFromWitnessMap,
30
- } from '@aztec/noir-protocol-circuits-types';
31
-
32
- import { RollupSimulator, WASMSimulator } from './index.js';
33
- import { SimulationProvider } from './simulation_provider.js';
34
-
35
- /**
36
- * Implements the rollup circuit simulator.
37
- */
38
- export class RealRollupCircuitSimulator implements RollupSimulator {
39
- private log = createDebugLogger('aztec:rollup-simulator');
40
-
41
- // Some circuits are so small it is faster to use WASM
42
- private wasmSimulator: WASMSimulator = new WASMSimulator();
43
-
44
- constructor(private simulationProvider: SimulationProvider) {}
45
-
46
- /**
47
- * Simulates the base parity circuit from its inputs.
48
- * @param inputs - Inputs to the circuit.
49
- * @returns The public inputs of the parity circuit.
50
- */
51
- public async baseParityCircuit(inputs: BaseParityInputs): Promise<ParityPublicInputs> {
52
- const witnessMap = convertBaseParityInputsToWitnessMap(inputs);
53
-
54
- const witness = await this.simulationProvider.simulateCircuit(witnessMap, BaseParityArtifact);
55
-
56
- const result = convertBaseParityOutputsFromWitnessMap(witness);
57
-
58
- return Promise.resolve(result);
59
- }
60
-
61
- /**
62
- * Simulates the root parity circuit from its inputs.
63
- * @param inputs - Inputs to the circuit.
64
- * @returns The public inputs of the parity circuit.
65
- */
66
- public async rootParityCircuit(inputs: RootParityInputs): Promise<ParityPublicInputs> {
67
- const witnessMap = convertRootParityInputsToWitnessMap(inputs);
68
-
69
- const witness = await this.simulationProvider.simulateCircuit(witnessMap, RootParityArtifact);
70
-
71
- const result = convertRootParityOutputsFromWitnessMap(witness);
72
-
73
- return Promise.resolve(result);
74
- }
75
-
76
- /**
77
- * Simulates the base rollup circuit from its inputs.
78
- * @param input - Inputs to the circuit.
79
- * @returns The public inputs as outputs of the simulation.
80
- */
81
- public async baseRollupCircuit(input: BaseRollupInputs): Promise<BaseOrMergeRollupPublicInputs> {
82
- const witnessMap = convertBaseRollupInputsToWitnessMap(input);
83
-
84
- const witness = await this.simulationProvider.simulateCircuit(witnessMap, BaseRollupArtifact);
85
-
86
- const result = convertBaseRollupOutputsFromWitnessMap(witness);
87
-
88
- return Promise.resolve(result);
89
- }
90
- /**
91
- * Simulates the merge rollup circuit from its inputs.
92
- * @param input - Inputs to the circuit.
93
- * @returns The public inputs as outputs of the simulation.
94
- */
95
- public async mergeRollupCircuit(input: MergeRollupInputs): Promise<BaseOrMergeRollupPublicInputs> {
96
- const witnessMap = convertMergeRollupInputsToWitnessMap(input);
97
-
98
- const witness = await this.wasmSimulator.simulateCircuit(witnessMap, MergeRollupArtifact);
99
-
100
- const result = convertMergeRollupOutputsFromWitnessMap(witness);
101
-
102
- return result;
103
- }
104
-
105
- /**
106
- * Simulates the root rollup circuit from its inputs.
107
- * @param input - Inputs to the circuit.
108
- * @returns The public inputs as outputs of the simulation.
109
- */
110
- public async rootRollupCircuit(input: RootRollupInputs): Promise<RootRollupPublicInputs> {
111
- const witnessMap = convertRootRollupInputsToWitnessMap(input);
112
-
113
- const [duration, witness] = await elapsed(() => this.wasmSimulator.simulateCircuit(witnessMap, RootRollupArtifact));
114
-
115
- const result = convertRootRollupOutputsFromWitnessMap(witness);
116
-
117
- this.log(`Simulated root rollup circuit`, {
118
- eventName: 'circuit-simulation',
119
- circuitName: 'root-rollup',
120
- duration,
121
- inputSize: input.toBuffer().length,
122
- outputSize: result.toBuffer().length,
123
- } satisfies CircuitSimulationStats);
124
-
125
- return result;
126
- }
127
- }