text stringlengths 12 786k |
|---|
let encoding = let open Data_encoding in def " tx_rollup_id " ~ title " : A tx rollup handle " ~ description : " A tx rollup notation as given to an RPC or inside scripts , is a base58 \ tx rollup hash " @@ splitted ~ binary : Hash . encoding ~ json : ( conv to_b58check ( fun s -> match ... |
let originated_tx_rollup nonce = let data = Data_encoding . Binary . to_bytes_exn Origination_nonce . encoding nonce in Hash . hash_bytes [ data ] |
let rpc_arg = let construct = to_b58check in let destruct hash = Result . map_error ( fun _ -> " Cannot parse tx rollup id " ) ( of_b58check hash ) in RPC_arg . make ~ descr " : A tx rollup identifier encoded in b58check . " ~ name " : tx_rollup_id " ~ construct ~ destruct ( ) |
module Index = struct type t = tx_rollup let path_length = 1 let to_path c l = let raw_key = Data_encoding . Binary . to_bytes_exn encoding c in let ( ` Hex key ) = Hex . of_bytes raw_key in key :: l let of_path = function | [ key ] -> Option . bind ( Hex . to_bytes ( ` Hex key ) ... |
let custom_root = ( RPC_path . ( open_root / " context " / " tx_rollup " ) : RPC_context . t RPC_path . context ) |
module S = struct let state = RPC_service . get_service ~ description " : Access the state of a rollup . " ~ query : RPC_query . empty ~ output : Tx_rollup_state . encoding RPC_path . ( custom_root /: Tx_rollup . rpc_arg / " state " ) let inbox = RPC_service . get_service ~ descrip... |
let register ( ) = let open Services_registration in opt_register1 ~ chunked : false S . state ( fun ctxt tx_rollup ( ) ( ) -> Tx_rollup_state . find ctxt tx_rollup >|=? snd ) ; opt_register1 ~ chunked : false S . inbox ( fun ctxt tx_rollup ( ) ( ) -> Tx_rollup_inbox . find c... |
let state ctxt block tx_rollup = RPC_context . make_call1 S . state ctxt block tx_rollup ( ) ( ) |
let inbox ctxt block tx_rollup = RPC_context . make_call1 S . inbox ctxt block tx_rollup ( ) ( ) |
type t = { fees_per_byte : Tez_repr . t ; inbox_ema : int ; last_inbox_level : Raw_level_repr . t option ; } |
let initial_state = { fees_per_byte = Tez_repr . zero ; inbox_ema = 0 ; last_inbox_level = None } |
let encoding : t Data_encoding . t = let open Data_encoding in conv ( fun { last_inbox_level ; fees_per_byte ; inbox_ema } -> ( last_inbox_level , fees_per_byte , inbox_ema ) ) ( fun ( last_inbox_level , fees_per_byte , inbox_ema ) -> { last_inbox_level ; fees_per_byte ; inbox_... |
let pp fmt { fees_per_byte ; last_inbox_level ; inbox_ema } = Format . fprintf fmt " Tx_rollup : fees_per_byte = % a ; inbox_ema % d ; last_inbox_level = % a " Tez_repr . pp fees_per_byte inbox_ema ( Format . pp_print_option Raw_level_repr . pp ) last_inbox_level |
let update_fees_per_byte : t -> final_size : int -> hard_limit : int -> t = fun ( { fees_per_byte ; inbox_ema ; _ } as state ) ~ final_size ~ hard_limit -> let threshold_increase = 90 in let threshold_decrease = 80 in let variation_factor = 5L in let inbox_ema_multiplier = 165 in let inbo... |
let fees { fees_per_byte ; _ } size = Tez_repr . ( fees_per_byte *? Int64 . of_int size ) |
let last_inbox_level { last_inbox_level ; _ } = last_inbox_level |
let append_inbox t level = { t with last_inbox_level = Some level } |
module Internal_for_tests = struct let make : fees_per_byte : Tez_repr . t -> inbox_ema : int -> last_inbox_level : Raw_level_repr . t option -> t = fun ~ fees_per_byte ~ inbox_ema ~ last_inbox_level -> { fees_per_byte ; inbox_ema ; last_inbox_level } let get_inbox_ema : t -> int = fun { i... |
type error += | Tx_rollup_already_exists of Tx_rollup_repr . t | Tx_rollup_does_not_exist of Tx_rollup_repr . t |
let init : Raw_context . t -> Tx_rollup_repr . t -> Raw_context . t tzresult Lwt . t = fun ctxt tx_rollup -> Storage . Tx_rollup . State . mem ctxt tx_rollup >>=? fun ( ctxt , already_exists ) -> fail_when already_exists ( Tx_rollup_already_exists tx_rollup ) >>=? fun ( ) -> Storage... |
let find : Raw_context . t -> Tx_rollup_repr . t -> ( Raw_context . t * Tx_rollup_state_repr . t option ) tzresult Lwt . t = Storage . Tx_rollup . State . find |
let get : Raw_context . t -> Tx_rollup_repr . t -> ( Raw_context . t * Tx_rollup_state_repr . t ) tzresult Lwt . t = fun ctxt tx_rollup -> find ctxt tx_rollup >>=? fun ( ctxt , state ) -> match state with | Some state -> return ( ctxt , state ) | None -> fail ( Tx_rollup_does_not... |
let assert_exist : Raw_context . t -> Tx_rollup_repr . t -> Raw_context . t tzresult Lwt . t = fun ctxt tx_rollup -> Storage . Tx_rollup . State . mem ctxt tx_rollup >>=? fun ( ctxt , tx_rollup_exists ) -> fail_unless tx_rollup_exists ( Tx_rollup_does_not_exist tx_rollup ) >>=? fun ( )... |
let update : Raw_context . t -> Tx_rollup_repr . t -> Tx_rollup_state_repr . t -> Raw_context . t tzresult Lwt . t = fun ctxt tx_rollup t -> Storage . Tx_rollup . State . update ctxt tx_rollup t >>=? fun ( ctxt , _ ) -> return ctxt |
let ( ) = let open Data_encoding in register_error_kind ` Permanent ~ id " : tx_rollup_already_exists " ~ title " : Transaction rollup was already created " ~ description : " The protocol tried to originate the same transaction rollup twice " ~ pp ( : fun ppf addr -> Format . fprintf ppf... |
let fresh_tx_rollup_from_current_nonce ctxt = Raw_context . increment_origination_nonce ctxt >|? fun ( ctxt , nonce ) -> ( ctxt , Tx_rollup_repr . originated_tx_rollup nonce ) |
let originate ctxt = fresh_tx_rollup_from_current_nonce ctxt >>?= fun ( ctxt , tx_rollup ) -> Tx_rollup_state_storage . init ctxt tx_rollup >|=? fun ctxt -> ( ctxt , tx_rollup ) |
let update_tx_rollups_at_block_finalization : Raw_context . t -> Raw_context . t tzresult Lwt . t = fun ctxt -> let level = ( Raw_context . current_level ctxt ) . level in Storage . Tx_rollup . fold ctxt level ~ init ( : ok ctxt ) ~ f ( : fun tx_rollup ctxt -> ctxt >>?= fun ctxt -> T... |
let script_parse_test sc scdec octx = ; ; |
let script_serialize_test sc scdec octx = ; ; |
let script_verify_is_spendable_test sc octx = ; ; |
let script_verify_spendable_by_test prefix sc adr octx = ; ; |
let tx_parse_test raw octx = ; ; |
let tx_parse_and_check_hash raw hash octx = ; ; |
let tx_parse_segwit_test raw dest sizes vsize hashes ? prefix ( : prefix ( = Params . of_network XTN ) . prefixes ) octx = ; ; |
let tlist = [ ( [ Script . OP_DUP ; Script . OP_HASH160 ; Script . OP_DATA ( 20 , Hex . to_string ( ` Hex " 89ABCDEFABBAABBAABBAABBAABBAABBAABBAABBA " ) ) ; Script . OP_EQUALVERIFY ; Script . OP_CHECKSIG ] , 25 ) ; ( [ Script . OP_DUP ; Script . OP_HASH160... |
type ' a ty = Ty of repr |
let obj ( Ty ty ) = ty |
let repr ty = Ty ( ty ) |
let print ( Ty ty ) = Format . asprintf " % a " %! Pprintast . core_type ty |
let domains = function | Ty { Parsetree . ptyp_desc = Parsetree . Ptyp_arrow ( _ , arg , ret ) ; _ } -> ( Ty arg , Ty ret ) | _ -> invalid_arg " Ty . domains " |
let curry ( Ty arg ) ( Ty ret ) = Ty { Parsetree . ptyp_desc = Parsetree . Ptyp_arrow ( Asttypes . Nolabel , arg , ret ) ; ptyp_loc = Location . none ; ptyp_loc_stack = [ ] ; ptyp_attributes = [ ] } |
let pair2 ( Ty t1 ) ( Ty t2 ) = Ty { Parsetree . ptyp_desc = Parsetree . Ptyp_tuple [ t1 ; t2 ] ; ptyp_loc = Location . none ; ptyp_loc_stack = [ ] ; ptyp_attributes = [ ] } |
let pair3 ( Ty t1 ) ( Ty t2 ) ( Ty t3 ) = Ty { Parsetree . ptyp_desc = Parsetree . Ptyp_tuple [ t1 ; t2 ; t3 ] ; ptyp_loc = Location . none ; ptyp_loc_stack = [ ] ; ptyp_attributes = [ ] } |
let pair4 ( Ty t1 ) ( Ty t2 ) ( Ty t3 ) ( Ty t4 ) = Ty { Parsetree . ptyp_desc = Parsetree . Ptyp_tuple [ t1 ; t2 ; t3 ; t4 ] ; ptyp_loc = Location . none ; ptyp_loc_stack = [ ] ; ptyp_attributes = [ ] } |
let lst ( Ty ty ) = Ty { Parsetree . ptyp_desc = Parsetree . Ptyp_constr ( { Asttypes . txt = Longident . Lident " list " ; loc = Location . none } , [ ty ] ) ; ptyp_loc = Location . none ; ptyp_loc_stack = [ ] ; ptyp_attributes = [ ] } |
module Impl = Snarky . Snark . Make ( Snarky . Backends . Mnt4 . Default ) |
type nonrec t = { a : bool ; b : field_var } |
type nonrec ' a u = { a1 : ' a ; b1 : bool } type nonrec ( ' a , ' b ) v_var = { a2 : ' a ; b2 : ' b } and ( ' a , ' b ) v = { a2 : ' a ; b2 : ' b } let v_typ x___3 x___2 = { Snarky . Types . Typ . store = ( fun { a2 ; b2 } -> Snarky . Typ_... |
let x __implicit3__ __implicit1__ x = let typ x___6 = v_typ x___6 x___6 in Snarky . exists ( typ __implicit3__ ) ~ compute : ( let open As_prover in fun ( ) -> { a2 = ( let typ x___4 = x___4 in As_prover . read ( typ __implicit1__ ) x ) ; b2 = ( let typ x___5 = x___5 in As_prove... |
let y ( ) = x Typ . boolean { Snarky . Types . Typ . store = ( fun x -> Snarky . Typ_monads . Store . return x ) ; Snarky . Types . Typ . read = ( fun x -> Snarky . Typ_monads . Read . return x ) ; Snarky . Types . Typ . alloc = ( let open Snarky . Typ_monads ... |
type id = string list [ @@ deriving show , eq , ord ] |
type vtype = | TUnbound of string * int option * Loc . t option | TId of id * Loc . t option | TComposed of id * t list * Loc . t option | TArrow of t * t * Loc . t option | TLink of t | TExpAlt of t list | TInt of int * Loc . t option |
let rec unlink t = match t with | { contents = TLink e } -> unlink e | { contents = TComposed ( id , elems , _ ) } -> { contents = TComposed ( id , List . map unlink elems , None ) } | { contents = TArrow ( t1 , t2 , _ ) } -> { contents = TArrow ( unlink t1 , ... |
let compare a b = compare ( unlink a ) ( unlink b ) |
let gensym_counter = ref 0 |
let gensym : unit -> string = fun ( ) -> let n = ! gensym_counter in let ( ) = incr gensym_counter in " ' " ^ string_of_int n |
let current_level_val = ref 1 |
let current_level ( ) = ! current_level_val |
let rec makeArrowType ( last : t ) ( types : t list ) : t = match types with | [ ] -> last | h :: t -> ref ( TArrow ( h , makeArrowType last t , None ) ) |
let rec stripArrow ( typ : t ) : t list * t = match typ with | { contents = TArrow ( t1 , t2 , _ ) } -> let args , last = stripArrow t2 in t1 :: args , last | _ -> [ ] , typ |
let newvar : unit -> t = fun ( ) -> ref ( TUnbound ( gensym ( ) , Some ( current_level ( ) ) , None ) ) |
let base ( t : t ) : id = match ! t with | TId ( id , _ ) -> id | TComposed ( id , _ , _ ) -> id | _ -> failwith " Typ . base : this type does not have a base type " |
let newinst ( t : t ) : t = let rec copy table t = try List . find ( fun ( key , _ ) -> key == t ) table |> snd , table with | Not_found -> match ! t with | TUnbound ( s , level , loc ) -> let o = ref ( TUnbound ( s , level , loc ) ) in o , ( t , o ) :: table... |
let rec fixType table t = try List . find ( fun key -> equal key t ) table , table with | _ -> match t with | { contents = TUnbound ( _ , _ , _ ) } -> t , t :: table | { contents = TComposed ( id , elems , loc ) } -> let elems ' , table ' = fixTypeList table elems... |
let fixOptType table ot = match ot with | None -> None , table | Some t -> let t ' , table ' = fixType table t in Some t ' , table ' |
let rec isUnbound ( t : t ) : bool = match t with | { contents = TUnbound ( _ , _ , _ ) } -> true | { contents = TId ( _ , _ ) } -> false | { contents = TInt ( _ , _ ) } -> false | { contents = TComposed ( _ , elems , _ ) } -> List . exists isUnb... |
let rec location ( t : t ) : Loc . t = match t with | { contents = TUnbound ( _ , _ , Some loc ) } -> loc | { contents = TId ( _ , Some loc ) } -> loc | { contents = TComposed ( _ , elems , Some loc ) } -> List . fold_left ( fun s a -> Loc . merge s ( loc... |
let getLevel = function | None -> current_level ( ) | Some n -> n |
let pickLoc ( loc1 : Loc . t option ) ( loc2 : Loc . t option ) : Loc . t option = match loc1 , loc2 with | None , _ -> loc2 | _ , None -> loc1 | Some l1 , _ when l1 = Loc . default -> loc2 | _ , Some l2 when l2 = Loc . default -> loc1 | _ -> loc1 |
let rec unify ( t1 : t ) ( t2 : t ) : bool = if t1 == t2 then true else match t1 , t2 with | { contents = TInt ( n1 , _ ) } , { contents = TInt ( n2 , _ ) } when n1 = n2 -> true | { contents = TUnbound ( n1 , level1 , loc1 ) } , { contents = TUnbound ( _ ... |
let rec join ( sep : string ) ( id : string list ) : string = match id with | [ ] -> " " | [ name ] -> name | h :: t -> h ^ sep ^ join sep t |
let rec getTupleName ( typ : t ) : string = match ! typ with | TId ( id , _ ) -> join " _ " id | TComposed ( id , elems , _ ) -> ( join " _ " id :: " _ " :: List . map getTupleName elems ) @ [ " _ " ] |> join " _ " | TLink e -> getTupleName e | TArro... |
let getTupleName ( typ : t ) : string = " _ " ^ getTupleName typ |
let arrayTypeAndSize typ = match ! typ with | TComposed ( [ " array " ] , [ t ; { contents = TInt ( n , _ ) } ] , _ ) -> t , n | _ -> failwith " arraySize : invalid input " |
let getSubTypes ( typ : t ) : t list = match ( ! unlink typ ) with | TComposed ( _ , elems , _ ) -> elems | _ -> [ ] |
let isArray ( typ : t ) : bool = match ( ! unlink typ ) with | TComposed ( [ " array " ] , _ , _ ) -> true | _ -> false |
let isTuple typ = match ! typ with | TComposed ( [ " tuple " ] , _ , _ ) -> true | _ -> false |
let isSimpleType ( typ : t ) : bool = match ! typ with | TId ( [ " real " ] , _ ) -> true | TId ( [ " fix16 " ] , _ ) -> true | TId ( [ " int " ] , _ ) -> true | TId ( [ " bool " ] , _ ) -> true | TId ( [ " unit " ] , _ ) -> tr... |
let isRealType ( typ : t ) : bool = match ! typ with | TId ( [ " real " ] , _ ) -> true | TId ( [ " fix16 " ] , _ ) -> true | _ -> false |
let isSimpleOpType ( typ : t option ) : bool = match typ with | Some t -> isSimpleType t | _ -> true |
let isTupleOpType ( typ : t option ) : bool = match typ with | Some t -> isTuple t | _ -> true |
let first ( t : t list ) : t = match t with | h :: _ -> h | _ -> failwith " Typ . first : invalid type " |
let makeListOpt t = match t with | Some t -> Some [ t ] | None -> None |
module Const = struct let ( |-> ) a b = ref ( TArrow ( a , b , None ) ) let empty = ref ( TId ( [ " " ] , None ) ) let type_type = ref ( TId ( [ " type " ] , None ) ) let unit_type = ref ( TId ( [ " unit " ] , None ) ) let bool_type = ref ( ... |
module Impl = Snarky . Snark . Make ( Snarky . Backends . Mnt4 . Default ) |
module Alias_alias = struct include struct type nonrec ( ' a , ' b ) u_var = ' a -> ' a and ( ' a , ' b ) u = ' a -> ' a let u_typ x___2 x___1 = Typ . fn x___2 x___2 end include struct type nonrec ( ' a , ' b ) v_var = ( ' a , ' a ) u_var and ( ' a , ' b ... |
module Alias_opaque = struct type nonrec ( ' a , ' b ) u type nonrec ( ' a , ' b ) v = ( ' a , ' a ) u let f ( x : ( int , int ) v ) : ( int , bool ) v = x let g ( x : ( int , bool ) v ) : ( int , int ) u = x let h ( x : ( bool , bool ) u ) ... |
module Alias_record = struct include struct type nonrec ( ' a , ' b ) u_var = { a : ' a ; b : ' b } and ( ' a , ' b ) u = { a : ' a ; b : ' b } let u_typ x___11 x___10 = { Snarky . Types . Typ . store = ( fun { a ; b } -> Snarky . Typ_monads . Store ... |
module Alias_variant = struct type nonrec ( ' a , ' b ) u = A | B | C of ' a | D of ' b type nonrec ( ' a , ' b ) v = ( ' a , ' a ) u let f ( x : ( int , int ) v ) : ( int , bool ) v = x let g ( x : ( int , bool ) v ) : ( int , int ) u = x le... |
module Kind = struct type t = | Var | Constr | Arrow | Tuple | Other let to_int = function | Var -> 0 | Constr -> 1 | Arrow -> 2 | Tuple -> 3 | Other -> 4 let of_int = function | 0 -> Var | 1 -> Constr | 2 -> Arrow | 3 -> Tuple | 4 -> Other | _ -> assert false let to_string = ... |
module Kind ' = struct type t = | Var | Constr of LongIdent . t | Arrow | Tuple | Other let to_int = function | Var -> 0 | Constr _ -> 1 | Arrow -> 2 | Tuple -> 3 | Other -> 4 let compare t1 t2 = match t1 , t2 with | Var , Var | Arrow , Arrow | Tuple , Tuple | Other , Other -... |
module rec Base : sig type t = | Var of Variable . t | FrozenVar of Variable . t | Constr of LongIdent . t * t Array . t | Arrow of NSet . t * t | Tuple of NSet . t | Other of Int . t val kind : t -> Kind . t val kind ' : t -> Kind ' . t val compare : t CCOrd . t val equal : t -... |
module HMap = CCHashtbl . Make ( Base ) |
module Map = CCMap . Make ( Base ) |
module Set = CCSet . Make ( Base ) |
module MSet = CCMultiSet . Make ( Base ) |
module Hashcons = struct type elt = t type t = elt HMap . t let make ( ) = HMap . create 17 let hashcons t ty = match HMap . find_opt t ty with | Some ty -> ty | None -> HMap . add t ty ty ; ty end |
module Env = struct type t = { var_gen : Variable . Gen . t ; hcons : Hashcons . t ; } let make ( ? hcons = Hashcons . make ( ) ) namespace = { var_gen = Variable . Gen . make namespace ; hcons ; } end |
let hashcons env ty = Hashcons . hashcons env . Env . hcons ty |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.