Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file validation_errors.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* Copyright (c) 2020 Metastate AG <hello@metastate.dev> *)(* *)(* 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. *)(* *)(*****************************************************************************)(***************** Prevalidation errors ***********************************)typeerror+=Parse_errortypeerror+=Too_many_operationstypeerror+=Oversized_operationof{size:int;max:int}typeerror+=|Future_block_headerof{block:Block_hash.t;block_time:Time.Protocol.t;time:Time.System.t;}typeerror+=Cannot_serialize_operation_metadatalet()=(* Parse error *)register_error_kind`Permanent~id:"node.prevalidation.parse_error"~title:"Parsing error in prevalidation"~description:"Raised when an operation has not been parsed correctly during \
prevalidation."~pp:(funppf()->Format.fprintfppf"Operation parsing error in prevalidation.")Data_encoding.empty(functionParse_error->Some()|_->None)(fun()->Parse_error);(* Too many operations *)register_error_kind`Temporary~id:"node.prevalidation.too_many_operations"~title:"Too many pending operations in prevalidation"~description:"The prevalidation context is full."~pp:(funppf()->Format.fprintfppf"Too many operations in prevalidation context.")Data_encoding.empty(functionToo_many_operations->Some()|_->None)(fun()->Too_many_operations);(* Oversized operation *)register_error_kind`Permanent~id:"node.prevalidation.oversized_operation"~title:"Oversized operation"~description:"The operation size is bigger than allowed."~pp:(funppf(size,max)->Format.fprintfppf"Oversized operation (size: %d, max: %d)"sizemax)Data_encoding.(obj2(req"size"int31)(req"max_size"int31))(functionOversized_operation{size;max}->Some(size,max)|_->None)(fun(size,max)->Oversized_operation{size;max});(* Block from the future *)register_error_kind`Temporary~id:"node.prevalidation.future_block_header"~title:"Future block header"~description:"The block was annotated with a time too far in the future."~pp:(funppf(block,block_time,time)->Format.fprintfppf"Future block header (block: %a, block_time: %a, time: %a)"Block_hash.ppblockTime.System.pp_hum(Time.System.of_protocol_exnblock_time)Time.System.pp_humtime)Data_encoding.(obj3(req"block"Block_hash.encoding)(req"block_time"Time.Protocol.encoding)(req"time"Time.System.encoding))(function|Future_block_header{block;block_time;time}->Some(block,block_time,time)|_->None)(fun(block,block_time,time)->Future_block_header{block;block_time;time});Error_monad.register_error_kind`Permanent~id:"block_validation.cannot_serialize_metadata"~title:"Cannot serialize metadata"~description:"Unable to serialize metadata"~pp:(funppf()->Format.fprintfppf"Unable to serialize the metadata for an operation.")Data_encoding.empty(functionCannot_serialize_operation_metadata->Some()|_->None)(fun()->Cannot_serialize_operation_metadata)(************************* State errors ***********************************)typeerror+=Unknown_chainofChain_id.ttypeerror+=Bad_data_dirtypeerror+=Block_not_invalidofBlock_hash.tlet()=(* Unknown network *)register_error_kind`Permanent~id:"node.state.unknown_chain"~title:"Unknown chain"~description:"The chain identifier could not be found in the chain identifiers table."~pp:(funppfid->Format.fprintfppf"Unknown chain %a"Chain_id.ppid)Data_encoding.(obj1(req"chain"Chain_id.encoding))(functionUnknown_chainx->Somex|_->None)(funx->Unknown_chainx);register_error_kind`Permanent~id:"node.state.bad_data_dir"~title:"Bad data directory"~description:"The data directory could not be read. This could be because it was \
generated with an old version of the octez-node program. Deleting and \
regenerating this directory may fix the problem."~pp:(funppf()->Format.fprintfppf"Bad data directory.")Data_encoding.empty(functionBad_data_dir->Some()|_->None)(fun()->Bad_data_dir);(* Block not invalid *)register_error_kind`Permanent~id:"node.state.block_not_invalid"~title:"Block not invalid"~description:"The invalid block to be unmarked was not actually invalid."~pp:(funppfblock->Format.fprintfppf"Block %a was expected to be invalid, but was not actually invalid."Block_hash.ppblock)Data_encoding.(obj1(req"block"Block_hash.encoding))(functionBlock_not_invalidblock->Someblock|_->None)(funblock->Block_not_invalidblock)(* Block database error *)typeerror+=Inconsistent_hashofContext_hash.t*Context_hash.ttypeerror+=Missing_block_metadata_hashofBlock_hash.ttypeerror+=Missing_operation_metadata_hashesofBlock_hash.tlet()=(* Inconsistent hash *)register_error_kind`Permanent~id:"node.state.block.inconsistent_context_hash"~title:"Inconsistent commit hash"~description:"When committing the context of a block, the announced context hash was \
not the one computed at commit time."~pp:(funppf(got,exp)->Format.fprintfppf"@[<v 2>Inconsistent hash:@ got: %a@ expected: %a"Context_hash.ppgotContext_hash.ppexp)Data_encoding.(obj2(req"wrong_context_hash"Context_hash.encoding)(req"expected_context_hash"Context_hash.encoding))(functionInconsistent_hash(got,exp)->Some(got,exp)|_->None)(fun(got,exp)->Inconsistent_hash(got,exp));register_error_kind`Permanent~id:"node.state.block.missing_block_metadata_hash"~title:"Missing block metadata hash"~description:"A block was expected to commit to a block metadata hash, however none \
was given."~pp:(funppfblock->Format.fprintfppf"@[<v 2>Missing block metadata hash at block: %a"Block_hash.ppblock)Data_encoding.(obj1(req"block"Block_hash.encoding))(functionMissing_block_metadata_hashblock->Someblock|_->None)(funblock->Missing_block_metadata_hashblock);register_error_kind`Permanent~id:"node.state.block.missing_operation_metadata_hashes"~title:"Missing operation metadata hashes"~description:"A block was expected to commit to operation metadata hashes, however \
none were given."~pp:(funppfblock->Format.fprintfppf"@[<v 2>Missing operation metadata hashes at block: %a"Block_hash.ppblock)Data_encoding.(obj1(req"block"Block_hash.encoding))(function|Missing_operation_metadata_hashesblock->Someblock|_->None)(funblock->Missing_operation_metadata_hashesblock)(******************* Bootstrap pipeline errors ****************************)typeerror+=Invalid_locatorofP2p_peer.Id.t*Block_locator.ttypeerror+=Too_short_locatorofP2p_peer.Id.t*Block_locator.tlet()=(* Invalid locator *)register_error_kind`Permanent~id:"node.bootstrap_pipeline.invalid_locator"~title:"Invalid block locator"~description:"Block locator is invalid."~pp:(funppf(id,locator)->Format.fprintfppf"Invalid block locator on peer %a:\n%a"P2p_peer.Id.ppidBlock_locator.pplocator)Data_encoding.(obj2(req"id"P2p_peer.Id.encoding)(req"locator"Block_locator.encoding))(functionInvalid_locator(id,loc)->Some(id,loc)|_->None)(fun(id,loc)->Invalid_locator(id,loc));(* Too short locator *)register_error_kind`Permanent~id:"node.bootstrap_pipeline.too_short_locator"~title:"Too short locator"~description:"Block locator is too short."~pp:(funppf(id,locator)->Format.fprintfppf"Too short locator on peer %a:\n%a"P2p_peer.Id.ppidBlock_locator.pplocator)Data_encoding.(obj2(req"id"P2p_peer.Id.encoding)(req"locator"Block_locator.encoding))(functionToo_short_locator(id,loc)->Some(id,loc)|_->None)(fun(id,loc)->Too_short_locator(id,loc))(******************* Protocol validator errors ****************************)typeprotocol_error=Compilation_failed|Dynlinking_failedtypeerror+=|Invalid_protocolof{hash:Protocol_hash.t;error:protocol_error}letprotocol_error_encoding=letopenData_encodinginunion[case(Tag0)~title:"Compilation failed"(obj1(req"error"(constant"compilation_failed")))(functionCompilation_failed->Some()|_->None)(fun()->Compilation_failed);case(Tag1)~title:"Dynlinking failed"(obj1(req"error"(constant"dynlinking_failed")))(functionDynlinking_failed->Some()|_->None)(fun()->Dynlinking_failed);]letpp_protocol_errorppf=function|Compilation_failed->Format.fprintfppf"compilation error"|Dynlinking_failed->Format.fprintfppf"dynlinking error"let()=(* Invalid protocol *)register_error_kind`Permanent~id:"node.protocol_validator.invalid_protocol"~title:"Invalid protocol"~description:"Invalid protocol."~pp:(funppf(protocol,error)->Format.fprintfppf"@[<v 2>Invalid protocol %a@ %a@]"Protocol_hash.pp_shortprotocolpp_protocol_errorerror)Data_encoding.(merge_objs(obj1(req"invalid_protocol"Protocol_hash.encoding))protocol_error_encoding)(function|Invalid_protocol{hash;error}->Some(hash,error)|_->None)(fun(hash,error)->Invalid_protocol{hash;error})typeerror+=Cannot_load_protocolofProtocol_hash.tlet()=register_error_kind`Permanent~id:"node.protocol_validator.cannot_load_protocol"~title:"Cannot load protocol"~description:"Cannot load protocol from disk"~pp:(funppfprotocol->Format.fprintfppf"Failed to load the protocol %a from disk: the corresponding files \
might be missing or corrupted."Protocol_hash.ppprotocol)Data_encoding.(obj1(req"protocol"Protocol_hash.encoding))(functionCannot_load_protocolprotocol->Someprotocol|_->None)(funprotocol->Cannot_load_protocolprotocol)(********************* Peer validator errors ******************************)typeerror+=Unknown_ancestor|Known_invalidlet()=(* Unknown ancestor *)register_error_kind`Permanent~id:"node.peer_validator.unknown_ancestor"~title:"Unknown ancestor"~description:"Unknown ancestor block found in the peer's chain"~pp:(funppf()->Format.fprintfppf"Unknown ancestor")Data_encoding.empty(functionUnknown_ancestor->Some()|_->None)(fun()->Unknown_ancestor);(* Known invalid *)register_error_kind`Permanent~id:"node.peer_validator.known_invalid"~title:"Known invalid"~description:"Known invalid block found in the peer's chain"~pp:(funppf()->Format.fprintfppf"Known invalid")Data_encoding.empty(functionKnown_invalid->Some()|_->None)(fun()->Known_invalid)(************************ Validator errors ********************************)typeerror+=Inactive_chainofChain_id.ttypeerror+=Checkpoint_errorofBlock_hash.t*P2p_peer.Id.toptionlet()=(* Inactive network *)register_error_kind`Branch~id:"node.validator.inactive_chain"~title:"Inactive chain"~description:"Attempted validation of a block from an inactive chain."~pp:(funppfchain->Format.fprintfppf"Tried to validate a block from chain %a, that is not currently \
considered active."Chain_id.ppchain)Data_encoding.(obj1(req"inactive_chain"Chain_id.encoding))(functionInactive_chainchain->Somechain|_->None)(funchain->Inactive_chainchain);register_error_kind`Branch~id:"node.validator.checkpoint_error"~title:"Block incompatible with the current checkpoint."~description:"The block belongs to a branch that is not compatible with the current \
checkpoint."~pp:(funppf(block,peer)->matchpeerwith|None->Format.fprintfppf"The block %a is incompatible with the current checkpoint."Block_hash.pp_shortblock|Somepeer->Format.fprintfppf"The peer %a send us a block which is a sibling of the configured \
checkpoint (%a)."P2p_peer.Id.pppeerBlock_hash.pp_shortblock)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))