123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* Copyright (c) 2019-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. *)(* *)(*****************************************************************************)letblock_param~name~desct=Tezos_clic.param~name~desc(Tezos_clic.parameter(fun_str->Lwt.return(Block_hash.of_b58checkstr)))tletoperation_param~name~desct=Tezos_clic.param~name~desc(Tezos_clic.parameter(fun_str->Lwt.return(Operation_hash.of_b58checkstr)))tletcommands()=letopenLwt_result_syntaxinletopenTezos_clicinletgroup={name="admin";title="Commands to perform privileged operations on the node";}in[command~group~desc:"Make the node forget its decision of rejecting blocks."no_options(prefixes["unmark";"invalid"]@@seq_of_param(block_param~name:"block"~desc:"blocks to remove from invalid list"))(fun()blocks(cctxt:#Client_context.full)->List.iter_es(funblock->let*()=Shell_services.Invalid_blocks.deletecctxtblockinlet*!()=cctxt#message"Block %a no longer marked invalid."Block_hash.ppblockinreturn_unit)blocks);command~group~desc:"Make the node forget every decision of rejecting blocks."no_options(prefixes["unmark";"all";"invalid";"blocks"]@@stop)(fun()(cctxt:#Client_context.full)->let*invalid_blocks=Shell_services.Invalid_blocks.listcctxt()inList.iter_es(fun{Chain_services.hash;_}->let*()=Shell_services.Invalid_blocks.deletecctxthashinlet*!()=cctxt#message"Block %a no longer marked invalid."Block_hash.pp_shorthashinreturn_unit)invalid_blocks);command~group~desc:"Retrieve the current checkpoint and display it in a format compatible \
with node argument `--checkpoint`."no_options(fixed["show";"current";"checkpoint"])(fun()(cctxt:#Client_context.full)->let*checkpoint_hash,checkpoint_level=Shell_services.Chain.Levels.checkpointcctxt~chain:cctxt#chain()inlet*!()=cctxt#message"@[<v 0>Checkpoint: %a@,Checkpoint level: %ld@]"Block_hash.ppcheckpoint_hashcheckpoint_levelinreturn_unit);command~group~desc:"Remove an operation from the mempool if present, reverting its effect \
if it was applied. Add it to the set of banned operations to prevent \
it from being fetched/processed/injected in the future. Note: If the \
baker has already received the operation, then it's necessary to \
restart it to flush the operation from it."no_options(prefixes["ban";"operation"]@@operation_param~name:"operation"~desc:"hash of operation to ban"@@stop)(fun()op_hash(cctxt:#Client_context.full)->let*()=Shell_services.Mempool.ban_operationcctxt~chain:cctxt#chainop_hashinlet*!()=cctxt#message"Operation %a is now banned."Operation_hash.ppop_hashinreturn_unit);command~group~desc:"Remove an operation from the set of banned operations (nothing \
happens if it was not banned)."no_options(prefixes["unban";"operation"]@@operation_param~name:"operation"~desc:"hash of operation to unban"@@stop)(fun()op_hash(cctxt:#Client_context.full)->let*()=Shell_services.Mempool.unban_operationcctxt~chain:cctxt#chainop_hashinlet*!()=cctxt#message"Operation %a is now unbanned."Operation_hash.ppop_hashinreturn_unit);command~group~desc:"Clear the set of banned operations."no_options(fixed["unban";"all";"operations"])(fun()(cctxt:#Client_context.full)->let*()=Shell_services.Mempool.unban_all_operationscctxt~chain:cctxt#chain()inlet*!()=cctxt#message"All operations are now unbanned."inreturn_unit);]