123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2023 Nomadic Labs, <contact@nomadic-labs.com> *)(* Copyright (c) 2023 Functori, <contact@functori.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. *)(* *)(*****************************************************************************)typelost_result=Draw|Timeout|Conflict_resolvedletlost_result_to_string=function|Draw->"draw"|Timeout->"timeout"|Conflict_resolved->"conflict resolved"letlost_result_encoding=Data_encoding.string_enum(List.map(funr->(lost_result_to_stringr,r))[Draw;Timeout;Conflict_resolved])typeerror+=|Cannot_produce_proofof{inbox_level:int32;start_tick:Z.t}|Bad_minimal_feesofstring|Disagree_with_cementedof{inbox_level:int32;ours:Commitment.Hash.toption;on_l1:Commitment.Hash.t;}|Unreliable_tezos_node_returning_inconsistent_game|Wrong_initial_pvm_stateof{initial_state_hash:State_hash.t;expected_state_hash:State_hash.t;}|Inconsistent_inboxof{layer1_inbox:Octez_smart_rollup.Inbox.t;inbox:Octez_smart_rollup.Inbox.t;}|Missing_PVM_stateofBlock_hash.t*Int32.t|Cannot_checkout_contextofBlock_hash.t*Smart_rollup_context_hash.toption|Cannot_checkout_l2_header|No_batcher|No_publisher|Refutation_player_failed_to_start|No_refutation_coordinator|Could_not_acquire_lockofstringtypeerror+=|Could_not_open_preimage_fileofString.t|Could_not_encode_raw_datatypeerror+=|Lost_gameoflost_result|Unparsable_boot_sectorof{path:string}|Invalid_genesis_stateof{expected:Commitment.Hash.t;actual:Commitment.Hash.t;}typeerror+=Operator_not_in_whitelisttypeerror+=Operator_has_no_stakedtypeerror+=Exit_bond_recovered_bailout_modetypeerror+=|Access_below_first_available_levelof{first_available_level:int32;accessed_level:int32;}typeerror+=|Unexpected_rollupof{rollup_address:Octez_smart_rollup.Address.t;saved_address:Octez_smart_rollup.Address.t;}let()=register_error_kind`Permanent~id:"bad_minimal_fees_arg"~title:"Bad -minimal-fees arg"~description:"invalid fee threshold in -fee-threshold"~pp:(funppfliteral->Format.fprintfppf"invalid minimal fees '%s'"literal)Data_encoding.(obj1(req"parameter"string))(functionBad_minimal_feesparameter->Someparameter|_->None)(funparameter->Bad_minimal_feesparameter);register_error_kind`Permanent~id:"internal.node_disagrees_with_cemented"~title:"Internal error: The node disagrees with a cemented commitment on L1"~description:"Internal error: The node disagrees with a cemented commitment on L1"~pp:(funppf(inbox_level,ours,on_l1)->Format.fprintfppf"Internal error: The node has commitment %a for inbox level %ld but \
this level is cemented on L1 with commitment %a"(Format.pp_print_option~none:(funppf()->Format.pp_print_stringppf"[None]")Commitment.Hash.pp)oursinbox_levelCommitment.Hash.ppon_l1)Data_encoding.(obj3(req"inbox_level"int32)(req"ours"(optionCommitment.Hash.encoding))(req"on_l1"Commitment.Hash.encoding))(function|Disagree_with_cemented{inbox_level;ours;on_l1}->Some(inbox_level,ours,on_l1)|_->None)(fun(inbox_level,ours,on_l1)->Disagree_with_cemented{inbox_level;ours;on_l1});letdescription="Internal error: The game invariant states that the dissection from the \
opponent must contain a tick we disagree with. If the retrieved game does \
not respect this, we cannot trust the Tezos node we are connected to and \
prefer to stop here."inregister_error_kind`Permanent~id:"internal.unreliable_tezos_node"~title:"Internal error: Tezos node seems unreliable"~description~pp:(funppf()->Format.fprintfppf"Unreliable Tezos node. %s"description)Data_encoding.unit(function|Unreliable_tezos_node_returning_inconsistent_game->Some()|_->None)(fun()->Unreliable_tezos_node_returning_inconsistent_game);register_error_kind`Permanent~id:"internal.cannot_produce_proof"~title:"Internal error: rollup node cannot produce refutation proof"~description:"The rollup node is in a state that prevents it from producing \
refutation proofs."~pp:(funppf(inbox_level,start_tick)->Format.fprintfppf"cannot produce proof for inbox level %ld starting at tick %a"inbox_levelZ.pp_printstart_tick)Data_encoding.(obj2(req"inbox_level"int32)(req"start_tick"z))(function|Cannot_produce_proof{inbox_level;start_tick}->Some(inbox_level,start_tick)|_->None)(fun(inbox_level,start_tick)->Cannot_produce_proof{inbox_level;start_tick});register_error_kind~id:"sc_rollup.node.Wrong_initial_pvm_state"~title:"Initial state produced by PVM is incorrect"~description:"Initial state produced by PVM is incorrect."~pp:(funppf(actual,expected)->Format.fprintfppf"The initial state hash produced by the PVM %a is not consistent\n\
\ with the one expected by the Layer 1 PVM implementation %a"State_hash.ppactualState_hash.ppexpected)`PermanentData_encoding.(obj2(req"initial_state_hash"State_hash.encoding)(req"expected_state_hash"State_hash.encoding))(function|Wrong_initial_pvm_state{initial_state_hash;expected_state_hash}->Some(initial_state_hash,expected_state_hash)|_->None)(fun(initial_state_hash,expected_state_hash)->Wrong_initial_pvm_state{initial_state_hash;expected_state_hash});register_error_kind~id:"internal.inconsistent_inbox"~title:"Internal error: Rollup node has an inconsistent inbox"~description:"The rollup node inbox should be the same as the layer 1 inbox."~pp:(funppf(layer1_inbox,inbox)->Format.fprintfppf"@[Rollup inbox:@;%a@]@;should be equal to @[Layer1 inbox:@;%a@]"Octez_smart_rollup.Inbox.ppinboxOctez_smart_rollup.Inbox.pplayer1_inbox)`PermanentData_encoding.(obj2(req"layer1_inbox"Octez_smart_rollup.Inbox.encoding)(req"inbox"Octez_smart_rollup.Inbox.encoding))(function|Inconsistent_inbox{layer1_inbox;inbox}->Some(layer1_inbox,inbox)|_->None)(fun(layer1_inbox,inbox)->Inconsistent_inbox{layer1_inbox;inbox});register_error_kind`Permanent~id:"internal.missing_pvm_state"~title:"Internal error: Missing PVM state"~description:"The rollup node cannot retrieve the state of the PVM."~pp:(funppf(block,level)->Format.fprintfppf"Cannot retrieve PVM state for block %a at level %ld"Block_hash.ppblocklevel)Data_encoding.(obj2(req"block"Block_hash.encoding)(req"level"int32))(function|Missing_PVM_state(block,level)->Some(block,level)|_->None)(fun(block,level)->Missing_PVM_state(block,level));register_error_kind`Permanent~id:"internal.cannot_checkout_context"~title:"Internal error: Cannot checkout context"~description:"The rollup node cannot checkout the context registered for the block."~pp:(funppf(block,context_hash)->Format.fprintfppf"The context %sfor block %a cannot be checkouted"(Option.fold~none:""~some:Smart_rollup_context_hash.to_b58checkcontext_hash)Block_hash.ppblock)Data_encoding.(obj2(req"block"Block_hash.encoding)(opt"context"Smart_rollup_context_hash.encoding))(function|Cannot_checkout_context(block,context)->Some(block,context)|_->None)(fun(block,context)->Cannot_checkout_context(block,context));register_error_kind`Permanent~id:"internal.cannot_checkout_l2_header"~title:"Internal error: Cannot checkout L2 header"~description:"The rollup node cannot checkout the l2 header registered for the block."~pp:(funppf()->Format.fprintfppf"The l2 header cannot be checkouted")Data_encoding.unit(functionCannot_checkout_l2_header->Some()|_->None)(fun()->Cannot_checkout_l2_header);register_error_kind`Permanent~id:"sc_rollup.node.lost_game"~title:"Lost refutation game"~description:"The rollup node lost a refutation game."~pp:(funppfresult->Format.fprintfppf"The rollup node lost the refutation game (%s)"(lost_result_to_stringresult))Data_encoding.(obj1(req"result"lost_result_encoding))(functionLost_gameresult->Someresult|_->None)(funresult->Lost_gameresult);register_error_kind`Permanent~id:"sc_rollup.node.unparsable_boot_sector"~title:"Unparsable boot sector"~description:"The boot sector provided is not parsable by the PVM."~pp:(funppfpath->Format.fprintfppf"The boot sector at path %S is unparsable"path)Data_encoding.(obj1(req"path"string))(functionUnparsable_boot_sector{path}->Somepath|_->None)(funpath->Unparsable_boot_sector{path});register_error_kind`Permanent~id:"sc_rollup.node.invalid_genesis_state"~title:"Invalid genesis state"~description:"The rollup node computed an invalid genesis state, it cannot continue."~pp:(funppf(expected,actual)->Format.fprintfppf"Genesis commitment computed (%a) is not equal to the rollup genesis \
(%a) commitment. The rollup node cannot continue. If you used the \
argument `--boot-sector-file` you probably provided the wrong boot \
sector. If not, please report the bug."Commitment.Hash.ppexpectedCommitment.Hash.ppactual)Data_encoding.(obj2(req"expected"Commitment.Hash.encoding)(req"actual"Commitment.Hash.encoding))(function|Invalid_genesis_state{expected;actual}->Some(expected,actual)|_->None)(fun(expected,actual)->Invalid_genesis_state{expected;actual});register_error_kind~id:"sc_rollup.node.no_batcher"~title:"No batcher for this node"~description:"This node does not have a batcher"~pp:(funppf()->Format.fprintfppf"This rollup node does not have batcher.")`PermanentData_encoding.unit(functionNo_batcher->Some()|_->None)(fun()->No_batcher);register_error_kind~id:"sc_rollup.node.no_publisher"~title:"No publisher for this node"~description:"This node does not have an operator to publish commitments"~pp:(funppf()->Format.fprintfppf"This rollup node does not have an operator to publish commitments.")`PermanentData_encoding.unit(functionNo_publisher->Some()|_->None)(fun()->No_publisher);register_error_kind~id:"sc_rollup.node.no_refutation_coordinator"~title:"No refutation coordinator for this node"~description:"This node does not have a refutation game coordinator"~pp:(funppf()->Format.fprintfppf"This node does not have a refutation game coordinator")`PermanentData_encoding.unit(functionNo_refutation_coordinator->Some()|_->None)(fun()->No_refutation_coordinator);register_error_kind~id:"sc_rollup.node.no_refutation_player"~title:"A refutation player failed to start"~description:"A refutation player failed to start"~pp:(funppf()->Format.fprintfppf"A refutation player failed to start.")`PermanentData_encoding.unit(functionRefutation_player_failed_to_start->Some()|_->None)(fun()->Refutation_player_failed_to_start);register_error_kind`Permanent~id:"could_not_acquire_lock"~title:"Could not acquire lock on data dir"~description:"Could not acquire lock on data dir."~pp:(funppff->Format.fprintfppf"Could not acquire lock on data directory, another rollup node may \
already be running with this data. If this is not the case, consider \
removing manually the file %S"f)Data_encoding.(obj1(req"lock_file"string))(functionCould_not_acquire_lockf->Somef|_->None)(funf->Could_not_acquire_lockf);register_error_kind~id:"sc_rollup.node.could_not_open_reveal_preimage_file"~title:"Could not open reveal preimage file"~description:"Could not open reveal preimage file."~pp:(funppfhash->Format.fprintfppf"Could not open file containing preimage of reveal hash %s"hash)`PermanentData_encoding.(obj1(req"hash"string))(function|Could_not_open_preimage_filefilename->Somefilename|_->None)(funfilename->Could_not_open_preimage_filefilename);register_error_kind~id:"sc_rollup.node.could_not_encode_raw_data"~title:"Could not encode raw data to reveal"~description:"Could not encode raw data to reveal."~pp:(funppf()->Format.pp_print_stringppf"Could not encode raw data to reveal with the expected protocol \
encoding")`PermanentData_encoding.unit(functionCould_not_encode_raw_data->Some()|_->None)(fun()->Could_not_encode_raw_data);register_error_kind~id:"sc_rollup.node.operator_not_in_whitelist"~title:"The operator is not in the whitelist"~description:"The operator is not in the whitelist."~pp:(funppf()->Format.pp_print_stringppf"The operator is not in the whitelist. Please restart the rollup node \
in bailout mode if you still have stakes.")`PermanentData_encoding.unit(functionOperator_not_in_whitelist->Some()|_->None)(fun()->Operator_not_in_whitelist);register_error_kind~id:"sc_rollup.node.operator_has_no_staked"~title:"The operator does not has any stake"~description:"The operator does not has any stake."~pp:(funppf()->Format.pp_print_stringppf"The operator does not has any stake.")`PermanentData_encoding.unit(functionOperator_has_no_staked->Some()|_->None)(fun()->Operator_has_no_staked);register_error_kind~id:"sc_rollup.node.exiting_bailout_mode"~title:"The rollup node is exiting."~description:"The rollup node is exiting after recovering the bond of the operator."~pp:(funppf()->Format.pp_print_stringppf"The rollup node is exiting after bailout mode.")`PermanentData_encoding.unit(functionExit_bond_recovered_bailout_mode->Some()|_->None)(fun()->Exit_bond_recovered_bailout_mode);register_error_kind`Permanent~id:"sc_rollup.node.access_below_first_available_level"~title:"Rollup node access data that is garbage collected"~description:"The rollup node attempts to access data that is garbage collected."~pp:(funppf(first,access)->Format.fprintfppf"Attempting to access data for level %ld, which is before the first \
available level %ld"accessfirst)Data_encoding.(obj2(req"first_available_level"int32)(req"accessed_level"int32))(function|Access_below_first_available_level{first_available_level;accessed_level}->Some(first_available_level,accessed_level)|_->None)(fun(first_available_level,accessed_level)->Access_below_first_available_level{first_available_level;accessed_level});register_error_kind~id:"sc_rollup.node.unexpected_rollup"~title:"Unexpected rollup for rollup node"~description:"This rollup node is already set up for another rollup."~pp:(funppf(rollup_address,saved_address)->Format.fprintfppf"This rollup node was already set up for rollup %a, it cannot be run \
for a different rollup %a."Address.ppsaved_addressAddress.pprollup_address)`PermanentData_encoding.(obj2(req"rollup_address"Address.encoding)(req"saved_address"Address.encoding))(function|Unexpected_rollup{rollup_address;saved_address}->Some(rollup_address,saved_address)|_->None)(fun(rollup_address,saved_address)->Unexpected_rollup{rollup_address;saved_address})