Skip to content

Commit 881d6a7

Browse files
authored
Improve ToWasmVMGas/FromWasmVMGas code level documentation (#1564)
1 parent 7078c13 commit 881d6a7

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

x/wasm/keeper/gas_register.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,13 @@ type GasRegister interface {
8383
ReplyCosts(pinned bool, reply wasmvmtypes.Reply) sdk.Gas
8484
// EventCosts costs to persist an event
8585
EventCosts(attrs []wasmvmtypes.EventAttribute, events wasmvmtypes.Events) sdk.Gas
86-
// ToWasmVMGas converts from sdk gas to wasmvm gas
86+
// ToWasmVMGas converts from Cosmos SDK gas units to [CosmWasm gas] (aka. wasmvm gas)
87+
//
88+
// [CosmWasm gas]: https://github.com/CosmWasm/cosmwasm/blob/v1.3.1/docs/GAS.md
8789
ToWasmVMGas(source sdk.Gas) uint64
88-
// FromWasmVMGas converts from wasmvm gas to sdk gas
90+
// FromWasmVMGas converts from [CosmWasm gas] (aka. wasmvm gas) to Cosmos SDK gas units
91+
//
92+
// [CosmWasm gas]: https://github.com/CosmWasm/cosmwasm/blob/v1.3.1/docs/GAS.md
8993
FromWasmVMGas(source uint64) sdk.Gas
9094
}
9195

@@ -240,7 +244,9 @@ func calcWithFreeTier(storedBytes, freeTier uint64) (uint64, uint64) {
240244
return storedBytes, 0
241245
}
242246

243-
// ToWasmVMGas convert to wasmVM contract runtime gas unit
247+
// ToWasmVMGas converts from Cosmos SDK gas units to [CosmWasm gas] (aka. wasmvm gas)
248+
//
249+
// [CosmWasm gas]: https://github.com/CosmWasm/cosmwasm/blob/v1.3.1/docs/GAS.md
244250
func (g WasmGasRegister) ToWasmVMGas(source storetypes.Gas) uint64 {
245251
x := source * g.c.GasMultiplier
246252
if x < source {
@@ -249,7 +255,9 @@ func (g WasmGasRegister) ToWasmVMGas(source storetypes.Gas) uint64 {
249255
return x
250256
}
251257

252-
// FromWasmVMGas converts to SDK gas unit
258+
// FromWasmVMGas converts from [CosmWasm gas] (aka. wasmvm gas) to Cosmos SDK gas units
259+
//
260+
// [CosmWasm gas]: https://github.com/CosmWasm/cosmwasm/blob/v1.3.1/docs/GAS.md
253261
func (g WasmGasRegister) FromWasmVMGas(source uint64) sdk.Gas {
254262
return source / g.c.GasMultiplier
255263
}

0 commit comments

Comments
 (0)