From c1f36a5ad270fdcf5b18ab47e6026931ad5a1480 Mon Sep 17 00:00:00 2001 From: Vincent Botbol Date: Tue, 31 Jul 2018 16:47:44 +0200 Subject: [PATCH] Alpha/Accuser: ensure that double endorsements denunciations happens only when endorsement are not from the same branch --- src/proto_alpha/lib_delegate/client_baking_denunciation.ml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/proto_alpha/lib_delegate/client_baking_denunciation.ml b/src/proto_alpha/lib_delegate/client_baking_denunciation.ml index cb481ecfd..6b00e84b9 100644 --- a/src/proto_alpha/lib_delegate/client_baking_denunciation.ml +++ b/src/proto_alpha/lib_delegate/client_baking_denunciation.ml @@ -94,7 +94,8 @@ let process_endorsements (cctxt : #Proto_alpha.full) state ~chain begin match Delegate_Map.find_opt delegate map with | None -> return @@ HLevel.add state.endorsements_table level (Delegate_Map.add delegate new_endorsement map) - | Some existing_endorsement -> + | Some existing_endorsement when + Block_hash.(existing_endorsement.shell.branch <> new_endorsement.shell.branch) -> get_block_offset level >>= fun block -> (* TODO : verify that the chains are coherent *) Alpha_block_services.hash cctxt ~chain:`Main ~block () >>=? fun block_hash -> @@ -115,6 +116,10 @@ let process_endorsements (cctxt : #Proto_alpha.full) state ~chain -% a Operation_hash.Logging.tag op_hash) >>= fun () -> return @@ HLevel.replace state.endorsements_table level (Delegate_Map.add delegate new_endorsement map) + | Some _ -> + (* This endorsement is already present in another + block but endorse the same predecessor *) + return_unit end | _ -> lwt_log_error Tag.DSL.(fun f ->