@aztec/end-to-end 0.0.0-test.1 → 0.0.1-commit.017a351
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 +76 -0
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/benchmark.js +298 -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 +318 -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 +46 -72
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +30 -20
- 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 +137 -106
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +44 -33
- 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 +136 -103
- package/dest/e2e_deploy_contract/deploy_test.d.ts +20 -11
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +28 -28
- package/dest/e2e_epochs/epochs_test.d.ts +98 -24
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +366 -61
- 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 +42 -24
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +194 -182
- 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 +16 -16
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +38 -43
- 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 +137 -0
- package/dest/e2e_p2p/p2p_network.d.ts +287 -31
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +281 -183
- 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 +73 -8
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +205 -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 +30 -15
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +110 -76
- 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 +56 -0
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
- package/dest/fixtures/e2e_prover_test.js +267 -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 +79 -8
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +76 -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/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 +272 -0
- package/dest/fixtures/setup.d.ts.map +1 -0
- package/dest/fixtures/setup.js +735 -0
- package/dest/fixtures/setup_p2p_test.d.ts +28 -16
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +103 -32
- 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 +30 -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/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/index.d.ts +1 -1
- 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 +46 -27
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +113 -55
- package/dest/shared/gas_portal_test_harness.d.ts +39 -28
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +64 -34
- 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 +202 -135
- 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/index.d.ts +1 -1
- package/dest/simulators/lending_simulator.d.ts +16 -9
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +38 -27
- 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 +301 -63
- package/dest/spartan/tx_metrics.d.ts +102 -0
- package/dest/spartan/tx_metrics.d.ts.map +1 -0
- package/dest/spartan/tx_metrics.js +475 -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 +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 -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 +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 +53 -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 +79 -64
- package/src/bench/client_flows/benchmark.ts +382 -0
- package/src/bench/client_flows/client_flows_benchmark.ts +399 -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 +49 -87
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +164 -172
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +194 -183
- package/src/e2e_deploy_contract/deploy_test.ts +42 -49
- package/src/e2e_epochs/epochs_test.ts +451 -93
- package/src/e2e_fees/bridging_race.notest.ts +74 -0
- package/src/e2e_fees/fees_test.ts +249 -262
- 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 +51 -60
- package/src/e2e_p2p/inactivity_slash_test.ts +180 -0
- package/src/e2e_p2p/p2p_network.ts +391 -240
- package/src/e2e_p2p/reqresp/utils.ts +274 -0
- package/src/e2e_p2p/shared.ts +304 -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 +140 -124
- 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 +329 -0
- package/src/fixtures/elu_monitor.ts +126 -0
- package/src/fixtures/fixtures.ts +98 -7
- package/src/fixtures/get_acvm_config.ts +4 -12
- package/src/fixtures/get_bb_config.ts +19 -13
- package/src/fixtures/ha_setup.ts +188 -0
- package/src/fixtures/index.ts +1 -0
- package/src/fixtures/l1_to_l2_messaging.ts +56 -24
- package/src/fixtures/schnorr_hardcoded_account_contract.ts +49 -0
- package/src/fixtures/setup.ts +1056 -0
- package/src/fixtures/setup_p2p_test.ts +142 -54
- package/src/fixtures/token_utils.ts +34 -16
- package/src/fixtures/utils.ts +29 -820
- package/src/fixtures/web3signer.ts +63 -0
- package/src/fixtures/with_telemetry_utils.ts +2 -2
- 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 +9 -19
- 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} +2 -2
- package/src/quality_of_service/prometheus_client.ts +113 -0
- package/src/shared/cross_chain_test_harness.ts +116 -90
- package/src/shared/gas_portal_test_harness.ts +75 -56
- 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 +259 -234
- package/src/shared/wait_for_l1_to_l2_message.ts +23 -0
- package/src/simulators/lending_simulator.ts +43 -26
- package/src/simulators/token_simulator.ts +18 -34
- package/src/spartan/DEVELOP.md +128 -0
- package/src/spartan/setup_test_wallets.ts +420 -96
- package/src/spartan/tx_metrics.ts +434 -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 +376 -0
- package/src/test-wallet/utils.ts +108 -0
- package/src/test-wallet/wallet_worker_script.ts +63 -0
- package/src/test-wallet/worker_wallet.ts +218 -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
package/dest/bench/utils.js
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { writeFileSync } from 'fs';
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import { join } from 'path';
|
|
1
|
+
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { BatchCall, NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
3
|
+
import { waitForTx } from '@aztec/aztec.js/node';
|
|
4
|
+
import { mean, stdDev, times } from '@aztec/foundation/collection';
|
|
5
|
+
import { BenchmarkingContract } from '@aztec/noir-test-contracts.js/Benchmarking';
|
|
6
|
+
import { mkdirSync, writeFileSync } from 'fs';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
import { PIPELINING_SETUP_OPTS } from '../fixtures/fixtures.js';
|
|
10
9
|
import { setup } from '../fixtures/utils.js';
|
|
11
10
|
/**
|
|
12
11
|
* Setup for benchmarks. Initializes a remote node with a single account and deploys a benchmark contract.
|
|
13
12
|
*/ export async function benchmarkSetup(opts) {
|
|
14
13
|
const context = await setup(1, {
|
|
14
|
+
...PIPELINING_SETUP_OPTS,
|
|
15
15
|
...opts,
|
|
16
16
|
telemetryConfig: {
|
|
17
17
|
benchmark: true
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
|
-
const
|
|
20
|
+
const defaultAccountAddress = context.accounts[0];
|
|
21
|
+
const { contract } = await BenchmarkingContract.deploy(context.wallet).send({
|
|
22
|
+
from: defaultAccountAddress
|
|
23
|
+
});
|
|
21
24
|
context.logger.info(`Deployed benchmarking contract at ${contract.address}`);
|
|
22
25
|
const sequencer = context.aztecNode.getSequencer();
|
|
23
26
|
const telemetry = context.telemetryClient;
|
|
@@ -28,7 +31,13 @@ import { setup } from '../fixtures/utils.js';
|
|
|
28
31
|
await telemetry.flush();
|
|
29
32
|
const data = telemetry.getMeters();
|
|
30
33
|
const formatted = formatMetricsForGithubBenchmarkAction(data, opts.metrics);
|
|
34
|
+
if (formatted.length === 0) {
|
|
35
|
+
throw new Error(`No benchmark data generated. Please review your test setup.`);
|
|
36
|
+
}
|
|
31
37
|
const benchOutput = opts.benchOutput ?? process.env.BENCH_OUTPUT ?? 'bench.json';
|
|
38
|
+
mkdirSync(path.dirname(benchOutput), {
|
|
39
|
+
recursive: true
|
|
40
|
+
});
|
|
32
41
|
writeFileSync(benchOutput, JSON.stringify(formatted));
|
|
33
42
|
context.logger.info(`Wrote ${data.length} metrics to ${benchOutput}`);
|
|
34
43
|
await origTeardown();
|
|
@@ -40,17 +49,20 @@ import { setup } from '../fixtures/utils.js';
|
|
|
40
49
|
sequencer
|
|
41
50
|
};
|
|
42
51
|
}
|
|
52
|
+
function isMetricDefinition(f) {
|
|
53
|
+
return 'description' in f;
|
|
54
|
+
}
|
|
43
55
|
function formatMetricsForGithubBenchmarkAction(data, filter) {
|
|
44
|
-
const allFilters = filter.map((f)=>
|
|
45
|
-
name: f,
|
|
56
|
+
const allFilters = filter.map((f)=>isMetricDefinition(f) ? {
|
|
57
|
+
name: f.name,
|
|
46
58
|
source: f,
|
|
47
59
|
transform: (x)=>x,
|
|
48
|
-
unit:
|
|
60
|
+
unit: f.unit
|
|
49
61
|
} : f);
|
|
50
62
|
return data.flatMap((meter)=>{
|
|
51
|
-
return meter.metrics.filter((metric)=>allFilters.map((f)=>f.source).includes(metric.name)).map((metric)=>[
|
|
63
|
+
return meter.metrics.filter((metric)=>allFilters.map((f)=>f.source.name).includes(metric.name)).map((metric)=>[
|
|
52
64
|
metric,
|
|
53
|
-
allFilters.find((f)=>f.source === metric.name)
|
|
65
|
+
allFilters.find((f)=>f.source.name === metric.name)
|
|
54
66
|
]).map(([metric, filter])=>({
|
|
55
67
|
name: `${meter.name}/${filter.name}`,
|
|
56
68
|
unit: filter.unit ?? metric.unit ?? 'unknown',
|
|
@@ -76,28 +88,6 @@ function getMetricValues(points) {
|
|
|
76
88
|
};
|
|
77
89
|
}
|
|
78
90
|
}
|
|
79
|
-
/**
|
|
80
|
-
* Creates and returns a directory with the current job name and a random number.
|
|
81
|
-
* @param index - Index to merge into the dir path.
|
|
82
|
-
* @returns A path to a created dir.
|
|
83
|
-
*/ export function makeDataDirectory(index) {
|
|
84
|
-
const testName = expect.getState().currentTestName.split(' ')[0].replaceAll('/', '_');
|
|
85
|
-
const db = join('data', testName, index.toString(), `${randomInt(99)}`);
|
|
86
|
-
mkdirpSync(db);
|
|
87
|
-
return db;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Returns the size in disk of a folder.
|
|
91
|
-
* @param path - Path to the folder.
|
|
92
|
-
* @returns Size in bytes.
|
|
93
|
-
*/ export function getFolderSize(path) {
|
|
94
|
-
return globSync('**', {
|
|
95
|
-
stat: true,
|
|
96
|
-
cwd: path,
|
|
97
|
-
nodir: true,
|
|
98
|
-
withFileTypes: true
|
|
99
|
-
}).reduce((accum, file)=>accum + file.size, 0);
|
|
100
|
-
}
|
|
101
91
|
/**
|
|
102
92
|
* Returns a call to the benchmark contract. Each call has a private execution (account entrypoint),
|
|
103
93
|
* a nested private call (create_note), a public call (increment_balance), and a nested public
|
|
@@ -108,17 +98,19 @@ function getMetricValues(points) {
|
|
|
108
98
|
* @param contract - Benchmarking contract.
|
|
109
99
|
* @param heavyPublicCompute - Whether the transactions include heavy public compute (like a big sha256).
|
|
110
100
|
* @returns A BatchCall instance.
|
|
111
|
-
*/
|
|
112
|
-
const owner = context.wallet.getAddress();
|
|
113
|
-
const sender = owner;
|
|
101
|
+
*/ async function makeCall(index, context, contract, heavyPublicCompute) {
|
|
114
102
|
if (heavyPublicCompute) {
|
|
115
103
|
return new BatchCall(context.wallet, [
|
|
116
|
-
|
|
104
|
+
contract.methods.sha256_hash_1024(randomBytesAsBigInts(1024))
|
|
117
105
|
]);
|
|
118
106
|
} else {
|
|
107
|
+
// We use random address for the new note owner because we can emit at most UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN
|
|
108
|
+
// logs for a given sender-recipient-contract tuple.
|
|
109
|
+
const ownerOfNewNote = await AztecAddress.random();
|
|
110
|
+
const [ownerOfBalance] = context.accounts;
|
|
119
111
|
return new BatchCall(context.wallet, [
|
|
120
|
-
|
|
121
|
-
|
|
112
|
+
contract.methods.create_note(ownerOfNewNote, index + 1),
|
|
113
|
+
contract.methods.increment_balance(ownerOfBalance, index + 1)
|
|
122
114
|
]);
|
|
123
115
|
}
|
|
124
116
|
}
|
|
@@ -131,40 +123,22 @@ function getMetricValues(points) {
|
|
|
131
123
|
* @param heavyPublicCompute - Whether the transactions include heavy public compute (like a big sha256).
|
|
132
124
|
* @returns Array of sent txs.
|
|
133
125
|
*/ export async function sendTxs(txCount, context, contract, heavyPublicCompute = false) {
|
|
134
|
-
const calls = await
|
|
126
|
+
const calls = await Promise.all(times(txCount, (index)=>makeCall(index, context, contract, heavyPublicCompute)));
|
|
135
127
|
context.logger.info(`Creating ${txCount} txs`);
|
|
136
|
-
const
|
|
137
|
-
skipPublicSimulation: true
|
|
138
|
-
})));
|
|
128
|
+
const [from] = context.accounts;
|
|
139
129
|
context.logger.info(`Sending ${txCount} txs`);
|
|
140
|
-
return
|
|
130
|
+
return Promise.all(calls.map(async (call)=>{
|
|
131
|
+
const { txHash } = await call.send({
|
|
132
|
+
from,
|
|
133
|
+
wait: NO_WAIT
|
|
134
|
+
});
|
|
135
|
+
return txHash;
|
|
136
|
+
}));
|
|
141
137
|
}
|
|
142
138
|
export async function waitTxs(txs, context, txWaitOpts) {
|
|
143
139
|
context.logger.info(`Awaiting ${txs.length} txs to be mined`);
|
|
144
|
-
await Promise.all(txs.map((
|
|
145
|
-
context.logger.info(
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Creates a new PXE
|
|
149
|
-
* @param node - Node to connect the pxe to.
|
|
150
|
-
* @param contract - Benchmark contract to add to the pxe.
|
|
151
|
-
* @param startingBlock - First l2 block to process.
|
|
152
|
-
* @returns The new PXE.
|
|
153
|
-
*/ export async function createNewPXE(node, contract, startingBlock = INITIAL_L2_BLOCK_NUM) {
|
|
154
|
-
const l1Contracts = await node.getL1ContractAddresses();
|
|
155
|
-
const { l1ChainId, protocolVersion } = await node.getNodeInfo();
|
|
156
|
-
const pxeConfig = {
|
|
157
|
-
l2StartingBlock: startingBlock,
|
|
158
|
-
l2BlockPollingIntervalMS: 100,
|
|
159
|
-
dataDirectory: undefined,
|
|
160
|
-
dataStoreMapSizeKB: 1024 * 1024,
|
|
161
|
-
l1Contracts,
|
|
162
|
-
l1ChainId,
|
|
163
|
-
version: protocolVersion
|
|
164
|
-
};
|
|
165
|
-
const pxe = await createPXEService(node, pxeConfig);
|
|
166
|
-
await pxe.registerContract(contract);
|
|
167
|
-
return pxe;
|
|
140
|
+
await Promise.all(txs.map((txHash)=>waitForTx(context.aztecNode, txHash, txWaitOpts)));
|
|
141
|
+
context.logger.info(`${txs.length} txs have been mined`);
|
|
168
142
|
}
|
|
169
143
|
function randomBytesAsBigInts(length) {
|
|
170
144
|
return [
|
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
3
|
+
import { type Logger } from '@aztec/aztec.js/log';
|
|
4
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
5
|
+
import type { TxHash } from '@aztec/aztec.js/tx';
|
|
6
|
+
import type { CheatCodes } from '@aztec/aztec/testing';
|
|
3
7
|
import { TokenBlacklistContract } from '@aztec/noir-contracts.js/TokenBlacklist';
|
|
4
|
-
import {
|
|
8
|
+
import { GenericProxyContract } from '@aztec/noir-test-contracts.js/GenericProxy';
|
|
9
|
+
import { InvalidAccountContract } from '@aztec/noir-test-contracts.js/InvalidAccount';
|
|
10
|
+
import type { SequencerClient } from '@aztec/sequencer-client';
|
|
11
|
+
import type { AztecNodeDebug } from '@aztec/stdlib/interfaces/client';
|
|
12
|
+
import { type EndToEndContext, type SetupOptions } from '../fixtures/setup.js';
|
|
5
13
|
import { TokenSimulator } from '../simulators/token_simulator.js';
|
|
14
|
+
import type { TestWallet } from '../test-wallet/test_wallet.js';
|
|
6
15
|
export declare class Role {
|
|
7
16
|
private isAdmin;
|
|
8
17
|
private isMinter;
|
|
@@ -17,30 +26,31 @@ export declare class Role {
|
|
|
17
26
|
};
|
|
18
27
|
}
|
|
19
28
|
export declare class BlacklistTokenContractTest {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
private snapshotManager;
|
|
29
|
+
static CHANGE_ROLES_DELAY: number;
|
|
30
|
+
context: EndToEndContext;
|
|
23
31
|
logger: Logger;
|
|
24
|
-
|
|
25
|
-
accounts: CompleteAddress[];
|
|
32
|
+
wallet: TestWallet;
|
|
26
33
|
asset: TokenBlacklistContract;
|
|
27
34
|
tokenSim: TokenSimulator;
|
|
28
|
-
badAccount:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
35
|
+
badAccount: InvalidAccountContract;
|
|
36
|
+
authwitProxy: GenericProxyContract;
|
|
37
|
+
cheatCodes: CheatCodes;
|
|
38
|
+
sequencer: SequencerClient;
|
|
39
|
+
aztecNode: AztecNode & AztecNodeDebug;
|
|
40
|
+
adminAddress: AztecAddress;
|
|
41
|
+
otherAddress: AztecAddress;
|
|
42
|
+
blacklistedAddress: AztecAddress;
|
|
32
43
|
constructor(testName: string);
|
|
33
|
-
|
|
44
|
+
crossTimestampOfChange(): Promise<void>;
|
|
34
45
|
/**
|
|
35
|
-
*
|
|
46
|
+
* Applies base setup:
|
|
36
47
|
* 1. Add 3 accounts.
|
|
37
48
|
* 2. Publicly deploy accounts, deploy token contract and a "bad account".
|
|
38
49
|
*/
|
|
39
|
-
|
|
40
|
-
setup(): Promise<void>;
|
|
41
|
-
snapshot: <T>(name: string, apply: (context: SubsystemsContext) => Promise<T>, restore?: (snapshotData: T, context: SubsystemsContext) => Promise<void>) => Promise<void>;
|
|
50
|
+
applyBaseSetup(): Promise<void>;
|
|
51
|
+
setup(opts?: Partial<SetupOptions>): Promise<void>;
|
|
42
52
|
teardown(): Promise<void>;
|
|
43
|
-
addPendingShieldNoteToPXE(contract: TokenBlacklistContract,
|
|
44
|
-
|
|
53
|
+
addPendingShieldNoteToPXE(contract: TokenBlacklistContract, recipient: AztecAddress, amount: bigint, secretHash: Fr, txHash: TxHash): Promise<void>;
|
|
54
|
+
applyMint(): Promise<void>;
|
|
45
55
|
}
|
|
46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0FBTyxDQUFDLFlBQVksQ0FBTSxpQkFRM0M7SUFFSyxRQUFRLGtCQUViO0lBRUsseUJBQXlCLENBQzdCLFFBQVEsRUFBRSxzQkFBc0IsRUFDaEMsU0FBUyxFQUFFLFlBQVksRUFDdkIsTUFBTSxFQUFFLE1BQU0sRUFDZCxVQUFVLEVBQUUsRUFBRSxFQUNkLE1BQU0sRUFBRSxNQUFNLGlCQWNmO0lBRUssU0FBUyxrQkFtRGQ7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blacklist_token_contract_test.d.ts","sourceRoot":"","sources":["../../src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"blacklist_token_contract_test.d.ts","sourceRoot":"","sources":["../../src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAC5C,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,qBAAqB,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAClF,OAAO,EAAE,sBAAsB,EAAE,MAAM,8CAA8C,CAAC;AACtF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAItE,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,YAAY,EAMlB,MAAM,sBAAsB,CAAC;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ztec/noir-contracts.js/DocsExample';
|
|
1
|
+
import { computeSecretHash } from '@aztec/aztec.js/crypto';
|
|
2
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
3
|
+
import { createLogger } from '@aztec/aztec.js/log';
|
|
5
4
|
import { TokenBlacklistContract } from '@aztec/noir-contracts.js/TokenBlacklist';
|
|
5
|
+
import { GenericProxyContract } from '@aztec/noir-test-contracts.js/GenericProxy';
|
|
6
|
+
import { InvalidAccountContract } from '@aztec/noir-test-contracts.js/InvalidAccount';
|
|
6
7
|
import { jest } from '@jest/globals';
|
|
7
|
-
import {
|
|
8
|
+
import { deployAccounts, ensureAuthRegistryPublished, publicDeployAccounts, setup, teardown } from '../fixtures/setup.js';
|
|
8
9
|
import { TokenSimulator } from '../simulators/token_simulator.js';
|
|
9
|
-
const { E2E_DATA_PATH: dataPath } = process.env;
|
|
10
10
|
export class Role {
|
|
11
11
|
isAdmin = false;
|
|
12
12
|
isMinter = false;
|
|
@@ -34,124 +34,155 @@ export class Role {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
export class BlacklistTokenContractTest {
|
|
37
|
-
// A low delay is really poor ux, but we need to keep it low for the tests to run "quickly".
|
|
38
37
|
// This value MUST match the same value that we have in the contract
|
|
39
|
-
static
|
|
40
|
-
|
|
38
|
+
static CHANGE_ROLES_DELAY = 86400;
|
|
39
|
+
context;
|
|
41
40
|
logger;
|
|
42
|
-
|
|
43
|
-
accounts = [];
|
|
41
|
+
wallet;
|
|
44
42
|
asset;
|
|
45
43
|
tokenSim;
|
|
46
44
|
badAccount;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
authwitProxy;
|
|
46
|
+
cheatCodes;
|
|
47
|
+
sequencer;
|
|
48
|
+
aztecNode;
|
|
49
|
+
adminAddress;
|
|
50
|
+
otherAddress;
|
|
51
|
+
blacklistedAddress;
|
|
50
52
|
constructor(testName){
|
|
51
53
|
this.logger = createLogger(`e2e:e2e_blacklist_token_contract:${testName}`);
|
|
52
|
-
this.snapshotManager = createSnapshotManager(`e2e_blacklist_token_contract/${testName}`, dataPath);
|
|
53
54
|
}
|
|
54
|
-
async
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
async crossTimestampOfChange() {
|
|
56
|
+
// Under AUTOMINE_E2E_OPTS, the 86400s warp crosses many epochs without any proofs being
|
|
57
|
+
// submitted. Mark current pending checkpoints as proven first so the rollup contract's
|
|
58
|
+
// pruning window doesn't reset the chain tip to genesis (which would make the warp's
|
|
59
|
+
// own empty-checkpoint propose fail with Rollup__InvalidArchive). See the AutomineSequencer
|
|
60
|
+
// README "Epoch proving caveat" and the equivalent pattern in lending_simulator.progressSlots.
|
|
61
|
+
await this.cheatCodes.rollup.markAsProven();
|
|
62
|
+
await this.cheatCodes.warpL2TimeAtLeastBy(this.aztecNode, BlacklistTokenContractTest.CHANGE_ROLES_DELAY);
|
|
58
63
|
}
|
|
59
64
|
/**
|
|
60
|
-
*
|
|
65
|
+
* Applies base setup:
|
|
61
66
|
* 1. Add 3 accounts.
|
|
62
67
|
* 2. Publicly deploy accounts, deploy token contract and a "bad account".
|
|
63
|
-
*/ async
|
|
64
|
-
//
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
this.accounts = this.wallets.map((w)=>w.getCompleteAddress());
|
|
72
|
-
});
|
|
73
|
-
await this.snapshotManager.snapshot('e2e_blacklist_token_contract', async ()=>{
|
|
74
|
-
// Create the token contract state.
|
|
75
|
-
// Move this account thing to addAccounts above?
|
|
76
|
-
this.logger.verbose(`Public deploy accounts...`);
|
|
77
|
-
await publicDeployAccounts(this.wallets[0], this.accounts.slice(0, 3));
|
|
78
|
-
this.logger.verbose(`Deploying TokenContract...`);
|
|
79
|
-
this.asset = await TokenBlacklistContract.deploy(this.admin, this.admin.getAddress()).send().deployed();
|
|
80
|
-
this.logger.verbose(`Token deployed to ${this.asset.address}`);
|
|
81
|
-
this.logger.verbose(`Deploying bad account...`);
|
|
82
|
-
this.badAccount = await DocsExampleContract.deploy(this.wallets[0]).send().deployed();
|
|
83
|
-
this.logger.verbose(`Deployed to ${this.badAccount.address}.`);
|
|
84
|
-
await this.mineBlocks();
|
|
85
|
-
return {
|
|
86
|
-
tokenContractAddress: this.asset.address,
|
|
87
|
-
badAccountAddress: this.badAccount.address
|
|
88
|
-
};
|
|
89
|
-
}, async ({ tokenContractAddress, badAccountAddress })=>{
|
|
90
|
-
// Restore the token contract state.
|
|
91
|
-
this.asset = await TokenBlacklistContract.at(tokenContractAddress, this.wallets[0]);
|
|
92
|
-
this.logger.verbose(`Token contract address: ${this.asset.address}`);
|
|
93
|
-
this.tokenSim = new TokenSimulator(this.asset, this.wallets[0], this.logger, this.accounts.map((a)=>a.address));
|
|
94
|
-
this.badAccount = await DocsExampleContract.at(badAccountAddress, this.wallets[0]);
|
|
95
|
-
this.logger.verbose(`Bad account address: ${this.badAccount.address}`);
|
|
96
|
-
expect(await this.asset.methods.get_roles(this.admin.getAddress()).simulate()).toEqual(new Role().withAdmin().toNoirStruct());
|
|
68
|
+
*/ async applyBaseSetup() {
|
|
69
|
+
// Bumped from 2 min: pipelined cadence (~24s/dependent-tx) makes the 3-account deploy plus token/bad-account/
|
|
70
|
+
// proxy deploys exceed the original window.
|
|
71
|
+
jest.setTimeout(600_000);
|
|
72
|
+
this.logger.info('Deploying 3 accounts');
|
|
73
|
+
const { deployedAccounts } = await deployAccounts(3, this.logger)({
|
|
74
|
+
wallet: this.context.wallet,
|
|
75
|
+
initialFundedAccounts: this.context.initialFundedAccounts
|
|
97
76
|
});
|
|
77
|
+
this.cheatCodes = this.context.cheatCodes;
|
|
78
|
+
this.aztecNode = this.context.aztecNodeService;
|
|
79
|
+
this.sequencer = this.context.sequencer;
|
|
80
|
+
this.wallet = this.context.wallet;
|
|
81
|
+
this.adminAddress = deployedAccounts[0].address;
|
|
82
|
+
this.otherAddress = deployedAccounts[1].address;
|
|
83
|
+
this.blacklistedAddress = deployedAccounts[2].address;
|
|
84
|
+
this.logger.info('Setting up blacklist token contract');
|
|
85
|
+
await ensureAuthRegistryPublished(this.wallet, this.adminAddress);
|
|
86
|
+
// Create the token contract state.
|
|
87
|
+
this.logger.verbose(`Public deploy accounts...`);
|
|
88
|
+
await publicDeployAccounts(this.wallet, [
|
|
89
|
+
this.adminAddress,
|
|
90
|
+
this.otherAddress,
|
|
91
|
+
this.blacklistedAddress
|
|
92
|
+
]);
|
|
93
|
+
this.logger.verbose(`Deploying TokenContract...`);
|
|
94
|
+
({ contract: this.asset } = await TokenBlacklistContract.deploy(this.wallet, this.adminAddress).send({
|
|
95
|
+
from: this.adminAddress
|
|
96
|
+
}));
|
|
97
|
+
this.logger.verbose(`Token deployed to ${this.asset.address}`);
|
|
98
|
+
this.logger.verbose(`Deploying bad account...`);
|
|
99
|
+
({ contract: this.badAccount } = await InvalidAccountContract.deploy(this.wallet).send({
|
|
100
|
+
from: this.adminAddress
|
|
101
|
+
}));
|
|
102
|
+
this.logger.verbose(`Deployed to ${this.badAccount.address}.`);
|
|
103
|
+
// Deploy a proxy contract for "on behalf of other" tests. The note owner must be the tx sender
|
|
104
|
+
// (so their notes are in scope), but msg_sender in the target must differ from the note owner
|
|
105
|
+
// to trigger authwit validation. The proxy forwards calls so that msg_sender != tx sender.
|
|
106
|
+
this.logger.verbose(`Deploying generic proxy...`);
|
|
107
|
+
({ contract: this.authwitProxy } = await GenericProxyContract.deploy(this.wallet).send({
|
|
108
|
+
from: this.adminAddress
|
|
109
|
+
}));
|
|
110
|
+
this.logger.verbose(`Deployed to ${this.authwitProxy.address}.`);
|
|
111
|
+
await this.crossTimestampOfChange();
|
|
112
|
+
this.tokenSim = new TokenSimulator(this.asset, this.wallet, this.adminAddress, this.logger, [
|
|
113
|
+
this.adminAddress,
|
|
114
|
+
this.otherAddress,
|
|
115
|
+
this.blacklistedAddress
|
|
116
|
+
]);
|
|
117
|
+
expect((await this.asset.methods.get_roles(this.adminAddress).simulate({
|
|
118
|
+
from: this.adminAddress
|
|
119
|
+
})).result).toEqual(new Role().withAdmin().toNoirStruct());
|
|
98
120
|
}
|
|
99
|
-
async setup() {
|
|
100
|
-
|
|
121
|
+
async setup(opts = {}) {
|
|
122
|
+
this.logger.info('Setting up fresh context');
|
|
123
|
+
this.context = await setup(0, {
|
|
124
|
+
...opts,
|
|
125
|
+
fundSponsoredFPC: true,
|
|
126
|
+
skipAccountDeployment: true
|
|
127
|
+
});
|
|
128
|
+
await this.applyBaseSetup();
|
|
101
129
|
}
|
|
102
|
-
snapshot = (name, apply, restore = ()=>Promise.resolve())=>this.snapshotManager.snapshot(name, apply, restore);
|
|
103
130
|
async teardown() {
|
|
104
|
-
await this.
|
|
131
|
+
await teardown(this.context);
|
|
105
132
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
async addPendingShieldNoteToPXE(contract, wallet, amount, secretHash, txHash) {
|
|
113
|
-
const txEffects = await wallet.getTxEffect(txHash);
|
|
114
|
-
await contract.methods.deliver_transparent_note(contract.address, amount, secretHash, txHash.hash, this.#toBoundedVec(txEffects.data.noteHashes, MAX_NOTE_HASHES_PER_TX), txEffects.data.nullifiers[0], wallet.getAddress()).simulate();
|
|
133
|
+
async addPendingShieldNoteToPXE(contract, recipient, amount, secretHash, txHash) {
|
|
134
|
+
const txEffects = await this.aztecNode.getTxEffect(txHash);
|
|
135
|
+
await contract.methods.process_transparent_note(contract.address, amount, secretHash, txHash.hash, txEffects.data.noteHashes, txEffects.data.nullifiers[0], recipient).simulate({
|
|
136
|
+
from: recipient
|
|
137
|
+
});
|
|
115
138
|
}
|
|
116
|
-
async
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
this.
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
this.
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
139
|
+
async applyMint() {
|
|
140
|
+
this.logger.info('Applying mint setup');
|
|
141
|
+
const { asset, tokenSim } = this;
|
|
142
|
+
const amount = 10000n;
|
|
143
|
+
const adminMinterRole = new Role().withAdmin().withMinter();
|
|
144
|
+
await this.asset.methods.update_roles(this.adminAddress, adminMinterRole.toNoirStruct()).send({
|
|
145
|
+
from: this.adminAddress
|
|
146
|
+
});
|
|
147
|
+
const blacklistRole = new Role().withBlacklisted();
|
|
148
|
+
await this.asset.methods.update_roles(this.blacklistedAddress, blacklistRole.toNoirStruct()).send({
|
|
149
|
+
from: this.adminAddress
|
|
150
|
+
});
|
|
151
|
+
await this.crossTimestampOfChange();
|
|
152
|
+
expect((await this.asset.methods.get_roles(this.adminAddress).simulate({
|
|
153
|
+
from: this.adminAddress
|
|
154
|
+
})).result).toEqual(adminMinterRole.toNoirStruct());
|
|
155
|
+
this.logger.verbose(`Minting ${amount} publicly...`);
|
|
156
|
+
await asset.methods.mint_public(this.adminAddress, amount).send({
|
|
157
|
+
from: this.adminAddress
|
|
158
|
+
});
|
|
159
|
+
this.logger.verbose(`Minting ${amount} privately...`);
|
|
160
|
+
const secret = Fr.random();
|
|
161
|
+
const secretHash = await computeSecretHash(secret);
|
|
162
|
+
const { receipt } = await asset.methods.mint_private(amount, secretHash).send({
|
|
163
|
+
from: this.adminAddress
|
|
164
|
+
});
|
|
165
|
+
await this.addPendingShieldNoteToPXE(asset, this.adminAddress, amount, secretHash, receipt.txHash);
|
|
166
|
+
await asset.methods.redeem_shield(this.adminAddress, amount, secret).send({
|
|
167
|
+
from: this.adminAddress
|
|
168
|
+
});
|
|
169
|
+
this.logger.verbose(`Minting complete.`);
|
|
170
|
+
tokenSim.mintPublic(this.adminAddress, amount);
|
|
171
|
+
const { result: publicBalance } = await asset.methods.balance_of_public(this.adminAddress).simulate({
|
|
172
|
+
from: this.adminAddress
|
|
173
|
+
});
|
|
174
|
+
this.logger.verbose(`Public balance of wallet 0: ${publicBalance}`);
|
|
175
|
+
expect(publicBalance).toEqual(this.tokenSim.balanceOfPublic(this.adminAddress));
|
|
176
|
+
tokenSim.mintPrivate(this.adminAddress, amount);
|
|
177
|
+
const { result: privateBalance } = await asset.methods.balance_of_private(this.adminAddress).simulate({
|
|
178
|
+
from: this.adminAddress
|
|
179
|
+
});
|
|
180
|
+
this.logger.verbose(`Private balance of wallet 0: ${privateBalance}`);
|
|
181
|
+
expect(privateBalance).toEqual(tokenSim.balanceOfPrivate(this.adminAddress));
|
|
182
|
+
const { result: totalSupply } = await asset.methods.total_supply().simulate({
|
|
183
|
+
from: this.adminAddress
|
|
155
184
|
});
|
|
185
|
+
this.logger.verbose(`Total supply: ${totalSupply}`);
|
|
186
|
+
expect(totalSupply).toEqual(tokenSim.totalSupply);
|
|
156
187
|
}
|
|
157
188
|
}
|