@aztec/end-to-end 0.81.0 → 0.82.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/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +3 -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 +7 -7
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +0 -1
- 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 +3 -18
- package/dest/e2e_deploy_contract/deploy_test.d.ts +2 -0
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +2 -0
- package/dest/e2e_epochs/epochs_test.d.ts +1 -2
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +7 -6
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +20 -29
- package/dest/e2e_prover/e2e_prover_test.d.ts +2 -0
- package/dest/e2e_prover/e2e_prover_test.d.ts.map +1 -1
- package/dest/e2e_prover/e2e_prover_test.js +7 -8
- package/dest/e2e_token_contract/token_contract_test.d.ts +2 -1
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +3 -1
- package/dest/fixtures/snapshot_manager.d.ts +4 -2
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.js +17 -16
- package/dest/fixtures/utils.d.ts +5 -5
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +13 -8
- package/dest/shared/capture_private_execution_steps.d.ts +7 -0
- package/dest/shared/capture_private_execution_steps.d.ts.map +1 -0
- package/dest/shared/capture_private_execution_steps.js +40 -0
- package/dest/shared/cross_chain_test_harness.d.ts +2 -2
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +16 -4
- package/dest/shared/gas_portal_test_harness.d.ts +11 -1
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +27 -12
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +24 -16
- package/dest/simulators/lending_simulator.d.ts +3 -5
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +5 -13
- package/dest/spartan/setup_test_wallets.d.ts +1 -1
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +6 -4
- package/dest/spartan/utils.d.ts +18 -5
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +8 -5
- package/package.json +33 -31
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +9 -5
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +3 -19
- package/src/e2e_deploy_contract/deploy_test.ts +3 -0
- package/src/e2e_epochs/epochs_test.ts +6 -5
- package/src/e2e_fees/fees_test.ts +21 -28
- package/src/e2e_prover/e2e_prover_test.ts +8 -7
- package/src/e2e_token_contract/token_contract_test.ts +4 -2
- package/src/fixtures/snapshot_manager.ts +24 -10
- package/src/fixtures/utils.ts +25 -9
- package/src/guides/up_quick_start.sh +1 -2
- package/src/shared/capture_private_execution_steps.ts +43 -0
- package/src/shared/cross_chain_test_harness.ts +14 -3
- package/src/shared/gas_portal_test_harness.ts +29 -9
- package/src/shared/uniswap_l1_l2.ts +16 -16
- package/src/simulators/lending_simulator.ts +7 -12
- package/src/spartan/setup_test_wallets.ts +7 -7
- package/src/spartan/utils.ts +8 -5
package/dest/fixtures/utils.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ import { type InitialAccountData } from '@aztec/accounts/testing';
|
|
|
4
4
|
import { type AztecNodeConfig } from '@aztec/aztec-node';
|
|
5
5
|
import { type AccountWalletWithSecretKey, type AztecAddress, type AztecNode, type ContractMethod, type Logger, type PXE, type Wallet } from '@aztec/aztec.js';
|
|
6
6
|
import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec.js/testing';
|
|
7
|
-
import type { BBNativePrivateKernelProver } from '@aztec/bb-prover';
|
|
8
7
|
import { type BlobSinkServer } from '@aztec/blob-sink/server';
|
|
9
8
|
import { type DeployL1ContractsArgs, type DeployL1ContractsReturnType, ForwarderContract } from '@aztec/ethereum';
|
|
10
9
|
import { startAnvil } from '@aztec/ethereum/test';
|
|
@@ -14,6 +13,7 @@ import { TestDateProvider } from '@aztec/foundation/timer';
|
|
|
14
13
|
import { type ProverNode } from '@aztec/prover-node';
|
|
15
14
|
import { type PXEService, type PXEServiceConfig } from '@aztec/pxe/server';
|
|
16
15
|
import type { SequencerClient } from '@aztec/sequencer-client';
|
|
16
|
+
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
17
17
|
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
18
18
|
import { type TelemetryClient, type TelemetryClientConfig } from '@aztec/telemetry-client';
|
|
19
19
|
import { type Chain, type HDAccount, type Hex, type PrivateKeyAccount } from 'viem';
|
|
@@ -25,13 +25,11 @@ export declare const setupL1Contracts: (l1RpcUrls: string[], account: HDAccount
|
|
|
25
25
|
* Sets up Private eXecution Environment (PXE).
|
|
26
26
|
* @param aztecNode - An instance of Aztec Node.
|
|
27
27
|
* @param opts - Partial configuration for the PXE service.
|
|
28
|
-
* @param firstPrivKey - The private key of the first account to be created.
|
|
29
28
|
* @param logger - The logger to be used.
|
|
30
29
|
* @param useLogSuffix - Whether to add a randomly generated suffix to the PXE debug logs.
|
|
31
|
-
* @
|
|
32
|
-
* @returns Private eXecution Environment (PXE), accounts, wallets and logger.
|
|
30
|
+
* @returns Private eXecution Environment (PXE), logger and teardown function.
|
|
33
31
|
*/
|
|
34
|
-
export declare function setupPXEService(aztecNode: AztecNode, opts?: Partial<PXEServiceConfig>, logger?: Logger, useLogSuffix?: boolean
|
|
32
|
+
export declare function setupPXEService(aztecNode: AztecNode, opts?: Partial<PXEServiceConfig>, logger?: Logger, useLogSuffix?: boolean): Promise<{
|
|
35
33
|
/**
|
|
36
34
|
* The PXE instance.
|
|
37
35
|
*/
|
|
@@ -84,6 +82,8 @@ export type SetupOptions = {
|
|
|
84
82
|
export type EndToEndContext = {
|
|
85
83
|
/** The Aztec Node service or client a connected to it. */
|
|
86
84
|
aztecNode: AztecNode;
|
|
85
|
+
/** Client to the Aztec Node admin interface (undefined if connected to remote environment) */
|
|
86
|
+
aztecNodeAdmin?: AztecNodeAdmin;
|
|
87
87
|
/** The prover node service (only set if startProverNode is true) */
|
|
88
88
|
proverNode: ProverNode | undefined;
|
|
89
89
|
/** A client to the sequencer service (undefined if connected to remote environment) */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/fixtures/utils.ts"],"names":[],"mappings":";;AACA,OAAO,EACL,KAAK,kBAAkB,EAKxB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,KAAK,eAAe,EAAsC,MAAM,mBAAmB,CAAC;AAC7F,OAAO,EACL,KAAK,0BAA0B,EAC/B,KAAK,YAAY,EACjB,KAAK,SAAS,EAEd,KAAK,cAAc,EAEnB,KAAK,MAAM,EACX,KAAK,GAAG,EAER,KAAK,MAAM,EAMZ,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/fixtures/utils.ts"],"names":[],"mappings":";;AACA,OAAO,EACL,KAAK,kBAAkB,EAKxB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,KAAK,eAAe,EAAsC,MAAM,mBAAmB,CAAC;AAC7F,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AsB,sBAAsB,CAAC,GAAG,EAAE,GAAG,iBAgBpD;AAED,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,SAAS,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,UAAU,SAAK,EAAE,WAAW,SAAI,iBAS/G;AAED,wBAAsB,uBAAuB,CAC3C,oBAAoB,EAAE,KAAK,MAAM,EAAE,EACnC,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,MAAM,EACrB,mBAAmB,GAAE,kBAAkB,EAAO,uBA+C/C;AAWD,wBAAsB,uBAAuB,CAC3C,eAAe,EAAE,eAAe,EAChC,UAAU,EAAE,KAAK,MAAM,EAAE,EACzB,aAAa,EAAE,GAAG,8BAWnB"}
|
package/dest/fixtures/utils.js
CHANGED
|
@@ -19,7 +19,9 @@ import { FeeJuiceContract } from '@aztec/noir-contracts.js/FeeJuice';
|
|
|
19
19
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
20
20
|
import { ProtocolContractAddress, protocolContractTreeRoot } from '@aztec/protocol-contracts';
|
|
21
21
|
import { createProverNode } from '@aztec/prover-node';
|
|
22
|
-
import {
|
|
22
|
+
import { createPXEServiceWithSimulationProvider, getPXEServiceConfig } from '@aztec/pxe/server';
|
|
23
|
+
import { WASMSimulator } from '@aztec/simulator/client';
|
|
24
|
+
import { SimulationProviderRecorderWrapper } from '@aztec/simulator/testing';
|
|
23
25
|
import { getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
24
26
|
import { Gas } from '@aztec/stdlib/gas';
|
|
25
27
|
import { getConfigEnvVars as getTelemetryConfig, initTelemetryClient } from '@aztec/telemetry-client';
|
|
@@ -82,12 +84,10 @@ export const setupL1Contracts = async (l1RpcUrls, account, logger, args = {}, ch
|
|
|
82
84
|
* Sets up Private eXecution Environment (PXE).
|
|
83
85
|
* @param aztecNode - An instance of Aztec Node.
|
|
84
86
|
* @param opts - Partial configuration for the PXE service.
|
|
85
|
-
* @param firstPrivKey - The private key of the first account to be created.
|
|
86
87
|
* @param logger - The logger to be used.
|
|
87
88
|
* @param useLogSuffix - Whether to add a randomly generated suffix to the PXE debug logs.
|
|
88
|
-
* @
|
|
89
|
-
|
|
90
|
-
*/ export async function setupPXEService(aztecNode, opts = {}, logger = getLogger(), useLogSuffix = false, proofCreator) {
|
|
89
|
+
* @returns Private eXecution Environment (PXE), logger and teardown function.
|
|
90
|
+
*/ export async function setupPXEService(aztecNode, opts = {}, logger = getLogger(), useLogSuffix = false) {
|
|
91
91
|
const pxeServiceConfig = {
|
|
92
92
|
...getPXEServiceConfig(),
|
|
93
93
|
...opts
|
|
@@ -97,7 +97,9 @@ export const setupL1Contracts = async (l1RpcUrls, account, logger, args = {}, ch
|
|
|
97
97
|
if (!configuredDataDirectory) {
|
|
98
98
|
pxeServiceConfig.dataDirectory = path.join(tmpdir(), randomBytes(8).toString('hex'));
|
|
99
99
|
}
|
|
100
|
-
const
|
|
100
|
+
const simulationProvider = new WASMSimulator();
|
|
101
|
+
const simulationProviderWithRecorder = new SimulationProviderRecorderWrapper(simulationProvider);
|
|
102
|
+
const pxe = await createPXEServiceWithSimulationProvider(aztecNode, simulationProviderWithRecorder, pxeServiceConfig, useLogSuffix);
|
|
101
103
|
const teardown = async ()=>{
|
|
102
104
|
if (!configuredDataDirectory) {
|
|
103
105
|
try {
|
|
@@ -158,11 +160,11 @@ export const setupL1Contracts = async (l1RpcUrls, account, logger, args = {}, ch
|
|
|
158
160
|
}
|
|
159
161
|
return {
|
|
160
162
|
aztecNode,
|
|
163
|
+
aztecNodeAdmin: undefined,
|
|
161
164
|
sequencer: undefined,
|
|
162
165
|
proverNode: undefined,
|
|
163
166
|
pxe: pxeClient,
|
|
164
167
|
deployL1ContractsValues,
|
|
165
|
-
accounts: await pxeClient.getRegisteredAccounts(),
|
|
166
168
|
config,
|
|
167
169
|
initialFundedAccounts,
|
|
168
170
|
wallet: wallets[0],
|
|
@@ -293,7 +295,9 @@ export const setupL1Contracts = async (l1RpcUrls, account, logger, args = {}, ch
|
|
|
293
295
|
l1ChainId: config.l1ChainId,
|
|
294
296
|
l1RpcUrls: config.l1RpcUrls,
|
|
295
297
|
rollupAddress: config.l1Contracts.rollupAddress,
|
|
296
|
-
port: blobSinkPort
|
|
298
|
+
port: blobSinkPort,
|
|
299
|
+
dataDirectory: config.dataDirectory,
|
|
300
|
+
dataStoreMapSizeKB: config.dataStoreMapSizeKB
|
|
297
301
|
}, telemetry);
|
|
298
302
|
await blobSink.start();
|
|
299
303
|
config.blobSinkUrl = `http://localhost:${blobSinkPort}`;
|
|
@@ -378,6 +382,7 @@ export const setupL1Contracts = async (l1RpcUrls, account, logger, args = {}, ch
|
|
|
378
382
|
};
|
|
379
383
|
return {
|
|
380
384
|
aztecNode,
|
|
385
|
+
aztecNodeAdmin: aztecNode,
|
|
381
386
|
blobSink,
|
|
382
387
|
cheatCodes,
|
|
383
388
|
config,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module exposes the ability to capture the private exection steps that go into our "Client IVC" prover.
|
|
3
|
+
* These are used for debugging and benchmarking barretenberg (the prover component).
|
|
4
|
+
*/
|
|
5
|
+
import type { ContractFunctionInteraction } from '@aztec/aztec.js/contracts';
|
|
6
|
+
export declare function capturePrivateExecutionStepsIfEnvSet(label: string, interaction: ContractFunctionInteraction): Promise<void>;
|
|
7
|
+
//# sourceMappingURL=capture_private_execution_steps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capture_private_execution_steps.d.ts","sourceRoot":"","sources":["../../src/shared/capture_private_execution_steps.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AA0B7E,wBAAsB,oCAAoC,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,2BAA2B,iBAYjH"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module exposes the ability to capture the private exection steps that go into our "Client IVC" prover.
|
|
3
|
+
* These are used for debugging and benchmarking barretenberg (the prover component).
|
|
4
|
+
*/ import { createLogger } from '@aztec/foundation/log';
|
|
5
|
+
import { serializeWitness } from '@aztec/noir-noirc_abi';
|
|
6
|
+
import { encode } from '@msgpack/msgpack';
|
|
7
|
+
import { promises as fs } from 'fs';
|
|
8
|
+
import path from 'path';
|
|
9
|
+
const logger = createLogger('e2e:capture-private-execution-steps');
|
|
10
|
+
// TODO(#7371): This is duplicated.
|
|
11
|
+
// Longer term we won't use this hacked together msgpack format
|
|
12
|
+
// Leaving duplicated as this eventually bb will provide a serialization
|
|
13
|
+
// helper for passing to a generic msgpack RPC endpoint.
|
|
14
|
+
async function _createClientIvcProofFiles(directory, executionSteps) {
|
|
15
|
+
const acirPath = path.join(directory, 'acir.msgpack');
|
|
16
|
+
const witnessPath = path.join(directory, 'witnesses.msgpack');
|
|
17
|
+
await fs.writeFile(acirPath, encode(executionSteps.map((map)=>map.bytecode)));
|
|
18
|
+
await fs.writeFile(witnessPath, encode(executionSteps.map((map)=>serializeWitness(map.witness))));
|
|
19
|
+
return {
|
|
20
|
+
acirPath,
|
|
21
|
+
witnessPath
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export async function capturePrivateExecutionStepsIfEnvSet(label, interaction) {
|
|
25
|
+
// Not included in env_var.ts as internal to e2e tests.
|
|
26
|
+
const ivcFolder = process.env.CAPTURE_IVC_FOLDER;
|
|
27
|
+
if (ivcFolder) {
|
|
28
|
+
logger.info(`Capturing client ivc execution steps for ${label}`);
|
|
29
|
+
const result = await interaction.profile({
|
|
30
|
+
profileMode: 'execution-steps'
|
|
31
|
+
});
|
|
32
|
+
const resultsDirectory = path.join(ivcFolder, label);
|
|
33
|
+
logger.info(`Writing private execution steps to ${resultsDirectory}`);
|
|
34
|
+
await fs.mkdir(resultsDirectory, {
|
|
35
|
+
recursive: true
|
|
36
|
+
});
|
|
37
|
+
await _createClientIvcProofFiles(resultsDirectory, result.executionSteps);
|
|
38
|
+
logger.info(`Wrote private execution steps to ${resultsDirectory}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AccountWallet, type AztecAddress, type AztecNode, EthAddress, type FieldsOf, Fr, type L2AmountClaim, type L2AmountClaimWithRecipient, type Logger, type PXE, type SiblingPath, type TxReceipt, type Wallet } from '@aztec/aztec.js';
|
|
1
|
+
import { type AccountWallet, AuthWitness, type AztecAddress, type AztecNode, EthAddress, type FieldsOf, Fr, type L2AmountClaim, type L2AmountClaimWithRecipient, type Logger, type PXE, type SiblingPath, type TxReceipt, type Wallet } from '@aztec/aztec.js';
|
|
2
2
|
import { type L1ContractAddresses, type ViemPublicClient, type ViemWalletClient } from '@aztec/ethereum';
|
|
3
3
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
4
4
|
import { TokenBridgeContract } from '@aztec/noir-contracts.js/TokenBridge';
|
|
@@ -102,7 +102,7 @@ export declare class CrossChainTestHarness {
|
|
|
102
102
|
sendL2PublicTransfer(transferAmount: bigint, receiverAddress: AztecAddress): Promise<void>;
|
|
103
103
|
consumeMessageOnAztecAndMintPrivately(claim: Pick<L2AmountClaimWithRecipient, 'claimAmount' | 'claimSecret' | 'messageLeafIndex' | 'recipient'>): Promise<void>;
|
|
104
104
|
consumeMessageOnAztecAndMintPublicly(claim: Pick<L2AmountClaim, 'claimAmount' | 'claimSecret' | 'messageLeafIndex'>): Promise<void>;
|
|
105
|
-
withdrawPrivateFromAztecToL1(withdrawAmount: bigint, nonce
|
|
105
|
+
withdrawPrivateFromAztecToL1(withdrawAmount: bigint, nonce: Fr | undefined, authWitness: AuthWitness): Promise<FieldsOf<TxReceipt>>;
|
|
106
106
|
withdrawPublicFromAztecToL1(withdrawAmount: bigint, nonce?: Fr): Promise<FieldsOf<TxReceipt>>;
|
|
107
107
|
getL2PrivateBalanceOf(owner: AztecAddress): Promise<any>;
|
|
108
108
|
expectPrivateBalanceOnL2(owner: AztecAddress, expectedBalance: bigint): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cross_chain_test_harness.d.ts","sourceRoot":"","sources":["../../src/shared/cross_chain_test_harness.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,UAAU,EACV,KAAK,QAAQ,EACb,EAAE,EAGF,KAAK,aAAa,EAClB,KAAK,0BAA0B,EAC/B,KAAK,MAAM,EACX,KAAK,GAAG,EACR,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,MAAM,EAEZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EAEtB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAE3E,OAAO,EAAE,KAAK,GAAG,EAAe,MAAM,MAAM,CAAC;AAK7C;;;;;;;;;GASG;AACH,wBAAsB,0CAA0C,CAC9D,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,gBAAgB,EAC9B,YAAY,EAAE,gBAAgB,EAC9B,qBAAqB,EAAE,UAAU,EACjC,KAAK,EAAE,YAAY,EACnB,sBAAsB,EAAE,UAAU,GACjC,OAAO,CAAC;IACT;;OAEG;IACH,KAAK,EAAE,aAAa,CAAC;IACrB;;OAEG;IACH,MAAM,EAAE,mBAAmB,CAAC;IAC5B;;OAEG;IACH,kBAAkB,EAAE,UAAU,CAAC;IAC/B;;OAEG;IACH,WAAW,EAAE,GAAG,CAAC;IACjB;;OAEG;IACH,eAAe,EAAE,GAAG,CAAC;CACtB,CAAC,CA+CD;AAGD;;;GAGG;AACH,qBAAa,qBAAqB;IA+C9B,2BAA2B;IACpB,SAAS,EAAE,SAA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,EAAE,mBAAmB;IAExD,2BAA2B;IACX,WAAW,EAAE,aAAa;
|
|
1
|
+
{"version":3,"file":"cross_chain_test_harness.d.ts","sourceRoot":"","sources":["../../src/shared/cross_chain_test_harness.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,aAAa,EAClB,WAAW,EACX,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,UAAU,EACV,KAAK,QAAQ,EACb,EAAE,EAGF,KAAK,aAAa,EAClB,KAAK,0BAA0B,EAC/B,KAAK,MAAM,EACX,KAAK,GAAG,EACR,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,MAAM,EAEZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EAEtB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAE3E,OAAO,EAAE,KAAK,GAAG,EAAe,MAAM,MAAM,CAAC;AAK7C;;;;;;;;;GASG;AACH,wBAAsB,0CAA0C,CAC9D,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,gBAAgB,EAC9B,YAAY,EAAE,gBAAgB,EAC9B,qBAAqB,EAAE,UAAU,EACjC,KAAK,EAAE,YAAY,EACnB,sBAAsB,EAAE,UAAU,GACjC,OAAO,CAAC;IACT;;OAEG;IACH,KAAK,EAAE,aAAa,CAAC;IACrB;;OAEG;IACH,MAAM,EAAE,mBAAmB,CAAC;IAC5B;;OAEG;IACH,kBAAkB,EAAE,UAAU,CAAC;IAC/B;;OAEG;IACH,WAAW,EAAE,GAAG,CAAC;IACjB;;OAEG;IACH,eAAe,EAAE,GAAG,CAAC;CACtB,CAAC,CA+CD;AAGD;;;GAGG;AACH,qBAAa,qBAAqB;IA+C9B,2BAA2B;IACpB,SAAS,EAAE,SAAS;IAC3B,2CAA2C;IACpC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,CAAC;IAW5B,qBAAqB,CAAC,YAAY,EAAE,MAAM;IAK1C,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,KAAU;IAK1D;;;;;;OAMG;IACG,qBAAqB,CAAC,OAAO,EAAE,EAAE,GAAG,GAAG;CAQ9C"}
|
|
@@ -100,12 +100,20 @@ import { mintTokensToPrivate } from '../fixtures/token_utils.js';
|
|
|
100
100
|
this.walletClient = walletClient;
|
|
101
101
|
this.l1ContractAddresses = l1ContractAddresses;
|
|
102
102
|
this.ownerWallet = ownerWallet;
|
|
103
|
-
this.l1TokenPortalManager = new L1TokenPortalManager(this.tokenPortalAddress, this.underlyingERC20Address, this.l1ContractAddresses.outboxAddress, this.publicClient, this.walletClient, this.logger);
|
|
103
|
+
this.l1TokenPortalManager = new L1TokenPortalManager(this.tokenPortalAddress, this.underlyingERC20Address, this.l1ContractAddresses.feeAssetHandlerAddress, this.l1ContractAddresses.outboxAddress, this.publicClient, this.walletClient, this.logger);
|
|
104
104
|
this.l1TokenManager = this.l1TokenPortalManager.getTokenManager();
|
|
105
105
|
this.ownerAddress = this.ownerWallet.getAddress();
|
|
106
106
|
}
|
|
107
107
|
async mintTokensOnL1(amount) {
|
|
108
|
-
|
|
108
|
+
const contract = getContract({
|
|
109
|
+
abi: TestERC20Abi,
|
|
110
|
+
address: this.l1TokenManager.tokenAddress.toString(),
|
|
111
|
+
client: this.walletClient
|
|
112
|
+
});
|
|
113
|
+
await contract.write.mint([
|
|
114
|
+
this.ethAccount.toString(),
|
|
115
|
+
amount
|
|
116
|
+
]);
|
|
109
117
|
expect(await this.l1TokenManager.getL1TokenBalance(this.ethAccount.toString())).toEqual(amount);
|
|
110
118
|
}
|
|
111
119
|
getL1BalanceOf(address) {
|
|
@@ -138,8 +146,12 @@ import { mintTokensToPrivate } from '../fixtures/token_utils.js';
|
|
|
138
146
|
const { claimAmount, claimSecret, messageLeafIndex } = claim;
|
|
139
147
|
await this.l2Bridge.methods.claim_public(this.ownerAddress, claimAmount, claimSecret, messageLeafIndex).send().wait();
|
|
140
148
|
}
|
|
141
|
-
async withdrawPrivateFromAztecToL1(withdrawAmount, nonce = Fr.ZERO) {
|
|
142
|
-
const withdrawReceipt = await this.l2Bridge.methods.exit_to_l1_private(this.l2Token.address, this.ethAccount, withdrawAmount, EthAddress.ZERO, nonce).send(
|
|
149
|
+
async withdrawPrivateFromAztecToL1(withdrawAmount, nonce = Fr.ZERO, authWitness) {
|
|
150
|
+
const withdrawReceipt = await this.l2Bridge.methods.exit_to_l1_private(this.l2Token.address, this.ethAccount, withdrawAmount, EthAddress.ZERO, nonce).send({
|
|
151
|
+
authWitnesses: [
|
|
152
|
+
authWitness
|
|
153
|
+
]
|
|
154
|
+
}).wait();
|
|
143
155
|
return withdrawReceipt;
|
|
144
156
|
}
|
|
145
157
|
async withdrawPublicFromAztecToL1(withdrawAmount, nonce = Fr.ZERO) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type AztecAddress, type AztecNode, EthAddress, L1FeeJuicePortalManager, type L1TokenManager, type L2AmountClaim, type Logger, type PXE, type Wallet } from '@aztec/aztec.js';
|
|
2
2
|
import type { ViemPublicClient, ViemWalletClient } from '@aztec/ethereum';
|
|
3
3
|
import { FeeJuiceContract } from '@aztec/noir-contracts.js/FeeJuice';
|
|
4
|
+
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
4
5
|
export interface IGasBridgingTestHarness {
|
|
5
6
|
getL1FeeJuiceBalance(address: EthAddress): Promise<bigint>;
|
|
6
7
|
prepareTokensOnL1(bridgeAmount: bigint, owner: AztecAddress): Promise<L2AmountClaim>;
|
|
@@ -10,6 +11,7 @@ export interface IGasBridgingTestHarness {
|
|
|
10
11
|
}
|
|
11
12
|
export interface FeeJuicePortalTestingHarnessFactoryConfig {
|
|
12
13
|
aztecNode: AztecNode;
|
|
14
|
+
aztecNodeAdmin?: AztecNodeAdmin;
|
|
13
15
|
pxeService: PXE;
|
|
14
16
|
publicClient: ViemPublicClient;
|
|
15
17
|
walletClient: ViemWalletClient;
|
|
@@ -30,6 +32,8 @@ export declare class FeeJuicePortalTestingHarnessFactory {
|
|
|
30
32
|
export declare class GasBridgingTestHarness implements IGasBridgingTestHarness {
|
|
31
33
|
/** Aztec node */
|
|
32
34
|
aztecNode: AztecNode;
|
|
35
|
+
/** Aztec node admin interface */
|
|
36
|
+
aztecNodeAdmin: AztecNodeAdmin | undefined;
|
|
33
37
|
/** Private eXecution Environment (PXE). */
|
|
34
38
|
pxeService: PXE;
|
|
35
39
|
/** Logger. */
|
|
@@ -42,6 +46,8 @@ export declare class GasBridgingTestHarness implements IGasBridgingTestHarness {
|
|
|
42
46
|
feeJuicePortalAddress: EthAddress;
|
|
43
47
|
/** Underlying token for portal tests. */
|
|
44
48
|
l1FeeJuiceAddress: EthAddress;
|
|
49
|
+
/** Fee asset handler address. */
|
|
50
|
+
feeAssetHandlerAddress: EthAddress;
|
|
45
51
|
/** Viem Public client instance. */
|
|
46
52
|
publicClient: ViemPublicClient;
|
|
47
53
|
/** Viem Wallet Client instance. */
|
|
@@ -51,6 +57,8 @@ export declare class GasBridgingTestHarness implements IGasBridgingTestHarness {
|
|
|
51
57
|
constructor(
|
|
52
58
|
/** Aztec node */
|
|
53
59
|
aztecNode: AztecNode,
|
|
60
|
+
/** Aztec node admin interface */
|
|
61
|
+
aztecNodeAdmin: AztecNodeAdmin | undefined,
|
|
54
62
|
/** Private eXecution Environment (PXE). */
|
|
55
63
|
pxeService: PXE,
|
|
56
64
|
/** Logger. */
|
|
@@ -63,13 +71,15 @@ export declare class GasBridgingTestHarness implements IGasBridgingTestHarness {
|
|
|
63
71
|
feeJuicePortalAddress: EthAddress,
|
|
64
72
|
/** Underlying token for portal tests. */
|
|
65
73
|
l1FeeJuiceAddress: EthAddress,
|
|
74
|
+
/** Fee asset handler address. */
|
|
75
|
+
feeAssetHandlerAddress: EthAddress,
|
|
66
76
|
/** Viem Public client instance. */
|
|
67
77
|
publicClient: ViemPublicClient,
|
|
68
78
|
/** Viem Wallet Client instance. */
|
|
69
79
|
walletClient: ViemWalletClient);
|
|
70
80
|
mintTokensOnL1(amount: bigint, to?: EthAddress): Promise<void>;
|
|
71
81
|
getL1FeeJuiceBalance(address: EthAddress): Promise<bigint>;
|
|
72
|
-
sendTokensToPortalPublic(bridgeAmount: bigint, l2Address: AztecAddress
|
|
82
|
+
sendTokensToPortalPublic(bridgeAmount: bigint, l2Address: AztecAddress): Promise<L2AmountClaim>;
|
|
73
83
|
consumeMessageOnAztecAndClaimPrivately(owner: AztecAddress, claim: L2AmountClaim): Promise<void>;
|
|
74
84
|
getL2PublicBalanceOf(owner: AztecAddress): Promise<any>;
|
|
75
85
|
expectPublicBalanceOnL2(owner: AztecAddress, expectedBalance: bigint): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gas_portal_test_harness.d.ts","sourceRoot":"","sources":["../../src/shared/gas_portal_test_harness.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,UAAU,EAEV,uBAAuB,EACvB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,MAAM,EACX,KAAK,GAAG,EACR,KAAK,MAAM,EAEZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"gas_portal_test_harness.d.ts","sourceRoot":"","sources":["../../src/shared/gas_portal_test_harness.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,UAAU,EAEV,uBAAuB,EACvB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,MAAM,EACX,KAAK,GAAG,EACR,KAAK,MAAM,EAEZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AA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|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { EthAddress, Fr, L1FeeJuicePortalManager, retryUntil } from '@aztec/aztec.js';
|
|
2
|
+
import { TestERC20Abi } from '@aztec/l1-artifacts/TestERC20Abi';
|
|
2
3
|
import { FeeJuiceContract } from '@aztec/noir-contracts.js/FeeJuice';
|
|
3
4
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
5
|
+
import { getContract } from 'viem';
|
|
4
6
|
export class FeeJuicePortalTestingHarnessFactory {
|
|
5
7
|
config;
|
|
6
8
|
constructor(config){
|
|
7
9
|
this.config = config;
|
|
8
10
|
}
|
|
9
11
|
async createReal() {
|
|
10
|
-
const { aztecNode, pxeService, publicClient, walletClient, wallet, logger } = this.config;
|
|
12
|
+
const { aztecNode, aztecNodeAdmin, pxeService, publicClient, walletClient, wallet, logger } = this.config;
|
|
11
13
|
const ethAccount = EthAddress.fromString((await walletClient.getAddresses())[0]);
|
|
12
14
|
const l1ContractAddresses = (await pxeService.getNodeInfo()).l1ContractAddresses;
|
|
13
15
|
const feeJuiceAddress = l1ContractAddresses.feeJuiceAddress;
|
|
@@ -16,7 +18,7 @@ export class FeeJuicePortalTestingHarnessFactory {
|
|
|
16
18
|
throw new Error('Fee Juice portal not deployed on L1');
|
|
17
19
|
}
|
|
18
20
|
const gasL2 = await FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, wallet);
|
|
19
|
-
return new GasBridgingTestHarness(aztecNode, pxeService, logger, gasL2, ethAccount, feeJuicePortalAddress, feeJuiceAddress, publicClient, walletClient);
|
|
21
|
+
return new GasBridgingTestHarness(aztecNode, aztecNodeAdmin, pxeService, logger, gasL2, ethAccount, feeJuicePortalAddress, feeJuiceAddress, l1ContractAddresses.feeAssetHandlerAddress, publicClient, walletClient);
|
|
20
22
|
}
|
|
21
23
|
static create(config) {
|
|
22
24
|
const factory = new FeeJuicePortalTestingHarnessFactory(config);
|
|
@@ -28,39 +30,52 @@ export class FeeJuicePortalTestingHarnessFactory {
|
|
|
28
30
|
* shared between cross chain tests.
|
|
29
31
|
*/ export class GasBridgingTestHarness {
|
|
30
32
|
aztecNode;
|
|
33
|
+
aztecNodeAdmin;
|
|
31
34
|
pxeService;
|
|
32
35
|
logger;
|
|
33
36
|
feeJuice;
|
|
34
37
|
ethAccount;
|
|
35
38
|
feeJuicePortalAddress;
|
|
36
39
|
l1FeeJuiceAddress;
|
|
40
|
+
feeAssetHandlerAddress;
|
|
37
41
|
publicClient;
|
|
38
42
|
walletClient;
|
|
39
43
|
l1TokenManager;
|
|
40
44
|
feeJuicePortalManager;
|
|
41
|
-
constructor(/** Aztec node */ aztecNode, /** Private eXecution Environment (PXE). */ pxeService, /** Logger. */ logger, /** L2 Token/Bridge contract. */ feeJuice, /** Eth account to interact with. */ ethAccount, /** Portal address. */ feeJuicePortalAddress, /** Underlying token for portal tests. */ l1FeeJuiceAddress, /** Viem Public client instance. */ publicClient, /** Viem Wallet Client instance. */ walletClient){
|
|
45
|
+
constructor(/** Aztec node */ aztecNode, /** Aztec node admin interface */ aztecNodeAdmin, /** Private eXecution Environment (PXE). */ pxeService, /** Logger. */ logger, /** L2 Token/Bridge contract. */ feeJuice, /** Eth account to interact with. */ ethAccount, /** Portal address. */ feeJuicePortalAddress, /** Underlying token for portal tests. */ l1FeeJuiceAddress, /** Fee asset handler address. */ feeAssetHandlerAddress, /** Viem Public client instance. */ publicClient, /** Viem Wallet Client instance. */ walletClient){
|
|
42
46
|
this.aztecNode = aztecNode;
|
|
47
|
+
this.aztecNodeAdmin = aztecNodeAdmin;
|
|
43
48
|
this.pxeService = pxeService;
|
|
44
49
|
this.logger = logger;
|
|
45
50
|
this.feeJuice = feeJuice;
|
|
46
51
|
this.ethAccount = ethAccount;
|
|
47
52
|
this.feeJuicePortalAddress = feeJuicePortalAddress;
|
|
48
53
|
this.l1FeeJuiceAddress = l1FeeJuiceAddress;
|
|
54
|
+
this.feeAssetHandlerAddress = feeAssetHandlerAddress;
|
|
49
55
|
this.publicClient = publicClient;
|
|
50
56
|
this.walletClient = walletClient;
|
|
51
|
-
this.feeJuicePortalManager = new L1FeeJuicePortalManager(this.feeJuicePortalAddress, this.l1FeeJuiceAddress, this.publicClient, this.walletClient, this.logger);
|
|
57
|
+
this.feeJuicePortalManager = new L1FeeJuicePortalManager(this.feeJuicePortalAddress, this.l1FeeJuiceAddress, this.feeAssetHandlerAddress, this.publicClient, this.walletClient, this.logger);
|
|
52
58
|
this.l1TokenManager = this.feeJuicePortalManager.getTokenManager();
|
|
53
59
|
}
|
|
54
60
|
async mintTokensOnL1(amount, to = this.ethAccount) {
|
|
55
|
-
const balanceBefore = await this.l1TokenManager.getL1TokenBalance(to.toString());
|
|
56
|
-
await this.l1TokenManager.mint(
|
|
57
|
-
|
|
61
|
+
// const balanceBefore = await this.l1TokenManager.getL1TokenBalance(to.toString());
|
|
62
|
+
await this.l1TokenManager.mint(to.toString());
|
|
63
|
+
const feeAssetL1 = getContract({
|
|
64
|
+
address: this.l1FeeJuiceAddress.toString(),
|
|
65
|
+
abi: TestERC20Abi,
|
|
66
|
+
client: this.walletClient
|
|
67
|
+
});
|
|
68
|
+
await feeAssetL1.write.mint([
|
|
69
|
+
to.toString(),
|
|
70
|
+
amount
|
|
71
|
+
]);
|
|
72
|
+
// expect(await this.l1TokenManager.getL1TokenBalance(to.toString())).toEqual(balanceBefore + amount);
|
|
58
73
|
}
|
|
59
74
|
async getL1FeeJuiceBalance(address) {
|
|
60
75
|
return await this.l1TokenManager.getL1TokenBalance(address.toString());
|
|
61
76
|
}
|
|
62
|
-
sendTokensToPortalPublic(bridgeAmount, l2Address
|
|
63
|
-
return this.feeJuicePortalManager.bridgeTokensPublic(l2Address, bridgeAmount,
|
|
77
|
+
sendTokensToPortalPublic(bridgeAmount, l2Address) {
|
|
78
|
+
return this.feeJuicePortalManager.bridgeTokensPublic(l2Address, bridgeAmount, false);
|
|
64
79
|
}
|
|
65
80
|
async consumeMessageOnAztecAndClaimPrivately(owner, claim) {
|
|
66
81
|
this.logger.info('Consuming messages on L2 Privately');
|
|
@@ -75,7 +90,8 @@ export class FeeJuicePortalTestingHarnessFactory {
|
|
|
75
90
|
expect(balance).toBe(expectedBalance);
|
|
76
91
|
}
|
|
77
92
|
async prepareTokensOnL1(bridgeAmount, owner) {
|
|
78
|
-
|
|
93
|
+
await this.mintTokensOnL1(bridgeAmount);
|
|
94
|
+
const claim = await this.sendTokensToPortalPublic(bridgeAmount, owner);
|
|
79
95
|
const isSynced = async ()=>await this.aztecNode.isL1ToL2MessageSynced(Fr.fromHexString(claim.messageHash));
|
|
80
96
|
await retryUntil(isSynced, `message ${claim.messageHash} sync`, 24, 1);
|
|
81
97
|
// Progress by 2 L2 blocks so that the l1ToL2Message added above will be available to use on L2.
|
|
@@ -88,11 +104,10 @@ export class FeeJuicePortalTestingHarnessFactory {
|
|
|
88
104
|
const claim = await this.prepareTokensOnL1(bridgeAmount, owner);
|
|
89
105
|
// Consume L1 -> L2 message and claim tokens privately on L2
|
|
90
106
|
await this.consumeMessageOnAztecAndClaimPrivately(owner, claim);
|
|
91
|
-
await this.expectPublicBalanceOnL2(owner, bridgeAmount);
|
|
92
107
|
}
|
|
93
108
|
async advanceL2Block() {
|
|
94
109
|
const initialBlockNumber = await this.aztecNode.getBlockNumber();
|
|
95
|
-
await this.
|
|
110
|
+
await this.aztecNodeAdmin?.flushTxs();
|
|
96
111
|
await retryUntil(async ()=>await this.aztecNode.getBlockNumber() >= initialBlockNumber + 1);
|
|
97
112
|
}
|
|
98
113
|
} // docs:end:cross_chain_test_harness
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uniswap_l1_l2.d.ts","sourceRoot":"","sources":["../../src/shared/uniswap_l1_l2.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,SAAS,EAGd,KAAK,MAAM,EACX,KAAK,GAAG,EAGT,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EACL,KAAK,2BAA2B,
|
|
1
|
+
{"version":3,"file":"uniswap_l1_l2.d.ts","sourceRoot":"","sources":["../../src/shared/uniswap_l1_l2.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,SAAS,EAGd,KAAK,MAAM,EACX,KAAK,GAAG,EAGT,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EACL,KAAK,2BAA2B,EAEhC,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EAGtB,MAAM,iBAAiB,CAAC;AAqBzB,2DAA2D;AAC3D,MAAM,MAAM,mBAAmB,GAAG;IAChC,0BAA0B;IAC1B,SAAS,EAAE,SAAS,CAAC;IACrB,+CAA+C;IAC/C,GAAG,EAAE,GAAG,CAAC;IACT,iDAAiD;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,YAAY,EAAE,gBAAgB,CAAC;IAC/B,mCAAmC;IACnC,YAAY,EAAE,gBAAgB,CAAC;IAC/B,wBAAwB;IACxB,WAAW,EAAE,aAAa,CAAC;IAC3B,0BAA0B;IAC1B,aAAa,EAAE,aAAa,CAAC;IAC7B,OAAO;IACP,uBAAuB,EAAE,2BAA2B,CAAC;IACrD,4BAA4B;IAC5B,UAAU,EAAE,UAAU,CAAC;CACxB,CAAC;AAGF,eAAO,MAAM,oBAAoB,UACxB,MAAM,QAAQ,mBAAmB,CAAC,WAChC,MAAM,QAAQ,IAAI,CAAC,2CA69B7B,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AztecAddress, EthAddress, Fr, computeAuthWitMessageHash, generateClaimSecret } from '@aztec/aztec.js';
|
|
2
|
-
import { deployL1Contract, extractEvent } from '@aztec/ethereum';
|
|
2
|
+
import { RollupContract, deployL1Contract, extractEvent } from '@aztec/ethereum';
|
|
3
3
|
import { sha256ToField } from '@aztec/foundation/crypto';
|
|
4
|
-
import { InboxAbi,
|
|
4
|
+
import { InboxAbi, UniswapPortalAbi, UniswapPortalBytecode } from '@aztec/l1-artifacts';
|
|
5
5
|
import { UniswapContract } from '@aztec/noir-contracts.js/Uniswap';
|
|
6
6
|
import { jest } from '@jest/globals';
|
|
7
7
|
import { getContract, parseEther, toFunctionSelector } from 'viem';
|
|
@@ -49,11 +49,7 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
|
|
|
49
49
|
if (Number(await publicClient.getBlockNumber()) < expectedForkBlockNumber) {
|
|
50
50
|
throw new Error('This test must be run on a fork of mainnet with the expected fork block');
|
|
51
51
|
}
|
|
52
|
-
rollup =
|
|
53
|
-
address: deployL1ContractsValues.l1ContractAddresses.rollupAddress.toString(),
|
|
54
|
-
abi: RollupAbi,
|
|
55
|
-
client: deployL1ContractsValues.walletClient
|
|
56
|
-
});
|
|
52
|
+
rollup = new RollupContract(deployL1ContractsValues.publicClient, deployL1ContractsValues.l1ContractAddresses.rollupAddress);
|
|
57
53
|
ownerAddress = ownerWallet.getAddress();
|
|
58
54
|
// sponsorAddress = sponsorWallet.getAddress();
|
|
59
55
|
ownerEthAddress = EthAddress.fromString((await walletClient.getAddresses())[0]);
|
|
@@ -114,14 +110,18 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
|
|
|
114
110
|
// 3. Owner gives uniswap approval to transfer the funds to public to self on its behalf
|
|
115
111
|
logger.info('Approving uniswap to transfer funds to public to self on my behalf');
|
|
116
112
|
const nonceForWETHTransferToPublicApproval = new Fr(1n);
|
|
117
|
-
await ownerWallet.createAuthWit({
|
|
113
|
+
const transferToPublicAuhtwit = await ownerWallet.createAuthWit({
|
|
118
114
|
caller: uniswapL2Contract.address,
|
|
119
115
|
action: wethCrossChainHarness.l2Token.methods.transfer_to_public(ownerAddress, uniswapL2Contract.address, wethAmountToBridge, nonceForWETHTransferToPublicApproval)
|
|
120
116
|
});
|
|
121
117
|
// 4. Swap on L1 - sends L2 to L1 message to withdraw WETH to L1 and another message to swap assets.
|
|
122
118
|
logger.info('Withdrawing weth to L1 and sending message to swap to dai');
|
|
123
119
|
const [secretForDepositingSwappedDai, secretHashForDepositingSwappedDai] = await generateClaimSecret();
|
|
124
|
-
const l2UniswapInteractionReceipt = await uniswapL2Contract.methods.swap_private(wethCrossChainHarness.l2Token.address, wethCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, nonceForWETHTransferToPublicApproval, uniswapFeeTier, minimumOutputAmount, secretHashForDepositingSwappedDai, ownerEthAddress).send(
|
|
120
|
+
const l2UniswapInteractionReceipt = await uniswapL2Contract.methods.swap_private(wethCrossChainHarness.l2Token.address, wethCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, nonceForWETHTransferToPublicApproval, uniswapFeeTier, minimumOutputAmount, secretHashForDepositingSwappedDai, ownerEthAddress).send({
|
|
121
|
+
authWitnesses: [
|
|
122
|
+
transferToPublicAuhtwit
|
|
123
|
+
]
|
|
124
|
+
}).wait();
|
|
125
125
|
const swapPrivateFunction = 'swap_private(address,uint256,uint24,address,uint256,bytes32,address)';
|
|
126
126
|
const swapPrivateContent = sha256ToField([
|
|
127
127
|
Buffer.from(toFunctionSelector(swapPrivateFunction).substring(2), 'hex'),
|
|
@@ -158,7 +158,7 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
|
|
|
158
158
|
// ensure that uniswap contract didn't eat the funds.
|
|
159
159
|
await wethCrossChainHarness.expectPublicBalanceOnL2(uniswapL2Contract.address, 0n);
|
|
160
160
|
// Since the outbox is only consumable when the block is proven, we need to set the block to be proven
|
|
161
|
-
await cheatCodes.rollup.markAsProven(await rollup.
|
|
161
|
+
await cheatCodes.rollup.markAsProven(await rollup.getBlockNumber());
|
|
162
162
|
// 5. Consume L2 to L1 message by calling uniswapPortal.swap_private()
|
|
163
163
|
logger.info('Execute withdraw and swap on the uniswapPortal!');
|
|
164
164
|
const daiL1BalanceOfPortalBeforeSwap = await daiCrossChainHarness.getL1BalanceOf(daiCrossChainHarness.tokenPortalAddress);
|
|
@@ -446,13 +446,17 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
|
|
|
446
446
|
// 2. owner gives uniswap approval to transfer the funds to public:
|
|
447
447
|
logger.info('Approving uniswap to transfer funds to public to self on my behalf');
|
|
448
448
|
const nonceForWETHTransferToPublicApproval = new Fr(3n);
|
|
449
|
-
await ownerWallet.createAuthWit({
|
|
449
|
+
const transferToPublicAuthwith = await ownerWallet.createAuthWit({
|
|
450
450
|
caller: uniswapL2Contract.address,
|
|
451
451
|
action: wethCrossChainHarness.l2Token.methods.transfer_to_public(ownerAddress, uniswapL2Contract.address, wethAmountToBridge, nonceForWETHTransferToPublicApproval)
|
|
452
452
|
});
|
|
453
453
|
// 3. Swap but send the wrong token address
|
|
454
454
|
logger.info('Swap but send the wrong token address');
|
|
455
|
-
await expect(uniswapL2Contract.methods.swap_private(wethCrossChainHarness.l2Token.address, daiCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, nonceForWETHTransferToPublicApproval, uniswapFeeTier, minimumOutputAmount, Fr.random(), ownerEthAddress).prove(
|
|
455
|
+
await expect(uniswapL2Contract.methods.swap_private(wethCrossChainHarness.l2Token.address, daiCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, nonceForWETHTransferToPublicApproval, uniswapFeeTier, minimumOutputAmount, Fr.random(), ownerEthAddress).prove({
|
|
456
|
+
authWitnesses: [
|
|
457
|
+
transferToPublicAuthwith
|
|
458
|
+
]
|
|
459
|
+
})).rejects.toThrow('Assertion failed: input_asset address is not the same as seen in the bridge contract');
|
|
456
460
|
});
|
|
457
461
|
// edge cases for public flow:
|
|
458
462
|
it("I don't need approval to call swap_public if I'm swapping on my own behalf", async ()=>{
|
|
@@ -503,7 +507,7 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
|
|
|
503
507
|
// Owner gives uniswap approval to transfer the funds to public to self on its behalf
|
|
504
508
|
logger.info('Approving uniswap to transfer the funds to public to self on my behalf');
|
|
505
509
|
const nonceForWETHTransferToPublicApproval = new Fr(4n);
|
|
506
|
-
await ownerWallet.createAuthWit({
|
|
510
|
+
const transferToPublicAuhtwit = await ownerWallet.createAuthWit({
|
|
507
511
|
caller: uniswapL2Contract.address,
|
|
508
512
|
action: wethCrossChainHarness.l2Token.methods.transfer_to_public(ownerAddress, uniswapL2Contract.address, wethAmountToBridge, nonceForWETHTransferToPublicApproval)
|
|
509
513
|
});
|
|
@@ -511,7 +515,11 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
|
|
|
511
515
|
// Swap
|
|
512
516
|
logger.info('Withdrawing weth to L1 and sending message to swap to dai');
|
|
513
517
|
const [, secretHashForDepositingSwappedDai] = await generateClaimSecret();
|
|
514
|
-
const withdrawReceipt = await uniswapL2Contract.methods.swap_private(wethCrossChainHarness.l2Token.address, wethCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, nonceForWETHTransferToPublicApproval, uniswapFeeTier, minimumOutputAmount, secretHashForDepositingSwappedDai, ownerEthAddress).send(
|
|
518
|
+
const withdrawReceipt = await uniswapL2Contract.methods.swap_private(wethCrossChainHarness.l2Token.address, wethCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, nonceForWETHTransferToPublicApproval, uniswapFeeTier, minimumOutputAmount, secretHashForDepositingSwappedDai, ownerEthAddress).send({
|
|
519
|
+
authWitnesses: [
|
|
520
|
+
transferToPublicAuhtwit
|
|
521
|
+
]
|
|
522
|
+
}).wait();
|
|
515
523
|
const swapPrivateContent = sha256ToField([
|
|
516
524
|
Buffer.from(toFunctionSelector('swap_private(address,uint256,uint24,address,uint256,bytes32,address)').substring(2), 'hex'),
|
|
517
525
|
wethCrossChainHarness.tokenPortalAddress.toBuffer32(),
|
|
@@ -557,7 +565,7 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
|
|
|
557
565
|
// ensure that user's funds were burnt
|
|
558
566
|
await wethCrossChainHarness.expectPrivateBalanceOnL2(ownerAddress, wethL2BalanceBeforeSwap - wethAmountToBridge);
|
|
559
567
|
// Since the outbox is only consumable when the block is proven, we need to set the block to be proven
|
|
560
|
-
await cheatCodes.rollup.markAsProven(await rollup.
|
|
568
|
+
await cheatCodes.rollup.markAsProven(await rollup.getBlockNumber());
|
|
561
569
|
// On L1 call swap_public!
|
|
562
570
|
logger.info('call swap_public on L1');
|
|
563
571
|
const swapArgs = [
|
|
@@ -637,7 +645,7 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
|
|
|
637
645
|
// check weth balance of owner on L2 (we first bridged `wethAmountToBridge` into L2 and now withdrew it!)
|
|
638
646
|
await wethCrossChainHarness.expectPublicBalanceOnL2(ownerAddress, 0n);
|
|
639
647
|
// Since the outbox is only consumable when the block is proven, we need to set the block to be proven
|
|
640
|
-
await cheatCodes.rollup.markAsProven(await rollup.
|
|
648
|
+
await cheatCodes.rollup.markAsProven(await rollup.getBlockNumber());
|
|
641
649
|
// Call swap_private on L1
|
|
642
650
|
logger.info('Execute withdraw and swap on the uniswapPortal!');
|
|
643
651
|
const swapArgs = [
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { AztecAddress, Fr } from '@aztec/aztec.js';
|
|
2
2
|
import { CheatCodes } from '@aztec/aztec.js/testing';
|
|
3
|
+
import type { RollupContract } from '@aztec/ethereum';
|
|
3
4
|
import type { TestDateProvider } from '@aztec/foundation/timer';
|
|
4
|
-
import type { RollupAbi } from '@aztec/l1-artifacts';
|
|
5
5
|
import type { LendingContract } from '@aztec/noir-contracts.js/Lending';
|
|
6
|
-
import type { Account, GetContractReturnType, HttpTransport, WalletClient } from 'viem';
|
|
7
|
-
import type * as chains from 'viem/chains';
|
|
8
6
|
import type { TokenSimulator } from './token_simulator.js';
|
|
9
7
|
/**
|
|
10
8
|
* Contains utilities to compute the "key" for private holdings in the public state.
|
|
@@ -30,7 +28,7 @@ export declare class LendingSimulator {
|
|
|
30
28
|
private rate;
|
|
31
29
|
private ethereumSlotDuration;
|
|
32
30
|
/** the rollup contract */
|
|
33
|
-
rollup:
|
|
31
|
+
rollup: RollupContract;
|
|
34
32
|
/** the lending contract */
|
|
35
33
|
lendingContract: LendingContract;
|
|
36
34
|
/** the collateral asset used in the lending contract */
|
|
@@ -47,7 +45,7 @@ export declare class LendingSimulator {
|
|
|
47
45
|
private mintedOutside;
|
|
48
46
|
constructor(cc: CheatCodes, account: LendingAccount, rate: bigint, ethereumSlotDuration: number,
|
|
49
47
|
/** the rollup contract */
|
|
50
|
-
rollup:
|
|
48
|
+
rollup: RollupContract,
|
|
51
49
|
/** the lending contract */
|
|
52
50
|
lendingContract: LendingContract,
|
|
53
51
|
/** the collateral asset used in the lending contract */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lending_simulator.d.ts","sourceRoot":"","sources":["../../src/simulators/lending_simulator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"lending_simulator.d.ts","sourceRoot":"","sources":["../../src/simulators/lending_simulator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAExE,OAAO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