From 2fbc60af7522c4e315e00904c6b4164f9eb359cd Mon Sep 17 00:00:00 2001 From: Milo Davis Date: Thu, 15 Mar 2018 01:05:31 -0400 Subject: [PATCH] Michelson: make maximum integer for gas 32 bit compatible (#169) --- src/proto_alpha/lib_protocol/src/gas.ml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/proto_alpha/lib_protocol/src/gas.ml b/src/proto_alpha/lib_protocol/src/gas.ml index 31548fff6..cefc7deeb 100644 --- a/src/proto_alpha/lib_protocol/src/gas.ml +++ b/src/proto_alpha/lib_protocol/src/gas.ml @@ -232,18 +232,20 @@ module Cost_of = struct | None -> default | Some x -> x + let max_int = 1073741823 + let shift_left x y = (alloc_cost @@ words_of_bits @@ let (+) = Pervasives.(+) in Z.numbits (Script_int.to_zint x) + - (unopt (Script_int.to_int y) ~default:2147483647)) + (unopt (Script_int.to_int y) ~default:max_int)) let shift_right x y = (alloc_cost @@ words_of_bits @@ max 1 @@ let (-) = Pervasives.(-) in Z.numbits (Script_int.to_zint x) - - unopt (Script_int.to_int y) ~default:2147483647) + unopt (Script_int.to_int y) ~default:max_int) let exec = step_cost 1