123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2022-2023 TriliTech <contact@trili.tech> *)(* *)(* 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. *)(* *)(*****************************************************************************)letforce_switch:(bool,Client_context.full)Tezos_clic.arg=Tezos_clic.switch~long:"force"~doc:"Overwrites the configuration file when it exists."()letimport_force_switch:(bool,Client_context.full)Tezos_clic.arg=Tezos_clic.switch~long:"force"~doc:"Import into an already populated data dir."()letsc_rollup_address_paramx=Smart_rollup_alias.Address.param~name:"smart-rollup-address"~desc:"The smart rollup address"xletsc_rollup_address_arg:(_,Client_context.full)Tezos_clic.arg=Tezos_clic.arg~long:"rollup"~placeholder:"smart-rollup-address"~doc:"The smart rollup address (required when no configuration file exists)"(Smart_rollup_alias.Address.parameter())(* Rollup node only arguments *)letoperator_paramnext=letopenLwt_result_syntaxinletdesc=Format.asprintf"Public key hash, or alias, of a smart rollup node operator. An operator \
can be specialized to a particular purpose by prefixing its key or \
alias by said purpose, e.g. operating:<alias_of_my_operator>. The \
possible purposes are: @[<h>%a@]."(Format.pp_print_list~pp_sep:(funfmt()->Format.pp_print_stringfmt", ")Purpose.pp_ex_purpose)Purpose.allinletparse_defaultcctxts=let*key=Client_keys.Public_key_hash.parse_source_stringcctxtsinreturn(`Defaultkey)inletparse_purposepurposecctxts=let*key=Client_keys.Public_key_hash.parse_source_stringcctxtsinreturn(`Purpose(purpose,key))inletall_purpose_casecctxt=List.map(funpurpose->(Purpose.to_string_ex_purposepurpose,parse_purposepurposecctxt))Purpose.allinTezos_clic.param~name:"operator"~desc(Tezos_clic.parameter(fun(cctxt:#Client_context.full)s->Client_aliases.parse_alternatives(("default",parse_defaultcctxt)::all_purpose_casecctxt)s))nextletpossible_modes=List.mapConfiguration.string_of_modeConfiguration.modesletmode_parameter=Tezos_clic.parameter~autocomplete:(fun(_cctxt:Client_context.full)->Lwt_result.returnpossible_modes)(fun_m->Lwt.return(Configuration.mode_of_stringm))letmode_doc=Format.asprintf"The mode for the rollup node (%s)@\n%a"(String.concat", "possible_modes)(Format.pp_print_list(funfmtmode->Format.fprintffmt"- %s: %s"(Configuration.string_of_modemode)(Configuration.description_of_modemode)))Configuration.modesletmode_paramparams=Tezos_clic.param~name:"mode"~desc:mode_docmode_parameterparamsletmode_arg=Tezos_clic.arg~long:"mode"~placeholder:"mode"~doc:(mode_doc^"\n(required when no configuration file exists)")mode_parameterletdal_node_endpoint_arg=Tezos_clic.arg~long:"dal-node"~placeholder:"dal-node-endpoint"~doc:(Format.sprintf"The address of the dal node from which the smart rollup node \
downloads slots. When not provided, the rollup node will not support \
the DAL. In production, a DAL node must be provided if DAL is \
enabled and used in the rollup.")(Tezos_clic.parameter(fun(_cctxt:Client_context.full)s->Lwt.return_ok(Uri.of_strings)))letpre_images_endpoint_arg=Tezos_clic.arg~long:"pre-images-endpoint"~placeholder:"url"~doc:(Format.sprintf"The address of a service which provides pre-images for the rollup. \
Missing pre-images will be downloaded remotely if they are not \
already present on disk.")(Tezos_clic.parameter(fun(_cctxt:Client_context.full)s->Lwt.return_ok(Uri.of_strings)))letloser_mode_arg=Tezos_clic.arg~long:"loser-mode"~placeholder:"mode"~doc:"Set the rollup node failure points (for test only!)."(Tezos_clic.parameter(fun(_cctxt:Client_context.full)s->matchLoser_mode.makeswith|Somet->Lwt_result.returnt|None->failwith"Invalid syntax for failure points"))(* Primitive argument parsers *)letstring_parameter=Tezos_clic.parameter(fun(_cctxt:Client_context.full)x->Lwt_result.returnx)letint_parameter=Tezos_clic.parameter(fun(cctxt:Client_context.full)p->tryLwt_result.return(int_of_stringp)with_->cctxt#error"Cannot read int")letz_parameter=Tezos_clic.parameter(fun(cctxt:Client_context.full)s->tryletopenLwt_result_syntaxinletv=Z.of_stringsinreturnvwith_->cctxt#error"Invalid number, must be a non negative number.")letint32_parameter=Tezos_clic.parameter(fun(cctxt:Client_context.full)p->tryLwt_result.return(Int32.of_stringp)with_->cctxt#error"Cannot read int")moduleBinary_dependent_args(P:sigvalbinary_name:stringend)=structopenPletrpc_addr_arg=letdefault=Configuration.default_rpc_addrinTezos_clic.arg~long:"rpc-addr"~placeholder:"rpc-address|ip"~doc:(Format.sprintf"The address the %s listens to. Default value is %s"binary_namedefault)string_parameterletmetrics_addr_arg=Tezos_clic.arg~long:"metrics-addr"~placeholder:"ADDR:PORT or :PORT (by default ADDR is localhost and PORT is 9933)"~doc:(Format.sprintf"The address of the %s metrics server."binary_name)string_parameterletdac_observer_endpoint_arg=Tezos_clic.arg~long:"dac-observer"~placeholder:"dac-observer-endpoint"~doc:(Format.sprintf"The address of the DAC observer node from which the %s downloads \
preimages requested through the reveal channel."P.binary_name)(Tezos_clic.parameter(fun(_cctxt:Client_context.full)s->Lwt.return_ok(Uri.of_strings)))letrpc_port_arg=letdefault=Configuration.default_rpc_port|>string_of_intinTezos_clic.arg~long:"rpc-port"~placeholder:"rpc-port"~doc:(Format.sprintf"The port the %s listens to. Default value is %s"binary_namedefault)int_parameterletacl_override_arg:([`Allow_all|`Secure]option,_)Tezos_clic.arg=Tezos_clic.arg~long:"acl-override"~placeholder:"kind"~doc:"Specify a different ACL for the rpc server to override the default \
one. Possible values are 'secure' and 'allow-all'"(Tezos_clic.parameter(fun(_cctxt:Client_context.full)->letopenLwt_result_syntaxinfunction|"secure"->return`Secure|"allow-all"|"allow_all"->return`Allow_all|_->failwith"Bad value for acl-override, possible values are 'secure' and \
'allow-all'"))letdata_dir_arg=letdefault=Configuration.default_data_dirinTezos_clic.default_arg~long:"data-dir"~placeholder:"data-dir"~doc:(Format.sprintf"The path to the %s data directory. Default value is %s"binary_namedefault)~defaultstring_parameterletboot_sector_file_arg=Tezos_clic.arg~long:"boot-sector-file"~placeholder:"file"~doc:(Format.sprintf"Path to the boot sector. The argument is optional, if the rollup \
was originated via the smart rollup originate operation, the %s \
will fetch the boot sector itself. This argument is required only \
if it's a bootstrapped smart rollup."binary_name)(Tezos_clic.parameter(fun(_cctxt:Client_context.full)path->letopenLwt_result_syntaxinlet*!exists=Lwt_unix.file_existspathinifexiststhenreturnpathelsefailwith"Boot sector not found at path %S"path))endletdac_timeout_arg=Tezos_clic.arg~long:"dac-timeout"~placeholder:"seconds"~doc:"Timeout in seconds for which the DAC observer client will wait for a \
preimage"z_parameterletreconnection_delay_arg=letdefault=Format.sprintf"%.1f"Configuration.default_reconnection_delayinletdoc=Format.asprintf"The first reconnection delay, in seconds, to wait before reconnecting \
to the Tezos node. The default delay is %s.\n\
The actual delay varies to follow a randomized exponential backoff \
(capped to 1.5h): [1.5^reconnection_attempt * delay ± 50%%]."defaultinTezos_clic.arg~long:"reconnection-delay"~placeholder:"delay"~doc(Tezos_clic.parameter(fun(_cctxt:Client_context.full)p->tryLwt_result.return(float_of_stringp)with_->failwith"Cannot read float"))letinjector_retention_period_arg=Tezos_clic.arg~long:"injector-retention-period"~placeholder:"blocks"~doc:(Format.sprintf"The number of blocks the injector keeps in memory. Decrease to free \
memory, and increase to be able to query information about included \
messages for longer. Default value is %d"Configuration.default_injector.retention_period)@@Tezos_clic.map_parameterint_parameter~f:(funp->ifp>Configuration.max_injector_retention_period||p<0thenFormat.ksprintfStdlib.failwith"injector-retention-period should be a positive number smaller \
than %d"Configuration.max_injector_retention_period;p)letinjector_attempts_arg=Tezos_clic.arg~long:"injector-attempts"~placeholder:"number"~doc:(Format.sprintf"The number of attempts that the injector will make to inject an \
operation when it fails. Default value is %d"Configuration.default_injector.attempts)@@Tezos_clic.map_parameterint_parameter~f:(funp->ifp<0thenFormat.ksprintfStdlib.failwith"injector-attempts should be positive";p)letinjection_ttl_arg=Tezos_clic.arg~long:"injection-ttl"~placeholder:"number"~doc:(Format.sprintf"The number of blocks after which an operation that is injected but \
never included is retried. Default value is %d"Configuration.default_injector.injection_ttl)@@Tezos_clic.map_parameterint_parameter~f:(funp->ifp<1thenStdlib.failwith"injection-ttl should be > 1";p)letpositive_int_parameter=Tezos_clic.parameter(fun(cctxt:Client_context.full)p->matchint_of_string_optpwith|Someiwheni>0->Lwt_result.returni|None|Some_->cctxt#error"Expected a valid positive integer, provided %s instead"p)letpositive_int32_parameter=Tezos_clic.parameter(fun(cctxt:Client_context.full)p->matchInt32.of_string_optpwith|SomeiwhenCompare.Int32.(i>0l)->Lwt_result.returni|None|Some_->cctxt#error"Expected a valid positive integer, provided %s instead"p)letindex_buffer_size_arg=Tezos_clic.arg~long:"index-buffer-size"~placeholder:"<nb_entries>"~doc:"The maximum cache size in memory before it is flushed to disk, used for \
indexes of the store."positive_int_parameterletirmin_cache_size_arg=Tezos_clic.arg~long:"irmin-cache-size"~placeholder:"<nb_entries>"~doc:"Size of Irmin cache in number of entries"positive_int_parameterletlog_kernel_debug_arg:(bool,Client_context.full)Tezos_clic.arg=Tezos_clic.switch~long:"log-kernel-debug"~doc:"Log the kernel debug output to kernel.log in the data directory"()letlog_kernel_debug_file_arg=Tezos_clic.arg~long:"log-kernel-debug-file"~placeholder:"file"~doc:""string_parameterletno_degraded_arg:(bool,Client_context.full)Tezos_clic.arg=Tezos_clic.switch~long:"no-degraded"~doc:"Prevent the rollup node from entering degraded mode on error. The \
rollup node will instead stop."()letgc_frequency_arg=Tezos_clic.arg~long:"gc-frequency"~placeholder:"blocks"~doc:(Format.sprintf"The number of blocks between each launch of the garbage collection. \
Default value is %ld."Configuration.default_gc_parameters.frequency_in_blocks)positive_int32_parameterlethistory_mode_parameter=Tezos_clic.parameter~autocomplete:(fun(_cctxt:Client_context.full)->Lwt_result.return["archive";"full"])(fun_m->Lwt_result.return(Configuration.history_mode_of_stringm))lethistory_mode_arg=Tezos_clic.arg~long:"history-mode"~placeholder:"history_mode"~doc:(Format.sprintf"The history mode for the rollup node (archive, full) (default is %s)"Configuration.(string_of_history_modedefault_history_mode))history_mode_parameterletwasm_dump_file_paramnext=Tezos_clic.param~name:"dump.<json|yaml>"~desc:"YAML or JSON file containing the dumped durable storage"string_parameternextletsnapshot_dir_arg=Tezos_clic.arg~long:"dest"~placeholder:"path"~doc:"Directory in which to export the snapshot (defaults to current \
directory)"string_parameterletsnapshot_file_paramnext=Tezos_clic.param~name:"snapshot_file"~desc:"Snapshot archive file"string_parameternextletno_checks_arg:(bool,Client_context.full)Tezos_clic.arg=Tezos_clic.switch~long:"no-check"~doc:"Don't check integrity of the snapshot."()letcompress_on_the_fly_arg:(bool,Client_context.full)Tezos_clic.arg=Tezos_clic.switch~long:"compress-on-the-fly"~doc:"Produce a compressed snapshot on the fly. The rollup node will use less \
disk space to produce the snapshot but will lock the rollup node (if \
running) for a longer time. Without this option, producing a snaphsot \
requires the available disk space to be around the size of the data \
dir."()letuncompressed:(bool,Client_context.full)Tezos_clic.arg=Tezos_clic.switch~long:"uncompressed"~doc:"Produce an uncompressed snapshot."()letcompact:(bool,Client_context.full)Tezos_clic.arg=Tezos_clic.switch~long:"compact"~doc:"Produce a compact snapshot with a single commit for the context."()letstring_list=Tezos_clic.parameter(fun(_cctxt:Client_context.full)s->letlist=String.split','sinLwt_result.returnlist)letcors_allowed_headers_arg=Tezos_clic.arg~long:"cors-headers"~placeholder:"ALLOWED_HEADERS"~doc:"List of accepted cors headers."string_listletcors_allowed_origins_arg=Tezos_clic.arg~long:"cors-origins"~placeholder:"ALLOWED_ORIGINS"~doc:"List of accepted cors origins."string_listletprotocol_hash_parameter=Tezos_clic.parameter(fun(_cctxt:Client_context.full)p->Lwt.return(Protocol_hash.of_b58checkp))letprotocol_hash_arg=Tezos_clic.arg~long:"protocol"~short:'P'~placeholder:"Proto"~doc:"Protocol hash in base58-check. If not provided, the export will be for \
the last registered protocol in the rollup node which may be different \
between different versions of the node."protocol_hash_parameterletprotocol_hash_paramnext=Tezos_clic.param~name:"protocol"~desc:"Protocol hash"protocol_hash_parameternextletapply_unsafe_patches_switch:(bool,Client_context.full)Tezos_clic.arg=Tezos_clic.switch~long:"apply-unsafe-patches"~doc:"Apply unsafe PVM patches in the configuration or hardcoded by the node."()