From 79b71ac0104be201acaa5039c31f85e35da1f815 Mon Sep 17 00:00:00 2001 From: Joe Huang Date: Mon, 19 Aug 2024 13:52:37 -0500 Subject: [PATCH] Dimitris comments --- .changeset/cuddly-eels-lay.md | 2 +- core/chains/evm/txmgr/evm_tx_store.go | 16 +++++++--------- core/chains/evm/txmgr/finalizer.go | 1 - 3 files changed, 8 insertions(+), 11 deletions(-) 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 }