Skip to content

Commit 82a8958

Browse files
committedAug 8, 2024·
track if we see missing transcations which are invalid
1 parent 6f8f70a commit 82a8958

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed
 

‎mempool/cat/block_builder.go

+13
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,19 @@ func (bf *blockFetcher) TryAddMissingTx(key types.TxKey, tx []byte) {
158158
}
159159
}
160160

161+
// IsMissingTx checks if a given transaction is missing from any of the block requests.
162+
func (bf *blockFetcher) IsMissingTx(key types.TxKey) bool {
163+
bf.mtx.Lock()
164+
defer bf.mtx.Unlock()
165+
for _, request := range bf.requests {
166+
_, ok := request.missingKeys[key.String()]
167+
if ok {
168+
return true
169+
}
170+
}
171+
return false
172+
}
173+
161174
// PruneOldRequests removes any requests that are older than the given height.
162175
func (bf *blockFetcher) pruneOldRequests(height int64) {
163176
for blockID, request := range bf.requests {

‎mempool/cat/reactor.go

+4
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ func (memR *Reactor) ReceiveEnvelope(e p2p.Envelope) {
263263
}
264264
_, err = memR.mempool.TryAddNewTx(ntx, key, txInfo)
265265
if err != nil && err != ErrTxInMempool && err != ErrTxRecentlyCommitted {
266+
if memR.blockFetcher.IsMissingTx(key) {
267+
memR.Logger.Error("tx in block is not valid by mempool")
268+
}
269+
266270
memR.Logger.Info("Could not add tx from peer", "peerID", peerID, "txKey", key, "err", err)
267271
return
268272
}

0 commit comments

Comments
 (0)
Please sign in to comment.