diff --git a/src/proto_alpha/lib_protocol/contract_storage.ml b/src/proto_alpha/lib_protocol/contract_storage.ml index 97d6c4d925b56ed6ae91023f793e089f4d9c64c6..b40489c5f0f4644a8e0edd1eef2445610e0772bb 100644 --- a/src/proto_alpha/lib_protocol/contract_storage.ml +++ b/src/proto_alpha/lib_protocol/contract_storage.ml @@ -443,14 +443,7 @@ let delete c contract = failwith "Non implicit contracts cannot be removed" | Some _ -> Contract_delegate_storage.unlink c contract >>=? fun c -> - Storage.Contract.Spendable_balance.remove_existing c contract - >>=? fun c -> - Contract_manager_storage.remove_existing c contract >>=? fun c -> - Storage.Contract.Counter.remove_existing c contract >>=? fun c -> - Storage.Contract.Code.remove c contract >>=? fun (c, _, _) -> - Storage.Contract.Storage.remove c contract >>=? fun (c, _, _) -> - Storage.Contract.Paid_storage_space.remove c contract >>= fun c -> - Storage.Contract.Used_storage_space.remove c contract >|= ok + Storage.Contract.remove c contract let allocated c contract = Storage.Contract.Spendable_balance.find c contract >>=? function diff --git a/src/proto_alpha/lib_protocol/storage.ml b/src/proto_alpha/lib_protocol/storage.ml index aa1b3825d99b75b9d2fb634e153c2a009344d202..9c152877f0ed1a741e931a3a063f1caaf846e168 100644 --- a/src/proto_alpha/lib_protocol/storage.ml +++ b/src/proto_alpha/lib_protocol/storage.ml @@ -188,6 +188,10 @@ module Contract = struct let list = Indexed_context.keys + let remove ctxt contract = + Raw_context.consume_gas ctxt (Storage_costs.write_access ~written_bytes:0) + >>?= fun ctxt -> Indexed_context.remove ctxt contract >|= ok + module Spendable_balance = Indexed_context.Make_map (struct diff --git a/src/proto_alpha/lib_protocol/storage.mli b/src/proto_alpha/lib_protocol/storage.mli index 4cefe26a75fd6072a2cfb14790ec74e8617ca2f5..69a5083d4d119848f4a08b825d5decd9ce5ee54c 100644 --- a/src/proto_alpha/lib_protocol/storage.mli +++ b/src/proto_alpha/lib_protocol/storage.mli @@ -69,6 +69,8 @@ module Contract : sig val list : Raw_context.t -> Contract_repr.t list Lwt.t + val remove : Raw_context.t -> Contract_repr.t -> Raw_context.t tzresult Lwt.t + (** The tez possessed by a contract and that can be used. A contract may also possess tez in frozen deposits. Empty balances (of zero tez) are only allowed for originated contracts, not for implicit