diff --git a/.changeset/cuddly-eels-lay.md b/.changeset/cuddly-eels-lay.md index 0262f64ded6..25b38d3164d 100644 --- a/.changeset/cuddly-eels-lay.md +++ b/.changeset/cuddly-eels-lay.md @@ -2,4 +2,4 @@ "chainlink": minor --- -Improve TXM performance by optimize Confirmer and Finalizer queries to stop pulling EVM receipt. #internal +Improve TXM performance by optimizing Confirmer and Finalizer queries to stop pulling EVM receipt. #internal diff --git a/core/chains/evm/txmgr/evm_tx_store.go b/core/chains/evm/txmgr/evm_tx_store.go index 6566213a380..3b4f6f484aa 100644 --- a/core/chains/evm/txmgr/evm_tx_store.go +++ b/core/chains/evm/txmgr/evm_tx_store.go @@ -2120,19 +2120,17 @@ func (o *evmTxStore) FindConfirmedTxesReceipts(ctx context.Context, finalizedBlo defer cancel() // note the receipts are partially loaded for performance reason - err = o.Transact(ctx, true, func(orm *evmTxStore) error { - sql := `SELECT evm.receipts.id, evm.receipts.tx_hash, evm.receipts.block_hash, evm.receipts.block_number FROM evm.receipts + + query := `SELECT evm.receipts.id, evm.receipts.tx_hash, evm.receipts.block_hash, evm.receipts.block_number FROM evm.receipts INNER JOIN evm.tx_attempts ON evm.tx_attempts.hash = evm.receipts.tx_hash INNER JOIN evm.txes ON evm.txes.id = evm.tx_attempts.eth_tx_id WHERE evm.txes.state = 'confirmed' AND evm.receipts.block_number <= $1 AND evm.txes.evm_chain_id = $2` - var dbReceipts []DbReceipt - err = o.q.SelectContext(ctx, &dbReceipts, sql, finalizedBlockNum, chainID.String()) - if len(dbReceipts) == 0 { - return nil - } + var dbReceipts []DbReceipt + err = o.q.SelectContext(ctx, &dbReceipts, query, finalizedBlockNum, chainID.String()) + if len(dbReceipts) != 0 { receipts = dbReceipts - return nil - }) + } + return receipts, err } diff --git a/core/chains/evm/txmgr/finalizer.go b/core/chains/evm/txmgr/finalizer.go index c0703560a80..60744636159 100644 --- a/core/chains/evm/txmgr/finalizer.go +++ b/core/chains/evm/txmgr/finalizer.go @@ -24,7 +24,6 @@ var _ Finalizer = (*evmFinalizer)(nil) const processHeadTimeout = 10 * time.Minute type finalizerTxStore interface { - // FindConfirmedTxesReceipts fetches partially loaded receipts for performance reason FindConfirmedTxesReceipts(ctx context.Context, finalizedBlockNum int64, chainID *big.Int) ([]Receipt, error) UpdateTxStatesToFinalizedUsingReceiptIds(ctx context.Context, txs []int64, chainId *big.Int) error }