Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file michelson_v1_gas.ml
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772(*****************************************************************************)(* *)(* 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 *)letcost_N_IAdd_bls12_381_fr=S.safe_int145(* model N_IAdd_bls12_381_g1 *)letcost_N_IAdd_bls12_381_g1=S.safe_int8_300(* model N_IAdd_bls12_381_g2 *)letcost_N_IAdd_bls12_381_g2=S.safe_int11_450letcost_linear_op_intsize1size2=letopenS_syntaxinletv0=S.safe_int(Compare.Int.maxsize1size2)inS.safe_int35+((v0lsr4)+(v0lsr7))(* model N_IAdd_intint *)(* Approximating 0.077989 x term *)letcost_N_IAdd_intint=cost_linear_op_int(* model N_IAdd_intnat *)(* Approximating 0.077997 x term *)letcost_N_IAdd_intnat=cost_linear_op_int(* model N_IAdd_natint *)(* Approximating 0.078154 x term *)letcost_N_IAdd_natint=cost_linear_op_int(* model N_IAdd_natnat *)(* Approximating 0.077807 x term *)letcost_N_IAdd_natnat=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_int25(* 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_int35+((v0lsr3)+(v0lsr6))(* model N_IAnd_nat *)(* Approximating 0.076804 x term *)letcost_N_IAnd_natsize1size2=letopenS_syntaxinletv0=S.safe_int(Compare.Int.minsize1size2)inS.safe_int35+((v0lsr4)+(v0lsr7))(* model N_IApply *)letcost_N_IApply=S.safe_int135(* model N_IBlake2b *)(* Approximating 1.120804 x term *)letcost_N_IBlake2bsize=letopenS_syntaxinletv0=S.safe_intsizeinS.safe_int605+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_int242_950+(v0+(v0lsr3))(* model N_ICheck_signature_p256 *)(* Approximating 1.111539 x term *)letcost_N_ICheck_signature_p256size=letopenS_syntaxinletv0=S.safe_intsizeinS.safe_int532_150+(v0+(v0lsr3))(* model N_ICheck_signature_secp256k1 *)(* Approximating 1.125404 x term *)letcost_N_ICheck_signature_secp256k1size=letopenS_syntaxinletv0=S.safe_intsizeinS.safe_int49_700+(v0+(v0lsr3))(* model N_IComb *)(* Approximating 3.315655 x term *)(* Note: size >= 2, so the cost is never 0 *)letcost_N_ICombsize=letopenS_syntaxinletv0=S.safe_intsizein(S.safe_int3*v0)+(v0lsr2)(* model N_IComb_get *)(* Approximating 0.531991 x term *)letcost_N_IComb_getsize=letopenS_syntaxinletv0=S.safe_intsizeinS.safe_int5+(v0lsr1)+(v0lsr5)(* model N_IComb_set *)(* Approximating 1.268749 x term *)letcost_N_IComb_setsize=letopenS_syntaxinletv0=S.safe_intsizeinS.safe_int10+(v0+(v0lsr2))(* 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_int20+((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_int20+(v0+(v0lsr1)+(v0lsr3))(* 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_int20+(S.safe_int2*v0)+(v0lsr1)+(v0lsr3)(* model N_IDug *)(* Approximating 6.718396 x term *)letcost_N_IDugsize=letopenS_syntaxinletv0=S.safe_intsizeinS.safe_int20+((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_int110elseletopenS_syntaxinletv0=S.safe_intq*S.safe_intsize2inS.safe_int110+(v0lsr10)+(v0lsr11)+(v0lsr13)(* model N_IEdiv_intint *)(* Approximating 0.001591 x term *)letcost_N_IEdiv_intint=cost_div_int(* model N_IEdiv_intnat *)(* Approximating 0.001548 x term *)letcost_N_IEdiv_intnat=cost_div_int(* model N_IEdiv_natint *)(* Approximating 0.001535 x term *)letcost_N_IEdiv_natint=cost_div_int(* model N_IEdiv_natnat *)(* Approximating 0.001605 x term *)letcost_N_IEdiv_natnat=cost_div_int(* model N_IEdiv_tez *)letcost_N_IEdiv_tez=S.safe_int65(* model N_IEdiv_teznat *)letcost_N_IEdiv_teznat=S.safe_int70(* model N_IEmpty_big_map *)letcost_N_IEmpty_big_map=S.safe_int15(* model N_IEmpty_map *)letcost_N_IEmpty_map=S.safe_int155(* model N_IEmpty_set *)letcost_N_IEmpty_set=S.safe_int155(* 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_IImplicit_account *)letcost_N_IImplicit_account=S.safe_int10(* model N_IInt_bls12_381_z_fr *)letcost_N_IInt_bls12_381_z_fr=S.safe_int40(* 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 32.7522064274 x term *)letcost_N_IKeccaksize=letopenS_syntaxinletv0=S.safe_intsizeinS.safe_int5100+((S.safe_int32*v0)+(v0lsr1)+(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_int25(* model N_IList_iter *)letcost_N_IList_iter_=S.safe_int50(* model N_IList_map *)letcost_N_IList_map_=S.safe_int45(* 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_int35+((v0lsr4)+(v0lsr5)+(v0lsr6))(* model N_ILsr_nat *)(* Approximating 0.115565 x term *)letcost_N_ILsr_natsize=letopenS_syntaxinletv0=S.safe_intsizeinS.safe_int35+((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_int80+(v0lsr5)+(v0lsr6)(* model N_IMap_get_and_update *)(* Approximating 0.145661 x term *)letcost_N_IMap_get_and_updatesize1size2=letopenS_syntaxinletv0=size1*log2size2inS.safe_int165+(v0lsr3)+(v0lsr6)(* model N_IMap_iter *)(* Approximating 5.235173 x term *)letcost_N_IMap_itersize=letopenS_syntaxinletv0=S.safe_intsizeinS.safe_int60+(S.safe_int5*v0)+(v0lsr2)(* model N_IMap_map *)(* Approximating 7.46280485884 x term *)letcost_N_IMap_mapsize=letopenS_syntaxinletv0=S.safe_intsizeinS.safe_int180+((S.safe_int7*v0)+(v0lsr1))(* model N_IMap_mem *)(* Approximating 0.048446 x term *)letcost_N_IMap_memsize1size2=letopenS_syntaxinletv0=size1*log2size2inS.safe_int80+(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_int100+(v0lsr4)+(v0lsr5)(* model N_IMul_bls12_381_fr *)letcost_N_IMul_bls12_381_fr=S.safe_int170(* model N_IMul_bls12_381_fr_z *)(* Approximating 1.059386 x term *)letcost_N_IMul_bls12_381_fr_zsize1=letopenS_syntaxinletv0=S.safe_intsize1inS.safe_int270+v0+(v0lsr4)(* model N_IMul_bls12_381_g1 *)letcost_N_IMul_bls12_381_g1=S.safe_int229_850(* model N_IMul_bls12_381_g2 *)letcost_N_IMul_bls12_381_g2=S.safe_int760_350(* model N_IMul_bls12_381_z_fr *)(* Approximating 1.068674 x term *)letcost_N_IMul_bls12_381_z_frsize1=letopenS_syntaxinletv0=S.safe_intsize1inS.safe_int270+v0+(v0lsr4)letcost_mulsize1size2=letopenS_syntaxinleta=S.add(S.safe_intsize1)(S.safe_intsize2)inletv0=a*log2ainS.safe_int75+(v0lsr1)+(v0lsr2)+(v0lsr4)(* model N_IMul_intint *)(* Approximating 0.857296 x term *)letcost_N_IMul_intint=cost_mul(* model N_IMul_intnat *)(* Approximating 0.857931 x term *)letcost_N_IMul_intnat=cost_mul(* model N_IMul_natint *)(* Approximating 0.861823 x term *)letcost_N_IMul_natint=cost_mul(* model N_IMul_natnat *)(* Approximating 0.849870 x term *)letcost_N_IMul_natnat=cost_mul(* model N_IMul_nattez *)letcost_N_IMul_nattez=S.safe_int100(* model N_IMul_teznat *)letcost_N_IMul_teznat=S.safe_int100(* model N_INeg_bls12_381_fr *)letcost_N_INeg_bls12_381_fr=S.safe_int120(* model N_INeg_bls12_381_g1 *)letcost_N_INeg_bls12_381_g1=S.safe_int290(* model N_INeg_bls12_381_g2 *)letcost_N_INeg_bls12_381_g2=S.safe_int555(* model N_INeg_int *)(* Approximating 0.065748 x term *)letcost_N_INeg_intsize=letopenS_syntaxinS.safe_int25+(S.safe_intsizelsr4)(* model N_INeg_nat *)(* Approximating 0.066076 x term *)letcost_N_INeg_natsize=letopenS_syntaxinS.safe_int25+(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_int25+((v0lsr4)+(v0lsr7))(* model N_INot_nat *)(* Approximating 0.074613 x term *)letcost_N_INot_natsize=letopenS_syntaxinletv0=S.safe_intsizeinS.safe_int25+((v0lsr4)+(v0lsr7))(* model N_INow *)letcost_N_INow=S.safe_int25(* 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 *)letcost_N_IPairing_check_bls12_381size=S.add(S.safe_int1_396_550)(S.mul(S.safe_int456_475)(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 4.214099 x term *)letcost_N_ISet_itersize=letopenS_syntaxinletv0=S.safe_intsizeinS.safe_int60+(S.safe_int4*v0)+(v0lsr2)(* 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_int460+((S.safe_int4*v0)+(v0lsr1)+(v0lsr2))(* model N_ISha3 *)(* Approximating 32.739046325 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_int535+(S.safe_int3*v0)(* model N_ISlice_bytes *)(* Approximating 0.065752 x term *)letcost_N_ISlice_bytessize=letopenS_syntaxinS.safe_int30+(S.safe_intsizelsr4)(* model N_ISlice_string *)(* Approximating 0.065688 x term *)letcost_N_ISlice_stringsize=letopenS_syntaxinS.safe_int30+(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_int70+(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_int25(* 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_int300(* model N_ITransfer_tokens *)letcost_N_ITransfer_tokens=S.safe_int30(* model N_IUncomb *)(* Approximating 3.772151 x term *)letcost_N_IUncombsize=letopenS_syntaxinletv0=S.safe_intsizeinS.safe_int25+(S.safe_int3*v0)+(v0lsr1)+(v0lsr2)(* model N_IUnpair *)letcost_N_IUnpair=S.safe_int10(* model N_IVoting_power *)letcost_N_IVoting_power=S.safe_int400(* 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_int130(* model N_KNil *)letcost_N_KNil=S.safe_int20(* model N_KReturn *)letcost_N_KReturn=S.safe_int15(* model N_KUndip *)letcost_N_KUndip=S.safe_int15(* model DECODING_BLS_FR *)letcost_DECODING_BLS_FR=S.safe_int50(* model DECODING_BLS_G1 *)letcost_DECODING_BLS_G1=S.safe_int195_000(* model DECODING_BLS_G2 *)letcost_DECODING_BLS_G2=S.safe_int660_000(* model B58CHECK_DECODING_CHAIN_ID *)letcost_B58CHECK_DECODING_CHAIN_ID=S.safe_int1_400(* model B58CHECK_DECODING_PUBLIC_KEY_HASH_ed25519 *)letcost_B58CHECK_DECODING_PUBLIC_KEY_HASH_ed25519=S.safe_int3_100(* model B58CHECK_DECODING_PUBLIC_KEY_HASH_p256 *)letcost_B58CHECK_DECODING_PUBLIC_KEY_HASH_p256=S.safe_int3_100(* model B58CHECK_DECODING_PUBLIC_KEY_HASH_secp256k1 *)letcost_B58CHECK_DECODING_PUBLIC_KEY_HASH_secp256k1=S.safe_int3_100(* model B58CHECK_DECODING_PUBLIC_KEY_ed25519 *)letcost_B58CHECK_DECODING_PUBLIC_KEY_ed25519=S.safe_int4_000(* model B58CHECK_DECODING_PUBLIC_KEY_p256 *)letcost_B58CHECK_DECODING_PUBLIC_KEY_p256=S.safe_int27_000(* model B58CHECK_DECODING_PUBLIC_KEY_secp256k1 *)letcost_B58CHECK_DECODING_PUBLIC_KEY_secp256k1=S.safe_int8_500(* model B58CHECK_DECODING_SIGNATURE_ed25519 *)letcost_B58CHECK_DECODING_SIGNATURE_ed25519=S.safe_int6_100(* model B58CHECK_DECODING_SIGNATURE_p256 *)letcost_B58CHECK_DECODING_SIGNATURE_p256=S.safe_int6_100(* model B58CHECK_DECODING_SIGNATURE_secp256k1 *)letcost_B58CHECK_DECODING_SIGNATURE_secp256k1=S.safe_int6_100(* model ENCODING_BLS_FR *)letcost_ENCODING_BLS_FR=S.safe_int30(* model ENCODING_BLS_G1 *)letcost_ENCODING_BLS_G1=S.safe_int30(* model ENCODING_BLS_G2 *)letcost_ENCODING_BLS_G2=S.safe_int30(* model B58CHECK_ENCODING_CHAIN_ID *)letcost_B58CHECK_ENCODING_CHAIN_ID=S.safe_int1_600(* model B58CHECK_ENCODING_PUBLIC_KEY_HASH_ed25519 *)letcost_B58CHECK_ENCODING_PUBLIC_KEY_HASH_ed25519=S.safe_int2_900(* model B58CHECK_ENCODING_PUBLIC_KEY_HASH_p256 *)letcost_B58CHECK_ENCODING_PUBLIC_KEY_HASH_p256=S.safe_int2_900(* model B58CHECK_ENCODING_PUBLIC_KEY_HASH_secp256k1 *)letcost_B58CHECK_ENCODING_PUBLIC_KEY_HASH_secp256k1=S.safe_int2_900(* model B58CHECK_ENCODING_PUBLIC_KEY_ed25519 *)letcost_B58CHECK_ENCODING_PUBLIC_KEY_ed25519=S.safe_int4_200(* model B58CHECK_ENCODING_PUBLIC_KEY_p256 *)letcost_B58CHECK_ENCODING_PUBLIC_KEY_p256=S.safe_int4_700(* model B58CHECK_ENCODING_PUBLIC_KEY_secp256k1 *)letcost_B58CHECK_ENCODING_PUBLIC_KEY_secp256k1=S.safe_int4_500(* model B58CHECK_ENCODING_SIGNATURE_ed25519 *)letcost_B58CHECK_ENCODING_SIGNATURE_ed25519=S.safe_int7_800(* model B58CHECK_ENCODING_SIGNATURE_p256 *)letcost_B58CHECK_ENCODING_SIGNATURE_p256=S.safe_int7_800(* model B58CHECK_ENCODING_SIGNATURE_secp256k1 *)letcost_B58CHECK_ENCODING_SIGNATURE_secp256k1=S.safe_int7_800(* 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_int23_000(* model DECODING_PUBLIC_KEY_secp256k1 *)letcost_DECODING_PUBLIC_KEY_secp256k1=S.safe_int4_800(* model DECODING_SIGNATURE_ed25519 *)letcost_DECODING_SIGNATURE_ed25519=S.safe_int30(* model DECODING_SIGNATURE_p256 *)letcost_DECODING_SIGNATURE_p256=S.safe_int30(* model DECODING_SIGNATURE_secp256k1 *)letcost_DECODING_SIGNATURE_secp256k1=S.safe_int30(* 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_int60(* model ENCODING_PUBLIC_KEY_HASH_p256 *)letcost_ENCODING_PUBLIC_KEY_HASH_p256=S.safe_int80(* 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_int570(* model ENCODING_PUBLIC_KEY_secp256k1 *)letcost_ENCODING_PUBLIC_KEY_secp256k1=S.safe_int440(* model ENCODING_SIGNATURE_ed25519 *)letcost_ENCODING_SIGNATURE_ed25519=S.safe_int40(* model ENCODING_SIGNATURE_p256 *)letcost_ENCODING_SIGNATURE_p256=S.safe_int40(* model ENCODING_SIGNATURE_secp256k1 *)letcost_ENCODING_SIGNATURE_secp256k1=S.safe_int40(* model TIMESTAMP_READABLE_DECODING *)letcost_TIMESTAMP_READABLE_DECODING=S.safe_int120(* model TIMESTAMP_READABLE_ENCODING *)letcost_TIMESTAMP_READABLE_ENCODING=S.safe_int800(* 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_int40(* 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_TYPE=S.safe_int20(* 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_noneletcons_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_map(sndBox.boxed))letmap_iter(typekv)((moduleBox):(k,v)Script_typed_ir.map)=atomic_step_cost(cost_N_IMap_iter(sndBox.boxed))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(String.lengths1)(String.lengths2))letslice_strings=atomic_step_cost(cost_N_ISlice_string(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_tezletmul_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_natletneg_inti=atomic_step_cost(cost_N_INeg_int(int_bytesi))letneg_natn=atomic_step_cost(cost_N_INeg_nat(int_bytesn))letadd_intinti1i2=atomic_step_cost(cost_N_IAdd_intint(int_bytesi1)(int_bytesi2))letadd_intnati1i2=atomic_step_cost(cost_N_IAdd_intnat(int_bytesi1)(int_bytesi2))letadd_natinti1i2=atomic_step_cost(cost_N_IAdd_natint(int_bytesi1)(int_bytesi2))letadd_natnati1i2=atomic_step_cost(cost_N_IAdd_natnat(int_bytesi1)(int_bytesi2))letsub_inti1i2=atomic_step_cost(cost_N_ISub_int(int_bytesi1)(int_bytesi2))letmul_intinti1i2=atomic_step_cost(cost_N_IMul_intint(int_bytesi1)(int_bytesi2))letmul_intnati1i2=atomic_step_cost(cost_N_IMul_intnat(int_bytesi1)(int_bytesi2))letmul_natinti1i2=atomic_step_cost(cost_N_IMul_natint(int_bytesi1)(int_bytesi2))letmul_natnati1i2=atomic_step_cost(cost_N_IMul_natnat(int_bytesi1)(int_bytesi2))letediv_teznat_tez_n=atomic_step_costcost_N_IEdiv_teznatletediv_tez=atomic_step_costcost_N_IEdiv_tezletediv_intinti1i2=atomic_step_cost(cost_N_IEdiv_intint(int_bytesi1)(int_bytesi2))letediv_intnati1i2=atomic_step_cost(cost_N_IEdiv_intnat(int_bytesi1)(int_bytesi2))letediv_natinti1i2=atomic_step_cost(cost_N_IEdiv_natint(int_bytesi1)(int_bytesi2))letediv_natnati1i2=atomic_step_cost(cost_N_IEdiv_natnat(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))letnot_nati=atomic_step_cost(cost_N_INot_nat(int_bytesi))letif_=atomic_step_costcost_N_IIfletloop=atomic_step_costcost_N_ILoopletloop_left=atomic_step_costcost_N_ILoop_leftletdip=atomic_step_costcost_N_IDipletcheck_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))(* --------------------------------------------------------------------- *)(* 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(String.lengths1)(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->let[@coq_axiom_with_reason"gadt"]reccompare: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.freeReturnletset_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_int80)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_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_mem(typekv)(elt:k)((moduleBox):(k,v)Script_typed_ir.map)=letopenS_syntaxinletper_elt_cost=compareBox.key_tyelteltinletsize=S.safe_int(sndBox.boxed)inletintercept=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_int(sndBox.boxed)inletintercept=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_int(sndBox.boxed)inletintercept=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_natnatticket_a.amountticket_b.amount)(* Continuations *)moduleControl=structletnil=atomic_step_costcost_N_KNilletcons=atomic_step_costcost_N_KConsletreturn=atomic_step_costcost_N_KReturnletundip=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_int100+(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=Bytes.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)(* Assuming unflattened storage: /contracts/hash1/.../hash6/key/balance,
balance stored on 64 bits *)letcontract_exists=Gas.cost_of_repr@@Storage_costs.read_access~path_length:9~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))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_type_cycle=atomic_step_costcost_UNPARSE_TYPEletunparse_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)endend