Skip to content

Commit

Permalink
Merge pull request #50 from piwonskp/fix/spam-nonce
Browse files Browse the repository at this point in the history
Fix nonce in spam command
  • Loading branch information
zeroXbrock authored Sep 29, 2023
2 parents dd63f72 + 20d7be6 commit bf4246f
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions core/src/lib/scripts/spam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export const spam = async (
wallet: Wallet,
params: {
targetBlockNumber: number,
virtualNonce: number,
txsPerBundle: number,
sendRoute: SendRoute,
txStrategy?: TxStrategy,
Expand All @@ -36,9 +35,8 @@ export const spam = async (
.map((_, idx) => mevFlood.generateSwaps(
swapParams,
[wallet],
params.virtualNonce + idx
idx
)))
params.virtualNonce = params.virtualNonce + txBundles.map(b => b.swaps.signedSwaps.length).reduce((a, b) => a + b, 0)
const bundle = txBundles.map(txb => txb.swaps.signedSwaps.map(s => s.signedTx)).flat()

if (params.sendRoute === SendRoute.Mempool) {
Expand All @@ -65,9 +63,8 @@ export const spamLoop = async (mevFlood: MevFlood, wallet: Wallet, params: {
}
let lastBlockSampledAt = now()
let targetBlockNumber = await wallet.provider.getBlockNumber() + 1
let virtualNonce = await wallet.getTransactionCount()
while (true) {
spam(mevFlood, wallet, {targetBlockNumber, virtualNonce, txsPerBundle: params.txsPerBundle, sendRoute: params.sendRoute, txStrategy: params.txStrategy})
spam(mevFlood, wallet, {targetBlockNumber, txsPerBundle: params.txsPerBundle, sendRoute: params.sendRoute, txStrategy: params.txStrategy})
await sleep(params.secondsPerBundle * 1000)
if (now() - lastBlockSampledAt > 12000) {
targetBlockNumber += 1
Expand Down

0 comments on commit bf4246f

Please sign in to comment.