@aztec/end-to-end 0.0.1-commit.03f7ef2 → 0.0.1-commit.0b941701
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/benchmark.d.ts +3 -2
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/benchmark.js +21 -1
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +12 -13
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +118 -133
- package/dest/bench/client_flows/data_extractor.js +3 -1
- package/dest/bench/utils.d.ts +9 -8
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +27 -18
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +6 -7
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +96 -112
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +15 -10
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +89 -70
- package/dest/e2e_deploy_contract/deploy_test.d.ts +4 -3
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +18 -13
- package/dest/e2e_epochs/epochs_test.d.ts +1 -1
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +5 -2
- package/dest/e2e_fees/bridging_race.notest.js +3 -5
- package/dest/e2e_fees/fees_test.d.ts +13 -13
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +123 -141
- package/dest/e2e_l1_publisher/write_json.d.ts +2 -2
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
- package/dest/e2e_l1_publisher/write_json.js +19 -15
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +6 -9
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +31 -39
- package/dest/e2e_p2p/inactivity_slash_test.d.ts +3 -3
- package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -1
- package/dest/e2e_p2p/inactivity_slash_test.js +3 -3
- package/dest/e2e_p2p/p2p_network.d.ts +7 -6
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +111 -104
- package/dest/e2e_p2p/shared.d.ts +6 -6
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +11 -18
- package/dest/e2e_token_contract/token_contract_test.d.ts +16 -9
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +89 -91
- package/dest/fixtures/e2e_prover_test.d.ts +8 -14
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +85 -94
- package/dest/fixtures/fixtures.d.ts +2 -2
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +1 -1
- package/dest/fixtures/setup.d.ts +218 -0
- package/dest/fixtures/setup.d.ts.map +1 -0
- package/dest/fixtures/setup.js +690 -0
- package/dest/fixtures/token_utils.d.ts +1 -1
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +7 -4
- package/dest/fixtures/utils.d.ts +5 -194
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +4 -619
- package/dest/quality_of_service/grafana_client.d.ts +41 -0
- package/dest/quality_of_service/grafana_client.d.ts.map +1 -0
- package/dest/quality_of_service/{alert_checker.js → grafana_client.js} +1 -1
- package/dest/quality_of_service/prometheus_client.d.ts +38 -0
- package/dest/quality_of_service/prometheus_client.d.ts.map +1 -0
- package/dest/quality_of_service/prometheus_client.js +67 -0
- package/dest/shared/cross_chain_test_harness.d.ts +16 -6
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +13 -13
- package/dest/shared/gas_portal_test_harness.d.ts +11 -1
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +1 -1
- package/dest/shared/index.d.ts +2 -2
- package/dest/shared/index.d.ts.map +1 -1
- package/dest/shared/submit-transactions.d.ts +3 -3
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/submit-transactions.js +9 -11
- package/dest/shared/uniswap_l1_l2.d.ts +3 -28
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +51 -33
- package/dest/simulators/lending_simulator.d.ts +5 -1
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +2 -2
- package/dest/spartan/setup_test_wallets.d.ts +4 -3
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +61 -34
- package/dest/spartan/tx_metrics.d.ts +17 -2
- package/dest/spartan/tx_metrics.d.ts.map +1 -1
- package/dest/spartan/tx_metrics.js +183 -6
- package/dest/spartan/utils/bot.d.ts +27 -0
- package/dest/spartan/utils/bot.d.ts.map +1 -0
- package/dest/spartan/utils/bot.js +141 -0
- package/dest/spartan/utils/chaos.d.ts +79 -0
- package/dest/spartan/utils/chaos.d.ts.map +1 -0
- package/dest/spartan/utils/chaos.js +142 -0
- package/dest/spartan/utils/clients.d.ts +39 -0
- package/dest/spartan/utils/clients.d.ts.map +1 -0
- package/dest/spartan/utils/clients.js +90 -0
- package/dest/spartan/utils/config.d.ts +36 -0
- package/dest/spartan/utils/config.d.ts.map +1 -0
- package/dest/spartan/utils/config.js +20 -0
- package/dest/spartan/utils/health.d.ts +63 -0
- package/dest/spartan/utils/health.d.ts.map +1 -0
- package/dest/spartan/utils/health.js +202 -0
- package/dest/spartan/utils/helm.d.ts +15 -0
- package/dest/spartan/utils/helm.d.ts.map +1 -0
- package/dest/spartan/utils/helm.js +47 -0
- package/dest/spartan/utils/index.d.ts +9 -0
- package/dest/spartan/utils/index.d.ts.map +1 -0
- package/dest/spartan/utils/index.js +18 -0
- package/dest/spartan/utils/k8s.d.ts +98 -0
- package/dest/spartan/utils/k8s.d.ts.map +1 -0
- package/dest/spartan/utils/k8s.js +257 -0
- package/dest/spartan/utils/nodes.d.ts +31 -0
- package/dest/spartan/utils/nodes.d.ts.map +1 -0
- package/dest/spartan/utils/nodes.js +290 -0
- package/dest/spartan/utils/scripts.d.ts +16 -0
- package/dest/spartan/utils/scripts.d.ts.map +1 -0
- package/dest/spartan/utils/scripts.js +66 -0
- package/dest/spartan/utils.d.ts +2 -231
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +1 -853
- package/package.json +40 -39
- package/src/bench/client_flows/benchmark.ts +24 -2
- package/src/bench/client_flows/client_flows_benchmark.ts +138 -204
- package/src/bench/client_flows/data_extractor.ts +1 -1
- package/src/bench/utils.ts +30 -20
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +104 -142
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +127 -116
- package/src/e2e_deploy_contract/deploy_test.ts +21 -14
- package/src/e2e_epochs/epochs_test.ts +31 -26
- package/src/e2e_fees/bridging_race.notest.ts +3 -9
- package/src/e2e_fees/fees_test.ts +172 -220
- package/src/e2e_l1_publisher/write_json.ts +21 -16
- package/src/e2e_nested_contract/nested_contract_test.ts +33 -56
- package/src/e2e_p2p/inactivity_slash_test.ts +5 -5
- package/src/e2e_p2p/p2p_network.ts +172 -168
- package/src/e2e_p2p/shared.ts +16 -25
- package/src/e2e_token_contract/token_contract_test.ts +103 -118
- package/src/fixtures/e2e_prover_test.ts +98 -133
- package/src/fixtures/fixtures.ts +1 -1
- package/src/fixtures/setup.ts +1017 -0
- package/src/fixtures/token_utils.ts +6 -5
- package/src/fixtures/utils.ts +27 -907
- package/src/quality_of_service/{alert_checker.ts → grafana_client.ts} +1 -1
- package/src/quality_of_service/prometheus_client.ts +113 -0
- package/src/shared/cross_chain_test_harness.ts +16 -36
- package/src/shared/gas_portal_test_harness.ts +1 -1
- package/src/shared/index.ts +1 -1
- package/src/shared/submit-transactions.ts +9 -15
- package/src/shared/uniswap_l1_l2.ts +58 -77
- package/src/simulators/lending_simulator.ts +2 -2
- package/src/spartan/setup_test_wallets.ts +79 -25
- package/src/spartan/tx_metrics.ts +129 -9
- package/src/spartan/utils/bot.ts +185 -0
- package/src/spartan/utils/chaos.ts +253 -0
- package/src/spartan/utils/clients.ts +100 -0
- package/src/spartan/utils/config.ts +26 -0
- package/src/spartan/utils/health.ts +255 -0
- package/src/spartan/utils/helm.ts +84 -0
- package/src/spartan/utils/index.ts +62 -0
- package/src/spartan/utils/k8s.ts +375 -0
- package/src/spartan/utils/nodes.ts +323 -0
- package/src/spartan/utils/scripts.ts +63 -0
- package/src/spartan/utils.ts +1 -1077
- package/dest/fixtures/snapshot_manager.d.ts +0 -93
- package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
- package/dest/fixtures/snapshot_manager.js +0 -493
- package/dest/quality_of_service/alert_checker.d.ts +0 -41
- package/dest/quality_of_service/alert_checker.d.ts.map +0 -1
- package/src/fixtures/snapshot_manager.ts +0 -651
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { generateSchnorrAccounts } from '@aztec/accounts/testing';
|
|
2
2
|
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
3
|
+
import { NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
3
4
|
import { L1FeeJuicePortalManager } from '@aztec/aztec.js/ethereum';
|
|
4
5
|
import { FeeJuicePaymentMethodWithClaim } from '@aztec/aztec.js/fee';
|
|
5
6
|
import { type FeePaymentMethod, SponsoredFeePaymentMethod } from '@aztec/aztec.js/fee';
|
|
6
7
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
7
|
-
import { type AztecNode, createAztecNodeClient } from '@aztec/aztec.js/node';
|
|
8
|
+
import { type AztecNode, createAztecNodeClient, waitForTx } from '@aztec/aztec.js/node';
|
|
8
9
|
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
9
10
|
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
10
11
|
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
@@ -84,11 +85,11 @@ export async function deploySponsoredTestAccountsWithTokens(
|
|
|
84
85
|
|
|
85
86
|
const paymentMethod = new SponsoredFeePaymentMethod(await getSponsoredFPCAddress());
|
|
86
87
|
const recipientDeployMethod = await recipientAccount.getDeployMethod();
|
|
87
|
-
await recipientDeployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod }
|
|
88
|
+
await recipientDeployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod }, wait: { timeout: 2400 } });
|
|
88
89
|
await Promise.all(
|
|
89
90
|
fundedAccounts.map(async a => {
|
|
90
91
|
const deployMethod = await a.getDeployMethod();
|
|
91
|
-
await deployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod }
|
|
92
|
+
await deployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod }, wait: { timeout: 2400 } }); // increase timeout on purpose in order to account for two empty epochs
|
|
92
93
|
logger.info(`Account deployed at ${a.address}`);
|
|
93
94
|
}),
|
|
94
95
|
);
|
|
@@ -116,6 +117,55 @@ export async function deploySponsoredTestAccountsWithTokens(
|
|
|
116
117
|
};
|
|
117
118
|
}
|
|
118
119
|
|
|
120
|
+
async function deployAccountWithDiagnostics(
|
|
121
|
+
account: { getDeployMethod: () => Promise<{ send: (opts: any) => any }>; address: any },
|
|
122
|
+
paymentMethod: SponsoredFeePaymentMethod,
|
|
123
|
+
aztecNode: AztecNode,
|
|
124
|
+
logger: Logger,
|
|
125
|
+
accountLabel: string,
|
|
126
|
+
): Promise<void> {
|
|
127
|
+
const deployMethod = await account.getDeployMethod();
|
|
128
|
+
let txHash;
|
|
129
|
+
try {
|
|
130
|
+
txHash = await deployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod }, wait: NO_WAIT });
|
|
131
|
+
await waitForTx(aztecNode, txHash, { timeout: 2400 });
|
|
132
|
+
logger.info(`${accountLabel} deployed at ${account.address}`);
|
|
133
|
+
} catch (error) {
|
|
134
|
+
const blockNumber = await aztecNode.getBlockNumber();
|
|
135
|
+
let receipt;
|
|
136
|
+
try {
|
|
137
|
+
receipt = await aztecNode.getTxReceipt(txHash);
|
|
138
|
+
} catch {
|
|
139
|
+
receipt = 'unavailable';
|
|
140
|
+
}
|
|
141
|
+
logger.error(`${accountLabel} deployment failed`, {
|
|
142
|
+
txHash: txHash.toString(),
|
|
143
|
+
receipt: JSON.stringify(receipt),
|
|
144
|
+
currentBlockNumber: blockNumber,
|
|
145
|
+
error: String(error),
|
|
146
|
+
});
|
|
147
|
+
throw error;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
async function deployAccountsInBatches(
|
|
152
|
+
accounts: { getDeployMethod: () => Promise<{ send: (opts: any) => any }>; address: any }[],
|
|
153
|
+
paymentMethod: SponsoredFeePaymentMethod,
|
|
154
|
+
aztecNode: AztecNode,
|
|
155
|
+
logger: Logger,
|
|
156
|
+
labelPrefix: string,
|
|
157
|
+
batchSize = 2,
|
|
158
|
+
): Promise<void> {
|
|
159
|
+
for (let i = 0; i < accounts.length; i += batchSize) {
|
|
160
|
+
const batch = accounts.slice(i, i + batchSize);
|
|
161
|
+
await Promise.all(
|
|
162
|
+
batch.map((account, idx) =>
|
|
163
|
+
deployAccountWithDiagnostics(account, paymentMethod, aztecNode, logger, `${labelPrefix}${i + idx + 1}`),
|
|
164
|
+
),
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
119
169
|
export async function deploySponsoredTestAccounts(
|
|
120
170
|
wallet: TestWallet,
|
|
121
171
|
aztecNode: AztecNode,
|
|
@@ -129,15 +179,9 @@ export async function deploySponsoredTestAccounts(
|
|
|
129
179
|
await registerSponsoredFPC(wallet);
|
|
130
180
|
|
|
131
181
|
const paymentMethod = new SponsoredFeePaymentMethod(await getSponsoredFPCAddress());
|
|
132
|
-
|
|
133
|
-
await
|
|
134
|
-
await
|
|
135
|
-
fundedAccounts.map(async a => {
|
|
136
|
-
const deployMethod = await a.getDeployMethod();
|
|
137
|
-
await deployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod } }).wait({ timeout: 2400 }); // increase timeout on purpose in order to account for two empty epochs
|
|
138
|
-
logger.info(`Account deployed at ${a.address}`);
|
|
139
|
-
}),
|
|
140
|
-
);
|
|
182
|
+
|
|
183
|
+
await deployAccountWithDiagnostics(recipientAccount, paymentMethod, aztecNode, logger, 'Recipient account');
|
|
184
|
+
await deployAccountsInBatches(fundedAccounts, paymentMethod, aztecNode, logger, 'Funded account ', 2);
|
|
141
185
|
|
|
142
186
|
return {
|
|
143
187
|
aztecNode,
|
|
@@ -175,7 +219,7 @@ export async function deployTestAccountsWithTokens(
|
|
|
175
219
|
fundedAccounts.map(async (a, i) => {
|
|
176
220
|
const paymentMethod = new FeeJuicePaymentMethodWithClaim(a.address, claims[i]);
|
|
177
221
|
const deployMethod = await a.getDeployMethod();
|
|
178
|
-
await deployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod } })
|
|
222
|
+
await deployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod } });
|
|
179
223
|
logger.info(`Account deployed at ${a.address}`);
|
|
180
224
|
}),
|
|
181
225
|
);
|
|
@@ -251,14 +295,19 @@ async function deployTokenAndMint(
|
|
|
251
295
|
logger: Logger,
|
|
252
296
|
) {
|
|
253
297
|
logger.verbose(`Deploying TokenContract...`);
|
|
254
|
-
const tokenContract = await TokenContract.deploy(
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
298
|
+
const { contract: tokenContract } = await TokenContract.deploy(
|
|
299
|
+
wallet,
|
|
300
|
+
admin,
|
|
301
|
+
TOKEN_NAME,
|
|
302
|
+
TOKEN_SYMBOL,
|
|
303
|
+
TOKEN_DECIMALS,
|
|
304
|
+
).send({
|
|
305
|
+
from: admin,
|
|
306
|
+
fee: {
|
|
307
|
+
paymentMethod,
|
|
308
|
+
},
|
|
309
|
+
wait: { timeout: 600, returnReceipt: true },
|
|
310
|
+
});
|
|
262
311
|
|
|
263
312
|
const tokenAddress = tokenContract.address;
|
|
264
313
|
|
|
@@ -268,8 +317,7 @@ async function deployTokenAndMint(
|
|
|
268
317
|
accounts.map(acc =>
|
|
269
318
|
TokenContract.at(tokenAddress, wallet)
|
|
270
319
|
.methods.mint_to_public(acc, mintAmount)
|
|
271
|
-
.send({ from: admin, fee: { paymentMethod } })
|
|
272
|
-
.wait({ timeout: 600 }),
|
|
320
|
+
.send({ from: admin, fee: { paymentMethod }, wait: { timeout: 600 } }),
|
|
273
321
|
),
|
|
274
322
|
);
|
|
275
323
|
|
|
@@ -309,17 +357,23 @@ export async function performTransfers({
|
|
|
309
357
|
|
|
310
358
|
const provenTxs = await Promise.all(txs);
|
|
311
359
|
|
|
312
|
-
await Promise.all(provenTxs.map(t => t.send(
|
|
360
|
+
await Promise.all(provenTxs.map(t => t.send({ wait: { timeout: 600 } })));
|
|
313
361
|
|
|
314
362
|
logger.info(`Completed round ${i + 1} / ${rounds}`);
|
|
315
363
|
}
|
|
316
364
|
}
|
|
317
365
|
|
|
366
|
+
export type WalletWrapper = {
|
|
367
|
+
wallet: TestWallet;
|
|
368
|
+
aztecNode: AztecNode;
|
|
369
|
+
cleanup: () => Promise<void>;
|
|
370
|
+
};
|
|
371
|
+
|
|
318
372
|
export async function createWalletAndAztecNodeClient(
|
|
319
373
|
nodeUrl: string,
|
|
320
374
|
proverEnabled: boolean,
|
|
321
375
|
logger: Logger,
|
|
322
|
-
): Promise<
|
|
376
|
+
): Promise<WalletWrapper> {
|
|
323
377
|
const aztecNode = createAztecNodeClient(nodeUrl);
|
|
324
378
|
const [bbConfig, acvmConfig] = await Promise.all([getBBConfig(logger), getACVMConfig(logger)]);
|
|
325
379
|
const pxeConfig = {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
2
|
+
import type { Logger } from '@aztec/foundation/log';
|
|
2
3
|
import type { L2Block } from '@aztec/stdlib/block';
|
|
3
|
-
import
|
|
4
|
+
import type { TopicType } from '@aztec/stdlib/p2p';
|
|
5
|
+
import { Tx, type TxReceipt } from '@aztec/stdlib/tx';
|
|
4
6
|
|
|
5
7
|
import { createHistogram } from 'perf_hooks';
|
|
6
8
|
|
|
@@ -19,14 +21,31 @@ export type TxInclusionData = {
|
|
|
19
21
|
export class TxInclusionMetrics {
|
|
20
22
|
private data = new Map<string, TxInclusionData>();
|
|
21
23
|
private groups = new Set<string>();
|
|
22
|
-
private blocks = new Map<number, Promise<L2Block>>();
|
|
24
|
+
private blocks = new Map<number, Promise<L2Block | undefined>>();
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
private p2pGossipLatencyByTopic: Partial<Record<TopicType, { p50: number; p95: number }>> = {};
|
|
27
|
+
|
|
28
|
+
private attestationLatency: { p50: number; p95: number } | undefined;
|
|
29
|
+
private attestationCounts: { success: number; failedBad: number; failedNode: number } | undefined;
|
|
30
|
+
private reqRespStats: { fraction: number; delayP50: number; delayP95: number } | undefined;
|
|
31
|
+
private peerStats: { avgCount: number; connectionDurationP50: number; connectionDurationP95: number } | undefined;
|
|
32
|
+
private mempoolMinedDelay:
|
|
33
|
+
| { txP50: number; txP95: number; attestationP50: number; attestationP95: number }
|
|
34
|
+
| undefined;
|
|
35
|
+
|
|
36
|
+
constructor(
|
|
37
|
+
private aztecNode: AztecNode,
|
|
38
|
+
private logger?: Logger,
|
|
39
|
+
) {}
|
|
25
40
|
|
|
26
41
|
recordSentTx(tx: Tx, group: string): void {
|
|
27
42
|
const txHash = tx.getTxHash().toString();
|
|
28
43
|
const priorityFees = tx.getGasSettings().maxPriorityFeesPerGas;
|
|
29
44
|
|
|
45
|
+
if (this.data.has(txHash)) {
|
|
46
|
+
this.logger?.debug(`Overwriting tx inclusion data for ${txHash}`, { txHash, group });
|
|
47
|
+
}
|
|
48
|
+
|
|
30
49
|
this.data.set(txHash, {
|
|
31
50
|
txHash,
|
|
32
51
|
sentAt: Math.trunc(Date.now() / 1000),
|
|
@@ -42,17 +61,31 @@ export class TxInclusionMetrics {
|
|
|
42
61
|
}
|
|
43
62
|
|
|
44
63
|
async recordMinedTx(txReceipt: TxReceipt): Promise<void> {
|
|
45
|
-
const {
|
|
46
|
-
if (
|
|
64
|
+
const { txHash, blockNumber } = txReceipt;
|
|
65
|
+
if (!txReceipt.isMined() || !txReceipt.hasExecutionSucceeded() || !blockNumber) {
|
|
66
|
+
this.logger?.debug('Skipping mined tx record due to receipt status', {
|
|
67
|
+
txHash: txHash.toString(),
|
|
68
|
+
status: txReceipt.status,
|
|
69
|
+
blockNumber,
|
|
70
|
+
});
|
|
47
71
|
return;
|
|
48
72
|
}
|
|
49
73
|
|
|
50
74
|
if (!this.blocks.has(blockNumber)) {
|
|
51
|
-
this.blocks.set(blockNumber, this.aztecNode.getBlock(blockNumber)
|
|
75
|
+
this.blocks.set(blockNumber, this.aztecNode.getBlock(blockNumber));
|
|
52
76
|
}
|
|
53
77
|
|
|
54
78
|
const block = await this.blocks.get(blockNumber)!;
|
|
55
|
-
|
|
79
|
+
if (!block) {
|
|
80
|
+
this.logger?.warn('Failed to load block for mined tx receipt', { txHash: txHash.toString(), blockNumber });
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const data = this.data.get(txHash.toString());
|
|
84
|
+
if (!data) {
|
|
85
|
+
const message = `Missing sent tx record for mined tx ${txHash.toString()}`;
|
|
86
|
+
this.logger?.warn(message, { txHash: txHash.toString(), blockNumber });
|
|
87
|
+
throw new Error(message);
|
|
88
|
+
}
|
|
56
89
|
data.blocknumber = blockNumber;
|
|
57
90
|
data.minedAt = Number(block.header.globalVariables.timestamp);
|
|
58
91
|
data.attestedAt = -1;
|
|
@@ -71,7 +104,7 @@ export class TxInclusionMetrics {
|
|
|
71
104
|
} {
|
|
72
105
|
const histogram = createHistogram({});
|
|
73
106
|
for (const tx of this.data.values()) {
|
|
74
|
-
if (!tx.blocknumber || tx.group !== group) {
|
|
107
|
+
if (!tx.blocknumber || tx.group !== group || tx.minedAt === -1) {
|
|
75
108
|
continue;
|
|
76
109
|
}
|
|
77
110
|
|
|
@@ -101,6 +134,30 @@ export class TxInclusionMetrics {
|
|
|
101
134
|
};
|
|
102
135
|
}
|
|
103
136
|
|
|
137
|
+
public recordP2PGossipLatency(topicName: TopicType, p50: number, p95: number): void {
|
|
138
|
+
this.p2pGossipLatencyByTopic[topicName] = { p50, p95 };
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
public recordAttestationLatency(p50: number, p95: number): void {
|
|
142
|
+
this.attestationLatency = { p50, p95 };
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
public recordAttestationCounts(success: number, failedBad: number, failedNode: number): void {
|
|
146
|
+
this.attestationCounts = { success, failedBad, failedNode };
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
public recordReqRespStats(fraction: number, delayP50: number, delayP95: number): void {
|
|
150
|
+
this.reqRespStats = { fraction, delayP50, delayP95 };
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
public recordPeerStats(avgCount: number, connectionDurationP50: number, connectionDurationP95: number): void {
|
|
154
|
+
this.peerStats = { avgCount, connectionDurationP50, connectionDurationP95 };
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
public recordMempoolMinedDelay(txP50: number, txP95: number, attestationP50: number, attestationP95: number): void {
|
|
158
|
+
this.mempoolMinedDelay = { txP50, txP95, attestationP50, attestationP95 };
|
|
159
|
+
}
|
|
160
|
+
|
|
104
161
|
toGithubActionBenchmarkJSON(): Array<{ name: string; unit: string; value: number; range?: number; extra?: string }> {
|
|
105
162
|
const data: Array<{ name: string; unit: string; value: number; range?: number; extra?: string }> = [];
|
|
106
163
|
for (const group of this.groups) {
|
|
@@ -125,6 +182,69 @@ export class TxInclusionMetrics {
|
|
|
125
182
|
);
|
|
126
183
|
}
|
|
127
184
|
|
|
128
|
-
|
|
185
|
+
for (const [topic, { p50, p95 }] of Object.entries(this.p2pGossipLatencyByTopic)) {
|
|
186
|
+
data.push({
|
|
187
|
+
name: `p2p_gossip_latency/${topic}/p50`,
|
|
188
|
+
unit: 'ms',
|
|
189
|
+
value: p50,
|
|
190
|
+
});
|
|
191
|
+
data.push({
|
|
192
|
+
name: `p2p_gossip_latency/${topic}/p95`,
|
|
193
|
+
unit: 'ms',
|
|
194
|
+
value: p95,
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (this.attestationLatency) {
|
|
199
|
+
data.push(
|
|
200
|
+
{ name: 'attestation_latency/p50', unit: 'ms', value: this.attestationLatency.p50 },
|
|
201
|
+
{ name: 'attestation_latency/p95', unit: 'ms', value: this.attestationLatency.p95 },
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (this.attestationCounts) {
|
|
206
|
+
const { success, failedBad, failedNode } = this.attestationCounts;
|
|
207
|
+
const total = success + failedBad + failedNode;
|
|
208
|
+
const ratio = total > 0 ? success / total : 0;
|
|
209
|
+
data.push(
|
|
210
|
+
{ name: 'attestation/success_count', unit: 'count', value: success },
|
|
211
|
+
{ name: 'attestation/failed_bad_proposal_count', unit: 'count', value: failedBad },
|
|
212
|
+
{ name: 'attestation/failed_node_issue_count', unit: 'count', value: failedNode },
|
|
213
|
+
{ name: 'attestation/success_ratio', unit: 'ratio', value: ratio },
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (this.reqRespStats) {
|
|
218
|
+
data.push(
|
|
219
|
+
{ name: 'req_resp/txs_requested_fraction', unit: 'ratio', value: this.reqRespStats.fraction },
|
|
220
|
+
{ name: 'req_resp/delay_p50', unit: 'ms', value: this.reqRespStats.delayP50 },
|
|
221
|
+
{ name: 'req_resp/delay_p95', unit: 'ms', value: this.reqRespStats.delayP95 },
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (this.peerStats) {
|
|
226
|
+
data.push(
|
|
227
|
+
{ name: 'peers/avg_count', unit: 'peers', value: this.peerStats.avgCount },
|
|
228
|
+
{ name: 'peers/connection_duration_p50', unit: 'ms', value: this.peerStats.connectionDurationP50 },
|
|
229
|
+
{ name: 'peers/connection_duration_p95', unit: 'ms', value: this.peerStats.connectionDurationP95 },
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (this.mempoolMinedDelay) {
|
|
234
|
+
data.push(
|
|
235
|
+
{ name: 'mempool/tx_mined_delay_p50', unit: 'ms', value: this.mempoolMinedDelay.txP50 },
|
|
236
|
+
{ name: 'mempool/tx_mined_delay_p95', unit: 'ms', value: this.mempoolMinedDelay.txP95 },
|
|
237
|
+
{ name: 'mempool/attestation_mined_delay_p50', unit: 'ms', value: this.mempoolMinedDelay.attestationP50 },
|
|
238
|
+
{ name: 'mempool/attestation_mined_delay_p95', unit: 'ms', value: this.mempoolMinedDelay.attestationP95 },
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const scenario = process.env.BENCH_SCENARIO?.trim();
|
|
243
|
+
if (!scenario) {
|
|
244
|
+
return data;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const scenarioPrefix = `scenario/${scenario}/`;
|
|
248
|
+
return data.map(entry => ({ ...entry, name: `${scenarioPrefix}${entry.name}` }));
|
|
129
249
|
}
|
|
130
250
|
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import type { Logger } from '@aztec/foundation/log';
|
|
2
|
+
import { sleep } from '@aztec/foundation/sleep';
|
|
3
|
+
|
|
4
|
+
import { exec } from 'child_process';
|
|
5
|
+
import { promisify } from 'util';
|
|
6
|
+
|
|
7
|
+
import { execHelmCommand, forceDeleteHelmReleaseRecord, getHelmReleaseStatus, hasDeployedHelmRelease } from './helm.js';
|
|
8
|
+
import { deleteResourceByLabel, getChartDir, waitForResourceByLabel } from './k8s.js';
|
|
9
|
+
|
|
10
|
+
const execAsync = promisify(exec);
|
|
11
|
+
|
|
12
|
+
export async function restartBot(namespace: string, log: Logger) {
|
|
13
|
+
log.info(`Restarting bot`);
|
|
14
|
+
await deleteResourceByLabel({ resource: 'pods', namespace, label: 'app.kubernetes.io/name=bot' });
|
|
15
|
+
await sleep(10 * 1000);
|
|
16
|
+
// Some bot images may take time to report Ready due to heavy boot-time proving.
|
|
17
|
+
// Waiting for PodReadyToStartContainers ensures the pod is scheduled and starting without blocking on full readiness.
|
|
18
|
+
await waitForResourceByLabel({
|
|
19
|
+
resource: 'pods',
|
|
20
|
+
namespace,
|
|
21
|
+
label: 'app.kubernetes.io/name=bot',
|
|
22
|
+
condition: 'PodReadyToStartContainers',
|
|
23
|
+
});
|
|
24
|
+
log.info(`Bot restarted`);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Installs or upgrades the transfer bot Helm release for the given namespace.
|
|
29
|
+
* Intended for test setup to enable L2 traffic generation only when needed.
|
|
30
|
+
*/
|
|
31
|
+
export async function installTransferBot({
|
|
32
|
+
namespace,
|
|
33
|
+
spartanDir,
|
|
34
|
+
logger: log,
|
|
35
|
+
replicas = 1,
|
|
36
|
+
txIntervalSeconds = 10,
|
|
37
|
+
followChain = 'PENDING',
|
|
38
|
+
mnemonic = process.env.LABS_INFRA_MNEMONIC ?? 'test test test test test test test test test test test junk',
|
|
39
|
+
mnemonicStartIndex,
|
|
40
|
+
botPrivateKey = process.env.BOT_TRANSFERS_L2_PRIVATE_KEY ?? '0xcafe01',
|
|
41
|
+
nodeUrl,
|
|
42
|
+
timeout = '15m',
|
|
43
|
+
reuseValues = true,
|
|
44
|
+
aztecSlotDuration = Number(process.env.AZTEC_SLOT_DURATION ?? 12),
|
|
45
|
+
}: {
|
|
46
|
+
namespace: string;
|
|
47
|
+
spartanDir: string;
|
|
48
|
+
logger: Logger;
|
|
49
|
+
replicas?: number;
|
|
50
|
+
txIntervalSeconds?: number;
|
|
51
|
+
followChain?: string;
|
|
52
|
+
mnemonic?: string;
|
|
53
|
+
mnemonicStartIndex?: number | string;
|
|
54
|
+
botPrivateKey?: string;
|
|
55
|
+
nodeUrl?: string;
|
|
56
|
+
timeout?: string;
|
|
57
|
+
reuseValues?: boolean;
|
|
58
|
+
aztecSlotDuration?: number;
|
|
59
|
+
}) {
|
|
60
|
+
const instanceName = `${namespace}-bot-transfers`;
|
|
61
|
+
const helmChartDir = getChartDir(spartanDir, 'aztec-bot');
|
|
62
|
+
const resolvedNodeUrl = nodeUrl ?? `http://${namespace}-rpc-aztec-node.${namespace}.svc.cluster.local:8080`;
|
|
63
|
+
|
|
64
|
+
log.info(`Installing/upgrading transfer bot: replicas=${replicas}, followChain=${followChain}`);
|
|
65
|
+
|
|
66
|
+
const values: Record<string, string | number | boolean> = {
|
|
67
|
+
'bot.replicaCount': replicas,
|
|
68
|
+
'bot.txIntervalSeconds': txIntervalSeconds,
|
|
69
|
+
'bot.followChain': followChain,
|
|
70
|
+
'bot.botPrivateKey': botPrivateKey,
|
|
71
|
+
'bot.nodeUrl': resolvedNodeUrl,
|
|
72
|
+
'bot.mnemonic': mnemonic,
|
|
73
|
+
'bot.feePaymentMethod': 'fee_juice',
|
|
74
|
+
'aztec.slotDuration': aztecSlotDuration,
|
|
75
|
+
// Ensure bot can reach its own PXE started in-process (default rpc.port is 8080)
|
|
76
|
+
// Note: since aztec-bot depends on aztec-node with alias `bot`, env vars go under `bot.node.env`.
|
|
77
|
+
'bot.node.env.BOT_PXE_URL': 'http://127.0.0.1:8080',
|
|
78
|
+
// Provide L1 execution RPC for bridging fee juice
|
|
79
|
+
'bot.node.env.ETHEREUM_HOSTS': `http://${namespace}-eth-execution.${namespace}.svc.cluster.local:8545`,
|
|
80
|
+
// Provide L1 mnemonic for bridging (falls back to labs mnemonic)
|
|
81
|
+
'bot.node.env.BOT_L1_MNEMONIC': mnemonic,
|
|
82
|
+
|
|
83
|
+
// The bot does not need Kubernetes API access. Disable RBAC + ServiceAccount creation so the chart
|
|
84
|
+
// can be installed by users without cluster-scoped RBAC permissions.
|
|
85
|
+
'bot.rbac.create': false,
|
|
86
|
+
'bot.serviceAccount.create': false,
|
|
87
|
+
'bot.serviceAccount.name': 'default',
|
|
88
|
+
};
|
|
89
|
+
// Ensure we derive a funded L1 key (index 0 is funded on anvil default mnemonic)
|
|
90
|
+
if (mnemonicStartIndex === undefined) {
|
|
91
|
+
values['bot.mnemonicStartIndex'] = 0;
|
|
92
|
+
}
|
|
93
|
+
// Also pass a funded private key directly if available
|
|
94
|
+
if (process.env.FUNDING_PRIVATE_KEY) {
|
|
95
|
+
values['bot.node.env.BOT_L1_PRIVATE_KEY'] = process.env.FUNDING_PRIVATE_KEY;
|
|
96
|
+
}
|
|
97
|
+
// Align bot image with the running network image: prefer env var, else detect from a validator pod
|
|
98
|
+
let repositoryFromEnv: string | undefined;
|
|
99
|
+
let tagFromEnv: string | undefined;
|
|
100
|
+
const aztecDockerImage = process.env.AZTEC_DOCKER_IMAGE;
|
|
101
|
+
if (aztecDockerImage && aztecDockerImage.includes(':')) {
|
|
102
|
+
const lastColon = aztecDockerImage.lastIndexOf(':');
|
|
103
|
+
repositoryFromEnv = aztecDockerImage.slice(0, lastColon);
|
|
104
|
+
tagFromEnv = aztecDockerImage.slice(lastColon + 1);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
let repository = repositoryFromEnv;
|
|
108
|
+
let tag = tagFromEnv;
|
|
109
|
+
if (!repository || !tag) {
|
|
110
|
+
try {
|
|
111
|
+
const { stdout } = await execAsync(
|
|
112
|
+
`kubectl get pods -l app.kubernetes.io/name=validator -n ${namespace} -o jsonpath='{.items[0].spec.containers[?(@.name=="aztec")].image}' | cat`,
|
|
113
|
+
);
|
|
114
|
+
const image = stdout.trim().replace(/^'|'$/g, '');
|
|
115
|
+
if (image && image.includes(':')) {
|
|
116
|
+
const lastColon = image.lastIndexOf(':');
|
|
117
|
+
repository = image.slice(0, lastColon);
|
|
118
|
+
tag = image.slice(lastColon + 1);
|
|
119
|
+
}
|
|
120
|
+
} catch (err) {
|
|
121
|
+
log.warn(`Could not detect aztec image from validator pod: ${String(err)}`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (repository && tag) {
|
|
125
|
+
values['global.aztecImage.repository'] = repository;
|
|
126
|
+
values['global.aztecImage.tag'] = tag;
|
|
127
|
+
}
|
|
128
|
+
if (mnemonicStartIndex !== undefined) {
|
|
129
|
+
values['bot.mnemonicStartIndex'] =
|
|
130
|
+
typeof mnemonicStartIndex === 'string' ? mnemonicStartIndex : Number(mnemonicStartIndex);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// If a previous install attempt left the release in a non-deployed state (e.g. FAILED),
|
|
134
|
+
// `helm upgrade --install` can error with "has no deployed releases".
|
|
135
|
+
// In that case, clear the release record and do a clean install.
|
|
136
|
+
const existingStatus = await getHelmReleaseStatus(instanceName, namespace);
|
|
137
|
+
if (existingStatus && existingStatus.toLowerCase() !== 'deployed') {
|
|
138
|
+
log.warn(`Transfer bot release ${instanceName} is in status '${existingStatus}'. Reinstalling cleanly.`);
|
|
139
|
+
await execAsync(`helm uninstall ${instanceName} --namespace ${namespace} --wait --ignore-not-found`).catch(
|
|
140
|
+
() => undefined,
|
|
141
|
+
);
|
|
142
|
+
// If helm left the release in `uninstalling`, force-delete the record so we can reinstall.
|
|
143
|
+
const afterUninstallStatus = await getHelmReleaseStatus(instanceName, namespace);
|
|
144
|
+
if (afterUninstallStatus?.toLowerCase() === 'uninstalling') {
|
|
145
|
+
await forceDeleteHelmReleaseRecord(instanceName, namespace, log);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// `--reuse-values` fails if the release has never successfully deployed (e.g. first install, or a previous failed install).
|
|
150
|
+
// Only reuse values when we have a deployed release to reuse from.
|
|
151
|
+
const effectiveReuseValues = reuseValues && (await hasDeployedHelmRelease(instanceName, namespace));
|
|
152
|
+
|
|
153
|
+
await execHelmCommand({
|
|
154
|
+
instanceName,
|
|
155
|
+
helmChartDir,
|
|
156
|
+
namespace,
|
|
157
|
+
valuesFile: undefined,
|
|
158
|
+
timeout,
|
|
159
|
+
values: values as unknown as Record<string, string | number | boolean>,
|
|
160
|
+
reuseValues: effectiveReuseValues,
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
if (replicas > 0) {
|
|
164
|
+
await waitForResourceByLabel({
|
|
165
|
+
resource: 'pods',
|
|
166
|
+
namespace,
|
|
167
|
+
label: 'app.kubernetes.io/name=bot',
|
|
168
|
+
condition: 'PodReadyToStartContainers',
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Uninstalls the transfer bot Helm release from the given namespace.
|
|
175
|
+
* Intended for test teardown to clean up bot resources.
|
|
176
|
+
*/
|
|
177
|
+
export async function uninstallTransferBot(namespace: string, log: Logger) {
|
|
178
|
+
const instanceName = `${namespace}-bot-transfers`;
|
|
179
|
+
log.info(`Uninstalling transfer bot release ${instanceName}`);
|
|
180
|
+
await execAsync(`helm uninstall ${instanceName} --namespace ${namespace} --wait --ignore-not-found`);
|
|
181
|
+
// Ensure any leftover pods are removed
|
|
182
|
+
await deleteResourceByLabel({ resource: 'pods', namespace, label: 'app.kubernetes.io/name=bot' }).catch(
|
|
183
|
+
() => undefined,
|
|
184
|
+
);
|
|
185
|
+
}
|