From 9b6a8d26a95e651db48b463d35b1f6030333a4aa Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 11 Jun 2024 14:43:10 -0400 Subject: [PATCH] Remove unnecessary message serialization in clob AnteHandle (backport #1327) (#1670) Co-authored-by: roy-dydx <133032749+roy-dydx@users.noreply.github.com> --- protocol/app/ante.go | 10 +++++++++- protocol/x/clob/ante/clob.go | 20 -------------------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/protocol/app/ante.go b/protocol/app/ante.go index 96cc663c7c..0f2db5dcd4 100644 --- a/protocol/app/ante.go +++ b/protocol/app/ante.go @@ -1,6 +1,8 @@ package app import ( + "sync" + errorsmod "cosmossdk.io/errors" "cosmossdk.io/store/cachemulti" storetypes "cosmossdk.io/store/types" @@ -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" ) @@ -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 diff --git a/protocol/x/clob/ante/clob.go b/protocol/x/clob/ante/clob.go index 42bb5ecf19..8578f179f5 100644 --- a/protocol/x/clob/ante/clob.go +++ b/protocol/x/clob/ante/clob.go @@ -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 { @@ -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) @@ -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,