Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file sc_rollup_operations.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2021 Nomadic Labs <contact@nomadic-labs.com> *)(* Copyright (c) 2022 TriliTech <contact@trili.tech> *)(* *)(* 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_contexttypeerror+=|(* Permanent *)Sc_rollup_invalid_parameters_type|(* Permanent *)Sc_rollup_invalid_atomic_batchlet()=letdescription="Invalid parameters type for rollup"inregister_error_kind`Permanent~id:"Sc_rollup_invalid_parameters_type"~title:"Invalid parameters type"~description~pp:(funfmt()->Format.fprintffmt"%s"description)Data_encoding.unit(functionSc_rollup_invalid_parameters_type->Some()|_->None)(fun()->Sc_rollup_invalid_parameters_type);letdescription="Smart-contract rollup atomic batch operation is not yet supported"inregister_error_kind`Permanent~id:"Sc_rollup_invalid_atomic_batch"~title:description~description~pp:(funppf()->Format.fprintfppf"%s"description)Data_encoding.empty(functionSc_rollup_invalid_atomic_batch->Some()|_->None)(fun()->Sc_rollup_invalid_atomic_batch)typeorigination_result={address:Sc_rollup.Address.t;size:Z.t}type'retcontinuation=unit->'rettzresult(* Only a subset of types are supported for rollups.
This function checks whether or not a type can be used for a rollup. *)letrecvalidate_ty:typeaacret.(a,ac)Script_typed_ir.ty->retcontinuation->rettzresult=funtyk->letopenScript_typed_irinmatchtywith(* Valid primitive types. *)|Unit_t->(k[@ocaml.tailcall])()|Int_t->(k[@ocaml.tailcall])()|Nat_t->(k[@ocaml.tailcall])()|Signature_t->(k[@ocaml.tailcall])()|String_t->(k[@ocaml.tailcall])()|Bytes_t->(k[@ocaml.tailcall])()|Key_hash_t->(k[@ocaml.tailcall])()|Key_t->(k[@ocaml.tailcall])()|Timestamp_t->(k[@ocaml.tailcall])()|Address_t->(k[@ocaml.tailcall])()|Bls12_381_g1_t->(k[@ocaml.tailcall])()|Bls12_381_g2_t->(k[@ocaml.tailcall])()|Bls12_381_fr_t->(k[@ocaml.tailcall])()|Bool_t->(k[@ocaml.tailcall])()|Never_t->(k[@ocaml.tailcall])()|Tx_rollup_l2_address_t->(k[@ocaml.tailcall])()|Chain_id_t->(k[@ocaml.tailcall])()(* Valid collection types. *)|Ticket_t(ty,_)->(validate_ty[@ocaml.tailcall])tyk|Set_t(ty,_)->(validate_ty[@ocaml.tailcall])tyk|Option_t(ty,_,_)->(validate_ty[@ocaml.tailcall])tyk|List_t(ty,_)->(validate_ty[@ocaml.tailcall])tyk|Pair_t(ty1,ty2,_,_)->(validate_two_tys[@ocaml.tailcall])ty1ty2k|Union_t(ty1,ty2,_,_)->(validate_two_tys[@ocaml.tailcall])ty1ty2k|Map_t(key_ty,val_ty,_)->(validate_two_tys[@ocaml.tailcall])key_tyval_tyk(* Invalid types. *)|Mutez_t->errorSc_rollup_invalid_parameters_type|Big_map_t(_key_ty,_val_ty,_)->errorSc_rollup_invalid_parameters_type|Contract_t_->errorSc_rollup_invalid_parameters_type|Sapling_transaction_t_->errorSc_rollup_invalid_parameters_type|Sapling_transaction_deprecated_t_->errorSc_rollup_invalid_parameters_type|Sapling_state_t_->errorSc_rollup_invalid_parameters_type|Operation_t->errorSc_rollup_invalid_parameters_type|Chest_t->errorSc_rollup_invalid_parameters_type|Chest_key_t->errorSc_rollup_invalid_parameters_type|Lambda_t(_,_,_)->errorSc_rollup_invalid_parameters_typeandvalidate_two_tys:typeaacbbcret.(a,ac)Script_typed_ir.ty->(b,bc)Script_typed_ir.ty->retcontinuation->rettzresult=funty1ty2k->(validate_ty[@ocaml.tailcall])ty1(fun()->(validate_ty[@ocaml.tailcall])ty2k)letvalidate_parameters_tyctxtparameters_ty=letopenTzresult_syntaxin(* Parse the type and check that the entrypoints are well-formed. Using
[parse_parameter_ty_and_entrypoints] restricts to [passable] types
(everything but operations), which is OK since [validate_ty] constraints
the type further. *)let*Ex_parameter_ty_and_entrypoints{arg_type;entrypoints=_},ctxt=Script_ir_translator.parse_parameter_ty_and_entrypointsctxt~legacy:false(Micheline.rootparameters_ty)in(* Check that the type is valid for rollups. *)let*ctxt=Gas.consumectxt(Sc_rollup_costs.is_valid_parameters_ty_cost~ty_size:Script_typed_ir.(ty_sizearg_type|>Type_size.to_int))inlet+()=validate_tyarg_typeokinctxtletoriginatectxt~kind~boot_sector~parameters_ty=letopenLwt_tzresult_syntaxinlet*?ctxt=letopenTzresult_syntaxinlet*parameters_ty,ctxt=Script.force_decode_in_context~consume_deserialization_gas:When_neededctxtparameters_tyinvalidate_parameters_tyctxtparameters_tyinlet+address,size,ctxt=Sc_rollup.originatectxt~kind~boot_sector~parameters_tyin({address;size},ctxt)letexecute_outbox_message_ctx_rollup_last_cemented_commitment~outbox_level:_~message_index:_~inclusion_proof:_~message:_=(* TODO: 3106
Implement business logic.
Involves validate inclusion proofs, transferring tickets and outputting
operations etc.
*)failSc_rollup_invalid_atomic_batch