Skip to content

Commit 5b1e9f2

Browse files
authored
fix: flaky e2e-p2p test (AztecProtocol#3831)
Fixes AztecProtocol#3654 **Note**: Lasse had a good hunch that it's most likely caused by different nodes using the same l1 publisher private key. This PR changes this and uses different accounts for different nodes. I am quite confident that that is the culprit so I will close the issue.
1 parent 2e0776a commit 5b1e9f2

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

yarn-project/end-to-end/src/e2e_p2p_network.test.ts

+13-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@ import { TestContractArtifact } from '@aztec/noir-contracts/Test';
1717
import { BootstrapNode, P2PConfig, createLibP2PPeerId } from '@aztec/p2p';
1818
import { ConstantKeyPair, PXEService, createPXEService, getPXEServiceConfig as getRpcConfig } from '@aztec/pxe';
1919

20+
import { mnemonicToAccount } from 'viem/accounts';
21+
22+
import { MNEMONIC } from './fixtures/fixtures.js';
2023
import { setup } from './fixtures/utils.js';
2124

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

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

0 commit comments

Comments
 (0)