@aztec/end-to-end 0.0.1-commit.d431d1c → 0.0.1-commit.d939eb5aa
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 +2 -2
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +25 -17
- package/dest/bench/client_flows/config.d.ts +2 -2
- package/dest/bench/client_flows/config.d.ts.map +1 -1
- package/dest/bench/client_flows/config.js +18 -0
- package/dest/bench/utils.d.ts +5 -4
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +13 -8
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +6 -3
- 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 +28 -19
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +2 -2
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +3 -2
- package/dest/e2e_deploy_contract/deploy_test.d.ts +2 -2
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.d.ts +17 -7
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +92 -42
- package/dest/e2e_fees/bridging_race.notest.js +1 -1
- package/dest/e2e_fees/fees_test.d.ts +2 -2
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +25 -18
- package/dest/e2e_l1_publisher/write_json.d.ts +4 -3
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
- package/dest/e2e_l1_publisher/write_json.js +1 -7
- package/dest/e2e_nested_contract/nested_contract_test.js +4 -6
- package/dest/e2e_p2p/inactivity_slash_test.js +3 -3
- package/dest/e2e_p2p/p2p_network.d.ts +9 -10
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +43 -21
- package/dest/e2e_p2p/reqresp/utils.d.ts +22 -0
- package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -0
- package/dest/e2e_p2p/reqresp/utils.js +190 -0
- package/dest/e2e_p2p/shared.d.ts +30 -12
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +62 -60
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts +2 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts.map +1 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.js +184 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts +18 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts.map +1 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.js +120 -0
- package/dest/e2e_token_contract/token_contract_test.d.ts +4 -2
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +20 -10
- 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 +34 -0
- package/dest/fixtures/e2e_prover_test.d.ts +7 -6
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +40 -49
- 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/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/ha_setup.d.ts +71 -0
- package/dest/fixtures/ha_setup.d.ts.map +1 -0
- package/dest/fixtures/ha_setup.js +116 -0
- package/dest/fixtures/index.d.ts +2 -1
- package/dest/fixtures/index.d.ts.map +1 -1
- package/dest/fixtures/index.js +1 -0
- package/dest/fixtures/setup.d.ts +57 -31
- package/dest/fixtures/setup.d.ts.map +1 -1
- package/dest/fixtures/setup.js +105 -178
- package/dest/fixtures/setup_p2p_test.d.ts +18 -11
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +43 -32
- 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 +7 -6
- package/dest/legacy-jest-resolver.d.cts +3 -0
- package/dest/legacy-jest-resolver.d.cts.map +1 -0
- package/dest/shared/cross_chain_test_harness.d.ts +3 -4
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +24 -24
- package/dest/shared/gas_portal_test_harness.js +3 -3
- 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 +41 -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 +4 -4
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/submit-transactions.js +9 -11
- package/dest/shared/uniswap_l1_l2.d.ts +1 -1
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +27 -28
- package/dest/simulators/lending_simulator.d.ts +1 -1
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +6 -6
- 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 +3 -24
- package/dest/spartan/setup_test_wallets.d.ts +12 -3
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +130 -42
- package/dest/spartan/tx_metrics.d.ts +38 -2
- package/dest/spartan/tx_metrics.d.ts.map +1 -1
- package/dest/spartan/tx_metrics.js +179 -5
- package/dest/spartan/utils/bot.d.ts +28 -0
- package/dest/spartan/utils/bot.d.ts.map +1 -0
- package/dest/spartan/utils/bot.js +142 -0
- package/dest/spartan/utils/chaos.d.ts +79 -0
- package/dest/spartan/utils/chaos.d.ts.map +1 -0
- package/dest/spartan/utils/chaos.js +142 -0
- package/dest/spartan/utils/clients.d.ts +39 -0
- package/dest/spartan/utils/clients.d.ts.map +1 -0
- package/dest/spartan/utils/clients.js +90 -0
- package/dest/spartan/utils/config.d.ts +45 -0
- package/dest/spartan/utils/config.d.ts.map +1 -0
- package/dest/spartan/utils/config.js +23 -0
- package/dest/spartan/utils/health.d.ts +63 -0
- package/dest/spartan/utils/health.d.ts.map +1 -0
- package/dest/spartan/utils/health.js +202 -0
- package/dest/spartan/utils/helm.d.ts +15 -0
- package/dest/spartan/utils/helm.d.ts.map +1 -0
- package/dest/spartan/utils/helm.js +47 -0
- package/dest/spartan/utils/index.d.ts +11 -0
- package/dest/spartan/utils/index.d.ts.map +1 -0
- package/dest/spartan/utils/index.js +22 -0
- package/dest/spartan/utils/k8s.d.ts +128 -0
- package/dest/spartan/utils/k8s.d.ts.map +1 -0
- package/dest/spartan/utils/k8s.js +381 -0
- package/dest/spartan/utils/nodes.d.ts +40 -0
- package/dest/spartan/utils/nodes.d.ts.map +1 -0
- package/dest/spartan/utils/nodes.js +461 -0
- package/dest/spartan/utils/pod_logs.d.ts +25 -0
- package/dest/spartan/utils/pod_logs.d.ts.map +1 -0
- package/dest/spartan/utils/pod_logs.js +74 -0
- package/dest/spartan/utils/scripts.d.ts +30 -0
- package/dest/spartan/utils/scripts.d.ts.map +1 -0
- package/dest/spartan/utils/scripts.js +81 -0
- package/dest/spartan/utils.d.ts +2 -260
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +1 -942
- package/dest/test-wallet/test_wallet.d.ts +84 -0
- package/dest/test-wallet/test_wallet.d.ts.map +1 -0
- package/dest/test-wallet/test_wallet.js +249 -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 +279 -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 +46 -43
- package/src/bench/client_flows/client_flows_benchmark.ts +36 -36
- package/src/bench/client_flows/config.ts +9 -1
- package/src/bench/utils.ts +15 -8
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +36 -29
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +7 -8
- package/src/e2e_deploy_contract/deploy_test.ts +3 -3
- package/src/e2e_epochs/epochs_test.ts +140 -92
- package/src/e2e_fees/bridging_race.notest.ts +2 -5
- package/src/e2e_fees/fees_test.ts +29 -41
- package/src/e2e_l1_publisher/write_json.ts +3 -8
- package/src/e2e_nested_contract/nested_contract_test.ts +7 -7
- package/src/e2e_p2p/inactivity_slash_test.ts +7 -7
- package/src/e2e_p2p/p2p_network.ts +71 -44
- package/src/e2e_p2p/reqresp/utils.ts +256 -0
- package/src/e2e_p2p/shared.ts +92 -80
- package/src/e2e_storage_proof/fixtures/storage_proof.json +915 -0
- package/src/e2e_storage_proof/fixtures/storage_proof_fetcher.ts +190 -0
- package/src/e2e_storage_proof/fixtures/storage_proof_fixture.ts +173 -0
- package/src/e2e_token_contract/token_contract_test.ts +27 -12
- package/src/fixtures/authwit_proxy.ts +54 -0
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/fixtures/e2e_prover_test.ts +49 -63
- package/src/fixtures/elu_monitor.ts +126 -0
- package/src/fixtures/fixtures.ts +10 -0
- package/src/fixtures/get_bb_config.ts +7 -6
- package/src/fixtures/ha_setup.ts +186 -0
- package/src/fixtures/index.ts +1 -0
- package/src/fixtures/setup.ts +144 -244
- package/src/fixtures/setup_p2p_test.ts +48 -52
- package/src/fixtures/token_utils.ts +7 -6
- package/src/guides/up_quick_start.sh +3 -3
- package/src/legacy-jest-resolver.cjs +135 -0
- package/src/shared/cross_chain_test_harness.ts +24 -34
- package/src/shared/gas_portal_test_harness.ts +2 -2
- package/src/shared/index.ts +1 -0
- package/src/shared/jest_setup.ts +51 -1
- package/src/shared/mock_state_view.ts +188 -0
- package/src/shared/submit-transactions.ts +11 -16
- package/src/shared/uniswap_l1_l2.ts +49 -51
- package/src/simulators/lending_simulator.ts +10 -6
- package/src/simulators/token_simulator.ts +6 -30
- package/src/spartan/setup_test_wallets.ts +183 -26
- package/src/spartan/tx_metrics.ts +153 -8
- package/src/spartan/utils/bot.ts +188 -0
- package/src/spartan/utils/chaos.ts +253 -0
- package/src/spartan/utils/clients.ts +100 -0
- package/src/spartan/utils/config.ts +29 -0
- package/src/spartan/utils/health.ts +255 -0
- package/src/spartan/utils/helm.ts +84 -0
- package/src/spartan/utils/index.ts +71 -0
- package/src/spartan/utils/k8s.ts +535 -0
- package/src/spartan/utils/nodes.ts +543 -0
- package/src/spartan/utils/pod_logs.ts +99 -0
- package/src/spartan/utils/scripts.ts +99 -0
- package/src/spartan/utils.ts +1 -1246
- package/src/test-wallet/test_wallet.ts +351 -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 +214 -0
- package/src/test-wallet/worker_wallet_schema.ts +13 -0
|
@@ -4,14 +4,12 @@
|
|
|
4
4
|
import { type AztecNodeConfig, AztecNodeService } from '@aztec/aztec-node';
|
|
5
5
|
import { range } from '@aztec/foundation/array';
|
|
6
6
|
import { SecretValue } from '@aztec/foundation/config';
|
|
7
|
-
import {
|
|
7
|
+
import { withLoggerBindings } from '@aztec/foundation/log/server';
|
|
8
8
|
import { bufferToHex } from '@aztec/foundation/string';
|
|
9
9
|
import type { DateProvider } from '@aztec/foundation/timer';
|
|
10
|
-
import type {
|
|
11
|
-
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
10
|
+
import type { GenesisData } from '@aztec/stdlib/world-state';
|
|
12
11
|
|
|
13
12
|
import getPort from 'get-port';
|
|
14
|
-
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
15
13
|
|
|
16
14
|
import { TEST_PEER_CHECK_INTERVAL_MS } from './fixtures.js';
|
|
17
15
|
import { createAndSyncProverNode, getPrivateKeyFromIndex } from './utils.js';
|
|
@@ -22,6 +20,11 @@ import { getEndToEndTestTelemetryClient } from './with_telemetry_utils.js';
|
|
|
22
20
|
// to avoid running validators with the same key
|
|
23
21
|
export const ATTESTER_PRIVATE_KEYS_START_INDEX = 3;
|
|
24
22
|
|
|
23
|
+
// Global counters for actor naming (start at 1)
|
|
24
|
+
let validatorCounter = 1;
|
|
25
|
+
let nodeCounter = 1;
|
|
26
|
+
let proverCounter = 1;
|
|
27
|
+
|
|
25
28
|
export function generatePrivateKeys(startIndex: number, numberOfKeys: number): `0x${string}`[] {
|
|
26
29
|
const privateKeys: `0x${string}`[] = [];
|
|
27
30
|
// Do not start from 0 as it is used during setup
|
|
@@ -37,17 +40,13 @@ export async function createNodes(
|
|
|
37
40
|
bootstrapNodeEnr: string,
|
|
38
41
|
numNodes: number,
|
|
39
42
|
bootNodePort: number,
|
|
40
|
-
|
|
43
|
+
genesis?: GenesisData,
|
|
41
44
|
dataDirectory?: string,
|
|
42
45
|
metricsPort?: number,
|
|
43
46
|
indexOffset = 0,
|
|
44
47
|
validatorsPerNode = 1,
|
|
45
48
|
): Promise<AztecNodeService[]> {
|
|
46
49
|
const nodePromises: Promise<AztecNodeService>[] = [];
|
|
47
|
-
const loggerIdStorage = new AsyncLocalStorage<string>();
|
|
48
|
-
const logNameHandler = (module: string) =>
|
|
49
|
-
loggerIdStorage.getStore() ? `${module}:${loggerIdStorage.getStore()}` : module;
|
|
50
|
-
addLogNameHandler(logNameHandler);
|
|
51
50
|
|
|
52
51
|
for (let i = 0; i < numNodes; i++) {
|
|
53
52
|
const index = indexOffset + i;
|
|
@@ -66,10 +65,9 @@ export async function createNodes(
|
|
|
66
65
|
port,
|
|
67
66
|
bootstrapNodeEnr,
|
|
68
67
|
validatorIndices,
|
|
69
|
-
|
|
68
|
+
genesis,
|
|
70
69
|
dataDir,
|
|
71
70
|
metricsPort,
|
|
72
|
-
loggerIdStorage,
|
|
73
71
|
);
|
|
74
72
|
nodePromises.push(nodePromise);
|
|
75
73
|
}
|
|
@@ -81,32 +79,38 @@ export async function createNodes(
|
|
|
81
79
|
throw new Error('Sequencer not found');
|
|
82
80
|
}
|
|
83
81
|
|
|
84
|
-
removeLogNameHandler(logNameHandler);
|
|
85
82
|
return nodes;
|
|
86
83
|
}
|
|
87
84
|
|
|
88
|
-
/**
|
|
85
|
+
/** Extended config type for createNode with test-specific overrides. */
|
|
86
|
+
export type CreateNodeConfig = AztecNodeConfig & {
|
|
87
|
+
/** Whether to skip starting the sequencer. */
|
|
88
|
+
dontStartSequencer?: boolean;
|
|
89
|
+
/** Override the private key (instead of deriving from addressIndex). */
|
|
90
|
+
validatorPrivateKey?: `0x${string}`;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/** Creates a P2P enabled instance of Aztec Node Service with a validator. */
|
|
89
94
|
export async function createNode(
|
|
90
|
-
config:
|
|
95
|
+
config: CreateNodeConfig,
|
|
91
96
|
dateProvider: DateProvider,
|
|
92
97
|
tcpPort: number,
|
|
93
98
|
bootstrapNode: string | undefined,
|
|
94
99
|
addressIndex: number | number[],
|
|
95
|
-
|
|
100
|
+
genesis?: GenesisData,
|
|
96
101
|
dataDirectory?: string,
|
|
97
102
|
metricsPort?: number,
|
|
98
|
-
loggerIdStorage?: AsyncLocalStorage<string>,
|
|
99
103
|
) {
|
|
100
|
-
const
|
|
104
|
+
const actorIndex = validatorCounter++;
|
|
105
|
+
return await withLoggerBindings({ actor: `validator-${actorIndex}` }, async () => {
|
|
101
106
|
const validatorConfig = await createValidatorConfig(config, bootstrapNode, tcpPort, addressIndex, dataDirectory);
|
|
102
107
|
const telemetry = await getEndToEndTestTelemetryClient(metricsPort);
|
|
103
108
|
return await AztecNodeService.createAndSync(
|
|
104
109
|
validatorConfig,
|
|
105
110
|
{ telemetry, dateProvider },
|
|
106
|
-
{
|
|
111
|
+
{ genesis, dontStartSequencer: config.dontStartSequencer },
|
|
107
112
|
);
|
|
108
|
-
};
|
|
109
|
-
return loggerIdStorage ? await loggerIdStorage.run(tcpPort.toString(), createNode) : createNode();
|
|
113
|
+
});
|
|
110
114
|
}
|
|
111
115
|
|
|
112
116
|
/** Creates a P2P enabled instance of Aztec Node Service without a validator */
|
|
@@ -115,23 +119,22 @@ export async function createNonValidatorNode(
|
|
|
115
119
|
dateProvider: DateProvider,
|
|
116
120
|
tcpPort: number,
|
|
117
121
|
bootstrapNode: string | undefined,
|
|
118
|
-
|
|
122
|
+
genesis?: GenesisData,
|
|
119
123
|
dataDirectory?: string,
|
|
120
124
|
metricsPort?: number,
|
|
121
|
-
loggerIdStorage?: AsyncLocalStorage<string>,
|
|
122
125
|
) {
|
|
123
|
-
const
|
|
126
|
+
const actorIndex = nodeCounter++;
|
|
127
|
+
return await withLoggerBindings({ actor: `node-${actorIndex}` }, async () => {
|
|
124
128
|
const p2pConfig = await createP2PConfig(baseConfig, bootstrapNode, tcpPort, dataDirectory);
|
|
125
129
|
const config: AztecNodeConfig = {
|
|
126
130
|
...p2pConfig,
|
|
127
131
|
disableValidator: true,
|
|
128
132
|
validatorPrivateKeys: undefined,
|
|
129
|
-
|
|
133
|
+
sequencerPublisherPrivateKeys: [],
|
|
130
134
|
};
|
|
131
135
|
const telemetry = await getEndToEndTestTelemetryClient(metricsPort);
|
|
132
|
-
return await AztecNodeService.createAndSync(config, { telemetry, dateProvider }, {
|
|
133
|
-
};
|
|
134
|
-
return loggerIdStorage ? await loggerIdStorage.run(tcpPort.toString(), createNode) : createNode();
|
|
136
|
+
return await AztecNodeService.createAndSync(config, { telemetry, dateProvider }, { genesis });
|
|
137
|
+
});
|
|
135
138
|
}
|
|
136
139
|
|
|
137
140
|
export async function createProverNode(
|
|
@@ -139,34 +142,26 @@ export async function createProverNode(
|
|
|
139
142
|
tcpPort: number,
|
|
140
143
|
bootstrapNode: string | undefined,
|
|
141
144
|
addressIndex: number,
|
|
142
|
-
|
|
143
|
-
|
|
145
|
+
deps: { dateProvider: DateProvider },
|
|
146
|
+
genesis?: GenesisData,
|
|
144
147
|
dataDirectory?: string,
|
|
145
148
|
metricsPort?: number,
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
+
): Promise<{ proverNode: AztecNodeService }> {
|
|
150
|
+
const actorIndex = proverCounter++;
|
|
151
|
+
return await withLoggerBindings({ actor: `prover-${actorIndex}` }, async () => {
|
|
149
152
|
const proverNodePrivateKey = getPrivateKeyFromIndex(ATTESTER_PRIVATE_KEYS_START_INDEX + addressIndex)!;
|
|
150
153
|
const telemetry = await getEndToEndTestTelemetryClient(metricsPort);
|
|
151
154
|
|
|
152
|
-
const
|
|
153
|
-
config,
|
|
154
|
-
bootstrapNode,
|
|
155
|
-
tcpPort,
|
|
156
|
-
dataDirectory,
|
|
157
|
-
);
|
|
155
|
+
const p2pConfig = await createP2PConfig(config, bootstrapNode, tcpPort, dataDirectory);
|
|
158
156
|
|
|
159
|
-
const aztecNodeRpcTxProvider = undefined;
|
|
160
157
|
return await createAndSyncProverNode(
|
|
161
158
|
bufferToHex(proverNodePrivateKey),
|
|
162
|
-
config,
|
|
163
|
-
{
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
{ ...proverNodeDeps, telemetry },
|
|
159
|
+
{ ...config, ...p2pConfig },
|
|
160
|
+
{ dataDirectory },
|
|
161
|
+
{ ...deps, telemetry },
|
|
162
|
+
{ genesis },
|
|
167
163
|
);
|
|
168
|
-
};
|
|
169
|
-
return loggerIdStorage ? await loggerIdStorage.run(tcpPort.toString(), createProverNode) : createProverNode();
|
|
164
|
+
});
|
|
170
165
|
}
|
|
171
166
|
|
|
172
167
|
export async function createP2PConfig(
|
|
@@ -192,26 +187,27 @@ export async function createP2PConfig(
|
|
|
192
187
|
}
|
|
193
188
|
|
|
194
189
|
export async function createValidatorConfig(
|
|
195
|
-
config:
|
|
190
|
+
config: CreateNodeConfig,
|
|
196
191
|
bootstrapNodeEnr?: string,
|
|
197
192
|
port?: number,
|
|
198
193
|
addressIndex: number | number[] = 1,
|
|
199
194
|
dataDirectory?: string,
|
|
200
195
|
) {
|
|
201
196
|
const addressIndices = Array.isArray(addressIndex) ? addressIndex : [addressIndex];
|
|
202
|
-
if (addressIndices.length === 0) {
|
|
197
|
+
if (addressIndices.length === 0 && !config.validatorPrivateKey) {
|
|
203
198
|
throw new Error('At least one address index must be provided to create a validator config');
|
|
204
199
|
}
|
|
205
200
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
201
|
+
// Use override private key if provided, otherwise derive from address indices
|
|
202
|
+
const attesterPrivateKeys = config.validatorPrivateKey
|
|
203
|
+
? [config.validatorPrivateKey]
|
|
204
|
+
: addressIndices.map(index => bufferToHex(getPrivateKeyFromIndex(ATTESTER_PRIVATE_KEYS_START_INDEX + index)!));
|
|
209
205
|
const p2pConfig = await createP2PConfig(config, bootstrapNodeEnr, port, dataDirectory);
|
|
210
206
|
const nodeConfig: AztecNodeConfig = {
|
|
211
207
|
...config,
|
|
212
208
|
...p2pConfig,
|
|
213
209
|
validatorPrivateKeys: new SecretValue(attesterPrivateKeys),
|
|
214
|
-
|
|
210
|
+
sequencerPublisherPrivateKeys: [new SecretValue(attesterPrivateKeys[0])],
|
|
215
211
|
};
|
|
216
212
|
|
|
217
213
|
return nodeConfig;
|
|
@@ -6,9 +6,9 @@ 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 { contract, instance } = await TokenContract.deploy(wallet, admin, 'TokenName', 'TokenSymbol', 18)
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
const { contract, instance } = await TokenContract.deploy(wallet, admin, 'TokenName', 'TokenSymbol', 18).send({
|
|
10
|
+
from: admin,
|
|
11
|
+
});
|
|
12
12
|
|
|
13
13
|
if (initialAdminBalance > 0n) {
|
|
14
14
|
await mintTokensToPrivate(contract, admin, admin, initialAdminBalance);
|
|
@@ -24,8 +24,9 @@ export async function mintTokensToPrivate(
|
|
|
24
24
|
minter: AztecAddress,
|
|
25
25
|
recipient: AztecAddress,
|
|
26
26
|
amount: bigint,
|
|
27
|
+
additionalScopes?: AztecAddress[],
|
|
27
28
|
) {
|
|
28
|
-
await token.methods.mint_to_private(recipient, amount).send({ from: minter })
|
|
29
|
+
await token.methods.mint_to_private(recipient, amount).send({ from: minter, additionalScopes });
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
export async function expectTokenBalance(
|
|
@@ -37,7 +38,7 @@ export async function expectTokenBalance(
|
|
|
37
38
|
) {
|
|
38
39
|
// Then check the balance
|
|
39
40
|
const contractWithWallet = TokenContract.at(token.address, wallet);
|
|
40
|
-
const balance = await contractWithWallet.methods.balance_of_private(owner).simulate({ from: owner });
|
|
41
|
+
const { result: balance } = await contractWithWallet.methods.balance_of_private(owner).simulate({ from: owner });
|
|
41
42
|
logger.info(`Account ${owner} balance: ${balance}`);
|
|
42
43
|
expect(balance).toBe(expectedBalance);
|
|
43
44
|
}
|
|
@@ -55,7 +56,7 @@ export async function mintNotes(
|
|
|
55
56
|
for (let mintedNotes = 0; mintedNotes < noteAmounts.length; mintedNotes += notesPerIteration) {
|
|
56
57
|
const toMint = noteAmounts.slice(mintedNotes, mintedNotes + notesPerIteration);
|
|
57
58
|
const actions = toMint.map(amt => asset.methods.mint_to_private(recipient, amt));
|
|
58
|
-
await new BatchCall(wallet, actions).send({ from: minter })
|
|
59
|
+
await new BatchCall(wallet, actions).send({ from: minter });
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
return noteAmounts.reduce((prev, curr) => prev + curr, 0n);
|
|
@@ -23,6 +23,8 @@ aztec-wallet create-account -a alice -f test0
|
|
|
23
23
|
aztec-wallet create-account -a bob -f test0
|
|
24
24
|
# docs:end:declare-accounts
|
|
25
25
|
|
|
26
|
+
aztec-wallet bridge-fee-juice 1000000000000000000000 accounts:alice --mint --no-wait
|
|
27
|
+
|
|
26
28
|
DEPLOY_OUTPUT=$(aztec-wallet deploy ../noir-contracts.js/artifacts/token_contract-Token.json --args accounts:test0 Test TST 18 -f test0)
|
|
27
29
|
TOKEN_ADDRESS=$(echo "$DEPLOY_OUTPUT" | grep -oE 'Contract deployed at 0x[0-9a-fA-F]+' | cut -d ' ' -f4)
|
|
28
30
|
echo "Deployed contract at $TOKEN_ADDRESS"
|
|
@@ -38,9 +40,7 @@ fi
|
|
|
38
40
|
|
|
39
41
|
TRANSFER_AMOUNT=42
|
|
40
42
|
|
|
41
|
-
aztec-wallet
|
|
42
|
-
|
|
43
|
-
aztec-wallet send transfer_in_private -ca last --args accounts:alice accounts:bob $TRANSFER_AMOUNT 1 -aw authwits:last -f test0
|
|
43
|
+
aztec-wallet send transfer_in_private -ca last --args accounts:alice accounts:bob $TRANSFER_AMOUNT 0 -f alice --payment method=fee_juice,claim
|
|
44
44
|
|
|
45
45
|
# Test end result
|
|
46
46
|
ALICE_BALANCE=$(aztec-wallet simulate balance_of_private -ca last --args accounts:alice -f alice)
|
|
@@ -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
|
+
};
|
|
@@ -18,7 +18,6 @@ import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses'
|
|
|
18
18
|
import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
|
|
19
19
|
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
20
20
|
import { retryUntil } from '@aztec/foundation/retry';
|
|
21
|
-
import type { FieldsOf } from '@aztec/foundation/types';
|
|
22
21
|
import { TestERC20Abi, TokenPortalAbi, TokenPortalBytecode } from '@aztec/l1-artifacts';
|
|
23
22
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
24
23
|
import { TokenBridgeContract } from '@aztec/noir-contracts.js/TokenBridge';
|
|
@@ -74,26 +73,26 @@ export async function deployAndInitializeTokenAndBridgeContracts(
|
|
|
74
73
|
});
|
|
75
74
|
|
|
76
75
|
// deploy l2 token
|
|
77
|
-
const token = await TokenContract.deploy(wallet, owner, 'TokenName', 'TokenSymbol', 18)
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
const { contract: token } = await TokenContract.deploy(wallet, owner, 'TokenName', 'TokenSymbol', 18).send({
|
|
77
|
+
from: owner,
|
|
78
|
+
});
|
|
80
79
|
|
|
81
80
|
// deploy l2 token bridge and attach to the portal
|
|
82
|
-
const bridge = await TokenBridgeContract.deploy(wallet, token.address, tokenPortalAddress)
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
const { contract: bridge } = await TokenBridgeContract.deploy(wallet, token.address, tokenPortalAddress).send({
|
|
82
|
+
from: owner,
|
|
83
|
+
});
|
|
85
84
|
|
|
86
|
-
if ((await token.methods.get_admin().simulate({ from: owner })) !== owner.toBigInt()) {
|
|
85
|
+
if ((await token.methods.get_admin().simulate({ from: owner })).result !== owner.toBigInt()) {
|
|
87
86
|
throw new Error(`Token admin is not ${owner}`);
|
|
88
87
|
}
|
|
89
88
|
|
|
90
|
-
if (!(await bridge.methods.get_config().simulate({ from: owner })).token.equals(token.address)) {
|
|
89
|
+
if (!(await bridge.methods.get_config().simulate({ from: owner })).result.token.equals(token.address)) {
|
|
91
90
|
throw new Error(`Bridge token is not ${token.address}`);
|
|
92
91
|
}
|
|
93
92
|
|
|
94
93
|
// make the bridge a minter on the token:
|
|
95
|
-
await token.methods.set_minter(bridge.address, true).send({ from: owner })
|
|
96
|
-
if ((await token.methods.is_minter(bridge.address).simulate({ from: owner })) === 1n) {
|
|
94
|
+
await token.methods.set_minter(bridge.address, true).send({ from: owner });
|
|
95
|
+
if ((await token.methods.is_minter(bridge.address).simulate({ from: owner })).result === 1n) {
|
|
97
96
|
throw new Error(`Bridge is not a minter`);
|
|
98
97
|
}
|
|
99
98
|
|
|
@@ -235,7 +234,7 @@ export class CrossChainTestHarness {
|
|
|
235
234
|
|
|
236
235
|
async mintTokensPublicOnL2(amount: bigint) {
|
|
237
236
|
this.logger.info('Minting tokens on L2 publicly');
|
|
238
|
-
await this.l2Token.methods.mint_to_public(this.ownerAddress, amount).send({ from: this.ownerAddress })
|
|
237
|
+
await this.l2Token.methods.mint_to_public(this.ownerAddress, amount).send({ from: this.ownerAddress });
|
|
239
238
|
}
|
|
240
239
|
|
|
241
240
|
async mintTokensPrivateOnL2(amount: bigint) {
|
|
@@ -246,8 +245,7 @@ export class CrossChainTestHarness {
|
|
|
246
245
|
// send a transfer tx to force through rollup with the message included
|
|
247
246
|
await this.l2Token.methods
|
|
248
247
|
.transfer_in_public(this.ownerAddress, receiverAddress, transferAmount, 0)
|
|
249
|
-
.send({ from: this.ownerAddress })
|
|
250
|
-
.wait();
|
|
248
|
+
.send({ from: this.ownerAddress });
|
|
251
249
|
}
|
|
252
250
|
|
|
253
251
|
async consumeMessageOnAztecAndMintPrivately(
|
|
@@ -257,8 +255,7 @@ export class CrossChainTestHarness {
|
|
|
257
255
|
const { recipient, claimAmount, claimSecret: secretForL2MessageConsumption, messageLeafIndex } = claim;
|
|
258
256
|
await this.l2Bridge.methods
|
|
259
257
|
.claim_private(recipient, claimAmount, secretForL2MessageConsumption, messageLeafIndex)
|
|
260
|
-
.send({ from: this.ownerAddress })
|
|
261
|
-
.wait();
|
|
258
|
+
.send({ from: this.ownerAddress });
|
|
262
259
|
}
|
|
263
260
|
|
|
264
261
|
async consumeMessageOnAztecAndMintPublicly(
|
|
@@ -268,34 +265,31 @@ export class CrossChainTestHarness {
|
|
|
268
265
|
const { claimAmount, claimSecret, messageLeafIndex } = claim;
|
|
269
266
|
await this.l2Bridge.methods
|
|
270
267
|
.claim_public(this.ownerAddress, claimAmount, claimSecret, messageLeafIndex)
|
|
271
|
-
.send({ from: this.ownerAddress })
|
|
272
|
-
.wait();
|
|
268
|
+
.send({ from: this.ownerAddress });
|
|
273
269
|
}
|
|
274
270
|
|
|
275
271
|
async withdrawPrivateFromAztecToL1(
|
|
276
272
|
withdrawAmount: bigint,
|
|
277
273
|
authwitNonce: Fr = Fr.ZERO,
|
|
278
274
|
authWitness: AuthWitness,
|
|
279
|
-
): Promise<
|
|
280
|
-
const withdrawReceipt = await this.l2Bridge.methods
|
|
275
|
+
): Promise<TxReceipt> {
|
|
276
|
+
const { receipt: withdrawReceipt } = await this.l2Bridge.methods
|
|
281
277
|
.exit_to_l1_private(this.l2Token.address, this.ethAccount, withdrawAmount, EthAddress.ZERO, authwitNonce)
|
|
282
|
-
.send({ authWitnesses: [authWitness], from: this.ownerAddress })
|
|
283
|
-
.wait();
|
|
278
|
+
.send({ authWitnesses: [authWitness], from: this.ownerAddress });
|
|
284
279
|
|
|
285
280
|
return withdrawReceipt;
|
|
286
281
|
}
|
|
287
282
|
|
|
288
|
-
async withdrawPublicFromAztecToL1(withdrawAmount: bigint, authwitNonce: Fr = Fr.ZERO): Promise<
|
|
289
|
-
const withdrawReceipt = await this.l2Bridge.methods
|
|
283
|
+
async withdrawPublicFromAztecToL1(withdrawAmount: bigint, authwitNonce: Fr = Fr.ZERO): Promise<TxReceipt> {
|
|
284
|
+
const { receipt: withdrawReceipt } = await this.l2Bridge.methods
|
|
290
285
|
.exit_to_l1_public(this.ethAccount, withdrawAmount, EthAddress.ZERO, authwitNonce)
|
|
291
|
-
.send({ from: this.ownerAddress })
|
|
292
|
-
.wait();
|
|
286
|
+
.send({ from: this.ownerAddress });
|
|
293
287
|
|
|
294
288
|
return withdrawReceipt;
|
|
295
289
|
}
|
|
296
290
|
|
|
297
291
|
async getL2PrivateBalanceOf(owner: AztecAddress) {
|
|
298
|
-
return await this.l2Token.methods.balance_of_private(owner).simulate({ from: owner });
|
|
292
|
+
return (await this.l2Token.methods.balance_of_private(owner).simulate({ from: owner })).result;
|
|
299
293
|
}
|
|
300
294
|
|
|
301
295
|
async expectPrivateBalanceOnL2(owner: AztecAddress, expectedBalance: bigint) {
|
|
@@ -305,7 +299,7 @@ export class CrossChainTestHarness {
|
|
|
305
299
|
}
|
|
306
300
|
|
|
307
301
|
async getL2PublicBalanceOf(owner: AztecAddress) {
|
|
308
|
-
return await this.l2Token.methods.balance_of_public(owner).simulate({ from: this.ownerAddress });
|
|
302
|
+
return (await this.l2Token.methods.balance_of_public(owner).simulate({ from: this.ownerAddress })).result;
|
|
309
303
|
}
|
|
310
304
|
|
|
311
305
|
async expectPublicBalanceOnL2(owner: AztecAddress, expectedBalance: bigint) {
|
|
@@ -333,18 +327,14 @@ export class CrossChainTestHarness {
|
|
|
333
327
|
|
|
334
328
|
async transferToPrivateOnL2(shieldAmount: bigint) {
|
|
335
329
|
this.logger.info('Transferring to private on L2');
|
|
336
|
-
await this.l2Token.methods
|
|
337
|
-
.transfer_to_private(this.ownerAddress, shieldAmount)
|
|
338
|
-
.send({ from: this.ownerAddress })
|
|
339
|
-
.wait();
|
|
330
|
+
await this.l2Token.methods.transfer_to_private(this.ownerAddress, shieldAmount).send({ from: this.ownerAddress });
|
|
340
331
|
}
|
|
341
332
|
|
|
342
333
|
async transferToPublicOnL2(amount: bigint, authwitNonce = Fr.ZERO) {
|
|
343
334
|
this.logger.info('Transferring tokens to public');
|
|
344
335
|
await this.l2Token.methods
|
|
345
336
|
.transfer_to_public(this.ownerAddress, this.ownerAddress, amount, authwitNonce)
|
|
346
|
-
.send({ from: this.ownerAddress })
|
|
347
|
-
.wait();
|
|
337
|
+
.send({ from: this.ownerAddress });
|
|
348
338
|
}
|
|
349
339
|
|
|
350
340
|
/**
|
|
@@ -127,11 +127,11 @@ export class GasBridgingTestHarness implements IGasBridgingTestHarness {
|
|
|
127
127
|
async consumeMessageOnAztecAndClaimPrivately(owner: AztecAddress, claimer: AztecAddress, claim: L2AmountClaim) {
|
|
128
128
|
this.logger.info('Consuming messages on L2 Privately');
|
|
129
129
|
const { claimAmount, claimSecret, messageLeafIndex } = claim;
|
|
130
|
-
await this.feeJuice.methods.claim(owner, claimAmount, claimSecret, messageLeafIndex).send({ from: claimer })
|
|
130
|
+
await this.feeJuice.methods.claim(owner, claimAmount, claimSecret, messageLeafIndex).send({ from: claimer });
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
async getL2PublicBalanceOf(owner: AztecAddress) {
|
|
134
|
-
return await this.feeJuice.methods.balance_of_public(owner).simulate({ from: owner });
|
|
134
|
+
return (await this.feeJuice.methods.balance_of_public(owner).simulate({ from: owner })).result;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
async expectPublicBalanceOnL2(owner: AztecAddress, expectedBalance: bigint) {
|
package/src/shared/index.ts
CHANGED
package/src/shared/jest_setup.ts
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/aztec.js/log';
|
|
2
2
|
|
|
3
|
-
import { beforeEach, expect } from '@jest/globals';
|
|
3
|
+
import { afterAll, afterEach, beforeEach, expect } from '@jest/globals';
|
|
4
|
+
import { readlinkSync } from 'fs';
|
|
4
5
|
import { basename } from 'path';
|
|
5
6
|
|
|
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
|
+
|
|
6
17
|
beforeEach(() => {
|
|
7
18
|
const { testPath, currentTestName } = expect.getState();
|
|
8
19
|
if (!testPath || !currentTestName) {
|
|
@@ -10,4 +21,43 @@ beforeEach(() => {
|
|
|
10
21
|
}
|
|
11
22
|
const logger = createLogger(`e2e:${basename(testPath).replace('.test.ts', '')}`);
|
|
12
23
|
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
|
+
}
|
|
13
63
|
});
|