Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: reduce peer check interval for e2e tests #10890

Merged
merged 2 commits into from
Dec 19, 2024
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
44 changes: 22 additions & 22 deletions yarn-project/end-to-end/src/e2e_p2p/p2p_network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,28 @@ export class P2PNetworkTest {
});
}

static async create({
testName,
numberOfNodes,
basePort,
metricsPort,
}: {
testName: string;
numberOfNodes: number;
basePort?: number;
metricsPort?: number;
}) {
const port = basePort || (await getPort());

const telemetry = await getEndToEndTestTelemetryClient(metricsPort);
const bootstrapNode = await createBootstrapNodeFromPrivateKey(BOOTSTRAP_NODE_PRIVATE_KEY, port, telemetry);
const bootstrapNodeEnr = bootstrapNode.getENR().encodeTxt();

const initialValidatorConfig = await createValidatorConfig({} as AztecNodeConfig, bootstrapNodeEnr);

return new P2PNetworkTest(testName, bootstrapNode, port, numberOfNodes, initialValidatorConfig);
}

/**
* Start a loop to sync the mock system time with the L1 block time
*/
Expand Down Expand Up @@ -108,28 +130,6 @@ export class P2PNetworkTest {
dateProvider.setTime(Number(timestamp.timestamp) * 1000);
}

static async create({
testName,
numberOfNodes,
basePort,
metricsPort,
}: {
testName: string;
numberOfNodes: number;
basePort?: number;
metricsPort?: number;
}) {
const port = basePort || (await getPort());

const telemetry = await getEndToEndTestTelemetryClient(metricsPort);
const bootstrapNode = await createBootstrapNodeFromPrivateKey(BOOTSTRAP_NODE_PRIVATE_KEY, port, telemetry);
const bootstrapNodeEnr = bootstrapNode.getENR().encodeTxt();

const initialValidatorConfig = await createValidatorConfig({} as AztecNodeConfig, bootstrapNodeEnr);

return new P2PNetworkTest(testName, bootstrapNode, port, numberOfNodes, initialValidatorConfig);
}

async applyBaseSnapshots() {
await this.snapshotManager.snapshot(
'add-validators',
Expand Down
2 changes: 2 additions & 0 deletions yarn-project/end-to-end/src/fixtures/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export const shouldCollectMetrics = () => {
return undefined;
};

export const TEST_PEER_CHECK_INTERVAL_MS = 1000;

export const MNEMONIC = 'test test test test test test test test test test test junk';
export const privateKey = Buffer.from('ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80', 'hex');
export const privateKey2 = Buffer.from('59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d', 'hex');
Expand Down
2 changes: 2 additions & 0 deletions yarn-project/end-to-end/src/fixtures/setup_p2p_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { type PXEService } from '@aztec/pxe';

import getPort from 'get-port';

import { TEST_PEER_CHECK_INTERVAL_MS } from './fixtures.js';
import { getPrivateKeyFromIndex } from './utils.js';
import { getEndToEndTestTelemetryClient } from './with_telemetry_utils.js';

Expand Down Expand Up @@ -101,6 +102,7 @@ export async function createValidatorConfig(
tcpAnnounceAddress: `127.0.0.1:${port}`,
udpAnnounceAddress: `127.0.0.1:${port}`,
p2pEnabled: true,
peerCheckIntervalMS: TEST_PEER_CHECK_INTERVAL_MS,
blockCheckIntervalMS: 1000,
transactionProtocol: '',
dataDirectory,
Expand Down
3 changes: 2 additions & 1 deletion yarn-project/end-to-end/src/fixtures/snapshot_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import path, { join } from 'path';
import { type Hex, getContract } from 'viem';
import { mnemonicToAccount } from 'viem/accounts';

import { MNEMONIC } from './fixtures.js';
import { MNEMONIC, TEST_PEER_CHECK_INTERVAL_MS } from './fixtures.js';
import { getACVMConfig } from './get_acvm_config.js';
import { getBBConfig } from './get_bb_config.js';
import { setupL1Contracts } from './setup_l1_contracts.js';
Expand Down Expand Up @@ -281,6 +281,7 @@ async function setupFromFresh(
// Fetch the AztecNode config.
// TODO: For some reason this is currently the union of a bunch of subsystems. That needs fixing.
const aztecNodeConfig: AztecNodeConfig & SetupOptions = { ...getConfigEnvVars(), ...opts };
aztecNodeConfig.peerCheckIntervalMS = TEST_PEER_CHECK_INTERVAL_MS;

// Create a temp directory for all ephemeral state and cleanup afterwards
const directoryToCleanup = path.join(tmpdir(), randomBytes(8).toString('hex'));
Expand Down
4 changes: 3 additions & 1 deletion yarn-project/end-to-end/src/fixtures/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ import {
import { mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
import { foundry } from 'viem/chains';

import { MNEMONIC } from './fixtures.js';
import { MNEMONIC, TEST_PEER_CHECK_INTERVAL_MS } from './fixtures.js';
import { getACVMConfig } from './get_acvm_config.js';
import { getBBConfig } from './get_bb_config.js';
import { isMetricsLoggingRequested, setupMetricsLogger } from './logging.js';
Expand Down Expand Up @@ -315,6 +315,8 @@ export async function setup(
chain: Chain = foundry,
): Promise<EndToEndContext> {
const config = { ...getConfigEnvVars(), ...opts };
config.peerCheckIntervalMS = TEST_PEER_CHECK_INTERVAL_MS;

const logger = getLogger();

// Create a temp directory for any services that need it and cleanup later
Expand Down
Loading