Skip to content

Commit

Permalink
Merge develop into master (#144)
Browse files Browse the repository at this point in the history
* Fix issues discovered by codacy

* Fix test.sh (2)

* Fix test.sh again

* Commented test "connection_with_grpc"
test.sh uses return codes in order to determine the successful test execution.
It runs all tests **without any arguments**, but connection_with_grpc requires 2 arguments.
Please, setup default args and uncomment.

* Bugfix in script/mktar-iroha.sh

* add dockerhub documentation

* add more explanation

* add text

* Improve documentation
- Move from README to docs
- Fix mistakes
  • Loading branch information
Warchant committed Jan 26, 2017
1 parent 0d33b6a commit 5efc068
Show file tree
Hide file tree
Showing 15 changed files with 361 additions and 354 deletions.
288 changes: 9 additions & 279 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,293 +7,23 @@

![alt tag](Iroha_3_sm.png)


# Pull Requests
Please include a developer certificate with pull requests: https://www.clahub.com/agreements/hyperledger/iroha

# How to build
[how_to_build](https://github.com/hyperledger/iroha/blob/master/docs/how_to_build.rst)


# Architecture (Draft)

### Directory tree
```
.
├── build (for cmake)
├── config
├── core
│   ├── consensus
│   │   └── connection
│   ├── crypto
│   ├── infra
│   │   ├── connection
│   │   ├── crypto
│   │   ├── protobuf
│   │   ├── repository
│   │   ├── server
│   │   ├── service
│   │   └── smart_contract
│   │   └── jvm
│   ├── model
│   │   ├── commands
│   │   ├── objects
│   │   ├── smart_contract
│   │   ├── state
│   │   ├── publisher
│   │   ├── repository
│   │   └── state
│   ├── publisher
│   ├── repository
│   │   ├── consensus
│   │   └── domain
│   ├── server
│   ├── service
│   ├── util
│   ├── validation
│   └── vendor
│      ├── Cappucino
│      ├── ed25519
│      ├── json
│      ├── KeccakCodePackage
│      ├── leveldb
│      └── thread_pool_cpp
├── docker
│   ├── build
│   │   └── scripts
│   ├── config-discovery
│   └── dev
│      └── scripts
├── docs
├── peer
├── smart_contract
│   └── SampleCurrency
├── test
│ ├── connection
│ ├── consensus
│ ├── crypto
│ ├── infra
│   │   ├── protobuf
│   │   └── repository
│ ├── smart_contract
│ └── vendor
├── tools
```

#### config/

It contains config file. currently we use yaml, but JSON is good like as yaml.

#### peer/

It contains main.cpp

#### smart_contract/

It contains smart_contract logic what user defines.
Currently use java virtual machine.

#### test/

There's few tests for iroha. :bow:
We accept pull requests.

#### core/

It contains main.

```
├── connection
├── consensus
├── crypto
├── domain
│   └── transactions
├── infra
│   ├── connection
│   ├── crypto
│   ├── repository
│   ├── server
│   └── smart_contract
│   └── jvm
├── repository
├── server
├── smart_contract
├── util
└── validation
```

We adopt a **Domain-Driven Development structure** as much as possible.

```
front API
|(1)
┌-------------┐
+ Cappuccino +------------------------
└--+----------┘
|
|
┌--┼----------┐ ┌---------------┐
| V sumeragi |(3) | Command exec |
| ----------+> |
└--|-------A--┘ └----+----------┘
|(2) | valdation |
| └-----------------┼------┐
| | |
|consensus building |(4) |
┌------------┐ ┌-V------+------┐ ┌-------┐
| connection | | repository |------ model |
└------------┘ └---------------┘ └-------┘
| |
Infra=|=============================|===========
|implement |implement
┌------┐ ┌-----┐
| grpc | | D B |
└------┘ └-----┘
```

#### core/connection (consensus layer)
It contains the P2P messaging function interface.
```C
void initialize_peer( std::unordered_map<std::string, std::string> config);

bool sendAll(std::string message);
bool send(std::string to,std::string message);
bool receive(std::function<void(std::string from,std::string message)> callback);
```
#### core/consensus (consensus layer)
It contains the consensus algorithm(s).
#### core/crypto (service)
It contains digital signature algorithms, base64, hash function interfaces, etc.
#### core/model (domain)
It contains asset model, transaction logic. independent of infra knowledge.
#### core/infra (infra layer)
It contains some source depend on vendor (third party) libraries.
If any source depends on vendor libraries, it should be in infra.
##### filenames
Filenames follow the convention: `"function"_with_"lib name".cpp`
```
connection
└── connection_with_aeron.cpp
repository
└── world_state_repository_with_level_db.cpp
```
#### core/server (UI layer)
It contains the server interface, currently.
```
void server();
```
#### core/smart_contract (service)
It contains the Java virtual machine interface.
```
void initializeVM(std::string contractName);
void finishVM();
void invokeFunction(
std::string functionName,
std::unordered_map<std::string, std::string> params);
```
#### core/util (other)
It contains logger, random, datetime, exception...
### Environment
```
JAVA_HOME := java's home
IROHA_HOME := iroha's root
```
## Requirement
```
cmake(3.5.2)
gRPC
LevelDB
```
## Recommended
```
fabric3 (python library, not hyperledger/fabric)
```
## Using dockerhub for development
Merges to master are automatically deployed to dockerhub at
[https://hub.docker.com/r/hyperledger/iroha-docker/](https://hub.docker.com/r/hyperledger/iroha-docker/), so it is possible to pull from there to start up a network with 4 servers. Currently only 4 servers are supported. Using this method, it is possible set up a network within a few minutes.
0. Install docker (at least version 1.13)
1. ```docker pull hyperledger/iroha-docker```
2. on master node: ```docker swarm init --advertise-addr=(insert master node IP here)``
3. on other 3 nodes: ```docker swarm join —token=(insert token here, printed out from the previous step on the master node)```
4. on master node: ```docker network create -d overlay iroha-network```
5. on master node:

```
docker service create \
--network iroha-network \
--name configdiscovery \
warchantua/configdiscovery
```

6. on master node:

```
docker service create \
--name iroha \
--mode global \
--network iroha-network \
--publish 1204:1204 \
hyperledger/iroha-docker /configure-then-run.sh
```

## Using docker and docker-compose for development
To build latest container with iroha, refer to [this guide](./docker/README.md).

After this, run network of 4 nodes:
```
docker-compose up
# open another terminal
docker-compose scale iroha=4
```

To set different number of nodes, change `command: 4` in `docker-compose.yml` and `iroha=4` in previous command.

## Installation
```
$ git submodule init
$ git submodule update
$ mkdir build
$ cd build
$ cmake ..
$ make
```
(in server)
or
```
$ fab deploy
```
(in local)

### Rebuilding gRPC stubs

This step should only be necessary if protobuf definitions changes, or version of gRPC or protoc has been updated.

(invoked from $IROHA_HOME)
```
protoc --cpp_out=core/infra/connection core/infra/connection/connection.proto
protoc --grpc_out=core/infra/connection --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` core/infra/connection/connection.proto
```
# Documentation
- [Architecture.](./docs/architecture.md)
- [Build iroha in local environment](./docs/how_to_build.rst)
- [Using docker to build iroha container](./docker/README.md)
- [Using docker-compose to setup test network of N nodes on a single computer](./docs/docker_compose.md)
- [Deploying a network of N nodes using docker swarm](./docs/docker_swarm.md)

## Authors
# Authors

[MakotoTakemiya](https://github.com/takemiyamakoto)
[MizukiSonoko](https://github.com/MizukiSonoko)

## License
# License

Copyright 2016 Soramitsu Co., Ltd.

Expand Down
4 changes: 2 additions & 2 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fi


if [[ ! -e ~/.docker/config.json ]]; then
expect -c '\
expect -c "\
set timeout 5
spawn docker login
expect "Username:*"
Expand All @@ -18,7 +18,7 @@ if [[ ! -e ~/.docker/config.json ]]; then
expect "Email:*"
send -- "$env(DOCKER_EMAIL)\r"
expect "*WARNING:*Login Succeeded*"
expect eof' 1>/dev/null || exit 1
expect eof" 1>/dev/null || exit 1
fi

docker push $1

0 comments on commit 5efc068

Please sign in to comment.