Skip to content

Commit

Permalink
Dimitris comments
Browse files Browse the repository at this point in the history
  • Loading branch information
huangzhen1997 committed Aug 19, 2024
1 parent c9db427 commit 79b71ac
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .changeset/cuddly-eels-lay.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 7 additions & 9 deletions core/chains/evm/txmgr/evm_tx_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
1 change: 0 additions & 1 deletion core/chains/evm/txmgr/finalizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 79b71ac

Please sign in to comment.