Skip to content

Commit

Permalink
Merge pull request #109 from DarkFlorist/sequencer-spam
Browse files Browse the repository at this point in the history
spam sequencer every 250ms until transaction succeeds
  • Loading branch information
KillariDev authored Dec 26, 2024
2 parents ede8d73 + 720e0dd commit a8f804e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app/ts/components/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export const SettingsModal = ({ display, bouquetNetwork, bouquetSettings }: { di
</span>
</label>
{ relayMode.value.value === 'mempool' ? <>
<SingleNotice variant = 'warn' title = 'Mempool mode is dangerous' description = { `When mempool mode is enabled. The transactions are sent as individual transactions to the below RPC URL. This means it's possible that only one of the transactions might end up on the chain. Use this mode only if a relay is not available for the network.`} />
<SingleNotice variant = 'warn' title = 'Mempool mode is dangerous' description = { `When mempool mode is enabled, transactions are sent individually to the RPC URL specified below. As a result, some transactions may not make it onto the blockchain. This mode should only be used if a private relay is unavailable for the network. Additionally, if a sweeper is active on your account there is a high risk that rescue attempts may fail, allowing the sweeper to steal your gas funds and other assets. Use this mode only as a last resort when no other options are available.`} />
<div key = {'mempoolSimulationRpcEndpoint'} className={`flex flex-col justify-center border h-16 outline-none px-4 focus-within:bg-white/5 bg-transparent ${!mempoolSimulationRpcEndpoint.value.valid ? 'border-red-400' : 'border-white/50 focus-within:border-white/80'}`}>
<span className='text-sm text-gray-500'>Mempool Simulation RPC URL (an RPC with eth_simulateV1 support)</span>
<input onInput={(e: JSX.TargetedEvent<HTMLInputElement>) => validateMempoolSimulationRpcEndpointInput(e.currentTarget.value)} value={mempoolSimulationRpcEndpoint.value.value} type='text' className='bg-transparent outline-none placeholder:text-gray-600' placeholder='https://' />
Expand Down
4 changes: 2 additions & 2 deletions app/ts/components/Submit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ export const Submit = ({
<div>
{ bouquetNetwork.value.relayMode === 'mempool' ? <>
<div style = 'padding-bottom: 10px;'>
<SingleNotice variant = 'warn' title = 'Mempool mode is dangerous' description = { `You are currently using Mempool mode. When mempool mode is enabled. The transactions are sent as individual transactions. This means it's possible that only one of the transactions might end up on the chain. Use this mode only if a relay is not available for the network.`} />
<SingleNotice variant = 'warn' title = 'Mempool mode is dangerous' description = { `You are currently using Mempool mode. Transactions are sent individually so some transactions may not make it onto the blockchain. This mode should only be used if a priate relay is unavailable for the network. Additionally, if a sweeper is active on your account there is a high risk that rescue attempts may fail, allowing the sweeper to steal your gas funds and other assets. Use this mode only as a last resort when no other options are available.`} />
</div>
<p><span className='font-bold'>Gas:</span> {formatUnits(getMaxBaseFeeInFutureBlock(blockInfo.value.baseFee, bouquetNetwork.value.blocksInFuture), 'gwei')} gwei + {formatUnits(bouquetNetwork.value.priorityFee.toString(), 'gwei')} gwei priority</p>
<p><span className='font-bold'>Transaction Submit RPC:</span> { bouquetNetwork.value.mempoolSubmitRpcEndpoint }</p>
Expand All @@ -292,7 +292,7 @@ export const Submit = ({
<div className='flex flex-row gap-6'>
<Button onClick={() => waitForSimulation(simulateCallback)} disabled={simulationPromise.value.state === 'pending'} variant='secondary'>Simulate</Button>
<Button onClick={toggleSubmission}>
{submissionStatus.value.active ? (bouquetNetwork.value.relayMode === 'relay' ? `Stop submitting to relay` : `Stop tracking the transactions`) : `Submit to ${ bouquetNetwork.value.relayMode }`}</Button>
{submissionStatus.value.active ? (bouquetNetwork.value.relayMode === 'relay' ? `Stop submitting to relay` : `Stop tracking the transactions`) : (bouquetNetwork.value.relayMode === 'mempool' ? `Accept the Risks and Submit`: `Submit to ${ bouquetNetwork.value.relayMode }`)}</Button>
</div>
<SimulationResult state={simulationPromise} />
<Bundles outstandingBundles={outstandingBundles} bouquetNetwork={bouquetNetwork}/>
Expand Down
24 changes: 13 additions & 11 deletions app/ts/library/flashbots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ export async function simulateBundle(
from: bigIntify(tx.transaction.from),
nonce: bigIntify(tx.transaction.nonce),
gas: bigIntify(tx.transaction.gasLimit),
gasPrice: tx.transaction.gasPrice,
maxPriorityFeePerGas: bigIntify(tx.transaction.maxPriorityFeePerGas),
maxFeePerGas: bigIntify(tx.transaction.maxFeePerGas),
input: tx.transaction.data === null || tx.transaction.data === undefined ? new Uint8Array() : hexStringToUint8Array(tx.transaction.data),
Expand Down Expand Up @@ -180,18 +179,21 @@ export async function sendBundle(bundle: Bundle, targetBlock: bigint, fundingAmo
id: index,
params: [transaction]
}))
if (network.mempoolSubmitRpcEndpoint === undefined) throw new Error('MemPool Submit Rpc Endpoint is not set')
const requests = await Promise.all(payloads.map(async (payload) => {
if (network.mempoolSubmitRpcEndpoint === undefined) throw new Error('MemPool Submit Rpc Endpoint is not set')
return await fetch(network.mempoolSubmitRpcEndpoint, { method: 'POST', body: payload, headers: { 'Content-Type': 'application/json' } })
}))
for (const request of requests) {
const response = await request.json()
if (response.error !== undefined && response.error !== null) {
throw new Error(response.error.message)
if (network.mempoolSubmitRpcEndpoint === undefined) throw new Error('MemPool Submit RPC Endpoint is not set')
for (const payload of payloads) {
const MAX_ATTEMPTS = 40
for (var attempt = 0; attempt < MAX_ATTEMPTS; attempt++ ) {
const request = await fetch(network.mempoolSubmitRpcEndpoint, { method: 'POST', body: payload, headers: { 'Content-Type': 'application/json' } })
const response = await request.json()
console.log(response)
if (response.error !== undefined) {
if (attempt >= MAX_ATTEMPTS - 1) throw new Error(response.error.message)
await new Promise(r => setTimeout(r, 50 + attempt * 50))
} else {
break
}
}
}

const bundleTransactions = transactions.map((signedTransaction) => {
const transactionDetails = Transaction.from(signedTransaction)
return {
Expand Down

0 comments on commit a8f804e

Please sign in to comment.