Skip to content

Commit e9e2318

Browse files
authored
fix: Uniswap e2e test "nonce too low" (#7633)
The uniswap e2e test was intermittently failing with "nonce too low" error when deploying the L1 contracts needed for testing. See [here](https://github.com/AztecProtocol/aztec-packages/actions/runs/10113107392/job/27969400151?pr=7630#step:4:1187) for an example run. This seems to happen because the same L1 account is used for pushing blocks from the sequencer and for deploying the contracts in the test. If both components try to send a tx at the same time, it fails with nonce too low since they clash on the nonce used. This PR changes it so the deployment of contracts for the test happens using a different anvil account.
1 parent 2a013b8 commit e9e2318

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

yarn-project/end-to-end/src/composed/uniswap_trade_on_l1_from_l2.test.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { setup as e2eSetup } from '../fixtures/utils.js';
1+
import { setup as e2eSetup, getL1WalletClient } from '../fixtures/utils.js';
22
import { type UniswapSetupContext, uniswapL1L2TestSuite } from '../shared/uniswap_l1_l2.js';
33

44
// This tests works on forked mainnet. There is a dump of the data in `dumpedState` such that we
@@ -18,9 +18,10 @@ const testSetup = async (): Promise<UniswapSetupContext> => {
1818
deployL1ContractsValues,
1919
wallets,
2020
logger,
21+
config,
2122
} = await e2eSetup(2, { stateLoad: dumpedState });
2223

23-
const walletClient = deployL1ContractsValues.walletClient;
24+
const walletClient = getL1WalletClient(config.rpcUrl, 1);
2425
const publicClient = deployL1ContractsValues.publicClient;
2526

2627
const ownerWallet = wallets[0];

yarn-project/end-to-end/src/fixtures/utils.ts

+10
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,16 @@ export async function setup(
439439
};
440440
}
441441

442+
/** Returns an L1 wallet client for anvil using a well-known private key based on the index. */
443+
export function getL1WalletClient(rpcUrl: string, index: number) {
444+
const hdAccount = mnemonicToAccount(MNEMONIC, { addressIndex: index });
445+
return createWalletClient({
446+
account: hdAccount,
447+
chain: foundry,
448+
transport: http(rpcUrl),
449+
});
450+
}
451+
442452
/**
443453
* Ensures there's a running Anvil instance and returns the RPC URL.
444454
* @returns

0 commit comments

Comments
 (0)