Skip to content

Commit 39ccb4e

Browse files
committed
fix loading tx receipts per block
1 parent f9d167a commit 39ccb4e

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

pkg/coordinator/wallet/manager.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,9 @@ func (manager *Manager) processBlockTransactions(block *execution.Block) {
9494
manager.walletsMutex.Lock()
9595

9696
wallets := map[common.Address]*Wallet{}
97-
pendingTxCount := uint64(0)
9897

9998
for addr := range manager.walletsMap {
10099
wallets[addr] = manager.walletsMap[addr]
101-
pendingTxCount += wallets[addr].pendingNonce - wallets[addr].confirmedNonce
102100
}
103101

104102
manager.walletsMutex.Unlock()
@@ -107,20 +105,11 @@ func (manager *Manager) processBlockTransactions(block *execution.Block) {
107105

108106
var blockReceipts []*ethtypes.Receipt
109107

110-
if pendingTxCount > 10 {
111-
// load all receipts for block to avoid receipt polling for each pending transaction
112-
blockReceipts = manager.loadBlockReceipts(block)
113-
}
108+
receiptsLoaded := false
114109

115110
signer := ethtypes.LatestSignerForChainID(manager.clientPool.GetBlockCache().GetChainID())
116111

117112
for idx, tx := range blockData.Transactions() {
118-
var txReceipt *ethtypes.Receipt
119-
120-
if blockReceipts != nil && idx < len(blockReceipts) {
121-
txReceipt = blockReceipts[idx]
122-
}
123-
124113
txFrom, err := ethtypes.Sender(signer, tx)
125114
if err != nil {
126115
manager.logger.Warnf("error decoding tx sender (block %v, tx %v): %v", block.Number, idx, err)
@@ -129,6 +118,17 @@ func (manager *Manager) processBlockTransactions(block *execution.Block) {
129118

130119
fromWallet := wallets[txFrom]
131120
if fromWallet != nil {
121+
if !receiptsLoaded {
122+
blockReceipts = manager.loadBlockReceipts(block)
123+
receiptsLoaded = true
124+
}
125+
126+
var txReceipt *ethtypes.Receipt
127+
128+
if blockReceipts != nil && idx < len(blockReceipts) {
129+
txReceipt = blockReceipts[idx]
130+
}
131+
132132
fromWallet.processTransactionInclusion(block, tx, txReceipt)
133133
}
134134

pkg/coordinator/wallet/wallet.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -454,10 +454,6 @@ func (wallet *Wallet) processTransactionInclusion(block *execution.Block, tx *ty
454454
return
455455
}
456456

457-
if receipt == nil {
458-
receipt = wallet.loadTransactionReceipt(context.Background(), block, tx)
459-
}
460-
461457
nonce := tx.Nonce()
462458

463459
wallet.txNonceMutex.Lock()

0 commit comments

Comments
 (0)