Skip to content

Commit

Permalink
Rebase to latest Hyperledger code
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed May 17, 2016
1 parent 2f070d5 commit d5eb9ae
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 16 deletions.
120 changes: 120 additions & 0 deletions README.s390x.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
This is a fork of the Hyperledger fabric repository which has been patched to compile on Linux s390x. Please follow the steps below to build Hyperledger. The instructions assume a Debian host but should also work on Ubuntu. When appropriate, commands for RHEL or SLES are also given.

####1. Install docker
For RHEL and SLES, you can get it at https://www.ibm.com/developerworks/linux/linux390/docker.html. And for Debian, you can get it here at https://github.com/gongsu832/docker-s390x-debian (statically linked binaries should work on all distros). On Debian and Ubuntu, you may need to install aufs-tools if it's not already installed and you want to use aufs (not recommended) as the storage driver..

```
apt-get install aufs-tools
```

While the docker daemon can automatically pull images on demand, it's better to pull the pre-built Hyperledger base image now since it's more than 1GB. To do that,

```
# docker daemon -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock > /var/log/docker.log 2>&1 &
# docker pull s390xlinux/hyperledger-go1.6-rocksdb4.6
```

Note that -H tcp://0.0.0.0:2375 is not really needed for pulling images. It's for doing the Hyperledger "behave" tests later.

####2. Install go 1.6
Due to legal reasons, IBM cannot yet distribute prebuilt go 1.6 binary for Linux s390x. There are instructions on how to build one yourself from the publically available source but the process is rather involved. Instead, the easiest way is to get a copy that someone else already built.

```
# docker pull brunswickheads/golang-1.6-s390x
# container_id=$(docker create brunswickheads/golang-1.6-s390x /bin/bash)
# docker cp $container_id:/usr/local/go - | tar x -C /opt --no-same-owner --no-same-permissions
# docker rm $container_id
```

This will extract go 1.6 from the docker image into /opt/go. To use it, set GOROOT=/opt/go and add /opt/go/bin to your PATH. You can delete brunswickheads/golang-1.6-s390x image afterwards if you no longer need it.

####3. Install rocksdb
The example below clones into /opt/rocksdb. You can choose wherever you prefer.

```
# cd /opt
# git clone https://github.com/facebook/rocksdb.git
# cd rocksdb
# make shared_lib
```

This generates librocksdb.so in /opt/rocksdb. For compiling code, add -I/opt/rocksdb/include to your compiler flag and -L/opt/rocksdb -lrocksdb to your linker flag. For running code, add /opt/rocksdb to your LD_LIBRARY_PATH.

####4. Build Hyperledger
Once again, the example below uses GOPATH=/opt/openchain and you are free to use wherever you prefer.

```
# apt-get install libbz2-dev libsnappy-dev zlib1g-dev
# cd /opt
# mkdir -p openchain/src/github.com/hyperledger
# cd openchain/src/github.com/hyperledger
# git clone https://github.com/gongsu832/fabric.git
# cd fabric/peer
# export GOPATH=/opt/openchain
# CGO_CFLAGS="-I/opt/rocksdb/include" CGO_LDFLAGS="-L/opt/rocksdb -lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" go build
```

For RHEL, replace apt-get command with
```
# yum install bzip2-devel snappy-devel zlib-devel
```

For SLES, replace apt-get command with
```
# zypper install libbz2-devel snappy-devel zlib-devel
```

This generates "peer" binary in the current directory.

To build the Hyperledger CA server, which is required when security is enabled,

```
# cd $GOPATH/src/github.com/hyperledger/fabric/membersrvc
# CGO_CFLAGS="-I/opt/rocksdb/include" CGO_LDFLAGS="-L/opt/rocksdb -lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" go build
```

#####To run the unit tests,

```
# cd $GOPATH/src/github.com/hyperledger/fabric/peer
# ./peer node start > /var/log/peer.log 2>&1 &
# CGO_CFLAGS="-I/opt/rocksdb/include" CGO_LDFLAGS="-L/opt/rocksdb -lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" go test -timeout=20m $(go list github.com/hyperledger/fabric/...|grep -v /vendor/|grep -v /examples/)
```

You should have no FAIL for any test. Note that to rerun the tests, you need to clean up all the leftover containers and images except s390xlinux/hyperledger-go1.6-rocksdb4.6.

