Coder Social home page Coder Social logo

minaprotocol / mina Goto Github PK

View Code? Open in Web Editor NEW
1.9K 1.9K 512.0 525.25 MB

Mina is a cryptocurrency protocol with a constant size blockchain, improving scaling while maintaining decentralization and security.

Home Page: https://minaprotocol.com

License: Apache License 2.0

OCaml 87.13% Shell 2.55% Makefile 0.17% Nix 0.48% Dockerfile 0.01% Python 0.51% HTML 0.06% Rust 3.20% JavaScript 0.66% C 0.01% Go 3.41% Reason 0.28% TeX 0.10% Ruby 0.01% Dhall 1.24% GAP 0.01% Smarty 0.13% Mustache 0.06% Awk 0.01% Jinja 0.01%
blockchain cryptocurrency mina ocaml zk-snarks

mina's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mina's Issues

Unify interpreters in snarky

Right now in snarky there are a bunch of different interpreters, which all essentially do the same recursion over the AST. I think these should be unified to reduce bug surface area

speed up loading keys

For some reason deserialization of keys in libsnark is very slow. This should be fixed

Functor over slow crypto EVERYWHERE so we can quickcheck more things

Conservation of wealth quickcheck test takes ~10seconds per trial inside Nanobit_base.ledger.ml

Keeping code here so we can put it back when we functor out the slow things.

let gen_perturbations ledger keys : t Quickcheck.Generator.t =
  let open Quickcheck.Generator in
  let open Quickcheck.Generator.Let_syntax in
  let ledger = copy ledger in
  let%bind changes = Int.gen_incl 1 100 in
  let%map transactions =
    list_with_length changes
      (Transaction.With_valid_signature.gen ~keys ~max_amount:100 ~max_fee:0)
  in
  List.iter transactions ~f:(fun txn ->
    apply_transaction ledger txn |> Or_error.ok_exn
  );
  ledger

let gen : (t * Signature_keypair.t array) Quickcheck.Generator.t =
  let ledger = create () in
  let open Quickcheck.Generator in
  let open Quickcheck.Generator.Let_syntax in
  let%bind num_accounts = Int.gen_incl 1 1000 in
  let keys = Array.init num_accounts ~f:(fun _ -> Signature_keypair.create ()) in
  (* Setup ledger *)
  printf "Begin setup\n%!";
  Array.iter keys ~f:(fun k ->
    let public_key = Public_key.compress k.public_key in
    update ledger public_key
      { public_key; balance = Currency.Balance.of_int 10_000 });
  printf "end setup\n%!";
  let%map ledger' = gen_perturbations ledger keys in
  printf "end perturbation\n%!";
  (ledger', keys)

let%test_unit "conservation_of_wealth" =
  let open Quickcheck.Generator in
  let open Quickcheck.Generator.Let_syntax in
  let gen =
    let%bind (ledger, keys) = gen in
    let%map ledger' = gen_perturbations ledger keys in
    (ledger, ledger')
  in
  let x = ref 0 in
  Quickcheck.test ~trials:100 gen ~f:(fun (ledger, ledger') ->
    let wealth ledger : Int64.t =
      List.fold (to_list ledger) ~init:Int64.zero ~f:(fun acc {balance} ->
        Int64.(+) acc (balance |> Currency.Balance.to_string |> Int64.of_string) )
    in
    let old_wealth = wealth ledger in
    let new_wealth = wealth ledger' in
    if new_wealth <> old_wealth then begin
      failwithf !"New_wealth %{sexp: Int64.t} is different from old_wealth %{sexp: Int64.t}" new_wealth old_wealth ();
    end;
    x := !x + 1;
    printf "Done with one trial %d\n%!" !x
  )

Eviction policy for queued ledger_fetcher get_ledger_at_hash calls

Eviction policy right now is "evict no one and crash if the buffer gets too big"

Alternatives:

  1. Queue up every new partial state as they enter the ledger fetcher and then evict all but the strongest state's ledger-hash
  2. Implement #177 and just cancel a few whenever we get too far behind, but keep downloading all of them.

More thought is required to actually decide which of the alternatives is best

Profile witness generation

Right now witness generation is kinda slow. I suspect a lot of time is eaten up in evaluating Cvar.ts, which are just ASTs of + and * with indices into an array at the leaves. There is sharing between Cvar.ts so this should be reflected in sharing intermediate results of computation.

Merkle ledger: support delete

Merkle ledger should have a delete operation. Specifically, we should have (at least)

val remove_at_index : t -> index -> unit

and keep track of which indices are empty, and then update can put new accounts into some arbitrary empty index.

Enable multicore for libsnark

NB: Libsnark multicore doesn't work in processes that are using async, so we'd have to start a process that didn't use async

Get rid of `= private Cvar.t`

definitions like

module Boolean : sig
  type var = private Cvar.t
end

are ultimately I think bad, because the coercion to Cvar.t leaves implicit the mapping between booleans and field elements. It would be better to have a function Boolean.to_zero_one : Boolean.var -> Cvar.t

Use Or_error in as_prover

Right now as_prover code throws sometimes, it would be nice if error'ing were more explicit. So, we should add Or_error to the As_prover monad stack

Use shared memory for the proving keys

Right now every process that does proving has a separate copy of the proving keys. The result is memory usage is several times worse than it should be. This is bad, we should change it.

"transition hashes"

Transition hashes should probably just go in the state so that states have computationally unique histories. As is, there is "malleability" in terms of what the nonce is as it's not included in the state.

write_or_drop

I suggest getting rid of write_or_drop as its use can be a bit error prone since there is not necessarily any relationship between the writer and reader provided.

miner loop

Miner loop doesn't yield to the scheduler. As a work around we've stuck a sleep in the loop

Unify "unpacked" and "packed" variables

Have a system like "number" which unifies packed and unpacked variables. It's annoying having to manually track around things that get packed and unpacked. Would be better to have "lazy" evaluation for unpacking so that any repeated unpacking is free.

transaction comparison

Use a different hash function on each client for comparing transactions to prevent grinding for priority.

Handle production flag for Kademlia

We need to:

  1. Not make keys deterministic based on the address
  2. Not try peers in a deterministic order
  3. Change some of the config (ex. to make the ping time 1hour, ala Cardano)

See comment in Main.hs of Kademlia-Haskell

Add `Linear_pipe.write_or_flush_downstream` or something similar

We have write_or_drop (which is prefer earlier thing)
We have write_or_exn (which means die if data gets backed up)
We don't have the "prefer later things" notion. What we'd want to do here is make some way to cancel downstream tasks that haven't finished yet to unblock the pipes.

Specifically we possibly want to use this when we're being too slow at getting ledgers but fast at generating ledger-hashes for the ledger-fetcher since this will prevent the miner from getting the most up-to-date information fast enough.

Make a `Process` module that doesn't leak processes after ocaml death

We currently spawn long-running processes to help us do work (see Kademlia).

Unfortunately, Core's Process module doesn't kill these spawned processes for us.

We should change Process to automatically cleanup after itself. ie: When this OCaml process dies, the process we spawned is also killed.

Tidy up broadcast

I suggest changing the type of Gossip_net.broadcast_all to

t -> Message.t -> (unit -> [`Done | `Continue] Deferred.t) Staged.t

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.