text stringlengths 12 786k |
|---|
let of_node ? name_tag node args ~ exec ~ client = { node ; exec ; client ; args ; name_tag } |
let baker_of_node ? name_tag nod ~ key = of_node nod ? name_tag ( Baker key ) |
let endorser_of_node ? name_tag nod ~ key = of_node nod ? name_tag ( Endorser key ) |
let accuser_of_node ? name_tag nod = of_node ? name_tag nod Accuser |
let arg_to_string = function | Baker k -> sprintf " baker -% s " k | Endorser k -> sprintf " endorser -% s " k | Accuser -> " accuser " |
let to_script state ( t : t ) = let base_dir = Tezos_client . base_dir ~ state t . client in let call t args = Tezos_executable . call state t . exec ~ path : ( base_dir // sprintf " exec -% s -% d % s " ( arg_to_string t . args ) t . node . Tezos_node . rpc_port ( Option . ... |
let process state ( t : t ) = Running_processes . Process . genspio ( sprintf " % s - for -% s % s " ( arg_to_string t . args ) t . node . Tezos_node . id ( Option . value_map t . name_tag ~ default " " : ~ f ( : sprintf " -% s " ) ) ) ( to_script state t ) |
module Make_cli = struct let flag name = [ sprintf " --% s " name ] let opt name s = [ sprintf " --% s " name ; s ] let optf name fmt = ksprintf ( opt name ) fmt end |
module Unix_files_sink = struct type t = { matches : string list option ; level_at_least : string } let all_at_least level_at_least = { matches = None ; level_at_least } let all_notices = all_at_least " notice " let all_info = all_at_least " info " end |
type kind = [ ` Node | ` Baker | ` Endorser | ` Accuser | ` Client | ` Admin ] |
type t = { kind : kind ; binary : string option ; unix_files_sink : Unix_files_sink . t option ; environment : ( string * string ) list } |
let make ? binary ? unix_files_sink ( ? environment = [ ] ) ( kind : [ < kind ] ) = { kind ; binary ; unix_files_sink ; environment } |
let kind_string ( kind : [ < kind ] ) = match kind with | ` Accuser -> " accuser - alpha " | ` Baker -> " baker - alpha " | ` Endorser -> " endorser - alpha " | ` Node -> " node " | ` Client -> " client " | ` Admin -> " admin - client " |
let default_binary t = sprintf " tezos -% s " ( kind_string t . kind ) |
let get t = Option . value t . binary ~ default ( : default_binary t ) |
let call state t ~ path args = let open Genspio . EDSL in let unix_files_sink = match t . unix_files_sink with | Some s -> Some s | None -> Environment_configuration . default_events_level state |> Option . map ~ f : Unix_files_sink . all_at_least in seq ( Option . value_map unix_files_sink ~ d... |
let cli_term ( ? extra_doc = " " ) state kind prefix = let open Cmdliner in let open Term in let docs = Manpage_builder . section state ~ rank : 2 ~ name " : EXECUTABLE PATHS " in pure ( fun binary -> { kind ; binary ; unix_files_sink = None ; environment = [ ] } ) $ Arg . ... |
type custom_network = [ ` Json of Ezjsonm . value ] |
type t = { id : string ; expected_connections : int ; rpc_port : int ; p2p_port : int ; peers : int list ; exec : Tezos_executable . t ; protocol : Tezos_protocol . t ; history_mode : [ ` Archive | ` Full of int | ` Rolling of int ] option ; single_process : bool ; cors_ori... |
let compare a b = Base . String . compare a . id b . id |
let equal a b = Base . String . equal a . id b . id |
let ef t = EF . ( desc_list ( af " Node :% S " t . id ) [ desc ( af " rpc " ) ( af " :% d " t . rpc_port ) ; desc ( af " p2p " ) ( af " :% d " t . p2p_port ) ; desc_list ( af " peers " ) ( List . map t . peers ~ f ( : af " :% d " ) ) ... |
let pp fmt t = Easy_format . Pretty . to_formatter fmt ( ef t ) |
let id t = t . id |
let make ? cors_origin ~ exec ( ? protocol = Tezos_protocol . default ( ) ) ? custom_network ( ? single_process = true ) ? history_mode id ~ expected_connections ~ rpc_port ~ p2p_port peers = { id ; expected_connections ; rpc_port ; p2p_port ; peers ; exec ; protocol ; history_... |
let make_path p ~ config t = Paths . root config // sprintf " node -% s " t . id // p |
let data_dir config t = make_path " data - dir " ~ config t |
let config_file config t = data_dir config t // " config . json " |
let identity_file config t = data_dir config t // " identity . json " |
let log_output config t = make_path " node - output . log " ~ config t |
let exec_path config t = make_path ~ config " exec " t |
module Config_file = struct open Tezos_rpc_http_server let network ( ? genesis_hash = " BLdZYwNF8Rn6zrTWkuRRNyrj6bQWPkfBog2YKhWhn5z3ApmpzBf " ) ( ) = let open Ezjsonm in [ ( " genesis " , dict [ ( " timestamp " , string " 2018 - 06 - 30T16 : 07 : 32Z " ) ; ( " bl... |
let node_command state t cmd options = Tezos_executable . call state t . exec ~ path ( : exec_path state t ) ( cmd @ opt " config - file " ( config_file state t ) @ opt " data - dir " ( data_dir state t ) @ options ) |
let run_command state t = let peers = List . concat_map t . peers ~ f ( : optf " peer " " 127 . 0 . 0 . 1 :% d " ) in let cors_origin = match t . cors_origin with | Some _ as s -> s | None -> Environment_configuration . default_cors_origin state in node_command state t [ " r... |
let start_script state t = let open Genspio . EDSL in let gen_id = node_command state t [ " identity " ; " generate " ; sprintf " % d " ( Tezos_protocol . expected_pow t . protocol ) ] [ ] in let tmp_config = tmp_file ( config_file state t ) in check_sequence ~ verbosity ` ... |
let process state t = Running_processes . Process . genspio t . id ( start_script state t ) |
let protocol t = t . protocol |
let connections node_list = let module Connection = struct type node = t type t = [ ` Duplex of node * node | ` From_to of node * node | ` Missing of node * int ] let compare a b = match ( a , b ) with | ` Duplex ( a , b ) , ` Duplex ( c , d ) when equal a d && equal b c -... |
module History_modes = struct type ' error edit = t list -> ( t list , ' error ) Asynchronous_result . t let cmdliner_term state : _ edit Cmdliner . Term . t = let open Cmdliner in let open Term in let history_mode_converter = Arg . enum [ ( " archive " , ` Archive ) ; ( " f... |
module Key = struct module Of_name = struct type t = { name : string ; pkh : Tezos_crypto . Ed25519 . Public_key_hash . t ; pk : Tezos_crypto . Ed25519 . Public_key . t ; sk : Tezos_crypto . Ed25519 . Secret_key . t } let make name = let seed = Bytes . of_string ( String . con... |
module Account = struct type t = | Of_name of string | Key_pair of { name : string ; pubkey : string ; pubkey_hash : string ; private_key : string } let of_name s = Of_name s let of_namef fmt = ksprintf of_name fmt let name = function Of_name n -> n | Key_pair k -> k . name let key_pair name ... |
module Voting_period = struct type t = [ ` Proposal | ` Exploration | ` Cooldown | ` Promotion | ` Adoption ] end |
module Protocol_kind = struct type t = [ ` Athens | ` Babylon | ` Carthage | ` Delphi | ` Edo | ` Florence | ` Granada | ` Hangzhou | ` Ithaca | ` Alpha ] let names = [ ( " Athens " , ` Athens ) ; ( " Babylon " , ` Babylon ) ; ( " Carthage " , ` ... |
type t = { id : string ; kind : Protocol_kind . t ; bootstrap_accounts : ( Account . t * Int64 . t ) list ; dictator : Account . t ; expected_pow : int ; name : string ; hash : string ; time_between_blocks : int list ; minimal_block_delay : int ; baking_reward_per_endorsement ... |
let compare a b = String . compare a . id b . id |
let make_bootstrap_accounts ~ balance n = List . init n ~ f ( : fun n -> ( Account . of_namef " bootacc -% d " n , balance ) ) |
let default ( ) = let dictator = Account . of_name " dictator - default " in { id = " default - bootstrap " ; kind = Protocol_kind . default ; bootstrap_accounts = make_bootstrap_accounts ~ balance : 4_000_000_000_000L 4 ; dictator ; expected_pow = 1 ; name = " alpha " ; ... |
let protocol_parameters_json t : Ezjsonm . t = let open Ezjsonm in let make_account ( account , amount ) = strings [ Account . pubkey account ; sprintf " % Ld " amount ] in let extra_post_babylon_stuff subkind = let alpha_specific_parameters = match subkind with | ` Alpha -> [ ( " tx... |
let voting_period_to_string t ( p : Voting_period . t ) = match p with | ` Promotion -> if Protocol_kind . ( t . kind < ` Florence ) then " promotion_vote " else " promotion " | ` Exploration -> if Protocol_kind . ( t . kind < ` Florence ) then " testing_vote " else " ... |
let sandbox { dictator ; _ } = let pk = Account . pubkey dictator in Ezjsonm . to_string ( ` O [ ( " genesis_pubkey " , ` String pk ) ] ) |
let protocol_parameters t = Ezjsonm . to_string ~ minify : false ( protocol_parameters_json t ) |
let expected_pow t = t . expected_pow |
let id t = t . id |
let kind t = t . kind |
let bootstrap_accounts t = List . map ~ f : fst t . bootstrap_accounts |
let dictator_name { dictator ; _ } = Account . name dictator |
let dictator_secret_key { dictator ; _ } = Account . private_key dictator |
let make_path config t = Paths . root config // sprintf " protocol -% s " ( id t ) |
let sandbox_path config t = make_path config t // " sandbox . json " |
let protocol_parameters_path config t = make_path config t // " protocol_parameters . json " |
let ensure_script state t = let open Genspio . EDSL in let file string p = let path = p state t in ( Caml . Filename . basename path , write_stdout ~ path ( : str path ) ( feed ~ string ( : str ( string t ) ) ( exec [ " cat " ] ) ) ) in check_sequence ~ verbosity ( ` ... |
let ensure state t = Running_processes . run_successful_cmdf state " sh - c % s " ( Genspio . Compile . to_one_liner ( ensure_script state t ) |> Caml . Filename . quote ) >>= fun _ -> return ( ) |
let cli_term state = let open Cmdliner in let open Term in let def = default ( ) in let docs = Manpage_builder . section state ~ rank : 2 ~ name " : PROTOCOL OPTIONS " in pure ( fun bootstrap_accounts ( ` Blocks_per_voting_period blocks_per_voting_period ) ( ` Protocol_hash hash ) ( ` ... |
module Pretty_print = struct open More_fmt let verbatim_protection f ppf json_blob = try f ppf json_blob with e -> json ppf json_blob ; cut ppf ( ) ; exn ppf e let fail_expecting s = failwith " PP : Expecting % s " s let mempool_pending_operations_rpc ppf mempool_json = let pp_op_list_short ppf l = ... |
module type CONTEXT = sig type t type key = string list type value = MBytes . t val mem : t -> key -> bool Lwt . t val dir_mem : t -> key -> bool Lwt . t val get : t -> key -> value option Lwt . t val set : t -> key -> value -> t Lwt . t val copy : t -> from : key -> to_ : key -> t optio... |
module Context = struct type key = string list type value = MBytes . t type ' ctxt ops = ( module CONTEXT with type t = ' ctxt ) type _ kind = . . type t = Context : { kind : ' a kind ; ctxt : ' a ; ops : ' a ops } -> t let mem ( Context { ops = ( module Ops ) ; ctxt ... |
type validation_result = { context : Context . t ; fitness : Fitness . t ; message : string option ; max_operations_ttl : int ; last_allowed_fork_level : Int32 . t ; } |
type quota = { max_size : int ; max_op : int option } |
type rpc_context = { block_hash : Block_hash . t ; block_header : Block_header . shell_header ; context : Context . t ; } |
module type T = sig type context type quota type validation_result type rpc_context type ' a tzresult val max_block_length : int val max_operation_data_length : int val validation_passes : quota list type block_header_data val block_header_data_encoding : block_header_data Data_encoding . t type block_header ... |
module type PROTOCOL = T with type context := Context . t and type quota := quota and type validation_result := validation_result and type rpc_context := rpc_context and type ' a tzresult := ' a Error_monad . tzresult |
module MakeV1 ( Param : sig val name : string end ) struct include Pervasives module Pervasives = Pervasives module Compare = Compare module Array = Array module List = List module Bytes = struct include Bytes include EndianBytes . BigEndian module LE = EndianBytes . LittleEndian end module String = st... |
let hooks = let replace_variables string = let replacements = [ ( " tz [ 123 ] \\ w { 33 } " , " [ PUBLIC_KEY_HASH ] " ) ; ( " edpk \\ w { 50 } " , " [ PUBLIC_KEY ] " ) ; ( " KT1 \\ w { 33 } " , " [ CONTRACT_HASH ] " ) ; ( " \\... |
type t = Tez_tag of repr [ @@ ocaml . unboxed ] |
type error += | Addition_overflow of t * t | Subtraction_underflow of t * t | Multiplication_overflow of t * int64 | Negative_multiplicator of t * int64 | Invalid_divisor of t * int64 |
let zero = Tez_tag 0L |
let one_mutez = Tez_tag 1L |
let max_mutez = Tez_tag Int64 . max_int |
let mul_int ( Tez_tag tez ) i = Tez_tag ( Int64 . mul tez i ) |
let one_cent = mul_int one_mutez 10_000L |
let fifty_cents = mul_int one_cent 50L |
let one = mul_int one_cent 100L |
let of_string s = let triplets = function | hd :: tl -> let len = String . length hd in Compare . Int . ( len <= 3 && len > 0 && List . for_all ( fun s -> String . length s = 3 ) tl ) | [ ] -> false in let integers s = triplets ( String . split_on_char ' , ' s ) in le... |
let pp ppf ( Tez_tag amount ) = let mult_int = 1_000_000L in let [ @ coq_struct " amount " ] rec left ppf amount = let ( d , r ) = ( Int64 . ( div amount 1000L ) , Int64 . ( rem amount 1000L ) ) in if d > 0L then Format . fprintf ppf " % a % 03Ld " left d r else Fo... |
let to_string t = Format . asprintf " % a " pp t |
let ( -? ) tez1 tez2 = let ( Tez_tag t1 ) = tez1 in let ( Tez_tag t2 ) = tez2 in if t2 <= t1 then ok ( Tez_tag ( Int64 . sub t1 t2 ) ) else error ( Subtraction_underflow ( tez1 , tez2 ) ) |
let sub_opt ( Tez_tag t1 ) ( Tez_tag t2 ) = if t2 <= t1 then Some ( Tez_tag ( Int64 . sub t1 t2 ) ) else None |
let ( +? ) tez1 tez2 = let ( Tez_tag t1 ) = tez1 in let ( Tez_tag t2 ) = tez2 in let t = Int64 . add t1 t2 in if t < t1 then error ( Addition_overflow ( tez1 , tez2 ) ) else ok ( Tez_tag t ) |
let ( *? ) tez m = let ( Tez_tag t ) = tez in if m < 0L then error ( Negative_multiplicator ( tez , m ) ) else if m = 0L then ok ( Tez_tag 0L ) else if t > Int64 . ( div max_int m ) then error ( Multiplication_overflow ( tez , m ) ) else ok ( Tez_tag ( Int64 . mul t ... |
let ( /? ) tez d = let ( Tez_tag t ) = tez in if d <= 0L then error ( Invalid_divisor ( tez , d ) ) else ok ( Tez_tag ( Int64 . div t d ) ) |
let mul_exn t m = match t *? Int64 . ( of_int m ) with | Ok v -> v | Error _ -> invalid_arg " mul_exn " |
let div_exn t d = match t /? Int64 . ( of_int d ) with | Ok v -> v | Error _ -> invalid_arg " div_exn " |
let of_mutez t = if t < 0L then None else Some ( Tez_tag t ) |
let of_mutez_exn x = match of_mutez x with None -> invalid_arg " Tez . of_mutez " | Some v -> v |
let to_mutez ( Tez_tag t ) = t |
let encoding = let open Data_encoding in let decode ( Tez_tag t ) = Z . of_int64 t in let encode = Json . wrap_error ( fun i -> Tez_tag ( Z . to_int64 i ) ) in Data_encoding . def name ( check_size 10 ( conv decode encode n ) ) |
let ( ) = let open Data_encoding in register_error_kind ` Temporary ~ id ( : id ^ " . addition_overflow " ) ~ title ( " : Overflowing " ^ id ^ " addition " ) ~ pp ( : fun ppf ( opa , opb ) -> Format . fprintf ppf " Overflowing addition of % a % s and % a % s " pp... |
let compare ( Tez_tag x ) ( Tez_tag y ) = compare x y |
let ( = ) ( Tez_tag x ) ( Tez_tag y ) = x = y |
let ( <> ) ( Tez_tag x ) ( Tez_tag y ) = x <> y |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.