@aztec/sequencer-client 0.1.0-alpha48 → 0.1.0-alpha57
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.
- package/.tsbuildinfo +1 -1
- package/dest/block_builder/solo_block_builder.test.js +3 -3
- package/dest/sequencer/processed_tx.d.ts +7 -3
- package/dest/sequencer/processed_tx.d.ts.map +1 -1
- package/dest/sequencer/processed_tx.js +5 -4
- package/dest/sequencer/public_processor.d.ts.map +1 -1
- package/dest/sequencer/public_processor.js +5 -5
- package/dest/sequencer/public_processor.test.js +18 -12
- package/package.json +10 -10
- package/src/block_builder/solo_block_builder.test.ts +2 -2
- package/src/sequencer/processed_tx.ts +19 -6
- package/src/sequencer/public_processor.test.ts +21 -10
- package/src/sequencer/public_processor.ts +8 -3
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
AztecAddress,
|
|
5
5
|
CallContext,
|
|
6
6
|
CircuitsWasm,
|
|
7
|
+
CombinedAccumulatedData,
|
|
7
8
|
EthAddress,
|
|
8
9
|
Fr,
|
|
9
10
|
FunctionData,
|
|
@@ -14,13 +15,14 @@ import {
|
|
|
14
15
|
PUBLIC_DATA_TREE_HEIGHT,
|
|
15
16
|
Proof,
|
|
16
17
|
PublicCallRequest,
|
|
18
|
+
PublicKernelPublicInputs,
|
|
17
19
|
makeEmptyProof,
|
|
18
20
|
makeTuple,
|
|
19
21
|
} from '@aztec/circuits.js';
|
|
20
22
|
import { computeCallStackItemHash } from '@aztec/circuits.js/abis';
|
|
21
23
|
import {
|
|
22
24
|
makeAztecAddress,
|
|
23
|
-
|
|
25
|
+
makePrivateKernelPublicInputsFinal,
|
|
24
26
|
makePublicCallRequest,
|
|
25
27
|
makeSelector,
|
|
26
28
|
} from '@aztec/circuits.js/factories';
|
|
@@ -39,7 +41,6 @@ import {
|
|
|
39
41
|
import { MerkleTreeOperations, TreeInfo } from '@aztec/world-state';
|
|
40
42
|
|
|
41
43
|
import { MockProxy, mock } from 'jest-mock-extended';
|
|
42
|
-
import pick from 'lodash.pick';
|
|
43
44
|
import times from 'lodash.times';
|
|
44
45
|
|
|
45
46
|
import { PublicProver } from '../prover/index.js';
|
|
@@ -101,13 +102,23 @@ describe('public_processor', () => {
|
|
|
101
102
|
const [processed, failed] = await processor.process([tx]);
|
|
102
103
|
|
|
103
104
|
expect(processed).toEqual([
|
|
104
|
-
{
|
|
105
|
+
{
|
|
106
|
+
isEmpty: false,
|
|
107
|
+
hash,
|
|
108
|
+
data: new PublicKernelPublicInputs(
|
|
109
|
+
CombinedAccumulatedData.fromFinalAccumulatedData(tx.data.end),
|
|
110
|
+
tx.data.constants,
|
|
111
|
+
),
|
|
112
|
+
proof: tx.proof,
|
|
113
|
+
encryptedLogs: tx.encryptedLogs,
|
|
114
|
+
unencryptedLogs: tx.unencryptedLogs,
|
|
115
|
+
},
|
|
105
116
|
]);
|
|
106
117
|
expect(failed).toEqual([]);
|
|
107
118
|
});
|
|
108
119
|
|
|
109
120
|
it('returns failed txs without aborting entire operation', async function () {
|
|
110
|
-
publicExecutor.
|
|
121
|
+
publicExecutor.simulate.mockRejectedValue(new Error(`Failed`));
|
|
111
122
|
|
|
112
123
|
const tx = mockTx();
|
|
113
124
|
const [processed, failed] = await processor.process([tx]);
|
|
@@ -151,7 +162,7 @@ describe('public_processor', () => {
|
|
|
151
162
|
const callStackItems = await Promise.all(callRequests.map(call => call.toPublicCallStackItem()));
|
|
152
163
|
const callStackHashes = callStackItems.map(call => computeCallStackItemHash(wasm, call));
|
|
153
164
|
|
|
154
|
-
const kernelOutput =
|
|
165
|
+
const kernelOutput = makePrivateKernelPublicInputsFinal(0x10);
|
|
155
166
|
kernelOutput.end.publicCallStack = padArrayEnd(callStackHashes, Fr.ZERO, MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX);
|
|
156
167
|
kernelOutput.end.privateCallStack = padArrayEnd([], Fr.ZERO, MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX);
|
|
157
168
|
|
|
@@ -159,7 +170,7 @@ describe('public_processor', () => {
|
|
|
159
170
|
ExtendedContractData.random(),
|
|
160
171
|
]);
|
|
161
172
|
|
|
162
|
-
publicExecutor.
|
|
173
|
+
publicExecutor.simulate.mockImplementation(execution => {
|
|
163
174
|
for (const request of callRequests) {
|
|
164
175
|
if (execution.contractAddress.equals(request.contractAddress)) {
|
|
165
176
|
return Promise.resolve(makePublicExecutionResultFromRequest(request));
|
|
@@ -173,7 +184,7 @@ describe('public_processor', () => {
|
|
|
173
184
|
expect(processed).toHaveLength(1);
|
|
174
185
|
expect(processed).toEqual([await expectedTxByHash(tx)]);
|
|
175
186
|
expect(failed).toHaveLength(0);
|
|
176
|
-
expect(publicExecutor.
|
|
187
|
+
expect(publicExecutor.simulate).toHaveBeenCalledTimes(2);
|
|
177
188
|
});
|
|
178
189
|
|
|
179
190
|
it('runs a tx with an enqueued public call with nested execution', async function () {
|
|
@@ -181,7 +192,7 @@ describe('public_processor', () => {
|
|
|
181
192
|
const callStackItem = await callRequest.toPublicCallStackItem();
|
|
182
193
|
const callStackHash = computeCallStackItemHash(wasm, callStackItem);
|
|
183
194
|
|
|
184
|
-
const kernelOutput =
|
|
195
|
+
const kernelOutput = makePrivateKernelPublicInputsFinal(0x10);
|
|
185
196
|
kernelOutput.end.publicCallStack = padArrayEnd([callStackHash], Fr.ZERO, MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX);
|
|
186
197
|
kernelOutput.end.privateCallStack = padArrayEnd([], Fr.ZERO, MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX);
|
|
187
198
|
|
|
@@ -202,14 +213,14 @@ describe('public_processor', () => {
|
|
|
202
213
|
args: new Array(ARGS_LENGTH).fill(Fr.ZERO),
|
|
203
214
|
}),
|
|
204
215
|
];
|
|
205
|
-
publicExecutor.
|
|
216
|
+
publicExecutor.simulate.mockResolvedValue(publicExecutionResult);
|
|
206
217
|
|
|
207
218
|
const [processed, failed] = await processor.process([tx]);
|
|
208
219
|
|
|
209
220
|
expect(processed).toHaveLength(1);
|
|
210
221
|
expect(processed).toEqual([await expectedTxByHash(tx)]);
|
|
211
222
|
expect(failed).toHaveLength(0);
|
|
212
|
-
expect(publicExecutor.
|
|
223
|
+
expect(publicExecutor.simulate).toHaveBeenCalledTimes(1);
|
|
213
224
|
});
|
|
214
225
|
});
|
|
215
226
|
});
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
import {
|
|
10
10
|
AztecAddress,
|
|
11
11
|
CircuitsWasm,
|
|
12
|
+
CombinedAccumulatedData,
|
|
12
13
|
ContractStorageRead,
|
|
13
14
|
ContractStorageUpdateRequest,
|
|
14
15
|
Fr,
|
|
@@ -108,7 +109,7 @@ export class PublicProcessor {
|
|
|
108
109
|
*/
|
|
109
110
|
public async process(txs: Tx[]): Promise<[ProcessedTx[], FailedTx[]]> {
|
|
110
111
|
// The processor modifies the tx objects in place, so we need to clone them.
|
|
111
|
-
txs = txs.map(tx => Tx.
|
|
112
|
+
txs = txs.map(tx => Tx.clone(tx));
|
|
112
113
|
const result: ProcessedTx[] = [];
|
|
113
114
|
const failed: FailedTx[] = [];
|
|
114
115
|
|
|
@@ -153,7 +154,11 @@ export class PublicProcessor {
|
|
|
153
154
|
this.log(`Executing enqueued public calls for tx ${await tx.getTxHash()}`);
|
|
154
155
|
if (!tx.enqueuedPublicFunctionCalls) throw new Error(`Missing preimages for enqueued public calls`);
|
|
155
156
|
|
|
156
|
-
let kernelOutput =
|
|
157
|
+
let kernelOutput = new KernelCircuitPublicInputs(
|
|
158
|
+
CombinedAccumulatedData.fromFinalAccumulatedData(tx.data.end),
|
|
159
|
+
tx.data.constants,
|
|
160
|
+
tx.data.isPrivate,
|
|
161
|
+
);
|
|
157
162
|
let kernelProof = tx.proof;
|
|
158
163
|
const newUnencryptedFunctionLogs: FunctionL2Logs[] = [];
|
|
159
164
|
|
|
@@ -172,7 +177,7 @@ export class PublicProcessor {
|
|
|
172
177
|
while (executionStack.length) {
|
|
173
178
|
const current = executionStack.pop()!;
|
|
174
179
|
const isExecutionRequest = !isPublicExecutionResult(current);
|
|
175
|
-
const result = isExecutionRequest ? await this.publicExecutor.
|
|
180
|
+
const result = isExecutionRequest ? await this.publicExecutor.simulate(current, this.globalVariables) : current;
|
|
176
181
|
newUnencryptedFunctionLogs.push(result.unencryptedLogs);
|
|
177
182
|
const functionSelector = result.execution.functionData.selector.toString();
|
|
178
183
|
this.log(
|