@aztec/end-to-end 0.0.1-commit.358457c → 0.0.1-commit.381b1a9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +15 -8
- package/dest/bench/utils.d.ts +1 -1
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +6 -3
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +1 -1
- 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 +14 -14
- package/dest/e2e_epochs/epochs_test.d.ts +1 -1
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +2 -1
- package/dest/e2e_fees/fees_test.d.ts +1 -1
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +12 -5
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +4 -6
- package/dest/e2e_p2p/p2p_network.d.ts +1 -1
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +2 -3
- package/dest/e2e_p2p/shared.js +1 -1
- package/dest/e2e_token_contract/token_contract_test.d.ts +1 -1
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +11 -11
- package/dest/fixtures/authwit_proxy.d.ts +3 -3
- package/dest/fixtures/authwit_proxy.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.d.ts +1 -1
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +6 -6
- package/dest/fixtures/setup.d.ts +8 -5
- package/dest/fixtures/setup.d.ts.map +1 -1
- package/dest/fixtures/setup.js +5 -4
- 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 +4 -5
- package/dest/shared/cross_chain_test_harness.d.ts +1 -1
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +13 -13
- package/dest/shared/gas_portal_test_harness.js +2 -2
- package/dest/shared/jest_setup.js +1 -10
- package/dest/shared/submit-transactions.d.ts +1 -1
- 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 +14 -17
- package/dest/simulators/lending_simulator.d.ts +1 -1
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +2 -2
- 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 +2 -2
- package/dest/spartan/setup_test_wallets.d.ts +4 -2
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +23 -10
- package/dest/spartan/utils/index.d.ts +2 -1
- package/dest/spartan/utils/index.d.ts.map +1 -1
- package/dest/spartan/utils/index.js +2 -0
- package/dest/spartan/utils/nodes.d.ts +5 -4
- package/dest/spartan/utils/nodes.d.ts.map +1 -1
- package/dest/spartan/utils/nodes.js +8 -8
- package/dest/test-wallet/test_wallet.js +1 -1
- package/dest/test-wallet/worker_wallet_schema.d.ts +1 -1
- package/package.json +40 -40
- package/src/bench/client_flows/client_flows_benchmark.ts +37 -30
- package/src/bench/utils.ts +7 -2
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +18 -14
- package/src/e2e_epochs/epochs_test.ts +1 -0
- package/src/e2e_fees/fees_test.ts +12 -5
- package/src/e2e_nested_contract/nested_contract_test.ts +6 -4
- package/src/e2e_p2p/p2p_network.ts +3 -2
- package/src/e2e_p2p/shared.ts +1 -1
- package/src/e2e_token_contract/token_contract_test.ts +16 -8
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/fixtures/e2e_prover_test.ts +11 -5
- package/src/fixtures/setup.ts +14 -8
- package/src/fixtures/token_utils.ts +5 -4
- package/src/shared/cross_chain_test_harness.ts +13 -9
- package/src/shared/gas_portal_test_harness.ts +1 -1
- package/src/shared/jest_setup.ts +1 -16
- package/src/shared/submit-transactions.ts +1 -4
- package/src/shared/uniswap_l1_l2.ts +35 -28
- package/src/simulators/lending_simulator.ts +4 -2
- package/src/simulators/token_simulator.ts +6 -2
- package/src/spartan/setup_test_wallets.ts +48 -25
- package/src/spartan/utils/index.ts +3 -0
- package/src/spartan/utils/nodes.ts +9 -14
- package/src/test-wallet/test_wallet.ts +1 -1
- package/dest/fixtures/elu_monitor.d.ts +0 -21
- package/dest/fixtures/elu_monitor.d.ts.map +0 -1
- package/dest/fixtures/elu_monitor.js +0 -102
- package/src/fixtures/elu_monitor.ts +0 -126
package/src/fixtures/setup.ts
CHANGED
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
deployAztecL1Contracts,
|
|
30
30
|
} from '@aztec/ethereum/deploy-aztec-l1-contracts';
|
|
31
31
|
import type { Delayer } from '@aztec/ethereum/l1-tx-utils';
|
|
32
|
-
import { EthCheatCodes, EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
|
|
32
|
+
import { type Anvil, EthCheatCodes, EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
|
|
33
33
|
import { BlockNumber, EpochNumber } from '@aztec/foundation/branded-types';
|
|
34
34
|
import { SecretValue } from '@aztec/foundation/config';
|
|
35
35
|
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
@@ -49,7 +49,6 @@ import type { SequencerClient } from '@aztec/sequencer-client';
|
|
|
49
49
|
import { type ContractInstanceWithAddress, getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
|
|
50
50
|
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
51
51
|
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
52
|
-
import type { P2PClientType } from '@aztec/stdlib/p2p';
|
|
53
52
|
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
54
53
|
import {
|
|
55
54
|
type TelemetryClient,
|
|
@@ -61,7 +60,6 @@ import { BenchmarkTelemetryClient } from '@aztec/telemetry-client/bench';
|
|
|
61
60
|
import { deployFundedSchnorrAccounts } from '@aztec/wallets/testing';
|
|
62
61
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
63
62
|
|
|
64
|
-
import type { Anvil } from '@viem/anvil';
|
|
65
63
|
import fs from 'fs/promises';
|
|
66
64
|
import { tmpdir } from 'os';
|
|
67
65
|
import path from 'path';
|
|
@@ -186,6 +184,11 @@ export type SetupOptions = {
|
|
|
186
184
|
anvilAccounts?: number;
|
|
187
185
|
/** Port to start anvil (defaults to 8545) */
|
|
188
186
|
anvilPort?: number;
|
|
187
|
+
/**
|
|
188
|
+
* Number of slots per epoch for Anvil's finality simulation.
|
|
189
|
+
* Anvil reports `finalized = latest - slotsInAnEpoch * 2`.
|
|
190
|
+
*/
|
|
191
|
+
anvilSlotsInAnEpoch?: number;
|
|
189
192
|
/** Key to use for publishing L1 contracts */
|
|
190
193
|
l1PublisherKey?: SecretValue<`0x${string}`>;
|
|
191
194
|
/** ZkPassport configuration (domain, scope, mock verifier) */
|
|
@@ -306,6 +309,7 @@ export async function setup(
|
|
|
306
309
|
l1BlockTime: opts.ethereumSlotDuration,
|
|
307
310
|
accounts: opts.anvilAccounts,
|
|
308
311
|
port: opts.anvilPort ?? (process.env.ANVIL_PORT ? parseInt(process.env.ANVIL_PORT) : undefined),
|
|
312
|
+
slotsInAnEpoch: opts.anvilSlotsInAnEpoch,
|
|
309
313
|
});
|
|
310
314
|
anvil = res.anvil;
|
|
311
315
|
config.l1RpcUrls = [res.rpcUrl];
|
|
@@ -456,7 +460,7 @@ export async function setup(
|
|
|
456
460
|
}
|
|
457
461
|
|
|
458
462
|
let mockGossipSubNetwork: MockGossipSubNetwork | undefined;
|
|
459
|
-
let p2pClientDeps: P2PClientDeps
|
|
463
|
+
let p2pClientDeps: P2PClientDeps | undefined = undefined;
|
|
460
464
|
|
|
461
465
|
if (opts.mockGossipSubNetwork) {
|
|
462
466
|
mockGossipSubNetwork = new MockGossipSubNetwork();
|
|
@@ -503,7 +507,7 @@ export async function setup(
|
|
|
503
507
|
const proverNodePrivateKeyHex: Hex = `0x${proverNodePrivateKey!.toString('hex')}`;
|
|
504
508
|
const proverNodeDataDirectory = path.join(directoryToCleanup, randomBytes(8).toString('hex'));
|
|
505
509
|
|
|
506
|
-
const p2pClientDeps: Partial<P2PClientDeps
|
|
510
|
+
const p2pClientDeps: Partial<P2PClientDeps> = {
|
|
507
511
|
p2pServiceFactory: mockGossipSubNetwork && getMockPubSubP2PServiceFactory(mockGossipSubNetwork!),
|
|
508
512
|
rpcTxProviders: [aztecNodeService],
|
|
509
513
|
};
|
|
@@ -719,7 +723,7 @@ export function createAndSyncProverNode(
|
|
|
719
723
|
deps: {
|
|
720
724
|
telemetry?: TelemetryClient;
|
|
721
725
|
dateProvider: DateProvider;
|
|
722
|
-
p2pClientDeps?: P2PClientDeps
|
|
726
|
+
p2pClientDeps?: P2PClientDeps;
|
|
723
727
|
},
|
|
724
728
|
options: { prefilledPublicData: PublicDataTreeLeaf[]; dontStart?: boolean },
|
|
725
729
|
): Promise<{ proverNode: AztecNodeService }> {
|
|
@@ -754,7 +758,9 @@ export function getBalancesFn(
|
|
|
754
758
|
): (...addresses: (AztecAddress | { address: AztecAddress })[]) => Promise<bigint[]> {
|
|
755
759
|
const balances = async (...addressLikes: (AztecAddress | { address: AztecAddress })[]) => {
|
|
756
760
|
const addresses = addressLikes.map(addressLike => ('address' in addressLike ? addressLike.address : addressLike));
|
|
757
|
-
const b = await Promise.all(
|
|
761
|
+
const b = await Promise.all(
|
|
762
|
+
addresses.map(async address => (await method(address).simulate({ from: address })).result),
|
|
763
|
+
);
|
|
758
764
|
const debugString = `${symbol} balances: ${addresses.map((address, i) => `${address}: ${b[i]}`).join(', ')}`;
|
|
759
765
|
logger.verbose(debugString);
|
|
760
766
|
return b;
|
|
@@ -872,7 +878,7 @@ export async function publicDeployAccounts(
|
|
|
872
878
|
|
|
873
879
|
const batch = new BatchCall(wallet, calls);
|
|
874
880
|
|
|
875
|
-
const txReceipt = await batch.send({ from: accountsToDeploy[0] });
|
|
881
|
+
const { receipt: txReceipt } = await batch.send({ from: accountsToDeploy[0] });
|
|
876
882
|
if (waitUntilProven) {
|
|
877
883
|
if (!node) {
|
|
878
884
|
throw new Error('Need to provide an AztecNode to wait for proven.');
|
|
@@ -6,7 +6,9 @@ import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
|
6
6
|
|
|
7
7
|
export async function deployToken(wallet: Wallet, admin: AztecAddress, initialAdminBalance: bigint, logger: Logger) {
|
|
8
8
|
logger.info(`Deploying Token contract...`);
|
|
9
|
-
const {
|
|
9
|
+
const {
|
|
10
|
+
receipt: { contract, instance },
|
|
11
|
+
} = await TokenContract.deploy(wallet, admin, 'TokenName', 'TokenSymbol', 18).send({
|
|
10
12
|
from: admin,
|
|
11
13
|
wait: { returnReceipt: true },
|
|
12
14
|
});
|
|
@@ -25,9 +27,8 @@ export async function mintTokensToPrivate(
|
|
|
25
27
|
minter: AztecAddress,
|
|
26
28
|
recipient: AztecAddress,
|
|
27
29
|
amount: bigint,
|
|
28
|
-
additionalScopes?: AztecAddress[],
|
|
29
30
|
) {
|
|
30
|
-
await token.methods.mint_to_private(recipient, amount).send({ from: minter
|
|
31
|
+
await token.methods.mint_to_private(recipient, amount).send({ from: minter });
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
export async function expectTokenBalance(
|
|
@@ -39,7 +40,7 @@ export async function expectTokenBalance(
|
|
|
39
40
|
) {
|
|
40
41
|
// Then check the balance
|
|
41
42
|
const contractWithWallet = TokenContract.at(token.address, wallet);
|
|
42
|
-
const balance = await contractWithWallet.methods.balance_of_private(owner).simulate({ from: owner });
|
|
43
|
+
const { result: balance } = await contractWithWallet.methods.balance_of_private(owner).simulate({ from: owner });
|
|
43
44
|
logger.info(`Account ${owner} balance: ${balance}`);
|
|
44
45
|
expect(balance).toBe(expectedBalance);
|
|
45
46
|
}
|
|
@@ -73,22 +73,26 @@ export async function deployAndInitializeTokenAndBridgeContracts(
|
|
|
73
73
|
});
|
|
74
74
|
|
|
75
75
|
// deploy l2 token
|
|
76
|
-
const token = await TokenContract.deploy(wallet, owner, 'TokenName', 'TokenSymbol', 18).send({
|
|
76
|
+
const { contract: token } = await TokenContract.deploy(wallet, owner, 'TokenName', 'TokenSymbol', 18).send({
|
|
77
|
+
from: owner,
|
|
78
|
+
});
|
|
77
79
|
|
|
78
80
|
// deploy l2 token bridge and attach to the portal
|
|
79
|
-
const bridge = await TokenBridgeContract.deploy(wallet, token.address, tokenPortalAddress).send({
|
|
81
|
+
const { contract: bridge } = await TokenBridgeContract.deploy(wallet, token.address, tokenPortalAddress).send({
|
|
82
|
+
from: owner,
|
|
83
|
+
});
|
|
80
84
|
|
|
81
|
-
if ((await token.methods.get_admin().simulate({ from: owner })) !== owner.toBigInt()) {
|
|
85
|
+
if ((await token.methods.get_admin().simulate({ from: owner })).result !== owner.toBigInt()) {
|
|
82
86
|
throw new Error(`Token admin is not ${owner}`);
|
|
83
87
|
}
|
|
84
88
|
|
|
85
|
-
if (!(await bridge.methods.get_config().simulate({ from: owner })).token.equals(token.address)) {
|
|
89
|
+
if (!(await bridge.methods.get_config().simulate({ from: owner })).result.token.equals(token.address)) {
|
|
86
90
|
throw new Error(`Bridge token is not ${token.address}`);
|
|
87
91
|
}
|
|
88
92
|
|
|
89
93
|
// make the bridge a minter on the token:
|
|
90
94
|
await token.methods.set_minter(bridge.address, true).send({ from: owner });
|
|
91
|
-
if ((await token.methods.is_minter(bridge.address).simulate({ from: owner })) === 1n) {
|
|
95
|
+
if ((await token.methods.is_minter(bridge.address).simulate({ from: owner })).result === 1n) {
|
|
92
96
|
throw new Error(`Bridge is not a minter`);
|
|
93
97
|
}
|
|
94
98
|
|
|
@@ -269,7 +273,7 @@ export class CrossChainTestHarness {
|
|
|
269
273
|
authwitNonce: Fr = Fr.ZERO,
|
|
270
274
|
authWitness: AuthWitness,
|
|
271
275
|
): Promise<TxReceipt> {
|
|
272
|
-
const withdrawReceipt = await this.l2Bridge.methods
|
|
276
|
+
const { receipt: withdrawReceipt } = await this.l2Bridge.methods
|
|
273
277
|
.exit_to_l1_private(this.l2Token.address, this.ethAccount, withdrawAmount, EthAddress.ZERO, authwitNonce)
|
|
274
278
|
.send({ authWitnesses: [authWitness], from: this.ownerAddress });
|
|
275
279
|
|
|
@@ -277,7 +281,7 @@ export class CrossChainTestHarness {
|
|
|
277
281
|
}
|
|
278
282
|
|
|
279
283
|
async withdrawPublicFromAztecToL1(withdrawAmount: bigint, authwitNonce: Fr = Fr.ZERO): Promise<TxReceipt> {
|
|
280
|
-
const withdrawReceipt = await this.l2Bridge.methods
|
|
284
|
+
const { receipt: withdrawReceipt } = await this.l2Bridge.methods
|
|
281
285
|
.exit_to_l1_public(this.ethAccount, withdrawAmount, EthAddress.ZERO, authwitNonce)
|
|
282
286
|
.send({ from: this.ownerAddress });
|
|
283
287
|
|
|
@@ -285,7 +289,7 @@ export class CrossChainTestHarness {
|
|
|
285
289
|
}
|
|
286
290
|
|
|
287
291
|
async getL2PrivateBalanceOf(owner: AztecAddress) {
|
|
288
|
-
return await this.l2Token.methods.balance_of_private(owner).simulate({ from: owner });
|
|
292
|
+
return (await this.l2Token.methods.balance_of_private(owner).simulate({ from: owner })).result;
|
|
289
293
|
}
|
|
290
294
|
|
|
291
295
|
async expectPrivateBalanceOnL2(owner: AztecAddress, expectedBalance: bigint) {
|
|
@@ -295,7 +299,7 @@ export class CrossChainTestHarness {
|
|
|
295
299
|
}
|
|
296
300
|
|
|
297
301
|
async getL2PublicBalanceOf(owner: AztecAddress) {
|
|
298
|
-
return await this.l2Token.methods.balance_of_public(owner).simulate({ from: this.ownerAddress });
|
|
302
|
+
return (await this.l2Token.methods.balance_of_public(owner).simulate({ from: this.ownerAddress })).result;
|
|
299
303
|
}
|
|
300
304
|
|
|
301
305
|
async expectPublicBalanceOnL2(owner: AztecAddress, expectedBalance: bigint) {
|
|
@@ -131,7 +131,7 @@ export class GasBridgingTestHarness implements IGasBridgingTestHarness {
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
async getL2PublicBalanceOf(owner: AztecAddress) {
|
|
134
|
-
return await this.feeJuice.methods.balance_of_public(owner).simulate({ from: owner });
|
|
134
|
+
return (await this.feeJuice.methods.balance_of_public(owner).simulate({ from: owner })).result;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
async expectPublicBalanceOnL2(owner: AztecAddress, expectedBalance: bigint) {
|
package/src/shared/jest_setup.ts
CHANGED
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/aztec.js/log';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { beforeEach, expect } from '@jest/globals';
|
|
4
4
|
import { basename } from 'path';
|
|
5
5
|
|
|
6
|
-
import { EluMonitor } from '../fixtures/elu_monitor.js';
|
|
7
|
-
|
|
8
|
-
const eluMonitor = process.env.ELU_MONITOR_FILE
|
|
9
|
-
? new EluMonitor(process.env.ELU_MONITOR_FILE, Number(process.env.ELU_MONITOR_INTERVAL_MS) || undefined)
|
|
10
|
-
: undefined;
|
|
11
|
-
|
|
12
|
-
if (eluMonitor) {
|
|
13
|
-
process.on('exit', () => eluMonitor.stop());
|
|
14
|
-
}
|
|
15
|
-
|
|
16
6
|
beforeEach(() => {
|
|
17
7
|
const { testPath, currentTestName } = expect.getState();
|
|
18
8
|
if (!testPath || !currentTestName) {
|
|
@@ -20,9 +10,4 @@ beforeEach(() => {
|
|
|
20
10
|
}
|
|
21
11
|
const logger = createLogger(`e2e:${basename(testPath).replace('.test.ts', '')}`);
|
|
22
12
|
logger.info(`Running test: ${currentTestName}`);
|
|
23
|
-
eluMonitor?.startTest(currentTestName);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
afterEach(() => {
|
|
27
|
-
eluMonitor?.stopTest();
|
|
28
13
|
});
|
|
@@ -19,10 +19,7 @@ export const submitTxsTo = async (
|
|
|
19
19
|
times(numTxs, async () => {
|
|
20
20
|
const accountManager = await wallet.createSchnorrAccount(Fr.random(), Fr.random(), GrumpkinScalar.random());
|
|
21
21
|
const deployMethod = await accountManager.getDeployMethod();
|
|
22
|
-
const txHash = await deployMethod.send({
|
|
23
|
-
from: submitter,
|
|
24
|
-
wait: NO_WAIT,
|
|
25
|
-
});
|
|
22
|
+
const { txHash } = await deployMethod.send({ from: submitter, wait: NO_WAIT });
|
|
26
23
|
|
|
27
24
|
logger.info(`Tx sent with hash ${txHash}`);
|
|
28
25
|
const receipt: TxReceipt = await wallet.getTxReceipt(txHash);
|
|
@@ -130,7 +130,9 @@ export const uniswapL1L2TestSuite = (
|
|
|
130
130
|
client: l1Client,
|
|
131
131
|
});
|
|
132
132
|
// deploy l2 uniswap contract and attach to portal
|
|
133
|
-
uniswapL2Contract = await UniswapContract.deploy(wallet, uniswapPortalAddress).send({
|
|
133
|
+
({ contract: uniswapL2Contract } = await UniswapContract.deploy(wallet, uniswapPortalAddress).send({
|
|
134
|
+
from: ownerAddress,
|
|
135
|
+
}));
|
|
134
136
|
|
|
135
137
|
const registryAddress = (await aztecNode.getNodeInfo()).l1ContractAddresses.registryAddress;
|
|
136
138
|
|
|
@@ -195,7 +197,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
195
197
|
logger.info('Withdrawing weth to L1 and sending message to swap to dai');
|
|
196
198
|
const [secretForDepositingSwappedDai, secretHashForDepositingSwappedDai] = await generateClaimSecret();
|
|
197
199
|
|
|
198
|
-
const l2UniswapInteractionReceipt = await uniswapL2Contract.methods
|
|
200
|
+
const { receipt: l2UniswapInteractionReceipt } = await uniswapL2Contract.methods
|
|
199
201
|
.swap_private(
|
|
200
202
|
wethCrossChainHarness.l2Token.address,
|
|
201
203
|
wethCrossChainHarness.l2Bridge.address,
|
|
@@ -250,8 +252,12 @@ export const uniswapL1L2TestSuite = (
|
|
|
250
252
|
await wethCrossChainHarness.expectPublicBalanceOnL2(uniswapL2Contract.address, 0n);
|
|
251
253
|
|
|
252
254
|
// Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch.
|
|
253
|
-
const
|
|
254
|
-
|
|
255
|
+
const swapResult = (await computeL2ToL1MembershipWitness(
|
|
256
|
+
aztecNode,
|
|
257
|
+
swapPrivateLeaf,
|
|
258
|
+
l2UniswapInteractionReceipt.txHash,
|
|
259
|
+
))!;
|
|
260
|
+
const { epochNumber: epoch } = swapResult;
|
|
255
261
|
await cheatCodes.rollup.advanceToEpoch(EpochNumber(epoch + 1));
|
|
256
262
|
await waitForProven(aztecNode, l2UniswapInteractionReceipt, { provenTimeout: 300 });
|
|
257
263
|
|
|
@@ -260,14 +266,17 @@ export const uniswapL1L2TestSuite = (
|
|
|
260
266
|
const daiL1BalanceOfPortalBeforeSwap = await daiCrossChainHarness.getL1BalanceOf(
|
|
261
267
|
daiCrossChainHarness.tokenPortalAddress,
|
|
262
268
|
);
|
|
263
|
-
const
|
|
264
|
-
|
|
269
|
+
const withdrawResult = (await computeL2ToL1MembershipWitness(
|
|
270
|
+
aztecNode,
|
|
271
|
+
withdrawLeaf,
|
|
272
|
+
l2UniswapInteractionReceipt.txHash,
|
|
273
|
+
))!;
|
|
265
274
|
|
|
266
|
-
const swapPrivateL2MessageIndex = swapResult
|
|
267
|
-
const swapPrivateSiblingPath = swapResult
|
|
275
|
+
const swapPrivateL2MessageIndex = swapResult.leafIndex;
|
|
276
|
+
const swapPrivateSiblingPath = swapResult.siblingPath;
|
|
268
277
|
|
|
269
|
-
const withdrawL2MessageIndex = withdrawResult
|
|
270
|
-
const withdrawSiblingPath = withdrawResult
|
|
278
|
+
const withdrawL2MessageIndex = withdrawResult.leafIndex;
|
|
279
|
+
const withdrawSiblingPath = withdrawResult.siblingPath;
|
|
271
280
|
|
|
272
281
|
const withdrawMessageMetadata = {
|
|
273
282
|
_epoch: BigInt(epoch),
|
|
@@ -787,7 +796,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
787
796
|
logger.info('Withdrawing weth to L1 and sending message to swap to dai');
|
|
788
797
|
|
|
789
798
|
const [, secretHashForDepositingSwappedDai] = await generateClaimSecret();
|
|
790
|
-
const withdrawReceipt = await uniswapL2Contract.methods
|
|
799
|
+
const { receipt: withdrawReceipt } = await uniswapL2Contract.methods
|
|
791
800
|
.swap_private(
|
|
792
801
|
wethCrossChainHarness.l2Token.address,
|
|
793
802
|
wethCrossChainHarness.l2Bridge.address,
|
|
@@ -838,16 +847,15 @@ export const uniswapL1L2TestSuite = (
|
|
|
838
847
|
chainId: new Fr(l1Client.chain.id),
|
|
839
848
|
});
|
|
840
849
|
|
|
841
|
-
const
|
|
842
|
-
const epoch =
|
|
843
|
-
const
|
|
844
|
-
const withdrawResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, withdrawLeaf);
|
|
850
|
+
const swapResult = (await computeL2ToL1MembershipWitness(aztecNode, swapPrivateLeaf, withdrawReceipt.txHash))!;
|
|
851
|
+
const { epochNumber: epoch } = swapResult;
|
|
852
|
+
const withdrawResult = (await computeL2ToL1MembershipWitness(aztecNode, withdrawLeaf, withdrawReceipt.txHash))!;
|
|
845
853
|
|
|
846
|
-
const swapPrivateL2MessageIndex = swapResult
|
|
847
|
-
const swapPrivateSiblingPath = swapResult
|
|
854
|
+
const swapPrivateL2MessageIndex = swapResult.leafIndex;
|
|
855
|
+
const swapPrivateSiblingPath = swapResult.siblingPath;
|
|
848
856
|
|
|
849
|
-
const withdrawL2MessageIndex = withdrawResult
|
|
850
|
-
const withdrawSiblingPath = withdrawResult
|
|
857
|
+
const withdrawL2MessageIndex = withdrawResult.leafIndex;
|
|
858
|
+
const withdrawSiblingPath = withdrawResult.siblingPath;
|
|
851
859
|
|
|
852
860
|
const withdrawMessageMetadata = {
|
|
853
861
|
_epoch: BigInt(epoch),
|
|
@@ -915,7 +923,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
915
923
|
|
|
916
924
|
// Call swap_public on L2
|
|
917
925
|
const secretHashForDepositingSwappedDai = Fr.random();
|
|
918
|
-
const withdrawReceipt = await uniswapL2Contract.methods
|
|
926
|
+
const { receipt: withdrawReceipt } = await uniswapL2Contract.methods
|
|
919
927
|
.swap_public(
|
|
920
928
|
ownerAddress,
|
|
921
929
|
wethCrossChainHarness.l2Bridge.address,
|
|
@@ -971,16 +979,15 @@ export const uniswapL1L2TestSuite = (
|
|
|
971
979
|
chainId: new Fr(l1Client.chain.id),
|
|
972
980
|
});
|
|
973
981
|
|
|
974
|
-
const
|
|
975
|
-
const epoch =
|
|
976
|
-
const
|
|
977
|
-
const withdrawResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, withdrawLeaf);
|
|
982
|
+
const swapResult = (await computeL2ToL1MembershipWitness(aztecNode, swapPublicLeaf, withdrawReceipt.txHash))!;
|
|
983
|
+
const { epochNumber: epoch } = swapResult;
|
|
984
|
+
const withdrawResult = (await computeL2ToL1MembershipWitness(aztecNode, withdrawLeaf, withdrawReceipt.txHash))!;
|
|
978
985
|
|
|
979
|
-
const swapPublicL2MessageIndex = swapResult
|
|
980
|
-
const swapPublicSiblingPath = swapResult
|
|
986
|
+
const swapPublicL2MessageIndex = swapResult.leafIndex;
|
|
987
|
+
const swapPublicSiblingPath = swapResult.siblingPath;
|
|
981
988
|
|
|
982
|
-
const withdrawL2MessageIndex = withdrawResult
|
|
983
|
-
const withdrawSiblingPath = withdrawResult
|
|
989
|
+
const withdrawL2MessageIndex = withdrawResult.leafIndex;
|
|
990
|
+
const withdrawSiblingPath = withdrawResult.siblingPath;
|
|
984
991
|
|
|
985
992
|
const withdrawMessageMetadata = {
|
|
986
993
|
_epoch: BigInt(epoch),
|
|
@@ -186,14 +186,16 @@ export class LendingSimulator {
|
|
|
186
186
|
|
|
187
187
|
expect(this.borrowed).toEqual(this.stableCoin.totalSupply - this.mintedOutside);
|
|
188
188
|
|
|
189
|
-
const asset = await this.lendingContract.methods.get_asset(0).simulate({ from: this.account.address });
|
|
189
|
+
const { result: asset } = await this.lendingContract.methods.get_asset(0).simulate({ from: this.account.address });
|
|
190
190
|
|
|
191
191
|
const interestAccumulator = asset['interest_accumulator'];
|
|
192
192
|
expect(interestAccumulator).toEqual(this.accumulator);
|
|
193
193
|
expect(asset['last_updated_ts']).toEqual(BigInt(this.time));
|
|
194
194
|
|
|
195
195
|
for (const key of [this.account.address, AztecAddress.fromField(await this.account.key())]) {
|
|
196
|
-
const privatePos = await this.lendingContract.methods
|
|
196
|
+
const { result: privatePos } = await this.lendingContract.methods
|
|
197
|
+
.get_position(key)
|
|
198
|
+
.simulate({ from: this.account.address });
|
|
197
199
|
expect(new Fr(privatePos['collateral'])).toEqual(this.collateral[key.toString()] ?? Fr.ZERO);
|
|
198
200
|
expect(new Fr(privatePos['static_debt'])).toEqual(this.staticDebt[key.toString()] ?? Fr.ZERO);
|
|
199
201
|
expect(privatePos['debt']).toEqual(
|
|
@@ -109,7 +109,9 @@ export class TokenSimulator {
|
|
|
109
109
|
await Promise.all(
|
|
110
110
|
chunk(calls, 5).map(batch => new BatchCall(this.defaultWallet, batch).simulate({ from: this.defaultAddress })),
|
|
111
111
|
)
|
|
112
|
-
)
|
|
112
|
+
)
|
|
113
|
+
.flat()
|
|
114
|
+
.map(r => r.result);
|
|
113
115
|
expect(results[0]).toEqual(this.totalSupply);
|
|
114
116
|
|
|
115
117
|
// Check that all our balances match
|
|
@@ -123,7 +125,9 @@ export class TokenSimulator {
|
|
|
123
125
|
const wallet = this.lookupProvider.get(address.toString());
|
|
124
126
|
const asset = wallet ? this.token.withWallet(wallet) : this.token;
|
|
125
127
|
|
|
126
|
-
const actualPrivateBalance = await asset.methods
|
|
128
|
+
const { result: actualPrivateBalance } = await asset.methods
|
|
129
|
+
.balance_of_private(address)
|
|
130
|
+
.simulate({ from: address });
|
|
127
131
|
expect(actualPrivateBalance).toEqual(this.balanceOfPrivate(address));
|
|
128
132
|
}
|
|
129
133
|
}
|
|
@@ -88,19 +88,11 @@ export async function deploySponsoredTestAccountsWithTokens(
|
|
|
88
88
|
|
|
89
89
|
const paymentMethod = new SponsoredFeePaymentMethod(await getSponsoredFPCAddress());
|
|
90
90
|
const recipientDeployMethod = await recipientAccount.getDeployMethod();
|
|
91
|
-
await recipientDeployMethod.send({
|
|
92
|
-
from: AztecAddress.ZERO,
|
|
93
|
-
fee: { paymentMethod },
|
|
94
|
-
wait: { timeout: 2400 },
|
|
95
|
-
});
|
|
91
|
+
await recipientDeployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod }, wait: { timeout: 2400 } });
|
|
96
92
|
await Promise.all(
|
|
97
93
|
fundedAccounts.map(async a => {
|
|
98
94
|
const deployMethod = await a.getDeployMethod();
|
|
99
|
-
await deployMethod.send({
|
|
100
|
-
from: AztecAddress.ZERO,
|
|
101
|
-
fee: { paymentMethod },
|
|
102
|
-
wait: { timeout: 2400 },
|
|
103
|
-
}); // increase timeout on purpose in order to account for two empty epochs
|
|
95
|
+
await deployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod }, wait: { timeout: 2400 } }); // increase timeout on purpose in order to account for two empty epochs
|
|
104
96
|
logger.info(`Account deployed at ${a.address}`);
|
|
105
97
|
}),
|
|
106
98
|
);
|
|
@@ -129,20 +121,28 @@ export async function deploySponsoredTestAccountsWithTokens(
|
|
|
129
121
|
}
|
|
130
122
|
|
|
131
123
|
async function deployAccountWithDiagnostics(
|
|
132
|
-
account: { getDeployMethod: () => Promise<{ send: (opts: any) => any }>; address: any },
|
|
124
|
+
account: { getDeployMethod: () => Promise<{ simulate: (opts: any) => any; send: (opts: any) => any }>; address: any },
|
|
133
125
|
paymentMethod: SponsoredFeePaymentMethod,
|
|
134
126
|
aztecNode: AztecNode,
|
|
135
127
|
logger: Logger,
|
|
136
128
|
accountLabel: string,
|
|
129
|
+
estimateGas?: boolean,
|
|
137
130
|
): Promise<void> {
|
|
138
131
|
const deployMethod = await account.getDeployMethod();
|
|
139
132
|
let txHash;
|
|
140
133
|
try {
|
|
141
|
-
|
|
134
|
+
let gasSettings;
|
|
135
|
+
if (estimateGas) {
|
|
136
|
+
const sim = await deployMethod.simulate({ from: AztecAddress.ZERO, fee: { paymentMethod } });
|
|
137
|
+
gasSettings = sim.estimatedGas;
|
|
138
|
+
logger.info(`${accountLabel} estimated gas: DA=${gasSettings.gasLimits.daGas} L2=${gasSettings.gasLimits.l2Gas}`);
|
|
139
|
+
}
|
|
140
|
+
const deployResult = await deployMethod.send({
|
|
142
141
|
from: AztecAddress.ZERO,
|
|
143
|
-
fee: { paymentMethod },
|
|
142
|
+
fee: { paymentMethod, gasSettings },
|
|
144
143
|
wait: NO_WAIT,
|
|
145
144
|
});
|
|
145
|
+
txHash = deployResult.txHash;
|
|
146
146
|
await waitForTx(aztecNode, txHash, { timeout: 2400 });
|
|
147
147
|
logger.info(`${accountLabel} deployed at ${account.address}`);
|
|
148
148
|
} catch (error) {
|
|
@@ -164,18 +164,29 @@ async function deployAccountWithDiagnostics(
|
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
async function deployAccountsInBatches(
|
|
167
|
-
accounts: {
|
|
167
|
+
accounts: {
|
|
168
|
+
getDeployMethod: () => Promise<{ simulate: (opts: any) => any; send: (opts: any) => any }>;
|
|
169
|
+
address: any;
|
|
170
|
+
}[],
|
|
168
171
|
paymentMethod: SponsoredFeePaymentMethod,
|
|
169
172
|
aztecNode: AztecNode,
|
|
170
173
|
logger: Logger,
|
|
171
174
|
labelPrefix: string,
|
|
172
175
|
batchSize = 2,
|
|
176
|
+
estimateGas?: boolean,
|
|
173
177
|
): Promise<void> {
|
|
174
178
|
for (let i = 0; i < accounts.length; i += batchSize) {
|
|
175
179
|
const batch = accounts.slice(i, i + batchSize);
|
|
176
180
|
await Promise.all(
|
|
177
181
|
batch.map((account, idx) =>
|
|
178
|
-
deployAccountWithDiagnostics(
|
|
182
|
+
deployAccountWithDiagnostics(
|
|
183
|
+
account,
|
|
184
|
+
paymentMethod,
|
|
185
|
+
aztecNode,
|
|
186
|
+
logger,
|
|
187
|
+
`${labelPrefix}${i + idx + 1}`,
|
|
188
|
+
estimateGas,
|
|
189
|
+
),
|
|
179
190
|
),
|
|
180
191
|
);
|
|
181
192
|
}
|
|
@@ -186,6 +197,7 @@ export async function deploySponsoredTestAccounts(
|
|
|
186
197
|
aztecNode: AztecNode,
|
|
187
198
|
logger: Logger,
|
|
188
199
|
numberOfFundedWallets = 1,
|
|
200
|
+
opts?: { estimateGas?: boolean },
|
|
189
201
|
): Promise<TestAccountsWithoutTokens> {
|
|
190
202
|
const [recipient, ...funded] = await generateSchnorrAccounts(numberOfFundedWallets + 1);
|
|
191
203
|
const recipientAccount = await wallet.createSchnorrAccount(recipient.secret, recipient.salt);
|
|
@@ -195,8 +207,23 @@ export async function deploySponsoredTestAccounts(
|
|
|
195
207
|
|
|
196
208
|
const paymentMethod = new SponsoredFeePaymentMethod(await getSponsoredFPCAddress());
|
|
197
209
|
|
|
198
|
-
await deployAccountWithDiagnostics(
|
|
199
|
-
|
|
210
|
+
await deployAccountWithDiagnostics(
|
|
211
|
+
recipientAccount,
|
|
212
|
+
paymentMethod,
|
|
213
|
+
aztecNode,
|
|
214
|
+
logger,
|
|
215
|
+
'Recipient account',
|
|
216
|
+
opts?.estimateGas,
|
|
217
|
+
);
|
|
218
|
+
await deployAccountsInBatches(
|
|
219
|
+
fundedAccounts,
|
|
220
|
+
paymentMethod,
|
|
221
|
+
aztecNode,
|
|
222
|
+
logger,
|
|
223
|
+
'Funded account ',
|
|
224
|
+
2,
|
|
225
|
+
opts?.estimateGas,
|
|
226
|
+
);
|
|
200
227
|
|
|
201
228
|
return {
|
|
202
229
|
aztecNode,
|
|
@@ -278,7 +305,7 @@ async function bridgeL1FeeJuice(
|
|
|
278
305
|
const claim = await portal.bridgeTokensPublic(recipient, amount, true /* mint */);
|
|
279
306
|
|
|
280
307
|
const isSynced = async () =>
|
|
281
|
-
(await aztecNode.
|
|
308
|
+
(await aztecNode.getL1ToL2MessageCheckpoint(Fr.fromHexString(claim.messageHash))) !== undefined;
|
|
282
309
|
await retryUntil(isSynced, `message ${claim.messageHash} sync`, 24, 0.5);
|
|
283
310
|
|
|
284
311
|
log.info(`Created a claim for ${amount} L1 fee juice to ${recipient}.`, claim);
|
|
@@ -310,13 +337,9 @@ async function deployTokenAndMint(
|
|
|
310
337
|
logger: Logger,
|
|
311
338
|
) {
|
|
312
339
|
logger.verbose(`Deploying TokenContract...`);
|
|
313
|
-
const {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
TOKEN_NAME,
|
|
317
|
-
TOKEN_SYMBOL,
|
|
318
|
-
TOKEN_DECIMALS,
|
|
319
|
-
).send({
|
|
340
|
+
const {
|
|
341
|
+
receipt: { contract: tokenContract },
|
|
342
|
+
} = await TokenContract.deploy(wallet, admin, TOKEN_NAME, TOKEN_SYMBOL, TOKEN_DECIMALS).send({
|
|
320
343
|
from: admin,
|
|
321
344
|
fee: {
|
|
322
345
|
paymentMethod,
|
|
@@ -255,18 +255,21 @@ export async function initHADb(namespace: string): Promise<void> {
|
|
|
255
255
|
}
|
|
256
256
|
|
|
257
257
|
/**
|
|
258
|
-
*
|
|
259
|
-
*
|
|
258
|
+
* Enables or disables probabilistic transaction dropping on validators and waits for rollout.
|
|
259
|
+
* Wired to env vars P2P_DROP_TX and P2P_DROP_TX_CHANCE via Helm values.
|
|
260
260
|
*/
|
|
261
261
|
export async function setValidatorTxDrop({
|
|
262
262
|
namespace,
|
|
263
|
+
enabled,
|
|
263
264
|
probability,
|
|
264
265
|
logger: log,
|
|
265
266
|
}: {
|
|
266
267
|
namespace: string;
|
|
268
|
+
enabled: boolean;
|
|
267
269
|
probability: number;
|
|
268
270
|
logger: Logger;
|
|
269
271
|
}) {
|
|
272
|
+
const drop = enabled ? 'true' : 'false';
|
|
270
273
|
const prob = String(probability);
|
|
271
274
|
|
|
272
275
|
const selectors = ['app.kubernetes.io/name=validator', 'app.kubernetes.io/component=validator', 'app=validator'];
|
|
@@ -281,7 +284,7 @@ export async function setValidatorTxDrop({
|
|
|
281
284
|
if (names.length === 0) {
|
|
282
285
|
continue;
|
|
283
286
|
}
|
|
284
|
-
const cmd = `kubectl set env statefulset -l ${selector} -n ${namespace} P2P_DROP_TX_CHANCE=${prob}`;
|
|
287
|
+
const cmd = `kubectl set env statefulset -l ${selector} -n ${namespace} P2P_DROP_TX=${drop} P2P_DROP_TX_CHANCE=${prob}`;
|
|
285
288
|
log.info(`command: ${cmd}`);
|
|
286
289
|
await execAsync(cmd);
|
|
287
290
|
updated = true;
|
|
@@ -363,24 +366,16 @@ export async function enableValidatorDynamicBootNode(
|
|
|
363
366
|
*/
|
|
364
367
|
export async function rollAztecPods(namespace: string, clearState: boolean = false) {
|
|
365
368
|
// Pod components use 'validator', but StatefulSets and PVCs use 'sequencer-node' for validators
|
|
366
|
-
// RPC nodes have nodeType='rpc-node' in Helm values, so their component label is 'rpc-node' (not 'rpc')
|
|
367
369
|
const podComponents = [
|
|
368
370
|
'p2p-bootstrap',
|
|
369
371
|
'prover-node',
|
|
370
372
|
'prover-broker',
|
|
371
373
|
'prover-agent',
|
|
372
374
|
'sequencer-node',
|
|
373
|
-
'rpc
|
|
374
|
-
'validator-ha-db',
|
|
375
|
-
];
|
|
376
|
-
const pvcComponents = [
|
|
377
|
-
'p2p-bootstrap',
|
|
378
|
-
'prover-node',
|
|
379
|
-
'prover-broker',
|
|
380
|
-
'sequencer-node',
|
|
381
|
-
'rpc-node',
|
|
375
|
+
'rpc',
|
|
382
376
|
'validator-ha-db',
|
|
383
377
|
];
|
|
378
|
+
const pvcComponents = ['p2p-bootstrap', 'prover-node', 'prover-broker', 'sequencer-node', 'rpc', 'validator-ha-db'];
|
|
384
379
|
// StatefulSet components that need to be scaled down before PVC deletion
|
|
385
380
|
// Note: validators use 'sequencer-node' as component label, not 'validator'
|
|
386
381
|
const statefulSetComponents = [
|
|
@@ -388,7 +383,7 @@ export async function rollAztecPods(namespace: string, clearState: boolean = fal
|
|
|
388
383
|
'prover-node',
|
|
389
384
|
'prover-broker',
|
|
390
385
|
'sequencer-node',
|
|
391
|
-
'rpc
|
|
386
|
+
'rpc',
|
|
392
387
|
'validator-ha-db',
|
|
393
388
|
];
|
|
394
389
|
|
|
@@ -275,7 +275,7 @@ export class TestWallet extends BaseWallet {
|
|
|
275
275
|
async proveTx(exec: ExecutionPayload, opts: Omit<SendOptions, 'wait'>): Promise<ProvenTx> {
|
|
276
276
|
const fee = await this.completeFeeOptions(opts.from, exec.feePayer, opts.fee?.gasSettings);
|
|
277
277
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(exec, opts.from, fee);
|
|
278
|
-
const txProvingResult = await this.pxe.proveTx(txRequest, this.
|
|
278
|
+
const txProvingResult = await this.pxe.proveTx(txRequest, this.scopesFor(opts.from));
|
|
279
279
|
return new ProvenTx(
|
|
280
280
|
this.aztecNode,
|
|
281
281
|
await txProvingResult.toTx(),
|