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

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
calbera committed Jan 31, 2024
1 parent ec7dffc commit 5e3cad1
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions cosmos/runtime/txpool/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,15 @@ 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
}

// 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)
return nil
}
if errs[0] != nil {
return errs[0]
}

Expand Down

0 comments on commit 5e3cad1

Please sign in to comment.