diff --git a/src/lib_shell_services/validation_errors.ml b/src/lib_shell_services/validation_errors.ml index 5331ea787..dc050b8d9 100644 --- a/src/lib_shell_services/validation_errors.ml +++ b/src/lib_shell_services/validation_errors.ml @@ -231,6 +231,7 @@ let () = (************************ Validator errors ********************************) type error += Inactive_chain of Chain_id.t +type error += Checkpoint_error of Block_hash.t * P2p_peer.Id.t option let () = (* Inactive network *) @@ -246,4 +247,28 @@ let () = Chain_id.pp chain) Data_encoding.(obj1 (req "inactive_chain" Chain_id.encoding)) (function Inactive_chain chain -> Some chain | _ -> None) - (fun chain -> Inactive_chain chain) + (fun chain -> Inactive_chain chain) ; + register_error_kind + `Branch + ~id:"node.validator.checkpoint_error" + ~title: "Block incompatble with the current checkpoint." + ~description: "The block belongs to a branch that is not compatible \ + with the current checkpoint." + ~pp: (fun ppf (block, peer) -> + match peer with + | None -> + Format.fprintf ppf + "The block %a is incompatible with the current checkpoint." + Block_hash.pp_short block + | Some peer -> + Format.fprintf ppf + "The peer %a send us a block which is a sibling \ + of the configured checkpoint (%a)." + P2p_peer.Id.pp peer + Block_hash.pp_short block) + Data_encoding.(obj2 + (req "block" Block_hash.encoding) + (opt "peer" P2p_peer.Id.encoding)) + (function Checkpoint_error (block, peer) -> Some (block, peer) | _ -> None) + (fun (block, peer) -> Checkpoint_error (block, peer)) + diff --git a/src/lib_shell_services/validation_errors.mli b/src/lib_shell_services/validation_errors.mli index f1e0a3254..3cbe7b0ee 100644 --- a/src/lib_shell_services/validation_errors.mli +++ b/src/lib_shell_services/validation_errors.mli @@ -45,3 +45,4 @@ type error += (************************ Validator errors ********************************) type error += Inactive_chain of Chain_id.t +type error += Checkpoint_error of Block_hash.t * P2p_peer.Id.t option