@aztec/end-to-end 0.0.1-commit.e558bd1c → 0.0.1-commit.e57c76e
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 +15 -1
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/benchmark.js +17 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +3 -3
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +36 -39
- package/dest/bench/client_flows/config.d.ts +2 -2
- package/dest/bench/client_flows/config.d.ts.map +1 -1
- package/dest/bench/client_flows/config.js +18 -0
- package/dest/bench/utils.d.ts +1 -1
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +8 -3
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +8 -5
- 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 +36 -17
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +16 -5
- 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 +39 -7
- package/dest/e2e_deploy_contract/deploy_test.d.ts +4 -4
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +2 -1
- package/dest/e2e_epochs/epochs_test.d.ts +33 -8
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +143 -44
- package/dest/e2e_fees/fees_test.d.ts +6 -3
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +50 -17
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +3 -3
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +6 -7
- package/dest/e2e_p2p/inactivity_slash_test.d.ts +1 -1
- package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -1
- package/dest/e2e_p2p/inactivity_slash_test.js +4 -3
- package/dest/e2e_p2p/p2p_network.d.ts +14 -12
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +70 -34
- package/dest/e2e_p2p/reqresp/utils.d.ts +3 -3
- package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -1
- package/dest/e2e_p2p/reqresp/utils.js +67 -14
- package/dest/e2e_p2p/shared.d.ts +37 -8
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +88 -51
- 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 +6 -4
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +23 -11
- 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 +9 -8
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +39 -50
- 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 +74 -1
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +71 -0
- package/dest/fixtures/get_bb_config.d.ts +1 -1
- package/dest/fixtures/get_bb_config.d.ts.map +1 -1
- package/dest/fixtures/get_bb_config.js +5 -5
- package/dest/fixtures/ha_setup.d.ts +2 -2
- package/dest/fixtures/ha_setup.d.ts.map +1 -1
- package/dest/fixtures/ha_setup.js +4 -2
- 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 +86 -32
- package/dest/fixtures/setup.d.ts.map +1 -1
- package/dest/fixtures/setup.js +209 -169
- package/dest/fixtures/setup_p2p_test.d.ts +14 -7
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +18 -15
- 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 +5 -7
- package/dest/fixtures/utils.d.ts +2 -2
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +1 -1
- 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/shared/cross_chain_test_harness.d.ts +4 -2
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +22 -18
- package/dest/shared/gas_portal_test_harness.d.ts +8 -5
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +19 -10
- package/dest/shared/index.d.ts +2 -1
- package/dest/shared/index.d.ts.map +1 -1
- package/dest/shared/index.js +1 -0
- package/dest/shared/jest_setup.js +41 -1
- package/dest/shared/mock_state_view.d.ts +86 -0
- package/dest/shared/mock_state_view.d.ts.map +1 -0
- package/dest/shared/mock_state_view.js +186 -0
- package/dest/shared/submit-transactions.d.ts +2 -2
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/submit-transactions.js +1 -1
- package/dest/shared/uniswap_l1_l2.d.ts +1 -1
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +56 -41
- 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 +10 -3
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +26 -14
- package/dest/simulators/token_simulator.d.ts +1 -1
- package/dest/simulators/token_simulator.d.ts.map +1 -1
- package/dest/simulators/token_simulator.js +3 -24
- package/dest/spartan/setup_test_wallets.d.ts +12 -3
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +108 -41
- package/dest/spartan/tx_metrics.d.ts +18 -4
- package/dest/spartan/tx_metrics.d.ts.map +1 -1
- package/dest/spartan/tx_metrics.js +74 -21
- package/dest/spartan/utils/bot.d.ts +3 -2
- package/dest/spartan/utils/bot.d.ts.map +1 -1
- package/dest/spartan/utils/bot.js +2 -1
- package/dest/spartan/utils/config.d.ts +10 -30
- package/dest/spartan/utils/config.d.ts.map +1 -1
- package/dest/spartan/utils/config.js +3 -1
- package/dest/spartan/utils/index.d.ts +4 -2
- package/dest/spartan/utils/index.d.ts.map +1 -1
- package/dest/spartan/utils/index.js +5 -1
- package/dest/spartan/utils/k8s.d.ts +3 -1
- package/dest/spartan/utils/k8s.d.ts.map +1 -1
- package/dest/spartan/utils/k8s.js +6 -0
- package/dest/spartan/utils/nodes.d.ts +4 -5
- package/dest/spartan/utils/nodes.d.ts.map +1 -1
- package/dest/spartan/utils/nodes.js +11 -11
- 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/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 +49 -45
- package/src/bench/client_flows/benchmark.ts +19 -0
- package/src/bench/client_flows/client_flows_benchmark.ts +64 -49
- package/src/bench/client_flows/config.ts +9 -1
- package/src/bench/utils.ts +10 -4
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +52 -25
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +53 -15
- package/src/e2e_deploy_contract/deploy_test.ts +6 -5
- package/src/e2e_epochs/epochs_test.ts +166 -68
- package/src/e2e_fees/bridging_race.notest.ts +1 -1
- package/src/e2e_fees/fees_test.ts +57 -32
- package/src/e2e_nested_contract/nested_contract_test.ts +10 -6
- package/src/e2e_p2p/inactivity_slash_test.ts +8 -7
- package/src/e2e_p2p/p2p_network.ts +93 -49
- package/src/e2e_p2p/reqresp/utils.ts +84 -17
- package/src/e2e_p2p/shared.ts +108 -65
- 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 +38 -11
- package/src/fixtures/authwit_proxy.ts +54 -0
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/fixtures/e2e_prover_test.ts +49 -56
- package/src/fixtures/elu_monitor.ts +126 -0
- package/src/fixtures/fixtures.ts +93 -0
- package/src/fixtures/get_bb_config.ts +7 -6
- package/src/fixtures/ha_setup.ts +7 -3
- package/src/fixtures/schnorr_hardcoded_account_contract.ts +49 -0
- package/src/fixtures/setup.ts +272 -233
- package/src/fixtures/setup_p2p_test.ts +21 -25
- package/src/fixtures/token_utils.ts +3 -3
- package/src/fixtures/utils.ts +2 -0
- 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/shared/cross_chain_test_harness.ts +27 -13
- package/src/shared/gas_portal_test_harness.ts +21 -11
- package/src/shared/index.ts +1 -0
- package/src/shared/jest_setup.ts +51 -1
- package/src/shared/mock_state_view.ts +188 -0
- package/src/shared/submit-transactions.ts +3 -2
- package/src/shared/uniswap_l1_l2.ts +104 -53
- package/src/shared/wait_for_l1_to_l2_message.ts +23 -0
- package/src/simulators/lending_simulator.ts +32 -14
- package/src/simulators/token_simulator.ts +6 -30
- package/src/spartan/setup_test_wallets.ts +146 -35
- package/src/spartan/tx_metrics.ts +82 -24
- package/src/spartan/utils/bot.ts +4 -1
- package/src/spartan/utils/config.ts +2 -0
- package/src/spartan/utils/index.ts +7 -0
- package/src/spartan/utils/k8s.ts +8 -0
- package/src/spartan/utils/nodes.ts +17 -12
- package/src/spartan/utils/pod_logs.ts +99 -0
- 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
|
@@ -7,8 +7,7 @@ import { SecretValue } from '@aztec/foundation/config';
|
|
|
7
7
|
import { withLoggerBindings } from '@aztec/foundation/log/server';
|
|
8
8
|
import { bufferToHex } from '@aztec/foundation/string';
|
|
9
9
|
import type { DateProvider } from '@aztec/foundation/timer';
|
|
10
|
-
import type {
|
|
11
|
-
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
10
|
+
import type { GenesisData } from '@aztec/stdlib/world-state';
|
|
12
11
|
|
|
13
12
|
import getPort from 'get-port';
|
|
14
13
|
|
|
@@ -41,7 +40,7 @@ export async function createNodes(
|
|
|
41
40
|
bootstrapNodeEnr: string,
|
|
42
41
|
numNodes: number,
|
|
43
42
|
bootNodePort: number,
|
|
44
|
-
|
|
43
|
+
genesis?: GenesisData,
|
|
45
44
|
dataDirectory?: string,
|
|
46
45
|
metricsPort?: number,
|
|
47
46
|
indexOffset = 0,
|
|
@@ -66,7 +65,7 @@ export async function createNodes(
|
|
|
66
65
|
port,
|
|
67
66
|
bootstrapNodeEnr,
|
|
68
67
|
validatorIndices,
|
|
69
|
-
|
|
68
|
+
genesis,
|
|
70
69
|
dataDir,
|
|
71
70
|
metricsPort,
|
|
72
71
|
);
|
|
@@ -89,6 +88,10 @@ export type CreateNodeConfig = AztecNodeConfig & {
|
|
|
89
88
|
dontStartSequencer?: boolean;
|
|
90
89
|
/** Override the private key (instead of deriving from addressIndex). */
|
|
91
90
|
validatorPrivateKey?: `0x${string}`;
|
|
91
|
+
/** Corrupt only the block proposal at this indexWithinCheckpoint (testing only). */
|
|
92
|
+
invalidBlockProposalIndexWithinCheckpoint?: number;
|
|
93
|
+
/** Accept proposal gossip regardless of slot timing (testing only). */
|
|
94
|
+
skipProposalSlotValidation?: boolean;
|
|
92
95
|
};
|
|
93
96
|
|
|
94
97
|
/** Creates a P2P enabled instance of Aztec Node Service with a validator. */
|
|
@@ -98,7 +101,7 @@ export async function createNode(
|
|
|
98
101
|
tcpPort: number,
|
|
99
102
|
bootstrapNode: string | undefined,
|
|
100
103
|
addressIndex: number | number[],
|
|
101
|
-
|
|
104
|
+
genesis?: GenesisData,
|
|
102
105
|
dataDirectory?: string,
|
|
103
106
|
metricsPort?: number,
|
|
104
107
|
) {
|
|
@@ -109,7 +112,7 @@ export async function createNode(
|
|
|
109
112
|
return await AztecNodeService.createAndSync(
|
|
110
113
|
validatorConfig,
|
|
111
114
|
{ telemetry, dateProvider },
|
|
112
|
-
{
|
|
115
|
+
{ genesis, dontStartSequencer: config.dontStartSequencer },
|
|
113
116
|
);
|
|
114
117
|
});
|
|
115
118
|
}
|
|
@@ -120,7 +123,7 @@ export async function createNonValidatorNode(
|
|
|
120
123
|
dateProvider: DateProvider,
|
|
121
124
|
tcpPort: number,
|
|
122
125
|
bootstrapNode: string | undefined,
|
|
123
|
-
|
|
126
|
+
genesis?: GenesisData,
|
|
124
127
|
dataDirectory?: string,
|
|
125
128
|
metricsPort?: number,
|
|
126
129
|
) {
|
|
@@ -131,10 +134,10 @@ export async function createNonValidatorNode(
|
|
|
131
134
|
...p2pConfig,
|
|
132
135
|
disableValidator: true,
|
|
133
136
|
validatorPrivateKeys: undefined,
|
|
134
|
-
|
|
137
|
+
sequencerPublisherPrivateKeys: [],
|
|
135
138
|
};
|
|
136
139
|
const telemetry = await getEndToEndTestTelemetryClient(metricsPort);
|
|
137
|
-
return await AztecNodeService.createAndSync(config, { telemetry, dateProvider }, {
|
|
140
|
+
return await AztecNodeService.createAndSync(config, { telemetry, dateProvider }, { genesis });
|
|
138
141
|
});
|
|
139
142
|
}
|
|
140
143
|
|
|
@@ -143,31 +146,24 @@ export async function createProverNode(
|
|
|
143
146
|
tcpPort: number,
|
|
144
147
|
bootstrapNode: string | undefined,
|
|
145
148
|
addressIndex: number,
|
|
146
|
-
|
|
147
|
-
|
|
149
|
+
deps: { dateProvider: DateProvider },
|
|
150
|
+
genesis?: GenesisData,
|
|
148
151
|
dataDirectory?: string,
|
|
149
152
|
metricsPort?: number,
|
|
150
|
-
) {
|
|
153
|
+
): Promise<{ proverNode: AztecNodeService }> {
|
|
151
154
|
const actorIndex = proverCounter++;
|
|
152
155
|
return await withLoggerBindings({ actor: `prover-${actorIndex}` }, async () => {
|
|
153
156
|
const proverNodePrivateKey = getPrivateKeyFromIndex(ATTESTER_PRIVATE_KEYS_START_INDEX + addressIndex)!;
|
|
154
157
|
const telemetry = await getEndToEndTestTelemetryClient(metricsPort);
|
|
155
158
|
|
|
156
|
-
const
|
|
157
|
-
config,
|
|
158
|
-
bootstrapNode,
|
|
159
|
-
tcpPort,
|
|
160
|
-
dataDirectory,
|
|
161
|
-
);
|
|
159
|
+
const p2pConfig = await createP2PConfig(config, bootstrapNode, tcpPort, dataDirectory);
|
|
162
160
|
|
|
163
|
-
const aztecNodeRpcTxProvider = undefined;
|
|
164
161
|
return await createAndSyncProverNode(
|
|
165
162
|
bufferToHex(proverNodePrivateKey),
|
|
166
|
-
config,
|
|
167
|
-
{
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
{ ...proverNodeDeps, telemetry },
|
|
163
|
+
{ ...config, ...p2pConfig },
|
|
164
|
+
{ dataDirectory },
|
|
165
|
+
{ ...deps, telemetry },
|
|
166
|
+
{ genesis },
|
|
171
167
|
);
|
|
172
168
|
});
|
|
173
169
|
}
|
|
@@ -215,7 +211,7 @@ export async function createValidatorConfig(
|
|
|
215
211
|
...config,
|
|
216
212
|
...p2pConfig,
|
|
217
213
|
validatorPrivateKeys: new SecretValue(attesterPrivateKeys),
|
|
218
|
-
|
|
214
|
+
sequencerPublisherPrivateKeys: [new SecretValue(attesterPrivateKeys[0])],
|
|
219
215
|
};
|
|
220
216
|
|
|
221
217
|
return nodeConfig;
|
|
@@ -8,7 +8,6 @@ export async function deployToken(wallet: Wallet, admin: AztecAddress, initialAd
|
|
|
8
8
|
logger.info(`Deploying Token contract...`);
|
|
9
9
|
const { contract, instance } = await TokenContract.deploy(wallet, admin, 'TokenName', 'TokenSymbol', 18).send({
|
|
10
10
|
from: admin,
|
|
11
|
-
wait: { returnReceipt: true },
|
|
12
11
|
});
|
|
13
12
|
|
|
14
13
|
if (initialAdminBalance > 0n) {
|
|
@@ -25,8 +24,9 @@ export async function mintTokensToPrivate(
|
|
|
25
24
|
minter: AztecAddress,
|
|
26
25
|
recipient: AztecAddress,
|
|
27
26
|
amount: bigint,
|
|
27
|
+
additionalScopes?: AztecAddress[],
|
|
28
28
|
) {
|
|
29
|
-
await token.methods.mint_to_private(recipient, amount).send({ from: minter });
|
|
29
|
+
await token.methods.mint_to_private(recipient, amount).send({ from: minter, additionalScopes });
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export async function expectTokenBalance(
|
|
@@ -38,7 +38,7 @@ export async function expectTokenBalance(
|
|
|
38
38
|
) {
|
|
39
39
|
// Then check the balance
|
|
40
40
|
const contractWithWallet = TokenContract.at(token.address, wallet);
|
|
41
|
-
const balance = await contractWithWallet.methods.balance_of_private(owner).simulate({ from: owner });
|
|
41
|
+
const { result: balance } = await contractWithWallet.methods.balance_of_private(owner).simulate({ from: owner });
|
|
42
42
|
logger.info(`Account ${owner} balance: ${balance}`);
|
|
43
43
|
expect(balance).toBe(expectedBalance);
|
|
44
44
|
}
|
package/src/fixtures/utils.ts
CHANGED
|
@@ -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
|
+
};
|
|
@@ -13,11 +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
20
|
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
20
|
-
import { retryUntil } from '@aztec/foundation/retry';
|
|
21
21
|
import { TestERC20Abi, TokenPortalAbi, TokenPortalBytecode } from '@aztec/l1-artifacts';
|
|
22
22
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
23
23
|
import { TokenBridgeContract } from '@aztec/noir-contracts.js/TokenBridge';
|
|
@@ -25,6 +25,7 @@ import { TokenBridgeContract } from '@aztec/noir-contracts.js/TokenBridge';
|
|
|
25
25
|
import { type Hex, getContract } from 'viem';
|
|
26
26
|
|
|
27
27
|
import { mintTokensToPrivate } from '../fixtures/token_utils.js';
|
|
28
|
+
import { waitForL1ToL2MessageSeen } from './wait_for_l1_to_l2_message.js';
|
|
28
29
|
|
|
29
30
|
/**
|
|
30
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.
|
|
@@ -73,22 +74,26 @@ export async function deployAndInitializeTokenAndBridgeContracts(
|
|
|
73
74
|
});
|
|
74
75
|
|
|
75
76
|
// deploy l2 token
|
|
76
|
-
const token = await TokenContract.deploy(wallet, owner, 'TokenName', 'TokenSymbol', 18).send({
|
|
77
|
+
const { contract: token } = await TokenContract.deploy(wallet, owner, 'TokenName', 'TokenSymbol', 18).send({
|
|
78
|
+
from: owner,
|
|
79
|
+
});
|
|
77
80
|
|
|
78
81
|
// deploy l2 token bridge and attach to the portal
|
|
79
|
-
const bridge = await TokenBridgeContract.deploy(wallet, token.address, tokenPortalAddress).send({
|
|
82
|
+
const { contract: bridge } = await TokenBridgeContract.deploy(wallet, token.address, tokenPortalAddress).send({
|
|
83
|
+
from: owner,
|
|
84
|
+
});
|
|
80
85
|
|
|
81
|
-
if ((await token.methods.get_admin().simulate({ from: owner })) !== owner.toBigInt()) {
|
|
86
|
+
if ((await token.methods.get_admin().simulate({ from: owner })).result !== owner.toBigInt()) {
|
|
82
87
|
throw new Error(`Token admin is not ${owner}`);
|
|
83
88
|
}
|
|
84
89
|
|
|
85
|
-
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)) {
|
|
86
91
|
throw new Error(`Bridge token is not ${token.address}`);
|
|
87
92
|
}
|
|
88
93
|
|
|
89
94
|
// make the bridge a minter on the token:
|
|
90
95
|
await token.methods.set_minter(bridge.address, true).send({ from: owner });
|
|
91
|
-
if ((await token.methods.is_minter(bridge.address).simulate({ from: owner })) === 1n) {
|
|
96
|
+
if ((await token.methods.is_minter(bridge.address).simulate({ from: owner })).result === 1n) {
|
|
92
97
|
throw new Error(`Bridge is not a minter`);
|
|
93
98
|
}
|
|
94
99
|
|
|
@@ -162,6 +167,7 @@ export class CrossChainTestHarness {
|
|
|
162
167
|
|
|
163
168
|
private readonly l1TokenManager: L1TokenManager;
|
|
164
169
|
private readonly l1TokenPortalManager: L1TokenPortalManager;
|
|
170
|
+
public readonly outboxContract: OutboxContract;
|
|
165
171
|
|
|
166
172
|
constructor(
|
|
167
173
|
/** Aztec node instance. */
|
|
@@ -202,6 +208,7 @@ export class CrossChainTestHarness {
|
|
|
202
208
|
this.logger,
|
|
203
209
|
);
|
|
204
210
|
this.l1TokenManager = this.l1TokenPortalManager.getTokenManager();
|
|
211
|
+
this.outboxContract = new OutboxContract(this.l1Client, this.l1ContractAddresses.outboxAddress);
|
|
205
212
|
}
|
|
206
213
|
|
|
207
214
|
async mintTokensOnL1(amount: bigint) {
|
|
@@ -269,7 +276,7 @@ export class CrossChainTestHarness {
|
|
|
269
276
|
authwitNonce: Fr = Fr.ZERO,
|
|
270
277
|
authWitness: AuthWitness,
|
|
271
278
|
): Promise<TxReceipt> {
|
|
272
|
-
const withdrawReceipt = await this.l2Bridge.methods
|
|
279
|
+
const { receipt: withdrawReceipt } = await this.l2Bridge.methods
|
|
273
280
|
.exit_to_l1_private(this.l2Token.address, this.ethAccount, withdrawAmount, EthAddress.ZERO, authwitNonce)
|
|
274
281
|
.send({ authWitnesses: [authWitness], from: this.ownerAddress });
|
|
275
282
|
|
|
@@ -277,7 +284,7 @@ export class CrossChainTestHarness {
|
|
|
277
284
|
}
|
|
278
285
|
|
|
279
286
|
async withdrawPublicFromAztecToL1(withdrawAmount: bigint, authwitNonce: Fr = Fr.ZERO): Promise<TxReceipt> {
|
|
280
|
-
const withdrawReceipt = await this.l2Bridge.methods
|
|
287
|
+
const { receipt: withdrawReceipt } = await this.l2Bridge.methods
|
|
281
288
|
.exit_to_l1_public(this.ethAccount, withdrawAmount, EthAddress.ZERO, authwitNonce)
|
|
282
289
|
.send({ from: this.ownerAddress });
|
|
283
290
|
|
|
@@ -285,7 +292,7 @@ export class CrossChainTestHarness {
|
|
|
285
292
|
}
|
|
286
293
|
|
|
287
294
|
async getL2PrivateBalanceOf(owner: AztecAddress) {
|
|
288
|
-
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;
|
|
289
296
|
}
|
|
290
297
|
|
|
291
298
|
async expectPrivateBalanceOnL2(owner: AztecAddress, expectedBalance: bigint) {
|
|
@@ -295,7 +302,7 @@ export class CrossChainTestHarness {
|
|
|
295
302
|
}
|
|
296
303
|
|
|
297
304
|
async getL2PublicBalanceOf(owner: AztecAddress) {
|
|
298
|
-
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;
|
|
299
306
|
}
|
|
300
307
|
|
|
301
308
|
async expectPublicBalanceOnL2(owner: AztecAddress, expectedBalance: bigint) {
|
|
@@ -315,10 +322,18 @@ export class CrossChainTestHarness {
|
|
|
315
322
|
withdrawFundsFromBridgeOnL1(
|
|
316
323
|
amount: bigint,
|
|
317
324
|
epochNumber: EpochNumber,
|
|
325
|
+
numCheckpointsInEpoch: number,
|
|
318
326
|
messageIndex: bigint,
|
|
319
327
|
siblingPath: SiblingPath<number>,
|
|
320
328
|
) {
|
|
321
|
-
return this.l1TokenPortalManager.withdrawFunds(
|
|
329
|
+
return this.l1TokenPortalManager.withdrawFunds(
|
|
330
|
+
amount,
|
|
331
|
+
this.ethAccount,
|
|
332
|
+
epochNumber,
|
|
333
|
+
numCheckpointsInEpoch,
|
|
334
|
+
messageIndex,
|
|
335
|
+
siblingPath,
|
|
336
|
+
);
|
|
322
337
|
}
|
|
323
338
|
|
|
324
339
|
async transferToPrivateOnL2(shieldAmount: bigint) {
|
|
@@ -342,8 +357,7 @@ export class CrossChainTestHarness {
|
|
|
342
357
|
*/
|
|
343
358
|
async makeMessageConsumable(msgHash: Fr | Hex) {
|
|
344
359
|
const frMsgHash = typeof msgHash === 'string' ? Fr.fromHexString(msgHash) : msgHash;
|
|
345
|
-
|
|
346
|
-
await retryUntil(async () => await this.aztecNode.isL1ToL2MessageSynced(frMsgHash), 'message sync', 10);
|
|
360
|
+
await waitForL1ToL2MessageSeen(this.aztecNode, frMsgHash, { timeoutSeconds: 10 });
|
|
347
361
|
|
|
348
362
|
await this.mintTokensPublicOnL2(0n);
|
|
349
363
|
await this.mintTokensPublicOnL2(0n);
|