@aztec/end-to-end 0.0.0-test.0 → 0.0.1-fake-c83136db25
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 +61 -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 +73 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/client_flows_benchmark.js +311 -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 -36
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +26 -66
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +20 -12
- 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 +85 -57
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +18 -24
- 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 +48 -69
- package/dest/e2e_deploy_contract/deploy_test.d.ts +14 -6
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +13 -19
- package/dest/e2e_epochs/epochs_test.d.ts +58 -17
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +224 -43
- 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 +63 -0
- package/dest/e2e_fees/fees_test.d.ts +20 -9
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +98 -107
- package/dest/e2e_l1_publisher/write_json.d.ts +10 -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 +9 -6
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +22 -19
- 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 +135 -0
- package/dest/e2e_p2p/p2p_network.d.ts +69 -22
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +180 -129
- package/dest/e2e_p2p/shared.d.ts +41 -5
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +163 -19
- package/dest/e2e_token_contract/token_contract_test.d.ts +11 -5
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +50 -26
- package/dest/{e2e_prover → fixtures}/e2e_prover_test.d.ts +14 -9
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
- package/dest/{e2e_prover → fixtures}/e2e_prover_test.js +95 -100
- 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 +1 -1
- 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 +1 -1
- package/dest/fixtures/get_bb_config.d.ts.map +1 -1
- package/dest/fixtures/get_bb_config.js +10 -17
- 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 +4 -4
- package/dest/fixtures/setup_p2p_test.d.ts +14 -13
- 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 +15 -7
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.js +147 -121
- package/dest/fixtures/token_utils.d.ts +6 -3
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +23 -10
- package/dest/fixtures/utils.d.ts +76 -37
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +464 -368
- package/dest/fixtures/web3signer.d.ts +5 -0
- package/dest/fixtures/web3signer.d.ts.map +1 -0
- package/dest/fixtures/web3signer.js +53 -0
- package/dest/quality_of_service/alert_checker.d.ts +1 -1
- package/dest/quality_of_service/alert_checker.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.d.ts +41 -25
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +104 -50
- package/dest/shared/gas_portal_test_harness.d.ts +32 -24
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +50 -29
- package/dest/shared/jest_setup.js +1 -1
- package/dest/shared/submit-transactions.d.ts +5 -3
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/submit-transactions.js +8 -7
- package/dest/shared/uniswap_l1_l2.d.ts +13 -11
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +138 -108
- package/dest/simulators/lending_simulator.d.ts +6 -6
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +13 -16
- package/dest/simulators/token_simulator.d.ts +5 -2
- 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 +23 -10
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +167 -58
- package/dest/spartan/utils.d.ts +100 -303
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +407 -130
- package/package.json +61 -56
- package/src/bench/client_flows/benchmark.ts +341 -0
- package/src/bench/client_flows/client_flows_benchmark.ts +402 -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 +22 -76
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +80 -77
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +63 -105
- package/src/e2e_deploy_contract/deploy_test.ts +23 -38
- package/src/e2e_epochs/epochs_test.ts +274 -54
- package/src/e2e_fees/bridging_race.notest.ts +80 -0
- package/src/e2e_fees/fees_test.ts +137 -136
- package/src/e2e_l1_publisher/write_json.ts +76 -0
- package/src/e2e_multi_validator/utils.ts +258 -0
- package/src/e2e_nested_contract/nested_contract_test.ts +27 -18
- package/src/e2e_p2p/inactivity_slash_test.ts +178 -0
- package/src/e2e_p2p/p2p_network.ts +272 -166
- package/src/e2e_p2p/shared.ts +244 -29
- package/src/e2e_token_contract/token_contract_test.ts +43 -39
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/{e2e_prover → fixtures}/e2e_prover_test.ts +101 -145
- package/src/fixtures/fixtures.ts +4 -3
- package/src/fixtures/get_acvm_config.ts +3 -11
- package/src/fixtures/get_bb_config.ts +18 -13
- package/src/fixtures/l1_to_l2_messaging.ts +53 -23
- package/src/fixtures/setup_l1_contracts.ts +6 -7
- package/src/fixtures/setup_p2p_test.ts +112 -38
- package/src/fixtures/snapshot_manager.ts +187 -139
- package/src/fixtures/token_utils.ts +29 -12
- package/src/fixtures/utils.ts +552 -425
- package/src/fixtures/web3signer.ts +63 -0
- package/src/guides/up_quick_start.sh +6 -14
- package/src/quality_of_service/alert_checker.ts +1 -1
- package/src/shared/cross_chain_test_harness.ts +108 -79
- package/src/shared/gas_portal_test_harness.ts +58 -49
- package/src/shared/jest_setup.ts +1 -1
- package/src/shared/submit-transactions.ts +12 -8
- package/src/shared/uniswap_l1_l2.ts +173 -176
- package/src/simulators/lending_simulator.ts +12 -15
- package/src/simulators/token_simulator.ts +21 -13
- package/src/spartan/DEVELOP.md +121 -0
- package/src/spartan/setup_test_wallets.ts +215 -93
- package/src/spartan/utils.ts +458 -130
- 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
|
@@ -1,28 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
CheatCodes,
|
|
8
|
-
type Logger,
|
|
9
|
-
type PXE,
|
|
10
|
-
createLogger,
|
|
11
|
-
sleep,
|
|
12
|
-
} from '@aztec/aztec.js';
|
|
13
|
-
import { FEE_FUNDING_FOR_TESTER_ACCOUNT } from '@aztec/constants';
|
|
14
|
-
import { type DeployL1ContractsArgs, RollupContract, createL1Clients } from '@aztec/ethereum';
|
|
1
|
+
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { type Logger, createLogger } from '@aztec/aztec.js/log';
|
|
3
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
4
|
+
import { CheatCodes } from '@aztec/aztec/testing';
|
|
5
|
+
import { type DeployL1ContractsArgs, RollupContract, createExtendedL1Client } from '@aztec/ethereum';
|
|
6
|
+
import { ChainMonitor } from '@aztec/ethereum/test';
|
|
15
7
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
16
|
-
import {
|
|
8
|
+
import { sleep } from '@aztec/foundation/sleep';
|
|
9
|
+
import { TestERC20Abi } from '@aztec/l1-artifacts';
|
|
17
10
|
import { AppSubscriptionContract } from '@aztec/noir-contracts.js/AppSubscription';
|
|
18
|
-
import { CounterContract } from '@aztec/noir-contracts.js/Counter';
|
|
19
11
|
import { FPCContract } from '@aztec/noir-contracts.js/FPC';
|
|
20
12
|
import { FeeJuiceContract } from '@aztec/noir-contracts.js/FeeJuice';
|
|
13
|
+
import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
|
|
21
14
|
import { TokenContract as BananaCoin } from '@aztec/noir-contracts.js/Token';
|
|
15
|
+
import { CounterContract } from '@aztec/noir-test-contracts.js/Counter';
|
|
22
16
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
23
17
|
import { getCanonicalFeeJuice } from '@aztec/protocol-contracts/fee-juice';
|
|
24
|
-
import { computePartialAddress } from '@aztec/stdlib/contract';
|
|
25
18
|
import { GasSettings } from '@aztec/stdlib/gas';
|
|
19
|
+
import { TestWallet } from '@aztec/test-wallet/server';
|
|
26
20
|
|
|
27
21
|
import { getContract } from 'viem';
|
|
28
22
|
|
|
@@ -37,9 +31,9 @@ import { mintTokensToPrivate } from '../fixtures/token_utils.js';
|
|
|
37
31
|
import {
|
|
38
32
|
type BalancesFn,
|
|
39
33
|
type SetupOptions,
|
|
40
|
-
|
|
34
|
+
ensureAccountContractsPublished,
|
|
41
35
|
getBalancesFn,
|
|
42
|
-
|
|
36
|
+
setupSponsoredFPC,
|
|
43
37
|
} from '../fixtures/utils.js';
|
|
44
38
|
import { FeeJuicePortalTestingHarnessFactory, type GasBridgingTestHarness } from '../shared/gas_portal_test_harness.js';
|
|
45
39
|
|
|
@@ -51,21 +45,20 @@ const { E2E_DATA_PATH: dataPath } = process.env;
|
|
|
51
45
|
* PublicDeployAccounts: Deploys the accounts publicly.
|
|
52
46
|
* DeployFeeJuice: Deploys the Fee Juice contract.
|
|
53
47
|
* FPCSetup: Deploys BananaCoin and FPC contracts, and bridges gas from L1.
|
|
48
|
+
* SponsoredFPCSetup: Deploys Sponsored FPC contract, and bridges gas from L1.
|
|
54
49
|
* FundAlice: Mints private and public bananas to Alice.
|
|
55
50
|
* SetupSubscription: Deploys a counter contract and a subscription contract, and mints Fee Juice to the subscription contract.
|
|
56
51
|
*/
|
|
57
52
|
export class FeesTest {
|
|
58
53
|
private snapshotManager: ISnapshotManager;
|
|
59
|
-
private
|
|
54
|
+
private accounts: AztecAddress[] = [];
|
|
60
55
|
|
|
61
56
|
public logger: Logger;
|
|
62
|
-
public pxe!: PXE;
|
|
63
57
|
public aztecNode!: AztecNode;
|
|
64
58
|
public cheatCodes!: CheatCodes;
|
|
65
59
|
|
|
66
|
-
public
|
|
60
|
+
public wallet!: TestWallet;
|
|
67
61
|
public aliceAddress!: AztecAddress;
|
|
68
|
-
public bobWallet!: AccountWallet;
|
|
69
62
|
public bobAddress!: AztecAddress;
|
|
70
63
|
public sequencerAddress!: AztecAddress;
|
|
71
64
|
public coinbase!: EthAddress;
|
|
@@ -74,9 +67,12 @@ export class FeesTest {
|
|
|
74
67
|
|
|
75
68
|
public gasSettings!: GasSettings;
|
|
76
69
|
|
|
70
|
+
public rollupContract!: RollupContract;
|
|
71
|
+
|
|
77
72
|
public feeJuiceContract!: FeeJuiceContract;
|
|
78
73
|
public bananaCoin!: BananaCoin;
|
|
79
74
|
public bananaFPC!: FPCContract;
|
|
75
|
+
public sponsoredFPC!: SponsoredFPCContract;
|
|
80
76
|
public counterContract!: CounterContract;
|
|
81
77
|
public subscriptionContract!: AppSubscriptionContract;
|
|
82
78
|
public feeJuiceBridgeTestHarness!: GasBridgingTestHarness;
|
|
@@ -103,6 +99,8 @@ export class FeesTest {
|
|
|
103
99
|
if (!numberOfAccounts) {
|
|
104
100
|
throw new Error('There must be at least 1 initial account.');
|
|
105
101
|
}
|
|
102
|
+
setupOptions.coinbase ??= EthAddress.random();
|
|
103
|
+
this.coinbase = setupOptions.coinbase!;
|
|
106
104
|
this.logger = createLogger(`e2e:e2e_fees:${testName}`);
|
|
107
105
|
this.snapshotManager = createSnapshotManager(
|
|
108
106
|
`e2e_fees/${testName}-${numberOfAccounts}`,
|
|
@@ -114,16 +112,15 @@ export class FeesTest {
|
|
|
114
112
|
|
|
115
113
|
async setup() {
|
|
116
114
|
const context = await this.snapshotManager.setup();
|
|
117
|
-
await context.aztecNode.setConfig({ feeRecipient: this.sequencerAddress, coinbase: this.coinbase });
|
|
118
115
|
|
|
119
|
-
|
|
120
|
-
this.chainMonitor = new ChainMonitor(rollupContract, this.logger, 200).start();
|
|
116
|
+
this.rollupContract = RollupContract.getFromConfig(context.aztecNodeConfig);
|
|
117
|
+
this.chainMonitor = new ChainMonitor(this.rollupContract, context.dateProvider, this.logger, 200).start();
|
|
121
118
|
|
|
122
119
|
return this;
|
|
123
120
|
}
|
|
124
121
|
|
|
125
122
|
async teardown() {
|
|
126
|
-
this.chainMonitor.stop();
|
|
123
|
+
await this.chainMonitor.stop();
|
|
127
124
|
await this.snapshotManager.teardown();
|
|
128
125
|
}
|
|
129
126
|
|
|
@@ -138,19 +135,41 @@ export class FeesTest {
|
|
|
138
135
|
}
|
|
139
136
|
}
|
|
140
137
|
|
|
141
|
-
async
|
|
142
|
-
const
|
|
138
|
+
async getBlockRewards() {
|
|
139
|
+
const blockReward = await this.rollupContract.getBlockReward();
|
|
140
|
+
const rewardConfig = await this.rollupContract.getRewardConfig();
|
|
141
|
+
|
|
142
|
+
const balance = await this.feeJuiceBridgeTestHarness.getL1FeeJuiceBalance(
|
|
143
|
+
EthAddress.fromString(rewardConfig.rewardDistributor),
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
const toDistribute = balance > blockReward ? blockReward : balance;
|
|
147
|
+
const sequencerBlockRewards = (toDistribute * BigInt(rewardConfig.sequencerBps)) / 10000n;
|
|
148
|
+
const proverBlockRewards = toDistribute - sequencerBlockRewards;
|
|
149
|
+
|
|
150
|
+
return { sequencerBlockRewards, proverBlockRewards };
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
async mintAndBridgeFeeJuice(minter: AztecAddress, recipient: AztecAddress) {
|
|
154
|
+
const claim = await this.feeJuiceBridgeTestHarness.prepareTokensOnL1(recipient);
|
|
143
155
|
const { claimSecret: secret, messageLeafIndex: index } = claim;
|
|
144
|
-
await this.feeJuiceContract.methods
|
|
156
|
+
await this.feeJuiceContract.methods
|
|
157
|
+
.claim(recipient, claim.claimAmount, secret, index)
|
|
158
|
+
.send({ from: minter })
|
|
159
|
+
.wait();
|
|
145
160
|
}
|
|
146
161
|
|
|
147
162
|
/** Alice mints bananaCoin tokens privately to the target address and redeems them. */
|
|
148
163
|
async mintPrivateBananas(amount: bigint, address: AztecAddress) {
|
|
149
|
-
const balanceBefore = await this.bananaCoin.methods
|
|
164
|
+
const balanceBefore = await this.bananaCoin.methods
|
|
165
|
+
.balance_of_private(address)
|
|
166
|
+
.simulate({ from: this.aliceAddress });
|
|
150
167
|
|
|
151
|
-
await mintTokensToPrivate(this.bananaCoin, this.
|
|
168
|
+
await mintTokensToPrivate(this.bananaCoin, this.aliceAddress, address, amount);
|
|
152
169
|
|
|
153
|
-
const balanceAfter = await this.bananaCoin.methods
|
|
170
|
+
const balanceAfter = await this.bananaCoin.methods
|
|
171
|
+
.balance_of_private(address)
|
|
172
|
+
.simulate({ from: this.aliceAddress });
|
|
154
173
|
expect(balanceAfter).toEqual(balanceBefore + amount);
|
|
155
174
|
}
|
|
156
175
|
|
|
@@ -165,66 +184,51 @@ export class FeesTest {
|
|
|
165
184
|
await this.snapshotManager.snapshot(
|
|
166
185
|
'initial_accounts',
|
|
167
186
|
deployAccounts(this.numberOfAccounts, this.logger),
|
|
168
|
-
async ({ deployedAccounts }, {
|
|
169
|
-
this.
|
|
187
|
+
async ({ deployedAccounts }, { wallet, aztecNode, cheatCodes }) => {
|
|
188
|
+
this.wallet = wallet;
|
|
170
189
|
this.aztecNode = aztecNode;
|
|
171
190
|
this.gasSettings = GasSettings.default({ maxFeesPerGas: (await this.aztecNode.getCurrentBaseFees()).mul(2) });
|
|
172
|
-
this.cheatCodes =
|
|
173
|
-
this.
|
|
174
|
-
this.
|
|
175
|
-
[this.
|
|
176
|
-
[this.aliceAddress, this.bobAddress, this.sequencerAddress] = this.wallets.map(w => w.getAddress());
|
|
191
|
+
this.cheatCodes = cheatCodes;
|
|
192
|
+
this.accounts = deployedAccounts.map(a => a.address);
|
|
193
|
+
this.accounts.forEach((a, i) => this.logger.verbose(`Account ${i} address: ${a}`));
|
|
194
|
+
[this.aliceAddress, this.bobAddress, this.sequencerAddress] = this.accounts.slice(0, 3);
|
|
177
195
|
|
|
178
196
|
// We set Alice as the FPC admin to avoid the need for deployment of another account.
|
|
179
197
|
this.fpcAdmin = this.aliceAddress;
|
|
180
198
|
|
|
181
199
|
const canonicalFeeJuice = await getCanonicalFeeJuice();
|
|
182
|
-
this.feeJuiceContract = await FeeJuiceContract.at(canonicalFeeJuice.address, this.
|
|
183
|
-
if (this.numberOfAccounts > 1) {
|
|
184
|
-
const bobInstance = (await this.bobWallet.getContractMetadata(this.bobAddress)).contractInstance;
|
|
185
|
-
await this.aliceWallet.registerAccount(deployedAccounts[1].secret, await computePartialAddress(bobInstance!));
|
|
186
|
-
}
|
|
187
|
-
this.coinbase = EthAddress.random();
|
|
188
|
-
|
|
189
|
-
const { publicClient, walletClient } = createL1Clients(aztecNodeConfig.l1RpcUrls, MNEMONIC);
|
|
190
|
-
this.feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({
|
|
191
|
-
aztecNode: aztecNode,
|
|
192
|
-
pxeService: pxe,
|
|
193
|
-
publicClient: publicClient,
|
|
194
|
-
walletClient: walletClient,
|
|
195
|
-
wallet: this.aliceWallet,
|
|
196
|
-
logger: this.logger,
|
|
197
|
-
});
|
|
200
|
+
this.feeJuiceContract = await FeeJuiceContract.at(canonicalFeeJuice.address, this.wallet);
|
|
198
201
|
},
|
|
199
202
|
);
|
|
200
203
|
}
|
|
201
204
|
|
|
202
205
|
async applyPublicDeployAccountsSnapshot() {
|
|
203
206
|
await this.snapshotManager.snapshot('public_deploy_accounts', () =>
|
|
204
|
-
|
|
207
|
+
ensureAccountContractsPublished(this.wallet, this.accounts),
|
|
205
208
|
);
|
|
206
209
|
}
|
|
207
210
|
|
|
208
211
|
async applySetupFeeJuiceSnapshot() {
|
|
209
212
|
await this.snapshotManager.snapshot(
|
|
210
213
|
'setup_fee_juice',
|
|
211
|
-
async
|
|
212
|
-
await setupCanonicalFeeJuice(context.pxe);
|
|
213
|
-
},
|
|
214
|
+
async () => {},
|
|
214
215
|
async (_data, context) => {
|
|
215
216
|
this.context = context;
|
|
216
217
|
|
|
217
|
-
this.feeJuiceContract = await FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, this.
|
|
218
|
+
this.feeJuiceContract = await FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, this.wallet);
|
|
218
219
|
|
|
219
|
-
this.getGasBalanceFn = getBalancesFn(
|
|
220
|
+
this.getGasBalanceFn = getBalancesFn(
|
|
221
|
+
'⛽',
|
|
222
|
+
this.feeJuiceContract.methods.balance_of_public,
|
|
223
|
+
this.aliceAddress,
|
|
224
|
+
this.logger,
|
|
225
|
+
);
|
|
220
226
|
|
|
221
|
-
const { publicClient, walletClient } = createL1Clients(context.aztecNodeConfig.l1RpcUrls, MNEMONIC);
|
|
222
227
|
this.feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({
|
|
223
228
|
aztecNode: context.aztecNode,
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
wallet: this.aliceWallet,
|
|
229
|
+
aztecNodeAdmin: context.aztecNode,
|
|
230
|
+
l1Client: context.deployL1ContractsValues.l1Client,
|
|
231
|
+
wallet: this.wallet,
|
|
228
232
|
logger: this.logger,
|
|
229
233
|
});
|
|
230
234
|
},
|
|
@@ -235,14 +239,27 @@ export class FeesTest {
|
|
|
235
239
|
await this.snapshotManager.snapshot(
|
|
236
240
|
'deploy_banana_token',
|
|
237
241
|
async () => {
|
|
238
|
-
const bananaCoin = await BananaCoin.deploy(this.
|
|
239
|
-
.send()
|
|
242
|
+
const bananaCoin = await BananaCoin.deploy(this.wallet, this.aliceAddress, 'BC', 'BC', 18n)
|
|
243
|
+
.send({ from: this.aliceAddress })
|
|
240
244
|
.deployed();
|
|
241
245
|
this.logger.info(`BananaCoin deployed at ${bananaCoin.address}`);
|
|
242
246
|
return { bananaCoinAddress: bananaCoin.address };
|
|
243
247
|
},
|
|
244
248
|
async ({ bananaCoinAddress }) => {
|
|
245
|
-
this.bananaCoin = await BananaCoin.at(bananaCoinAddress, this.
|
|
249
|
+
this.bananaCoin = await BananaCoin.at(bananaCoinAddress, this.wallet);
|
|
250
|
+
const logger = this.logger;
|
|
251
|
+
this.getBananaPublicBalanceFn = getBalancesFn(
|
|
252
|
+
'🍌.public',
|
|
253
|
+
this.bananaCoin.methods.balance_of_public,
|
|
254
|
+
this.aliceAddress,
|
|
255
|
+
logger,
|
|
256
|
+
);
|
|
257
|
+
this.getBananaPrivateBalanceFn = getBalancesFn(
|
|
258
|
+
'🍌.private',
|
|
259
|
+
this.bananaCoin.methods.balance_of_private,
|
|
260
|
+
this.aliceAddress,
|
|
261
|
+
logger,
|
|
262
|
+
);
|
|
246
263
|
},
|
|
247
264
|
);
|
|
248
265
|
}
|
|
@@ -252,16 +269,16 @@ export class FeesTest {
|
|
|
252
269
|
'fpc_setup',
|
|
253
270
|
async context => {
|
|
254
271
|
const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice;
|
|
255
|
-
expect((await context.
|
|
272
|
+
expect((await context.wallet.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true);
|
|
256
273
|
|
|
257
274
|
const bananaCoin = this.bananaCoin;
|
|
258
|
-
const bananaFPC = await FPCContract.deploy(this.
|
|
259
|
-
.send()
|
|
275
|
+
const bananaFPC = await FPCContract.deploy(this.wallet, bananaCoin.address, this.fpcAdmin)
|
|
276
|
+
.send({ from: this.aliceAddress })
|
|
260
277
|
.deployed();
|
|
261
278
|
|
|
262
279
|
this.logger.info(`BananaPay deployed at ${bananaFPC.address}`);
|
|
263
280
|
|
|
264
|
-
await this.feeJuiceBridgeTestHarness.bridgeFromL1ToL2(
|
|
281
|
+
await this.feeJuiceBridgeTestHarness.bridgeFromL1ToL2(bananaFPC.address, this.aliceAddress);
|
|
265
282
|
|
|
266
283
|
return {
|
|
267
284
|
bananaFPCAddress: bananaFPC.address,
|
|
@@ -271,62 +288,79 @@ export class FeesTest {
|
|
|
271
288
|
};
|
|
272
289
|
},
|
|
273
290
|
async (data, context) => {
|
|
274
|
-
const bananaFPC = await FPCContract.at(data.bananaFPCAddress, this.
|
|
291
|
+
const bananaFPC = await FPCContract.at(data.bananaFPCAddress, this.wallet);
|
|
275
292
|
this.bananaFPC = bananaFPC;
|
|
276
293
|
|
|
277
|
-
const logger = this.logger;
|
|
278
|
-
this.getBananaPublicBalanceFn = getBalancesFn('🍌.public', this.bananaCoin.methods.balance_of_public, logger);
|
|
279
|
-
this.getBananaPrivateBalanceFn = getBalancesFn(
|
|
280
|
-
'🍌.private',
|
|
281
|
-
this.bananaCoin.methods.balance_of_private,
|
|
282
|
-
logger,
|
|
283
|
-
);
|
|
284
|
-
|
|
285
294
|
this.getCoinbaseBalance = async () => {
|
|
286
|
-
const
|
|
295
|
+
const l1Client = createExtendedL1Client(context.aztecNodeConfig.l1RpcUrls, MNEMONIC);
|
|
287
296
|
const gasL1 = getContract({
|
|
288
297
|
address: data.l1FeeJuiceAddress.toString(),
|
|
289
298
|
abi: TestERC20Abi,
|
|
290
|
-
client:
|
|
299
|
+
client: l1Client,
|
|
291
300
|
});
|
|
292
301
|
return await gasL1.read.balanceOf([this.coinbase.toString()]);
|
|
293
302
|
};
|
|
294
303
|
|
|
295
304
|
this.getCoinbaseSequencerRewards = async () => {
|
|
296
|
-
|
|
297
|
-
const rollup = getContract({
|
|
298
|
-
address: data.rollupAddress.toString(),
|
|
299
|
-
abi: RollupAbi,
|
|
300
|
-
client: walletClient,
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
return await rollup.read.getSequencerRewards([this.coinbase.toString()]);
|
|
305
|
+
return await this.rollupContract.getSequencerRewards(this.coinbase);
|
|
304
306
|
};
|
|
305
307
|
|
|
306
308
|
this.getProverFee = async (blockNumber: number) => {
|
|
307
|
-
const
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
});
|
|
309
|
+
const block = await this.aztecNode.getBlock(blockNumber);
|
|
310
|
+
|
|
311
|
+
// @todo @lherskind As we deal with #13601
|
|
312
|
+
// Right now the value is from `FeeLib.sol`
|
|
313
|
+
const L1_GAS_PER_EPOCH_VERIFIED = 1000000n;
|
|
313
314
|
|
|
314
|
-
|
|
315
|
+
// We round up
|
|
316
|
+
const mulDiv = (a: bigint, b: bigint, c: bigint) => (a * b) / c + ((a * b) % c > 0n ? 1n : 0n);
|
|
317
|
+
|
|
318
|
+
const { baseFee } = await this.rollupContract.getL1FeesAt(block!.header.globalVariables.timestamp);
|
|
319
|
+
const proverCost =
|
|
320
|
+
mulDiv(
|
|
321
|
+
mulDiv(L1_GAS_PER_EPOCH_VERIFIED, baseFee, await this.rollupContract.getEpochDuration()),
|
|
322
|
+
1n,
|
|
323
|
+
await this.rollupContract.getManaTarget(),
|
|
324
|
+
) + (await this.rollupContract.getProvingCostPerMana());
|
|
325
|
+
|
|
326
|
+
const price = await this.rollupContract.getFeeAssetPerEth();
|
|
315
327
|
|
|
316
|
-
const block = await this.pxe.getBlock(blockNumber);
|
|
317
328
|
const mana = block!.header.totalManaUsed.toBigInt();
|
|
318
|
-
return mana *
|
|
329
|
+
return mulDiv(mana * proverCost, price, 10n ** 9n);
|
|
319
330
|
};
|
|
320
331
|
},
|
|
321
332
|
);
|
|
322
333
|
}
|
|
323
334
|
|
|
335
|
+
public async applySponsoredFPCSetupSnapshot() {
|
|
336
|
+
await this.snapshotManager.snapshot(
|
|
337
|
+
'sponsored_fpc_setup',
|
|
338
|
+
async context => {
|
|
339
|
+
const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice;
|
|
340
|
+
expect((await context.wallet.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true);
|
|
341
|
+
|
|
342
|
+
const sponsoredFPC = await setupSponsoredFPC(this.wallet);
|
|
343
|
+
this.logger.info(`SponsoredFPC at ${sponsoredFPC.address}`);
|
|
344
|
+
|
|
345
|
+
return {
|
|
346
|
+
sponsoredFPCAddress: sponsoredFPC.address,
|
|
347
|
+
};
|
|
348
|
+
},
|
|
349
|
+
async data => {
|
|
350
|
+
this.sponsoredFPC = await SponsoredFPCContract.at(data.sponsoredFPCAddress, this.wallet);
|
|
351
|
+
},
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
|
|
324
355
|
public async applyFundAliceWithBananas() {
|
|
325
356
|
await this.snapshotManager.snapshot(
|
|
326
357
|
'fund_alice',
|
|
327
358
|
async () => {
|
|
328
359
|
await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress);
|
|
329
|
-
await this.bananaCoin.methods
|
|
360
|
+
await this.bananaCoin.methods
|
|
361
|
+
.mint_to_public(this.aliceAddress, this.ALICE_INITIAL_BANANAS)
|
|
362
|
+
.send({ from: this.aliceAddress })
|
|
363
|
+
.wait();
|
|
330
364
|
},
|
|
331
365
|
() => Promise.resolve(),
|
|
332
366
|
);
|
|
@@ -341,37 +375,4 @@ export class FeesTest {
|
|
|
341
375
|
() => Promise.resolve(),
|
|
342
376
|
);
|
|
343
377
|
}
|
|
344
|
-
|
|
345
|
-
public async applySetupSubscription() {
|
|
346
|
-
await this.snapshotManager.snapshot(
|
|
347
|
-
'setup_subscription',
|
|
348
|
-
async () => {
|
|
349
|
-
const counterContract = await CounterContract.deploy(this.bobWallet, 0, this.bobAddress).send().deployed();
|
|
350
|
-
|
|
351
|
-
// Deploy subscription contract, that allows subscriptions for SUBSCRIPTION_AMOUNT of bananas
|
|
352
|
-
const subscriptionContract = await AppSubscriptionContract.deploy(
|
|
353
|
-
this.bobWallet,
|
|
354
|
-
counterContract.address,
|
|
355
|
-
this.bobAddress,
|
|
356
|
-
this.bananaCoin.address,
|
|
357
|
-
this.SUBSCRIPTION_AMOUNT,
|
|
358
|
-
this.APP_SPONSORED_TX_GAS_LIMIT,
|
|
359
|
-
)
|
|
360
|
-
.send()
|
|
361
|
-
.deployed();
|
|
362
|
-
|
|
363
|
-
// Mint some Fee Juice to the subscription contract
|
|
364
|
-
// Could also use bridgeFromL1ToL2 from the harness, but this is more direct
|
|
365
|
-
await this.mintAndBridgeFeeJuice(subscriptionContract.address, FEE_FUNDING_FOR_TESTER_ACCOUNT);
|
|
366
|
-
return {
|
|
367
|
-
counterContractAddress: counterContract.address,
|
|
368
|
-
subscriptionContractAddress: subscriptionContract.address,
|
|
369
|
-
};
|
|
370
|
-
},
|
|
371
|
-
async ({ counterContractAddress, subscriptionContractAddress }) => {
|
|
372
|
-
this.counterContract = await CounterContract.at(counterContractAddress, this.bobWallet);
|
|
373
|
-
this.subscriptionContract = await AppSubscriptionContract.at(subscriptionContractAddress, this.bobWallet);
|
|
374
|
-
},
|
|
375
|
-
);
|
|
376
|
-
}
|
|
377
378
|
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import type { L2Block } from '@aztec/aztec.js/block';
|
|
3
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
4
|
+
import { BatchedBlob, Blob, getPrefixedEthBlobCommitments } from '@aztec/blob-lib';
|
|
5
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
6
|
+
|
|
7
|
+
import { writeFile } from 'fs/promises';
|
|
8
|
+
|
|
9
|
+
const AZTEC_GENERATE_TEST_DATA = !!process.env.AZTEC_GENERATE_TEST_DATA;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Creates a json object that can be used to test the solidity contract.
|
|
13
|
+
* The json object must be put into
|
|
14
|
+
*/
|
|
15
|
+
export async function writeJson(
|
|
16
|
+
fileName: string,
|
|
17
|
+
block: L2Block,
|
|
18
|
+
l1ToL2Content: Fr[],
|
|
19
|
+
blobs: Blob[],
|
|
20
|
+
batchedBlob: BatchedBlob,
|
|
21
|
+
recipientAddress: AztecAddress,
|
|
22
|
+
deployerAddress: `0x${string}`,
|
|
23
|
+
): Promise<void> {
|
|
24
|
+
if (!AZTEC_GENERATE_TEST_DATA) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
// Path relative to the package.json in the end-to-end folder
|
|
28
|
+
const path = `../../l1-contracts/test/fixtures/${fileName}.json`;
|
|
29
|
+
|
|
30
|
+
const asHex = (value: Fr | Buffer | EthAddress | AztecAddress, size = 64) => {
|
|
31
|
+
const buffer = Buffer.isBuffer(value) ? value : value.toBuffer();
|
|
32
|
+
return `0x${buffer.toString('hex').padStart(size, '0')}`;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const jsonObject = {
|
|
36
|
+
populate: {
|
|
37
|
+
l1ToL2Content: l1ToL2Content.map(value => asHex(value)),
|
|
38
|
+
recipient: asHex(recipientAddress.toField()),
|
|
39
|
+
sender: deployerAddress,
|
|
40
|
+
},
|
|
41
|
+
messages: {
|
|
42
|
+
l2ToL1Messages: block.body.txEffects.flatMap(txEffect => txEffect.l2ToL1Msgs).map(value => asHex(value)),
|
|
43
|
+
},
|
|
44
|
+
block: {
|
|
45
|
+
// The json formatting in forge is a bit brittle, so we convert Fr to a number in the few values below.
|
|
46
|
+
// This should not be a problem for testing as long as the values are not larger than u32.
|
|
47
|
+
archive: asHex(block.archive.root),
|
|
48
|
+
blobCommitments: getPrefixedEthBlobCommitments(blobs),
|
|
49
|
+
batchedBlobInputs: batchedBlob.getEthBlobEvaluationInputs(),
|
|
50
|
+
blockNumber: block.number,
|
|
51
|
+
body: `0x${block.body.toBuffer().toString('hex')}`,
|
|
52
|
+
header: {
|
|
53
|
+
lastArchiveRoot: asHex(block.header.lastArchive.root),
|
|
54
|
+
contentCommitment: {
|
|
55
|
+
blobsHash: asHex(block.header.contentCommitment.blobsHash),
|
|
56
|
+
inHash: asHex(block.header.contentCommitment.inHash),
|
|
57
|
+
outHash: asHex(block.header.contentCommitment.outHash),
|
|
58
|
+
},
|
|
59
|
+
slotNumber: Number(block.header.globalVariables.slotNumber),
|
|
60
|
+
timestamp: Number(block.header.globalVariables.timestamp),
|
|
61
|
+
coinbase: asHex(block.header.globalVariables.coinbase, 40),
|
|
62
|
+
feeRecipient: asHex(block.header.globalVariables.feeRecipient),
|
|
63
|
+
gasFees: {
|
|
64
|
+
feePerDaGas: Number(block.header.globalVariables.gasFees.feePerDaGas),
|
|
65
|
+
feePerL2Gas: Number(block.header.globalVariables.gasFees.feePerL2Gas),
|
|
66
|
+
},
|
|
67
|
+
totalManaUsed: block.header.totalManaUsed.toNumber(),
|
|
68
|
+
},
|
|
69
|
+
headerHash: asHex(block.getCheckpointHeader().hash()),
|
|
70
|
+
numTxs: block.body.txEffects.length,
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const output = JSON.stringify(jsonObject, null, 2);
|
|
75
|
+
await writeFile(path, output, 'utf8');
|
|
76
|
+
}
|