@aztec/end-to-end 0.0.1-commit.1142ef1 → 0.0.1-commit.179ed20
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 +3 -2
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/benchmark.js +21 -1
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +12 -13
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +117 -132
- package/dest/bench/utils.d.ts +6 -5
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +9 -7
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +6 -7
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +96 -112
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +6 -7
- 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 +65 -62
- package/dest/e2e_deploy_contract/deploy_test.d.ts +4 -3
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +18 -13
- package/dest/e2e_epochs/epochs_test.d.ts +7 -1
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +30 -8
- package/dest/e2e_fees/bridging_race.notest.js +3 -5
- package/dest/e2e_fees/fees_test.d.ts +13 -13
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +122 -140
- package/dest/e2e_l1_publisher/write_json.d.ts +4 -3
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
- package/dest/e2e_l1_publisher/write_json.js +14 -13
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +6 -9
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +31 -39
- package/dest/e2e_p2p/inactivity_slash_test.d.ts +3 -3
- package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -1
- package/dest/e2e_p2p/inactivity_slash_test.js +3 -3
- package/dest/e2e_p2p/p2p_network.d.ts +7 -6
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +110 -103
- package/dest/e2e_p2p/reqresp/utils.d.ts +22 -0
- package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -0
- package/dest/e2e_p2p/reqresp/utils.js +153 -0
- package/dest/e2e_p2p/shared.d.ts +6 -6
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +9 -16
- package/dest/e2e_token_contract/token_contract_test.d.ts +16 -9
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +89 -91
- package/dest/fixtures/e2e_prover_test.d.ts +8 -14
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +85 -93
- package/dest/fixtures/setup.d.ts +218 -0
- package/dest/fixtures/setup.d.ts.map +1 -0
- package/dest/fixtures/setup.js +695 -0
- package/dest/fixtures/setup_p2p_test.d.ts +4 -5
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +24 -19
- package/dest/fixtures/token_utils.d.ts +1 -1
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +7 -4
- package/dest/fixtures/utils.d.ts +5 -191
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +4 -615
- package/dest/quality_of_service/prometheus_client.d.ts +38 -0
- package/dest/quality_of_service/prometheus_client.d.ts.map +1 -0
- package/dest/quality_of_service/prometheus_client.js +67 -0
- package/dest/shared/cross_chain_test_harness.d.ts +14 -4
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +11 -11
- package/dest/shared/gas_portal_test_harness.d.ts +11 -1
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +1 -1
- package/dest/shared/submit-transactions.d.ts +3 -3
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/submit-transactions.js +9 -11
- package/dest/shared/uniswap_l1_l2.d.ts +1 -1
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +12 -12
- package/dest/simulators/lending_simulator.d.ts +5 -1
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +2 -2
- package/dest/spartan/setup_test_wallets.d.ts +1 -1
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +61 -34
- package/dest/spartan/tx_metrics.d.ts +51 -2
- package/dest/spartan/tx_metrics.d.ts.map +1 -1
- package/dest/spartan/tx_metrics.js +333 -6
- package/dest/spartan/utils/bot.d.ts +27 -0
- package/dest/spartan/utils/bot.d.ts.map +1 -0
- package/dest/spartan/utils/bot.js +141 -0
- package/dest/spartan/utils/chaos.d.ts +79 -0
- package/dest/spartan/utils/chaos.d.ts.map +1 -0
- package/dest/spartan/utils/chaos.js +142 -0
- package/dest/spartan/utils/clients.d.ts +39 -0
- package/dest/spartan/utils/clients.d.ts.map +1 -0
- package/dest/spartan/utils/clients.js +90 -0
- package/dest/spartan/utils/config.d.ts +36 -0
- package/dest/spartan/utils/config.d.ts.map +1 -0
- package/dest/spartan/utils/config.js +20 -0
- package/dest/spartan/utils/health.d.ts +63 -0
- package/dest/spartan/utils/health.d.ts.map +1 -0
- package/dest/spartan/utils/health.js +202 -0
- package/dest/spartan/utils/helm.d.ts +15 -0
- package/dest/spartan/utils/helm.d.ts.map +1 -0
- package/dest/spartan/utils/helm.js +47 -0
- package/dest/spartan/utils/index.d.ts +9 -0
- package/dest/spartan/utils/index.d.ts.map +1 -0
- package/dest/spartan/utils/index.js +18 -0
- package/dest/spartan/utils/k8s.d.ts +126 -0
- package/dest/spartan/utils/k8s.d.ts.map +1 -0
- package/dest/spartan/utils/k8s.js +375 -0
- package/dest/spartan/utils/nodes.d.ts +41 -0
- package/dest/spartan/utils/nodes.d.ts.map +1 -0
- package/dest/spartan/utils/nodes.js +461 -0
- package/dest/spartan/utils/scripts.d.ts +16 -0
- package/dest/spartan/utils/scripts.d.ts.map +1 -0
- package/dest/spartan/utils/scripts.js +66 -0
- package/dest/spartan/utils.d.ts +2 -253
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +1 -892
- package/package.json +40 -39
- package/src/bench/client_flows/benchmark.ts +24 -2
- package/src/bench/client_flows/client_flows_benchmark.ts +137 -203
- package/src/bench/utils.ts +9 -7
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +104 -142
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +99 -106
- package/src/e2e_deploy_contract/deploy_test.ts +21 -14
- package/src/e2e_epochs/epochs_test.ts +59 -33
- package/src/e2e_fees/bridging_race.notest.ts +3 -9
- package/src/e2e_fees/fees_test.ts +171 -217
- package/src/e2e_l1_publisher/write_json.ts +16 -13
- package/src/e2e_nested_contract/nested_contract_test.ts +33 -56
- package/src/e2e_p2p/inactivity_slash_test.ts +5 -5
- package/src/e2e_p2p/p2p_network.ts +171 -167
- package/src/e2e_p2p/reqresp/utils.ts +207 -0
- package/src/e2e_p2p/shared.ts +20 -22
- package/src/e2e_token_contract/token_contract_test.ts +103 -118
- package/src/fixtures/e2e_prover_test.ts +99 -133
- package/src/fixtures/setup.ts +1017 -0
- package/src/fixtures/setup_p2p_test.ts +15 -20
- package/src/fixtures/token_utils.ts +6 -5
- package/src/fixtures/utils.ts +27 -901
- package/src/quality_of_service/prometheus_client.ts +113 -0
- package/src/shared/cross_chain_test_harness.ts +13 -27
- package/src/shared/gas_portal_test_harness.ts +1 -1
- package/src/shared/submit-transactions.ts +9 -15
- package/src/shared/uniswap_l1_l2.ts +12 -19
- package/src/simulators/lending_simulator.ts +2 -2
- package/src/spartan/setup_test_wallets.ts +72 -24
- package/src/spartan/tx_metrics.ts +255 -9
- package/src/spartan/utils/bot.ts +185 -0
- package/src/spartan/utils/chaos.ts +253 -0
- package/src/spartan/utils/clients.ts +100 -0
- package/src/spartan/utils/config.ts +26 -0
- package/src/spartan/utils/health.ts +255 -0
- package/src/spartan/utils/helm.ts +84 -0
- package/src/spartan/utils/index.ts +64 -0
- package/src/spartan/utils/k8s.ts +527 -0
- package/src/spartan/utils/nodes.ts +538 -0
- package/src/spartan/utils/scripts.ts +63 -0
- package/src/spartan/utils.ts +1 -1158
- package/dest/fixtures/snapshot_manager.d.ts +0 -93
- package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
- package/dest/fixtures/snapshot_manager.js +0 -488
- package/src/fixtures/snapshot_manager.ts +0 -646
|
@@ -14,13 +14,15 @@ import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
|
|
|
14
14
|
import { BlockNumber, CheckpointNumber, EpochNumber } from '@aztec/foundation/branded-types';
|
|
15
15
|
import { SecretValue } from '@aztec/foundation/config';
|
|
16
16
|
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
17
|
-
import {
|
|
17
|
+
import { withLoggerBindings } from '@aztec/foundation/log/server';
|
|
18
18
|
import { retryUntil } from '@aztec/foundation/retry';
|
|
19
19
|
import { sleep } from '@aztec/foundation/sleep';
|
|
20
20
|
import { SpamContract } from '@aztec/noir-test-contracts.js/Spam';
|
|
21
|
+
import { TestContract } from '@aztec/noir-test-contracts.js/Test';
|
|
21
22
|
import { getMockPubSubP2PServiceFactory } from '@aztec/p2p/test-helpers';
|
|
22
23
|
import { ProverNode, type ProverNodeConfig, ProverNodePublisher } from '@aztec/prover-node';
|
|
23
24
|
import type { TestProverNode } from '@aztec/prover-node/test';
|
|
25
|
+
import type { PXEConfig } from '@aztec/pxe/config';
|
|
24
26
|
import {
|
|
25
27
|
type SequencerClient,
|
|
26
28
|
type SequencerEvents,
|
|
@@ -49,7 +51,11 @@ export const WORLD_STATE_BLOCK_CHECK_INTERVAL = 50;
|
|
|
49
51
|
export const ARCHIVER_POLL_INTERVAL = 50;
|
|
50
52
|
export const DEFAULT_L1_BLOCK_TIME = process.env.CI ? 12 : 8;
|
|
51
53
|
|
|
52
|
-
export type EpochsTestOpts = Partial<SetupOptions> & {
|
|
54
|
+
export type EpochsTestOpts = Partial<SetupOptions> & {
|
|
55
|
+
numberOfAccounts?: number;
|
|
56
|
+
pxeOpts?: Partial<PXEConfig>;
|
|
57
|
+
aztecSlotDurationInL1Slots?: number;
|
|
58
|
+
};
|
|
53
59
|
|
|
54
60
|
export type TrackedSequencerEvent = {
|
|
55
61
|
[K in keyof SequencerEvents]: Parameters<SequencerEvents[K]>[0] & {
|
|
@@ -94,7 +100,7 @@ export class EpochsTestContext {
|
|
|
94
100
|
? parseInt(process.env.L1_BLOCK_TIME)
|
|
95
101
|
: DEFAULT_L1_BLOCK_TIME;
|
|
96
102
|
const ethereumSlotDuration = opts.ethereumSlotDuration ?? envEthereumSlotDuration;
|
|
97
|
-
const aztecSlotDuration = opts.aztecSlotDuration ??
|
|
103
|
+
const aztecSlotDuration = opts.aztecSlotDuration ?? (opts.aztecSlotDurationInL1Slots ?? 2) * ethereumSlotDuration;
|
|
98
104
|
const aztecEpochDuration = opts.aztecEpochDuration ?? 6;
|
|
99
105
|
const aztecProofSubmissionEpochs = opts.aztecProofSubmissionEpochs ?? 1;
|
|
100
106
|
const l1PublishingTime = opts.l1PublishingTime ?? 1;
|
|
@@ -121,30 +127,36 @@ export class EpochsTestContext {
|
|
|
121
127
|
|
|
122
128
|
// Set up system without any account nor protocol contracts
|
|
123
129
|
// and with faster block times and shorter epochs.
|
|
124
|
-
const context = await setup(
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
130
|
+
const context = await setup(
|
|
131
|
+
opts.numberOfAccounts ?? 0,
|
|
132
|
+
{
|
|
133
|
+
automineL1Setup: true,
|
|
134
|
+
checkIntervalMs: 50,
|
|
135
|
+
archiverPollingIntervalMS: ARCHIVER_POLL_INTERVAL,
|
|
136
|
+
worldStateBlockCheckIntervalMS: WORLD_STATE_BLOCK_CHECK_INTERVAL,
|
|
137
|
+
aztecEpochDuration,
|
|
138
|
+
aztecSlotDuration,
|
|
139
|
+
ethereumSlotDuration,
|
|
140
|
+
aztecProofSubmissionEpochs,
|
|
141
|
+
aztecTargetCommitteeSize: opts.initialValidators?.length ?? 0,
|
|
142
|
+
minTxsPerBlock: 0,
|
|
143
|
+
realProofs: false,
|
|
144
|
+
startProverNode: true,
|
|
145
|
+
proverTestDelayMs: opts.proverTestDelayMs ?? 0,
|
|
146
|
+
// We use numeric incremental prover ids for simplicity, but we can switch to
|
|
147
|
+
// using the prover's eth address if the proverId is used for something in the rollup contract
|
|
148
|
+
// Use numeric EthAddress for deterministic prover id
|
|
149
|
+
proverId: EthAddress.fromNumber(1),
|
|
150
|
+
worldStateBlockHistory: WORLD_STATE_BLOCK_HISTORY,
|
|
151
|
+
exitDelaySeconds: DefaultL1ContractsConfig.exitDelaySeconds,
|
|
152
|
+
slasherFlavor: 'none',
|
|
153
|
+
l1PublishingTime,
|
|
154
|
+
...opts,
|
|
155
|
+
},
|
|
156
|
+
// Use checkpointed chain tip for PXE by default to avoid issues with blocks being dropped due to pruned anchor blocks.
|
|
157
|
+
// Can be overridden via opts.pxeOpts.
|
|
158
|
+
{ syncChainTip: 'checkpointed', ...opts.pxeOpts },
|
|
159
|
+
);
|
|
148
160
|
|
|
149
161
|
this.context = context;
|
|
150
162
|
this.proverNodes = context.proverNode ? [context.proverNode] : [];
|
|
@@ -199,19 +211,19 @@ export class EpochsTestContext {
|
|
|
199
211
|
public async createProverNode(opts: { dontStart?: boolean } & Partial<ProverNodeConfig> = {}) {
|
|
200
212
|
this.logger.warn('Creating and syncing a simulated prover node...');
|
|
201
213
|
const proverNodePrivateKey = this.getNextPrivateKey();
|
|
202
|
-
const
|
|
203
|
-
const proverNode = await
|
|
214
|
+
const proverIndex = this.proverNodes.length + 1;
|
|
215
|
+
const proverNode = await withLoggerBindings({ actor: `prover-${proverIndex}` }, () =>
|
|
204
216
|
createAndSyncProverNode(
|
|
205
217
|
proverNodePrivateKey,
|
|
206
218
|
{ ...this.context.config },
|
|
207
219
|
{
|
|
208
220
|
dataDirectory: join(this.context.config.dataDirectory!, randomBytes(8).toString('hex')),
|
|
209
|
-
proverId: EthAddress.fromNumber(
|
|
221
|
+
proverId: EthAddress.fromNumber(proverIndex),
|
|
210
222
|
dontStart: opts.dontStart,
|
|
211
223
|
...opts,
|
|
212
224
|
},
|
|
213
225
|
this.context.aztecNode,
|
|
214
|
-
|
|
226
|
+
this.context.prefilledPublicData ?? [],
|
|
215
227
|
{ dateProvider: this.context.dateProvider },
|
|
216
228
|
),
|
|
217
229
|
);
|
|
@@ -235,12 +247,13 @@ export class EpochsTestContext {
|
|
|
235
247
|
private async createNode(
|
|
236
248
|
opts: Partial<AztecNodeConfig> & { txDelayerMaxInclusionTimeIntoSlot?: number; dontStartSequencer?: boolean } = {},
|
|
237
249
|
) {
|
|
238
|
-
const
|
|
250
|
+
const nodeIndex = this.nodes.length + 1;
|
|
251
|
+
const actorPrefix = opts.disableValidator ? 'node' : 'validator';
|
|
239
252
|
const { mockGossipSubNetwork } = this.context;
|
|
240
253
|
const resolvedConfig = { ...this.context.config, ...opts };
|
|
241
254
|
const p2pEnabled = resolvedConfig.p2pEnabled || mockGossipSubNetwork !== undefined;
|
|
242
255
|
const p2pIp = resolvedConfig.p2pIp ?? (p2pEnabled ? '127.0.0.1' : undefined);
|
|
243
|
-
const node = await
|
|
256
|
+
const node = await withLoggerBindings({ actor: `${actorPrefix}-${nodeIndex}` }, () =>
|
|
244
257
|
AztecNodeService.createAndSync(
|
|
245
258
|
{
|
|
246
259
|
...resolvedConfig,
|
|
@@ -370,6 +383,19 @@ export class EpochsTestContext {
|
|
|
370
383
|
return SpamContract.at(instance.address, wallet);
|
|
371
384
|
}
|
|
372
385
|
|
|
386
|
+
/** Registers the TestContract on the given wallet. */
|
|
387
|
+
public async registerTestContract(wallet: Wallet, salt = Fr.ZERO) {
|
|
388
|
+
const instance = await getContractInstanceFromInstantiationParams(TestContract.artifact, {
|
|
389
|
+
constructorArgs: [],
|
|
390
|
+
constructorArtifact: undefined,
|
|
391
|
+
salt,
|
|
392
|
+
publicKeys: undefined,
|
|
393
|
+
deployer: undefined,
|
|
394
|
+
});
|
|
395
|
+
await wallet.registerContract(instance, TestContract.artifact);
|
|
396
|
+
return TestContract.at(instance.address, wallet);
|
|
397
|
+
}
|
|
398
|
+
|
|
373
399
|
/** Creates an L1 client using a fresh account with funds from anvil, with a tx delayer already set up. */
|
|
374
400
|
public async createL1Client() {
|
|
375
401
|
const { client, delayer } = withDelayer(
|
|
@@ -26,11 +26,8 @@ describe('e2e_fees bridging_race', () => {
|
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
beforeAll(async () => {
|
|
29
|
-
await t.
|
|
30
|
-
|
|
31
|
-
await t.applySetupFeeJuiceSnapshot();
|
|
32
|
-
|
|
33
|
-
({ wallet, logger } = await t.setup());
|
|
29
|
+
await t.setup();
|
|
30
|
+
({ wallet, logger } = t);
|
|
34
31
|
});
|
|
35
32
|
|
|
36
33
|
afterAll(async () => {
|
|
@@ -70,10 +67,7 @@ describe('e2e_fees bridging_race', () => {
|
|
|
70
67
|
// Yes, we need to REFACTOR it at some point
|
|
71
68
|
const claim = await t.feeJuiceBridgeTestHarness.prepareTokensOnL1(bobsAddress);
|
|
72
69
|
const { claimSecret: secret, messageLeafIndex: index } = claim;
|
|
73
|
-
await t.feeJuiceContract.methods
|
|
74
|
-
.claim(bobsAddress, claim.claimAmount, secret, index)
|
|
75
|
-
.send({ from: bobsAddress })
|
|
76
|
-
.wait();
|
|
70
|
+
await t.feeJuiceContract.methods.claim(bobsAddress, claim.claimAmount, secret, index).send({ from: bobsAddress });
|
|
77
71
|
const [balance] = await t.getGasBalanceFn(bobsAddress);
|
|
78
72
|
expect(balance).toEqual(claim.claimAmount);
|
|
79
73
|
});
|
|
@@ -26,25 +26,19 @@ import { getContract } from 'viem';
|
|
|
26
26
|
|
|
27
27
|
import { MNEMONIC } from '../fixtures/fixtures.js';
|
|
28
28
|
import {
|
|
29
|
-
type
|
|
30
|
-
type
|
|
31
|
-
createSnapshotManager,
|
|
29
|
+
type EndToEndContext,
|
|
30
|
+
type SetupOptions,
|
|
32
31
|
deployAccounts,
|
|
33
|
-
|
|
32
|
+
publicDeployAccounts,
|
|
33
|
+
setup,
|
|
34
|
+
teardown,
|
|
35
|
+
} from '../fixtures/setup.js';
|
|
34
36
|
import { mintTokensToPrivate } from '../fixtures/token_utils.js';
|
|
35
|
-
import {
|
|
36
|
-
type BalancesFn,
|
|
37
|
-
type SetupOptions,
|
|
38
|
-
ensureAccountContractsPublished,
|
|
39
|
-
getBalancesFn,
|
|
40
|
-
setupSponsoredFPC,
|
|
41
|
-
} from '../fixtures/utils.js';
|
|
37
|
+
import { type BalancesFn, getBalancesFn, setupSponsoredFPC } from '../fixtures/utils.js';
|
|
42
38
|
import { FeeJuicePortalTestingHarnessFactory, type GasBridgingTestHarness } from '../shared/gas_portal_test_harness.js';
|
|
43
39
|
|
|
44
|
-
const { E2E_DATA_PATH: dataPath } = process.env;
|
|
45
|
-
|
|
46
40
|
/**
|
|
47
|
-
* Test fixture for testing fees. Provides the following
|
|
41
|
+
* Test fixture for testing fees. Provides the following setup steps:
|
|
48
42
|
* InitialAccounts: Initializes 3 Schnorr account contracts.
|
|
49
43
|
* PublicDeployAccounts: Deploys the accounts publicly.
|
|
50
44
|
* DeployFeeJuice: Deploys the Fee Juice contract.
|
|
@@ -54,8 +48,8 @@ const { E2E_DATA_PATH: dataPath } = process.env;
|
|
|
54
48
|
* SetupSubscription: Deploys a counter contract and a subscription contract, and mints Fee Juice to the subscription contract.
|
|
55
49
|
*/
|
|
56
50
|
export class FeesTest {
|
|
57
|
-
private snapshotManager: ISnapshotManager;
|
|
58
51
|
private accounts: AztecAddress[] = [];
|
|
52
|
+
public context!: EndToEndContext;
|
|
59
53
|
|
|
60
54
|
public logger: Logger;
|
|
61
55
|
public aztecNode!: AztecNode;
|
|
@@ -82,7 +76,6 @@ export class FeesTest {
|
|
|
82
76
|
public subscriptionContract!: AppSubscriptionContract;
|
|
83
77
|
public feeJuiceBridgeTestHarness!: GasBridgingTestHarness;
|
|
84
78
|
|
|
85
|
-
public context!: SubsystemsContext;
|
|
86
79
|
public chainMonitor!: ChainMonitor;
|
|
87
80
|
|
|
88
81
|
public getCoinbaseBalance!: () => Promise<bigint>;
|
|
@@ -99,7 +92,7 @@ export class FeesTest {
|
|
|
99
92
|
constructor(
|
|
100
93
|
testName: string,
|
|
101
94
|
private numberOfAccounts = 3,
|
|
102
|
-
setupOptions: Partial<SetupOptions & DeployAztecL1ContractsArgs> = {},
|
|
95
|
+
private setupOptions: Partial<SetupOptions & DeployAztecL1ContractsArgs> = {},
|
|
103
96
|
) {
|
|
104
97
|
if (!numberOfAccounts) {
|
|
105
98
|
throw new Error('There must be at least 1 initial account.');
|
|
@@ -107,30 +100,33 @@ export class FeesTest {
|
|
|
107
100
|
setupOptions.coinbase ??= EthAddress.random();
|
|
108
101
|
this.coinbase = setupOptions.coinbase!;
|
|
109
102
|
this.logger = createLogger(`e2e:e2e_fees:${testName}`);
|
|
110
|
-
this.snapshotManager = createSnapshotManager(
|
|
111
|
-
`e2e_fees/${testName}-${numberOfAccounts}`,
|
|
112
|
-
dataPath,
|
|
113
|
-
{ startProverNode: true, ...setupOptions },
|
|
114
|
-
{ ...setupOptions },
|
|
115
|
-
);
|
|
116
103
|
}
|
|
117
104
|
|
|
118
105
|
async setup() {
|
|
119
|
-
|
|
106
|
+
this.logger.verbose('Setting up fresh context...');
|
|
107
|
+
this.context = await setup(0, {
|
|
108
|
+
startProverNode: true,
|
|
109
|
+
...this.setupOptions,
|
|
110
|
+
fundSponsoredFPC: true,
|
|
111
|
+
skipAccountDeployment: true,
|
|
112
|
+
l1ContractsArgs: { ...this.setupOptions },
|
|
113
|
+
});
|
|
120
114
|
|
|
121
|
-
this.rollupContract = RollupContract.getFromConfig(context.
|
|
122
|
-
this.chainMonitor = new ChainMonitor(this.rollupContract, context.dateProvider
|
|
115
|
+
this.rollupContract = RollupContract.getFromConfig(this.context.config);
|
|
116
|
+
this.chainMonitor = new ChainMonitor(this.rollupContract, this.context.dateProvider!, this.logger, 200).start();
|
|
117
|
+
|
|
118
|
+
await this.applyBaseSetup();
|
|
123
119
|
|
|
124
120
|
return this;
|
|
125
121
|
}
|
|
126
122
|
|
|
127
123
|
async teardown() {
|
|
128
124
|
await this.chainMonitor.stop();
|
|
129
|
-
await this.
|
|
125
|
+
await teardown(this.context);
|
|
130
126
|
}
|
|
131
127
|
|
|
132
128
|
setIsMarkingAsProven(b: boolean) {
|
|
133
|
-
this.context.watcher
|
|
129
|
+
this.context.watcher!.setIsMarkingAsProven(b);
|
|
134
130
|
}
|
|
135
131
|
|
|
136
132
|
async catchUpProvenChain() {
|
|
@@ -156,10 +152,7 @@ export class FeesTest {
|
|
|
156
152
|
async mintAndBridgeFeeJuice(minter: AztecAddress, recipient: AztecAddress) {
|
|
157
153
|
const claim = await this.feeJuiceBridgeTestHarness.prepareTokensOnL1(recipient);
|
|
158
154
|
const { claimSecret: secret, messageLeafIndex: index } = claim;
|
|
159
|
-
await this.feeJuiceContract.methods
|
|
160
|
-
.claim(recipient, claim.claimAmount, secret, index)
|
|
161
|
-
.send({ from: minter })
|
|
162
|
-
.wait();
|
|
155
|
+
await this.feeJuiceContract.methods.claim(recipient, claim.claimAmount, secret, index).send({ from: minter });
|
|
163
156
|
}
|
|
164
157
|
|
|
165
158
|
/** Alice mints bananaCoin tokens privately to the target address and redeems them. */
|
|
@@ -176,210 +169,171 @@ export class FeesTest {
|
|
|
176
169
|
expect(balanceAfter).toEqual(balanceBefore + amount);
|
|
177
170
|
}
|
|
178
171
|
|
|
179
|
-
public async
|
|
180
|
-
await this.
|
|
181
|
-
await this.
|
|
182
|
-
await this.
|
|
183
|
-
await this.
|
|
172
|
+
public async applyBaseSetup() {
|
|
173
|
+
await this.applyInitialAccounts();
|
|
174
|
+
await this.applyPublicDeployAccounts();
|
|
175
|
+
await this.applySetupFeeJuice();
|
|
176
|
+
await this.applyDeployBananaToken();
|
|
184
177
|
}
|
|
185
178
|
|
|
186
|
-
async
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
179
|
+
async applyInitialAccounts() {
|
|
180
|
+
this.logger.info('Applying initial accounts setup');
|
|
181
|
+
|
|
182
|
+
const { deployedAccounts } = await deployAccounts(
|
|
183
|
+
this.numberOfAccounts,
|
|
184
|
+
this.logger,
|
|
185
|
+
)({
|
|
186
|
+
wallet: this.context.wallet,
|
|
187
|
+
initialFundedAccounts: this.context.initialFundedAccounts,
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
this.wallet = this.context.wallet;
|
|
191
|
+
this.aztecNode = this.context.aztecNodeService!;
|
|
192
|
+
this.aztecNodeAdmin = this.context.aztecNodeService!;
|
|
193
|
+
this.gasSettings = GasSettings.default({ maxFeesPerGas: (await this.aztecNode.getCurrentMinFees()).mul(2) });
|
|
194
|
+
this.cheatCodes = this.context.cheatCodes;
|
|
195
|
+
this.accounts = deployedAccounts.map(a => a.address);
|
|
196
|
+
this.accounts.forEach((a, i) => this.logger.verbose(`Account ${i} address: ${a}`));
|
|
197
|
+
[this.aliceAddress, this.bobAddress, this.sequencerAddress] = this.accounts.slice(0, 3);
|
|
198
|
+
|
|
199
|
+
// We set Alice as the FPC admin to avoid the need for deployment of another account.
|
|
200
|
+
this.fpcAdmin = this.aliceAddress;
|
|
201
|
+
|
|
202
|
+
const canonicalFeeJuice = await getCanonicalFeeJuice();
|
|
203
|
+
this.feeJuiceContract = FeeJuiceContract.at(canonicalFeeJuice.address, this.wallet);
|
|
207
204
|
}
|
|
208
205
|
|
|
209
|
-
async
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
);
|
|
206
|
+
async applyPublicDeployAccounts() {
|
|
207
|
+
this.logger.info('Applying public deploy accounts setup');
|
|
208
|
+
await publicDeployAccounts(this.wallet, this.accounts);
|
|
213
209
|
}
|
|
214
210
|
|
|
215
|
-
async
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
'⛽',
|
|
226
|
-
this.feeJuiceContract.methods.balance_of_public,
|
|
227
|
-
this.aliceAddress,
|
|
228
|
-
this.logger,
|
|
229
|
-
);
|
|
230
|
-
|
|
231
|
-
this.feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({
|
|
232
|
-
aztecNode: context.aztecNode,
|
|
233
|
-
aztecNodeAdmin: context.aztecNode,
|
|
234
|
-
l1Client: context.deployL1ContractsValues.l1Client,
|
|
235
|
-
wallet: this.wallet,
|
|
236
|
-
logger: this.logger,
|
|
237
|
-
});
|
|
238
|
-
},
|
|
211
|
+
async applySetupFeeJuice() {
|
|
212
|
+
this.logger.info('Applying fee juice setup');
|
|
213
|
+
|
|
214
|
+
this.feeJuiceContract = FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, this.wallet);
|
|
215
|
+
|
|
216
|
+
this.getGasBalanceFn = getBalancesFn(
|
|
217
|
+
'⛽',
|
|
218
|
+
this.feeJuiceContract.methods.balance_of_public,
|
|
219
|
+
this.aliceAddress,
|
|
220
|
+
this.logger,
|
|
239
221
|
);
|
|
222
|
+
|
|
223
|
+
this.feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({
|
|
224
|
+
aztecNode: this.context.aztecNodeService!,
|
|
225
|
+
aztecNodeAdmin: this.context.aztecNodeService!,
|
|
226
|
+
l1Client: this.context.deployL1ContractsValues.l1Client,
|
|
227
|
+
wallet: this.wallet,
|
|
228
|
+
logger: this.logger,
|
|
229
|
+
});
|
|
240
230
|
}
|
|
241
231
|
|
|
242
|
-
async
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
'🍌.private',
|
|
263
|
-
this.bananaCoin.methods.balance_of_private,
|
|
264
|
-
this.aliceAddress,
|
|
265
|
-
logger,
|
|
266
|
-
);
|
|
267
|
-
return Promise.resolve();
|
|
268
|
-
},
|
|
232
|
+
async applyDeployBananaToken() {
|
|
233
|
+
this.logger.info('Applying deploy banana token setup');
|
|
234
|
+
|
|
235
|
+
const bananaCoin = await BananaCoin.deploy(this.wallet, this.aliceAddress, 'BC', 'BC', 18n).send({
|
|
236
|
+
from: this.aliceAddress,
|
|
237
|
+
});
|
|
238
|
+
this.logger.info(`BananaCoin deployed at ${bananaCoin.address}`);
|
|
239
|
+
|
|
240
|
+
this.bananaCoin = bananaCoin;
|
|
241
|
+
this.getBananaPublicBalanceFn = getBalancesFn(
|
|
242
|
+
'🍌.public',
|
|
243
|
+
this.bananaCoin.methods.balance_of_public,
|
|
244
|
+
this.aliceAddress,
|
|
245
|
+
this.logger,
|
|
246
|
+
);
|
|
247
|
+
this.getBananaPrivateBalanceFn = getBalancesFn(
|
|
248
|
+
'🍌.private',
|
|
249
|
+
this.bananaCoin.methods.balance_of_private,
|
|
250
|
+
this.aliceAddress,
|
|
251
|
+
this.logger,
|
|
269
252
|
);
|
|
270
253
|
}
|
|
271
254
|
|
|
272
|
-
public async
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
await this.rollupContract.getManaTarget(),
|
|
329
|
-
) + (await this.rollupContract.getProvingCostPerMana());
|
|
330
|
-
|
|
331
|
-
const price = await this.rollupContract.getFeeAssetPerEth();
|
|
332
|
-
|
|
333
|
-
const mana = block!.header.totalManaUsed.toBigInt();
|
|
334
|
-
return mulDiv(mana * proverCost, price, 10n ** 9n);
|
|
335
|
-
};
|
|
336
|
-
return Promise.resolve();
|
|
337
|
-
},
|
|
338
|
-
);
|
|
255
|
+
public async applyFPCSetup() {
|
|
256
|
+
this.logger.info('Applying FPC setup');
|
|
257
|
+
|
|
258
|
+
const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice;
|
|
259
|
+
expect((await this.wallet.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true);
|
|
260
|
+
|
|
261
|
+
const bananaCoin = this.bananaCoin;
|
|
262
|
+
const bananaFPC = await FPCContract.deploy(this.wallet, bananaCoin.address, this.fpcAdmin).send({
|
|
263
|
+
from: this.aliceAddress,
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
this.logger.info(`BananaPay deployed at ${bananaFPC.address}`);
|
|
267
|
+
|
|
268
|
+
await this.feeJuiceBridgeTestHarness.bridgeFromL1ToL2(bananaFPC.address, this.aliceAddress);
|
|
269
|
+
|
|
270
|
+
this.bananaFPC = bananaFPC;
|
|
271
|
+
|
|
272
|
+
const l1FeeJuiceAddress = this.feeJuiceBridgeTestHarness.l1FeeJuiceAddress;
|
|
273
|
+
|
|
274
|
+
this.getCoinbaseBalance = async () => {
|
|
275
|
+
const l1Client = createExtendedL1Client(this.context.config.l1RpcUrls, MNEMONIC);
|
|
276
|
+
const gasL1 = getContract({
|
|
277
|
+
address: l1FeeJuiceAddress.toString(),
|
|
278
|
+
abi: TestERC20Abi,
|
|
279
|
+
client: l1Client,
|
|
280
|
+
});
|
|
281
|
+
return await gasL1.read.balanceOf([this.coinbase.toString()]);
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
this.getCoinbaseSequencerRewards = async () => {
|
|
285
|
+
return await this.rollupContract.getSequencerRewards(this.coinbase);
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
this.getProverFee = async (blockNumber: BlockNumber) => {
|
|
289
|
+
const block = await this.aztecNode.getBlock(blockNumber);
|
|
290
|
+
|
|
291
|
+
// @todo @lherskind As we deal with #13601
|
|
292
|
+
// Right now the value is from `FeeLib.sol`
|
|
293
|
+
const L1_GAS_PER_EPOCH_VERIFIED = 1000000n;
|
|
294
|
+
|
|
295
|
+
// We round up
|
|
296
|
+
const mulDiv = (a: bigint, b: bigint, c: bigint) => (a * b) / c + ((a * b) % c > 0n ? 1n : 0n);
|
|
297
|
+
|
|
298
|
+
const { baseFee } = await this.rollupContract.getL1FeesAt(block!.header.globalVariables.timestamp);
|
|
299
|
+
const proverCost =
|
|
300
|
+
mulDiv(
|
|
301
|
+
mulDiv(L1_GAS_PER_EPOCH_VERIFIED, baseFee, BigInt(await this.rollupContract.getEpochDuration())),
|
|
302
|
+
1n,
|
|
303
|
+
await this.rollupContract.getManaTarget(),
|
|
304
|
+
) + (await this.rollupContract.getProvingCostPerMana());
|
|
305
|
+
|
|
306
|
+
const price = await this.rollupContract.getEthPerFeeAsset();
|
|
307
|
+
|
|
308
|
+
const mana = block!.header.totalManaUsed.toBigInt();
|
|
309
|
+
return mulDiv(mana * proverCost, 10n ** 12n, price);
|
|
310
|
+
};
|
|
339
311
|
}
|
|
340
312
|
|
|
341
|
-
public async
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
return {
|
|
352
|
-
sponsoredFPCAddress: sponsoredFPC.address,
|
|
353
|
-
};
|
|
354
|
-
},
|
|
355
|
-
data => {
|
|
356
|
-
this.sponsoredFPC = SponsoredFPCContract.at(data.sponsoredFPCAddress, this.wallet);
|
|
357
|
-
return Promise.resolve();
|
|
358
|
-
},
|
|
359
|
-
);
|
|
313
|
+
public async applySponsoredFPCSetup() {
|
|
314
|
+
this.logger.info('Applying sponsored FPC setup');
|
|
315
|
+
|
|
316
|
+
const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice;
|
|
317
|
+
expect((await this.wallet.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true);
|
|
318
|
+
|
|
319
|
+
const sponsoredFPCInstance = await setupSponsoredFPC(this.wallet);
|
|
320
|
+
this.logger.info(`SponsoredFPC at ${sponsoredFPCInstance.address}`);
|
|
321
|
+
|
|
322
|
+
this.sponsoredFPC = SponsoredFPCContract.at(sponsoredFPCInstance.address, this.wallet);
|
|
360
323
|
}
|
|
361
324
|
|
|
362
325
|
public async applyFundAliceWithBananas() {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
.send({ from: this.aliceAddress })
|
|
370
|
-
.wait();
|
|
371
|
-
},
|
|
372
|
-
() => Promise.resolve(),
|
|
373
|
-
);
|
|
326
|
+
this.logger.info('Applying fund Alice with bananas setup');
|
|
327
|
+
|
|
328
|
+
await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress);
|
|
329
|
+
await this.bananaCoin.methods
|
|
330
|
+
.mint_to_public(this.aliceAddress, this.ALICE_INITIAL_BANANAS)
|
|
331
|
+
.send({ from: this.aliceAddress });
|
|
374
332
|
}
|
|
375
333
|
|
|
376
334
|
public async applyFundAliceWithPrivateBananas() {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress);
|
|
381
|
-
},
|
|
382
|
-
() => Promise.resolve(),
|
|
383
|
-
);
|
|
335
|
+
this.logger.info('Applying fund Alice with private bananas setup');
|
|
336
|
+
|
|
337
|
+
await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress);
|
|
384
338
|
}
|
|
385
339
|
}
|