Skip to content

Commit

Permalink
fix: Uniswap e2e test "nonce too low" (#7633)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
spalladino authored Jul 26, 2024
1 parent 2a013b8 commit e9e2318
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { setup as e2eSetup } from '../fixtures/utils.js';
import { setup as e2eSetup, getL1WalletClient } from '../fixtures/utils.js';
import { type UniswapSetupContext, uniswapL1L2TestSuite } from '../shared/uniswap_l1_l2.js';

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

const walletClient = deployL1ContractsValues.walletClient;
const walletClient = getL1WalletClient(config.rpcUrl, 1);
const publicClient = deployL1ContractsValues.publicClient;

const ownerWallet = wallets[0];
Expand Down
10 changes: 10 additions & 0 deletions yarn-project/end-to-end/src/fixtures/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,16 @@ export async function setup(
};
}

/** Returns an L1 wallet client for anvil using a well-known private key based on the index. */
export function getL1WalletClient(rpcUrl: string, index: number) {
const hdAccount = mnemonicToAccount(MNEMONIC, { addressIndex: index });
return createWalletClient({
account: hdAccount,
chain: foundry,
transport: http(rpcUrl),
});
}

/**
* Ensures there's a running Anvil instance and returns the RPC URL.
* @returns
Expand Down

0 comments on commit e9e2318

Please sign in to comment.