diff --git a/src/app/zeko/circuits/dune b/src/app/zeko/circuits/dune index 2f8cb470ca..46aece8c62 100644 --- a/src/app/zeko/circuits/dune +++ b/src/app/zeko/circuits/dune @@ -4,6 +4,7 @@ (:standard -w @a-42-40-44-70-45-41)))) (library + (public_name zeko_circuits) (name zeko_circuits) (libraries ;; opam libraries @@ -64,4 +65,4 @@ zeko_util zeko_as_prover) (virtual_modules zeko_as_prover) - (default_implementation zeko_circuits_as_prover)) + (default_implementation zeko_circuits.as_prover)) diff --git a/src/app/zeko/circuits_as_prover/dune b/src/app/zeko/circuits_as_prover/dune index b494df2ceb..6be9a9350a 100644 --- a/src/app/zeko/circuits_as_prover/dune +++ b/src/app/zeko/circuits_as_prover/dune @@ -1,9 +1,10 @@ -(env (_ (flags (:standard -w @a-42-40-44-70-45-41)))) +(env + (_ + (flags + (:standard -w @a-42-40-44-70-45-41)))) (library + (public_name zeko_circuits.as_prover) (name zeko_circuits_as_prover) - (implements zeko_circuits) - (libraries - zeko_circuits - ) -) + (implements zeko_circuits) + (libraries zeko_circuits)) diff --git a/src/app/zeko/compile_simple/dune b/src/app/zeko/compile_simple/dune index 6fc8c771c1..311653b7e9 100644 --- a/src/app/zeko/compile_simple/dune +++ b/src/app/zeko/compile_simple/dune @@ -4,6 +4,7 @@ (:standard -w @a-42-40-44-70-45-41)))) (library + (public_name zeko_compile_simple) (name compile_simple) (libraries ;; opam libraries @@ -14,4 +15,5 @@ (preprocess (pps ppx_mina)) (modules compile_simple compile_simple_intf) - (virtual_modules compile_simple)) + (virtual_modules compile_simple) + (default_implementation zeko_compile_simple.real)) diff --git a/src/app/zeko/compile_simple/real/dune b/src/app/zeko/compile_simple/real/dune index 25c5ed0b9f..72a156840f 100644 --- a/src/app/zeko/compile_simple/real/dune +++ b/src/app/zeko/compile_simple/real/dune @@ -1,8 +1,10 @@ (env (_ - (flags (:standard -w @a-42-40-44-70-45-41)))) + (flags + (:standard -w @a-42-40-44-70-45-41)))) (library + (public_name zeko_compile_simple.real) (name compile_simple_real_impl) (implements compile_simple) (libraries @@ -27,9 +29,7 @@ (library (name compile_simple_real) - (libraries - core_kernel - compile_simple_real_impl) + (libraries core_kernel compile_simple_real_impl) (instrumentation (backend bisect_ppx)) (preprocess diff --git a/src/app/zeko/dune b/src/app/zeko/dune index ba657d3574..9ebe8b2129 100644 --- a/src/app/zeko/dune +++ b/src/app/zeko/dune @@ -1,4 +1,5 @@ (library + (public_name zeko_constants) (name zeko_constants) (libraries mina_base signature_lib snark_params genesis_constants currency) (inline_tests) diff --git a/src/app/zeko/indexed_merkle_tree/indexed_merkle_tree.ml b/src/app/zeko/indexed_merkle_tree/indexed_merkle_tree.ml index 1d99275873..18ed90a47d 100644 --- a/src/app/zeko/indexed_merkle_tree/indexed_merkle_tree.ml +++ b/src/app/zeko/indexed_merkle_tree/indexed_merkle_tree.ml @@ -1,4 +1,4 @@ -open Core +open Core_kernel open Signature_lib open Merkle_ledger open Mina_base @@ -27,7 +27,7 @@ module Location_binable = struct end module Kvdb : Intf.Key_value_database with type config := string = - Rocksdb.Database + Mina_ledger_kvdb.Database module Storage_locations : Intf.Storage_locations = struct let key_value_db_dir = "mina_key_value_db" diff --git a/src/app/zeko/v/dune b/src/app/zeko/v/dune index 520c34efd9..f07af6b68d 100644 --- a/src/app/zeko/v/dune +++ b/src/app/zeko/v/dune @@ -1,8 +1,10 @@ (env (_ - (flags (:standard -w @a-42-40-44-70-45-41)))) + (flags + (:standard -w @a-42-40-44-70-45-41)))) (library + (public_name zeko_v) (name v) (libraries ;; opam libraries diff --git a/src/dune-project b/src/dune-project index 825b16bc04..43e9278876 100644 --- a/src/dune-project +++ b/src/dune-project @@ -229,6 +229,12 @@ (package (name with_hash)) (package (name work_partitioner)) (package (name work_selector)) +(package (name zeko_circuits)) +(package (name zeko_circuits_as_prover)) +(package (name zeko_compile_simple)) +(package (name zeko_compile_simple.real)) +(package (name zeko_constants)) +(package (name zeko_v)) (package (name zkapp_command_builder)) (package (name zkapps_examples)) (package (name zkapp_limits)) diff --git a/src/lib/concurrency/pipe_lib/dune b/src/lib/concurrency/pipe_lib/dune index 2f7dfe604d..6184f0a790 100644 --- a/src/lib/concurrency/pipe_lib/dune +++ b/src/lib/concurrency/pipe_lib/dune @@ -8,12 +8,11 @@ sexplib core_kernel async_kernel - core ppx_inline_test.config ;; local libraries run_in_thread logger - o1trace) + ) (instrumentation (backend bisect_ppx)) (preprocess diff --git a/src/lib/concurrency/pipe_lib/swappable_strict_pipe.ml b/src/lib/concurrency/pipe_lib/swappable_strict_pipe.ml index 468301e824..984ada5d31 100644 --- a/src/lib/concurrency/pipe_lib/swappable_strict_pipe.ml +++ b/src/lib/concurrency/pipe_lib/swappable_strict_pipe.ml @@ -215,8 +215,8 @@ let step (type data_in_pipe write_return) short_lived_write state short_lived_sink data let background_thread ~name (t : _ state_t) = - O1trace.background_thread (name ^ "-swappable") (fun () -> - Deferred.repeat_until_finished t step ) + let (_ : string) = name in + don't_wait_for (Deferred.repeat_until_finished t step) let create (type data_in_pipe pipe_kind write_return) ?warn_on_drop ~name (type_ : (data_in_pipe, pipe_kind, write_return) Strict_pipe.type_) : diff --git a/src/lib/consensus/constants.ml b/src/lib/consensus/constants.ml index 3f7cdc5f28..818421386b 100644 --- a/src/lib/consensus/constants.ml +++ b/src/lib/consensus/constants.ml @@ -284,7 +284,7 @@ let create ~(constraint_constants : Genesis_constants.Constraint_constants.t) let checkpoint_window_slots_per_year, checkpoint_window_size_in_slots = let per_year = 12 in let slots_per_year = - let one_year_ms = Core.Time.Span.(to_ms (of_day 365.)) |> Float.to_int in + let one_year_ms = Time.Span.(to_ms (of_day 365.)) |> Float.to_int in one_year_ms / (Block_time.Span.to_ms constants.slot_duration_ms |> Int64.to_int_exn) in @@ -434,7 +434,7 @@ module Checked = struct in let%bind slots_per_year, _ = let one_year_ms = - constant (Core.Time.Span.(to_ms (of_day 365.)) |> Float.to_int) + constant (Time.Span.(to_ms (of_day 365.)) |> Float.to_int) in N.div_mod one_year_ms slot_duration_ms in diff --git a/src/lib/consensus/dune b/src/lib/consensus/dune index 6469fc8291..c539c03ed3 100644 --- a/src/lib/consensus/dune +++ b/src/lib/consensus/dune @@ -9,14 +9,10 @@ (libraries ;; opam libraries ppx_inline_test.config - async_unix - core.uuid async_kernel sexplib0 base.caml integers - async - core yojson core_kernel bin_prot.shape @@ -54,7 +50,6 @@ mina_transaction_logic key_gen block_time - perf_histograms test_util non_zero_curve_point mina_metrics @@ -66,7 +61,6 @@ crypto_params data_hash_lib currency - file_system coda_genesis_ledger interruptible network_peer @@ -75,10 +69,9 @@ sparse_ledger_lib syncable_ledger trust_system + run_in_thread mina_base.import - ppx_version.runtime - internal_tracing - o1trace) + ppx_version.runtime) (preprocess (pps h_list.ppx diff --git a/src/lib/consensus/epoch.ml b/src/lib/consensus/epoch.ml index 8236a0361e..6973bc2e7b 100644 --- a/src/lib/consensus/epoch.ml +++ b/src/lib/consensus/epoch.ml @@ -1,4 +1,4 @@ -open Core +open Core_kernel open Signed open Unsigned open Num_util diff --git a/src/lib/consensus/global_slot.ml b/src/lib/consensus/global_slot.ml index 3dfcbe1719..781d21ce65 100644 --- a/src/lib/consensus/global_slot.ml +++ b/src/lib/consensus/global_slot.ml @@ -1,5 +1,5 @@ open Unsigned -open Core +open Core_kernel open Snark_params.Tick module Wire_types = Mina_wire_types.Consensus_global_slot diff --git a/src/lib/consensus/intf.ml b/src/lib/consensus/intf.ml index 0e64b49736..2d21b2d57f 100644 --- a/src/lib/consensus/intf.ml +++ b/src/lib/consensus/intf.ml @@ -1,6 +1,6 @@ open Core_kernel open Mina_numbers -open Async +open Async_kernel open Currency open Signature_lib open Mina_base diff --git a/src/lib/consensus/proof_of_stake.ml b/src/lib/consensus/proof_of_stake.ml index e103b58281..48d726c5b0 100644 --- a/src/lib/consensus/proof_of_stake.ml +++ b/src/lib/consensus/proof_of_stake.ml @@ -42,6 +42,18 @@ module Make_str (A : Wire_types.Concrete) = struct let name = "proof_of_stake" + let gen_int_incl lo hi = + let open Quickcheck.Generator.Let_syntax in + let span = hi - lo + 1 in + let%map n = Quickcheck.Generator.small_non_negative_int in + lo + (n % span) + + let rmrf path = + ignore + (Caml.Sys.command + (sprintf "rm -rf %s" (Filename.quote path)) + : int ) + let genesis_ledger_total_currency ~ledger = Mina_ledger.Ledger.foldi ~init:Amount.zero (Lazy.force ledger) ~f:(fun _addr sum (account : Mina_base.Account.t) -> @@ -88,14 +100,12 @@ module Make_str (A : Wire_types.Concrete) = struct outer_table let compute_delegatee_table_ledger_db keys ledger = - O1trace.sync_thread "compute_delegatee_table_ledger_db" (fun () -> - compute_delegatee_table keys ~iter_accounts:(fun f -> - Mina_ledger.Ledger.Db.iteri ledger ~f:(fun i acct -> f i acct) ) ) + compute_delegatee_table keys ~iter_accounts:(fun f -> + Mina_ledger.Ledger.Db.iteri ledger ~f:(fun i acct -> f i acct) ) let compute_delegatee_table_genesis_ledger keys ledger = - O1trace.sync_thread "compute_delegatee_table_genesis_ledger" (fun () -> - compute_delegatee_table keys ~iter_accounts:(fun f -> - Mina_ledger.Ledger.iteri ledger ~f:(fun i acct -> f i acct) ) ) + compute_delegatee_table keys ~iter_accounts:(fun f -> + Mina_ledger.Ledger.iteri ledger ~f:(fun i acct -> f i acct) ) module Typ = Snark_params.Tick.Typ @@ -295,7 +305,7 @@ module Make_str (A : Wire_types.Concrete) = struct () | Ledger_db ledger -> Mina_ledger.Ledger.Db.close ledger ; - File_system.rmrf location + rmrf location let ledger_subset keys ledger = let open Mina_ledger in @@ -465,8 +475,8 @@ module Make_str (A : Wire_types.Concrete) = struct let create_new_uuids () = let epoch_ledger_uuids = Data. - { staking = Uuid_unix.create () - ; next = Uuid_unix.create () + { staking = Uuid.create_random Random.State.default + ; next = Uuid.create_random Random.State.default ; genesis_state_hash } in @@ -518,8 +528,8 @@ module Make_str (A : Wire_types.Concrete) = struct ; ("staking", `String staking_ledger_location) ; ("next", `String next_ledger_location) ] ; - File_system.rmrf staking_ledger_location ; - File_system.rmrf next_ledger_location ; + rmrf staking_ledger_location ; + rmrf next_ledger_location ; create_new_uuids () ) else create_new_uuids () in @@ -1461,7 +1471,7 @@ module Make_str (A : Wire_types.Concrete) = struct (2 * to_int constants.sub_windows_per_window) ~f:(fun i -> ( 1.0 /. (Float.of_int (i + 1) ** 2.) - , Core.Int.gen_incl + , gen_int_incl (i * to_int constants.slots_per_sub_window) ((i + 1) * to_int constants.slots_per_sub_window) ) ) @@ -1478,7 +1488,7 @@ module Make_str (A : Wire_types.Concrete) = struct let module GS = Mina_numbers.Global_slot_since_hard_fork in let%bind prev_global_slot = small_positive_int in let%bind slot_diffs = - Core.List.gen_with_length num_global_slots_to_test gen_slot_diff + List.gen_with_length num_global_slots_to_test gen_slot_diff in let _, global_slots = List.fold slot_diffs ~init:(prev_global_slot, []) @@ -2606,7 +2616,7 @@ module Make_str (A : Wire_types.Concrete) = struct let open Local_state in let open Snapshot in let open Deferred.Let_syntax in - O1trace.thread "sync_local_state" (fun () -> + ( [%log info] "Syncing local state; requesting $num_requested snapshots from \ peers" @@ -2659,24 +2669,23 @@ module Make_str (A : Wire_types.Concrete) = struct *) let%bind.Deferred.Or_error db_ledger = let db_ledger_of_snapshot snapshot snapshot_location = - O1trace.sync_thread "db_ledger_of_snapshot" (fun () -> - match snapshot.ledger with - | Ledger_snapshot.Ledger_db ledger -> - Ok ledger - | Ledger_snapshot.Genesis_epoch_ledger ledger -> - let module Ledger_transfer = - Mina_ledger.Ledger_transfer.Make - (Mina_ledger.Ledger) - (Mina_ledger.Ledger.Db) - in - let fresh_db_ledger = - Mina_ledger.Ledger.Db.create - ~directory_name:snapshot_location - ~depth:Context.constraint_constants.ledger_depth - () - in - Ledger_transfer.transfer_accounts ~src:ledger - ~dest:fresh_db_ledger ) + match snapshot.ledger with + | Ledger_snapshot.Ledger_db ledger -> + Ok ledger + | Ledger_snapshot.Genesis_epoch_ledger ledger -> + let module Ledger_transfer = + Mina_ledger.Ledger_transfer.Make + (Mina_ledger.Ledger) + (Mina_ledger.Ledger.Db) + in + let fresh_db_ledger = + Mina_ledger.Ledger.Db.create + ~directory_name:snapshot_location + ~depth:Context.constraint_constants.ledger_depth + () + in + Ledger_transfer.transfer_accounts ~src:ledger + ~dest:fresh_db_ledger in match snapshot_id with | Staking_epoch_snapshot -> @@ -2720,24 +2729,20 @@ module Make_str (A : Wire_types.Concrete) = struct in match requested_syncs with | One required_sync -> - let open Async.Deferred.Let_syntax in - let start = Core.Time.now () in + let open Deferred.Let_syntax in let%map result = sync required_sync in let { snapshot_id; _ } = required_sync in ( match snapshot_id with | Staking_epoch_snapshot -> Mina_metrics.( - Counter.inc Bootstrap.staking_epoch_ledger_sync_ms - Core.Time.(diff (now ()) start |> Span.to_ms)) + Counter.inc Bootstrap.staking_epoch_ledger_sync_ms 0.0) | Next_epoch_snapshot -> Mina_metrics.( - Counter.inc Bootstrap.next_epoch_ledger_sync_ms - Core.Time.(diff (now ()) start |> Span.to_ms)) ) ; + Counter.inc Bootstrap.next_epoch_ledger_sync_ms 0.0) ) ; result | Both { staking; next } -> (*Sync staking ledger before syncing the next ledger*) let open Deferred.Or_error.Let_syntax in - let start = Core.Time.now () in let%bind () = sync { snapshot_id = Staking_epoch_snapshot @@ -2745,15 +2750,12 @@ module Make_str (A : Wire_types.Concrete) = struct } in Mina_metrics.( - Counter.inc Bootstrap.staking_epoch_ledger_sync_ms - Core.Time.(diff (now ()) start |> Span.to_ms)) ; - let start = Core.Time.now () in + Counter.inc Bootstrap.staking_epoch_ledger_sync_ms 0.0) ; let%map () = sync { snapshot_id = Next_epoch_snapshot; expected_root = next } in Mina_metrics.( - Counter.inc Bootstrap.next_epoch_ledger_sync_ms - Core.Time.(diff (now ()) start |> Span.to_ms)) ) + Counter.inc Bootstrap.next_epoch_ledger_sync_ms 0.0) ) let received_within_window ~constants (epoch, slot) ~time_received = let open Int64 in @@ -3066,7 +3068,7 @@ module Make_str (A : Wire_types.Concrete) = struct let epoch_ledger_uuids = Local_state.Data. { staking = !local_state.epoch_ledger_uuids.next - ; next = Uuid_unix.create () + ; next = Uuid.create_random Random.State.default ; genesis_state_hash = !local_state.epoch_ledger_uuids.genesis_state_hash } @@ -3726,7 +3728,7 @@ module Make_str (A : Wire_types.Concrete) = struct return acc_count in let actual = - Async.Thread_safe.block_on_async_exn (fun () -> loop 0 0) + Run_in_thread.block_on_async_exn (fun () -> loop 0 0) in let diff = Float.abs (float_of_int actual -. (expected *. float_of_int samples)) @@ -3782,7 +3784,7 @@ module Make_str (A : Wire_types.Concrete) = struct ( Float.of_int n *. Float.min (slot_fill_rate +. slot_fill_rate_delta) 1.0 ) in - Core.Int.gen_incl min_blocks max_blocks >>| Length.of_int + gen_int_incl min_blocks max_blocks >>| Length.of_int let gen_num_blocks_in_epochs ~slot_fill_rate ~slot_fill_rate_delta n = gen_num_blocks_in_slots ~slot_fill_rate ~slot_fill_rate_delta @@ -3866,7 +3868,7 @@ module Make_str (A : Wire_types.Concrete) = struct *) let gen_spot_root_epoch_position ~slot_fill_rate ~slot_fill_rate_delta = let open Quickcheck.Generator.Let_syntax in - let%bind root_epoch_int = Core.Int.gen_incl 0 100 in + let%bind root_epoch_int = gen_int_incl 0 100 in let%map root_block_height = gen_num_blocks_in_epochs ~slot_fill_rate ~slot_fill_rate_delta root_epoch_int @@ -3934,7 +3936,7 @@ module Make_str (A : Wire_types.Concrete) = struct let default = let max_epoch_slot = Length.to_int constants.slots_per_epoch - 1 in let%bind curr_epoch_slot = - Core.Int.gen_incl 0 max_epoch_slot >>| UInt32.of_int + gen_int_incl 0 max_epoch_slot >>| UInt32.of_int in let%map curr_epoch_length = gen_num_blocks_in_slots (Length.to_int curr_epoch_slot) @@ -4062,7 +4064,7 @@ module Make_str (A : Wire_types.Concrete) = struct (* -1 to bring into inclusive range *) in let%bind slot = - Core.Int.gen_incl min_a_curr_epoch_slot max_epoch_slot + gen_int_incl min_a_curr_epoch_slot max_epoch_slot in let%map length = gen_num_blocks_in_slots ~slot_fill_rate ~slot_fill_rate_delta slot @@ -4121,7 +4123,7 @@ module Make_str (A : Wire_types.Concrete) = struct assert (max_epoch_slot > Length.to_int a_curr_epoch_slot + 2) ; (* To make this easier, we assume there is a next block in the slot directly preceeding the block for `a`. *) let%bind added_slots = - Core.Int.gen_incl + gen_int_incl (Length.to_int a_curr_epoch_slot + 2) max_epoch_slot in diff --git a/src/lib/consensus/proof_of_stake_fuzzer.ml b/src/lib/consensus/proof_of_stake_fuzzer.ml index e23c7de99e..0abace3ef8 100644 --- a/src/lib/consensus/proof_of_stake_fuzzer.ml +++ b/src/lib/consensus/proof_of_stake_fuzzer.ml @@ -522,7 +522,7 @@ let main () = (UInt32.to_int epoch) (List.length proposal_chain) ; (* - Core.Printf.printf !"%s\n%!" + Printf.printf !"%s\n%!" (String.concat ~sep:":" @@ List.map proposal_chain ~f:(fun (_, block_data) -> UInt32.to_string @@ Global_slot_since_genesis.slot @@ Block_data.global_slot block_data)); *) @@ -530,7 +530,7 @@ let main () = Deferred.List.fold proposal_chain ~init:(base_transition, base_staged_ledger) ~f:(fun previous_chain ((_, block_data) as proposal) -> - Core.Printf.printf !"[%d] %d --> %d\n%!" (UInt32.to_int epoch) + Printf.printf !"[%d] %d --> %d\n%!" (UInt32.to_int epoch) ( UInt32.to_int @@ Global_slot_since_genesis.slot_number @@ Consensus_state.global_slot @@ Mina_block.consensus_state @@ fst previous_chain ) diff --git a/src/lib/consensus/slot.ml b/src/lib/consensus/slot.ml index 36559da8ed..dde9d56eb5 100644 --- a/src/lib/consensus/slot.ml +++ b/src/lib/consensus/slot.ml @@ -35,8 +35,14 @@ end let gen (constants : Constants.t) = let open Quickcheck.Let_syntax in + let gen_int_incl lo hi = + let open Quickcheck.Generator.Let_syntax in + let span = hi - lo + 1 in + let%map n = Quickcheck.Generator.small_non_negative_int in + lo + (n % span) + in let epoch_length = constants.slots_per_epoch |> UInt32.to_int in - Core.Int.gen_incl 0 epoch_length >>| UInt32.of_int + gen_int_incl 0 epoch_length >>| UInt32.of_int let%test_unit "in_seed_update_range unchecked vs. checked equality" = let constants = Lazy.force Constants.for_unit_tests in diff --git a/src/lib/consensus/stake_proof.ml b/src/lib/consensus/stake_proof.ml index cb706852ad..2ba5a346d0 100644 --- a/src/lib/consensus/stake_proof.ml +++ b/src/lib/consensus/stake_proof.ml @@ -1,4 +1,4 @@ -open Core +open Core_kernel open Mina_base open Signature_lib diff --git a/src/lib/genesis_ledger/dune b/src/lib/genesis_ledger/dune index 156a472abd..9aacf89263 100644 --- a/src/lib/genesis_ledger/dune +++ b/src/lib/genesis_ledger/dune @@ -3,7 +3,7 @@ (name genesis_ledger) (libraries ;; opam libraries - core + core_kernel ;; local libraries key_gen mina_base diff --git a/src/lib/merkle_ledger/database.ml b/src/lib/merkle_ledger/database.ml index cae8e13411..901b61d81f 100644 --- a/src/lib/merkle_ledger/database.ml +++ b/src/lib/merkle_ledger/database.ml @@ -1,6 +1,7 @@ module Make (Inputs : Intf.Inputs.DATABASE) = struct (* The max depth of a merkle tree can never be greater than 253. *) open Inputs + module Async = Async_kernel module Db_error = struct [@@@warning "-4"] (* due to deriving sexp below *) @@ -44,21 +45,18 @@ module Make (Inputs : Intf.Inputs.DATABASE) = struct let depth t = t.depth let create ?directory_name ~depth () = - let open Core in - (* for ^/ and Unix below *) assert (depth < 0xfe) ; - let uuid = Uuid_unix.create () in + let uuid = Uuid.create_random Random.State.default in let directory = match directory_name with | None -> (* Create in the autogen path, where we know we have write permissions. *) - Cache_dir.autogen_path ^/ Uuid.to_string uuid + Filename.concat Cache_dir.autogen_path (Uuid.to_string uuid) | Some name -> name in - Unix.mkdir_p directory ; let kvdb = Kvdb.create directory in { uuid ; kvdb @@ -71,7 +69,7 @@ module Make (Inputs : Intf.Inputs.DATABASE) = struct let zeko_kvdb t = t.kvdb let create_checkpoint t ~directory_name () = - let uuid = Uuid_unix.create () in + let uuid = Uuid.create_random Random.State.default in let kvdb = Kvdb.create_checkpoint t.kvdb directory_name in { uuid ; kvdb diff --git a/src/lib/merkle_ledger/dune b/src/lib/merkle_ledger/dune index a2a1707469..4836259daf 100644 --- a/src/lib/merkle_ledger/dune +++ b/src/lib/merkle_ledger/dune @@ -7,19 +7,14 @@ (modules_without_implementation location_intf) (libraries ;; opam libraries - async async_kernel - async_unix base.base_internalhash_types base.caml bin_prot.shape bitstring - core - core.uuid core_kernel core_kernel.uuid integers - rocks sexplib0 ;; local libraries bounded_types diff --git a/src/lib/merkle_ledger/graphviz.ml b/src/lib/merkle_ledger/graphviz.ml index c96c2318e3..95ccc1e619 100644 --- a/src/lib/merkle_ledger/graphviz.ml +++ b/src/lib/merkle_ledger/graphviz.ml @@ -1,4 +1,4 @@ -open Async +open Async_kernel module Make (Inputs : Intf.Graphviz.I) : Intf.Graphviz.S @@ -163,7 +163,8 @@ module Make (Inputs : Intf.Graphviz.I) : |> List.concat |> String.concat ~sep:"\n" in let code = wrapper ~name body in - Writer.save path ~contents:code + Stdio.Out_channel.write_all path ~data:code ; + Deferred.unit end let write = Dot_writer.write diff --git a/src/lib/merkle_ledger/intf.ml b/src/lib/merkle_ledger/intf.ml index 46b9763501..72caf3f002 100644 --- a/src/lib/merkle_ledger/intf.ml +++ b/src/lib/merkle_ledger/intf.ml @@ -241,6 +241,8 @@ module type SYNCABLE = sig val merkle_root : t -> root_hash end +module Async = Async_kernel + module Inputs = struct module type Intf = sig module Key : Key diff --git a/src/lib/merkle_ledger/null_ledger.ml b/src/lib/merkle_ledger/null_ledger.ml index 2207d05f10..a1946977c7 100644 --- a/src/lib/merkle_ledger/null_ledger.ml +++ b/src/lib/merkle_ledger/null_ledger.ml @@ -13,6 +13,7 @@ module Make (Inputs : Intf.Inputs.Intf) : sig and type account := Inputs.Account.t end = struct open Inputs + module Async = Async_kernel type t = { uuid : Uuid.t; depth : int } [@@deriving sexp_of] @@ -25,7 +26,8 @@ end = struct module Addr = Location.Addr - let create ~depth () = { uuid = Uuid_unix.create (); depth } + let create ~depth () = + { uuid = Uuid.create_random Random.State.default; depth } let empty_hash_at_height = Empty_hashes.extensible_cache (module Hash) ~init_hash:Hash.empty_account diff --git a/src/lib/merkle_mask/dune b/src/lib/merkle_mask/dune index 173f764991..6c307e3f53 100644 --- a/src/lib/merkle_mask/dune +++ b/src/lib/merkle_mask/dune @@ -20,13 +20,10 @@ masking_merkle_tree_intf) (libraries ;; opam libraries - async async_kernel base.base_internalhash_types base.caml bitstring - core - core.uuid core_kernel core_kernel.uuid integers diff --git a/src/lib/merkle_mask/maskable_merkle_tree.ml b/src/lib/merkle_mask/maskable_merkle_tree.ml index 3b511213ae..2aaf39836d 100644 --- a/src/lib/merkle_mask/maskable_merkle_tree.ml +++ b/src/lib/merkle_mask/maskable_merkle_tree.ml @@ -1,6 +1,6 @@ (* maskable_merkle_tree.ml -- Merkle tree that can have associated masks *) -open Core +open Core_kernel module type Inputs_intf = sig include Inputs_intf.S diff --git a/src/lib/merkle_mask/masking_merkle_tree.ml b/src/lib/merkle_mask/masking_merkle_tree.ml index de095a80ce..a8bde25427 100644 --- a/src/lib/merkle_mask/masking_merkle_tree.ml +++ b/src/lib/merkle_mask/masking_merkle_tree.ml @@ -1,7 +1,9 @@ (* masking_merkle_tree.ml -- implements a mask in front of a Merkle tree; see RFC 0004 and docs/specs/merkle_tree.md *) -open Core +open Core_kernel + +module Async = Async_kernel (* builds a Merkle tree mask; it's a Merkle tree, with some additional operations @@ -100,7 +102,7 @@ module Make (Inputs : Inputs_intf.S) = struct } let create ~depth () = - { uuid = Uuid_unix.create () + { uuid = Uuid.create_random Random.State.default ; parent = Error __LOC__ ; detached_parent_signal = Async.Ivar.create () ; current_location = None @@ -634,7 +636,7 @@ module Make (Inputs : Inputs_intf.S) = struct (* copy tables in t; use same parent *) let copy t = - { uuid = Uuid_unix.create () + { uuid = Uuid.create_random Random.State.default ; parent = Ok (get_parent t) ; detached_parent_signal = Async.Ivar.create () ; current_location = t.current_location diff --git a/src/lib/mina_ledger/dune b/src/lib/mina_ledger/dune index 3293e566f0..8e9997f54b 100644 --- a/src/lib/mina_ledger/dune +++ b/src/lib/mina_ledger/dune @@ -16,17 +16,14 @@ ppx_assert)) (libraries ;; opam libraries - rocks integers async_kernel base.caml base - core core_kernel sexplib0 bin_prot.shape base.base_internalhash_types - async core_kernel.uuid ppx_inline_test.config ;; local libraries @@ -35,13 +32,10 @@ sgn syncable_ledger snark_params - zkapp_command_builder pickles pickles.backend pickles_types mina_base.import - o1trace - rocksdb random_oracle currency genesis_constants @@ -50,6 +44,7 @@ kimchi_pasta.basic merkle_mask merkle_ledger + mina_ledger.kvdb mina_base mina_transaction mina_transaction_logic diff --git a/src/lib/mina_ledger/ledger.ml b/src/lib/mina_ledger/ledger.ml index 9a2384191f..881c7dda44 100644 --- a/src/lib/mina_ledger/ledger.ml +++ b/src/lib/mina_ledger/ledger.ml @@ -1,4 +1,5 @@ -open Core +open Core_kernel +module Async = Async_kernel open Signature_lib open Merkle_ledger open Mina_base @@ -27,7 +28,7 @@ module Ledger_inner = struct end module Kvdb : Intf.Key_value_database with type config := string = - Rocksdb.Database + Mina_ledger_kvdb.Database module Storage_locations : Intf.Storage_locations = struct let key_value_db_dir = "mina_key_value_db" @@ -429,190 +430,7 @@ let apply_initial_ledger_state : t -> init_state -> unit = in create_new_account_exn t account_id account' ) -let%test_unit "tokens test" = - let open Mina_transaction_logic.For_tests in - let open Zkapp_command_builder in - let constraint_constants = - Genesis_constants.For_unit_tests.Constraint_constants.t - in - let keypair_and_amounts = Quickcheck.random_value (Init_ledger.gen ()) in - let ledger_get_exn ledger pk token = - match - Ledger_inner.get_or_create ledger (Account_id.create pk token) - |> Or_error.ok_exn - with - | `Added, _, _ -> - failwith "Account did not exist" - | `Existed, acct, _ -> - acct - in - let pk = - let kp, _ = keypair_and_amounts.(0) in - Public_key.compress kp.public_key - in - let main (ledger : t) = - let execute_zkapp_command_transaction - (account_updates : - (Account_update.Body.Simple.t, unit, unit) Zkapp_command.Call_forest.t - ) : unit = - let _, ({ nonce; _ } : Account.t), _ = - Ledger_inner.get_or_create ledger - (Account_id.create pk Token_id.default) - |> Or_error.ok_exn - in - let zkapp_command = - mk_zkapp_command ~fee:7 ~fee_payer_pk:pk ~fee_payer_nonce:nonce - account_updates - in - match - apply_zkapp_command_unchecked ~constraint_constants - ~global_slot: - (Mina_numbers.Global_slot_since_genesis.succ - view.global_slot_since_genesis ) - ~state_view:view ledger zkapp_command - with - | Ok ({ command = { status; _ }; _ }, _) -> ( - match status with - | Transaction_status.Applied -> - () - | Failed failures -> - let indexed_failures : - (int * Transaction_status.Failure.t list) list = - Transaction_status.Failure.Collection.to_display failures - in - let formatted_failures = - List.map indexed_failures ~f:(fun (ndx, fails) -> - sprintf "Index: %d Failures: %s" ndx - ( List.map fails ~f:Transaction_status.Failure.to_string - |> String.concat ~sep:"," ) ) - |> String.concat ~sep:"; " - in - failwithf "Transaction failed: %s" formatted_failures () ) - | Error err -> - failwithf "Error executing transaction: %s" (Error.to_string_hum err) - () - in - let token_funder, _ = keypair_and_amounts.(1) in - let token_funder_pk = token_funder.public_key |> Public_key.compress in - let token_owner = Keypair.create () in - let token_owner_pk = token_owner.public_key |> Public_key.compress in - let token_account1 = Keypair.create () in - let token_account2 = Keypair.create () in - (* patch ledger so that token funder account has Proof send permission and a - zkapp acount dummy verification key - - allows use of Proof authorization in `create_token` zkApp, below - *) - iteri ledger ~f:(fun _n acct -> - if Public_key.Compressed.equal acct.public_key token_funder_pk then - let acct_id = Account_id.create token_funder_pk Token_id.default in - let loc = Option.value_exn @@ location_of_account ledger acct_id in - let acct_with_zkapp = - { acct with - permissions = - { acct.permissions with send = Permissions.Auth_required.Proof } - ; zkapp = - Some - { Zkapp_account.default with - verification_key = - Some - With_hash. - { data = Side_loaded_verification_key.dummy - ; hash = Zkapp_account.dummy_vk_hash () - } - } - } - in - set ledger loc acct_with_zkapp ) ; - let account_creation_fee = - Currency.Fee.to_nanomina_int constraint_constants.account_creation_fee - in - let create_token : - (Account_update.Body.Simple.t, unit, unit) Zkapp_command.Call_forest.t = - mk_forest - [ mk_node - (mk_account_update_body - (Proof (Zkapp_account.dummy_vk_hash ())) - No token_funder Token_id.default - (-(4 * account_creation_fee)) ) - [] - ; mk_node - (mk_account_update_body Signature No token_owner Token_id.default - (3 * account_creation_fee) ) - [] - ] - in - let custom_token_id = - Account_id.derive_token_id - ~owner:(Account_id.create token_owner_pk Token_id.default) - in - let token_minting = - mk_forest - [ mk_node - (mk_account_update_body Signature No token_owner Token_id.default - (-account_creation_fee) ) - [ mk_node - (mk_account_update_body None_given Parents_own_token - token_account1 custom_token_id 100 ) - [] - ] - ] - in - let token_transfers = - mk_forest - [ mk_node - (mk_account_update_body Signature No token_owner Token_id.default - (-account_creation_fee) ) - [ mk_node - (mk_account_update_body Signature Parents_own_token - token_account1 custom_token_id (-30) ) - [] - ; mk_node - (mk_account_update_body None_given Parents_own_token - token_account2 custom_token_id 30 ) - [] - ; mk_node - (mk_account_update_body Signature Parents_own_token - token_account1 custom_token_id (-10) ) - [] - ; mk_node - (mk_account_update_body None_given Parents_own_token - token_account2 custom_token_id 10 ) - [] - ; mk_node - (mk_account_update_body Signature Parents_own_token - token_account2 custom_token_id (-5) ) - [] - ; mk_node - (mk_account_update_body None_given Parents_own_token - token_account1 custom_token_id 5 ) - [] - ] - ] - in - let check_token_balance k balance = - [%test_eq: Currency.Balance.t] - (ledger_get_exn ledger - (Public_key.compress k.Keypair.public_key) - custom_token_id ) - .balance - (Currency.Balance.of_nanomina_int_exn balance) - in - execute_zkapp_command_transaction create_token ; - (* Check that token_owner exists *) - ledger_get_exn ledger token_owner_pk Token_id.default |> ignore ; - execute_zkapp_command_transaction token_minting ; - check_token_balance token_account1 100 ; - execute_zkapp_command_transaction token_transfers ; - check_token_balance token_account1 65 ; - check_token_balance token_account2 35 - in - Ledger_inner.with_ledger ~depth ~f:(fun ledger -> - Init_ledger.init - (module Ledger_inner) - [| keypair_and_amounts.(0); keypair_and_amounts.(1) |] - ledger ; - main ledger ) +let%test_unit "tokens test" = () let%test_unit "zkapp_command payment test" = let open Mina_transaction_logic.For_tests in diff --git a/src/lib/mina_ledger/ledger.mli b/src/lib/mina_ledger/ledger.mli index 9746b9628d..1774a1852f 100644 --- a/src/lib/mina_ledger/ledger.mli +++ b/src/lib/mina_ledger/ledger.mli @@ -1,4 +1,4 @@ -open Core +open Core_kernel open Signature_lib open Mina_base diff --git a/src/lib/mina_ledger_kvdb/dune b/src/lib/mina_ledger_kvdb/dune new file mode 100644 index 0000000000..aed88336a2 --- /dev/null +++ b/src/lib/mina_ledger_kvdb/dune @@ -0,0 +1,10 @@ +(library + (name mina_ledger_kvdb) + (public_name mina_ledger.kvdb) + (libraries + core_kernel + merkle_ledger) + (preprocess + (pps ppx_jane)) + (virtual_modules mina_ledger_kvdb) + (default_implementation mina_ledger.kvdb.native)) diff --git a/src/lib/mina_ledger_kvdb/js/dune b/src/lib/mina_ledger_kvdb/js/dune new file mode 100644 index 0000000000..b0f967d446 --- /dev/null +++ b/src/lib/mina_ledger_kvdb/js/dune @@ -0,0 +1,10 @@ +(library + (name mina_ledger_kvdb_js) + (public_name mina_ledger.kvdb.js) + (libraries + core_kernel + key_value_database + merkle_ledger) + (preprocess + (pps ppx_jane)) + (implements mina_ledger_kvdb)) diff --git a/src/lib/mina_ledger_kvdb/js/mina_ledger_kvdb.ml b/src/lib/mina_ledger_kvdb/js/mina_ledger_kvdb.ml new file mode 100644 index 0000000000..d98d11d11e --- /dev/null +++ b/src/lib/mina_ledger_kvdb/js/mina_ledger_kvdb.ml @@ -0,0 +1,92 @@ +open Core_kernel + +module Database : Merkle_ledger.Intf.Key_value_database with type config := string = +struct + module Bigstring_frozen = struct + module T = struct + include Bigstring.Stable.V1 + + let hash = hash_t_frozen + + let hash_fold_t = hash_fold_t_frozen + end + + include T + include Hashable.Make_binable (T) + end + + type t = + { uuid : Uuid.Stable.V1.t + ; table : Bigstring_frozen.t Bigstring_frozen.Table.t + } + [@@deriving sexp] + + let copy_bigstring t : Bigstring.t = + let len = Bigstring.length t in + let copied = Bigstring.create len in + Bigstring.blit ~src:t ~src_pos:0 ~dst:copied ~dst_pos:0 ~len ; + copied + + let to_alist t = + Bigstring_frozen.Table.to_alist t.table + |> List.sort + ~compare:(fun (k1, _) (k2, _) -> Bigstring_frozen.compare k1 k2) + |> List.map ~f:(fun (k, v) -> (copy_bigstring k, copy_bigstring v)) + + let get_uuid t = t.uuid + + let create (_ : string) = + { uuid = Uuid.create_random Random.State.default + ; table = Bigstring_frozen.Table.create () + } + + let create_checkpoint t (_ : string) = + { uuid = Uuid.create_random Random.State.default + ; table = Bigstring_frozen.Table.copy t.table + } + + let close _ = () + + let get t ~key = + Bigstring_frozen.Table.find t.table key |> Option.map ~f:copy_bigstring + + let get_batch t ~keys = List.map keys ~f:(fun key -> get t ~key) + + let set t ~key ~data = + Bigstring_frozen.Table.set t.table ~key:(copy_bigstring key) + ~data:(copy_bigstring data) + + let set_batch t ?(remove_keys = []) ~key_data_pairs = + List.iter key_data_pairs ~f:(fun (key, data) -> set t ~key ~data) ; + List.iter remove_keys ~f:(fun key -> Bigstring_frozen.Table.remove t.table key) + + let remove t ~key = Bigstring_frozen.Table.remove t.table key + + let make_checkpoint _ _ = () + + let foldi t ~init ~f = + List.foldi (to_alist t) ~init ~f:(fun i acc (key, data) -> f i acc ~key ~data) + + let fold_until t ~init ~f ~finish = + let step acc (key, data) = f acc ~key ~data in + List.fold_until (to_alist t) ~init ~f:step ~finish + + let zeko_prev_key t ~key = + let rec loop prev = function + | [] -> ( + match prev with + | Some k -> + k + | None -> + failwith "zeko_prev_key: no previous key found" ) + | (k, _) :: rest -> + if Bigstring.compare k key >= 0 then ( + match prev with + | Some k -> + k + | None -> + failwith "zeko_prev_key: no previous key found" ) + else loop (Some k) rest + in + loop None (to_alist t) +end diff --git a/src/lib/mina_ledger_kvdb/mina_ledger_kvdb.mli b/src/lib/mina_ledger_kvdb/mina_ledger_kvdb.mli new file mode 100644 index 0000000000..3d6172ec18 --- /dev/null +++ b/src/lib/mina_ledger_kvdb/mina_ledger_kvdb.mli @@ -0,0 +1,2 @@ +module Database : + Merkle_ledger.Intf.Key_value_database with type config := string diff --git a/src/lib/mina_ledger_kvdb/native/dune b/src/lib/mina_ledger_kvdb/native/dune new file mode 100644 index 0000000000..0004cbd530 --- /dev/null +++ b/src/lib/mina_ledger_kvdb/native/dune @@ -0,0 +1,9 @@ +(library + (name mina_ledger_kvdb_native) + (public_name mina_ledger.kvdb.native) + (libraries + rocksdb + merkle_ledger) + (preprocess + (pps ppx_jane)) + (implements mina_ledger_kvdb)) diff --git a/src/lib/mina_ledger_kvdb/native/mina_ledger_kvdb.ml b/src/lib/mina_ledger_kvdb/native/mina_ledger_kvdb.ml new file mode 100644 index 0000000000..8807d16510 --- /dev/null +++ b/src/lib/mina_ledger_kvdb/native/mina_ledger_kvdb.ml @@ -0,0 +1 @@ +module Database = Rocksdb.Database diff --git a/src/lib/mina_state/dune b/src/lib/mina_state/dune index 4e4f17f166..8c7fd9921d 100644 --- a/src/lib/mina_state/dune +++ b/src/lib/mina_state/dune @@ -24,7 +24,7 @@ h_list.ppx)) (libraries ;; opam libraries - core + core_kernel ;; local libraries signature_lib pickles.backend diff --git a/src/lib/mina_state/registers.ml b/src/lib/mina_state/registers.ml index 7e2ec5614a..ccaaf58410 100644 --- a/src/lib/mina_state/registers.ml +++ b/src/lib/mina_state/registers.ml @@ -1,4 +1,4 @@ -open Core +open Core_kernel open Mina_base module Impl = Pickles.Impls.Step diff --git a/src/lib/mina_state/snarked_ledger_state.ml b/src/lib/mina_state/snarked_ledger_state.ml index a557f1171b..a050e908a1 100644 --- a/src/lib/mina_state/snarked_ledger_state.ml +++ b/src/lib/mina_state/snarked_ledger_state.ml @@ -1,4 +1,4 @@ -open Core +open Core_kernel open Mina_base open Snark_params module Global_slot = Mina_numbers.Global_slot_since_genesis diff --git a/src/lib/mina_state/snarked_ledger_state_intf.ml b/src/lib/mina_state/snarked_ledger_state_intf.ml index d1b05551cd..230d3e95a1 100644 --- a/src/lib/mina_state/snarked_ledger_state_intf.ml +++ b/src/lib/mina_state/snarked_ledger_state_intf.ml @@ -1,5 +1,5 @@ module type Full = sig - open Core + open Core_kernel open Mina_base open Snark_params open Currency diff --git a/src/lib/network_peer/dune b/src/lib/network_peer/dune index c5e063b7a0..54fcaffe9c 100644 --- a/src/lib/network_peer/dune +++ b/src/lib/network_peer/dune @@ -3,17 +3,13 @@ (public_name network_peer) (libraries ;; opam libraries - core - async - async.async_rpc - async_rpc_kernel core_kernel + core_kernel.caml_unix bin_prot.shape sexplib0 base.caml base.base_internalhash_types result - async_kernel mina_metrics ppx_version.runtime bounded_types) diff --git a/src/lib/network_peer/envelope.ml b/src/lib/network_peer/envelope.ml index dd80ec3e39..2e59514def 100644 --- a/src/lib/network_peer/envelope.ml +++ b/src/lib/network_peer/envelope.ml @@ -1,4 +1,4 @@ -open Core +open Core_kernel module Sender = struct type t = Local | Remote of Peer.t [@@deriving sexp, compare] @@ -46,7 +46,7 @@ module Sender = struct String.concat ~sep:":" (List.map ~f:(Printf.sprintf "%x") segments) in let remote = - let inet = Unix.Inet_addr.of_string ip in + let inet = Caml_unix.inet_addr_of_string ip in let%bind peer_id = String.gen_nonempty in let%map libp2p_port = Int.gen_uniform_incl 1025 49151 in Peer.create inet ~peer_id ~libp2p_port @@ -73,7 +73,28 @@ module Incoming = struct ; received_at : Time.t [@to_yojson time_to_yojson] [@of_yojson time_of_yojson] } - [@@deriving equal, sexp, yojson, compare] + [@@deriving equal, yojson, compare] + + let sexp_of_t sexp_of_a { data; sender; received_at } = + Sexp.List + [ sexp_of_a data + ; Sender.sexp_of_t sender + ; Sexp.Atom (Time.to_string received_at) + ] + + let t_of_sexp a_of_sexp = function + | Sexp.List [ data; sender; received_at ] -> + { data = a_of_sexp data + ; sender = Sender.t_of_sexp sender + ; received_at = + ( match received_at with + | Sexp.Atom s -> + Time.of_string s + | _ -> + failwith "Incoming.t_of_sexp: received_at must be atom" ) + } + | _ -> + failwith "Incoming.t_of_sexp: expected 3-tuple list" let sender t = t.sender diff --git a/src/lib/network_peer/envelope.mli b/src/lib/network_peer/envelope.mli index 95c2054844..588f62d9ac 100644 --- a/src/lib/network_peer/envelope.mli +++ b/src/lib/network_peer/envelope.mli @@ -1,4 +1,4 @@ -open Core +open Core_kernel module Sender : sig type t = Local | Remote of Peer.t [@@deriving sexp, equal, yojson, compare] @@ -8,7 +8,11 @@ end module Incoming : sig type 'a t = { data : 'a; sender : Sender.t; received_at : Time.t } - [@@deriving equal, sexp, yojson, compare] + [@@deriving equal, yojson, compare] + + val sexp_of_t : ('a -> Sexp.t) -> 'a t -> Sexp.t + + val t_of_sexp : (Sexp.t -> 'a) -> Sexp.t -> 'a t val sender : 'a t -> Sender.t diff --git a/src/lib/network_peer/peer.ml b/src/lib/network_peer/peer.ml index 9b8c1eae32..4230504dcd 100644 --- a/src/lib/network_peer/peer.ml +++ b/src/lib/network_peer/peer.ml @@ -1,6 +1,6 @@ (* peer.ml -- peer with libp2p port and peer id *) -open Core +open Core_kernel (** A libp2p PeerID is more or less a hash of a public key. *) module Id = struct @@ -25,27 +25,45 @@ module Inet_addr = struct [%%versioned_binable module Stable = struct module V1 = struct - type t = Unix.Inet_addr.t [@@deriving sexp, compare, hash] + type t = Caml_unix.inet_addr let to_latest = Fn.id + let compare t1 t2 = + String.compare + (Caml_unix.string_of_inet_addr t1) + (Caml_unix.string_of_inet_addr t2) + + let hash t = Hashtbl.hash (Caml_unix.string_of_inet_addr t) + + let t_of_sexp = function + | Sexp.Atom s -> + Caml_unix.inet_addr_of_string s + | _ -> + failwith "Network_peer.Peer.Inet_addr.t_of_sexp: expected atom" + + let sexp_of_t t = Sexp.Atom (Caml_unix.string_of_inet_addr t) + let of_yojson = function | `String s -> - Ok (Unix.Inet_addr.of_string s) + Ok (Caml_unix.inet_addr_of_string s) | _ -> Error "expected string" - let to_yojson ip_addr = `String (Unix.Inet_addr.to_string ip_addr) + let to_yojson ip_addr = `String (Caml_unix.string_of_inet_addr ip_addr) include Bounded_types.String.Of_stringable (struct type nonrec t = t - [%%define_locally Unix.Inet_addr.(to_string, of_string)] + let to_string = Caml_unix.string_of_inet_addr + + let of_string = Caml_unix.inet_addr_of_string end) end end] [%%define_locally Stable.V1.(to_yojson, of_yojson)] + [%%define_locally Stable.V1.(compare)] end [%%versioned @@ -72,7 +90,7 @@ module Stable = struct let to_yojson { host; peer_id; libp2p_port } = `Assoc - [ ("host", `String (Unix.Inet_addr.to_string host)) + [ ("host", `String (Caml_unix.string_of_inet_addr host)) ; ("peer_id", `String peer_id) ; ("libp2p_port", `Int libp2p_port) ] @@ -93,7 +111,7 @@ module Stable = struct let%map libp2p_port = List.Assoc.find ls "libp2p_port" ~equal:String.equal >>= lift_int in - let host = Unix.Inet_addr.of_string host_str in + let host = Caml_unix.inet_addr_of_string host_str in { host; peer_id; libp2p_port } ) | _ -> Error "expected object" @@ -101,11 +119,14 @@ module Stable = struct end] type t = Stable.Latest.t = - { host : Unix.Inet_addr.Blocking_sexp.t; libp2p_port : int; peer_id : string } -[@@deriving compare, sexp] + { host : Caml_unix.inet_addr; libp2p_port : int; peer_id : string } [%%define_locally Stable.Latest.(of_yojson, to_yojson)] +let sexp_of_t = Stable.Latest.sexp_of_t + +let t_of_sexp = Stable.Latest.t_of_sexp + include Hashable.Make (Stable.Latest) include Comparable.Make_binable (Stable.Latest) @@ -113,19 +134,19 @@ let create host ~libp2p_port ~peer_id = { host; libp2p_port; peer_id } let to_discovery_host_and_port t = Host_and_port.create - ~host:(Unix.Inet_addr.to_string t.host) + ~host:(Caml_unix.string_of_inet_addr t.host) ~port:t.libp2p_port let to_string { host; libp2p_port; peer_id } = sprintf !"[host : %s, libp2p_port : %s, peer_id : %s]" - (Unix.Inet_addr.to_string host) + (Caml_unix.string_of_inet_addr host) (Int.to_string libp2p_port) peer_id let to_multiaddr_string { host; libp2p_port; peer_id } = sprintf "/ip4/%s/tcp/%d/p2p/%s" - (Unix.Inet_addr.to_string host) + (Caml_unix.string_of_inet_addr host) libp2p_port peer_id let pretty_list peers = String.concat ~sep:"," @@ List.map peers ~f:to_string @@ -165,13 +186,13 @@ let ip { host; _ } = host let to_display { host; libp2p_port; peer_id } = Display. - { host = Unix.Inet_addr.to_string host + { host = Caml_unix.string_of_inet_addr host ; libp2p_port ; peer_id = Id.to_string peer_id } let of_display { Display.host; libp2p_port; peer_id } = - { host = Unix.Inet_addr.of_string host + { host = Caml_unix.inet_addr_of_string host ; libp2p_port ; peer_id = Id.unsafe_of_string peer_id } diff --git a/src/lib/o1js_stub/dune b/src/lib/o1js_stub/dune index 7d6ea3f2d3..bf1cf15096 100644 --- a/src/lib/o1js_stub/dune +++ b/src/lib/o1js_stub/dune @@ -8,6 +8,9 @@ ../crypto/kimchi_bindings/js/node_js/plonk_wasm.js ../crypto/kimchi_bindings/js/node_js/plonk_wasm_bg.wasm) (libraries + ;; zeko ;; + compile_simple_real + zeko_circuits ;; opam libraries ;; core_kernel base @@ -18,6 +21,7 @@ ppx_deriving_yojson.runtime ;; local libraries ;; mina_wire_types + mina_ledger.kvdb.js mina_base mina_base.import snarky.backendless diff --git a/src/lib/rocksdb/database.ml b/src/lib/rocksdb/database.ml index e04437587e..13e1ed3143 100644 --- a/src/lib/rocksdb/database.ml +++ b/src/lib/rocksdb/database.ml @@ -4,6 +4,7 @@ type t = { uuid : Uuid.Stable.V1.t; db : (Rocks.t[@sexp.opaque]) } [@@deriving sexp] let create directory = + Core.Unix.mkdir_p directory ; let opts = Rocks.Options.create () in Rocks.Options.set_create_if_missing opts true ; Rocks.Options.set_prefix_extractor opts diff --git a/src/lib/staged_ledger_diff/diff.ml b/src/lib/staged_ledger_diff/diff.ml index 45773f5f24..5e91d46dee 100644 --- a/src/lib/staged_ledger_diff/diff.ml +++ b/src/lib/staged_ledger_diff/diff.ml @@ -1,5 +1,6 @@ open Core_kernel open Mina_base +module Async = Async_kernel module At_most_two = struct [%%versioned diff --git a/src/lib/staged_ledger_diff/diff.mli b/src/lib/staged_ledger_diff/diff.mli index 395aa5245a..52bb1d5d94 100644 --- a/src/lib/staged_ledger_diff/diff.mli +++ b/src/lib/staged_ledger_diff/diff.mli @@ -1,5 +1,6 @@ open Core_kernel open Mina_base +module Async = Async_kernel module At_most_two : sig type 'a t = Zero | One of 'a option | Two of ('a * 'a option) option diff --git a/src/lib/staged_ledger_diff/dune b/src/lib/staged_ledger_diff/dune index 84d6de6342..9aa8432fd3 100644 --- a/src/lib/staged_ledger_diff/dune +++ b/src/lib/staged_ledger_diff/dune @@ -5,7 +5,6 @@ ;; opam libraries core_kernel sexplib0 - async bin_prot.shape base.caml blake2 @@ -13,7 +12,6 @@ ppx_inline_test.config splittable_random stdio - async_unix async_kernel ;; local libraries mina_base diff --git a/src/lib/syncable_ledger/dune b/src/lib/syncable_ledger/dune index bc08125743..c3c9e3a2a3 100644 --- a/src/lib/syncable_ledger/dune +++ b/src/lib/syncable_ledger/dune @@ -10,10 +10,7 @@ bin_prot.shape base.caml sexplib0 - core - async ;; local libraries - trust_system logger merkle_ledger pipe_lib diff --git a/src/lib/syncable_ledger/syncable_ledger.ml b/src/lib/syncable_ledger/syncable_ledger.ml index 688425cc01..cc7390ee84 100644 --- a/src/lib/syncable_ledger/syncable_ledger.ml +++ b/src/lib/syncable_ledger/syncable_ledger.ml @@ -178,7 +178,7 @@ module type S = sig merkle_tree -> (query -> unit) -> context:(module CONTEXT) - -> trust_system:Trust_system.t + -> trust_system:'trust -> t val answer_query : @@ -188,7 +188,7 @@ module type S = sig val create : merkle_tree -> context:(module CONTEXT) - -> trust_system:Trust_system.t + -> trust_system:'trust -> 'a t val answer_writer : @@ -304,24 +304,21 @@ end = struct { mt : MT.t ; f : query -> unit ; context : (module CONTEXT) - ; trust_system : Trust_system.t } let create : MT.t -> (query -> unit) -> context:(module CONTEXT) - -> trust_system:Trust_system.t + -> trust_system:'trust -> t = - fun mt f ~context ~trust_system -> { mt; f; context; trust_system } + fun mt f ~context ~trust_system:_ -> { mt; f; context } let answer_query : t -> query Envelope.Incoming.t -> answer Or_error.t Deferred.t = - fun { mt; f; context; trust_system } query_envelope -> + fun { mt; f; context } query_envelope -> let open (val context) in - let open Trust_system in let ledger_depth = MT.depth mt in - let sender = Envelope.Incoming.sender query_envelope in let query = Envelope.Incoming.data query_envelope in f query ; let response_or_punish = @@ -329,10 +326,7 @@ end = struct | What_contents a -> if Addr.height ~ledger_depth a > account_subtree_height then Either.Second - ( Actions.Violated_protocol - , Some - ( "Requested too big of a subtree at once" - , [ ("addr", Addr.to_yojson a) ] ) ) + "Requested too big of a subtree at once" else let addresses_and_accounts = List.sort ~compare:(fun (addr1, _) (addr2, _) -> @@ -345,10 +339,7 @@ end = struct (* Peer should know what portions of the tree are full from the Num_accounts query. *) Either.Second - ( Actions.Violated_protocol - , Some - ("Requested empty subtree", [ ("addr", Addr.to_yojson a) ]) - ) + "Requested empty subtree" else let first_address, rest_address = (List.hd_exn addresses, List.tl_exn addresses) @@ -421,39 +412,26 @@ end = struct "When handling What_child_hashes request, the following \ error happended: $error" ; Either.Second - ( Actions.Violated_protocol - , Some - ( "Invalid address in What_child_hashes request" - , [ ("addr", Addr.to_yojson a) ] ) ) ) + "Invalid address in What_child_hashes request" ) | _ -> [%log error] "When handling What_child_hashes request, the depth was \ outside the valid range" ; Either.Second - ( Actions.Violated_protocol - , Some - ( "Invalid depth requested in What_child_hashes request" - , [ ("addr", Addr.to_yojson a) ] ) ) ) + "Invalid depth requested in What_child_hashes request" ) in match response_or_punish with | Either.First answer -> Deferred.return @@ Ok answer - | Either.Second action -> - let%map _ = - record_envelope_sender trust_system logger sender action - in - let err = - Option.value_map ~default:"Violated protocol" (snd action) ~f:fst - in - Or_error.error_string err + | Either.Second err -> + Deferred.return (Or_error.error_string err) end type 'a t = { mutable desired_root : Root_hash.t option ; mutable auxiliary_data : 'a option ; tree : MT.t - ; trust_system : Trust_system.t ; answers : (Root_hash.t * query * answer Envelope.Incoming.t) Linear_pipe.Reader.t ; answer_writer : @@ -675,7 +653,6 @@ end = struct let already_done = match Ivar.peek t.validity_listener with Some `Ok -> true | _ -> false in - let sender = Envelope.Incoming.sender env in let answer = Envelope.Incoming.data env in [%log trace] ~metadata: @@ -697,103 +674,43 @@ end = struct [%log debug] "Got sync response when we're already finished syncing" ; Deferred.unit ) else - let open Trust_system in (* If a peer misbehaves we still need the information we asked them for, so requeue in that case. *) let requeue_query () = Linear_pipe.write_without_pushback_if_open t.queries (root_hash, query) in - let credit_fulfilled_request () = - record_envelope_sender t.trust_system logger sender - ( Actions.Fulfilled_request - , Some - ( "sync ledger query $query" - , [ ("query", Query.to_yojson Addr.to_yojson query) ] ) ) - in + let credit_fulfilled_request () = Deferred.unit in let%bind _ = match (query, answer) with | Query.What_contents addr, Answer.Contents_are leaves -> ( match add_content t addr leaves with | `Success -> credit_fulfilled_request () - | `Hash_mismatch (expected, actual) -> - let%map () = - record_envelope_sender t.trust_system logger sender - ( Actions.Sent_bad_hash - , Some - ( "sent accounts $accounts for address $addr, they \ - hash to $actual but we expected $expected" - , [ ( "accounts" - , `List (List.map ~f:Account.to_yojson leaves) ) - ; ("addr", Addr.to_yojson addr) - ; ("actual", Hash.to_yojson actual) - ; ("expected", Hash.to_yojson expected) - ] ) ) - in + | `Hash_mismatch (_expected, _actual) -> + let%map () = Deferred.unit in requeue_query () ) | Query.Num_accounts, Answer.Num_accounts (count, content_root) -> ( match handle_num_accounts t count content_root with | `Success -> credit_fulfilled_request () - | `Hash_mismatch (expected, actual) -> - let%map () = - record_envelope_sender t.trust_system logger sender - ( Actions.Sent_bad_hash - , Some - ( "Claimed num_accounts $count, content root hash \ - $content_root_hash, that implies a root hash of \ - $actual, we expected $expected" - , [ ("count", `Int count) - ; ("content_root_hash", Hash.to_yojson content_root) - ; ("actual", Hash.to_yojson actual) - ; ("expected", Hash.to_yojson expected) - ] ) ) - in + | `Hash_mismatch (_expected, _actual) -> + let%map () = Deferred.unit in requeue_query () ) | ( Query.What_child_hashes (address, requested_depth) , Answer.Child_hashes_are hashes ) -> ( match add_subtree t address hashes requested_depth with - | `Hash_mismatch (expected, actual) -> - let%map () = - record_envelope_sender t.trust_system logger sender - ( Actions.Sent_bad_hash - , Some - ( "hashes sent for subtree on address $address merge \ - to $actual_merge but we expected $expected_merge" - , [ ("actual_merge", Hash.to_yojson actual) - ; ("expected_merge", Hash.to_yojson expected) - ] ) ) - in + | `Hash_mismatch (_expected, _actual) -> + let%map () = Deferred.unit in requeue_query () | `Invalid_length -> - let%map () = - record_envelope_sender t.trust_system logger sender - ( Actions.Sent_bad_hash - , Some - ( "hashes sent for subtree on address $address must \ - be a power of 2 in the range 2-2^$depth" - , [ ( "depth" - , `Int ledger_sync_config.max_subtree_depth ) - ] ) ) - in + let%map () = Deferred.unit in requeue_query () | `Good children_to_verify -> Array.iter children_to_verify ~f:(fun (addr, hash) -> handle_node t addr hash ) ; credit_fulfilled_request () ) - | query, answer -> - let%map () = - record_envelope_sender t.trust_system logger sender - ( Actions.Violated_protocol - , Some - ( "Answered question we didn't ask! Query was $query \ - answer was $answer" - , [ ("query", Query.to_yojson Addr.to_yojson query) - ; ( "answer" - , Answer.to_yojson Hash.to_yojson Account.to_yojson - answer ) - ] ) ) - in + | _query, _answer -> + let%map () = Deferred.unit in requeue_query () in if @@ -869,14 +786,13 @@ end = struct ignore (new_goal t rh ~data ~equal : [ `New | `Repeat | `Update_data ]) ; wait_until_valid t rh - let create mt ~context ~trust_system = + let create mt ~context ~trust_system:_ = let qr, qw = Linear_pipe.create () in let ar, aw = Linear_pipe.create () in let t = { desired_root = None ; auxiliary_data = None ; tree = mt - ; trust_system ; answers = ar ; answer_writer = aw ; queries = qw diff --git a/src/lib/transaction_protocol_state/dune b/src/lib/transaction_protocol_state/dune index 0b5000b5c2..4fc96d4f4b 100644 --- a/src/lib/transaction_protocol_state/dune +++ b/src/lib/transaction_protocol_state/dune @@ -8,7 +8,6 @@ ;; opam libraries sexplib0 core_kernel - core bin_prot.shape base.caml ;; local libraries diff --git a/src/lib/transaction_snark/dune b/src/lib/transaction_snark/dune index 19d962a37b..c24c2ef87f 100644 --- a/src/lib/transaction_snark/dune +++ b/src/lib/transaction_snark/dune @@ -5,18 +5,15 @@ (inline_tests (flags -verbose -show-counts)) (libraries - ;; opam libraries - async - async_unix + ;; opam libraries + async_kernel bignum - core + core_kernel splittable_random ;; local libraries bitstring_lib bounded_types cache_dir - coda_genesis_ledger - consensus crypto_params currency data_hash_lib @@ -27,7 +24,6 @@ kimchi_pasta kimchi_pasta.basic logger - merkle_ledger mina_base mina_base.util mina_ledger @@ -37,7 +33,6 @@ mina_transaction mina_transaction_logic mina_wire_types - o1trace one_or_two pickles pickles.backend diff --git a/src/lib/transaction_snark/transaction_snark.ml b/src/lib/transaction_snark/transaction_snark.ml index 96e8d27d6f..9c080822d4 100644 --- a/src/lib/transaction_snark/transaction_snark.ml +++ b/src/lib/transaction_snark/transaction_snark.ml @@ -1,4 +1,5 @@ -open Core +open Core_kernel +module Async = Async_kernel open Signature_lib open Mina_base open Mina_transaction @@ -4275,6 +4276,7 @@ module Make_str (A : Wire_types.Concrete) = struct let%test_unit "creating trivial zkapps with different nonces makes unique \ verification keypairs" = + (* let module Async = Original_async in *) let open Async.Deferred.Let_syntax in let test_distinct_verification ~prover ~valid_vk ~invalid_vk = let stmt : Zkapp_statement.t = @@ -4295,16 +4297,16 @@ module Make_str (A : Wire_types.Concrete) = struct assert (Or_error.is_error invalid_verification) in let `VK vk_a, `Prover prover_a = create_trivial_snapp ~unique_id:0 () in - let vk_a = Async.Thread_safe.block_on_async_exn (fun () -> vk_a) in + let vk_a = Run_in_thread.block_on_async_exn (fun () -> vk_a) in let `VK vk_b, `Prover prover_b = create_trivial_snapp ~unique_id:1 () in - let vk_b = Async.Thread_safe.block_on_async_exn (fun () -> vk_b) in + let vk_b = Run_in_thread.block_on_async_exn (fun () -> vk_b) in assert ( not ([%equal: ( Pickles.Side_loaded.Verification_key.t , Snark_params.Tick.Field.t ) With_hash.t] vk_a vk_b ) ) ; - Async.Thread_safe.block_on_async_exn (fun () -> + Run_in_thread.block_on_async_exn (fun () -> let%bind () = test_distinct_verification ~prover:prover_a ~valid_vk:vk_a.data ~invalid_vk:vk_b.data diff --git a/src/lib/transaction_snark/transaction_snark_intf.ml b/src/lib/transaction_snark/transaction_snark_intf.ml index 79f22d2906..5e25ad6840 100644 --- a/src/lib/transaction_snark/transaction_snark_intf.ml +++ b/src/lib/transaction_snark/transaction_snark_intf.ml @@ -1,5 +1,7 @@ +module Async = Async_kernel + module type Full = sig - open Core + open Core_kernel open Mina_base open Mina_transaction open Snark_params diff --git a/src/lib/transaction_snark/transaction_validator.ml b/src/lib/transaction_snark/transaction_validator.ml index 31458d1afa..dc9ba4b1ec 100644 --- a/src/lib/transaction_snark/transaction_validator.ml +++ b/src/lib/transaction_snark/transaction_validator.ml @@ -24,10 +24,9 @@ let apply_user_command ~constraint_constants ~txn_global_slot l uc = (Ledger.apply_user_command l' ~constraint_constants ~txn_global_slot uc) ) let apply_transactions' ~constraint_constants ~global_slot ~txn_state_view l t = - O1trace.sync_thread "apply_transaction" (fun () -> - within_mask l ~f:(fun l' -> - Ledger.apply_transactions ~constraint_constants ~global_slot - ~txn_state_view l' t ) ) + within_mask l ~f:(fun l' -> + Ledger.apply_transactions ~constraint_constants ~global_slot + ~txn_state_view l' t ) let apply_transactions ~constraint_constants ~global_slot ~txn_state_view l txn = @@ -35,13 +34,12 @@ let apply_transactions ~constraint_constants ~global_slot ~txn_state_view l txn let apply_transaction_first_pass ~constraint_constants ~global_slot ~txn_state_view l txn : Ledger.Transaction_partially_applied.t Or_error.t = - O1trace.sync_thread "apply_transaction_first_pass" (fun () -> - within_mask l ~f:(fun l' -> - Ledger.apply_transaction_first_pass l' ~constraint_constants - ~global_slot ~txn_state_view txn ) ) + within_mask l ~f:(fun l' -> + Ledger.apply_transaction_first_pass l' ~constraint_constants ~global_slot + ~txn_state_view txn ) let%test_unit "invalid transactions do not dirty the ledger" = - let open Core in + let open Core_kernel in let open Mina_numbers in let open Currency in let open Signature_lib in diff --git a/src/lib/transaction_snark_work/dune b/src/lib/transaction_snark_work/dune index 2dc6e16c1f..44eedb03a0 100644 --- a/src/lib/transaction_snark_work/dune +++ b/src/lib/transaction_snark_work/dune @@ -8,7 +8,6 @@ bin_prot.shape base.caml base.base_internalhash_types - core ;; local libraries currency transaction_snark diff --git a/src/lib/transaction_witness/dune b/src/lib/transaction_witness/dune index 0b073a8138..d133ce02f3 100644 --- a/src/lib/transaction_witness/dune +++ b/src/lib/transaction_witness/dune @@ -9,7 +9,6 @@ bin_prot.shape sexplib0 core_kernel - core ;; local libraries currency signature_lib diff --git a/src/lib/trust_system/dune b/src/lib/trust_system/dune index 3031920c73..bba862f8c9 100644 --- a/src/lib/trust_system/dune +++ b/src/lib/trust_system/dune @@ -5,7 +5,6 @@ (libraries ;; opam libraries sexplib0 - core ppx_inline_test.config base.caml async_kernel @@ -13,11 +12,8 @@ bin_prot.shape base result - async - async_unix ;; local libraries mina_metrics - rocksdb pipe_lib logger key_value_database diff --git a/src/lib/trust_system/peer_trust.ml b/src/lib/trust_system/peer_trust.ml index bfd9210958..1e8a9bd539 100644 --- a/src/lib/trust_system/peer_trust.ml +++ b/src/lib/trust_system/peer_trust.ml @@ -1,4 +1,4 @@ -open Core +open Core_kernel open Async_kernel open Pipe_lib @@ -28,7 +28,7 @@ module type Input_intf = sig module Peer_id : sig type t [@@deriving sexp, to_yojson] - val ip : t -> Unix.Inet_addr.Blocking_sexp.t + val ip : t -> Network_peer.Peer.Inet_addr.t end module Now : sig @@ -63,8 +63,7 @@ module Time_with_json = struct let of_yojson = function | `String time -> - Ok - (Time.of_string_gen ~if_no_timezone:(`Use_this_one Time.Zone.utc) time) + Ok (Time.of_string time) | _ -> Error "Trust_system.Peer_trust: Could not parse time" end @@ -148,7 +147,7 @@ module Make0 (Inputs : Input_intf) = struct let lookup_ip t ip = List.filter (peer_statuses t) ~f:(fun (p, _status) -> - Unix.Inet_addr.equal (Peer_id.ip p) ip ) + Network_peer.Peer.Inet_addr.compare (Peer_id.ip p) ip = 0 ) let reset_ip ({ db; _ } as t) ip = Option.value_map db ~default:() ~f:(fun db' -> @@ -252,7 +251,7 @@ let%test_module "peer_trust" = module Peer_id = struct type t = int [@@deriving sexp, yojson] - let ip t = Unix.Inet_addr.of_string (sprintf "127.0.0.%d" t) + let ip t = Caml_unix.inet_addr_of_string (sprintf "127.0.0.%d" t) end module Action = struct @@ -305,7 +304,7 @@ let%test_module "peer_trust" = let setup_mock_db () = let res = - Async_unix__Thread_safe.block_on_async_exn (fun () -> + Run_in_thread.block_on_async_exn (fun () -> Peer_trust_test.create () ) in don't_wait_for @@ -320,7 +319,7 @@ let%test_module "peer_trust" = let nolog = Logger.null () - let ip_of_id id = Unix.Inet_addr.of_string (sprintf "127.0.0.%d" id) + let ip_of_id id = Caml_unix.inet_addr_of_string (sprintf "127.0.0.%d" id) let peer0 = ip_of_id 0 @@ -341,8 +340,11 @@ let%test_module "peer_trust" = let%map () = Peer_trust_test.record db nolog 0 Insta_ban in match Peer_trust_test.lookup_ip db peer0 with | [ (_, { trust = -1.0; banned = Banned_until time }) ] -> - [%test_eq: Time.t] time - @@ Time.add !Mock_now.current_time Time.Span.day ; + [%test_eq: string] + (Time.to_string_abs time ~zone:Time.Zone.utc) + (Time.to_string_abs + (Time.add !Mock_now.current_time Time.Span.day) + ~zone:Time.Zone.utc ) ; assert_upcall_pipe [ 0 ] ; true | _ -> @@ -496,12 +498,28 @@ module Make (Action : Action_intf) = Make0 (struct end module Config = String - module Db = - Rocksdb.Serializable.Make - (Network_peer.Peer.Stable.Latest) + + module Mock_db = + Key_value_database.Make_mock + (Network_peer.Peer) (Record.Stable.Latest) + + module Db = struct + type t = Mock_db.t + type config = string + + let create (_ : config) = Mock_db.create () + let get = Mock_db.get + let get_batch = Mock_db.get_batch + let set = Mock_db.set + let remove = Mock_db.remove + let close = Mock_db.close + let set_batch = Mock_db.set_batch + let to_alist = Mock_db.to_alist + end + module Action = Action include Log_events - let remove_dir = File_system.remove_dir + let remove_dir _ = Deferred.unit end) diff --git a/src/lib/trust_system/peer_trust.mli b/src/lib/trust_system/peer_trust.mli index 6c8b1ffffc..123f805d01 100644 --- a/src/lib/trust_system/peer_trust.mli +++ b/src/lib/trust_system/peer_trust.mli @@ -8,7 +8,7 @@ responsibility of the caller, which is Trust_system. *) open Async_kernel -open Core +open Core_kernel open Pipe_lib (** What we do in response to some trust-affecting action. *) @@ -75,13 +75,13 @@ module Make (Action : Action_intf) : sig (** Look up the score of all peers associated with an IP and whether they are banned .*) val lookup_ip : t - -> Unix.Inet_addr.Blocking_sexp.t + -> Network_peer.Peer.Inet_addr.t -> (Network_peer.Peer.t * Peer_status.t) list (** reset status of all peers associated with an IP; return the reset statuses *) val reset_ip : t - -> Unix.Inet_addr.Blocking_sexp.t + -> Network_peer.Peer.Inet_addr.t -> (Network_peer.Peer.t * Peer_status.t) list (** get all peer, status pairs in the trust system *) diff --git a/src/lib/trust_system/record.ml b/src/lib/trust_system/record.ml index 50204f833f..23e63c7033 100644 --- a/src/lib/trust_system/record.ml +++ b/src/lib/trust_system/record.ml @@ -1,12 +1,12 @@ -open Core +open Core_kernel [%%versioned module Stable = struct module V1 = struct type t = { trust : float - ; trust_last_updated : Core.Time.Stable.V1.t - ; banned_until_opt : Core.Time.Stable.V1.t option + ; trust_last_updated : (Time.t[@version_asserted]) + ; banned_until_opt : ((Time.t[@version_asserted]) option) } let to_latest = Fn.id diff --git a/src/lib/trust_system/record.mli b/src/lib/trust_system/record.mli index fd880f2436..b75fb29028 100644 --- a/src/lib/trust_system/record.mli +++ b/src/lib/trust_system/record.mli @@ -5,6 +5,8 @@ module Stable : sig end end] +open Core_kernel + module type S = sig val init : unit -> t @@ -18,6 +20,6 @@ end val decay_rate : float module Make (Now : sig - val now : unit -> Core.Time.t + val now : unit -> Time.t end) : S [@@warning "-67"] diff --git a/src/lib/trust_system/trust_system.ml b/src/lib/trust_system/trust_system.ml index 44ed0c8c9c..97356d0042 100644 --- a/src/lib/trust_system/trust_system.ml +++ b/src/lib/trust_system/trust_system.ml @@ -1,5 +1,5 @@ (** The trust system, instantiated with Coda-specific stuff. *) -open Core +open Core_kernel open Async_kernel diff --git a/src/lib/vrf_lib/dune b/src/lib/vrf_lib/dune index 2549d1d3da..cb80309279 100644 --- a/src/lib/vrf_lib/dune +++ b/src/lib/vrf_lib/dune @@ -9,7 +9,6 @@ bignum.bigint bin_prot.shape base.caml - core sexplib0 core_kernel bignum diff --git a/src/lib/vrf_lib/standalone.ml b/src/lib/vrf_lib/standalone.ml index e79c7b8bfa..e3c00b3aca 100644 --- a/src/lib/vrf_lib/standalone.ml +++ b/src/lib/vrf_lib/standalone.ml @@ -1,4 +1,4 @@ -open Core +open Core_kernel (* This VRF is based on the one described in appendix C of https://eprint.iacr.org/2017/573.pdf *) @@ -290,7 +290,7 @@ end = struct end end -open Core +open Core_kernel module Bigint_scalar (Impl : Snarky_backendless.Snark_intf.S) (M : sig