From 5809b1fb4112ab4264bb2af57c981e2529c3005f Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:45:41 +0000 Subject: [PATCH 1/2] fix: reduce peer check interval for e2e tests --- .../end-to-end/src/e2e_p2p/p2p_network.ts | 44 +++++++++---------- .../end-to-end/src/fixtures/fixtures.ts | 2 + .../end-to-end/src/fixtures/setup_p2p_test.ts | 2 + .../src/fixtures/snapshot_manager.ts | 3 +- yarn-project/end-to-end/src/fixtures/utils.ts | 4 +- 5 files changed, 31 insertions(+), 24 deletions(-) diff --git a/yarn-project/end-to-end/src/e2e_p2p/p2p_network.ts b/yarn-project/end-to-end/src/e2e_p2p/p2p_network.ts index 2d55474e7c8..4bfe4c45e99 100644 --- a/yarn-project/end-to-end/src/e2e_p2p/p2p_network.ts +++ b/yarn-project/end-to-end/src/e2e_p2p/p2p_network.ts @@ -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 */ @@ -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', diff --git a/yarn-project/end-to-end/src/fixtures/fixtures.ts b/yarn-project/end-to-end/src/fixtures/fixtures.ts index 79d10d0d2da..7fec6f90d39 100644 --- a/yarn-project/end-to-end/src/fixtures/fixtures.ts +++ b/yarn-project/end-to-end/src/fixtures/fixtures.ts @@ -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'); diff --git a/yarn-project/end-to-end/src/fixtures/setup_p2p_test.ts b/yarn-project/end-to-end/src/fixtures/setup_p2p_test.ts index 1d31d41ab6c..5ddcc3b6ee2 100644 --- a/yarn-project/end-to-end/src/fixtures/setup_p2p_test.ts +++ b/yarn-project/end-to-end/src/fixtures/setup_p2p_test.ts @@ -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'; @@ -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, diff --git a/yarn-project/end-to-end/src/fixtures/snapshot_manager.ts b/yarn-project/end-to-end/src/fixtures/snapshot_manager.ts index 2acb78f7d47..d031d18c5bd 100644 --- a/yarn-project/end-to-end/src/fixtures/snapshot_manager.ts +++ b/yarn-project/end-to-end/src/fixtures/snapshot_manager.ts @@ -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'; @@ -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')); diff --git a/yarn-project/end-to-end/src/fixtures/utils.ts b/yarn-project/end-to-end/src/fixtures/utils.ts index b931dfe1260..d6698a0ca04 100644 --- a/yarn-project/end-to-end/src/fixtures/utils.ts +++ b/yarn-project/end-to-end/src/fixtures/utils.ts @@ -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'; @@ -315,6 +315,8 @@ export async function setup( chain: Chain = foundry, ): Promise { 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 From b6bfdc0e5f0208142700229748b7b40ad7e3a3cd Mon Sep 17 00:00:00 2001 From: Maddiaa <47148561+Maddiaa0@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:48:01 +0000 Subject: [PATCH 2/2] =?UTF-8?q?Revert=20"fix(revert):=20"chore:=20increase?= =?UTF-8?q?=20default=20peer=20discovery=20heartbeat=20to=2030=20=E2=80=A6?= =?UTF-8?q?"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 852afb2be8af4d643c47d7ec6db868f4795575b0. --- yarn-project/p2p/src/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/p2p/src/config.ts b/yarn-project/p2p/src/config.ts index 0e30bc2efe3..5f5ea19258a 100644 --- a/yarn-project/p2p/src/config.ts +++ b/yarn-project/p2p/src/config.ts @@ -170,7 +170,7 @@ export const p2pConfigMappings: ConfigMappingsType = { peerCheckIntervalMS: { env: 'P2P_PEER_CHECK_INTERVAL_MS', description: 'The frequency in which to check for new peers.', - ...numberConfigHelper(1_000), + ...numberConfigHelper(30_000), }, l2QueueSize: { env: 'P2P_L2_QUEUE_SIZE',