@aztec/end-to-end 0.0.0-test.1 → 0.0.1-commit.21caa21
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 +334 -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 +19 -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 +50 -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 +59 -18
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +226 -44
- 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 +21 -10
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +103 -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 +139 -0
- package/dest/e2e_p2p/p2p_network.d.ts +275 -23
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +184 -131
- 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 +63 -0
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
- package/dest/{e2e_prover → fixtures}/e2e_prover_test.js +104 -105
- package/dest/fixtures/fixtures.d.ts +6 -7
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +4 -3
- 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 +2 -14
- 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 +9 -6
- 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/logging.d.ts +1 -1
- package/dest/fixtures/setup_l1_contracts.d.ts +476 -5
- 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 +15 -14
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +81 -21
- package/dest/fixtures/snapshot_manager.d.ts +17 -9
- 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 +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 +524 -40
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +464 -369
- 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 +1 -1
- 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 +39 -34
- 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 +14 -12
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +146 -116
- 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 +15 -16
- 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 +201 -58
- package/dest/spartan/utils.d.ts +116 -313
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +434 -130
- package/package.json +65 -58
- package/src/bench/client_flows/benchmark.ts +341 -0
- package/src/bench/client_flows/client_flows_benchmark.ts +447 -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 +65 -106
- package/src/e2e_deploy_contract/deploy_test.ts +24 -39
- package/src/e2e_epochs/epochs_test.ts +276 -55
- package/src/e2e_fees/bridging_race.notest.ts +80 -0
- package/src/e2e_fees/fees_test.ts +142 -138
- 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 +182 -0
- package/src/e2e_p2p/p2p_network.ts +279 -169
- package/src/e2e_p2p/shared.ts +247 -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 +107 -152
- 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 +126 -38
- package/src/fixtures/snapshot_manager.ts +187 -139
- package/src/fixtures/token_utils.ts +32 -15
- package/src/fixtures/utils.ts +580 -434
- package/src/fixtures/web3signer.ts +63 -0
- 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 +108 -79
- 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 +181 -184
- package/src/simulators/lending_simulator.ts +14 -15
- package/src/simulators/token_simulator.ts +21 -13
- package/src/spartan/DEVELOP.md +121 -0
- package/src/spartan/setup_test_wallets.ts +251 -93
- package/src/spartan/utils.ts +490 -130
- 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/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.getCheckpointReward();
|
|
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 =
|
|
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 = 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 =
|
|
218
|
+
this.feeJuiceContract = 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,28 @@ 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
|
-
|
|
245
|
-
this.bananaCoin =
|
|
248
|
+
({ bananaCoinAddress }) => {
|
|
249
|
+
this.bananaCoin = 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
|
+
);
|
|
263
|
+
return Promise.resolve();
|
|
246
264
|
},
|
|
247
265
|
);
|
|
248
266
|
}
|
|
@@ -252,16 +270,16 @@ export class FeesTest {
|
|
|
252
270
|
'fpc_setup',
|
|
253
271
|
async context => {
|
|
254
272
|
const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice;
|
|
255
|
-
expect((await context.
|
|
273
|
+
expect((await context.wallet.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true);
|
|
256
274
|
|
|
257
275
|
const bananaCoin = this.bananaCoin;
|
|
258
|
-
const bananaFPC = await FPCContract.deploy(this.
|
|
259
|
-
.send()
|
|
276
|
+
const bananaFPC = await FPCContract.deploy(this.wallet, bananaCoin.address, this.fpcAdmin)
|
|
277
|
+
.send({ from: this.aliceAddress })
|
|
260
278
|
.deployed();
|
|
261
279
|
|
|
262
280
|
this.logger.info(`BananaPay deployed at ${bananaFPC.address}`);
|
|
263
281
|
|
|
264
|
-
await this.feeJuiceBridgeTestHarness.bridgeFromL1ToL2(
|
|
282
|
+
await this.feeJuiceBridgeTestHarness.bridgeFromL1ToL2(bananaFPC.address, this.aliceAddress);
|
|
265
283
|
|
|
266
284
|
return {
|
|
267
285
|
bananaFPCAddress: bananaFPC.address,
|
|
@@ -270,53 +288,69 @@ export class FeesTest {
|
|
|
270
288
|
rollupAddress: context.deployL1ContractsValues.l1ContractAddresses.rollupAddress,
|
|
271
289
|
};
|
|
272
290
|
},
|
|
273
|
-
|
|
274
|
-
const bananaFPC =
|
|
291
|
+
(data, context) => {
|
|
292
|
+
const bananaFPC = FPCContract.at(data.bananaFPCAddress, this.wallet);
|
|
275
293
|
this.bananaFPC = bananaFPC;
|
|
276
294
|
|
|
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
295
|
this.getCoinbaseBalance = async () => {
|
|
286
|
-
const
|
|
296
|
+
const l1Client = createExtendedL1Client(context.aztecNodeConfig.l1RpcUrls, MNEMONIC);
|
|
287
297
|
const gasL1 = getContract({
|
|
288
298
|
address: data.l1FeeJuiceAddress.toString(),
|
|
289
299
|
abi: TestERC20Abi,
|
|
290
|
-
client:
|
|
300
|
+
client: l1Client,
|
|
291
301
|
});
|
|
292
302
|
return await gasL1.read.balanceOf([this.coinbase.toString()]);
|
|
293
303
|
};
|
|
294
304
|
|
|
295
305
|
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()]);
|
|
306
|
+
return await this.rollupContract.getSequencerRewards(this.coinbase);
|
|
304
307
|
};
|
|
305
308
|
|
|
306
309
|
this.getProverFee = async (blockNumber: number) => {
|
|
307
|
-
const
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
});
|
|
310
|
+
const block = await this.aztecNode.getBlock(blockNumber);
|
|
311
|
+
|
|
312
|
+
// @todo @lherskind As we deal with #13601
|
|
313
|
+
// Right now the value is from `FeeLib.sol`
|
|
314
|
+
const L1_GAS_PER_EPOCH_VERIFIED = 1000000n;
|
|
313
315
|
|
|
314
|
-
|
|
316
|
+
// We round up
|
|
317
|
+
const mulDiv = (a: bigint, b: bigint, c: bigint) => (a * b) / c + ((a * b) % c > 0n ? 1n : 0n);
|
|
318
|
+
|
|
319
|
+
const { baseFee } = await this.rollupContract.getL1FeesAt(block!.header.globalVariables.timestamp);
|
|
320
|
+
const proverCost =
|
|
321
|
+
mulDiv(
|
|
322
|
+
mulDiv(L1_GAS_PER_EPOCH_VERIFIED, baseFee, await this.rollupContract.getEpochDuration()),
|
|
323
|
+
1n,
|
|
324
|
+
await this.rollupContract.getManaTarget(),
|
|
325
|
+
) + (await this.rollupContract.getProvingCostPerMana());
|
|
326
|
+
|
|
327
|
+
const price = await this.rollupContract.getFeeAssetPerEth();
|
|
315
328
|
|
|
316
|
-
const block = await this.pxe.getBlock(blockNumber);
|
|
317
329
|
const mana = block!.header.totalManaUsed.toBigInt();
|
|
318
|
-
return mana *
|
|
330
|
+
return mulDiv(mana * proverCost, price, 10n ** 9n);
|
|
319
331
|
};
|
|
332
|
+
return Promise.resolve();
|
|
333
|
+
},
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
public async applySponsoredFPCSetupSnapshot() {
|
|
338
|
+
await this.snapshotManager.snapshot(
|
|
339
|
+
'sponsored_fpc_setup',
|
|
340
|
+
async context => {
|
|
341
|
+
const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice;
|
|
342
|
+
expect((await context.wallet.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true);
|
|
343
|
+
|
|
344
|
+
const sponsoredFPC = await setupSponsoredFPC(this.wallet);
|
|
345
|
+
this.logger.info(`SponsoredFPC at ${sponsoredFPC.address}`);
|
|
346
|
+
|
|
347
|
+
return {
|
|
348
|
+
sponsoredFPCAddress: sponsoredFPC.address,
|
|
349
|
+
};
|
|
350
|
+
},
|
|
351
|
+
data => {
|
|
352
|
+
this.sponsoredFPC = SponsoredFPCContract.at(data.sponsoredFPCAddress, this.wallet);
|
|
353
|
+
return Promise.resolve();
|
|
320
354
|
},
|
|
321
355
|
);
|
|
322
356
|
}
|
|
@@ -326,7 +360,10 @@ export class FeesTest {
|
|
|
326
360
|
'fund_alice',
|
|
327
361
|
async () => {
|
|
328
362
|
await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress);
|
|
329
|
-
await this.bananaCoin.methods
|
|
363
|
+
await this.bananaCoin.methods
|
|
364
|
+
.mint_to_public(this.aliceAddress, this.ALICE_INITIAL_BANANAS)
|
|
365
|
+
.send({ from: this.aliceAddress })
|
|
366
|
+
.wait();
|
|
330
367
|
},
|
|
331
368
|
() => Promise.resolve(),
|
|
332
369
|
);
|
|
@@ -341,37 +378,4 @@ export class FeesTest {
|
|
|
341
378
|
() => Promise.resolve(),
|
|
342
379
|
);
|
|
343
380
|
}
|
|
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
381
|
}
|
|
@@ -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
|
+
}
|