1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2020-2021 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. *)(* *)(*****************************************************************************)typeerror+=|Block_not_foundof{hash:Block_hash.t;distance:int}|Resulting_context_hash_not_foundof{hash:Block_hash.t;level:int32}|Bad_levelof{head_level:Int32.t;given_level:Int32.t}|Block_metadata_not_foundofBlock_hash.t|Protocol_not_foundof{protocol_level:int}|Cannot_switch_history_modeof{previous_mode:History_mode.t;next_mode:History_mode.t;}|Invalid_head_switchof{checkpoint_level:int32;given_head:Block_hash.t*int32;}|Inconsistent_store_stateofstring|Inconsistent_operations_hashof{expected:Operation_list_list_hash.t;got:Operation_list_list_hash.t;}let()=register_error_kind`Permanent~id:"store.block_not_found"~title:"Block not found"~description:"Block not found"~pp:(funppf(block_hash,distance)->Format.fprintfppf"Cannot find block at distance %d from block %a."distanceBlock_hash.ppblock_hash)Data_encoding.(obj1(req"block_not_found"@@tup2Block_hash.encodingint31))(function|Block_not_found{hash;distance}->Some(hash,distance)|_->None)(fun(hash,distance)->Block_not_found{hash;distance});register_error_kind`Permanent~id:"store.resulting_context_hash_not_found"~title:"Resulting context hash not found"~description:"Resulting context hash not found"~pp:(funppf(block_hash,level)->Format.fprintfppf"Cannot find the resulting context hash for the block %a (level: %ld)."Block_hash.ppblock_hashlevel)Data_encoding.(obj1(req"block_not_found"@@tup2Block_hash.encodingint32))(function|Resulting_context_hash_not_found{hash;level}->Some(hash,level)|_->None)(fun(hash,level)->Resulting_context_hash_not_found{hash;level});register_error_kind`Permanent~id:"store.bad_level"~title:"Bad level"~description:"Read a block at level past our current head."~pp:(funppf(head_level,given_level)->Format.fprintfppf"The block at level %ld is beyond our current head's level : %ld."given_levelhead_level)Data_encoding.(obj2(req"head_level"int32)(req"given_level"int32))(function|Bad_level{head_level;given_level}->Some(head_level,given_level)|_->None)(fun(head_level,given_level)->Bad_level{head_level;given_level});register_error_kind`Permanent~id:"store.metadata_not_found"~title:"Block metadata not found"~description:"Block metadata not found"~pp:(funppfblock_hash->Format.fprintfppf"Unable to find block %a's metadata."Block_hash.ppblock_hash)Data_encoding.(obj1(req"block_metadata_not_found"Block_hash.encoding))(function|Block_metadata_not_foundblock_hash->Someblock_hash|_->None)(funblock_hash->Block_metadata_not_foundblock_hash);register_error_kind`Permanent~id:"store.protocol_not_found"~title:"Protocol not found"~description:"Protocol not found"~pp:(funppfprotocol_level->Format.fprintfppf"Unable to find protocol %d."protocol_level)Data_encoding.(obj1(req"protocol_level"int31))(function|Protocol_not_found{protocol_level}->Someprotocol_level|_->None)(funprotocol_level->Protocol_not_found{protocol_level});register_error_kind`Permanent~id:"config_file.cannot_switch_history_mode"~title:"Cannot switch history mode"~description:"Cannot switch history mode."~pp:(funppf(prev,next)->Format.fprintfppf"Cannot switch from history mode %a to %a. In order to change your \
history mode please refer to the Tezos node documentation. If you \
really want to change your history mode, run this command again with \
the `--force-history-mode-switch` option."History_mode.ppprevHistory_mode.ppnext)(Data_encoding.obj2(Data_encoding.req"previous_mode"History_mode.encoding)(Data_encoding.req"next_mode"History_mode.encoding))(function|Cannot_switch_history_modex->Some(x.previous_mode,x.next_mode)|_->None)(fun(previous_mode,next_mode)->Cannot_switch_history_mode{previous_mode;next_mode});register_error_kind`Permanent~id:"store.invalid_head_switch"~title:"Invalid head switch"~description:"The given head is not consistent with the current store's savepoint"~pp:(funppf(minimum_allowed_level,(head_hash,head_level))->Format.fprintfppf"The given head %a (%ld) is below the minimum allowed level %ld."Block_hash.pphead_hashhead_levelminimum_allowed_level)Data_encoding.(obj2(req"minimum_allowed_level"int32)(req"given_head"@@tup2Block_hash.encodingint32))(function|Invalid_head_switch{checkpoint_level;given_head}->Some(checkpoint_level,given_head)|_->None)(fun(checkpoint_level,given_head)->Invalid_head_switch{checkpoint_level;given_head});register_error_kind`Permanent~id:"snapshots.inconsistent_operation_hashes"~title:"Inconsistent operation hashes"~description:"The operations given do not match their hashes."~pp:(funppf(oph,oph')->Format.fprintfppf"Inconsistent operation hashes. Expected: %a, got %a."Operation_list_list_hash.ppophOperation_list_list_hash.ppoph')Data_encoding.(obj2(req"expected_operation_hashes"Operation_list_list_hash.encoding)(req"received_operation_hashes"Operation_list_list_hash.encoding))(function|Inconsistent_operations_hash{expected;got}->Some(expected,got)|_->None)(fun(expected,got)->Inconsistent_operations_hash{expected;got})typecemented_store_inconsistency=|Missing_cycleof{low_cycle:string;high_cycle:string}|Inconsistent_cycle_startof{cycle_start:Int32.t;expected_cycle_start:Int32.t;}|Bad_offsetof{level:int;cycle:string}|Unexpected_levelof{block_hash:Block_hash.t;expected:Int32.t;got:Int32.t;}|Corrupted_indexofBlock_hash.t|Inconsistent_highest_cemented_levelof{highest_cemented_level:Int32.t;cementing_highwatermark:Int32.t;}letcemented_store_inconsistency_encoding=letopenData_encodinginunion[case(Tag0)~title:"Missing cycle"(obj2(req"low_cycle"string)(req"high_cycle"string))(function|Missing_cycle{low_cycle;high_cycle}->Some(low_cycle,high_cycle)|_->None)(fun(low_cycle,high_cycle)->Missing_cycle{low_cycle;high_cycle});case(Tag1)~title:"Inconsistent_cycle_start"(obj2(req"cycle_start"int32)(req"expected_cycle_start"int32))(function|Inconsistent_cycle_start{expected_cycle_start;cycle_start}->Some(expected_cycle_start,cycle_start)|_->None)(fun(expected_cycle_start,cycle_start)->Inconsistent_cycle_start{expected_cycle_start;cycle_start});case(Tag2)~title:"Bad offset"(obj2(req"level"int31)(req"cycle"string))(function|Bad_offset{level;cycle}->Some(level,cycle)|_->None)(fun(level,cycle)->Bad_offset{level;cycle});case(Tag3)~title:"Unexpected level"(obj3(req"block_hash"Block_hash.encoding)(req"expected"int32)(req"got"int32))(function|Unexpected_level{block_hash;expected;got}->Some(block_hash,expected,got)|_->None)(fun(block_hash,expected,got)->Unexpected_level{block_hash;expected;got});case(Tag4)~title:"Corrupted index"(obj1(req"block_hash"Block_hash.encoding))(functionCorrupted_indexh->Someh|_->None)(funh->Corrupted_indexh);case(Tag5)~title:"Inconsistent highest cemented level"(obj2(req"highest_cemented_level"int32)(req"cementing_highwatermark"int32))(function|Inconsistent_highest_cemented_level{highest_cemented_level;cementing_highwatermark}->Some(highest_cemented_level,cementing_highwatermark)|_->None)(fun(highest_cemented_level,cementing_highwatermark)->Inconsistent_highest_cemented_level{highest_cemented_level;cementing_highwatermark});]typestore_block_error=|Invalid_block|Invalid_operations_lengthof{validation_passes:int;operations:int}|Invalid_operations_data_lengthof{validation_passes:int;operations_data:int;}|Inconsistent_operations_lengthsof{operations_lengths:string;operations_data_lengths:string;}|Invalid_last_allowed_fork_levelof{last_allowed_fork_level:int32;genesis_level:int32;}letstore_block_error_encoding=letopenData_encodinginunion[case(Tag0)~title:"Invalid operations length"(obj2(req"validation_passes"int31)(req"operations"int31))(function|Invalid_operations_length{validation_passes;operations}->Some(validation_passes,operations)|_->None)(fun(validation_passes,operations)->Invalid_operations_length{validation_passes;operations});case(Tag1)~title:"Invalid operations data length"(obj2(req"validation_passes"int31)(req"operations_data"int31))(function|Invalid_operations_data_length{validation_passes;operations_data}->Some(validation_passes,operations_data)|_->None)(fun(validation_passes,operations_data)->Invalid_operations_data_length{validation_passes;operations_data});case(Tag2)~title:"Inconsistent operations length"(obj2(req"operations_lengths"string)(req"operations_data_lengths"string))(function|Inconsistent_operations_lengths{operations_lengths;operations_data_lengths}->Some(operations_lengths,operations_data_lengths)|_->None)(fun(operations_lengths,operations_data_lengths)->Inconsistent_operations_lengths{operations_lengths;operations_data_lengths});]typeerror+=|Cannot_write_in_readonly|Wrong_predecessorofBlock_hash.t*int|Invalid_blocks_to_cement|Wrong_floating_kind_swap|Cannot_update_floating_store|Cannot_instanciate_temporary_floating_store|Merge_already_running|Merge_error|Cannot_load_degraded_store|Cannot_merge_storeof{status:string}|Failed_to_init_cemented_block_storeofstring|Cannot_cement_blocks_metadataof[`Empty|`Not_cemented]|Cannot_cement_blocksof[`Empty|`Higher_cemented]|Temporary_cemented_file_existsofstring|Inconsistent_cemented_fileofstring*string|Inconsistent_cemented_storeofcemented_store_inconsistency|Missing_last_allowed_fork_level_block|Inconsistent_block_hashof{level:Int32.t;expected_hash:Block_hash.t;computed_hash:Block_hash.t;}|Inconsistent_block_predecessorof{block_hash:Block_hash.t;level:Int32.t;expected_hash:Block_hash.t;computed_hash:Block_hash.t;}|Cannot_encode_blockofBlock_hash.t|Cannot_store_blockofBlock_hash.t*store_block_error|Cannot_checkout_contextofBlock_hash.t*Context_hash.t|Cannot_find_protocolofint|Invalid_genesis_marking|Cannot_retrieve_savepointofInt32.t|Cannot_set_targetof(Block_hash.t*Int32.t)|Missing_commit_infoofstring|Inconsistent_chain_store|Fork_testchain_not_allowed|Cannot_fork_testchainofChain_id.t|Cannot_load_testchainofstring|Missing_activation_blockofBlock_hash.t*Protocol_hash.t*History_mode.t|Inconsistent_protocol_commit_infoofBlock_hash.t*Protocol_hash.t|Failed_to_get_live_blocksofBlock_hash.t|Target_mismatch|Bad_head_invariantlet()=Error_monad.register_error_kind`Permanent~id:"store.cannot_write_in_readonly"~title:"Cannot write in readonly"~description:"Cannot write data in store when in readonly"~pp:(funppf()->Format.fprintfppf"Cannot write data in store when in readonly.")Data_encoding.empty(functionCannot_write_in_readonly->Some()|_->None)(fun()->Cannot_write_in_readonly);Error_monad.register_error_kind`Temporary~id:"store.wrong_predecessor"~title:"Wrong predecessor"~description:"Failed to get block's predecessor"~pp:(funppf(hash,offset)->Format.fprintfppf"Failed to get the nth predecessor of %a. The offset is invalid: %d."Block_hash.pphashoffset)Data_encoding.(obj2(req"hash"Block_hash.encoding)(req"offset"int31))(function|Wrong_predecessor(hash,offset)->Some(hash,offset)|_->None)(fun(hash,offset)->Wrong_predecessor(hash,offset));Error_monad.register_error_kind`Temporary~id:"store.invalid_blocks_to_cement"~title:"Invalid blocks to cement"~description:"Invalid block list to cement"~pp:(funppf()->Format.fprintfppf"Invalid block list to cement: the block list must be correctly \
chained and their levels growing strictly by one between each block.")Data_encoding.empty(functionInvalid_blocks_to_cement->Some()|_->None)(fun()->Invalid_blocks_to_cement);Error_monad.register_error_kind`Temporary~id:"store.wrong_floating_kind_swap"~title:"Wrong floating kind swap"~description:"Try to swap wrong floating store kind"~pp:(funppf()->Format.fprintfppf"Failed to swap floating stores: tried to swap floating store of the \
same kind.")Data_encoding.empty(functionWrong_floating_kind_swap->Some()|_->None)(fun()->Wrong_floating_kind_swap);Error_monad.register_error_kind`Temporary~id:"store.cannot_update_floating_store"~title:"Cannot update floating store"~description:"Cannot update floating store"~pp:(funppf()->Format.fprintfppf"Cannot update the floating store: failed to retrieve enough blocks to \
cement.")Data_encoding.empty(functionCannot_update_floating_store->Some()|_->None)(fun()->Cannot_update_floating_store);Error_monad.register_error_kind`Temporary~id:"store.cannot_instanciate_temporary_floating_store"~title:"Cannot instanciate temporary floating store"~description:"Cannot instanciate temporary floating store"~pp:(funppf()->Format.fprintfppf"Cannot instanciate temporary floating store.")Data_encoding.empty(function|Cannot_instanciate_temporary_floating_store->Some()|_->None)(fun()->Cannot_instanciate_temporary_floating_store);Error_monad.register_error_kind`Temporary~id:"store.merge_error"~title:"Merge error"~description:"Error while merging the store"~pp:(funppf()->Format.fprintfppf"Error while merging the store.")Data_encoding.empty(functionMerge_error->Some()|_->None)(fun()->Merge_error);Error_monad.register_error_kind`Temporary~id:"store.merge_already_running"~title:"Merge already running"~description:"The store's merge is already running"~pp:(funppf()->Format.fprintfppf"The store's merge is already running.")Data_encoding.empty(functionMerge_already_running->Some()|_->None)(fun()->Merge_already_running);Error_monad.register_error_kind`Permanent~id:"store.cannot_load_degraded_store"~title:"Cannot load degraded store"~description:"Cannot load a degraded block store."~pp:(funppf()->Format.fprintfppf"Cannot load a degraded store. Its consistency must first be restored.")Data_encoding.empty(functionCannot_load_degraded_store->Some()|_->None)(fun()->Cannot_load_degraded_store);Error_monad.register_error_kind`Permanent~id:"store.cannot_merge_store"~title:"Cannot merge store"~description:"Cannot merge the store."~pp:(funppfstatus->Format.fprintfppf"Cannot merge the store, unexpected status: %s."status)Data_encoding.(obj1(req"status"string))(functionCannot_merge_store{status}->Somestatus|_->None)(funstatus->Cannot_merge_store{status});Error_monad.register_error_kind`Temporary~id:"store.failed_to_init_cemented_block_store"~title:"Failed to init cemented block store"~description:"Failed to initialize the cemented block store"~pp:(funppfpath->Format.fprintfppf"Failed to initialize the cemented block store: file %s is not a \
directory."path)Data_encoding.(obj1(req"path"string))(function|Failed_to_init_cemented_block_storepath->Somepath|_->None)(funpath->Failed_to_init_cemented_block_storepath);Error_monad.register_error_kind`Temporary~id:"store.cannot_cement_blocks_metadata"~title:"Cannot cement blocks metadata"~description:"Cannot cement blocks metadata"~pp:(funppfreason->Format.fprintfppf"Failed to cement the blocks metadata: %s."(matchreasonwith|`Empty->"the given list of blocks is empty"|`Not_cemented->"the given blocks ar not cemented"))Data_encoding.(obj1(req"reason"(string_enum[("empty",`Empty);("not_cemented",`Not_cemented)])))(functionCannot_cement_blocks_metadatar->Somer|_->None)(funr->Cannot_cement_blocks_metadatar);Error_monad.register_error_kind`Temporary~id:"store.cannot_cement_blocks"~title:"Cannot cement blocks"~description:"Cannot cement blocks"~pp:(funppfreason->Format.fprintfppf"Failed to merge the store: %s."(matchreasonwith|`Empty->"no valid cycles were found"|`Higher_cemented->"the highest cemented block has a higher level than the given \
blocks"))Data_encoding.(obj1(req"reason"(string_enum[("empty",`Empty);("higher_cemented",`Higher_cemented)])))(functionCannot_cement_blocksr->Somer|_->None)(funr->Cannot_cement_blocksr);Error_monad.register_error_kind`Temporary~id:"store.temporary_cemented_file_exists"~title:"Temporary cemented file exists"~description:"The temporary cemented file already exists"~pp:(funppfpath->Format.fprintfppf"Error while merging the store: the temporary cemented file %s already \
exists."path)Data_encoding.(obj1(req"path"string))(functionTemporary_cemented_file_existspath->Somepath|_->None)(funpath->Temporary_cemented_file_existspath);Error_monad.register_error_kind`Temporary~id:"store.inconsistent_cemented_file"~title:"Inconsistent cemented file"~description:"Failed to read a cemented file"~pp:(funppf(path,trace)->Format.fprintfppf"Failed to read the cemented file %s. Unexpected failure: %s."pathtrace)Data_encoding.(obj2(req"path"string)(req"trace"string))(function|Inconsistent_cemented_file(path,trace)->Some(path,trace)|_->None)(fun(path,trace)->Inconsistent_cemented_file(path,trace));Error_monad.register_error_kind`Temporary~id:"store.inconsistent_cemented_store"~title:"Inconsistent cemented store"~description:"Failed to check indexes consistency"~pp:(funppfcsi->Format.fprintfppf"The store is in an unexpected and inconsistent state: %s."(matchcsiwith|Missing_cycle{low_cycle;high_cycle}->Format.sprintf"missing cycle between %s and %s"low_cyclehigh_cycle|Inconsistent_cycle_start{cycle_start;expected_cycle_start}->Format.asprintf"inconsistent cycle starting at %ld but expected at %ld"cycle_startexpected_cycle_start|Bad_offset{level;cycle}->Format.asprintf"bad offset found for block %d in cycle %s"levelcycle|Unexpected_level{block_hash;expected;got}->Format.asprintf"bad level found for block %a - expected %ld got %ld"Block_hash.ppblock_hashexpectedgot|Corrupted_indexh->Format.asprintf"%a was not found in the imported store"Block_hash.pph|Inconsistent_highest_cemented_level{highest_cemented_level;cementing_highwatermark}->Format.sprintf"the most recent cemented block (%ld) is not the previous \
cemented highwatermark (%ld)"highest_cemented_levelcementing_highwatermark))Data_encoding.(obj1(req"inconsistent_cemented_file"cemented_store_inconsistency_encoding))(functionInconsistent_cemented_storecsi->Somecsi|_->None)(funcsi->Inconsistent_cemented_storecsi);Error_monad.register_error_kind`Temporary~id:"store.missing_last_allowed_fork_level_block"~title:"Missing last allowed fork level block"~description:"Current head's last allowed fork level block (or its associated \
metadata) cannot be found in the store."~pp:(funppf()->Format.fprintfppf"Current head's last allowed fork level block or (its associated \
metadata) cannot be found in the store.")Data_encoding.empty(functionMissing_last_allowed_fork_level_block->Some()|_->None)(fun()->Missing_last_allowed_fork_level_block);Error_monad.register_error_kind`Temporary~id:"store.inconsistent_block_hash"~title:"Inconsistent block hash"~description:"Inconsistent block hash found"~pp:(funppf(level,expected_hash,computed_hash)->Format.fprintfppf"Inconsistent block: inconsistent hash found for block %ld. Expected \
%a, got %a."levelBlock_hash.ppexpected_hashBlock_hash.ppcomputed_hash)Data_encoding.(obj3(req"level"int32)(req"expected_hash"Block_hash.encoding)(req"computed_hash"Block_hash.encoding))(function|Inconsistent_block_hash{level;expected_hash;computed_hash}->Some(level,expected_hash,computed_hash)|_->None)(fun(level,expected_hash,computed_hash)->Inconsistent_block_hash{level;expected_hash;computed_hash});Error_monad.register_error_kind`Temporary~id:"store.inconsistent_block_predecessor"~title:"Inconsistent block predecessor"~description:"Inconsistent block predecessor"~pp:(funppf(block_hash,level,expected_hash,computed_hash)->Format.fprintfppf"Inconsistent block: inconsistent predecessor found for block %a (%ld) \
- expected: %a vs got: %a."Block_hash.ppblock_hashlevelBlock_hash.ppexpected_hashBlock_hash.ppcomputed_hash)Data_encoding.(obj4(req"block_hash"Block_hash.encoding)(req"level"int32)(req"expected_hash"Block_hash.encoding)(req"computed_hash"Block_hash.encoding))(function|Inconsistent_block_predecessor{block_hash;level;expected_hash;computed_hash}->Some(block_hash,level,expected_hash,computed_hash)|_->None)(fun(block_hash,level,expected_hash,computed_hash)->Inconsistent_block_predecessor{block_hash;level;expected_hash;computed_hash});Error_monad.register_error_kind`Temporary~id:"store.cannot_encode_block"~title:"Cannot encode block"~description:"Failed to encode block"~pp:(funppfhash->Format.fprintfppf"Failed to write block in floating store: cannot encode block %a."Block_hash.pphash)Data_encoding.(obj1(req"hash"Block_hash.encoding))(functionCannot_encode_blockhash->Somehash|_->None)(funhash->Cannot_encode_blockhash);Error_monad.register_error_kind`Temporary~id:"store.cannot_store_block"~title:"Cannot store block"~description:"Failed to store block"~pp:(funppf(hash,err)->Format.fprintfppf"Failed to store block %a: %s."Block_hash.pphash(matcherrwith|Invalid_block->"the block is marked as invalid"|Invalid_operations_length{validation_passes;operations}->Format.sprintf"invalid operations length %d (%d was expected)"operationsvalidation_passes|Invalid_operations_data_length{validation_passes;operations_data}->Format.sprintf"invalid operation_data length %d (%d was expected)"validation_passesoperations_data|Inconsistent_operations_lengths{operations_lengths;operations_data_lengths}->Format.sprintf"inconsistent operations (%s) and operations_data (%s) lengths"operations_lengthsoperations_data_lengths|Invalid_last_allowed_fork_level{last_allowed_fork_level;genesis_level}->Format.sprintf"block's last allowed fork level (%ld) is below the genesis \
level (%ld)"last_allowed_fork_levelgenesis_level))Data_encoding.(obj2(req"hash"Block_hash.encoding)(req"err"store_block_error_encoding))(functionCannot_store_block(hash,err)->Some(hash,err)|_->None)(fun(hash,err)->Cannot_store_block(hash,err));Error_monad.register_error_kind`Temporary~id:"store.cannot_checkout_context"~title:"Cannot checkout context"~description:"Failed to checkout context"~pp:(funppf(bh,ch)->Format.fprintfppf"Failed to checkout the context (%a) for block %a."Context_hash.ppchBlock_hash.ppbh)Data_encoding.(obj2(req"block_hash"Block_hash.encoding)(req"context_hash"Context_hash.encoding))(functionCannot_checkout_context(bh,ch)->Some(bh,ch)|_->None)(fun(bh,ch)->Cannot_checkout_context(bh,ch));Error_monad.register_error_kind`Temporary~id:"store.cannot_find_protocol"~title:"Cannot find protocol"~description:"Cannot find protocol"~pp:(funppfproto_level->Format.fprintfppf"Cannot find protocol with level %d."proto_level)Data_encoding.(obj1(req"protocol_level"int31))(function|Cannot_find_protocolproto_level->Someproto_level|_->None)(funproto_level->Cannot_find_protocolproto_level);Error_monad.register_error_kind`Temporary~id:"store.invalid_genesis_marking"~title:"Invalid genesis marking"~description:"Cannot mark genesis as invalid"~pp:(funppf()->Format.fprintfppf"Cannot mark the genesis block is invalid.")Data_encoding.empty(functionInvalid_genesis_marking->Some()|_->None)(fun()->Invalid_genesis_marking);Error_monad.register_error_kind`Temporary~id:"store.cannot_retrieve_savepoint"~title:"Cannot retrieve savepoint"~description:"Failed to retrieve savepoint"~pp:(funppflevel->Format.fprintfppf"Failed to retrieve the new savepoint hash (expected at level %ld)."level)Data_encoding.(obj1(req"level"int32))(functionCannot_retrieve_savepointlevel->Somelevel|_->None)(funlevel->Cannot_retrieve_savepointlevel);Error_monad.register_error_kind`Temporary~id:"store.cannot_set_target"~title:"Cannot set target"~description:"The given block to be set as target is invalid."~pp:(funppf(given_target_hash,given_target_level)->Format.fprintfppf"Failed to set the given target %a (%ld): it is either invalid, or not \
a predecessor of the checkpoint."Block_hash.ppgiven_target_hashgiven_target_level)Data_encoding.(obj1(req"given_target"(tup2Block_hash.encodingint32)))(functionCannot_set_targetgiven_target->Somegiven_target|_->None)(fungiven_target->Cannot_set_targetgiven_target);Error_monad.register_error_kind`Temporary~id:"store.missing_commit_info"~title:"Missing commit info"~description:"Failed to retreive commit info"~pp:(funppftrace->Format.fprintfppf"Failed to retreive commit info: %s@.Is the context initialized?"trace)Data_encoding.(obj1(req"trace"string))(functionMissing_commit_infotrace->Sometrace|_->None)(funtrace->Missing_commit_infotrace);Error_monad.register_error_kind`Temporary~id:"store.inconsistent_chain_store"~title:"Inconsistent chain store"~description:"Failed to load chain store"~pp:(funppf()->Format.fprintfppf"Failed to load the chain store: could not retrieve head metadata.")Data_encoding.empty(functionInconsistent_chain_store->Some()|_->None)(fun()->Inconsistent_chain_store);Error_monad.register_error_kind`Temporary~id:"store.fork_testchain_not_allowed"~title:"Fork testchain not allowed"~description:"Forking the test chain is not allowed"~pp:(funppf()->Format.fprintfppf"Failed to fork the test chain: it is not allowed by the store's \
configuration.")Data_encoding.empty(functionFork_testchain_not_allowed->Some()|_->None)(fun()->Fork_testchain_not_allowed);Error_monad.register_error_kind`Temporary~id:"store.cannot_fork_testchain"~title:"Cannot fork testchain"~description:"Failed to fork testchain"~pp:(funppfchain_id->Format.fprintfppf"Failed to fork the testchain: the testchain %a already exists."Chain_id.ppchain_id)Data_encoding.(obj1(req"chain_id"Chain_id.encoding))(functionCannot_fork_testchainchain_id->Somechain_id|_->None)(funchain_id->Cannot_fork_testchainchain_id);Error_monad.register_error_kind`Temporary~id:"store.cannot_load_testchain"~title:"Cannot load testchain"~description:"Failed to load the testchain"~pp:(funppfpath->Format.fprintfppf"Failed to load the testchain as it was not found in %s."path)Data_encoding.(obj1(req"path"string))(functionCannot_load_testchainpath->Somepath|_->None)(funpath->Cannot_load_testchainpath);Error_monad.register_error_kind`Temporary~id:"store.missing_activation_block"~title:"Missing activation block"~description:"Missing activation block while restoring snapshot"~pp:(funppf(bh,ph,hm)->Format.fprintfppf"Failed to restore snapshot: the expected activation block %a \
originating the protocol %a was not found for %a."Block_hash.ppbhProtocol_hash.ppphHistory_mode.pphm)Data_encoding.(obj3(req"block_hash"Block_hash.encoding)(req"protocol_hash"Protocol_hash.encoding)(req"history_mode"History_mode.encoding))(function|Missing_activation_block(bh,ph,hm)->Some(bh,ph,hm)|_->None)(fun(bh,ph,hm)->Missing_activation_block(bh,ph,hm));Error_monad.register_error_kind`Temporary~id:"store.inconsistent_protocol_commit_info"~title:"Inconsistent protocol commit info"~description:"Inconsistent protocol commit info while restoring snapshot"~pp:(funppf(bh,ph)->Format.fprintfppf"Failed to restore snapshot: inconsistent commit info found for \
transition block %a activating protocol %a."Block_hash.ppbhProtocol_hash.ppph)Data_encoding.(obj2(req"block_hash"Block_hash.encoding)(req"protocol_hash"Protocol_hash.encoding))(function|Inconsistent_protocol_commit_info(bh,ph)->Some(bh,ph)|_->None)(fun(bh,ph)->Inconsistent_protocol_commit_info(bh,ph));Error_monad.register_error_kind`Permanent~id:"store.failed_to_get_live_blocks"~title:"Fail to get live blocks"~description:"Unable to compute live blocks from a given block."~pp:(funppf(hash:Block_hash.t)->Format.fprintfppf"Failed to get live blocks from block %a"Block_hash.pphash)Data_encoding.(obj1(req"hash"Block_hash.encoding))(functionFailed_to_get_live_blocksh->Someh|_->None)(funh->Failed_to_get_live_blocksh);Error_monad.register_error_kind`Permanent~id:"store.target_mismatch"~title:"target mismatch"~description:"Target is reached but it is not a head's ancestor."~pp:(funppf()->Format.fprintfppf"Target is reached but it is not a head's ancestor.")Data_encoding.empty(functionTarget_mismatch->Some()|_->None)(fun()->Target_mismatch);Error_monad.register_error_kind`Permanent~id:"store.bad_head_invariant"~title:"Bad head invariant"~description:"Bad invariant during Store.set_head"~pp:(funppf()->Format.fprintfppf"Bad invariant during Store.set_head")Data_encoding.empty(functionBad_head_invariant->Some()|_->None)(fun()->Bad_head_invariant)(* Consistency errors: *)typeerror+=|Unexpected_missing_blockof{block_name:string}|Unexpected_missing_block_metadataof{block_name:string}|Unexpected_missing_activation_blockof{block:Block_hash.t;protocol:Protocol_hash.t;}|Unexpected_missing_protocolof{protocol_level:int}|Inconsistent_genesisof{expected:Block_hash.t;got:Block_hash.t}|Inconsistent_cementing_highwatermarkof{highest_cemented_level:Int32.t;cementing_highwatermark:Int32.t;}|Inconsistent_history_modeofHistory_mode.t|Bad_ordering_invariantof{genesis:Int32.t;caboose:Int32.t;savepoint:Int32.t;cementing_highwatermark:Int32.toption;checkpoint:Int32.t;head:Int32.t;}let()=register_error_kind`Permanent~id:"store.unexpected_missing_block"~title:"Unexpected missing block"~description:"A block is unexpectedly missing from the store."~pp:(funppfblock_name->Format.fprintfppf"The block '%s' is unexpectedly missing from the store."block_name)Data_encoding.(obj1(req"missing_block"string))(function|Unexpected_missing_block{block_name}->Someblock_name|_->None)(funblock_name->Unexpected_missing_block{block_name});register_error_kind`Permanent~id:"store.unexpected_missing_block_metadata"~title:"Unexpected missing block metadata"~description:"A block's metadata is unexpectedly missing from the store."~pp:(funppfblock_name->Format.fprintfppf"The block '%s' metadata is unexpectedly missing from the store."block_name)Data_encoding.(obj1(req"missing_block_metadata"string))(function|Unexpected_missing_block_metadata{block_name}->Someblock_name|_->None)(funblock_name->Unexpected_missing_block_metadata{block_name});register_error_kind`Permanent~id:"store.unexpected_missing_activation_block"~title:"Unexpected missing activaiton block"~description:"An activation block is unexpectedly missing from the store."~pp:(funppf(block,proto)->Format.fprintfppf"The block %a activating protocol %a is unexpectedly missing from the \
store."Block_hash.ppblockProtocol_hash.ppproto)Data_encoding.(obj2(req"block"Block_hash.encoding)(req"protocol"Protocol_hash.encoding))(function|Unexpected_missing_activation_block{block;protocol}->Some(block,protocol)|_->None)(fun(block,protocol)->Unexpected_missing_activation_block{block;protocol});register_error_kind`Permanent~id:"store.unexpected_missing_protocol"~title:"Unexpected missing protocol"~description:"A protocol is unexpectedly missing from the store."~pp:(funppfprotocol_level->Format.fprintfppf"The protocol %d is unexpectedly missing from the store."protocol_level)Data_encoding.(obj1(req"protocol_level"int31))(function|Unexpected_missing_protocol{protocol_level}->Someprotocol_level|_->None)(funprotocol_level->Unexpected_missing_protocol{protocol_level});register_error_kind`Permanent~id:"store.inconsistent_genesis"~title:"Inconsistent genesis"~description:"The given genesis block is inconsistent with the store."~pp:(funppf(expected,got)->Format.fprintfppf"The genesis (%a) found in the store is not the one expected (%a)."Block_hash.ppgotBlock_hash.ppexpected)Data_encoding.(obj2(req"expected"Block_hash.encoding)(req"got"Block_hash.encoding))(function|Inconsistent_genesis{expected;got}->Some(expected,got)|_->None)(fun(expected,got)->Inconsistent_genesis{expected;got});register_error_kind`Permanent~id:"store.inconsistent_cementing_highwatermark"~title:"Inconsistent cementing highwatermark"~description:"The stored cementing highwatermark is inconsistent with the store."~pp:(funppf(highest_cemented_level,cementing_highwatermark)->Format.fprintfppf"The stored cemented highwatermark (level: %ld) differs from the \
highest cemented block (level: %ld)"cementing_highwatermarkhighest_cemented_level)Data_encoding.(obj2(req"highest_cemented_level"int32)(req"cementing_highwatermark"int32))(function|Inconsistent_cementing_highwatermark{highest_cemented_level;cementing_highwatermark}->Some(highest_cemented_level,cementing_highwatermark)|_->None)(fun(highest_cemented_level,cementing_highwatermark)->Inconsistent_cementing_highwatermark{highest_cemented_level;cementing_highwatermark});register_error_kind`Permanent~id:"store.inconsistent_history_mode"~title:"Inconsistent history mode"~description:"The history mode does not correspond to the store."~pp:(funppfhistory_mode->Format.fprintfppf"the history mode (%a) is not compatible with the store"History_mode.pphistory_mode)Data_encoding.(obj1(req"history_mode"History_mode.encoding))(functionInconsistent_history_modehm->Somehm|_->None)(funhm->Inconsistent_history_modehm);register_error_kind`Permanent~id:"store.bad_ordering_invariant"~title:"Bad ordering invariant"~description:"The ordering invariant does not hold"~pp:(funppf(genesis,caboose,savepoint,cementing_highwatermark,checkpoint,head)->Format.fprintfppf"Invariant '%ld (genesis) ≤ %ld (caboose) ≤ %ld (savepoint) ≤ %a \
[cementing_highwatermark] ≤\n\
\ %ld (checkpoint) ≤ all(alternate_heads ∪ (%ld) current_head)' does \
not hold"genesiscaboosesavepoint(Format.pp_print_option~none:(funppf()->Format.fprintfppf"(n/a)")(funppf->Format.fprintfppf"%ld"))cementing_highwatermarkcheckpointhead)Data_encoding.(obj6(req"genesis"int32)(req"caboose"int32)(req"savepoint"int32)(req"cementing_highwatermark"(optionint32))(req"checkpoint"int32)(req"head"int32))(function|Bad_ordering_invariant{genesis;caboose;savepoint;cementing_highwatermark;checkpoint;head;}->Some(genesis,caboose,savepoint,cementing_highwatermark,checkpoint,head)|_->None)(fun(genesis,caboose,savepoint,cementing_highwatermark,checkpoint,head)->Bad_ordering_invariant{genesis;caboose;savepoint;cementing_highwatermark;checkpoint;head})typecorruption_kind=|Inferred_headofBlock_hash.t*Int32.t|Cannot_find_floating_savepoint|Cannot_find_savepoint_candidate|Cannot_find_floating_caboose|Cannot_find_caboose_candidate|Cannot_find_block_with_metadata|Cannot_find_activation_blockofint|Missing_genesisletcorruption_kind_encoding=letopenData_encodinginunion[case(Tag0)~title:"Inferred_head"(obj2(req"hash"Block_hash.encoding)(req"level"int32))(function|Inferred_head(hash,level)->Some(hash,level)|_->None)(fun(hash,level)->Inferred_head(hash,level));case(Tag1)~title:"Cannot_find_floating_savepoint"empty(functionCannot_find_floating_savepoint->Some()|_->None)(fun()->Cannot_find_floating_savepoint);case(Tag2)~title:"Cannot_find_savepoint_candidate"empty(functionCannot_find_savepoint_candidate->Some()|_->None)(fun()->Cannot_find_savepoint_candidate);case(Tag3)~title:"Cannot_find_floating_caboose"empty(functionCannot_find_floating_caboose->Some()|_->None)(fun()->Cannot_find_floating_caboose);case(Tag4)~title:"Cannot_find_caboose_candidate"empty(functionCannot_find_caboose_candidate->Some()|_->None)(fun()->Cannot_find_caboose_candidate);case(Tag5)~title:"Cannot_find_block_with_metadata"empty(functionCannot_find_block_with_metadata->Some()|_->None)(fun()->Cannot_find_block_with_metadata);case(Tag6)~title:"Cannot_find_activation_block"(obj1(req"proto_level"int31))(function|Cannot_find_activation_blockproto_level->Someproto_level|_->None)(funproto_level->Cannot_find_activation_blockproto_level);case(Tag7)~title:"Missing_genesis"empty(functionMissing_genesis->Some()|_->None)(fun()->Missing_genesis);]letpp_corruption_kindppf=function|Inferred_head(hash,level)->Format.fprintfppf"inferred head (%a, %ld) must have metadata"Block_hash.pphashlevel|Cannot_find_floating_savepoint->Format.fprintfppf"failed to find a valid savepoint in the floating store. No block with \
metadata were found"|Cannot_find_savepoint_candidate->Format.fprintfppf"failed to find the savepoint candidate in the store"|Cannot_find_floating_caboose->Format.fprintfppf"failed to find a valid caboose in the floating store"|Cannot_find_caboose_candidate->Format.fprintfppf"failed to find the caboose candidate in the store"|Cannot_find_block_with_metadata->Format.fprintfppf"cannot find block with metadata in the store. At least the head must \
have metadata"|Cannot_find_activation_blockproto_level->Format.fprintfppf"failed to find a valid activation block for protocol %d"proto_level|Missing_genesis->Format.fprintfppf"the genesis block is not available in the store"typeerror+=Corrupted_storeofcorruption_kindlet()=Error_monad.register_error_kind`Permanent~id:"store.corrupted_store"~title:"Corrupted store"~description:"The store is corrupted"~pp:(funppfkind->Format.fprintfppf"The store is corrupted irremediably: %a."pp_corruption_kindkind)Data_encoding.(obj1(req"kind"corruption_kind_encoding))(functionCorrupted_storek->Somek|_->None)(funk->Corrupted_storek)(* Store upgrade errors *)typeerror+=|Cannot_find_chain_dirofstring|V_3_0_upgrade_missing_floating_blockof{block_hash:Block_hash.t;block_level:Int32.t;floating_kind:string;}let()=Error_monad.register_error_kind`Permanent~id:"store.cannot_find_chain_dir"~title:"Cannot find chain dir"~description:"Cannot find chain dir while upgrading storage"~pp:(funppfpath->Format.fprintfppf"Failed to upgrade the storage. The chain directory %s cannot be \
found. Make sure that the data directory contains data of the \
expected network."path)Data_encoding.(obj1(req"path"string))(functionCannot_find_chain_dirp->Somep|_->None)(funp->Cannot_find_chain_dirp);register_error_kind`Permanent~id:"block_store.v_3_0_upgrade_missing_floating_block"~title:"V.3.0 upgrade missing floating block"~description:"Failed to upgrade the floating store"~pp:(funppf(block_hash,block_level,floating_kind)->Format.fprintfppf"Failed to upgrade block %a (level %ld) for %s floating store: block \
not found in the index."Block_hash.ppblock_hashblock_levelfloating_kind)Data_encoding.(obj3(req"block_hash"Block_hash.encoding)(req"block_level"int32)(req"floating_kind"string))(function|V_3_0_upgrade_missing_floating_block{block_hash;block_level;floating_kind}->Some(block_hash,block_level,floating_kind)|_->None)(fun(block_hash,block_level,floating_kind)->V_3_0_upgrade_missing_floating_block{block_hash;block_level;floating_kind})