@aztec/end-to-end 0.0.1-commit.03f7ef2 → 0.0.1-commit.04d373f
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/benchmark.d.ts +17 -2
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/benchmark.js +38 -1
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +14 -15
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +132 -150
- 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/client_flows/data_extractor.js +3 -1
- package/dest/bench/utils.d.ts +9 -8
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +33 -19
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +12 -10
- 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 +120 -117
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +30 -14
- 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 +122 -70
- package/dest/e2e_deploy_contract/deploy_test.d.ts +6 -5
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +20 -14
- package/dest/e2e_epochs/epochs_test.d.ts +39 -8
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +172 -51
- package/dest/e2e_fees/bridging_race.notest.js +3 -5
- package/dest/e2e_fees/fees_test.d.ts +18 -15
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +158 -143
- 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 +14 -16
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +7 -10
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +32 -41
- package/dest/e2e_p2p/inactivity_slash_test.d.ts +3 -3
- package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -1
- package/dest/e2e_p2p/inactivity_slash_test.js +8 -6
- package/dest/e2e_p2p/p2p_network.d.ts +20 -17
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +167 -124
- 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 +206 -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 +88 -68
- 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 +20 -11
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +103 -93
- 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 +15 -20
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +115 -135
- 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 +78 -2
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +75 -1
- package/dest/fixtures/get_bb_config.d.ts +1 -1
- package/dest/fixtures/get_bb_config.d.ts.map +1 -1
- package/dest/fixtures/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/schnorr_hardcoded_account_contract.d.ts +25 -0
- package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts.map +1 -0
- package/dest/fixtures/schnorr_hardcoded_account_contract.js +37 -0
- package/dest/fixtures/setup.d.ts +266 -0
- package/dest/fixtures/setup.d.ts.map +1 -0
- package/dest/fixtures/setup.js +714 -0
- package/dest/fixtures/setup_p2p_test.d.ts +22 -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/fixtures/utils.d.ts +5 -194
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +4 -619
- 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/install_legacy_contracts.d.cts +10 -0
- package/dest/install_legacy_contracts.d.cts.map +1 -0
- package/dest/legacy-jest-resolver.d.cts +3 -0
- package/dest/legacy-jest-resolver.d.cts.map +1 -0
- 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 +18 -6
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +33 -29
- package/dest/shared/gas_portal_test_harness.d.ts +18 -5
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +20 -11
- 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.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 +3 -28
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +88 -47
- package/dest/shared/wait_for_l1_to_l2_message.d.ts +13 -0
- package/dest/shared/wait_for_l1_to_l2_message.d.ts.map +1 -0
- package/dest/shared/wait_for_l1_to_l2_message.js +10 -0
- package/dest/simulators/lending_simulator.d.ts +14 -3
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +28 -16
- 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 +15 -5
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +133 -43
- package/dest/spartan/tx_metrics.d.ts +68 -5
- package/dest/spartan/tx_metrics.d.ts.map +1 -1
- package/dest/spartan/tx_metrics.js +399 -19
- 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 +19 -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 -231
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +1 -853
- package/dest/test-wallet/test_wallet.d.ts +85 -0
- package/dest/test-wallet/test_wallet.d.ts.map +1 -0
- package/dest/test-wallet/test_wallet.js +273 -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 +66 -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 +53 -0
- package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
- package/dest/test-wallet/worker_wallet.js +155 -0
- package/dest/test-wallet/worker_wallet_schema.d.ts +160 -0
- package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
- package/dest/test-wallet/worker_wallet_schema.js +22 -0
- package/package.json +53 -45
- package/src/bench/client_flows/benchmark.ts +43 -2
- package/src/bench/client_flows/client_flows_benchmark.ts +189 -240
- package/src/bench/client_flows/config.ts +9 -1
- package/src/bench/client_flows/data_extractor.ts +1 -1
- package/src/bench/utils.ts +38 -22
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +141 -152
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +166 -118
- package/src/e2e_deploy_contract/deploy_test.ts +24 -16
- package/src/e2e_epochs/epochs_test.ts +218 -94
- package/src/e2e_fees/bridging_race.notest.ts +4 -10
- package/src/e2e_fees/fees_test.ts +207 -230
- package/src/e2e_l1_publisher/write_json.ts +16 -16
- package/src/e2e_nested_contract/nested_contract_test.ts +38 -57
- package/src/e2e_p2p/inactivity_slash_test.ts +8 -6
- package/src/e2e_p2p/p2p_network.ts +239 -191
- package/src/e2e_p2p/reqresp/utils.ts +274 -0
- package/src/e2e_p2p/shared.ts +115 -86
- 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 +129 -117
- 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 +143 -185
- package/src/fixtures/elu_monitor.ts +126 -0
- package/src/fixtures/fixtures.ts +97 -1
- package/src/fixtures/get_bb_config.ts +7 -6
- package/src/fixtures/ha_setup.ts +188 -0
- package/src/fixtures/index.ts +1 -0
- package/src/fixtures/schnorr_hardcoded_account_contract.ts +49 -0
- package/src/fixtures/setup.ts +1037 -0
- package/src/fixtures/setup_p2p_test.ts +52 -52
- package/src/fixtures/token_utils.ts +7 -6
- package/src/fixtures/utils.ts +29 -907
- package/src/forward-compatibility/wallet_rpc_client.ts +14 -0
- package/src/forward-compatibility/wallet_service.ts +104 -0
- package/src/guides/up_quick_start.sh +3 -5
- package/src/install_legacy_contracts.cjs +75 -0
- package/src/legacy-jest-resolver.cjs +112 -0
- package/src/quality_of_service/{alert_checker.ts → grafana_client.ts} +1 -1
- package/src/quality_of_service/prometheus_client.ts +113 -0
- package/src/shared/cross_chain_test_harness.ts +34 -40
- package/src/shared/gas_portal_test_harness.ts +22 -12
- package/src/shared/index.ts +2 -1
- 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 +114 -108
- package/src/shared/wait_for_l1_to_l2_message.ts +23 -0
- package/src/simulators/lending_simulator.ts +34 -16
- package/src/simulators/token_simulator.ts +6 -30
- package/src/spartan/setup_test_wallets.ts +191 -29
- package/src/spartan/tx_metrics.ts +329 -25
- 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 -1077
- package/src/test-wallet/test_wallet.ts +376 -0
- package/src/test-wallet/utils.ts +108 -0
- package/src/test-wallet/wallet_worker_script.ts +60 -0
- package/src/test-wallet/worker_wallet.ts +218 -0
- package/src/test-wallet/worker_wallet_schema.ts +13 -0
- package/dest/fixtures/snapshot_manager.d.ts +0 -93
- package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
- package/dest/fixtures/snapshot_manager.js +0 -493
- package/dest/quality_of_service/alert_checker.d.ts +0 -41
- package/dest/quality_of_service/alert_checker.d.ts.map +0 -1
- package/src/fixtures/snapshot_manager.ts +0 -651
|
@@ -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
|
+
});
|
|
@@ -18,10 +18,10 @@ aztec-wallet() {
|
|
|
18
18
|
|
|
19
19
|
aztec-wallet import-test-accounts
|
|
20
20
|
|
|
21
|
-
# docs:start:declare-accounts
|
|
22
21
|
aztec-wallet create-account -a alice -f test0
|
|
23
22
|
aztec-wallet create-account -a bob -f test0
|
|
24
|
-
|
|
23
|
+
|
|
24
|
+
aztec-wallet bridge-fee-juice 1000000000000000000000 accounts:alice --mint --no-wait
|
|
25
25
|
|
|
26
26
|
DEPLOY_OUTPUT=$(aztec-wallet deploy ../noir-contracts.js/artifacts/token_contract-Token.json --args accounts:test0 Test TST 18 -f test0)
|
|
27
27
|
TOKEN_ADDRESS=$(echo "$DEPLOY_OUTPUT" | grep -oE 'Contract deployed at 0x[0-9a-fA-F]+' | cut -d ' ' -f4)
|
|
@@ -38,9 +38,7 @@ fi
|
|
|
38
38
|
|
|
39
39
|
TRANSFER_AMOUNT=42
|
|
40
40
|
|
|
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
|
|
41
|
+
aztec-wallet send transfer_in_private -ca last --args accounts:alice accounts:bob $TRANSFER_AMOUNT 0 -f alice --payment method=fee_juice,claim
|
|
44
42
|
|
|
45
43
|
# Test end result
|
|
46
44
|
ALICE_BALANCE=$(aztec-wallet simulate balance_of_private -ca last --args accounts:alice -f alice)
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Installs pinned legacy @aztec/* contract-artifact packages into .legacy-contracts/<version>/.
|
|
3
|
+
//
|
|
4
|
+
// Called from two places:
|
|
5
|
+
// - bootstrap.sh ci-compat-e2e: pre-populates the cache on the host before hermetic test
|
|
6
|
+
// containers launch. The containers run with --net=none (see ci3/docker_isolate), so on-demand
|
|
7
|
+
// installs from inside them fail with EAI_AGAIN.
|
|
8
|
+
// - legacy-jest-resolver.cjs: on-demand install for local dev, where jest runs with network.
|
|
9
|
+
//
|
|
10
|
+
// Idempotent: no-op when all packages are already present.
|
|
11
|
+
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
12
|
+
|
|
13
|
+
const path = require('path');
|
|
14
|
+
const fs = require('fs');
|
|
15
|
+
const { execFileSync } = require('child_process');
|
|
16
|
+
|
|
17
|
+
const REDIRECTED = ['@aztec/noir-contracts.js', '@aztec/noir-test-contracts.js', '@aztec/accounts'];
|
|
18
|
+
|
|
19
|
+
const e2eRoot = path.resolve(__dirname, '..');
|
|
20
|
+
|
|
21
|
+
function cacheRoot(version) {
|
|
22
|
+
return path.join(e2eRoot, '.legacy-contracts', version);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function pkgJsonPath(version, pkg) {
|
|
26
|
+
return path.join(cacheRoot(version), 'node_modules', pkg, 'package.json');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function installLegacyContracts(version) {
|
|
30
|
+
if (!version) {
|
|
31
|
+
throw new Error('installLegacyContracts: version is required');
|
|
32
|
+
}
|
|
33
|
+
if (REDIRECTED.every(pkg => fs.existsSync(pkgJsonPath(version, pkg)))) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const cacheDir = cacheRoot(version);
|
|
38
|
+
fs.mkdirSync(cacheDir, { recursive: true });
|
|
39
|
+
|
|
40
|
+
// Seed a standalone package.json so `npm install --prefix` treats cacheRoot as its own project. Without this, npm
|
|
41
|
+
// walks up and finds the yarn-project workspace root, which breaks on `workspace:` protocol deps and risks
|
|
42
|
+
// clobbering the monorepo's node_modules.
|
|
43
|
+
const seed = path.join(cacheDir, 'package.json');
|
|
44
|
+
if (!fs.existsSync(seed)) {
|
|
45
|
+
fs.writeFileSync(seed, JSON.stringify({ name: 'legacy-contracts-cache', private: true }));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const specs = REDIRECTED.map(pkg => `${pkg}@${version}`);
|
|
49
|
+
process.stderr.write(`[legacy-contracts] installing ${specs.join(' ')} into ${cacheDir}\n`);
|
|
50
|
+
// --prefix: install into cacheRoot instead of cwd, so the cache is isolated from the monorepo.
|
|
51
|
+
// --no-save: don't write the installed packages back to the seeded package.json.
|
|
52
|
+
// --ignore-scripts: skip lifecycle scripts (preinstall/postinstall) of the legacy packages and their transitive
|
|
53
|
+
// deps; we only want the files on disk, not to run any build steps.
|
|
54
|
+
// --legacy-peer-deps: tolerate peer-dependency mismatches between the pinned legacy @aztec/* graph and whatever
|
|
55
|
+
// current versions npm would otherwise try to reconcile.
|
|
56
|
+
execFileSync(
|
|
57
|
+
'npm',
|
|
58
|
+
['install', '--prefix', cacheDir, '--no-save', '--ignore-scripts', '--legacy-peer-deps', ...specs],
|
|
59
|
+
{ stdio: 'inherit' },
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
// Verify versions on disk match the requested version.
|
|
63
|
+
for (const pkg of REDIRECTED) {
|
|
64
|
+
const onDisk = JSON.parse(fs.readFileSync(pkgJsonPath(version, pkg), 'utf8')).version;
|
|
65
|
+
if (onDisk !== version) {
|
|
66
|
+
throw new Error(`[legacy-contracts] ${pkg} on disk is ${onDisk}, expected ${version}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
module.exports = { installLegacyContracts, REDIRECTED, cacheRoot };
|
|
72
|
+
|
|
73
|
+
if (require.main === module) {
|
|
74
|
+
installLegacyContracts(process.argv[2]);
|
|
75
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
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
|
+
// Cache population lives in install_legacy_contracts.cjs — invoked lazily here for local dev, and eagerly
|
|
12
|
+
// by bootstrap.sh ci-compat-e2e before hermetic test containers (which run with --net=none) launch.
|
|
13
|
+
//
|
|
14
|
+
// Missing artifacts: legacy version directories are immutable, so an artifact missing from the cache means the
|
|
15
|
+
// contract was added after the pinned release — there's nothing to compat-test. Rather than failing or silently
|
|
16
|
+
// falling back to the workspace artifact (which would turn the compat run into a regular e2e run that always
|
|
17
|
+
// passes), we log the miss and exit the process cleanly with code 0. The test never runs, but the per-test CI
|
|
18
|
+
// log captures the explanatory line so the reason is auditable. This keeps the change scoped to this resolver,
|
|
19
|
+
// avoiding a new exit-code contract in the shared ci3 test runner.
|
|
20
|
+
//
|
|
21
|
+
// Activated by env var; passthrough otherwise.
|
|
22
|
+
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
23
|
+
|
|
24
|
+
const path = require('path');
|
|
25
|
+
const fs = require('fs');
|
|
26
|
+
const { installLegacyContracts, REDIRECTED, cacheRoot } = require('./install_legacy_contracts.cjs');
|
|
27
|
+
|
|
28
|
+
const version = process.env.CONTRACT_ARTIFACTS_VERSION;
|
|
29
|
+
const cacheDir = version ? cacheRoot(version) : null;
|
|
30
|
+
|
|
31
|
+
function pkgJsonPath(name) {
|
|
32
|
+
return path.join(cacheDir, 'node_modules', name, 'package.json');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Kept in a separate module (not inlined) because bootstrap.sh ci-compat-e2e also calls it directly
|
|
36
|
+
// via `node .../install_legacy_contracts.cjs <version>` to pre-populate the cache on the host before
|
|
37
|
+
// hermetic --net=none test containers launch. Inlining here would force us to duplicate the logic
|
|
38
|
+
// in bash or re-run jest just to trigger the install.
|
|
39
|
+
if (version) {
|
|
40
|
+
installLegacyContracts(version);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let bannerPrinted = false;
|
|
44
|
+
const seen = new Set();
|
|
45
|
+
|
|
46
|
+
function printBannerOnce() {
|
|
47
|
+
if (bannerPrinted || !version) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
bannerPrinted = true;
|
|
51
|
+
const lines = ['='.repeat(60), `[legacy-contracts][jest] CONTRACT_ARTIFACTS_VERSION=${version}`];
|
|
52
|
+
for (const p of REDIRECTED) {
|
|
53
|
+
const v = JSON.parse(fs.readFileSync(pkgJsonPath(p), 'utf8')).version;
|
|
54
|
+
if (v !== version) {
|
|
55
|
+
throw new Error(`[legacy-contracts] ${p} on disk is ${v}, expected ${version}`);
|
|
56
|
+
}
|
|
57
|
+
lines.push(`[legacy-contracts][jest] redirecting ${p}/artifacts/*.json -> .legacy-contracts/${version}/...`);
|
|
58
|
+
}
|
|
59
|
+
lines.push('='.repeat(60));
|
|
60
|
+
process.stderr.write(lines.join('\n') + '\n');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Match a resolved absolute path against the workspace artifacts dirs and return the legacy cache equivalent, or null
|
|
64
|
+
// if it's not an artifact path we should redirect.
|
|
65
|
+
function legacyArtifactPath(resolved) {
|
|
66
|
+
if (!resolved.endsWith('.json')) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
for (const pkg of REDIRECTED) {
|
|
70
|
+
// pkg = '@aztec/noir-contracts.js' -> match '/noir-contracts.js/artifacts/'
|
|
71
|
+
const dirName = pkg.split('/')[1];
|
|
72
|
+
const marker = `/${dirName}/artifacts/`;
|
|
73
|
+
const idx = resolved.indexOf(marker);
|
|
74
|
+
if (idx === -1) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const basename = resolved.slice(idx + marker.length);
|
|
78
|
+
return path.join(cacheDir, 'node_modules', pkg, 'artifacts', basename);
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
module.exports = function legacyResolver(request, options) {
|
|
84
|
+
// Always run the default resolver first. We only inspect (and possibly rewrite) the *result*; this catches both
|
|
85
|
+
// bare-specifier imports of `@aztec/noir-contracts.js/artifacts/foo.json` and the relative `../artifacts/foo.json`
|
|
86
|
+
// imports inside the workspace TS wrapper classes — both resolve to the same workspace artifact path that we then
|
|
87
|
+
// redirect.
|
|
88
|
+
const resolved = options.defaultResolver(request, options);
|
|
89
|
+
if (!version) {
|
|
90
|
+
return resolved;
|
|
91
|
+
}
|
|
92
|
+
printBannerOnce();
|
|
93
|
+
const legacy = legacyArtifactPath(resolved);
|
|
94
|
+
if (!legacy) {
|
|
95
|
+
return resolved;
|
|
96
|
+
}
|
|
97
|
+
if (!fs.existsSync(legacy)) {
|
|
98
|
+
// Contract was added after this historical release, there is nothing to compat-test for it. Exit the process
|
|
99
|
+
// cleanly with code 0 so the test runner reports the run as passed.
|
|
100
|
+
fs.writeSync(
|
|
101
|
+
2,
|
|
102
|
+
`[legacy-contracts][jest] artifact ${path.basename(legacy)} not in legacy cache @${version}; ` +
|
|
103
|
+
`assumed added after this release. No compat coverage applicable for this version, treating as passed.\n`,
|
|
104
|
+
);
|
|
105
|
+
process.exit(0);
|
|
106
|
+
}
|
|
107
|
+
if (!seen.has(resolved)) {
|
|
108
|
+
seen.add(resolved);
|
|
109
|
+
process.stderr.write(`[legacy-contracts][jest] redirected ${path.basename(legacy)} -> ${legacy}\n`);
|
|
110
|
+
}
|
|
111
|
+
return legacy;
|
|
112
|
+
};
|
|
@@ -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
|
+
};
|
|
@@ -13,12 +13,11 @@ import type { AztecNode } from '@aztec/aztec.js/node';
|
|
|
13
13
|
import type { SiblingPath } from '@aztec/aztec.js/trees';
|
|
14
14
|
import type { TxReceipt } from '@aztec/aztec.js/tx';
|
|
15
15
|
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
16
|
+
import { OutboxContract } from '@aztec/ethereum/contracts';
|
|
16
17
|
import { deployL1Contract } from '@aztec/ethereum/deploy-l1-contract';
|
|
17
18
|
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
18
19
|
import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
|
|
19
|
-
import {
|
|
20
|
-
import { retryUntil } from '@aztec/foundation/retry';
|
|
21
|
-
import type { FieldsOf } from '@aztec/foundation/types';
|
|
20
|
+
import { EpochNumber } from '@aztec/foundation/branded-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';
|
|
@@ -26,6 +25,7 @@ import { TokenBridgeContract } from '@aztec/noir-contracts.js/TokenBridge';
|
|
|
26
25
|
import { type Hex, getContract } from 'viem';
|
|
27
26
|
|
|
28
27
|
import { mintTokensToPrivate } from '../fixtures/token_utils.js';
|
|
28
|
+
import { waitForL1ToL2MessageSeen } from './wait_for_l1_to_l2_message.js';
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* Deploy L1 token and portal, initialize portal, deploy a non native l2 token contract, its L2 bridge contract and attach is to the portal.
|
|
@@ -74,26 +74,26 @@ export async function deployAndInitializeTokenAndBridgeContracts(
|
|
|
74
74
|
});
|
|
75
75
|
|
|
76
76
|
// deploy l2 token
|
|
77
|
-
const token = await TokenContract.deploy(wallet, owner, 'TokenName', 'TokenSymbol', 18)
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
const { contract: token } = await TokenContract.deploy(wallet, owner, 'TokenName', 'TokenSymbol', 18).send({
|
|
78
|
+
from: owner,
|
|
79
|
+
});
|
|
80
80
|
|
|
81
81
|
// deploy l2 token bridge and attach to the portal
|
|
82
|
-
const bridge = await TokenBridgeContract.deploy(wallet, token.address, tokenPortalAddress)
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
const { contract: bridge } = await TokenBridgeContract.deploy(wallet, token.address, tokenPortalAddress).send({
|
|
83
|
+
from: owner,
|
|
84
|
+
});
|
|
85
85
|
|
|
86
|
-
if ((await token.methods.get_admin().simulate({ from: owner })) !== owner.toBigInt()) {
|
|
86
|
+
if ((await token.methods.get_admin().simulate({ from: owner })).result !== owner.toBigInt()) {
|
|
87
87
|
throw new Error(`Token admin is not ${owner}`);
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
if (!(await bridge.methods.get_config().simulate({ from: owner })).token.equals(token.address)) {
|
|
90
|
+
if (!(await bridge.methods.get_config().simulate({ from: owner })).result.token.equals(token.address)) {
|
|
91
91
|
throw new Error(`Bridge token is not ${token.address}`);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
// 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) {
|
|
95
|
+
await token.methods.set_minter(bridge.address, true).send({ from: owner });
|
|
96
|
+
if ((await token.methods.is_minter(bridge.address).simulate({ from: owner })).result === 1n) {
|
|
97
97
|
throw new Error(`Bridge is not a minter`);
|
|
98
98
|
}
|
|
99
99
|
|
|
@@ -167,6 +167,7 @@ export class CrossChainTestHarness {
|
|
|
167
167
|
|
|
168
168
|
private readonly l1TokenManager: L1TokenManager;
|
|
169
169
|
private readonly l1TokenPortalManager: L1TokenPortalManager;
|
|
170
|
+
public readonly outboxContract: OutboxContract;
|
|
170
171
|
|
|
171
172
|
constructor(
|
|
172
173
|
/** Aztec node instance. */
|
|
@@ -207,6 +208,7 @@ export class CrossChainTestHarness {
|
|
|
207
208
|
this.logger,
|
|
208
209
|
);
|
|
209
210
|
this.l1TokenManager = this.l1TokenPortalManager.getTokenManager();
|
|
211
|
+
this.outboxContract = new OutboxContract(this.l1Client, this.l1ContractAddresses.outboxAddress);
|
|
210
212
|
}
|
|
211
213
|
|
|
212
214
|
async mintTokensOnL1(amount: bigint) {
|
|
@@ -235,7 +237,7 @@ export class CrossChainTestHarness {
|
|
|
235
237
|
|
|
236
238
|
async mintTokensPublicOnL2(amount: bigint) {
|
|
237
239
|
this.logger.info('Minting tokens on L2 publicly');
|
|
238
|
-
await this.l2Token.methods.mint_to_public(this.ownerAddress, amount).send({ from: this.ownerAddress })
|
|
240
|
+
await this.l2Token.methods.mint_to_public(this.ownerAddress, amount).send({ from: this.ownerAddress });
|
|
239
241
|
}
|
|
240
242
|
|
|
241
243
|
async mintTokensPrivateOnL2(amount: bigint) {
|
|
@@ -246,8 +248,7 @@ export class CrossChainTestHarness {
|
|
|
246
248
|
// send a transfer tx to force through rollup with the message included
|
|
247
249
|
await this.l2Token.methods
|
|
248
250
|
.transfer_in_public(this.ownerAddress, receiverAddress, transferAmount, 0)
|
|
249
|
-
.send({ from: this.ownerAddress })
|
|
250
|
-
.wait();
|
|
251
|
+
.send({ from: this.ownerAddress });
|
|
251
252
|
}
|
|
252
253
|
|
|
253
254
|
async consumeMessageOnAztecAndMintPrivately(
|
|
@@ -257,8 +258,7 @@ export class CrossChainTestHarness {
|
|
|
257
258
|
const { recipient, claimAmount, claimSecret: secretForL2MessageConsumption, messageLeafIndex } = claim;
|
|
258
259
|
await this.l2Bridge.methods
|
|
259
260
|
.claim_private(recipient, claimAmount, secretForL2MessageConsumption, messageLeafIndex)
|
|
260
|
-
.send({ from: this.ownerAddress })
|
|
261
|
-
.wait();
|
|
261
|
+
.send({ from: this.ownerAddress });
|
|
262
262
|
}
|
|
263
263
|
|
|
264
264
|
async consumeMessageOnAztecAndMintPublicly(
|
|
@@ -268,34 +268,31 @@ export class CrossChainTestHarness {
|
|
|
268
268
|
const { claimAmount, claimSecret, messageLeafIndex } = claim;
|
|
269
269
|
await this.l2Bridge.methods
|
|
270
270
|
.claim_public(this.ownerAddress, claimAmount, claimSecret, messageLeafIndex)
|
|
271
|
-
.send({ from: this.ownerAddress })
|
|
272
|
-
.wait();
|
|
271
|
+
.send({ from: this.ownerAddress });
|
|
273
272
|
}
|
|
274
273
|
|
|
275
274
|
async withdrawPrivateFromAztecToL1(
|
|
276
275
|
withdrawAmount: bigint,
|
|
277
276
|
authwitNonce: Fr = Fr.ZERO,
|
|
278
277
|
authWitness: AuthWitness,
|
|
279
|
-
): Promise<
|
|
280
|
-
const withdrawReceipt = await this.l2Bridge.methods
|
|
278
|
+
): Promise<TxReceipt> {
|
|
279
|
+
const { receipt: withdrawReceipt } = await this.l2Bridge.methods
|
|
281
280
|
.exit_to_l1_private(this.l2Token.address, this.ethAccount, withdrawAmount, EthAddress.ZERO, authwitNonce)
|
|
282
|
-
.send({ authWitnesses: [authWitness], from: this.ownerAddress })
|
|
283
|
-
.wait();
|
|
281
|
+
.send({ authWitnesses: [authWitness], from: this.ownerAddress });
|
|
284
282
|
|
|
285
283
|
return withdrawReceipt;
|
|
286
284
|
}
|
|
287
285
|
|
|
288
|
-
async withdrawPublicFromAztecToL1(withdrawAmount: bigint, authwitNonce: Fr = Fr.ZERO): Promise<
|
|
289
|
-
const withdrawReceipt = await this.l2Bridge.methods
|
|
286
|
+
async withdrawPublicFromAztecToL1(withdrawAmount: bigint, authwitNonce: Fr = Fr.ZERO): Promise<TxReceipt> {
|
|
287
|
+
const { receipt: withdrawReceipt } = await this.l2Bridge.methods
|
|
290
288
|
.exit_to_l1_public(this.ethAccount, withdrawAmount, EthAddress.ZERO, authwitNonce)
|
|
291
|
-
.send({ from: this.ownerAddress })
|
|
292
|
-
.wait();
|
|
289
|
+
.send({ from: this.ownerAddress });
|
|
293
290
|
|
|
294
291
|
return withdrawReceipt;
|
|
295
292
|
}
|
|
296
293
|
|
|
297
294
|
async getL2PrivateBalanceOf(owner: AztecAddress) {
|
|
298
|
-
return await this.l2Token.methods.balance_of_private(owner).simulate({ from: owner });
|
|
295
|
+
return (await this.l2Token.methods.balance_of_private(owner).simulate({ from: owner })).result;
|
|
299
296
|
}
|
|
300
297
|
|
|
301
298
|
async expectPrivateBalanceOnL2(owner: AztecAddress, expectedBalance: bigint) {
|
|
@@ -305,7 +302,7 @@ export class CrossChainTestHarness {
|
|
|
305
302
|
}
|
|
306
303
|
|
|
307
304
|
async getL2PublicBalanceOf(owner: AztecAddress) {
|
|
308
|
-
return await this.l2Token.methods.balance_of_public(owner).simulate({ from: this.ownerAddress });
|
|
305
|
+
return (await this.l2Token.methods.balance_of_public(owner).simulate({ from: this.ownerAddress })).result;
|
|
309
306
|
}
|
|
310
307
|
|
|
311
308
|
async expectPublicBalanceOnL2(owner: AztecAddress, expectedBalance: bigint) {
|
|
@@ -324,14 +321,16 @@ export class CrossChainTestHarness {
|
|
|
324
321
|
|
|
325
322
|
withdrawFundsFromBridgeOnL1(
|
|
326
323
|
amount: bigint,
|
|
327
|
-
|
|
324
|
+
epochNumber: EpochNumber,
|
|
325
|
+
numCheckpointsInEpoch: number,
|
|
328
326
|
messageIndex: bigint,
|
|
329
327
|
siblingPath: SiblingPath<number>,
|
|
330
328
|
) {
|
|
331
329
|
return this.l1TokenPortalManager.withdrawFunds(
|
|
332
330
|
amount,
|
|
333
331
|
this.ethAccount,
|
|
334
|
-
|
|
332
|
+
epochNumber,
|
|
333
|
+
numCheckpointsInEpoch,
|
|
335
334
|
messageIndex,
|
|
336
335
|
siblingPath,
|
|
337
336
|
);
|
|
@@ -339,18 +338,14 @@ export class CrossChainTestHarness {
|
|
|
339
338
|
|
|
340
339
|
async transferToPrivateOnL2(shieldAmount: bigint) {
|
|
341
340
|
this.logger.info('Transferring to private on L2');
|
|
342
|
-
await this.l2Token.methods
|
|
343
|
-
.transfer_to_private(this.ownerAddress, shieldAmount)
|
|
344
|
-
.send({ from: this.ownerAddress })
|
|
345
|
-
.wait();
|
|
341
|
+
await this.l2Token.methods.transfer_to_private(this.ownerAddress, shieldAmount).send({ from: this.ownerAddress });
|
|
346
342
|
}
|
|
347
343
|
|
|
348
344
|
async transferToPublicOnL2(amount: bigint, authwitNonce = Fr.ZERO) {
|
|
349
345
|
this.logger.info('Transferring tokens to public');
|
|
350
346
|
await this.l2Token.methods
|
|
351
347
|
.transfer_to_public(this.ownerAddress, this.ownerAddress, amount, authwitNonce)
|
|
352
|
-
.send({ from: this.ownerAddress })
|
|
353
|
-
.wait();
|
|
348
|
+
.send({ from: this.ownerAddress });
|
|
354
349
|
}
|
|
355
350
|
|
|
356
351
|
/**
|
|
@@ -362,8 +357,7 @@ export class CrossChainTestHarness {
|
|
|
362
357
|
*/
|
|
363
358
|
async makeMessageConsumable(msgHash: Fr | Hex) {
|
|
364
359
|
const frMsgHash = typeof msgHash === 'string' ? Fr.fromHexString(msgHash) : msgHash;
|
|
365
|
-
|
|
366
|
-
await retryUntil(async () => await this.aztecNode.isL1ToL2MessageSynced(frMsgHash), 'message sync', 10);
|
|
360
|
+
await waitForL1ToL2MessageSeen(this.aztecNode, frMsgHash, { timeoutSeconds: 10 });
|
|
367
361
|
|
|
368
362
|
await this.mintTokensPublicOnL2(0n);
|
|
369
363
|
await this.mintTokensPublicOnL2(0n);
|