Skip to content

Commit

Permalink
Remove unnecessary message serialization in clob AnteHandle (backport #…
Browse files Browse the repository at this point in the history
…1327) (#1670)

Co-authored-by: roy-dydx <133032749+roy-dydx@users.noreply.github.com>
  • Loading branch information
mergify[bot] and roy-dydx authored Jun 11, 2024
1 parent 2d1f980 commit 9b6a8d2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 21 deletions.
10 changes: 9 additions & 1 deletion protocol/app/ante.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package app

import (
"sync"

errorsmod "cosmossdk.io/errors"
"cosmossdk.io/store/cachemulti"
storetypes "cosmossdk.io/store/types"
Expand All @@ -9,10 +11,11 @@ import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
"sync"

customante "github.com/dydxprotocol/v4-chain/protocol/app/ante"
"github.com/dydxprotocol/v4-chain/protocol/lib"
libante "github.com/dydxprotocol/v4-chain/protocol/lib/ante"
"github.com/dydxprotocol/v4-chain/protocol/lib/log"
clobante "github.com/dydxprotocol/v4-chain/protocol/x/clob/ante"
clobtypes "github.com/dydxprotocol/v4-chain/protocol/x/clob/types"
)
Expand Down Expand Up @@ -135,6 +138,11 @@ type lockingAnteHandler struct {
}

func (h *lockingAnteHandler) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool) (sdk.Context, error) {
ctx = log.AddPersistentTagsToLogger(ctx,
log.Callback, lib.TxMode(ctx),
log.BlockHeight, ctx.BlockHeight()+1,
)

isClob, err := clobante.IsSingleClobMsgTx(tx)
if err != nil {
return ctx, err
Expand Down
20 changes: 0 additions & 20 deletions protocol/x/clob/ante/clob.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,8 @@ func (cd ClobDecorator) AnteHandle(
msgs := tx.GetMsgs()
var msg = msgs[0]

// Set request-level logging tags
ctx = log.AddPersistentTagsToLogger(ctx,
log.Module, log.Clob,
log.Callback, lib.TxMode(ctx),
log.BlockHeight, ctx.BlockHeight()+1,
log.Msg, msg,
)

switch msg := msg.(type) {
case *types.MsgCancelOrder:
ctx = log.AddPersistentTagsToLogger(ctx,
log.Handler, log.CancelOrder,
)

if msg.OrderId.IsStatefulOrder() {
err = cd.clobKeeper.CancelStatefulOrder(ctx, msg)
} else {
Expand All @@ -104,9 +92,6 @@ func (cd ClobDecorator) AnteHandle(
)

case *types.MsgPlaceOrder:
ctx = log.AddPersistentTagsToLogger(ctx,
log.Handler, log.PlaceOrder,
)
if msg.Order.OrderId.IsStatefulOrder() {
err = cd.clobKeeper.PlaceStatefulOrder(ctx, msg, false)

Expand Down Expand Up @@ -145,11 +130,6 @@ func (cd ClobDecorator) AnteHandle(
return next(ctx, tx, simulate)
}

ctx = log.AddPersistentTagsToLogger(
ctx,
log.Handler, log.MsgBatchCancel,
)

success, failures, err := cd.clobKeeper.BatchCancelShortTermOrder(
ctx,
msg,
Expand Down

0 comments on commit 9b6a8d2

Please sign in to comment.