@aztec/end-to-end 0.0.1-commit.d431d1c → 0.0.1-commit.e2b2873ed
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 +2 -2
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +31 -16
- package/dest/bench/client_flows/config.d.ts +2 -2
- package/dest/bench/client_flows/config.d.ts.map +1 -1
- package/dest/bench/client_flows/config.js +18 -0
- package/dest/bench/utils.d.ts +5 -4
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +9 -7
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +4 -2
- 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 +17 -8
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +2 -2
- 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 +3 -2
- package/dest/e2e_deploy_contract/deploy_test.d.ts +2 -2
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.d.ts +7 -1
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +38 -10
- package/dest/e2e_fees/bridging_race.notest.js +1 -1
- package/dest/e2e_fees/fees_test.d.ts +2 -2
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +11 -11
- package/dest/e2e_l1_publisher/write_json.d.ts +4 -3
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
- package/dest/e2e_l1_publisher/write_json.js +1 -7
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +2 -2
- package/dest/e2e_p2p/p2p_network.d.ts +2 -2
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +6 -2
- package/dest/e2e_p2p/reqresp/utils.d.ts +22 -0
- package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -0
- package/dest/e2e_p2p/reqresp/utils.js +153 -0
- 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 +14 -17
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts +2 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts.map +1 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.js +184 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts +18 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts.map +1 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.js +120 -0
- package/dest/e2e_token_contract/token_contract_test.d.ts +4 -2
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +13 -3
- package/dest/fixtures/e2e_prover_test.d.ts +2 -2
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +8 -5
- package/dest/fixtures/ha_setup.d.ts +71 -0
- package/dest/fixtures/ha_setup.d.ts.map +1 -0
- package/dest/fixtures/ha_setup.js +114 -0
- package/dest/fixtures/index.d.ts +2 -1
- package/dest/fixtures/index.d.ts.map +1 -1
- package/dest/fixtures/index.js +1 -0
- package/dest/fixtures/setup.d.ts +19 -17
- package/dest/fixtures/setup.d.ts.map +1 -1
- package/dest/fixtures/setup.js +42 -95
- package/dest/fixtures/setup_p2p_test.d.ts +12 -8
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +29 -21
- 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/shared/cross_chain_test_harness.d.ts +3 -4
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +11 -11
- package/dest/shared/gas_portal_test_harness.js +1 -1
- package/dest/shared/submit-transactions.d.ts +4 -4
- 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 +1 -1
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +20 -18
- package/dest/simulators/lending_simulator.js +2 -2
- package/dest/simulators/token_simulator.d.ts +1 -1
- package/dest/simulators/token_simulator.d.ts.map +1 -1
- package/dest/simulators/token_simulator.js +2 -23
- package/dest/spartan/setup_test_wallets.d.ts +2 -2
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +64 -35
- package/dest/spartan/tx_metrics.d.ts +38 -2
- package/dest/spartan/tx_metrics.d.ts.map +1 -1
- package/dest/spartan/tx_metrics.js +178 -4
- 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 +39 -0
- package/dest/spartan/utils/config.d.ts.map +1 -0
- package/dest/spartan/utils/config.js +21 -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 +126 -0
- package/dest/spartan/utils/k8s.d.ts.map +1 -0
- package/dest/spartan/utils/k8s.js +375 -0
- package/dest/spartan/utils/nodes.d.ts +41 -0
- package/dest/spartan/utils/nodes.d.ts.map +1 -0
- package/dest/spartan/utils/nodes.js +461 -0
- package/dest/spartan/utils/scripts.d.ts +30 -0
- package/dest/spartan/utils/scripts.d.ts.map +1 -0
- package/dest/spartan/utils/scripts.js +81 -0
- package/dest/spartan/utils.d.ts +2 -260
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +1 -942
- package/dest/test-wallet/test_wallet.d.ts +82 -0
- package/dest/test-wallet/test_wallet.d.ts.map +1 -0
- package/dest/test-wallet/test_wallet.js +214 -0
- package/dest/test-wallet/utils.d.ts +41 -0
- package/dest/test-wallet/utils.d.ts.map +1 -0
- package/dest/test-wallet/utils.js +71 -0
- package/package.json +43 -39
- package/src/bench/client_flows/client_flows_benchmark.ts +19 -36
- package/src/bench/client_flows/config.ts +9 -1
- package/src/bench/utils.ts +10 -8
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +20 -14
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +7 -8
- package/src/e2e_deploy_contract/deploy_test.ts +3 -3
- package/src/e2e_epochs/epochs_test.ts +71 -35
- package/src/e2e_fees/bridging_race.notest.ts +2 -5
- package/src/e2e_fees/fees_test.ts +21 -40
- package/src/e2e_l1_publisher/write_json.ts +3 -8
- package/src/e2e_nested_contract/nested_contract_test.ts +3 -5
- package/src/e2e_p2p/inactivity_slash_test.ts +4 -4
- package/src/e2e_p2p/p2p_network.ts +20 -14
- package/src/e2e_p2p/reqresp/utils.ts +207 -0
- package/src/e2e_p2p/shared.ts +22 -22
- package/src/e2e_storage_proof/fixtures/storage_proof.json +915 -0
- package/src/e2e_storage_proof/fixtures/storage_proof_fetcher.ts +190 -0
- package/src/e2e_storage_proof/fixtures/storage_proof_fixture.ts +173 -0
- package/src/e2e_token_contract/token_contract_test.ts +14 -7
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/fixtures/e2e_prover_test.ts +8 -13
- package/src/fixtures/ha_setup.ts +184 -0
- package/src/fixtures/index.ts +1 -0
- package/src/fixtures/setup.ts +50 -128
- package/src/fixtures/setup_p2p_test.ts +31 -27
- package/src/fixtures/token_utils.ts +6 -5
- package/src/guides/up_quick_start.sh +3 -3
- package/src/shared/cross_chain_test_harness.ts +13 -27
- package/src/shared/gas_portal_test_harness.ts +1 -1
- package/src/shared/submit-transactions.ts +11 -16
- package/src/shared/uniswap_l1_l2.ts +21 -30
- package/src/simulators/lending_simulator.ts +2 -2
- package/src/simulators/token_simulator.ts +1 -29
- package/src/spartan/setup_test_wallets.ts +75 -25
- package/src/spartan/tx_metrics.ts +152 -7
- 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 +27 -0
- package/src/spartan/utils/health.ts +255 -0
- package/src/spartan/utils/helm.ts +84 -0
- package/src/spartan/utils/index.ts +64 -0
- package/src/spartan/utils/k8s.ts +527 -0
- package/src/spartan/utils/nodes.ts +538 -0
- package/src/spartan/utils/scripts.ts +99 -0
- package/src/spartan/utils.ts +1 -1246
- package/src/test-wallet/test_wallet.ts +305 -0
- package/src/test-wallet/utils.ts +112 -0
|
@@ -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';
|
|
@@ -12,11 +13,13 @@ import type { Logger } from '@aztec/foundation/log';
|
|
|
12
13
|
import { retryUntil } from '@aztec/foundation/retry';
|
|
13
14
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
14
15
|
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
15
|
-
import {
|
|
16
|
+
import { registerInitialLocalNetworkAccountsInWallet } from '@aztec/wallets/testing';
|
|
16
17
|
|
|
17
18
|
import { getACVMConfig } from '../fixtures/get_acvm_config.js';
|
|
18
19
|
import { getBBConfig } from '../fixtures/get_bb_config.js';
|
|
19
20
|
import { getSponsoredFPCAddress, registerSponsoredFPC } from '../fixtures/utils.js';
|
|
21
|
+
import { TestWallet } from '../test-wallet/test_wallet.js';
|
|
22
|
+
import { proveInteraction } from '../test-wallet/utils.js';
|
|
20
23
|
|
|
21
24
|
export interface TestAccounts {
|
|
22
25
|
aztecNode: AztecNode;
|
|
@@ -84,11 +87,11 @@ export async function deploySponsoredTestAccountsWithTokens(
|
|
|
84
87
|
|
|
85
88
|
const paymentMethod = new SponsoredFeePaymentMethod(await getSponsoredFPCAddress());
|
|
86
89
|
const recipientDeployMethod = await recipientAccount.getDeployMethod();
|
|
87
|
-
await recipientDeployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod }
|
|
90
|
+
await recipientDeployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod }, wait: { timeout: 2400 } });
|
|
88
91
|
await Promise.all(
|
|
89
92
|
fundedAccounts.map(async a => {
|
|
90
93
|
const deployMethod = await a.getDeployMethod();
|
|
91
|
-
await deployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod }
|
|
94
|
+
await deployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod }, wait: { timeout: 2400 } }); // increase timeout on purpose in order to account for two empty epochs
|
|
92
95
|
logger.info(`Account deployed at ${a.address}`);
|
|
93
96
|
}),
|
|
94
97
|
);
|
|
@@ -116,6 +119,55 @@ export async function deploySponsoredTestAccountsWithTokens(
|
|
|
116
119
|
};
|
|
117
120
|
}
|
|
118
121
|
|
|
122
|
+
async function deployAccountWithDiagnostics(
|
|
123
|
+
account: { getDeployMethod: () => Promise<{ send: (opts: any) => any }>; address: any },
|
|
124
|
+
paymentMethod: SponsoredFeePaymentMethod,
|
|
125
|
+
aztecNode: AztecNode,
|
|
126
|
+
logger: Logger,
|
|
127
|
+
accountLabel: string,
|
|
128
|
+
): Promise<void> {
|
|
129
|
+
const deployMethod = await account.getDeployMethod();
|
|
130
|
+
let txHash;
|
|
131
|
+
try {
|
|
132
|
+
txHash = await deployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod }, wait: NO_WAIT });
|
|
133
|
+
await waitForTx(aztecNode, txHash, { timeout: 2400 });
|
|
134
|
+
logger.info(`${accountLabel} deployed at ${account.address}`);
|
|
135
|
+
} catch (error) {
|
|
136
|
+
const blockNumber = await aztecNode.getBlockNumber();
|
|
137
|
+
let receipt;
|
|
138
|
+
try {
|
|
139
|
+
receipt = await aztecNode.getTxReceipt(txHash);
|
|
140
|
+
} catch {
|
|
141
|
+
receipt = 'unavailable';
|
|
142
|
+
}
|
|
143
|
+
logger.error(`${accountLabel} deployment failed`, {
|
|
144
|
+
txHash: txHash.toString(),
|
|
145
|
+
receipt: JSON.stringify(receipt),
|
|
146
|
+
currentBlockNumber: blockNumber,
|
|
147
|
+
error: String(error),
|
|
148
|
+
});
|
|
149
|
+
throw error;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
async function deployAccountsInBatches(
|
|
154
|
+
accounts: { getDeployMethod: () => Promise<{ send: (opts: any) => any }>; address: any }[],
|
|
155
|
+
paymentMethod: SponsoredFeePaymentMethod,
|
|
156
|
+
aztecNode: AztecNode,
|
|
157
|
+
logger: Logger,
|
|
158
|
+
labelPrefix: string,
|
|
159
|
+
batchSize = 2,
|
|
160
|
+
): Promise<void> {
|
|
161
|
+
for (let i = 0; i < accounts.length; i += batchSize) {
|
|
162
|
+
const batch = accounts.slice(i, i + batchSize);
|
|
163
|
+
await Promise.all(
|
|
164
|
+
batch.map((account, idx) =>
|
|
165
|
+
deployAccountWithDiagnostics(account, paymentMethod, aztecNode, logger, `${labelPrefix}${i + idx + 1}`),
|
|
166
|
+
),
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
119
171
|
export async function deploySponsoredTestAccounts(
|
|
120
172
|
wallet: TestWallet,
|
|
121
173
|
aztecNode: AztecNode,
|
|
@@ -129,15 +181,9 @@ export async function deploySponsoredTestAccounts(
|
|
|
129
181
|
await registerSponsoredFPC(wallet);
|
|
130
182
|
|
|
131
183
|
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
|
-
);
|
|
184
|
+
|
|
185
|
+
await deployAccountWithDiagnostics(recipientAccount, paymentMethod, aztecNode, logger, 'Recipient account');
|
|
186
|
+
await deployAccountsInBatches(fundedAccounts, paymentMethod, aztecNode, logger, 'Funded account ', 2);
|
|
141
187
|
|
|
142
188
|
return {
|
|
143
189
|
aztecNode,
|
|
@@ -175,7 +221,7 @@ export async function deployTestAccountsWithTokens(
|
|
|
175
221
|
fundedAccounts.map(async (a, i) => {
|
|
176
222
|
const paymentMethod = new FeeJuicePaymentMethodWithClaim(a.address, claims[i]);
|
|
177
223
|
const deployMethod = await a.getDeployMethod();
|
|
178
|
-
await deployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod } })
|
|
224
|
+
await deployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod } });
|
|
179
225
|
logger.info(`Account deployed at ${a.address}`);
|
|
180
226
|
}),
|
|
181
227
|
);
|
|
@@ -251,14 +297,19 @@ async function deployTokenAndMint(
|
|
|
251
297
|
logger: Logger,
|
|
252
298
|
) {
|
|
253
299
|
logger.verbose(`Deploying TokenContract...`);
|
|
254
|
-
const tokenContract = await TokenContract.deploy(
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
300
|
+
const { contract: tokenContract } = await TokenContract.deploy(
|
|
301
|
+
wallet,
|
|
302
|
+
admin,
|
|
303
|
+
TOKEN_NAME,
|
|
304
|
+
TOKEN_SYMBOL,
|
|
305
|
+
TOKEN_DECIMALS,
|
|
306
|
+
).send({
|
|
307
|
+
from: admin,
|
|
308
|
+
fee: {
|
|
309
|
+
paymentMethod,
|
|
310
|
+
},
|
|
311
|
+
wait: { timeout: 600, returnReceipt: true },
|
|
312
|
+
});
|
|
262
313
|
|
|
263
314
|
const tokenAddress = tokenContract.address;
|
|
264
315
|
|
|
@@ -268,8 +319,7 @@ async function deployTokenAndMint(
|
|
|
268
319
|
accounts.map(acc =>
|
|
269
320
|
TokenContract.at(tokenAddress, wallet)
|
|
270
321
|
.methods.mint_to_public(acc, mintAmount)
|
|
271
|
-
.send({ from: admin, fee: { paymentMethod } })
|
|
272
|
-
.wait({ timeout: 600 }),
|
|
322
|
+
.send({ from: admin, fee: { paymentMethod }, wait: { timeout: 600 } }),
|
|
273
323
|
),
|
|
274
324
|
);
|
|
275
325
|
|
|
@@ -309,7 +359,7 @@ export async function performTransfers({
|
|
|
309
359
|
|
|
310
360
|
const provenTxs = await Promise.all(txs);
|
|
311
361
|
|
|
312
|
-
await Promise.all(provenTxs.map(t => t.send(
|
|
362
|
+
await Promise.all(provenTxs.map(t => t.send({ wait: { timeout: 600 } })));
|
|
313
363
|
|
|
314
364
|
logger.info(`Completed round ${i + 1} / ${rounds}`);
|
|
315
365
|
}
|
|
@@ -1,10 +1,137 @@
|
|
|
1
1
|
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Logger } from '@aztec/foundation/log';
|
|
3
|
+
import type { L2Block } from '@aztec/stdlib/block';
|
|
3
4
|
import type { TopicType } from '@aztec/stdlib/p2p';
|
|
4
|
-
import { Tx, type TxReceipt
|
|
5
|
+
import { Tx, type TxReceipt } from '@aztec/stdlib/tx';
|
|
5
6
|
|
|
6
7
|
import { createHistogram } from 'perf_hooks';
|
|
7
8
|
|
|
9
|
+
/** Metrics class for proving-related benchmarks. */
|
|
10
|
+
export class ProvingMetrics {
|
|
11
|
+
private successfulTxs: number | undefined;
|
|
12
|
+
private proofDuration: number | undefined;
|
|
13
|
+
private activeAgents: number | undefined;
|
|
14
|
+
private avgQueueTime: number | undefined;
|
|
15
|
+
private jobRetries: number | undefined;
|
|
16
|
+
private jobDuration: number | undefined;
|
|
17
|
+
private timedOutJobs: number | undefined;
|
|
18
|
+
private resolvedJobs: number | undefined;
|
|
19
|
+
private rejectedJobs: number | undefined;
|
|
20
|
+
private epochProvingDuration: number | undefined;
|
|
21
|
+
private provenTransactions: number | undefined;
|
|
22
|
+
private provenBlocks: number | undefined;
|
|
23
|
+
|
|
24
|
+
constructor(private prefix: string) {}
|
|
25
|
+
|
|
26
|
+
recordSuccessfulTxs(count: number): void {
|
|
27
|
+
this.successfulTxs = count;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
recordProofDuration(seconds: number): void {
|
|
31
|
+
this.proofDuration = seconds;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
recordActiveAgents(count: number): void {
|
|
35
|
+
this.activeAgents = count;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
recordAvgQueueTime(ms: number): void {
|
|
39
|
+
this.avgQueueTime = ms;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
recordJobRetries(count: number): void {
|
|
43
|
+
this.jobRetries = count;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
recordJobDuration(ms: number): void {
|
|
47
|
+
this.jobDuration = ms;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
recordTimedOutJobs(count: number): void {
|
|
51
|
+
this.timedOutJobs = count;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
recordResolvedJobs(count: number): void {
|
|
55
|
+
this.resolvedJobs = count;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
recordRejectedJobs(count: number): void {
|
|
59
|
+
this.rejectedJobs = count;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
recordEpochProvingDuration(seconds: number): void {
|
|
63
|
+
this.epochProvingDuration = seconds;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
recordProvenTransactions(count: number): void {
|
|
67
|
+
this.provenTransactions = count;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
recordProvenBlocks(count: number): void {
|
|
71
|
+
this.provenBlocks = count;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
toGithubActionBenchmarkJSON(): Array<{ name: string; unit: string; value: number }> {
|
|
75
|
+
const data: Array<{ name: string; unit: string; value: number }> = [];
|
|
76
|
+
|
|
77
|
+
if (this.successfulTxs !== undefined) {
|
|
78
|
+
data.push({ name: `${this.prefix}/successful_txs`, unit: 'count', value: this.successfulTxs });
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (this.proofDuration !== undefined) {
|
|
82
|
+
data.push({ name: `${this.prefix}/proof_duration`, unit: 's', value: this.proofDuration });
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (this.activeAgents !== undefined) {
|
|
86
|
+
data.push({ name: `${this.prefix}/active_agents`, unit: 'count', value: this.activeAgents });
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (this.avgQueueTime !== undefined) {
|
|
90
|
+
data.push({ name: `${this.prefix}/avg_queue_time`, unit: 'ms', value: this.avgQueueTime });
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (this.jobRetries !== undefined) {
|
|
94
|
+
data.push({ name: `${this.prefix}/job_retries`, unit: 'count', value: this.jobRetries });
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (this.jobDuration !== undefined) {
|
|
98
|
+
data.push({ name: `${this.prefix}/job_duration`, unit: 'ms', value: this.jobDuration });
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (this.timedOutJobs !== undefined) {
|
|
102
|
+
data.push({ name: `${this.prefix}/timed_out_jobs`, unit: 'count', value: this.timedOutJobs });
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (this.resolvedJobs !== undefined) {
|
|
106
|
+
data.push({ name: `${this.prefix}/resolved_jobs`, unit: 'count', value: this.resolvedJobs });
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (this.rejectedJobs !== undefined) {
|
|
110
|
+
data.push({ name: `${this.prefix}/rejected_jobs`, unit: 'count', value: this.rejectedJobs });
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (this.epochProvingDuration !== undefined) {
|
|
114
|
+
data.push({ name: `${this.prefix}/epoch_proving_duration`, unit: 's', value: this.epochProvingDuration });
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (this.provenTransactions !== undefined) {
|
|
118
|
+
data.push({ name: `${this.prefix}/proven_transactions`, unit: 'count', value: this.provenTransactions });
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (this.provenBlocks !== undefined) {
|
|
122
|
+
data.push({ name: `${this.prefix}/proven_blocks`, unit: 'count', value: this.provenBlocks });
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const scenario = process.env.BENCH_SCENARIO?.trim();
|
|
126
|
+
if (!scenario) {
|
|
127
|
+
return data;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const scenarioPrefix = `scenario/${scenario}/`;
|
|
131
|
+
return data.map(entry => ({ ...entry, name: `${scenarioPrefix}${entry.name}` }));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
8
135
|
export type TxInclusionData = {
|
|
9
136
|
txHash: string;
|
|
10
137
|
sentAt: number;
|
|
@@ -20,7 +147,7 @@ export type TxInclusionData = {
|
|
|
20
147
|
export class TxInclusionMetrics {
|
|
21
148
|
private data = new Map<string, TxInclusionData>();
|
|
22
149
|
private groups = new Set<string>();
|
|
23
|
-
private blocks = new Map<number, Promise<
|
|
150
|
+
private blocks = new Map<number, Promise<L2Block | undefined>>();
|
|
24
151
|
|
|
25
152
|
private p2pGossipLatencyByTopic: Partial<Record<TopicType, { p50: number; p95: number }>> = {};
|
|
26
153
|
|
|
@@ -32,12 +159,19 @@ export class TxInclusionMetrics {
|
|
|
32
159
|
| { txP50: number; txP95: number; attestationP50: number; attestationP95: number }
|
|
33
160
|
| undefined;
|
|
34
161
|
|
|
35
|
-
constructor(
|
|
162
|
+
constructor(
|
|
163
|
+
private aztecNode: AztecNode,
|
|
164
|
+
private logger?: Logger,
|
|
165
|
+
) {}
|
|
36
166
|
|
|
37
167
|
recordSentTx(tx: Tx, group: string): void {
|
|
38
168
|
const txHash = tx.getTxHash().toString();
|
|
39
169
|
const priorityFees = tx.getGasSettings().maxPriorityFeesPerGas;
|
|
40
170
|
|
|
171
|
+
if (this.data.has(txHash)) {
|
|
172
|
+
this.logger?.debug(`Overwriting tx inclusion data for ${txHash}`, { txHash, group });
|
|
173
|
+
}
|
|
174
|
+
|
|
41
175
|
this.data.set(txHash, {
|
|
42
176
|
txHash,
|
|
43
177
|
sentAt: Math.trunc(Date.now() / 1000),
|
|
@@ -53,8 +187,13 @@ export class TxInclusionMetrics {
|
|
|
53
187
|
}
|
|
54
188
|
|
|
55
189
|
async recordMinedTx(txReceipt: TxReceipt): Promise<void> {
|
|
56
|
-
const {
|
|
57
|
-
if (
|
|
190
|
+
const { txHash, blockNumber } = txReceipt;
|
|
191
|
+
if (!txReceipt.isMined() || !txReceipt.hasExecutionSucceeded() || !blockNumber) {
|
|
192
|
+
this.logger?.debug('Skipping mined tx record due to receipt status', {
|
|
193
|
+
txHash: txHash.toString(),
|
|
194
|
+
status: txReceipt.status,
|
|
195
|
+
blockNumber,
|
|
196
|
+
});
|
|
58
197
|
return;
|
|
59
198
|
}
|
|
60
199
|
|
|
@@ -64,9 +203,15 @@ export class TxInclusionMetrics {
|
|
|
64
203
|
|
|
65
204
|
const block = await this.blocks.get(blockNumber)!;
|
|
66
205
|
if (!block) {
|
|
206
|
+
this.logger?.warn('Failed to load block for mined tx receipt', { txHash: txHash.toString(), blockNumber });
|
|
67
207
|
return;
|
|
68
208
|
}
|
|
69
|
-
const data = this.data.get(txHash.toString())
|
|
209
|
+
const data = this.data.get(txHash.toString());
|
|
210
|
+
if (!data) {
|
|
211
|
+
const message = `Missing sent tx record for mined tx ${txHash.toString()}`;
|
|
212
|
+
this.logger?.warn(message, { txHash: txHash.toString(), blockNumber });
|
|
213
|
+
throw new Error(message);
|
|
214
|
+
}
|
|
70
215
|
data.blocknumber = blockNumber;
|
|
71
216
|
data.minedAt = Number(block.header.globalVariables.timestamp);
|
|
72
217
|
data.attestedAt = -1;
|
|
@@ -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
|
+
}
|