text stringlengths 0 601k |
|---|
type ' accu stack_ty_traverse = { apply : ' ty ' s . ' accu -> ( ' ty , ' s ) stack_ty -> ' accu ; } |
let stack_ty_traverse ( type a t ) ( sty : ( a , t ) stack_ty ) init f = let rec aux : type b u . ' accu -> ( b , u ) stack_ty -> ' accu = fun accu sty -> match sty with | Bot_t -> f . apply accu sty | Item_t ( _ , sty ' ) -> aux ( f . apply accu sty ) sty ' in aux init sty |
type ' a value_traverse = { apply : ' t . ' a -> ' t ty -> ' t -> ' a ; apply_comparable : ' t . ' a -> ' t comparable_ty -> ' t -> ' a ; } |
let value_traverse ( type t ) ( ty : ( t ty , t comparable_ty ) union ) ( x : t ) init f = let rec aux : type ret t . ' accu -> t ty -> t -> ( ' accu -> ret ) -> ret = fun accu ty x continue -> let accu = f . apply accu ty x in let next2 ty1 ty2 x1 x2 = ( aux [ @ ocaml . tailcall ] ) accu ty1 x1 @@ fun accu -> ( aux [ ... |
let stack_top_ty : type a b s . ( a , b * s ) stack_ty -> a ty = function | Item_t ( ty , _ ) -> ty |
let script_string_size s = Script_string . to_string s |> string_size |
let ty_traverse_f = let base_basic = !! 0 in let base_compound_no_meta = header_size in let base_compound _meta = h1w in let apply_comparable : type a . nodes_and_size -> a comparable_ty -> nodes_and_size = fun accu cty -> match cty with | Unit_key -> ret_succ_adding accu base_basic | Int_key -> ret_succ_adding accu ba... |
let comparable_ty_size : type a . a comparable_ty -> nodes_and_size = fun cty -> comparable_ty_traverse cty zero ty_traverse_f |
let ty_size : type a . a ty -> nodes_and_size = fun ty -> ty_traverse ty zero ty_traverse_f |
let stack_ty_size s = let apply : type a s . nodes_and_size -> ( a , s ) stack_ty -> nodes_and_size = fun accu s -> match s with | Bot_t -> ret_succ accu | Item_t ( ty , _ ) -> ret_succ_adding ( accu ++ ty_size ty ) h2w in stack_ty_traverse s zero { apply } |
let script_nat_size n = Script_int . to_zint n |> z_size |
let script_int_size n = Script_int . to_zint n |> z_size |
let signature_size = h3w +? Signature . size |
let key_hash_size ( x : Signature . public_key_hash ) = h1w +? Signature . ( match x with | Ed25519 _ -> Ed25519 . Public_key_hash . size | Secp256k1 _ -> Secp256k1 . Public_key_hash . size | P256 _ -> P256 . Public_key_hash . size ) |
let public_key_size ( x : public_key ) = let ks = Signature . Public_key . size x in h1w +? ks |
let timestamp_size x = Script_timestamp . to_zint x |> z_size |
let address_size addr = h2w +! destination_size addr . destination +! Entrypoint . in_memory_size addr . entrypoint |
let view_signature_size ( View_signature { name ; input_ty ; output_ty } ) = ret_adding ( ty_size input_ty ++ ty_size output_ty ) ( h3w +! script_string_size name ) |
let peano_shape_proof = let scale = header_size +! h1w in fun k -> scale *? k |
let stack_prefix_preservation_witness_size = let kinfo_size = h2w in let scale = header_size +! ( h2w +! kinfo_size ) in fun k -> scale *? k |
let contract_size { arg_ty ; address } = ret_adding ( ty_size arg_ty ) ( h2w +! address_size address ) |
let sapling_state_size { Sapling . id ; diff ; memo_size = _ } = h3w +! option_size ( fun x -> z_size ( Sapling . Id . unparse_to_z x ) ) id +! Sapling . diff_in_memory_size diff +! sapling_memo_size_size |
let operation_size { piop ; lazy_storage_diff } = ret_adding ( Operation . packed_internal_operation_in_memory_size piop ++ option_size_vec Lazy_storage . diffs_in_memory_size lazy_storage_diff ) h2w |
let chain_id_size = h1w +? Chain_id . size |
let ticket_size { ticketer ; contents = _ ; amount } = h3w +! Contract . in_memory_size ticketer +! script_nat_size amount |
let chest_size chest = let locked_value_size = 256 in let rsa_public_size = 256 in let ciphertext_size = Script_timelock . get_plaintext_size chest in h3w +? ( locked_value_size + rsa_public_size + ciphertext_size ) |
let chest_key_size _ = let unlocked_value_size = 256 in let proof_size = 256 in h2w +? ( unlocked_value_size + proof_size ) |
let view_size { input_ty ; output_ty ; view_code } = ret_adding ( node_size input_ty ++ node_size output_ty ++ node_size view_code ) h3w |
let views_size views = SMap . fold ( fun k view accu -> ret_adding ( accu ++ view_size view ) ( script_string_size k +! h4w ) ) views zero |
let rec entrypoints_size : type arg . arg entrypoints -> nodes_and_size = fun { name ; nested } -> let name_size = option_size Entrypoint . in_memory_size name in let nested_size = match nested with | Entrypoints_None -> zero | Entrypoints_Union { left ; right } -> ret_adding ( entrypoints_size left ++ entrypoints_size... |
let kinfo_size { iloc = _ ; kstack_ty = _ } = h2w |
let rec value_size : type a . count_lambda_nodes : bool -> nodes_and_size -> ( a ty , a comparable_ty ) union -> a -> nodes_and_size = fun ~ count_lambda_nodes accu ty x -> let apply : type a . nodes_and_size -> a ty -> a -> nodes_and_size = fun accu ty x -> match ty with | Unit_t -> ret_succ accu | Int_t -> ret_succ_a... |
let rec kinstr_extra_size : type a s r f . ( a , s , r , f ) kinstr -> nodes_and_size = fun t -> let ret_zero x = ( Nodes . zero , x ) in let apply : type a s r f . nodes_and_size -> ( a , s , r , f ) kinstr -> nodes_and_size = fun accu t -> let stack_prefix_preservation_witness_size n = ret_zero ( !! 24 *? n ) in let ... |
let lambda_size lam = let ( lambda_nodes , lambda_size ) = lambda_size ~ count_lambda_nodes : true zero lam in let ( lambda_extra_size_nodes , lambda_extra_size ) = lambda_extra_size lam in let size = ( lambda_size *? 157 /? 100 ) +! ( lambda_extra_size *? 18 /? 100 ) in ( Nodes . add lambda_nodes lambda_extra_size_nod... |
let kinstr_size kinstr = let ( kinstr_extra_size_nodes , kinstr_extra_size ) = kinstr_extra_size kinstr in let ( kinstr_nodes , kinstr_size ) = kinstr_size ~ count_lambda_nodes : true zero kinstr in let size = ( kinstr_size *? 157 /? 100 ) +! ( kinstr_extra_size *? 18 /? 100 ) in ( Nodes . add kinstr_nodes kinstr_extra... |
let value_size ty x = value_size ~ count_lambda_nodes : true zero ( L ty ) x |
module Internal_for_tests = struct let ty_size = ty_size let comparable_ty_size = comparable_ty_size let kinstr_size = kinstr_size end |
module Size_benchmarks_shared_config = struct include Translator_benchmarks . Config type workload = { size : int } let workload_encoding : workload Data_encoding . t = let open Data_encoding in def " size_encoding " @@ conv ( fun { size } -> size ) ( fun size -> { size } ) ( obj1 ( req " size " int31 ) ) let workload_... |
module Value_size_benchmark : sig include Tezos_benchmark . Benchmark . S val size_based_model : string -> workload Model . t include Size_benchmarks_shared_config let name = " VALUE_SIZE " let models = [ ( model_name , size_based_model name ) ] let info = " Benchmarking Script_typed_ir_size . value_size " let value_si... |
let ( ) = Registration_helpers . register ( module Value_size_benchmark ) |
module Type_size_benchmark : Tezos_benchmark . Benchmark . S = struct include Size_benchmarks_shared_config type config = unit let config_encoding = Data_encoding . unit let default_config = ( ) let name = " TYPE_SIZE " let info = " Benchmarking the time it takes to compute Script_typed_ir_size . ty_size " let models =... |
let ( ) = Registration_helpers . register ( module Type_size_benchmark ) |
module Comparable_type_size_benchmark : Tezos_benchmark . Benchmark . S = struct include Size_benchmarks_shared_config let name = " COMPARABLE_TYPE_SIZE " let info = " Benchmarking the time it takes to compute \ Script_typed_ir_size . comparable_ty_size " let models = [ ( model_name , size_based_model name ) ] let type... |
let ( ) = Registration_helpers . register ( module Comparable_type_size_benchmark ) |
module Kinstr_size_benchmark : sig include Tezos_benchmark . Benchmark . S val size_based_model : string -> workload Model . t include Size_benchmarks_shared_config let name = " KINSTR_SIZE " let models = [ ( model_name , size_based_model name ) ] let info = " Benchmarking Script_typed_ir_size . kinstr_size " let kinst... |
let ( ) = Registration_helpers . register ( module Kinstr_size_benchmark ) |
module Node_size_benchmark : Benchmark . S = struct include Script_repr_benchmarks . Script_repr_shared_config let name = " NODE_SIZE " let info = " Benchmarking the time it takes to compute Script_typed_ir_size . node_size " let size_based_model = Model . make ~ conv ( : function { micheline_nodes } -> ( micheline_nod... |
let ( ) = Registration_helpers . register ( module Node_size_benchmark ) |
let with_pipe f = let fd_r , fd_w = Unix . pipe ( ) in try let res = f ( fd_r , fd_w ) in Unix . close fd_r ; Unix . close fd_w ; res with exn -> Unix . close fd_r ; Unix . close fd_w ; raise exn |
let with_in_channel filename f = let ic = open_in_bin filename in try let res = f ic in close_in ic ; res with exn -> close_in ic ; raise exn |
let with_out_channel filename f = let oc = open_out_bin filename in try let res = f oc in close_out oc ; res with exn -> close_out oc ; raise exn |
let read_process name args ( in_r , _in_w ) ( out_r , out_w ) ( err_r , err_w ) = let pid = try Unix . create_process name args in_r out_w err_w with Unix . Unix_error ( Unix . ENOENT , _ , _ ) -> raise ( Failure ( name ^ " : command not found " ) ) in match Unix . waitpid [ ] pid with | _ , Unix . WEXITED 0 -> input_l... |
let read_process_output name args = with_pipe @@ fun in_pipe -> with_pipe @@ fun out_pipe -> read_process name args in_pipe out_pipe out_pipe |
let read_process_stdout name args = with_pipe @@ fun in_pipe -> with_pipe @@ fun out_pipe -> with_pipe @@ fun err_pipe -> read_process name args in_pipe out_pipe err_pipe |
let string_of_file filename = with_in_channel filename @@ fun ic -> let s = Bytes . create 32759 in let b = Buffer . create 1000 in let rec iter ic b s = let nread = input ic s 0 32759 in if nread > 0 then begin Buffer . add_subbytes b s 0 nread ; iter ic b s end in iter ic b s ; Buffer . contents b |
module Sigver = struct end |
module SStack = struct type t = int Stack . t ; ; let create ( ) = Stack . create ( ) ; ; let pop st = Stack . pop st ; ; let top st = Stack . top st ; ; let rec push_data d st = match String . length d with | 0 -> ( ) | n -> Stack . push ( Char . code ( String . get d 0 ) ) st ; push_data ( String . sub d 1 ( n - 1 ) ... |
let rec _eval sigver st altst scr = let rec to_endif_or_else st altst scr = match scr with | [ ] -> false | op :: scr ' -> match op with | OP_ENDIF -> _eval sigver st altst scr ' | OP_ELSE -> _eval sigver st altst scr ' | _ -> to_endif_or_else st altst scr ' in let rec to_endif st altst scr = match scr with | [ ] -> fa... |
let eval sigver scr = let st = SStack . create ( ) in let altst = SStack . create ( ) in try _eval sigver st altst ( fst scr ) with _ -> false ; ; |
let verify sigver s1 s2 = Script . join s1 s2 |> eval sigver ; ; |
let is_spendable scr = not ( Script_nulldata . Output . check scr ) ; ; |
let spendable_by src prefix = let ml = [ ( module Script_pubkeyhash . Output : Script_template . Output ) ; ( module Script_pubkey . Output : Script_template . Output ) ; ( module Script_scripthash . Output : Script_template . Output ) ; ( module Script_multisig . Output : Script_template . Output ) ; ( module Script_w... |
let classify_output src = let ml = [ ( module Script_pubkeyhash . Output : Script_template . Output ) ; ( module Script_pubkey . Output : Script_template . Output ) ; ( module Script_scripthash . Output : Script_template . Output ) ; ( module Script_multisig . Output : Script_template . Output ) ; ( module Script_witne... |
inherit t " nums " initializer scroll # set_range 197 method ! can_focus = false method ! draw ctx _focused = let { rows ; _ } = LTerm_draw . size ctx in for row = 0 to rows - 1 do LTerm_draw . draw_string ctx row 0 ( Zed_string . of_utf8 ( string_of_int ( row + scroll # offset ) ) ) done end |
let main ( ) = let waiter , wakener = wait ( ) in let exit = new button " exit " in exit # on_click ( wakeup wakener ) ; let adj = new scrollable in let scroll = new vscrollbar adj in let nums = new scrollable_nums adj in let hbox = new hbox in hbox # add ~ expand : true nums ; hbox # add ~ expand : false scroll ; let ... |
let ( ) = Lwt_main . run ( main ( ) ) |
inherit label " scroll " method ! can_focus = false method ! size_request = { rows = 1 ; cols = 0 } val style = LTerm_style . { none with foreground = Some red ; background = Some green } ; method ! draw ctx _focused = LTerm_draw . fill_style ctx style ; LTerm_draw . draw_string_aligned ctx 0 H_align_center ~ style ( Z... |
let main ( ) = let waiter , wakener = wait ( ) in let exit = new button " exit " in exit # on_click ( wakeup wakener ) ; let vbox = new vbox in let add_scroll ( vbox : vbox ) ~ range ~ size = let adj = new scrollable in let hscroll = new hscrollbar adj in let label = new scroll_label adj in adj # set_range range ; adj ... |
let ( ) = Lwt_main . run ( main ( ) ) |
let test ~ __FILE__ ? output_file ( ? tags = [ ] ) title f = let tags = " sc_rollup " :: tags in match output_file with | Some output_file -> Protocol . register_regression_test ~ output_file ~ __FILE__ ~ title ~ tags f | None -> Protocol . register_test ~ __FILE__ ~ title ~ tags f |
let setup f ~ protocol = let sc_rollup_enable = [ ( [ " sc_rollup_enable " ] , Some " true " ) ] in let base = Either . right ( protocol , None ) in let * parameter_file = Protocol . write_parameter_file ~ base sc_rollup_enable in let * ( node , client ) = Client . init_with_protocol ~ parameter_file ` Client ~ protoco... |
let sc_rollup_node_rpc sc_node service = let * curl = RPC . Curl . get ( ) in match curl with | None -> return None | Some curl -> let url = Printf . sprintf " % s /% s " ( Sc_rollup_node . endpoint sc_node ) service in let * response = curl ~ url in return ( Some response ) |
let test_origination = let output_file = " sc_rollup_origination " in test ~ __FILE__ ~ output_file " origination of a SCORU executes without error " ( fun protocol -> setup ~ protocol @@ fun _node client bootstrap1_key -> let * rollup_address = Client . originate_sc_rollup ~ burn_cap : Tez . ( of_int 9999999 ) ~ src :... |
let with_fresh_rollup f tezos_node tezos_client bootstrap1_key = let * rollup_address = Client . originate_sc_rollup ~ burn_cap : Tez . ( of_int 9999999 ) ~ src : bootstrap1_key ~ kind " : arith " ~ boot_sector " " : tezos_client in let sc_rollup_node = Sc_rollup_node . create tezos_node in let * configuration_filename... |
let test_rollup_node_configuration = let output_file = " sc_rollup_node_configuration " in test ~ __FILE__ ~ output_file " configuration of a smart contract optimistic rollup node " ( fun protocol -> setup ~ protocol @@ with_fresh_rollup @@ fun _rollup_address _sc_rollup_node filename -> let read_configuration = let op... |
let test_rollup_node_running = test ~ __FILE__ ~ tags [ " : run " ] " running a smart contract rollup node " ( fun protocol -> setup ~ protocol @@ with_fresh_rollup @@ fun rollup_address sc_rollup_node _filename -> let * ( ) = Sc_rollup_node . run sc_rollup_node in let * rollup_address_from_rpc = sc_rollup_node_rpc sc_... |
let test_rollup_client_gets_address = let output_file = " sc_rollup_client_gets_address " in test ~ __FILE__ ~ output_file ~ tags [ " : run " ; " client " ] " getting a smart - contract rollup address through the client " ( fun protocol -> setup ~ protocol @@ with_fresh_rollup @@ fun rollup_address sc_rollup_node _file... |
let test_rollup_inbox = let output_file = " sc_rollup_inbox " in test ~ __FILE__ ~ output_file ~ tags [ " : inbox " ] " pushing messages in the inbox " ( fun protocol -> setup ~ protocol @@ fun node client -> ( with_fresh_rollup @@ fun sc_rollup_address _sc_rollup_node _filename -> let send msg = let * ( ) = Client . s... |
let register ~ protocols = test_origination ~ protocols ; test_rollup_node_configuration ~ protocols ; test_rollup_node_running ~ protocols ; test_rollup_client_gets_address ~ protocols ; test_rollup_inbox ~ protocols |
module PVM = struct type boot_sector = Alpha_context . Sc_rollup . PVM . boot_sector module type S = sig val name : string val parse_boot_sector : string -> boot_sector option val pp_boot_sector : Format . formatter -> boot_sector -> unit end type t = ( module S ) end |
let kind_of_string = function " arith " -> Some Kind . Example_arith | _ -> None |
let example_arith_pvm = ( module Sc_rollup_arith : PVM . S ) |
let of_kind = function Kind . Example_arith -> example_arith_pvm |
let kind_of ( module M : PVM . S ) = match kind_of_string M . name with | Some k -> k | None -> failwith ( Format . sprintf " The module named % s is not in Sc_rollups . all . " M . name ) |
let from ~ name = Option . map of_kind ( kind_of_string name ) |
let all_names = List . map ( fun k -> let ( module M : PVM . S ) = of_kind k in M . name ) all |
let string_of_kind k = let ( module M ) = of_kind k in M . name |
let pp fmt k = Format . fprintf fmt " % s " ( string_of_kind k ) |
type t = { name : string ; path : string ; sc_node : Sc_rollup_node . t ; base_dir : string ; color : Log . Color . t ; } |
let next_name = ref 1 |
let fresh_name ( ) = let index = ! next_name in incr next_name ; " client " ^ string_of_int index |
let ( ) = Test . declare_reset_function @@ fun ( ) -> next_name := 1 |
let create ? name ? path ? base_dir ( ? color = Log . Color . FG . green ) sc_node = let name = match name with None -> fresh_name ( ) | Some name -> name in let path = match path with None -> Constant . sc_rollup_client | Some p -> p in let base_dir = match base_dir with None -> Temp . dir name | Some dir -> dir in { ... |
let base_dir_arg sc_client = [ " -- base - dir " ; sc_client . base_dir ] |
let endpoint_arg sc_client = [ " -- endpoint " ; Sc_rollup_node . endpoint sc_client . sc_node ] |
let spawn_command ? hooks sc_client command = Process . spawn ~ name : sc_client . name ~ color : sc_client . color ? hooks sc_client . path ( base_dir_arg sc_client @ endpoint_arg sc_client @ command ) |
let sc_rollup_address sc_client = let * out = spawn_command sc_client [ " get " ; " sc " ; " rollup " ; " address " ] |> Process . check_and_read_stdout in return ( String . trim out ) |
module Inbox_hash = struct let prefix = " scib1 " let encoded_size = 55 module H = Blake2B . Make ( Base58 ) ( struct let name = " inbox_hash " let title = " The hash of a the inbox of a smart contract rollup " let b58check_prefix = inbox_hash let size = None end ) include H let ( ) = Base58 . check_encoded_prefix b58c... |
type t = { hash : hash ; inbox_size : int64 } |
let pp fmtr { hash ; inbox_size } = Format . fprintf fmtr " [ @< v 2 { > hash = % a ; , @ inbox_size = % Ld } ] " @ pp_hash hash inbox_size |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.