123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.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. *)(* *)(*****************************************************************************)typebootstrap_account={public_key_hash:Signature.Public_key_hash.t;public_key:Signature.Public_key.toption;amount:Tez_repr.t;}typebootstrap_contract={delegate:Signature.Public_key_hash.t;amount:Tez_repr.t;script:Script_repr.t;}typet={bootstrap_accounts:bootstrap_accountlist;bootstrap_contracts:bootstrap_contractlist;commitments:Commitment_repr.tlist;constants:Constants_repr.parametric;security_deposit_ramp_up_cycles:intoption;no_reward_cycles:intoption;}letbootstrap_account_encoding=letopenData_encodinginunion[case(Tag0)~title:"Public_key_known"(tup2Signature.Public_key.encodingTez_repr.encoding)(function|{public_key_hash;public_key=Somepublic_key;amount}->assert(Signature.Public_key_hash.equal(Signature.Public_key.hashpublic_key)public_key_hash);Some(public_key,amount)|{public_key=None}->None)(fun(public_key,amount)->{public_key=Somepublic_key;public_key_hash=Signature.Public_key.hashpublic_key;amount});case(Tag1)~title:"Public_key_unknown"(tup2Signature.Public_key_hash.encodingTez_repr.encoding)(function|{public_key_hash;public_key=None;amount}->Some(public_key_hash,amount)|{public_key=Some_}->None)(fun(public_key_hash,amount)->{public_key=None;public_key_hash;amount})]letbootstrap_contract_encoding=letopenData_encodinginconv(fun{delegate;amount;script}->(delegate,amount,script))(fun(delegate,amount,script)->{delegate;amount;script})(obj3(req"delegate"Signature.Public_key_hash.encoding)(req"amount"Tez_repr.encoding)(req"script"Script_repr.encoding))letencoding=letopenData_encodinginconv(fun{bootstrap_accounts;bootstrap_contracts;commitments;constants;security_deposit_ramp_up_cycles;no_reward_cycles}->((bootstrap_accounts,bootstrap_contracts,commitments,security_deposit_ramp_up_cycles,no_reward_cycles),constants))(fun((bootstrap_accounts,bootstrap_contracts,commitments,security_deposit_ramp_up_cycles,no_reward_cycles),constants)->{bootstrap_accounts;bootstrap_contracts;commitments;constants;security_deposit_ramp_up_cycles;no_reward_cycles})(merge_objs(obj5(req"bootstrap_accounts"(listbootstrap_account_encoding))(dft"bootstrap_contracts"(listbootstrap_contract_encoding)[])(dft"commitments"(listCommitment_repr.encoding)[])(opt"security_deposit_ramp_up_cycles"int31)(opt"no_reward_cycles"int31))Constants_repr.parametric_encoding)(* Only for migration from 004 to 005 *)moduleProto_004=structtypeparametric={preserved_cycles:int;blocks_per_cycle:int32;blocks_per_commitment:int32;blocks_per_roll_snapshot:int32;blocks_per_voting_period:int32;time_between_blocks:Period_repr.tlist;endorsers_per_block:int;hard_gas_limit_per_operation:Z.t;hard_gas_limit_per_block:Z.t;proof_of_work_threshold:int64;tokens_per_roll:Tez_repr.t;michelson_maximum_type_size:int;seed_nonce_revelation_tip:Tez_repr.t;origination_size:int;block_security_deposit:Tez_repr.t;endorsement_security_deposit:Tez_repr.t;block_reward:Tez_repr.t;endorsement_reward:Tez_repr.t;cost_per_byte:Tez_repr.t;hard_storage_limit_per_operation:Z.t;test_chain_duration:int64;(* in seconds *)}letdefault={preserved_cycles=5;blocks_per_cycle=4096l;blocks_per_commitment=32l;blocks_per_roll_snapshot=256l;blocks_per_voting_period=32768l;time_between_blocks=List.mapPeriod_repr.of_seconds_exn[60L;75L];endorsers_per_block=32;hard_gas_limit_per_operation=Z.of_int800_000;hard_gas_limit_per_block=Z.of_int8_000_000;proof_of_work_threshold=Int64.(sub(shift_left1L46)1L);tokens_per_roll=Tez_repr.(mul_exnone8_000);michelson_maximum_type_size=1000;seed_nonce_revelation_tip=beginmatchTez_repr.(one/?8L)with|Okc->c|Error_->assertfalseend;origination_size=257;block_security_deposit=Tez_repr.(mul_exnone512);endorsement_security_deposit=Tez_repr.(mul_exnone64);block_reward=Tez_repr.(mul_exnone16);endorsement_reward=Tez_repr.(mul_exnone2);hard_storage_limit_per_operation=Z.of_int60_000;cost_per_byte=Tez_repr.of_mutez_exn1_000L;test_chain_duration=Int64.mul32768L60L;}(* This encoding is used to read configuration files (e.g. sandbox.json)
where some fields can be missing, in that case they are replaced by
the default. *)letconstants_encoding=letopenData_encodinginconv(fun(c:parametric)->letmoduleCompare_time_between_blocks=Compare.List(Period_repr)inletmoduleCompare_keys=Compare.List(Ed25519.Public_key)inletopt(=)defv=ifdef=vthenNoneelseSomevinletpreserved_cycles=optCompare.Int.(=)default.preserved_cyclesc.preserved_cyclesandblocks_per_cycle=optCompare.Int32.(=)default.blocks_per_cyclec.blocks_per_cycleandblocks_per_commitment=optCompare.Int32.(=)default.blocks_per_commitmentc.blocks_per_commitmentandblocks_per_roll_snapshot=optCompare.Int32.(=)default.blocks_per_roll_snapshotc.blocks_per_roll_snapshotandblocks_per_voting_period=optCompare.Int32.(=)default.blocks_per_voting_periodc.blocks_per_voting_periodandtime_between_blocks=optCompare_time_between_blocks.(=)default.time_between_blocksc.time_between_blocksandendorsers_per_block=optCompare.Int.(=)default.endorsers_per_blockc.endorsers_per_blockandhard_gas_limit_per_operation=optCompare.Z.(=)default.hard_gas_limit_per_operationc.hard_gas_limit_per_operationandhard_gas_limit_per_block=optCompare.Z.(=)default.hard_gas_limit_per_blockc.hard_gas_limit_per_blockandproof_of_work_threshold=optCompare.Int64.(=)default.proof_of_work_thresholdc.proof_of_work_thresholdandtokens_per_roll=optTez_repr.(=)default.tokens_per_rollc.tokens_per_rollandmichelson_maximum_type_size=optCompare.Int.(=)default.michelson_maximum_type_sizec.michelson_maximum_type_sizeandseed_nonce_revelation_tip=optTez_repr.(=)default.seed_nonce_revelation_tipc.seed_nonce_revelation_tipandorigination_size=optCompare.Int.(=)default.origination_sizec.origination_sizeandblock_security_deposit=optTez_repr.(=)default.block_security_depositc.block_security_depositandendorsement_security_deposit=optTez_repr.(=)default.endorsement_security_depositc.endorsement_security_depositandblock_reward=optTez_repr.(=)default.block_rewardc.block_rewardandendorsement_reward=optTez_repr.(=)default.endorsement_rewardc.endorsement_rewardandcost_per_byte=optTez_repr.(=)default.cost_per_bytec.cost_per_byteandhard_storage_limit_per_operation=optCompare.Z.(=)default.hard_storage_limit_per_operationc.hard_storage_limit_per_operationandtest_chain_duration=optCompare.Int64.(=)default.test_chain_durationc.test_chain_durationin((preserved_cycles,blocks_per_cycle,blocks_per_commitment,blocks_per_roll_snapshot,blocks_per_voting_period,time_between_blocks,endorsers_per_block,hard_gas_limit_per_operation,hard_gas_limit_per_block),((proof_of_work_threshold,tokens_per_roll,michelson_maximum_type_size,seed_nonce_revelation_tip,origination_size,block_security_deposit,endorsement_security_deposit,block_reward),(endorsement_reward,cost_per_byte,hard_storage_limit_per_operation,test_chain_duration))))(fun((preserved_cycles,blocks_per_cycle,blocks_per_commitment,blocks_per_roll_snapshot,blocks_per_voting_period,time_between_blocks,endorsers_per_block,hard_gas_limit_per_operation,hard_gas_limit_per_block),((proof_of_work_threshold,tokens_per_roll,michelson_maximum_type_size,seed_nonce_revelation_tip,origination_size,block_security_deposit,endorsement_security_deposit,block_reward),(endorsement_reward,cost_per_byte,hard_storage_limit_per_operation,test_chain_duration)))->letunoptdef=functionNone->def|Somev->vin{preserved_cycles=unoptdefault.preserved_cyclespreserved_cycles;blocks_per_cycle=unoptdefault.blocks_per_cycleblocks_per_cycle;blocks_per_commitment=unoptdefault.blocks_per_commitmentblocks_per_commitment;blocks_per_roll_snapshot=unoptdefault.blocks_per_roll_snapshotblocks_per_roll_snapshot;blocks_per_voting_period=unoptdefault.blocks_per_voting_periodblocks_per_voting_period;time_between_blocks=unoptdefault.time_between_blocks@@time_between_blocks;endorsers_per_block=unoptdefault.endorsers_per_blockendorsers_per_block;hard_gas_limit_per_operation=unoptdefault.hard_gas_limit_per_operationhard_gas_limit_per_operation;hard_gas_limit_per_block=unoptdefault.hard_gas_limit_per_blockhard_gas_limit_per_block;proof_of_work_threshold=unoptdefault.proof_of_work_thresholdproof_of_work_threshold;tokens_per_roll=unoptdefault.tokens_per_rolltokens_per_roll;michelson_maximum_type_size=unoptdefault.michelson_maximum_type_sizemichelson_maximum_type_size;seed_nonce_revelation_tip=unoptdefault.seed_nonce_revelation_tipseed_nonce_revelation_tip;origination_size=unoptdefault.origination_sizeorigination_size;block_security_deposit=unoptdefault.block_security_depositblock_security_deposit;endorsement_security_deposit=unoptdefault.endorsement_security_depositendorsement_security_deposit;block_reward=unoptdefault.block_rewardblock_reward;endorsement_reward=unoptdefault.endorsement_rewardendorsement_reward;cost_per_byte=unoptdefault.cost_per_bytecost_per_byte;hard_storage_limit_per_operation=unoptdefault.hard_storage_limit_per_operationhard_storage_limit_per_operation;test_chain_duration=unoptdefault.test_chain_durationtest_chain_duration;})(merge_objs(obj9(opt"preserved_cycles"uint8)(opt"blocks_per_cycle"int32)(opt"blocks_per_commitment"int32)(opt"blocks_per_roll_snapshot"int32)(opt"blocks_per_voting_period"int32)(opt"time_between_blocks"(listPeriod_repr.encoding))(opt"endorsers_per_block"uint16)(opt"hard_gas_limit_per_operation"z)(opt"hard_gas_limit_per_block"z))(merge_objs(obj8(opt"proof_of_work_threshold"int64)(opt"tokens_per_roll"Tez_repr.encoding)(opt"michelson_maximum_type_size"uint16)(opt"seed_nonce_revelation_tip"Tez_repr.encoding)(opt"origination_size"int31)(opt"block_security_deposit"Tez_repr.encoding)(opt"endorsement_security_deposit"Tez_repr.encoding)(opt"block_reward"Tez_repr.encoding))(obj4(opt"endorsement_reward"Tez_repr.encoding)(opt"cost_per_byte"Tez_repr.encoding)(opt"hard_storage_limit_per_operation"z)(opt"test_chain_duration"int64))))end