Skip to content

Commit f85d3f6

Browse files
committed
Use const
1 parent 6470abe commit f85d3f6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

x/wasm/keeper/handler_plugin_encoders.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ import (
2424
"github.com/CosmWasm/wasmd/x/wasm/types"
2525
)
2626

27+
// anyMsgGasCost is the gas cost for unpacking an AnyMsg, in CosmWasm gas units (not SDK gas units).
28+
// With the default gas multiplier, this amounts to 5 SDK gas.
29+
const anyMsgGasCost = 700000
30+
2731
type (
2832
BankEncoder func(sender sdk.AccAddress, msg *wasmvmtypes.BankMsg) ([]sdk.Msg, error)
2933
CustomEncoder func(sender sdk.AccAddress, msg json.RawMessage) ([]sdk.Msg, error)
@@ -213,7 +217,7 @@ func EncodeAnyMsg(unpacker codectypes.AnyUnpacker) AnyEncoder {
213217
}
214218
var sdkMsg sdk.Msg
215219

216-
ctx.GasMeter().ConsumeGas(700000/types.DefaultGasMultiplier, "unpacking AnyMsg")
220+
ctx.GasMeter().ConsumeGas(anyMsgGasCost/types.DefaultGasMultiplier, "unpacking AnyMsg")
217221
if err := unpacker.UnpackAny(&codecAny, &sdkMsg); err != nil {
218222
return nil, errorsmod.Wrap(types.ErrInvalidMsg, fmt.Sprintf("Cannot unpack proto message with type URL: %s", msg.TypeURL))
219223
}

0 commit comments

Comments
 (0)