@aztec/end-to-end 0.0.0-test.1 → 0.0.1-commit.1142ef1
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 +79 -0
- package/dest/bench/utils.d.ts +14 -40
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +37 -70
- 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 +29 -28
- 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 +79 -82
- 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 +107 -110
- 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 +55 -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 -113
- 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 +147 -138
- 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 +92 -54
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +452 -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/grafana_client.d.ts +41 -0
- package/dest/quality_of_service/grafana_client.d.ts.map +1 -0
- package/dest/quality_of_service/{alert_checker.js → grafana_client.js} +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 +106 -52
- 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 +2 -2
- package/dest/shared/index.d.ts.map +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 +3 -25
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +170 -120
- 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 +27 -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 +151 -313
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +598 -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 +35 -81
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +80 -77
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +103 -122
- 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 +150 -142
- 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 +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 +252 -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 +112 -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 +189 -160
- package/src/fixtures/token_utils.ts +32 -15
- package/src/fixtures/utils.ts +556 -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 → grafana_client.ts} +2 -2
- package/src/shared/cross_chain_test_harness.ts +113 -87
- package/src/shared/gas_portal_test_harness.ts +59 -50
- package/src/shared/index.ts +1 -1
- package/src/shared/jest_setup.ts +1 -1
- package/src/shared/submit-transactions.ts +12 -8
- package/src/shared/uniswap_l1_l2.ts +194 -211
- 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 +258 -93
- package/src/spartan/tx_metrics.ts +130 -0
- package/src/spartan/utils.ts +722 -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/quality_of_service/alert_checker.d.ts +0 -41
- package/dest/quality_of_service/alert_checker.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/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,39 @@ 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(rewardConfig.rewardDistributor);
|
|
148
|
+
|
|
149
|
+
const toDistribute = balance > blockReward ? blockReward : balance;
|
|
150
|
+
const sequencerBlockRewards = (toDistribute * BigInt(rewardConfig.sequencerBps)) / 10000n;
|
|
151
|
+
const proverBlockRewards = toDistribute - sequencerBlockRewards;
|
|
152
|
+
|
|
153
|
+
return { sequencerBlockRewards, proverBlockRewards };
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
async mintAndBridgeFeeJuice(minter: AztecAddress, recipient: AztecAddress) {
|
|
157
|
+
const claim = await this.feeJuiceBridgeTestHarness.prepareTokensOnL1(recipient);
|
|
143
158
|
const { claimSecret: secret, messageLeafIndex: index } = claim;
|
|
144
|
-
await this.feeJuiceContract.methods
|
|
159
|
+
await this.feeJuiceContract.methods
|
|
160
|
+
.claim(recipient, claim.claimAmount, secret, index)
|
|
161
|
+
.send({ from: minter })
|
|
162
|
+
.wait();
|
|
145
163
|
}
|
|
146
164
|
|
|
147
165
|
/** Alice mints bananaCoin tokens privately to the target address and redeems them. */
|
|
148
166
|
async mintPrivateBananas(amount: bigint, address: AztecAddress) {
|
|
149
|
-
const balanceBefore = await this.bananaCoin.methods
|
|
167
|
+
const balanceBefore = await this.bananaCoin.methods
|
|
168
|
+
.balance_of_private(address)
|
|
169
|
+
.simulate({ from: this.aliceAddress });
|
|
150
170
|
|
|
151
|
-
await mintTokensToPrivate(this.bananaCoin, this.
|
|
171
|
+
await mintTokensToPrivate(this.bananaCoin, this.aliceAddress, address, amount);
|
|
152
172
|
|
|
153
|
-
const balanceAfter = await this.bananaCoin.methods
|
|
173
|
+
const balanceAfter = await this.bananaCoin.methods
|
|
174
|
+
.balance_of_private(address)
|
|
175
|
+
.simulate({ from: this.aliceAddress });
|
|
154
176
|
expect(balanceAfter).toEqual(balanceBefore + amount);
|
|
155
177
|
}
|
|
156
178
|
|
|
@@ -165,66 +187,52 @@ export class FeesTest {
|
|
|
165
187
|
await this.snapshotManager.snapshot(
|
|
166
188
|
'initial_accounts',
|
|
167
189
|
deployAccounts(this.numberOfAccounts, this.logger),
|
|
168
|
-
async ({ deployedAccounts }, {
|
|
169
|
-
this.
|
|
190
|
+
async ({ deployedAccounts }, { wallet, aztecNode, cheatCodes }) => {
|
|
191
|
+
this.wallet = wallet;
|
|
170
192
|
this.aztecNode = aztecNode;
|
|
171
|
-
this.
|
|
172
|
-
this.
|
|
173
|
-
this.
|
|
174
|
-
this.
|
|
175
|
-
|
|
176
|
-
[this.aliceAddress, this.bobAddress, this.sequencerAddress] = this.
|
|
193
|
+
this.aztecNodeAdmin = aztecNode;
|
|
194
|
+
this.gasSettings = GasSettings.default({ maxFeesPerGas: (await this.aztecNode.getCurrentMinFees()).mul(2) });
|
|
195
|
+
this.cheatCodes = cheatCodes;
|
|
196
|
+
this.accounts = deployedAccounts.map(a => a.address);
|
|
197
|
+
this.accounts.forEach((a, i) => this.logger.verbose(`Account ${i} address: ${a}`));
|
|
198
|
+
[this.aliceAddress, this.bobAddress, this.sequencerAddress] = this.accounts.slice(0, 3);
|
|
177
199
|
|
|
178
200
|
// We set Alice as the FPC admin to avoid the need for deployment of another account.
|
|
179
201
|
this.fpcAdmin = this.aliceAddress;
|
|
180
202
|
|
|
181
203
|
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
|
-
});
|
|
204
|
+
this.feeJuiceContract = FeeJuiceContract.at(canonicalFeeJuice.address, this.wallet);
|
|
198
205
|
},
|
|
199
206
|
);
|
|
200
207
|
}
|
|
201
208
|
|
|
202
209
|
async applyPublicDeployAccountsSnapshot() {
|
|
203
210
|
await this.snapshotManager.snapshot('public_deploy_accounts', () =>
|
|
204
|
-
|
|
211
|
+
ensureAccountContractsPublished(this.wallet, this.accounts),
|
|
205
212
|
);
|
|
206
213
|
}
|
|
207
214
|
|
|
208
215
|
async applySetupFeeJuiceSnapshot() {
|
|
209
216
|
await this.snapshotManager.snapshot(
|
|
210
217
|
'setup_fee_juice',
|
|
211
|
-
async
|
|
212
|
-
await setupCanonicalFeeJuice(context.pxe);
|
|
213
|
-
},
|
|
218
|
+
async () => {},
|
|
214
219
|
async (_data, context) => {
|
|
215
220
|
this.context = context;
|
|
216
221
|
|
|
217
|
-
this.feeJuiceContract =
|
|
222
|
+
this.feeJuiceContract = FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, this.wallet);
|
|
218
223
|
|
|
219
|
-
this.getGasBalanceFn = getBalancesFn(
|
|
224
|
+
this.getGasBalanceFn = getBalancesFn(
|
|
225
|
+
'⛽',
|
|
226
|
+
this.feeJuiceContract.methods.balance_of_public,
|
|
227
|
+
this.aliceAddress,
|
|
228
|
+
this.logger,
|
|
229
|
+
);
|
|
220
230
|
|
|
221
|
-
const { publicClient, walletClient } = createL1Clients(context.aztecNodeConfig.l1RpcUrls, MNEMONIC);
|
|
222
231
|
this.feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({
|
|
223
232
|
aztecNode: context.aztecNode,
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
wallet: this.aliceWallet,
|
|
233
|
+
aztecNodeAdmin: context.aztecNode,
|
|
234
|
+
l1Client: context.deployL1ContractsValues.l1Client,
|
|
235
|
+
wallet: this.wallet,
|
|
228
236
|
logger: this.logger,
|
|
229
237
|
});
|
|
230
238
|
},
|
|
@@ -235,14 +243,28 @@ export class FeesTest {
|
|
|
235
243
|
await this.snapshotManager.snapshot(
|
|
236
244
|
'deploy_banana_token',
|
|
237
245
|
async () => {
|
|
238
|
-
const bananaCoin = await BananaCoin.deploy(this.
|
|
239
|
-
.send()
|
|
246
|
+
const bananaCoin = await BananaCoin.deploy(this.wallet, this.aliceAddress, 'BC', 'BC', 18n)
|
|
247
|
+
.send({ from: this.aliceAddress })
|
|
240
248
|
.deployed();
|
|
241
249
|
this.logger.info(`BananaCoin deployed at ${bananaCoin.address}`);
|
|
242
250
|
return { bananaCoinAddress: bananaCoin.address };
|
|
243
251
|
},
|
|
244
|
-
|
|
245
|
-
this.bananaCoin =
|
|
252
|
+
({ bananaCoinAddress }) => {
|
|
253
|
+
this.bananaCoin = BananaCoin.at(bananaCoinAddress, this.wallet);
|
|
254
|
+
const logger = this.logger;
|
|
255
|
+
this.getBananaPublicBalanceFn = getBalancesFn(
|
|
256
|
+
'🍌.public',
|
|
257
|
+
this.bananaCoin.methods.balance_of_public,
|
|
258
|
+
this.aliceAddress,
|
|
259
|
+
logger,
|
|
260
|
+
);
|
|
261
|
+
this.getBananaPrivateBalanceFn = getBalancesFn(
|
|
262
|
+
'🍌.private',
|
|
263
|
+
this.bananaCoin.methods.balance_of_private,
|
|
264
|
+
this.aliceAddress,
|
|
265
|
+
logger,
|
|
266
|
+
);
|
|
267
|
+
return Promise.resolve();
|
|
246
268
|
},
|
|
247
269
|
);
|
|
248
270
|
}
|
|
@@ -252,16 +274,16 @@ export class FeesTest {
|
|
|
252
274
|
'fpc_setup',
|
|
253
275
|
async context => {
|
|
254
276
|
const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice;
|
|
255
|
-
expect((await context.
|
|
277
|
+
expect((await context.wallet.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true);
|
|
256
278
|
|
|
257
279
|
const bananaCoin = this.bananaCoin;
|
|
258
|
-
const bananaFPC = await FPCContract.deploy(this.
|
|
259
|
-
.send()
|
|
280
|
+
const bananaFPC = await FPCContract.deploy(this.wallet, bananaCoin.address, this.fpcAdmin)
|
|
281
|
+
.send({ from: this.aliceAddress })
|
|
260
282
|
.deployed();
|
|
261
283
|
|
|
262
284
|
this.logger.info(`BananaPay deployed at ${bananaFPC.address}`);
|
|
263
285
|
|
|
264
|
-
await this.feeJuiceBridgeTestHarness.bridgeFromL1ToL2(
|
|
286
|
+
await this.feeJuiceBridgeTestHarness.bridgeFromL1ToL2(bananaFPC.address, this.aliceAddress);
|
|
265
287
|
|
|
266
288
|
return {
|
|
267
289
|
bananaFPCAddress: bananaFPC.address,
|
|
@@ -270,54 +292,70 @@ export class FeesTest {
|
|
|
270
292
|
rollupAddress: context.deployL1ContractsValues.l1ContractAddresses.rollupAddress,
|
|
271
293
|
};
|
|
272
294
|
},
|
|
273
|
-
|
|
274
|
-
const bananaFPC =
|
|
295
|
+
(data, context) => {
|
|
296
|
+
const bananaFPC = FPCContract.at(data.bananaFPCAddress, this.wallet);
|
|
275
297
|
this.bananaFPC = bananaFPC;
|
|
276
298
|
|
|
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
299
|
this.getCoinbaseBalance = async () => {
|
|
286
|
-
const
|
|
300
|
+
const l1Client = createExtendedL1Client(context.aztecNodeConfig.l1RpcUrls, MNEMONIC);
|
|
287
301
|
const gasL1 = getContract({
|
|
288
302
|
address: data.l1FeeJuiceAddress.toString(),
|
|
289
303
|
abi: TestERC20Abi,
|
|
290
|
-
client:
|
|
304
|
+
client: l1Client,
|
|
291
305
|
});
|
|
292
306
|
return await gasL1.read.balanceOf([this.coinbase.toString()]);
|
|
293
307
|
};
|
|
294
308
|
|
|
295
309
|
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()]);
|
|
310
|
+
return await this.rollupContract.getSequencerRewards(this.coinbase);
|
|
304
311
|
};
|
|
305
312
|
|
|
306
|
-
this.getProverFee = async (blockNumber:
|
|
307
|
-
const
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
+
this.getProverFee = async (blockNumber: BlockNumber) => {
|
|
314
|
+
const block = await this.aztecNode.getBlock(blockNumber);
|
|
315
|
+
|
|
316
|
+
// @todo @lherskind As we deal with #13601
|
|
317
|
+
// Right now the value is from `FeeLib.sol`
|
|
318
|
+
const L1_GAS_PER_EPOCH_VERIFIED = 1000000n;
|
|
319
|
+
|
|
320
|
+
// We round up
|
|
321
|
+
const mulDiv = (a: bigint, b: bigint, c: bigint) => (a * b) / c + ((a * b) % c > 0n ? 1n : 0n);
|
|
313
322
|
|
|
314
|
-
const
|
|
323
|
+
const { baseFee } = await this.rollupContract.getL1FeesAt(block!.header.globalVariables.timestamp);
|
|
324
|
+
const proverCost =
|
|
325
|
+
mulDiv(
|
|
326
|
+
mulDiv(L1_GAS_PER_EPOCH_VERIFIED, baseFee, BigInt(await this.rollupContract.getEpochDuration())),
|
|
327
|
+
1n,
|
|
328
|
+
await this.rollupContract.getManaTarget(),
|
|
329
|
+
) + (await this.rollupContract.getProvingCostPerMana());
|
|
330
|
+
|
|
331
|
+
const price = await this.rollupContract.getFeeAssetPerEth();
|
|
315
332
|
|
|
316
|
-
const block = await this.pxe.getBlock(blockNumber);
|
|
317
333
|
const mana = block!.header.totalManaUsed.toBigInt();
|
|
318
|
-
return mana *
|
|
334
|
+
return mulDiv(mana * proverCost, price, 10n ** 9n);
|
|
335
|
+
};
|
|
336
|
+
return Promise.resolve();
|
|
337
|
+
},
|
|
338
|
+
);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
public async applySponsoredFPCSetupSnapshot() {
|
|
342
|
+
await this.snapshotManager.snapshot(
|
|
343
|
+
'sponsored_fpc_setup',
|
|
344
|
+
async context => {
|
|
345
|
+
const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice;
|
|
346
|
+
expect((await context.wallet.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true);
|
|
347
|
+
|
|
348
|
+
const sponsoredFPC = await setupSponsoredFPC(this.wallet);
|
|
349
|
+
this.logger.info(`SponsoredFPC at ${sponsoredFPC.address}`);
|
|
350
|
+
|
|
351
|
+
return {
|
|
352
|
+
sponsoredFPCAddress: sponsoredFPC.address,
|
|
319
353
|
};
|
|
320
354
|
},
|
|
355
|
+
data => {
|
|
356
|
+
this.sponsoredFPC = SponsoredFPCContract.at(data.sponsoredFPCAddress, this.wallet);
|
|
357
|
+
return Promise.resolve();
|
|
358
|
+
},
|
|
321
359
|
);
|
|
322
360
|
}
|
|
323
361
|
|
|
@@ -326,7 +364,10 @@ export class FeesTest {
|
|
|
326
364
|
'fund_alice',
|
|
327
365
|
async () => {
|
|
328
366
|
await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress);
|
|
329
|
-
await this.bananaCoin.methods
|
|
367
|
+
await this.bananaCoin.methods
|
|
368
|
+
.mint_to_public(this.aliceAddress, this.ALICE_INITIAL_BANANAS)
|
|
369
|
+
.send({ from: this.aliceAddress })
|
|
370
|
+
.wait();
|
|
330
371
|
},
|
|
331
372
|
() => Promise.resolve(),
|
|
332
373
|
);
|
|
@@ -341,37 +382,4 @@ export class FeesTest {
|
|
|
341
382
|
() => Promise.resolve(),
|
|
342
383
|
);
|
|
343
384
|
}
|
|
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
385
|
}
|
|
@@ -0,0 +1,74 @@
|
|
|
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
|
+
blobsHash: asHex(block.header.blobsHash),
|
|
56
|
+
inHash: asHex(block.header.inHash),
|
|
57
|
+
slotNumber: Number(block.header.globalVariables.slotNumber),
|
|
58
|
+
timestamp: Number(block.header.globalVariables.timestamp),
|
|
59
|
+
coinbase: asHex(block.header.globalVariables.coinbase, 40),
|
|
60
|
+
feeRecipient: asHex(block.header.globalVariables.feeRecipient),
|
|
61
|
+
gasFees: {
|
|
62
|
+
feePerDaGas: Number(block.header.globalVariables.gasFees.feePerDaGas),
|
|
63
|
+
feePerL2Gas: Number(block.header.globalVariables.gasFees.feePerL2Gas),
|
|
64
|
+
},
|
|
65
|
+
totalManaUsed: block.header.totalManaUsed.toNumber(),
|
|
66
|
+
},
|
|
67
|
+
headerHash: asHex(block.getCheckpointHeader().hash()),
|
|
68
|
+
numTxs: block.body.txEffects.length,
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const output = JSON.stringify(jsonObject, null, 2);
|
|
73
|
+
await writeFile(path, output, 'utf8');
|
|
74
|
+
}
|