Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file michelson_v1_gas.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* Copyright (c) 2019-2020 Nomadic Labs <contact@nomadic-labs.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. *)(* *)(*****************************************************************************)openAlpha_contextopenGasmoduleS=Saturation_reprmoduleCost_of=structmoduleS_syntax=struct(* This is a good enough approximation. S.numbits 0 = 0 *)letlog2x=S.safe_int(1+S.numbitsx)let(+)=S.addlet(*)=S.mullet(lsr)=S.shift_rightendletz_bytes(z:Z.t)=letbits=Z.numbitszin(7+bits)/8letint_bytes(z:'aScript_int.num)=z_bytes(Script_int.to_zintz)letmanager_operation=step_cost@@S.safe_int1_000moduleGenerated_costs=struct(* Automatically generated costs functions. *)(* model N_IAbs_int *)(* Approximating 0.065045 x term *)letcost_N_IAbs_intsize=S.safe_int(25+(sizelsr4))(* model N_IAdd_bls12_381_fr *)(* when benchmarking, compile bls12-381-unix without ADX *)letcost_N_IAdd_bls12_381_fr=S.safe_int45(* model N_IAdd_bls12_381_g1 *)(* when benchmarking, compile bls12-381-unix without ADX *)letcost_N_IAdd_bls12_381_g1=S.safe_int925(* model N_IAdd_bls12_381_g2 *)(* when benchmarking, compile bls12-381-unix without ADX *)letcost_N_IAdd_bls12_381_g2=S.safe_int2_520letcost_linear_op_intsize1size2=letopenS_syntaxinletv0=S.safe_int(Compare.Int.maxsize1size2)inS.safe_int55+((v0lsr4)+(v0lsr7))(* model N_IAdd_int *)(* Approximating 0.078154 x term *)letcost_N_IAdd_int=cost_linear_op_int(* model N_IAdd_nat *)(* Approximating 0.077807 x term *)letcost_N_IAdd_nat=cost_linear_op_int(* model N_IAdd_seconds_to_timestamp *)(* Approximating 0.078056 x term *)letcost_N_IAdd_seconds_to_timestamp=cost_linear_op_int(* model N_IAdd_tez *)letcost_N_IAdd_tez=S.safe_int20(* model N_IAdd_timestamp_to_seconds *)(* Approximating 0.077771 x term *)letcost_N_IAdd_timestamp_to_seconds=cost_linear_op_int(* model N_IAddress *)letcost_N_IAddress=S.safe_int10(* model N_IAmount *)letcost_N_IAmount=S.safe_int15(* model N_IAnd *)letcost_N_IAnd=S.safe_int20(* model N_IAnd_int_nat *)(* Approximating 0.076804 x 2 x term *)letcost_N_IAnd_int_natsize1size2=letopenS_syntaxinletv0=S.safe_int(Compare.Int.minsize1size2)inS.safe_int50+((v0lsr3)+(v0lsr6))(* model N_IAnd_nat *)(* Approximating 0.076804 x term *)(* The difference with `cost_N_IAnd_int_nat` comes from Zarith, where the
complexity of `Z.logand` depends on the sign of the argument. *)letcost_N_IAnd_natsize1size2=letopenS_syntaxinletv0=S.safe_int(Compare.Int.minsize1size2)inS.safe_int50+((v0lsr4)+(v0lsr7))(* model N_IApply *)letcost_N_IApply=S.safe_int160(* model N_IBlake2b *)(* Approximating 1.120804 x term *)letcost_N_IBlake2bsize=letopenS_syntaxinletv0=S.safe_intsizeinS.safe_int430+v0+(v0lsr3)(* model N_IBytes_size *)letcost_N_IBytes_size=S.safe_int15(* model N_ICar *)letcost_N_ICar=S.safe_int10(* model N_ICdr *)letcost_N_ICdr=S.safe_int10(* model N_IChainId *)letcost_N_IChainId=S.safe_int15(* model N_ICheck_signature_ed25519 *)(* Approximating 1.123507 x term *)letcost_N_ICheck_signature_ed25519size=letopenS_syntaxinletv0=S.safe_intsizeinS.safe_int65_800+(v0+(v0lsr3))(* model N_ICheck_signature_p256 *)(* Approximating 1.111539 x term *)letcost_N_ICheck_signature_p256size=letopenS_syntaxinletv0=S.safe_intsizeinS.safe_int990_000+(v0+(v0lsr3))(* model N_ICheck_signature_secp256k1 *)(* Approximating 1.125404 x term *)letcost_N_ICheck_signature_secp256k1size=letopenS_syntaxinletv0=S.safe_intsizeinS.safe_int51_600+(v0+(v0lsr3))(* model N_IComb *)(* Approximating 3.531001 x term *)(* Note: size >= 2, so the cost is never 0 *)letcost_N_ICombsize=letopenS_syntaxinletv0=S.safe_intsizein(S.safe_int3*v0)+(v0lsr1)+(v0lsr5)(* model N_IComb_get *)(* Approximating 0.573180 x term *)letcost_N_IComb_getsize=letopenS_syntaxinletv0=S.safe_intsizeinS.safe_int30+(v0lsr1)+(v0lsr4)(* model N_IComb_set *)(* Approximating 1.287531 x term *)letcost_N_IComb_setsize=letopenS_syntaxinletv0=S.safe_intsizeinS.safe_int40+(v0+(v0lsr2)+(v0lsr5))(* Model N_ICompare *)(* Approximating 0.024413 x term *)letcost_N_IComparesize1size2=letopenS_syntaxinletv0=S.safe_int(Compare.Int.minsize1size2)inS.safe_int35+((v0lsr6)+(v0lsr7))(* model N_IConcat_bytes_pair *)(* Approximating 0.065017 x term *)letcost_N_IConcat_bytes_pairsize1size2=letopenS_syntaxinletv0=S.safe_intsize1+S.safe_intsize2inS.safe_int65+(v0lsr4)(* model N_IConcat_string_pair *)(* Approximating 0.061402 x term *)letcost_N_IConcat_string_pairsize1size2=letopenS_syntaxinletv0=S.safe_intsize1+S.safe_intsize2inS.safe_int65+(v0lsr4)(* model N_ICons_list *)letcost_N_ICons_list=S.safe_int15(* model N_ICons_none *)letcost_N_ICons_none=S.safe_int15(* model N_ICons_pair *)letcost_N_ICons_pair=S.safe_int15(* model N_ICons_some *)letcost_N_ICons_some=S.safe_int15(* model N_IConst *)letcost_N_IConst=S.safe_int10(* model N_IContract *)letcost_N_IContract=S.safe_int30(* model N_ICreate_contract *)letcost_N_ICreate_contract=S.safe_int30(* model N_IDiff_timestamps *)(* Approximating 0.077922 x term *)letcost_N_IDiff_timestamps=cost_linear_op_int(* model N_IDig *)(* Approximating 6.750442 x term *)letcost_N_IDigsize=letopenS_syntaxinletv0=S.safe_intsizeinS.safe_int60+((S.safe_int6*v0)+(v0lsr1)+(v0lsr2))(* model N_IDip *)letcost_N_IDip=S.safe_int15(* model N_IDipN *)(* Approximating 1.708122 x term *)letcost_N_IDipNsize=letopenS_syntaxinletv0=S.safe_intsizeinS.safe_int45+(v0+(v0lsr1)+(v0lsr3))(* model N_IView *)letcost_N_IView=S.safe_int1460(* model N_IDrop *)letcost_N_IDrop=S.safe_int10(* model N_IDropN *)(* Approximating 2.713108 x term *)letcost_N_IDropNsize=letopenS_syntaxinletv0=S.safe_intsizeinS.safe_int60+(S.safe_int2*v0)+(v0lsr1)+(v0lsr3)(* model N_IDug *)(* Approximating 6.718396 x term *)letcost_N_IDugsize=letopenS_syntaxinletv0=S.safe_intsizeinS.safe_int60+((S.safe_int6*v0)+(v0lsr1)+(v0lsr2))(* model N_IDup *)letcost_N_IDup=S.safe_int10(* model N_IDupN *)(* Approximating 1.129785 x term *)letcost_N_IDupNsize=letopenS_syntaxinletv0=S.safe_intsizeinS.safe_int20+v0+(v0lsr3)letcost_div_intsize1size2=letq=size1-size2inifCompare.Int.(q<0)thenS.safe_int140elseletopenS_syntaxinletv0=S.safe_intq*S.safe_intsize2inS.safe_int140+(v0lsr10)+(v0lsr11)+(v0lsr13)(* model N_IEdiv_int *)(* Approximating 0.001591 x term *)letcost_N_IEdiv_int=cost_div_int(* model N_IEdiv_nat *)(* Approximating 0.001605 x term *)letcost_N_IEdiv_nat=cost_div_int(* model N_IEdiv_tez *)letcost_N_IEdiv_tez=S.safe_int140(* model N_IEdiv_teznat *)letcost_N_IEdiv_teznat=S.safe_int140(* model N_IEmpty_big_map *)letcost_N_IEmpty_big_map=S.safe_int15(* model N_IEmpty_map *)letcost_N_IEmpty_map=S.safe_int220(* model N_IEmpty_set *)letcost_N_IEmpty_set=S.safe_int220(* model N_IEq *)letcost_N_IEq=S.safe_int15(* model N_IExec *)letcost_N_IExec=S.safe_int15(* model N_IFailwith *)(* let cost_N_IFailwith = S.safe_int 105 *)(* model N_IGe *)letcost_N_IGe=S.safe_int15(* model N_IGt *)letcost_N_IGt=S.safe_int15(* model N_IHalt *)letcost_N_IHalt=S.safe_int15(* model N_IHash_key *)letcost_N_IHash_key=S.safe_int655(* model N_IIf *)letcost_N_IIf=S.safe_int10(* model N_IIf_cons *)letcost_N_IIf_cons=S.safe_int10(* model N_IIf_left *)letcost_N_IIf_left=S.safe_int10(* model N_IIf_none *)letcost_N_IIf_none=S.safe_int10(* model N_IOpt_map *)letcost_opt_map=S.safe_int15(* model N_IImplicit_account *)letcost_N_IImplicit_account=S.safe_int10(* model N_IInt_bls12_381_z_fr *)(* when benchmarking, compile bls12-381-unix without ADX *)letcost_N_IInt_bls12_381_z_fr=S.safe_int125(* model N_IInt_nat *)letcost_N_IInt_nat=S.safe_int15(* model N_IIs_nat *)letcost_N_IIs_nat=S.safe_int15(* model N_IKeccak *)(* Approximating 8.276352 x term *)letcost_N_IKeccaksize=letopenS_syntaxinletv0=S.safe_intsizeinS.safe_int1350+((S.safe_int8*v0)+(v0lsr2))(* model N_ILambda *)letcost_N_ILambda=S.safe_int10(* model N_ILe *)letcost_N_ILe=S.safe_int15(* model N_ILeft *)letcost_N_ILeft=S.safe_int15(* model N_ILevel *)letcost_N_ILevel=S.safe_int15(* model N_IList_iter *)letcost_N_IList_iter_=S.safe_int25(* model N_IList_map *)letcost_N_IList_map_=S.safe_int25(* model N_IList_size *)letcost_N_IList_size=S.safe_int15(* model N_ILoop *)letcost_N_ILoop=S.safe_int10(* model N_ILoop_left *)letcost_N_ILoop_left=S.safe_int10(* model N_ILsl_nat *)(* Approximating 0.115642 x term *)letcost_N_ILsl_natsize=letopenS_syntaxinletv0=S.safe_intsizeinS.safe_int60+((v0lsr4)+(v0lsr5)+(v0lsr6))(* model N_ILsr_nat *)(* Approximating 0.115565 x term *)letcost_N_ILsr_natsize=letopenS_syntaxinletv0=S.safe_intsizeinS.safe_int60+((v0lsr4)+(v0lsr5)+(v0lsr6))(* model N_ILt *)letcost_N_ILt=S.safe_int15(* model N_IMap_get *)(* Approximating 0.048359 x term *)letcost_N_IMap_getsize1size2=letopenS_syntaxinletv0=size1*log2size2inS.safe_int110+(v0lsr5)+(v0lsr6)(* model N_IMap_get_and_update *)(* Approximating 0.145661 x term *)letcost_N_IMap_get_and_updatesize1size2=letopenS_syntaxinletv0=size1*log2size2inS.safe_int135+(v0lsr3)+(v0lsr6)(* model N_IMap_iter *)(* Approximating 7.621331 x term *)letcost_N_IMap_itersize=letopenS_syntaxinletv0=S.safe_intsizeinS.safe_int70+(S.safe_int7*v0)+(v0lsr1)+(v0lsr3)(* model N_IMap_map *)(* Approximating 7.46280485884 x term *)letcost_N_IMap_mapsize=letopenS_syntaxinletv0=S.safe_intsizeinS.safe_int265+((S.safe_int7*v0)+(v0lsr1))(* model N_IMap_mem *)(* Approximating 0.048446 x term *)letcost_N_IMap_memsize1size2=letopenS_syntaxinletv0=size1*log2size2inS.safe_int110+(v0lsr5)+(v0lsr6)(* model N_IMap_size *)letcost_N_IMap_size=S.safe_int15(* model N_IMap_update *)(* Approximating 0.097072 x term *)letcost_N_IMap_updatesize1size2=letopenS_syntaxinletv0=size1*log2size2inS.safe_int130+(v0lsr4)+(v0lsr5)(* model N_IMul_bls12_381_fr *)(* when benchmarking, compile bls12-381-unix without ADX *)letcost_N_IMul_bls12_381_fr=S.safe_int65(* model N_IMul_bls12_381_fr_z *)(* Approximating 1.059386 x term *)(* when benchmarking, compile bls12-381-unix without ADX *)letcost_N_IMul_bls12_381_fr_zsize1=letopenS_syntaxinletv0=S.safe_intsize1inS.safe_int330+v0+(v0lsr4)(* model N_IMul_bls12_381_g1 *)(* when benchmarking, compile bls12-381-unix without ADX *)letcost_N_IMul_bls12_381_g1=S.safe_int103_000(* model N_IMul_bls12_381_g2 *)(* when benchmarking, compile bls12-381-unix without ADX *)letcost_N_IMul_bls12_381_g2=S.safe_int220_000(* model N_IMul_bls12_381_z_fr *)(* Approximating 1.068674 x term *)(* when benchmarking, compile bls12-381-unix without ADX *)letcost_N_IMul_bls12_381_z_frsize1=letopenS_syntaxinletv0=S.safe_intsize1inS.safe_int330+v0+(v0lsr4)letcost_mulsize1size2=letopenS_syntaxinleta=S.add(S.safe_intsize1)(S.safe_intsize2)inletv0=a*log2ainS.safe_int100+(v0lsr1)+(v0lsr2)+(v0lsr4)(* model N_IMul_int *)(* Approximating 0.857931 x term *)letcost_N_IMul_int=cost_mul(* model N_IMul_nat *)(* Approximating 0.861823 x term *)letcost_N_IMul_nat=cost_mul(* model N_IMul_nattez *)letcost_N_IMul_nattez=S.safe_int50(* model N_IMul_teznat *)letcost_N_IMul_teznat=S.safe_int50(* model N_INeg_bls12_381_fr *)(* when benchmarking, compile bls12-381-unix without ADX *)letcost_N_INeg_bls12_381_fr=S.safe_int45(* model N_INeg_bls12_381_g1 *)(* when benchmarking, compile bls12-381-unix without ADX *)letcost_N_INeg_bls12_381_g1=S.safe_int60(* model N_INeg_bls12_381_g2 *)(* when benchmarking, compile bls12-381-unix without ADX *)letcost_N_INeg_bls12_381_g2=S.safe_int85(* model N_INeg *)(* Approximating 0.066076 x term *)letcost_N_INegsize=letopenS_syntaxinS.safe_int40+(S.safe_intsizelsr4)(* model N_INeq *)letcost_N_INeq=S.safe_int15(* model N_INil *)letcost_N_INil=S.safe_int15(* model N_INot *)letcost_N_INot=S.safe_int10(* model N_INot_int *)(* Approximating 0.075541 x term *)letcost_N_INot_intsize=letopenS_syntaxinletv0=S.safe_intsizeinS.safe_int50+((v0lsr4)+(v0lsr7))(* model N_INow *)letcost_N_INow=S.safe_int15(* model N_IOpen_chest *)(* 612000 + chest * 19 + time * 19050 *)letcost_N_IOpen_chest~chest~time=letopenS_syntaxinletv0=S.safe_intchestinletv1=S.safe_inttimeinS.safe_int612_000+(S.safe_int19*v0)+(S.safe_int19050*v1)(* model N_IOr *)letcost_N_IOr=S.safe_int15(* model N_IOr_nat *)(* Approximating 0.075758 x term *)letcost_N_IOr_nat=cost_linear_op_int(* model N_IPairing_check_bls12_381 *)(* when benchmarking, compile bls12-381-unix without ADX *)letcost_N_IPairing_check_bls12_381size=S.add(S.safe_int450_000)(S.mul(S.safe_int342_500)(S.safe_intsize))(* model N_IRead_ticket *)letcost_N_IRead_ticket=S.safe_int15(* model N_IRight *)letcost_N_IRight=S.safe_int15(* model N_ISapling_empty_state *)letcost_N_ISapling_empty_state=S.safe_int15(* model N_ISapling_verify_update *)(* Approximating 1.27167 x term *)(* Approximating 38.72115 x term *)letcost_N_ISapling_verify_updatesize1size2=letopenS_syntaxinletv1=S.safe_intsize1inletv0=S.safe_intsize2inS.safe_int84_050+(v1+(v1lsr2))+(S.safe_int39*v0)(* model N_ISelf_address *)letcost_N_ISelf_address=S.safe_int15(* model N_ISelf *)letcost_N_ISelf=S.safe_int15(* model N_ISender *)letcost_N_ISender=S.safe_int15(* model N_ISet_delegate *)letcost_N_ISet_delegate=S.safe_int40(* model N_ISet_iter *)(* Approximating 7.633555 x term *)letcost_N_ISet_itersize=letopenS_syntaxinletv0=S.safe_intsizeinS.safe_int70+(S.safe_int7*v0)+(v0lsr1)+(v0lsr3)(* model N_ISet_size *)letcost_N_ISet_size=S.safe_int15(* model N_ISha256 *)(* Approximating 4.763264 x term *)letcost_N_ISha256size=letopenS_syntaxinletv0=S.safe_intsizeinS.safe_int600+((S.safe_int4*v0)+(v0lsr1)+(v0lsr2))(* model N_ISha3 *)(* Approximating 8.362339 x term *)letcost_N_ISha3=cost_N_IKeccak(* model N_ISha512 *)(* Approximating 3.074641 x term *)letcost_N_ISha512size=letopenS_syntaxinletv0=S.safe_intsizeinS.safe_int680+(S.safe_int3*v0)(* model N_ISlice_bytes *)(* Approximating 0.065752 x term *)letcost_N_ISlice_bytessize=letopenS_syntaxinS.safe_int40+(S.safe_intsizelsr4)(* model N_ISlice_string *)(* Approximating 0.065688 x term *)letcost_N_ISlice_stringsize=letopenS_syntaxinS.safe_int40+(S.safe_intsizelsr4)(* model N_ISource *)letcost_N_ISource=S.safe_int15(* model N_ISplit_ticket *)(* Approximating 0.132362 x term *)letcost_N_ISplit_ticketsize1size2=letopenS_syntaxinletv1=S.safe_int(Compare.Int.maxsize1size2)inS.safe_int55+(v1lsr3)(* model N_IString_size *)letcost_N_IString_size=S.safe_int15(* model N_ISub_int *)(* Approximating 0.077849 x term *)letcost_N_ISub_int=cost_linear_op_int(* model N_ISub_tez *)letcost_N_ISub_tez=S.safe_int20(* model N_ISub_tez_legacy *)letcost_N_ISub_tez_legacy=S.safe_int20(* model N_ISub_timestamp_seconds *)(* Approximating 0.077794 x term *)letcost_N_ISub_timestamp_seconds=cost_linear_op_int(* model N_ISwap *)letcost_N_ISwap=S.safe_int10(* model N_ITicket *)letcost_N_ITicket=S.safe_int15(* model N_ITotal_voting_power *)letcost_N_ITotal_voting_power=S.safe_int370(* model N_ITransfer_tokens *)letcost_N_ITransfer_tokens=S.safe_int30(* model N_IUncomb *)(* Approximating 3.944710 x term *)letcost_N_IUncombsize=letopenS_syntaxinletv0=S.safe_intsizeinS.safe_int25+(S.safe_int4*v0)(* model N_IUnpair *)letcost_N_IUnpair=S.safe_int10(* model N_IVoting_power *)letcost_N_IVoting_power=S.safe_int530(* model N_IXor *)letcost_N_IXor=S.safe_int20(* model N_IXor_nat *)(* Approximating 0.075601 x term *)letcost_N_IXor_nat=cost_linear_op_int(* model N_KCons *)letcost_N_KCons=S.safe_int15(* model N_KIter *)letcost_N_KIter=S.safe_int20(* model N_KList_enter_body *)(* Approximating 1.672196 x term *)letcost_N_KList_enter_bodyxssize_ys=matchxswith|[]->letopenS_syntaxinletv0=S.safe_intsize_ysinS.safe_int40+(v0+(v0lsr1)+(v0lsr3))|_::_->S.safe_int70(* model N_KList_exit_body *)letcost_N_KList_exit_body=S.safe_int30(* model N_KLoop_in *)letcost_N_KLoop_in=S.safe_int15(* model N_KLoop_in_left *)letcost_N_KLoop_in_left=S.safe_int15(* model N_KMap_enter_body *)letcost_N_KMap_enter_body=S.safe_int165(* model N_KNil *)letcost_N_KNil=S.safe_int20(* model N_KReturn *)letcost_N_KReturn=S.safe_int15(* model N_KView_exit *)letcost_N_KView_exit=S.safe_int20(* model N_KMap_head *)letconst_N_KMap_head=S.safe_int20(* model N_KUndip *)letcost_N_KUndip=S.safe_int15(* model DECODING_BLS_FR *)(* when benchmarking, compile bls12-381-unix without ADX, see
https://gitlab.com/dannywillems/ocaml-bls12-381/-/blob/71d0b4d467fbfaa6452d702fcc408d7a70916a80/README.md#install
*)letcost_DECODING_BLS_FR=S.safe_int150(* model DECODING_BLS_G1 *)(* when benchmarking, compile bls12-381-unix without ADX *)letcost_DECODING_BLS_G1=S.safe_int65_300(* model DECODING_BLS_G2 *)(* when benchmarking, compile bls12-381-unix without ADX *)letcost_DECODING_BLS_G2=S.safe_int73_300(* model B58CHECK_DECODING_CHAIN_ID *)letcost_B58CHECK_DECODING_CHAIN_ID=S.safe_int1_600(* model B58CHECK_DECODING_PUBLIC_KEY_HASH_ed25519 *)letcost_B58CHECK_DECODING_PUBLIC_KEY_HASH_ed25519=S.safe_int3_300(* model B58CHECK_DECODING_PUBLIC_KEY_HASH_p256 *)letcost_B58CHECK_DECODING_PUBLIC_KEY_HASH_p256=S.safe_int3_300(* model B58CHECK_DECODING_PUBLIC_KEY_HASH_secp256k1 *)letcost_B58CHECK_DECODING_PUBLIC_KEY_HASH_secp256k1=S.safe_int3_300(* model B58CHECK_DECODING_PUBLIC_KEY_ed25519 *)letcost_B58CHECK_DECODING_PUBLIC_KEY_ed25519=S.safe_int4_200(* model B58CHECK_DECODING_PUBLIC_KEY_p256 *)letcost_B58CHECK_DECODING_PUBLIC_KEY_p256=S.safe_int325_000(* model B58CHECK_DECODING_PUBLIC_KEY_secp256k1 *)letcost_B58CHECK_DECODING_PUBLIC_KEY_secp256k1=S.safe_int9_000(* model B58CHECK_DECODING_SIGNATURE_ed25519 *)letcost_B58CHECK_DECODING_SIGNATURE_ed25519=S.safe_int6_400(* model B58CHECK_DECODING_SIGNATURE_p256 *)letcost_B58CHECK_DECODING_SIGNATURE_p256=S.safe_int6_400(* model B58CHECK_DECODING_SIGNATURE_secp256k1 *)letcost_B58CHECK_DECODING_SIGNATURE_secp256k1=S.safe_int6_400(* model ENCODING_BLS_FR *)letcost_ENCODING_BLS_FR=S.safe_int80(* model ENCODING_BLS_G1 *)letcost_ENCODING_BLS_G1=S.safe_int3200(* model ENCODING_BLS_G2 *)letcost_ENCODING_BLS_G2=S.safe_int3900(* model B58CHECK_ENCODING_CHAIN_ID *)letcost_B58CHECK_ENCODING_CHAIN_ID=S.safe_int1_800(* model B58CHECK_ENCODING_PUBLIC_KEY_HASH_ed25519 *)letcost_B58CHECK_ENCODING_PUBLIC_KEY_HASH_ed25519=S.safe_int3_200(* model B58CHECK_ENCODING_PUBLIC_KEY_HASH_p256 *)letcost_B58CHECK_ENCODING_PUBLIC_KEY_HASH_p256=S.safe_int3_200(* model B58CHECK_ENCODING_PUBLIC_KEY_HASH_secp256k1 *)letcost_B58CHECK_ENCODING_PUBLIC_KEY_HASH_secp256k1=S.safe_int3_200(* model B58CHECK_ENCODING_PUBLIC_KEY_ed25519 *)letcost_B58CHECK_ENCODING_PUBLIC_KEY_ed25519=S.safe_int4_500(* model B58CHECK_ENCODING_PUBLIC_KEY_p256 *)letcost_B58CHECK_ENCODING_PUBLIC_KEY_p256=S.safe_int4_550(* model B58CHECK_ENCODING_PUBLIC_KEY_secp256k1 *)letcost_B58CHECK_ENCODING_PUBLIC_KEY_secp256k1=S.safe_int4_950(* model B58CHECK_ENCODING_SIGNATURE_ed25519 *)letcost_B58CHECK_ENCODING_SIGNATURE_ed25519=S.safe_int8_300(* model B58CHECK_ENCODING_SIGNATURE_p256 *)letcost_B58CHECK_ENCODING_SIGNATURE_p256=S.safe_int8_300(* model B58CHECK_ENCODING_SIGNATURE_secp256k1 *)letcost_B58CHECK_ENCODING_SIGNATURE_secp256k1=S.safe_int8_300(* model DECODING_CHAIN_ID *)letcost_DECODING_CHAIN_ID=S.safe_int50(* model DECODING_PUBLIC_KEY_HASH_ed25519 *)letcost_DECODING_PUBLIC_KEY_HASH_ed25519=S.safe_int50(* model DECODING_PUBLIC_KEY_HASH_p256 *)letcost_DECODING_PUBLIC_KEY_HASH_p256=S.safe_int50(* model DECODING_PUBLIC_KEY_HASH_secp256k1 *)letcost_DECODING_PUBLIC_KEY_HASH_secp256k1=S.safe_int50(* model DECODING_PUBLIC_KEY_ed25519 *)letcost_DECODING_PUBLIC_KEY_ed25519=S.safe_int60(* model DECODING_PUBLIC_KEY_p256 *)letcost_DECODING_PUBLIC_KEY_p256=S.safe_int320_000(* model DECODING_PUBLIC_KEY_secp256k1 *)letcost_DECODING_PUBLIC_KEY_secp256k1=S.safe_int4_900(* model DECODING_SIGNATURE_ed25519 *)letcost_DECODING_SIGNATURE_ed25519=S.safe_int35(* model DECODING_SIGNATURE_p256 *)letcost_DECODING_SIGNATURE_p256=S.safe_int35(* model DECODING_SIGNATURE_secp256k1 *)letcost_DECODING_SIGNATURE_secp256k1=S.safe_int35(* model DECODING_Chest_key *)letcost_DECODING_Chest_key=S.safe_int5900(* model DECODING_Chest *)(* Approximating 0.039349 x term *)letcost_DECODING_Chest~bytes=letopenS_syntaxinletv0=S.safe_intbytesinS.safe_int7400+(v0lsr5)+(v0lsr7)(* model ENCODING_CHAIN_ID *)letcost_ENCODING_CHAIN_ID=S.safe_int50(* model ENCODING_PUBLIC_KEY_HASH_ed25519 *)letcost_ENCODING_PUBLIC_KEY_HASH_ed25519=S.safe_int70(* model ENCODING_PUBLIC_KEY_HASH_p256 *)letcost_ENCODING_PUBLIC_KEY_HASH_p256=S.safe_int70(* model ENCODING_PUBLIC_KEY_HASH_secp256k1 *)letcost_ENCODING_PUBLIC_KEY_HASH_secp256k1=S.safe_int70(* model ENCODING_PUBLIC_KEY_ed25519 *)letcost_ENCODING_PUBLIC_KEY_ed25519=S.safe_int80(* model ENCODING_PUBLIC_KEY_p256 *)letcost_ENCODING_PUBLIC_KEY_p256=S.safe_int90(* model ENCODING_PUBLIC_KEY_secp256k1 *)letcost_ENCODING_PUBLIC_KEY_secp256k1=S.safe_int455(* model ENCODING_SIGNATURE_ed25519 *)letcost_ENCODING_SIGNATURE_ed25519=S.safe_int45(* model ENCODING_SIGNATURE_p256 *)letcost_ENCODING_SIGNATURE_p256=S.safe_int45(* model ENCODING_SIGNATURE_secp256k1 *)letcost_ENCODING_SIGNATURE_secp256k1=S.safe_int45(* model ENCODING_Chest_key *)letcost_ENCODING_Chest_key=S.safe_int13500(* model ENCODING_Chest *)(* Approximating 0.120086 x term *)letcost_ENCODING_Chest~plaintext_size=letopenS_syntaxinletv0=S.safe_intplaintext_sizeinS.safe_int16630+(v0lsr3)(* model TIMESTAMP_READABLE_DECODING *)letcost_TIMESTAMP_READABLE_DECODING=S.safe_int100(* model TIMESTAMP_READABLE_ENCODING *)letcost_TIMESTAMP_READABLE_ENCODING=S.safe_int820(* model CHECK_PRINTABLE *)letcost_CHECK_PRINTABLEsize=letopenS_syntaxinS.safe_int14+(S.safe_int10*S.safe_intsize)(* model MERGE_TYPES
This is the estimated cost of one iteration of merge_types, extracted
and copied manually from the parameter fit for the MERGE_TYPES benchmark
(the model is parametric on the size of the type, which we don't have
access to in O(1)). *)letcost_MERGE_TYPES=S.safe_int220(* model TYPECHECKING_CODE
This is the cost of one iteration of parse_instr, extracted by hand from the
parameter fit for the TYPECHECKING_CODE benchmark. *)letcost_TYPECHECKING_CODE=S.safe_int220(* model UNPARSING_CODE
This is the cost of one iteration of unparse_instr, extracted by hand from the
parameter fit for the UNPARSING_CODE benchmark. *)letcost_UNPARSING_CODE=S.safe_int115(* model TYPECHECKING_DATA
This is the cost of one iteration of parse_data, extracted by hand from the
parameter fit for the TYPECHECKING_DATA benchmark. *)letcost_TYPECHECKING_DATA=S.safe_int100(* model UNPARSING_DATA
This is the cost of one iteration of unparse_data, extracted by hand from the
parameter fit for the UNPARSING_DATA benchmark. *)letcost_UNPARSING_DATA=S.safe_int45(* model PARSE_TYPE
This is the cost of one iteration of parse_ty, extracted by hand from the
parameter fit for the PARSE_TYPE benchmark. *)letcost_PARSE_TYPE=S.safe_int60(* model UNPARSE_TYPE
This is the cost of one iteration of unparse_ty, extracted by hand from the
parameter fit for the UNPARSE_TYPE benchmark. *)letcost_UNPARSE_TYPEtype_size=S.mul(S.safe_int20)type_size(* TODO: Add benchmarked value from [Unparse_comparable_type_benchmark]. *)letcost_UNPARSE_COMPARABLE_TYPEtype_size=S.mul(S.safe_int20)type_size(* TODO: benchmark *)letcost_COMPARABLE_TY_OF_TY=S.safe_int120(* model SAPLING_TRANSACTION_ENCODING *)letcost_SAPLING_TRANSACTION_ENCODING~inputs~outputs=S.safe_int(1500+(inputs*160)+(outputs*320))(* model SAPLING_DIFF_ENCODING *)letcost_SAPLING_DIFF_ENCODING~nfs~cms=S.safe_int((nfs*22)+(cms*215))endmoduleInterpreter=structopenGenerated_costsletdrop=atomic_step_costcost_N_IDropletdup=atomic_step_costcost_N_IDupletswap=atomic_step_costcost_N_ISwapletcons_some=atomic_step_costcost_N_ICons_someletcons_none=atomic_step_costcost_N_ICons_noneletif_none=atomic_step_costcost_N_IIf_noneletopt_map=atomic_step_costcost_opt_mapletcons_pair=atomic_step_costcost_N_ICons_pairletunpair=atomic_step_costcost_N_IUnpairletcar=atomic_step_costcost_N_ICarletcdr=atomic_step_costcost_N_ICdrletcons_left=atomic_step_costcost_N_ILeftletcons_right=atomic_step_costcost_N_IRightletif_left=atomic_step_costcost_N_IIf_leftletcons_list=atomic_step_costcost_N_ICons_listletnil=atomic_step_costcost_N_INilletif_cons=atomic_step_costcost_N_IIf_consletlist_map:'aScript_typed_ir.boxed_list->Gas.cost=fun{length;_}->atomic_step_cost(cost_N_IList_maplength)letlist_size=atomic_step_costcost_N_IList_sizeletlist_iter:'aScript_typed_ir.boxed_list->Gas.cost=fun{length;_}->atomic_step_cost(cost_N_IList_iterlength)letempty_set=atomic_step_costcost_N_IEmpty_setletset_iter(typea)((moduleBox):aScript_typed_ir.set)=atomic_step_cost(cost_N_ISet_iterBox.size)letset_size=atomic_step_costcost_N_ISet_sizeletempty_map=atomic_step_costcost_N_IEmpty_mapletmap_map(typekv)((moduleBox):(k,v)Script_typed_ir.map)=atomic_step_cost(cost_N_IMap_mapBox.size)letmap_iter(typekv)((moduleBox):(k,v)Script_typed_ir.map)=atomic_step_cost(cost_N_IMap_iterBox.size)letmap_size=atomic_step_costcost_N_IMap_sizeletbig_map_elt_size=S.safe_intScript_expr_hash.sizeletbig_map_mem({size;_}:_Script_typed_ir.big_map_overlay)=atomic_step_cost(cost_N_IMap_membig_map_elt_size(S.safe_intsize))letbig_map_get({size;_}:_Script_typed_ir.big_map_overlay)=atomic_step_cost(cost_N_IMap_getbig_map_elt_size(S.safe_intsize))letbig_map_update({size;_}:_Script_typed_ir.big_map_overlay)=atomic_step_cost(cost_N_IMap_updatebig_map_elt_size(S.safe_intsize))letbig_map_get_and_update({size;_}:_Script_typed_ir.big_map_overlay)=atomic_step_cost(cost_N_IMap_get_and_updatebig_map_elt_size(S.safe_intsize))letadd_seconds_timestamp:'aScript_int.num->Script_timestamp.t->Gas.cost=funsecondstimestamp->letseconds_bytes=int_bytessecondsinlettimestamp_bytes=z_bytes(Script_timestamp.to_zinttimestamp)inatomic_step_cost(cost_N_IAdd_seconds_to_timestampseconds_bytestimestamp_bytes)letadd_timestamp_seconds:Script_timestamp.t->'aScript_int.num->Gas.cost=funtimestampseconds->letseconds_bytes=int_bytessecondsinlettimestamp_bytes=z_bytes(Script_timestamp.to_zinttimestamp)inatomic_step_cost(cost_N_IAdd_timestamp_to_secondstimestamp_bytesseconds_bytes)letsub_timestamp_seconds:Script_timestamp.t->'aScript_int.num->Gas.cost=funtimestampseconds->letseconds_bytes=int_bytessecondsinlettimestamp_bytes=z_bytes(Script_timestamp.to_zinttimestamp)inatomic_step_cost(cost_N_ISub_timestamp_secondstimestamp_bytesseconds_bytes)letdiff_timestampst1t2=lett1_bytes=z_bytes(Script_timestamp.to_zintt1)inlett2_bytes=z_bytes(Script_timestamp.to_zintt2)inatomic_step_cost(cost_N_IDiff_timestampst1_bytest2_bytes)letconcat_string_pairs1s2=atomic_step_cost(cost_N_IConcat_string_pair(Script_string.lengths1)(Script_string.lengths2))letslice_strings=atomic_step_cost(cost_N_ISlice_string(Script_string.lengths))letstring_size=atomic_step_costcost_N_IString_sizeletconcat_bytes_pairb1b2=atomic_step_cost(cost_N_IConcat_bytes_pair(Bytes.lengthb1)(Bytes.lengthb2))letslice_bytesb=atomic_step_cost(cost_N_ISlice_bytes(Bytes.lengthb))letbytes_size=atomic_step_costcost_N_IBytes_sizeletadd_tez=atomic_step_costcost_N_IAdd_tezletsub_tez=atomic_step_costcost_N_ISub_tezletsub_tez_legacy=atomic_step_costcost_N_ISub_tez_legacyletmul_teznat=atomic_step_costcost_N_IMul_teznatletmul_nattez=atomic_step_costcost_N_IMul_nattezletbool_or=atomic_step_costcost_N_IOrletbool_and=atomic_step_costcost_N_IAndletbool_xor=atomic_step_costcost_N_IXorletbool_not=atomic_step_costcost_N_INotletis_nat=atomic_step_costcost_N_IIs_natletabs_inti=atomic_step_cost(cost_N_IAbs_int(int_bytesi))letint_nat=atomic_step_costcost_N_IInt_natletnegi=atomic_step_cost(cost_N_INeg(int_bytesi))letadd_inti1i2=atomic_step_cost(cost_N_IAdd_int(int_bytesi1)(int_bytesi2))letadd_nati1i2=atomic_step_cost(cost_N_IAdd_nat(int_bytesi1)(int_bytesi2))letsub_inti1i2=atomic_step_cost(cost_N_ISub_int(int_bytesi1)(int_bytesi2))letmul_inti1i2=atomic_step_cost(cost_N_IMul_int(int_bytesi1)(int_bytesi2))letmul_nati1i2=atomic_step_cost(cost_N_IMul_nat(int_bytesi1)(int_bytesi2))letediv_teznat_tez_n=atomic_step_costcost_N_IEdiv_teznatletediv_tez=atomic_step_costcost_N_IEdiv_tezletediv_inti1i2=atomic_step_cost(cost_N_IEdiv_int(int_bytesi1)(int_bytesi2))letediv_nati1i2=atomic_step_cost(cost_N_IEdiv_nat(int_bytesi1)(int_bytesi2))leteq=atomic_step_costcost_N_IEqletlsl_natshifted=atomic_step_cost(cost_N_ILsl_nat(int_bytesshifted))letlsr_natshifted=atomic_step_cost(cost_N_ILsr_nat(int_bytesshifted))letor_natn1n2=atomic_step_cost(cost_N_IOr_nat(int_bytesn1)(int_bytesn2))letand_natn1n2=atomic_step_cost(cost_N_IAnd_nat(int_bytesn1)(int_bytesn2))letand_int_natn1n2=atomic_step_cost(cost_N_IAnd_int_nat(int_bytesn1)(int_bytesn2))letxor_natn1n2=atomic_step_cost(cost_N_IXor_nat(int_bytesn1)(int_bytesn2))letnot_inti=atomic_step_cost(cost_N_INot_int(int_bytesi))letif_=atomic_step_costcost_N_IIfletloop=atomic_step_costcost_N_ILoopletloop_left=atomic_step_costcost_N_ILoop_leftletdip=atomic_step_costcost_N_IDipletview=atomic_step_costcost_N_IViewletcheck_signature(pkey:Signature.public_key)b=letcost=matchpkeywith|Ed25519_->cost_N_ICheck_signature_ed25519(Bytes.lengthb)|Secp256k1_->cost_N_ICheck_signature_secp256k1(Bytes.lengthb)|P256_->cost_N_ICheck_signature_p256(Bytes.lengthb)inatomic_step_costcostletblake2bb=atomic_step_cost(cost_N_IBlake2b(Bytes.lengthb))letsha256b=atomic_step_cost(cost_N_ISha256(Bytes.lengthb))letsha512b=atomic_step_cost(cost_N_ISha512(Bytes.lengthb))letdignn=atomic_step_cost(cost_N_IDign)letdugnn=atomic_step_cost(cost_N_IDugn)letdipnn=atomic_step_cost(cost_N_IDipNn)letdropnn=atomic_step_cost(cost_N_IDropNn)letvoting_power=atomic_step_costcost_N_IVoting_powerlettotal_voting_power=atomic_step_costcost_N_ITotal_voting_powerletkeccakb=atomic_step_cost(cost_N_IKeccak(Bytes.lengthb))letsha3b=atomic_step_cost(cost_N_ISha3(Bytes.lengthb))letadd_bls12_381_g1=atomic_step_costcost_N_IAdd_bls12_381_g1letadd_bls12_381_g2=atomic_step_costcost_N_IAdd_bls12_381_g2letadd_bls12_381_fr=atomic_step_costcost_N_IAdd_bls12_381_frletmul_bls12_381_g1=atomic_step_costcost_N_IMul_bls12_381_g1letmul_bls12_381_g2=atomic_step_costcost_N_IMul_bls12_381_g2letmul_bls12_381_fr=atomic_step_costcost_N_IMul_bls12_381_frletmul_bls12_381_fr_zz=atomic_step_cost(cost_N_IMul_bls12_381_fr_z(int_bytesz))letmul_bls12_381_z_frz=atomic_step_cost(cost_N_IMul_bls12_381_z_fr(int_bytesz))letint_bls12_381_fr=atomic_step_costcost_N_IInt_bls12_381_z_frletneg_bls12_381_g1=atomic_step_costcost_N_INeg_bls12_381_g1letneg_bls12_381_g2=atomic_step_costcost_N_INeg_bls12_381_g2letneg_bls12_381_fr=atomic_step_costcost_N_INeg_bls12_381_frletneq=atomic_step_costcost_N_INeqletpairing_check_bls12_381(l:'aScript_typed_ir.boxed_list)=atomic_step_cost(cost_N_IPairing_check_bls12_381l.length)letcombn=atomic_step_cost(cost_N_ICombn)letuncombn=atomic_step_cost(cost_N_IUncombn)letcomb_getn=atomic_step_cost(cost_N_IComb_getn)letcomb_setn=atomic_step_cost(cost_N_IComb_setn)letdupnn=atomic_step_cost(cost_N_IDupNn)letsapling_verify_update~inputs~outputs=atomic_step_cost(cost_N_ISapling_verify_updateinputsoutputs)letsapling_empty_state=atomic_step_costcost_N_ISapling_empty_statelethalt=atomic_step_costcost_N_IHaltletconst=atomic_step_costcost_N_IConstletempty_big_map=atomic_step_costcost_N_IEmpty_big_mapletlt=atomic_step_costcost_N_ILtletle=atomic_step_costcost_N_ILeletgt=atomic_step_costcost_N_IGtletge=atomic_step_costcost_N_IGeletexec=atomic_step_costcost_N_IExecletapply=atomic_step_costcost_N_IApplyletlambda=atomic_step_costcost_N_ILambdaletaddress=atomic_step_costcost_N_IAddressletcontract=atomic_step_costcost_N_IContractlettransfer_tokens=atomic_step_costcost_N_ITransfer_tokensletimplicit_account=atomic_step_costcost_N_IImplicit_accountletcreate_contract=atomic_step_costcost_N_ICreate_contractletset_delegate=atomic_step_costcost_N_ISet_delegateletlevel=atomic_step_costcost_N_ILevelletnow=atomic_step_costcost_N_INowletsource=atomic_step_costcost_N_ISourceletsender=atomic_step_costcost_N_ISenderletself=atomic_step_costcost_N_ISelfletself_address=atomic_step_costcost_N_ISelf_addressletamount=atomic_step_costcost_N_IAmountletchain_id=atomic_step_costcost_N_IChainIdletticket=atomic_step_costcost_N_ITicketletread_ticket=atomic_step_costcost_N_IRead_ticketlethash_key_=atomic_step_costcost_N_IHash_keyletsplit_ticket_amount_aamount_b=atomic_step_cost(cost_N_ISplit_ticket(int_bytesamount_a)(int_bytesamount_b))letopen_chest~chest~time=letplaintext=Timelock.get_plaintext_sizechestinletlog_time=Z.log2Z.(addonetime)inatomic_step_cost(cost_N_IOpen_chest~chest:plaintext~time:log_time)(* --------------------------------------------------------------------- *)(* Semi-hand-crafted models *)letcompare_unit=atomic_step_cost(S.safe_int10)letcompare_pair_tag=atomic_step_cost(S.safe_int10)letcompare_union_tag=atomic_step_cost(S.safe_int10)letcompare_option_tag=atomic_step_cost(S.safe_int10)letcompare_bool=atomic_step_cost(cost_N_ICompare11)letcompare_signature=atomic_step_cost(S.safe_int92)letcompare_strings1s2=atomic_step_cost(cost_N_ICompare(Script_string.lengths1)(Script_string.lengths2))letcompare_bytesb1b2=atomic_step_cost(cost_N_ICompare(Bytes.lengthb1)(Bytes.lengthb2))letcompare_mutez=atomic_step_cost(cost_N_ICompare88)letcompare_inti1i2=atomic_step_cost(cost_N_ICompare(int_bytesi1)(int_bytesi2))letcompare_natn1n2=atomic_step_cost(cost_N_ICompare(int_bytesn1)(int_bytesn2))letcompare_key_hash=letsz=Signature.Public_key_hash.sizeinatomic_step_cost(cost_N_ICompareszsz)letcompare_key=atomic_step_cost(S.safe_int92)letcompare_timestampt1t2=atomic_step_cost(cost_N_ICompare(z_bytes(Script_timestamp.to_zintt1))(z_bytes(Script_timestamp.to_zintt2)))(* Maximum size of an entrypoint in bytes *)letentrypoint_size=31letcompare_address=letsz=Signature.Public_key_hash.size+entrypoint_sizeinatomic_step_cost(cost_N_ICompareszsz)letcompare_chain_id=atomic_step_cost(S.safe_int30)(* Defunctionalized CPS *)typecont=|Compare:'aScript_typed_ir.comparable_ty*'a*'a*cont->cont|Return:contletcompare:typea.aScript_typed_ir.comparable_ty->a->a->cost=funtyxy->letreccompare:typea.aScript_typed_ir.comparable_ty->a->a->cost->cont->cost=funtyxyacck->matchtywith|Unit_key_->(apply[@tailcall])Gas.(acc+@compare_unit)k|Never_key_->(matchxwith_->.)|Bool_key_->(apply[@tailcall])Gas.(acc+@compare_bool)k|String_key_->(apply[@tailcall])Gas.(acc+@compare_stringxy)k|Signature_key_->(apply[@tailcall])Gas.(acc+@compare_signature)k|Bytes_key_->(apply[@tailcall])Gas.(acc+@compare_bytesxy)k|Mutez_key_->(apply[@tailcall])Gas.(acc+@compare_mutez)k|Int_key_->(apply[@tailcall])Gas.(acc+@compare_intxy)k|Nat_key_->(apply[@tailcall])Gas.(acc+@compare_natxy)k|Key_hash_key_->(apply[@tailcall])Gas.(acc+@compare_key_hash)k|Key_key_->(apply[@tailcall])Gas.(acc+@compare_key)k|Timestamp_key_->(apply[@tailcall])Gas.(acc+@compare_timestampxy)k|Address_key_->(apply[@tailcall])Gas.(acc+@compare_address)k|Chain_id_key_->(apply[@tailcall])Gas.(acc+@compare_chain_id)k|Pair_key((tl,_),(tr,_),_)->(* Reasonable over-approximation of the cost of lexicographic comparison. *)let(xl,xr)=xinlet(yl,yr)=yin(compare[@tailcall])tlxlylGas.(acc+@compare_pair_tag)(Compare(tr,xr,yr,k))|Union_key((tl,_),(tr,_),_)->(match(x,y)with|(Lx,Ly)->(compare[@tailcall])tlxyGas.(acc+@compare_union_tag)k|(L_,R_)->(apply[@tailcall])Gas.(acc+@compare_union_tag)k|(R_,L_)->(apply[@tailcall])Gas.(acc+@compare_union_tag)k|(Rx,Ry)->(compare[@tailcall])trxyGas.(acc+@compare_union_tag)k)|Option_key(t,_)->(match(x,y)with|(None,None)->(apply[@tailcall])Gas.(acc+@compare_option_tag)k|(None,Some_)->(apply[@tailcall])Gas.(acc+@compare_option_tag)k|(Some_,None)->(apply[@tailcall])Gas.(acc+@compare_option_tag)k|(Somex,Somey)->(compare[@tailcall])txyGas.(acc+@compare_option_tag)k)andapplycostk=matchkwith|Compare(ty,x,y,k)->(compare[@tailcall])tyxycostk|Return->costincomparetyxyGas.freeReturn[@@coq_axiom_with_reason"non top-level mutually recursive function"]letview_mem(elt:Script_string.t)(m:Script_typed_ir.viewScript_typed_ir.SMap.t)=letopenS_syntaxinletper_elt_cost=compare(Script_typed_ir.string_key~annot:None)elteltinletsize=S.safe_int(Script_typed_ir.SMap.cardinalm)inletintercept=atomic_step_cost(S.safe_int80)inGas.(intercept+@(log2size*@per_elt_cost))letview_get=view_memletview_update(elt:Script_string.t)(m:Script_typed_ir.viewScript_typed_ir.SMap.t)=letopenS_syntaxinletper_elt_cost=compare(Script_typed_ir.string_key~annot:None)elteltinletsize=S.safe_int(Script_typed_ir.SMap.cardinalm)inletintercept=atomic_step_cost(S.safe_int80)inGas.(intercept+@(S.safe_int2*log2size*@per_elt_cost))letset_mem(typea)(elt:a)((moduleBox):aScript_typed_ir.set)=letopenS_syntaxinletper_elt_cost=compareBox.elt_tyelteltinletsize=S.safe_intBox.sizeinletintercept=atomic_step_cost(S.safe_int115)inGas.(intercept+@(log2size*@per_elt_cost))letset_update(typea)(elt:a)((moduleBox):aScript_typed_ir.set)=letopenS_syntaxinletper_elt_cost=compareBox.elt_tyelteltinletsize=S.safe_intBox.sizeinletintercept=atomic_step_cost(S.safe_int130)in(* The 2 factor reflects the update vs mem overhead as benchmarked
on non-structured data *)Gas.(intercept+@(S.safe_int2*log2size*@per_elt_cost))letmap_mem(typekv)(elt:k)((moduleBox):(k,v)Script_typed_ir.map)=letopenS_syntaxinletper_elt_cost=compareBox.key_tyelteltinletsize=S.safe_intBox.sizeinletintercept=atomic_step_cost(S.safe_int80)inGas.(intercept+@(log2size*@per_elt_cost))letmap_get=map_memletmap_update(typekv)(elt:k)((moduleBox):(k,v)Script_typed_ir.map)=letopenS_syntaxinletper_elt_cost=compareBox.key_tyelteltinletsize=S.safe_intBox.sizeinletintercept=atomic_step_cost(S.safe_int80)in(* The 2 factor reflects the update vs mem overhead as benchmarked
on non-structured data *)Gas.(intercept+@(S.safe_int2*log2size*@per_elt_cost))letmap_get_and_update(typekv)(elt:k)((moduleBox):(k,v)Script_typed_ir.map)=letopenS_syntaxinletper_elt_cost=compareBox.key_tyelteltinletsize=S.safe_intBox.sizeinletintercept=atomic_step_cost(S.safe_int80)in(* The 3 factor reflects the update vs mem overhead as benchmarked
on non-structured data *)Gas.(intercept+@(S.safe_int3*log2size*@per_elt_cost))letjoin_tickets:'aScript_typed_ir.comparable_ty->'aScript_typed_ir.ticket->'aScript_typed_ir.ticket->Gas.cost=funtyticket_aticket_b->letcontents_comparison=comparetyticket_a.contentsticket_b.contentsinGas.(contents_comparison+@compare_address+@add_natticket_a.amountticket_b.amount)(* Continuations *)moduleControl=structletnil=atomic_step_costcost_N_KNilletcons=atomic_step_costcost_N_KConsletreturn=atomic_step_costcost_N_KReturnletview_exit=atomic_step_costcost_N_KView_exitletmap_head=atomic_step_costconst_N_KMap_headletundip=atomic_step_costcost_N_KUndipletloop_in=atomic_step_costcost_N_KLoop_inletloop_in_left=atomic_step_costcost_N_KLoop_in_leftletiter=atomic_step_costcost_N_KIterletlist_enter_bodyxsys_len=atomic_step_cost(cost_N_KList_enter_bodyxsys_len)letlist_exit_body=atomic_step_costcost_N_KList_exit_bodyletmap_enter_body=atomic_step_costcost_N_KMap_enter_bodyletmap_exit_body(typekv)(key:k)(map:(k,v)Script_typed_ir.map)=map_updatekeymapend(* --------------------------------------------------------------------- *)(* Hand-crafted models *)(* The cost functions below where not benchmarked, a cost model was derived
from looking at similar instructions. *)(* Cost for Concat_string is paid in two steps: when entering the interpreter,
the user pays for the cost of computing the information necessary to compute
the actual gas (so it's meta-gas): indeed, one needs to run through the
list of strings to compute the total allocated cost.
[concat_string_precheck] corresponds to the meta-gas cost of this computation.
*)letconcat_string_precheck(l:'aScript_typed_ir.boxed_list)=(* we set the precheck to be slightly more expensive than cost_N_IList_iter *)atomic_step_cost(S.mul(S.safe_intl.length)(S.safe_int10))(* This is the cost of allocating a string and blitting existing ones into it. *)letconcat_stringtotal_bytes=atomic_step_costS.(add(S.safe_int100)(S.edivtotal_bytes(S.safe_int10)))(* Same story as Concat_string. *)letconcat_bytestotal_bytes=atomic_step_costS.(add(S.safe_int100)(S.edivtotal_bytes(S.safe_int10)))(* Cost of access taken care of in Contract_storage.get_balance_carbonated *)letbalance=Gas.free(* Cost of Unpack pays two integer comparisons, and a Bytes slice *)letunpackbytes=letblen=Bytes.lengthbytesinletopenS_syntaxinatomic_step_cost(S.safe_int260+(S.safe_intblenlsr3))(* TODO benchmark *)(* FIXME: imported from 006, needs proper benchmarks *)letunpack_failedbytes=(* We cannot instrument failed deserialization,
so we take worst case fees: a set of size 1 bytes values. *)letblen=String.lengthbytesinletlen=S.safe_intbleninletd=Z.numbits(Z.of_intblen)in(len*@alloc_mbytes_cost1)+@len*@(S.safe_intd*@(alloc_cost(S.safe_int3)+@step_costS.one))endmoduleTypechecking=structopenGenerated_costsletpublic_key_optimized=atomic_step_cost@@S.(maxcost_DECODING_PUBLIC_KEY_ed25519(maxcost_DECODING_PUBLIC_KEY_secp256k1cost_DECODING_PUBLIC_KEY_p256))letpublic_key_readable=atomic_step_cost@@S.(maxcost_B58CHECK_DECODING_PUBLIC_KEY_ed25519(maxcost_B58CHECK_DECODING_PUBLIC_KEY_secp256k1cost_B58CHECK_DECODING_PUBLIC_KEY_p256))letkey_hash_optimized=atomic_step_cost@@S.(maxcost_DECODING_PUBLIC_KEY_HASH_ed25519(maxcost_DECODING_PUBLIC_KEY_HASH_secp256k1cost_DECODING_PUBLIC_KEY_HASH_p256))letkey_hash_readable=atomic_step_cost@@S.(maxcost_B58CHECK_DECODING_PUBLIC_KEY_HASH_ed25519(maxcost_B58CHECK_DECODING_PUBLIC_KEY_HASH_secp256k1cost_B58CHECK_DECODING_PUBLIC_KEY_HASH_p256))letsignature_optimized=atomic_step_cost@@S.(maxcost_DECODING_SIGNATURE_ed25519(maxcost_DECODING_SIGNATURE_secp256k1cost_DECODING_SIGNATURE_p256))letsignature_readable=atomic_step_cost@@S.(maxcost_B58CHECK_DECODING_SIGNATURE_ed25519(maxcost_B58CHECK_DECODING_SIGNATURE_secp256k1cost_B58CHECK_DECODING_SIGNATURE_p256))letchain_id_optimized=atomic_step_costcost_DECODING_CHAIN_IDletchain_id_readable=atomic_step_costcost_B58CHECK_DECODING_CHAIN_ID(* Reasonable approximation *)letaddress_optimized=key_hash_optimized(* Reasonable approximation *)letcontract_optimized=key_hash_optimized(* Reasonable approximation *)letcontract_readable=key_hash_readableletbls12_381_g1=atomic_step_costcost_DECODING_BLS_G1letbls12_381_g2=atomic_step_costcost_DECODING_BLS_G2letbls12_381_fr=atomic_step_costcost_DECODING_BLS_FRletcheck_printables=atomic_step_cost(cost_CHECK_PRINTABLE(String.lengths))letmerge_cycle=atomic_step_costcost_MERGE_TYPESletparse_type_cycle=atomic_step_costcost_PARSE_TYPEletparse_instr_cycle=atomic_step_costcost_TYPECHECKING_CODEletparse_data_cycle=atomic_step_costcost_TYPECHECKING_DATAletcomparable_ty_of_ty_cycle=atomic_step_costcost_COMPARABLE_TY_OF_TY(* Cost of a cycle of checking that a type is dupable *)(* TODO: bench *)letcheck_dupable_cycle=atomic_step_costcost_TYPECHECKING_DATAletbool=freeletunit=freelettimestamp_readable=atomic_step_costcost_TIMESTAMP_READABLE_DECODING(* Reasonable estimate. *)letcontract=Gas.(S.safe_int2*@public_key_readable)(* Balance stored at /contracts/index/hash/balance, on 64 bits *)letcontract_exists=Gas.cost_of_repr@@Storage_costs.read_access~path_length:4~read_bytes:8(* Constructing proof arguments consists in a decreasing loop in the result
monad, allocating at each step. We charge a reasonable overapproximation. *)letproof_argumentn=atomic_step_cost(S.mul(S.safe_intn)(S.safe_int50))letchest_key=atomic_step_costcost_DECODING_Chest_keyletchest~bytes=atomic_step_cost(cost_DECODING_Chest~bytes)endmoduleUnparsing=structopenGenerated_costsletpublic_key_optimized=atomic_step_cost@@S.(maxcost_ENCODING_PUBLIC_KEY_ed25519(maxcost_ENCODING_PUBLIC_KEY_secp256k1cost_ENCODING_PUBLIC_KEY_p256))letpublic_key_readable=atomic_step_cost@@S.(maxcost_B58CHECK_ENCODING_PUBLIC_KEY_ed25519(maxcost_B58CHECK_ENCODING_PUBLIC_KEY_secp256k1cost_B58CHECK_ENCODING_PUBLIC_KEY_p256))letkey_hash_optimized=atomic_step_cost@@S.(maxcost_ENCODING_PUBLIC_KEY_HASH_ed25519(maxcost_ENCODING_PUBLIC_KEY_HASH_secp256k1cost_ENCODING_PUBLIC_KEY_HASH_p256))letkey_hash_readable=atomic_step_cost@@S.(maxcost_B58CHECK_ENCODING_PUBLIC_KEY_HASH_ed25519(maxcost_B58CHECK_ENCODING_PUBLIC_KEY_HASH_secp256k1cost_B58CHECK_ENCODING_PUBLIC_KEY_HASH_p256))letsignature_optimized=atomic_step_cost@@S.(maxcost_ENCODING_SIGNATURE_ed25519(maxcost_ENCODING_SIGNATURE_secp256k1cost_ENCODING_SIGNATURE_p256))letsignature_readable=atomic_step_cost@@S.(maxcost_B58CHECK_ENCODING_SIGNATURE_ed25519(maxcost_B58CHECK_ENCODING_SIGNATURE_secp256k1cost_B58CHECK_ENCODING_SIGNATURE_p256))letchain_id_optimized=atomic_step_costcost_ENCODING_CHAIN_IDletchain_id_readable=atomic_step_costcost_B58CHECK_ENCODING_CHAIN_IDlettimestamp_readable=atomic_step_costcost_TIMESTAMP_READABLE_ENCODING(* Reasonable approximation *)letaddress_optimized=key_hash_optimized(* Reasonable approximation *)letcontract_optimized=key_hash_optimized(* Reasonable approximation *)letcontract_readable=key_hash_readableletbls12_381_g1=atomic_step_costcost_ENCODING_BLS_G1letbls12_381_g2=atomic_step_costcost_ENCODING_BLS_G2letbls12_381_fr=atomic_step_costcost_ENCODING_BLS_FRletunparse_typety=atomic_step_cost@@cost_UNPARSE_TYPEScript_typed_ir.(ty_sizety|>Type_size.to_int)letunparse_comparable_typecomp_ty=atomic_step_cost@@cost_UNPARSE_COMPARABLE_TYPEScript_typed_ir.(comparable_ty_sizecomp_ty|>Type_size.to_int)letunparse_instr_cycle=atomic_step_costcost_UNPARSING_CODEletunparse_data_cycle=atomic_step_costcost_UNPARSING_DATAletunit=Gas.free(* Reasonable estimate. *)letcontract=Gas.(S.safe_int2*@public_key_readable)(* Reuse 006 costs. *)letoperationbytes=Script.bytes_node_costbytesletsapling_transaction(t:Sapling.transaction)=letinputs=List.lengtht.inputsinletoutputs=List.lengtht.outputsinatomic_step_cost(cost_SAPLING_TRANSACTION_ENCODING~inputs~outputs)letsapling_diff(d:Sapling.diff)=letnfs=List.lengthd.nullifiersinletcms=List.lengthd.commitments_and_ciphertextsinatomic_step_cost(cost_SAPLING_DIFF_ENCODING~nfs~cms)letchest_key=atomic_step_costcost_ENCODING_Chest_keyletchest~plaintext_size=atomic_step_cost(cost_ENCODING_Chest~plaintext_size)endend