Skip to content

Commit

Permalink
log
Browse files Browse the repository at this point in the history
  • Loading branch information
roy-dydx committed Mar 27, 2024
1 parent 0d2e79c commit 755a67b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions protocol/app/ante.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app

import (
"fmt"
"sync"

errorsmod "cosmossdk.io/errors"
Expand All @@ -17,6 +18,7 @@ import (
libante "github.com/dydxprotocol/v4-chain/protocol/lib/ante"
"github.com/dydxprotocol/v4-chain/protocol/lib/metrics"
clobante "github.com/dydxprotocol/v4-chain/protocol/x/clob/ante"
"github.com/dydxprotocol/v4-chain/protocol/x/clob/types"
clobtypes "github.com/dydxprotocol/v4-chain/protocol/x/clob/types"
)

Expand Down Expand Up @@ -137,6 +139,10 @@ type lockingAnteHandler struct {
clob clobante.ClobDecorator
}

func orderIdStr(id types.OrderId, tag string) string {
return fmt.Sprintf("%s:%s:%d:%d", tag, id.SubaccountId.Owner, id.SubaccountId.Number, id.ClientId)
}

func (h *lockingAnteHandler) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool) (sdk.Context, error) {
isClob, err := clobante.IsSingleClobMsgTx(tx)
if err != nil {
Expand Down Expand Up @@ -237,6 +243,16 @@ func (h *lockingAnteHandler) clobAnteHandle(ctx sdk.Context, tx sdk.Tx, simulate
"roy_clob_tx",
metrics.Count,
)
msgs := tx.GetMsgs()
var orderId types.OrderId
switch msg := msgs[0].(type) {
case *types.MsgCancelOrder:
orderId = msg.OrderId
ctx.Logger().Info("roycloblog", "order_id", orderIdStr(orderId, "cancel"), "block_height", ctx.BlockHeight())
case *types.MsgPlaceOrder:
orderId = msg.Order.OrderId
ctx.Logger().Info("roycloblog", "order_id", orderIdStr(orderId, "place"), "block_height", ctx.BlockHeight())
}

if ctx, err = h.clobRateLimit.AnteHandle(ctx, tx, simulate, noOpAnteHandle); err != nil {
return ctx, err
Expand Down

0 comments on commit 755a67b

Please sign in to comment.