Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/pink-frogs-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@eth-optimism/batch-submitter': patch
---

Properly clear state root batch txs on startup
17 changes: 9 additions & 8 deletions packages/batch-submitter/src/exec/run-batch-submitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
Expand All @@ -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
)
Expand Down Expand Up @@ -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')) {
Expand Down