Git Product home page Git Product logo

go-dag's Introduction

GoDAG

BlockDAG algorithms Go Lang simulation.

BlockChain (for example Bitcoin, Etherum, etc.) is just a 'k=0' special subtype of BlockDAG, that's why they suffer from the highly restrictive throughput. DAG is the future!

Thanks Yonatan Sompolinsky and Aviv Zohar for the most important contributions on blockDAG research, and their great paper "PHANTOM: A Scalable BlockDAG protocol" on International Association for Cryptologic Research (IACR) in Feb. 2018.

They setup a start-up company to develop BlockDAG since Q4 2017, their website: [https://www.daglabs.com]. And there's an official DAGlabs slack channel: [https://daglabs.slack.com].


How to build this simulation

Here is my Go Lang environment, the other Go version such as 1.9 should also be OK.

$ go version
go version go1.10.1 darwin/amd64

To run the simulation for the example on the paper page 7 Fig.3 or page 16 Fig.4, for algorithm 1 Selection of a blue set.

$ go test -run=Fig3
$ go test -run=Fig4

To add a new example DAG to see the DAG blue selection behaviour, it's quite easy. For example, to test a DAG in this figure 'Fig.4', just add a piece of codes like this: Fig.4

	ChainAddBlock("Genesis", []string{}, chain)

	ChainAddBlock("B", []string{"Genesis"}, chain)
	ChainAddBlock("C", []string{"Genesis"}, chain)
	ChainAddBlock("D", []string{"Genesis"}, chain)
	ChainAddBlock("E", []string{"Genesis"}, chain)

	ChainAddBlock("F", []string{"B","C"}, chain)
	ChainAddBlock("I", []string{"C","D"}, chain)
	ChainAddBlock("H", []string{"E"}, chain)

	ChainAddBlock("J", []string{"F","D"}, chain)
	ChainAddBlock("L", []string{"F"}, chain)
	ChainAddBlock("K", []string{"J","I","E"}, chain)
	ChainAddBlock("N", []string{"D","H"}, chain)

	ChainAddBlock("M", []string{"L","K"}, chain)
	ChainAddBlock("O", []string{"K"}, chain)
	ChainAddBlock("P", []string{"K"}, chain)
	ChainAddBlock("Q", []string{"N"}, chain)

	ChainAddBlock("R", []string{"O","P","N"}, chain)

	ChainAddBlock("S", []string{"Q"}, chain)
	ChainAddBlock("T", []string{"S"}, chain)
	ChainAddBlock("U", []string{"T"}, chain)

Click to Run the demo

And Run it in Go Playground : #c5f015Click to Run#c5f015. You can edit your blockDAG example and run the 'blue selection algorithm' online! The output will be like this:

- BlockDAG Algorithms Simulation - Algorithm 1: Selection of a blue set. -
chainInitialize(): done. blocks= 20
blue set selection done. blue blocks = (G).B.C.D.F.I.J.K.O.P.M.R.(V). 	total blue: 13

Other Tests

To run the simulation for the example on page 3 Fig.2, page 8 "C. Step #2", for algorithm 2 Ordering of the DAG.

$ go test -run=Fig2

To run the benchmark test:

$ go test ./phantom -bench=Blocks -benchmem

$ go test ./ -test.bench BlueSelection -benchmem  -run=^$

$ go test ./ -test.bench BlockOrdering -benchmem  -run=^$

Engagement

Please join us the BlockDAG discussion on https://godag.github.io.

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.