1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2022 Nomadic Labs. <contact@nomadic-labs.com> *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* Copyright (c) 2020 Metastate AG <hello@metastate.dev> *)(* *)(* 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. *)(* *)(*****************************************************************************)moduleShell_error_monad=Error_monadtypeshell_error=error=..openEnvironment_contextopenEnvironment_protocol_TmoduletypeT=sigincludeTezos_protocol_environment_sigs.V11.TwithtypeFormat.formatter=Format.formatterandtype'aSeq.node='aSeq.nodeandtype'aSeq.t=unit->'aSeq.nodeandtype'aData_encoding.t='aData_encoding.tandtype'aData_encoding.Compact.t='aData_encoding.Compact.tandtype'aData_encoding.lazy_t='aData_encoding.lazy_tandtype'aLwt.t='aLwt.tandtype('a,'b)Pervasives.result=('a,'b)resultandtypeChain_id.t=Chain_id.tandtypeBlock_hash.t=Block_hash.tandtypeOperation_hash.t=Operation_hash.tandtypeOperation_list_hash.t=Operation_list_hash.tandtypeOperation_list_list_hash.t=Operation_list_list_hash.tandtypeContext.t=Context.tandtypeContext.cache_key=Environment_context.Context.cache_keyandtypeContext.cache_value=Environment_context.Context.cache_valueandtypeContext_hash.t=Context_hash.tandtypeContext_hash.Version.t=Context_hash.Version.tandtypeContext.config=Tezos_context_sigs.Config.tandmoduleContext.Proof=Environment_context.Context.ProofandtypeContext_binary.t=Tezos_context_memory.Context_binary.tandtypeContext_binary.tree=Tezos_context_memory.Context_binary.treeandtypeProtocol_hash.t=Protocol_hash.tandtypeTime.t=Time.Protocol.tandtypeOperation.shell_header=Operation.shell_headerandtypeOperation.t=Operation.tandtypeBlock_header.shell_header=Block_header.shell_headerandtypeBlock_header.t=Block_header.tandtype'aRPC_directory.t='aTezos_rpc.Directory.tandtypeEd25519.Public_key_hash.t=Tezos_crypto.Signature.Ed25519.Public_key_hash.tandtypeEd25519.Public_key.t=Tezos_crypto.Signature.Ed25519.Public_key.tandtypeEd25519.t=Tezos_crypto.Signature.Ed25519.tandtypeSecp256k1.Public_key_hash.t=Tezos_crypto.Signature.Secp256k1.Public_key_hash.tandtypeSecp256k1.Public_key.t=Tezos_crypto.Signature.Secp256k1.Public_key.tandtypeSecp256k1.t=Tezos_crypto.Signature.Secp256k1.tandtypeP256.Public_key_hash.t=Tezos_crypto.Signature.P256.Public_key_hash.tandtypeP256.Public_key.t=Tezos_crypto.Signature.P256.Public_key.tandtypeP256.t=Tezos_crypto.Signature.P256.tandtypeBls.Public_key_hash.t=Tezos_crypto.Signature.Bls.Public_key_hash.tandtypeBls.Public_key.t=Tezos_crypto.Signature.Bls.Public_key.tandtypeBls.t=Tezos_crypto.Signature.Bls.tandtypeSignature.public_key_hash=Tezos_crypto.Signature.V1.public_key_hashandtypeSignature.public_key=Tezos_crypto.Signature.V1.public_keyandtypeSignature.signature=Tezos_crypto.Signature.V1.signatureandtypeSignature.t=Tezos_crypto.Signature.V1.tandtypeSignature.watermark=Tezos_crypto.Signature.V1.watermarkandtypeMicheline.canonical_location=Micheline.canonical_locationandtype'aMicheline.canonical='aMicheline.canonicalandtypeZ.t=Z.tandtypeQ.t=Q.tandtype('a,'b)Micheline.node=('a,'b)Micheline.nodeandtypeData_encoding.json_schema=Data_encoding.json_schemaandtype('a,'b)RPC_path.t=('a,'b)Tezos_rpc.Path.tandtypeRPC_service.meth=Tezos_rpc.Service.methandtype(+'m,'pr,'p,'q,'i,'o)RPC_service.t=('m,'pr,'p,'q,'i,'o)Tezos_rpc.Service.tandtypeError_monad.shell_tztrace=Error_monad.tztraceandtype'aError_monad.shell_tzresult=('a,Error_monad.tztrace)resultandtypeTimelock.chest=Tezos_crypto.Timelock.chestandtypeTimelock.chest_key=Tezos_crypto.Timelock.chest_keyandtypeTimelock.opening_result=Tezos_crypto.Timelock.opening_resultandmoduleSapling=Tezos_sapling.Core.Validatorandtype('a,'b)Either.t=('a,'b)Stdlib.Either.tandtypeBls.Primitive.Fr.t=Bls12_381.Fr.tandtypePlonk.proof=Tezos_protocol_environment_structs.V11.Plonk.proofandtypePlonk.public_parameters=Tezos_protocol_environment_structs.V11.Plonk.verifier_public_parametersandtypeDal.parameters=Tezos_crypto_dal.Cryptobox.Verifier.parametersandtypeDal.commitment=Tezos_crypto_dal.Cryptobox.Verifier.commitmentandtypeDal.commitment_proof=Tezos_crypto_dal.Cryptobox.Verifier.commitment_proofandtypeDal.page_proof=Tezos_crypto_dal.Cryptobox.Verifier.page_proofandtypeBounded.Non_negative_int32.t=Tezos_base.Bounded.Non_negative_int32.tandtypeWasm_2_0_0.version=Tezos_scoru_wasm.Wasm_pvm_state.versionandtypeWasm_2_0_0.input=Tezos_scoru_wasm.Wasm_pvm_state.input_infoandtypeWasm_2_0_0.output=Tezos_scoru_wasm.Wasm_pvm_state.output_infoandtypeWasm_2_0_0.reveal=Tezos_scoru_wasm.Wasm_pvm_state.revealandtypeWasm_2_0_0.input_request=Tezos_scoru_wasm.Wasm_pvm_state.input_requestandtypeWasm_2_0_0.info=Tezos_scoru_wasm.Wasm_pvm_state.infoandmoduleSkip_list=Tezos_base.Skip_listandtypeSmart_rollup.Address.t=Tezos_crypto.Hashed.Smart_rollup_address.tandtypeSmart_rollup.Commitment_hash.t=Tezos_crypto.Hashed.Smart_rollup_commitment_hash.tandtypeSmart_rollup.State_hash.t=Tezos_crypto.Hashed.Smart_rollup_state_hash.tandtypeSmart_rollup.Inbox_hash.t=Tezos_crypto.Hashed.Smart_rollup_inbox_hash.tandtypeSmart_rollup.Merkelized_payload_hashes_hash.t=Tezos_crypto.Hashed.Smart_rollup_merkelized_payload_hashes_hash.ttypeerror+=Ecoproto_errorofError_monad.errorvalwrap_tzerror:Error_monad.error->errorvalwrap_tztrace:Error_monad.errorError_monad.trace->errortracevalwrap_tzresult:'aError_monad.tzresult->'atzresultmoduleLift(P:Updater.PROTOCOL):PROTOCOLwithtypeblock_header_data=P.block_header_dataandtypeblock_header_metadata=P.block_header_metadataandtypeblock_header=P.block_headerandtypeoperation_data=P.operation_dataandtypeoperation_receipt=P.operation_receiptandtypeoperation=P.operationandtypevalidation_state=P.validation_stateandtypeapplication_state=P.application_stateclass['chain,'block]proto_rpc_context:Tezos_rpc.Context.t->(unit,(unit*'chain)*'block)RPC_path.t->['chain*'block]RPC_context.simpleclass['block]proto_rpc_context_of_directory:('block->RPC_context.t)->RPC_context.tRPC_directory.t->['block]RPC_context.simpleendmoduleMake(Param:sigvalname:stringend)()=struct(* The protocol V11 only supports 64-bits architectures. We ensure this the
hard way with a dynamic check. *)let()=matchSys.word_sizewith|32->Printf.eprintf"FAILURE: Environment V11 does not support 32-bit architectures\n%!";Stdlib.exit1|64->()|n->Printf.eprintf"FAILURE: Unknown, unsupported architecture (%d bits)\n%!"n;Stdlib.exit1moduleCamlinternalFormatBasics=CamlinternalFormatBasicsincludeStdlibmodulePervasives=StdlibmoduleLogging=structtypelevel=Internal_event.level=|Debug|Info|Notice|Warning|Error|Fatalletlogging_function=refNoneletname_colon_space=Param.name^": "letnull_formatter=Format.make_formatter(fun___->())(fun()->())letlog(level:Internal_event.level)=match!logging_functionwith|None->Format.ikfprintfignorenull_formatter|Somef->Format.kasprintf(funs->flevel(name_colon_space^s))letlog_string(level:Internal_event.level)s=match!logging_functionwith|None->()|Somef->flevel(name_colon_space^s)endmoduleCompare=ComparemoduleEither=EithermoduleSeq=Tezos_protocol_environment_structs.V11.SeqmoduleList=Tezos_error_monad.TzLwtreslib.ListmoduleArray=Tezos_protocol_environment_structs.V11.ArraymoduleChar=CharmoduleBytes=Tezos_base.TzPervasives.BytesmoduleHex=Tezos_stdlib.HexmoduleString=StringmoduleBits=BitsmoduleTzEndian=TzEndianmoduleSet=Tezos_error_monad.TzLwtreslib.SetmoduleMap=Tezos_error_monad.TzLwtreslib.MapmoduleInt32=Int32moduleInt64=Int64moduleFormat=FormatmoduleFallbackArray=FallbackArrayletnot_a_sys_excnext_classifier=function|Unix.Unix_error_|UnixLabels.Unix_error_|Sys_error_->false|e->next_classifieremoduleOption=structincludeTezos_error_monad.TzLwtreslib.Option(* This as well as the catchers in [Result] and [Error_monad] are different
from the ones in Lwtreslib/Error Monad in that they also hide the Unix
and System errors. This is because, from the point-of-view of the
protocol, these exceptions are too abstract and too indeterministic. *)letcatch?(catch_only=fun_->true)f=(* Note that [catch] also special-cases its own set of exceptions. *)catch~catch_only:(not_a_sys_exccatch_only)fletcatch_s?(catch_only=fun_->true)f=catch_s~catch_only:(not_a_sys_exccatch_only)fendmoduleResult=structincludeTezos_error_monad.TzLwtreslib.Resultletcatch?(catch_only=fun_->true)f=catch~catch_only:(not_a_sys_exccatch_only)fletcatch_f?(catch_only=fun_->true)f=catch_f~catch_only:(not_a_sys_exccatch_only)fletcatch_s?(catch_only=fun_->true)f=catch_s~catch_only:(not_a_sys_exccatch_only)fendmoduleRaw_hashes=structletsha256=Tezos_crypto.Hacl.Hash.SHA256.digestletsha512=Tezos_crypto.Hacl.Hash.SHA512.digestletblake2bmsg=Tezos_crypto.Blake2B.to_bytes(Tezos_crypto.Blake2B.hash_bytes[msg])letkeccak256msg=Tezos_crypto.Hacl.Hash.Keccak_256.digestmsgletsha3_256msg=Tezos_crypto.Hacl.Hash.SHA3_256.digestmsgletsha3_512msg=Tezos_crypto.Hacl.Hash.SHA3_512.digestmsgendmoduleZ=ZmoduleQ=QmoduleLwt=LwtmoduleData_encoding=structincludeTezos_protocol_environment_structs.V11.Data_encodingtypetag_size=[`Uint8|`Uint16]letdefname?title?descriptionencoding=def(Param.name^"."^name)?title?descriptionencoding(* TODO: https://gitlab.com/nomadic-labs/data-encoding/-/issues/58
Remove when fix is integrated in data-encoding. *)letsplitted~json~binary=letopenData_encoding__.Encodinginlete=splitted~json~binaryin{ewithencoding=(matche.encodingwith|Splitted{encoding;json_encoding;_}->Splitted{encoding;json_encoding;is_obj=is_objjson&&is_objbinary;is_tup=is_tupjson&&is_tupbinary;}|desc->desc);}letpositive_int32_schema=Json_schema.(create(element(Integer{multiple_of=None;minimum=Some(0.,`Inclusive);maximum=Some(Int32.(to_floatmax_int),`Inclusive);})))endmoduleTime=Time.ProtocolmoduleEd25519=Tezos_crypto.Signature.Ed25519moduleSecp256k1=Tezos_crypto.Signature.Secp256k1moduleP256=Tezos_crypto.Signature.P256moduleBls=Tezos_crypto.Signature.BlsmoduleSignature=Tezos_crypto.Signature.V1moduleTimelock=Tezos_crypto.TimelockmoduleVdf=Class_group_vdf.Vdf_self_containedmoduleS=structmoduletypeT=Tezos_base.S.TmoduletypeHASHABLE=Tezos_base.S.HASHABLEmoduletypeMINIMAL_HASH=Tezos_crypto.Intfs.MINIMAL_HASHmoduletypeB58_DATA=sigtypetvalto_b58check:t->stringvalto_short_b58check:t->stringvalof_b58check_exn:string->tvalof_b58check_opt:string->toptiontypeTezos_crypto.Base58.data+=Dataoftvalb58check_encoding:tTezos_crypto.Base58.encodingendmoduletypeRAW_DATA=sigtypetvalsize:int(* in bytes *)valto_bytes:t->Bytes.tvalof_bytes_opt:Bytes.t->toptionvalof_bytes_exn:Bytes.t->tendmoduletypeENCODER=sigtypetvalencoding:tData_encoding.tvalrpc_arg:tTezos_rpc.Arg.tendmoduletypeINDEXES_SET=sigincludeSet.Svalrandom_elt:t->eltvalencoding:tData_encoding.tendmoduletypeINDEXES_MAP=sigincludeMap.Svalencoding:'aData_encoding.t->'atData_encoding.tendmoduletypeINDEXES=sigtypetmoduleSet:INDEXES_SETwithtypeelt=tmoduleMap:INDEXES_MAPwithtypekey=tendmoduletypeHASH=sigincludeMINIMAL_HASHincludeRAW_DATAwithtypet:=tincludeB58_DATAwithtypet:=tincludeENCODERwithtypet:=tincludeINDEXESwithtypet:=tendmoduletypeMERKLE_TREE=sigtypeeltincludeHASHvalcompute:eltlist->tvalempty:ttypepath=Leftofpath*t|Rightoft*path|Opvalcompute_path:eltlist->int->pathvalcheck_path:path->elt->t*intvalpath_encoding:pathData_encoding.tendmoduletypeSIGNATURE_PUBLIC_KEY_HASH=sigtypetvalpp:Format.formatter->t->unitvalpp_short:Format.formatter->t->unitincludeCompare.Swithtypet:=tincludeRAW_DATAwithtypet:=tincludeB58_DATAwithtypet:=tincludeENCODERwithtypet:=tincludeINDEXESwithtypet:=tvalzero:tendmoduletypeSIGNATURE_PUBLIC_KEY=sigtypetvalpp:Format.formatter->t->unitincludeCompare.Swithtypet:=tincludeB58_DATAwithtypet:=tincludeENCODERwithtypet:=ttypepublic_key_hash_tvalhash:t->public_key_hash_tvalsize:t->int(* in bytes *)valof_bytes_without_validation:bytes->toptionendmoduletypeSIGNATURE=sigmodulePublic_key_hash:SIGNATURE_PUBLIC_KEY_HASHmodulePublic_key:SIGNATURE_PUBLIC_KEYwithtypepublic_key_hash_t:=Public_key_hash.ttypetvalpp:Format.formatter->t->unitincludeRAW_DATAwithtypet:=tincludeCompare.Swithtypet:=tincludeB58_DATAwithtypet:=tincludeENCODERwithtypet:=tvalzero:ttypewatermark(** Check a signature *)valcheck:?watermark:watermark->Public_key.t->t->Bytes.t->boolendmoduletypeAGGREGATE_SIGNATURE=sigincludeSIGNATUREvalaggregate_check:(Public_key.t*watermarkoption*bytes)list->t->boolvalaggregate_signature_opt:tlist->toptionendmoduletypeSPLIT_SIGNATURE=sigincludeSIGNATUREtypeprefixtypesplitted={prefix:prefixoption;suffix:Bytes.t}valsplit_signature:t->splittedvalof_splitted:splitted->toptionvalprefix_encoding:prefixData_encoding.tendmoduletypeFIELD=sigtypet(** The order of the finite field *)valorder:Z.t(** Minimal number of bytes required to encode a value of the field. *)valsize_in_bytes:int(** [check_bytes bs] returns [true] if [bs] is a correct byte
representation of a field element *)valcheck_bytes:Bytes.t->bool(** The neutral element for the addition *)valzero:t(** The neutral element for the multiplication *)valone:t(** [add a b] returns [a + b mod order] *)valadd:t->t->t(** [mul a b] returns [a * b mod order] *)valmul:t->t->t(** [eq a b] returns [true] if [a = b mod order], else [false] *)valeq:t->t->bool(** [negate x] returns [-x mod order]. Equivalently, [negate x] returns the
unique [y] such that [x + y mod order = 0]
*)valnegate:t->t(** [inverse_opt x] returns [x^-1] if [x] is not [0] as an option, else [None] *)valinverse_opt:t->toption(** [pow x n] returns [x^n] *)valpow:t->Z.t->t(** From a predefined bytes representation, construct a value t. It is not
required that to_bytes [(Option.get (of_bytes_opt t)) = t]. By default, little endian encoding
is used and the given element is modulo the prime order *)valof_bytes_opt:Bytes.t->toption(** Convert the value t to a bytes representation which can be used for
hashing for instance. It is not required that [Option.get (to_bytes
(of_bytes_opt t)) = t]. By default, little endian encoding is used, and
length of the resulting bytes may vary depending on the order.
*)valto_bytes:t->Bytes.tend(** Module type for the prime fields GF(p) *)moduletypePRIME_FIELD=sigincludeFIELD(** Actual number of bytes allocated for a value of type t *)valsize_in_memory:int(** [of_z x] builds an element t from the Zarith element [x]. [mod order] is
applied if [x >= order] or [x < 0]. *)valof_z:Z.t->t(** [to_z x] builds a Zarith element, using the decimal representation.
Arithmetic on the result can be done using the modular functions on
integers *)valto_z:t->Z.tendmoduletypeCURVE=sig(** The type of the element in the elliptic curve *)typet(** Actual number of bytes allocated for a value of type t *)valsize_in_memory:int(** The size of a point representation, in bytes *)valsize_in_bytes:intmoduleScalar:FIELD(** Check if a point, represented as a byte array, is on the curve **)valcheck_bytes:Bytes.t->bool(** Attempt to construct a point from a byte array *)valof_bytes_opt:Bytes.t->toption(** Return a representation in bytes *)valto_bytes:t->Bytes.t(** Zero of the elliptic curve *)valzero:t(** A fixed generator of the elliptic curve *)valone:t(** Return the addition of two element *)valadd:t->t->t(** Double the element *)valdouble:t->t(** Return the opposite of the element *)valnegate:t->t(** Return [true] if the two elements are algebraically the same *)valeq:t->t->bool(** Multiply an element by a scalar *)valmul:t->Scalar.t->tendendmoduleError_core=structincludeTezos_error_monad.Core_maker.Make(structletid=Format.asprintf"proto.%s."Param.nameend)(structtypet=[`Branch(** Errors that may not happen in another context *)|`Temporary(** Errors that may not happen in a later context *)|`Permanent(** Errors that will happen no matter the context *)|`Outdated(** Errors that happen when the context is too old *)]letdefault_category=`Temporaryletstring_of_category=function|`Permanent->"permanent"|`Outdated->"outdated"|`Branch->"branch"|`Temporary->"temporary"letclassify=function|`Permanent->Tezos_error_monad.Error_classification.Permanent|`Branch->Branch|`Temporary->Temporary|`Outdated->Outdatedend)endtypeerror_category=Error_core.error_categorytypeshell_error+=Ecoproto_errorofError_core.errormoduleWrapped_error_monad=structtypeunwrapped=Error_core.error=..include(Error_core:sigincludeTezos_error_monad.Sig.COREwithtypeerror:=unwrappedandtypeerror_category=error_categoryend)letunwrap=functionEcoproto_errorecoerror->Someecoerror|_->Noneletwrapecoerror=Ecoproto_errorecoerrorendmoduleError_monad=structtypeshell_tztrace=Error_monad.tztracetype'ashell_tzresult=('a,Error_monad.tztrace)resultincludeError_coreincludeTezos_error_monad.TzLwtreslib.MonadincludeTezos_error_monad.Monad_maker.Make(Error_core)(TzTrace)(Tezos_error_monad.TzLwtreslib.Monad)(* Backwards compatibility additions (dont_wait, trace helpers) *)includeTezos_protocol_environment_structs.V11.Error_monad_infix_globalslettzfaile=Lwt.return_error(TzTrace.makee)leterrore=Error(TzTrace.makee)letdont_waitexerf=dont_waitferexlettrace_of_errore=TzTrace.makeeletmake_trace_encodinge=TzTrace.encodingeletpp_trace=pp_print_tracetype'errtrace='errTzTrace.trace(* Shadowing catch to prevent catching system exceptions *)typeerror+=Exnofexnlet()=register_error_kind`Temporary~id:"failure"~title:"Exception"~description:"Exception safely wrapped in an error"~pp:(funppfs->Format.fprintfppf"@[<h 0>%a@]"Format.pp_print_texts)Data_encoding.(obj1(req"msg"@@stringPlain))(function|Exn(Failuremsg)->Somemsg|Exnexn->Some(Printexc.to_stringexn)|_->None)(funmsg->Exn(Failuremsg))leterror_of_exne=TzTrace.make@@Exneletcatch?catch_onlyf=Result.catch?catch_onlyf|>Result.map_errorerror_of_exnletcatch_f?catch_onlyfh=Result.catch?catch_onlyf|>Result.map_error(fune->trace_of_error(he))letcatch_s?catch_onlyf=letopenLwt_syntaxinlet+r=Result.catch_s?catch_onlyfinResult.map_error(fune->error_of_exne)rletboth_e=Tezos_error_monad.TzLwtreslib.Monad.Traced_result_syntax.bothletjoin_e=Tezos_error_monad.TzLwtreslib.Monad.Traced_result_syntax.joinletall_e=Tezos_error_monad.TzLwtreslib.Monad.Traced_result_syntax.allendlet()=letid=Format.asprintf"proto.%s.wrapper"Param.nameinShell_error_monad.register_wrapped_error_kind(moduleWrapped_error_monad)~id~title:("Error returned by protocol "^Param.name)~description:("Wrapped error for economic protocol "^Param.name^".")letwrap_tzerrorerror=Ecoproto_errorerrorletwrap_tztracet=List.mapwrap_tzerrortletwrap_tzresultr=Result.map_errorwrap_tztracermoduleChain_id =Chain_idmoduleBlock_hash=Block_hashmoduleOperation_hash=Operation_hashmoduleOperation_list_hash=Operation_list_hashmoduleOperation_list_list_hash=Operation_list_list_hashmoduleContext_hash=Context_hashmoduleProtocol_hash=Protocol_hashmoduleBlake2B=Tezos_crypto.Blake2BmoduleFitness=FitnessmoduleOperation=OperationmoduleBlock_header=Block_headermoduleBounded=BoundedmoduleProtocol=ProtocolmoduleRPC_arg=Tezos_rpc.ArgmoduleRPC_path=Tezos_rpc.PathmoduleRPC_query=Tezos_rpc.QuerymoduleRPC_service=Tezos_rpc.ServicemoduleRPC_answer=structtype'ot=[`Okof'o(* 200 *)|`OkChunkof'o(* 200 but with chunked transfer encoding *)|`OkStreamof'ostream(* 200 *)|`Createdofstringoption(* 201 *)|`No_content(* 204 *)|`UnauthorizedofError_monad.errorlistoption(* 401 *)|`ForbiddenofError_monad.errorlistoption(* 403 *)|`Not_foundofError_monad.errorlistoption(* 404 *)|`ConflictofError_monad.errorlistoption(* 409 *)|`ErrorofError_monad.errorlistoption(* 500 *)]and'astream='aResto_directory.Answer.stream={next:unit->'aoptionLwt.t;shutdown:unit->unit;}letreturnx=Lwt.return(`Okx)letreturn_chunkedx=Lwt.return(`OkChunkx)letreturn_streamx=Lwt.return(`OkStreamx)letnot_found=Lwt.return(`Not_foundNone)letfailerr=Lwt.return(`Error(Someerr))endmoduleRPC_directory=structincludeTezos_rpc.Directoryletgen_registerdirservicehandler=letopenLwt_syntaxingen_registerdirservice(funpqi->let*r=handlerpqiinmatchrwith|`Oko->RPC_answer.returno|`OkChunko->RPC_answer.return_chunkedo|`OkStreams->RPC_answer.return_streams|`Createds->Lwt.return(`Createds)|`No_content->Lwt.return`No_content|`Unauthorizede->lete=Option.map(List.map(fune->Ecoproto_errore))einLwt.return(`Unauthorizede)|`Forbiddene->lete=Option.map(List.map(fune->Ecoproto_errore))einLwt.return(`Forbiddene)|`Not_founde->lete=Option.map(List.map(fune->Ecoproto_errore))einLwt.return(`Not_founde)|`Conflicte->lete=Option.map(List.map(fune->Ecoproto_errore))einLwt.return(`Conflicte)|`Errore->lete=Option.map(List.map(fune->Ecoproto_errore))einLwt.return(`Errore))letregister~chunkeddirservicehandler=letopenLwt_syntaxingen_registerdirservice(funpqi->let*r=handlerpqiinmatchrwith|Okowhenchunked->RPC_answer.return_chunkedo|Oko(* otherwise *)->RPC_answer.returno|Errore->RPC_answer.faile)letopt_register~chunkeddirservicehandler=letopenLwt_syntaxingen_registerdirservice(funpqi->let*r=handlerpqiinmatchrwith|Ok(Someo)whenchunked->RPC_answer.return_chunkedo|Ok(Someo)(* otherwise *)->RPC_answer.returno|OkNone->RPC_answer.not_found|Errore->RPC_answer.faile)letlwt_register~chunkeddirservicehandler=letopenLwt_syntaxingen_registerdirservice(funpqi->let*o=handlerpqiinifchunkedthenRPC_answer.return_chunkedoelseRPC_answer.returno)openCurryletregister0~chunkedrootsf=register~chunkedroots(curryZf)letregister1~chunkedrootsf=register~chunkedroots(curry(SZ)f)letregister2~chunkedrootsf=register~chunkedroots(curry(S(SZ))f)letregister3~chunkedrootsf=register~chunkedroots(curry(S(S(SZ)))f)letregister4~chunkedrootsf=register~chunkedroots(curry(S(S(S(SZ))))f)letregister5~chunkedrootsf=register~chunkedroots(curry(S(S(S(S(SZ)))))f)letopt_register0~chunkedrootsf=opt_register~chunkedroots(curryZf)letopt_register1~chunkedrootsf=opt_register~chunkedroots(curry(SZ)f)letopt_register2~chunkedrootsf=opt_register~chunkedroots(curry(S(SZ))f)letopt_register3~chunkedrootsf=opt_register~chunkedroots(curry(S(S(SZ)))f)letopt_register4~chunkedrootsf=opt_register~chunkedroots(curry(S(S(S(SZ))))f)letopt_register5~chunkedrootsf=opt_register~chunkedroots(curry(S(S(S(S(SZ)))))f)letgen_register0rootsf=gen_registerroots(curryZf)letgen_register1rootsf=gen_registerroots(curry(SZ)f)letgen_register2rootsf=gen_registerroots(curry(S(SZ))f)letgen_register3rootsf=gen_registerroots(curry(S(S(SZ)))f)letgen_register4rootsf=gen_registerroots(curry(S(S(S(SZ))))f)letgen_register5rootsf=gen_registerroots(curry(S(S(S(S(SZ)))))f)letlwt_register0~chunkedrootsf=lwt_register~chunkedroots(curryZf)letlwt_register1~chunkedrootsf=lwt_register~chunkedroots(curry(SZ)f)letlwt_register2~chunkedrootsf=lwt_register~chunkedroots(curry(S(SZ))f)letlwt_register3~chunkedrootsf=lwt_register~chunkedroots(curry(S(S(SZ)))f)letlwt_register4~chunkedrootsf=lwt_register~chunkedroots(curry(S(S(S(SZ))))f)letlwt_register5~chunkedrootsf=lwt_register~chunkedroots(curry(S(S(S(S(SZ)))))f)endmoduleRPC_context=structtypet=rpc_contextclasstype['pr]simple=objectmethodcall_proto_service0:'m'q'i'o.(([<Tezos_rpc.Service.meth]as'm),t,t,'q,'i,'o)Tezos_rpc.Service.t->'pr->'q->'i->'oError_monad.shell_tzresultLwt.tmethodcall_proto_service1:'m'a'q'i'o.(([<Tezos_rpc.Service.meth]as'm),t,t*'a,'q,'i,'o)Tezos_rpc.Service.t->'pr->'a->'q->'i->'oError_monad.shell_tzresultLwt.tmethodcall_proto_service2:'m'a'b'q'i'o.(([<Tezos_rpc.Service.meth]as'm),t,(t*'a)*'b,'q,'i,'o)Tezos_rpc.Service.t->'pr->'a->'b->'q->'i->'oError_monad.shell_tzresultLwt.tmethodcall_proto_service3:'m'a'b'c'q'i'o.(([<RPC_service.meth]as'm),t,((t*'a)*'b)*'c,'q,'i,'o)RPC_service.t->'pr->'a->'b->'c->'q->'i->'oError_monad.shell_tzresultLwt.tendletmake_call0s(ctxt:_simple)=ctxt#call_proto_service0sletmake_call0=(make_call0:_->_simple->_:>_->_#simple->_)letmake_call1s(ctxt:_simple)=ctxt#call_proto_service1sletmake_call1=(make_call1:_->_simple->_:>_->_#simple->_)letmake_call2s(ctxt:_simple)=ctxt#call_proto_service2sletmake_call2=(make_call2:_->_simple->_:>_->_#simple->_)letmake_call3s(ctxt:_simple)=ctxt#call_proto_service3sletmake_call3=(make_call3:_->_simple->_:>_->_#simple->_)letmake_opt_call0sctxtblockqi=letopenLwt_syntaxinlet*r=make_call0sctxtblockqiinmatchrwith|Error[Tezos_rpc.Context.Not_found_]->Lwt.return_okNone|Error_asv->Lwt.returnv|Okv->Lwt.return_ok(Somev)letmake_opt_call1sctxtblocka1qi=letopenLwt_syntaxinlet*r=make_call1sctxtblocka1qiinmatchrwith|Error[Tezos_rpc.Context.Not_found_]->Lwt.return_okNone|Error_asv->Lwt.returnv|Okv->Lwt.return_ok(Somev)letmake_opt_call2 sctxtblocka1a2qi=letopenLwt_syntaxinlet*r=make_call2sctxtblocka1a2qiinmatchrwith|Error[Tezos_rpc.Context.Not_found_]->Lwt.return_okNone|Error_asv->Lwt.returnv|Okv->Lwt.return_ok(Somev)letmake_opt_call3sctxtblocka1a2a3qi=letopenLwt_syntaxinlet*r=make_call3sctxtblocka1a2a3qiinmatchrwith|Error[Tezos_rpc.Context.Not_found_]->Lwt.return_okNone|Error_asv->Lwt.returnv|Okv->Lwt.return_ok(Somev)endmoduleSapling=Tezos_sapling.Core.ValidatormoduleMicheline=structincludeMichelineincludeMicheline_encoding(* The environment exposes a single canonical encoding for Micheline
expression. Since env-V4, it is encoding-v2 because this is the most
recent, most correct-at-time-of-writing encoding. For backwards
compatibility reason, you should never upgrade (nor downgrade) this.
Future fixes and improvements of the encoding should be made available in
future environments only. *)letcanonical_encoding~variantencoding=canonical_encoding_v2~variant:(Param.name^"."^variant)encodingendmoduleUpdater=structtypenonrecvalidation_result=validation_result={context:Context.t;fitness:Fitness.t;message:stringoption;max_operations_ttl:int;last_allowed_fork_level:Int32.t;}typenonrecquota=quota={max_size:int;max_op:intoption}typenonrecrpc_context=rpc_context={block_hash:Block_hash.t;block_header:Block_header.shell_header;context:Context.t;}letactivate=Context.set_protocolmoduletypePROTOCOL=Environment_protocol_T_V10.Twithtypecontext:=Context.tandtypecache_value:=Environment_context.Context.cache_valueandtypecache_key:=Environment_context.Context.cache_keyandtypequota:=quotaandtypevalidation_result:=validation_resultandtyperpc_context:=rpc_contextandtypetztrace:=Error_monad.tztraceandtype'atzresult:='aError_monad.tzresultendmoduleBase58=structincludeTezos_crypto.Base58letsimple_encodeencs=simple_encodeencsletsimple_decodeencs=simple_decodeencsincludeMake(structtypecontext=Context.tend)letdecodes=decodesendmoduleContext=structincludeContextincludeEnvironment_context.V11moduletypePROOF_ENCODING=Tezos_context_sigs.Context.PROOF_ENCODINGmoduleProof_encoding=Tezos_context_merkle_proof_encoding.Merkle_proof_encodingletcompletectxts=Base58.completectxtsendmoduleContext_binary=structincludeTezos_context_memory.Context_binarymoduleTree=structtypenonrectree=treetypenonrect=ttypekey=stringlisttypevalue=bytesincludeTezos_context_memory.Context_binary.TreeendendmoduleWasm_2_0_0=structtypeinput=Tezos_scoru_wasm.Wasm_pvm_state.input_info={inbox_level:Bounded.Non_negative_int32.t;message_counter:Z.t;}typeoutput=Tezos_scoru_wasm.Wasm_pvm_state.output_info={outbox_level:Bounded.Non_negative_int32.t;message_index:Z.t;}typereveal=Tezos_scoru_wasm.Wasm_pvm_state.reveal=|Reveal_rawofstringtypeinput_request=Tezos_scoru_wasm.Wasm_pvm_state.input_request=|No_input_required|Input_required|Reveal_requiredofrevealtypeinfo=Tezos_scoru_wasm.Wasm_pvm_state.info={current_tick:Z.t;last_input_read:inputoption;input_request:input_request;}typeversion=Tezos_scoru_wasm.Wasm_pvm_state.versionletv3=Tezos_scoru_wasm.Wasm_pvm_state.V3moduleMake(Tree:Context.TREEwithtypekey=stringlistandtypevalue=bytes)=structtypeTezos_tree_encoding.tree_instance+=PVM_treeofTree.treeincludeTezos_scoru_wasm.Wasm_pvm.Make(structincludeTreeletselect=function|PVM_treet->t|_->raiseTezos_tree_encoding.Incorrect_tree_typeletwrapt=PVM_treetend)endendmoduleLift(P:Updater.PROTOCOL)=structletenvironment_version=Protocol.V11letexpected_context_hash=Predecessor_resulting_contextincludePletvalue_of_key~chain_id~predecessor_context~predecessor_timestamp~predecessor_level~predecessor_fitness~predecessor~timestamp=letopenLwt_result_syntaxinlet*!r=value_of_key~chain_id~predecessor_context~predecessor_timestamp~predecessor_level~predecessor_fitness~predecessor~timestampinlet*?f=wrap_tzresultrinreturn(funx->let*!r=fxinLwt.return(wrap_tzresultr))(** Ensure that the cache is correctly loaded in memory
before running any operations. *)letload_predecessor_cachepredecessor_contextchain_idmode(predecessor_header:Block_header.shell_header)cache=letopenLwt_result_syntaxinletpredecessor_hash,timestamp=matchmodewith|Applicationblock_header|Partial_validationblock_header->(block_header.shell.predecessor,block_header.shell.timestamp)|Construction{predecessor_hash;timestamp;_}|Partial_construction{predecessor_hash;timestamp}->(predecessor_hash,timestamp)inlet*value_of_key=value_of_key~chain_id~predecessor_context~predecessor_timestamp:predecessor_header.timestamp~predecessor_level:predecessor_header.level~predecessor_fitness:predecessor_header.fitness~predecessor:predecessor_hash~timestampinContext.load_cachepredecessor_hashpredecessor_contextcachevalue_of_keyletbegin_validationctxtchain_idmode~predecessor~cache=letopenLwt_result_syntaxinlet*ctxt=load_predecessor_cachectxtchain_idmodepredecessorcacheinlet*!validation_state=begin_validationctxtchain_idmode~predecessorinLwt.return(wrap_tzresultvalidation_state)letvalidate_operation?check_signaturevalidation_stateophoperation=letopenLwt_syntaxinlet+validation_state=validate_operation?check_signaturevalidation_stateophoperationinwrap_tzresultvalidation_stateletfinalize_validationvalidation_state=letopenLwt_syntaxinlet+res=finalize_validationvalidation_stateinwrap_tzresultresletbegin_applicationctxtchain_idmode~predecessor~cache=letopenLwt_result_syntaxinlet*ctxt=load_predecessor_cachectxtchain_idmodepredecessorcacheinlet*!application_state=begin_applicationctxtchain_id~predecessormodeinLwt.return(wrap_tzresultapplication_state)letapply_operationapplication_stateophoperation=letopenLwt_syntaxinlet+application_state=apply_operationapplication_stateophoperationinwrap_tzresultapplication_stateletfinalize_applicationstateshell_header=letopenLwt_syntaxinlet+res=finalize_applicationstateshell_headerinwrap_tzresultresletinitchain_idcbh=letopenLwt_syntaxinlet+r=initchain_idcbhinwrap_tzresultrletset_log_message_consumerf=Logging.logging_function:=SomefmoduleMempool=structincludeMempooltypeadd_error=|Validation_errorofError_monad.shell_tztrace|Add_conflictofoperation_conflictletadd_operation?check_signature?conflict_handlerinfomempoolop:(t*add_result,add_error)resultLwt.t=letopenLwt_syntaxinlet+r=Mempool.add_operation?check_signature?conflict_handlerinfomempoolopinmatchrwith|Okv->Okv|Error(Mempool.Validation_errore)->Error(Validation_error(wrap_tztracee))|Error(Mempool.Add_conflictc)->Error(Add_conflictc)letinitctxtchain_id~head_hash~head~cache=letopenLwt_result_syntaxinlet*ctxt=load_predecessor_cachectxtchain_id(Partial_construction{predecessor_hash=head_hash;timestamp=head.Block_header.timestamp;})headcacheinlet*!r=initctxtchain_id~head_hash~headinLwt.return(wrap_tzresultr)endendclass['chain,'block]proto_rpc_context(t:Tezos_rpc.Context.t)(prefix:(unit,(unit*'chain)*'block)RPC_path.t)=objectmethodcall_proto_service0:'m'q'i'o.(([<RPC_service.meth]as'm),RPC_context.t,RPC_context.t,'q,'i,'o)RPC_service.t->'chain*'block->'q->'i->'otzresultLwt.t=funs(chain,block)qi->lets=RPC_service.subst0sinlets=RPC_service.prefixprefixsint#call_services(((),chain),block)qimethodcall_proto_service1:'m'a'q'i'o.(([<RPC_service.meth]as'm),RPC_context.t,RPC_context.t*'a,'q,'i,'o)RPC_service.t->'chain*'block->'a->'q->'i->'otzresultLwt.t=funs(chain,block)a1qi->lets=RPC_service.subst1sinlets=RPC_service.prefixprefixsint#call_services((((),chain),block),a1)qimethodcall_proto_service2:'m'a'b'q'i'o.(([<RPC_service.meth]as'm),RPC_context.t,(RPC_context.t*'a)*'b,'q,'i,'o)RPC_service.t->'chain*'block->'a->'b->'q->'i->'otzresultLwt.t=funs(chain,block)a1a2qi->lets=RPC_service.subst2sinlets=RPC_service.prefixprefixsint#call_services(((((),chain),block),a1),a2)qimethodcall_proto_service3:'m'a'b'c'q'i'o.(([<RPC_service.meth]as'm),RPC_context.t,((RPC_context.t*'a)*'b)*'c,'q,'i,'o)RPC_service.t->'chain*'block->'a->'b->'c->'q->'i->'otzresultLwt.t=funs(chain,block)a1a2a3qi->lets=RPC_service.subst3sinlets=RPC_service.prefixprefixsint#call_services((((((),chain),block),a1),a2),a3)qiendclass['block]proto_rpc_context_of_directoryconvdir:['block]RPC_context.simple=letlookup=newTezos_rpc.Context.of_directorydirinobjectmethodcall_proto_service0:'m'q'i'o.(([<RPC_service.meth]as'm),RPC_context.t,RPC_context.t,'q,'i,'o)RPC_service.t->'block->'q->'i->'otzresultLwt.t=funsblockqi->letrpc_context=convblockinlookup#call_servicesrpc_contextqimethodcall_proto_service1:'m'a'q'i'o.(([<RPC_service.meth]as'm),RPC_context.t,RPC_context.t*'a,'q,'i,'o)RPC_service.t->'block->'a->'q->'i->'otzresultLwt.t=funsblocka1qi->letrpc_context=convblockinlookup#call_services(rpc_context,a1)qimethodcall_proto_service2:'m'a'b'q'i'o.(([<RPC_service.meth]as'm),RPC_context.t,(RPC_context.t*'a)*'b,'q,'i,'o)RPC_service.t->'block->'a->'b->'q->'i->'otzresultLwt.t=funsblocka1a2qi->letrpc_context=convblockinlookup#call_services((rpc_context,a1),a2)qimethodcall_proto_service3:'m'a'b'c'q'i'o.(([<RPC_service.meth]as'm),RPC_context.t,((RPC_context.t*'a)*'b)*'c,'q,'i,'o)RPC_service.t->'block->'a->'b->'c->'q->'i->'otzresultLwt.t=funsblocka1a2a3qi->letrpc_context=convblockinlookup#call_services(((rpc_context,a1),a2),a3)qiendmoduleEquality_witness=Environment_context.Equality_witnessmodulePlonk=Tezos_protocol_environment_structs.V11.PlonkmoduleDal=structincludeTezos_crypto_dal.Cryptobox.Verifierletverify_pagetcommitment~page_indexpagepage_proof=matchverify_pagetcommitment~page_indexpagepage_proofwith|Error`Page_length_mismatch->Error`Page_length_mismatch|Error`Page_index_out_of_range->Error`Segment_index_out_of_range|Error(`Invalid_page|`Invalid_degree_strictly_less_than_expected_)->Okfalse|Ok()->OktrueendmoduleSkip_list=Skip_listmoduleSmart_rollup=structmoduleAddress=Tezos_crypto.Hashed.Smart_rollup_addressmoduleCommitment_hash=Tezos_crypto.Hashed.Smart_rollup_commitment_hashmoduleState_hash=Tezos_crypto.Hashed.Smart_rollup_state_hashmoduleInbox_hash=Tezos_crypto.Hashed.Smart_rollup_inbox_hashmoduleMerkelized_payload_hashes_hash=Tezos_crypto.Hashed.Smart_rollup_merkelized_payload_hashes_hashendend