text stringlengths 0 601k |
|---|
module Info = struct [ %% versioned module Stable = struct [ @@@ no_toplevel_latest_type ] no_toplevel_latest_type module V2 = struct type t = { statements : Statement . Stable . V2 . t ; work_ids : int One_or_two . Stable . V1 . t ; fee : Fee . Stable . V1 . t ; prover : Public_key . Compressed . Stable . V1 . t } [ @... |
module T = struct [ %% versioned module Stable = struct [ @@@ no_toplevel_latest_type ] no_toplevel_latest_type module V2 = struct type t = { fee : Fee . Stable . V1 . t ; proofs : Ledger_proof . Stable . V2 . t One_or_two . Stable . V1 . t ; prover : Public_key . Compressed . Stable . V1 . t } [ @@ deriving compare , ... |
module Checked = struct include T let create_unsafe = Fn . id end |
let fee { fee ; _ } = fee |
module Failure = struct [ %% versioned module Stable = struct module V2 = struct type t = | Predicate [ @ value 1 ] 1 | Source_not_present | Receiver_not_present | Amount_insufficient_to_create_account | Cannot_pay_creation_fee_in_token | Source_insufficient_balance | Source_minimum_balance_violation | Receiver_already... |
module Stable = struct module V2 = struct type t = Applied | Failed of Failure . Collection . Stable . V1 . t [ @@ deriving sexp , yojson , equal , compare ] compare let to_latest = Fn . id end end ] end |
let state_body_hash = U . genesis_state_body_hash ( module struct module Ledger = struct include Ledger let merkle_root t = Frozen_ledger_hash . of_ledger_hash @@ merkle_root t let merkle_root_after_user_command_exn t ~ txn_global_slot txn = let hash = merkle_root_after_user_command_exn ~ constraint_constants : U . con... |
module Body = struct type ( ' tag , ' public_key , ' token_id , ' amount , ' bool ) ' bool t_ = { tag : ' tag ; source_pk : ' public_key ; receiver_pk : ' public_key ; token_id : ' token_id ; amount : ' amount ; token_locked : ' bool } [ @@ deriving sexp , hlist ] hlist type t = ( Tag . t , Public_key . Compressed . t ... |
module Payload_common = struct module Poly = struct type ( ' fee , ' public_key , ' token_id , ' nonce , ' global_slot , ' memo ) ' memo t = { fee : ' fee ; fee_token : ' token_id ; fee_payer_pk : ' public_key ; nonce : ' nonce ; valid_until : ' global_slot ; memo : ' memo } [ @@ deriving sexp , hlist ] hlist end let t... |
type t = ( Payload_common . t , Body . t ) t Signed_command_payload . Poly . t |
type payload = t [ @@ deriving sexp ] sexp |
let of_user_command_payload ( { common = { memo ; fee ; fee_payer_pk ; nonce ; valid_until } ; body } : Signed_command_payload . t ) : t = { common = { fee ; fee_token = Token_id . default ; fee_payer_pk ; nonce ; valid_until ; memo } ; body = Body . of_user_command_payload_body body } |
let gen = let open Quickcheck . Generator . Let_syntax in let % bind common = Signed_command_payload . Common . gen in let % map body = Body . gen ~ fee : common . fee in Signed_command_payload . Poly { . common ; body } |
type var = ( Payload_common . Checked . t , Body . var ) var Signed_command_payload . Poly . t |
let typ : ( var , t ) t Typ . t = let to_hlist = Signed_command_payload . Poly . to_hlist in let of_hlist = Signed_command_payload . Poly . of_hlist in Typ . of_hlistable [ Payload_common . typ ; Body . typ ] ~ var_to_hlist : to_hlist ~ var_of_hlist : of_hlist ~ value_to_hlist : to_hlist ~ value_of_hlist : of_hlist |
module Checked = struct let to_input_legacy ( { common ; body } : var ) var = let % map common = Signed_command_payload . Common . Checked . to_input_legacy ( Payload_common . to_signed_command_payload_common common ) common and body = Body . Checked . to_input_legacy body in Random_oracle . Input . Legacy . append com... |
let to_input_legacy ( { common ; body } : t ) t = Random_oracle . Input . Legacy . append ( Signed_command_payload . Common . to_input_legacy ( Payload_common . to_signed_command_payload_common common ) common ) ( Body . to_input_legacy body ) body |
let excess ( payload : t ) t : Amount . Signed . t = let tag = payload . body . tag in let fee = payload . common . fee in let amount = payload . body . amount in match tag with | Payment | Stake_delegation | Create_account | Mint_tokens -> Amount . Signed . of_unsigned ( Amount . of_fee fee ) fee | Fee_transfer -> Opt... |
let fee_excess ( { body = { tag ; amount ; _ } ; common = { fee ; _ } } : t ) t = match tag with | Payment | Stake_delegation | Create_account | Mint_tokens -> Fee_excess . of_single ( Token_id . default , Fee . Signed . of_unsigned fee ) fee | Fee_transfer -> let excess = Option . value_exn ( Amount . add_fee amount f... |
let supply_increase ( payload : payload ) payload = let tag = payload . body . tag in match tag with | Coinbase -> payload . body . amount | Payment | Stake_delegation | Create_account | Mint_tokens | Fee_transfer -> Amount . zero |
type t = | Payment | Stake_delegation | Create_account | Mint_tokens | Fee_transfer | Coinbase |
let to_string = function | Payment -> " payment " | Stake_delegation -> " delegation " | Create_account -> " create_account " | Mint_tokens -> " mint_tokens " | Fee_transfer -> " fee - transfer " | Coinbase -> " coinbase " |
let gen = Quickcheck . Generator . map ( Int . gen_incl min max ) max ~ f ( : fun i -> Option . value_exn ( of_enum i ) i ) |
module Bits = struct type t = bool * bool * bool [ @@ deriving equal ] equal let of_int i : t = let test_mask mask = i land mask = mask in ( test_mask 0b100 , test_mask 0b10 , test_mask 0b1 ) 0b1 let of_t x = of_int ( to_enum x ) x let payment = of_t Payment let stake_delegation = of_t Stake_delegation let create_accou... |
module Unpacked = struct module Poly = struct type ' bool t = { is_payment : ' bool ; is_stake_delegation : ' bool ; is_create_account : ' bool ; is_mint_tokens : ' bool ; is_fee_transfer : ' bool ; is_coinbase : ' bool ; is_user_command : ' bool } [ @@ deriving equal , hlist ] hlist [ %% ifdef consensus_mechanism ] co... |
let unpacked_t_of_t = function | Payment -> Unpacked . payment | Stake_delegation -> Unpacked . stake_delegation | Create_account -> Unpacked . create_account | Mint_tokens -> Unpacked . mint_tokens | Fee_transfer -> Unpacked . fee_transfer | Coinbase -> Unpacked . coinbase |
let to_bits tag = Bits . to_bits ( Unpacked . to_bits_t ( unpacked_t_of_t tag ) tag ) tag |
let to_input_legacy tag = Random_oracle . Input . Legacy . bitstring ( to_bits tag ) tag |
let t_of_unpacked_t ( unpacked : Unpacked . t ) t : t = match List . Assoc . find ~ equal : Unpacked . equal [ ( Unpacked . payment , Payment ) Payment ; ( Unpacked . stake_delegation , Stake_delegation ) Stake_delegation ; ( Unpacked . create_account , Create_account ) Create_account ; ( Unpacked . mint_tokens , Mint_... |
let bits_t_of_t tag = Unpacked . to_bits_t ( unpacked_t_of_t tag ) tag |
let t_of_bits_t tag = t_of_unpacked_t ( Unpacked . of_bits_t tag ) tag |
let unpacked_of_t tag = Unpacked . constant ( unpacked_t_of_t tag ) tag |
let bits_of_t tag = Bits . constant ( bits_t_of_t tag ) tag |
let unpacked_typ = Typ . transport Unpacked . typ ~ there : unpacked_t_of_t ~ back : t_of_unpacked_t |
let bits_typ = Typ . transport Bits . typ ~ there : bits_t_of_t ~ back : t_of_bits_t ( module struct let test_predicate checked unchecked = let checked x = Checked . return ( checked x ) x in for i = min to max do Test_util . test_equal unpacked_typ Boolean . typ checked unchecked ( Option . value_exn ( of_enum i ) i )... |
module Hashless_ledger = struct type t = { base : Ledger . t ; overlay : ( Account . Identifier . t , Account . t ) t Hashtbl . t } type location = Ours of Account . Identifier . t | Theirs of Ledger . Location . t let msg s = s ^ " : somehow we got a location that isn ' t present in the underlying ledger " let get t =... |
let apply_user_command ~ constraint_constants ~ txn_global_slot l uc = Result . map ~ f ( : fun applied_txn -> applied_txn . Transaction_applied . Signed_command_applied . common . user_command . status ) ( apply_user_command l ~ constraint_constants ~ txn_global_slot uc ) uc |
let apply_transaction ' ~ constraint_constants ~ txn_state_view l t = O1trace . sync_thread " apply_transaction " ( fun ( ) -> apply_transaction ~ constraint_constants ~ txn_state_view l t ) |
let apply_transaction ~ constraint_constants ~ txn_state_view l txn = Result . map ~ f : Transaction_applied . user_command_status ( apply_transaction ' l ~ constraint_constants ~ txn_state_view txn ) txn |
module Parties_segment_witness = struct open Mina_base open Mina_ledger open Currency [ %% versioned module Stable = struct module V1 = struct type t = { global_ledger : Sparse_ledger . Stable . V2 . t ; local_state_init : ( ( Token_id . Stable . V1 . t , unit Parties . Call_forest . With_hashes . Stable . V1 . t ) Sta... |
module Stable = struct module V2 = struct type t = { transaction : Mina_transaction . Transaction . Stable . V2 . t ; ledger : Mina_ledger . Sparse_ledger . Stable . V2 . t ; protocol_state_body : Mina_state . Protocol_state . Body . Value . Stable . V2 . t ; init_stack : Mina_base . Pending_coinbase . Stack_versioned ... |
let transfer_and_check_balances ( ? with_burn = false ) ~ loc b ( ? fee = Tez . zero ) ? expect_failure src dst amount = let open Lwt_tzresult_syntax in let *? amount_fee = fee +? amount in let * bal_src = Context . Contract . balance ( I b ) src in let * bal_dst = Context . Contract . balance ( I b ) dst in let * op =... |
let n_transactions n b ? fee source dest amount = List . fold_left_es ( fun b _ -> transfer_and_check_balances ~ loc : __LOC__ b ? fee source dest amount >|=? fun ( b , _ ) -> b ) b ( 1 -- n ) |
module Make ( IO : S . IO ) = struct open IO type reader = unit -> Transfer . chunk IO . t type writer = string -> unit IO . t module Chunked = struct let remaining_length chunk remaining = let read_len = Int64 . of_int ( String . length chunk ) in Int64 . sub remaining read_len let read_chunk ic size = let max_read_le... |
module type Transformer = sig type t val transform_expression_children : t -> Expression . t -> bool val expression : t -> Expression . t -> Expression . t val transform_children : t -> Statement . t -> t * bool val statement : t -> Statement . t -> t * Statement . t list end |
module type StatementTransformer = sig type t val statement : t -> Statement . t -> t * Statement . t list end |
module Identity : sig val transform_expression_children : ' t -> Expression . t -> bool val expression : ' t -> Expression . t -> Expression . t val transform_children : ' t -> Statement . t -> ' t * bool val statement : ' t -> Statement . t -> ' t * Statement . t list let transform_expression_children _ _ = true let e... |
module Make ( Transformer : Transformer ) = struct type result = { state : Transformer . t ; source : Source . t ; } let source { source ; _ } = source let transform state source = let state = ref state in let transform_list list ~ f = let accumulate list element = f element :: list in List . fold_left list ~ f : accum... |
module MakeStatementTransformer ( Transformer : StatementTransformer ) = struct type result = { state : Transformer . t ; source : Source . t ; } let source { source ; _ } = source let transform state source = let state = ref state in let open Statement in let rec transform_statement { Node . location ; value } = let v... |
let transform_expressions ~ transform statement = let module TransformExpressions = Make ( struct type t = unit let transform_expression_children _ _ = true let expression _ { Node . value ; location } = { Node . value = transform value ; location } let transform_children state _ = state , true let statement state stat... |
let sanitize_expression expression = let transform = function | Expression . Name ( Name . Identifier identifier ) -> Expression . Name ( Name . Identifier ( Identifier . sanitized identifier ) ) | Name ( Name . Attribute ( { attribute ; _ } as attribute_expression ) ) -> Name ( Name . Attribute { attribute_expression ... |
let sanitize_statement statement = let module SanitizeSignatures = MakeStatementTransformer ( struct type t = unit let statement state = function | { Node . value = Statement . Define ( { Define . signature = { Define . Signature . name ; parameters ; _ } as signature ; _ } as define ) ; _ ; } as statement -> let trans... |
module Toc = struct open Tyxml type t = heading list and heading = H of int * string let to_string ( H ( size , text ) ) = " H " ^ string_of_int size ^ " " ^ text let get_int = function H ( i , _ ) -> i let toc doc = let open Omd in let rec loop acc = function | [ ] -> List . rev acc | ( b : attributes block ) :: bs ->... |
module Image = struct type t = { conf : Image . Transform . conf ; path : Fpath . t ; responsive : Responsive . Images . t ; } let v ~ quality ~ path ~ dst responsive = { conf = Image . Transform . { quality ; dst ; rename = Fun . id ; files = [ ] } ; path ; responsive ; } let transform t blocks = let open Omd in let f... |
module ModifyingTransformer : sig type t = int include Transform . Transformer with type t := t val final : t -> int include Transform . Identity type t = int let final count = count let expression _ = function | { Node . location ; value = Expression . Constant ( Constant . Integer number ) } -> { Node . location ; va... |
module ShallowModifyingTransformer : sig type t = int include Transform . Transformer with type t := t include Transform . Identity include ModifyingTransformer let transform_children state _ = state , false end |
module ModifyingTransform = Transform . Make ( ModifyingTransformer ) |
module ShallowModifyingTransform = Transform . Make ( ShallowModifyingTransformer ) |
let assert_modifying_source ( ? shallow = false ) statements expected_statements expected_sum = let state , modified = if shallow then let { ShallowModifyingTransform . state ; source } = ShallowModifyingTransform . transform 0 ( Source . create statements ) in state , source else let { ModifyingTransform . state ; sou... |
let test_transform _ = assert_modifying_source [ + Statement . Expression ( + Expression . Constant ( Constant . Integer 1 ) ) ; + Statement . Expression ( + Expression . Constant ( Constant . Integer 2 ) ) ; ] [ + Statement . Expression ( + Expression . Constant ( Constant . Integer 2 ) ) ; + Statement . Expression ( ... |
module ExpandingTransformer : sig type t = unit include Transform . Transformer with type t := t include Transform . Identity type t = unit let statement state statement = state , [ statement ; statement ] end |
module ShallowExpandingTransformer : sig type t = unit include Transform . Transformer with type t := t include Transform . Identity include ExpandingTransformer let transform_children state _ = state , false end |
module ExpandingTransform = Transform . Make ( ExpandingTransformer ) |
module ShallowExpandingTransform = Transform . Make ( ShallowExpandingTransformer ) |
let assert_expanded_source ( ? shallow = false ) statements expected_statements = let modified = if shallow then ShallowExpandingTransform . transform ( ) ( Source . create statements ) |> ShallowExpandingTransform . source else ExpandingTransform . transform ( ) ( Source . create statements ) |> ExpandingTransform . s... |
let test_expansion _ = assert_expanded_source [ + Statement . Expression ( + Expression . Constant ( Constant . Float 1 . 0 ) ) ; + Statement . Expression ( + Expression . Constant ( Constant . Float 2 . 0 ) ) ; ] [ + Statement . Expression ( + Expression . Constant ( Constant . Float 1 . 0 ) ) ; + Statement . Expressi... |
let test_expansion_with_stop _ = let module StoppingExpandingTransformer : sig type t = unit include Transform . Transformer with type t := t end = struct include ExpandingTransformer let transform_children state _ = state , false end in let module StoppingExpandingTransform = Transform . Make ( StoppingExpandingTransf... |
let test_double_count _ = let module DoubleCounterTransformer : sig type t = int include Transform . Transformer with type t := t end = struct include Transform . Identity type t = int let statement count statement = count + 1 , [ statement ] end in let module ShallowDoubleCounterTransformer : sig type t = int include ... |
let test_conditional_count _ = let module NestedCounterTransformer : sig type t = { is_nested : bool ; statement_count : int ; } include Transform . Transformer with type t := t end = struct type t = { is_nested : bool ; statement_count : int ; } let transform_expression_children _ _ = false let transform_children ( { ... |
let test_statement_transformer _ = let module ModifyingStatementTransformer : sig type t = int include Transform . StatementTransformer with type t := t val final : t -> int end = struct type t = int let final count = count let statement count { Node . location ; value } = let count , value = match value with | Stateme... |
let test_transform_expression _ = let keep_first_argument = function | Expression . Call { Call . callee = { Node . value = Name ( Identifier given_callee_name ) ; location } ; arguments = argument :: _ ; } -> Expression . Call { Call . callee = { Node . value = Name ( Identifier given_callee_name ) ; location } ; argu... |
let test_sanitize_statement _ = let assert_sanitized statements expected = let given_statement , expected_statement = match statements , parse expected |> Source . statements with | [ { Node . value = given_statement ; _ } ] , [ { Node . value = expected_statement ; _ } ] -> given_statement , expected_statement | _ -> ... |
let ( ) = " transform " >::: [ " transform " >:: test_transform ; " expansion " >:: test_expansion ; " expansion_with_stop " >:: test_expansion_with_stop ; " statement_double_counter " >:: test_double_count ; " statement_conditional_counter " >:: test_conditional_count ; " statement_transformer " >:: test_statement_tra... |
module Apply_optimization_framework ( Input : Semantics . Bioinformatics_base ) module Transformation_types = struct type ' a from = ' a Input . repr type ' a term = | Unknown : ' a from -> ' a term | Apply : ( ' a -> ' b ) term * ' a term -> ' b term | Lambda : ( ' a term -> ' b term ) -> ( ' a -> ' b ) term | List_ma... |
module Apply ( Input : Semantics . Bioinformatics_base ) = struct module The_pass = Apply_optimization_framework ( Input ) include Optimization_framework . Generic_optimizer ( The_pass . Transformation ) ( Input ) include The_pass . Language_delta end |
module Big_int = struct include Big_int exception Error let sexp_of_big_int x = Sexp . Atom ( Big_int . string_of_big_int x ) let big_int_of_sexp sexp = match sexp with | Sexp . Atom str -> Big_int . big_int_of_string str | Sexp . List _ -> raise Error end |
module T = struct type t = [ | ` Null | ` String of String . t | ` Bool of Bool . t | ` Int of Int64 . t | ` BigInt of Big_int . big_int | ` Float of Float . t | ` Bytes of string | ` Array of t list | ` Map of ( t , t ) Map . Poly . t | ` UUID of Uuid . t | ` Keyword of String . t | ` Symbol of String . t | ` Time of ... |
module CacheCode = struct exception Invalid_cache_code of string let base_char_index = 48 let cache_code_digits = 44 let max_count = 44 * 44 - 1 let to_int s = match String . length s with | 1 -> ( Char . to_int s . [ 0 ] ) - base_char_index | 2 -> ( ( Char . to_int s . [ 0 ] ) - base_char_index ) * cache_code_digits +... |
module Reader = struct exception Internal_error exception Parse_error of string module Context = struct type tag = | Quote | List | Set | CMap | Unknown of string with sexp let tag_of_string = function | " ' " ~# -> Quote | " ~# list " -> List | " ~# set " -> Set | " ~# cmap " -> CMap | s -> Unknown ( String . drop_pre... |
module Writer = struct exception Todo module Cache = struct type t = { count : int ; cache : int String . Map . t } let empty = { count = 0 ; cache = String . Map . empty } let find { cache ; _ } = String . Map . find cache let track { cache ; count } key = if String . length key > 3 then if count > CacheCode . max_cou... |
module type Inputs_intf = sig module Transition_frontier : module type of Transition_frontier end |
module Make ( Inputs : Inputs_intf ) Inputs_intf : Mina_intf . Transition_chain_prover_intf with type transition_frontier := Inputs . Transition_frontier . t = struct open Inputs let find_in_root_history frontier state_hash = let open Transition_frontier . Extensions in let open Option . Let_syntax in let root_history ... |
let global_max_length ( genesis_constants : Genesis_constants . t ) t = genesis_constants . protocol . k |
let rejected_blocks = Queue . create ( ) |
let validated_blocks = Queue . create ( ) |
type t = { logger : Logger . t ; verifier : Verifier . t ; consensus_local_state : Consensus . Data . Local_state . t ; catchup_tree : Catchup_tree . t ; full_frontier : Full_frontier . t ; persistent_root : Persistent_root . t ; persistent_root_instance : Persistent_root . Instance . t ; persistent_frontier : Persiste... |
let catchup_tree t = t . catchup_tree |
type Structured_log_events . t += Added_breadcrumb_user_commands [ @@ deriving register_event ] register_event |
type Structured_log_events . t += Applying_diffs of { diffs : Yojson . Safe . t list } [ @@ deriving register_event { msg = " Applying diffs : $ diffs " } ] |
let genesis_root_data ~ precomputed_values = let transition = External_transition . Validated . lift @@ Mina_block . Validated . lift @@ Mina_block . genesis ~ precomputed_values in let constraint_constants = precomputed_values . constraint_constants in let scan_state = Staged_ledger . Scan_state . empty ~ constraint_c... |
let load_from_persistence_and_start ~ logger ~ verifier ~ consensus_local_state ~ max_length ~ persistent_root ~ persistent_root_instance ~ persistent_frontier ~ persistent_frontier_instance ~ precomputed_values ~ catchup_mode ignore_consensus_local_state = let open Deferred . Result . Let_syntax in let root_identifier... |
let rec load_with_max_length : max_length : int -> ? retry_with_fresh_db : bool -> logger : Logger . t -> verifier : Verifier . t -> consensus_local_state : Consensus . Data . Local_state . t -> persistent_root : Persistent_root . t -> persistent_frontier : Persistent_frontier . t -> precomputed_values : Precomputed_va... |
let load ( ? retry_with_fresh_db = true ) true ~ logger ~ verifier ~ consensus_local_state ~ persistent_root ~ persistent_frontier ~ precomputed_values ~ catchup_mode ( ) = let max_length = global_max_length ( Precomputed_values . genesis_constants precomputed_values ) precomputed_values in load_with_max_length ~ max_l... |
let close ~ loc { logger ; verifier = _ ; consensus_local_state = _ ; catchup_tree = _ ; full_frontier ; persistent_root = _safe_to_ignore_1 ; persistent_root_instance ; persistent_frontier = _safe_to_ignore_2 ; persistent_frontier_instance ; extensions ; closed ; genesis_state_hash = _ } = [ % log debug ] debug " Clos... |
let closed t = Ivar . read t . closed |
let persistent_root { persistent_root ; _ } = persistent_root |
let persistent_frontier { persistent_frontier ; _ } = persistent_frontier |
let extensions { extensions ; _ } = extensions |
let genesis_state_hash { genesis_state_hash ; _ } = genesis_state_hash |
let root_snarked_ledger { persistent_root_instance ; _ } = Persistent_root . Instance . snarked_ledger persistent_root_instance |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.