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