text stringlengths 0 601k |
|---|
let test_timed_account ( ) = let num_of_fee_payers = 5 in let trials = 1 in Test_util . with_randomness 123456789 ( fun ( ) -> let test i = let ledger , fee_payer_keypairs , keymap = mk_ledgers_and_fee_payers ~ is_timed : true ~ num_of_fee_payers ( ) in Quickcheck . test ~ trials : 1 ( Mina_generators . Parties_generat... |
let ( ) = let num_of_fee_payers = 5 in let trials = 2 in generate_parties_and_apply_them_consecutively ( ) ; generate_parties_and_apply_them_freshly ( ) ; let open Mina_generators . Parties_generators in let open Transaction_status . Failure in mk_invalid_test ~ num_of_fee_payers ~ trials ~ type_of_failure : Invalid_pr... |
module Spec = Transaction_snark . For_tests . Spec ( module struct let memo = Signed_command_memo . create_from_string_exn " Zkapp payments tests " let constraint_constants = U . constraint_constants let merkle_root_after_parties_exn t ~ txn_state_view txn = let hash = Ledger . merkle_root_after_parties_exn ~ constrain... |
module Closed_interval = struct [ %% versioned module Stable = struct module V1 = struct type ' a t = { lower : ' a ; upper : ' a } [ @@ deriving annot , sexp , equal , compare , hash , yojson , hlist , fields ] fields end end ] end let gen gen_a compare_a = let open Quickcheck . Let_syntax in let % bind a1 = gen_a in ... |
let assert_ b e = if b then Ok ( ) else Or_error . error_string e |
module Numeric = struct module Tc = struct type ( ' var , ' a ) ' a t = { zero : ' a ; max_value : ' a ; compare : ' a -> ' a -> int ; equal : ' a -> ' a -> bool ; typ : ( ' var , ' a ) ' a Typ . t ; to_input : ' a -> F . t Random_oracle_input . Chunked . t ; to_input_checked : ' var -> Field . Var . t Random_oracle_in... |
module Eq_data = struct include Or_ignore module Tc = struct type ( ' var , ' a ) ' a t = { equal : ' a -> ' a -> bool ; equal_checked : ' var -> ' var -> Boolean . var ; default : ' a ; typ : ( ' var , ' a ) ' a Typ . t ; to_input : ' a -> F . t Random_oracle_input . Chunked . t ; to_input_checked : ' var -> Field . V... |
module Hash = struct include Eq_data let to_input tc = to_input ~ explicit : true tc let typ = typ_explicit end |
module Leaf_typs = struct let public_key ( ) = Public_key . Compressed ( . Or_ignore . typ_explicit ~ ignore : invalid_public_key typ ) typ open Eq_data . Tc let field = Eq_data . typ_explicit field let receipt_chain_hash = Hash . typ receipt_chain_hash let ledger_hash = Hash . typ ledger_hash let frozen_ledger_hash = ... |
module Account = struct module Poly = struct [ %% versioned module Stable = struct module V1 = struct type ( ' balance , ' nonce , ' receipt_chain_hash , ' pk , ' field ) ' field t = { balance : ' balance ; nonce : ' nonce ; receipt_chain_hash : ' receipt_chain_hash ; public_key : ' pk ; delegate : ' pk ; state : ' fie... |
module Protocol_state = struct module Epoch_data = struct module Poly = Epoch_data . Poly [ %% versioned module Stable = struct module V1 = struct type t = ( ( Frozen_ledger_hash . Stable . V1 . t Hash . Stable . V1 . t , Currency . Amount . Stable . V1 . t Numeric . Stable . V1 . t ) Epoch_ledger . Poly . Stable . V1 ... |
module Account_type = struct [ %% versioned module Stable = struct module V1 = struct type t = User | Zkapp | None | Any [ @@ deriving sexp , equal , yojson , hash , compare ] compare let to_latest = Fn . id end end ] end let check ( t : t ) t ( a : A . t option ) option = match ( a , t ) t with | _ , Any -> Ok ( ) | N... |
module Other = struct module Poly = struct [ %% versioned module Stable = struct module V1 = struct type ( ' account , ' account_transition , ' vk ) ' vk t = { predicate : ' account ; account_transition : ' account_transition ; account_vk : ' vk } [ @@ deriving hlist , sexp , equal , yojson , hash , compare ] compare e... |
module Poly = struct [ %% versioned module Stable = struct module V1 = struct type ( ' account , ' protocol_state , ' other , ' pk ) ' pk t = { self_predicate : ' account ; other : ' other ; fee_payer : ' pk ; protocol_state_predicate : ' protocol_state } [ @@ deriving hlist , sexp , equal , yojson , hash , compare ] c... |
module Stable = struct module V2 = struct type t = ( Account . Stable . V2 . t , Protocol_state . Stable . V1 . t , Other . Stable . V2 . t , Public_key . Compressed . Stable . V1 . t Eq_data . Stable . V1 . t ) Poly . Stable . V1 . t [ @@ deriving sexp , equal , yojson , hash , compare ] compare let to_latest = Fn . i... |
let to_input ( { self_predicate ; other ; fee_payer ; protocol_state_predicate } : t ) t = let open Random_oracle_input . Chunked in List . reduce_exn ~ f : append [ Account . to_input self_predicate ; Other . to_input other ; Eq_data ( . to_input_explicit ( Tc . public_key ( ) ) ) fee_payer ; Protocol_state . to_input... |
let digest t = Random_oracle ( . hash ~ init : Hash_prefix . zkapp_precondition ( pack_input ( to_input t ) t ) t ) t |
let accept : t = { self_predicate = Account . accept ; other = Other . accept ; fee_payer = Ignore ; protocol_state_predicate = Protocol_state . accept } |
module Checked = struct type t = ( Account . Checked . t , Protocol_state . Checked . t , Other . Checked . t , Public_key . Compressed . var Or_ignore . Checked . t ) Poly . Stable . Latest . t let to_input ( { self_predicate ; other ; fee_payer ; protocol_state_predicate } : t ) t = let open Random_oracle_input . Chu... |
let typ ( ) : ( Checked . t , Stable . Latest . t ) t Typ . t = Poly . typ [ Account . typ ( ) ; Other . typ ( ) ; Eq_data ( . typ_explicit ( Tc . public_key ( ) ) ) ; Protocol_state . typ ] |
module V = struct [ %% versioned module Stable = struct [ @@@ no_toplevel_latest_type ] no_toplevel_latest_type module V1 = struct type ' a t = ' a Vector . Vector_8 . Stable . V1 . t [ @@ deriving compare , yojson , sexp , hash , equal ] equal end end ] end type ' a t = ' a Vector . Vector_8 . t [ @@ deriving compare ... |
let ( ) = let _f : type a . unit -> ( a V . t , a Vector . With_length ( With_lengthMax_state_size ) With_lengthMax_state_size . t ) t Type_equal . t = fun ( ) -> Type_equal . T in ( ) |
let typ t = Vector . typ t Max_state_size . n |
module Value = struct [ %% versioned module Stable = struct [ @@@ no_toplevel_latest_type ] no_toplevel_latest_type module V1 = struct type t = Zkapp_basic . F . Stable . V1 . t V . Stable . V1 . t [ @@ deriving sexp , equal , yojson , hash , compare ] compare let to_latest = Fn . id end end ] end type t = Zkapp_basic ... |
let to_input ( t : _ V . t ) t ~ f = Vector ( . reduce_exn ( map t ~ f ) f ~ f : Random_oracle_input . Chunked . append ) append |
let deriver inner obj = let open Fields_derivers_zkapps . Derivers in iso ~ map : V . of_list_exn ~ contramap : V . to_list ( ( list @@ inner @@ o ( ) ) ( o ( ) ) ) obj |
module Poly = struct [ %% versioned module Stable = struct module V1 = struct type ' comm t = { transaction : ' comm ; at_party : ' comm } [ @@ deriving hlist , sexp , yojson ] yojson end end ] end let to_field_elements ( t : ' c t ) t : ' c array = let [ x0 ; x1 ] = to_hlist t in [ | x0 ; x1 ] | end [ %% versioned |
module Stable = struct module V2 = struct type t = Parties . Transaction_commitment . Stable . V1 . t Poly . Stable . V1 . t [ @@ deriving sexp , yojson ] yojson let to_latest = Fn . id end end ] end |
let to_field_elements : t -> _ = Poly . to_field_elements |
module Checked = struct type t = Parties . Transaction_commitment . Checked . t Poly . t let to_field_elements : t -> _ = Poly . to_field_elements open Pickles . Impls . Step module Assert = struct let equal ( t1 : t ) t ( t2 : t ) t = Array . iter2_exn ~ f : Field . Assert . equal ( to_field_elements t1 ) t1 ( to_fiel... |
let typ = let open Poly in Typ . of_hlistable Parties . Transaction_commitment [ . typ ; typ ] ~ var_to_hlist : to_hlist ~ var_of_hlist : of_hlist ~ value_to_hlist : to_hlist ~ value_of_hlist : of_hlist [ %% endif ] endif |
module Flags = struct open Command let default_fee = Currency . Fee . of_formatted_string " 1 " let min_fee = Currency . Fee . of_formatted_string " 0 . 003 " let memo = Param . flag " -- memo " ~ doc " : STRING Memo accompanying the transaction " Param ( . optional string ) string let fee = Param . flag " -- fee " ~ d... |
let create_zkapp_account = let create_command ~ debug ~ keyfile ~ fee ~ zkapp_keyfile ~ amount ~ nonce ~ memo ( ) = let open Deferred . Let_syntax in let % map parties = create_zkapp_account ~ debug ~ keyfile ~ fee ~ zkapp_keyfile ~ amount ~ nonce ~ memo in Util . print_snapp_transaction parties ; ( ) in Command ( . le... |
let upgrade_zkapp = let create_command ~ debug ~ keyfile ~ fee ~ nonce ~ memo ~ zkapp_keyfile ~ verification_key ~ zkapp_uri ~ auth ( ) = let open Deferred . Let_syntax in let % map parties = upgrade_zkapp ~ debug ~ keyfile ~ fee ~ nonce ~ memo ~ zkapp_keyfile ~ verification_key ~ zkapp_uri ~ auth in Util . print_snapp... |
let transfer_funds = let create_command ~ debug ~ keyfile ~ fee ~ nonce ~ memo ~ receivers ( ) = let open Deferred . Let_syntax in let % map parties = transfer_funds ~ debug ~ keyfile ~ fee ~ nonce ~ memo ~ receivers in Util . print_snapp_transaction parties ; ( ) in let read_key_and_amount count = let read ( ) = let o... |
let update_state = let create_command ~ debug ~ keyfile ~ fee ~ nonce ~ memo ~ zkapp_keyfile ~ app_state ( ) = let open Deferred . Let_syntax in let % map parties = update_state ~ debug ~ keyfile ~ fee ~ nonce ~ memo ~ zkapp_keyfile ~ app_state in Util . print_snapp_transaction parties ; ( ) in Command ( . let open Let... |
let update_zkapp_uri = let create_command ~ debug ~ keyfile ~ fee ~ nonce ~ memo ~ snapp_keyfile ~ zkapp_uri ~ auth ( ) = let open Deferred . Let_syntax in let % map parties = update_zkapp_uri ~ debug ~ keyfile ~ fee ~ nonce ~ memo ~ snapp_keyfile ~ zkapp_uri ~ auth in Util . print_snapp_transaction parties ; ( ) in Co... |
let update_sequence_state = let create_command ~ debug ~ keyfile ~ fee ~ nonce ~ memo ~ zkapp_keyfile ~ sequence_state ( ) = let open Deferred . Let_syntax in let % map parties = update_sequence_state ~ debug ~ keyfile ~ fee ~ nonce ~ memo ~ zkapp_keyfile ~ sequence_state in Util . print_snapp_transaction parties ; ( )... |
let update_token_symbol = let create_command ~ debug ~ keyfile ~ fee ~ nonce ~ memo ~ snapp_keyfile ~ token_symbol ~ auth ( ) = let open Deferred . Let_syntax in let % map parties = update_token_symbol ~ debug ~ keyfile ~ fee ~ nonce ~ memo ~ snapp_keyfile ~ token_symbol ~ auth in Util . print_snapp_transaction parties... |
let update_permissions = let create_command ~ debug ~ keyfile ~ fee ~ nonce ~ memo ~ zkapp_keyfile ~ permissions ~ current_auth ( ) = let open Deferred . Let_syntax in let % map parties = update_permissions ~ debug ~ keyfile ~ fee ~ nonce ~ memo ~ zkapp_keyfile ~ permissions ~ current_auth in Util . print_snapp_transac... |
let test_zkapp_with_genesis_ledger = Command ( . let open Let_syntax in Command . async ~ summary : " Generate a trivial zkApp transaction and genesis ledger with \ verification key for testing " ( let % map keyfile = Param . flag " -- fee - payer - key " ~ doc : " KEYFILE Private key file for the fee payer of the tran... |
let txn_commands = [ ( " create - zkapp - account " , create_zkapp_account ) create_zkapp_account ; ( " upgrade - zkapp " , upgrade_zkapp ) upgrade_zkapp ; ( " transfer - funds " , transfer_funds ) transfer_funds ; ( " update - state " , update_state ) update_state ; ( " update - zkapp - uri " , update_zkapp_uri ) upda... |
let ( ) = Command . run ( Command . group ~ summary " : ZkApp test transaction " ~ preserve_subcommand_order ( ) : txn_commands ) |
let crc_table = Array . init 256 ( fun n -> let crc = ref ( Int32 . of_int n ) n in for j = 0 to 7 do crc := if Int32 . to_int ( Int32 . logand ( ! crc ) crc 1l ) 1l <> 0 then Int32 . logxor ( Int32 . shift_right_logical ( ! crc ) crc 1 ) 1 polynom else Int32 . shift_right_logical ( ! crc ) crc 1 ; done ; ! crc ) crc |
let compress ( ? level = 6 ) 6 ( ? header = true ) true refill flush = let inbuf = Bytes . create buffer_size and outbuf = Bytes . create buffer_size in let zs = Extc . zlib_deflate_init2 level ( if header then max_wbits else - max_wbits ) max_wbits in let rec compr inpos inavail = if inavail = 0 then begin let incount... |
let compress_direct ( ? level = 6 ) 6 ( ? header = true ) true flush = let outbuf = Bytes . create buffer_size in let zs = Extc . zlib_deflate_init2 level ( if header then max_wbits else - max_wbits ) max_wbits in let rec compr inbuf inpos inavail = if inavail = 0 then ( ) else begin let res = Extc . zlib_deflate zs ~ ... |
let uncompress ( ? header = true ) true refill flush = let inbuf = Bytes . create buffer_size and outbuf = Bytes . create buffer_size in let zs = Extc . zlib_inflate_init2 ( if header then max_wbits else - max_wbits ) max_wbits in let rec uncompr inpos inavail = if inavail = 0 then begin let incount = refill inbuf in i... |
let update_crc crc buf pos len = let c = ref ( Int32 . lognot crc ) crc in for i = pos to ( len + pos - 1 ) 1 do let b = Int32 . of_int ( int_of_char ( Bytes . get buf i ) i ) i in c := Int32 . logxor ( Array . get crc_table ( Int32 . to_int ( Int32 . logand ( Int32 . logxor ! c b ) b 0xFFl ) 0xFFl ) 0xFFl ) 0xFFl ( In... |
type location = Loc of int * int |
let input_name = ref " " |
let input_chan = ref stdin |
let initialize iname = input_name := iname ; input_chan := open_in iname |
let output_lines ff char1 char2 charline1 line1 line2 = let n1 = char1 - charline1 and n2 = char2 - charline1 in if line2 > line1 then fprintf ff " , line % d -% d , characters % d -% d :\ n " line1 line2 n1 n2 else fprintf ff " , line % d , characters % d -% d :\ n " line1 n1 n2 ; ( ) |
let output_loc ff input seek line_flag ( Loc ( pos1 , pos2 ) ) = let pr_chars n c = for i = 1 to n do pp_print_char ff c done in let skip_line ( ) = try while input ( ) != ' \ n ' do ( ) done with End_of_file -> ( ) in let copy_line ( ) = let c = ref ' ' in begin try while c := input ( ) ; ! c != ' \ n ' do pp_print_ch... |
let output_location ff loc = let p = pos_in ! input_chan in fprintf ff " File " \% s " " \ ! input_name ; output_loc ff ( fun ( ) -> input_char ! input_chan ) ( seek_in ! input_chan ) true loc ; seek_in ! input_chan p |
let output_input_name ff = fprintf ff " File " \% s " , \ line 1 :\ n " ! input_name |
type carray = ( float , float64_elt , c_layout ) Array1 . t |
type zarray = ( int32 , int32_elt , c_layout ) Array1 . t |
let cmake n = let r = Array1 . create float64 c_layout n in Array1 . fill r 0 . 0 ; r |
let zmake n = let r = Array1 . create int32 c_layout n in Array1 . fill r 0l ; r |
let get_zin v i = Array1 . get v i <> 0l |
let zzero zinvec length = for i = 0 to length - 1 do Array1 . set zinvec i 0l done |
type ' s f_alloc = unit -> ' s |
type ' s f_maxsize = ' s -> int * int |
type ' s f_csize = ' s -> int |
type ' s f_zsize = ' s -> int |
type ( ' s , ' o ) f_step = ' s -> carray -> carray -> zarray -> float -> ' o |
type ' s f_ders = ' s -> carray -> carray -> zarray -> carray -> float -> unit |
type ' s f_zero = ' s -> carray -> zarray -> carray -> float -> unit |
type ' s f_reset = ' s -> unit |
type ' s f_horizon = ' s -> float |
let time_eq f1 f2 = if abs_float ( f1 . - f2 ) < min_float then true else let rel_error = if abs_float f1 > abs_float f2 then abs_float ( ( f1 . - f2 ) . / f1 ) else abs_float ( ( f1 . - f2 ) . / f2 ) in ( rel_error <= 0 . 000001 ) |
let time_leq t1 t2 = t1 < t2 || time_eq t1 t2 |
let time_geq t1 t2 = t1 > t2 || time_eq t1 t2 |
module type STATE_SOLVER = sig type t type nvec val cmake : int -> nvec val unvec : nvec -> carray type rhsfn = float -> carray -> carray -> unit type dkyfn = nvec -> float -> int -> unit val initialize : rhsfn -> nvec -> t val reinitialize : t -> float -> nvec -> unit val step : t -> float -> nvec -> float val get_dky... |
module type STATE_SOLVER_SENS = sig include STATE_SOLVER type sensmat val smake : int -> int -> sensmat val arrays_of_sensmat : sensmat -> float array array type rhsfn = carray -> float -> carray -> carray -> unit type dkysensfn = sensmat -> float -> int -> unit val initialize : rhsfn -> carray -> nvec -> sensmat -> t ... |
module type ZEROC_SOLVER = sig type t type zcfn = float -> carray -> carray -> unit val initialize : int -> zcfn -> carray -> t val initialize_only : int -> zcfn -> carray -> t val reinitialize : t -> float -> carray -> unit val step : t -> float -> carray -> unit val takeoff : t -> bool val has_roots : t -> bool val f... |
module type RUNTIME = sig val go : unit hsimu -> unit val check : bool hsimu -> int -> unit end |
module type DISCRETE_RUNTIME = sig val go : float -> ( unit -> unit ) -> unit end |
type file_kind = ZLS | ZLI ; ; |
let file_dependencies_as kind source_file = try if Sys . file_exists source_file then begin match kind with | ZLS -> zls_file_dependencies source_file | ZLI -> zli_file_dependencies source_file end with x -> let report_err = function | Zlexer . Lexical_error ( err , range ) -> lexical_error err range | Zparser . Error ... |
let file_dependencies source_file = if Filename . check_suffix source_file " . zls " then file_dependencies_as ZLS source_file else if Filename . check_suffix source_file " . zli " then file_dependencies_as ZLI source_file else ( ) |
let usage = " Usage : zlsdep [ options ] < source files >\ nOptions are " : |
let _ = try add_to_load_path Filename . current_dir_name ; Arg . parse [ " - I " , Arg . String add_to_load_path , " < dir > Add < dir > to the list of include directories " ; " - impl " , Arg . String ( file_dependencies_as ZLS ) , " < f > Process < f > as a . zls file " ; " - intf " , Arg . String ( file_dependencies... |
sig val enable_logging : unit -> unit val min_step_size : float option ref val max_step_size : float option ref val max_sim_time : float option ref val speedup : float ref val step : ' s Zls . f_alloc -> ' s Zls . f_csize -> ' s Zls . f_zsize -> ' s Zls . f_horizon -> ' s Zls . f_maxsize -> ' s Zls . f_ders -> ( ' s , ... |
module Make ( SSolver : Zls . STATE_SOLVER ) ( ZSolver : Zls . ZEROC_SOLVER ) = let no_time_in_solver = - 1 . 0 let add_margin h = h . + ( 2 . 0 . * epsilon_float . * h ) let max_sim_time = ref None let min_step_size = ref None let max_step_size = ref None let always_reinit = ref true let precise_logging = ref false le... |
module Make ( SSolver : Zls . STATE_SOLVER ) = struct |
module Solver = Zlsolve . Make ( SSolver ) ( Illinois ) |
let wait_next_instant = let delay = ref 0 . 0 in let rec wait_next_instant starting ending delta = let diff = ( delta . - ( ending . - starting ) ) . - ! delay in if diff > 0 . 0 then begin try delay := 0 . 0 ; ignore ( Unix . select [ ] [ ] [ ] diff ) ; false with Unix . Unix_error ( Unix . EINTR , _ , _ ) -> wait_nex... |
let go ( Ztypes . Hsim { alloc = main_alloc ; maxsize = main_maxsize ; csize = main_csize ; zsize = main_zsize ; step = main_step ; derivative = main_ders ; crossings = main_zero ; reset = main_reset ; horizon = main_horizon ; } ) = let stepfn = Solver . step main_alloc main_csize main_zsize main_horizon main_maxsize m... |
let check ( Ztypes . Hsim { alloc = main_alloc ; maxsize = main_maxsize ; csize = main_csize ; zsize = main_zsize ; step = main_step ; derivative = main_ders ; crossings = main_zero ; reset = main_reset ; horizon = main_horizon ; } ) limit = let stepfn = Solver . step main_alloc main_csize main_zsize main_horizon main_... |
module Make ( SSolver : Zls . STATE_SOLVER ) = |
module Solver = Zlsolve . Make ( SSolver ) ( Illinois ) |
let _ = GMain . init ( ) |
let start_playing = ref true |
let destroy ( ) = GMain . Main . quit ( ) |
let low_prio = Glib . int_of_priority ` LOW -> Glib . Timeout . id = " ml_g_timeout_add " main_ders main_step main_zero main_reset = val stepfn = Solver . step main_alloc main_csize main_zsize main_horizon main_maxsize main_ders main_step main_zero main_reset val mutable last_wall_clk = Unix . gettimeofday ( ) val muta... |
let go ( Ztypes . Hsim { alloc = main_alloc ; maxsize = main_maxsize ; csize = main_csize ; zsize = main_zsize ; step = main_step ; derivative = main_ders ; crossings = main_zero ; reset = main_reset ; horizon = main_horizon ; } ) = let w = GWindow . window ~ title " : Simulator " ~ width : 250 ~ height : 70 ~ resizabl... |
let check _ _ = assert false |
let _ = GMain . init ( ) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.