Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file p2p_errors.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* Copyright (c) 2020 Nomadic Labs <contact@nomadic-labs.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(************************ p2p io scheduler ********************************)typeerror+=Connection_closedtypeerror+=Connection_errorlet()=(* Connection closed *)register_error_kind`Permanent~id:"node.p2p_io_scheduler.connection_closed"~title:"Connection closed"~description:"IO error: connection with a peer is closed."~pp:(funppf()->Format.fprintfppf"IO error: connection with a peer is closed.")Data_encoding.empty(functionConnection_closed->Some()|_->None)(fun()->Connection_closed);register_error_kind`Permanent~id:"node.p2p_io_scheduler.connection_error"~title:"Connection error"~description:"IO error: connection error while reading from a peer."~pp:(funppf()->Format.fprintfppf"IO error: connection error while reading from a peer.")Data_encoding.empty(functionConnection_error->Some()|_->None)(fun()->Connection_error)(***************************** p2p socket *********************************)typeerror+=Decipher_errortypeerror+=Invalid_message_sizetypeerror+=Invalid_incoming_ciphertext_sizetypeerror+=Rejected_socket_connectiontypeerror+=|Rejected_by_nackof{motive:P2p_rejection.t;alternative_points:P2p_point.Id.tlistoption;}typeerror+=Rejected_no_common_protocolof{announced:Network_version.t}typeerror+=Decoding_errorofData_encoding.Binary.read_errortypeerror+=MyselfofP2p_connection.Id.ttypeerror+=Not_enough_proof_of_workofP2p_peer.Id.ttypeerror+=Invalid_authtypeerror+=Invalid_chunks_sizeof{value:int;min:int;max:int}let()=(* Decipher error *)register_error_kind`Permanent~id:"node.p2p_socket.decipher_error"~title:"Decipher error"~description:"An error occurred while deciphering."~pp:(funppf()->Format.fprintfppf"An error occurred while deciphering.")Data_encoding.empty(functionDecipher_error->Some()|_->None)(fun()->Decipher_error);(* Invalid message size *)register_error_kind`Permanent~id:"node.p2p_socket.invalid_message_size"~title:"Invalid message size"~description:"The size of the message to be written is invalid."~pp:(funppf()->Format.fprintfppf"The size of the message to be written is invalid.")Data_encoding.empty(functionInvalid_message_size->Some()|_->None)(fun()->Invalid_message_size);(* Invalid incoming ciphertext size *)register_error_kind`Permanent~id:"node.p2p_socket.invalid_incoming_ciphertext_size"~title:"Invalid incoming ciphertext size"~description:"The announced size for the incoming ciphertext is invalid."~pp:(funppf()->Format.fprintfppf"The announced size for the incoming ciphertext is invalid.")Data_encoding.empty(functionInvalid_incoming_ciphertext_size->Some()|_->None)(fun()->Invalid_incoming_ciphertext_size);(* Rejected socket connection *)register_error_kind`Permanent~id:"node.p2p_socket.rejected_socket_connection"~title:"Rejected socket connection"~description:"Rejected peer connection: rejected socket connection."~pp:(funppf()->Format.fprintfppf"Rejected peer connection: rejected socket connection.")Data_encoding.empty(functionRejected_socket_connection->Some()|_->None)(fun()->Rejected_socket_connection);(* Rejected socket connection, peer gave us with alternative points *)register_error_kind`Permanent~id:"node.p2p_socket.rejected_by_nack"~title:"Rejected socket connection by Nack"~description:"Rejected peer connection: The peer rejected the socket connection by \
Nack with a list of alternative peers."~pp:(funppf(motive,alt_points)->Format.fprintfppf"Rejected peer connection: Peer rejected us on motive \"%a\" and \
proposed %a alternative peers."P2p_rejection.ppmotive(funppfalt_points->matchalt_pointswith|None->Format.pp_print_stringppf"no"|Somel->Format.pp_print_intppf@@List.lengthl)alt_points)Data_encoding.(obj2(req"motive"P2p_rejection.encoding)(opt"alternative_points"(listP2p_point.Id.encoding)))(function|Rejected_by_nack{motive;alternative_points}->Some(motive,alternative_points)|_->None)(fun(motive,alternative_points)->Rejected_by_nack{motive;alternative_points});(* Rejected socket connection, no common network protocol *)register_error_kind`Permanent~id:"node.p2p_socket.rejected_no_common_protocol"~title:"Rejected socket connection - no common network protocol"~description:"Rejected peer connection: rejected socket connection as we have no \
common network protocol with the peer."~pp:(funppf_lst->Format.fprintfppf"Rejected peer connection: no common network protocol.")Data_encoding.(obj1(req"announced_version"Network_version.encoding))(function|Rejected_no_common_protocol{announced}->Someannounced|_->None)(funannounced->Rejected_no_common_protocol{announced});(* Decoding error *)register_error_kind`Permanent~id:"node.p2p_socket.decoding_error"~title:"Decoding error"~description:"An error occurred while decoding."~pp:(funppfre->Format.fprintfppf"An error occurred while decoding: %a."Data_encoding.Binary.pp_read_errorre)Data_encoding.(obj1@@req"read_error"Binary.read_error_encoding)(functionDecoding_errorre->Somere|_->None)(funre->Decoding_errorre);(* Myself *)register_error_kind`Permanent~id:"node.p2p_socket.myself"~title:"Myself"~description:"Remote peer is actually yourself."~pp:(funppfid->Format.fprintfppf"Remote peer %a cannot be authenticated: peer is actually yourself."P2p_connection.Id.ppid)Data_encoding.(obj1(req"connection_id"P2p_connection.Id.encoding))(functionMyselfid->Someid|_->None)(funid->Myselfid);(* Not enough proof of work *)register_error_kind`Permanent~id:"node.p2p_socket.not_enough_proof_of_work"~title:"Not enough proof of work"~description:"Remote peer cannot be authenticated: not enough proof of work."~pp:(funppfid->Format.fprintfppf"Remote peer %a cannot be authenticated: not enough proof of work."P2p_peer.Id.ppid)Data_encoding.(obj1(req"peer_id"P2p_peer.Id.encoding))(functionNot_enough_proof_of_workid->Someid|_->None)(funid->Not_enough_proof_of_workid);(* Invalid authentication *)register_error_kind`Permanent~id:"node.p2p_socket.invalid_auth"~title:"Invalid authentication"~description:"Rejected peer connection: invalid authentication."~pp:(funppf()->Format.fprintfppf"Rejected peer connection: invalid authentication.")Data_encoding.empty(functionInvalid_auth->Some()|_->None)(fun()->Invalid_auth);(* Invalid chunks size *)register_error_kind`Permanent~id:"node.p2p_socket.invalid_chunks_size"~title:"Invalid chunks size"~description:"Size of chunks is not valid."~pp:(funppf(value,min,max)->Format.fprintfppf"Size of chunks is invalid: should be between %d and %d but is %d"minmaxvalue)Data_encoding.(obj3(req"value"int31)(req"min"int31)(req"max"int31))(function|Invalid_chunks_size{value;min;max}->Some(value,min,max)|_->None)(fun(value,min,max)->Invalid_chunks_size{value;min;max})(***************************** p2p pool ***********************************)typeerror+=Pending_connectiontypeerror+=Connectedtypeerror+=Connection_refusedtypeerror+=Rejectedof{peer:P2p_peer.Id.t;motive:P2p_rejection.t}typeerror+=Too_many_connectionstypeerror+=Private_modetypeerror+=Point_bannedofP2p_point.Id.ttypeerror+=Peer_bannedofP2p_peer.Id.ttypeerror+=P2p_layer_disabledtypeerror+=|Identity_check_failureof{point:P2p_point.Id.t;expected_peer_id:P2p_peer.Id.t;received_peer_id:P2p_peer.Id.t;}let()=(* Pending connection *)register_error_kind`Permanent~id:"node.p2p_pool.pending_connection"~title:"Pending connection"~description:"Fail to connect with a peer: a connection is already pending."~pp:(funppf()->Format.fprintfppf"Fail to connect with a peer: a connection is already pending.")Data_encoding.empty(functionPending_connection->Some()|_->None)(fun()->Pending_connection);(* Connected *)register_error_kind`Permanent~id:"node.p2p_pool.connected"~title:"Connected"~description:"Fail to connect with a peer: a connection is already established."~pp:(funppf()->Format.fprintfppf"Fail to connect with a peer: a connection is already established.")Data_encoding.empty(functionConnected->Some()|_->None)(fun()->Connected);(* Connected refused *)register_error_kind`Permanent~id:"node.p2p_pool.connection_refused"~title:"Connection refused"~description:"Connection was refused."~pp:(funppf()->Format.fprintfppf"Connection was refused.")Data_encoding.empty(functionConnection_refused->Some()|_->None)(fun()->Connection_refused);(* Rejected *)register_error_kind`Permanent~id:"node.p2p_pool.rejected"~title:"Rejected peer"~description:"Connection to peer was rejected by us."~pp:(funppf(peer,motive)->Format.fprintfppf"Connection to peer %a was rejected by us on motive: %a."P2p_peer.Id.pppeerP2p_rejection.ppmotive)Data_encoding.(obj2(req"peer_id"P2p_peer.Id.encoding)(req"motive"P2p_rejection.encoding))(functionRejected{peer;motive}->Some(peer,motive)|_->None)(fun(peer,motive)->Rejected{peer;motive});(* Too many connections *)register_error_kind`Permanent~id:"node.p2p_pool.too_many_connections"~title:"Too many connections"~description:"Too many connections."~pp:(funppf()->Format.fprintfppf"Too many connections.")Data_encoding.empty(functionToo_many_connections->Some()|_->None)(fun()->Too_many_connections);(* Private mode *)register_error_kind`Permanent~id:"node.p2p_pool.private_mode"~title:"Private mode"~description:"Node is in private mode."~pp:(funppf()->Format.fprintfppf"Node is in private mode.")Data_encoding.empty(functionPrivate_mode->Some()|_->None)(fun()->Private_mode);(* Point Banned *)register_error_kind`Permanent~id:"node.p2p_pool.point_banned"~title:"Point Banned"~description:"The address you tried to connect is banned."~pp:(funppf(addr,_port)->Format.fprintfppf"The address you tried to connect (%a) is banned."P2p_addr.ppaddr)Data_encoding.(obj1(req"point"P2p_point.Id.encoding))(functionPoint_bannedpoint->Somepoint|_->None)(funpoint->Point_bannedpoint);(* Peer Banned *)register_error_kind`Permanent~id:"node.p2p_pool.peer_banned"~title:"Peer Banned"~description:"The peer identity you tried to connect is banned."~pp:(funppfpeer_id->Format.fprintfppf"The peer identity you tried to connect (%a) is banned."P2p_peer.Id.pppeer_id)Data_encoding.(obj1(req"peer"P2p_peer.Id.encoding))(functionPeer_bannedpeer_id->Somepeer_id|_->None)(funpeer_id->Peer_bannedpeer_id);(* P2p_layer_disabled *)register_error_kind`Permanent~id:"node.p2p_pool.disabled"~title:"P2P layer disabled"~description:"The P2P layer on this node is not active."~pp:(funppf()->Format.fprintfppf"P2P layer disabled.")Data_encoding.empty(functionP2p_layer_disabled->Some()|_->None)(fun()->P2p_layer_disabled);register_error_kind`Permanent~id:"node.p2p_connect_handler.identity_check_failure"~title:"Unexpected peer identity"~description:"Peer announced an identity which does not match the one specified on \
the command-line."~pp:(funppf(point,expected_peer_id,received_peer_id)->Format.fprintfppf"For point `%a`: Expected peer identity `%a` and received peer \
identity `%a`."P2p_point.Id.pppointP2p_peer.Id.ppexpected_peer_idP2p_peer.Id.ppreceived_peer_id)Data_encoding.(obj3(req"point"P2p_point.Id.encoding)(req"expected_peer_id"P2p_peer.Id.encoding)(req"received_peer_id"P2p_peer.Id.encoding))(function|Identity_check_failure{point;expected_peer_id;received_peer_id}->Some(point,expected_peer_id,received_peer_id)|_->None)(fun(point,expected_peer_id,received_peer_id)->Identity_check_failure{point;expected_peer_id;received_peer_id})