From ae7414d4a359826104e764bf4c0fe5e6624c90f6 Mon Sep 17 00:00:00 2001 From: kyzooghost <73516204+kyzooghost@users.noreply.github.com> Date: Thu, 8 May 2025 18:24:52 +1000 Subject: [PATCH] postman test script from concurrent to serial tx (#954) --- postman/scripts/manualTestSendMessages.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/postman/scripts/manualTestSendMessages.ts b/postman/scripts/manualTestSendMessages.ts index 86ed7ce3..683b51f2 100644 --- a/postman/scripts/manualTestSendMessages.ts +++ b/postman/scripts/manualTestSendMessages.ts @@ -40,7 +40,7 @@ import { config } from "dotenv"; import yargs from "yargs"; import { hideBin } from "yargs/helpers"; import { sanitizePrivKey } from "./cli"; -import { ContractTransactionReceipt, Wallet, JsonRpcProvider } from "ethers"; +import { Wallet, JsonRpcProvider, ContractTransactionResponse } from "ethers"; import { LineaRollup, LineaRollup__factory } from "@consensys/linea-sdk"; import { SendMessageArgs } from "./types"; import { encodeSendMessage } from "./helpers"; @@ -134,7 +134,7 @@ const sendMessage = async ( messageNonce: bigint, senderNonce: number, logString: string, -): Promise => { +): Promise => { const lineaRollup = LineaRollup__factory.connect(L1_MESSAGE_SERVICE_ADDRESS[deploymentEnv], sender) as LineaRollup; const tx = await lineaRollup.sendMessage(args.to, args.fee, args.calldata, { value: args.fee, nonce: senderNonce }); const messageHash = encodeSendMessage( @@ -147,21 +147,22 @@ const sendMessage = async ( ); console.log(`Sent message with messageHash=${messageHash}. ${logString}`); - return await tx.wait(); + return tx; }; const sendMessages = async (deploymentEnv: DeploymentEnv, sender: Wallet, testScenarios: TestScenario[]) => { const nextSenderNonce = await sender.getNonce(); const nextMessageCounter = await getMessageCounter(deploymentEnv, sender); - const sendMessagePromises: Promise[] = testScenarios.map((s, i) => { + // If we send concurrently, we have high risk of sending nonces out of order + for (let i = 0; i < testScenarios.length; i++) { + const s = testScenarios[i]; const functionArgs: SendMessageArgs = { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion to: sender.address, fee: s.fee, calldata: s.calldata, }; - return sendMessage( + await sendMessage( deploymentEnv, sender, functionArgs, @@ -169,8 +170,7 @@ const sendMessages = async (deploymentEnv: DeploymentEnv, sender: Wallet, testSc nextSenderNonce + i, s.logString, ); - }); - await Promise.all(sendMessagePromises); + } }; const getMessageCounter = async (deploymentEnv: DeploymentEnv, signer: Wallet) => {