12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379(*****************************************************************************)(* *)(* 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;level:Int32.t;hash:Block_hash.t;}|Unexpected_missing_block_metadataof{block_name:string;level:Int32.t;hash:Block_hash.t;}|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:(funppf(block_name,level,hash)->Format.fprintfppf"The block '%s' (%ld, %a) is unexpectedly missing from the store."block_namelevelBlock_hash.pp_shorthash)Data_encoding.(obj3(req"missing_block"string)(req"level"int32)(req"hash"Block_hash.encoding))(function|Unexpected_missing_block{block_name;level;hash}->Some(block_name,level,hash)|_->None)(fun(block_name,level,hash)->Unexpected_missing_block{block_name;level;hash});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:(funppf(block_name,level,hash)->Format.fprintfppf"The block '%s' (%ld, %a) metadata is unexpectedly missing from the \
store."block_namelevelBlock_hash.pp_shorthash)Data_encoding.(obj3(req"missing_block_metadata"string)(req"level"int32)(req"hash"Block_hash.encoding))(function|Unexpected_missing_block_metadata{block_name;level;hash}->Some(block_name,level,hash)|_->None)(fun(block_name,level,hash)->Unexpected_missing_block_metadata{block_name;level;hash});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})