@aztec/end-to-end 0.0.1-commit.9ef841308 → 0.0.1-commit.a89ec08
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/README.md +27 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +26 -12
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +3 -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 +1 -1
- package/dest/e2e_fees/fees_test.js +1 -1
- package/dest/e2e_p2p/inactivity_slash_test.d.ts +1 -1
- package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -1
- package/dest/e2e_p2p/inactivity_slash_test.js +1 -0
- package/dest/e2e_p2p/p2p_network.d.ts +1 -1
- package/dest/e2e_p2p/p2p_network.js +1 -1
- package/dest/e2e_p2p/reqresp/utils.d.ts +1 -1
- package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -1
- package/dest/e2e_p2p/reqresp/utils.js +2 -15
- package/dest/e2e_p2p/shared.d.ts +13 -1
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +23 -0
- package/dest/fixtures/authwit_proxy.d.ts +1 -1
- package/dest/fixtures/authwit_proxy.d.ts.map +1 -1
- package/dest/fixtures/authwit_proxy.js +4 -0
- package/dest/fixtures/e2e_prover_test.d.ts +3 -4
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +10 -5
- package/dest/fixtures/get_bb_config.d.ts +1 -1
- package/dest/fixtures/get_bb_config.d.ts.map +1 -1
- package/dest/fixtures/get_bb_config.js +5 -5
- package/dest/fixtures/setup.d.ts +4 -5
- package/dest/fixtures/setup.d.ts.map +1 -1
- 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 +5 -2
- package/dest/forward-compatibility/wallet_rpc_client.d.ts +7 -0
- package/dest/forward-compatibility/wallet_rpc_client.d.ts.map +1 -0
- package/dest/forward-compatibility/wallet_rpc_client.js +15 -0
- package/dest/forward-compatibility/wallet_service.d.ts +3 -0
- package/dest/forward-compatibility/wallet_service.d.ts.map +1 -0
- package/dest/forward-compatibility/wallet_service.js +109 -0
- package/dest/legacy-jest-resolver.d.cts +3 -0
- package/dest/legacy-jest-resolver.d.cts.map +1 -0
- package/dest/shared/jest_setup.js +1 -41
- package/dest/shared/submit-transactions.d.ts +1 -1
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/simulators/token_simulator.js +1 -1
- package/dest/spartan/setup_test_wallets.d.ts +1 -1
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +5 -55
- package/dest/spartan/tx_metrics.js +1 -1
- package/dest/spartan/utils/config.d.ts +1 -7
- package/dest/spartan/utils/config.d.ts.map +1 -1
- package/dest/spartan/utils/config.js +1 -3
- package/dest/spartan/utils/index.d.ts +1 -2
- package/dest/spartan/utils/index.d.ts.map +1 -1
- package/dest/spartan/utils/index.js +0 -2
- package/dest/spartan/utils/nodes.d.ts +5 -4
- 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 +16 -8
- package/dest/test-wallet/test_wallet.d.ts.map +1 -1
- package/dest/test-wallet/test_wallet.js +82 -46
- package/dest/test-wallet/worker_wallet.d.ts +4 -4
- package/dest/test-wallet/worker_wallet.d.ts.map +1 -1
- package/dest/test-wallet/worker_wallet_schema.d.ts +1 -1
- package/package.json +45 -42
- package/src/bench/client_flows/client_flows_benchmark.ts +21 -30
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +3 -6
- package/src/e2e_fees/fees_test.ts +1 -1
- package/src/e2e_p2p/inactivity_slash_test.ts +1 -0
- package/src/e2e_p2p/p2p_network.ts +1 -1
- package/src/e2e_p2p/reqresp/utils.ts +2 -23
- package/src/e2e_p2p/shared.ts +42 -0
- package/src/fixtures/authwit_proxy.ts +4 -0
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/fixtures/e2e_prover_test.ts +15 -7
- package/src/fixtures/get_bb_config.ts +6 -7
- package/src/fixtures/setup.ts +3 -4
- package/src/fixtures/token_utils.ts +4 -1
- package/src/forward-compatibility/wallet_rpc_client.ts +14 -0
- package/src/forward-compatibility/wallet_service.ts +104 -0
- package/src/legacy-jest-resolver.cjs +135 -0
- package/src/shared/jest_setup.ts +1 -51
- package/src/shared/submit-transactions.ts +4 -1
- package/src/simulators/token_simulator.ts +1 -1
- package/src/spartan/setup_test_wallets.ts +6 -55
- package/src/spartan/tx_metrics.ts +1 -1
- package/src/spartan/utils/config.ts +0 -2
- package/src/spartan/utils/index.ts +0 -3
- package/src/spartan/utils/nodes.ts +10 -15
- package/src/test-wallet/test_wallet.ts +100 -50
- package/src/test-wallet/worker_wallet.ts +3 -2
- package/dest/fixtures/elu_monitor.d.ts +0 -21
- package/dest/fixtures/elu_monitor.d.ts.map +0 -1
- package/dest/fixtures/elu_monitor.js +0 -102
- package/dest/spartan/utils/pod_logs.d.ts +0 -25
- package/dest/spartan/utils/pod_logs.d.ts.map +0 -1
- package/dest/spartan/utils/pod_logs.js +0 -74
- package/src/fixtures/elu_monitor.ts +0 -126
- package/src/spartan/utils/pod_logs.ts +0 -99
|
@@ -13,10 +13,8 @@ const {
|
|
|
13
13
|
BB_SKIP_CLEANUP = '',
|
|
14
14
|
TEMP_DIR = tmpdir(),
|
|
15
15
|
BB_WORKING_DIRECTORY = '',
|
|
16
|
-
BB_NUM_IVC_VERIFIERS = '
|
|
16
|
+
BB_NUM_IVC_VERIFIERS = '1',
|
|
17
17
|
BB_IVC_CONCURRENCY = '1',
|
|
18
|
-
BB_CHONK_VERIFY_MAX_BATCH = '16',
|
|
19
|
-
BB_CHONK_VERIFY_BATCH_CONCURRENCY = '6',
|
|
20
18
|
} = process.env;
|
|
21
19
|
|
|
22
20
|
export const getBBConfig = async (
|
|
@@ -43,15 +41,16 @@ export const getBBConfig = async (
|
|
|
43
41
|
const bbSkipCleanup = ['1', 'true'].includes(BB_SKIP_CLEANUP);
|
|
44
42
|
const cleanup = bbSkipCleanup ? () => Promise.resolve() : () => tryRmDir(directoryToCleanup);
|
|
45
43
|
|
|
44
|
+
const numIvcVerifiers = Number(BB_NUM_IVC_VERIFIERS);
|
|
45
|
+
const ivcConcurrency = Number(BB_IVC_CONCURRENCY);
|
|
46
|
+
|
|
46
47
|
return {
|
|
47
48
|
bbSkipCleanup,
|
|
48
49
|
bbBinaryPath,
|
|
49
50
|
bbWorkingDirectory,
|
|
50
51
|
cleanup,
|
|
51
|
-
numConcurrentIVCVerifiers:
|
|
52
|
-
bbIVCConcurrency:
|
|
53
|
-
bbChonkVerifyMaxBatch: Number(BB_CHONK_VERIFY_MAX_BATCH),
|
|
54
|
-
bbChonkVerifyConcurrency: Number(BB_CHONK_VERIFY_BATCH_CONCURRENCY),
|
|
52
|
+
numConcurrentIVCVerifiers: numIvcVerifiers,
|
|
53
|
+
bbIVCConcurrency: ivcConcurrency,
|
|
55
54
|
};
|
|
56
55
|
} catch (err) {
|
|
57
56
|
logger.error(`Native BB not available, error: ${err}`);
|
package/src/fixtures/setup.ts
CHANGED
|
@@ -30,8 +30,7 @@ import {
|
|
|
30
30
|
deployAztecL1Contracts,
|
|
31
31
|
} from '@aztec/ethereum/deploy-aztec-l1-contracts';
|
|
32
32
|
import type { Delayer } from '@aztec/ethereum/l1-tx-utils';
|
|
33
|
-
import { EthCheatCodes, EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
|
|
34
|
-
import type { Anvil } from '@aztec/ethereum/test';
|
|
33
|
+
import { type Anvil, EthCheatCodes, EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
|
|
35
34
|
import { BlockNumber, EpochNumber } from '@aztec/foundation/branded-types';
|
|
36
35
|
import { SecretValue } from '@aztec/foundation/config';
|
|
37
36
|
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
@@ -49,7 +48,7 @@ import type { ProverNodeConfig } from '@aztec/prover-node';
|
|
|
49
48
|
import { type PXEConfig, getPXEConfig } from '@aztec/pxe/server';
|
|
50
49
|
import type { SequencerClient } from '@aztec/sequencer-client';
|
|
51
50
|
import { type ContractInstanceWithAddress, getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
|
|
52
|
-
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
51
|
+
import type { AztecNodeAdmin, AztecNodeDebug } from '@aztec/stdlib/interfaces/client';
|
|
53
52
|
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
54
53
|
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
55
54
|
import {
|
|
@@ -210,7 +209,7 @@ export type EndToEndContext = {
|
|
|
210
209
|
/** The Anvil instance (only set if anvil was started locally). */
|
|
211
210
|
anvil: Anvil | undefined;
|
|
212
211
|
/** The Aztec Node service or client a connected to it. */
|
|
213
|
-
aztecNode: AztecNode;
|
|
212
|
+
aztecNode: AztecNode & AztecNodeDebug;
|
|
214
213
|
/** The Aztec Node as a service. */
|
|
215
214
|
aztecNodeService: AztecNodeService;
|
|
216
215
|
/** Client to the Aztec Node admin interface. */
|
|
@@ -6,8 +6,11 @@ import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
|
6
6
|
|
|
7
7
|
export async function deployToken(wallet: Wallet, admin: AztecAddress, initialAdminBalance: bigint, logger: Logger) {
|
|
8
8
|
logger.info(`Deploying Token contract...`);
|
|
9
|
-
const {
|
|
9
|
+
const {
|
|
10
|
+
receipt: { contract, instance },
|
|
11
|
+
} = await TokenContract.deploy(wallet, admin, 'TokenName', 'TokenSymbol', 18).send({
|
|
10
12
|
from: admin,
|
|
13
|
+
wait: { returnReceipt: true },
|
|
11
14
|
});
|
|
12
15
|
|
|
13
16
|
if (initialAdminBalance > 0n) {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
2
|
+
import { WalletSchema } from '@aztec/aztec.js/wallet';
|
|
3
|
+
import { createSafeJsonRpcClient, makeFetch } from '@aztec/foundation/json-rpc/client';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Creates a JSON-RPC client that connects to a remote wallet service.
|
|
7
|
+
* The returned object implements the {@link Wallet} interface, proxying all calls over HTTP to the specified URL.
|
|
8
|
+
*/
|
|
9
|
+
export function createWalletClient(url: string): Wallet {
|
|
10
|
+
return createSafeJsonRpcClient<Wallet>(url, WalletSchema, {
|
|
11
|
+
namespaceMethods: 'wallet',
|
|
12
|
+
fetch: makeFetch([1, 2, 3], false),
|
|
13
|
+
});
|
|
14
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
#!/usr/bin/env -S node --no-warnings
|
|
2
|
+
/**
|
|
3
|
+
* Standalone entrypoint that spins up a local Aztec network (L1 + node) and exposes a {@link NodeEmbeddedWallet} over
|
|
4
|
+
* JSON-RPC.
|
|
5
|
+
*
|
|
6
|
+
* Intended for forward-compatibility testing: an **old** release image runs this script so that **new** tests can send
|
|
7
|
+
* new artifacts to old runtime code (loadContractArtifact, ACIR simulator, class-ID computation, entrypoint encoding,
|
|
8
|
+
* etc.).
|
|
9
|
+
*/
|
|
10
|
+
import { getSchnorrAccountContractAddress } from '@aztec/accounts/schnorr';
|
|
11
|
+
import { getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
12
|
+
import { createLocalNetwork } from '@aztec/aztec';
|
|
13
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
14
|
+
import { WalletSchema } from '@aztec/aztec.js/wallet';
|
|
15
|
+
import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
|
|
16
|
+
import { createNamespacedSafeJsonRpcServer, startHttpRpcServer } from '@aztec/foundation/json-rpc/server';
|
|
17
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
18
|
+
import { AztecNodeApiSchema } from '@aztec/stdlib/interfaces/client';
|
|
19
|
+
import { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
20
|
+
|
|
21
|
+
const logger = createLogger('wallet-service');
|
|
22
|
+
|
|
23
|
+
const { ETHEREUM_HOSTS = 'http://localhost:8545', NODE_PORT = '8080', WALLET_PORT = '8081' } = process.env;
|
|
24
|
+
|
|
25
|
+
async function main() {
|
|
26
|
+
const l1RpcUrls = ETHEREUM_HOSTS.split(',').map(url => url.trim());
|
|
27
|
+
|
|
28
|
+
// Some tests (e.g. AMM) need 4 accounts but only 3 are funded via genesis. Generate deterministic keys for a 4th
|
|
29
|
+
// account so we can compute its address before network startup and include it in genesis funding. We cannot do this
|
|
30
|
+
// in the test because Wallet interface does not expose account creation functionality (only TestWallet exposes that
|
|
31
|
+
// but that's not used in forward compatibility testing).
|
|
32
|
+
const extraAccountSecret = Fr.fromHexString('0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef');
|
|
33
|
+
const extraAccountSalt = Fr.ZERO;
|
|
34
|
+
const extraAccountSigningKey = GrumpkinScalar.random();
|
|
35
|
+
const extraAccountAddress = await getSchnorrAccountContractAddress(
|
|
36
|
+
extraAccountSecret,
|
|
37
|
+
extraAccountSalt,
|
|
38
|
+
extraAccountSigningKey,
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
logger.info('Starting wallet service...', { l1RpcUrls });
|
|
42
|
+
|
|
43
|
+
// createLocalNetwork deploys L1 contracts, starts the node, and optionally deploys funded test accounts (when
|
|
44
|
+
// TEST_ACCOUNTS=true via env). We are not proving anything just like is done when local network is started by
|
|
45
|
+
// the `aztecStart` function. The extra account address is passed via prefundAddresses so it gets fee juice at genesis.
|
|
46
|
+
const { node, stop: stopNetwork } = await createLocalNetwork(
|
|
47
|
+
{ l1RpcUrls, realProofs: false, prefundAddresses: [extraAccountAddress.toString()] },
|
|
48
|
+
logger.info,
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
// Create an ephemeral embedded wallet backed by the local node.
|
|
52
|
+
const wallet = await EmbeddedWallet.create(node, { ephemeral: true });
|
|
53
|
+
|
|
54
|
+
// Re-register the initial test accounts so they are available via wallet.getAccounts(). createLocalNetwork deploys
|
|
55
|
+
// them onchain but uses a temporary wallet that is then stopped.
|
|
56
|
+
//
|
|
57
|
+
// We use the non-lazy import path (@aztec/accounts/testing, not /lazy) to avoid the dynamic JSON import that is
|
|
58
|
+
// incompatible with Node.js import attribute enforcement.
|
|
59
|
+
const testAccountsData = await getInitialTestAccountsData();
|
|
60
|
+
const accounts = await Promise.all(
|
|
61
|
+
testAccountsData.map(({ secret, salt, signingKey }) => wallet.createSchnorrAccount(secret, salt, signingKey)),
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
// Register and deploy the 4th account.
|
|
65
|
+
const extraAccount = await wallet.createSchnorrAccount(extraAccountSecret, extraAccountSalt, extraAccountSigningKey);
|
|
66
|
+
const deployMethod = await extraAccount.getDeployMethod();
|
|
67
|
+
await deployMethod.send({ from: accounts[0].address });
|
|
68
|
+
|
|
69
|
+
logger.info('Embedded wallet created', {
|
|
70
|
+
accounts: [...accounts, extraAccount].map(a => a.address.toString()),
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// Contract artifacts are large, so allow generous body sizes for RPC requests.
|
|
74
|
+
const rpcOptions = { maxBodySizeBytes: '50mb' };
|
|
75
|
+
|
|
76
|
+
// Serve node RPC
|
|
77
|
+
const nodeRpcServer = createNamespacedSafeJsonRpcServer({ node: [node, AztecNodeApiSchema] }, rpcOptions);
|
|
78
|
+
const nodeHttpServer = await startHttpRpcServer(nodeRpcServer, { port: NODE_PORT });
|
|
79
|
+
logger.info(`Node JSON-RPC server listening on port ${nodeHttpServer.port}`);
|
|
80
|
+
|
|
81
|
+
// Serve wallet RPC
|
|
82
|
+
const walletRpcServer = createNamespacedSafeJsonRpcServer({ wallet: [wallet, WalletSchema] }, rpcOptions);
|
|
83
|
+
const walletHttpServer = await startHttpRpcServer(walletRpcServer, { port: WALLET_PORT });
|
|
84
|
+
logger.info(`Wallet JSON-RPC server listening on port ${walletHttpServer.port}`);
|
|
85
|
+
|
|
86
|
+
const shutdown = async () => {
|
|
87
|
+
logger.info('Shutting down...');
|
|
88
|
+
nodeHttpServer.close();
|
|
89
|
+
walletHttpServer.close();
|
|
90
|
+
await wallet.stop();
|
|
91
|
+
await stopNetwork();
|
|
92
|
+
process.exit(0);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
96
|
+
process.once('SIGINT', shutdown);
|
|
97
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
98
|
+
process.once('SIGTERM', shutdown);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
main().catch(err => {
|
|
102
|
+
logger.error('Wallet service failed to start', err);
|
|
103
|
+
process.exit(1);
|
|
104
|
+
});
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// Custom Jest resolver. When CONTRACT_ARTIFACTS_VERSION is set, redirects *only* JSON artifact files under
|
|
2
|
+
// @aztec/noir-contracts.js/artifacts/, @aztec/noir-test-contracts.js/artifacts/, and @aztec/accounts/artifacts/ to a local cache of the pinned
|
|
3
|
+
// legacy versions. TypeScript wrapper classes (e.g. Token.ts) continue to load from the current workspace and use the
|
|
4
|
+
// current @aztec/aztec.js — only the artifact JSON (the deployed-contract ABI / bytecode / notes surface) is swapped.
|
|
5
|
+
//
|
|
6
|
+
// Why JSON-only: the JSON artifact is the actual interchange surface a "deployed contract" exposes. The TS wrapper is
|
|
7
|
+
// generated client-side ergonomics that's tightly coupled to the current @aztec/aztec.js API. Redirecting the wrapper
|
|
8
|
+
// would couple this test to a moving aztec.js surface and break at import time on unrelated breaking changes; we want
|
|
9
|
+
// to fail only on actual artifact-compat regressions.
|
|
10
|
+
//
|
|
11
|
+
// The cache is populated on demand by running `npm install` into .legacy-contracts/<version>/.
|
|
12
|
+
//
|
|
13
|
+
// Activated by env var; passthrough otherwise.
|
|
14
|
+
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
15
|
+
|
|
16
|
+
const path = require('path');
|
|
17
|
+
const fs = require('fs');
|
|
18
|
+
const { execSync } = require('child_process');
|
|
19
|
+
|
|
20
|
+
const version = process.env.CONTRACT_ARTIFACTS_VERSION;
|
|
21
|
+
const REDIRECTED = ['@aztec/noir-contracts.js', '@aztec/noir-test-contracts.js', '@aztec/accounts'];
|
|
22
|
+
|
|
23
|
+
// Jest sets rootDir to <e2e>/src; this file lives there too.
|
|
24
|
+
const e2eRoot = path.resolve(__dirname, '..');
|
|
25
|
+
const cacheRoot = version ? path.join(e2eRoot, '.legacy-contracts', version) : null;
|
|
26
|
+
|
|
27
|
+
function pkgJsonPath(name) {
|
|
28
|
+
return path.join(cacheRoot, 'node_modules', name, 'package.json');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function ensureCache() {
|
|
32
|
+
const missing = REDIRECTED.some(p => !fs.existsSync(pkgJsonPath(p)));
|
|
33
|
+
if (!missing) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
fs.mkdirSync(cacheRoot, { recursive: true });
|
|
37
|
+
// Seed a standalone package.json so `npm install --prefix` treats cacheRoot as its own project. Without this, npm
|
|
38
|
+
// walks up and finds the yarn-project workspace root, which breaks on `workspace:` protocol deps and risks
|
|
39
|
+
// clobbering the monorepo's node_modules.
|
|
40
|
+
const seed = path.join(cacheRoot, 'package.json');
|
|
41
|
+
if (!fs.existsSync(seed)) {
|
|
42
|
+
fs.writeFileSync(seed, JSON.stringify({ name: 'legacy-contracts-cache', private: true }));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const specs = REDIRECTED.map(p => `${p}@${version}`).join(' ');
|
|
46
|
+
process.stderr.write(`[legacy-contracts] installing ${specs} into ${cacheRoot}\n`);
|
|
47
|
+
// --prefix: install into cacheRoot instead of cwd, so the cache is isolated from the monorepo.
|
|
48
|
+
// --no-save: don't write the installed packages back to the seeded package.json.
|
|
49
|
+
// --ignore-scripts: skip lifecycle scripts (preinstall/postinstall) of the legacy packages and their transitive
|
|
50
|
+
// deps; we only want the files on disk, not to run any build steps.
|
|
51
|
+
// --legacy-peer-deps: tolerate peer-dependency mismatches between the pinned legacy @aztec/* graph and whatever
|
|
52
|
+
// current versions npm would otherwise try to reconcile.
|
|
53
|
+
execSync(`npm install --prefix "${cacheRoot}" --no-save --ignore-scripts --legacy-peer-deps ${specs}`, {
|
|
54
|
+
stdio: 'inherit',
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// Verify versions on disk match the requested version.
|
|
58
|
+
for (const p of REDIRECTED) {
|
|
59
|
+
const onDisk = JSON.parse(fs.readFileSync(pkgJsonPath(p), 'utf8')).version;
|
|
60
|
+
if (onDisk !== version) {
|
|
61
|
+
throw new Error(`[legacy-contracts] ${p} on disk is ${onDisk}, expected ${version}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (version) {
|
|
67
|
+
ensureCache();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
let bannerPrinted = false;
|
|
71
|
+
const seen = new Set();
|
|
72
|
+
|
|
73
|
+
function printBannerOnce() {
|
|
74
|
+
if (bannerPrinted || !version) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
bannerPrinted = true;
|
|
78
|
+
const lines = ['='.repeat(60), `[legacy-contracts][jest] CONTRACT_ARTIFACTS_VERSION=${version}`];
|
|
79
|
+
for (const p of REDIRECTED) {
|
|
80
|
+
const v = JSON.parse(fs.readFileSync(pkgJsonPath(p), 'utf8')).version;
|
|
81
|
+
if (v !== version) {
|
|
82
|
+
throw new Error(`[legacy-contracts] ${p} on disk is ${v}, expected ${version}`);
|
|
83
|
+
}
|
|
84
|
+
lines.push(`[legacy-contracts][jest] redirecting ${p}/artifacts/*.json -> .legacy-contracts/${version}/...`);
|
|
85
|
+
}
|
|
86
|
+
lines.push('='.repeat(60));
|
|
87
|
+
process.stderr.write(lines.join('\n') + '\n');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Match a resolved absolute path against the workspace artifacts dirs and return the legacy cache equivalent, or null
|
|
91
|
+
// if it's not an artifact path we should redirect.
|
|
92
|
+
function legacyArtifactPath(resolved) {
|
|
93
|
+
if (!resolved.endsWith('.json')) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
for (const pkg of REDIRECTED) {
|
|
97
|
+
// pkg = '@aztec/noir-contracts.js' -> match '/noir-contracts.js/artifacts/'
|
|
98
|
+
const dirName = pkg.split('/')[1];
|
|
99
|
+
const marker = `/${dirName}/artifacts/`;
|
|
100
|
+
const idx = resolved.indexOf(marker);
|
|
101
|
+
if (idx === -1) {
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
const basename = resolved.slice(idx + marker.length);
|
|
105
|
+
return path.join(cacheRoot, 'node_modules', pkg, 'artifacts', basename);
|
|
106
|
+
}
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
module.exports = function legacyResolver(request, options) {
|
|
111
|
+
// Always run the default resolver first. We only inspect (and possibly rewrite) the *result*; this catches both
|
|
112
|
+
// bare-specifier imports of `@aztec/noir-contracts.js/artifacts/foo.json` and the relative `../artifacts/foo.json`
|
|
113
|
+
// imports inside the workspace TS wrapper classes — both resolve to the same workspace artifact path that we then
|
|
114
|
+
// redirect.
|
|
115
|
+
const resolved = options.defaultResolver(request, options);
|
|
116
|
+
if (!version) {
|
|
117
|
+
return resolved;
|
|
118
|
+
}
|
|
119
|
+
printBannerOnce();
|
|
120
|
+
const legacy = legacyArtifactPath(resolved);
|
|
121
|
+
if (!legacy) {
|
|
122
|
+
return resolved;
|
|
123
|
+
}
|
|
124
|
+
if (!fs.existsSync(legacy)) {
|
|
125
|
+
throw new Error(
|
|
126
|
+
`[legacy-contracts] artifact ${path.basename(legacy)} not present in legacy cache @${version}; ` +
|
|
127
|
+
`the contract may have been added after that release. Pin a newer CONTRACT_ARTIFACTS_VERSION or skip this test.`,
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
if (!seen.has(resolved)) {
|
|
131
|
+
seen.add(resolved);
|
|
132
|
+
process.stderr.write(`[legacy-contracts][jest] redirected ${path.basename(legacy)} -> ${legacy}\n`);
|
|
133
|
+
}
|
|
134
|
+
return legacy;
|
|
135
|
+
};
|
package/src/shared/jest_setup.ts
CHANGED
|
@@ -1,19 +1,8 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/aztec.js/log';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import { readlinkSync } from 'fs';
|
|
3
|
+
import { beforeEach, expect } from '@jest/globals';
|
|
5
4
|
import { basename } from 'path';
|
|
6
5
|
|
|
7
|
-
import { EluMonitor } from '../fixtures/elu_monitor.js';
|
|
8
|
-
|
|
9
|
-
const eluMonitor = process.env.ELU_MONITOR_FILE
|
|
10
|
-
? new EluMonitor(process.env.ELU_MONITOR_FILE, Number(process.env.ELU_MONITOR_INTERVAL_MS) || undefined)
|
|
11
|
-
: undefined;
|
|
12
|
-
|
|
13
|
-
if (eluMonitor) {
|
|
14
|
-
process.on('exit', () => eluMonitor.stop());
|
|
15
|
-
}
|
|
16
|
-
|
|
17
6
|
beforeEach(() => {
|
|
18
7
|
const { testPath, currentTestName } = expect.getState();
|
|
19
8
|
if (!testPath || !currentTestName) {
|
|
@@ -21,43 +10,4 @@ beforeEach(() => {
|
|
|
21
10
|
}
|
|
22
11
|
const logger = createLogger(`e2e:${basename(testPath).replace('.test.ts', '')}`);
|
|
23
12
|
logger.info(`Running test: ${currentTestName}`);
|
|
24
|
-
eluMonitor?.startTest(currentTestName);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
afterEach(() => {
|
|
28
|
-
eluMonitor?.stopTest();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
// Log leaked handles after all tests complete. This runs after test-level afterAll hooks,
|
|
32
|
-
// so any handles still alive at this point were not properly cleaned up during teardown.
|
|
33
|
-
// This diagnostic helps identify the source of exit hangs without masking them.
|
|
34
|
-
afterAll(() => {
|
|
35
|
-
const handles = (process as any)._getActiveHandles();
|
|
36
|
-
if (handles.length > 0) {
|
|
37
|
-
const details = handles.map((h: any) => {
|
|
38
|
-
const type = h?.constructor?.name ?? typeof h;
|
|
39
|
-
const fd = h?.fd ?? h?._handle?.fd ?? '?';
|
|
40
|
-
const destroyed = h?.destroyed ?? '?';
|
|
41
|
-
const hasRef = typeof h?.hasRef === 'function' ? h.hasRef() : '?';
|
|
42
|
-
const localAddr = h?.localAddress ?? '';
|
|
43
|
-
const remoteAddr = h?.remoteAddress ?? '';
|
|
44
|
-
const localPort = h?.localPort ?? '';
|
|
45
|
-
const remotePort = h?.remotePort ?? '';
|
|
46
|
-
const proto = Object.getPrototypeOf(h)?.constructor?.name ?? '?';
|
|
47
|
-
const keys = Object.keys(h).slice(0, 10).join(',');
|
|
48
|
-
let fdTarget = '';
|
|
49
|
-
if (typeof fd === 'number') {
|
|
50
|
-
try {
|
|
51
|
-
fdTarget = ` -> ${readlinkSync(`/proc/self/fd/${fd}`)}`;
|
|
52
|
-
} catch {
|
|
53
|
-
// ignore
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return ` ${type}(fd=${fd}, destroyed=${destroyed}, hasRef=${hasRef}${fdTarget}) proto=${proto} addr=${localAddr}:${localPort}->${remoteAddr}:${remotePort} keys=[${keys}]`;
|
|
57
|
-
});
|
|
58
|
-
process.stderr.write(
|
|
59
|
-
`\n[jest_setup] WARNING: ${handles.length} handle(s) still active after teardown:\n${details.join('\n')}\n` +
|
|
60
|
-
`These may prevent Jest from exiting. Investigate and fix the leak.\n\n`,
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
13
|
});
|
|
@@ -19,7 +19,10 @@ export const submitTxsTo = async (
|
|
|
19
19
|
times(numTxs, async () => {
|
|
20
20
|
const accountManager = await wallet.createSchnorrAccount(Fr.random(), Fr.random(), GrumpkinScalar.random());
|
|
21
21
|
const deployMethod = await accountManager.getDeployMethod();
|
|
22
|
-
const { txHash } = await deployMethod.send({
|
|
22
|
+
const { txHash } = await deployMethod.send({
|
|
23
|
+
from: submitter,
|
|
24
|
+
wait: NO_WAIT,
|
|
25
|
+
});
|
|
23
26
|
|
|
24
27
|
logger.info(`Tx sent with hash ${txHash}`);
|
|
25
28
|
const receipt: TxReceipt = await wallet.getTxReceipt(txHash);
|
|
@@ -110,7 +110,7 @@ export class TokenSimulator {
|
|
|
110
110
|
chunk(calls, 5).map(batch => new BatchCall(this.defaultWallet, batch).simulate({ from: this.defaultAddress })),
|
|
111
111
|
)
|
|
112
112
|
)
|
|
113
|
-
.
|
|
113
|
+
.flat()
|
|
114
114
|
.map(r => r.result);
|
|
115
115
|
expect(results[0]).toEqual(this.totalSupply);
|
|
116
116
|
|
|
@@ -11,7 +11,7 @@ import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
|
11
11
|
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
12
12
|
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
13
13
|
import type { Logger } from '@aztec/foundation/log';
|
|
14
|
-
import {
|
|
14
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
15
15
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
16
16
|
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
17
17
|
import { registerInitialLocalNetworkAccountsInWallet } from '@aztec/wallets/testing';
|
|
@@ -139,8 +139,8 @@ async function deployAccountWithDiagnostics(
|
|
|
139
139
|
): Promise<void> {
|
|
140
140
|
const deployMethod = await account.getDeployMethod();
|
|
141
141
|
let txHash;
|
|
142
|
-
let gasSettings: any;
|
|
143
142
|
try {
|
|
143
|
+
let gasSettings;
|
|
144
144
|
if (estimateGas) {
|
|
145
145
|
const sim = await deployMethod.simulate({ from: NO_FROM, fee: { paymentMethod } });
|
|
146
146
|
gasSettings = sim.estimatedGas;
|
|
@@ -170,51 +170,6 @@ async function deployAccountWithDiagnostics(
|
|
|
170
170
|
});
|
|
171
171
|
throw error;
|
|
172
172
|
}
|
|
173
|
-
|
|
174
|
-
// Track the tx hash across retries so we don't re-send when the previous tx is still pending.
|
|
175
|
-
let sentTxHash: { txHash: any } | undefined;
|
|
176
|
-
|
|
177
|
-
await retry(
|
|
178
|
-
async () => {
|
|
179
|
-
// Check if already deployed (handles case where previous attempt succeeded but waitForTx timed out)
|
|
180
|
-
const existing = await aztecNode.getContract(account.address);
|
|
181
|
-
if (existing) {
|
|
182
|
-
logger.info(`${accountLabel} already deployed at ${account.address}, skipping`);
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// If we already sent a tx, check if it was dropped before deciding to re-send.
|
|
187
|
-
if (sentTxHash) {
|
|
188
|
-
const prevReceipt = await aztecNode.getTxReceipt(sentTxHash.txHash);
|
|
189
|
-
if (prevReceipt.isDropped()) {
|
|
190
|
-
logger.info(`${accountLabel} previous tx ${sentTxHash.txHash} was dropped, re-sending`);
|
|
191
|
-
sentTxHash = undefined;
|
|
192
|
-
} else {
|
|
193
|
-
logger.info(`${accountLabel} previous tx ${sentTxHash.txHash} still pending, waiting again...`);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
if (!sentTxHash) {
|
|
198
|
-
const deployResult = await deployMethod.send({
|
|
199
|
-
from: AztecAddress.ZERO,
|
|
200
|
-
fee: { paymentMethod, gasSettings },
|
|
201
|
-
wait: NO_WAIT,
|
|
202
|
-
});
|
|
203
|
-
sentTxHash = { txHash: deployResult.txHash };
|
|
204
|
-
logger.info(`${accountLabel} tx sent`, { txHash: sentTxHash.txHash.toString() });
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
const receipt = await waitForTx(aztecNode, sentTxHash.txHash, { timeout: 600 });
|
|
208
|
-
if (receipt.isDropped()) {
|
|
209
|
-
sentTxHash = undefined;
|
|
210
|
-
throw new Error(`${accountLabel} tx was dropped, retrying...`);
|
|
211
|
-
}
|
|
212
|
-
logger.info(`${accountLabel} deployed at ${account.address}`);
|
|
213
|
-
},
|
|
214
|
-
`deploy ${accountLabel}`,
|
|
215
|
-
makeBackoff([1, 2, 4, 8, 16]),
|
|
216
|
-
logger,
|
|
217
|
-
);
|
|
218
173
|
}
|
|
219
174
|
|
|
220
175
|
async function deployAccountsInBatches(
|
|
@@ -391,18 +346,14 @@ async function deployTokenAndMint(
|
|
|
391
346
|
logger: Logger,
|
|
392
347
|
) {
|
|
393
348
|
logger.verbose(`Deploying TokenContract...`);
|
|
394
|
-
const {
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
TOKEN_NAME,
|
|
398
|
-
TOKEN_SYMBOL,
|
|
399
|
-
TOKEN_DECIMALS,
|
|
400
|
-
).send({
|
|
349
|
+
const {
|
|
350
|
+
receipt: { contract: tokenContract },
|
|
351
|
+
} = await TokenContract.deploy(wallet, admin, TOKEN_NAME, TOKEN_SYMBOL, TOKEN_DECIMALS).send({
|
|
401
352
|
from: admin,
|
|
402
353
|
fee: {
|
|
403
354
|
paymentMethod,
|
|
404
355
|
},
|
|
405
|
-
wait: { timeout: 600 },
|
|
356
|
+
wait: { timeout: 600, returnReceipt: true },
|
|
406
357
|
});
|
|
407
358
|
|
|
408
359
|
const tokenAddress = tokenContract.address;
|
|
@@ -8,7 +8,6 @@ const logger = createLogger('e2e:k8s-utils');
|
|
|
8
8
|
const testConfigSchema = z.object({
|
|
9
9
|
NAMESPACE: z.string().default('scenario'),
|
|
10
10
|
REAL_VERIFIER: schemas.Boolean.optional().default(true),
|
|
11
|
-
DEBUG_FORCE_TX_PROOF_VERIFICATION: schemas.Boolean.optional().default(true),
|
|
12
11
|
CREATE_ETH_DEVNET: schemas.Boolean.optional().default(false),
|
|
13
12
|
L1_RPC_URLS_JSON: z.string().optional(),
|
|
14
13
|
L1_ACCOUNT_MNEMONIC: z.string().optional(),
|
|
@@ -17,7 +16,6 @@ const testConfigSchema = z.object({
|
|
|
17
16
|
AZTEC_PROOF_SUBMISSION_WINDOW: z.coerce.number().optional().default(5),
|
|
18
17
|
AZTEC_LAG_IN_EPOCHS_FOR_VALIDATOR_SET: z.coerce.number().optional().default(2),
|
|
19
18
|
FUNDING_PRIVATE_KEY: z.string().optional(),
|
|
20
|
-
AZTEC_ADMIN_API_KEY: z.string().optional(),
|
|
21
19
|
});
|
|
22
20
|
|
|
23
21
|
export type TestConfig = z.infer<typeof testConfigSchema>;
|
|
@@ -66,6 +66,3 @@ export { getPublicViemClient, getL1DeploymentAddresses, getNodeClient } from './
|
|
|
66
66
|
|
|
67
67
|
// Health checks
|
|
68
68
|
export { ChainHealth, type ChainHealthSnapshot } from './health.js';
|
|
69
|
-
|
|
70
|
-
// Pod log extraction
|
|
71
|
-
export { type BlockBuiltLogEntry, fetchBlockBuiltLogs } from './pod_logs.js';
|
|
@@ -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);
|
|
177
177
|
return { result: await fn(client), process };
|
|
178
178
|
} catch (err) {
|
|
179
179
|
// Kill the port-forward before retrying
|
|
@@ -255,18 +255,21 @@ export async function initHADb(namespace: string): Promise<void> {
|
|
|
255
255
|
}
|
|
256
256
|
|
|
257
257
|
/**
|
|
258
|
-
*
|
|
259
|
-
*
|
|
258
|
+
* Enables or disables probabilistic transaction dropping on validators and waits for rollout.
|
|
259
|
+
* Wired to env vars P2P_DROP_TX and P2P_DROP_TX_CHANCE via Helm values.
|
|
260
260
|
*/
|
|
261
261
|
export async function setValidatorTxDrop({
|
|
262
262
|
namespace,
|
|
263
|
+
enabled,
|
|
263
264
|
probability,
|
|
264
265
|
logger: log,
|
|
265
266
|
}: {
|
|
266
267
|
namespace: string;
|
|
268
|
+
enabled: boolean;
|
|
267
269
|
probability: number;
|
|
268
270
|
logger: Logger;
|
|
269
271
|
}) {
|
|
272
|
+
const drop = enabled ? 'true' : 'false';
|
|
270
273
|
const prob = String(probability);
|
|
271
274
|
|
|
272
275
|
const selectors = ['app.kubernetes.io/name=validator', 'app.kubernetes.io/component=validator', 'app=validator'];
|
|
@@ -281,7 +284,7 @@ export async function setValidatorTxDrop({
|
|
|
281
284
|
if (names.length === 0) {
|
|
282
285
|
continue;
|
|
283
286
|
}
|
|
284
|
-
const cmd = `kubectl set env statefulset -l ${selector} -n ${namespace} P2P_DROP_TX_CHANCE=${prob}`;
|
|
287
|
+
const cmd = `kubectl set env statefulset -l ${selector} -n ${namespace} P2P_DROP_TX=${drop} P2P_DROP_TX_CHANCE=${prob}`;
|
|
285
288
|
log.info(`command: ${cmd}`);
|
|
286
289
|
await execAsync(cmd);
|
|
287
290
|
updated = true;
|
|
@@ -363,24 +366,16 @@ export async function enableValidatorDynamicBootNode(
|
|
|
363
366
|
*/
|
|
364
367
|
export async function rollAztecPods(namespace: string, clearState: boolean = false) {
|
|
365
368
|
// 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')
|
|
367
369
|
const podComponents = [
|
|
368
370
|
'p2p-bootstrap',
|
|
369
371
|
'prover-node',
|
|
370
372
|
'prover-broker',
|
|
371
373
|
'prover-agent',
|
|
372
374
|
'sequencer-node',
|
|
373
|
-
'rpc
|
|
374
|
-
'validator-ha-db',
|
|
375
|
-
];
|
|
376
|
-
const pvcComponents = [
|
|
377
|
-
'p2p-bootstrap',
|
|
378
|
-
'prover-node',
|
|
379
|
-
'prover-broker',
|
|
380
|
-
'sequencer-node',
|
|
381
|
-
'rpc-node',
|
|
375
|
+
'rpc',
|
|
382
376
|
'validator-ha-db',
|
|
383
377
|
];
|
|
378
|
+
const pvcComponents = ['p2p-bootstrap', 'prover-node', 'prover-broker', 'sequencer-node', 'rpc', 'validator-ha-db'];
|
|
384
379
|
// StatefulSet components that need to be scaled down before PVC deletion
|
|
385
380
|
// Note: validators use 'sequencer-node' as component label, not 'validator'
|
|
386
381
|
const statefulSetComponents = [
|
|
@@ -388,7 +383,7 @@ export async function rollAztecPods(namespace: string, clearState: boolean = fal
|
|
|
388
383
|
'prover-node',
|
|
389
384
|
'prover-broker',
|
|
390
385
|
'sequencer-node',
|
|
391
|
-
'rpc
|
|
386
|
+
'rpc',
|
|
392
387
|
'validator-ha-db',
|
|
393
388
|
];
|
|
394
389
|
|