Git Product home page Git Product logo

minaprotocol / mina Goto Github PK

View Code? Open in Web Editor NEW
2.0K 101.0 525.0 536.92 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 86.88% Shell 2.33% Makefile 0.17% Nix 0.48% Dockerfile 0.01% Python 0.51% HTML 0.06% Rust 3.27% JavaScript 0.66% C 0.01% Go 3.43% Reason 0.28% TeX 0.11% Ruby 0.01% Dhall 1.63% GAP 0.01% Smarty 0.12% Mustache 0.06% Awk 0.01% Jinja 0.01%
cryptocurrency blockchain ocaml zk-snarks mina

mina's Introduction

Build status

Develop Compatible Master
Build status - develop Build status - compatible Build status - master

Mina logo

Mina is the first cryptocurrency with a lightweight, constant-sized blockchain. This is the main source code repository for the Mina project and contains code for the OCaml protocol implementation, the Mina Protocol website, and wallet. Enjoy!

Notes

Mina is still under active development and APIs are evolving. If you build on the APIs, be aware that breaking changes can occur.

The Mina implementation of the Rosetta API offers a more stable and useful interface for retrieving the blockchain's state. Rosetta is run as a separate process and it relies on an archive being connected to a node. The source code for the archive and Rosetta implementation are in src/app/archive and src/app/rosetta. Be sure to follow updates in the project if these resources are relocated.

What is Mina?

Mina Walkthrough

Technical Papers

Blog

Contributing

For information on how to make technical and non-technical contributions, see the repository contributing guidelines in CONTRIBUTING and the Contributing Guide docs.

Developers

The Node Developers docs contain helpful information about contributing code to Mina and using Mina APIs to build applications.

Quick Links

Community

  • Join the public Mina Protocol Discord server. Please come by if you need help or have any questions.
  • Participate in our online communities.
  • Get the latest updates by signing up for the Mina newsletter. Select SIGN UP FOR NEWSLETTER on the home page of the Mina Protocol website.

License

Apache 2.0

Commits older than 2018-10-03 do not have a LICENSE file or this notice, but are distributed under the same terms.

mina's People

Contributors

balsoft avatar bkase avatar dannywillems avatar deepthiskumar avatar dkijania avatar emberian avatar figitaki avatar firobe avatar georgeee avatar ghost-not-in-the-shell avatar imeckler avatar joaosreis avatar jspada avatar lk86 avatar martinminkov avatar mergify[bot] avatar michellewong793 avatar mimoo avatar mitschabaude avatar mrmr1993 avatar nholland94 avatar o1ahmad avatar psteckler avatar querolita avatar quitestochastic avatar rbonichon avatar schmavery avatar sventimir avatar wu-s-john avatar ylecornec avatar

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

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

Tidy up broadcast

I suggest changing the type of Gossip_net.broadcast_all to

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

miner loop

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

speed up loading keys

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

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.

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

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

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.

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
  )

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.

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.

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

transaction comparison

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

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

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

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.

"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.

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.

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.

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.