Commit e5ba9b1d authored by Conner Fromknecht's avatar Conner Fromknecht Committed by GitHub

Merge pull request #2006 from cfromknecht/clear-state-batch-pending-tx

fix(batch-submitter): clear state root batches
parents 5599aed1 9fe09f70
---
'@eth-optimism/batch-submitter': patch
---
Properly clear state root batch txs on startup
......@@ -430,20 +430,21 @@ export const run = async () => {
// Loops infinitely!
const loop = async (
func: () => Promise<TransactionReceipt>
func: () => Promise<TransactionReceipt>,
signer: Signer
): Promise<void> => {
// Clear all pending transactions
if (clearPendingTxs) {
try {
const pendingTxs = await sequencerSigner.getTransactionCount('pending')
const latestTxs = await sequencerSigner.getTransactionCount('latest')
const pendingTxs = await signer.getTransactionCount('pending')
const latestTxs = await signer.getTransactionCount('latest')
if (pendingTxs > latestTxs) {
logger.info(
'Detected pending transactions. Clearing all transactions!'
)
for (let i = latestTxs; i < pendingTxs; i++) {
const response = await sequencerSigner.sendTransaction({
to: await sequencerSigner.getAddress(),
const response = await signer.sendTransaction({
to: await signer.getAddress(),
value: 0,
nonce: i,
})
......@@ -456,7 +457,7 @@ export const run = async () => {
logger.debug('empty transaction data', {
data: response.data,
})
await sequencerSigner.provider.waitForTransaction(
await signer.provider.waitForTransaction(
response.hash,
requiredEnvVars.NUM_CONFIRMATIONS
)
......@@ -508,10 +509,10 @@ export const run = async () => {
// Run batch submitters in two seperate infinite loops!
if (requiredEnvVars.RUN_TX_BATCH_SUBMITTER) {
loop(() => txBatchSubmitter.submitNextBatch())
loop(() => txBatchSubmitter.submitNextBatch(), sequencerSigner)
}
if (requiredEnvVars.RUN_STATE_BATCH_SUBMITTER) {
loop(() => stateBatchSubmitter.submitNextBatch())
loop(() => stateBatchSubmitter.submitNextBatch(), proposerSigner)
}
if (config.bool('run-metrics-server', env.RUN_METRICS_SERVER === 'true')) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment