Skip to content

Commit

Permalink
Merge branch 'master' into feature/add-how-to
Browse files Browse the repository at this point in the history
  • Loading branch information
MizukiSonoko committed Dec 20, 2016
2 parents c066d1c + 2935684 commit 20aa42e
Show file tree
Hide file tree
Showing 106 changed files with 4,307 additions and 2,585 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ build/*
.vscode/*
.idea/*
*xcworkspace*
.vscode/*
*cmake-build-debug*
cmake-build-debu/*
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
[submodule "core/vendor/Cappuccino"]
path = core/vendor/Cappuccino
url = https://github.com/MizukiSonoko/Cappuccino.git
ignore = dirty
[submodule "core/vendor/Cappuccino/lib/json"]
path = core/vendor/Cappuccino/lib/json
url = https://github.com/nlohmann/json.git
Expand Down
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 2.8)
PROJECT(iroha CXX)

ENABLE_LANGUAGE(C)
Expand All @@ -12,6 +12,8 @@ SET(CMAKE_SHARED_LINKER_FLAGS "-lpthread -lssl")
add_subdirectory(core)
add_subdirectory(peer)

add_subdirectory(tools)

if(NOT without-test)
enable_testing()
include(test/gtest.cmake)
Expand Down
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
![alt tag](Iroha_3_sm.png)

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

# Architecture (Draft)

Expand Down Expand Up @@ -185,18 +185,24 @@ IROHA_HOME := iroha's root
## Requirement
```
cmake(3.5.2)
gRPC
LevelDB
```
## Recommended
```
fabric3 (python library, not hyperledger/fabric)
```
## Using docker and docker-compose for development
Refer to [this guide](./docs/using_docker.md).
## Installation
```
$ git submodules init
$ git submodules update
$ git submodule init
$ git submodule update
$ mkdir build
$ cd build
$ cmake ..
$ make
```
Expand All @@ -206,6 +212,16 @@ 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
```
## Authors
Expand Down
29 changes: 29 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

# Run this script inside 'iroha-dev' docker container to build iroha and its dependencies!

error(){
echo "[Error] $1"
exit 1
}


if [ -z ${IROHA_HOME} ]; then
error "Empty variable IROHA_HOME"
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"

# build iroha (important: build using single thread!)
(cd $IROHA_HOME && \
(mkdir $IROHA_HOME/build || echo "[+] build directory already exists, rebuilding") && \
cd $IROHA_HOME/build && \
cmake .. && \
make ) || error "Can't build iroha"
48 changes: 20 additions & 28 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,32 @@ machine:
- 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
- cd /tmp
- sudo apt-get -y purge cmake
- curl -sSL https://cmake.org/files/v3.5/cmake-3.5.2-Linux-x86_64.tar.gz | sudo tar -xzC /opt

checkout:
post:
- 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
- cd $IROHA_HOME/core/vendor/KeccakCodePackage; make; make generic64/libkeccak.a
- cd $IROHA_HOME/core/infra/crypto/; make

dependencies:
cache_directories:
- ~/iroha/core/vendor/
- /tmp/protobuf
- /tmp/grpc
pre:
- cd /tmp; git clone -b v3.0.0 https://github.com/google/protobuf.git
- cd /tmp/protobuf;(git cherry-pick 1760feb621a913189b90fe8595fffb74bce84598; echo Force continue)
- cd /tmp/protobuf; ./autogen.sh; ./configure --prefix=/usr; make -j 16; sudo make install
- 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
- cd /tmp; git clone -b $(curl -L http://grpc.io/release) https://github.com/grpc/grpc
- cd /tmp/grpc; git submodule update --init; make; sudo make install

- 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
override:
- mkdir build; cd build; cmake ..; make
checkout:
post:
- cd $IROHA_HOME
- rm -rf core/vendor/KeccakCodePackage
- rm -rf core/vendor/leveldb
- rm -rf core/vendor/ed25519
- rm -rf core/vendor/json
- rm -rf core/vendor/Cappuccino
- git clone https://github.com/gvanas/KeccakCodePackage.git core/vendor/KeccakCodePackage
- git clone https://github.com/google/leveldb.git core/vendor/leveldb
- git clone https://github.com/MizukiSonoko/ed25519.git core/vendor/ed25519
- git clone https://github.com/nlohmann/json.git core/vendor/json
- git clone --recursive https://github.com/MizukiSonoko/Cappuccino.git core/vendor/Cappuccino
- cd $IROHA_HOME/core/vendor/leveldb; make -j 14
- cd $IROHA_HOME/core/vendor/ed25519; make -j 14
- cd $IROHA_HOME/core/vendor/KeccakCodePackage; make; make generic64/libkeccak.a
- cd $IROHA_HOME/core/infra/crypto/; make

test:
pre:
- mkdir build; cd build; cmake ..; make
override:
- ./test.sh
- ./test.sh
1 change: 0 additions & 1 deletion core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ add_subdirectory(infra)
add_subdirectory(util)
add_subdirectory(vendor)
add_subdirectory(crypto)
add_subdirectory(service)

add_subdirectory(validation)
2 changes: 1 addition & 1 deletion core/consensus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ ADD_LIBRARY(sumeragi STATIC
sumeragi.cpp
)
target_link_libraries(sumeragi
json_parse_with_nlohman
peer_service_with_json
connection_with_grpc
signature
event_repository
commands
objects
)

Expand Down
34 changes: 9 additions & 25 deletions core/consensus/connection/connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,8 @@ limitations under the License.
#include <memory>
#include <functional>

#include "../../model/commands/add.hpp"
#include "../../model/commands/transfer.hpp"

#include "../../model/objects/asset.hpp"
#include "../../model/objects/domain.hpp"
#include "../../model/objects/message.hpp"

#include "../../model/transaction.hpp"

#include "../../infra/protobuf/event.grpc.pb.h"
#include "../consensus_event.hpp"
#include "../event.hpp"

namespace connection {

Expand All @@ -46,25 +37,18 @@ namespace connection {

bool send(
const std::string& ip,
const std::unique_ptr<
::event::Event
>& msg);
const Event::ConsensusEvent& msg)
;

bool sendAll(
const std::unique_ptr<
::event::Event
>& msg);

bool send(
const std::string& to,
const std::unique_ptr<
::event::Event
>& message);
const Event::ConsensusEvent& msg
);

bool receive(const std::function<void(
const std::string& from,
std::unique_ptr<::event::Event>&& message)
>& callback);
const std::string&,
Event::ConsensusEvent&)
>& callback);


void addSubscriber(std::string ip);

Expand Down
96 changes: 9 additions & 87 deletions core/consensus/consensus_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,98 +11,20 @@ namespace event{
template<typename T>
using Add = command::Add<T>;

using Type = json_parse::Type;
using Object = json_parse::Object;

template <>
ConsensusEvent<Transaction<Transfer<object::Asset>>>::ConsensusEvent(
Object obj
):
Transaction(obj.dictSub["transaction"])
{
order = obj.dictSub["order"].integer;
std::vector<Object> eventSigs = obj.dictSub["eventSignatures"].listSub;
std::cout << eventSigs.size() << std::endl;
for(auto&& sig : eventSigs){
std::cout <<"Oh "<< sig.dictSub["publicKey"].str << " " << sig.dictSub["signature"].str << std::endl;
if(
sig.dictSub["publicKey"].str != "" &&
sig.dictSub["signature"].str != ""
){
_eventSignatures.push_back(eventSignature(sig.dictSub["publicKey"].str,sig.dictSub["signature"].str));
}
}
}
template<typename T>
using Update = command::Update<T>;

template <>
ConsensusEvent<Transaction<Add<object::Asset>>>::ConsensusEvent(
Object obj
):
Transaction(obj.dictSub["transaction"])
{
order = obj.dictSub["order"].integer;
std::vector<Object> eventSigs = obj.dictSub["eventSignatures"].listSub;
for(auto&& sig : eventSigs){
_eventSignatures.push_back(eventSignature(sig.dictSub["publicKey"].str, sig.dictSub["signature"].str));
}
void ConsensusEvent<Transaction<Update<object::Asset>>>::execution(){
logger::info("execution","update! Asset");
}

template <>
ConsensusEvent<Transaction<Add<object::Domain>>>::ConsensusEvent(
Object obj
):
Transaction(obj)
{
order = obj.dictSub["order"].floating;
std::vector<Object> eventSigs = obj.dictSub["eventSignatures"].listSub;
for(auto&& sig : eventSigs){
_eventSignatures.push_back(eventSignature(sig.dictSub["publicKey"].str,sig.dictSub["signature"].str));
}
void ConsensusEvent<Transaction<Add<object::Asset>>>::execution(){
logger::info("execution","add! Asset");
}

template <>
ConsensusEvent<Transaction<Transfer<object::Asset>>>::ConsensusEvent(
const std::string& senderPubkey,
const std::string& receiverPubkey,
const std::string& name,
const int& value
):
Transaction(
senderPubkey,
receiverPubkey,
name,
value
)
{}

template <>
ConsensusEvent<Transaction<Add<object::Asset>>>::ConsensusEvent(
const std::string& senderPubkey,
const std::string& domain,
const std::string& name,
const unsigned long long& value,
const unsigned int& precision
):
Transaction(
senderPubkey,
domain,
name,
value,
precision
)
{}

template <>
ConsensusEvent<Transaction<Add<object::Domain>>>::ConsensusEvent(
const std::string& senderPubkey,
const std::string& ownerPublicKey,
const std::string& name
):
Transaction(
senderPubkey,
ownerPublicKey,
name
)
{}
void ConsensusEvent<Transaction<Add<object::Domain>>>::execution(){
logger::info("execution","add! Asset");
}

};
Loading

0 comments on commit 20aa42e

Please sign in to comment.