123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2022 Nomadic Labs, <contact@nomadic-labs.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(** These generators aims at generating operations which are not
necessary correct. The goal is to tests functions such as {!
Operation.compare} with as much as possible parameters that play a
role in operation [weight] computation.
When adding a new operation, one should also add its weight
computation, hence knows which kind of generator should be provided
for this new operation.*)openProtocolopenAlpha_context(** {2 Operations kind labelling.} *)letconsensus_pass=`PConsensusletanonymous_pass=`PAnonymousletvote_pass=`PVoteletmanager_pass=`PManagerletall_passes=[`PConsensus;`PAnonymous;`PVote;`PManager]letall_non_manager_passes=[`PConsensus;`PAnonymous;`PVote]letconsensus_kinds=[`KPreattestation;`KAttestation;`KDal_attestation]letanonymous_kinds=[`KSeed_nonce_revelation;`KVdf_revelation;`KDouble_attestation;`KDouble_preattestation;`KDouble_baking;`KActivate_account;]letvote_kinds=[`KProposals;`KBallot](* N.b. we do not consider Failing_noop as those will never be valid. *)letmanager_kinds=[`KReveal;`KTransaction;`KOrigination;`KDelegation;`KSet_deposits_limit;`KIncrease_paid_storage;`KRegister_global_constant;`KTransfer_ticket;`KDal_publish_slot_header;`KSc_rollup_originate;`KSc_rollup_add_messages;`KSc_rollup_cement;`KSc_rollup_publish;`KSc_rollup_refute;`KSc_rollup_timeout;`KSc_rollup_execute_outbox_message;`KSc_rollup_recover_bond;]letpass_to_operation_kinds=function|`PConsensus->consensus_kinds|`PVote->vote_kinds|`PAnonymous->anonymous_kinds|`PManager->[`KManager]letpp_kindfmtk=Format.fprintffmt"%s"(matchkwith|`KPreattestation->"KPreattestation"|`KAttestation->"KAttestation"|`KDal_attestation->"KDal_attestation"|`KSeed_nonce_revelation->"KSeed_nonce_revelation"|`KVdf_revelation->"KVdf_revelation"|`KDouble_attestation->"KDouble_attestation"|`KDouble_preattestation->"KDouble_preattestation"|`KDouble_baking->"KDouble_baking"|`KActivate_account->"KActivate_account"|`KProposals->"KProposals"|`KBallot->"KBallot"|`KManager->"KManager")(** {2 Generators} *)moduleGen_hash(H:sigtypetvalsize:intvalof_bytes_exn:bytes->tend)=structletgen=letopenQCheck2.Geninlet+str=string_size(pureH.size)inH.of_bytes_exn(Bytes.unsafe_of_stringstr)end(** {3 Selection in hashes list} *)letgen_block_hash=letmoduleG=Gen_hash(Block_hash)inG.genletrandom_payload_hash=letmoduleG=Gen_hash(Block_payload_hash)inG.genletgen_algo=QCheck2.Gen.oneoflSignature.algosletrandom_seed=letopenQCheck2.Geninlet+str=string_size(pureTezos_crypto.Hacl.Ed25519.sk_size)inBytes.unsafe_of_stringstrletrandom_keys=letopenQCheck2.Geninlet*algo=gen_algoinlet+seed=random_seedinSignature.generate_key~algo~seed()letrandom_tz1=letopenQCheck2.Geninlet+str=string_size(pureSignature.Ed25519.Public_key_hash.size)in(Ed25519(Signature.Ed25519.Public_key_hash.of_string_exnstr):public_key_hash)letrandom_tz2=letopenQCheck2.Geninlet+str=string_size(pureSignature.Secp256k1.Public_key_hash.size)in(Secp256k1(Signature.Secp256k1.Public_key_hash.of_string_exnstr):public_key_hash)letrandom_tz3=letopenQCheck2.Geninlet+str=string_size(pureSignature.P256.Public_key_hash.size)in(P256(Signature.P256.Public_key_hash.of_string_exnstr):public_key_hash)letrandom_tz4=letopenQCheck2.Geninlet+str=string_size(pureSignature.Bls.Public_key_hash.size)in(Bls(Signature.Bls.Public_key_hash.of_string_exnstr):public_key_hash)letrandom_pkh=letopenQCheck2.Geninlet*algo=gen_algoinmatchalgowith|Ed25519->random_tz1|Secp256k1->random_tz2|P256->random_tz3|Bls->random_tz4letrandom_pk=letopenQCheck2.Geninlet+_,pk,_=random_keysinpkletrandom_signature=letopenQCheck2.Geninlet*algo=option~ratio:0.8gen_algoinmatchalgowith|None->let+str=string_size(pureSignature.Ed25519.size)in(Unknown(Bytes.unsafe_of_stringstr):Signature.t)|SomeEd25519->let+str=string_size(pureSignature.Ed25519.size)in(Ed25519(Signature.Ed25519.of_string_exnstr):Signature.t)|SomeSecp256k1->let+str=string_size(pureSignature.Secp256k1.size)in(Secp256k1(Signature.Secp256k1.of_string_exnstr):Signature.t)|SomeP256->let+str=string_size(pureSignature.P256.size)in(P256(Signature.P256.of_string_exnstr):Signature.t)|SomeBls->let+seed=random_seedinlet_,_,sk=Signature.generate_key~algo:Bls~seed()inSignature.signskBytes.emptyletrandom_signature=letopenQCheck2.Geningraft_cornersrandom_signatureSignature.[of_ed25519Signature.Ed25519.zero;of_secp256k1Signature.Secp256k1.zero;of_p256Signature.P256.zero;of_blsSignature.Bls.zero;Unknown(Bytes.make64'\000');]()letrandom_contract_hash=letmoduleG=Gen_hash(Contract_hash)inG.genletblock_headers=letbh1={json|{ "level": 2, "proto": 1, "predecessor": "BLbcVY1kYiKQy2MJJfoHJMN2xRk5QPG1PEKWMDSyW2JMxBsMmiL", "timestamp": "2022-08-08T11:16:30Z", "validation_pass": 4, "operations_hash": "LLoa7bxRTKaQN2bLYoitYB6bU2DvLnBAqrVjZcvJ364cTcX2PZYKU", "fitness": [ "02", "00000002", "", "ffffffff", "00000001" ], "context": "CoUvpF8XBUfz3w9CJumt4ZKGZkrcdcfs1Qdrrd1ZeFij64E1QCud", "payload_hash": "vh2TyrWeZ2dydEy9ZjmvrjQvyCs5sdHZPypcZrXDUSM1tNuPermf", "payload_round": 1, "proof_of_work_nonce": "62de1e0d00000000", "liquidity_baking_toggle_vote": "pass", "adaptive_issuance_vote": "pass", "signature": "sigaXGo4DWsZwo1SvbKCp2hLgE5jcwd61Ufkc3iMt3sXy3NBj9jticuJKJnRhyH2ZPJQMwEuDqQTgZgoK5xRH6HeF7YxLb4u" }|json}inletbh2={json|{ "level": 3, "proto": 1, "predecessor": "BLAUNUbzKHgA4DYQEXCbxY73wdE2roGAzvJJbFp8dQe62Ekpada", "timestamp": "2022-08-08T11:16:32Z", "validation_pass": 4, "operations_hash": "LLoaWjBX8Cm8DVpoLNtm7FPNnxUdL6Dakq122pVfNHYaf2rE9GQXi", "fitness": [ "02", "00000003", "", "fffffffe", "00000000" ], "context": "CoUtWowJUqXwMm4pbR1jjyFfVRHqRHGs6bYVDaaByvbmULoAND2x", "payload_hash": "vh1p1VzeYjZLEW6WDqdTwVy354KEmGCDgPmagEKcLN4NT4X58mNk", "payload_round": 0, "proof_of_work_nonce": "62de1e0d00000000", "liquidity_baking_toggle_vote": "pass", "adaptive_issuance_vote": "pass", "signature": "sigVqWWE7BPuxHqPWiVRmzQ1eMZZAPAxGJ94ytY2sjV8Y1Z4QH1F2bPGZS1ZeWDbqmcppPPFobRpi7wNasQ17Mm9CFGKag2t" }|json}inletbh3={json|{ "level": 4, "proto": 1, "predecessor": "BLuurCvGmNPTzXSnGCpcFPy5h8A49PwH2LnfAWBnp5R1qv5czwe", "timestamp": "2022-08-08T11:16:33Z", "validation_pass": 4, "operations_hash": "LLoaf8AANzyNxhk715zykDrwG5Bpqw6FsZLWWNp2Dcm3ewFrcc3Wc", "fitness": [ "02", "00000004", "", "ffffffff", "00000000" ], "context": "CoVzxEBMDhxpGVxrguik6r5qVogJBFyhuvwm2KZBcsmvqhekPiwL", "payload_hash": "vh2gWcSUUhJBwvjx4vS7JN5ioMVWpHCSK6W2MKNPr5dn6NUdfFDQ", "payload_round": 0, "proof_of_work_nonce": "62de1e0d00000000", "seed_nonce_hash": "nceV3VjdHp1yk6uqcQicQBxLJY1AfWvLSabQpqnpiqkC1q2tS35EN", "liquidity_baking_toggle_vote": "pass", "adaptive_issuance_vote": "pass", "signature": "sigijumaDLSQwjh2AKK7af1VcEDsZsRwbweL8hF176puhHy3ySVocNCbrwPqJLiQP8EbqY5YL6z6b1vDaw12h8MQU2Rh4SW1" }|json}inList.map(funs->letopenData_encoding.Jsoninfrom_strings|>function|Okjson->destructAlpha_context.Block_header.encodingjson|Error_->assertfalse)[bh1;bh2;bh3]letrandom_block_header=QCheck2.Gen.oneoflblock_headersletrandom_sc_rollup=letmoduleG=Gen_hash(Sc_rollup.Address)inG.genletrandom_proto=letmoduleG=Gen_hash(Protocol_hash)inG.genletrandom_code=letopenQCheck2.Geninlet+str=string_size(pureSignature.Ed25519.Public_key_hash.size)inlet(`Hexhex)=Hex.of_stringstrinBlinded_public_key_hash.activation_code_of_hexhex|>WithExceptions.Option.get~loc:__LOC__(** {2 Operations parameters generators} *)letrandom_shell:Tezos_base.Operation.shell_headerQCheck2.Gen.t=letopenQCheck2.Geninlet+branch=gen_block_hashinTezos_base.Operation.{branch}letgen_slot=letopenQCheck2.Geninlet+i=small_natinmatchSlot.Internal_for_tests.of_intiwith|Okslot->slot|Error_->assertfalseletgen_level=letopenQCheck2.Geninlet+i=ui32inmatchRaw_level.of_int32iwithOkv->v|Error_->assertfalseletgen_round=letopenQCheck2.Geninlet+i=ui32inmatchRound.of_int32iwithOkv->v|Error_->assertfalseletgenerate_consensus_content:consensus_contentQCheck2.Gen.t=letopenQCheck2.Geninlet*slot=gen_slotinlet*level=gen_levelinlet*round=gen_roundinlet+block_payload_hash=random_payload_hashin{slot;level;round;block_payload_hash}letgen_tez=letopenQCheck2.Geninlet+i=ui64inmatchTez.of_muteziwithNone->Tez.zero|Somev->vletgen_fee=gen_tezletgen_amount=gen_tezletgen_amount_in_bytes=letopenQCheck2.Geninlet+i=natinZ.of_intiletrandom_contract=letopenQCheck2.Geninlet*b=boolinifbthenlet+pkh=random_pkhinContract.Implicitpkhelselet+contract_hash=random_contract_hashinContract.Originatedcontract_hashletgen_counters=letopenQCheck2.Geninlet+i=natinManager_counter.Internal_for_tests.of_intiletgen_ticket_amounts=letopenQCheck2.Geninlet+i=natinOption.value(Ticket_amount.of_zint(Z.of_inti))~default:Ticket_amount.oneletgen_gas_limit=letopenQCheck2.Geninlet+i=natinGas.Arith.integral_of_int_exniletgen_storage_limit=letopenQCheck2.Geninlet+i=natinZ.of_intiletnonces=List.map(funi->letb=Bytes.create32inBytes.set_int8b0i;Alpha_context.Nonce.of_bytesb|>function|Okv->v|Error_->assertfalse)[1;2;3]letrandom_nonce=QCheck2.Gen.oneoflnoncesletvdf_solutions=letopenEnvironment.Vdfinletopt_assert=functionSomev->v|None->assertfalseinList.map(funi->letb=Bytes.createform_size_bytesinBytes.set_int8b0i;letresult=result_of_bytes_optb|>opt_assertinletproof=proof_of_bytes_optb|>opt_assertin(result,proof))[1;2;3](** {2 Generators for each Operation Kind} *)letwrap_operationsh(pdata:'kindprotocol_data):'kindoperation={shell=sh;protocol_data=pdata}letgenerate_op(gen_op:'kindcontentsQCheck2.Gen.t):'kindoperationQCheck2.Gen.t=letopenQCheck2.Geninlet*op=gen_opinlet*signature=option~ratio:0.9random_signatureinlet+shell=random_shellinletcontents=Singleopinletprotocol_data={contents;signature}inwrap_operationshellprotocol_dataletgenerate_operationgen_op=letopenQCheck2.Geninlet+op=generate_opgen_opinOperation.packopletgenerate_preattestation=letopenQCheck2.Geninlet+cc=generate_consensus_contentinPreattestationccletgenerate_attestation=letopenQCheck2.Geninlet+cc=generate_consensus_contentinAttestationccletgenerate_dal_attestation=letopenQCheck2.Geninlet*level=gen_levelinlet+slot=gen_slotinDal_attestationDal.Attestation.{attestation=Dal.Attestation.empty;level;slot}letgenerate_vdf_revelation=letopenQCheck2.Geninlet+solution=oneoflvdf_solutionsinVdf_revelation{solution}letgenerate_seed_nonce_revelation=letopenQCheck2.Geninlet*level=gen_levelinlet+nonce=random_nonceinSeed_nonce_revelation{level;nonce}letgenerate_double_preattestation=letopenQCheck2.Geninlet*op1=generate_opgenerate_preattestationinlet+op2=generate_opgenerate_preattestationinDouble_preattestation_evidence{op1;op2}letgenerate_double_attestation=letopenQCheck2.Geninlet*op1=generate_opgenerate_attestationinlet+op2=generate_opgenerate_attestationinDouble_attestation_evidence{op1;op2}letgenerate_double_baking=letopenQCheck2.Geninlet*bh1=random_block_headerinlet+bh2=random_block_headerinDouble_baking_evidence{bh1;bh2}letgenerate_activate_account=letopenQCheck2.Geninlet*activation_code=random_codeinlet+id=random_tz1inletid=matchidwithSignature.Ed25519pkh->pkh|_->assertfalseinActivate_account{id;activation_code}letrandom_period=letopenQCheck2.Geninlet+i=ui32iniletgenerate_proposals=letopenQCheck2.Geninlet*source=random_pkhinlet+period=random_periodinletproposals=[]inProposals{source;period;proposals}letgenerate_ballot=letopenQCheck2.Geninlet*source=random_pkhinlet*period=random_periodinlet+proposal=random_protoinletballot=Vote.PassinBallot{source;period;proposal;ballot}letgenerate_manager_aux?sourcegen_manop=letopenQCheck2.Geninlet*source=matchsourcewithNone->random_pkh|Somesource->returnsourceinlet*fee=gen_feeinlet*counter=gen_countersinlet*gas_limit=gen_gas_limitinlet*storage_limit=gen_storage_limitinlet+operation=gen_manopinManager_operation{source;fee;counter;operation;gas_limit;storage_limit}letgenerate_manager?sourcegen_manop=generate_op(generate_manager_aux?sourcegen_manop)letgenerate_manager_operation?sourcegen_manop=letopenQCheck2.Geninlet+manop=generate_manager?sourcegen_manopinOperation.packmanopletgenerate_reveal=letopenQCheck2.Geninlet+pk=random_pkinRevealpkletgenerate_transaction=letopenQCheck2.Geninlet*amount=gen_amountinlet+destination=random_contractinletparameters=Script.unit_parameterinletentrypoint=Entrypoint.defaultinTransaction{amount;parameters;entrypoint;destination}letgenerate_origination=letopenQCheck2.Geninlet+credit=gen_amountinletdelegate=Noneinletscript=Script.{code=unit_parameter;storage=unit_parameter}inOrigination{delegate;script;credit}letgenerate_delegation=letopenQCheck2.Geninlet+delegate=optionrandom_pkhinDelegationdelegateletgenerate_increase_paid_storage=letopenQCheck2.Geninlet*amount_in_bytes=gen_amount_in_bytesinlet+destination=random_contract_hashinIncrease_paid_storage{amount_in_bytes;destination}letgenerate_set_deposits_limit=letopenQCheck2.Geninlet+amount_opt=optiongen_amountinSet_deposits_limitamount_optletgenerate_register_global_constant=letvalue=Script_repr.lazy_expr(Expr.from_string"Pair 1 2")inQCheck2.Gen.pure(Register_global_constant{value})letgenerate_transfer_ticket=letopenQCheck2.Geninlet*ticketer=random_contractinlet*destination=random_contractinlet+amount=gen_ticket_amountsinletcontents=Script.lazy_expr(Expr.from_string"1")inletty=Script.lazy_expr(Expr.from_string"nat")inletentrypoint=Entrypoint.defaultinTransfer_ticket{contents;ty;ticketer;amount;destination;entrypoint}letgenerate_dal_publish_slot_header=letslot_index=Alpha_context.Dal.Slot_index.zeroinletcommitment=Alpha_context.Dal.Slot.Commitment.zeroinletcommitment_proof=Alpha_context.Dal.Slot.Commitment_proof.zeroinletslot_header=Alpha_context.Dal.Operations.Publish_slot_header.{slot_index;commitment;commitment_proof}inQCheck2.Gen.pure(Dal_publish_slot_headerslot_header)letgenerate_sc_rollup_originate=letkind=Sc_rollup.Kind.Example_arithinletboot_sector=""inletparameters_ty=Script.lazy_expr(Expr.from_string"1")inletwhitelist=NoneinQCheck2.Gen.pure(Sc_rollup_originate{kind;boot_sector;parameters_ty;whitelist})letgenerate_sc_rollup_add_messages=letopenQCheck2.Geninreturn(Sc_rollup_add_messages{messages=[]})letsc_dummy_commitment=letnumber_of_ticks=matchSc_rollup.Number_of_ticks.of_value3000Lwith|None->assertfalse|Somex->xinSc_rollup.Commitment.{predecessor=Sc_rollup.Commitment.Hash.zero;inbox_level=Raw_level.of_int32_exnInt32.zero;number_of_ticks;compressed_state=Sc_rollup.State_hash.zero;}letgenerate_sc_rollup_cement=letopenQCheck2.Geninlet+rollup=random_sc_rollupinSc_rollup_cement{rollup}letgenerate_sc_rollup_publish=letopenQCheck2.Geninlet+rollup=random_sc_rollupinletcommitment=sc_dummy_commitmentinSc_rollup_publish{rollup;commitment}letgenerate_sc_rollup_refute=letopenQCheck2.Geninlet*opponent=random_pkhinlet+rollup=random_sc_rollupinletrefutation:Sc_rollup.Game.refutation=Sc_rollup.Game.Move{choice=Sc_rollup.Tick.initial;step=Dissection[]}inSc_rollup_refute{rollup;opponent;refutation}letgenerate_sc_rollup_timeout=letopenQCheck2.Geninlet*source=random_pkhinlet*rollup=random_sc_rollupinlet+staker=random_pkhinletstakers=Sc_rollup.Game.Index.makesourcestakerinSc_rollup_timeout{rollup;stakers}letgenerate_sc_rollup_execute_outbox_message=letopenQCheck2.Geninlet+rollup=random_sc_rollupinletcemented_commitment=Sc_rollup.Commitment.hash_uncarbonatedsc_dummy_commitmentinletoutput_proof=""inSc_rollup_execute_outbox_message{rollup;cemented_commitment;output_proof}letgenerate_sc_rollup_recover_bond=letopenQCheck2.Geninlet*staker=random_pkhinlet+sc_rollup=random_sc_rollupinSc_rollup_recover_bond{sc_rollup;staker}(** {2 By Kind Operation Generator} *)letgenerator_of?source=function|`KReveal->generate_manager_operation?sourcegenerate_reveal|`KTransaction->generate_manager_operation?sourcegenerate_transaction|`KOrigination->generate_manager_operation?sourcegenerate_origination|`KSet_deposits_limit->generate_manager_operation?sourcegenerate_set_deposits_limit|`KIncrease_paid_storage->generate_manager_operation?sourcegenerate_increase_paid_storage|`KDelegation->generate_manager_operation?sourcegenerate_delegation|`KRegister_global_constant->generate_manager_operation?sourcegenerate_register_global_constant|`KTransfer_ticket->generate_manager_operation?sourcegenerate_transfer_ticket|`KDal_publish_slot_header->generate_manager_operation?sourcegenerate_dal_publish_slot_header|`KSc_rollup_originate->generate_manager_operation?sourcegenerate_sc_rollup_originate|`KSc_rollup_add_messages->generate_manager_operation?sourcegenerate_sc_rollup_add_messages|`KSc_rollup_cement->generate_manager_operation?sourcegenerate_sc_rollup_cement|`KSc_rollup_publish->generate_manager_operation?sourcegenerate_sc_rollup_publish|`KSc_rollup_refute->generate_manager_operation?sourcegenerate_sc_rollup_refute|`KSc_rollup_timeout->generate_manager_operation?sourcegenerate_sc_rollup_timeout|`KSc_rollup_execute_outbox_message->generate_manager_operation?sourcegenerate_sc_rollup_execute_outbox_message|`KSc_rollup_recover_bond->generate_manager_operation?sourcegenerate_sc_rollup_recover_bondletgenerate_non_manager_operation=letopenQCheck2.Geninlet*pass=oneoflall_non_manager_passesinlet*kind=oneofl(pass_to_operation_kindspass)inmatchkindwith|`KPreattestation->generate_operationgenerate_preattestation|`KAttestation->generate_operationgenerate_attestation|`KDal_attestation->generate_operationgenerate_dal_attestation|`KSeed_nonce_revelation->generate_operationgenerate_seed_nonce_revelation|`KVdf_revelation->generate_operationgenerate_vdf_revelation|`KDouble_attestation->generate_operationgenerate_double_attestation|`KDouble_preattestation->generate_operationgenerate_double_preattestation|`KDouble_baking->generate_operationgenerate_double_baking|`KActivate_account->generate_operationgenerate_activate_account|`KProposals->generate_operationgenerate_proposals|`KBallot->generate_operationgenerate_ballot|`KManager->assertfalseletgenerate_manager_operationbatch_size=letopenQCheck2.Geninlet*source=random_pkhinletsource=Somesourceinlet*l=flatten_l(Stdlib.List.initbatch_size(fun_->oneoflmanager_kinds))inlet*packed_manager_ops=flatten_l(List.map(generator_of?source)l)inletfirst_op=Stdlib.List.hdpacked_manager_opsinletunpacked_operations=List.map(function|{Alpha_context.protocol_data=Operation_data{contents;_};_}->(matchContents_listcontentswith|Contents_list(Singleo)->Contentso|Contents_list(Cons(Manager_operation{operation=Reveal_;_},Singleo))->Contentso|_->assertfalse))packed_manager_opsinletcontents_list=List.fold_left(funacc->function|Contents(Manager_operationm)->Contents(Manager_operationm)::acc|x->x::acc)[]unpacked_operations|>List.revinlet(Contents_listcontents_list)=matchOperation.of_listcontents_listwithOkv->v|_->assertfalseinletsignature=matchfirst_op.protocol_datawith|Operation_data{signature;_}->signatureinletprotocol_data={contents=contents_list;signature}inreturn(Operation.pack{shell=first_op.shell;protocol_data})(** The default upper bound on the number of manager operations in a batch.
As of December 2022, there is no batch maximal size enforced
anywhere in the protocol. However, the Octez Shell only accepts
batches of at most [operations_batch_size] operations, which has a
default value of [50] in [src/lib_shell_services/shell_limits.ml].
The protocol tests do not necessarily have to align with this
value, but there is no reason either to choose a different
one. Therefore, they use the same bound, but decremented once to
account for some tests adding a reveal at the front of the batch as
needed. *)letmax_batch_size=49letgenerate_operation=letopenQCheck2.Geninlet*pass=oneoflall_passesinlet*kind=oneofl(pass_to_operation_kindspass)inlet+packed_operation=matchkindwith|`KPreattestation->generate_operationgenerate_preattestation|`KAttestation->generate_operationgenerate_attestation|`KDal_attestation->generate_operationgenerate_dal_attestation|`KSeed_nonce_revelation->generate_operationgenerate_seed_nonce_revelation|`KVdf_revelation->generate_operationgenerate_vdf_revelation|`KDouble_attestation->generate_operationgenerate_double_attestation|`KDouble_preattestation->generate_operationgenerate_double_preattestation|`KDouble_baking->generate_operationgenerate_double_baking|`KActivate_account->generate_operationgenerate_activate_account|`KProposals->generate_operationgenerate_proposals|`KBallot->generate_operationgenerate_ballot|`KManager->let*batch_size=int_range1max_batch_sizeingenerate_manager_operationbatch_sizein(kind,(Operation.hash_packedpacked_operation,packed_operation))