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 () => { ...@@ -430,20 +430,21 @@ export const run = async () => {
// Loops infinitely! // Loops infinitely!
const loop = async ( const loop = async (
func: () => Promise<TransactionReceipt> func: () => Promise<TransactionReceipt>,
signer: Signer
): Promise<void> => { ): Promise<void> => {
// Clear all pending transactions // Clear all pending transactions
if (clearPendingTxs) { if (clearPendingTxs) {
try { try {
const pendingTxs = await sequencerSigner.getTransactionCount('pending') const pendingTxs = await signer.getTransactionCount('pending')
const latestTxs = await sequencerSigner.getTransactionCount('latest') const latestTxs = await signer.getTransactionCount('latest')
if (pendingTxs > latestTxs) { if (pendingTxs > latestTxs) {
logger.info( logger.info(
'Detected pending transactions. Clearing all transactions!' 'Detected pending transactions. Clearing all transactions!'
) )
for (let i = latestTxs; i < pendingTxs; i++) { for (let i = latestTxs; i < pendingTxs; i++) {
const response = await sequencerSigner.sendTransaction({ const response = await signer.sendTransaction({
to: await sequencerSigner.getAddress(), to: await signer.getAddress(),
value: 0, value: 0,
nonce: i, nonce: i,
}) })
...@@ -456,7 +457,7 @@ export const run = async () => { ...@@ -456,7 +457,7 @@ export const run = async () => {
logger.debug('empty transaction data', { logger.debug('empty transaction data', {
data: response.data, data: response.data,
}) })
await sequencerSigner.provider.waitForTransaction( await signer.provider.waitForTransaction(
response.hash, response.hash,
requiredEnvVars.NUM_CONFIRMATIONS requiredEnvVars.NUM_CONFIRMATIONS
) )
...@@ -508,10 +509,10 @@ export const run = async () => { ...@@ -508,10 +509,10 @@ export const run = async () => {
// Run batch submitters in two seperate infinite loops! // Run batch submitters in two seperate infinite loops!
if (requiredEnvVars.RUN_TX_BATCH_SUBMITTER) { if (requiredEnvVars.RUN_TX_BATCH_SUBMITTER) {
loop(() => txBatchSubmitter.submitNextBatch()) loop(() => txBatchSubmitter.submitNextBatch(), sequencerSigner)
} }
if (requiredEnvVars.RUN_STATE_BATCH_SUBMITTER) { if (requiredEnvVars.RUN_STATE_BATCH_SUBMITTER) {
loop(() => stateBatchSubmitter.submitNextBatch()) loop(() => stateBatchSubmitter.submitNextBatch(), proposerSigner)
} }
if (config.bool('run-metrics-server', env.RUN_METRICS_SERVER === 'true')) { 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