Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
aljo242 committed Jul 2, 2024
1 parent e324323 commit 50cd6dc
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions abci/checktx/mempool_parity_check_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,28 +87,35 @@ func (m MempoolParityCheckTx) CheckTx() CheckTx {
), nil
}

// run the checkTxHandler
res, checkTxError := 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 {
// check if the tx exists first
if txInMempool {
// prepare cleanup closure to remove tx if marked
removeTx := false
defer func() {
if removeTx {
// 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,
)
}
}
}()

// run the checkTxHandler
res, checkTxError := 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 && txInMempool {
removeTx = true
}

sdkCtx := m.GetContextForTx(req)
lane, err := m.matchLane(sdkCtx, tx)
if err != nil {
if isReCheck && txInMempool {
removeTx = true

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

View check run for this annotation

Codecov / codecov/patch

abci/checktx/mempool_parity_check_tx.go#L115-L116

Added lines #L115 - L116 were not covered by tests
}

m.logger.Debug("failed to match lane", "lane", lane, "err", err)
return sdkerrors.ResponseCheckTxWithEvents(
err,
Expand All @@ -124,23 +131,17 @@ func (m MempoolParityCheckTx) CheckTx() CheckTx {

txSize := int64(len(req.Tx))
if txSize > laneSize {
if isReCheck && txInMempool {
removeTx = true

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

View check run for this annotation

Codecov / codecov/patch

abci/checktx/mempool_parity_check_tx.go#L135

Added line #L135 was not covered by tests
}

m.logger.Debug(
"tx size exceeds max block bytes",
"tx", tx,
"tx size", txSize,
"max bytes", laneSize,
)

// remove the tx from app side mempool
if txInMempool && isReCheck {
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,
)
}
}

return sdkerrors.ResponseCheckTxWithEvents(
fmt.Errorf("tx size exceeds max bytes for lane %s", lane.Name()),
0,
Expand Down

0 comments on commit 50cd6dc

Please sign in to comment.