Skip to content

Commit fbe365a

Browse files
authored
Merge pull request #1731 from scrtlabs/wasmd-fix
wasmd-patch
2 parents 021381f + b68e780 commit fbe365a

File tree

3 files changed

+6
-18
lines changed

3 files changed

+6
-18
lines changed

x/compute/internal/keeper/handler_plugin.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -610,21 +610,6 @@ func (h SDKMessageHandler) handleSdkMessage(ctx sdk.Context, contractAddr sdk.Ad
610610
return nil, sdkerrors.ErrUnknownRequest.Wrapf("can't route message %+v", msg)
611611
}
612612

613-
// callDepthMessageHandler is a wrapper around a Messenger that checks the call depth before dispatching a message.
614-
type callDepthMessageHandler struct {
615-
Messenger
616-
MaxCallDepth uint32
617-
}
618-
619-
func (h callDepthMessageHandler) DispatchMsg(ctx sdk.Context, contractAddr sdk.AccAddress, contractIBCPortID string, msg v1wasmTypes.CosmosMsg) (events []sdk.Event, data [][]byte, err error) {
620-
ctx, err = checkAndIncreaseCallDepth(ctx, h.MaxCallDepth)
621-
if err != nil {
622-
return nil, nil, err
623-
}
624-
625-
return h.Messenger.DispatchMsg(ctx, contractAddr, contractIBCPortID, msg)
626-
}
627-
628613
// convertWasmIBCTimeoutHeightToCosmosHeight converts a wasm type ibc timeout height to ibc module type height
629614
func convertWasmIBCTimeoutHeightToCosmosHeight(ibcTimeoutBlock *v1wasmTypes.IBCTimeoutBlock) ibcclienttypes.Height {
630615
if ibcTimeoutBlock == nil {

x/compute/internal/keeper/keeper.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,6 @@ func NewKeeper(
165165
LastMsgManager: lastMsgManager,
166166
authority: authority,
167167
}
168-
// always wrap the messenger, even if it was replaced by an option
169-
keeper.messenger = callDepthMessageHandler{keeper.messenger, keeper.maxCallDepth}
170168
keeper.queryPlugins = DefaultQueryPlugins(govKeeper, distKeeper, mintKeeper, bankKeeper, stakingKeeper, queryRouter, &keeper, channelKeeper).Merge(customPlugins)
171169

172170
return keeper
@@ -1476,6 +1474,11 @@ func (k *Keeper) handleContractResponse(
14761474
}
14771475

14781476
responseHandler := NewContractResponseHandler(NewMessageDispatcher(k.messenger, k))
1477+
// keep track of call depth
1478+
ctx, err := checkAndIncreaseCallDepth(ctx, k.maxCallDepth)
1479+
if err != nil {
1480+
return nil, err
1481+
}
14791482
return responseHandler.Handle(ctx, contractAddr, ibcPort, msgs, data, ogTx, ogSigInfo)
14801483
}
14811484

x/compute/internal/types/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
)
1818

1919
const (
20-
DefaultMaxCallDepth = uint32(500)
20+
DefaultMaxCallDepth = uint32(100)
2121
defaultLRUCacheSize = uint64(0)
2222
defaultEnclaveLRUCacheSize = uint16(100)
2323
defaultQueryGasLimit = uint64(10_000_000)

0 commit comments

Comments
 (0)