diff --git a/circle.yml b/circle.yml index d5fbed444b..8984921148 100644 --- a/circle.yml +++ b/circle.yml @@ -1,51 +1,45 @@ machine: + services: + - docker environment: IROHA_HOME: $(pwd)/iroha PATH: $PATH:/opt/cmake-3.5.2-Linux-x86_64/bin JAVA_HOME: /usr/lib/jvm/java-1.8.0-openjdk-amd64/ java: version: 'oraclejdk8' - pre: - - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y - - sudo apt-get update - - sudo apt-get install g++-5 - - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 20 - - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 20 - - g++ -v - - - sudo apt-get -y install build-essential libtcmalloc-minimal4 && sudo ln -s /usr/lib/libtcmalloc_minimal.so.4 /usr/lib/libtcmalloc_minimal.so - - sudo apt-get -y install xsltproc - - sudo apt-get -y install libhdf5-serial-dev libleveldb-dev libsnappy-dev liblmdb-dev - - sudo apt-get -y install autoconf automake libtool unzip + checkout: post: - - git submodule init - - git submodule update - - - cd $IROHA_HOME - - cd $IROHA_HOME/core/vendor/leveldb; make -j 4 - - cd $IROHA_HOME/core/vendor/ed25519; make -j 4 - - cd $IROHA_HOME/core/vendor/Cappuccino; git pull origin master - - cd $IROHA_HOME/core/vendor/KeccakCodePackage; make; make generic64/libkeccak.a - - cd $IROHA_HOME/core/infra/crypto/; make + - git submodule sync + - git submodule update --init --recursive dependencies: cache_directories: - ~/iroha/core/vendor/ - - /tmp/protobuf - - /tmp/grpc - pre: - - if [[ ! -e /tmp/protobuf ]]; then git clone -b v3.0.0 https://github.com/google/protobuf.git /tmp/protobuf; cd /tmp/protobuf; (git cherry-pick 1760feb621a913189b90fe8595fffb74bce84598; echo Force continue); cd /tmp/protobuf; ./autogen.sh; ./configure --prefix=/usr; make -j 4; fi; - - cd /tmp/protobuf; sudo make install - - protoc --version + - ~/docker + override: + # one way to cache iroha-dev container is to save it to tar image. 2 mins vs 10 mins without caching. + - if [[ -e ~/docker/iroha-dev.tar ]]; then docker load -i ~/docker/iroha-dev.tar; fi + # build iroha-dev (if it is in cache, this step will be skipped) and iroha-docker (production) images + - ${IROHA_HOME}/docker/build.sh + # cache iroha-dev image. takes 30 sec to save into file + - mkdir -p ~/docker; docker save hyperledger/iroha-dev > ~/docker/iroha-dev.tar - - if [[ ! -e /tmp/grpc ]]; then git clone -b $(curl -L http://grpc.io/release) https://github.com/grpc/grpc /tmp/grpc; cd /tmp/grpc; git submodule update --init; make -j 4; fi; - - cd /tmp/grpc; sudo make install - - which grpc_cpp_plugin test: pre: - - mkdir build; cd build; cmake ..; make - override: - - ./test.sh + # TESTS: + # first, run ctest inside a container + - docker run -p 1204:1204 hyperledger/iroha-docker /test.sh + # then, run iroha with dummy config (1 node) and test curl request + - docker run -d -p 1204:1204 hyperledger/iroha-docker /run.sh && sleep 5 && curl -X POST http://127.0.0.1:1204/account/register -d '{"publicKey":"WdvM/DPabapmtA7ISbTYPywbHxk8gWu2221LzmcmAgw=","alias":"yonezu","timestamp":1482053586}' + + +deployment: + hub: + branch: master + commands: + - docker login -u ${DOCKER_USER} -p ${DOCKER_PASS} + - docker push hyperledger/iroha-docker + diff --git a/docker-compose.yml b/docker-compose.yml index 750692148e..2cd009dd9f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,7 +18,7 @@ services: - 8000 iroha1: - image: hyperledger/iroha + image: hyperledger/iroha-docker depends_on: - configdiscovery expose: @@ -38,7 +38,7 @@ services: iroha2: - image: hyperledger/iroha + image: hyperledger/iroha-docker depends_on: - configdiscovery expose: @@ -51,7 +51,7 @@ services: iroha3: - image: hyperledger/iroha + image: hyperledger/iroha-docker depends_on: - configdiscovery expose: @@ -64,7 +64,7 @@ services: iroha4: - image: hyperledger/iroha + image: hyperledger/iroha-docker depends_on: - configdiscovery expose: diff --git a/docker/build.sh b/docker/build.sh index b8288e9c68..9b3635a67d 100755 --- a/docker/build.sh +++ b/docker/build.sh @@ -6,10 +6,10 @@ if [ -z ${IROHA_HOME} ]; then fi # build iroha-dev image -docker build -t hyperledger/iroha-dev ${IROHA_HOME}/docker/dev +docker build --rm=false -t hyperledger/iroha-dev ${IROHA_HOME}/docker/dev # run dev container to build iroha -docker run -i --rm \ +docker run -i \ -v ${IROHA_HOME}/docker/build:/build \ -v ${IROHA_HOME}:/opt/iroha \ hyperledger/iroha-dev \ @@ -24,4 +24,4 @@ docker run -i --rm \ COMMANDS # build hyperledger/iroha container -docker build -t hyperledger/iroha ${IROHA_HOME}/docker/build +docker build --rm=false -t hyperledger/iroha-docker ${IROHA_HOME}/docker/build diff --git a/docker/build/Dockerfile b/docker/build/Dockerfile index 213fa47d37..a306a59f4e 100644 --- a/docker/build/Dockerfile +++ b/docker/build/Dockerfile @@ -1,7 +1,7 @@ #----------------------------------------------------------------------- # iroha-rel - IROHA container for Release # -# build : docker build -t hyperledger/iroha . +# build : docker build -t hyperledger/iroha-docker . # # Copyright (c) 2016 Soramitsu,Co.,Ltd. # All Rights Reserved. @@ -11,8 +11,8 @@ FROM ubuntu MAINTAINER Takeshi Yonezu / Bogdan Vaneev -LABEL BUILD="docker build -t hyperledger/iroha ." -LABEL RUN="docker run -d --name iroha hyperledger/iroha" +LABEL BUILD="docker build -t hyperledger/iroha-docker ." +LABEL RUN="docker run -d --name iroha hyperledger/iroha-docker" ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64 # IROHA_HOME here should be the same as IROHA_RELEASE in iroha-dev @@ -21,17 +21,20 @@ ENV IROHA_HOME=/usr/local/iroha # this copies iroha and unpacks its binaries ADD ./iroha.tar / ADD ./scripts / +ADD ./config/sumeragi.json /tmp/sumeragi.json RUN groupadd -g 168 iroha && \ useradd -u 168 -c "IROHA Administrator" -s /bin/bash -m -d ${IROHA_HOME} -p $(perl -e "print(crypt('passw0rd', 'sa'));") -g iroha iroha && \ usermod -G adm,sudo iroha && \ - echo "export IROHA_HOME=${IROHA_HOME}" >> ${IROHA_HOME}/.bashrc && \ - echo "export JAVA_HOME=${JAVA_HOME}" >> ${IROHA_HOME}/.bashrc; \ apt update && apt -y upgrade && apt -y install default-jdk netcat libsnappy-dev; \ echo /usr/local/lib >>/etc/ld.so.conf && \ echo ${IROHA_HOME}/lib >>/etc/ld.so.conf && \ + + mkdir -p ${IROHA_HOME}/config && \ + cp /tmp/sumeragi.json ${IROHA_HOME}/config/sumeragi.json && \ + ldconfig CMD ["/run.sh"] diff --git a/docker/build/README.md b/docker/build/README.md index 27d9ce6e85..bd7453bb99 100644 --- a/docker/build/README.md +++ b/docker/build/README.md @@ -6,5 +6,28 @@ This directory will be mounted to `iroha-dev` container. After successful build, Then, to build iroha container, run: ``` -docker build -t hyperledger/iroha . +docker build -t hyperledger/iroha-docker . ``` + + +# Default config + +Default `sumeragi.json` is + +```json +{ + "group": [ + { + "ip": "127.0.0.1", + "name": "da77880a3da4", + "publicKey": "u7X/zQ/Dq21WW7YH4rbkpiCYJXjPxk5t3qNDKiVwBx8=" + } + ], + "me": { + "ip": "127.0.0.1", + "name": "da77880a3da4", + "privateKey": "cPY84e0BXGUHBjT4QdlPI0LI3BPIfUfSZjB8jdWURkNQ+pEagT/ysrewbt2YUo/Qbfd5vczW5oDooGSNUBTj9g==", + "publicKey": "u7X/zQ/Dq21WW7YH4rbkpiCYJXjPxk5t3qNDKiVwBx8=" + } +} +``` \ No newline at end of file diff --git a/docker/build/config/sumeragi.json b/docker/build/config/sumeragi.json new file mode 100644 index 0000000000..c6ff803432 --- /dev/null +++ b/docker/build/config/sumeragi.json @@ -0,0 +1,15 @@ +{ + "group": [ + { + "ip": "127.0.0.1", + "name": "da77880a3da4", + "publicKey": "u7X/zQ/Dq21WW7YH4rbkpiCYJXjPxk5t3qNDKiVwBx8=" + } + ], + "me": { + "ip": "127.0.0.1", + "name": "da77880a3da4", + "privateKey": "cPY84e0BXGUHBjT4QdlPI0LI3BPIfUfSZjB8jdWURkNQ+pEagT/ysrewbt2YUo/Qbfd5vczW5oDooGSNUBTj9g==", + "publicKey": "u7X/zQ/Dq21WW7YH4rbkpiCYJXjPxk5t3qNDKiVwBx8=" + } +} \ No newline at end of file diff --git a/docker/build/scripts/test.sh b/docker/build/scripts/test.sh new file mode 100755 index 0000000000..7016ff0cdb --- /dev/null +++ b/docker/build/scripts/test.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +total=0 +for file in ${IROHA_HOME}/test_bin/*; do + ./${file} + total=$((total + $?)) +done +exit 0 diff --git a/docker/dev/Dockerfile b/docker/dev/Dockerfile index 88aa6ae649..2a20e8e348 100644 --- a/docker/dev/Dockerfile +++ b/docker/dev/Dockerfile @@ -29,6 +29,8 @@ RUN apt-get update && apt-get -y upgrade; \ curl \ git \ make \ + build-essential \ + cmake \ g++-5 \ gcc-5 \ default-jdk \ diff --git a/docker/dev/scripts/build-iroha.sh b/docker/dev/scripts/build-iroha.sh index 6476f8d62e..6ed7bd24ce 100755 --- a/docker/dev/scripts/build-iroha.sh +++ b/docker/dev/scripts/build-iroha.sh @@ -14,15 +14,24 @@ fi # build dependencies -(cd $IROHA_HOME/core/vendor/leveldb && make -j4) || error "Can't build leveldb submodule" -(cd $IROHA_HOME/core/vendor/ed25519 && make -j4) || error "Can't build ed25519 submodule" -(cd $IROHA_HOME/core/vendor/KeccakCodePackage && \ - make -j4 && \ - make -j4 generic64/libkeccak.a) || error "Can't build KeccakCodePackage submodule" -(cd $IROHA_HOME/core/infra/crypto && make -j4) || error "Can't build crypto submodule" +cd $IROHA_HOME/core/vendor/leveldb +make clean 2>/dev/null 1>&2 +make -j4 || error "Can't build leveldb submodule" + +cd $IROHA_HOME/core/vendor/ed25519 +make clean 2>/dev/null 1>&2 +make -j4 || error "Can't build ed25519 submodule" + +cd $IROHA_HOME/core/vendor/KeccakCodePackage +make clean 2>/dev/null 1>&2 +(make -j4 && make -j4 generic64/libkeccak.a) || error "Can't build KeccakCodePackage submodule" + +cd $IROHA_HOME/core/infra/crypto +make clean 2>/dev/null 1>&2 +make -j4 || error "Can't build crypto submodule" # build iroha (important: build using single thread!) -(mkdir -p $IROHA_BUILD || echo "[+] build directory already exists, rebuilding") && \ -cd $IROHA_BUILD && \ -cmake $IROHA_HOME && \ +mkdir -p $IROHA_BUILD && \ +cd $IROHA_BUILD && \ +cmake $IROHA_HOME && \ make || error "Can't build iroha" diff --git a/docker/dev/scripts/mktar-iroha.sh b/docker/dev/scripts/mktar-iroha.sh index a45b74e91d..0ff486a62c 100755 --- a/docker/dev/scripts/mktar-iroha.sh +++ b/docker/dev/scripts/mktar-iroha.sh @@ -5,7 +5,8 @@ if [ -z ${IROHA_RELEASE} ]; then exit 1 fi -cd ${IROHA_RELEASE} +cd ${IROHA_RELEASE} || (echo "[-] No folder ${IROHA_RELEASE}" && exit 1) + rsync -av ${IROHA_BUILD}/bin $IROHA_RELEASE && \ rsync -av ${IROHA_BUILD}/lib $IROHA_RELEASE && \ rsync -av ${IROHA_BUILD}/my_test_bin $IROHA_RELEASE && \ diff --git a/docs/iroha_whitepaper.md b/docs/iroha_whitepaper.md index e8bbb06b5f..df980b9214 100644 --- a/docs/iroha_whitepaper.md +++ b/docs/iroha_whitepaper.md @@ -1,6 +1,6 @@ #Iroha v1.0 (draft)# -The following is a specification for Iroha 1.0. Many parts are still in development and have not yet been implemented, but for the sake of design, this document is generally written in the present tense. Future revisions will annotate the development status of the various sections. +The following is a specification for Iroha 1.0. Many parts are still in development and have not yet been implemented, but for the sake of design, this document is generally written in the present tense. --- @@ -31,6 +31,8 @@ Having a solid distributed ledger system is not useful if there are no applicati ### 2.1. P2P Network +***Development status: currently all peers are validating peers*** + Generally, 3*f*+1 nodes are needed to tolerate *f* Byzantine nodes in the network (albeit some consensus algorithms have higher node requirements). The number of *f* that a system should be made to tolerate should be determined by the system maintainer, based on the requirements for expected use cases. The following node types are considered: @@ -41,6 +43,8 @@ The following node types are considered: ### 2.2. Membership service +***Development status: add/remove peer functions are currently in development. ETA: before end of February*** + Membership is provided in a decentralized way, on ledger. By default 2*f*+1 signatures are needed to confirm adding or removing nodes to the network. In future work, it is planned to add finer granularity permissions, similar to unix style permissions an membership groups.