@aztec/end-to-end 0.0.1-commit.d6f2b3f94 → 0.0.1-commit.dbf9cec
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 +3 -3
- 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 +10 -0
- 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_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 +9 -7
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +53 -34
- package/dest/e2e_fees/fees_test.d.ts +2 -2
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +6 -6
- 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 +16 -2
- package/dest/e2e_p2p/reqresp/utils.d.ts +3 -3
- package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -1
- package/dest/e2e_p2p/reqresp/utils.js +32 -8
- package/dest/e2e_p2p/shared.d.ts +2 -2
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +2 -1
- 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 +10 -0
- package/dest/fixtures/authwit_proxy.d.ts +15 -0
- package/dest/fixtures/authwit_proxy.d.ts.map +1 -0
- package/dest/fixtures/authwit_proxy.js +30 -0
- package/dest/fixtures/e2e_prover_test.d.ts +4 -4
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +27 -34
- package/dest/fixtures/elu_monitor.d.ts +21 -0
- package/dest/fixtures/elu_monitor.d.ts.map +1 -0
- package/dest/fixtures/elu_monitor.js +102 -0
- package/dest/fixtures/fixtures.d.ts +5 -1
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +6 -0
- package/dest/fixtures/ha_setup.d.ts +1 -1
- package/dest/fixtures/ha_setup.d.ts.map +1 -1
- package/dest/fixtures/ha_setup.js +3 -1
- package/dest/fixtures/setup.d.ts +26 -10
- package/dest/fixtures/setup.d.ts.map +1 -1
- package/dest/fixtures/setup.js +56 -81
- package/dest/fixtures/setup_p2p_test.d.ts +6 -3
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +12 -9
- package/dest/fixtures/token_utils.d.ts +2 -2
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +3 -2
- package/dest/shared/index.d.ts +2 -1
- package/dest/shared/index.d.ts.map +1 -1
- package/dest/shared/index.js +1 -0
- package/dest/shared/jest_setup.js +10 -1
- package/dest/shared/mock_state_view.d.ts +86 -0
- package/dest/shared/mock_state_view.d.ts.map +1 -0
- package/dest/shared/mock_state_view.js +186 -0
- package/dest/shared/submit-transactions.d.ts +2 -2
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.d.ts +1 -1
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- 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 +9 -2
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +31 -1
- package/dest/spartan/utils/bot.d.ts +3 -2
- package/dest/spartan/utils/bot.d.ts.map +1 -1
- package/dest/spartan/utils/bot.js +2 -1
- package/dest/spartan/utils/config.d.ts +4 -1
- package/dest/spartan/utils/config.d.ts.map +1 -1
- package/dest/spartan/utils/config.js +2 -1
- package/dest/spartan/utils/index.d.ts +3 -2
- package/dest/spartan/utils/index.d.ts.map +1 -1
- package/dest/spartan/utils/index.js +3 -1
- package/dest/spartan/utils/k8s.d.ts +3 -1
- package/dest/spartan/utils/k8s.d.ts.map +1 -1
- package/dest/spartan/utils/k8s.js +6 -0
- package/dest/spartan/utils/nodes.d.ts +4 -5
- package/dest/spartan/utils/nodes.d.ts.map +1 -1
- package/dest/spartan/utils/nodes.js +9 -9
- package/dest/test-wallet/test_wallet.d.ts +83 -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/dest/test-wallet/wallet_worker_script.d.ts +2 -0
- package/dest/test-wallet/wallet_worker_script.d.ts.map +1 -0
- package/dest/test-wallet/wallet_worker_script.js +48 -0
- package/dest/test-wallet/worker_wallet.d.ts +52 -0
- package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
- package/dest/test-wallet/worker_wallet.js +151 -0
- package/dest/test-wallet/worker_wallet_schema.d.ts +274 -0
- package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
- package/dest/test-wallet/worker_wallet_schema.js +10 -0
- package/package.json +40 -39
- package/src/bench/client_flows/client_flows_benchmark.ts +3 -7
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +10 -1
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +1 -1
- package/src/e2e_deploy_contract/deploy_test.ts +1 -1
- package/src/e2e_epochs/epochs_test.ts +66 -66
- package/src/e2e_fees/bridging_race.notest.ts +1 -1
- package/src/e2e_fees/fees_test.ts +6 -21
- package/src/e2e_p2p/p2p_network.ts +25 -3
- package/src/e2e_p2p/reqresp/utils.ts +36 -8
- package/src/e2e_p2p/shared.ts +2 -1
- package/src/e2e_token_contract/token_contract_test.ts +10 -1
- package/src/fixtures/authwit_proxy.ts +50 -0
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/fixtures/e2e_prover_test.ts +26 -36
- package/src/fixtures/elu_monitor.ts +126 -0
- package/src/fixtures/fixtures.ts +10 -0
- package/src/fixtures/ha_setup.ts +3 -1
- package/src/fixtures/setup.ts +74 -111
- package/src/fixtures/setup_p2p_test.ts +9 -17
- package/src/fixtures/token_utils.ts +2 -1
- package/src/guides/up_quick_start.sh +3 -3
- package/src/shared/index.ts +1 -0
- package/src/shared/jest_setup.ts +16 -1
- package/src/shared/mock_state_view.ts +188 -0
- package/src/shared/submit-transactions.ts +6 -2
- package/src/shared/uniswap_l1_l2.ts +1 -1
- package/src/simulators/token_simulator.ts +1 -29
- package/src/spartan/setup_test_wallets.ts +58 -4
- package/src/spartan/utils/bot.ts +4 -1
- package/src/spartan/utils/config.ts +1 -0
- package/src/spartan/utils/index.ts +4 -0
- package/src/spartan/utils/k8s.ts +8 -0
- package/src/spartan/utils/nodes.ts +15 -10
- package/src/test-wallet/test_wallet.ts +306 -0
- package/src/test-wallet/utils.ts +112 -0
- package/src/test-wallet/wallet_worker_script.ts +60 -0
- package/src/test-wallet/worker_wallet.ts +213 -0
- package/src/test-wallet/worker_wallet_schema.ts +13 -0
|
@@ -4,7 +4,8 @@ import { Fr, GrumpkinScalar } from '@aztec/aztec.js/fields';
|
|
|
4
4
|
import type { Logger } from '@aztec/aztec.js/log';
|
|
5
5
|
import { TxHash, type TxReceipt, TxStatus } from '@aztec/aztec.js/tx';
|
|
6
6
|
import { times } from '@aztec/foundation/collection';
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
import type { TestWallet } from '../test-wallet/test_wallet.js';
|
|
8
9
|
|
|
9
10
|
// submits a set of transactions to the provided Wallet
|
|
10
11
|
export const submitTxsTo = async (
|
|
@@ -18,7 +19,10 @@ export const submitTxsTo = async (
|
|
|
18
19
|
times(numTxs, async () => {
|
|
19
20
|
const accountManager = await wallet.createSchnorrAccount(Fr.random(), Fr.random(), GrumpkinScalar.random());
|
|
20
21
|
const deployMethod = await accountManager.getDeployMethod();
|
|
21
|
-
const txHash = await deployMethod.send({
|
|
22
|
+
const txHash = await deployMethod.send({
|
|
23
|
+
from: submitter,
|
|
24
|
+
wait: NO_WAIT,
|
|
25
|
+
});
|
|
22
26
|
|
|
23
27
|
logger.info(`Tx sent with hash ${txHash}`);
|
|
24
28
|
const receipt: TxReceipt = await wallet.getTxReceipt(txHash);
|
|
@@ -17,12 +17,12 @@ import { InboxAbi, UniswapPortalAbi, UniswapPortalBytecode } from '@aztec/l1-art
|
|
|
17
17
|
import { UniswapContract } from '@aztec/noir-contracts.js/Uniswap';
|
|
18
18
|
import { computeL2ToL1MessageHash } from '@aztec/stdlib/hash';
|
|
19
19
|
import { computeL2ToL1MembershipWitness } from '@aztec/stdlib/messaging';
|
|
20
|
-
import type { TestWallet } from '@aztec/test-wallet/server';
|
|
21
20
|
|
|
22
21
|
import { jest } from '@jest/globals';
|
|
23
22
|
import { type GetContractReturnType, getContract, parseEther, toFunctionSelector } from 'viem';
|
|
24
23
|
|
|
25
24
|
import { type EndToEndContext, ensureAccountContractsPublished } from '../fixtures/utils.js';
|
|
25
|
+
import type { TestWallet } from '../test-wallet/test_wallet.js';
|
|
26
26
|
import { CrossChainTestHarness } from './cross_chain_test_harness.js';
|
|
27
27
|
|
|
28
28
|
// PSA: This tests works on forked mainnet. There is a dump of the data in `dumpedState` such that we
|
|
@@ -119,39 +119,11 @@ export class TokenSimulator {
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
async checkPrivate() {
|
|
122
|
-
// Private calls
|
|
123
|
-
const defaultLookups = [];
|
|
124
|
-
const nonDefaultLookups = [];
|
|
125
|
-
|
|
126
122
|
for (const address of this.accounts) {
|
|
127
|
-
if (this.lookupProvider.has(address.toString())) {
|
|
128
|
-
nonDefaultLookups.push(address);
|
|
129
|
-
} else {
|
|
130
|
-
defaultLookups.push(address);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const defaultCalls = defaultLookups.map(address => this.token.methods.balance_of_private(address));
|
|
135
|
-
const results = (
|
|
136
|
-
await Promise.all(
|
|
137
|
-
chunk(defaultCalls, 4).map(batch =>
|
|
138
|
-
new BatchCall(this.defaultWallet, batch).simulate({ from: this.defaultAddress }),
|
|
139
|
-
),
|
|
140
|
-
)
|
|
141
|
-
).flat();
|
|
142
|
-
for (let i = 0; i < defaultLookups.length; i++) {
|
|
143
|
-
expect(results[i]).toEqual(this.balanceOfPrivate(defaultLookups[i]));
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// We are just running individual calls for the non-default lookups
|
|
147
|
-
// @todo We should also batch these
|
|
148
|
-
for (const address of nonDefaultLookups) {
|
|
149
123
|
const wallet = this.lookupProvider.get(address.toString());
|
|
150
124
|
const asset = wallet ? this.token.withWallet(wallet) : this.token;
|
|
151
125
|
|
|
152
|
-
const actualPrivateBalance = await asset.methods
|
|
153
|
-
.balance_of_private({ address })
|
|
154
|
-
.simulate({ from: this.defaultAddress });
|
|
126
|
+
const actualPrivateBalance = await asset.methods.balance_of_private(address).simulate({ from: address });
|
|
155
127
|
expect(actualPrivateBalance).toEqual(this.balanceOfPrivate(address));
|
|
156
128
|
}
|
|
157
129
|
}
|
|
@@ -13,11 +13,14 @@ import type { Logger } from '@aztec/foundation/log';
|
|
|
13
13
|
import { retryUntil } from '@aztec/foundation/retry';
|
|
14
14
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
15
15
|
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
16
|
-
import {
|
|
16
|
+
import { registerInitialLocalNetworkAccountsInWallet } from '@aztec/wallets/testing';
|
|
17
17
|
|
|
18
18
|
import { getACVMConfig } from '../fixtures/get_acvm_config.js';
|
|
19
19
|
import { getBBConfig } from '../fixtures/get_bb_config.js';
|
|
20
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';
|
|
23
|
+
import { WorkerWallet } from '../test-wallet/worker_wallet.js';
|
|
21
24
|
|
|
22
25
|
export interface TestAccounts {
|
|
23
26
|
aztecNode: AztecNode;
|
|
@@ -85,11 +88,19 @@ export async function deploySponsoredTestAccountsWithTokens(
|
|
|
85
88
|
|
|
86
89
|
const paymentMethod = new SponsoredFeePaymentMethod(await getSponsoredFPCAddress());
|
|
87
90
|
const recipientDeployMethod = await recipientAccount.getDeployMethod();
|
|
88
|
-
await recipientDeployMethod.send({
|
|
91
|
+
await recipientDeployMethod.send({
|
|
92
|
+
from: AztecAddress.ZERO,
|
|
93
|
+
fee: { paymentMethod },
|
|
94
|
+
wait: { timeout: 2400 },
|
|
95
|
+
});
|
|
89
96
|
await Promise.all(
|
|
90
97
|
fundedAccounts.map(async a => {
|
|
91
98
|
const deployMethod = await a.getDeployMethod();
|
|
92
|
-
await deployMethod.send({
|
|
99
|
+
await deployMethod.send({
|
|
100
|
+
from: AztecAddress.ZERO,
|
|
101
|
+
fee: { paymentMethod },
|
|
102
|
+
wait: { timeout: 2400 },
|
|
103
|
+
}); // increase timeout on purpose in order to account for two empty epochs
|
|
93
104
|
logger.info(`Account deployed at ${a.address}`);
|
|
94
105
|
}),
|
|
95
106
|
);
|
|
@@ -127,7 +138,11 @@ async function deployAccountWithDiagnostics(
|
|
|
127
138
|
const deployMethod = await account.getDeployMethod();
|
|
128
139
|
let txHash;
|
|
129
140
|
try {
|
|
130
|
-
txHash = await deployMethod.send({
|
|
141
|
+
txHash = await deployMethod.send({
|
|
142
|
+
from: AztecAddress.ZERO,
|
|
143
|
+
fee: { paymentMethod },
|
|
144
|
+
wait: NO_WAIT,
|
|
145
|
+
});
|
|
131
146
|
await waitForTx(aztecNode, txHash, { timeout: 2400 });
|
|
132
147
|
logger.info(`${accountLabel} deployed at ${account.address}`);
|
|
133
148
|
} catch (error) {
|
|
@@ -395,3 +410,42 @@ export async function createWalletAndAztecNodeClient(
|
|
|
395
410
|
},
|
|
396
411
|
};
|
|
397
412
|
}
|
|
413
|
+
|
|
414
|
+
export type WorkerWalletWrapper = {
|
|
415
|
+
wallet: WorkerWallet;
|
|
416
|
+
aztecNode: AztecNode;
|
|
417
|
+
cleanup: () => Promise<void>;
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
export async function createWorkerWalletClient(
|
|
421
|
+
nodeUrl: string,
|
|
422
|
+
proverEnabled: boolean,
|
|
423
|
+
logger: Logger,
|
|
424
|
+
): Promise<WorkerWalletWrapper> {
|
|
425
|
+
const aztecNode = createAztecNodeClient(nodeUrl);
|
|
426
|
+
const [bbConfig, acvmConfig] = await Promise.all([getBBConfig(logger), getACVMConfig(logger)]);
|
|
427
|
+
|
|
428
|
+
// Strip cleanup functions — they can't be structured-cloned for worker transfer
|
|
429
|
+
const { cleanup: bbCleanup, ...bbPaths } = bbConfig ?? {};
|
|
430
|
+
const { cleanup: acvmCleanup, ...acvmPaths } = acvmConfig ?? {};
|
|
431
|
+
|
|
432
|
+
const pxeConfig = {
|
|
433
|
+
dataDirectory: undefined,
|
|
434
|
+
dataStoreMapSizeKb: 1024 * 1024,
|
|
435
|
+
...bbPaths,
|
|
436
|
+
...acvmPaths,
|
|
437
|
+
proverEnabled,
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
const wallet = await WorkerWallet.create(nodeUrl, pxeConfig);
|
|
441
|
+
|
|
442
|
+
return {
|
|
443
|
+
wallet,
|
|
444
|
+
aztecNode,
|
|
445
|
+
async cleanup() {
|
|
446
|
+
await wallet.stop();
|
|
447
|
+
await bbCleanup?.();
|
|
448
|
+
await acvmCleanup?.();
|
|
449
|
+
},
|
|
450
|
+
};
|
|
451
|
+
}
|
package/src/spartan/utils/bot.ts
CHANGED
|
@@ -34,7 +34,8 @@ export async function installTransferBot({
|
|
|
34
34
|
logger: log,
|
|
35
35
|
replicas = 1,
|
|
36
36
|
txIntervalSeconds = 10,
|
|
37
|
-
followChain = '
|
|
37
|
+
followChain = 'CHECKPOINTED',
|
|
38
|
+
pxeSyncChainTip = 'proposed',
|
|
38
39
|
mnemonic = process.env.LABS_INFRA_MNEMONIC ?? 'test test test test test test test test test test test junk',
|
|
39
40
|
mnemonicStartIndex,
|
|
40
41
|
botPrivateKey = process.env.BOT_TRANSFERS_L2_PRIVATE_KEY ?? '0xcafe01',
|
|
@@ -49,6 +50,7 @@ export async function installTransferBot({
|
|
|
49
50
|
replicas?: number;
|
|
50
51
|
txIntervalSeconds?: number;
|
|
51
52
|
followChain?: string;
|
|
53
|
+
pxeSyncChainTip?: string;
|
|
52
54
|
mnemonic?: string;
|
|
53
55
|
mnemonicStartIndex?: number | string;
|
|
54
56
|
botPrivateKey?: string;
|
|
@@ -67,6 +69,7 @@ export async function installTransferBot({
|
|
|
67
69
|
'bot.replicaCount': replicas,
|
|
68
70
|
'bot.txIntervalSeconds': txIntervalSeconds,
|
|
69
71
|
'bot.followChain': followChain,
|
|
72
|
+
'bot.pxeSyncChainTip': pxeSyncChainTip,
|
|
70
73
|
'bot.botPrivateKey': botPrivateKey,
|
|
71
74
|
'bot.nodeUrl': resolvedNodeUrl,
|
|
72
75
|
'bot.mnemonic': mnemonic,
|
|
@@ -16,6 +16,7 @@ const testConfigSchema = z.object({
|
|
|
16
16
|
AZTEC_PROOF_SUBMISSION_WINDOW: z.coerce.number().optional().default(5),
|
|
17
17
|
AZTEC_LAG_IN_EPOCHS_FOR_VALIDATOR_SET: z.coerce.number().optional().default(2),
|
|
18
18
|
FUNDING_PRIVATE_KEY: z.string().optional(),
|
|
19
|
+
AZTEC_ADMIN_API_KEY: z.string().optional(),
|
|
19
20
|
});
|
|
20
21
|
|
|
21
22
|
export type TestConfig = z.infer<typeof testConfigSchema>;
|
|
@@ -25,6 +25,7 @@ export {
|
|
|
25
25
|
getRPCEndpoint,
|
|
26
26
|
getEthereumEndpoint,
|
|
27
27
|
createResilientPrometheusConnection,
|
|
28
|
+
scaleProverAgents,
|
|
28
29
|
} from './k8s.js';
|
|
29
30
|
|
|
30
31
|
// Chaos Mesh
|
|
@@ -40,6 +41,9 @@ export {
|
|
|
40
41
|
applyNetworkShaping,
|
|
41
42
|
} from './chaos.js';
|
|
42
43
|
|
|
44
|
+
// Helm
|
|
45
|
+
export { hasDeployedHelmRelease } from './helm.js';
|
|
46
|
+
|
|
43
47
|
// Bot management
|
|
44
48
|
export { restartBot, installTransferBot, uninstallTransferBot } from './bot.js';
|
|
45
49
|
|
package/src/spartan/utils/k8s.ts
CHANGED
|
@@ -522,6 +522,14 @@ export function createResilientPrometheusConnection(
|
|
|
522
522
|
return { connect, runAlertCheck };
|
|
523
523
|
}
|
|
524
524
|
|
|
525
|
+
/** Scales the prover-agent Deployment to the given number of replicas. */
|
|
526
|
+
export async function scaleProverAgents(namespace: string, replicas: number, log: Logger): Promise<void> {
|
|
527
|
+
const label = 'app.kubernetes.io/component=prover-agent';
|
|
528
|
+
const command = `kubectl scale deployment -l ${label} -n ${namespace} --replicas=${replicas} --timeout=2m`;
|
|
529
|
+
log.info(`Scaling prover agents to ${replicas}: ${command}`);
|
|
530
|
+
await execAsync(command);
|
|
531
|
+
}
|
|
532
|
+
|
|
525
533
|
export function getChartDir(spartanDir: string, chartName: string) {
|
|
526
534
|
return path.join(spartanDir.trim(), chartName);
|
|
527
535
|
}
|
|
@@ -173,7 +173,7 @@ export async function withSequencersAdmin<T>(env: TestConfig, fn: (node: AztecNo
|
|
|
173
173
|
if (statusRes.status !== 200) {
|
|
174
174
|
throw new Error(`Admin endpoint returned status ${statusRes.status}`);
|
|
175
175
|
}
|
|
176
|
-
const client = createAztecNodeAdminClient(url);
|
|
176
|
+
const client = createAztecNodeAdminClient(url, {}, undefined, env.AZTEC_ADMIN_API_KEY);
|
|
177
177
|
return { result: await fn(client), process };
|
|
178
178
|
} catch (err) {
|
|
179
179
|
// Kill the port-forward before retrying
|
|
@@ -255,21 +255,18 @@ export async function initHADb(namespace: string): Promise<void> {
|
|
|
255
255
|
}
|
|
256
256
|
|
|
257
257
|
/**
|
|
258
|
-
*
|
|
259
|
-
* Wired to env
|
|
258
|
+
* Sets probabilistic transaction dropping on validators and waits for rollout.
|
|
259
|
+
* Use probability=0 to disable. Wired to env var P2P_DROP_TX_CHANCE via Helm values.
|
|
260
260
|
*/
|
|
261
261
|
export async function setValidatorTxDrop({
|
|
262
262
|
namespace,
|
|
263
|
-
enabled,
|
|
264
263
|
probability,
|
|
265
264
|
logger: log,
|
|
266
265
|
}: {
|
|
267
266
|
namespace: string;
|
|
268
|
-
enabled: boolean;
|
|
269
267
|
probability: number;
|
|
270
268
|
logger: Logger;
|
|
271
269
|
}) {
|
|
272
|
-
const drop = enabled ? 'true' : 'false';
|
|
273
270
|
const prob = String(probability);
|
|
274
271
|
|
|
275
272
|
const selectors = ['app.kubernetes.io/name=validator', 'app.kubernetes.io/component=validator', 'app=validator'];
|
|
@@ -284,7 +281,7 @@ export async function setValidatorTxDrop({
|
|
|
284
281
|
if (names.length === 0) {
|
|
285
282
|
continue;
|
|
286
283
|
}
|
|
287
|
-
const cmd = `kubectl set env statefulset -l ${selector} -n ${namespace}
|
|
284
|
+
const cmd = `kubectl set env statefulset -l ${selector} -n ${namespace} P2P_DROP_TX_CHANCE=${prob}`;
|
|
288
285
|
log.info(`command: ${cmd}`);
|
|
289
286
|
await execAsync(cmd);
|
|
290
287
|
updated = true;
|
|
@@ -366,16 +363,24 @@ export async function enableValidatorDynamicBootNode(
|
|
|
366
363
|
*/
|
|
367
364
|
export async function rollAztecPods(namespace: string, clearState: boolean = false) {
|
|
368
365
|
// Pod components use 'validator', but StatefulSets and PVCs use 'sequencer-node' for validators
|
|
366
|
+
// RPC nodes have nodeType='rpc-node' in Helm values, so their component label is 'rpc-node' (not 'rpc')
|
|
369
367
|
const podComponents = [
|
|
370
368
|
'p2p-bootstrap',
|
|
371
369
|
'prover-node',
|
|
372
370
|
'prover-broker',
|
|
373
371
|
'prover-agent',
|
|
374
372
|
'sequencer-node',
|
|
375
|
-
'rpc',
|
|
373
|
+
'rpc-node',
|
|
374
|
+
'validator-ha-db',
|
|
375
|
+
];
|
|
376
|
+
const pvcComponents = [
|
|
377
|
+
'p2p-bootstrap',
|
|
378
|
+
'prover-node',
|
|
379
|
+
'prover-broker',
|
|
380
|
+
'sequencer-node',
|
|
381
|
+
'rpc-node',
|
|
376
382
|
'validator-ha-db',
|
|
377
383
|
];
|
|
378
|
-
const pvcComponents = ['p2p-bootstrap', 'prover-node', 'prover-broker', 'sequencer-node', 'rpc', 'validator-ha-db'];
|
|
379
384
|
// StatefulSet components that need to be scaled down before PVC deletion
|
|
380
385
|
// Note: validators use 'sequencer-node' as component label, not 'validator'
|
|
381
386
|
const statefulSetComponents = [
|
|
@@ -383,7 +388,7 @@ export async function rollAztecPods(namespace: string, clearState: boolean = fal
|
|
|
383
388
|
'prover-node',
|
|
384
389
|
'prover-broker',
|
|
385
390
|
'sequencer-node',
|
|
386
|
-
'rpc',
|
|
391
|
+
'rpc-node',
|
|
387
392
|
'validator-ha-db',
|
|
388
393
|
];
|
|
389
394
|
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import { EcdsaKAccountContract, EcdsaRAccountContract } from '@aztec/accounts/ecdsa';
|
|
2
|
+
import { SchnorrAccountContract } from '@aztec/accounts/schnorr';
|
|
3
|
+
import { StubAccountContractArtifact, createStubAccount } from '@aztec/accounts/stub';
|
|
4
|
+
import { type Account, type AccountContract, SignerlessAccount } from '@aztec/aztec.js/account';
|
|
5
|
+
import {
|
|
6
|
+
type CallIntent,
|
|
7
|
+
type ContractFunctionInteractionCallIntent,
|
|
8
|
+
type IntentInnerHash,
|
|
9
|
+
SetPublicAuthwitContractInteraction,
|
|
10
|
+
computeInnerAuthWitHashFromAction,
|
|
11
|
+
isContractFunctionInteractionCallIntent,
|
|
12
|
+
lookupValidity,
|
|
13
|
+
} from '@aztec/aztec.js/authorization';
|
|
14
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
15
|
+
import { AccountManager, type SendOptions } from '@aztec/aztec.js/wallet';
|
|
16
|
+
import type { DefaultAccountEntrypointOptions } from '@aztec/entrypoints/account';
|
|
17
|
+
import { Fq, Fr } from '@aztec/foundation/curves/bn254';
|
|
18
|
+
import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
|
|
19
|
+
import type { AccessScopes, NotesFilter } from '@aztec/pxe/client/lazy';
|
|
20
|
+
import { type PXEConfig, getPXEConfig } from '@aztec/pxe/config';
|
|
21
|
+
import { PXE, type PXECreationOptions, createPXE } from '@aztec/pxe/server';
|
|
22
|
+
import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
23
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
24
|
+
import { getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
|
|
25
|
+
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
26
|
+
import type { NoteDao } from '@aztec/stdlib/note';
|
|
27
|
+
import type { BlockHeader, TxHash, TxReceipt, TxSimulationResult } from '@aztec/stdlib/tx';
|
|
28
|
+
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
29
|
+
import { BaseWallet, type FeeOptions } from '@aztec/wallet-sdk/base-wallet';
|
|
30
|
+
|
|
31
|
+
import { AztecNodeProxy, ProvenTx } from './utils.js';
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Data for generating an account.
|
|
35
|
+
*/
|
|
36
|
+
export interface AccountData {
|
|
37
|
+
secret: Fr;
|
|
38
|
+
salt: Fr;
|
|
39
|
+
contract: AccountContract;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Wallet implementation that stores accounts in memory and provides extra debugging
|
|
44
|
+
* utilities
|
|
45
|
+
* It is intended to be used in e2e tests.
|
|
46
|
+
*/
|
|
47
|
+
export class TestWallet extends BaseWallet {
|
|
48
|
+
constructor(
|
|
49
|
+
pxe: PXE,
|
|
50
|
+
private readonly nodeRef: AztecNodeProxy,
|
|
51
|
+
) {
|
|
52
|
+
super(pxe, nodeRef);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static async create(
|
|
56
|
+
node: AztecNode,
|
|
57
|
+
overridePXEConfig?: Partial<PXEConfig>,
|
|
58
|
+
options: PXECreationOptions = { loggers: {} },
|
|
59
|
+
): Promise<TestWallet> {
|
|
60
|
+
const nodeRef = new AztecNodeProxy(node);
|
|
61
|
+
const pxeConfig = Object.assign(getPXEConfig(), {
|
|
62
|
+
proverEnabled: overridePXEConfig?.proverEnabled ?? false,
|
|
63
|
+
...overridePXEConfig,
|
|
64
|
+
});
|
|
65
|
+
const pxe = await createPXE(nodeRef, pxeConfig, options);
|
|
66
|
+
return new TestWallet(pxe, nodeRef);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Updates the underlying node that this wallet and its PXE communicate with.
|
|
71
|
+
* @param node - The new AztecNode to forward all calls to.
|
|
72
|
+
*/
|
|
73
|
+
updateNode(node: AztecNode): void {
|
|
74
|
+
this.nodeRef.updateTargetNode(node);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
createSchnorrAccount(secret: Fr, salt: Fr, signingKey?: Fq): Promise<AccountManager> {
|
|
78
|
+
signingKey = signingKey ?? deriveSigningKey(secret);
|
|
79
|
+
const accountData = {
|
|
80
|
+
secret,
|
|
81
|
+
salt,
|
|
82
|
+
contract: new SchnorrAccountContract(signingKey),
|
|
83
|
+
};
|
|
84
|
+
return this.createAccount(accountData);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
createECDSARAccount(secret: Fr, salt: Fr, signingKey: Buffer): Promise<AccountManager> {
|
|
88
|
+
const accountData = {
|
|
89
|
+
secret,
|
|
90
|
+
salt,
|
|
91
|
+
contract: new EcdsaRAccountContract(signingKey),
|
|
92
|
+
};
|
|
93
|
+
return this.createAccount(accountData);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
createECDSAKAccount(secret: Fr, salt: Fr, signingKey: Buffer): Promise<AccountManager> {
|
|
97
|
+
const accountData = {
|
|
98
|
+
secret,
|
|
99
|
+
salt,
|
|
100
|
+
contract: new EcdsaKAccountContract(signingKey),
|
|
101
|
+
};
|
|
102
|
+
return this.createAccount(accountData);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async getFakeAccountDataFor(address: AztecAddress) {
|
|
106
|
+
const originalAccount = await this.getAccountFromAddress(address);
|
|
107
|
+
if (originalAccount instanceof SignerlessAccount) {
|
|
108
|
+
throw new Error(`Cannot create fake account data for SignerlessAccount at address: ${address}`);
|
|
109
|
+
}
|
|
110
|
+
const originalAddress = (originalAccount as Account).getCompleteAddress();
|
|
111
|
+
const contractInstance = await this.pxe.getContractInstance(originalAddress.address);
|
|
112
|
+
if (!contractInstance) {
|
|
113
|
+
throw new Error(`No contract instance found for address: ${originalAddress.address}`);
|
|
114
|
+
}
|
|
115
|
+
const stubAccount = createStubAccount(originalAddress);
|
|
116
|
+
const instance = await getContractInstanceFromInstantiationParams(StubAccountContractArtifact, {
|
|
117
|
+
salt: Fr.random(),
|
|
118
|
+
});
|
|
119
|
+
return {
|
|
120
|
+
account: stubAccount,
|
|
121
|
+
instance,
|
|
122
|
+
artifact: StubAccountContractArtifact,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
protected accounts: Map<string, Account> = new Map();
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Toggle for running "simulated simulations" when calling simulateTx.
|
|
129
|
+
*
|
|
130
|
+
* When this flag is true, simulateViaEntrypoint constructs a request using a fake account
|
|
131
|
+
* (and accepts contract overrides on the input) and the PXE emulates kernel effects without
|
|
132
|
+
* generating kernel witnesses. When false, simulateViaEntrypoint defers to the standard
|
|
133
|
+
* simulation path via the real account entrypoint.
|
|
134
|
+
*/
|
|
135
|
+
private simulatedSimulations = false;
|
|
136
|
+
|
|
137
|
+
enableSimulatedSimulations() {
|
|
138
|
+
this.simulatedSimulations = true;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
disableSimulatedSimulations() {
|
|
142
|
+
this.simulatedSimulations = false;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
setMinFeePadding(value?: number) {
|
|
146
|
+
this.minFeePadding = value ?? 0.5;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
protected getAccountFromAddress(address: AztecAddress): Promise<Account> {
|
|
150
|
+
let account: Account | undefined;
|
|
151
|
+
if (address.equals(AztecAddress.ZERO)) {
|
|
152
|
+
account = new SignerlessAccount();
|
|
153
|
+
} else {
|
|
154
|
+
account = this.accounts.get(address?.toString() ?? '');
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (!account) {
|
|
158
|
+
throw new Error(`Account not found in wallet for address: ${address}`);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return Promise.resolve(account);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
getAccounts() {
|
|
165
|
+
return Promise.resolve(Array.from(this.accounts.values()).map(acc => ({ alias: '', item: acc.getAddress() })));
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
async createAccount(accountData?: AccountData): Promise<AccountManager> {
|
|
169
|
+
const secret = accountData?.secret ?? Fr.random();
|
|
170
|
+
const salt = accountData?.salt ?? Fr.random();
|
|
171
|
+
const contract = accountData?.contract ?? new SchnorrAccountContract(GrumpkinScalar.random());
|
|
172
|
+
|
|
173
|
+
const accountManager = await AccountManager.create(this, secret, contract, salt);
|
|
174
|
+
|
|
175
|
+
const instance = accountManager.getInstance();
|
|
176
|
+
const artifact = await contract.getContractArtifact();
|
|
177
|
+
|
|
178
|
+
await this.registerContract(instance, artifact, secret);
|
|
179
|
+
|
|
180
|
+
this.accounts.set(accountManager.address.toString(), await accountManager.getAccount());
|
|
181
|
+
|
|
182
|
+
return accountManager;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
lookupValidity(
|
|
186
|
+
onBehalfOf: AztecAddress,
|
|
187
|
+
intent: IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
|
|
188
|
+
witness: AuthWitness,
|
|
189
|
+
): Promise<{
|
|
190
|
+
isValidInPrivate: boolean;
|
|
191
|
+
isValidInPublic: boolean;
|
|
192
|
+
}> {
|
|
193
|
+
return lookupValidity(this, onBehalfOf, intent, witness);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
public setPublicAuthWit(
|
|
197
|
+
from: AztecAddress,
|
|
198
|
+
messageHashOrIntent: Fr | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
|
|
199
|
+
authorized: boolean,
|
|
200
|
+
): Promise<SetPublicAuthwitContractInteraction> {
|
|
201
|
+
return SetPublicAuthwitContractInteraction.create(this, from, messageHashOrIntent, authorized);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
public override async createAuthWit(
|
|
205
|
+
from: AztecAddress,
|
|
206
|
+
intent: IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
|
|
207
|
+
): Promise<AuthWitness> {
|
|
208
|
+
const account = await this.getAccountFromAddress(from);
|
|
209
|
+
const chainInfo = await this.getChainInfo();
|
|
210
|
+
let intentInnerHash: IntentInnerHash;
|
|
211
|
+
if ('caller' in intent) {
|
|
212
|
+
const call = isContractFunctionInteractionCallIntent(intent)
|
|
213
|
+
? await intent.action.getFunctionCall()
|
|
214
|
+
: intent.call;
|
|
215
|
+
const innerHash = await computeInnerAuthWitHashFromAction(intent.caller, call);
|
|
216
|
+
intentInnerHash = { innerHash, consumer: call.to };
|
|
217
|
+
} else {
|
|
218
|
+
intentInnerHash = intent;
|
|
219
|
+
}
|
|
220
|
+
return account.createAuthWit(intentInnerHash, chainInfo);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Override simulateViaEntrypoint to use fake accounts for kernelless simulation
|
|
225
|
+
* when simulatedSimulations is enabled. Otherwise falls through to the real entrypoint path.
|
|
226
|
+
*/
|
|
227
|
+
protected override async simulateViaEntrypoint(
|
|
228
|
+
executionPayload: ExecutionPayload,
|
|
229
|
+
from: AztecAddress,
|
|
230
|
+
feeOptions: FeeOptions,
|
|
231
|
+
scopes: AccessScopes,
|
|
232
|
+
skipTxValidation?: boolean,
|
|
233
|
+
skipFeeEnforcement?: boolean,
|
|
234
|
+
): Promise<TxSimulationResult> {
|
|
235
|
+
if (!this.simulatedSimulations) {
|
|
236
|
+
return super.simulateViaEntrypoint(
|
|
237
|
+
executionPayload,
|
|
238
|
+
from,
|
|
239
|
+
feeOptions,
|
|
240
|
+
scopes,
|
|
241
|
+
skipTxValidation,
|
|
242
|
+
skipFeeEnforcement,
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
247
|
+
const executionOptions: DefaultAccountEntrypointOptions = {
|
|
248
|
+
txNonce: Fr.random(),
|
|
249
|
+
cancellable: this.cancellableTransactions,
|
|
250
|
+
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions,
|
|
251
|
+
};
|
|
252
|
+
const finalExecutionPayload = feeExecutionPayload
|
|
253
|
+
? mergeExecutionPayloads([feeExecutionPayload, executionPayload])
|
|
254
|
+
: executionPayload;
|
|
255
|
+
const { account: fromAccount, instance, artifact } = await this.getFakeAccountDataFor(from);
|
|
256
|
+
const chainInfo = await this.getChainInfo();
|
|
257
|
+
const txRequest = await fromAccount.createTxExecutionRequest(
|
|
258
|
+
finalExecutionPayload,
|
|
259
|
+
feeOptions.gasSettings,
|
|
260
|
+
chainInfo,
|
|
261
|
+
executionOptions,
|
|
262
|
+
);
|
|
263
|
+
const contractOverrides = {
|
|
264
|
+
[from.toString()]: { instance, artifact },
|
|
265
|
+
};
|
|
266
|
+
return this.pxe.simulateTx(txRequest, {
|
|
267
|
+
simulatePublic: true,
|
|
268
|
+
skipFeeEnforcement: true,
|
|
269
|
+
skipTxValidation: true,
|
|
270
|
+
overrides: { contracts: contractOverrides },
|
|
271
|
+
scopes,
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
async proveTx(exec: ExecutionPayload, opts: Omit<SendOptions, 'wait'>): Promise<ProvenTx> {
|
|
276
|
+
const fee = await this.completeFeeOptions(opts.from, exec.feePayer, opts.fee?.gasSettings);
|
|
277
|
+
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(exec, opts.from, fee);
|
|
278
|
+
const txProvingResult = await this.pxe.proveTx(txRequest, this.scopesFrom(opts.from, opts.additionalScopes));
|
|
279
|
+
return new ProvenTx(
|
|
280
|
+
this.aztecNode,
|
|
281
|
+
await txProvingResult.toTx(),
|
|
282
|
+
txProvingResult.getOffchainEffects(),
|
|
283
|
+
txProvingResult.stats,
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
getTxReceipt(txHash: TxHash): Promise<TxReceipt> {
|
|
288
|
+
return this.aztecNode.getTxReceipt(txHash);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
getNotes(filter: NotesFilter): Promise<NoteDao[]> {
|
|
292
|
+
return this.pxe.debug.getNotes(filter);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
getSyncedBlockHeader(): Promise<BlockHeader> {
|
|
296
|
+
return this.pxe.getSyncedBlockHeader();
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
sync(): Promise<void> {
|
|
300
|
+
return this.pxe.debug.sync();
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
stop(): Promise<void> {
|
|
304
|
+
return this.pxe.stop();
|
|
305
|
+
}
|
|
306
|
+
}
|