@aztec/end-to-end 0.0.1-commit.8f9871590 → 0.0.1-commit.9117c5f5a
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/dest/bench/client_flows/client_flows_benchmark.d.ts +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +1 -0
- package/dest/e2e_epochs/epochs_test.d.ts +9 -7
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +53 -34
- package/dest/e2e_fees/fees_test.js +1 -1
- package/dest/e2e_p2p/p2p_network.d.ts +1 -1
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +16 -2
- package/dest/e2e_p2p/reqresp/utils.d.ts +3 -3
- package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -1
- package/dest/e2e_p2p/reqresp/utils.js +32 -8
- package/dest/fixtures/e2e_prover_test.d.ts +3 -3
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +27 -34
- package/dest/fixtures/elu_monitor.d.ts +21 -0
- package/dest/fixtures/elu_monitor.d.ts.map +1 -0
- package/dest/fixtures/elu_monitor.js +102 -0
- package/dest/fixtures/fixtures.d.ts +5 -1
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +6 -0
- package/dest/fixtures/setup.d.ts +25 -9
- package/dest/fixtures/setup.d.ts.map +1 -1
- package/dest/fixtures/setup.js +46 -77
- package/dest/fixtures/setup_p2p_test.d.ts +6 -3
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +12 -9
- package/dest/fixtures/token_utils.d.ts +2 -2
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +3 -2
- package/dest/shared/jest_setup.js +41 -1
- package/dest/shared/submit-transactions.d.ts +1 -1
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.d.ts +8 -1
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +28 -0
- package/dest/spartan/utils/bot.d.ts +3 -2
- package/dest/spartan/utils/bot.d.ts.map +1 -1
- package/dest/spartan/utils/bot.js +2 -1
- package/dest/spartan/utils/config.d.ts +4 -1
- package/dest/spartan/utils/config.d.ts.map +1 -1
- package/dest/spartan/utils/config.js +2 -1
- package/dest/spartan/utils/index.d.ts +3 -2
- package/dest/spartan/utils/index.d.ts.map +1 -1
- package/dest/spartan/utils/index.js +3 -1
- package/dest/spartan/utils/k8s.d.ts +3 -1
- package/dest/spartan/utils/k8s.d.ts.map +1 -1
- package/dest/spartan/utils/k8s.js +6 -0
- package/dest/spartan/utils/nodes.d.ts +4 -5
- package/dest/spartan/utils/nodes.d.ts.map +1 -1
- package/dest/spartan/utils/nodes.js +9 -9
- package/dest/test-wallet/test_wallet.js +1 -1
- package/dest/test-wallet/wallet_worker_script.d.ts +2 -0
- package/dest/test-wallet/wallet_worker_script.d.ts.map +1 -0
- package/dest/test-wallet/wallet_worker_script.js +48 -0
- package/dest/test-wallet/worker_wallet.d.ts +52 -0
- package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
- package/dest/test-wallet/worker_wallet.js +151 -0
- package/dest/test-wallet/worker_wallet_schema.d.ts +274 -0
- package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
- package/dest/test-wallet/worker_wallet_schema.js +10 -0
- package/package.json +43 -44
- package/src/bench/client_flows/client_flows_benchmark.ts +1 -0
- package/src/e2e_epochs/epochs_test.ts +66 -66
- package/src/e2e_fees/fees_test.ts +1 -1
- package/src/e2e_p2p/p2p_network.ts +24 -2
- package/src/e2e_p2p/reqresp/utils.ts +36 -8
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/fixtures/e2e_prover_test.ts +25 -35
- package/src/fixtures/elu_monitor.ts +126 -0
- package/src/fixtures/fixtures.ts +10 -0
- package/src/fixtures/setup.ts +64 -108
- package/src/fixtures/setup_p2p_test.ts +9 -17
- package/src/fixtures/token_utils.ts +2 -1
- package/src/shared/jest_setup.ts +51 -1
- package/src/shared/submit-transactions.ts +4 -1
- package/src/spartan/setup_test_wallets.ts +55 -3
- package/src/spartan/utils/bot.ts +3 -0
- package/src/spartan/utils/config.ts +1 -0
- package/src/spartan/utils/index.ts +4 -0
- package/src/spartan/utils/k8s.ts +8 -0
- package/src/spartan/utils/nodes.ts +15 -10
- package/src/test-wallet/test_wallet.ts +1 -1
- package/src/test-wallet/wallet_worker_script.ts +60 -0
- package/src/test-wallet/worker_wallet.ts +213 -0
- package/src/test-wallet/worker_wallet_schema.ts +13 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { InitialAccountData } from '@aztec/accounts/testing';
|
|
2
|
-
import {
|
|
2
|
+
import { AztecNodeService } from '@aztec/aztec-node';
|
|
3
3
|
import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
|
|
4
4
|
import { type Logger, createLogger } from '@aztec/aztec.js/log';
|
|
5
5
|
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
@@ -11,13 +11,11 @@ import {
|
|
|
11
11
|
TestCircuitVerifier,
|
|
12
12
|
} from '@aztec/bb-prover';
|
|
13
13
|
import { BackendType, Barretenberg } from '@aztec/bb.js';
|
|
14
|
-
import { createBlobClientWithFileStores } from '@aztec/blob-client/client';
|
|
15
14
|
import type { DeployAztecL1ContractsReturnType } from '@aztec/ethereum/deploy-aztec-l1-contracts';
|
|
16
15
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
17
16
|
import { SecretValue } from '@aztec/foundation/config';
|
|
18
17
|
import { FeeAssetHandlerAbi } from '@aztec/l1-artifacts';
|
|
19
18
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
20
|
-
import { type ProverNode, type ProverNodeConfig, createProverNode } from '@aztec/prover-node';
|
|
21
19
|
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
22
20
|
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
23
21
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
@@ -73,8 +71,8 @@ export class FullProverTest {
|
|
|
73
71
|
circuitProofVerifier?: ClientProtocolCircuitVerifier;
|
|
74
72
|
provenAsset!: TokenContract;
|
|
75
73
|
context!: EndToEndContext;
|
|
76
|
-
private
|
|
77
|
-
private
|
|
74
|
+
private proverAztecNode!: AztecNodeService;
|
|
75
|
+
private simulatedProverAztecNode!: AztecNodeService;
|
|
78
76
|
public l1Contracts!: DeployAztecL1ContractsReturnType;
|
|
79
77
|
public proverAddress!: EthAddress;
|
|
80
78
|
private minNumberOfTxsPerBlock: number;
|
|
@@ -146,7 +144,7 @@ export class FullProverTest {
|
|
|
146
144
|
// We don't wish to mark as proven automatically, so we set the flag to false
|
|
147
145
|
this.context.watcher.setIsMarkingAsProven(false);
|
|
148
146
|
|
|
149
|
-
this.
|
|
147
|
+
this.simulatedProverAztecNode = this.context.proverNode!;
|
|
150
148
|
({
|
|
151
149
|
aztecNode: this.aztecNode,
|
|
152
150
|
deployL1ContractsValues: this.l1Contracts,
|
|
@@ -155,7 +153,6 @@ export class FullProverTest {
|
|
|
155
153
|
this.aztecNodeAdmin = this.context.aztecNodeService;
|
|
156
154
|
|
|
157
155
|
const config = this.context.aztecNodeConfig;
|
|
158
|
-
const blobClient = await createBlobClientWithFileStores(config, this.logger);
|
|
159
156
|
|
|
160
157
|
// Configure a full prover PXE
|
|
161
158
|
let acvmConfig: Awaited<ReturnType<typeof getACVMConfig>> | undefined;
|
|
@@ -217,20 +214,13 @@ export class FullProverTest {
|
|
|
217
214
|
this.provenWallet = provenWallet;
|
|
218
215
|
this.logger.info(`Full prover PXE started`);
|
|
219
216
|
|
|
220
|
-
// Shutdown the current, simulated prover node
|
|
217
|
+
// Shutdown the current, simulated prover node (by stopping its hosting aztec node)
|
|
221
218
|
this.logger.verbose('Shutting down simulated prover node');
|
|
222
|
-
await this.
|
|
223
|
-
|
|
224
|
-
// Creating temp store and archiver for fully proven prover node
|
|
225
|
-
this.logger.verbose('Starting archiver for new prover node');
|
|
226
|
-
const archiver = await createArchiver(
|
|
227
|
-
{ ...this.context.aztecNodeConfig, dataDirectory: undefined },
|
|
228
|
-
{ blobClient, dateProvider: this.context.dateProvider },
|
|
229
|
-
{ blockUntilSync: true },
|
|
230
|
-
);
|
|
219
|
+
await this.simulatedProverAztecNode.stop();
|
|
231
220
|
|
|
232
221
|
// The simulated prover node (now shutdown) used private key index 2
|
|
233
222
|
const proverNodePrivateKey = getPrivateKeyFromIndex(2);
|
|
223
|
+
const proverNodePrivateKeyHex = `0x${proverNodePrivateKey!.toString('hex')}` as const;
|
|
234
224
|
const proverNodeSenderAddress = privateKeyToAddress(new Buffer32(proverNodePrivateKey!).toString());
|
|
235
225
|
this.proverAddress = EthAddress.fromString(proverNodeSenderAddress);
|
|
236
226
|
|
|
@@ -238,14 +228,21 @@ export class FullProverTest {
|
|
|
238
228
|
await this.mintFeeJuice(proverNodeSenderAddress);
|
|
239
229
|
|
|
240
230
|
this.logger.verbose('Starting prover node');
|
|
241
|
-
const
|
|
242
|
-
|
|
243
|
-
|
|
231
|
+
const sponsoredFPCAddress = await getSponsoredFPCAddress();
|
|
232
|
+
const { prefilledPublicData } = await getGenesisValues(
|
|
233
|
+
this.context.initialFundedAccounts.map(a => a.address).concat(sponsoredFPCAddress),
|
|
234
|
+
);
|
|
235
|
+
|
|
236
|
+
const proverNodeConfig: Parameters<typeof AztecNodeService.createAndSync>[0] = {
|
|
237
|
+
...config,
|
|
238
|
+
enableProverNode: true,
|
|
239
|
+
disableValidator: true,
|
|
244
240
|
dataDirectory: undefined,
|
|
241
|
+
txCollectionNodeRpcUrls: [],
|
|
245
242
|
proverId: this.proverAddress,
|
|
246
243
|
realProofs: this.realProofs,
|
|
247
244
|
proverAgentCount: 2,
|
|
248
|
-
|
|
245
|
+
proverPublisherPrivateKeys: [new SecretValue(proverNodePrivateKeyHex)],
|
|
249
246
|
proverNodeMaxPendingJobs: 100,
|
|
250
247
|
proverNodeMaxParallelBlocksPerEpoch: 32,
|
|
251
248
|
proverNodePollingIntervalMs: 100,
|
|
@@ -255,21 +252,14 @@ export class FullProverTest {
|
|
|
255
252
|
txGatheringTimeoutMs: 24_000,
|
|
256
253
|
proverNodeFailedEpochStore: undefined,
|
|
257
254
|
proverNodeEpochProvingDelayMs: undefined,
|
|
255
|
+
validatorPrivateKeys: new SecretValue([]),
|
|
258
256
|
};
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
this.proverNode = await createProverNode(
|
|
264
|
-
proverConfig,
|
|
265
|
-
{
|
|
266
|
-
aztecNodeTxProvider: this.aztecNode,
|
|
267
|
-
archiver: archiver as Archiver,
|
|
268
|
-
},
|
|
257
|
+
|
|
258
|
+
this.proverAztecNode = await AztecNodeService.createAndSync(
|
|
259
|
+
proverNodeConfig,
|
|
260
|
+
{ dateProvider: this.context.dateProvider, p2pClientDeps: { rpcTxProviders: [this.aztecNode] } },
|
|
269
261
|
{ prefilledPublicData },
|
|
270
262
|
);
|
|
271
|
-
await this.proverNode.start();
|
|
272
|
-
|
|
273
263
|
this.logger.warn(`Proofs are now enabled`, { realProofs: this.realProofs });
|
|
274
264
|
return this;
|
|
275
265
|
}
|
|
@@ -289,8 +279,8 @@ export class FullProverTest {
|
|
|
289
279
|
await this.provenComponents[i].teardown();
|
|
290
280
|
}
|
|
291
281
|
|
|
292
|
-
// clean up the full prover node
|
|
293
|
-
await this.
|
|
282
|
+
// clean up the full prover node (by stopping its hosting aztec node)
|
|
283
|
+
await this.proverAztecNode.stop();
|
|
294
284
|
|
|
295
285
|
await Barretenberg.destroySingleton();
|
|
296
286
|
await this.bbConfigCleanup?.();
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { appendFileSync } from 'node:fs';
|
|
2
|
+
import { type EventLoopUtilization, type IntervalHistogram, monitorEventLoopDelay, performance } from 'node:perf_hooks';
|
|
3
|
+
|
|
4
|
+
const NANOS_PER_MS = 1_000_000;
|
|
5
|
+
|
|
6
|
+
/** Samples event-loop utilization, delay histogram, and heap usage per test, writing columnar text to a file. */
|
|
7
|
+
export class EluMonitor {
|
|
8
|
+
private filePath: string;
|
|
9
|
+
private intervalMs: number;
|
|
10
|
+
private timer: ReturnType<typeof setInterval> | undefined;
|
|
11
|
+
private lastELU: EventLoopUtilization | undefined;
|
|
12
|
+
private histogram: IntervalHistogram;
|
|
13
|
+
private testName: string | undefined;
|
|
14
|
+
private testStart: number | undefined;
|
|
15
|
+
private eluSamples: number[] = [];
|
|
16
|
+
|
|
17
|
+
constructor(filePath: string, intervalMs?: number) {
|
|
18
|
+
this.filePath = filePath;
|
|
19
|
+
this.intervalMs = intervalMs ?? 2000;
|
|
20
|
+
this.histogram = monitorEventLoopDelay({ resolution: 20 });
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Begin sampling for a test. Writes a header line and starts the periodic sampler. */
|
|
24
|
+
startTest(testName: string): void {
|
|
25
|
+
this.stopTest();
|
|
26
|
+
|
|
27
|
+
this.testName = testName;
|
|
28
|
+
this.testStart = performance.now();
|
|
29
|
+
this.eluSamples = [];
|
|
30
|
+
|
|
31
|
+
appendFileSync(this.filePath, `\n=== Test: ${testName} ===\n`);
|
|
32
|
+
appendFileSync(
|
|
33
|
+
this.filePath,
|
|
34
|
+
padColumns('TIME', 'ELU', 'EL_DLY_P50', 'EL_DLY_P99', 'EL_DLY_MAX', 'HEAP_MB') + '\n',
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
this.lastELU = performance.eventLoopUtilization();
|
|
38
|
+
this.histogram.enable();
|
|
39
|
+
|
|
40
|
+
this.timer = setInterval(() => this.sample(), this.intervalMs);
|
|
41
|
+
// Allow the process to exit even if the timer is still running.
|
|
42
|
+
this.timer.unref();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Stop sampling and write a summary line. */
|
|
46
|
+
stopTest(): void {
|
|
47
|
+
if (!this.timer) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Take a final sample before stopping.
|
|
52
|
+
this.sample();
|
|
53
|
+
|
|
54
|
+
clearInterval(this.timer);
|
|
55
|
+
this.timer = undefined;
|
|
56
|
+
this.histogram.disable();
|
|
57
|
+
this.histogram.reset();
|
|
58
|
+
|
|
59
|
+
this.writeSummary();
|
|
60
|
+
|
|
61
|
+
this.lastELU = undefined;
|
|
62
|
+
this.testName = undefined;
|
|
63
|
+
this.testStart = undefined;
|
|
64
|
+
this.eluSamples = [];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Alias for stopTest — call on process exit to flush any remaining data. */
|
|
68
|
+
stop(): void {
|
|
69
|
+
this.stopTest();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private sample(): void {
|
|
73
|
+
const newELU = performance.eventLoopUtilization();
|
|
74
|
+
const delta = performance.eventLoopUtilization(newELU, this.lastELU);
|
|
75
|
+
this.lastELU = newELU;
|
|
76
|
+
|
|
77
|
+
const elu = delta.utilization;
|
|
78
|
+
this.eluSamples.push(elu);
|
|
79
|
+
|
|
80
|
+
const p50 = this.histogram.percentile(50) / NANOS_PER_MS;
|
|
81
|
+
const p99 = this.histogram.percentile(99) / NANOS_PER_MS;
|
|
82
|
+
const max = this.histogram.max / NANOS_PER_MS;
|
|
83
|
+
const heapMb = Math.round(process.memoryUsage().heapUsed / (1024 * 1024));
|
|
84
|
+
|
|
85
|
+
const now = new Date();
|
|
86
|
+
const time = [now.getHours(), now.getMinutes(), now.getSeconds()].map(n => String(n).padStart(2, '0')).join(':');
|
|
87
|
+
|
|
88
|
+
const line = padColumns(
|
|
89
|
+
time,
|
|
90
|
+
elu.toFixed(2),
|
|
91
|
+
`${p50.toFixed(1)}ms`,
|
|
92
|
+
`${p99.toFixed(1)}ms`,
|
|
93
|
+
`${max.toFixed(1)}ms`,
|
|
94
|
+
String(heapMb),
|
|
95
|
+
);
|
|
96
|
+
appendFileSync(this.filePath, line + '\n');
|
|
97
|
+
|
|
98
|
+
// Reset histogram so next sample only reflects the new interval.
|
|
99
|
+
this.histogram.reset();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
private writeSummary(): void {
|
|
103
|
+
if (this.eluSamples.length === 0 || this.testStart === undefined) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const mean = this.eluSamples.reduce((a, b) => a + b, 0) / this.eluSamples.length;
|
|
108
|
+
const maxElu = Math.max(...this.eluSamples);
|
|
109
|
+
const sorted = [...this.eluSamples].sort((a, b) => a - b);
|
|
110
|
+
const p90Elu = sorted[Math.floor(sorted.length * 0.9)] ?? maxElu;
|
|
111
|
+
const durationS = ((performance.now() - this.testStart) / 1000).toFixed(1);
|
|
112
|
+
|
|
113
|
+
let summary = `--- Summary: mean_elu=${mean.toFixed(2)} max_elu=${maxElu.toFixed(2)} p90_elu=${p90Elu.toFixed(2)} duration=${durationS}s`;
|
|
114
|
+
if (maxElu > 0.85) {
|
|
115
|
+
summary += ' WARNING:ELU>0.85';
|
|
116
|
+
}
|
|
117
|
+
summary += ' ---\n';
|
|
118
|
+
|
|
119
|
+
appendFileSync(this.filePath, summary);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function padColumns(...cols: string[]): string {
|
|
124
|
+
const widths = [11, 7, 12, 12, 12, 8];
|
|
125
|
+
return cols.map((col, i) => col.padEnd(widths[i] ?? 10)).join('');
|
|
126
|
+
}
|
package/src/fixtures/fixtures.ts
CHANGED
|
@@ -7,6 +7,16 @@ export const shouldCollectMetrics = () => {
|
|
|
7
7
|
return undefined;
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
+
/** Returns the boot node UDP port from environment variable or default value. */
|
|
11
|
+
export function getBootNodeUdpPort(): number {
|
|
12
|
+
return process.env.BOOT_NODE_UDP_PORT ? parseInt(process.env.BOOT_NODE_UDP_PORT, 10) : 4500;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Returns the anvil port from environment variable or default value. */
|
|
16
|
+
export function getAnvilPort(): number {
|
|
17
|
+
return process.env.ANVIL_PORT ? parseInt(process.env.ANVIL_PORT, 10) : 8545;
|
|
18
|
+
}
|
|
19
|
+
|
|
10
20
|
export const TEST_PEER_CHECK_INTERVAL_MS = 1000;
|
|
11
21
|
export const TEST_MAX_PENDING_TX_POOL_COUNT = 10_000; // Number of max pending TXs ~ 1.56GB
|
|
12
22
|
|
package/src/fixtures/setup.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
|
|
2
2
|
import { type InitialAccountData, generateSchnorrAccounts } from '@aztec/accounts/testing';
|
|
3
|
-
import { type Archiver, createArchiver } from '@aztec/archiver';
|
|
4
3
|
import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
|
|
5
4
|
import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
|
|
6
5
|
import {
|
|
@@ -16,7 +15,6 @@ import { type Logger, createLogger } from '@aztec/aztec.js/log';
|
|
|
16
15
|
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
17
16
|
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
18
17
|
import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec/testing';
|
|
19
|
-
import { createBlobClientWithFileStores } from '@aztec/blob-client/client';
|
|
20
18
|
import { SPONSORED_FPC_SALT } from '@aztec/constants';
|
|
21
19
|
import { isAnvilTestChain } from '@aztec/ethereum/chain';
|
|
22
20
|
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
@@ -30,13 +28,9 @@ import {
|
|
|
30
28
|
type ZKPassportArgs,
|
|
31
29
|
deployAztecL1Contracts,
|
|
32
30
|
} from '@aztec/ethereum/deploy-aztec-l1-contracts';
|
|
33
|
-
import {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
EthCheatCodesWithState,
|
|
37
|
-
createDelayedL1TxUtilsFromViemWallet,
|
|
38
|
-
startAnvil,
|
|
39
|
-
} from '@aztec/ethereum/test';
|
|
31
|
+
import type { Delayer } from '@aztec/ethereum/l1-tx-utils';
|
|
32
|
+
import { EthCheatCodes, EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
|
|
33
|
+
import type { Anvil } from '@aztec/ethereum/test';
|
|
40
34
|
import { BlockNumber, EpochNumber } from '@aztec/foundation/branded-types';
|
|
41
35
|
import { SecretValue } from '@aztec/foundation/config';
|
|
42
36
|
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
@@ -45,20 +39,17 @@ import { withLoggerBindings } from '@aztec/foundation/log/server';
|
|
|
45
39
|
import { retryUntil } from '@aztec/foundation/retry';
|
|
46
40
|
import { sleep } from '@aztec/foundation/sleep';
|
|
47
41
|
import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
|
|
48
|
-
import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
49
42
|
import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
|
|
50
43
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
51
44
|
import type { P2PClientDeps } from '@aztec/p2p';
|
|
52
45
|
import { MockGossipSubNetwork, getMockPubSubP2PServiceFactory } from '@aztec/p2p/test-helpers';
|
|
53
46
|
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
54
|
-
import
|
|
47
|
+
import type { ProverNodeConfig } from '@aztec/prover-node';
|
|
55
48
|
import { type PXEConfig, getPXEConfig } from '@aztec/pxe/server';
|
|
56
49
|
import type { SequencerClient } from '@aztec/sequencer-client';
|
|
57
|
-
import type { TestSequencerClient } from '@aztec/sequencer-client/test';
|
|
58
50
|
import { type ContractInstanceWithAddress, getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
|
|
59
51
|
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
60
52
|
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
61
|
-
import type { P2PClientType } from '@aztec/stdlib/p2p';
|
|
62
53
|
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
63
54
|
import {
|
|
64
55
|
type TelemetryClient,
|
|
@@ -70,7 +61,6 @@ import { BenchmarkTelemetryClient } from '@aztec/telemetry-client/bench';
|
|
|
70
61
|
import { deployFundedSchnorrAccounts } from '@aztec/wallets/testing';
|
|
71
62
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
72
63
|
|
|
73
|
-
import type { Anvil } from '@viem/anvil';
|
|
74
64
|
import fs from 'fs/promises';
|
|
75
65
|
import { tmpdir } from 'os';
|
|
76
66
|
import path from 'path';
|
|
@@ -219,8 +209,8 @@ export type EndToEndContext = {
|
|
|
219
209
|
aztecNodeService: AztecNodeService;
|
|
220
210
|
/** Client to the Aztec Node admin interface. */
|
|
221
211
|
aztecNodeAdmin: AztecNodeAdmin;
|
|
222
|
-
/** The prover node
|
|
223
|
-
proverNode:
|
|
212
|
+
/** The aztec node running the prover node subsystem (only set if startProverNode is true). */
|
|
213
|
+
proverNode: AztecNodeService | undefined;
|
|
224
214
|
/** A client to the sequencer service. */
|
|
225
215
|
sequencer: SequencerClient | undefined;
|
|
226
216
|
/** Return values from deployAztecL1Contracts function. */
|
|
@@ -249,6 +239,10 @@ export type EndToEndContext = {
|
|
|
249
239
|
telemetryClient: TelemetryClient;
|
|
250
240
|
/** Mock gossip sub network used for gossipping messages (only if mockGossipSubNetwork was set to true in opts) */
|
|
251
241
|
mockGossipSubNetwork: MockGossipSubNetwork | undefined;
|
|
242
|
+
/** Delayer for sequencer L1 txs (only when enableDelayer is true). */
|
|
243
|
+
sequencerDelayer: Delayer | undefined;
|
|
244
|
+
/** Delayer for prover node L1 txs (only when enableDelayer and startProverNode are true). */
|
|
245
|
+
proverDelayer: Delayer | undefined;
|
|
252
246
|
/** Prefilled public data used for setting up nodes. */
|
|
253
247
|
prefilledPublicData: PublicDataTreeLeaf[] | undefined;
|
|
254
248
|
/** ACVM config (only set if running locally). */
|
|
@@ -288,6 +282,8 @@ export async function setup(
|
|
|
288
282
|
config.realProofs = !!opts.realProofs;
|
|
289
283
|
// Only enforce the time table if requested
|
|
290
284
|
config.enforceTimeTable = !!opts.enforceTimeTable;
|
|
285
|
+
// Enable the tx delayer for tests (default config has it disabled, so we force-enable it here)
|
|
286
|
+
config.enableDelayer = true;
|
|
291
287
|
config.listenAddress = '127.0.0.1';
|
|
292
288
|
|
|
293
289
|
config.minTxPoolAgeMs = opts.minTxPoolAgeMs ?? 0;
|
|
@@ -339,11 +335,11 @@ export async function setup(
|
|
|
339
335
|
publisherPrivKeyHex = opts.l1PublisherKey.getValue();
|
|
340
336
|
publisherHdAccount = privateKeyToAccount(publisherPrivKeyHex);
|
|
341
337
|
} else if (
|
|
342
|
-
config.
|
|
343
|
-
config.
|
|
344
|
-
config.
|
|
338
|
+
config.sequencerPublisherPrivateKeys &&
|
|
339
|
+
config.sequencerPublisherPrivateKeys.length > 0 &&
|
|
340
|
+
config.sequencerPublisherPrivateKeys[0].getValue() != NULL_KEY
|
|
345
341
|
) {
|
|
346
|
-
publisherPrivKeyHex = config.
|
|
342
|
+
publisherPrivKeyHex = config.sequencerPublisherPrivateKeys[0].getValue();
|
|
347
343
|
publisherHdAccount = privateKeyToAccount(publisherPrivKeyHex);
|
|
348
344
|
} else if (!MNEMONIC) {
|
|
349
345
|
throw new Error(`Mnemonic not provided and no publisher private key`);
|
|
@@ -352,7 +348,7 @@ export async function setup(
|
|
|
352
348
|
const publisherPrivKeyRaw = publisherHdAccount.getHdKey().privateKey;
|
|
353
349
|
const publisherPrivKey = publisherPrivKeyRaw === null ? null : Buffer.from(publisherPrivKeyRaw);
|
|
354
350
|
publisherPrivKeyHex = `0x${publisherPrivKey!.toString('hex')}` as const;
|
|
355
|
-
config.
|
|
351
|
+
config.sequencerPublisherPrivateKeys = [new SecretValue(publisherPrivKeyHex)];
|
|
356
352
|
}
|
|
357
353
|
|
|
358
354
|
if (config.coinbase === undefined) {
|
|
@@ -459,7 +455,7 @@ export async function setup(
|
|
|
459
455
|
}
|
|
460
456
|
|
|
461
457
|
let mockGossipSubNetwork: MockGossipSubNetwork | undefined;
|
|
462
|
-
let p2pClientDeps: P2PClientDeps
|
|
458
|
+
let p2pClientDeps: P2PClientDeps | undefined = undefined;
|
|
463
459
|
|
|
464
460
|
if (opts.mockGossipSubNetwork) {
|
|
465
461
|
mockGossipSubNetwork = new MockGossipSubNetwork();
|
|
@@ -499,36 +495,33 @@ export async function setup(
|
|
|
499
495
|
);
|
|
500
496
|
const sequencerClient = aztecNodeService.getSequencer();
|
|
501
497
|
|
|
502
|
-
|
|
503
|
-
const publisher = (sequencerClient as TestSequencerClient).sequencer.publisher;
|
|
504
|
-
publisher.l1TxUtils = DelayedTxUtils.fromL1TxUtils(publisher.l1TxUtils, config.ethereumSlotDuration, l1Client);
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
let proverNode: ProverNode | undefined = undefined;
|
|
498
|
+
let proverNode: AztecNodeService | undefined = undefined;
|
|
508
499
|
if (opts.startProverNode) {
|
|
509
500
|
logger.verbose('Creating and syncing a simulated prover node...');
|
|
510
501
|
const proverNodePrivateKey = getPrivateKeyFromIndex(2);
|
|
511
502
|
const proverNodePrivateKeyHex: Hex = `0x${proverNodePrivateKey!.toString('hex')}`;
|
|
512
503
|
const proverNodeDataDirectory = path.join(directoryToCleanup, randomBytes(8).toString('hex'));
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
504
|
+
|
|
505
|
+
const p2pClientDeps: Partial<P2PClientDeps> = {
|
|
506
|
+
p2pServiceFactory: mockGossipSubNetwork && getMockPubSubP2PServiceFactory(mockGossipSubNetwork!),
|
|
507
|
+
rpcTxProviders: [aztecNodeService],
|
|
517
508
|
};
|
|
518
|
-
|
|
509
|
+
|
|
510
|
+
({ proverNode } = await createAndSyncProverNode(
|
|
519
511
|
proverNodePrivateKeyHex,
|
|
520
512
|
config,
|
|
521
|
-
proverNodeConfig,
|
|
522
|
-
aztecNodeService,
|
|
523
|
-
prefilledPublicData,
|
|
524
513
|
{
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
: undefined,
|
|
514
|
+
...config.proverNodeConfig,
|
|
515
|
+
dataDirectory: proverNodeDataDirectory,
|
|
528
516
|
},
|
|
529
|
-
|
|
517
|
+
{ dateProvider, p2pClientDeps, telemetry: telemetryClient },
|
|
518
|
+
{ prefilledPublicData },
|
|
519
|
+
));
|
|
530
520
|
}
|
|
531
521
|
|
|
522
|
+
const sequencerDelayer = sequencerClient?.getDelayer();
|
|
523
|
+
const proverDelayer = proverNode?.getProverNode()?.getDelayer();
|
|
524
|
+
|
|
532
525
|
logger.verbose('Creating a pxe...');
|
|
533
526
|
const pxeConfig = { ...getPXEConfig(), ...pxeOpts };
|
|
534
527
|
pxeConfig.dataDirectory = path.join(directoryToCleanup, randomBytes(8).toString('hex'));
|
|
@@ -629,6 +622,8 @@ export async function setup(
|
|
|
629
622
|
mockGossipSubNetwork,
|
|
630
623
|
prefilledPublicData,
|
|
631
624
|
proverNode,
|
|
625
|
+
sequencerDelayer,
|
|
626
|
+
proverDelayer,
|
|
632
627
|
sequencer: sequencerClient,
|
|
633
628
|
teardown,
|
|
634
629
|
telemetryClient,
|
|
@@ -712,81 +707,42 @@ export async function waitForProvenChain(node: AztecNode, targetBlock?: BlockNum
|
|
|
712
707
|
);
|
|
713
708
|
}
|
|
714
709
|
|
|
710
|
+
/**
|
|
711
|
+
* Creates an AztecNodeService with the prover node enabled as a subsystem.
|
|
712
|
+
* Returns both the aztec node service (for lifecycle management) and the prover node (for test internals access).
|
|
713
|
+
*/
|
|
715
714
|
export function createAndSyncProverNode(
|
|
716
715
|
proverNodePrivateKey: `0x${string}`,
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
716
|
+
baseConfig: AztecNodeConfig,
|
|
717
|
+
configOverrides: Pick<AztecNodeConfig, 'dataDirectory'>,
|
|
718
|
+
deps: {
|
|
719
|
+
telemetry?: TelemetryClient;
|
|
720
|
+
dateProvider: DateProvider;
|
|
721
|
+
p2pClientDeps?: P2PClientDeps;
|
|
722
|
+
},
|
|
723
|
+
options: { prefilledPublicData: PublicDataTreeLeaf[]; dontStart?: boolean },
|
|
724
|
+
): Promise<{ proverNode: AztecNodeService }> {
|
|
723
725
|
return withLoggerBindings({ actor: 'prover-0' }, async () => {
|
|
724
|
-
const
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
{ blobClient, dateProvider: proverNodeDeps.dateProvider },
|
|
736
|
-
{ blockUntilSync: true },
|
|
737
|
-
);
|
|
738
|
-
|
|
739
|
-
const proverConfig: ProverNodeConfig = {
|
|
740
|
-
...aztecNodeConfig,
|
|
741
|
-
txCollectionNodeRpcUrls: [],
|
|
742
|
-
realProofs: false,
|
|
743
|
-
proverAgentCount: 2,
|
|
744
|
-
publisherPrivateKeys: [new SecretValue(proverNodePrivateKey)],
|
|
745
|
-
proverNodeMaxPendingJobs: 10,
|
|
746
|
-
proverNodeMaxParallelBlocksPerEpoch: 32,
|
|
747
|
-
proverNodePollingIntervalMs: 200,
|
|
748
|
-
txGatheringIntervalMs: 1000,
|
|
749
|
-
txGatheringBatchSize: 10,
|
|
750
|
-
txGatheringMaxParallelRequestsPerNode: 10,
|
|
751
|
-
txGatheringTimeoutMs: 24_000,
|
|
752
|
-
proverNodeFailedEpochStore: undefined,
|
|
753
|
-
proverId: EthAddress.fromNumber(1),
|
|
754
|
-
proverNodeEpochProvingDelayMs: undefined,
|
|
755
|
-
...proverNodeConfig,
|
|
756
|
-
};
|
|
757
|
-
|
|
758
|
-
const l1TxUtils = createDelayedL1TxUtils(
|
|
759
|
-
aztecNodeConfig,
|
|
760
|
-
proverNodePrivateKey,
|
|
761
|
-
'prover-node',
|
|
762
|
-
proverNodeDeps.dateProvider,
|
|
726
|
+
const proverNode = await AztecNodeService.createAndSync(
|
|
727
|
+
{
|
|
728
|
+
...baseConfig,
|
|
729
|
+
...configOverrides,
|
|
730
|
+
p2pPort: 0,
|
|
731
|
+
enableProverNode: true,
|
|
732
|
+
disableValidator: true,
|
|
733
|
+
proverPublisherPrivateKeys: [new SecretValue(proverNodePrivateKey)],
|
|
734
|
+
},
|
|
735
|
+
deps,
|
|
736
|
+
{ ...options, dontStartProverNode: options.dontStart },
|
|
763
737
|
);
|
|
764
738
|
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
{ ...proverNodeDeps, aztecNodeTxProvider, archiver: archiver as Archiver, l1TxUtils },
|
|
768
|
-
{ prefilledPublicData },
|
|
769
|
-
);
|
|
770
|
-
getLogger().info(`Created and synced prover node`, { publisherAddress: l1TxUtils.client.account!.address });
|
|
771
|
-
if (!proverNodeConfig.dontStart) {
|
|
772
|
-
await proverNode.start();
|
|
739
|
+
if (!proverNode.getProverNode()) {
|
|
740
|
+
throw new Error('Prover node subsystem was not created despite enableProverNode being set');
|
|
773
741
|
}
|
|
774
|
-
return proverNode;
|
|
775
|
-
});
|
|
776
|
-
}
|
|
777
742
|
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
logName: string,
|
|
782
|
-
dateProvider?: DateProvider,
|
|
783
|
-
) {
|
|
784
|
-
const l1Client = createExtendedL1Client(aztecNodeConfig.l1RpcUrls, privateKey, foundry);
|
|
785
|
-
|
|
786
|
-
const log = createLogger(logName);
|
|
787
|
-
const l1TxUtils = createDelayedL1TxUtilsFromViemWallet(l1Client, log, dateProvider, aztecNodeConfig);
|
|
788
|
-
l1TxUtils.enableDelayer(aztecNodeConfig.ethereumSlotDuration);
|
|
789
|
-
return l1TxUtils;
|
|
743
|
+
getLogger().info(`Created and synced prover node`);
|
|
744
|
+
return { proverNode };
|
|
745
|
+
});
|
|
790
746
|
}
|
|
791
747
|
|
|
792
748
|
export type BalancesFn = ReturnType<typeof getBalancesFn>;
|
|
@@ -7,7 +7,6 @@ import { SecretValue } from '@aztec/foundation/config';
|
|
|
7
7
|
import { withLoggerBindings } from '@aztec/foundation/log/server';
|
|
8
8
|
import { bufferToHex } from '@aztec/foundation/string';
|
|
9
9
|
import type { DateProvider } from '@aztec/foundation/timer';
|
|
10
|
-
import type { ProverNodeConfig, ProverNodeDeps } from '@aztec/prover-node';
|
|
11
10
|
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
12
11
|
|
|
13
12
|
import getPort from 'get-port';
|
|
@@ -131,7 +130,7 @@ export async function createNonValidatorNode(
|
|
|
131
130
|
...p2pConfig,
|
|
132
131
|
disableValidator: true,
|
|
133
132
|
validatorPrivateKeys: undefined,
|
|
134
|
-
|
|
133
|
+
sequencerPublisherPrivateKeys: [],
|
|
135
134
|
};
|
|
136
135
|
const telemetry = await getEndToEndTestTelemetryClient(metricsPort);
|
|
137
136
|
return await AztecNodeService.createAndSync(config, { telemetry, dateProvider }, { prefilledPublicData });
|
|
@@ -143,31 +142,24 @@ export async function createProverNode(
|
|
|
143
142
|
tcpPort: number,
|
|
144
143
|
bootstrapNode: string | undefined,
|
|
145
144
|
addressIndex: number,
|
|
146
|
-
|
|
145
|
+
deps: { dateProvider: DateProvider },
|
|
147
146
|
prefilledPublicData?: PublicDataTreeLeaf[],
|
|
148
147
|
dataDirectory?: string,
|
|
149
148
|
metricsPort?: number,
|
|
150
|
-
) {
|
|
149
|
+
): Promise<{ proverNode: AztecNodeService }> {
|
|
151
150
|
const actorIndex = proverCounter++;
|
|
152
151
|
return await withLoggerBindings({ actor: `prover-${actorIndex}` }, async () => {
|
|
153
152
|
const proverNodePrivateKey = getPrivateKeyFromIndex(ATTESTER_PRIVATE_KEYS_START_INDEX + addressIndex)!;
|
|
154
153
|
const telemetry = await getEndToEndTestTelemetryClient(metricsPort);
|
|
155
154
|
|
|
156
|
-
const
|
|
157
|
-
config,
|
|
158
|
-
bootstrapNode,
|
|
159
|
-
tcpPort,
|
|
160
|
-
dataDirectory,
|
|
161
|
-
);
|
|
155
|
+
const p2pConfig = await createP2PConfig(config, bootstrapNode, tcpPort, dataDirectory);
|
|
162
156
|
|
|
163
|
-
const aztecNodeRpcTxProvider = undefined;
|
|
164
157
|
return await createAndSyncProverNode(
|
|
165
158
|
bufferToHex(proverNodePrivateKey),
|
|
166
|
-
config,
|
|
167
|
-
{
|
|
168
|
-
|
|
169
|
-
prefilledPublicData,
|
|
170
|
-
{ ...proverNodeDeps, telemetry },
|
|
159
|
+
{ ...config, ...p2pConfig },
|
|
160
|
+
{ dataDirectory },
|
|
161
|
+
{ ...deps, telemetry },
|
|
162
|
+
{ prefilledPublicData: prefilledPublicData ?? [] },
|
|
171
163
|
);
|
|
172
164
|
});
|
|
173
165
|
}
|
|
@@ -215,7 +207,7 @@ export async function createValidatorConfig(
|
|
|
215
207
|
...config,
|
|
216
208
|
...p2pConfig,
|
|
217
209
|
validatorPrivateKeys: new SecretValue(attesterPrivateKeys),
|
|
218
|
-
|
|
210
|
+
sequencerPublisherPrivateKeys: [new SecretValue(attesterPrivateKeys[0])],
|
|
219
211
|
};
|
|
220
212
|
|
|
221
213
|
return nodeConfig;
|
|
@@ -25,8 +25,9 @@ export async function mintTokensToPrivate(
|
|
|
25
25
|
minter: AztecAddress,
|
|
26
26
|
recipient: AztecAddress,
|
|
27
27
|
amount: bigint,
|
|
28
|
+
additionalScopes?: AztecAddress[],
|
|
28
29
|
) {
|
|
29
|
-
await token.methods.mint_to_private(recipient, amount).send({ from: minter });
|
|
30
|
+
await token.methods.mint_to_private(recipient, amount).send({ from: minter, additionalScopes });
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
export async function expectTokenBalance(
|