diff --git a/zetaclient/cctx_scanner.go b/zetaclient/cctx_scanner.go index e9d85f8419..ff6c93976a 100644 --- a/zetaclient/cctx_scanner.go +++ b/zetaclient/cctx_scanner.go @@ -16,7 +16,8 @@ import ( ) const ( - RescanBatch uint64 = 10 + RescanBatch uint64 = 10 + LogPrintBlks int64 = 10 ) // CctxScanner scans missed pending cctx and updates their status @@ -82,7 +83,7 @@ func (sc *CctxScanner) ScanMissedPendingCctx(bn int64, chainID int64, maxNonce u } } -func (sc *CctxScanner) EarliestPendingCctxByChain(chainID int64) *crosschaintypes.CrossChainTx { +func (sc *CctxScanner) EarliestPendingCctxByChain(bn int64, chainID int64) *crosschaintypes.CrossChainTx { oldPendingCctxs := sc.AllMissedPendingCctxByChain(chainID) // try removing finalized cctx @@ -107,9 +108,19 @@ func (sc *CctxScanner) EarliestPendingCctxByChain(chainID int64) *crosschaintype newPendingCctxs := sc.AllMissedPendingCctxByChain(chainID) if len(newPendingCctxs) == 0 { + sc.logger.Info().Msgf("scanner: pending cctxs for chain %d is empty, next nonce to scan %d", chainID, sc.nextNonceToScan[chainID]) return nil } - return newPendingCctxs[0] + + // log print for monitoring + oldestCctx := newPendingCctxs[0] + latestCctx := newPendingCctxs[len(newPendingCctxs)-1] + if bn%LogPrintBlks == 0 { + sc.logger.Info().Msgf("scanner: pending cctxs for chain %d, oldest %d, latest %d, next nonce to scan %d", + chainID, oldestCctx.GetCurrentOutTxParam().OutboundTxTssNonce, latestCctx.GetCurrentOutTxParam().OutboundTxTssNonce, sc.nextNonceToScan[chainID]) + } + + return oldestCctx } // Note: deep clone is unnecessary as the cctx list is used in a single thread diff --git a/zetaclient/zetacore_observer.go b/zetaclient/zetacore_observer.go index a11cd1e4e8..b11d4316a4 100644 --- a/zetaclient/zetacore_observer.go +++ b/zetaclient/zetacore_observer.go @@ -159,7 +159,7 @@ func (co *CoreObserver) startSendScheduler() { // Scan missed pending (forever) cctx in history and get the earliest // #nosec G701 non negative value co.scanner.ScanMissedPendingCctx(bn, c.ChainId, uint64(pendingNonces.NonceLow)) - earliestCctx := co.scanner.EarliestPendingCctxByChain(c.ChainId) + earliestCctx := co.scanner.EarliestPendingCctxByChain(bn, c.ChainId) if earliestCctx != nil { // append earliest missed pending cctx to head cctxList = append([]*types.CrossChainTx{earliestCctx}, cctxList...) } @@ -223,6 +223,10 @@ func (co *CoreObserver) startSendScheduler() { co.logger.ZetaChainWatcher.Error().Err(err).Msgf("IsSendOutTxProcessed fail, Chain ID: %s", c.ChainName) continue } + // skip keysign for missed pending (forever) cctx as outTx was already finalized + if co.scanner.IsMissedPendingCctx(c.ChainId, params.OutboundTxTssNonce) { + continue + } if included { co.logger.ZetaChainWatcher.Info().Msgf("send outTx already included; do not schedule") continue