Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

Commit

Permalink
fix(mempool): properly mark txs as seen
Browse files Browse the repository at this point in the history
  • Loading branch information
itsdevbear committed Jan 31, 2024
1 parent ec7dffc commit 5980606
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions cosmos/runtime/txpool/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ package txpool
import (
"context"
"errors"
"fmt"
"math/big"
"sync"

Expand Down Expand Up @@ -127,13 +128,16 @@ func (m *Mempool) Insert(ctx context.Context, sdkTx sdk.Tx) error {
m.blockBuilderMu.RLock()
errs := m.TxPool.Add([]*ethtypes.Transaction{ethTx}, false, false)
m.blockBuilderMu.RUnlock()
if len(errs) > 0 {
// Handle case where a node broadcasts to itself, we don't want it to fail CheckTx.
if errors.Is(errs[0], ethtxpool.ErrAlreadyKnown) &&
(sCtx.ExecMode() == sdk.ExecModeCheck || sCtx.ExecMode() == sdk.ExecModeReCheck) {
telemetry.IncrCounter(float32(1), MetricKeyMempoolKnownTxs)
return nil
}
fmt.Println("Inserting tx into mempool", len(errs))

Check failure on line 131 in cosmos/runtime/txpool/mempool.go

View workflow job for this annotation

GitHub Actions / ci (lint, polaris-linux-latest, 1.21.6)

use of `fmt.Println` forbidden by pattern `^(fmt\.Print(|f|ln)|print|println)$` (forbidigo)

// Handle case where a node broadcasts to itself, we don't want it to fail CheckTx.
// Note: it's safe to check errs[0] because geth returns `errs` of length 1.
if errors.Is(errs[0], ethtxpool.ErrAlreadyKnown) &&
(sCtx.ExecMode() == sdk.ExecModeCheck || sCtx.ExecMode() == sdk.ExecModeReCheck) {
telemetry.IncrCounter(float32(1), MetricKeyMempoolKnownTxs)
sCtx.Logger().Info("mempool insert: tx already in mempool", "mode", sCtx.ExecMode())
return nil
} else if errs[0] != nil {
return errs[0]
}

Expand Down

0 comments on commit 5980606

Please sign in to comment.