Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ import { deriveSigningKey } from '@aztec/stdlib/keys';
import { TestWallet } from '@aztec/test-wallet/server';

import { MNEMONIC } from '../../fixtures/fixtures.js';
import { type SubsystemsContext, deployAccounts, setupFromFresh, teardown } from '../../fixtures/snapshot_manager.js';
import { type EndToEndContext, type SetupOptions, deployAccounts, setup, teardown } from '../../fixtures/setup.js';
import { mintTokensToPrivate } from '../../fixtures/token_utils.js';
import { type SetupOptions, setupSponsoredFPC } from '../../fixtures/utils.js';
import { setupSponsoredFPC } from '../../fixtures/utils.js';
import { CrossChainTestHarness } from '../../shared/cross_chain_test_harness.js';
import {
FeeJuicePortalTestingHarnessFactory,
Expand All @@ -50,7 +50,7 @@ export class ClientFlowsBenchmark {
public logger: Logger;
public aztecNode!: AztecNode;
public cheatCodes!: CheatCodes;
public context!: SubsystemsContext;
public context!: EndToEndContext;
public chainMonitor!: ChainMonitor;
public feeJuiceBridgeTestHarness!: GasBridgingTestHarness;
public adminWallet!: TestWallet;
Expand Down Expand Up @@ -130,13 +130,18 @@ export class ClientFlowsBenchmark {

async setup() {
this.logger.info('Setting up subsystems from fresh');
this.context = await setupFromFresh(this.logger, this.setupOptions, this.setupOptions);
this.context = await setup(0, {
...this.setupOptions,
fundSponsoredFPC: true,
skipAccountDeployment: true,
l1ContractsArgs: this.setupOptions,
});
await this.applyBaseSetup();

await this.context.aztecNode.setConfig({ feeRecipient: this.sequencerAddress, coinbase: this.coinbase });
await this.context.aztecNodeService!.setConfig({ feeRecipient: this.sequencerAddress, coinbase: this.coinbase });

const rollupContract = RollupContract.getFromConfig(this.context.aztecNodeConfig);
this.chainMonitor = new ChainMonitor(rollupContract, this.context.dateProvider, this.logger, 200).start();
const rollupContract = RollupContract.getFromConfig(this.context.config);
this.chainMonitor = new ChainMonitor(rollupContract, this.context.dateProvider!, this.logger, 200).start();

return this;
}
Expand Down Expand Up @@ -203,7 +208,7 @@ export class ClientFlowsBenchmark {
const [{ address: adminAddress }, { address: sequencerAddress }] = deployedAccounts;

this.adminWallet = this.context.wallet;
this.aztecNode = this.context.aztecNode;
this.aztecNode = this.context.aztecNodeService!;
this.cheatCodes = this.context.cheatCodes;

this.adminAddress = adminAddress;
Expand Down Expand Up @@ -231,8 +236,8 @@ export class ClientFlowsBenchmark {
this.feeJuiceContract = FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, this.adminWallet);

this.feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({
aztecNode: this.context.aztecNode,
aztecNodeAdmin: this.context.aztecNode,
aztecNode: this.context.aztecNodeService!,
aztecNodeAdmin: this.context.aztecNodeService!,
l1Client: this.context.deployL1ContractsValues.l1Client,
wallet: this.adminWallet,
logger: this.logger,
Expand Down Expand Up @@ -302,7 +307,7 @@ export class ClientFlowsBenchmark {
}

public async createCrossChainTestHarness(owner: AztecAddress) {
const l1Client = createExtendedL1Client(this.context.aztecNodeConfig.l1RpcUrls, MNEMONIC);
const l1Client = createExtendedL1Client(this.context.config.l1RpcUrls, MNEMONIC);

const underlyingERC20Address = await deployL1Contract(l1Client, TestERC20Abi, TestERC20Bytecode, [
'Underlying',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@ import type { TestWallet } from '@aztec/test-wallet/server';

import { jest } from '@jest/globals';

import {
type SubsystemsContext,
deployAccounts,
publicDeployAccounts,
setupFromFresh,
teardown,
} from '../fixtures/snapshot_manager.js';
import { type EndToEndContext, deployAccounts, publicDeployAccounts, setup, teardown } from '../fixtures/setup.js';
import { TokenSimulator } from '../simulators/token_simulator.js';

export class Role {
Expand Down Expand Up @@ -53,7 +47,7 @@ export class BlacklistTokenContractTest {
// This value MUST match the same value that we have in the contract
static CHANGE_ROLES_DELAY = 86400;

context!: SubsystemsContext;
context!: EndToEndContext;
logger: Logger;
wallet!: TestWallet;
asset!: TokenBlacklistContract;
Expand Down Expand Up @@ -98,8 +92,8 @@ export class BlacklistTokenContractTest {
});

this.cheatCodes = this.context.cheatCodes;
this.aztecNode = this.context.aztecNode;
this.sequencer = this.context.sequencer;
this.aztecNode = this.context.aztecNodeService!;
this.sequencer = this.context.sequencer!;
this.wallet = this.context.wallet;
this.adminAddress = deployedAccounts[0].address;
this.otherAddress = deployedAccounts[1].address;
Expand Down Expand Up @@ -137,7 +131,10 @@ export class BlacklistTokenContractTest {

async setup() {
this.logger.info('Setting up fresh context');
this.context = await setupFromFresh(this.logger);
this.context = await setup(0, {
fundSponsoredFPC: true,
skipAccountDeployment: true,
});
await this.applyBaseSetup();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ import type { TestWallet } from '@aztec/test-wallet/server';

import { MNEMONIC } from '../fixtures/fixtures.js';
import {
type SubsystemsContext,
type EndToEndContext,
type SetupOptions,
deployAccounts,
publicDeployAccounts,
setupFromFresh,
setup,
teardown,
} from '../fixtures/snapshot_manager.js';
import type { SetupOptions } from '../fixtures/utils.js';
} from '../fixtures/setup.js';
import { CrossChainTestHarness } from '../shared/cross_chain_test_harness.js';

export class CrossChainMessagingTest {
private requireEpochProven: boolean;
private setupOptions: SetupOptions;
private deployL1ContractsArgs: Partial<DeployAztecL1ContractsArgs>;
logger: Logger;
context!: SubsystemsContext;
context!: EndToEndContext;
aztecNode!: AztecNode;
aztecNodeConfig!: AztecNodeConfig;
aztecNodeAdmin!: AztecNodeAdmin;
Expand Down Expand Up @@ -76,7 +76,12 @@ export class CrossChainMessagingTest {

async setup() {
this.logger.info('Setting up cross chain messaging test');
this.context = await setupFromFresh(this.logger, this.setupOptions, this.deployL1ContractsArgs);
this.context = await setup(0, {
...this.setupOptions,
fundSponsoredFPC: true,
skipAccountDeployment: true,
l1ContractsArgs: this.deployL1ContractsArgs,
});
await this.applyBaseSetup();
}

Expand Down Expand Up @@ -105,16 +110,16 @@ export class CrossChainMessagingTest {

async applyBaseSetup() {
// Set up base context fields
this.aztecNode = this.context.aztecNode;
this.aztecNode = this.context.aztecNodeService!;
this.wallet = this.context.wallet;
this.aztecNodeConfig = this.context.aztecNodeConfig;
this.aztecNodeConfig = this.context.config;
this.cheatCodes = this.context.cheatCodes;
this.deployL1ContractsValues = this.context.deployL1ContractsValues;
this.aztecNodeAdmin = this.context.aztecNode;
this.aztecNodeAdmin = this.context.aztecNodeService!;

if (this.requireEpochProven) {
// Turn off the watcher to prevent it from keep marking blocks as proven.
this.context.watcher.setIsMarkingAsProven(false);
this.context.watcher!.setIsMarkingAsProven(false);
}

// Deploy 3 accounts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ describe('e2e_cross_chain_messaging l1_to_l2', () => {
// Stop proving
const lastProven = await aztecNode.getBlockNumber();
log.warn(`Stopping proof submission at block ${lastProven} to allow drift`);
t.context.watcher.setIsMarkingAsProven(false);
t.context.watcher!.setIsMarkingAsProven(false);

// Mine several blocks to ensure drift
log.warn(`Mining blocks to allow drift`);
Expand Down Expand Up @@ -210,14 +210,14 @@ describe('e2e_cross_chain_messaging l1_to_l2', () => {
// On private, we simulate the tx locally and check that we get a missing message error, then we advance to the next block
await expect(() => consume().simulate({ from: user1Address })).rejects.toThrow(/No L1 to L2 message found/);
await tryAdvanceBlock();
await t.context.watcher.markAsProven();
await t.context.watcher!.markAsProven();
} else {
// On public, we actually send the tx and check that it reverts due to the missing message.
// This advances the block too as a side-effect. Note that we do not rely on a simulation since the cross chain messages
// do not get added at the beginning of the block during node_simulatePublicCalls (maybe they should?).
const { status } = await consume().send({ from: user1Address }).wait({ dontThrowOnRevert: true });
expect(status).toEqual(TxStatus.APP_LOGIC_REVERTED);
await t.context.watcher.markAsProven();
await t.context.watcher!.markAsProven();
}
});

Expand Down
13 changes: 8 additions & 5 deletions yarn-project/end-to-end/src/e2e_deploy_contract/deploy_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import type { StatefulTestContract } from '@aztec/noir-test-contracts.js/Statefu
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
import type { TestWallet } from '@aztec/test-wallet/server';

import { type SubsystemsContext, deployAccounts, setupFromFresh, teardown } from '../fixtures/snapshot_manager.js';
import { type EndToEndContext, deployAccounts, setup, teardown } from '../fixtures/setup.js';

export class DeployTest {
public context!: SubsystemsContext;
public context!: EndToEndContext;
public logger: Logger;
public wallet!: TestWallet;
public defaultAccountAddress!: AztecAddress;
Expand All @@ -26,10 +26,13 @@ export class DeployTest {

async setup() {
this.logger.info('Setting up test environment');
this.context = await setupFromFresh(this.logger);
this.aztecNode = this.context.aztecNode;
this.context = await setup(0, {
fundSponsoredFPC: true,
skipAccountDeployment: true,
});
this.aztecNode = this.context.aztecNodeService!;
this.wallet = this.context.wallet;
this.aztecNodeAdmin = this.context.aztecNode;
this.aztecNodeAdmin = this.context.aztecNodeService!;
await this.applyInitialAccount();
return this;
}
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/end-to-end/src/e2e_epochs/epochs_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export class EpochsTestContext {
...opts,
},
this.context.aztecNode,
undefined,
this.context.prefilledPublicData ?? [],
{ dateProvider: this.context.dateProvider },
),
);
Expand Down
6 changes: 3 additions & 3 deletions yarn-project/end-to-end/src/e2e_fees/failures.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('e2e_fees failures', () => {

// Prove up until the current state by just marking it as proven.
// Then turn off the watcher to prevent it from keep proving
await t.context.watcher.trigger();
await t.context.watcher!.trigger();
await t.cheatCodes.rollup.advanceToNextEpoch();
await t.catchUpProvenChain();
t.setIsMarkingAsProven(false);
Expand Down Expand Up @@ -78,7 +78,7 @@ describe('e2e_fees failures', () => {
await expectMapping(t.getGasBalanceFn, [aliceAddress, bananaFPC.address], [initialAliceGas, initialFPCGas]);

// We wait until the proven chain is caught up so all previous fees are paid out.
await t.context.watcher.trigger();
await t.context.watcher!.trigger();
await t.cheatCodes.rollup.advanceToNextEpoch();
await t.catchUpProvenChain();

Expand All @@ -100,7 +100,7 @@ describe('e2e_fees failures', () => {

// @note There is a potential race condition here if other tests send transactions that get into the same
// epoch and thereby pays out fees at the same time (when proven).
await t.context.watcher.trigger();
await t.context.watcher!.trigger();
await t.cheatCodes.rollup.advanceToNextEpoch();
await t.catchUpProvenChain();

Expand Down
39 changes: 21 additions & 18 deletions yarn-project/end-to-end/src/e2e_fees/fees_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ import { getContract } from 'viem';

import { MNEMONIC } from '../fixtures/fixtures.js';
import {
type SubsystemsContext,
type EndToEndContext,
type SetupOptions,
deployAccounts,
publicDeployAccounts,
setupFromFresh,
setup,
teardown,
} from '../fixtures/snapshot_manager.js';
} from '../fixtures/setup.js';
import { mintTokensToPrivate } from '../fixtures/token_utils.js';
import { type BalancesFn, type SetupOptions, getBalancesFn, setupSponsoredFPC } from '../fixtures/utils.js';
import { type BalancesFn, getBalancesFn, setupSponsoredFPC } from '../fixtures/utils.js';
import { FeeJuicePortalTestingHarnessFactory, type GasBridgingTestHarness } from '../shared/gas_portal_test_harness.js';

/**
Expand All @@ -48,7 +49,7 @@ import { FeeJuicePortalTestingHarnessFactory, type GasBridgingTestHarness } from
*/
export class FeesTest {
private accounts: AztecAddress[] = [];
public context!: SubsystemsContext;
public context!: EndToEndContext;

public logger: Logger;
public aztecNode!: AztecNode;
Expand Down Expand Up @@ -103,14 +104,16 @@ export class FeesTest {

async setup() {
this.logger.verbose('Setting up fresh context...');
this.context = await setupFromFresh(
this.logger,
{ startProverNode: true, ...this.setupOptions },
{ ...this.setupOptions },
);
this.context = await setup(0, {
startProverNode: true,
...this.setupOptions,
fundSponsoredFPC: true,
skipAccountDeployment: true,
l1ContractsArgs: { ...this.setupOptions },
});

this.rollupContract = RollupContract.getFromConfig(this.context.aztecNodeConfig);
this.chainMonitor = new ChainMonitor(this.rollupContract, this.context.dateProvider, this.logger, 200).start();
this.rollupContract = RollupContract.getFromConfig(this.context.config);
this.chainMonitor = new ChainMonitor(this.rollupContract, this.context.dateProvider!, this.logger, 200).start();

await this.applyBaseSetup();

Expand All @@ -123,7 +126,7 @@ export class FeesTest {
}

setIsMarkingAsProven(b: boolean) {
this.context.watcher.setIsMarkingAsProven(b);
this.context.watcher!.setIsMarkingAsProven(b);
}

async catchUpProvenChain() {
Expand Down Expand Up @@ -188,8 +191,8 @@ export class FeesTest {
});

this.wallet = this.context.wallet;
this.aztecNode = this.context.aztecNode;
this.aztecNodeAdmin = this.context.aztecNode;
this.aztecNode = this.context.aztecNodeService!;
this.aztecNodeAdmin = this.context.aztecNodeService!;
this.gasSettings = GasSettings.default({ maxFeesPerGas: (await this.aztecNode.getCurrentMinFees()).mul(2) });
this.cheatCodes = this.context.cheatCodes;
this.accounts = deployedAccounts.map(a => a.address);
Expand Down Expand Up @@ -221,8 +224,8 @@ export class FeesTest {
);

this.feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({
aztecNode: this.context.aztecNode,
aztecNodeAdmin: this.context.aztecNode,
aztecNode: this.context.aztecNodeService!,
aztecNodeAdmin: this.context.aztecNodeService!,
l1Client: this.context.deployL1ContractsValues.l1Client,
wallet: this.wallet,
logger: this.logger,
Expand Down Expand Up @@ -272,7 +275,7 @@ export class FeesTest {
const l1FeeJuiceAddress = this.feeJuiceBridgeTestHarness.l1FeeJuiceAddress;

this.getCoinbaseBalance = async () => {
const l1Client = createExtendedL1Client(this.context.aztecNodeConfig.l1RpcUrls, MNEMONIC);
const l1Client = createExtendedL1Client(this.context.config.l1RpcUrls, MNEMONIC);
const gasL1 = getContract({
address: l1FeeJuiceAddress.toString(),
abi: TestERC20Abi,
Expand Down
Loading
Loading