Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions x/compute/internal/keeper/handler_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -610,21 +610,6 @@ func (h SDKMessageHandler) handleSdkMessage(ctx sdk.Context, contractAddr sdk.Ad
return nil, sdkerrors.ErrUnknownRequest.Wrapf("can't route message %+v", msg)
}

// callDepthMessageHandler is a wrapper around a Messenger that checks the call depth before dispatching a message.
type callDepthMessageHandler struct {
Messenger
MaxCallDepth uint32
}

func (h callDepthMessageHandler) DispatchMsg(ctx sdk.Context, contractAddr sdk.AccAddress, contractIBCPortID string, msg v1wasmTypes.CosmosMsg) (events []sdk.Event, data [][]byte, err error) {
ctx, err = checkAndIncreaseCallDepth(ctx, h.MaxCallDepth)
if err != nil {
return nil, nil, err
}

return h.Messenger.DispatchMsg(ctx, contractAddr, contractIBCPortID, msg)
}

// convertWasmIBCTimeoutHeightToCosmosHeight converts a wasm type ibc timeout height to ibc module type height
func convertWasmIBCTimeoutHeightToCosmosHeight(ibcTimeoutBlock *v1wasmTypes.IBCTimeoutBlock) ibcclienttypes.Height {
if ibcTimeoutBlock == nil {
Expand Down
7 changes: 5 additions & 2 deletions x/compute/internal/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,6 @@ func NewKeeper(
LastMsgManager: lastMsgManager,
authority: authority,
}
// always wrap the messenger, even if it was replaced by an option
keeper.messenger = callDepthMessageHandler{keeper.messenger, keeper.maxCallDepth}
keeper.queryPlugins = DefaultQueryPlugins(govKeeper, distKeeper, mintKeeper, bankKeeper, stakingKeeper, queryRouter, &keeper, channelKeeper).Merge(customPlugins)

return keeper
Expand Down Expand Up @@ -1476,6 +1474,11 @@ func (k *Keeper) handleContractResponse(
}

responseHandler := NewContractResponseHandler(NewMessageDispatcher(k.messenger, k))
// keep track of call depth
ctx, err := checkAndIncreaseCallDepth(ctx, k.maxCallDepth)
if err != nil {
return nil, err
}
return responseHandler.Handle(ctx, contractAddr, ibcPort, msgs, data, ogTx, ogSigInfo)
}

Expand Down
2 changes: 1 addition & 1 deletion x/compute/internal/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
)

const (
DefaultMaxCallDepth = uint32(500)
DefaultMaxCallDepth = uint32(100)
defaultLRUCacheSize = uint64(0)
defaultEnclaveLRUCacheSize = uint16(100)
defaultQueryGasLimit = uint64(10_000_000)
Expand Down
Loading