text
stringlengths 12
786k
|
---|
module Cametallayer = struct type m type t = m Ctypes . structure let ctype : t Ctypes . typ = Ctypes . structure " CAmetallayer " let pp = Vk__helpers . Pp . abstract end |
type cametallayer = Cametallayer . t Ctypes . structure |
module type Config = sig val shift : int val char_of_digit : int -> char val digit_of_char : char -> int end |
module type S = sig val encode : Buffer . t -> int -> unit val decode : char Stream . t -> int end |
module Make ( C : Config ) = struct let vlq_base = 1 lsl C . shift let vlq_base_mask = vlq_base - 1 let vlq_continuation_bit = vlq_base let vlq_signed_of_int value = if value < 0 then ( ( - value ) lsl 1 ) + 1 else ( value lsl 1 ) + 0 let rec encode_vlq buf vlq = let digit = vlq land vlq_base_mask in let vlq = vlq lsr C . shift in if vlq = 0 then Buffer . add_char buf ( C . char_of_digit digit ) else begin Buffer . add_char buf ( C . char_of_digit ( digit lor vlq_continuation_bit ) ) ; encode_vlq buf vlq end let encode buf value = let vlq = vlq_signed_of_int value in encode_vlq buf vlq let decode = let rec helper ( acc , shift ) stream = let chr = try Stream . next stream with Stream . Failure -> raise Unexpected_eof in let digit = C . digit_of_char chr in let continued = ( digit land vlq_continuation_bit ) != 0 in let acc = acc + ( digit land vlq_base_mask ) lsl shift in if continued then helper ( acc , shift + C . shift ) stream else acc in fun stream -> let acc = helper ( 0 , 0 ) stream in let abs = acc / 2 in if acc land 1 = 0 then abs else ( - abs ) end |
module Base64 = Make ( struct let shift = 5 let base64 = " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 " +/ let char_of_digit digit = if 0 <= digit && digit < String . length base64 then base64 . [ digit ] else failwith ( Printf . sprintf " Must be between 0 and 63 : % d " digit ) let digit_of_char chr = try String . index base64 chr with Not_found -> raise ( Invalid_base64 chr ) end ) |
let code_rev = let a = Array . make 255 ( - 1 ) in for i = 0 to String . length code - 1 do a . ( Char . code code . [ i ] ) <- i done ; a |
let vlq_base = 1 lsl vlq_base_shift |
let vlq_base_mask = vlq_base - 1 |
let toVLQSigned v = if v < 0 then ( - v lsl 1 ) + 1 else v lsl 1 |
let fromVLQSigned v = let is_neg = v land 1 = 1 in let shift = v lsr 1 in if is_neg then - shift else shift |
let add_char buf x = Buffer . add_char buf code . [ x ] |
let rec encode ' buf x = let digit = x land vlq_base_mask in let rest = x lsr vlq_base_shift in if rest = 0 then add_char buf digit else ( add_char buf ( digit lor vlq_continuation_bit ) ; encode ' buf rest ) |
let encode b x = let vql = toVLQSigned x in encode ' b vql |
let encode_l b l = List . iter ~ f ( : encode b ) l |
let rec decode ' acc s start pos = let digit = code_rev . ( Char . code s . [ pos ] ) in if digit = - 1 then invalid_arg " Vql64 . decode ' " ; let cont = digit land vlq_continuation_bit = vlq_continuation_bit in let digit = digit land vlq_base_mask in let acc = acc + ( digit lsl ( ( pos - start ) * vlq_base_shift ) ) in if cont then decode ' acc s start ( succ pos ) else acc , succ pos |
let decode s p = let d , i = decode ' 0 s p p in fromVLQSigned d , i |
let decode_l s ~ pos ~ len = let rec aux pos acc len = if len = 0 then List . rev acc else if len < 0 then invalid_arg " Vlq64 . decode_l " else let d , i = decode s pos in let len = len - ( i - pos ) in aux i ( d :: acc ) len in aux pos [ ] len |
module Make ( V : HashCmp ) ( L : Lattice ) ( R : Result ) = struct type v = V . t * L . t type r = R . t type d = Leaf of r | Branch of V . t * L . t * t * t and t = { id : int ; d : d } let equal x y = x . id = y . id let rec to_string t = match t . d with | Leaf r -> R . to_string r | Branch ( v , l , t , f ) -> Printf . sprintf " B ( % s = % s , % s , % s ) " ( V . to_string v ) ( L . to_string l ) ( to_string t ) ( to_string f ) type this_t = t module M = struct module Table = Weak . Make ( struct type t = this_t let hash t = match t . d with | Leaf r -> 101 * R . hash r | Branch ( v , l , t , f ) -> 191 * ( V . hash v ) + 877 * ( L . hash l ) + 3511 * t . id + 3559 * f . id let equal a b = match a . d , b . d with | Leaf r1 , Leaf r2 -> R . compare r1 r2 = 0 | Branch ( vx , lx , tx , fx ) , Branch ( vy , ly , ty , fy ) -> V . compare vx vy = 0 && tx . id = ty . id && fx . id = fy . id && L . compare lx ly = 0 | _ , _ -> false end ) type t = { table : Table . t ; mutable sym : int } let create size = { table = Table . create size ; sym = 1 } let clear t = Table . clear t . table let gensym t = let s = t . sym in t . sym <- t . sym + 1 ; s let get t d = try Table . find t . table { id = 0 ; d } with Not_found -> Table . merge t . table { id = gensym t ; d } let remove t d = Table . remove t . table { id = 0 ; d } end let manager = M . create 100 let mk_leaf r = M . get manager ( Leaf r ) let mk_branch v l t f = if equal t f then begin t end else M . get manager ( Branch ( v , l , t , f ) ) let rec fold g h t = match t . d with | Leaf r -> g r | Branch ( v , l , t , f ) -> h ( v , l ) ( fold g h t ) ( fold g h f ) let destruct g h t = match t . d with | Leaf r -> g r | Branch ( v , l , t , f ) -> h ( v , l ) t f let rec iter ( ? order ` = Pre ) g h t = match t . d with | Leaf r -> g r | Branch ( v , l , t , f ) -> match order with | ` Pre -> h ( v , l ) t f ; iter ~ order g h t ; iter ~ order g h f | ` Post -> iter ~ order g h t ; iter ~ order g h f ; h ( v , l ) t f let const r = mk_leaf r let atom ( v , l ) t f = mk_branch v l ( const t ) ( const f ) let restrict lst = let rec loop xs u = match xs , u . d with | [ ] , _ | _ , Leaf _ -> u | ( v , l ) :: xs ' , Branch ( v ' , l ' , t , f ) -> match V . compare v v ' with | 0 -> if L . subset_eq l l ' then loop xs ' t else loop xs f | - 1 -> loop xs ' u | 1 -> mk_branch v ' l ' ( loop xs t ) ( loop xs f ) | _ -> assert false in loop ( List . sort ( fun ( u , _ ) ( v , _ ) -> V . compare u v ) lst ) let peek t = match t . d with | Leaf r -> Some r | Branch _ -> None let rec map_r g = fold ( fun r -> const ( g r ) ) ( fun ( v , l ) t f -> mk_branch v l t f ) let rec prod x y = match x . d , y . d with | Leaf r , _ -> if R . ( compare r zero ) = 0 then x else if R . ( compare r one ) = 0 then y else map_r ( R . prod r ) y | _ , Leaf r -> if R . ( compare zero r ) = 0 then y else if R . ( compare one r ) = 0 then x else map_r ( fun x -> R . prod x r ) x | Branch ( vx , lx , tx , fx ) , Branch ( vy , ly , ty , fy ) -> begin match V . compare vx vy with | 0 -> begin match L . meet ~ tight : true lx ly with | Some ( l ) -> mk_branch vx l ( prod tx ty ) ( prod fx fy ) | None -> begin match L . compare lx ly with | 0 -> assert false | - 1 -> mk_branch vx lx ( prod tx ( restrict [ ( vx , lx ) ] y ) ) ( prod fx y ) | 1 -> mk_branch vy ly ( prod ( restrict [ ( vy , ly ) ] x ) ty ) ( prod x fy ) | _ -> assert false end end | - 1 -> mk_branch vx lx ( prod tx y ) ( prod fx y ) | 1 -> mk_branch vy ly ( prod x ty ) ( prod x fy ) | _ -> assert false end let rec sum x y = match x . d , y . d with | Leaf r , _ -> if R . ( compare r zero ) = 0 then y else map_r ( R . sum r ) y | _ , Leaf r -> if R . ( compare zero r ) = 0 then x else map_r ( fun x -> R . sum x r ) x | Branch ( vx , lx , tx , fx ) , Branch ( vy , ly , ty , fy ) -> begin match V . compare vx vy with | 0 -> begin match L . join ~ tight : true lx ly with | Some ( l ) -> mk_branch vx l ( sum tx ty ) ( sum fx fy ) | None -> begin match L . compare lx ly with | 0 -> assert false | - 1 -> mk_branch vx lx ( sum tx ( restrict [ ( vx , lx ) ] y ) ) ( sum fx y ) | 1 -> mk_branch vy ly ( sum ( restrict [ ( vy , ly ) ] x ) ty ) ( sum x fy ) | _ -> assert false end end | - 1 -> mk_branch vx lx ( sum tx y ) ( sum fx y ) | 1 -> mk_branch vy ly ( sum x ty ) ( sum x fy ) | _ -> assert false end module VH = Hashtbl . Make ( struct type t = v let equal ( v1 , l1 ) ( v2 , l2 ) = V . compare v1 v2 = 0 && L . compare l1 l2 = 0 let hash ( v , l ) = 191 * ( V . hash v ) + 877 * ( L . hash l ) end ) let rec support t = let s = VH . create 20 in iter ( fun _ -> ( ) ) ( fun v _ _ -> VH . replace s v ( ) ) t ; VH . fold ( fun v ( ) acc -> v :: acc ) s [ ] let to_dot t = let open Format in let buf = Buffer . create 200 in let fmt = formatter_of_buffer buf in let seen = Hashtbl . create ~ random : true 20 in let rank = VH . create 20 in pp_set_margin fmt ( 1 lsl 29 ) ; fprintf fmt " digraph tdk { @\ n " ; let rec loop t = if not ( Hashtbl . mem seen t . id ) then begin Hashtbl . add seen t . id ( ) ; match t . d with | Leaf r -> fprintf fmt " % d [ shape = box label " =\% s " ] ; \@\ n " t . id ( R . to_string r ) | Branch ( v , l , a , b ) -> begin try Hashtbl . add ( VH . find rank ( v , l ) ) t . id ( ) with Not_found -> let s = Hashtbl . create ~ random : true 10 in Hashtbl . add s t . id ( ) ; VH . add rank ( v , l ) s end ; fprintf fmt " % d [ label " =\% s = % s " ] ; \@\ n " t . id ( V . to_string v ) ( L . to_string l ) ; fprintf fmt " % d -> % d ; @\ n " t . id a . id ; fprintf fmt " % d -> % d [ style " =\ dashed " ] ; \@\ n " t . id b . id ; loop a ; loop b end in loop t ; VH . iter ( fun _ s -> fprintf fmt " { rank = same ; " ; Hashtbl . iter ( fun x ( ) -> fprintf fmt " % d " x ) s ; fprintf fmt " ; } @\ n " ) rank ; fprintf fmt " } . " ; @ Buffer . contents buf end |
let network = [ " host " ] |
let download_cache = Obuilder_spec . Cache . v " opam - archives " ~ target " :/ home / opam . / opam / download - cache " |
let dune_cache = Obuilder_spec . Cache . v " opam - dune - cache " ~ target " :/ home / opam . / cache / dune " |
let cache = [ download_cache ; dune_cache ] |
type t0 = { voodoo_do : Git . Commit_id . t ; voodoo_prep : Git . Commit_id . t ; voodoo_gen : Git . Commit_id . t ; } |
module Op = struct type voodoo = t0 type t = No_context let id = " voodoo - repository " let pp f _ = Fmt . pf f " voodoo - repository " let auto_cancel = false module Key = struct type t = Git . Commit . t let digest = Git . Commit . hash end module Value = struct type t = voodoo let to_yojson commit = let hash = Git . Commit_id . hash commit in let repo = Git . Commit_id . repo commit in let gref = Git . Commit_id . gref commit in ` Assoc [ ( " hash " , ` String hash ) ; ( " repo " , ` String repo ) ; ( " gref " , ` String gref ) ] let of_yojson_exn json = let open Yojson . Safe . Util in let hash = json |> member " hash " |> to_string in let gref = json |> member " gref " |> to_string in let repo = json |> member " repo " |> to_string in Git . Commit_id . v ~ repo ~ gref ~ hash let marshal { voodoo_do ; voodoo_prep ; voodoo_gen } = ` Assoc [ ( " do " , to_yojson voodoo_do ) ; ( " prep " , to_yojson voodoo_prep ) ; ( " gen " , to_yojson voodoo_gen ) ; ] |> Yojson . Safe . to_string let unmarshal t = let json = Yojson . Safe . from_string t in let open Yojson . Safe . Util in let voodoo_do = json |> member " do " |> of_yojson_exn in let voodoo_prep = json |> member " prep " |> of_yojson_exn in let voodoo_gen = json |> member " gen " |> of_yojson_exn in { voodoo_do ; voodoo_prep ; voodoo_gen } end let voodoo_prep_paths = Fpath . [ v " voodoo - prep . opam " ; v " src / voodoo - prep " / ] let voodoo_do_paths = Fpath . [ v " voodoo - do . opam " ; v " voodoo - lib . opam " ; v " src / voodoo - do " ; / v " src / voodoo " / ] let voodoo_gen_paths = Fpath . [ v " voodoo - gen . opam " ; v " src / voodoo - gen " ; / v " src / voodoo " ; / v " src / voodoo - web " / ] let get_oldest_commit_for ~ job ~ dir ~ from paths = let paths = List . map Fpath . to_string paths in let cmd = " git " :: " log " :: " - n " :: " 1 " :: " -- format = format :% H " :: from :: " " -- :: paths in let cmd = ( " " , Array . of_list cmd ) in Current . Process . check_output ~ cwd : dir ~ job ~ cancellable : false cmd |> Lwt_result . map String . trim let with_hash ~ id hash = Git . Commit_id . v ~ repo ( : Git . Commit_id . repo id ) ~ gref ( : Git . Commit_id . gref id ) ~ hash let build No_context job commit = let open Lwt . Syntax in let ( let ** ) = Lwt_result . bind in let * ( ) = Current . Job . start ~ level : Harmless job in Git . with_checkout ~ job commit @@ fun dir -> let id = Git . Commit . id commit in let from = Git . Commit_id . hash id in let ** voodoo_prep = get_oldest_commit_for ~ job ~ dir ~ from voodoo_prep_paths in let ** voodoo_do = get_oldest_commit_for ~ job ~ dir ~ from voodoo_do_paths in let ** voodoo_gen = get_oldest_commit_for ~ job ~ dir ~ from voodoo_gen_paths in Current . Job . log job " Prep commit : % s " voodoo_prep ; Current . Job . log job " Do commit : % s " voodoo_do ; Current . Job . log job " Gen commit : % s " voodoo_gen ; let voodoo_prep = with_hash ~ id voodoo_prep in let voodoo_do = with_hash ~ id voodoo_do in let voodoo_gen = with_hash ~ id voodoo_gen in Lwt . return_ok { voodoo_prep ; voodoo_do ; voodoo_gen } end |
module VoodooCache = Current_cache . Make ( Op ) |
let v ( ) = let daily = Current_cache . Schedule . v ~ valid_for ( : Duration . of_day 1 ) ( ) in let git = Git . clone ~ schedule : daily ~ gref " : main " " https :// github . com / ocaml - doc / voodoo . git " in let open Current . Syntax in Current . component " voodoo " |> let > git = git in VoodooCache . get No_context git |
type t = { voodoo_do : Git . Commit_id . t ; voodoo_prep : Git . Commit_id . t ; voodoo_gen : Git . Commit_id . t ; config : Config . t ; } |
let v config = let open Current . Syntax in let + { voodoo_do ; voodoo_prep ; voodoo_gen } = v ( ) in { voodoo_do ; voodoo_prep ; voodoo_gen ; config } |
let remote_uri commit = let repo = Git . Commit_id . repo commit in let commit = Git . Commit_id . hash commit in repo ^ " " # ^ commit |
let digest t = let key = Fmt . str " % s \ n % s \ n % s \ n % s \ n " ( Git . Commit_id . hash t . voodoo_prep ) ( Git . Commit_id . hash t . voodoo_do ) ( Git . Commit_id . hash t . voodoo_gen ) ( Config . odoc t . config ) in Digest . ( string key |> to_hex ) |
module Prep = struct type voodoo = t type t = Git . Commit_id . t let v { voodoo_prep ; _ } = voodoo_prep let spec ~ base t = let open Obuilder_spec in base |> Spec . add [ run ~ network " sudo apt - get update && sudo apt - get install - yy m4 pkg - config " ; run ~ network ~ cache " opam pin - ny % s && opam depext - iy voodoo - prep " ( remote_uri t ) ; run " cp ( $ opam config var bin ) / voodoo - prep / home / opam " ; ] let digest = Git . Commit_id . hash let commit = Fun . id end |
module Do = struct type voodoo = t type t = { commit : Git . Commit_id . t ; config : Config . t } let v { voodoo_do ; config ; _ } = { commit = voodoo_do ; config } let spec ~ base t = let open Obuilder_spec in base |> Spec . add [ run ~ network " sudo apt - get update && sudo apt - get install - yy m4 " ; run ~ network ~ cache " opam pin - ny odoc % s && opam depext - iy odoc && opam exec -- odoc -- version " ( Config . odoc t . config ) ; run ~ network ~ cache " opam pin - ny % s && opam depext - iy voodoo - do " ( remote_uri t . commit ) ; run " cp ( $ opam config var bin ) / odoc ( $ opam config var bin ) / voodoo - do / home / opam " ; ] let digest t = Git . Commit_id . hash t . commit ^ Config . odoc t . config let commit t = t . commit end |
module Gen = struct type voodoo = t type t = { commit : Git . Commit_id . t ; config : Config . t } let v { voodoo_gen ; config ; _ } = { commit = voodoo_gen ; config } let spec ~ base t = let open Obuilder_spec in base |> Spec . add [ run ~ network " sudo apt - get update && sudo apt - get install - yy m4 && opam repo set - url default \ https :// github . com / ocaml / opam - repository . git # c1ab98721ec2efc4c65d0c5a65a85c826925db6c " ; run ~ network ~ cache " opam pin - ny odoc % s && opam depext - iy odoc && opam exec -- odoc -- version " ( Config . odoc t . config ) ; run ~ network ~ cache " opam pin - ny % s && opam depext - iy voodoo - gen " ( remote_uri t . commit ) ; run " cp ( $ opam config var bin ) / odoc ( $ opam config var bin ) / voodoo - gen / home / opam " ; ] let digest t = Git . Commit_id . hash t . commit ^ Config . odoc t . config let commit t = t . commit end |
type ballot = Yay | Nay | Pass |
let ballot_encoding = let of_int8 = function | 0 -> Yay | 1 -> Nay | 2 -> Pass | _ -> invalid_arg " ballot_of_int8 " in let to_int8 = function | Yay -> 0 | Nay -> 1 | Pass -> 2 in let open Data_encoding in splitted ~ binary : ( conv to_int8 of_int8 int8 ) ~ json : ( string_enum [ " yay " , Yay ; " nay " , Nay ; " pass " , Pass ; ] ) |
let recorded_proposal_count_for_delegate ctxt proposer = Storage . Vote . Proposals_count . find ctxt proposer >|=? Option . value ~ default : 0 |
let record_proposal ctxt proposal proposer = recorded_proposal_count_for_delegate ctxt proposer >>=? fun count -> Storage . Vote . Proposals_count . add ctxt proposer ( count + 1 ) >>= fun ctxt -> Storage . Vote . Proposals . add ctxt ( proposal , proposer ) >|= ok |
let get_proposals ctxt = Storage . Vote . Proposals . fold ctxt ~ order ` : Sorted ~ init ( : ok Protocol_hash . Map . empty ) ~ f ( : fun ( proposal , delegate ) acc -> Storage . Vote . Listings . get ctxt delegate >>=? fun weight -> Lwt . return ( acc >|? fun acc -> let previous = match Protocol_hash . Map . find proposal acc with | None -> 0L | Some x -> x in Protocol_hash . Map . add proposal ( Int64 . add weight previous ) acc ) ) |
let clear_proposals ctxt = Storage . Vote . Proposals_count . clear ctxt >>= fun ctxt -> Storage . Vote . Proposals . clear ctxt |
type ballots = { yay : int64 ; nay : int64 ; pass : int64 } |
let ballots_encoding = let open Data_encoding in conv ( fun { yay ; nay ; pass } -> ( yay , nay , pass ) ) ( fun ( yay , nay , pass ) -> { yay ; nay ; pass } ) @@ obj3 ( req " yay " int64 ) ( req " nay " int64 ) ( req " pass " int64 ) |
let get_ballots ctxt = Storage . Vote . Ballots . fold ctxt ~ order ` : Sorted ~ f ( : fun delegate ballot ( ballots : ballots tzresult ) -> Storage . Vote . Listings . get ctxt delegate >>=? fun weight -> let count = Int64 . add weight in Lwt . return ( ballots >|? fun ballots -> match ballot with | Yay -> { ballots with yay = count ballots . yay } | Nay -> { ballots with nay = count ballots . nay } | Pass -> { ballots with pass = count ballots . pass } ) ) ~ init ( : ok { yay = 0L ; nay = 0L ; pass = 0L } ) |
let listings_encoding = Data_encoding . ( list ( obj2 ( req " pkh " Signature . Public_key_hash . encoding ) ( req " voting_power " int64 ) ) ) |
let update_listings ctxt = Storage . Vote . Listings . clear ctxt >>= fun ctxt -> Stake_storage . fold ctxt ( ctxt , 0L ) ~ order ` : Sorted ~ f ( : fun ( delegate , stake ) ( ctxt , total ) -> let weight = Tez_repr . to_mutez stake in Storage . Vote . Listings . init ctxt delegate weight >>=? fun ctxt -> return ( ctxt , Int64 . add total weight ) ) >>=? fun ( ctxt , total ) -> Storage . Vote . Voting_power_in_listings . add ctxt total >>= fun ctxt -> return ctxt |
let get_voting_power_free ctxt owner = Storage . Vote . Listings . find ctxt owner >|=? Option . value ~ default : 0L |
let get_voting_power ctxt owner = let open Raw_context in consume_gas ctxt ( Storage_costs . read_access ~ path_length : 4 ~ read_bytes : 8 ) >>?= fun ctxt -> Storage . Vote . Listings . find ctxt owner >|=? function | None -> ( ctxt , 0L ) | Some power -> ( ctxt , power ) |
let get_total_voting_power ctxt = let open Raw_context in consume_gas ctxt ( Storage_costs . read_access ~ path_length : 2 ~ read_bytes : 8 ) >>?= fun ctxt -> get_total_voting_power_free ctxt >|=? fun total_voting_power -> ( ctxt , total_voting_power ) |
let get_current_quorum ctxt = Storage . Vote . Participation_ema . get ctxt >|=? fun participation_ema -> let quorum_min = Constants_storage . quorum_min ctxt in let quorum_max = Constants_storage . quorum_max ctxt in let quorum_diff = Int32 . sub quorum_max quorum_min in Int32 . ( add quorum_min ( div ( mul participation_ema quorum_diff ) 100_00l ) ) |
let init ctxt ~ start_position = let participation_ema = Constants_storage . quorum_max ctxt in Storage . Vote . Participation_ema . init ctxt participation_ema >>=? fun ctxt -> Voting_period_storage . init_first_period ctxt ~ start_position |
let test_proto_files = [ " main . ml " ; " main . mli " ] |
let test_proto_TEZOS_PROTOCOL = { { | " modules " : [ " Main " ] , " expected_env_version " : 3 } } | |
type period = { index : int ; kind : string ; start_position : int ; position : int ; remaining : int ; } |
let period_type : period Check . typ = Check . convert ( fun { index ; kind ; start_position ; position ; remaining } -> ( index , kind , start_position , position , remaining ) ) Check . ( tuple5 int string int int int ) |
let decode_period json = let index = JSON . ( json |-> " voting_period " |-> " index " |> as_int ) in let kind = JSON . ( json |-> " voting_period " |-> " kind " |> as_string ) in let start_position = JSON . ( json |-> " voting_period " |-> " start_position " |> as_int ) in let position = JSON . ( json |-> " position " |> as_int ) in let remaining = JSON . ( json |-> " remaining " |> as_int ) in { index ; kind ; start_position ; position ; remaining } |
let get_current_period client = let * json = RPC . Votes . get_current_period client in return ( decode_period json ) |
let get_successor_period client = let * json = RPC . Votes . get_successor_period client in return ( decode_period json ) |
let check_current_period client expected_period = let * period = get_current_period client in Check . ( ( period = expected_period ) period_type ) ~ error_msg " : expected current_period = % R , got % L " ; unit |
let check_successor_period client expected_period = let * period = get_successor_period client in Check . ( ( period = expected_period ) period_type ) ~ error_msg " : expected successor_period = % R , got % L " ; unit |
type level = { level : int ; level_position : int ; cycle : int ; cycle_position : int ; expected_commitment : bool ; } |
let level_type : level Check . typ = Check . convert ( fun { level ; level_position ; cycle ; cycle_position ; expected_commitment } -> ( level , level_position , cycle , cycle_position , expected_commitment ) ) Check . ( tuple5 int int int int bool ) |
let decode_level json = let level = JSON . ( json |-> " level " |> as_int ) in let level_position = JSON . ( json |-> " level_position " |> as_int ) in let cycle = JSON . ( json |-> " cycle " |> as_int ) in let cycle_position = JSON . ( json |-> " cycle_position " |> as_int ) in let expected_commitment = JSON . ( json |-> " expected_commitment " |> as_bool ) in { level ; level_position ; cycle ; cycle_position ; expected_commitment } |
let get_current_level client = let * json = RPC . get_current_level client in return ( decode_level json ) |
let check_current_level client expected_level = let * level = get_current_level client in Check . ( ( level = expected_level ) level_type ) ~ error_msg " : expected current_period = % R , got % L " ; unit |
let get_proposals client = let * proposals = RPC . Votes . get_proposals client in JSON . as_list proposals |> List . map JSON . as_list |> List . map ( function | [ hash ; _ ] -> JSON . as_string hash | _ -> Test . fail " invalid proposal in JSON response : expected a list with 2 items " ) |> return |
let get_current_proposal client = let * proposal = RPC . Votes . get_current_proposal client in if JSON . is_null proposal then return None else return ( Some JSON . ( proposal |> as_string ) ) |
let check_current_proposal client expected_proposal_hash = let * current_proposal = get_current_proposal client in Check . ( ( current_proposal = Some expected_proposal_hash ) ( option string ) ) ~ error_msg " : expected current_proposal = % R , got % L " ; unit |
let get_protocols client = let * block = RPC . get_block_metadata client in return ( JSON . ( block |-> " protocol " |> as_string ) , JSON . ( block |-> " next_protocol " |> as_string ) ) |
let check_protocols client expected_protocols = let * protocols = get_protocols client in Check . ( ( protocols = expected_protocols ) ( tuple2 string string ) ) ~ error_msg " : expected ( protocol , next_protocol ) = % R , got % L " ; unit |
let check_listings_not_empty client = let * listings = RPC . Votes . get_listings client in match JSON . as_list listings with | [ ] -> Test . fail " Expected GET . . . / votes / listing RPC to return a non - empty list " | _ :: _ -> unit |
type target_protocol = Known of Protocol . t | Injected_test |
let target_protocol_tag = function | Known protocol -> Protocol . tag protocol | Injected_test -> " injected_test " |
let register ~ from_protocol ( ~ to_protocol : target_protocol ) ~ loser_protocols = Test . register ~ __FILE__ ~ title : ( sf " amendment : % s -> % s ( losers : % s ) " ( Protocol . tag from_protocol ) ( target_protocol_tag to_protocol ) ( String . concat " , " ( List . map Protocol . tag loser_protocols ) ) ) ~ tags : ( " amendment " :: ( " from_ " ^ Protocol . tag from_protocol ) :: ( " to_ " ^ target_protocol_tag to_protocol ) :: List . map ( fun p -> " loser_ " ^ Protocol . tag p ) loser_protocols @ [ ( match to_protocol with | Known _ -> " known " | Injected_test -> " injected " ) ; ] ) @@ fun ( ) -> let * parameter_file = Protocol . write_parameter_file ~ base ( : Right ( from_protocol , None ) ) [ ( [ " blocks_per_cycle " ] , Some " 8 " ) ; ( [ " blocks_per_voting_period " ] , Some " 4 " ) ; ] in let * node = Node . init [ Synchronisation_threshold 0 ] in let * client = Client . init ~ endpoint ( : Node node ) ( ) in let * ( ) = Client . activate_protocol ~ protocol : from_protocol ~ parameter_file client in let * ( ) = check_current_level client { level = 1 ; level_position = 0 ; cycle = 0 ; cycle_position = 0 ; expected_commitment = false ; } in let * ( ) = check_current_period client { index = 0 ; kind = " proposal " ; start_position = 0 ; position = 0 ; remaining = 3 ; } in let * ( ) = check_successor_period client { index = 0 ; kind = " proposal " ; start_position = 0 ; position = 1 ; remaining = 2 ; } in Log . info " Current period : proposal . " ; let * ( ) = Client . bake_for client in let * ( ) = Client . bake_for client in let * ( ) = check_current_level client { level = 3 ; level_position = 2 ; cycle = 0 ; cycle_position = 2 ; expected_commitment = false ; } in let * ( ) = check_current_period client { index = 0 ; kind = " proposal " ; start_position = 0 ; position = 2 ; remaining = 1 ; } in let * ( ) = Client . bake_for client in let * ( ) = check_current_period client { index = 0 ; kind = " proposal " ; start_position = 0 ; position = 3 ; remaining = 0 ; } in let * proposals = get_proposals client in Check . ( ( proposals = [ ] ) ( list string ) ) ~ error_msg " : expected proposal list to be empty , got % L " ; let * ( ) = check_listings_not_empty client in let * period = Client . show_voting_period client in Check . ( ( period = " proposal " ) string ) ~ error_msg " : expected tezos - client show voting period to return % R , got % L " ; let * to_protocol_hash = match to_protocol with | Known protocol -> return ( Protocol . hash protocol ) | Injected_test -> let protocol_path = Temp . dir " test_proto " in let * ( ) = Process . run " cp " ( List . map ( fun filename -> test_proto_dir // filename ) test_proto_files @ [ protocol_path ] ) in ( with_open_out ( protocol_path // " TEZOS_PROTOCOL " ) @@ fun ch -> output_string ch test_proto_TEZOS_PROTOCOL ) ; let * protocols_before = Client . Admin . list_protocols client in let * test_proto_hash = Client . Admin . inject_protocol client ~ protocol_path in let * protocols_after = Client . Admin . list_protocols client in if List . mem test_proto_hash protocols_before then Test . fail " Test protocol % s was already known , I can ' t test injection with \ it . " test_proto_hash ; if not ( List . mem test_proto_hash protocols_after ) then Test . fail " Test protocol % s is not known even though it was injected \ successfully . " test_proto_hash ; Log . info " Injected : % s " test_proto_hash ; return test_proto_hash in let * ( ) = Client . submit_proposals ~ proto_hashes ( : to_protocol_hash :: List . map Protocol . hash loser_protocols ) client in let * ( ) = Client . bake_for client in let * proposals = get_proposals client in let expected_proposals = to_protocol_hash :: List . map Protocol . hash loser_protocols in let sort = List . sort String . compare in Check . ( ( sort proposals = sort expected_proposals ) ( list string ) ) ~ error_msg " : expected proposals = % R , got % L " ; let * ( ) = Client . submit_proposals ~ key : Constant . bootstrap2 . alias ~ proto_hash : to_protocol_hash client in let * ( ) = Client . bake_for client in let * proposals = get_proposals client in Check . ( ( sort proposals = sort expected_proposals ) ( list string ) ) ~ error_msg " : expected proposals = % R , got % L " ; let * ( ) = Client . bake_for client in let * ( ) = Client . bake_for client in let * ( ) = check_current_level client { level = 8 ; level_position = 7 ; cycle = 0 ; cycle_position = 7 ; expected_commitment = true ; } in let * ( ) = check_current_period client { index = 1 ; kind = " proposal " ; start_position = 4 ; position = 3 ; remaining = 0 ; } in let * ( ) = check_listings_not_empty client in let * ( ) = check_current_proposal client to_protocol_hash in let * ( ) = Client . bake_for client in let * ( ) = check_current_period client { index = 2 ; kind = " exploration " ; start_position = 8 ; position = 0 ; remaining = 3 ; } in let * ( ) = check_current_proposal client to_protocol_hash in Log . info " Current period : exploration , with current proposal : % s . " ( target_protocol_tag to_protocol ) ; let vote ( account : Account . key ) ballot = Client . submit_ballot ~ key : account . alias ~ proto_hash : to_protocol_hash ballot client in let * ( ) = vote Constant . bootstrap1 Yay in let * ( ) = vote Constant . bootstrap2 Yay in let * ( ) = vote Constant . bootstrap3 Yay in let * ( ) = Client . bake_for client in let * ( ) = check_current_level client { level = 10 ; level_position = 9 ; cycle = 1 ; cycle_position = 1 ; expected_commitment = false ; } in let * ( ) = check_current_period client { index = 2 ; kind = " exploration " ; start_position = 8 ; position = 1 ; remaining = 2 ; } in let * ( ) = Client . bake_for client in let * ( ) = Client . bake_for client in let * ( ) = check_current_period client { index = 2 ; kind = " exploration " ; start_position = 8 ; position = 3 ; remaining = 0 ; } in let * ( ) = Client . bake_for client in let * ( ) = check_current_period client { index = 3 ; kind = " cooldown " ; start_position = 12 ; position = 0 ; remaining = 3 ; } in let * current_proposal = get_current_proposal client in Check . ( ( current_proposal = Some to_protocol_hash ) ( option string ) ) ~ error_msg " : expected current_proposal = % R , got % L " ; Log . info " Current period : cooldown , with current proposal : % s . " ( target_protocol_tag to_protocol ) ; let * ( ) = Client . bake_for client in let * ( ) = check_current_level client { level = 14 ; level_position = 13 ; cycle = 1 ; cycle_position = 5 ; expected_commitment = false ; } in let * ( ) = check_current_period client { index = 3 ; kind = " cooldown " ; start_position = 12 ; position = 1 ; remaining = 2 ; } in let * ( ) = Client . bake_for client in let * ( ) = Client . bake_for client in let * ( ) = check_current_period client { index = 3 ; kind = " cooldown " ; start_position = 12 ; position = 3 ; remaining = 0 ; } in let * ( ) = Client . bake_for client in let * ( ) = check_current_period client { index = 4 ; kind = " promotion " ; start_position = 16 ; position = 0 ; remaining = 3 ; } in let * current_proposal = get_current_proposal client in Check . ( ( current_proposal = Some to_protocol_hash ) ( option string ) ) ~ error_msg " : expected current_proposal = % R , got % L " ; Log . info " Current period : promotion , with current proposal : % s . " ( target_protocol_tag to_protocol ) ; let * ( ) = vote Constant . bootstrap1 Yay in let * ( ) = vote Constant . bootstrap2 Yay in let * ( ) = vote Constant . bootstrap3 Yay in let * ( ) = vote Constant . bootstrap4 Yay in let * ( ) = vote Constant . bootstrap5 Nay in let * ( ) = Client . bake_for client in let * ( ) = check_current_level client { level = 18 ; level_position = 17 ; cycle = 2 ; cycle_position = 1 ; expected_commitment = false ; } in let * ( ) = check_current_period client { index = 4 ; kind = " promotion " ; start_position = 16 ; position = 1 ; remaining = 2 ; } in let * ( ) = Client . bake_for client in let * ( ) = Client . bake_for client in let * ( ) = check_current_period client { index = 4 ; kind = " promotion " ; start_position = 16 ; position = 3 ; remaining = 0 ; } in let * ( ) = Client . bake_for client in let * ( ) = check_current_period client { index = 5 ; kind = " adoption " ; start_position = 20 ; position = 0 ; remaining = 3 ; } in let * current_proposal = get_current_proposal client in Check . ( ( current_proposal = Some to_protocol_hash ) ( option string ) ) ~ error_msg " : expected current_proposal = % R , got % L " ; Log . info " Current period : adoption , with current proposal : % s . " ( target_protocol_tag to_protocol ) ; let * ( ) = Client . bake_for client in let * ( ) = check_current_level client { level = 22 ; level_position = 21 ; cycle = 2 ; cycle_position = 5 ; expected_commitment = false ; } in let * ( ) = check_current_period client { index = 5 ; kind = " adoption " ; start_position = 20 ; position = 1 ; remaining = 2 ; } in let * ( ) = Client . bake_for client in let * ( ) = check_protocols client ( Protocol . hash from_protocol , Protocol . hash from_protocol ) in Log . info " Baking last block of adoption period . . . " ; let * ( ) = Client . bake_for client in match to_protocol with | Injected_test -> Log . info " Creating a second node . . . " ; let * node2 = Node . init [ Synchronisation_threshold 1 ] in let check_event_fetching_protocol = Node . wait_for node2 " fetching_protocol . v0 " @@ fun json -> let hash = JSON . ( json |-> " hash " |> as_string ) in if hash = Protocol . hash from_protocol then None else ( Check . ( ( hash = to_protocol_hash ) string ) ~ error_msg " : expected node2 to fetch protocol % R , got % L " ; Log . info " Node 2 is fetching the injected protocol . " ; Some ( ) ) in let check_event_new_protocol_initialisation = Node . wait_for node2 " new_protocol_initialisation . v0 " @@ fun json -> let hash = JSON . as_string json in if hash = Protocol . hash from_protocol then None else ( Check . ( ( hash = to_protocol_hash ) string ) ~ error_msg " : expected node2 to initialize protocol % R , got % L " ; Log . info " Node 2 initialized the injected protocol . " ; Some ( ) ) in let check_event_update_protocol_table = Node . wait_for node2 " update_protocol_table . v0 " @@ fun json -> let proto_hash = JSON . ( json |-> " proto_hash " |> as_string ) in if proto_hash = Protocol . hash from_protocol then None else let proto_level = JSON . ( json |-> " proto_level " |> as_int ) in Check . ( ( ( proto_hash , proto_level ) = ( to_protocol_hash , 2 ) ) ( tuple2 string int ) ) ~ error_msg : " expected node 2 to update its protocol table with % R , got % L " ; Log . info " Node 2 updated its protocol table with the injected protocol . " ; Some ( ) in let * ( ) = Client . Admin . connect_address ~ peer : node2 client in Log . info " Node 2 initialized and connected to node1 , waiting for it to sync . . . " ; let * level = Node . wait_for_level node2 ( Node . get_level node ) in Log . info " Both nodes are at level % d . " level ; let all_checks = let * ( ) = check_event_fetching_protocol and * ( ) = check_event_new_protocol_initialisation and * ( ) = check_event_update_protocol_table in unit in let timeout = let * ( ) = Lwt_unix . sleep 60 . in Test . fail " timeout while waiting for fetching_protocol , \ new_protocol_initialisation , or update_protocol_table " in let * ( ) = Lwt . pick [ all_checks ; timeout ] in unit | Known _ -> let * ( ) = check_current_period client { index = 5 ; kind = " adoption " ; start_position = 20 ; position = 3 ; remaining = 0 ; } in let * ( ) = check_protocols client ( Protocol . hash from_protocol , to_protocol_hash ) in Log . info " Current period : adoption , with next protocol : % s . " ( target_protocol_tag to_protocol ) ; Log . info " Baking transition block . . . " ; let everybody = List . map ( fun x -> x . Account . public_key_hash ) Constant . bootstrap_keys in let * ( ) = Client . bake_for ~ keys : everybody client in let * ( ) = check_current_period client { index = 6 ; kind = " proposal " ; start_position = 24 ; position = 0 ; remaining = 3 ; } in let * ( ) = check_protocols client ( to_protocol_hash , to_protocol_hash ) in Log . info " Current period : proposal , with protocol : % s . " ( target_protocol_tag to_protocol ) ; let * ( ) = Client . bake_for ~ keys : everybody client in let * ( ) = check_current_period client { index = 6 ; kind = " proposal " ; start_position = 24 ; position = 1 ; remaining = 2 ; } in check_protocols client ( to_protocol_hash , to_protocol_hash ) |
type kind = Proposal | Exploration | Cooldown | Promotion | Adoption |
let string_of_kind = function | Proposal -> " proposal " | Exploration -> " exploration " | Cooldown -> " cooldown " | Promotion -> " promotion " | Adoption -> " adoption " |
let pp_kind ppf kind = Format . fprintf ppf " % s " @@ string_of_kind kind |
let kind_encoding = let open Data_encoding in union ~ tag_size ` : Uint8 [ case ( Tag 0 ) ~ title " : Proposal " ( constant " proposal " ) ( function Proposal -> Some ( ) | _ -> None ) ( fun ( ) -> Proposal ) ; case ( Tag 1 ) ~ title " : exploration " ( constant " exploration " ) ( function Exploration -> Some ( ) | _ -> None ) ( fun ( ) -> Exploration ) ; case ( Tag 2 ) ~ title " : Cooldown " ( constant " cooldown " ) ( function Cooldown -> Some ( ) | _ -> None ) ( fun ( ) -> Cooldown ) ; case ( Tag 3 ) ~ title " : Promotion " ( constant " promotion " ) ( function Promotion -> Some ( ) | _ -> None ) ( fun ( ) -> Promotion ) ; case ( Tag 4 ) ~ title " : Adoption " ( constant " adoption " ) ( function Adoption -> Some ( ) | _ -> None ) ( fun ( ) -> Adoption ) ; ] |
let succ_kind = function | Proposal -> Exploration | Exploration -> Cooldown | Cooldown -> Promotion | Promotion -> Adoption | Adoption -> Proposal |
type voting_period = { index : int32 ; kind : kind ; start_position : int32 } |
type info = { voting_period : t ; position : int32 ; remaining : int32 } |
let root ~ start_position = { index = 0l ; kind = Proposal ; start_position } |
let pp ppf { index ; kind ; start_position } = Format . fprintf ppf " [ @< hv 2 > index : % ld , @ kind :% a , @ start_position : % ld ] " @ index pp_kind kind start_position |
let pp_info ppf { voting_period ; position ; remaining } = Format . fprintf ppf " [ @< hv 2 > voting_period : % a , @ position :% ld , @ remaining : % ld ] " @ pp voting_period position remaining |
let encoding = let open Data_encoding in conv ( fun { index ; kind ; start_position } -> ( index , kind , start_position ) ) ( fun ( index , kind , start_position ) -> { index ; kind ; start_position } ) ( obj3 ( req " index " ~ description : " The voting period ' s index . Starts at 0 with the first block of \ the Alpha family of protocols . " int32 ) ( req ~ description : " One of the several kinds of periods in the voting procedure . " " kind " kind_encoding ) ( req ~ description : " The relative position of the first level of the period with \ respect to the first level of the Alpha family of protocols . " " start_position " int32 ) ) |
let info_encoding = let open Data_encoding in conv ( fun { voting_period ; position ; remaining } -> ( voting_period , position , remaining ) ) ( fun ( voting_period , position , remaining ) -> { voting_period ; position ; remaining } ) ( obj3 ( req ~ description " : The voting period to which the block belongs . " " voting_period " encoding ) ( req ~ description " : The position of the block within the voting period . " " position " int32 ) ( req ~ description : " The number of blocks remaining till the end of the voting period . " " remaining " int32 ) ) type nonrec t = t let compare p p ' = Compare . Int32 . compare p . index p ' . index end ) |
let raw_reset period ~ start_position = let index = Int32 . succ period . index in let kind = Proposal in { index ; kind ; start_position } |
let raw_succ period ~ start_position = let index = Int32 . succ period . index in let kind = succ_kind period . kind in { index ; kind ; start_position } |
let position_since ( level : Level_repr . t ) ( voting_period : t ) = Int32 . ( sub level . level_position voting_period . start_position ) |
let remaining_blocks ( level : Level_repr . t ) ( voting_period : t ) ~ blocks_per_voting_period = let position = position_since level voting_period in Int32 . ( sub blocks_per_voting_period ( succ position ) ) |
let init_first_period ctxt ~ start_position = init ctxt @@ Voting_period_repr . root ~ start_position >>=? fun ctxt -> Storage . Vote . Pred_period_kind . init ctxt Voting_period_repr . Proposal |
let common ctxt = get_current ctxt >>=? fun current_period -> Storage . Vote . Pred_period_kind . update ctxt current_period . kind >|=? fun ctxt -> let start_position = Int32 . succ ( Level_storage . current ctxt ) . level_position in ( ctxt , current_period , start_position ) |
let reset ctxt = common ctxt >>=? fun ( ctxt , current_period , start_position ) -> Voting_period_repr . raw_reset current_period ~ start_position |> set_current ctxt |
let succ ctxt = common ctxt >>=? fun ( ctxt , current_period , start_position ) -> Voting_period_repr . raw_succ current_period ~ start_position |> set_current ctxt |
let get_current_kind ctxt = get_current ctxt >|=? fun { kind ; _ } -> kind |
let get_current_info ctxt = get_current ctxt >|=? fun voting_period -> let blocks_per_voting_period = Constants_storage . blocks_per_voting_period ctxt in let level = Level_storage . current ctxt in let position = Voting_period_repr . position_since level voting_period in let remaining = Voting_period_repr . remaining_blocks level voting_period ~ blocks_per_voting_period in Voting_period_repr . { voting_period ; position ; remaining } |
let get_current_remaining ctxt = get_current ctxt >|=? fun voting_period -> let blocks_per_voting_period = Constants_storage . blocks_per_voting_period ctxt in Voting_period_repr . remaining_blocks ( Level_storage . current ctxt ) voting_period ~ blocks_per_voting_period |
let is_last_block ctxt = get_current_remaining ctxt >|=? fun remaining -> Compare . Int32 . ( remaining = 0l ) |
let get_rpc_current_info ctxt = get_current_info ctxt >>=? fun ( { voting_period ; position ; _ } as voting_period_info ) -> if Compare . Int32 . ( position = Int32 . minus_one ) then let level = Level_storage . current ctxt in let blocks_per_voting_period = Constants_storage . blocks_per_voting_period ctxt in Storage . Vote . Pred_period_kind . get ctxt >|=? fun pred_kind -> let voting_period : Voting_period_repr . t = { index = Int32 . pred voting_period . index ; kind = pred_kind ; start_position = Int32 . ( sub voting_period . start_position blocks_per_voting_period ) ; } in let position = Voting_period_repr . position_since level voting_period in let remaining = Voting_period_repr . remaining_blocks level voting_period ~ blocks_per_voting_period in ( { voting_period ; remaining ; position } : Voting_period_repr . info ) else return voting_period_info |
let get_rpc_succ_info ctxt = Level_storage . from_raw_with_offset ctxt ~ offset : 1l ( Level_storage . current ctxt ) . level >>?= fun level -> get_current ctxt >|=? fun voting_period -> let blocks_per_voting_period = Constants_storage . blocks_per_voting_period ctxt in let position = Voting_period_repr . position_since level voting_period in let remaining = Voting_period_repr . remaining_blocks level voting_period ~ blocks_per_voting_period in Voting_period_repr . { voting_period ; position ; remaining } |
module S = struct let path = RPC_path . ( open_root / " votes " ) let ballots = RPC_service . get_service ~ description " : Sum of ballots casted so far during a voting period . " ~ query : RPC_query . empty ~ output : Vote . ballots_encoding RPC_path . ( path / " ballots " ) let ballot_list = RPC_service . get_service ~ description " : Ballots casted so far during a voting period . " ~ query : RPC_query . empty ~ output : Data_encoding . ( list ( obj2 ( req " pkh " Signature . Public_key_hash . encoding ) ( req " ballot " Vote . ballot_encoding ) ) ) RPC_path . ( path / " ballot_list " ) let current_period = RPC_service . get_service ~ description : " Returns the voting period ( index , kind , starting position ) and \ related information ( position , remaining ) of the interrogated block . " ~ query : RPC_query . empty ~ output : Voting_period . info_encoding RPC_path . ( path / " current_period " ) let successor_period = RPC_service . get_service ~ description : " Returns the voting period ( index , kind , starting position ) and \ related information ( position , remaining ) of the next block . Useful to \ craft operations that will be valid in the next block . " ~ query : RPC_query . empty ~ output : Voting_period . info_encoding RPC_path . ( path / " successor_period " ) let current_quorum = RPC_service . get_service ~ description " : Current expected quorum . " ~ query : RPC_query . empty ~ output : Data_encoding . int32 RPC_path . ( path / " current_quorum " ) let listings = RPC_service . get_service ~ description " : List of delegates with their voting power . " ~ query : RPC_query . empty ~ output : Vote . listings_encoding RPC_path . ( path / " listings " ) let proposals = RPC_service . get_service ~ description " : List of proposals with number of supporters . " ~ query : RPC_query . empty ~ output ( : Protocol_hash . Map . encoding Data_encoding . int64 ) RPC_path . ( path / " proposals " ) let current_proposal = RPC_service . get_service ~ description " : Current proposal under evaluation . " ~ query : RPC_query . empty ~ output ( : Data_encoding . option Protocol_hash . encoding ) RPC_path . ( path / " current_proposal " ) let total_voting_power = RPC_service . get_service ~ description " : Total voting power in the voting listings . " ~ query : RPC_query . empty ~ output : Data_encoding . int64 RPC_path . ( path / " total_voting_power " ) end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.