Skip to content

Commit

Permalink
Move AddPersistentTagsToLogger out of the CheckTx global lock
Browse files Browse the repository at this point in the history
  • Loading branch information
roy-dydx committed Apr 3, 2024
1 parent c025d28 commit 0bf993b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 21 deletions.
1 change: 1 addition & 0 deletions .github/workflows/protocol-build-and-push-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Protocol Build & Push Image to AWS ECR
on: # yamllint disable-line rule:truthy
push:
branches:
- roy/msgser
- main
- 'release/[a-z]+/v0.[0-9]+.x' # e.g. release/protocol/v0.1.x
- 'release/[a-z]+/v[0-9]+.x' # e.g. release/protocol/v1.x
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/protocol-build-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Protocol Build & Push Image to AWS ECR
on: # yamllint disable-line rule:truthy
push:
branches:
- roy/msgser
- main
- 'release/[a-z]+/v0.[0-9]+.x' # e.g. release/protocol/v0.1.x
- 'release/[a-z]+/v[0-9]+.x' # e.g. release/protocol/v1.x
Expand Down
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 @@ -63,20 +63,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 @@ -96,9 +84,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)

Expand Down Expand Up @@ -137,11 +122,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 0bf993b

Please sign in to comment.