From 455012d4e99f6981626cf90c862f6d57d8453182 Mon Sep 17 00:00:00 2001 From: Pierre Chambart Date: Sat, 23 Jun 2018 03:15:07 +0200 Subject: [PATCH] Do not burn when there is nothing to burn. It would fail when the contract is eliminated --- src/proto_alpha/lib_protocol/src/fees_storage.ml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/proto_alpha/lib_protocol/src/fees_storage.ml b/src/proto_alpha/lib_protocol/src/fees_storage.ml index 85933d491..2a2a9a7d4 100644 --- a/src/proto_alpha/lib_protocol/src/fees_storage.ml +++ b/src/proto_alpha/lib_protocol/src/fees_storage.ml @@ -39,9 +39,15 @@ let burn_fees_for_storage c ~payer = let cost_per_byte = Constants_storage.cost_per_byte c in Lwt.return (Tez_repr.(cost_per_byte *? (Z.to_int64 storage_space_to_pay))) >>=? fun to_burn -> (* Burning the fees... *) - trace Cannot_pay_storage_fee - (Contract_storage.spend_from_script c payer to_burn) >>=? fun c -> - return c + if Tez_repr.(to_burn = Tez_repr.zero) then + (* If the payer was was deleted by transfering all its balance, and no space was used, + burning zero would fail *) + return c + else + trace Cannot_pay_storage_fee + (Contract_storage.must_exist c payer >>=? fun () -> + Contract_storage.spend_from_script c payer to_burn) >>=? fun c -> + return c let with_fees_for_storage c ~payer f = Lwt.return (Raw_context.init_storage_space_to_pay c) >>=? fun c ->