From 8a8912c9bd96399e59bbcbd6a8f2d9875eab088d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Fri, 23 Nov 2018 17:44:29 +0100 Subject: [PATCH] Mempool: correctly filter out endorsement without bond --- src/proto_alpha/lib_protocol/src/apply.ml | 13 +++++++++---- .../lib_protocol/src/helpers_services.ml | 2 +- src/proto_alpha/lib_protocol/src/main.ml | 8 +++++++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/proto_alpha/lib_protocol/src/apply.ml b/src/proto_alpha/lib_protocol/src/apply.ml index 4b60879ec..307025d77 100644 --- a/src/proto_alpha/lib_protocol/src/apply.ml +++ b/src/proto_alpha/lib_protocol/src/apply.ml @@ -738,7 +738,7 @@ let apply_manager_contents_list ctxt mode baker contents_list = | `Success ctxt -> Lwt.return (ctxt, results) let apply_contents_list - (type kind) ctxt chain_id mode pred_block baker + (type kind) ctxt ~partial chain_id mode pred_block baker (operation : kind operation) (contents_list : kind contents_list) : (context * kind contents_result_list) tzresult Lwt.t = @@ -761,7 +761,12 @@ let apply_contents_list Lwt.return Tez.(Constants.endorsement_security_deposit ctxt *? Int64.of_int gap) >>=? fun deposit -> - add_deposit ctxt delegate deposit >>=? fun ctxt -> + begin + if partial then + Delegate.freeze_deposit ctxt delegate deposit + else + add_deposit ctxt delegate deposit + end >>=? fun ctxt -> Global.get_last_block_priority ctxt >>=? fun block_priority -> Baking.endorsement_reward ctxt ~block_priority gap >>=? fun reward -> Delegate.freeze_rewards ctxt delegate reward >>=? fun ctxt -> @@ -912,10 +917,10 @@ let apply_contents_list apply_manager_contents_list ctxt mode baker op >>= fun (ctxt, result) -> return (ctxt, result) -let apply_operation ctxt chain_id mode pred_block baker hash operation = +let apply_operation ctxt ~partial chain_id mode pred_block baker hash operation = let ctxt = Contract.init_origination_nonce ctxt hash in apply_contents_list - ctxt chain_id mode pred_block baker operation + ctxt ~partial chain_id mode pred_block baker operation operation.protocol_data.contents >>=? fun (ctxt, result) -> let ctxt = Gas.set_unlimited ctxt in let ctxt = Contract.unset_origination_nonce ctxt in diff --git a/src/proto_alpha/lib_protocol/src/helpers_services.ml b/src/proto_alpha/lib_protocol/src/helpers_services.ml index e78a590b2..12a8fcf99 100644 --- a/src/proto_alpha/lib_protocol/src/helpers_services.ml +++ b/src/proto_alpha/lib_protocol/src/helpers_services.ml @@ -299,7 +299,7 @@ module Scripts = struct return result | _ -> Apply.apply_contents_list - ctxt Chain_id.zero Optimized shell.branch baker operation + ctxt ~partial:true Chain_id.zero Optimized shell.branch baker operation operation.protocol_data.contents >>=? fun (_ctxt, result) -> return result diff --git a/src/proto_alpha/lib_protocol/src/main.ml b/src/proto_alpha/lib_protocol/src/main.ml index 3156e6c7a..f5f8a656c 100644 --- a/src/proto_alpha/lib_protocol/src/main.ml +++ b/src/proto_alpha/lib_protocol/src/main.ml @@ -192,7 +192,13 @@ let apply_operation | Partial_construction { predecessor } -> predecessor, Signature.Public_key_hash.zero in - Apply.apply_operation ctxt chain_id Optimized predecessor baker + let partial = + match mode with + | Partial_construction _ + | Partial_application _ -> true + | Application _ + | Full_construction _ -> false in + Apply.apply_operation ~partial ctxt chain_id Optimized predecessor baker (Alpha_context.Operation.hash operation) operation >>=? fun (ctxt, result) -> let op_count = op_count + 1 in