Ako - A Generic Hashgraph Based Consensus Engine
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.circleci
cmd
common
crypto
demo
docker
hashgraph
img
mobile
net
node
proxy
research/spike
scripts
service
terraform
version
.gitignore
LICENSE
README.md
glide.lock
glide.yaml
makefile

README.md

AKO

BFT Consensus platform for distributed applications.

Ako allows many computers to behave as one. It uses Peer to Peer (P2P) networking and a consensus algorithm to guarantee that multiple connected computers process the same commands in the same order; a technique known as state machine replication. This makes for secure systems that can tolerate arbitrary failures including malicious behaviour.

Ako is based on and heavily modifies the amazing work done by Babble

NOTE: This is alpha software. Please contact us if you intend to run it in production.

Consensus Algorithm and Blockchain

We use the Hashgraph consensus algorithm, invented by Leemon Baird. It is best described in the white-paper and its accompanying document. The algorithm is protected by patents in the USA. Therefore, anyone intending to use this software in the USA should obtain a license from the patent holders.

Hashgraph is based on the intuitive idea that gossiping about gossip itself yields enough information to compute a consensus ordering of events. It attains the theoretical limit of tolerating up to one-third of faulty nodes without compromising on speed. For those familiar with the jargon, it is a leaderless, asynchronous BFT consensus algorithm.

Ako projects the output of the consensus algorithm onto a linear blockchain which is more suitable for representing an ordered list of transactions and facilitates the creation of light-clients. For information about this projection we are in the process of compiling documentation.

Design

Ako is designed to integrate with applications written in any programming language.

    +--------------------------------------+
    | APP                                  |
    |                                      |
    |  +-------------+     +------------+  | 
    |  | Service     | <-- | State      |  |
    |  |             |     |            |  |
    |  +-------------+     +------------+  |
    |          |                |          |
    |       +----------------------+       |
    |       | Ako Proxy         |       |
    |       +----------------------+       |
    |          |                ^          |
    +----------|----------------|----------+
               |                |
--------- SubmitTx(tx) ---- CommitBlock(Block) ------- (JSON-RPC/TCP)
               |                |
 +-------------|----------------|------------------------------+
 | AKO      |                |                              |
 |             v                |                              |
 |          +----------------------+                           |
 |          | App Proxy            |                           |
 |          |                      |                           |
 |          +----------------------+                           |
 |                     |                                       |
 |   +-------------------------------------+                   |
 |   | Core                                |                   |
 |   |                                     |                   |
 |   |                                     |    +----------+   |
 |   |  +-----------+        +---------+   |    | Service  |   |
 |   |  | Hashgraph |        | Store   |   | -- |          | <----> HTTP API
 |   |  +-----------+        +----------   |    |          |   |
 |   |                                     |    +----------+   |
 |   |                                     |                   |
 |   +-------------------------------------+                   |
 |                     |                                       |
 |   +-------------------------------------+                   |
 |   | Transport                           |                   |
 |   |                                     |                   |
 |   +-------------------------------------+                   |
 |                     ^                                       |
 +---------------------|---------------------------------------+
                       |
                       v

                    Network

Almost any software application can be modelled in terms of a service and a state. The service is responsible for processing commands (ex. user input), while the state is responsible for manipulating and storing the data (eg. database). Usually, when commands require updating the data, the service will invoke the state directly. In a distributed application, however, commands (referred to as transactions in this context), must be broadcasted to all replicas and put in a common order before being applied to the state. This is what ensures that all replicas process the same commands in the same order. Hence, the service no longer communicates directly with the state (except for read-only requests), but forwards commands to a transaction ordering system which takes care of broadcasting and ordering the transactions across all replicas before feeding them back to the application's state.

Ako is an ordering system that plugs into any application thanks to a very simple JSON-RPC interface over TCP. It uses a consensus algorithm, to replicate and order the transactions, and a blockchain to represent the resulting list. A blockchain is a linear data structure composed of batches of transactions, hashed and signed together, easily allowing to verify any transaction. So, instead of applying commands directly to the state, Ako applications must forward the commands to Ako and let them be processed asynchronously by the consensus system before receiving them back, in blocks, ready to be applied to the state.

Build from source

The easiest way to build binaries is to do so in a hermetic Docker container. Use this simple command:

[...]/ako$ make dist

This will launch the build in a Docker container and write all the artifacts in the build/ folder.

[...]/ako$ tree build
build/
├── dist
│   ├── ako_0.1.0_darwin_386.zip
│   ├── ako_0.1.0_darwin_amd64.zip
│   ├── ako_0.1.0_freebsd_386.zip
│   ├── ako_0.1.0_freebsd_arm.zip
│   ├── ako_0.1.0_linux_386.zip
│   ├── ako_0.1.0_linux_amd64.zip
│   ├── ako_0.1.0_linux_arm.zip
│   ├── ako_0.1.0_SHA256SUMS
│   ├── ako_0.1.0_windows_386.zip
│   └── ako_0.1.0_windows_amd64.zip
└── pkg
    ├── darwin_386
    │   └── ako
    ├── darwin_amd64
    │   └── ako
    ├── freebsd_386
    │   └── ako
    ├── freebsd_arm
    │   └── ako
    ├── linux_386
    │   └── ako
    ├── linux_amd64
    │   └── ako
    ├── linux_arm
    │   └── ako
    ├── windows_386
    │   └── ako.exe
    └── windows_amd64
        └── ako.exe

Dev

Go

Ako is written in Golang. Hence, the first step is to install Go version 1.9 or above which is both the programming language and a CLI tool for managing Go code. Go is very opinionated and will require you to define a workspace where all your go code will reside.

Ako and dependencies

Clone the repository in the appropriate GOPATH subdirectory:

$ mkdir -p $GOPATH/src/github.com/fulcrumchain/
$ cd $GOPATH/src/github.com/fulcrumchain
[...]/fulcrumchain$ git clone https://github.com/fulcrumchain/ako.git

Ako uses Glide to manage dependencies.

[...]/ako$ curl https://glide.sh/get | sh
[...]/ako$ glide install

This will download all dependencies and put them in the vendor folder.

macOS requirements

Bash scripts used in this project assume the use of gnu versions of coreutils.

Please ensure you have gnu versions of these programs installed:-

# --with-default-names makes the `sed` and `awk` commands default to gnu sed and gnu awk respectively.
brew install gnu-sed gawk --with-default-names

Testing

Ako has extensive unit-testing. Use the Go tool to run tests:

[...]/ako$ make test

If everything goes well, it should output something along these lines:

ok      github.com/fulcrumchain/ako/net      0.052s
ok      github.com/fulcrumchain/ako/common   0.011s
?       github.com/fulcrumchain/ako/cmd      [no test files]
?       github.com/fulcrumchain/ako/cmd/dummy_client [no test files]
ok      github.com/fulcrumchain/ako/hashgraph        0.174s
ok      github.com/fulcrumchain/ako/node     1.699s
ok      github.com/fulcrumchain/ako/proxy    0.018s
ok      github.com/fulcrumchain/ako/crypto   0.028s