@aztec/end-to-end 0.0.0-test.1 → 0.0.1-fake-ceab37513c
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/benchmark.d.ts +60 -0
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/benchmark.js +261 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +69 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/client_flows_benchmark.js +315 -0
- package/dest/bench/client_flows/config.d.ts +14 -0
- package/dest/bench/client_flows/config.d.ts.map +1 -0
- package/dest/bench/client_flows/config.js +106 -0
- package/dest/bench/client_flows/data_extractor.d.ts +2 -0
- package/dest/bench/client_flows/data_extractor.d.ts.map +1 -0
- package/dest/bench/client_flows/data_extractor.js +99 -0
- package/dest/bench/utils.d.ts +10 -27
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +27 -43
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +15 -7
- 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 +66 -38
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +10 -18
- 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 +34 -53
- package/dest/e2e_deploy_contract/deploy_test.d.ts +4 -2
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +9 -6
- package/dest/e2e_epochs/epochs_test.d.ts +56 -17
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +222 -42
- package/dest/e2e_fees/bridging_race.notest.d.ts +2 -0
- package/dest/e2e_fees/bridging_race.notest.d.ts.map +1 -0
- package/dest/e2e_fees/bridging_race.notest.js +60 -0
- package/dest/e2e_fees/fees_test.d.ts +16 -5
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +87 -88
- package/dest/e2e_l1_publisher/write_json.d.ts +8 -0
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -0
- package/dest/e2e_l1_publisher/write_json.js +57 -0
- package/dest/e2e_multi_validator/utils.d.ts +12 -0
- package/dest/e2e_multi_validator/utils.d.ts.map +1 -0
- package/dest/e2e_multi_validator/utils.js +214 -0
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +5 -5
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +19 -14
- package/dest/e2e_p2p/inactivity_slash_test.d.ts +31 -0
- package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -0
- package/dest/e2e_p2p/inactivity_slash_test.js +132 -0
- package/dest/e2e_p2p/p2p_network.d.ts +56 -21
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +154 -125
- package/dest/e2e_p2p/shared.d.ts +41 -3
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +146 -6
- package/dest/e2e_token_contract/token_contract_test.d.ts +10 -5
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +51 -24
- package/dest/{e2e_prover → fixtures}/e2e_prover_test.d.ts +7 -4
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
- package/dest/{e2e_prover → fixtures}/e2e_prover_test.js +67 -62
- package/dest/fixtures/fixtures.d.ts +5 -6
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +4 -3
- package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
- package/dest/fixtures/get_acvm_config.js +2 -14
- package/dest/fixtures/get_bb_config.d.ts.map +1 -1
- package/dest/fixtures/get_bb_config.js +8 -15
- package/dest/fixtures/l1_to_l2_messaging.d.ts +8 -5
- package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
- package/dest/fixtures/l1_to_l2_messaging.js +44 -18
- package/dest/fixtures/setup_l1_contracts.d.ts +3 -3
- package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -1
- package/dest/fixtures/setup_l1_contracts.js +3 -3
- package/dest/fixtures/setup_p2p_test.d.ts +14 -6
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +73 -21
- package/dest/fixtures/snapshot_manager.d.ts +8 -3
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.js +120 -104
- package/dest/fixtures/token_utils.d.ts +4 -3
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +24 -7
- package/dest/fixtures/utils.d.ts +65 -22
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +439 -318
- package/dest/fixtures/web3signer.d.ts +5 -0
- package/dest/fixtures/web3signer.d.ts.map +1 -0
- package/dest/fixtures/web3signer.js +42 -0
- package/dest/shared/cross_chain_test_harness.d.ts +28 -18
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +97 -41
- package/dest/shared/gas_portal_test_harness.d.ts +23 -18
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +43 -25
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.d.ts +5 -6
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +136 -90
- package/dest/simulators/lending_simulator.d.ts +5 -6
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +11 -15
- package/dest/simulators/token_simulator.d.ts +2 -1
- package/dest/simulators/token_simulator.d.ts.map +1 -1
- package/dest/simulators/token_simulator.js +16 -13
- package/dest/spartan/setup_test_wallets.d.ts +8 -1
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +108 -22
- package/dest/spartan/utils.d.ts +60 -307
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +200 -115
- package/package.json +60 -56
- package/src/bench/client_flows/benchmark.ts +341 -0
- package/src/bench/client_flows/client_flows_benchmark.ts +422 -0
- package/src/bench/client_flows/config.ts +61 -0
- package/src/bench/client_flows/data_extractor.ts +111 -0
- package/src/bench/utils.ts +26 -52
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +60 -40
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +47 -75
- package/src/e2e_deploy_contract/deploy_test.ts +11 -8
- package/src/e2e_epochs/epochs_test.ts +276 -54
- package/src/e2e_fees/bridging_race.notest.ts +75 -0
- package/src/e2e_fees/fees_test.ts +121 -108
- package/src/e2e_l1_publisher/write_json.ts +74 -0
- package/src/e2e_multi_validator/utils.ts +258 -0
- package/src/e2e_nested_contract/nested_contract_test.ts +22 -14
- package/src/e2e_p2p/inactivity_slash_test.ts +174 -0
- package/src/e2e_p2p/p2p_network.ts +212 -144
- package/src/e2e_p2p/shared.ts +234 -14
- package/src/e2e_token_contract/token_contract_test.ts +42 -38
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/{e2e_prover → fixtures}/e2e_prover_test.ts +62 -69
- package/src/fixtures/fixtures.ts +4 -3
- package/src/fixtures/get_acvm_config.ts +2 -10
- package/src/fixtures/get_bb_config.ts +15 -11
- package/src/fixtures/l1_to_l2_messaging.ts +53 -23
- package/src/fixtures/setup_l1_contracts.ts +5 -6
- package/src/fixtures/setup_p2p_test.ts +112 -30
- package/src/fixtures/snapshot_manager.ts +150 -102
- package/src/fixtures/token_utils.ts +33 -8
- package/src/fixtures/utils.ts +530 -352
- package/src/fixtures/web3signer.ts +46 -0
- package/src/guides/up_quick_start.sh +4 -4
- package/src/shared/cross_chain_test_harness.ts +92 -52
- package/src/shared/gas_portal_test_harness.ts +47 -31
- package/src/shared/uniswap_l1_l2.ts +127 -124
- package/src/simulators/lending_simulator.ts +11 -15
- package/src/simulators/token_simulator.ts +17 -12
- package/src/spartan/DEVELOP.md +116 -0
- package/src/spartan/setup_test_wallets.ts +144 -29
- package/src/spartan/utils.ts +194 -116
- package/dest/e2e_prover/e2e_prover_test.d.ts.map +0 -1
- package/dest/sample-dapp/connect.js +0 -12
- package/dest/sample-dapp/contracts.js +0 -10
- package/dest/sample-dapp/deploy.js +0 -35
- package/dest/sample-dapp/index.js +0 -98
- package/src/sample-dapp/connect.mjs +0 -16
- package/src/sample-dapp/contracts.mjs +0 -14
- package/src/sample-dapp/deploy.mjs +0 -40
- package/src/sample-dapp/index.mjs +0 -128
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
import { EcdsaRAccountContractArtifact, getEcdsaRAccount } from '@aztec/accounts/ecdsa';
|
|
2
|
+
import { SchnorrAccountContractArtifact, getSchnorrAccount, getSchnorrWallet } from '@aztec/accounts/schnorr';
|
|
3
|
+
import {
|
|
4
|
+
type AccountWallet,
|
|
5
|
+
AccountWalletWithSecretKey,
|
|
6
|
+
AztecAddress,
|
|
7
|
+
type AztecNode,
|
|
8
|
+
FeeJuicePaymentMethod,
|
|
9
|
+
FeeJuicePaymentMethodWithClaim,
|
|
10
|
+
type FeePaymentMethod,
|
|
11
|
+
type Logger,
|
|
12
|
+
type PXE,
|
|
13
|
+
PrivateFeePaymentMethod,
|
|
14
|
+
SponsoredFeePaymentMethod,
|
|
15
|
+
type Wallet,
|
|
16
|
+
createLogger,
|
|
17
|
+
} from '@aztec/aztec.js';
|
|
18
|
+
import { CheatCodes } from '@aztec/aztec/testing';
|
|
19
|
+
import { type DeployL1ContractsArgs, RollupContract, createExtendedL1Client, deployL1Contract } from '@aztec/ethereum';
|
|
20
|
+
import { ChainMonitor } from '@aztec/ethereum/test';
|
|
21
|
+
import { randomBytes } from '@aztec/foundation/crypto';
|
|
22
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
23
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
24
|
+
import { TestERC20Abi } from '@aztec/l1-artifacts/TestERC20Abi';
|
|
25
|
+
import { TestERC20Bytecode } from '@aztec/l1-artifacts/TestERC20Bytecode';
|
|
26
|
+
import { AMMContract } from '@aztec/noir-contracts.js/AMM';
|
|
27
|
+
import { FPCContract } from '@aztec/noir-contracts.js/FPC';
|
|
28
|
+
import { FeeJuiceContract } from '@aztec/noir-contracts.js/FeeJuice';
|
|
29
|
+
import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
|
|
30
|
+
import { TokenContract as BananaCoin, TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
31
|
+
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
32
|
+
import { getCanonicalFeeJuice } from '@aztec/protocol-contracts/fee-juice';
|
|
33
|
+
import { type PXEServiceConfig, createPXEService, getPXEServiceConfig } from '@aztec/pxe/server';
|
|
34
|
+
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
35
|
+
|
|
36
|
+
import { MNEMONIC } from '../../fixtures/fixtures.js';
|
|
37
|
+
import {
|
|
38
|
+
type ISnapshotManager,
|
|
39
|
+
type SubsystemsContext,
|
|
40
|
+
createSnapshotManager,
|
|
41
|
+
deployAccounts,
|
|
42
|
+
} from '../../fixtures/snapshot_manager.js';
|
|
43
|
+
import { mintTokensToPrivate } from '../../fixtures/token_utils.js';
|
|
44
|
+
import { type SetupOptions, setupSponsoredFPC } from '../../fixtures/utils.js';
|
|
45
|
+
import { CrossChainTestHarness } from '../../shared/cross_chain_test_harness.js';
|
|
46
|
+
import {
|
|
47
|
+
FeeJuicePortalTestingHarnessFactory,
|
|
48
|
+
type GasBridgingTestHarness,
|
|
49
|
+
} from '../../shared/gas_portal_test_harness.js';
|
|
50
|
+
import { ProxyLogger } from './benchmark.js';
|
|
51
|
+
import { type ClientFlowsConfig, FULL_FLOWS_CONFIG, KEY_FLOWS_CONFIG } from './config.js';
|
|
52
|
+
|
|
53
|
+
const { E2E_DATA_PATH: dataPath, BENCHMARK_CONFIG } = process.env;
|
|
54
|
+
|
|
55
|
+
export type AccountType = 'ecdsar1' | 'schnorr';
|
|
56
|
+
export type FeePaymentMethodGetter = (wallet: Wallet) => Promise<FeePaymentMethod>;
|
|
57
|
+
export type BenchmarkingFeePaymentMethod = 'bridged_fee_juice' | 'private_fpc' | 'sponsored_fpc' | 'fee_juice';
|
|
58
|
+
|
|
59
|
+
export class ClientFlowsBenchmark {
|
|
60
|
+
private snapshotManager: ISnapshotManager;
|
|
61
|
+
|
|
62
|
+
public logger: Logger;
|
|
63
|
+
public pxe!: PXE;
|
|
64
|
+
public aztecNode!: AztecNode;
|
|
65
|
+
public cheatCodes!: CheatCodes;
|
|
66
|
+
public context!: SubsystemsContext;
|
|
67
|
+
public chainMonitor!: ChainMonitor;
|
|
68
|
+
public feeJuiceBridgeTestHarness!: GasBridgingTestHarness;
|
|
69
|
+
|
|
70
|
+
// The admin that aids in the setup of the test
|
|
71
|
+
public adminWallet!: AccountWallet;
|
|
72
|
+
public adminAddress!: AztecAddress;
|
|
73
|
+
|
|
74
|
+
// Aztec Node config
|
|
75
|
+
public sequencerAddress!: AztecAddress;
|
|
76
|
+
public coinbase!: EthAddress;
|
|
77
|
+
|
|
78
|
+
// Contracts
|
|
79
|
+
public feeJuiceContract!: FeeJuiceContract;
|
|
80
|
+
// Asset in which fees are paid via FPC
|
|
81
|
+
public bananaCoin!: BananaCoin;
|
|
82
|
+
public bananaFPC!: FPCContract;
|
|
83
|
+
// Random asset we want to trade
|
|
84
|
+
public candyBarCoin!: TokenContract;
|
|
85
|
+
// AMM contract
|
|
86
|
+
public amm!: AMMContract;
|
|
87
|
+
// Liquidity token for AMM
|
|
88
|
+
public liquidityToken!: TokenContract;
|
|
89
|
+
// Sponsored FPC contract
|
|
90
|
+
public sponsoredFPC!: SponsoredFPCContract;
|
|
91
|
+
|
|
92
|
+
// PXE used by the benchmarking user. It can be set up with client-side proving enabled
|
|
93
|
+
public userPXE!: PXE;
|
|
94
|
+
|
|
95
|
+
public realProofs = ['true', '1'].includes(process.env.REAL_PROOFS ?? '');
|
|
96
|
+
|
|
97
|
+
public paymentMethods: Record<BenchmarkingFeePaymentMethod, { forWallet: FeePaymentMethodGetter; circuits: number }> =
|
|
98
|
+
{
|
|
99
|
+
// eslint-disable-next-line camelcase
|
|
100
|
+
bridged_fee_juice: {
|
|
101
|
+
forWallet: this.getBridgedFeeJuicePaymentMethodForWallet.bind(this),
|
|
102
|
+
circuits: 2, // FeeJuice claim + kernel inner
|
|
103
|
+
},
|
|
104
|
+
// eslint-disable-next-line camelcase
|
|
105
|
+
private_fpc: {
|
|
106
|
+
forWallet: this.getPrivateFPCPaymentMethodForWallet.bind(this),
|
|
107
|
+
circuits:
|
|
108
|
+
2 + // FPC entrypoint + kernel inner
|
|
109
|
+
2 + // BananaCoin transfer_to_public + kernel inner
|
|
110
|
+
2 + // Account verify_private_authwit + kernel inner
|
|
111
|
+
2, // BananaCoin prepare_private_balance_increase + kernel inner
|
|
112
|
+
},
|
|
113
|
+
// eslint-disable-next-line camelcase
|
|
114
|
+
sponsored_fpc: {
|
|
115
|
+
forWallet: this.getSponsoredFPCPaymentMethodForWallet.bind(this),
|
|
116
|
+
circuits: 2, // Sponsored FPC sponsor_unconditionally + kernel inner
|
|
117
|
+
},
|
|
118
|
+
// eslint-disable-next-line camelcase
|
|
119
|
+
fee_juice: {
|
|
120
|
+
forWallet: this.getFeeJuicePaymentMethodForWallet.bind(this),
|
|
121
|
+
circuits: 0,
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
public config: ClientFlowsConfig;
|
|
126
|
+
|
|
127
|
+
private proxyLogger: ProxyLogger;
|
|
128
|
+
|
|
129
|
+
constructor(testName?: string, setupOptions: Partial<SetupOptions & DeployL1ContractsArgs> = {}) {
|
|
130
|
+
this.logger = createLogger(`bench:client_flows${testName ? `:${testName}` : ''}`);
|
|
131
|
+
this.snapshotManager = createSnapshotManager(
|
|
132
|
+
`bench_client_flows${testName ? `/${testName}` : ''}`,
|
|
133
|
+
dataPath,
|
|
134
|
+
{ startProverNode: true, ...setupOptions },
|
|
135
|
+
{ ...setupOptions },
|
|
136
|
+
);
|
|
137
|
+
this.config = BENCHMARK_CONFIG === 'key_flows' ? KEY_FLOWS_CONFIG : FULL_FLOWS_CONFIG;
|
|
138
|
+
ProxyLogger.create();
|
|
139
|
+
this.proxyLogger = ProxyLogger.getInstance();
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
async setup() {
|
|
143
|
+
const context = await this.snapshotManager.setup();
|
|
144
|
+
await context.aztecNode.setConfig({ feeRecipient: this.sequencerAddress, coinbase: this.coinbase });
|
|
145
|
+
|
|
146
|
+
const rollupContract = RollupContract.getFromConfig(context.aztecNodeConfig);
|
|
147
|
+
this.chainMonitor = new ChainMonitor(rollupContract, context.dateProvider, this.logger, 200).start();
|
|
148
|
+
|
|
149
|
+
return this;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
async teardown() {
|
|
153
|
+
await this.chainMonitor.stop();
|
|
154
|
+
await this.snapshotManager.teardown();
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
async mintAndBridgeFeeJuice(address: AztecAddress) {
|
|
158
|
+
const claim = await this.feeJuiceBridgeTestHarness.prepareTokensOnL1(address);
|
|
159
|
+
const { claimSecret: secret, messageLeafIndex: index } = claim;
|
|
160
|
+
await this.feeJuiceContract.methods
|
|
161
|
+
.claim(address, claim.claimAmount, secret, index)
|
|
162
|
+
.send({ from: this.adminAddress })
|
|
163
|
+
.wait();
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** Admin mints bananaCoin tokens privately to the target address and redeems them. */
|
|
167
|
+
async mintPrivateBananas(amount: bigint, address: AztecAddress) {
|
|
168
|
+
const balanceBefore = await this.bananaCoin.methods
|
|
169
|
+
.balance_of_private(address)
|
|
170
|
+
.simulate({ from: this.adminAddress });
|
|
171
|
+
|
|
172
|
+
await mintTokensToPrivate(this.bananaCoin, this.adminAddress, this.adminWallet, address, amount);
|
|
173
|
+
|
|
174
|
+
const balanceAfter = await this.bananaCoin.methods
|
|
175
|
+
.balance_of_private(address)
|
|
176
|
+
.simulate({ from: this.adminAddress });
|
|
177
|
+
expect(balanceAfter).toEqual(balanceBefore + amount);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
async createBenchmarkingAccountManager(pxe: PXE, type: 'ecdsar1' | 'schnorr') {
|
|
181
|
+
const benchysSecretKey = Fr.random();
|
|
182
|
+
const salt = Fr.random();
|
|
183
|
+
|
|
184
|
+
let benchysPrivateSigningKey;
|
|
185
|
+
let benchysAccountManager;
|
|
186
|
+
if (type === 'schnorr') {
|
|
187
|
+
benchysPrivateSigningKey = deriveSigningKey(benchysSecretKey);
|
|
188
|
+
benchysAccountManager = await getSchnorrAccount(pxe, benchysSecretKey, benchysPrivateSigningKey, salt);
|
|
189
|
+
} else if (type === 'ecdsar1') {
|
|
190
|
+
benchysPrivateSigningKey = randomBytes(32);
|
|
191
|
+
benchysAccountManager = await getEcdsaRAccount(pxe, benchysSecretKey, benchysPrivateSigningKey, salt);
|
|
192
|
+
} else {
|
|
193
|
+
throw new Error(`Unknown account type: ${type}`);
|
|
194
|
+
}
|
|
195
|
+
await benchysAccountManager.register();
|
|
196
|
+
return benchysAccountManager;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
public async applyBaseSnapshots() {
|
|
200
|
+
await this.applyInitialAccountsSnapshot();
|
|
201
|
+
await this.applySetupFeeJuiceSnapshot();
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
async applyInitialAccountsSnapshot() {
|
|
205
|
+
await this.snapshotManager.snapshot(
|
|
206
|
+
'initial_accounts',
|
|
207
|
+
deployAccounts(2, this.logger),
|
|
208
|
+
async ({ deployedAccounts }, { pxe, aztecNode, aztecNodeConfig }) => {
|
|
209
|
+
this.pxe = pxe;
|
|
210
|
+
|
|
211
|
+
this.aztecNode = aztecNode;
|
|
212
|
+
this.cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, pxe);
|
|
213
|
+
|
|
214
|
+
const deployedWallets = await Promise.all(
|
|
215
|
+
deployedAccounts.map(a => getSchnorrWallet(pxe, a.address, a.signingKey)),
|
|
216
|
+
);
|
|
217
|
+
[this.adminWallet] = deployedWallets;
|
|
218
|
+
this.adminAddress = this.adminWallet.getAddress();
|
|
219
|
+
this.sequencerAddress = deployedWallets[1].getAddress();
|
|
220
|
+
|
|
221
|
+
const canonicalFeeJuice = await getCanonicalFeeJuice();
|
|
222
|
+
this.feeJuiceContract = await FeeJuiceContract.at(canonicalFeeJuice.address, this.adminWallet);
|
|
223
|
+
this.coinbase = EthAddress.random();
|
|
224
|
+
|
|
225
|
+
const userPXEConfig = getPXEServiceConfig();
|
|
226
|
+
const l1Contracts = await aztecNode.getL1ContractAddresses();
|
|
227
|
+
const userPXEConfigWithContracts = {
|
|
228
|
+
...userPXEConfig,
|
|
229
|
+
proverEnabled: this.realProofs,
|
|
230
|
+
l1Contracts,
|
|
231
|
+
} as PXEServiceConfig;
|
|
232
|
+
|
|
233
|
+
this.userPXE = await createPXEService(this.aztecNode, userPXEConfigWithContracts, {
|
|
234
|
+
loggers: {
|
|
235
|
+
prover: this.proxyLogger.createLogger('pxe:bb:wasm:bundle:proxied'),
|
|
236
|
+
},
|
|
237
|
+
});
|
|
238
|
+
},
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
async applySetupFeeJuiceSnapshot() {
|
|
243
|
+
await this.snapshotManager.snapshot(
|
|
244
|
+
'setup_fee_juice',
|
|
245
|
+
async () => {},
|
|
246
|
+
async (_data, context) => {
|
|
247
|
+
this.context = context;
|
|
248
|
+
|
|
249
|
+
this.feeJuiceContract = await FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, this.adminWallet);
|
|
250
|
+
|
|
251
|
+
this.feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({
|
|
252
|
+
aztecNode: context.aztecNode,
|
|
253
|
+
aztecNodeAdmin: context.aztecNode,
|
|
254
|
+
pxeService: context.pxe,
|
|
255
|
+
l1Client: context.deployL1ContractsValues.l1Client,
|
|
256
|
+
wallet: this.adminWallet,
|
|
257
|
+
logger: this.logger,
|
|
258
|
+
});
|
|
259
|
+
},
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
async applyDeployBananaTokenSnapshot() {
|
|
264
|
+
await this.snapshotManager.snapshot(
|
|
265
|
+
'deploy_banana_token',
|
|
266
|
+
async () => {
|
|
267
|
+
const bananaCoin = await BananaCoin.deploy(this.adminWallet, this.adminAddress, 'BC', 'BC', 18n)
|
|
268
|
+
.send({ from: this.adminAddress })
|
|
269
|
+
.deployed();
|
|
270
|
+
this.logger.info(`BananaCoin deployed at ${bananaCoin.address}`);
|
|
271
|
+
return { bananaCoinAddress: bananaCoin.address };
|
|
272
|
+
},
|
|
273
|
+
async ({ bananaCoinAddress }) => {
|
|
274
|
+
this.bananaCoin = await BananaCoin.at(bananaCoinAddress, this.adminWallet);
|
|
275
|
+
},
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
async applyDeployCandyBarTokenSnapshot() {
|
|
280
|
+
await this.snapshotManager.snapshot(
|
|
281
|
+
'deploy_candy_bar_token',
|
|
282
|
+
async () => {
|
|
283
|
+
const candyBarCoin = await TokenContract.deploy(this.adminWallet, this.adminAddress, 'CBC', 'CBC', 18n)
|
|
284
|
+
.send({ from: this.adminAddress })
|
|
285
|
+
.deployed();
|
|
286
|
+
this.logger.info(`CandyBarCoin deployed at ${candyBarCoin.address}`);
|
|
287
|
+
return { candyBarCoinAddress: candyBarCoin.address };
|
|
288
|
+
},
|
|
289
|
+
async ({ candyBarCoinAddress }) => {
|
|
290
|
+
this.candyBarCoin = await TokenContract.at(candyBarCoinAddress, this.adminWallet);
|
|
291
|
+
},
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
public async applyFPCSetupSnapshot() {
|
|
296
|
+
await this.snapshotManager.snapshot(
|
|
297
|
+
'fpc_setup',
|
|
298
|
+
async context => {
|
|
299
|
+
const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice;
|
|
300
|
+
expect((await context.pxe.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true);
|
|
301
|
+
|
|
302
|
+
const bananaCoin = this.bananaCoin;
|
|
303
|
+
const bananaFPC = await FPCContract.deploy(this.adminWallet, bananaCoin.address, this.adminAddress)
|
|
304
|
+
.send({ from: this.adminAddress })
|
|
305
|
+
.deployed();
|
|
306
|
+
|
|
307
|
+
this.logger.info(`BananaPay deployed at ${bananaFPC.address}`);
|
|
308
|
+
|
|
309
|
+
await this.feeJuiceBridgeTestHarness.bridgeFromL1ToL2(bananaFPC.address, this.adminAddress);
|
|
310
|
+
|
|
311
|
+
return { bananaFPCAddress: bananaFPC.address };
|
|
312
|
+
},
|
|
313
|
+
async data => {
|
|
314
|
+
this.bananaFPC = await FPCContract.at(data.bananaFPCAddress, this.adminWallet);
|
|
315
|
+
},
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
async applyDeploySponsoredFPCSnapshot() {
|
|
320
|
+
await this.snapshotManager.snapshot(
|
|
321
|
+
'deploy_sponsored_fpc',
|
|
322
|
+
async () => {
|
|
323
|
+
const sponsoredFPC = await setupSponsoredFPC(this.pxe);
|
|
324
|
+
this.logger.info(`SponsoredFPC at ${sponsoredFPC.address}`);
|
|
325
|
+
return { sponsoredFPCAddress: sponsoredFPC.address };
|
|
326
|
+
},
|
|
327
|
+
async ({ sponsoredFPCAddress }) => {
|
|
328
|
+
this.sponsoredFPC = await SponsoredFPCContract.at(sponsoredFPCAddress, this.adminWallet);
|
|
329
|
+
},
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
public async createCrossChainTestHarness(owner: AccountWallet) {
|
|
334
|
+
const l1Client = createExtendedL1Client(this.context.aztecNodeConfig.l1RpcUrls, MNEMONIC);
|
|
335
|
+
|
|
336
|
+
const underlyingERC20Address = await deployL1Contract(l1Client, TestERC20Abi, TestERC20Bytecode, [
|
|
337
|
+
'Underlying',
|
|
338
|
+
'UND',
|
|
339
|
+
l1Client.account.address,
|
|
340
|
+
]).then(({ address }) => address);
|
|
341
|
+
|
|
342
|
+
this.logger.verbose(`Setting up cross chain harness...`);
|
|
343
|
+
const crossChainTestHarness = await CrossChainTestHarness.new(
|
|
344
|
+
this.aztecNode,
|
|
345
|
+
this.pxe,
|
|
346
|
+
l1Client,
|
|
347
|
+
owner,
|
|
348
|
+
owner.getAddress(),
|
|
349
|
+
this.logger,
|
|
350
|
+
underlyingERC20Address,
|
|
351
|
+
);
|
|
352
|
+
|
|
353
|
+
this.logger.verbose(`L2 token deployed to: ${crossChainTestHarness.l2Token.address}`);
|
|
354
|
+
|
|
355
|
+
return crossChainTestHarness;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
public async createAndFundBenchmarkingWallet(accountType: AccountType) {
|
|
359
|
+
const benchysAccountManager = await this.createBenchmarkingAccountManager(this.pxe, accountType);
|
|
360
|
+
const benchysWallet = await benchysAccountManager.getWallet();
|
|
361
|
+
const benchysAddress = benchysAccountManager.getAddress();
|
|
362
|
+
const claim = await this.feeJuiceBridgeTestHarness.prepareTokensOnL1(benchysAddress);
|
|
363
|
+
const paymentMethod = new FeeJuicePaymentMethodWithClaim(benchysWallet, claim);
|
|
364
|
+
await benchysAccountManager.deploy({ fee: { paymentMethod } }).wait();
|
|
365
|
+
// Register benchy on the user's PXE, where we're going to be interacting from
|
|
366
|
+
await this.userPXE.registerContract({
|
|
367
|
+
instance: benchysAccountManager.getInstance(),
|
|
368
|
+
artifact: accountType === 'ecdsar1' ? EcdsaRAccountContractArtifact : SchnorrAccountContractArtifact,
|
|
369
|
+
});
|
|
370
|
+
await this.userPXE.registerAccount(benchysWallet.getSecretKey(), benchysWallet.getCompleteAddress().partialAddress);
|
|
371
|
+
const entrypoint = await benchysAccountManager.getAccount();
|
|
372
|
+
return new AccountWalletWithSecretKey(
|
|
373
|
+
this.userPXE,
|
|
374
|
+
entrypoint,
|
|
375
|
+
benchysWallet.getSecretKey(),
|
|
376
|
+
benchysAccountManager.salt,
|
|
377
|
+
);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
public async applyDeployAmmSnapshot() {
|
|
381
|
+
await this.snapshotManager.snapshot(
|
|
382
|
+
'deploy_amm',
|
|
383
|
+
async () => {
|
|
384
|
+
const liquidityToken = await TokenContract.deploy(this.adminWallet, this.adminAddress, 'LPT', 'LPT', 18n)
|
|
385
|
+
.send({ from: this.adminAddress })
|
|
386
|
+
.deployed();
|
|
387
|
+
const amm = await AMMContract.deploy(
|
|
388
|
+
this.adminWallet,
|
|
389
|
+
this.bananaCoin.address,
|
|
390
|
+
this.candyBarCoin.address,
|
|
391
|
+
liquidityToken.address,
|
|
392
|
+
)
|
|
393
|
+
.send({ from: this.adminAddress })
|
|
394
|
+
.deployed();
|
|
395
|
+
this.logger.info(`AMM deployed at ${amm.address}`);
|
|
396
|
+
await liquidityToken.methods.set_minter(amm.address, true).send({ from: this.adminAddress }).wait();
|
|
397
|
+
return { ammAddress: amm.address, liquidityTokenAddress: liquidityToken.address };
|
|
398
|
+
},
|
|
399
|
+
async ({ ammAddress, liquidityTokenAddress }) => {
|
|
400
|
+
this.liquidityToken = await TokenContract.at(liquidityTokenAddress, this.adminWallet);
|
|
401
|
+
this.amm = await AMMContract.at(ammAddress, this.adminWallet);
|
|
402
|
+
},
|
|
403
|
+
);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
public async getBridgedFeeJuicePaymentMethodForWallet(wallet: Wallet) {
|
|
407
|
+
const claim = await this.feeJuiceBridgeTestHarness.prepareTokensOnL1(wallet.getAddress());
|
|
408
|
+
return new FeeJuicePaymentMethodWithClaim(wallet, claim);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
public getPrivateFPCPaymentMethodForWallet(wallet: Wallet) {
|
|
412
|
+
return Promise.resolve(new PrivateFeePaymentMethod(this.bananaFPC.address, wallet));
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
public getSponsoredFPCPaymentMethodForWallet(_wallet: Wallet) {
|
|
416
|
+
return Promise.resolve(new SponsoredFeePaymentMethod(this.sponsoredFPC.address));
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
public getFeeJuicePaymentMethodForWallet(wallet: Wallet) {
|
|
420
|
+
return Promise.resolve(new FeeJuicePaymentMethod(wallet.getAddress()));
|
|
421
|
+
}
|
|
422
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { AccountType, BenchmarkingFeePaymentMethod } from './client_flows_benchmark.js';
|
|
2
|
+
|
|
3
|
+
export type ClientFlowConfig = {
|
|
4
|
+
accounts: AccountType[];
|
|
5
|
+
feePaymentMethods: BenchmarkingFeePaymentMethod[];
|
|
6
|
+
recursions?: number[];
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type ClientFlows = 'accountDeployments' | 'deployments' | 'transfers' | 'bridging' | 'amm';
|
|
10
|
+
|
|
11
|
+
export type ClientFlowsConfig = {
|
|
12
|
+
[key in ClientFlows]: ClientFlowConfig;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const KEY_FLOWS_CONFIG: ClientFlowsConfig = {
|
|
16
|
+
accountDeployments: {
|
|
17
|
+
accounts: ['ecdsar1', 'schnorr'],
|
|
18
|
+
feePaymentMethods: ['sponsored_fpc'],
|
|
19
|
+
},
|
|
20
|
+
deployments: {
|
|
21
|
+
accounts: ['ecdsar1', 'schnorr'],
|
|
22
|
+
feePaymentMethods: ['sponsored_fpc'],
|
|
23
|
+
},
|
|
24
|
+
amm: {
|
|
25
|
+
accounts: ['ecdsar1'],
|
|
26
|
+
feePaymentMethods: ['sponsored_fpc'],
|
|
27
|
+
},
|
|
28
|
+
bridging: {
|
|
29
|
+
accounts: ['ecdsar1'],
|
|
30
|
+
feePaymentMethods: ['sponsored_fpc'],
|
|
31
|
+
},
|
|
32
|
+
transfers: {
|
|
33
|
+
accounts: ['ecdsar1'],
|
|
34
|
+
feePaymentMethods: ['sponsored_fpc', 'private_fpc'],
|
|
35
|
+
recursions: [0, 1],
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const FULL_FLOWS_CONFIG: ClientFlowsConfig = {
|
|
40
|
+
accountDeployments: {
|
|
41
|
+
accounts: ['ecdsar1', 'schnorr'],
|
|
42
|
+
feePaymentMethods: ['bridged_fee_juice', 'sponsored_fpc'],
|
|
43
|
+
},
|
|
44
|
+
deployments: {
|
|
45
|
+
accounts: ['ecdsar1', 'schnorr'],
|
|
46
|
+
feePaymentMethods: ['bridged_fee_juice', 'sponsored_fpc'],
|
|
47
|
+
},
|
|
48
|
+
amm: {
|
|
49
|
+
accounts: ['ecdsar1', 'schnorr'],
|
|
50
|
+
feePaymentMethods: ['sponsored_fpc', 'private_fpc'],
|
|
51
|
+
},
|
|
52
|
+
bridging: {
|
|
53
|
+
accounts: ['ecdsar1', 'schnorr'],
|
|
54
|
+
feePaymentMethods: ['sponsored_fpc', 'private_fpc'],
|
|
55
|
+
},
|
|
56
|
+
transfers: {
|
|
57
|
+
accounts: ['ecdsar1', 'schnorr'],
|
|
58
|
+
feePaymentMethods: ['sponsored_fpc', 'private_fpc'],
|
|
59
|
+
recursions: [0, 1, 2],
|
|
60
|
+
},
|
|
61
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { Logger } from '@aztec/aztec.js';
|
|
2
|
+
import { BBNativePrivateKernelProver } from '@aztec/bb-prover/client/native';
|
|
3
|
+
import { BBWASMBundlePrivateKernelProver } from '@aztec/bb-prover/client/wasm/bundle';
|
|
4
|
+
import { createLogger, logger } from '@aztec/foundation/log';
|
|
5
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
6
|
+
import { WASMSimulator } from '@aztec/simulator/client';
|
|
7
|
+
import type { PrivateExecutionStep } from '@aztec/stdlib/kernel';
|
|
8
|
+
import type { ProvingStats, ProvingTimings, SimulationStats } from '@aztec/stdlib/tx';
|
|
9
|
+
|
|
10
|
+
import { Decoder } from 'msgpackr';
|
|
11
|
+
import { readFile, readdir, writeFile } from 'node:fs/promises';
|
|
12
|
+
import { join } from 'node:path';
|
|
13
|
+
|
|
14
|
+
import { type Log, type ProverType, ProxyLogger, generateBenchmark } from './benchmark.js';
|
|
15
|
+
|
|
16
|
+
type NativeProverConfig = { bbBinaryPath?: string; bbWorkingDirectory?: string };
|
|
17
|
+
|
|
18
|
+
async function createProver(config: NativeProverConfig = {}, log: Logger) {
|
|
19
|
+
const simulator = new WASMSimulator();
|
|
20
|
+
if (!config.bbBinaryPath || !config.bbWorkingDirectory) {
|
|
21
|
+
return { prover: new BBWASMBundlePrivateKernelProver(simulator, 16, log), type: 'wasm' as ProverType };
|
|
22
|
+
} else {
|
|
23
|
+
const bbConfig = config as Required<NativeProverConfig>;
|
|
24
|
+
return {
|
|
25
|
+
prover: await BBNativePrivateKernelProver.new(
|
|
26
|
+
{ bbSkipCleanup: false, numConcurrentIVCVerifiers: 1, bbIVCConcurrency: 1, ...bbConfig },
|
|
27
|
+
simulator,
|
|
28
|
+
log,
|
|
29
|
+
),
|
|
30
|
+
type: 'native' as ProverType,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function main() {
|
|
36
|
+
ProxyLogger.create();
|
|
37
|
+
const proxyLogger = ProxyLogger.getInstance();
|
|
38
|
+
const ivcFolder = process.env.CAPTURE_IVC_FOLDER;
|
|
39
|
+
if (!ivcFolder) {
|
|
40
|
+
throw new Error('CAPTURE_IVC_FOLDER is not set');
|
|
41
|
+
}
|
|
42
|
+
const flows = await readdir(ivcFolder);
|
|
43
|
+
logger.info(`Flows in ${ivcFolder}: \n${flows.map(flowName => `\t- ${flowName}`).join('\n')}`);
|
|
44
|
+
const { prover, type: proverType } = await createProver(
|
|
45
|
+
{ bbBinaryPath: process.env.BB_BINARY_PATH, bbWorkingDirectory: process.env.BB_WORKING_DIRECTORY },
|
|
46
|
+
proxyLogger.createLogger('bb:prover'),
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const userLog = createLogger('client_ivc_flows:data_processor');
|
|
50
|
+
|
|
51
|
+
for (const flow of flows) {
|
|
52
|
+
userLog.info(`Processing flow ${flow}`);
|
|
53
|
+
const ivcInputs = await readFile(join(ivcFolder, flow, 'ivc-inputs.msgpack'));
|
|
54
|
+
const stepsFromFile: PrivateExecutionStep[] = new Decoder({ useRecords: false }).unpack(ivcInputs);
|
|
55
|
+
const witnesses = await readFile(join(ivcFolder, flow, 'witnesses.json'));
|
|
56
|
+
|
|
57
|
+
const witnessStack = JSON.parse(witnesses.toString()).map((witnessMap: Record<string, string>) => {
|
|
58
|
+
return new Map<number, string>(Object.entries(witnessMap).map(([k, v]) => [Number(k), v]));
|
|
59
|
+
});
|
|
60
|
+
const profileFile = await readFile(join(ivcFolder, flow, 'profile.json'));
|
|
61
|
+
const profile = JSON.parse(profileFile.toString()) as {
|
|
62
|
+
stats: ProvingStats | SimulationStats;
|
|
63
|
+
steps: {
|
|
64
|
+
functionName: string;
|
|
65
|
+
gateCount: number;
|
|
66
|
+
timings: { witgen: number; gateCount: number };
|
|
67
|
+
}[];
|
|
68
|
+
};
|
|
69
|
+
const privateExecutionSteps: PrivateExecutionStep[] = profile.steps.map((step, i) => ({
|
|
70
|
+
functionName: step.functionName,
|
|
71
|
+
gateCount: step.gateCount,
|
|
72
|
+
bytecode: stepsFromFile[i].bytecode,
|
|
73
|
+
// TODO(AD) do we still want to take this from witness.json?
|
|
74
|
+
witness: witnessStack[i],
|
|
75
|
+
vk: stepsFromFile[i].vk,
|
|
76
|
+
timings: {
|
|
77
|
+
witgen: step.timings.witgen,
|
|
78
|
+
gateCount: step.timings.gateCount,
|
|
79
|
+
},
|
|
80
|
+
}));
|
|
81
|
+
|
|
82
|
+
let error: any;
|
|
83
|
+
let currentLogs: Log[] = [];
|
|
84
|
+
let provingTime;
|
|
85
|
+
try {
|
|
86
|
+
const provingTimer = new Timer();
|
|
87
|
+
await prover.createClientIvcProof(privateExecutionSteps);
|
|
88
|
+
provingTime = provingTimer.ms();
|
|
89
|
+
} catch (e) {
|
|
90
|
+
userLog.error(`Failed to generate client ivc proof for ${flow}`, e);
|
|
91
|
+
error = (e as Error).message;
|
|
92
|
+
}
|
|
93
|
+
// Extract logs from this run from the proxy and write them to disk unconditionally
|
|
94
|
+
currentLogs = proxyLogger.getLogs();
|
|
95
|
+
await writeFile(join(ivcFolder, flow, 'logs.json'), JSON.stringify(currentLogs, null, 2));
|
|
96
|
+
if (!(profile.stats.timings as ProvingTimings).proving) {
|
|
97
|
+
(profile.stats.timings as ProvingTimings).proving = provingTime;
|
|
98
|
+
}
|
|
99
|
+
const benchmark = generateBenchmark(flow, currentLogs, profile.stats, privateExecutionSteps, proverType, error);
|
|
100
|
+
await writeFile(join(ivcFolder, flow, 'benchmark.json'), JSON.stringify(benchmark, null, 2));
|
|
101
|
+
proxyLogger.flushLogs();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
try {
|
|
106
|
+
await main();
|
|
107
|
+
} catch (e) {
|
|
108
|
+
// eslint-disable-next-line no-console
|
|
109
|
+
console.error(e);
|
|
110
|
+
process.exit(1);
|
|
111
|
+
}
|