diff --git a/common/txmgr/address_state.go b/common/txmgr/address_state.go index 6619cb47398..79557cf13f5 100644 --- a/common/txmgr/address_state.go +++ b/common/txmgr/address_state.go @@ -152,23 +152,6 @@ func (as *AddressState[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) FindTx return as.idempotencyKeyToTx[key] } -func (as *AddressState[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) MaxConfirmedSequence() SEQ { - as.RLock() - defer as.RUnlock() - - var maxSeq SEQ - for _, tx := range as.confirmed { - if tx.Sequence == nil { - continue - } - if (*tx.Sequence).Int64() > maxSeq.Int64() { - maxSeq = *tx.Sequence - } - } - - return maxSeq -} - func (as *AddressState[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) ApplyToTxsByState( txStates []txmgrtypes.TxState, fn func(*txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]), diff --git a/common/txmgr/inmemory_store.go b/common/txmgr/inmemory_store.go index 551e0c51077..4cfcf484b94 100644 --- a/common/txmgr/inmemory_store.go +++ b/common/txmgr/inmemory_store.go @@ -1718,8 +1718,22 @@ func (ms *InMemoryStore[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) MarkA wg.Add(1) go func(as *AddressState[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) { // TODO(jtw): THIS IS EVM SPECIFIC THIS SHOULD BE GENERALIZED - maxConfirmedSequence := as.MaxConfirmedSequence() - filter := func(tx *txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) bool { + // Get the max confirmed sequence + filter := func(tx *txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) bool { return true } + states := []txmgrtypes.TxState{TxConfirmed} + txs := as.FetchTxs(states, filter) + var maxConfirmedSequence SEQ + for _, tx := range txs { + if tx.Sequence == nil { + continue + } + if (*tx.Sequence).Int64() > maxConfirmedSequence.Int64() { + maxConfirmedSequence = *tx.Sequence + } + } + + // Mark all unconfirmed txs with a sequence less than the max confirmed sequence as confirmed_missing_receipt + filter = func(tx *txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) bool { if tx.Sequence == nil { return false } @@ -1729,8 +1743,8 @@ func (ms *InMemoryStore[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) MarkA return (*tx.Sequence).Int64() < maxConfirmedSequence.Int64() } - states := []txmgrtypes.TxState{TxUnconfirmed} - txs := as.FetchTxs(states, filter) + states = []txmgrtypes.TxState{TxUnconfirmed} + txs = as.FetchTxs(states, filter) for _, tx := range txs { attempt := tx.TxAttempts[0]