@aztec/end-to-end 4.0.0-devnet.1-patch.0 → 4.0.0-devnet.2-patch.0
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 +2 -2
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +3 -3
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +4 -2
- 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 +10 -0
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +2 -2
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.d.ts +2 -2
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.d.ts +9 -7
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +53 -34
- package/dest/e2e_fees/fees_test.d.ts +2 -2
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +5 -5
- package/dest/e2e_p2p/p2p_network.d.ts +2 -2
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +2 -2
- 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 +32 -8
- package/dest/e2e_p2p/shared.d.ts +2 -2
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +2 -1
- package/dest/e2e_token_contract/token_contract_test.d.ts +4 -2
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +10 -0
- package/dest/fixtures/authwit_proxy.d.ts +15 -0
- package/dest/fixtures/authwit_proxy.d.ts.map +1 -0
- package/dest/fixtures/authwit_proxy.js +30 -0
- package/dest/fixtures/e2e_prover_test.d.ts +4 -4
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +27 -34
- package/dest/fixtures/fixtures.d.ts +5 -1
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +6 -0
- package/dest/fixtures/ha_setup.d.ts +1 -1
- package/dest/fixtures/ha_setup.d.ts.map +1 -1
- package/dest/fixtures/ha_setup.js +3 -1
- package/dest/fixtures/setup.d.ts +27 -10
- package/dest/fixtures/setup.d.ts.map +1 -1
- package/dest/fixtures/setup.js +56 -81
- package/dest/fixtures/setup_p2p_test.d.ts +6 -3
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +12 -9
- 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/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/uniswap_l1_l2.d.ts +1 -1
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- 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 -23
- package/dest/spartan/setup_test_wallets.d.ts +9 -2
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +31 -1
- 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/index.d.ts +2 -2
- package/dest/spartan/utils/index.d.ts.map +1 -1
- package/dest/spartan/utils/index.js +1 -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/test-wallet/test_wallet.d.ts +83 -0
- package/dest/test-wallet/test_wallet.d.ts.map +1 -0
- package/dest/test-wallet/test_wallet.js +214 -0
- package/dest/test-wallet/utils.d.ts +41 -0
- package/dest/test-wallet/utils.d.ts.map +1 -0
- package/dest/test-wallet/utils.js +71 -0
- package/dest/test-wallet/wallet_worker_script.d.ts +2 -0
- package/dest/test-wallet/wallet_worker_script.d.ts.map +1 -0
- package/dest/test-wallet/wallet_worker_script.js +40 -0
- package/dest/test-wallet/worker_wallet.d.ts +52 -0
- package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
- package/dest/test-wallet/worker_wallet.js +103 -0
- package/dest/test-wallet/worker_wallet_schema.d.ts +271 -0
- package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
- package/dest/test-wallet/worker_wallet_schema.js +10 -0
- package/package.json +40 -39
- package/src/bench/client_flows/client_flows_benchmark.ts +3 -7
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +10 -1
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +1 -1
- package/src/e2e_deploy_contract/deploy_test.ts +1 -1
- package/src/e2e_epochs/epochs_test.ts +66 -66
- package/src/e2e_fees/bridging_race.notest.ts +1 -1
- package/src/e2e_fees/fees_test.ts +5 -20
- package/src/e2e_p2p/p2p_network.ts +3 -3
- package/src/e2e_p2p/reqresp/utils.ts +36 -8
- package/src/e2e_p2p/shared.ts +2 -1
- package/src/e2e_token_contract/token_contract_test.ts +10 -1
- package/src/fixtures/authwit_proxy.ts +50 -0
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/fixtures/e2e_prover_test.ts +26 -36
- package/src/fixtures/fixtures.ts +10 -0
- package/src/fixtures/ha_setup.ts +3 -1
- package/src/fixtures/setup.ts +73 -109
- package/src/fixtures/setup_p2p_test.ts +9 -17
- package/src/guides/up_quick_start.sh +3 -3
- package/src/shared/index.ts +1 -0
- package/src/shared/mock_state_view.ts +188 -0
- package/src/shared/submit-transactions.ts +2 -1
- package/src/shared/uniswap_l1_l2.ts +1 -1
- package/src/simulators/token_simulator.ts +1 -29
- package/src/spartan/setup_test_wallets.ts +43 -1
- package/src/spartan/utils/bot.ts +4 -1
- package/src/spartan/utils/index.ts +1 -0
- package/src/spartan/utils/k8s.ts +8 -0
- package/src/test-wallet/test_wallet.ts +306 -0
- package/src/test-wallet/utils.ts +112 -0
- package/src/test-wallet/wallet_worker_script.ts +43 -0
- package/src/test-wallet/worker_wallet.ts +165 -0
- package/src/test-wallet/worker_wallet_schema.ts +13 -0
package/src/fixtures/setup.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
|
|
2
2
|
import { type InitialAccountData, generateSchnorrAccounts } from '@aztec/accounts/testing';
|
|
3
|
-
import { type Archiver, createArchiver } from '@aztec/archiver';
|
|
4
3
|
import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
|
|
5
4
|
import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
|
|
6
5
|
import {
|
|
@@ -16,7 +15,6 @@ import { type Logger, createLogger } from '@aztec/aztec.js/log';
|
|
|
16
15
|
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
17
16
|
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
18
17
|
import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec/testing';
|
|
19
|
-
import { createBlobClientWithFileStores } from '@aztec/blob-client/client';
|
|
20
18
|
import { SPONSORED_FPC_SALT } from '@aztec/constants';
|
|
21
19
|
import { isAnvilTestChain } from '@aztec/ethereum/chain';
|
|
22
20
|
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
@@ -30,13 +28,8 @@ import {
|
|
|
30
28
|
type ZKPassportArgs,
|
|
31
29
|
deployAztecL1Contracts,
|
|
32
30
|
} from '@aztec/ethereum/deploy-aztec-l1-contracts';
|
|
33
|
-
import {
|
|
34
|
-
|
|
35
|
-
EthCheatCodes,
|
|
36
|
-
EthCheatCodesWithState,
|
|
37
|
-
createDelayedL1TxUtilsFromViemWallet,
|
|
38
|
-
startAnvil,
|
|
39
|
-
} from '@aztec/ethereum/test';
|
|
31
|
+
import type { Delayer } from '@aztec/ethereum/l1-tx-utils';
|
|
32
|
+
import { EthCheatCodes, EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
|
|
40
33
|
import { BlockNumber, EpochNumber } from '@aztec/foundation/branded-types';
|
|
41
34
|
import { SecretValue } from '@aztec/foundation/config';
|
|
42
35
|
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
@@ -45,16 +38,14 @@ import { withLoggerBindings } from '@aztec/foundation/log/server';
|
|
|
45
38
|
import { retryUntil } from '@aztec/foundation/retry';
|
|
46
39
|
import { sleep } from '@aztec/foundation/sleep';
|
|
47
40
|
import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
|
|
48
|
-
import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
49
41
|
import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
|
|
50
42
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
51
43
|
import type { P2PClientDeps } from '@aztec/p2p';
|
|
52
44
|
import { MockGossipSubNetwork, getMockPubSubP2PServiceFactory } from '@aztec/p2p/test-helpers';
|
|
53
45
|
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
54
|
-
import
|
|
46
|
+
import type { ProverNodeConfig } from '@aztec/prover-node';
|
|
55
47
|
import { type PXEConfig, getPXEConfig } from '@aztec/pxe/server';
|
|
56
48
|
import type { SequencerClient } from '@aztec/sequencer-client';
|
|
57
|
-
import type { TestSequencerClient } from '@aztec/sequencer-client/test';
|
|
58
49
|
import { type ContractInstanceWithAddress, getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
|
|
59
50
|
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
60
51
|
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
@@ -67,7 +58,7 @@ import {
|
|
|
67
58
|
initTelemetryClient,
|
|
68
59
|
} from '@aztec/telemetry-client';
|
|
69
60
|
import { BenchmarkTelemetryClient } from '@aztec/telemetry-client/bench';
|
|
70
|
-
import {
|
|
61
|
+
import { deployFundedSchnorrAccounts } from '@aztec/wallets/testing';
|
|
71
62
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
72
63
|
|
|
73
64
|
import type { Anvil } from '@viem/anvil';
|
|
@@ -84,6 +75,7 @@ import {
|
|
|
84
75
|
} from 'viem/accounts';
|
|
85
76
|
import { type Chain, foundry } from 'viem/chains';
|
|
86
77
|
|
|
78
|
+
import { TestWallet } from '../test-wallet/test_wallet.js';
|
|
87
79
|
import { MNEMONIC, TEST_MAX_PENDING_TX_POOL_COUNT, TEST_PEER_CHECK_INTERVAL_MS } from './fixtures.js';
|
|
88
80
|
import { getACVMConfig } from './get_acvm_config.js';
|
|
89
81
|
import { getBBConfig } from './get_bb_config.js';
|
|
@@ -218,8 +210,8 @@ export type EndToEndContext = {
|
|
|
218
210
|
aztecNodeService: AztecNodeService;
|
|
219
211
|
/** Client to the Aztec Node admin interface. */
|
|
220
212
|
aztecNodeAdmin: AztecNodeAdmin;
|
|
221
|
-
/** The prover node
|
|
222
|
-
proverNode:
|
|
213
|
+
/** The aztec node running the prover node subsystem (only set if startProverNode is true). */
|
|
214
|
+
proverNode: AztecNodeService | undefined;
|
|
223
215
|
/** A client to the sequencer service. */
|
|
224
216
|
sequencer: SequencerClient | undefined;
|
|
225
217
|
/** Return values from deployAztecL1Contracts function. */
|
|
@@ -248,6 +240,10 @@ export type EndToEndContext = {
|
|
|
248
240
|
telemetryClient: TelemetryClient;
|
|
249
241
|
/** Mock gossip sub network used for gossipping messages (only if mockGossipSubNetwork was set to true in opts) */
|
|
250
242
|
mockGossipSubNetwork: MockGossipSubNetwork | undefined;
|
|
243
|
+
/** Delayer for sequencer L1 txs (only when enableDelayer is true). */
|
|
244
|
+
sequencerDelayer: Delayer | undefined;
|
|
245
|
+
/** Delayer for prover node L1 txs (only when enableDelayer and startProverNode are true). */
|
|
246
|
+
proverDelayer: Delayer | undefined;
|
|
251
247
|
/** Prefilled public data used for setting up nodes. */
|
|
252
248
|
prefilledPublicData: PublicDataTreeLeaf[] | undefined;
|
|
253
249
|
/** ACVM config (only set if running locally). */
|
|
@@ -287,8 +283,12 @@ export async function setup(
|
|
|
287
283
|
config.realProofs = !!opts.realProofs;
|
|
288
284
|
// Only enforce the time table if requested
|
|
289
285
|
config.enforceTimeTable = !!opts.enforceTimeTable;
|
|
286
|
+
// Enable the tx delayer for tests (default config has it disabled, so we force-enable it here)
|
|
287
|
+
config.enableDelayer = true;
|
|
290
288
|
config.listenAddress = '127.0.0.1';
|
|
291
289
|
|
|
290
|
+
config.minTxPoolAgeMs = opts.minTxPoolAgeMs ?? 0;
|
|
291
|
+
|
|
292
292
|
const logger = getLogger();
|
|
293
293
|
|
|
294
294
|
// Create a temp directory for any services that need it and cleanup later
|
|
@@ -336,11 +336,11 @@ export async function setup(
|
|
|
336
336
|
publisherPrivKeyHex = opts.l1PublisherKey.getValue();
|
|
337
337
|
publisherHdAccount = privateKeyToAccount(publisherPrivKeyHex);
|
|
338
338
|
} else if (
|
|
339
|
-
config.
|
|
340
|
-
config.
|
|
341
|
-
config.
|
|
339
|
+
config.sequencerPublisherPrivateKeys &&
|
|
340
|
+
config.sequencerPublisherPrivateKeys.length > 0 &&
|
|
341
|
+
config.sequencerPublisherPrivateKeys[0].getValue() != NULL_KEY
|
|
342
342
|
) {
|
|
343
|
-
publisherPrivKeyHex = config.
|
|
343
|
+
publisherPrivKeyHex = config.sequencerPublisherPrivateKeys[0].getValue();
|
|
344
344
|
publisherHdAccount = privateKeyToAccount(publisherPrivKeyHex);
|
|
345
345
|
} else if (!MNEMONIC) {
|
|
346
346
|
throw new Error(`Mnemonic not provided and no publisher private key`);
|
|
@@ -349,7 +349,7 @@ export async function setup(
|
|
|
349
349
|
const publisherPrivKeyRaw = publisherHdAccount.getHdKey().privateKey;
|
|
350
350
|
const publisherPrivKey = publisherPrivKeyRaw === null ? null : Buffer.from(publisherPrivKeyRaw);
|
|
351
351
|
publisherPrivKeyHex = `0x${publisherPrivKey!.toString('hex')}` as const;
|
|
352
|
-
config.
|
|
352
|
+
config.sequencerPublisherPrivateKeys = [new SecretValue(publisherPrivKeyHex)];
|
|
353
353
|
}
|
|
354
354
|
|
|
355
355
|
if (config.coinbase === undefined) {
|
|
@@ -412,9 +412,14 @@ export async function setup(
|
|
|
412
412
|
if (enableAutomine) {
|
|
413
413
|
await ethCheatCodes.setAutomine(false);
|
|
414
414
|
await ethCheatCodes.setIntervalMining(config.ethereumSlotDuration);
|
|
415
|
-
dateProvider.setTime((await ethCheatCodes.timestamp()) * 1000);
|
|
416
415
|
}
|
|
417
416
|
|
|
417
|
+
// Always sync dateProvider to L1 time after deploying L1 contracts, regardless of mining mode.
|
|
418
|
+
// In compose mode, L1 time may have drifted ahead of system time due to the local-network watcher
|
|
419
|
+
// warping time forward on each filled slot. Without this sync, the sequencer computes the wrong
|
|
420
|
+
// slot from its dateProvider and cannot propose blocks.
|
|
421
|
+
dateProvider.setTime((await ethCheatCodes.timestamp()) * 1000);
|
|
422
|
+
|
|
418
423
|
if (opts.l2StartTime) {
|
|
419
424
|
await ethCheatCodes.warp(opts.l2StartTime, { resetBlockInterval: true });
|
|
420
425
|
}
|
|
@@ -491,36 +496,33 @@ export async function setup(
|
|
|
491
496
|
);
|
|
492
497
|
const sequencerClient = aztecNodeService.getSequencer();
|
|
493
498
|
|
|
494
|
-
|
|
495
|
-
const publisher = (sequencerClient as TestSequencerClient).sequencer.publisher;
|
|
496
|
-
publisher.l1TxUtils = DelayedTxUtils.fromL1TxUtils(publisher.l1TxUtils, config.ethereumSlotDuration, l1Client);
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
let proverNode: ProverNode | undefined = undefined;
|
|
499
|
+
let proverNode: AztecNodeService | undefined = undefined;
|
|
500
500
|
if (opts.startProverNode) {
|
|
501
501
|
logger.verbose('Creating and syncing a simulated prover node...');
|
|
502
502
|
const proverNodePrivateKey = getPrivateKeyFromIndex(2);
|
|
503
503
|
const proverNodePrivateKeyHex: Hex = `0x${proverNodePrivateKey!.toString('hex')}`;
|
|
504
504
|
const proverNodeDataDirectory = path.join(directoryToCleanup, randomBytes(8).toString('hex'));
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
505
|
+
|
|
506
|
+
const p2pClientDeps: Partial<P2PClientDeps<P2PClientType.Full>> = {
|
|
507
|
+
p2pServiceFactory: mockGossipSubNetwork && getMockPubSubP2PServiceFactory(mockGossipSubNetwork!),
|
|
508
|
+
rpcTxProviders: [aztecNodeService],
|
|
509
509
|
};
|
|
510
|
-
|
|
510
|
+
|
|
511
|
+
({ proverNode } = await createAndSyncProverNode(
|
|
511
512
|
proverNodePrivateKeyHex,
|
|
512
513
|
config,
|
|
513
|
-
proverNodeConfig,
|
|
514
|
-
aztecNodeService,
|
|
515
|
-
prefilledPublicData,
|
|
516
514
|
{
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
: undefined,
|
|
515
|
+
...config.proverNodeConfig,
|
|
516
|
+
dataDirectory: proverNodeDataDirectory,
|
|
520
517
|
},
|
|
521
|
-
|
|
518
|
+
{ dateProvider, p2pClientDeps, telemetry: telemetryClient },
|
|
519
|
+
{ prefilledPublicData },
|
|
520
|
+
));
|
|
522
521
|
}
|
|
523
522
|
|
|
523
|
+
const sequencerDelayer = sequencerClient?.getDelayer();
|
|
524
|
+
const proverDelayer = proverNode?.getProverNode()?.getDelayer();
|
|
525
|
+
|
|
524
526
|
logger.verbose('Creating a pxe...');
|
|
525
527
|
const pxeConfig = { ...getPXEConfig(), ...pxeOpts };
|
|
526
528
|
pxeConfig.dataDirectory = path.join(directoryToCleanup, randomBytes(8).toString('hex'));
|
|
@@ -621,6 +623,8 @@ export async function setup(
|
|
|
621
623
|
mockGossipSubNetwork,
|
|
622
624
|
prefilledPublicData,
|
|
623
625
|
proverNode,
|
|
626
|
+
sequencerDelayer,
|
|
627
|
+
proverDelayer,
|
|
624
628
|
sequencer: sequencerClient,
|
|
625
629
|
teardown,
|
|
626
630
|
telemetryClient,
|
|
@@ -704,93 +708,53 @@ export async function waitForProvenChain(node: AztecNode, targetBlock?: BlockNum
|
|
|
704
708
|
);
|
|
705
709
|
}
|
|
706
710
|
|
|
711
|
+
/**
|
|
712
|
+
* Creates an AztecNodeService with the prover node enabled as a subsystem.
|
|
713
|
+
* Returns both the aztec node service (for lifecycle management) and the prover node (for test internals access).
|
|
714
|
+
*/
|
|
707
715
|
export function createAndSyncProverNode(
|
|
708
716
|
proverNodePrivateKey: `0x${string}`,
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
717
|
+
baseConfig: AztecNodeConfig,
|
|
718
|
+
configOverrides: Pick<AztecNodeConfig, 'dataDirectory'>,
|
|
719
|
+
deps: {
|
|
720
|
+
telemetry?: TelemetryClient;
|
|
721
|
+
dateProvider: DateProvider;
|
|
722
|
+
p2pClientDeps?: P2PClientDeps<P2PClientType.Full>;
|
|
723
|
+
},
|
|
724
|
+
options: { prefilledPublicData: PublicDataTreeLeaf[]; dontStart?: boolean },
|
|
725
|
+
): Promise<{ proverNode: AztecNodeService }> {
|
|
715
726
|
return withLoggerBindings({ actor: 'prover-0' }, async () => {
|
|
716
|
-
const
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
{ blobClient, dateProvider: proverNodeDeps.dateProvider },
|
|
728
|
-
{ blockUntilSync: true },
|
|
729
|
-
);
|
|
730
|
-
|
|
731
|
-
const proverConfig: ProverNodeConfig = {
|
|
732
|
-
...aztecNodeConfig,
|
|
733
|
-
txCollectionNodeRpcUrls: [],
|
|
734
|
-
realProofs: false,
|
|
735
|
-
proverAgentCount: 2,
|
|
736
|
-
publisherPrivateKeys: [new SecretValue(proverNodePrivateKey)],
|
|
737
|
-
proverNodeMaxPendingJobs: 10,
|
|
738
|
-
proverNodeMaxParallelBlocksPerEpoch: 32,
|
|
739
|
-
proverNodePollingIntervalMs: 200,
|
|
740
|
-
txGatheringIntervalMs: 1000,
|
|
741
|
-
txGatheringBatchSize: 10,
|
|
742
|
-
txGatheringMaxParallelRequestsPerNode: 10,
|
|
743
|
-
txGatheringTimeoutMs: 24_000,
|
|
744
|
-
proverNodeFailedEpochStore: undefined,
|
|
745
|
-
proverId: EthAddress.fromNumber(1),
|
|
746
|
-
proverNodeEpochProvingDelayMs: undefined,
|
|
747
|
-
...proverNodeConfig,
|
|
748
|
-
};
|
|
749
|
-
|
|
750
|
-
const l1TxUtils = createDelayedL1TxUtils(
|
|
751
|
-
aztecNodeConfig,
|
|
752
|
-
proverNodePrivateKey,
|
|
753
|
-
'prover-node',
|
|
754
|
-
proverNodeDeps.dateProvider,
|
|
727
|
+
const proverNode = await AztecNodeService.createAndSync(
|
|
728
|
+
{
|
|
729
|
+
...baseConfig,
|
|
730
|
+
...configOverrides,
|
|
731
|
+
p2pPort: 0,
|
|
732
|
+
enableProverNode: true,
|
|
733
|
+
disableValidator: true,
|
|
734
|
+
proverPublisherPrivateKeys: [new SecretValue(proverNodePrivateKey)],
|
|
735
|
+
},
|
|
736
|
+
deps,
|
|
737
|
+
{ ...options, dontStartProverNode: options.dontStart },
|
|
755
738
|
);
|
|
756
739
|
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
{ ...proverNodeDeps, aztecNodeTxProvider, archiver: archiver as Archiver, l1TxUtils },
|
|
760
|
-
{ prefilledPublicData },
|
|
761
|
-
);
|
|
762
|
-
getLogger().info(`Created and synced prover node`, { publisherAddress: l1TxUtils.client.account!.address });
|
|
763
|
-
if (!proverNodeConfig.dontStart) {
|
|
764
|
-
await proverNode.start();
|
|
740
|
+
if (!proverNode.getProverNode()) {
|
|
741
|
+
throw new Error('Prover node subsystem was not created despite enableProverNode being set');
|
|
765
742
|
}
|
|
766
|
-
return proverNode;
|
|
767
|
-
});
|
|
768
|
-
}
|
|
769
743
|
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
logName: string,
|
|
774
|
-
dateProvider?: DateProvider,
|
|
775
|
-
) {
|
|
776
|
-
const l1Client = createExtendedL1Client(aztecNodeConfig.l1RpcUrls, privateKey, foundry);
|
|
777
|
-
|
|
778
|
-
const log = createLogger(logName);
|
|
779
|
-
const l1TxUtils = createDelayedL1TxUtilsFromViemWallet(l1Client, log, dateProvider, aztecNodeConfig);
|
|
780
|
-
l1TxUtils.enableDelayer(aztecNodeConfig.ethereumSlotDuration);
|
|
781
|
-
return l1TxUtils;
|
|
744
|
+
getLogger().info(`Created and synced prover node`);
|
|
745
|
+
return { proverNode };
|
|
746
|
+
});
|
|
782
747
|
}
|
|
783
748
|
|
|
784
749
|
export type BalancesFn = ReturnType<typeof getBalancesFn>;
|
|
785
750
|
export function getBalancesFn(
|
|
786
751
|
symbol: string,
|
|
787
752
|
method: ContractMethod,
|
|
788
|
-
from: AztecAddress,
|
|
789
753
|
logger: any,
|
|
790
754
|
): (...addresses: (AztecAddress | { address: AztecAddress })[]) => Promise<bigint[]> {
|
|
791
755
|
const balances = async (...addressLikes: (AztecAddress | { address: AztecAddress })[]) => {
|
|
792
756
|
const addresses = addressLikes.map(addressLike => ('address' in addressLike ? addressLike.address : addressLike));
|
|
793
|
-
const b = await Promise.all(addresses.map(address => method(address).simulate({ from })));
|
|
757
|
+
const b = await Promise.all(addresses.map(address => method(address).simulate({ from: address })));
|
|
794
758
|
const debugString = `${symbol} balances: ${addresses.map((address, i) => `${address}: ${b[i]}`).join(', ')}`;
|
|
795
759
|
logger.verbose(debugString);
|
|
796
760
|
return b;
|
|
@@ -7,7 +7,6 @@ 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 { ProverNodeConfig, ProverNodeDeps } from '@aztec/prover-node';
|
|
11
10
|
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
12
11
|
|
|
13
12
|
import getPort from 'get-port';
|
|
@@ -131,7 +130,7 @@ export async function createNonValidatorNode(
|
|
|
131
130
|
...p2pConfig,
|
|
132
131
|
disableValidator: true,
|
|
133
132
|
validatorPrivateKeys: undefined,
|
|
134
|
-
|
|
133
|
+
sequencerPublisherPrivateKeys: [],
|
|
135
134
|
};
|
|
136
135
|
const telemetry = await getEndToEndTestTelemetryClient(metricsPort);
|
|
137
136
|
return await AztecNodeService.createAndSync(config, { telemetry, dateProvider }, { prefilledPublicData });
|
|
@@ -143,31 +142,24 @@ export async function createProverNode(
|
|
|
143
142
|
tcpPort: number,
|
|
144
143
|
bootstrapNode: string | undefined,
|
|
145
144
|
addressIndex: number,
|
|
146
|
-
|
|
145
|
+
deps: { dateProvider: DateProvider },
|
|
147
146
|
prefilledPublicData?: PublicDataTreeLeaf[],
|
|
148
147
|
dataDirectory?: string,
|
|
149
148
|
metricsPort?: number,
|
|
150
|
-
) {
|
|
149
|
+
): Promise<{ proverNode: AztecNodeService }> {
|
|
151
150
|
const actorIndex = proverCounter++;
|
|
152
151
|
return await withLoggerBindings({ actor: `prover-${actorIndex}` }, async () => {
|
|
153
152
|
const proverNodePrivateKey = getPrivateKeyFromIndex(ATTESTER_PRIVATE_KEYS_START_INDEX + addressIndex)!;
|
|
154
153
|
const telemetry = await getEndToEndTestTelemetryClient(metricsPort);
|
|
155
154
|
|
|
156
|
-
const
|
|
157
|
-
config,
|
|
158
|
-
bootstrapNode,
|
|
159
|
-
tcpPort,
|
|
160
|
-
dataDirectory,
|
|
161
|
-
);
|
|
155
|
+
const p2pConfig = await createP2PConfig(config, bootstrapNode, tcpPort, dataDirectory);
|
|
162
156
|
|
|
163
|
-
const aztecNodeRpcTxProvider = undefined;
|
|
164
157
|
return await createAndSyncProverNode(
|
|
165
158
|
bufferToHex(proverNodePrivateKey),
|
|
166
|
-
config,
|
|
167
|
-
{
|
|
168
|
-
|
|
169
|
-
prefilledPublicData,
|
|
170
|
-
{ ...proverNodeDeps, telemetry },
|
|
159
|
+
{ ...config, ...p2pConfig },
|
|
160
|
+
{ dataDirectory },
|
|
161
|
+
{ ...deps, telemetry },
|
|
162
|
+
{ prefilledPublicData: prefilledPublicData ?? [] },
|
|
171
163
|
);
|
|
172
164
|
});
|
|
173
165
|
}
|
|
@@ -215,7 +207,7 @@ export async function createValidatorConfig(
|
|
|
215
207
|
...config,
|
|
216
208
|
...p2pConfig,
|
|
217
209
|
validatorPrivateKeys: new SecretValue(attesterPrivateKeys),
|
|
218
|
-
|
|
210
|
+
sequencerPublisherPrivateKeys: [new SecretValue(attesterPrivateKeys[0])],
|
|
219
211
|
};
|
|
220
212
|
|
|
221
213
|
return nodeConfig;
|
|
@@ -23,6 +23,8 @@ aztec-wallet create-account -a alice -f test0
|
|
|
23
23
|
aztec-wallet create-account -a bob -f test0
|
|
24
24
|
# docs:end:declare-accounts
|
|
25
25
|
|
|
26
|
+
aztec-wallet bridge-fee-juice 1000000000000000000000 accounts:alice --mint --no-wait
|
|
27
|
+
|
|
26
28
|
DEPLOY_OUTPUT=$(aztec-wallet deploy ../noir-contracts.js/artifacts/token_contract-Token.json --args accounts:test0 Test TST 18 -f test0)
|
|
27
29
|
TOKEN_ADDRESS=$(echo "$DEPLOY_OUTPUT" | grep -oE 'Contract deployed at 0x[0-9a-fA-F]+' | cut -d ' ' -f4)
|
|
28
30
|
echo "Deployed contract at $TOKEN_ADDRESS"
|
|
@@ -38,9 +40,7 @@ fi
|
|
|
38
40
|
|
|
39
41
|
TRANSFER_AMOUNT=42
|
|
40
42
|
|
|
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
|
|
43
|
+
aztec-wallet send transfer_in_private -ca last --args accounts:alice accounts:bob $TRANSFER_AMOUNT 0 -f alice --payment method=fee_juice,claim
|
|
44
44
|
|
|
45
45
|
# Test end result
|
|
46
46
|
ALICE_BALANCE=$(aztec-wallet simulate balance_of_private -ca last --args accounts:alice -f alice)
|
package/src/shared/index.ts
CHANGED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { EthAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { type Logger, createLogger } from '@aztec/aztec.js/log';
|
|
3
|
+
import type { EthCheatCodes } from '@aztec/aztec/testing';
|
|
4
|
+
import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
|
|
5
|
+
|
|
6
|
+
import { getContract } from 'viem';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Mock StateView contract for testing the Uniswap price oracle.
|
|
10
|
+
*
|
|
11
|
+
* Wraps a compiled Solidity contract that mimics the Uniswap V4 StateView's getSlot0 function.
|
|
12
|
+
* The mock allows setting return values dynamically for testing different price scenarios.
|
|
13
|
+
*
|
|
14
|
+
* Solidity source:
|
|
15
|
+
* ```solidity
|
|
16
|
+
* // SPDX-License-Identifier: Apache-2.0
|
|
17
|
+
* pragma solidity >=0.8.27;
|
|
18
|
+
*
|
|
19
|
+
* contract MockStateView {
|
|
20
|
+
* uint160 public sqrtPriceX96;
|
|
21
|
+
* int24 public tick;
|
|
22
|
+
* uint24 public protocolFee;
|
|
23
|
+
* uint24 public lpFee;
|
|
24
|
+
*
|
|
25
|
+
* function setReturnValues(
|
|
26
|
+
* uint160 _sqrtPriceX96,
|
|
27
|
+
* int24 _tick,
|
|
28
|
+
* uint24 _protocolFee,
|
|
29
|
+
* uint24 _lpFee
|
|
30
|
+
* ) external {
|
|
31
|
+
* sqrtPriceX96 = _sqrtPriceX96;
|
|
32
|
+
* tick = _tick;
|
|
33
|
+
* protocolFee = _protocolFee;
|
|
34
|
+
* lpFee = _lpFee;
|
|
35
|
+
* }
|
|
36
|
+
*
|
|
37
|
+
* function getSlot0(bytes32 poolId) external view returns (uint160, int24, uint24, uint24) {
|
|
38
|
+
* return (sqrtPriceX96, tick, protocolFee, lpFee);
|
|
39
|
+
* }
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export class MockStateView {
|
|
44
|
+
private static readonly BYTECODE: `0x${string}` =
|
|
45
|
+
'0x608060405234801561000f575f5ffd5b5060043610610060575f3560e01c80633eaf5d9f14610064578063704ce43e146100825780638db791d2146100a0578063b0e21e8a146100be578063b52e4bdd146100dc578063c815641c146100f8575b5f5ffd5b61006c61012b565b60405161007991906102ab565b60405180910390f35b61008a61013d565b60405161009791906102e1565b60405180910390f35b6100a8610151565b6040516100b59190610328565b60405180910390f35b6100c6610175565b6040516100d391906102e1565b60405180910390f35b6100f660048036038101906100f191906103c3565b610189565b005b610112600480360381019061010d919061045a565b61022b565b6040516101229493929190610485565b60405180910390f35b5f60149054906101000a900460020b81565b5f601a9054906101000a900462ffffff1681565b5f5f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b5f60179054906101000a900462ffffff1681565b835f5f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550825f60146101000a81548162ffffff021916908360020b62ffffff160217905550815f60176101000a81548162ffffff021916908362ffffff160217905550805f601a6101000a81548162ffffff021916908362ffffff16021790555050505050565b5f5f5f5f5f5f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff165f60149054906101000a900460020b5f60179054906101000a900462ffffff165f601a9054906101000a900462ffffff1693509350935093509193509193565b5f8160020b9050919050565b6102a581610290565b82525050565b5f6020820190506102be5f83018461029c565b92915050565b5f62ffffff82169050919050565b6102db816102c4565b82525050565b5f6020820190506102f45f8301846102d2565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b610322816102fa565b82525050565b5f60208201905061033b5f830184610319565b92915050565b5f5ffd5b61034e816102fa565b8114610358575f5ffd5b50565b5f8135905061036981610345565b92915050565b61037881610290565b8114610382575f5ffd5b50565b5f813590506103938161036f565b92915050565b6103a2816102c4565b81146103ac575f5ffd5b50565b5f813590506103bd81610399565b92915050565b5f5f5f5f608085870312156103db576103da610341565b5b5f6103e88782880161035b565b94505060206103f987828801610385565b935050604061040a878288016103af565b925050606061041b878288016103af565b91505092959194509250565b5f819050919050565b61043981610427565b8114610443575f5ffd5b50565b5f8135905061045481610430565b92915050565b5f6020828403121561046f5761046e610341565b5b5f61047c84828501610446565b91505092915050565b5f6080820190506104985f830187610319565b6104a5602083018661029c565b6104b260408301856102d2565b6104bf60608301846102d2565b9594505050505056fea2646970667358221220f8b1bfff284535bc078368ed34bd5e78981644845f3c9c1f5a4b8448c976805464736f6c634300081f0033';
|
|
46
|
+
private static readonly ABI = [
|
|
47
|
+
{
|
|
48
|
+
type: 'function',
|
|
49
|
+
name: 'setReturnValues',
|
|
50
|
+
inputs: [
|
|
51
|
+
{ name: '_sqrtPriceX96', type: 'uint160' },
|
|
52
|
+
{ name: '_tick', type: 'int24' },
|
|
53
|
+
{ name: '_protocolFee', type: 'uint24' },
|
|
54
|
+
{ name: '_lpFee', type: 'uint24' },
|
|
55
|
+
],
|
|
56
|
+
outputs: [],
|
|
57
|
+
stateMutability: 'nonpayable',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
inputs: [
|
|
61
|
+
{
|
|
62
|
+
internalType: 'bytes32',
|
|
63
|
+
name: 'poolId',
|
|
64
|
+
type: 'bytes32',
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
name: 'getSlot0',
|
|
68
|
+
outputs: [
|
|
69
|
+
{
|
|
70
|
+
internalType: 'uint160',
|
|
71
|
+
name: '',
|
|
72
|
+
type: 'uint160',
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
internalType: 'int24',
|
|
76
|
+
name: '',
|
|
77
|
+
type: 'int24',
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
internalType: 'uint24',
|
|
81
|
+
name: '',
|
|
82
|
+
type: 'uint24',
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
internalType: 'uint24',
|
|
86
|
+
name: '',
|
|
87
|
+
type: 'uint24',
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
stateMutability: 'view',
|
|
91
|
+
type: 'function',
|
|
92
|
+
},
|
|
93
|
+
] as const;
|
|
94
|
+
|
|
95
|
+
private constructor(
|
|
96
|
+
private readonly address: EthAddress,
|
|
97
|
+
private readonly walletClient: ExtendedViemWalletClient,
|
|
98
|
+
private readonly log: Logger = createLogger('mock-state-view'),
|
|
99
|
+
) {}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Deploys the mock StateView contract at the specified address using etch.
|
|
103
|
+
* @param ethCheatCodes - Cheat codes for etching bytecode
|
|
104
|
+
* @param walletClient - Wallet client for sending transactions
|
|
105
|
+
* @param address - Address to deploy the mock at (typically the real StateView address)
|
|
106
|
+
*/
|
|
107
|
+
static async deploy(
|
|
108
|
+
ethCheatCodes: EthCheatCodes,
|
|
109
|
+
walletClient: ExtendedViemWalletClient,
|
|
110
|
+
address: EthAddress,
|
|
111
|
+
): Promise<MockStateView> {
|
|
112
|
+
await ethCheatCodes.etch(address, MockStateView.BYTECODE);
|
|
113
|
+
return new MockStateView(address, walletClient);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Sets the price using the ethPerFeeAssetE12 format (same as rollup contract).
|
|
118
|
+
* Computes the corresponding sqrtPriceX96 internally.
|
|
119
|
+
*
|
|
120
|
+
* Math (from fee_asset_price_oracle.ts):
|
|
121
|
+
* ethPerFeeAssetE12 = 1e12 * 2^192 / sqrtPriceX96^2
|
|
122
|
+
*
|
|
123
|
+
* Inverted:
|
|
124
|
+
* sqrtPriceX96^2 = 1e12 * 2^192 / ethPerFeeAssetE12
|
|
125
|
+
* sqrtPriceX96 = sqrt(1e12 * 2^192 / ethPerFeeAssetE12)
|
|
126
|
+
*
|
|
127
|
+
* @param ethPerFeeAssetE12 - The price in ETH per fee asset, scaled by 1e12
|
|
128
|
+
*/
|
|
129
|
+
async setEthPerFeeAsset(ethPerFeeAssetE12: bigint) {
|
|
130
|
+
const sqrtPriceX96 = this.ethPerFeeAssetE12ToSqrtPriceX96(ethPerFeeAssetE12);
|
|
131
|
+
return await this.setSqrtPriceX96(sqrtPriceX96);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Sets the sqrtPriceX96 value directly (Uniswap's price encoding).
|
|
136
|
+
* @param sqrtPriceX96 - The sqrtPriceX96 value
|
|
137
|
+
* @param tick - The tick value (default 10)
|
|
138
|
+
* @param protocolFee - The protocol fee (default 0)
|
|
139
|
+
* @param lpFee - The LP fee (default 500)
|
|
140
|
+
*/
|
|
141
|
+
async setSqrtPriceX96(sqrtPriceX96: bigint, tick: number = 10, protocolFee: number = 0, lpFee: number = 500) {
|
|
142
|
+
const contract = getContract({
|
|
143
|
+
address: this.address.toString() as `0x${string}`,
|
|
144
|
+
abi: MockStateView.ABI,
|
|
145
|
+
client: this.walletClient,
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
const hash = await contract.write.setReturnValues([sqrtPriceX96, tick, protocolFee, lpFee]);
|
|
149
|
+
this.log.info(`Set sqrtPriceX96 to ${sqrtPriceX96}`);
|
|
150
|
+
return await this.walletClient.waitForTransactionReceipt({ hash });
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Converts ethPerFeeAssetE12 to sqrtPriceX96 (inverse of sqrtPriceX96ToEthPerFeeAssetE12).
|
|
155
|
+
*
|
|
156
|
+
* Math:
|
|
157
|
+
* sqrtPriceX96 = sqrt(1e12 * 2^192 / ethPerFeeAssetE12)
|
|
158
|
+
*/
|
|
159
|
+
ethPerFeeAssetE12ToSqrtPriceX96(ethPerFeeAssetE12: bigint): bigint {
|
|
160
|
+
if (ethPerFeeAssetE12 === 0n) {
|
|
161
|
+
throw new Error('Cannot convert zero ethPerFeeAssetE12');
|
|
162
|
+
}
|
|
163
|
+
const Q192 = 2n ** 192n;
|
|
164
|
+
const sqrtPriceSquared = (10n ** 12n * Q192) / ethPerFeeAssetE12;
|
|
165
|
+
return this.bigintSqrt(sqrtPriceSquared);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** Integer square root using Newton's method */
|
|
169
|
+
bigintSqrt(n: bigint): bigint {
|
|
170
|
+
if (n < 0n) {
|
|
171
|
+
throw new Error('Cannot compute sqrt of negative number');
|
|
172
|
+
}
|
|
173
|
+
if (n === 0n) {
|
|
174
|
+
return 0n;
|
|
175
|
+
}
|
|
176
|
+
let x = n;
|
|
177
|
+
let y = (x + 1n) / 2n;
|
|
178
|
+
while (y < x) {
|
|
179
|
+
x = y;
|
|
180
|
+
y = (x + n / x) / 2n;
|
|
181
|
+
}
|
|
182
|
+
return x;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export function diffInBps(a: bigint, b: bigint): bigint {
|
|
187
|
+
return ((a - b) * 10000n) / b;
|
|
188
|
+
}
|
|
@@ -4,7 +4,8 @@ import { Fr, GrumpkinScalar } from '@aztec/aztec.js/fields';
|
|
|
4
4
|
import type { Logger } from '@aztec/aztec.js/log';
|
|
5
5
|
import { TxHash, type TxReceipt, TxStatus } from '@aztec/aztec.js/tx';
|
|
6
6
|
import { times } from '@aztec/foundation/collection';
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
import type { TestWallet } from '../test-wallet/test_wallet.js';
|
|
8
9
|
|
|
9
10
|
// submits a set of transactions to the provided Wallet
|
|
10
11
|
export const submitTxsTo = async (
|
|
@@ -17,12 +17,12 @@ import { InboxAbi, UniswapPortalAbi, UniswapPortalBytecode } from '@aztec/l1-art
|
|
|
17
17
|
import { UniswapContract } from '@aztec/noir-contracts.js/Uniswap';
|
|
18
18
|
import { computeL2ToL1MessageHash } from '@aztec/stdlib/hash';
|
|
19
19
|
import { computeL2ToL1MembershipWitness } from '@aztec/stdlib/messaging';
|
|
20
|
-
import type { TestWallet } from '@aztec/test-wallet/server';
|
|
21
20
|
|
|
22
21
|
import { jest } from '@jest/globals';
|
|
23
22
|
import { type GetContractReturnType, getContract, parseEther, toFunctionSelector } from 'viem';
|
|
24
23
|
|
|
25
24
|
import { type EndToEndContext, ensureAccountContractsPublished } from '../fixtures/utils.js';
|
|
25
|
+
import type { TestWallet } from '../test-wallet/test_wallet.js';
|
|
26
26
|
import { CrossChainTestHarness } from './cross_chain_test_harness.js';
|
|
27
27
|
|
|
28
28
|
// PSA: This tests works on forked mainnet. There is a dump of the data in `dumpedState` such that we
|
|
@@ -119,39 +119,11 @@ export class TokenSimulator {
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
async checkPrivate() {
|
|
122
|
-
// Private calls
|
|
123
|
-
const defaultLookups = [];
|
|
124
|
-
const nonDefaultLookups = [];
|
|
125
|
-
|
|
126
122
|
for (const address of this.accounts) {
|
|
127
|
-
if (this.lookupProvider.has(address.toString())) {
|
|
128
|
-
nonDefaultLookups.push(address);
|
|
129
|
-
} else {
|
|
130
|
-
defaultLookups.push(address);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const defaultCalls = defaultLookups.map(address => this.token.methods.balance_of_private(address));
|
|
135
|
-
const results = (
|
|
136
|
-
await Promise.all(
|
|
137
|
-
chunk(defaultCalls, 4).map(batch =>
|
|
138
|
-
new BatchCall(this.defaultWallet, batch).simulate({ from: this.defaultAddress }),
|
|
139
|
-
),
|
|
140
|
-
)
|
|
141
|
-
).flat();
|
|
142
|
-
for (let i = 0; i < defaultLookups.length; i++) {
|
|
143
|
-
expect(results[i]).toEqual(this.balanceOfPrivate(defaultLookups[i]));
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// We are just running individual calls for the non-default lookups
|
|
147
|
-
// @todo We should also batch these
|
|
148
|
-
for (const address of nonDefaultLookups) {
|
|
149
123
|
const wallet = this.lookupProvider.get(address.toString());
|
|
150
124
|
const asset = wallet ? this.token.withWallet(wallet) : this.token;
|
|
151
125
|
|
|
152
|
-
const actualPrivateBalance = await asset.methods
|
|
153
|
-
.balance_of_private({ address })
|
|
154
|
-
.simulate({ from: this.defaultAddress });
|
|
126
|
+
const actualPrivateBalance = await asset.methods.balance_of_private(address).simulate({ from: address });
|
|
155
127
|
expect(actualPrivateBalance).toEqual(this.balanceOfPrivate(address));
|
|
156
128
|
}
|
|
157
129
|
}
|