From 5e3cad1ba9125b60caa05cf211860b6674723cb8 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Tue, 30 Jan 2024 22:26:30 -0500 Subject: [PATCH] fix --- cosmos/runtime/txpool/mempool.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/cosmos/runtime/txpool/mempool.go b/cosmos/runtime/txpool/mempool.go index ecf582eb1..ffecb681c 100644 --- a/cosmos/runtime/txpool/mempool.go +++ b/cosmos/runtime/txpool/mempool.go @@ -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] }