Skip to content

Commit

Permalink
exclude MsgBatchCancel from mempool (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonfung-dydx authored and roy-dydx committed Apr 9, 2024
1 parent 6d0767b commit c50784d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions mempool/clist_mempool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ func TestMempoolConcurrentUpdateAndReceiveCheckTxResponse(t *testing.T) {
go func(h int) {
defer wg.Done()

err := mp.Update(int64(h), []types.Tx{tx}, abciResponses(1, abci.CodeTypeOK), nil, nil)
err := mp.Update(int64(h), time.UnixMilli(1), []types.Tx{tx}, abciResponses(1, abci.CodeTypeOK), nil, nil)
require.NoError(t, err)
require.Equal(t, int64(h), mp.height.Load(), "height mismatch")
}(h)
Expand Down Expand Up @@ -798,7 +798,7 @@ func TestMempoolNotifyTxsAvailable(t *testing.T) {
require.Empty(t, mp.TxsAvailable())

// Updating the pool will remove the tx and set the variable to false
err := mp.Update(1, []types.Tx{tx}, abciResponses(1, abci.CodeTypeOK), nil, nil)
err := mp.Update(1, time.UnixMilli(1), []types.Tx{tx}, abciResponses(1, abci.CodeTypeOK), nil, nil)
require.NoError(t, err)
require.Zero(t, mp.Size())
require.False(t, mp.notifiedTxsAvailable.Load())
Expand Down
6 changes: 5 additions & 1 deletion mempool/dydx_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

// IsShortTermClobOrderTransaction returns true if the provided `tx` is a
// Cosmos transaction containing a short-term `MsgPlaceOrder` or
// short-term `MsgCancelOrder` message.
// short-term `MsgCancelOrder` or `MsgBatchCancel` message.
func IsShortTermClobOrderTransaction(
tx types.Tx,
mempoolLogger log.Logger,
Expand Down Expand Up @@ -44,6 +44,10 @@ func IsShortTermClobOrderTransaction(
}
return msgCancelOrder.OrderId.IsShortTermOrder()
}
if cosmosTx.Body.Messages[0].TypeUrl == "/dydxprotocol.clob.MsgBatchCancel" {
// MsgBatchCancel only processes short term order cancellations as of right now.
return true
}
}

return false
Expand Down

0 comments on commit c50784d

Please sign in to comment.