Skip to content

Commit 2fad356

Browse files
committed
Use more realistic humanize and canonicalize mock cost
1 parent e50490c commit 2fad356

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

packages/vm/src/instance.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ mod tests {
914914

915915
let report2 = instance.create_gas_report();
916916
assert_eq!(report2.used_externally, 251);
917-
assert_eq!(report2.used_internally, 9589728);
917+
assert_eq!(report2.used_internally, 12109530);
918918
assert_eq!(report2.limit, LIMIT);
919919
assert_eq!(
920920
report2.remaining,
@@ -1105,7 +1105,7 @@ mod tests {
11051105
.unwrap();
11061106

11071107
let init_used = orig_gas - instance.get_gas_left();
1108-
assert_eq!(init_used, 9589979);
1108+
assert_eq!(init_used, 12109781);
11091109
}
11101110

11111111
#[test]

packages/vm/src/testing/mock.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,13 @@ use crate::backend::unwrap_or_return_with_gas;
1111
use crate::{Backend, BackendApi, BackendError, BackendResult, GasInfo};
1212

1313
pub const MOCK_CONTRACT_ADDR: &str = "cosmwasmcontract"; // TODO: use correct address
14-
const GAS_COST_HUMANIZE: u64 = 44; // TODO: these seem very low
15-
const GAS_COST_CANONICALIZE: u64 = 55;
14+
/// Default gas multiplier in wasmd.
15+
/// See https://github.com/CosmWasm/wasmd/blob/v0.51.0/x/wasm/types/gas_register.go#L34
16+
const WASMD_GAS_MULTIPLIER: u64 = 140_000;
17+
/// See https://github.com/CosmWasm/wasmd/blob/v0.51.0/x/wasm/keeper/api.go#L27
18+
const GAS_COST_HUMANIZE: u64 = 4 * WASMD_GAS_MULTIPLIER;
19+
/// See https://github.com/CosmWasm/wasmd/blob/v0.51.0/x/wasm/keeper/api.go#L28
20+
const GAS_COST_CANONICALIZE: u64 = 5 * WASMD_GAS_MULTIPLIER;
1621

1722
/// Default prefix used when creating Bech32 encoded address.
1823
const BECH32_PREFIX: &str = "cosmwasm";

0 commit comments

Comments
 (0)