From 2404246fb33517748acbcaaf323bde1b3124879e Mon Sep 17 00:00:00 2001 From: Pierre Chambart Date: Fri, 1 Jun 2018 17:36:32 +0200 Subject: [PATCH] Alpha: Non implicit contracts cannot be removed --- .../lib_protocol/src/contract_storage.ml | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/proto_alpha/lib_protocol/src/contract_storage.ml b/src/proto_alpha/lib_protocol/src/contract_storage.ml index f311a5dc4..3908576c2 100644 --- a/src/proto_alpha/lib_protocol/src/contract_storage.ml +++ b/src/proto_alpha/lib_protocol/src/contract_storage.ml @@ -235,18 +235,22 @@ let create_implicit c manager ~balance = ~spendable:true ~delegatable:false let delete c contract = - Delegate_storage.remove c contract >>=? fun c -> - Storage.Contract.Balance.delete c contract >>=? fun c -> - Storage.Contract.Manager.delete c contract >>=? fun c -> - Storage.Contract.Spendable.del c contract >>= fun c -> - Storage.Contract.Delegatable.del c contract >>= fun c -> - Storage.Contract.Counter.delete 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_fees.remove c contract >>= fun c -> - Storage.Contract.Used_storage_space.remove c contract >>= fun c -> - Storage.Contract.Big_map.clear (c, contract) >>=? fun (c, _) -> - return c + match Contract_repr.is_implicit contract with + | None -> + (* For non implicit contract Big_map should be cleared *) + failwith "Non implicit contracts cannot be removed" + | Some _ -> + Delegate_storage.remove c contract >>=? fun c -> + Storage.Contract.Balance.delete c contract >>=? fun c -> + Storage.Contract.Manager.delete c contract >>=? fun c -> + Storage.Contract.Spendable.del c contract >>= fun c -> + Storage.Contract.Delegatable.del c contract >>= fun c -> + Storage.Contract.Counter.delete 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_fees.remove c contract >>= fun c -> + Storage.Contract.Used_storage_space.remove c contract >>= fun c -> + return c let allocated c contract = Storage.Contract.Counter.get_option c contract >>=? function