From e81b045d4218a044210851bfac70f3d0742119d3 Mon Sep 17 00:00:00 2001 From: Alain Mebsout Date: Fri, 29 Jun 2018 15:51:27 +0200 Subject: [PATCH] Alpha: minor adjustments to gas costs --- src/bin_client/test/test_contracts.sh | 2 +- src/proto_alpha/lib_protocol/src/gas_limit_repr.ml | 4 ++-- .../lib_protocol/src/michelson_v1_gas.ml | 14 +++++++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/bin_client/test/test_contracts.sh b/src/bin_client/test/test_contracts.sh index ea715dac6..0513124c9 100755 --- a/src/bin_client/test/test_contracts.sh +++ b/src/bin_client/test/test_contracts.sh @@ -210,7 +210,7 @@ assert_storage $contract_dir/exec_concat.tz '"?"' '""' '"_abc"' assert_storage $contract_dir/exec_concat.tz '"?"' '"test"' '"test_abc"' # Get current steps to quota -assert_storage $contract_dir/steps_to_quota.tz 111 Unit 399815 +assert_storage $contract_dir/steps_to_quota.tz 111 Unit 399813 # Gas bounds checks assert_fails $client -l originate contract first_explosion for bootstrap1 \ diff --git a/src/proto_alpha/lib_protocol/src/gas_limit_repr.ml b/src/proto_alpha/lib_protocol/src/gas_limit_repr.ml index 085c1cfa9..1960c71b8 100644 --- a/src/proto_alpha/lib_protocol/src/gas_limit_repr.ml +++ b/src/proto_alpha/lib_protocol/src/gas_limit_repr.ml @@ -112,10 +112,10 @@ let alloc_cost n = bytes_written = Z.zero } let alloc_bytes_cost n = - alloc_cost (n / 8) + alloc_cost ((n + 7) / 8) let alloc_bits_cost n = - alloc_cost (n / 64) + alloc_cost ((n + 63) / 64) let step_cost n = { allocations = Z.zero ; diff --git a/src/proto_alpha/lib_protocol/src/michelson_v1_gas.ml b/src/proto_alpha/lib_protocol/src/michelson_v1_gas.ml index 1cf4537ba..61be2f502 100644 --- a/src/proto_alpha/lib_protocol/src/michelson_v1_gas.ml +++ b/src/proto_alpha/lib_protocol/src/michelson_v1_gas.ml @@ -71,9 +71,9 @@ module Cost_of = struct let map_size = step_cost 2 - let big_map_mem _key _map = step_cost 200 - let big_map_get _key _map = step_cost 200 - let big_map_update _key _value _map = step_cost 200 + let big_map_mem _key _map = step_cost 50 + let big_map_get _key _map = step_cost 50 + let big_map_update _key _value _map = step_cost 10 let set_access : type elt. elt -> elt Script_typed_ir.set -> int = fun _key (module Box) -> @@ -186,7 +186,7 @@ module Cost_of = struct let set_delegate = step_cost 10 +@ write_bytes_cost (Z.of_int 32) let balance = step_cost 1 +@ read_bytes_cost (Z.of_int 8) let now = step_cost 5 - let check_signature = step_cost 100 + let check_signature = step_cost 1000 let hash_key = step_cost 3 +@ bytes 20 let hash data len = 10 *@ step_cost (MBytes.length data) +@ bytes len let steps_to_quota = step_cost 1 @@ -195,11 +195,11 @@ module Cost_of = struct let amount = step_cost 1 let compare_bool _ _ = step_cost 1 let compare_string s1 s2 = - step_cost (Compare.Int.max (String.length s1) (String.length s2) / 8) +@ step_cost 1 + step_cost ((7 + Compare.Int.max (String.length s1) (String.length s2)) / 8) +@ step_cost 1 let compare_bytes s1 s2 = - step_cost (Compare.Int.max (MBytes.length s1) (MBytes.length s2) / 8) +@ step_cost 1 + step_cost ((7 + Compare.Int.max (MBytes.length s1) (MBytes.length s2)) / 8) +@ step_cost 1 let compare_tez _ _ = step_cost 1 - let compare_zint n1 n2 = step_cost (Compare.Int.max (Z.numbits n1) (Z.numbits n2) / 8) +@ step_cost 1 + let compare_zint n1 n2 = step_cost ((7 + Compare.Int.max (Z.numbits n1) (Z.numbits n2)) / 8) +@ step_cost 1 let compare_int n1 n2 = compare_zint (Script_int.to_zint n1) (Script_int.to_zint n2) let compare_nat = compare_int let compare_key_hash _ _ = alloc_bytes_cost 36