From f3b6fd76366a45a15d0e9768779023bcaa09cc69 Mon Sep 17 00:00:00 2001 From: Jonathan Fung <121899091+jonfung-dydx@users.noreply.github.com> Date: Fri, 14 Jun 2024 12:46:57 -0400 Subject: [PATCH] MsgBatchCancel Skip sequence number validation (#1698) --- protocol/app/ante/util.go | 4 ++++ protocol/app/ante/util_test.go | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/protocol/app/ante/util.go b/protocol/app/ante/util.go index c1a6d66725..dd4139c894 100644 --- a/protocol/app/ante/util.go +++ b/protocol/app/ante/util.go @@ -34,6 +34,10 @@ func ShouldSkipSequenceValidation(msgs []sdk.Msg) (shouldSkipValidation bool) { } // This is a `GoodTilBlock` message, continue to check the next message. continue + case + *clobtypes.MsgBatchCancel: + // MsgBatchCancel only supports short term orders. + continue default: // Early return for messages that require sequence number validation. return false diff --git a/protocol/app/ante/util_test.go b/protocol/app/ante/util_test.go index d0698207d7..40bd847128 100644 --- a/protocol/app/ante/util_test.go +++ b/protocol/app/ante/util_test.go @@ -28,6 +28,12 @@ func TestSkipSequenceValidation(t *testing.T) { }, shouldSkipValidation: true, }, + "single batch cancel message": { + msgs: []sdk.Msg{ + constants.Msg_BatchCancel, + }, + shouldSkipValidation: true, + }, "single transfer message": { msgs: []sdk.Msg{ constants.Msg_Transfer, @@ -86,6 +92,13 @@ func TestSkipSequenceValidation(t *testing.T) { }, shouldSkipValidation: false, }, + "mix of conditional orders and short term batch cancel orders": { + msgs: []sdk.Msg{ + constants.Msg_BatchCancel, + constants.Msg_PlaceOrder_Conditional, + }, + shouldSkipValidation: false, + }, } for name, tc := range testCases { t.Run(name, func(t *testing.T) {