@aztec/end-to-end 3.0.0-devnet.2 → 3.0.0-devnet.20251212
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 +1 -1
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/benchmark.js +2 -2
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +9 -2
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +58 -33
- package/dest/bench/client_flows/config.d.ts +1 -1
- package/dest/bench/client_flows/data_extractor.d.ts +1 -1
- package/dest/bench/client_flows/data_extractor.js +8 -30
- package/dest/bench/utils.d.ts +2 -2
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +1 -1
- 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 +2 -2
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +3 -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 +6 -4
- 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 +10 -9
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +11 -9
- package/dest/e2e_fees/bridging_race.notest.d.ts +1 -1
- package/dest/e2e_fees/bridging_race.notest.js +2 -2
- package/dest/e2e_fees/fees_test.d.ts +5 -3
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +14 -10
- package/dest/e2e_l1_publisher/write_json.d.ts +1 -1
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
- package/dest/e2e_l1_publisher/write_json.js +5 -4
- package/dest/e2e_multi_validator/utils.d.ts +1 -1
- package/dest/e2e_multi_validator/utils.js +1 -1
- 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 +4 -3
- 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 +6 -2
- package/dest/e2e_p2p/p2p_network.d.ts +218 -11
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +11 -5
- 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 +6 -5
- package/dest/e2e_token_contract/token_contract_test.d.ts +1 -1
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +2 -2
- package/dest/fixtures/e2e_prover_test.d.ts +4 -2
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +18 -14
- package/dest/fixtures/fixtures.d.ts +1 -1
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +1 -1
- package/dest/fixtures/get_acvm_config.d.ts +1 -1
- package/dest/fixtures/get_acvm_config.js +1 -1
- package/dest/fixtures/get_bb_config.d.ts +1 -1
- package/dest/fixtures/get_bb_config.d.ts.map +1 -1
- package/dest/fixtures/index.d.ts +1 -1
- package/dest/fixtures/l1_to_l2_messaging.d.ts +4 -3
- package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
- package/dest/fixtures/l1_to_l2_messaging.js +2 -2
- package/dest/fixtures/logging.d.ts +1 -1
- package/dest/fixtures/setup_l1_contracts.d.ts +475 -4
- package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -1
- package/dest/fixtures/setup_l1_contracts.js +1 -1
- package/dest/fixtures/setup_p2p_test.d.ts +4 -4
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +18 -10
- package/dest/fixtures/snapshot_manager.d.ts +3 -3
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.js +6 -4
- package/dest/fixtures/token_utils.d.ts +5 -2
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +7 -4
- package/dest/fixtures/utils.d.ts +453 -7
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +26 -19
- package/dest/fixtures/web3signer.d.ts +1 -1
- package/dest/fixtures/web3signer.js +1 -1
- package/dest/fixtures/with_telemetry_utils.d.ts +2 -2
- package/dest/fixtures/with_telemetry_utils.d.ts.map +1 -1
- package/dest/fixtures/with_telemetry_utils.js +2 -2
- package/dest/index.d.ts +1 -1
- package/dest/quality_of_service/alert_checker.d.ts +1 -1
- package/dest/quality_of_service/alert_checker.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.d.ts +5 -14
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +1 -1
- package/dest/shared/gas_portal_test_harness.d.ts +2 -12
- 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 +1 -1
- package/dest/shared/jest_setup.d.ts +1 -1
- package/dest/shared/submit-transactions.d.ts +1 -1
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.d.ts +3 -2
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +15 -13
- package/dest/simulators/index.d.ts +1 -1
- package/dest/simulators/lending_simulator.d.ts +2 -6
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +5 -3
- package/dest/simulators/token_simulator.d.ts +1 -1
- package/dest/simulators/token_simulator.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.d.ts +5 -3
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +45 -10
- package/dest/spartan/tx_metrics.d.ts +39 -0
- package/dest/spartan/tx_metrics.d.ts.map +1 -0
- package/dest/spartan/tx_metrics.js +95 -0
- package/dest/spartan/utils.d.ts +31 -21
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +93 -33
- package/package.json +42 -40
- package/src/bench/client_flows/benchmark.ts +2 -2
- package/src/bench/client_flows/client_flows_benchmark.ts +80 -33
- package/src/bench/client_flows/data_extractor.ts +9 -31
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +2 -2
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +7 -6
- package/src/e2e_deploy_contract/deploy_test.ts +1 -1
- package/src/e2e_epochs/epochs_test.ts +19 -16
- package/src/e2e_fees/bridging_race.notest.ts +2 -2
- package/src/e2e_fees/fees_test.ts +18 -12
- package/src/e2e_l1_publisher/write_json.ts +5 -4
- package/src/e2e_multi_validator/utils.ts +1 -1
- package/src/e2e_nested_contract/nested_contract_test.ts +4 -3
- package/src/e2e_p2p/inactivity_slash_test.ts +9 -3
- package/src/e2e_p2p/p2p_network.ts +15 -12
- package/src/e2e_p2p/shared.ts +13 -6
- package/src/e2e_token_contract/token_contract_test.ts +2 -2
- package/src/fixtures/e2e_prover_test.ts +16 -17
- package/src/fixtures/fixtures.ts +1 -2
- package/src/fixtures/get_acvm_config.ts +1 -1
- package/src/fixtures/l1_to_l2_messaging.ts +4 -2
- package/src/fixtures/setup_l1_contracts.ts +2 -1
- package/src/fixtures/setup_p2p_test.ts +23 -9
- package/src/fixtures/snapshot_manager.ts +7 -10
- package/src/fixtures/token_utils.ts +4 -4
- package/src/fixtures/utils.ts +51 -31
- package/src/fixtures/web3signer.ts +1 -1
- package/src/fixtures/with_telemetry_utils.ts +2 -2
- package/src/guides/up_quick_start.sh +1 -1
- package/src/shared/cross_chain_test_harness.ts +5 -2
- package/src/shared/gas_portal_test_harness.ts +2 -2
- package/src/shared/uniswap_l1_l2.ts +16 -19
- package/src/simulators/lending_simulator.ts +6 -4
- package/src/spartan/DEVELOP.md +7 -0
- package/src/spartan/setup_test_wallets.ts +49 -12
- package/src/spartan/tx_metrics.ts +130 -0
- package/src/spartan/utils.ts +107 -33
|
@@ -6,12 +6,13 @@ import { type FeePaymentMethod, SponsoredFeePaymentMethod } from '@aztec/aztec.j
|
|
|
6
6
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
7
7
|
import { type AztecNode, createAztecNodeClient } from '@aztec/aztec.js/node';
|
|
8
8
|
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
9
|
-
import { createEthereumChain
|
|
9
|
+
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
10
|
+
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
10
11
|
import type { Logger } from '@aztec/foundation/log';
|
|
11
12
|
import { retryUntil } from '@aztec/foundation/retry';
|
|
12
13
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
13
14
|
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
14
|
-
import { TestWallet, proveInteraction,
|
|
15
|
+
import { TestWallet, proveInteraction, registerInitialLocalNetworkAccountsInWallet } from '@aztec/test-wallet/server';
|
|
15
16
|
|
|
16
17
|
import { getACVMConfig } from '../fixtures/get_acvm_config.js';
|
|
17
18
|
import { getBBConfig } from '../fixtures/get_bb_config.js';
|
|
@@ -28,6 +29,11 @@ export interface TestAccounts {
|
|
|
28
29
|
tokenAddress: AztecAddress;
|
|
29
30
|
}
|
|
30
31
|
|
|
32
|
+
export type TestAccountsWithoutTokens = Omit<
|
|
33
|
+
TestAccounts,
|
|
34
|
+
'tokenAddress' | 'tokenContract' | 'tokenName' | 'tokenAdminAddress'
|
|
35
|
+
>;
|
|
36
|
+
|
|
31
37
|
const TOKEN_NAME = 'USDC';
|
|
32
38
|
const TOKEN_SYMBOL = 'USD';
|
|
33
39
|
const TOKEN_DECIMALS = 18n;
|
|
@@ -42,14 +48,14 @@ export async function setupTestAccountsWithTokens(
|
|
|
42
48
|
const aztecNode = createAztecNodeClient(nodeUrl);
|
|
43
49
|
const wallet = await TestWallet.create(aztecNode);
|
|
44
50
|
|
|
45
|
-
const [recipientAccount, ...accounts] = (await
|
|
51
|
+
const [recipientAccount, ...accounts] = (await registerInitialLocalNetworkAccountsInWallet(wallet)).slice(
|
|
46
52
|
0,
|
|
47
53
|
ACCOUNT_COUNT + 1,
|
|
48
54
|
);
|
|
49
55
|
|
|
50
56
|
const tokenAdmin = accounts[0];
|
|
51
57
|
const tokenAddress = await deployTokenAndMint(wallet, accounts, tokenAdmin, mintAmount, undefined, logger);
|
|
52
|
-
const tokenContract =
|
|
58
|
+
const tokenContract = TokenContract.at(tokenAddress, wallet);
|
|
53
59
|
|
|
54
60
|
return {
|
|
55
61
|
aztecNode,
|
|
@@ -63,7 +69,7 @@ export async function setupTestAccountsWithTokens(
|
|
|
63
69
|
};
|
|
64
70
|
}
|
|
65
71
|
|
|
66
|
-
export async function
|
|
72
|
+
export async function deploySponsoredTestAccountsWithTokens(
|
|
67
73
|
wallet: TestWallet,
|
|
68
74
|
aztecNode: AztecNode,
|
|
69
75
|
mintAmount: bigint,
|
|
@@ -96,7 +102,7 @@ export async function deploySponsoredTestAccounts(
|
|
|
96
102
|
new SponsoredFeePaymentMethod(await getSponsoredFPCAddress()),
|
|
97
103
|
logger,
|
|
98
104
|
);
|
|
99
|
-
const tokenContract =
|
|
105
|
+
const tokenContract = TokenContract.at(tokenAddress, wallet);
|
|
100
106
|
|
|
101
107
|
return {
|
|
102
108
|
aztecNode,
|
|
@@ -110,6 +116,37 @@ export async function deploySponsoredTestAccounts(
|
|
|
110
116
|
};
|
|
111
117
|
}
|
|
112
118
|
|
|
119
|
+
export async function deploySponsoredTestAccounts(
|
|
120
|
+
wallet: TestWallet,
|
|
121
|
+
aztecNode: AztecNode,
|
|
122
|
+
logger: Logger,
|
|
123
|
+
numberOfFundedWallets = 1,
|
|
124
|
+
): Promise<TestAccountsWithoutTokens> {
|
|
125
|
+
const [recipient, ...funded] = await generateSchnorrAccounts(numberOfFundedWallets + 1);
|
|
126
|
+
const recipientAccount = await wallet.createSchnorrAccount(recipient.secret, recipient.salt);
|
|
127
|
+
const fundedAccounts = await Promise.all(funded.map(a => wallet.createSchnorrAccount(a.secret, a.salt)));
|
|
128
|
+
|
|
129
|
+
await registerSponsoredFPC(wallet);
|
|
130
|
+
|
|
131
|
+
const paymentMethod = new SponsoredFeePaymentMethod(await getSponsoredFPCAddress());
|
|
132
|
+
const recipientDeployMethod = await recipientAccount.getDeployMethod();
|
|
133
|
+
await recipientDeployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod } }).wait({ timeout: 2400 });
|
|
134
|
+
await Promise.all(
|
|
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
|
+
);
|
|
141
|
+
|
|
142
|
+
return {
|
|
143
|
+
aztecNode,
|
|
144
|
+
wallet,
|
|
145
|
+
accounts: fundedAccounts.map(acc => acc.address),
|
|
146
|
+
recipientAddress: recipientAccount.address,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
113
150
|
export async function deployTestAccountsWithTokens(
|
|
114
151
|
nodeUrl: string,
|
|
115
152
|
l1RpcUrls: string[],
|
|
@@ -152,7 +189,7 @@ export async function deployTestAccountsWithTokens(
|
|
|
152
189
|
undefined,
|
|
153
190
|
logger,
|
|
154
191
|
);
|
|
155
|
-
const tokenContract =
|
|
192
|
+
const tokenContract = TokenContract.at(tokenAddress, wallet);
|
|
156
193
|
|
|
157
194
|
return {
|
|
158
195
|
aztecNode,
|
|
@@ -228,9 +265,9 @@ async function deployTokenAndMint(
|
|
|
228
265
|
logger.verbose(`Minting ${mintAmount} public assets to the ${accounts.length} accounts...`);
|
|
229
266
|
|
|
230
267
|
await Promise.all(
|
|
231
|
-
accounts.map(
|
|
232
|
-
|
|
233
|
-
.mint_to_public(acc, mintAmount)
|
|
268
|
+
accounts.map(acc =>
|
|
269
|
+
TokenContract.at(tokenAddress, wallet)
|
|
270
|
+
.methods.mint_to_public(acc, mintAmount)
|
|
234
271
|
.send({ from: admin, fee: { paymentMethod } })
|
|
235
272
|
.wait({ timeout: 600 }),
|
|
236
273
|
),
|
|
@@ -260,8 +297,8 @@ export async function performTransfers({
|
|
|
260
297
|
// Default to sponsored fee payment if no fee method is provided
|
|
261
298
|
const defaultFeePaymentMethod = feePaymentMethod || new SponsoredFeePaymentMethod(await getSponsoredFPCAddress());
|
|
262
299
|
for (let i = 0; i < rounds; i++) {
|
|
263
|
-
const txs = testAccounts.accounts.map(
|
|
264
|
-
const token =
|
|
300
|
+
const txs = testAccounts.accounts.map(acc => {
|
|
301
|
+
const token = TokenContract.at(testAccounts.tokenAddress, testAccounts.wallet);
|
|
265
302
|
return proveInteraction(wallet, token.methods.transfer_in_public(acc, recipient, transferAmount, 0), {
|
|
266
303
|
from: acc,
|
|
267
304
|
fee: {
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
2
|
+
import type { L2Block } from '@aztec/stdlib/block';
|
|
3
|
+
import { Tx, type TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
4
|
+
|
|
5
|
+
import { createHistogram } from 'perf_hooks';
|
|
6
|
+
|
|
7
|
+
export type TxInclusionData = {
|
|
8
|
+
txHash: string;
|
|
9
|
+
sentAt: number;
|
|
10
|
+
minedAt: number;
|
|
11
|
+
attestedAt: number;
|
|
12
|
+
blocknumber: number;
|
|
13
|
+
priorityFee: number;
|
|
14
|
+
totalFee: number;
|
|
15
|
+
positionInBlock: number;
|
|
16
|
+
group: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export class TxInclusionMetrics {
|
|
20
|
+
private data = new Map<string, TxInclusionData>();
|
|
21
|
+
private groups = new Set<string>();
|
|
22
|
+
private blocks = new Map<number, Promise<L2Block>>();
|
|
23
|
+
|
|
24
|
+
constructor(private aztecNode: AztecNode) {}
|
|
25
|
+
|
|
26
|
+
recordSentTx(tx: Tx, group: string): void {
|
|
27
|
+
const txHash = tx.getTxHash().toString();
|
|
28
|
+
const priorityFees = tx.getGasSettings().maxPriorityFeesPerGas;
|
|
29
|
+
|
|
30
|
+
this.data.set(txHash, {
|
|
31
|
+
txHash,
|
|
32
|
+
sentAt: Math.trunc(Date.now() / 1000),
|
|
33
|
+
minedAt: -1,
|
|
34
|
+
attestedAt: -1,
|
|
35
|
+
blocknumber: -1,
|
|
36
|
+
priorityFee: Number(priorityFees.feePerDaGas + priorityFees.feePerL2Gas),
|
|
37
|
+
totalFee: -1,
|
|
38
|
+
positionInBlock: -1,
|
|
39
|
+
group,
|
|
40
|
+
});
|
|
41
|
+
this.groups.add(group);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async recordMinedTx(txReceipt: TxReceipt): Promise<void> {
|
|
45
|
+
const { status, txHash, blockNumber } = txReceipt;
|
|
46
|
+
if (status !== TxStatus.SUCCESS || !blockNumber) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (!this.blocks.has(blockNumber)) {
|
|
51
|
+
this.blocks.set(blockNumber, this.aztecNode.getBlock(blockNumber) as Promise<L2Block>);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const block = await this.blocks.get(blockNumber)!;
|
|
55
|
+
const data = this.data.get(txHash.toString())!;
|
|
56
|
+
data.blocknumber = blockNumber;
|
|
57
|
+
data.minedAt = Number(block.header.globalVariables.timestamp);
|
|
58
|
+
data.attestedAt = -1;
|
|
59
|
+
data.totalFee = Number(txReceipt.transactionFee ?? 0n);
|
|
60
|
+
data.positionInBlock = block.body.txEffects.findIndex(txEffect => txEffect.txHash.equals(txHash));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public inclusionTimeInSeconds(group: string): {
|
|
64
|
+
count: number;
|
|
65
|
+
group: string;
|
|
66
|
+
min: number;
|
|
67
|
+
mean: number;
|
|
68
|
+
max: number;
|
|
69
|
+
median: number;
|
|
70
|
+
p99: number;
|
|
71
|
+
} {
|
|
72
|
+
const histogram = createHistogram({});
|
|
73
|
+
for (const tx of this.data.values()) {
|
|
74
|
+
if (!tx.blocknumber || tx.group !== group) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
histogram.record(tx.minedAt - tx.sentAt);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (histogram.count === 0) {
|
|
82
|
+
return {
|
|
83
|
+
group,
|
|
84
|
+
count: 0,
|
|
85
|
+
mean: 0,
|
|
86
|
+
max: 0,
|
|
87
|
+
median: 0,
|
|
88
|
+
min: 0,
|
|
89
|
+
p99: 0,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
group,
|
|
95
|
+
count: histogram.count,
|
|
96
|
+
mean: histogram.mean,
|
|
97
|
+
max: histogram.max,
|
|
98
|
+
median: histogram.percentile(50),
|
|
99
|
+
min: histogram.min,
|
|
100
|
+
p99: histogram.percentile(99),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
toGithubActionBenchmarkJSON(): Array<{ name: string; unit: string; value: number; range?: number; extra?: string }> {
|
|
105
|
+
const data: Array<{ name: string; unit: string; value: number; range?: number; extra?: string }> = [];
|
|
106
|
+
for (const group of this.groups) {
|
|
107
|
+
const stats = this.inclusionTimeInSeconds(group);
|
|
108
|
+
|
|
109
|
+
data.push(
|
|
110
|
+
{
|
|
111
|
+
name: `${group}/avg_inclusion`,
|
|
112
|
+
unit: 's',
|
|
113
|
+
value: stats.mean,
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
name: `${group}/median_inclusion`,
|
|
117
|
+
unit: 's',
|
|
118
|
+
value: stats.median,
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: `${group}/p99_inclusion`,
|
|
122
|
+
unit: 's',
|
|
123
|
+
value: stats.p99,
|
|
124
|
+
},
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return data;
|
|
129
|
+
}
|
|
130
|
+
}
|
package/src/spartan/utils.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/aztec.js/log';
|
|
2
2
|
import type { RollupCheatCodes } from '@aztec/aztec/testing';
|
|
3
|
-
import type { L1ContractAddresses
|
|
3
|
+
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
4
|
+
import type { ViemPublicClient } from '@aztec/ethereum/types';
|
|
5
|
+
import type { CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
4
6
|
import type { Logger } from '@aztec/foundation/log';
|
|
7
|
+
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
5
8
|
import { makeBackoff, retry } from '@aztec/foundation/retry';
|
|
6
9
|
import { schemas } from '@aztec/foundation/schemas';
|
|
7
10
|
import { sleep } from '@aztec/foundation/sleep';
|
|
@@ -160,9 +163,42 @@ export async function startPortForward({
|
|
|
160
163
|
return { process, port };
|
|
161
164
|
}
|
|
162
165
|
|
|
163
|
-
export function
|
|
166
|
+
export function getExternalIP(namespace: string, serviceName: string): Promise<string> {
|
|
167
|
+
const { promise, resolve, reject } = promiseWithResolvers<string>();
|
|
168
|
+
const process = spawn(
|
|
169
|
+
'kubectl',
|
|
170
|
+
[
|
|
171
|
+
'get',
|
|
172
|
+
'service',
|
|
173
|
+
'-n',
|
|
174
|
+
namespace,
|
|
175
|
+
`${namespace}-${serviceName}`,
|
|
176
|
+
'--output',
|
|
177
|
+
"jsonpath='{.status.loadBalancer.ingress[0].ip}'",
|
|
178
|
+
],
|
|
179
|
+
{
|
|
180
|
+
stdio: 'pipe',
|
|
181
|
+
},
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
let ip = '';
|
|
185
|
+
process.stdout.on('data', data => {
|
|
186
|
+
ip += data;
|
|
187
|
+
});
|
|
188
|
+
process.on('error', err => {
|
|
189
|
+
reject(err);
|
|
190
|
+
});
|
|
191
|
+
process.on('exit', () => {
|
|
192
|
+
// kubectl prints JSON. Remove the quotes
|
|
193
|
+
resolve(ip.replace(/"|'/g, ''));
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
return promise;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export function startPortForwardForRPC(namespace: string, index = 0) {
|
|
164
200
|
return startPortForward({
|
|
165
|
-
resource: `
|
|
201
|
+
resource: `pod/${namespace}-rpc-aztec-node-${index}`,
|
|
166
202
|
namespace,
|
|
167
203
|
containerPort: 8080,
|
|
168
204
|
});
|
|
@@ -295,6 +331,32 @@ async function execHelmCommand(args: Parameters<typeof createHelmCommand>[0]) {
|
|
|
295
331
|
return stdout;
|
|
296
332
|
}
|
|
297
333
|
|
|
334
|
+
export async function uninstallChaosMesh(instanceName: string, namespace: string, logger: Logger) {
|
|
335
|
+
// uninstall the helm chart if it exists
|
|
336
|
+
logger.info(`Uninstalling helm chart ${instanceName}`);
|
|
337
|
+
await execAsync(`helm uninstall ${instanceName} --namespace ${namespace} --wait --ignore-not-found`);
|
|
338
|
+
// and delete the chaos-mesh resources created by this release
|
|
339
|
+
const deleteByLabel = async (resource: string) => {
|
|
340
|
+
const args = {
|
|
341
|
+
resource,
|
|
342
|
+
namespace: namespace,
|
|
343
|
+
label: `app.kubernetes.io/instance=${instanceName}`,
|
|
344
|
+
} as const;
|
|
345
|
+
logger.info(`Deleting ${resource} resources for release ${instanceName}`);
|
|
346
|
+
await deleteResourceByLabel(args).catch(e => {
|
|
347
|
+
logger.error(`Error deleting ${resource}: ${e}`);
|
|
348
|
+
logger.info(`Force deleting ${resource}`);
|
|
349
|
+
return deleteResourceByLabel({ ...args, force: true });
|
|
350
|
+
});
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
await deleteByLabel('podchaos');
|
|
354
|
+
await deleteByLabel('networkchaos');
|
|
355
|
+
await deleteByLabel('podnetworkchaos');
|
|
356
|
+
await deleteByLabel('workflows');
|
|
357
|
+
await deleteByLabel('workflownodes');
|
|
358
|
+
}
|
|
359
|
+
|
|
298
360
|
/**
|
|
299
361
|
* Installs a Helm chart with the given parameters.
|
|
300
362
|
* @param instanceName - The name of the Helm chart instance.
|
|
@@ -317,7 +379,6 @@ export async function installChaosMeshChart({
|
|
|
317
379
|
targetNamespace,
|
|
318
380
|
valuesFile,
|
|
319
381
|
helmChartDir,
|
|
320
|
-
chaosMeshNamespace = 'chaos-mesh',
|
|
321
382
|
timeout = '10m',
|
|
322
383
|
clean = true,
|
|
323
384
|
values = {},
|
|
@@ -334,32 +395,13 @@ export async function installChaosMeshChart({
|
|
|
334
395
|
logger: Logger;
|
|
335
396
|
}) {
|
|
336
397
|
if (clean) {
|
|
337
|
-
|
|
338
|
-
logger.info(`Uninstalling helm chart ${instanceName}`);
|
|
339
|
-
await execAsync(`helm uninstall ${instanceName} --namespace ${chaosMeshNamespace} --wait --ignore-not-found`);
|
|
340
|
-
// and delete the chaos-mesh resources created by this release
|
|
341
|
-
const deleteByLabel = async (resource: string) => {
|
|
342
|
-
const args = {
|
|
343
|
-
resource,
|
|
344
|
-
namespace: chaosMeshNamespace,
|
|
345
|
-
label: `app.kubernetes.io/instance=${instanceName}`,
|
|
346
|
-
} as const;
|
|
347
|
-
logger.info(`Deleting ${resource} resources for release ${instanceName}`);
|
|
348
|
-
await deleteResourceByLabel(args).catch(e => {
|
|
349
|
-
logger.error(`Error deleting ${resource}: ${e}`);
|
|
350
|
-
logger.info(`Force deleting ${resource}`);
|
|
351
|
-
return deleteResourceByLabel({ ...args, force: true });
|
|
352
|
-
});
|
|
353
|
-
};
|
|
354
|
-
|
|
355
|
-
await deleteByLabel('podchaos');
|
|
356
|
-
await deleteByLabel('networkchaos');
|
|
398
|
+
await uninstallChaosMesh(instanceName, targetNamespace, logger);
|
|
357
399
|
}
|
|
358
400
|
|
|
359
401
|
return execHelmCommand({
|
|
360
402
|
instanceName,
|
|
361
403
|
helmChartDir,
|
|
362
|
-
namespace:
|
|
404
|
+
namespace: targetNamespace,
|
|
363
405
|
valuesFile,
|
|
364
406
|
timeout,
|
|
365
407
|
values: { ...values, 'global.targetNamespace': targetNamespace },
|
|
@@ -491,24 +533,24 @@ export function applyNetworkShaping({
|
|
|
491
533
|
});
|
|
492
534
|
}
|
|
493
535
|
|
|
494
|
-
export async function
|
|
536
|
+
export async function awaitCheckpointNumber(
|
|
495
537
|
rollupCheatCodes: RollupCheatCodes,
|
|
496
|
-
|
|
538
|
+
checkpointNumber: CheckpointNumber,
|
|
497
539
|
timeoutSeconds: number,
|
|
498
540
|
logger: Logger,
|
|
499
541
|
) {
|
|
500
|
-
logger.info(`Waiting for
|
|
542
|
+
logger.info(`Waiting for checkpoint ${checkpointNumber}`);
|
|
501
543
|
let tips = await rollupCheatCodes.getTips();
|
|
502
544
|
const endTime = Date.now() + timeoutSeconds * 1000;
|
|
503
|
-
while (tips.pending <
|
|
504
|
-
logger.info(`At
|
|
545
|
+
while (tips.pending < checkpointNumber && Date.now() < endTime) {
|
|
546
|
+
logger.info(`At checkpoint ${tips.pending}`);
|
|
505
547
|
await sleep(1000);
|
|
506
548
|
tips = await rollupCheatCodes.getTips();
|
|
507
549
|
}
|
|
508
|
-
if (tips.pending <
|
|
509
|
-
throw new Error(`Timeout waiting for
|
|
550
|
+
if (tips.pending < checkpointNumber) {
|
|
551
|
+
throw new Error(`Timeout waiting for checkpoint ${checkpointNumber}, only reached ${tips.pending}`);
|
|
510
552
|
} else {
|
|
511
|
-
logger.info(`Reached
|
|
553
|
+
logger.info(`Reached checkpoint ${tips.pending}`);
|
|
512
554
|
}
|
|
513
555
|
}
|
|
514
556
|
|
|
@@ -908,3 +950,35 @@ export function getGitProjectRoot(): string {
|
|
|
908
950
|
throw new Error(`Failed to determine git project root: ${error}`);
|
|
909
951
|
}
|
|
910
952
|
}
|
|
953
|
+
|
|
954
|
+
/** Returns a client to the RPC of the given sequencer (defaults to first) */
|
|
955
|
+
export async function getNodeClient(
|
|
956
|
+
env: TestConfig,
|
|
957
|
+
index: number = 0,
|
|
958
|
+
): Promise<{ node: ReturnType<typeof createAztecNodeClient>; port: number; process: ChildProcess }> {
|
|
959
|
+
const namespace = env.NAMESPACE;
|
|
960
|
+
const containerPort = 8080;
|
|
961
|
+
const sequencers = await getSequencers(namespace);
|
|
962
|
+
const sequencer = sequencers[index];
|
|
963
|
+
if (!sequencer) {
|
|
964
|
+
throw new Error(`No sequencer found at index ${index} in namespace ${namespace}`);
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
const { process, port } = await startPortForward({
|
|
968
|
+
resource: `pod/${sequencer}`,
|
|
969
|
+
namespace,
|
|
970
|
+
containerPort,
|
|
971
|
+
});
|
|
972
|
+
|
|
973
|
+
const url = `http://localhost:${port}`;
|
|
974
|
+
await retry(
|
|
975
|
+
() => fetch(`${url}/status`).then(res => res.status === 200),
|
|
976
|
+
'forward port',
|
|
977
|
+
makeBackoff([1, 1, 2, 6]),
|
|
978
|
+
logger,
|
|
979
|
+
true,
|
|
980
|
+
);
|
|
981
|
+
|
|
982
|
+
const client = createAztecNodeClient(url);
|
|
983
|
+
return { node: client, port, process };
|
|
984
|
+
}
|