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: flaky e2e-p2p test #3831

Merged
merged 2 commits into from
Jan 4, 2024
Merged
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
15 changes: 13 additions & 2 deletions yarn-project/end-to-end/src/e2e_p2p_network.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@ import { TestContractArtifact } from '@aztec/noir-contracts/Test';
import { BootstrapNode, P2PConfig, createLibP2PPeerId } from '@aztec/p2p';
import { ConstantKeyPair, PXEService, createPXEService, getPXEServiceConfig as getRpcConfig } from '@aztec/pxe';

import { mnemonicToAccount } from 'viem/accounts';

import { MNEMONIC } from './fixtures/fixtures.js';
import { setup } from './fixtures/utils.js';

// Don't set this to a higher value than 9 because each node will use a different L1 publisher account and anvil seeds
// only 10 accounts with ETH (9 and not 10 because first account is used by sandbox).
const NUM_NODES = 4;
const NUM_TXS_PER_BLOCK = 4;
const NUM_TXS_PER_NODE = 2;
Expand Down Expand Up @@ -55,7 +60,7 @@ describe('e2e_p2p_network', () => {
// is if the txs are successfully gossiped around the nodes.
const contexts: NodeContext[] = [];
for (let i = 0; i < NUM_NODES; i++) {
const node = await createNode(i + 1 + BOOT_NODE_TCP_PORT, bootstrapNodeAddress);
const node = await createNode(i + 1 + BOOT_NODE_TCP_PORT, bootstrapNodeAddress, i);
const context = await createPXEServiceAndSubmitTransactions(node, NUM_TXS_PER_NODE);
contexts.push(context);
}
Expand Down Expand Up @@ -107,7 +112,13 @@ describe('e2e_p2p_network', () => {
};

// creates a P2P enabled instance of Aztec Node Service
const createNode = async (tcpListenPort: number, bootstrapNode: string) => {
const createNode = async (tcpListenPort: number, bootstrapNode: string, publisherAddressIndex: number) => {
// We use different L1 publisher accounts in order to avoid duplicate tx nonces. We start from
// publisherAddressIndex + 1 because index 0 was already used during sandbox setup.
const hdAccount = mnemonicToAccount(MNEMONIC, { addressIndex: publisherAddressIndex + 1 });
const publisherPrivKey = Buffer.from(hdAccount.getHdKey().privateKey!);
config.publisherPrivateKey = `0x${publisherPrivKey!.toString('hex')}`;

const newConfig: AztecNodeConfig = {
...config,
tcpListenPort,
Expand Down