@aztec/end-to-end 0.0.0-test.0 → 0.0.1-commit.001888fc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/bench/client_flows/benchmark.d.ts +62 -0
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/benchmark.js +281 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +79 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/client_flows_benchmark.js +329 -0
- package/dest/bench/client_flows/config.d.ts +14 -0
- package/dest/bench/client_flows/config.d.ts.map +1 -0
- package/dest/bench/client_flows/config.js +124 -0
- package/dest/bench/client_flows/data_extractor.d.ts +2 -0
- package/dest/bench/client_flows/data_extractor.d.ts.map +1 -0
- package/dest/bench/client_flows/data_extractor.js +79 -0
- package/dest/bench/utils.d.ts +16 -41
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +44 -72
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +28 -19
- 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 +125 -103
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +32 -32
- 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 +105 -104
- package/dest/e2e_deploy_contract/deploy_test.d.ts +19 -10
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +26 -27
- package/dest/e2e_epochs/epochs_test.d.ts +75 -24
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +290 -58
- package/dest/e2e_fees/bridging_race.notest.d.ts +2 -0
- package/dest/e2e_fees/bridging_race.notest.d.ts.map +1 -0
- package/dest/e2e_fees/bridging_race.notest.js +61 -0
- package/dest/e2e_fees/fees_test.d.ts +38 -23
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +169 -183
- package/dest/e2e_l1_publisher/write_json.d.ts +11 -0
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -0
- package/dest/e2e_l1_publisher/write_json.js +56 -0
- package/dest/e2e_multi_validator/utils.d.ts +12 -0
- package/dest/e2e_multi_validator/utils.d.ts.map +1 -0
- package/dest/e2e_multi_validator/utils.js +214 -0
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +15 -15
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +36 -42
- package/dest/e2e_p2p/inactivity_slash_test.d.ts +31 -0
- package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -0
- package/dest/e2e_p2p/inactivity_slash_test.js +136 -0
- package/dest/e2e_p2p/p2p_network.d.ts +282 -27
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +255 -176
- 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 +64 -8
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +200 -27
- 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 +29 -14
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +107 -75
- 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 +55 -0
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
- package/dest/fixtures/e2e_prover_test.js +271 -0
- 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 +10 -8
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +11 -5
- package/dest/fixtures/get_acvm_config.d.ts +2 -2
- package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
- package/dest/fixtures/get_acvm_config.js +3 -15
- package/dest/fixtures/get_bb_config.d.ts +2 -2
- package/dest/fixtures/get_bb_config.d.ts.map +1 -1
- package/dest/fixtures/get_bb_config.js +10 -17
- 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/l1_to_l2_messaging.d.ts +11 -7
- package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
- package/dest/fixtures/l1_to_l2_messaging.js +45 -19
- package/dest/fixtures/logging.d.ts +1 -1
- package/dest/fixtures/setup.d.ts +239 -0
- package/dest/fixtures/setup.d.ts.map +1 -0
- package/dest/fixtures/setup.js +606 -0
- package/dest/fixtures/setup_p2p_test.d.ts +23 -15
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +102 -31
- package/dest/fixtures/token_utils.d.ts +10 -4
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +33 -13
- package/dest/fixtures/utils.d.ts +5 -153
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +4 -552
- package/dest/fixtures/web3signer.d.ts +5 -0
- package/dest/fixtures/web3signer.d.ts.map +1 -0
- package/dest/fixtures/web3signer.js +53 -0
- package/dest/fixtures/with_telemetry_utils.d.ts +2 -2
- package/dest/fixtures/with_telemetry_utils.d.ts.map +1 -1
- package/dest/fixtures/with_telemetry_utils.js +2 -2
- package/dest/index.d.ts +1 -1
- package/dest/quality_of_service/grafana_client.d.ts +41 -0
- package/dest/quality_of_service/grafana_client.d.ts.map +1 -0
- package/dest/quality_of_service/{alert_checker.js → grafana_client.js} +1 -1
- package/dest/quality_of_service/prometheus_client.d.ts +38 -0
- package/dest/quality_of_service/prometheus_client.d.ts.map +1 -0
- package/dest/quality_of_service/prometheus_client.js +67 -0
- package/dest/shared/cross_chain_test_harness.d.ts +44 -27
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +107 -53
- package/dest/shared/gas_portal_test_harness.d.ts +33 -25
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +51 -30
- package/dest/shared/index.d.ts +3 -2
- package/dest/shared/index.d.ts.map +1 -1
- package/dest/shared/index.js +1 -0
- package/dest/shared/jest_setup.d.ts +1 -1
- package/dest/shared/jest_setup.js +42 -2
- 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 +6 -4
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/submit-transactions.js +15 -16
- package/dest/shared/uniswap_l1_l2.d.ts +3 -25
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +175 -126
- package/dest/simulators/index.d.ts +1 -1
- package/dest/simulators/lending_simulator.d.ts +7 -7
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +17 -18
- package/dest/simulators/token_simulator.d.ts +6 -3
- package/dest/simulators/token_simulator.d.ts.map +1 -1
- package/dest/simulators/token_simulator.js +12 -30
- package/dest/spartan/setup_test_wallets.d.ts +36 -11
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +276 -62
- package/dest/spartan/tx_metrics.d.ts +88 -0
- package/dest/spartan/tx_metrics.d.ts.map +1 -0
- package/dest/spartan/tx_metrics.js +422 -0
- 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 -415
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +1 -445
- 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 +72 -62
- package/src/bench/client_flows/benchmark.ts +363 -0
- package/src/bench/client_flows/client_flows_benchmark.ts +388 -0
- package/src/bench/client_flows/config.ts +69 -0
- package/src/bench/client_flows/data_extractor.ts +89 -0
- package/src/bench/utils.ts +47 -86
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +149 -171
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +155 -182
- package/src/e2e_deploy_contract/deploy_test.ts +40 -48
- package/src/e2e_epochs/epochs_test.ts +364 -93
- package/src/e2e_fees/bridging_race.notest.ts +74 -0
- package/src/e2e_fees/fees_test.ts +213 -259
- package/src/e2e_l1_publisher/write_json.ts +77 -0
- package/src/e2e_multi_validator/utils.ts +258 -0
- package/src/e2e_nested_contract/nested_contract_test.ts +48 -59
- package/src/e2e_p2p/inactivity_slash_test.ts +179 -0
- package/src/e2e_p2p/p2p_network.ts +367 -234
- package/src/e2e_p2p/reqresp/utils.ts +256 -0
- package/src/e2e_p2p/shared.ts +315 -39
- 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 +132 -126
- 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 +332 -0
- package/src/fixtures/elu_monitor.ts +126 -0
- package/src/fixtures/fixtures.ts +15 -7
- package/src/fixtures/get_acvm_config.ts +4 -12
- package/src/fixtures/get_bb_config.ts +18 -13
- package/src/fixtures/ha_setup.ts +186 -0
- package/src/fixtures/index.ts +1 -0
- package/src/fixtures/l1_to_l2_messaging.ts +56 -24
- package/src/fixtures/setup.ts +903 -0
- package/src/fixtures/setup_p2p_test.ts +134 -50
- package/src/fixtures/token_utils.ts +37 -16
- package/src/fixtures/utils.ts +27 -820
- package/src/fixtures/web3signer.ts +63 -0
- package/src/fixtures/with_telemetry_utils.ts +2 -2
- package/src/guides/up_quick_start.sh +9 -17
- package/src/quality_of_service/{alert_checker.ts → grafana_client.ts} +2 -2
- package/src/quality_of_service/prometheus_client.ts +113 -0
- package/src/shared/cross_chain_test_harness.ts +110 -94
- package/src/shared/gas_portal_test_harness.ts +59 -50
- package/src/shared/index.ts +2 -1
- package/src/shared/jest_setup.ts +52 -2
- package/src/shared/mock_state_view.ts +188 -0
- package/src/shared/submit-transactions.ts +19 -20
- package/src/shared/uniswap_l1_l2.ts +207 -226
- package/src/simulators/lending_simulator.ts +18 -17
- package/src/simulators/token_simulator.ts +18 -34
- package/src/spartan/DEVELOP.md +128 -0
- package/src/spartan/setup_test_wallets.ts +393 -95
- package/src/spartan/tx_metrics.ts +376 -0
- 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 -582
- 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
- package/dest/e2e_prover/e2e_prover_test.d.ts +0 -56
- package/dest/e2e_prover/e2e_prover_test.d.ts.map +0 -1
- package/dest/e2e_prover/e2e_prover_test.js +0 -291
- package/dest/fixtures/setup_l1_contracts.d.ts +0 -6
- package/dest/fixtures/setup_l1_contracts.d.ts.map +0 -1
- package/dest/fixtures/setup_l1_contracts.js +0 -17
- package/dest/fixtures/snapshot_manager.d.ts +0 -87
- package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
- package/dest/fixtures/snapshot_manager.js +0 -479
- package/dest/quality_of_service/alert_checker.d.ts +0 -41
- package/dest/quality_of_service/alert_checker.d.ts.map +0 -1
- package/dest/sample-dapp/connect.js +0 -12
- package/dest/sample-dapp/contracts.js +0 -10
- package/dest/sample-dapp/deploy.js +0 -35
- package/dest/sample-dapp/index.js +0 -98
- package/src/e2e_prover/e2e_prover_test.ts +0 -418
- package/src/fixtures/setup_l1_contracts.ts +0 -27
- package/src/fixtures/snapshot_manager.ts +0 -617
- package/src/sample-dapp/connect.mjs +0 -16
- package/src/sample-dapp/contracts.mjs +0 -14
- package/src/sample-dapp/deploy.mjs +0 -40
- package/src/sample-dapp/index.mjs +0 -128
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
2
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
3
|
+
import { sleep } from '@aztec/foundation/sleep';
|
|
4
|
+
import { RemoteSigner } from '@aztec/node-keystore';
|
|
5
|
+
|
|
6
|
+
import { mkdirSync } from 'node:fs';
|
|
7
|
+
import { writeFile } from 'node:fs/promises';
|
|
8
|
+
import { join } from 'node:path';
|
|
9
|
+
|
|
10
|
+
export async function createWeb3SignerKeystore(dir: string, ...privateKeys: string[]) {
|
|
11
|
+
const yaml = privateKeys
|
|
12
|
+
.map(
|
|
13
|
+
pk => `\
|
|
14
|
+
type: file-raw
|
|
15
|
+
keyType: SECP256K1
|
|
16
|
+
privateKey: ${pk}`,
|
|
17
|
+
)
|
|
18
|
+
.join('\n---\n');
|
|
19
|
+
|
|
20
|
+
// NOTE: nodejs stdlib can only create temp directories, not temp files!
|
|
21
|
+
// this write uses wx (write-exclusive) so it'll throw if the file already exists
|
|
22
|
+
const path = join(dir, `keystore-${randomBytes(4).toString('hex')}.yaml`);
|
|
23
|
+
await writeFile(path, yaml, { flag: 'wx' });
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export async function refreshWeb3Signer(url: string, ...expectedAddresses: string[]) {
|
|
27
|
+
await fetch(new URL('reload', url), { method: 'POST' });
|
|
28
|
+
|
|
29
|
+
if (expectedAddresses.length > 0) {
|
|
30
|
+
await retryUntil(
|
|
31
|
+
async () => {
|
|
32
|
+
try {
|
|
33
|
+
await RemoteSigner.validateAccess(url, expectedAddresses);
|
|
34
|
+
return true;
|
|
35
|
+
} catch {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
'web3signer refresh',
|
|
40
|
+
10,
|
|
41
|
+
0.5,
|
|
42
|
+
);
|
|
43
|
+
} else {
|
|
44
|
+
await sleep(1000);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function getWeb3SignerTestKeystoreDir(): string {
|
|
49
|
+
if (process.env.WEB3_SIGNER_TEST_KEYSTORE_DIR) {
|
|
50
|
+
mkdirSync(process.env.WEB3_SIGNER_TEST_KEYSTORE_DIR, { recursive: true });
|
|
51
|
+
return process.env.WEB3_SIGNER_TEST_KEYSTORE_DIR;
|
|
52
|
+
} else {
|
|
53
|
+
throw new Error('Web3signer not running');
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function getWeb3SignerUrl(): string {
|
|
58
|
+
if (process.env.WEB3_SIGNER_URL) {
|
|
59
|
+
return process.env.WEB3_SIGNER_URL;
|
|
60
|
+
} else {
|
|
61
|
+
throw new Error('Web3signer not running');
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -7,12 +7,12 @@ import {
|
|
|
7
7
|
} from '@aztec/telemetry-client';
|
|
8
8
|
import { OTelPinoStream } from '@aztec/telemetry-client/otel-pino-stream';
|
|
9
9
|
|
|
10
|
-
export function getEndToEndTestTelemetryClient(metricsPort?: number): TelemetryClient {
|
|
10
|
+
export async function getEndToEndTestTelemetryClient(metricsPort?: number): Promise<TelemetryClient> {
|
|
11
11
|
if (metricsPort) {
|
|
12
12
|
const otelStream = new OTelPinoStream({ levels });
|
|
13
13
|
registerLoggingStream(otelStream);
|
|
14
14
|
}
|
|
15
|
-
return initTelemetryClient(getEndToEndTestTelemetryConfig(metricsPort));
|
|
15
|
+
return await initTelemetryClient(getEndToEndTestTelemetryConfig(metricsPort));
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/**
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# Run locally from end-to-end folder while running anvil and
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Run locally from end-to-end folder while running anvil and local network with:
|
|
3
3
|
# PATH=$PATH:../node_modules/.bin ./src/guides/up_quick_start.sh
|
|
4
4
|
set -eux
|
|
5
5
|
|
|
6
6
|
export WALLET_DATA_DIRECTORY=$(mktemp -d)/up_quick_start
|
|
7
|
+
export PXE_PROVER="none"
|
|
7
8
|
|
|
8
9
|
function on_exit {
|
|
9
10
|
echo "Cleaning up $WALLET_DATA_DIRECTORY..."
|
|
@@ -18,37 +19,28 @@ aztec-wallet() {
|
|
|
18
19
|
aztec-wallet import-test-accounts
|
|
19
20
|
|
|
20
21
|
# docs:start:declare-accounts
|
|
21
|
-
aztec-wallet create-account -a alice
|
|
22
|
-
aztec-wallet create-account -a bob
|
|
22
|
+
aztec-wallet create-account -a alice -f test0
|
|
23
|
+
aztec-wallet create-account -a bob -f test0
|
|
23
24
|
# docs:end:declare-accounts
|
|
24
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"
|
|
29
|
-
# docs:end:deploy
|
|
30
31
|
|
|
31
|
-
# docs:start:mint-private
|
|
32
32
|
MINT_AMOUNT=69
|
|
33
|
-
aztec-wallet send mint_to_private -ca last --args accounts:
|
|
34
|
-
# docs:end:mint-private
|
|
33
|
+
aztec-wallet send mint_to_private -ca last --args accounts:alice $MINT_AMOUNT -f test0
|
|
35
34
|
|
|
36
|
-
# docs:start:get-balance
|
|
37
35
|
ALICE_BALANCE=$(aztec-wallet simulate balance_of_private -ca last --args accounts:alice -f alice)
|
|
38
36
|
if ! echo $ALICE_BALANCE | grep -q $MINT_AMOUNT; then
|
|
39
37
|
echo "Incorrect Alice balance after transaction (expected $MINT_AMOUNT but got $ALICE_BALANCE)"
|
|
40
38
|
exit 1
|
|
41
39
|
fi
|
|
42
|
-
# docs:end:get-balance
|
|
43
40
|
|
|
44
|
-
# docs:start:transfer
|
|
45
41
|
TRANSFER_AMOUNT=42
|
|
46
42
|
|
|
47
|
-
aztec-wallet
|
|
48
|
-
aztec-wallet add-authwit authwits:last alice -f test0
|
|
49
|
-
|
|
50
|
-
aztec-wallet send transfer_in_private -ca last --args accounts:alice accounts:bob $TRANSFER_AMOUNT 1 -f test0
|
|
51
|
-
# docs:end:transfer
|
|
43
|
+
aztec-wallet send transfer_in_private -ca last --args accounts:alice accounts:bob $TRANSFER_AMOUNT 0 -f alice --payment method=fee_juice,claim
|
|
52
44
|
|
|
53
45
|
# Test end result
|
|
54
46
|
ALICE_BALANCE=$(aztec-wallet simulate balance_of_private -ca last --args accounts:alice -f alice)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Logger } from '@aztec/aztec.js';
|
|
1
|
+
import type { Logger } from '@aztec/aztec.js/log';
|
|
2
2
|
|
|
3
3
|
import * as fs from 'fs';
|
|
4
4
|
import * as yaml from 'js-yaml';
|
|
@@ -25,7 +25,7 @@ const DEFAULT_CONFIG: AlertCheckerConfig = {
|
|
|
25
25
|
grafanaCredentials: 'admin:admin',
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
export class
|
|
28
|
+
export class GrafanaClient {
|
|
29
29
|
private config: AlertCheckerConfig;
|
|
30
30
|
private logger: Logger;
|
|
31
31
|
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
export type PromteheusClientOptions = {
|
|
2
|
+
server: URL;
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
export class PrometheusClient {
|
|
6
|
+
constructor(
|
|
7
|
+
private config: PromteheusClientOptions,
|
|
8
|
+
private httpClient: typeof fetch = fetch,
|
|
9
|
+
) {}
|
|
10
|
+
|
|
11
|
+
public async querySingleValue(query: string, time = new Date()): Promise<number> {
|
|
12
|
+
const resp = await this.queryRaw(query, time);
|
|
13
|
+
if (resp.status === 'success') {
|
|
14
|
+
if (resp.data.resultType === 'vector') {
|
|
15
|
+
if (resp.data.result.length === 0) {
|
|
16
|
+
return 0;
|
|
17
|
+
}
|
|
18
|
+
const [_, value] = resp.data.result[0].value;
|
|
19
|
+
return parseFloat(value);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
throw new TypeError('Unsupported response body', { cause: JSON.stringify(resp) });
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public queryRaw(query: string, time = new Date()): Promise<PrometheusResponse> {
|
|
27
|
+
const searchParams = new URLSearchParams();
|
|
28
|
+
searchParams.set('query', query);
|
|
29
|
+
searchParams.set('time', String(Math.trunc(time.getTime() / 1000)));
|
|
30
|
+
searchParams.set('limit', '10');
|
|
31
|
+
|
|
32
|
+
return this.callPrometheus('query', searchParams);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public queryRangeRaw(
|
|
36
|
+
query: string,
|
|
37
|
+
step: PrometheusDuration,
|
|
38
|
+
start: Date,
|
|
39
|
+
end = new Date(),
|
|
40
|
+
): Promise<PrometheusResponse> {
|
|
41
|
+
const searchParams = new URLSearchParams();
|
|
42
|
+
searchParams.set('query', query);
|
|
43
|
+
searchParams.set('step', step);
|
|
44
|
+
searchParams.set('start', String(Math.trunc(start.getTime() / 1000)));
|
|
45
|
+
searchParams.set('end', String(Math.trunc(end.getTime() / 1000)));
|
|
46
|
+
searchParams.set('limit', '10');
|
|
47
|
+
|
|
48
|
+
return this.callPrometheus('query_range', searchParams);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
private async callPrometheus(api: string, searchParams: URLSearchParams): Promise<PrometheusResponse> {
|
|
52
|
+
const url = new URL('api/v1/' + api, this.config.server);
|
|
53
|
+
for (const [name, value] of searchParams) {
|
|
54
|
+
url.searchParams.append(name, value);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const resp = await this.httpClient(url, { method: 'GET' });
|
|
58
|
+
if (!resp.ok || resp.status !== 200) {
|
|
59
|
+
throw new Error('Invalid HTTP response from Prometheus', {
|
|
60
|
+
cause: {
|
|
61
|
+
url,
|
|
62
|
+
status: resp.status,
|
|
63
|
+
statusText: resp.statusText,
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const body = await resp.json();
|
|
69
|
+
if ('status' in body && (body.status === 'error' || body.status === 'success')) {
|
|
70
|
+
return body;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
throw new Error('Invalid response from Prometheus', {
|
|
74
|
+
cause: {
|
|
75
|
+
url,
|
|
76
|
+
body,
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export type PrometheusDuration = `${number}s` | `${number}m` | `${number}h`;
|
|
83
|
+
|
|
84
|
+
export type PrometheusData =
|
|
85
|
+
| {
|
|
86
|
+
resultType: 'vector';
|
|
87
|
+
result: Array<{
|
|
88
|
+
metric: unknown;
|
|
89
|
+
value: [unixTimestamp: number, value: string];
|
|
90
|
+
}>;
|
|
91
|
+
}
|
|
92
|
+
| {
|
|
93
|
+
resultType: 'matrix';
|
|
94
|
+
result: Array<{
|
|
95
|
+
metric: unknown;
|
|
96
|
+
values: [unixTimestamp: number, value: string];
|
|
97
|
+
}>;
|
|
98
|
+
}
|
|
99
|
+
| {
|
|
100
|
+
resultType: 'scalar' | 'string';
|
|
101
|
+
result: unknown;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export type PrometheusResponse =
|
|
105
|
+
| {
|
|
106
|
+
status: 'error';
|
|
107
|
+
errorType: string;
|
|
108
|
+
error: string;
|
|
109
|
+
}
|
|
110
|
+
| {
|
|
111
|
+
status: 'success';
|
|
112
|
+
data: PrometheusData;
|
|
113
|
+
};
|
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { EthAddress } from '@aztec/aztec.js/addresses';
|
|
3
|
+
import { AuthWitness } from '@aztec/aztec.js/authorization';
|
|
2
4
|
import {
|
|
3
|
-
type AccountWallet,
|
|
4
|
-
type AztecAddress,
|
|
5
|
-
type AztecNode,
|
|
6
|
-
EthAddress,
|
|
7
|
-
type FieldsOf,
|
|
8
|
-
Fr,
|
|
9
5
|
type L1TokenManager,
|
|
10
6
|
L1TokenPortalManager,
|
|
11
7
|
type L2AmountClaim,
|
|
12
8
|
type L2AmountClaimWithRecipient,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
} from '@aztec/
|
|
21
|
-
import type { L1ContractAddresses
|
|
9
|
+
} from '@aztec/aztec.js/ethereum';
|
|
10
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
11
|
+
import type { Logger } from '@aztec/aztec.js/log';
|
|
12
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
13
|
+
import type { SiblingPath } from '@aztec/aztec.js/trees';
|
|
14
|
+
import type { TxReceipt } from '@aztec/aztec.js/tx';
|
|
15
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
16
|
+
import { deployL1Contract } from '@aztec/ethereum/deploy-l1-contract';
|
|
17
|
+
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
18
|
+
import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
|
|
19
|
+
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
20
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
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';
|
|
@@ -27,7 +26,6 @@ import { type Hex, getContract } from 'viem';
|
|
|
27
26
|
|
|
28
27
|
import { mintTokensToPrivate } from '../fixtures/token_utils.js';
|
|
29
28
|
|
|
30
|
-
// docs:start:deployAndInitializeTokenAndBridgeContracts
|
|
31
29
|
/**
|
|
32
30
|
* Deploy L1 token and portal, initialize portal, deploy a non native l2 token contract, its L2 bridge contract and attach is to the portal.
|
|
33
31
|
* @param wallet - the wallet instance
|
|
@@ -40,8 +38,7 @@ import { mintTokensToPrivate } from '../fixtures/token_utils.js';
|
|
|
40
38
|
*/
|
|
41
39
|
export async function deployAndInitializeTokenAndBridgeContracts(
|
|
42
40
|
wallet: Wallet,
|
|
43
|
-
|
|
44
|
-
publicClient: ViemPublicClient,
|
|
41
|
+
l1Client: ExtendedViemWalletClient,
|
|
45
42
|
rollupRegistryAddress: EthAddress,
|
|
46
43
|
owner: AztecAddress,
|
|
47
44
|
underlyingERC20Address: EthAddress,
|
|
@@ -68,35 +65,34 @@ export async function deployAndInitializeTokenAndBridgeContracts(
|
|
|
68
65
|
underlyingERC20: any;
|
|
69
66
|
}> {
|
|
70
67
|
// deploy the token portal
|
|
71
|
-
const { address: tokenPortalAddress } = await deployL1Contract(
|
|
72
|
-
walletClient,
|
|
73
|
-
publicClient,
|
|
74
|
-
TokenPortalAbi,
|
|
75
|
-
TokenPortalBytecode,
|
|
76
|
-
);
|
|
68
|
+
const { address: tokenPortalAddress } = await deployL1Contract(l1Client, TokenPortalAbi, TokenPortalBytecode);
|
|
77
69
|
const tokenPortal = getContract({
|
|
78
70
|
address: tokenPortalAddress.toString(),
|
|
79
71
|
abi: TokenPortalAbi,
|
|
80
|
-
client:
|
|
72
|
+
client: l1Client,
|
|
81
73
|
});
|
|
82
74
|
|
|
83
75
|
// deploy l2 token
|
|
84
|
-
const token = await TokenContract.deploy(wallet, owner, 'TokenName', 'TokenSymbol', 18).send(
|
|
76
|
+
const { contract: token } = await TokenContract.deploy(wallet, owner, 'TokenName', 'TokenSymbol', 18).send({
|
|
77
|
+
from: owner,
|
|
78
|
+
});
|
|
85
79
|
|
|
86
80
|
// deploy l2 token bridge and attach to the portal
|
|
87
|
-
const bridge = await TokenBridgeContract.deploy(wallet, token.address, tokenPortalAddress).send(
|
|
81
|
+
const { contract: bridge } = await TokenBridgeContract.deploy(wallet, token.address, tokenPortalAddress).send({
|
|
82
|
+
from: owner,
|
|
83
|
+
});
|
|
88
84
|
|
|
89
|
-
if ((await token.methods.get_admin().simulate()) !== owner.toBigInt()) {
|
|
85
|
+
if ((await token.methods.get_admin().simulate({ from: owner })).result !== owner.toBigInt()) {
|
|
90
86
|
throw new Error(`Token admin is not ${owner}`);
|
|
91
87
|
}
|
|
92
88
|
|
|
93
|
-
if (!(await bridge.methods.get_config().simulate()).token.equals(token.address)) {
|
|
89
|
+
if (!(await bridge.methods.get_config().simulate({ from: owner })).result.token.equals(token.address)) {
|
|
94
90
|
throw new Error(`Bridge token is not ${token.address}`);
|
|
95
91
|
}
|
|
96
92
|
|
|
97
93
|
// make the bridge a minter on the token:
|
|
98
|
-
await token.methods.set_minter(bridge.address, true).send()
|
|
99
|
-
if ((await token.methods.is_minter(bridge.address).simulate()) === 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) {
|
|
100
96
|
throw new Error(`Bridge is not a minter`);
|
|
101
97
|
}
|
|
102
98
|
|
|
@@ -109,12 +105,22 @@ export async function deployAndInitializeTokenAndBridgeContracts(
|
|
|
109
105
|
const underlyingERC20 = getContract({
|
|
110
106
|
address: underlyingERC20Address.toString(),
|
|
111
107
|
abi: TestERC20Abi,
|
|
112
|
-
client:
|
|
108
|
+
client: l1Client,
|
|
113
109
|
});
|
|
114
110
|
|
|
115
111
|
return { token, bridge, tokenPortalAddress, tokenPortal, underlyingERC20 };
|
|
116
112
|
}
|
|
117
|
-
|
|
113
|
+
|
|
114
|
+
export type CrossChainContext = {
|
|
115
|
+
l2Token: AztecAddress;
|
|
116
|
+
l2Bridge: AztecAddress;
|
|
117
|
+
tokenPortal: EthAddress;
|
|
118
|
+
underlying: EthAddress;
|
|
119
|
+
ethAccount: EthAddress;
|
|
120
|
+
ownerAddress: AztecAddress;
|
|
121
|
+
inbox: EthAddress;
|
|
122
|
+
outbox: EthAddress;
|
|
123
|
+
};
|
|
118
124
|
|
|
119
125
|
/**
|
|
120
126
|
* A Class for testing cross chain interactions, contains common interactions
|
|
@@ -123,54 +129,47 @@ export async function deployAndInitializeTokenAndBridgeContracts(
|
|
|
123
129
|
export class CrossChainTestHarness {
|
|
124
130
|
static async new(
|
|
125
131
|
aztecNode: AztecNode,
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
wallet: AccountWallet,
|
|
132
|
+
l1Client: ExtendedViemWalletClient,
|
|
133
|
+
wallet: Wallet,
|
|
134
|
+
ownerAddress: AztecAddress,
|
|
130
135
|
logger: Logger,
|
|
131
136
|
underlyingERC20Address: EthAddress,
|
|
132
137
|
): Promise<CrossChainTestHarness> {
|
|
133
|
-
const ethAccount = EthAddress.fromString((await
|
|
134
|
-
const l1ContractAddresses = (await
|
|
138
|
+
const ethAccount = EthAddress.fromString((await l1Client.getAddresses())[0]);
|
|
139
|
+
const l1ContractAddresses = (await aztecNode.getNodeInfo()).l1ContractAddresses;
|
|
135
140
|
|
|
136
141
|
// Deploy and initialize all required contracts
|
|
137
142
|
logger.info('Deploying and initializing token, portal and its bridge...');
|
|
138
143
|
const { token, bridge, tokenPortalAddress, underlyingERC20 } = await deployAndInitializeTokenAndBridgeContracts(
|
|
139
144
|
wallet,
|
|
140
|
-
|
|
141
|
-
publicClient,
|
|
145
|
+
l1Client,
|
|
142
146
|
l1ContractAddresses.registryAddress,
|
|
143
|
-
|
|
147
|
+
ownerAddress,
|
|
144
148
|
underlyingERC20Address,
|
|
145
149
|
);
|
|
146
150
|
logger.info('Deployed and initialized token, portal and its bridge.');
|
|
147
151
|
|
|
148
152
|
return new CrossChainTestHarness(
|
|
149
153
|
aztecNode,
|
|
150
|
-
pxeService,
|
|
151
154
|
logger,
|
|
152
155
|
token,
|
|
153
156
|
bridge,
|
|
154
157
|
ethAccount,
|
|
155
158
|
tokenPortalAddress,
|
|
156
159
|
underlyingERC20.address,
|
|
157
|
-
|
|
158
|
-
walletClient,
|
|
160
|
+
l1Client,
|
|
159
161
|
l1ContractAddresses,
|
|
160
162
|
wallet,
|
|
163
|
+
ownerAddress,
|
|
161
164
|
);
|
|
162
165
|
}
|
|
163
166
|
|
|
164
167
|
private readonly l1TokenManager: L1TokenManager;
|
|
165
168
|
private readonly l1TokenPortalManager: L1TokenPortalManager;
|
|
166
169
|
|
|
167
|
-
public readonly ownerAddress: AztecAddress;
|
|
168
|
-
|
|
169
170
|
constructor(
|
|
170
171
|
/** Aztec node instance. */
|
|
171
172
|
public aztecNode: AztecNode,
|
|
172
|
-
/** Private eXecution Environment (PXE). */
|
|
173
|
-
public pxeService: PXE,
|
|
174
173
|
/** Logger. */
|
|
175
174
|
public logger: Logger,
|
|
176
175
|
|
|
@@ -186,32 +185,39 @@ export class CrossChainTestHarness {
|
|
|
186
185
|
public tokenPortalAddress: EthAddress,
|
|
187
186
|
/** Underlying token for portal tests. */
|
|
188
187
|
public underlyingERC20Address: EthAddress,
|
|
189
|
-
/** Viem
|
|
190
|
-
public
|
|
191
|
-
/** Viem Wallet Client instance. */
|
|
192
|
-
public walletClient: ViemWalletClient,
|
|
188
|
+
/** Viem Extended client instance. */
|
|
189
|
+
public l1Client: ExtendedViemWalletClient,
|
|
193
190
|
|
|
194
191
|
/** Deployment addresses for all L1 contracts */
|
|
195
192
|
public readonly l1ContractAddresses: L1ContractAddresses,
|
|
196
193
|
|
|
197
|
-
/** Wallet
|
|
198
|
-
public readonly
|
|
194
|
+
/** Wallet to simulate and send txs from. */
|
|
195
|
+
public readonly wallet: Wallet,
|
|
196
|
+
|
|
197
|
+
/** Owner of the l2 token and bridge */
|
|
198
|
+
public readonly ownerAddress: AztecAddress,
|
|
199
199
|
) {
|
|
200
200
|
this.l1TokenPortalManager = new L1TokenPortalManager(
|
|
201
201
|
this.tokenPortalAddress,
|
|
202
202
|
this.underlyingERC20Address,
|
|
203
|
+
this.l1ContractAddresses.feeAssetHandlerAddress,
|
|
203
204
|
this.l1ContractAddresses.outboxAddress,
|
|
204
|
-
this.
|
|
205
|
-
this.walletClient,
|
|
205
|
+
this.l1Client,
|
|
206
206
|
this.logger,
|
|
207
207
|
);
|
|
208
208
|
this.l1TokenManager = this.l1TokenPortalManager.getTokenManager();
|
|
209
|
-
this.ownerAddress = this.ownerWallet.getAddress();
|
|
210
209
|
}
|
|
211
210
|
|
|
212
211
|
async mintTokensOnL1(amount: bigint) {
|
|
213
|
-
|
|
214
|
-
|
|
212
|
+
const contract = getContract({
|
|
213
|
+
abi: TestERC20Abi,
|
|
214
|
+
address: this.l1TokenManager.tokenAddress.toString(),
|
|
215
|
+
client: this.l1Client,
|
|
216
|
+
});
|
|
217
|
+
const balanceBefore = await this.l1TokenManager.getL1TokenBalance(this.ethAccount.toString());
|
|
218
|
+
const hash = await contract.write.mint([this.ethAccount.toString(), amount]);
|
|
219
|
+
await this.l1Client.waitForTransactionReceipt({ hash });
|
|
220
|
+
expect(await this.l1TokenManager.getL1TokenBalance(this.ethAccount.toString())).toEqual(balanceBefore + amount);
|
|
215
221
|
}
|
|
216
222
|
|
|
217
223
|
getL1BalanceOf(address: EthAddress) {
|
|
@@ -228,16 +234,18 @@ export class CrossChainTestHarness {
|
|
|
228
234
|
|
|
229
235
|
async mintTokensPublicOnL2(amount: bigint) {
|
|
230
236
|
this.logger.info('Minting tokens on L2 publicly');
|
|
231
|
-
await this.l2Token.methods.mint_to_public(this.ownerAddress, amount).send(
|
|
237
|
+
await this.l2Token.methods.mint_to_public(this.ownerAddress, amount).send({ from: this.ownerAddress });
|
|
232
238
|
}
|
|
233
239
|
|
|
234
240
|
async mintTokensPrivateOnL2(amount: bigint) {
|
|
235
|
-
await mintTokensToPrivate(this.l2Token, this.
|
|
241
|
+
await mintTokensToPrivate(this.l2Token, this.ownerAddress, this.ownerAddress, amount);
|
|
236
242
|
}
|
|
237
243
|
|
|
238
244
|
async sendL2PublicTransfer(transferAmount: bigint, receiverAddress: AztecAddress) {
|
|
239
245
|
// send a transfer tx to force through rollup with the message included
|
|
240
|
-
await this.l2Token.methods
|
|
246
|
+
await this.l2Token.methods
|
|
247
|
+
.transfer_in_public(this.ownerAddress, receiverAddress, transferAmount, 0)
|
|
248
|
+
.send({ from: this.ownerAddress });
|
|
241
249
|
}
|
|
242
250
|
|
|
243
251
|
async consumeMessageOnAztecAndMintPrivately(
|
|
@@ -247,8 +255,7 @@ export class CrossChainTestHarness {
|
|
|
247
255
|
const { recipient, claimAmount, claimSecret: secretForL2MessageConsumption, messageLeafIndex } = claim;
|
|
248
256
|
await this.l2Bridge.methods
|
|
249
257
|
.claim_private(recipient, claimAmount, secretForL2MessageConsumption, messageLeafIndex)
|
|
250
|
-
.send()
|
|
251
|
-
.wait();
|
|
258
|
+
.send({ from: this.ownerAddress });
|
|
252
259
|
}
|
|
253
260
|
|
|
254
261
|
async consumeMessageOnAztecAndMintPublicly(
|
|
@@ -258,30 +265,31 @@ export class CrossChainTestHarness {
|
|
|
258
265
|
const { claimAmount, claimSecret, messageLeafIndex } = claim;
|
|
259
266
|
await this.l2Bridge.methods
|
|
260
267
|
.claim_public(this.ownerAddress, claimAmount, claimSecret, messageLeafIndex)
|
|
261
|
-
.send()
|
|
262
|
-
.wait();
|
|
268
|
+
.send({ from: this.ownerAddress });
|
|
263
269
|
}
|
|
264
270
|
|
|
265
|
-
async withdrawPrivateFromAztecToL1(
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
271
|
+
async withdrawPrivateFromAztecToL1(
|
|
272
|
+
withdrawAmount: bigint,
|
|
273
|
+
authwitNonce: Fr = Fr.ZERO,
|
|
274
|
+
authWitness: AuthWitness,
|
|
275
|
+
): Promise<TxReceipt> {
|
|
276
|
+
const { receipt: withdrawReceipt } = await this.l2Bridge.methods
|
|
277
|
+
.exit_to_l1_private(this.l2Token.address, this.ethAccount, withdrawAmount, EthAddress.ZERO, authwitNonce)
|
|
278
|
+
.send({ authWitnesses: [authWitness], from: this.ownerAddress });
|
|
270
279
|
|
|
271
280
|
return withdrawReceipt;
|
|
272
281
|
}
|
|
273
282
|
|
|
274
|
-
async withdrawPublicFromAztecToL1(withdrawAmount: bigint,
|
|
275
|
-
const withdrawReceipt = await this.l2Bridge.methods
|
|
276
|
-
.exit_to_l1_public(this.ethAccount, withdrawAmount, EthAddress.ZERO,
|
|
277
|
-
.send()
|
|
278
|
-
.wait();
|
|
283
|
+
async withdrawPublicFromAztecToL1(withdrawAmount: bigint, authwitNonce: Fr = Fr.ZERO): Promise<TxReceipt> {
|
|
284
|
+
const { receipt: withdrawReceipt } = await this.l2Bridge.methods
|
|
285
|
+
.exit_to_l1_public(this.ethAccount, withdrawAmount, EthAddress.ZERO, authwitNonce)
|
|
286
|
+
.send({ from: this.ownerAddress });
|
|
279
287
|
|
|
280
288
|
return withdrawReceipt;
|
|
281
289
|
}
|
|
282
290
|
|
|
283
291
|
async getL2PrivateBalanceOf(owner: AztecAddress) {
|
|
284
|
-
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;
|
|
285
293
|
}
|
|
286
294
|
|
|
287
295
|
async expectPrivateBalanceOnL2(owner: AztecAddress, expectedBalance: bigint) {
|
|
@@ -291,7 +299,7 @@ export class CrossChainTestHarness {
|
|
|
291
299
|
}
|
|
292
300
|
|
|
293
301
|
async getL2PublicBalanceOf(owner: AztecAddress) {
|
|
294
|
-
return await this.l2Token.methods.balance_of_public(owner).simulate();
|
|
302
|
+
return (await this.l2Token.methods.balance_of_public(owner).simulate({ from: this.ownerAddress })).result;
|
|
295
303
|
}
|
|
296
304
|
|
|
297
305
|
async expectPublicBalanceOnL2(owner: AztecAddress, expectedBalance: bigint) {
|
|
@@ -299,8 +307,8 @@ export class CrossChainTestHarness {
|
|
|
299
307
|
expect(balance).toBe(expectedBalance);
|
|
300
308
|
}
|
|
301
309
|
|
|
302
|
-
getL2ToL1MessageLeaf(withdrawAmount: bigint, callerOnL1: EthAddress = EthAddress.ZERO): Fr {
|
|
303
|
-
return this.l1TokenPortalManager.getL2ToL1MessageLeaf(
|
|
310
|
+
async getL2ToL1MessageLeaf(withdrawAmount: bigint, callerOnL1: EthAddress = EthAddress.ZERO): Promise<Fr> {
|
|
311
|
+
return await this.l1TokenPortalManager.getL2ToL1MessageLeaf(
|
|
304
312
|
withdrawAmount,
|
|
305
313
|
this.ethAccount,
|
|
306
314
|
this.l2Bridge.address,
|
|
@@ -310,27 +318,23 @@ export class CrossChainTestHarness {
|
|
|
310
318
|
|
|
311
319
|
withdrawFundsFromBridgeOnL1(
|
|
312
320
|
amount: bigint,
|
|
313
|
-
|
|
321
|
+
epochNumber: EpochNumber,
|
|
314
322
|
messageIndex: bigint,
|
|
315
323
|
siblingPath: SiblingPath<number>,
|
|
316
324
|
) {
|
|
317
|
-
return this.l1TokenPortalManager.withdrawFunds(
|
|
318
|
-
amount,
|
|
319
|
-
this.ethAccount,
|
|
320
|
-
BigInt(blockNumber),
|
|
321
|
-
messageIndex,
|
|
322
|
-
siblingPath,
|
|
323
|
-
);
|
|
325
|
+
return this.l1TokenPortalManager.withdrawFunds(amount, this.ethAccount, epochNumber, messageIndex, siblingPath);
|
|
324
326
|
}
|
|
325
327
|
|
|
326
328
|
async transferToPrivateOnL2(shieldAmount: bigint) {
|
|
327
329
|
this.logger.info('Transferring to private on L2');
|
|
328
|
-
await this.l2Token.methods.transfer_to_private(this.ownerAddress, shieldAmount).send(
|
|
330
|
+
await this.l2Token.methods.transfer_to_private(this.ownerAddress, shieldAmount).send({ from: this.ownerAddress });
|
|
329
331
|
}
|
|
330
332
|
|
|
331
|
-
async transferToPublicOnL2(amount: bigint,
|
|
333
|
+
async transferToPublicOnL2(amount: bigint, authwitNonce = Fr.ZERO) {
|
|
332
334
|
this.logger.info('Transferring tokens to public');
|
|
333
|
-
await this.l2Token.methods
|
|
335
|
+
await this.l2Token.methods
|
|
336
|
+
.transfer_to_public(this.ownerAddress, this.ownerAddress, amount, authwitNonce)
|
|
337
|
+
.send({ from: this.ownerAddress });
|
|
334
338
|
}
|
|
335
339
|
|
|
336
340
|
/**
|
|
@@ -348,5 +352,17 @@ export class CrossChainTestHarness {
|
|
|
348
352
|
await this.mintTokensPublicOnL2(0n);
|
|
349
353
|
await this.mintTokensPublicOnL2(0n);
|
|
350
354
|
}
|
|
355
|
+
|
|
356
|
+
toCrossChainContext(): CrossChainContext {
|
|
357
|
+
return {
|
|
358
|
+
l2Token: this.l2Token.address,
|
|
359
|
+
l2Bridge: this.l2Bridge.address,
|
|
360
|
+
tokenPortal: this.tokenPortalAddress,
|
|
361
|
+
underlying: this.underlyingERC20Address,
|
|
362
|
+
ethAccount: this.ethAccount,
|
|
363
|
+
ownerAddress: this.ownerAddress,
|
|
364
|
+
inbox: this.l1ContractAddresses.inboxAddress,
|
|
365
|
+
outbox: this.l1ContractAddresses.outboxAddress,
|
|
366
|
+
};
|
|
367
|
+
}
|
|
351
368
|
}
|
|
352
|
-
// docs:end:cross_chain_test_harness
|