Giter VIP home page Giter VIP logo

yt-chain's Introduction

yt-chain

Build Status

yt-chain is just a toy of blockchain inspired by this article Learn Blockchains by Building One. Originally, that's python based project, so I want to use rust to implement a one, and giving some improvements to the rust based one.

Platforms supported

  • Linux(including raspberry pi, aarch64, x86)
  • Windows

Stacks

  • rust. A systems programming language that runs blazingly fast, prevents segfaults, and guarantees thread safety.
  • actix-web. A blazingly fast asynchronous web framework based on Rust.
  • sled. This is a lock-free embedded database, purely written by rust, having high performance and easy usage, etc.
  • CUDA. A parallel computing platform and programming model that enables dramatic increases in computing performance by harnessing the power of the graphics processing unit (GPU). Use gpu to accelerate mining block instead of cpu.

Requirements

  1. Linux platform.
  2. Latest stable/nightly rust.
    • If you want to run this project on raspberry pi, use nightly rust, and uncomment line 39, 40 in file Cargo.toml to enable "nightly" feature of sled, due to the bug 32-bit ARM compatibility.
  3. CUDA installed(at least 8.0, and device is capable of compute capability at least 3.5).
    • This is for accelerating mining blocks, there're some implemented encryption algorithms like sha256/384/512. It's optional, if you don't use GPU to mine blocks.
  4. CMake(at least 3.8).

Build && Run

  • Configure the yt-chain.toml file
CPU mining mode

If you want cpu to mine the block, use following command to build the project

cargo run --release
GPU mining mode

But if you want to try GPU(CUDA) to mine blocks, run the coming command.

cargo run --features "cuda" --release

These mining algorithms are optimized, no bank conflicts, aligned accessing global memory, close to 100% occupancy. I tested it on my device(Jetson TX2), which is a pascal featured embedded device. It only has 256 CUDA cores, runs 2048 ร— 2 threads at a time.

If you compile the project on desktop computer(equipped GTX series graphic card), it will run much faster than this device. Such as GTX-1080/GTX-2080 device, having 2560 CUDA cores, in theory, it should be 10x faster than my testing device at least, and the memory bandwidth is much bigger than Jetson TX2.

Calculate 2048ร—100 elements at a time

Algorithm Time cost on kernel(cuda function)
sha256 1.50ms
sha384 3.83ms
sha512 3.92ms

Usage

There're some APIs created for operate the server.

  • /chain/ get the whole block chain
  • /mine/ mine a new block, and add it to the block chain
  • /transaction/new/ create a transaction to current block chain
  • /nodes/register/ add a another block chain server to current node server
  • /nodes/resolve/ get consensus with the registered node server
Mining.

mining

Get the whole blockchain.

chains

Transaction.

transaction

Before this operation, start a another node server.

Register a node

register

Consensus.

consensus

yt-chain's People

Contributors

dengjianping avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

sbnair

yt-chain's Issues

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.