Skip to content

Commit

Permalink
fix backport
Browse files Browse the repository at this point in the history
  • Loading branch information
nivasan1 committed Apr 22, 2024
1 parent 66fb0dd commit 006b743
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
10 changes: 4 additions & 6 deletions abci/checktx/check_tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,16 @@ func (s *CheckTxTestSuite) TestRemovalOnRecheckTx() {
s.Require().NoError(err)

mevLane := s.InitLane(math.LegacyOneDec(), nil)
mempool, err := block.NewLanedMempool(s.Ctx.Logger(), []block.Lane{mevLane}, moduleLaneFetcher{
mevLane,
})
mempool, err := block.NewLanedMempool(s.Ctx.Logger(), []block.Lane{mevLane})
s.Require().NoError(err)

handler := checktx.NewMempoolParityCheckTx(
s.Ctx.Logger(),
mempool,
s.EncCfg.TxConfig.TxDecoder(),
func(*cometabci.RequestCheckTx) (*cometabci.ResponseCheckTx, error) {
func(cometabci.RequestCheckTx) cometabci.ResponseCheckTx {
// always fail
return &cometabci.ResponseCheckTx{Code: 1}, nil
return cometabci.ResponseCheckTx{Code: 1}
},
).CheckTx()

Expand All @@ -149,7 +147,7 @@ func (s *CheckTxTestSuite) TestRemovalOnRecheckTx() {
s.Require().True(mempool.Contains(tx))

// check tx
res, err := handler(&cometabci.RequestCheckTx{Tx: txBz, Type: cometabci.CheckTxType_Recheck})
res := handler(cometabci.RequestCheckTx{Tx: txBz, Type: cometabci.CheckTxType_Recheck})
s.Require().NoError(err)

s.Require().Equal(uint32(1), res.Code)
Expand Down
11 changes: 5 additions & 6 deletions abci/checktx/mempool_parity_check_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,28 +74,27 @@ func (m MempoolParityCheckTx) CheckTx() CheckTx {
}

// run the checkTxHandler
res, checkTxError := m.checkTxHandler(req)
res := m.checkTxHandler(req)

// if re-check fails for a transaction, we'll need to explicitly purge the tx from
// the app-side mempool
if isInvalidCheckTxExecution(res, checkTxError) && isReCheck {
if isInvalidCheckTxExecution(res) && isReCheck {
// check if the tx exists first
if m.mempl.Contains(tx) {
// remove the tx
if err := m.mempl.Remove(tx); err != nil {
m.logger.Debug(
"failed to remove tx from app-side mempool when purging for re-check failure",
"removal-err", err,
"check-tx-err", checkTxError,
)

Check warning on line 89 in abci/checktx/mempool_parity_check_tx.go

View check run for this annotation

Codecov / codecov/patch

abci/checktx/mempool_parity_check_tx.go#L86-L89

Added lines #L86 - L89 were not covered by tests
}
}
}

return res, checkTxError
return res
}
}

func isInvalidCheckTxExecution(resp *cmtabci.ResponseCheckTx, checkTxErr error) bool {
return resp == nil || resp.Code != 0 || checkTxErr != nil
func isInvalidCheckTxExecution(resp cmtabci.ResponseCheckTx) bool {
return resp.Code != 0
}

0 comments on commit 006b743

Please sign in to comment.