diff --git a/yarn-project/end-to-end/src/e2e_p2p_network.test.ts b/yarn-project/end-to-end/src/e2e_p2p_network.test.ts index 5c2d746aa6a..a5888f24dcb 100644 --- a/yarn-project/end-to-end/src/e2e_p2p_network.test.ts +++ b/yarn-project/end-to-end/src/e2e_p2p_network.test.ts @@ -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; @@ -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); } @@ -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,