From 0c8549b871146472eb8c272b8426ec94376eca41 Mon Sep 17 00:00:00 2001 From: Alain Mebsout Date: Thu, 28 Jun 2018 01:40:32 +0200 Subject: [PATCH] Alpha: remove minimal serialization gas computation --- src/proto_alpha/lib_protocol/src/alpha_context.mli | 1 - src/proto_alpha/lib_protocol/src/script_repr.ml | 12 ------------ src/proto_alpha/lib_protocol/src/script_repr.mli | 2 -- src/proto_alpha/lib_protocol/src/storage.ml | 5 ++--- 4 files changed, 2 insertions(+), 18 deletions(-) diff --git a/src/proto_alpha/lib_protocol/src/alpha_context.mli b/src/proto_alpha/lib_protocol/src/alpha_context.mli index 017e73adf..668758e35 100644 --- a/src/proto_alpha/lib_protocol/src/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/src/alpha_context.mli @@ -304,7 +304,6 @@ module Script : sig val force_decode : lazy_expr -> (expr * Gas.cost) tzresult val force_bytes : lazy_expr -> (MBytes.t * Gas.cost) tzresult val minimal_deserialize_cost : lazy_expr -> Gas.cost - val minimal_serialize_cost : lazy_expr -> Gas.cost end module Constants : sig diff --git a/src/proto_alpha/lib_protocol/src/script_repr.ml b/src/proto_alpha/lib_protocol/src/script_repr.ml index bdad89873..d0f0d2948 100644 --- a/src/proto_alpha/lib_protocol/src/script_repr.ml +++ b/src/proto_alpha/lib_protocol/src/script_repr.ml @@ -132,15 +132,3 @@ let minimal_deserialize_cost lexpr = (fun b -> alloc_bytes_cost (MBytes.length b)) (fun c_free _ -> c_free) lexpr - -let minimal_serialize_cost lexpr = - let open Gas_limit_repr in - Data_encoding.fold_lazy - (fun v -> - let blocks, _words = expr_size v in - step_cost blocks +@ - alloc_bytes_cost blocks (* TODO *) - ) - (fun _ -> Gas_limit_repr.free) - (fun _ c_free -> c_free) - lexpr diff --git a/src/proto_alpha/lib_protocol/src/script_repr.mli b/src/proto_alpha/lib_protocol/src/script_repr.mli index 8299c38ff..eb319a201 100644 --- a/src/proto_alpha/lib_protocol/src/script_repr.mli +++ b/src/proto_alpha/lib_protocol/src/script_repr.mli @@ -40,5 +40,3 @@ val force_decode : lazy_expr -> (expr * Gas_limit_repr.cost) tzresult val force_bytes : lazy_expr -> (MBytes.t * Gas_limit_repr.cost) tzresult val minimal_deserialize_cost : lazy_expr -> Gas_limit_repr.cost - -val minimal_serialize_cost : lazy_expr -> Gas_limit_repr.cost diff --git a/src/proto_alpha/lib_protocol/src/storage.ml b/src/proto_alpha/lib_protocol/src/storage.ml index f425e4e01..e34bbdeba 100644 --- a/src/proto_alpha/lib_protocol/src/storage.ml +++ b/src/proto_alpha/lib_protocol/src/storage.ml @@ -159,9 +159,8 @@ module Contract = struct let consume_serialize_gas ctxt value = Lwt.return @@ - ( Raw_context.consume_gas ctxt (Script_repr.minimal_serialize_cost value) >>? fun _ -> - Script_repr.force_bytes value >>? fun (_value, value_cost) -> - Raw_context.consume_gas ctxt value_cost) + (Script_repr.force_bytes value >>? fun (_value, value_cost) -> + Raw_context.consume_gas ctxt value_cost) let get ctxt contract = get ctxt contract >>=? fun (ctxt, value) ->