#####To run the behave tests,

Install docker-compose and behave if you haven't already,

```
# apt-get install python-setuptools python-pip
# pip install docker-compose behave
```

For RHEL
```
# yum install python-setuptools
# curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
# python get-pip.py
# pip install docker-compose behave
```

For SLES
```
# zypper install python-devel python-setuptools
# curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
# python get-pip.py
# pip install docker-compose behave
```

Then run the behave tests,

```
# cd $GOPATH/src/github.com/hyperledger/fabric/bddtests
# behave >behave.log 2>&1 &
```

You may have a few failed and skipped tests and it's OK to ignore them if they are not "cannot connect to Docker endpoint" error mentioned below. Note that to rerun the tests, you need to clean up all the leftover containers and images except s390xlinux/hyperledger-go1.6-rocksdb4.6, hyperledger-peer, and membersrvc.

If you have tests failing for reason like "cannot connect to Docker endpoint", check the IP address of interface docker0 on your system. In compose-defaults.yml file, the IP address is assumed to be 172.17.0.1. You must change it to match what you have on your system.
4 changes: 2 additions & 2 deletions consensus/docker-compose-files/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from hyperledger/fabric-baseimage:latest
from s390xlinux/hyperledger-go1.6-rocksdb4.6:latest

# Copy GOPATH src and install Peer
RUN mkdir -p /var/hyperledger/db
RUN mkdir -p /var/hyperledger/production
WORKDIR $GOPATH/src/github.com/hyperledger/fabric
COPY . .
WORKDIR $GOPATH/src/github.com/hyperledger/fabric/peer
RUN CGO_CFLAGS=" " CGO_LDFLAGS="-lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" go install && cp $GOPATH/src/github.com/hyperledger/fabric/peer/core.yaml $GOPATH/bin
RUN CGO_CFLAGS="-I/opt/rocksdb/include" CGO_LDFLAGS="-L/opt/rocksdb -lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" go install && cp $GOPATH/src/github.com/hyperledger/fabric/peer/core.yaml $GOPATH/bin
RUN cp $GOPATH/src/github.com/hyperledger/fabric/consensus/obcpbft/config.yaml $GOPATH/bin
# RUN CGO_CFLAGS=" " CGO_LDFLAGS="-lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" go install
# RUN cd membersrvc && go install
2 changes: 1 addition & 1 deletion core/container/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func getCodeChainBytesInMem() (io.Reader, error) {
inputbuf := bytes.NewBuffer(nil)
gw := gzip.NewWriter(inputbuf)
tr := tar.NewWriter(gw)
dockerFileContents := []byte("FROM busybox:latest\n\nCMD echo hello")
dockerFileContents := []byte("FROM s390x/busybox:latest\n\nCMD echo hello")
dockerFileSize := int64(len([]byte(dockerFileContents)))

tr.WriteHeader(&tar.Header{Name: "Dockerfile", Size: dockerFileSize, ModTime: startTime, AccessTime: startTime, ChangeTime: startTime})
Expand Down
6 changes: 3 additions & 3 deletions core/ledger/genesis/genesis_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ peer:
networkId: dev

Dockerfile: |
from hyperledger/fabric-baseimage
from s390xlinux/hyperledger-go1.6-rocksdb4.6:latest
# Copy GOPATH src and install Peer
COPY src $GOPATH/src
RUN mkdir -p /var/hyperledger/db
WORKDIR $GOPATH/src/github.com/hyperledger/fabric/peer/
RUN CGO_CFLAGS=" " CGO_LDFLAGS="-lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" go install && cp $GOPATH/src/github.com/hyperledger/fabric/peer/core.yaml $GOPATH/bin
RUN CGO_CFLAGS="-I/opt/rocksdb/include" CGO_LDFLAGS="-L/opt/rocksdb -lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" go install && cp $GOPATH/src/github.com/hyperledger/fabric/peer/core.yaml $GOPATH/bin
# The Address this Peer will bind to for providing services
address: 0.0.0.0:30303
Expand Down Expand Up @@ -186,7 +186,7 @@ chaincode:

# This is the basis for the Golang Dockerfile. Additional commands will be appended depedendent upon the chaincode specification.
Dockerfile: |
from hyperledger/fabric-baseimage
from s390xlinux/hyperledger-go1.6-rocksdb4.6:latest
COPY src $GOPATH/src
WORKDIR $GOPATH
Expand Down
2 changes: 1 addition & 1 deletion examples/chaincode/go/utxo/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from hyperledger/fabric-baseimage
from s390xlinux/hyperledger-go1.6-rocksdb4.6:latest

RUN apt-get update && apt-get install pkg-config autoconf libtool -y
RUN cd /tmp && git clone https://github.com/bitcoin/secp256k1.git && cd secp256k1/
Expand Down
4 changes: 2 additions & 2 deletions membersrvc/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from hyperledger/fabric-baseimage:latest
from s390xlinux/hyperledger-go1.6-rocksdb4.6:latest
# Copy GOPATH src and install Peer
RUN mkdir -p /var/hyperledger/db
WORKDIR $GOPATH/src/github.com/hyperledger/fabric/
COPY . .
WORKDIR membersrvc
RUN pwd
RUN CGO_CFLAGS=" " CGO_LDFLAGS="-lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" go install && cp $GOPATH/src/github.com/hyperledger/fabric/membersrvc/membersrvc.yaml $GOPATH/bin
RUN CGO_CFLAGS="-I/opt/rocksdb/include" CGO_LDFLAGS="-L/opt/rocksdb -lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" go install && cp $GOPATH/src/github.com/hyperledger/fabric/membersrvc/membersrvc.yaml $GOPATH/bin
# RUN CGO_CFLAGS=" " CGO_LDFLAGS="-lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" go install
6 changes: 3 additions & 3 deletions membersrvc/ca/ca_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ peer:
networkId: dev

Dockerfile: |
from hyperledger/fabric-baseimage:latest
from s390xlinux/hyperledger-go1.6-rocksdb4.6:latest
# Copy GOPATH src and install Peer
COPY src $GOPATH/src
RUN mkdir -p /var/hyperledger/db
WORKDIR $GOPATH/src/github.com/hyperledger/fabric/peer/
RUN CGO_CFLAGS=" " CGO_LDFLAGS="-lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" go install && cp $GOPATH/src/github.com/hyperledger/fabric/peer/core.yaml $GOPATH/bin
RUN CGO_CFLAGS="-I/opt/rocksdb/include" CGO_LDFLAGS="-L/opt/rocksdb -lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" go install && cp $GOPATH/src/github.com/hyperledger/fabric/peer/core.yaml $GOPATH/bin
# The Address this Peer will listen on
listenAddress: 0.0.0.0:30303
Expand Down Expand Up @@ -239,7 +239,7 @@ chaincode:

# This is the basis for the Golang Dockerfile. Additional commands will be appended depedendent upon the chaincode specification.
Dockerfile: |
from hyperledger/fabric-baseimage
from s390xlinux/hyperledger-go1.6-rocksdb4.6:latest
COPY src $GOPATH/src
WORKDIR $GOPATH
Expand Down
6 changes: 3 additions & 3 deletions peer/core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ peer:
networkId: dev

Dockerfile: |
from hyperledger/fabric-baseimage:latest
from s390xlinux/hyperledger-go1.6-rocksdb4.6:latest
# Copy GOPATH src and install Peer
COPY src $GOPATH/src
RUN mkdir -p /var/hyperledger/db
WORKDIR $GOPATH/src/github.com/hyperledger/fabric/peer/
RUN CGO_CFLAGS=" " CGO_LDFLAGS="-lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" go install && cp $GOPATH/src/github.com/hyperledger/fabric/peer/core.yaml $GOPATH/bin
RUN CGO_CFLAGS="-I/opt/rocksdb/include" CGO_LDFLAGS="-L/opt/rocksdb -lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" go install && cp $GOPATH/src/github.com/hyperledger/fabric/peer/core.yaml $GOPATH/bin
# The Address this Peer will listen on
Expand Down Expand Up @@ -289,7 +289,7 @@ chaincode:
# This is the basis for the Golang Dockerfile. Additional commands will
# be appended depedendent upon the chaincode specification.
Dockerfile: |
from hyperledger/fabric-baseimage
from s390xlinux/hyperledger-go1.6-rocksdb4.6:latest
#from utxo:0.1.0
COPY src $GOPATH/src
WORKDIR $GOPATH
Expand Down
2 changes: 1 addition & 1 deletion vendor/github.com/mattn/go-sqlite3/sqlite3_other.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d5eb9ae

Please sign in to comment.