-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
484d689
commit ed4a5c7
Showing
148 changed files
with
15,597 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "sawtooth-channel-dgm-tp"] | ||
path = sawtooth-channel-dgm-tp | ||
url = https://github.com/trustbridge/sawtooth-channel-dgm-tp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
Sawtooth Channel Example | ||
======================== | ||
|
||
This is an example of a Hyperledger Sawtooth blockchain network, | ||
for the purpose of demonstrating the Sawtooth | ||
Generic Discrete Message Transaction Processor | ||
(https://github.com/trustbridge/sawtooth-channel-dgm-tp). | ||
|
||
Together, this provides a G2G channel component as described at http://edi3.org | ||
|
||
The code in this repository draws heavily on Apache-2 licenced examples | ||
from https://github.com/hyperledger | ||
|
||
|
||
Running local demo | ||
------------------ | ||
|
||
This assumes you have a working docker environment and docker-compose. | ||
|
||
**1. start up services with docker-compose.** | ||
|
||
sawtooth-channel-dgm-tp is inculded as a submodule, | ||
so ensure your copy exists and is up to date: | ||
:: | ||
git submodule update | ||
|
||
Then run it with docker compose: | ||
:: | ||
docker-compose -f sawtooth-channel-dgm-tp/local.yml up --build --force | ||
|
||
This runs up the following services: | ||
|
||
* ``validator`` | ||
* ``rest-api`` | ||
* ``identity transaction processor`` | ||
* ``settings transaction processor`` | ||
* ``generic discrete message transaction processor`` | ||
* ``client`` | ||
|
||
**2. start up bash session on client container** | ||
|
||
:: | ||
|
||
docker exec -it sawtooth-shell-local bash | ||
|
||
**3. create a transaction from within client container.** | ||
|
||
``gdm send`` expects sender_ref, subject, object, predicate, sender, receiver in that order. | ||
|
||
:: | ||
|
||
python3 bin/gdm send 123456789 somechamber create skljhdfkjhskdjhksjhf AU CN --url http://rest-api:8008 | ||
|
||
You should get a response like this:: | ||
|
||
Response: { | ||
"link": "http://rest-api:8008/batch_statuses?id=fc9d35c7ae17191f02705a166cee84475f0d2d462e9e1e9cf637debbb3aca17c2a8c44d08c4c18ef51f6a4a4b447ce26d9d4f4f9e4df32155e671d8d744fba8d" | ||
} | ||
|
||
|
||
**5. you can then use the link to get the status of the batch** | ||
|
||
:: | ||
|
||
curl http://rest-api:8008/batch_statuses?id=fc9d35c7ae17191f02705a166cee84475f0d2d462e9e1e9cf637debbb3aca17c2a8c44d08c4c18ef51f6a4a4b447ce26d9d4f4f9e4df32155e671d8d744fba8d | ||
|
||
the response should tell you whether the batch has been added to the blockchain | ||
|
||
:: | ||
|
||
{ | ||
"data": [ | ||
{ | ||
"id": "fc9d35c7ae17191f02705a166cee84475f0d2d462e9e1e9cf637debbb3aca17c2a8c44d08c4c18ef51f6a4a4b447ce26d9d4f4f9e4df32155e671d8d744fba8d", | ||
"invalid_transactions": [], | ||
"status": "COMMITTED" | ||
} | ||
], | ||
"link": "http://rest-api:8008/batch_statuses?id=fc9d35c7ae17191f02705a166cee84475f0d2d462e9e1e9cf637debbb3aca17c2a8c44d08c4c18ef51f6a4a4b447ce26d9d4f4f9e4df32155e671d8d744fba8d" | ||
} | ||
|
||
**6. check for handling of duplicate sender_ref** | ||
|
||
The transaction processor will fail if a message with the same sender_ref as an existing message is sent to the validator. If you submit another transaction with the same sender ref you should see a response like this: | ||
|
||
:: | ||
|
||
{ | ||
"data": [ | ||
{ | ||
"id": "d6565473d3ba56726b4415e942da3d5fb6e5060a139c264ccdcd5019b4b7eaf2543951cd207aaa5a1128fc85089601b9f592d9626df20f9dbf8597c6afb18098", | ||
"invalid_transactions": [ | ||
{ | ||
"id": "5bd7e25e5d75fe1d33b673c853f487fd17c43ffda9db511a60fcdae1416f004d28e10de829cd95a9da4cf6d437f604a5e474d6dae65a53d926aef7ca48057b27", | ||
"message": "Invalid action: Message already exists: 123456789" | ||
} | ||
], | ||
"status": "INVALID" | ||
} | ||
], | ||
"link": "http://rest-api:8008/batch_statuses?id=d6565473d3ba56726b4415e942da3d5fb6e5060a139c264ccdcd5019b4b7eaf2543951cd207aaa5a1128fc85089601b9f592d9626df20f9dbf8597c6afb18098" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.2.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 2017 Intel Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# ------------------------------------------------------------------------------ | ||
|
||
top_dir=$(cd $(dirname $(dirname $0)) && pwd) | ||
bin=$top_dir/families/block_info/sawtooth_block_info/bin/block-info-tp | ||
|
||
if [ -e $bin ] | ||
then | ||
$bin $* | ||
else | ||
echo "Please build block_info first with 'build_all'" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright 2017 Intel Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# ------------------------------------------------------------------------------ | ||
|
||
set -e | ||
|
||
top_dir=$(cd $(dirname $(dirname $0)) && pwd) | ||
|
||
cd $top_dir | ||
docker build -f docker/sawtooth-av -t sawtooth-av docker \ | ||
--build-arg https_proxy=$https_proxy \ | ||
--build-arg http_proxy=$http_proxy \ | ||
--build-arg HTTPS_PROXY=$HTTPS_PROXY \ | ||
--build-arg HTTP_PROXY=$HTTP_PROXY | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,216 @@ | ||
#!/usr/bin/env bash | ||
# Copyright 2017 Intel Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# ------------------------------------------------------------------------------ | ||
|
||
# This script was developed for usage inside a docker container and makes | ||
# assumptions that the 'bin/install_packaging_deps' has already been run | ||
# to install the dependencies. This script can be run in a clean docker | ||
# environment with the following commands: | ||
# | ||
# cd sawtooth-core | ||
# docker run \ | ||
# -v $(pwd):/project/sawtooth-core \ | ||
# --workdir /project/sawtooth-core \ | ||
# --env https_proxy=$https_proxy \ | ||
# --env http_proxy=$http_proxy \ | ||
# --env HTTPS_PROXY=$HTTPS_PROXY \ | ||
# --env HTTP_PROXY=$HTTP_PROXY \ | ||
# -t ubuntu:bionic\ | ||
# bash -c " \ | ||
# apt-get update \ | ||
# && ./bin/install_packaging_deps \ | ||
# && ./bin/build_ext_debs \ | ||
# " | ||
# Between builds you may want to clean the intermediate and output directories" | ||
# cd sawtooth-core | ||
# rm -rf projects packages | ||
# | ||
|
||
set -e | ||
|
||
build_dir=$(pwd)/projects | ||
pkg_dir=$(pwd)/packages | ||
|
||
while getopts :p:b:h opt | ||
do | ||
case $opt in | ||
h) | ||
echo "Usage:" | ||
echo " $0 [-b build_dir] [-p package_dir]" | ||
echo | ||
echo "Options:" | ||
echo " -h print usage and exit" | ||
echo " -b build_dir directory to build in" | ||
echo " -p package_dir directory to place debs in" | ||
exit 0 | ||
;; | ||
b) | ||
build_dir=$OPTARG | ||
;; | ||
p) | ||
pkg_dir=$OPTARG | ||
;; | ||
\?) | ||
echo "Invalid option: -$OPTARG" >&2 | ||
exit 2 | ||
;; | ||
esac | ||
done | ||
|
||
|
||
main() { | ||
info "Building debs in $build_dir and storing in $pkg_dir" | ||
|
||
mkdir -p ${build_dir} && mkdir -p ${pkg_dir} | ||
|
||
build_python_debs | ||
} | ||
|
||
build_python_debs() { | ||
|
||
info "Building debs needed by the Sawtooth Validator and Python SDK" | ||
|
||
build_dir_python=${build_dir}/python | ||
mkdir -p $build_dir_python | ||
cd ${build_dir_python} | ||
|
||
# WARNING: Order is important | ||
pip_pkgs=' | ||
cchardet | ||
grpcio | ||
protobuf | ||
grpcio-tools | ||
setuptools_scm | ||
pytest-runner==2.6.2 | ||
secp256k1 | ||
pytz | ||
lmdb | ||
pyformance | ||
' | ||
|
||
# secp256k1 needs a couple of libraries not readily available | ||
libsecp256k1_debs=' | ||
libsecp256k1-0_0.1~20161228-1_amd64.deb | ||
libsecp256k1-dev_0.1~20161228-1_amd64.deb | ||
' | ||
|
||
# Download and install additional secp256k dependencies | ||
info "Downloading and installing libsecp256k1 debs" | ||
for deb in $libsecp256k1_debs; do | ||
if [[ -e $pkg_dir/$deb ]] | ||
then | ||
warn "Skipping $deb, already exists at $pkg_dir/$deb" | ||
else | ||
wget http://ftp.br.debian.org/debian/pool/main/libs/libsecp256k1/$deb | ||
dpkg -i $deb | ||
mv $deb $pkg_dir | ||
fi | ||
done | ||
|
||
info "Installing all pip packages for building" | ||
pip3 install $pip_pkgs | ||
|
||
for pkg in $pip_pkgs; do | ||
package_python_deb $pkg | ||
done | ||
|
||
info "Uninstalling packages installed by pip" | ||
pip3 uninstall -y $pip_pkgs | ||
|
||
info "Done building packages" | ||
echo $(ls -1 $pkg_dir/*.deb) | ||
} | ||
|
||
info() { | ||
echo -e "\033[0;36m\n[--- $1 ---]\n\033[0m" | ||
} | ||
|
||
warn() { | ||
echo -e "\033[0;31m\n[--- $1 ---]\n\033[0m" | ||
} | ||
|
||
package_python_deb() { | ||
cd ${build_dir_python} | ||
|
||
pip_pkg_name=$1 | ||
tar_pkg_name=$(echo "$pip_pkg_name" | \ | ||
sed -e 's/==.*//' \ | ||
-e 's/async_/async-/' \ | ||
-e 's/cryptography-/cryptography_/') | ||
|
||
deb_pkg_name=$(echo "$tar_pkg_name" | \ | ||
sed -e 's/setuptools_/setuptools-/' \ | ||
-e 's/cryptography_/cryptography-/') | ||
|
||
if [ -z $(find $pkg_dir -name "python3-$deb_pkg_name\_*.deb") ] | ||
then | ||
info "Downloading source code for $pip_pkg_name" | ||
pip3 download --no-binary :all: \ | ||
--disable-pip-version-check \ | ||
--no-deps $pip_pkg_name | ||
|
||
tarball=$tar_pkg_name*.tar.gz | ||
info "Extracting $tarball" | ||
tar xfz $tarball; | ||
|
||
rm -f $tarball | ||
|
||
info "Building $deb_pkg_name deb" | ||
# Remove version fixing and fix async-timeout inconsistency | ||
|
||
cd ${build_dir_python}/$tar_pkg_name* | ||
|
||
# Arcane wizadry to get protobuf to build right | ||
if [ $tar_pkg_name = 'protobuf' ]; then | ||
# Grab protoc and .proto files expected by protobuf | ||
wget https://github.com/google/protobuf/releases/download/v3.2.0/protoc-3.2.0-linux-x86_64.zip | ||
|
||
# Unpack and relocate | ||
mkdir src | ||
unzip protoc-3.2.0-linux-x86_64.zip -d src | ||
mv src/include/* src/ && mv src/bin/* src/ | ||
|
||
# Patch bad relative paths | ||
sed 's/\.\.\/src/\.\.\/\.\.\/src/' < setup.py > patch.py && mv patch.py setup.py | ||
fi | ||
|
||
# This test is failing, so we need to skip it. | ||
if [ $tar_pkg_name == 'pyformance' ]; then | ||
rm ./tests/test__syslog_reporter.py | ||
fi | ||
|
||
# Package build errors. "original source dist cannot contain .pyc files" | ||
if [ $tar_pkg_name == 'cchardet' ]; then | ||
rm ./src/tests/test.pyc | ||
fi | ||
|
||
# Build the package | ||
python3 setup.py --command-packages=stdeb.command bdist_deb | ||
info "Finished building $deb_pkg_name deb" | ||
|
||
info "Installing $deb_pkg_name deb" | ||
# Install the package | ||
dpkg -i deb_dist/*.deb | ||
|
||
info "Saving $deb_pkg_name deb to $pkg_dir" | ||
# Save the package | ||
cp deb_dist/*.deb $pkg_dir | ||
else | ||
warn "Skipping $deb_pkg_name, already exists in $pkg_dir" | ||
fi | ||
|
||
} | ||
|
||
main |
Oops, something went wrong.