├── .dockerignore ├── .env ├── .github └── settings.yml ├── .gitignore ├── .pycodestyle ├── .pylintrc ├── BUILD.md ├── CODEOWNERS ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Dockerfile ├── Dockerfile-installed-bionic ├── Dockerfile-installed-xenial ├── Jenkinsfile ├── LICENSE ├── MAINTAINERS.md ├── NOTICES ├── README.md ├── RELEASE_NOTES.md ├── SECURITY.md ├── VERSION ├── bin ├── authorize-cicd ├── get_version ├── intkey ├── intkey-tp-python ├── noop ├── protogen ├── run_bandit ├── run_docker_test ├── run_lint ├── run_tests ├── xo └── xo-tp-python ├── ci ├── nightly │ ├── sawtooth-intkey-tp-python │ └── sawtooth-xo-tp-python ├── sawtooth-build-docs ├── sawtooth-intkey-tp-python ├── sawtooth-publish-python-sdk └── sawtooth-xo-tp-python ├── docker-compose-installed.yaml ├── docker-compose.yaml ├── docker ├── bandit ├── compose │ ├── copy-debs.yaml │ ├── run-lint.yaml │ └── sawtooth-build.yaml └── lint ├── docs ├── Makefile ├── make.bat └── source │ ├── _static │ ├── theme_overrides.css │ └── version_switcher.js │ ├── _templates │ └── indexcontent.html │ ├── conf.py │ └── contents.rst ├── examples ├── intkey_python │ ├── Dockerfile │ ├── Dockerfile-installed-bionic │ ├── Dockerfile-installed-xenial │ ├── Dockerfile-tests-installed │ ├── nose2.cfg │ ├── packaging │ │ └── systemd │ │ │ ├── sawtooth-intkey-tp-python │ │ │ └── sawtooth-intkey-tp-python.service │ ├── sawtooth_intkey │ │ ├── __init__.py │ │ ├── client_cli │ │ │ ├── __init__.py │ │ │ ├── create_batch.py │ │ │ ├── exceptions.py │ │ │ ├── generate.py │ │ │ ├── intkey_cli.py │ │ │ ├── intkey_client.py │ │ │ ├── intkey_workload.py │ │ │ ├── load.py │ │ │ ├── populate.py │ │ │ └── workload │ │ │ │ ├── __init__.py │ │ │ │ ├── sawtooth_workload.py │ │ │ │ └── workload_generator.py │ │ ├── intkey_message_factory.py │ │ └── processor │ │ │ ├── __init__.py │ │ │ ├── handler.py │ │ │ └── main.py │ ├── setup.py │ ├── setup_tests.py │ └── tests │ │ ├── test_tp_intkey.py │ │ └── test_tp_intkey_python.yaml ├── noop_python │ └── sawtooth_noop │ │ ├── __init__.py │ │ └── client_cli │ │ ├── __init__.py │ │ ├── create_batch.py │ │ ├── exceptions.py │ │ ├── main.py │ │ └── workload.py └── xo_python │ ├── Dockerfile │ ├── Dockerfile-installed-bionic │ ├── Dockerfile-installed-xenial │ ├── Dockerfile-tests-installed │ ├── nose2.cfg │ ├── packaging │ ├── systemd │ │ ├── sawtooth-xo-tp-python │ │ └── sawtooth-xo-tp-python.service │ └── xo.toml.example │ ├── sawtooth_xo │ ├── __init__.py │ ├── processor │ │ ├── __init__.py │ │ ├── config │ │ │ ├── __init__.py │ │ │ └── xo.py │ │ ├── handler.py │ │ ├── main.py │ │ ├── xo_payload.py │ │ └── xo_state.py │ ├── xo_cli.py │ ├── xo_client.py │ ├── xo_exceptions.py │ └── xo_message_factory.py │ ├── setup.py │ ├── setup_tests.py │ └── tests │ ├── test_tp_xo.py │ └── test_tp_xo_python.yaml ├── images ├── rookies16-small.png ├── rookies16.png ├── sawtooth_logo_light_blue-small.png └── sawtooth_logo_light_blue.png ├── nose2.cfg ├── packaging ├── log_config.toml.example ├── path.toml.example └── ubuntu │ └── postinst ├── protos ├── authorization.proto ├── batch.proto ├── block.proto ├── block_info.proto ├── client_batch.proto ├── client_batch_submit.proto ├── client_block.proto ├── client_event.proto ├── client_list_control.proto ├── client_peers.proto ├── client_receipt.proto ├── client_state.proto ├── client_status.proto ├── client_transaction.proto ├── consensus.proto ├── events.proto ├── genesis.proto ├── identity.proto ├── merkle.proto ├── network.proto ├── processor.proto ├── setting.proto ├── state_context.proto ├── transaction.proto ├── transaction_receipt.proto └── validator.proto ├── sawtooth_processor_test ├── __init__.py ├── message_factory.py ├── message_types.py ├── mock_validator.py └── transaction_processor_test_case.py ├── sawtooth_sdk ├── __init__.py ├── consensus │ ├── __init__.py │ ├── driver.py │ ├── engine.py │ ├── exceptions.py │ ├── service.py │ ├── zmq_driver.py │ └── zmq_service.py ├── messaging │ ├── __init__.py │ ├── exceptions.py │ ├── future.py │ └── stream.py └── processor │ ├── __init__.py │ ├── config.py │ ├── context.py │ ├── core.py │ ├── exceptions.py │ ├── handler.py │ └── log.py ├── sawtooth_signing ├── __init__.py ├── core.py └── secp256k1.py ├── setup.py └── tests ├── python-sdk-tests.dockerfile ├── sawtooth_integration ├── docker │ ├── integration-tests.dockerfile │ ├── test_intkey_cli.yaml │ ├── test_intkey_smoke_python.yaml │ ├── test_systemd_services.yaml │ ├── test_two_families.yaml │ ├── test_workload.yaml │ └── test_xo_smoke_python.yaml ├── nose2.cfg └── tests │ ├── __init__.py │ ├── integration_tools.py │ ├── intkey_client.py │ ├── test_intkey_cli.py │ ├── test_intkey_smoke.py │ ├── test_systemd.sh │ ├── test_two_families.py │ ├── test_workload.py │ └── test_xo_smoke.py ├── signing-tests.dockerfile ├── test_context.py ├── test_secp256k1_signer.py ├── test_zmq_driver.py ├── test_zmq_service.py ├── unit_python_sdk.yaml └── unit_signing.yaml /.dockerignore: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | # Exclude IDE and Editor files 17 | /.idea/ 18 | *.sublime* 19 | 20 | # Everything else 21 | 22 | /build/ 23 | 24 | /coverage 25 | /coverage/html 26 | /**/.coverage 27 | 28 | /docs/build/ 29 | /docs/source/_autogen/ 30 | /docs/source/cli/output/ 31 | /docs/source/sdks/ 32 | 33 | /examples/xo_python/build/ 34 | /examples/xo_python/**/__pycache__/ 35 | /examples/intkey_python/build/ 36 | /examples/intkey_python/**/__pycache__/ 37 | /examples/noop_python/**/__pycache__/ 38 | 39 | /sawtooth_processor_test/__pycache__/ 40 | 41 | /sawtooth_sdk/__pycache__/ 42 | /sawtooth_sdk/consensus/__pycache__/ 43 | /sawtooth_sdk/messaging/__pycache__/ 44 | /sawtooth_sdk/processor/__pycache__/ 45 | /sawtooth_sdk/protobuf/ 46 | 47 | /tests/__pycache__/ 48 | /tests/sawtooth_integration/tests/__pycache__/ 49 | 50 | /sawtooth_signing.egg-info/ 51 | /sawtooth_signing/**/__pycache__/ 52 | 53 | *.batch 54 | -------------------------------------------------------------------------------- /.env: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Cargill Incorporated 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | ISOLATION_ID=latest 16 | INSTALL_TYPE=-local 17 | DISTRO=bionic 18 | -------------------------------------------------------------------------------- /.github/settings.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Cargill Incorporated 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | repository: 16 | # See https://developer.github.com/v3/repos/#edit for all available settings. 17 | name: sawtooth-sdk-python 18 | homepage: https://wiki.hyperledger.org/display/sawtooth 19 | private: false 20 | has_issues: true 21 | archived: true 22 | has_projects: false 23 | has_wiki: false 24 | has_downloads: false 25 | default_branch: main 26 | allow_squash_merge: false 27 | allow_merge_commit: true 28 | allow_rebase_merge: true 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | # Exclude IDE and Editor files 17 | /.idea/ 18 | *.sublime* 19 | 20 | # Everything else 21 | 22 | /build/ 23 | 24 | /coverage 25 | /coverage/html 26 | /**/.coverage 27 | 28 | /docs/build/ 29 | /docs/source/_autogen/ 30 | /docs/source/cli/output/ 31 | /docs/source/sdks/ 32 | 33 | /examples/xo_python/build/ 34 | /examples/xo_python/**/__pycache__/ 35 | /examples/intkey_python/build/ 36 | /examples/intkey_python/**/__pycache__/ 37 | /examples/noop_python/**/__pycache__/ 38 | 39 | /sawtooth_processor_test/__pycache__/ 40 | 41 | /sawtooth_sdk/__pycache__/ 42 | /sawtooth_sdk/consensus/__pycache__/ 43 | /sawtooth_sdk/messaging/__pycache__/ 44 | /sawtooth_sdk/processor/__pycache__/ 45 | /sawtooth_sdk/protobuf/ 46 | 47 | /tests/__pycache__/ 48 | /tests/sawtooth_integration/tests/__pycache__/ 49 | 50 | /sawtooth_signing.egg-info/ 51 | /sawtooth_signing/**/__pycache__/ 52 | 53 | *.batch 54 | -------------------------------------------------------------------------------- /.pycodestyle: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | [pycodestyle] 17 | # W503: line break before binary operator 18 | # E722 do not use bare except 19 | ignore=W503,E722 20 | exclude=build,docs,*_pb2.py 21 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @agunde406 @cianx @dcmiddle @jsmitchell @peterschwarz @rberg2 @rbuysse @vaporos 2 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | Code of Conduct Guidelines 2 | ========================== 3 | 4 | Please review the Hyperledger [Code of 5 | Conduct](https://tsc.hyperledger.org/code-of-conduct.html) before participating 6 | and abide by these community standards. 7 | 8 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Hyperledger Sawtooth 2 | 3 | Hyperledger Sawtooth is Apache 2.0 licensed and accepts contributions via 4 | [GitHub](https://github.com/hyperledger/sawtooth-core) pull requests. 5 | 6 | Please see 7 | [Contributing](https://sawtooth.hyperledger.org/docs/core/releases/latest/community/contributing.html) 8 | in the Sawtooth documentation for information on how to contribute and the guidelines for contributions. 9 | 10 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Cargill Incorporated 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # docker build -f Dockerfile -t sawtooth-sdk-python-local . 16 | 17 | # -------------=== python sdk build ===------------- 18 | 19 | FROM ubuntu:bionic 20 | 21 | RUN apt-get update \ 22 | && apt-get install gnupg -y 23 | 24 | ENV VERSION=AUTO_STRICT 25 | 26 | RUN echo "deb http://repo.sawtooth.me/ubuntu/nightly bionic universe" >> /etc/apt/sources.list \ 27 | && (apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 44FC67F19B2466EA \ 28 | || apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 44FC67F19B2466EA) \ 29 | && apt-get update 30 | 31 | RUN apt-get install -y -q \ 32 | git \ 33 | python3 \ 34 | python3-stdeb 35 | 36 | RUN apt-get install -y -q \ 37 | python3-grpcio \ 38 | python3-grpcio-tools \ 39 | python3-protobuf 40 | 41 | RUN apt-get install -y -q \ 42 | python3-colorlog \ 43 | python3-secp256k1 \ 44 | python3-toml \ 45 | python3-yaml \ 46 | python3-zmq 47 | 48 | ENV PATH=$PATH:/project/sawtooth-sdk-python/bin 49 | 50 | WORKDIR /project/sawtooth-sdk-python 51 | 52 | CMD echo "\033[0;32m--- Building python sdk ---\n\033[0m" \ 53 | && bin/protogen \ 54 | && python3 setup.py clean --all \ 55 | && python3 setup.py build 56 | -------------------------------------------------------------------------------- /Dockerfile-installed-bionic: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Cargill Incorporated 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # docker build -f Dockerfile-installed-bionic -t sawtooth-sdk-python . 16 | 17 | # -------------=== python sdk build ===------------- 18 | 19 | FROM ubuntu:bionic as sawtooth-sdk-python-builder 20 | 21 | RUN apt-get update \ 22 | && apt-get install gnupg -y 23 | 24 | ENV VERSION=AUTO_STRICT 25 | 26 | RUN echo "deb http://repo.sawtooth.me/ubuntu/ci bionic universe" >> /etc/apt/sources.list \ 27 | && (apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 8AA7AF1F1091A5FD \ 28 | || apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 8AA7AF1F1091A5FD) \ 29 | && apt-get update \ 30 | && apt-get install -y -q \ 31 | git \ 32 | python3 \ 33 | python3-colorlog \ 34 | python3-protobuf \ 35 | python3-stdeb \ 36 | python3-grpcio-tools \ 37 | python3-grpcio \ 38 | python3-secp256k1 \ 39 | python3-toml \ 40 | python3-yaml \ 41 | python3-zmq 42 | 43 | COPY . /project 44 | 45 | RUN /project/bin/protogen \ 46 | && cd /project \ 47 | && if [ -d "debian" ]; then rm -rf debian; fi \ 48 | && python3 setup.py clean --all \ 49 | && python3 setup.py --command-packages=stdeb.command debianize \ 50 | && if [ -d "packaging/ubuntu" ]; then cp -R packaging/ubuntu/* debian/; fi \ 51 | && dpkg-buildpackage -b -rfakeroot -us -uc 52 | 53 | 54 | # -------------=== python sdk docker build ===------------- 55 | FROM ubuntu:bionic 56 | 57 | RUN apt-get update \ 58 | && apt-get install gnupg -y 59 | 60 | COPY --from=sawtooth-sdk-python-builder /python3-sawtooth-sdk*.deb /tmp 61 | 62 | RUN echo "deb http://repo.sawtooth.me/ubuntu/ci bionic universe" >> /etc/apt/sources.list \ 63 | && (apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 8AA7AF1F1091A5FD \ 64 | || apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 8AA7AF1F1091A5FD) \ 65 | && apt-get update \ 66 | && dpkg -i /tmp/python3-sawtooth*.deb || true \ 67 | && apt-get -f -y install \ 68 | && apt-get clean \ 69 | && rm -rf /var/lib/apt/lists/* 70 | -------------------------------------------------------------------------------- /Dockerfile-installed-xenial: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Cargill Incorporated 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # docker build -f Dockerfile-installed-xenial -t sawtooth-sdk-python . 16 | 17 | # -------------=== python sdk build ===------------- 18 | 19 | FROM ubuntu:xenial as sawtooth-sdk-python-builder 20 | 21 | ENV VERSION=AUTO_STRICT 22 | 23 | RUN echo "deb http://repo.sawtooth.me/ubuntu/ci xenial universe" >> /etc/apt/sources.list \ 24 | && (apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 8AA7AF1F1091A5FD \ 25 | || apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 8AA7AF1F1091A5FD) \ 26 | && apt-get update \ 27 | && apt-get install -y -q --allow-downgrades \ 28 | git \ 29 | python3 \ 30 | python3-colorlog \ 31 | python3-protobuf \ 32 | python3-stdeb \ 33 | python3-grpcio-tools \ 34 | python3-grpcio \ 35 | python3-secp256k1 \ 36 | python3-toml \ 37 | python3-yaml \ 38 | python3-zmq 39 | 40 | COPY . /project 41 | 42 | RUN dpkg -i /tmp/python3-sawtooth-*.deb || true \ 43 | && apt-get -f -y install \ 44 | && /project/bin/protogen \ 45 | && cd /project \ 46 | && if [ -d "debian" ]; then rm -rf debian; fi \ 47 | && python3 setup.py clean --all \ 48 | && python3 setup.py --command-packages=stdeb.command debianize \ 49 | && if [ -d "packaging/ubuntu" ]; then cp -R packaging/ubuntu/* debian/; fi \ 50 | && dpkg-buildpackage -b -rfakeroot -us -uc 51 | 52 | 53 | # -------------=== python sdk docker build ===------------- 54 | FROM ubuntu:xenial 55 | 56 | COPY --from=sawtooth-sdk-python-builder /python3-sawtooth-sdk*.deb /tmp 57 | 58 | RUN echo "deb http://repo.sawtooth.me/ubuntu/ci xenial universe" >> /etc/apt/sources.list \ 59 | && (apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 8AA7AF1F1091A5FD \ 60 | || apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 8AA7AF1F1091A5FD) \ 61 | && apt-get update \ 62 | && dpkg -i /tmp/python3-sawtooth*.deb || true \ 63 | && apt-get -f -y install \ 64 | && apt-get clean \ 65 | && rm -rf /var/lib/apt/lists/* 66 | -------------------------------------------------------------------------------- /MAINTAINERS.md: -------------------------------------------------------------------------------- 1 | ## Maintainers 2 | 3 | ### Active Maintainers 4 | | Name | GitHub | 5 | | --- | --- | 6 | | Andi Gunderson | agunde406 | 7 | | Cian Montgomery | cianx | 8 | | Dan Middleton | dcmiddle | 9 | | James Mitchell | jsmitchell | 10 | | Peter Schwarz | peterschwarz | 11 | | Richard Berg | rberg2 | 12 | | Ryan Beck-Buysse | rbuysse | 13 | | Shawn Amundson | vaporos | 14 | 15 | ### Retired Maintainers 16 | | Name | GitHub | 17 | | --- | --- | 18 | | Adam Ludvik | aludvik | 19 | | Anne Chenette | chenette | 20 | | Boyd Johnson | boydjohnson | 21 | | Darian Plumb | dplumb94 | 22 | | Jamie Jason | jjason | 23 | | Nick Drozd | nick-drozd | 24 | | Zac Delventhal | delventhalz | 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Hyperledger Sawtooth 2 | 3 | This project has moved (see below). 4 | 5 | Hyperledger Sawtooth was a project to provide an enterprise solution for 6 | building, deploying, and running distributed ledgers (also called blockchains). 7 | 8 | # Project Status 9 | 10 | This Hyperledger project, Hyperledger Sawtooth, has been archived and is no 11 | longer active within Hyperledger. 12 | 13 | Sawtooth is now maintained by the Splinter community. For more information, 14 | visit: https://github.com/splintercommunity/sawtooth-core/ 15 | 16 | # License 17 | 18 | Hyperledger Sawtooth software is licensed under the [Apache License Version 2.0](LICENSE) software license. 19 | -------------------------------------------------------------------------------- /RELEASE_NOTES.md: -------------------------------------------------------------------------------- 1 | # Release Notes 2 | 3 | ## Changes in Sawtooth Python SDK 1.2.5 4 | 5 | * Update publishing scripts to compile protobufs before publishing to pypi 6 | 7 | ## Changes in Sawtooth Python SDK 1.2.4 8 | 9 | * Update signing code to be compatible with secp256k1-py 0.14.0 10 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Hyperledger Security Policy 2 | 3 | ## Reporting a Security Bug 4 | 5 | If you think you have discovered a security issue in any of the Hyperledger 6 | projects, we'd love to hear from you. We will take all security bugs 7 | seriously and if confirmed upon investigation we will patch it within a 8 | reasonable amount of time and release a public security bulletin discussing 9 | the impact and credit the discoverer. 10 | 11 | There are two ways to report a security bug. The easiest is to email a 12 | description of the flaw and any related information (e.g. reproduction 13 | steps, version) to 14 | [security at hyperledger dot org](mailto:security@hyperledger.org). 15 | 16 | The other way is to file a confidential security bug in our 17 | [JIRA bug tracking system](https://jira.hyperledger.org). 18 | Be sure to set the “Security Level” to “Security issue”. 19 | 20 | The process by which the Hyperledger Security Team handles security bugs 21 | is documented further in our 22 | [Defect Response](https://wiki.hyperledger.org/display/HYP/Defect+Response) 23 | page on our [wiki](https://wiki.hyperledger.org). 24 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 1.2.6 2 | -------------------------------------------------------------------------------- /bin/authorize-cicd: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright 2017 Intel Corporation 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # ------------------------------------------------------------------------------ 17 | 18 | if [[ -z $1 || -z $2 ]] 19 | then 20 | echo "USAGE: $0 [user] [authlist]" 21 | exit 1 22 | fi 23 | 24 | authlist=$(cat $2 | grep user | sed 's#.*: \(.*$\)#\1#') 25 | for user in $authlist 26 | do 27 | if [[ $user == $1 ]] 28 | then 29 | echo "SUCCESS: User '$1' authorized" 30 | exit 0 31 | fi 32 | done 33 | 34 | echo "FAILED: User '$1' not authorized." 35 | exit 1 36 | -------------------------------------------------------------------------------- /bin/get_version: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # Copyright 2016, 2017 Intel Corporation 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # ------------------------------------------------------------------------------ 17 | 18 | import os 19 | import subprocess 20 | import sys 21 | 22 | top_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) 23 | 24 | version_file = top_dir + "/VERSION" 25 | 26 | with open(version_file, 'r') as f: 27 | version_data = f.read().strip() 28 | 29 | 30 | def bump_version(version): 31 | (major, minor, patch) = version.split('.') 32 | if 'rc' in patch: 33 | parts = patch.split('rc') 34 | parts[1] = str(int(parts[1]) + 1) 35 | patch = "rc".join(parts) 36 | else: 37 | patch = str(int(patch) + 1) 38 | return ".".join([major, minor, patch]) 39 | 40 | 41 | def auto_version(default, strict): 42 | output = subprocess.check_output(['git', 'describe', '--dirty']) 43 | parts = output.decode('utf-8').strip().split('-', 3) 44 | parts[0] = parts[0][1:] # strip the leading 'v' 45 | if len(parts) > 1: 46 | parts[0] = bump_version(parts[0]) 47 | if default != parts[0]: 48 | msg = "VERSION file and (bumped?) git describe versions differ: " \ 49 | "{} != {}".format(default, parts[0]) 50 | if strict: 51 | print("ERROR: " + msg, file=sys.stderr) 52 | sys.exit(1) 53 | else: 54 | print("WARNING: " + msg, file=sys.stderr) 55 | print( 56 | "WARNING: using setup.py version {}".format(default), 57 | file=sys.stderr) 58 | parts[0] = default 59 | 60 | if len(parts) > 1: 61 | parts[0] = "-dev".join([parts[0], parts[1].replace("-", ".")]) 62 | if len(parts) == 4: 63 | parts[0] = parts[0] + "-" + parts[3] 64 | return parts[0] 65 | else: 66 | return parts[0] 67 | 68 | 69 | def version(default): 70 | if 'VERSION' in os.environ: 71 | if os.environ['VERSION'] == 'AUTO_STRICT': 72 | version = auto_version(default, strict=True) 73 | elif os.environ['VERSION'] == 'AUTO': 74 | version = auto_version(default, strict=False) 75 | else: 76 | version = os.environ['VERSION'] 77 | else: 78 | version = default + "-dev1" 79 | return version 80 | 81 | 82 | print(version(version_data)) 83 | -------------------------------------------------------------------------------- /bin/intkey: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # Copyright 2016 Intel Corporation 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # ------------------------------------------------------------------------------ 17 | 18 | import os 19 | import sys 20 | import sysconfig 21 | 22 | build_str = "lib.{}-{}.{}".format( 23 | sysconfig.get_platform(), 24 | sys.version_info.major, sys.version_info.minor) 25 | 26 | sys.path.insert(0, os.path.join( 27 | os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 28 | 'examples', 'intkey_python')) 29 | sys.path.insert(0, os.path.join( 30 | os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 31 | )) 32 | 33 | from sawtooth_intkey.client_cli.intkey_cli import main_wrapper 34 | 35 | if __name__ == '__main__': 36 | main_wrapper() 37 | -------------------------------------------------------------------------------- /bin/intkey-tp-python: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright 2016 Intel Corporation 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # ------------------------------------------------------------------------------ 17 | 18 | import os 19 | import sys 20 | import sysconfig 21 | 22 | build_str = "lib.{}-{}.{}".format( 23 | sysconfig.get_platform(), 24 | sys.version_info.major, sys.version_info.minor) 25 | 26 | sys.path.insert(0, os.path.join( 27 | os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 28 | 'examples', 'intkey_python')) 29 | sys.path.insert(0, os.path.join( 30 | os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 31 | )) 32 | 33 | from sawtooth_intkey.processor.main import main 34 | 35 | if __name__ == '__main__': 36 | main() 37 | -------------------------------------------------------------------------------- /bin/noop: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # Copyright 2017 Intel Corporation 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # ------------------------------------------------------------------------------ 17 | 18 | import os 19 | import sys 20 | import sysconfig 21 | 22 | build_str = "lib.{}-{}.{}".format( 23 | sysconfig.get_platform(), 24 | sys.version_info.major, sys.version_info.minor) 25 | 26 | sys.path.insert(0, os.path.join( 27 | os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 28 | 'examples', 'noop_python')) 29 | sys.path.insert(0, os.path.join( 30 | os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 31 | )) 32 | 33 | from sawtooth_noop.client_cli.main import main_wrapper 34 | 35 | if __name__ == '__main__': 36 | main_wrapper() 37 | -------------------------------------------------------------------------------- /bin/protogen: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright 2017 Intel Corporation 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # ------------------------------------------------------------------------------ 17 | 18 | import os 19 | import tempfile 20 | from glob import glob 21 | import re 22 | import subprocess 23 | import sys 24 | 25 | 26 | try: 27 | from grpc.tools.protoc import main as _protoc 28 | except ImportError: 29 | print("Error: grpc.tools.protoc not found") 30 | exit(1) 31 | 32 | 33 | JOIN = os.path.join 34 | TOP_DIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) 35 | 36 | 37 | def main(args=None): 38 | if args is None: 39 | args = sys.argv[1:] 40 | # Generate and distribute top-level protos 41 | proto_dir = JOIN(TOP_DIR, "protos") 42 | 43 | protoc(proto_dir, TOP_DIR, "sawtooth_sdk/protobuf") 44 | 45 | 46 | def protoc(src_dir, base_dir, pkg, language="python"): 47 | if language == "python": 48 | protoc_python(src_dir, base_dir, pkg) 49 | 50 | 51 | def protoc_python(src_dir, base_dir, pkg): 52 | # 1. Create output package directory 53 | pkg_dir = JOIN(TOP_DIR, base_dir, pkg) 54 | os.makedirs(pkg_dir, exist_ok=True) 55 | 56 | # 2. 'touch' the __init__.py file if the output directory exists 57 | init_py = JOIN(pkg_dir, "__init__.py") 58 | if not os.path.exists(init_py): 59 | with open(init_py, "w") as fd: 60 | pass # Just need it to exist 61 | 62 | # 3. Create a temp directory for building 63 | with tempfile.TemporaryDirectory() as tmp_dir: 64 | tmp_pkg_dir = JOIN(tmp_dir, pkg) 65 | os.makedirs(tmp_pkg_dir) 66 | 67 | # 4. Get a list of all .proto files to build 68 | cwd = os.getcwd() 69 | os.chdir(src_dir) 70 | proto_files = glob("*.proto") 71 | os.chdir(cwd) 72 | 73 | # 5. Copy protos to temp dir and fix imports 74 | for proto in proto_files: 75 | src = JOIN(src_dir, proto) 76 | dst = JOIN(tmp_pkg_dir, proto) 77 | with open(src, encoding='utf-8') as fin: 78 | with open(dst, "w", encoding='utf-8') as fout: 79 | src_contents = fin.read() 80 | fixed_contents = fix_import(src_contents, pkg) 81 | fout.write(fixed_contents) 82 | 83 | # 6. Compile protobuf files 84 | _protoc([ 85 | __file__, 86 | "-I=%s" % tmp_dir, 87 | "--python_out=%s" % JOIN(TOP_DIR, base_dir), 88 | ] + glob("%s/*.proto" % tmp_pkg_dir)) 89 | 90 | 91 | def fix_import(contents, pkg, sub_dir=False): 92 | pattern = r'^import "(.*)\.proto\"' 93 | if sub_dir: 94 | template = r'import "%s/\1_pb2/\1.proto"' 95 | else: 96 | template = r'import "%s/\1.proto"' 97 | 98 | return re.sub( 99 | pattern, 100 | lambda match: match.expand(template) % pkg, 101 | contents, 102 | flags=re.MULTILINE) 103 | 104 | 105 | if __name__ == "__main__": 106 | try: 107 | main() 108 | except KeyboardInterrupt: 109 | exit(1) 110 | -------------------------------------------------------------------------------- /bin/run_bandit: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright 2017 Intel Corporation 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # ------------------------------------------------------------------------------ 17 | 18 | top_dir=$(cd $(dirname $(dirname $0)) && pwd) 19 | 20 | directories=" 21 | build/* 22 | sawtooth_processor_test/* 23 | tests/* 24 | " 25 | 26 | if [ ! -d "$top_dir/build" ]; then 27 | mkdir $top_dir/build 28 | fi 29 | 30 | for dir in $directories 31 | do 32 | if [ -z $ignore ] 33 | then 34 | ignore="$top_dir/$dir" 35 | else 36 | ignore="$ignore,$top_dir/$dir" 37 | fi 38 | done 39 | 40 | bandit -ll -r --ignore-nosec $top_dir \ 41 | --exclude $ignore \ 42 | -f html \ 43 | -o /project/sawtooth-sdk-python/build/bandit.html 44 | -------------------------------------------------------------------------------- /bin/xo: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # Copyright 2017 Intel Corporation 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # ------------------------------------------------------------------------------ 17 | 18 | import os 19 | import sys 20 | import sysconfig 21 | 22 | build_str = "lib.{}-{}.{}".format( 23 | sysconfig.get_platform(), 24 | sys.version_info.major, sys.version_info.minor) 25 | 26 | sys.path.insert(0, os.path.join( 27 | os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 28 | )) 29 | 30 | sys.path.insert(0, os.path.join( 31 | os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 32 | 'examples', 'xo_python')) 33 | 34 | from sawtooth_xo.xo_cli import main_wrapper 35 | 36 | if __name__ == '__main__': 37 | main_wrapper() 38 | -------------------------------------------------------------------------------- /bin/xo-tp-python: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright 2017 Intel Corporation 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # ------------------------------------------------------------------------------ 17 | 18 | import os 19 | import sys 20 | import sysconfig 21 | 22 | build_str = "lib.{}-{}.{}".format( 23 | sysconfig.get_platform(), 24 | sys.version_info.major, sys.version_info.minor) 25 | 26 | sys.path.insert(0, os.path.join( 27 | os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 28 | )) 29 | 30 | sys.path.insert(0, os.path.join( 31 | os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 32 | 'examples', 'xo_python')) 33 | 34 | from sawtooth_xo.processor.main import main 35 | 36 | if __name__ == '__main__': 37 | main() 38 | -------------------------------------------------------------------------------- /ci/nightly/sawtooth-intkey-tp-python: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | # Description: 17 | # Builds an image with the Sawtooth TP Intkey package installed from 18 | # the nightly Sawtooth Package Repository. 19 | # 20 | # Build: 21 | # $ cd sawtooth-sdk-python/ci/nightly 22 | # $ docker build . -f sawtooth-intkey-tp-python -t sawtooth-intkey-tp-python 23 | # 24 | # Run: 25 | # $ cd sawtooth-sdk-python 26 | # $ docker run sawtooth-intkey-tp-python 27 | 28 | FROM ubuntu:bionic 29 | 30 | RUN apt-get update \ 31 | && apt-get install gnupg -y 32 | 33 | LABEL "install-type"="repo" 34 | 35 | RUN echo "deb [arch=amd64] http://repo.sawtooth.me/ubuntu/nightly bionic universe" >> /etc/apt/sources.list \ 36 | && (apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 44FC67F19B2466EA \ 37 | || apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 44FC67F19B2466EA) \ 38 | && apt-get update \ 39 | && apt-get install -y -q \ 40 | python3-sawtooth-intkey \ 41 | && apt-get clean \ 42 | && rm -rf /var/lib/apt/lists/* 43 | 44 | EXPOSE 4004/tcp 45 | 46 | CMD ["intkey-tp-python", "-vv"] 47 | -------------------------------------------------------------------------------- /ci/nightly/sawtooth-xo-tp-python: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | # Description: 17 | # Builds an image with the Sawtooth TP XO package installed from 18 | # the nightly Sawtooth Package Repository. 19 | # 20 | # Build: 21 | # $ cd sawtooth-sdk-python/ci/nightly 22 | # $ docker build . -f sawtooth-xo-tp-python -t sawtooth-xo-tp-python 23 | # 24 | # Run: 25 | # $ cd sawtooth-sdk-python 26 | # $ docker run sawtooth-xo-tp-python 27 | 28 | FROM ubuntu:bionic 29 | 30 | RUN apt-get update \ 31 | && apt-get install gnupg -y 32 | 33 | LABEL "install-type"="repo" 34 | 35 | RUN echo "deb [arch=amd64] http://repo.sawtooth.me/ubuntu/nightly bionic universe" >> /etc/apt/sources.list \ 36 | && (apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 44FC67F19B2466EA \ 37 | || apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 44FC67F19B2466EA) \ 38 | && apt-get update \ 39 | && apt-get install -y -q \ 40 | python3-sawtooth-xo \ 41 | && apt-get clean \ 42 | && rm -rf /var/lib/apt/lists/* 43 | 44 | EXPOSE 4004/tcp 45 | 46 | CMD ["xo-tp-python", "-vv"] 47 | -------------------------------------------------------------------------------- /ci/sawtooth-build-docs: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | # Description: 17 | # Builds the environment needed to build the Sawtooth docs 18 | # Running the image will put the Sawtooth docs in 19 | # sawtooth-sdk-python/docs/build on your local machine. 20 | # 21 | # Build: 22 | # $ cd sawtooth-sdk-python 23 | # $ docker build . -f ci/sawtooth-build-docs -t sawtooth-build-docs 24 | # 25 | # Run: 26 | # $ cd sawtooth-sdk-python 27 | # $ docker run -v $(pwd):/project/sawtooth-sdk-python sawtooth-build-docs 28 | 29 | FROM ubuntu:bionic 30 | 31 | RUN apt-get update \ 32 | && apt-get install gnupg -y 33 | 34 | RUN echo "deb [arch=amd64] http://repo.sawtooth.me/ubuntu/ci bionic universe" >> /etc/apt/sources.list \ 35 | && (apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 8AA7AF1F1091A5FD \ 36 | || apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 8AA7AF1F1091A5FD) \ 37 | && apt-get update \ 38 | && apt-get install -y -q \ 39 | build-essential \ 40 | git \ 41 | latexmk \ 42 | libffi-dev \ 43 | libssl-dev \ 44 | libzmq3-dev \ 45 | pep8 \ 46 | pkg-config \ 47 | python3-aiodns \ 48 | python3-aiohttp \ 49 | python3-async-timeout \ 50 | python3-bitcoin \ 51 | python3-cbor \ 52 | python3-cchardet \ 53 | python3-colorlog \ 54 | python3-cryptography-vectors \ 55 | python3-cryptography \ 56 | python3-dev \ 57 | python3-grpcio-tools \ 58 | python3-grpcio \ 59 | python3-lmdb \ 60 | python3-multidict \ 61 | python3-netifaces \ 62 | python3-pyformance \ 63 | python3-pip \ 64 | python3-protobuf \ 65 | python3-pycares \ 66 | python3-pytest-runner \ 67 | python3-pytest \ 68 | python3-pytz \ 69 | python3-requests \ 70 | python3-secp256k1 \ 71 | python3-setuptools-scm \ 72 | python3-six \ 73 | python3-toml \ 74 | python3-yaml \ 75 | python3-yarl \ 76 | python3-zmq \ 77 | unzip \ 78 | && apt-get clean \ 79 | && rm -rf /var/lib/apt/lists/* \ 80 | && pip3 install \ 81 | pylint \ 82 | bandit==1.7.1 83 | 84 | 85 | ENV DEBIAN_FRONTEND=noninteractive 86 | 87 | RUN apt-get update && apt-get install -y -q \ 88 | curl \ 89 | dvipng \ 90 | make \ 91 | sudo \ 92 | texlive-fonts-recommended \ 93 | texlive-latex-base \ 94 | texlive-latex-extra \ 95 | texlive-latex-recommended \ 96 | zip \ 97 | && apt-get clean \ 98 | && rm -rf /var/lib/apt/lists/* \ 99 | && pip3 install \ 100 | docutils==0.16 \ 101 | mistune==0.8.4 \ 102 | sphinx==2.0.1 \ 103 | sphinxcontrib-httpdomain \ 104 | sphinxcontrib-openapi \ 105 | sphinx_rtd_theme 106 | 107 | WORKDIR /project/sawtooth-sdk-python/docs 108 | CMD make python 109 | -------------------------------------------------------------------------------- /ci/sawtooth-intkey-tp-python: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | # Description: 17 | # Builds an image with the Sawtooth TP Intkey package installed from 18 | # the Sawtooth Package Repository. 19 | # 20 | # Build: 21 | # $ cd sawtooth-sdk-python/docker 22 | # $ docker build . -f sawtooth-intkey-tp-python -t sawtooth-intkey-tp-python 23 | # 24 | # Run: 25 | # $ cd sawtooth-sdk-python 26 | # $ docker run sawtooth-intkey-tp-python 27 | 28 | FROM ubuntu:bionic 29 | 30 | RUN apt-get update \ 31 | && apt-get install gnupg -y 32 | 33 | LABEL "install-type"="repo" 34 | 35 | RUN echo "deb [arch=amd64] http://repo.sawtooth.me/ubuntu/chime/stable bionic universe" >> /etc/apt/sources.list \ 36 | && (apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 8AA7AF1F1091A5FD \ 37 | || apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 8AA7AF1F1091A5FD) \ 38 | && apt-get update \ 39 | && apt-get install -y -q \ 40 | python3-sawtooth-intkey \ 41 | && apt-get clean \ 42 | && rm -rf /var/lib/apt/lists/* 43 | 44 | EXPOSE 4004/tcp 45 | 46 | CMD ["intkey-tp-python", "-vv"] 47 | -------------------------------------------------------------------------------- /ci/sawtooth-publish-python-sdk: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | # Description: 17 | # Builds an environment to publish the Sawtooth Python SDK to PyPI. 18 | # Two variables, $PYPI_USER and $PYPI_PASS, must be passed in at runtime 19 | # using Docker's -e option. 20 | # 21 | # docker build -t sawtooth-publish-python-sdk -f ci/sawtooth-publish-python-sdk . 22 | # docker run --rm -v $(pwd):/project/sawtooth-sdk-python -e PYPI_USER=%user% -e PYPI_PASS=%pass% sawtooth-publish-python-sdk 23 | 24 | FROM ubuntu:bionic 25 | 26 | RUN apt-get update \ 27 | && apt-get install gnupg -y 28 | 29 | RUN echo "deb http://repo.sawtooth.me/ubuntu/ci bionic universe" >> /etc/apt/sources.list \ 30 | && (apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 8AA7AF1F1091A5FD \ 31 | || apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 8AA7AF1F1091A5FD) \ 32 | && apt-get update \ 33 | && apt-get install -y \ 34 | ca-certificates \ 35 | python3 \ 36 | python3-grpcio-tools \ 37 | python3-grpcio \ 38 | python3-pip \ 39 | python3-protobuf \ 40 | && apt-get clean \ 41 | && rm -rf /var/lib/apt/lists/* \ 42 | && python3 -m pip install --upgrade pip \ 43 | && python3 -m pip install --upgrade setuptools twine \ 44 | && echo '[distutils]\n\ 45 | index-servers =\n\ 46 | pypi\n\ 47 | \n\ 48 | [pypi]\n\ 49 | username=@USER@\n\ 50 | password=@PASS@\n\ 51 | ' > /root/.pypirc 52 | 53 | CMD sed -i'' -e "s/@USER@/$PYPI_USER/g" /root/.pypirc \ 54 | && sed -i'' -e "s/@PASS@/$PYPI_PASS/g" /root/.pypirc \ 55 | && cd /project/sawtooth-sdk-python/ \ 56 | && /project/sawtooth-sdk-python/bin/protogen \ 57 | && python3 setup.py sdist bdist_wheel \ 58 | && twine upload dist/* 59 | -------------------------------------------------------------------------------- /ci/sawtooth-xo-tp-python: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | # Description: 17 | # Builds an image with the Sawtooth TP XO package installed from 18 | # the Sawtooth Package Repository. 19 | # 20 | # Build: 21 | # $ cd sawtooth-sdk-python/docker 22 | # $ docker build . -f sawtooth-xo-tp-python -t sawtooth-xo-tp-python 23 | # 24 | # Run: 25 | # $ cd sawtooth-sdk-python 26 | # $ docker run sawtooth-xo-tp-python 27 | 28 | FROM ubuntu:bionic 29 | 30 | RUN apt-get update \ 31 | && apt-get install gnupg -y 32 | 33 | LABEL "install-type"="repo" 34 | 35 | RUN echo "deb [arch=amd64] http://repo.sawtooth.me/ubuntu/chime/stable bionic universe" >> /etc/apt/sources.list \ 36 | && (apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 8AA7AF1F1091A5FD \ 37 | || apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 8AA7AF1F1091A5FD) \ 38 | && apt-get update \ 39 | && apt-get install -y -q \ 40 | python3-sawtooth-xo \ 41 | && apt-get clean \ 42 | && rm -rf /var/lib/apt/lists/* 43 | 44 | EXPOSE 4004/tcp 45 | 46 | CMD ["xo-tp-python", "-vv"] 47 | -------------------------------------------------------------------------------- /docker/bandit: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Cargill Incorporated 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | FROM ubuntu:bionic 16 | 17 | RUN apt-get update \ 18 | && apt-get install gnupg -y 19 | 20 | RUN echo "deb [arch=amd64] http://repo.sawtooth.me/ubuntu/ci bionic universe" >> /etc/apt/sources.list \ 21 | && (apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 8AA7AF1F1091A5FD \ 22 | || apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 8AA7AF1F1091A5FD) \ 23 | && apt-get update 24 | 25 | RUN apt-get install -y -q \ 26 | python3-dev \ 27 | python3-pip \ 28 | && pip3 install \ 29 | bandit==1.7.1 \ 30 | coverage --upgrade 31 | 32 | ENV PATH=$PATH:/project/sawtooth-sdk-python/bin 33 | -------------------------------------------------------------------------------- /docker/compose/copy-debs.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Cargill Incorporated 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | version: '3.6' 16 | 17 | services: 18 | 19 | intkey-tp-python: 20 | image: sawtooth-intkey-tp-python:${ISOLATION_ID} 21 | volumes: 22 | - ../../build/debs:/build/debs 23 | command: | 24 | bash -c " 25 | cp /tmp/*.deb /build/debs 26 | " 27 | 28 | xo-tp-python: 29 | image: sawtooth-xo-tp-python:${ISOLATION_ID} 30 | volumes: 31 | - ../../build/debs:/build/debs 32 | command: | 33 | bash -c " 34 | cp /tmp/*.deb /build/debs 35 | " 36 | 37 | python-sdk: 38 | image: sawtooth-sdk-python:${ISOLATION_ID} 39 | volumes: 40 | - ../../build/debs:/build/debs 41 | command: | 42 | bash -c " 43 | cp /tmp/*.deb /build/debs 44 | " 45 | 46 | intkey-tests: 47 | image: sawtooth-intkey-tests:${ISOLATION_ID} 48 | volumes: 49 | - ../../build/debs:/build/debs 50 | command: | 51 | bash -c " 52 | cp /tmp/*.deb /build/debs 53 | " 54 | 55 | xo-tests: 56 | image: sawtooth-xo-tests:${ISOLATION_ID} 57 | volumes: 58 | - ../../build/debs:/build/debs 59 | command: | 60 | bash -c " 61 | cp /tmp/*.deb /build/debs 62 | " 63 | -------------------------------------------------------------------------------- /docker/compose/run-lint.yaml: -------------------------------------------------------------------------------- 1 | 2 | # Copyright 2018 Cargill Incorporated 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | version: '3.6' 17 | 18 | services: 19 | 20 | lint-python: 21 | build: 22 | context: ../ 23 | dockerfile: ./lint 24 | args: 25 | - http_proxy 26 | - https_proxy 27 | - no_proxy 28 | image: lint:${ISOLATION_ID} 29 | volumes: 30 | - ../../:/project/sawtooth-sdk-python 31 | command: run_lint 32 | -------------------------------------------------------------------------------- /docker/compose/sawtooth-build.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Cargill Incorporated 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | version: '3.6' 16 | 17 | services: 18 | 19 | python-sdk: 20 | build: 21 | context: ../../ 22 | dockerfile: ./Dockerfile 23 | args: 24 | - http_proxy 25 | - https_proxy 26 | - no_proxy 27 | image: sawtooth-python-sdk-local:${ISOLATION_ID} 28 | volumes: 29 | - ../../:/project/sawtooth-sdk-python 30 | -------------------------------------------------------------------------------- /docker/lint: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Cargill Incorporated 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | FROM ubuntu:bionic 16 | 17 | RUN apt-get update \ 18 | && apt-get install gnupg -y 19 | 20 | RUN echo "deb [arch=amd64] http://repo.sawtooth.me/ubuntu/nightly bionic universe" >> /etc/apt/sources.list \ 21 | && (apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 44FC67F19B2466EA \ 22 | || apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 44FC67F19B2466EA) \ 23 | && apt-get update 24 | 25 | RUN apt-get install -y -q \ 26 | git \ 27 | python3 \ 28 | python3-aiohttp \ 29 | python3-cbor \ 30 | python3-sawtooth-cli \ 31 | python3-colorlog \ 32 | python3-cryptography-vectors \ 33 | python3-cryptography \ 34 | python3-lmdb \ 35 | python3-netifaces \ 36 | python3-pip \ 37 | python3-protobuf \ 38 | python3-pyformance \ 39 | python3-requests \ 40 | python3-secp256k1 \ 41 | python3-toml \ 42 | python3-yaml \ 43 | python3-zmq \ 44 | && pip3 install \ 45 | pylint==2.6.2 \ 46 | pycodestyle \ 47 | bandit==1.7.1 \ 48 | coverage --upgrade 49 | 50 | RUN apt-get install -y -q \ 51 | build-essential \ 52 | git \ 53 | libssl-dev \ 54 | libzmq3-dev \ 55 | openssl \ 56 | python3-grpcio-tools 57 | 58 | ENV PATH=$PATH:/project/sawtooth-sdk-python/bin 59 | 60 | RUN apt-get install -y -q \ 61 | build-essential \ 62 | curl \ 63 | libssl-dev \ 64 | gcc \ 65 | libzmq3-dev \ 66 | openssl \ 67 | pkg-config \ 68 | python3-grpcio-tools \ 69 | unzip 70 | 71 | WORKDIR /project/sawtooth-sdk-python 72 | -------------------------------------------------------------------------------- /docs/source/_static/theme_overrides.css: -------------------------------------------------------------------------------- 1 | /* Copyright 2017 Intel Corporation 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | ------------------------------------------------------------------------------*/ 14 | /* Override table cells ignoring width settings when content is too long 15 | */ 16 | .wy-table-responsive table td, .wy-table-responsive table th { 17 | white-space: normal; 18 | } 19 | -------------------------------------------------------------------------------- /docs/source/_static/version_switcher.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016, 2017 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * ------------------------------------------------------------------------------ 16 | */ 17 | 18 | var VERSION_URL = 'https://sawtooth.hyperledger.org/docs/versions.json'; 19 | var versionRequest = new XMLHttpRequest(); 20 | var versionSwitcher = document.getElementById('version_switcher'); 21 | 22 | versionSwitcher.onchange = function() { 23 | if (this.value) { 24 | window.location.assign(this.value); 25 | } 26 | }; 27 | 28 | versionRequest.onreadystatechange = function() { 29 | if (!versionSwitcher.length && versionRequest.responseText) { 30 | var versions = JSON.parse(versionRequest.responseText); 31 | versions.forEach(function(versionTuple) { 32 | var option = document.createElement('option'); 33 | option.innerText = versionTuple[0]; 34 | option.value = versionTuple[1]; 35 | versionSwitcher.appendChild(option); 36 | if (window.location.href === option.value) { 37 | option.selected = true; 38 | } 39 | }); 40 | } 41 | }; 42 | 43 | versionRequest.open('GET', VERSION_URL, true); 44 | versionRequest.send(null); 45 | -------------------------------------------------------------------------------- /docs/source/_templates/indexcontent.html: -------------------------------------------------------------------------------- 1 | {# 2 | # Licensed under Creative Commons Attribution 4.0 International License 3 | # https://creativecommons.org/licenses/by/4.0/ 4 | #} 5 | 6 | {%- extends "layout.html" %} 7 | {% set title = 'Overview' %} 8 | {% block body %} 9 | 10 | 11 | {% endblock %} 12 | -------------------------------------------------------------------------------- /docs/source/contents.rst: -------------------------------------------------------------------------------- 1 | 2 | Table of Contents 3 | ================= 4 | 5 | .. toctree:: 6 | 7 | sdks/python_sdk/processor.rst 8 | sdks/python_sdk/sawtooth_signing.rst 9 | 10 | .. Licensed under Creative Commons Attribution 4.0 International License 11 | .. https://creativecommons.org/licenses/by/4.0/ 12 | -------------------------------------------------------------------------------- /examples/intkey_python/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Cargill Incorporated 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # docker build -f examples/intkey_python/Dockerfile -t intkey-tp-python-local . 16 | 17 | # -------------=== intkey-tp-python build ===------------- 18 | 19 | FROM ubuntu:bionic 20 | 21 | RUN apt-get update \ 22 | && apt-get install gnupg -y 23 | 24 | RUN echo "deb http://repo.sawtooth.me/ubuntu/nightly bionic universe" >> /etc/apt/sources.list \ 25 | && (apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 44FC67F19B2466EA \ 26 | || apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 44FC67F19B2466EA) \ 27 | && apt-get update 28 | 29 | RUN apt-get install -y -q \ 30 | git \ 31 | python3 \ 32 | python3-stdeb 33 | 34 | RUN apt-get install -y -q \ 35 | python3-grpcio \ 36 | python3-grpcio-tools \ 37 | python3-protobuf 38 | 39 | RUN apt-get install -y -q \ 40 | python3-cbor \ 41 | python3-colorlog \ 42 | python3-secp256k1 \ 43 | python3-toml \ 44 | python3-yaml \ 45 | python3-zmq 46 | 47 | RUN mkdir -p /var/log/sawtooth 48 | 49 | ENV PATH=$PATH:/project/sawtooth-sdk-python/bin 50 | 51 | WORKDIR /project/sawtooth-sdk-python 52 | 53 | CMD echo "\033[0;32m--- Building intkey-tp-python ---\n\033[0m" \ 54 | && bin/protogen \ 55 | && cd examples/intkey_python \ 56 | && python3 setup.py clean --all \ 57 | && python3 setup.py build 58 | -------------------------------------------------------------------------------- /examples/intkey_python/Dockerfile-installed-xenial: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Cargill Incorporated 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # docker build -f examples/intkey_python/Dockerfile-installed-xenial -t sawtooth-intkey-tp-python . 16 | 17 | # -------------=== python sdk build ===------------- 18 | 19 | FROM ubuntu:xenial as sawtooth-sdk-python-builder 20 | 21 | ENV VERSION=AUTO_STRICT 22 | 23 | 24 | RUN echo "deb http://repo.sawtooth.me/ubuntu/ci xenial universe" >> /etc/apt/sources.list \ 25 | && (apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 8AA7AF1F1091A5FD \ 26 | || apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 8AA7AF1F1091A5FD) \ 27 | && apt-get update \ 28 | && apt-get install -y -q --allow-downgrades \ 29 | git \ 30 | python3 \ 31 | python3-colorlog \ 32 | python3-protobuf \ 33 | python3-stdeb \ 34 | python3-grpcio-tools \ 35 | python3-grpcio \ 36 | python3-secp256k1 \ 37 | python3-toml \ 38 | python3-yaml 39 | 40 | COPY . /project 41 | 42 | RUN /project/bin/protogen \ 43 | && cd /project/ \ 44 | && if [ -d "debian" ]; then rm -rf debian; fi \ 45 | && python3 setup.py clean --all \ 46 | && python3 setup.py --command-packages=stdeb.command debianize \ 47 | && if [ -d "packaging/ubuntu" ]; then cp -R packaging/ubuntu/* debian/; fi \ 48 | && dpkg-buildpackage -b -rfakeroot -us -uc 49 | 50 | # -------------=== python intkey tp build ===------------- 51 | 52 | FROM ubuntu:xenial as python-intkey-tp-builder 53 | 54 | ENV VERSION=AUTO_STRICT 55 | 56 | RUN echo "deb http://repo.sawtooth.me/ubuntu/ci xenial universe" >> /etc/apt/sources.list \ 57 | && (apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 8AA7AF1F1091A5FD \ 58 | || apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 8AA7AF1F1091A5FD) \ 59 | && apt-get update \ 60 | && apt-get install -y -q --allow-downgrades \ 61 | git \ 62 | python3 \ 63 | python3-cbor \ 64 | python3-colorlog \ 65 | python3-grpcio-tools \ 66 | python3-grpcio \ 67 | python3-protobuf \ 68 | python3-stdeb 69 | 70 | COPY --from=sawtooth-sdk-python-builder /python3-sawtooth-sdk*.deb /tmp 71 | 72 | COPY . /project 73 | 74 | RUN dpkg -i /tmp/python3-sawtooth-*.deb || true \ 75 | && apt-get -f -y install \ 76 | && /project/bin/protogen \ 77 | && cd /project/examples/intkey_python/ \ 78 | && if [ -d "debian" ]; then rm -rf debian; fi \ 79 | && python3 setup.py clean --all \ 80 | && python3 setup.py --command-packages=stdeb.command debianize \ 81 | && if [ -d "packaging/ubuntu" ]; then cp -R packaging/ubuntu/* debian/; fi \ 82 | && dpkg-buildpackage -b -rfakeroot -us -uc 83 | 84 | # -------------=== python-intkey-tp docker build ===------------- 85 | FROM ubuntu:xenial 86 | 87 | COPY --from=sawtooth-sdk-python-builder /python3-sawtooth-sdk*.deb /tmp 88 | 89 | COPY --from=python-intkey-tp-builder /project/examples/python3-sawtooth-intkey*.deb /tmp 90 | 91 | RUN echo "deb http://repo.sawtooth.me/ubuntu/ci xenial universe" >> /etc/apt/sources.list \ 92 | && (apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 8AA7AF1F1091A5FD \ 93 | || apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 8AA7AF1F1091A5FD) \ 94 | && apt-get update \ 95 | && dpkg -i /tmp/python3-sawtooth-*.deb || true \ 96 | && apt-get -f -y install 97 | -------------------------------------------------------------------------------- /examples/intkey_python/nose2.cfg: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | [unittest] 16 | start-dir = tests 17 | code-directories = .. 18 | test-file-pattern = test*.py 19 | plugins = nose2.plugins.coverage 20 | 21 | [coverage] 22 | always-on = True 23 | -------------------------------------------------------------------------------- /examples/intkey_python/packaging/systemd/sawtooth-intkey-tp-python: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | SAWTOOTH_INTKEY_TP_PYTHON_ARGS=-v -C tcp://localhost:4004 17 | -------------------------------------------------------------------------------- /examples/intkey_python/packaging/systemd/sawtooth-intkey-tp-python.service: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | [Unit] 17 | Description=Sawtooth Intkey TP Python 18 | After=network.target 19 | 20 | [Service] 21 | User=sawtooth 22 | Group=sawtooth 23 | EnvironmentFile=-/etc/default/sawtooth-intkey-tp-python 24 | ExecStart=/usr/bin/intkey-tp-python $SAWTOOTH_INTKEY_TP_PYTHON_ARGS 25 | Restart=on-failure 26 | 27 | [Install] 28 | WantedBy=multi-user.target 29 | -------------------------------------------------------------------------------- /examples/intkey_python/sawtooth_intkey/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | __all__ = [ 17 | 'client_cli', 18 | 'processor' 19 | ] 20 | -------------------------------------------------------------------------------- /examples/intkey_python/sawtooth_intkey/client_cli/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | -------------------------------------------------------------------------------- /examples/intkey_python/sawtooth_intkey/client_cli/exceptions.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | 17 | class IntKeyCliException(Exception): 18 | pass 19 | 20 | 21 | class IntkeyClientException(Exception): 22 | pass 23 | -------------------------------------------------------------------------------- /examples/intkey_python/sawtooth_intkey/client_cli/workload/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | -------------------------------------------------------------------------------- /examples/intkey_python/sawtooth_intkey/intkey_message_factory.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | import cbor 17 | 18 | from sawtooth_intkey.processor.handler import INTKEY_ADDRESS_PREFIX 19 | from sawtooth_intkey.processor.handler import make_intkey_address 20 | 21 | from sawtooth_processor_test.message_factory import MessageFactory 22 | 23 | 24 | class IntkeyMessageFactory: 25 | def __init__(self, signer=None): 26 | self._factory = MessageFactory( 27 | family_name='intkey', 28 | family_version='1.0', 29 | namespace=INTKEY_ADDRESS_PREFIX, 30 | signer=signer) 31 | 32 | def _dumps(self, obj): 33 | return cbor.dumps(obj, sort_keys=True) 34 | 35 | def _loads(self, data): 36 | return cbor.loads(data) 37 | 38 | def create_tp_register(self): 39 | return self._factory.create_tp_register() 40 | 41 | def create_tp_response(self, status): 42 | return self._factory.create_tp_response(status) 43 | 44 | def _create_txn(self, txn_function, verb, name, value): 45 | payload = self._dumps({'Verb': verb, 'Name': name, 'Value': value}) 46 | 47 | addresses = [make_intkey_address(name)] 48 | 49 | return txn_function(payload, addresses, addresses, []) 50 | 51 | def create_tp_process_request(self, verb, name, value,): 52 | txn_function = self._factory.create_tp_process_request 53 | return self._create_txn(txn_function, verb, name, value) 54 | 55 | def create_transaction(self, verb, name, value,): 56 | txn_function = self._factory.create_transaction 57 | return self._create_txn(txn_function, verb, name, value) 58 | 59 | def create_batch(self, triples): 60 | txns = [ 61 | self.create_transaction(verb, name, value) 62 | for verb, name, value in triples 63 | ] 64 | 65 | return self._factory.create_batch(txns) 66 | 67 | def create_get_request(self, name): 68 | addresses = [make_intkey_address(name)] 69 | return self._factory.create_get_request(addresses) 70 | 71 | def create_get_response(self, name, value): 72 | address = make_intkey_address(name) 73 | 74 | if value is not None: 75 | data = self._dumps({name: value}) 76 | else: 77 | data = None 78 | 79 | return self._factory.create_get_response({address: data}) 80 | 81 | def create_set_request(self, name, value): 82 | address = make_intkey_address(name) 83 | 84 | if value is not None: 85 | data = self._dumps({name: value}) 86 | else: 87 | data = None 88 | 89 | return self._factory.create_set_request({address: data}) 90 | 91 | def create_set_response(self, name): 92 | addresses = [make_intkey_address(name)] 93 | return self._factory.create_set_response(addresses) 94 | -------------------------------------------------------------------------------- /examples/intkey_python/sawtooth_intkey/processor/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | __all__ = [ 17 | 'main' 18 | ] 19 | -------------------------------------------------------------------------------- /examples/intkey_python/sawtooth_intkey/processor/main.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | import sys 17 | import argparse 18 | import pkg_resources 19 | 20 | from sawtooth_intkey.processor.handler import IntkeyTransactionHandler 21 | 22 | from sawtooth_sdk.processor.core import TransactionProcessor 23 | from sawtooth_sdk.processor.log import init_console_logging 24 | from sawtooth_sdk.processor.log import log_configuration 25 | from sawtooth_sdk.processor.config import get_log_config 26 | from sawtooth_sdk.processor.config import get_log_dir 27 | 28 | 29 | DISTRIBUTION_NAME = 'sawtooth-intkey' 30 | 31 | 32 | def parse_args(args): 33 | parser = argparse.ArgumentParser( 34 | formatter_class=argparse.RawTextHelpFormatter) 35 | 36 | parser.add_argument( 37 | '-C', '--connect', 38 | default='tcp://localhost:4004', 39 | help='Endpoint for the validator connection') 40 | 41 | parser.add_argument('-v', '--verbose', 42 | action='count', 43 | default=0, 44 | help='Increase output sent to stderr') 45 | 46 | try: 47 | version = pkg_resources.get_distribution(DISTRIBUTION_NAME).version 48 | except pkg_resources.DistributionNotFound: 49 | version = 'UNKNOWN' 50 | 51 | parser.add_argument( 52 | '-V', '--version', 53 | action='version', 54 | version=(DISTRIBUTION_NAME + ' (Hyperledger Sawtooth) version {}') 55 | .format(version), 56 | help='print version information') 57 | 58 | return parser.parse_args(args) 59 | 60 | 61 | def main(args=None): 62 | if args is None: 63 | args = sys.argv[1:] 64 | opts = parse_args(args) 65 | processor = None 66 | try: 67 | processor = TransactionProcessor(url=opts.connect) 68 | log_config = get_log_config(filename="intkey_log_config.toml") 69 | 70 | # If no toml, try loading yaml 71 | if log_config is None: 72 | log_config = get_log_config(filename="intkey_log_config.yaml") 73 | 74 | if log_config is not None: 75 | log_configuration(log_config=log_config) 76 | else: 77 | log_dir = get_log_dir() 78 | # use the transaction processor zmq identity for filename 79 | log_configuration( 80 | log_dir=log_dir, 81 | name="intkey-" + str(processor.zmq_id)[2:-1]) 82 | 83 | init_console_logging(verbose_level=opts.verbose) 84 | 85 | # The prefix should eventually be looked up from the 86 | # validator's namespace registry. 87 | handler = IntkeyTransactionHandler() 88 | 89 | processor.add_handler(handler) 90 | 91 | processor.start() 92 | except KeyboardInterrupt: 93 | pass 94 | except Exception as e: # pylint: disable=broad-except 95 | print("Error: {}".format(e), file=sys.stderr) 96 | finally: 97 | if processor is not None: 98 | processor.stop() 99 | -------------------------------------------------------------------------------- /examples/intkey_python/setup.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | from __future__ import print_function 17 | 18 | import os 19 | import subprocess 20 | 21 | from setuptools import setup, find_packages 22 | 23 | 24 | data_files = [] 25 | 26 | if os.path.exists("/etc/default"): 27 | data_files.append( 28 | ('/etc/default', ['packaging/systemd/sawtooth-intkey-tp-python'])) 29 | 30 | if os.path.exists("/lib/systemd/system"): 31 | data_files.append( 32 | ('/lib/systemd/system', 33 | ['packaging/systemd/sawtooth-intkey-tp-python.service'])) 34 | 35 | setup( 36 | name='sawtooth-intkey', 37 | version=subprocess.check_output( 38 | ['../../bin/get_version']).decode('utf-8').strip(), 39 | description='Sawtooth Intkey Python Example', 40 | author='Hyperledger Sawtooth', 41 | url='https://github.com/hyperledger/sawtooth-sdk-python', 42 | packages=find_packages(), 43 | install_requires=[ 44 | "cbor", 45 | "colorlog", 46 | "sawtooth-sdk", 47 | ], 48 | data_files=data_files, 49 | entry_points={ 50 | 'console_scripts': [ 51 | 'intkey = sawtooth_intkey.client_cli.intkey_cli:main_wrapper', 52 | 'intkey-tp-python = sawtooth_intkey.processor.main:main' 53 | ] 54 | }) 55 | -------------------------------------------------------------------------------- /examples/intkey_python/setup_tests.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | from __future__ import print_function 17 | 18 | import os 19 | import subprocess 20 | 21 | from setuptools import setup, find_packages 22 | 23 | 24 | data_files = [] 25 | 26 | if os.path.exists("tests"): 27 | data_files.append(('/data/tests/intkey', ['tests/test_tp_intkey.py'])) 28 | data_files.append(('/data/tests/intkey', [ 29 | '../../tests/sawtooth_integration/tests/test_intkey_smoke.py'])) 30 | 31 | try: 32 | os.environ["ST_VERSION"] 33 | print('Using ST_VERSION') 34 | VERSION = os.environ["ST_VERSION"] 35 | except KeyError: 36 | print('ST_VERSION not set. Using get_version') 37 | VERSION = subprocess.check_output( 38 | ['../../bin/get_version']).decode('utf-8').strip() 39 | 40 | setup( 41 | name='sawtooth-intkey-tests', 42 | version=VERSION, 43 | description='Sawtooth Intkey Python Test', 44 | author='Hyperledger Sawtooth', 45 | url='https://github.com/hyperledger/sawtooth-sdk-python', 46 | packages=find_packages(), 47 | install_requires=[ 48 | "cbor", 49 | "colorlog", 50 | "sawtooth-sdk", 51 | ], 52 | data_files=data_files, 53 | entry_points={ 54 | 'console_scripts': [ 55 | 'intkey = sawtooth_intkey.client_cli.intkey_cli:main_wrapper', 56 | 'intkey-tp-python = sawtooth_intkey.processor.main:main' 57 | ] 58 | }) 59 | -------------------------------------------------------------------------------- /examples/intkey_python/tests/test_tp_intkey_python.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | version: "2.1" 17 | 18 | services: 19 | 20 | intkey-tp-python: 21 | build: 22 | context: ../../.. 23 | dockerfile: ./examples/intkey_python/Dockerfile 24 | args: 25 | - http_proxy 26 | - https_proxy 27 | - no_proxy 28 | image: sawtooth-intkey-tp-python$INSTALL_TYPE:$ISOLATION_ID 29 | volumes: 30 | - $SAWTOOTH_SDK_PYTHON:/project/sawtooth-sdk-python 31 | expose: 32 | - 4004 33 | command: intkey-tp-python -vv -C tcp://test-tp-intkey-python:4004 34 | stop_signal: SIGKILL 35 | 36 | test-tp-intkey-python: 37 | build: 38 | context: ../../.. 39 | dockerfile: tests/python-sdk-tests.dockerfile 40 | args: 41 | - http_proxy 42 | - https_proxy 43 | - no_proxy 44 | image: python-sdk-tests:$ISOLATION_ID 45 | volumes: 46 | - $SAWTOOTH_SDK_PYTHON:/project/sawtooth-sdk-python 47 | expose: 48 | - 4004 49 | command: nose2-3 50 | -c /project/sawtooth-sdk-python/examples/intkey_python/nose2.cfg 51 | -v 52 | -s /project/sawtooth-sdk-python/examples/intkey_python/tests 53 | test_tp_intkey 54 | stop_signal: SIGKILL 55 | environment: 56 | TEST_BIND: "tcp://eth0:4004" 57 | PYTHONPATH: "/project/sawtooth-sdk-python/:\ 58 | /project/sawtooth-sdk-python/examples/intkey_python:\ 59 | /project/sawtooth-sdk-python/tests" 60 | -------------------------------------------------------------------------------- /examples/noop_python/sawtooth_noop/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | __all__ = [ 17 | 'client_cli' 18 | ] 19 | -------------------------------------------------------------------------------- /examples/noop_python/sawtooth_noop/client_cli/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | -------------------------------------------------------------------------------- /examples/noop_python/sawtooth_noop/client_cli/create_batch.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # Copyright 2017 Intel Corporation 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # ------------------------------------------------------------------------------ 17 | 18 | import hashlib 19 | import logging 20 | import binascii 21 | import random 22 | 23 | import sawtooth_sdk.protobuf.batch_pb2 as batch_pb2 24 | import sawtooth_sdk.protobuf.transaction_pb2 as transaction_pb2 25 | 26 | 27 | LOGGER = logging.getLogger(__name__) 28 | 29 | 30 | class NoopPayload: 31 | def __init__(self): 32 | self.nonce = binascii.b2a_hex(random.getrandbits( 33 | 8 * 8).to_bytes(8, byteorder='little')) 34 | self._sha512 = None 35 | 36 | def sha512(self): 37 | if self._sha512 is None: 38 | self._sha512 = hashlib.sha512(self.nonce).hexdigest() 39 | return self._sha512 40 | 41 | 42 | def create_noop_transaction(signer): 43 | payload = NoopPayload() 44 | 45 | header = transaction_pb2.TransactionHeader( 46 | signer_public_key=signer.get_public_key().as_hex(), 47 | family_name='noop', 48 | family_version='1.0', 49 | inputs=[], 50 | outputs=[], 51 | dependencies=[], 52 | payload_sha512=payload.sha512(), 53 | batcher_public_key=signer.get_public_key().as_hex(), 54 | nonce=hex(random.randint(0, 2**64))) 55 | 56 | header_bytes = header.SerializeToString() 57 | 58 | signature = signer.sign(header_bytes) 59 | 60 | transaction = transaction_pb2.Transaction( 61 | header=header_bytes, 62 | payload=payload.nonce, 63 | header_signature=signature) 64 | 65 | return transaction 66 | 67 | 68 | def create_batch(transactions, signer): 69 | transaction_signatures = [t.header_signature for t in transactions] 70 | 71 | header = batch_pb2.BatchHeader( 72 | signer_public_key=signer.get_public_key().as_hex(), 73 | transaction_ids=transaction_signatures) 74 | 75 | header_bytes = header.SerializeToString() 76 | 77 | signature = signer.sign(header_bytes) 78 | 79 | batch = batch_pb2.Batch( 80 | header=header_bytes, 81 | transactions=transactions, 82 | header_signature=signature) 83 | 84 | return batch 85 | -------------------------------------------------------------------------------- /examples/noop_python/sawtooth_noop/client_cli/exceptions.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | 17 | class NoopCliException(Exception): 18 | pass 19 | -------------------------------------------------------------------------------- /examples/xo_python/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Cargill Incorporated 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # docker build -f examples/sdk/xo_python/Dockerfile -t xo-tp-python-local . 16 | 17 | # -------------=== build ===------------- 18 | 19 | FROM ubuntu:bionic 20 | 21 | RUN apt-get update \ 22 | && apt-get install gnupg -y 23 | 24 | RUN echo "deb http://repo.sawtooth.me/ubuntu/nightly bionic universe" >> /etc/apt/sources.list \ 25 | && (apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 44FC67F19B2466EA \ 26 | || apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 44FC67F19B2466EA) \ 27 | && apt-get update 28 | 29 | RUN apt-get install -y -q \ 30 | git \ 31 | python3 \ 32 | python3-stdeb 33 | 34 | RUN apt-get install -y -q \ 35 | python3-grpcio \ 36 | python3-grpcio-tools \ 37 | python3-protobuf 38 | 39 | RUN apt-get install -y -q \ 40 | python3-cbor \ 41 | python3-colorlog \ 42 | python3-secp256k1 \ 43 | python3-toml \ 44 | python3-yaml \ 45 | python3-zmq 46 | 47 | RUN mkdir -p /var/log/sawtooth 48 | 49 | ENV PATH=$PATH:/project/sawtooth-sdk-python/bin 50 | 51 | WORKDIR /project/sawtooth-sdk-python 52 | 53 | CMD echo "\033[0;32m--- Building xo-tp-python ---\n\033[0m" \ 54 | && bin/protogen \ 55 | && cd examples/xo_python \ 56 | && python3 setup.py clean --all \ 57 | && python3 setup.py build 58 | -------------------------------------------------------------------------------- /examples/xo_python/Dockerfile-installed-xenial: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Cargill Incorporated 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # docker build -f examples/xo_python/Dockerfile-installed-xenial -t sawtooth-xo-tp-python . 16 | 17 | # -------------=== python sdk build ===------------- 18 | 19 | FROM ubuntu:xenial as sawtooth-sdk-python-builder 20 | 21 | ENV VERSION=AUTO_STRICT 22 | 23 | RUN echo "deb http://repo.sawtooth.me/ubuntu/ci xenial universe" >> /etc/apt/sources.list \ 24 | && (apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 8AA7AF1F1091A5FD \ 25 | || apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 8AA7AF1F1091A5FD) \ 26 | && apt-get update \ 27 | && apt-get install -y -q --allow-downgrades \ 28 | git \ 29 | python3 \ 30 | python3-colorlog \ 31 | python3-protobuf \ 32 | python3-stdeb \ 33 | python3-grpcio-tools \ 34 | python3-grpcio \ 35 | python3-secp256k1 \ 36 | python3-toml \ 37 | python3-yaml 38 | 39 | COPY . /project 40 | 41 | RUN /project/bin/protogen \ 42 | && cd /project/ \ 43 | && if [ -d "debian" ]; then rm -rf debian; fi \ 44 | && python3 setup.py clean --all \ 45 | && python3 setup.py --command-packages=stdeb.command debianize \ 46 | && if [ -d "packaging/ubuntu" ]; then cp -R packaging/ubuntu/* debian/; fi \ 47 | && dpkg-buildpackage -b -rfakeroot -us -uc 48 | 49 | # -------------=== python xo tp build ===------------- 50 | 51 | FROM ubuntu:xenial as python-xo-tp-builder 52 | 53 | ENV VERSION=AUTO_STRICT 54 | 55 | RUN echo "deb http://repo.sawtooth.me/ubuntu/ci xenial universe" >> /etc/apt/sources.list \ 56 | && (apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 8AA7AF1F1091A5FD \ 57 | || apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 8AA7AF1F1091A5FD) \ 58 | && apt-get update \ 59 | && apt-get install -y -q --allow-downgrades \ 60 | git \ 61 | python3 \ 62 | python3-cbor \ 63 | python3-colorlog \ 64 | python3-grpcio-tools \ 65 | python3-grpcio \ 66 | python3-protobuf \ 67 | python3-stdeb 68 | 69 | COPY --from=sawtooth-sdk-python-builder /python3-sawtooth-sdk*.deb /tmp 70 | 71 | COPY . /project 72 | 73 | RUN dpkg -i /tmp/python3-sawtooth-*.deb || true \ 74 | && apt-get -f -y install \ 75 | && /project/bin/protogen \ 76 | && cd /project/examples/xo_python/ \ 77 | && if [ -d "debian" ]; then rm -rf debian; fi \ 78 | && python3 setup.py clean --all \ 79 | && python3 setup.py --command-packages=stdeb.command debianize \ 80 | && if [ -d "packaging/ubuntu" ]; then cp -R packaging/ubuntu/* debian/; fi \ 81 | && dpkg-buildpackage -b -rfakeroot -us -uc 82 | 83 | # -------------=== python-xo-tp docker build ===------------- 84 | FROM ubuntu:xenial 85 | 86 | COPY --from=sawtooth-sdk-python-builder /python3-sawtooth-sdk*.deb /tmp 87 | 88 | COPY --from=python-xo-tp-builder /project/examples/python3-sawtooth-xo*.deb /tmp 89 | 90 | RUN echo "deb http://repo.sawtooth.me/ubuntu/ci xenial universe" >> /etc/apt/sources.list \ 91 | && (apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 8AA7AF1F1091A5FD \ 92 | || apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 8AA7AF1F1091A5FD) \ 93 | && apt-get update \ 94 | && dpkg -i /tmp/python3-sawtooth-*.deb || true \ 95 | && apt-get -f -y install 96 | -------------------------------------------------------------------------------- /examples/xo_python/nose2.cfg: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | [unittest] 16 | start-dir = tests 17 | code-directories = .. 18 | test-file-pattern = test*.py 19 | plugins = nose2.plugins.coverage 20 | 21 | [coverage] 22 | always-on = True 23 | -------------------------------------------------------------------------------- /examples/xo_python/packaging/systemd/sawtooth-xo-tp-python: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | SAWTOOTH_XO_TP_PYTHON_ARGS=-v -C tcp://localhost:4004 17 | -------------------------------------------------------------------------------- /examples/xo_python/packaging/systemd/sawtooth-xo-tp-python.service: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | [Unit] 17 | Description=Sawtooth XO TP Python 18 | After=network.target 19 | 20 | [Service] 21 | User=sawtooth 22 | Group=sawtooth 23 | EnvironmentFile=-/etc/default/sawtooth-xo-tp-python 24 | ExecStart=/usr/bin/xo-tp-python $SAWTOOTH_XO_TP_PYTHON_ARGS 25 | Restart=on-failure 26 | 27 | [Install] 28 | WantedBy=multi-user.target 29 | -------------------------------------------------------------------------------- /examples/xo_python/packaging/xo.toml.example: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2017 Intel Corporation 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # ------------------------------------------------------------------------------ 16 | 17 | # 18 | # Sawtooth -- XO Transaction Processor Configuration 19 | # 20 | 21 | # The url to connect to a running Validator 22 | # connect = "tcp://localhost:4004" 23 | -------------------------------------------------------------------------------- /examples/xo_python/sawtooth_xo/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ----------------------------------------------------------------------------- 15 | 16 | __all__ = [ 17 | 'xo_cli', 18 | 'xo_client', 19 | 'xo_exceptions' 20 | ] 21 | -------------------------------------------------------------------------------- /examples/xo_python/sawtooth_xo/processor/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | __all__ = [ 17 | 'main' 18 | ] 19 | -------------------------------------------------------------------------------- /examples/xo_python/sawtooth_xo/processor/config/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | -------------------------------------------------------------------------------- /examples/xo_python/sawtooth_xo/processor/xo_payload.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ----------------------------------------------------------------------------- 15 | 16 | from sawtooth_sdk.processor.exceptions import InvalidTransaction 17 | 18 | 19 | class XoPayload: 20 | 21 | def __init__(self, payload): 22 | try: 23 | # The payload is csv utf-8 encoded string 24 | name, action, space = payload.decode().split(",") 25 | except ValueError as e: 26 | raise InvalidTransaction("Invalid payload serialization") from e 27 | 28 | if not name: 29 | raise InvalidTransaction('Name is required') 30 | 31 | if '|' in name: 32 | raise InvalidTransaction('Name cannot contain "|"') 33 | 34 | if not action: 35 | raise InvalidTransaction('Action is required') 36 | 37 | if action not in ('create', 'take', 'delete'): 38 | raise InvalidTransaction('Invalid action: {}'.format(action)) 39 | 40 | if action == 'take': 41 | try: 42 | 43 | if int(space) not in range(1, 10): 44 | raise InvalidTransaction( 45 | "Space must be an integer from 1 to 9") 46 | except ValueError: 47 | raise InvalidTransaction( 48 | 'Space must be an integer from 1 to 9') from ValueError 49 | 50 | if action == 'take': 51 | space = int(space) 52 | 53 | self._name = name 54 | self._action = action 55 | self._space = space 56 | 57 | @staticmethod 58 | def from_bytes(payload): 59 | return XoPayload(payload=payload) 60 | 61 | @property 62 | def name(self): 63 | return self._name 64 | 65 | @property 66 | def action(self): 67 | return self._action 68 | 69 | @property 70 | def space(self): 71 | return self._space 72 | -------------------------------------------------------------------------------- /examples/xo_python/sawtooth_xo/xo_exceptions.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | 17 | class XoException(Exception): 18 | pass 19 | -------------------------------------------------------------------------------- /examples/xo_python/sawtooth_xo/xo_message_factory.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | from sawtooth_processor_test.message_factory import MessageFactory 17 | 18 | 19 | class XoMessageFactory: 20 | def __init__(self, signer=None): 21 | self._factory = MessageFactory( 22 | family_name="xo", 23 | family_version="1.0", 24 | namespace=MessageFactory.sha512("xo".encode("utf-8"))[0:6], 25 | signer=signer) 26 | 27 | def _game_to_address(self, game): 28 | return self._factory.namespace + \ 29 | self._factory.sha512(game.encode())[0:64] 30 | 31 | def create_tp_register(self): 32 | return self._factory.create_tp_register() 33 | 34 | def create_tp_response(self, status): 35 | return self._factory.create_tp_response(status) 36 | 37 | def _create_txn(self, txn_function, game, action, space=None): 38 | payload = ",".join([ 39 | str(game), str(action), str(space) 40 | ]).encode() 41 | 42 | addresses = [self._game_to_address(game)] 43 | 44 | return txn_function(payload, addresses, addresses, []) 45 | 46 | def create_tp_process_request(self, action, game, space=None): 47 | txn_function = self._factory.create_tp_process_request 48 | return self._create_txn(txn_function, game, action, space) 49 | 50 | def create_transaction(self, game, action, space=None): 51 | txn_function = self._factory.create_transaction 52 | return self._create_txn(txn_function, game, action, space) 53 | 54 | def create_get_request(self, game): 55 | addresses = [self._game_to_address(game)] 56 | return self._factory.create_get_request(addresses) 57 | 58 | def create_get_response( 59 | self, game, board="---------", state="P1-NEXT", player1="", player2="" 60 | ): 61 | address = self._game_to_address(game) 62 | 63 | data = None 64 | if board is not None: 65 | data = ",".join([game, board, state, player1, player2]).encode() 66 | else: 67 | data = None 68 | 69 | return self._factory.create_get_response({address: data}) 70 | 71 | def create_set_request( 72 | self, game, board="---------", state="P1-NEXT", player1="", player2="" 73 | ): 74 | address = self._game_to_address(game) 75 | 76 | data = None 77 | if state is not None: 78 | data = ",".join([game, board, state, player1, player2]).encode() 79 | else: 80 | data = None 81 | 82 | return self._factory.create_set_request({address: data}) 83 | 84 | def create_set_response(self, game): 85 | addresses = [self._game_to_address(game)] 86 | return self._factory.create_set_response(addresses) 87 | 88 | def get_public_key(self): 89 | return self._factory.get_public_key() 90 | -------------------------------------------------------------------------------- /examples/xo_python/setup.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | from __future__ import print_function 17 | 18 | import os 19 | import subprocess 20 | 21 | from setuptools import setup, find_packages 22 | 23 | conf_dir = "/etc/sawtooth" 24 | 25 | data_files = [ 26 | (conf_dir, ['packaging/xo.toml.example']) 27 | ] 28 | 29 | if os.path.exists("/etc/default"): 30 | data_files.append( 31 | ('/etc/default', ['packaging/systemd/sawtooth-xo-tp-python'])) 32 | 33 | if os.path.exists("/lib/systemd/system"): 34 | data_files.append(('/lib/systemd/system', 35 | ['packaging/systemd/sawtooth-xo-tp-python.service'])) 36 | 37 | setup( 38 | name='sawtooth-xo', 39 | version=subprocess.check_output( 40 | ['../../bin/get_version']).decode('utf-8').strip(), 41 | description='Sawtooth XO Example', 42 | author='Hyperledger Sawtooth', 43 | url='https://github.com/hyperledger/sawtooth-sdk-python', 44 | packages=find_packages(), 45 | install_requires=[ 46 | 'aiohttp', 47 | 'colorlog', 48 | 'protobuf', 49 | 'sawtooth-sdk', 50 | 'PyYAML', 51 | ], 52 | data_files=data_files, 53 | entry_points={ 54 | 'console_scripts': [ 55 | 'xo = sawtooth_xo.xo_cli:main_wrapper', 56 | 'xo-tp-python = sawtooth_xo.processor.main:main', 57 | ] 58 | }) 59 | -------------------------------------------------------------------------------- /examples/xo_python/setup_tests.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | from __future__ import print_function 17 | 18 | import os 19 | import subprocess 20 | 21 | from setuptools import setup, find_packages 22 | 23 | 24 | data_files = [] 25 | 26 | if os.path.exists("tests"): 27 | data_files.append(('/data/tests/xo', ['tests/test_tp_xo.py'])) 28 | data_files.append(('/data/tests/xo', [ 29 | '../../tests/sawtooth_integration/tests/test_xo_smoke.py'])) 30 | 31 | try: 32 | os.environ["ST_VERSION"] 33 | print('Using ST_VERSION') 34 | VERSION = os.environ["ST_VERSION"] 35 | except KeyError: 36 | print('ST_VERSION not set. Using get_version') 37 | VERSION = subprocess.check_output( 38 | ['../../bin/get_version']).decode('utf-8').strip() 39 | 40 | setup( 41 | name='sawtooth-xo-tests', 42 | version=VERSION, 43 | description='Sawtooth XO Python Test', 44 | author='Hyperledger Sawtooth', 45 | url='https://github.com/hyperledger/sawtooth-sdk-python', 46 | packages=find_packages(), 47 | install_requires=[ 48 | 'aiohttp', 49 | 'colorlog', 50 | 'protobuf', 51 | 'sawtooth-sdk', 52 | 'PyYAML', 53 | ], 54 | data_files=data_files, 55 | entry_points={ 56 | 'console_scripts': [ 57 | 'xo = sawtooth_xo.xo_cli:main_wrapper', 58 | 'xo-tp-python = sawtooth_xo.processor.main:main', 59 | ] 60 | }) 61 | -------------------------------------------------------------------------------- /examples/xo_python/tests/test_tp_xo_python.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | version: "2.1" 17 | 18 | services: 19 | 20 | xo-tp-python: 21 | build: 22 | context: ../../.. 23 | dockerfile: ./examples/xo_python/Dockerfile 24 | args: 25 | - http_proxy 26 | - https_proxy 27 | - no_proxy 28 | image: sawtooth-xo-tp-python$INSTALL_TYPE:$ISOLATION_ID 29 | volumes: 30 | - $SAWTOOTH_SDK_PYTHON:/project/sawtooth-sdk-python 31 | expose: 32 | - 4004 33 | command: xo-tp-python -vv -C tcp://test-tp-xo-python:4004 34 | stop_signal: SIGKILL 35 | 36 | test-tp-xo-python: 37 | build: 38 | context: ../../.. 39 | dockerfile: tests/python-sdk-tests.dockerfile 40 | args: 41 | - http_proxy 42 | - https_proxy 43 | - no_proxy 44 | image: python-sdk-tests:$ISOLATION_ID 45 | volumes: 46 | - $SAWTOOTH_SDK_PYTHON:/project/sawtooth-sdk-python 47 | expose: 48 | - 4004 49 | command: nose2-3 50 | -c /project/sawtooth-sdk-python/examples/xo_python/nose2.cfg 51 | -v 52 | -s /project/sawtooth-sdk-python/examples/xo_python/tests 53 | test_tp_xo 54 | stop_signal: SIGKILL 55 | environment: 56 | TEST_BIND: "tcp://eth0:4004" 57 | PYTHONPATH: "\ 58 | /project/sawtooth-sdk-python/:\ 59 | /project/sawtooth-sdk-python/examples/xo_python" 60 | -------------------------------------------------------------------------------- /images/rookies16-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledger-archives/sawtooth-sdk-python/5e9715f476331b91b4d29f06c189a6981854289f/images/rookies16-small.png -------------------------------------------------------------------------------- /images/rookies16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledger-archives/sawtooth-sdk-python/5e9715f476331b91b4d29f06c189a6981854289f/images/rookies16.png -------------------------------------------------------------------------------- /images/sawtooth_logo_light_blue-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledger-archives/sawtooth-sdk-python/5e9715f476331b91b4d29f06c189a6981854289f/images/sawtooth_logo_light_blue-small.png -------------------------------------------------------------------------------- /images/sawtooth_logo_light_blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledger-archives/sawtooth-sdk-python/5e9715f476331b91b4d29f06c189a6981854289f/images/sawtooth_logo_light_blue.png -------------------------------------------------------------------------------- /nose2.cfg: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | [unittest] 16 | start-dir = tests 17 | code-directories = .. 18 | test-file-pattern = test*.py 19 | plugins = nose2.plugins.coverage 20 | 21 | [coverage] 22 | always-on = True 23 | -------------------------------------------------------------------------------- /packaging/log_config.toml.example: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2017 Intel Corporation 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # ------------------------------------------------------------------------------ 16 | 17 | version = 1 18 | disable_existing_loggers = false 19 | 20 | [formatters.simple] 21 | format = "[%(asctime)s.%(msecs)03d [%(threadName)s] %(module)s %(levelname)s] %(message)s" 22 | datefmt = "%H:%M:%S" 23 | 24 | [handlers.debug] 25 | level = "DEBUG" 26 | formatter = "simple" 27 | class = "logging.FileHandler" 28 | filename = "example-debug.log" 29 | 30 | [handlers.interconnect] 31 | level = "DEBUG" 32 | formatter = "simple" 33 | class = "logging.handlers.RotatingFileHandler" 34 | filename = "example-interconnect.log" 35 | maxBytes = 5000000 36 | backupCount=20 37 | 38 | [handlers.error] 39 | level = "ERROR" 40 | formatter = "simple" 41 | class = "logging.FileHandler" 42 | filename = "example-error.log" 43 | 44 | [loggers."sawtooth_validator.networking.interconnect"] 45 | level = "DEBUG" 46 | propagate = true 47 | handlers = [ "interconnect"] 48 | 49 | [root] 50 | level = "DEBUG" 51 | handlers = [ "error", "debug"] 52 | -------------------------------------------------------------------------------- /packaging/path.toml.example: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2017 Intel Corporation 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # ------------------------------------------------------------------------------ 16 | 17 | # 18 | # Sawtooth -- Path Configuration 19 | # 20 | 21 | 22 | # Important! 23 | # 24 | # Configuration using this file is usually unnecessary. For non-standard 25 | # directory paths, use of the SAWTOOTH_HOME environment variable is preferred 26 | # over use of this configuration file. 27 | # 28 | # This file should be used when installing on an operating system distribution 29 | # and the default paths are not appropriate. For example, some Unix-based 30 | # operating systems do not use /var/lib, and therefore configuring data_dir 31 | # to the natural operating system default path for application data would be 32 | # appropriate. 33 | 34 | 35 | # This file allows for setting the following: 36 | # key_dir - the directory path to use when loading key files 37 | # data_dir - the directory path to store data files such as the block store 38 | # log_dir - the directory path to write log files 39 | # 40 | # In addition, the default path examples below include the following path which 41 | # may not be modified using this file: 42 | # conf_dir - the directory path containing configuration files 43 | 44 | 45 | # When the SAWTOOTH_HOME environment variable is set, the default paths are as 46 | # follows: 47 | # 48 | # conf_dir = SAWTOOTH_HOME/etc/ 49 | # key_dir = SAWTOOTH_HOME/keys/ 50 | # data_dir = SAWTOOTH_HOME/data/ 51 | # log_dir = SAWTOOTH_HOME/logs/ 52 | # 53 | # So, for example if SAWTOOTH_HOME is set to a value of /tmp/testing, then the 54 | # default for data_dir will be /tmp/testing/data/. 55 | # 56 | # When the SAWTOOTH_HOME environment variable is not set, then the operating 57 | # system defaults are used. 58 | 59 | 60 | # On Windows, the path is relative to the CLI command being run. The directory 61 | # one level up from the command is the 'base_dir'; the command generally being 62 | # installed within base_dir/bin/. The rest of the directories are relative to 63 | # base_dir: 64 | # conf_dir = base_dir\conf\ 65 | # key_dir = base_dir\conf\keys\ 66 | # data_dir = base_dir\data\ 67 | # log_dir = base_dir\logs\ 68 | # 69 | # For example, if Sawtooth is installed in C:\sawtooth\, the validator 70 | # executable would be C:\sawtooth\bin\validator.exe and the data directory 71 | # would be C:\sawtooth\data\. 72 | 73 | 74 | # On Linux, the default path settings are: 75 | # 76 | # conf_dir = "/etc/sawtooth" 77 | # key_dir = "/etc/sawtooth/keys" 78 | # data_dir = "/var/lib/sawtooth" 79 | # log_dir = "/var/log/sawtooth" 80 | -------------------------------------------------------------------------------- /packaging/ubuntu/postinst: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2017 Intel Corporation 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # ------------------------------------------------------------------------------ 17 | 18 | set -e 19 | 20 | directories=" 21 | /var/lib/sawtooth 22 | /var/log/sawtooth 23 | /etc/sawtooth 24 | " 25 | 26 | user="sawtooth" 27 | group="sawtooth" 28 | 29 | if ! getent group $group > /dev/null; then 30 | addgroup --quiet --system $group 31 | fi 32 | 33 | if ! getent passwd $user > /dev/null; then 34 | adduser --quiet --system --ingroup $group $user 35 | fi 36 | 37 | for dir in $directories 38 | do 39 | chown -R $user:$group $dir 40 | done 41 | -------------------------------------------------------------------------------- /protos/authorization.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Intel Corporation 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // ----------------------------------------------------------------------------- 15 | 16 | syntax = "proto3"; 17 | option java_multiple_files = true; 18 | option java_package = "sawtooth.sdk.protobuf"; 19 | option go_package = "authorization_pb2"; 20 | 21 | message ConnectionRequest { 22 | // This is the first message that must be sent to start off authorization. 23 | // The endpoint of the connection. 24 | string endpoint = 1; 25 | } 26 | 27 | enum RoleType { 28 | ROLE_TYPE_UNSET = 0; 29 | 30 | // A shorthand request for asking for all allowed roles. 31 | ALL = 1; 32 | 33 | // Role defining validator to validator communication 34 | NETWORK = 2; 35 | } 36 | 37 | message ConnectionResponse { 38 | // Whether the connection can participate in authorization 39 | enum Status { 40 | STATUS_UNSET = 0; 41 | OK = 1; 42 | ERROR = 2; 43 | } 44 | 45 | //Authorization Type required for the authorization procedure 46 | enum AuthorizationType { 47 | AUTHORIZATION_TYPE_UNSET = 0; 48 | TRUST = 1; 49 | CHALLENGE = 2; 50 | } 51 | 52 | message RoleEntry { 53 | // The role type for this role entry 54 | RoleType role = 1; 55 | 56 | // The Authorization Type required for the above role 57 | AuthorizationType auth_type = 2; 58 | } 59 | 60 | repeated RoleEntry roles = 1; 61 | Status status = 2; 62 | } 63 | 64 | message AuthorizationTrustRequest { 65 | // A set of requested RoleTypes 66 | repeated RoleType roles = 1; 67 | string public_key = 2; 68 | } 69 | 70 | message AuthorizationTrustResponse { 71 | // The actual set the requester has access to 72 | repeated RoleType roles = 1; 73 | } 74 | 75 | message AuthorizationViolation { 76 | // The Role the requester did not have access to 77 | RoleType violation = 1; 78 | } 79 | 80 | message AuthorizationChallengeRequest { 81 | // Empty message sent to request a payload to sign 82 | } 83 | 84 | message AuthorizationChallengeResponse { 85 | // Random payload that the connecting node must sign 86 | bytes payload = 1; 87 | } 88 | 89 | message AuthorizationChallengeSubmit { 90 | // public key of node 91 | string public_key = 1; 92 | 93 | // signature derived from signing the challenge payload 94 | string signature = 3; 95 | 96 | // A set of requested Roles 97 | repeated RoleType roles = 4; 98 | } 99 | 100 | message AuthorizationChallengeResult { 101 | // The approved roles for that connection 102 | repeated RoleType roles = 1; 103 | } 104 | -------------------------------------------------------------------------------- /protos/batch.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Intel Corporation 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // ----------------------------------------------------------------------------- 15 | 16 | syntax = "proto3"; 17 | 18 | option java_multiple_files = true; 19 | option java_package = "sawtooth.sdk.protobuf"; 20 | option go_package = "batch_pb2"; 21 | 22 | import "transaction.proto"; 23 | 24 | message BatchHeader { 25 | // Public key for the client that signed the BatchHeader 26 | string signer_public_key = 1; 27 | 28 | // List of transaction.header_signatures that match the order of 29 | // transactions required for the batch 30 | repeated string transaction_ids = 2; 31 | } 32 | 33 | message Batch { 34 | // The serialized version of the BatchHeader 35 | bytes header = 1; 36 | 37 | // The signature derived from signing the header 38 | string header_signature = 2; 39 | 40 | // A list of the transactions that match the list of 41 | // transaction_ids listed in the batch header 42 | repeated Transaction transactions = 3; 43 | 44 | // A debugging flag which indicates this batch should be traced through the 45 | // system, resulting in a higher level of debugging output. 46 | bool trace = 4; 47 | } 48 | 49 | message BatchList { 50 | repeated Batch batches = 1; 51 | } 52 | -------------------------------------------------------------------------------- /protos/block.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Intel Corporation 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // ----------------------------------------------------------------------------- 15 | 16 | syntax = "proto3"; 17 | option java_multiple_files = true; 18 | option java_package = "sawtooth.sdk.protobuf"; 19 | option go_package = "block_pb2"; 20 | 21 | import "batch.proto"; 22 | 23 | message BlockHeader { 24 | // Block number in the chain 25 | uint64 block_num = 1; 26 | 27 | // The header_signature of the previous block that was added to the chain. 28 | string previous_block_id = 2; 29 | 30 | // Public key for the component internal to the validator that 31 | // signed the BlockHeader 32 | string signer_public_key = 3; 33 | 34 | // List of batch.header_signatures that match the order of batches 35 | // required for the block 36 | repeated string batch_ids = 4; 37 | 38 | // Bytes that are set and verified by the consensus algorithm used to 39 | // create and validate the block 40 | bytes consensus = 5; 41 | 42 | // The state_root_hash should match the final state_root after all 43 | // transactions in the batches have been applied, otherwise the block 44 | // is not valid 45 | string state_root_hash = 6; 46 | } 47 | 48 | message Block { 49 | // The serialized version of the BlockHeader 50 | bytes header = 1; 51 | 52 | // The signature derived from signing the header 53 | string header_signature = 2; 54 | 55 | // A list of batches. The batches may contain new batches that other 56 | // validators may not have received yet, or they will be all batches needed 57 | // for block validation when passed to the journal 58 | repeated Batch batches = 3; 59 | } 60 | -------------------------------------------------------------------------------- /protos/block_info.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Intel Corporation 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // ----------------------------------------------------------------------------- 15 | 16 | syntax = "proto3"; 17 | 18 | option java_multiple_files = true; 19 | option java_package = "sawtooth.block_info.protobuf"; 20 | option go_package = "block_info_pb2"; 21 | 22 | message BlockInfoConfig { 23 | uint64 latest_block = 1; 24 | uint64 oldest_block = 2; 25 | uint64 target_count = 3; 26 | uint64 sync_tolerance = 4; 27 | } 28 | 29 | message BlockInfo { 30 | // Block number in the chain 31 | uint64 block_num = 1; 32 | // The header_signature of the previous block that was added to the chain. 33 | string previous_block_id = 2; 34 | // Public key for the component internal to the validator that 35 | // signed the BlockHeader 36 | string signer_public_key = 3; 37 | // The signature derived from signing the header 38 | string header_signature = 4; 39 | // Approximately when this block was committed, as a Unix UTC timestamp 40 | uint64 timestamp = 5; 41 | } 42 | 43 | message BlockInfoTxn { 44 | // The new block to add to state 45 | BlockInfo block = 1; 46 | // If this is set, the new target number of blocks to store in state 47 | uint64 target_count = 2; 48 | // If set, the new network time synchronization tolerance. 49 | uint64 sync_tolerance = 3; 50 | } 51 | -------------------------------------------------------------------------------- /protos/client_batch.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Intel Corporation 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // ----------------------------------------------------------------------------- 15 | 16 | syntax = "proto3"; 17 | 18 | option java_multiple_files = true; 19 | option java_package = "sawtooth.sdk.protobuf"; 20 | option go_package = "client_batch_pb2"; 21 | 22 | import "batch.proto"; 23 | import "client_list_control.proto"; 24 | 25 | 26 | // A request to return a list of batches from the validator. May include the id 27 | // of a particular block to be the `head` of the chain being requested. In that 28 | // case the list will include the batches from that block, and all batches 29 | // previous to that block on the chain. Filter with specific `batch_ids`. 30 | message ClientBatchListRequest { 31 | string head_id = 1; 32 | repeated string batch_ids = 2; 33 | ClientPagingControls paging = 3; 34 | repeated ClientSortControls sorting = 4; 35 | } 36 | 37 | // A response that lists batches from newest to oldest. 38 | // 39 | // Statuses: 40 | // * OK - everything worked as expected 41 | // * INTERNAL_ERROR - general error, such as protobuf failing to deserialize 42 | // * NOT_READY - the validator does not yet have a genesis block 43 | // * NO_ROOT - the head block specified was not found 44 | // * NO_RESOURCE - no batches were found with the parameters specified 45 | // * INVALID_PAGING - the paging controls were malformed or out of range 46 | // * INVALID_SORT - the sorting controls were malformed or invalid 47 | message ClientBatchListResponse { 48 | enum Status { 49 | STATUS_UNSET = 0; 50 | OK = 1; 51 | INTERNAL_ERROR = 2; 52 | NOT_READY = 3; 53 | NO_ROOT = 4; 54 | NO_RESOURCE = 5; 55 | INVALID_PAGING = 6; 56 | INVALID_SORT = 7; 57 | INVALID_ID = 8; 58 | } 59 | Status status = 1; 60 | repeated Batch batches = 2; 61 | string head_id = 3; 62 | ClientPagingResponse paging = 4; 63 | } 64 | 65 | // Fetches a specific batch by its id (header_signature) from the blockchain. 66 | message ClientBatchGetRequest { 67 | string batch_id = 1; 68 | } 69 | 70 | // A response that returns the batch specified by a ClientBatchGetRequest. 71 | // 72 | // Statuses: 73 | // * OK - everything worked as expected, batch has been fetched 74 | // * INTERNAL_ERROR - general error, such as protobuf failing to deserialize 75 | // * NO_RESOURCE - no batch with the specified id exists 76 | message ClientBatchGetResponse { 77 | enum Status { 78 | STATUS_UNSET = 0; 79 | OK = 1; 80 | INTERNAL_ERROR = 2; 81 | NO_RESOURCE = 5; 82 | INVALID_ID = 8; 83 | } 84 | Status status = 1; 85 | Batch batch = 2; 86 | } 87 | -------------------------------------------------------------------------------- /protos/client_event.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Intel Corporation 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // ----------------------------------------------------------------------------- 15 | 16 | syntax = "proto3"; 17 | 18 | option java_multiple_files = true; 19 | option java_package = "sawtooth.sdk.protobuf"; 20 | option go_package = "client_event_pb2"; 21 | 22 | import "events.proto"; 23 | 24 | 25 | message ClientEventsSubscribeRequest { 26 | repeated EventSubscription subscriptions = 1; 27 | // The block id (or ids, if trying to walk back a fork) the subscriber last 28 | // received events on. It can be set to empty if it has not yet received the 29 | // genesis block. 30 | repeated string last_known_block_ids = 2; 31 | } 32 | 33 | message ClientEventsSubscribeResponse { 34 | enum Status { 35 | STATUS_UNSET = 0; 36 | OK = 1; 37 | INVALID_FILTER = 2; 38 | UNKNOWN_BLOCK = 3; 39 | } 40 | Status status = 1; 41 | // Additional information about the response status 42 | string response_message = 2; 43 | } 44 | 45 | message ClientEventsUnsubscribeRequest {} 46 | 47 | message ClientEventsUnsubscribeResponse { 48 | enum Status { 49 | STATUS_UNSET = 0; 50 | OK = 1; 51 | INTERNAL_ERROR = 2; 52 | } 53 | Status status = 1; 54 | } 55 | 56 | message ClientEventsGetRequest { 57 | repeated EventSubscription subscriptions = 1; 58 | repeated string block_ids = 2; 59 | } 60 | 61 | message ClientEventsGetResponse { 62 | enum Status { 63 | STATUS_UNSET = 0; 64 | OK = 1; 65 | INTERNAL_ERROR = 2; 66 | INVALID_FILTER = 3; 67 | UNKNOWN_BLOCK = 4; 68 | } 69 | Status status = 1; 70 | repeated Event events = 2; 71 | 72 | } 73 | -------------------------------------------------------------------------------- /protos/client_list_control.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Intel Corporation 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // ----------------------------------------------------------------------------- 15 | 16 | syntax = "proto3"; 17 | 18 | option java_multiple_files = true; 19 | option java_package = "sawtooth.sdk.protobuf"; 20 | option go_package = "client_list_control_pb2"; 21 | 22 | // Paging controls to be sent with List requests. 23 | // Attributes: 24 | // start: The id of a resource to start the page with 25 | // limit: The number of results per page, defaults to 100 and maxes out at 1000 26 | message ClientPagingControls { 27 | string start = 1; 28 | int32 limit = 2; 29 | } 30 | 31 | // Information about the pagination used, sent back with List responses. 32 | // Attributes: 33 | // next: The id of the first resource in the next page 34 | // start: The id of the first resource in the returned page 35 | // limit: The number of results per page, defaults to 100 and maxes out at 1000 36 | message ClientPagingResponse { 37 | string next = 1; 38 | string start = 2; 39 | int32 limit = 3; 40 | 41 | } 42 | 43 | // Sorting controls to be sent with List requests. More than one can be sent. 44 | // If so, the first is used, and additional controls are tie-breakers. 45 | // Attributes: 46 | // keys: Nested set of keys to sort by (i.e. ['default, block_num']) 47 | // reverse: Whether or not to reverse the sort (i.e. descending order) 48 | message ClientSortControls { 49 | repeated string keys = 1; 50 | bool reverse = 2; 51 | } 52 | -------------------------------------------------------------------------------- /protos/client_peers.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Intel Corporation 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // ----------------------------------------------------------------------------- 15 | 16 | syntax = "proto3"; 17 | 18 | option java_multiple_files = true; 19 | option java_package = "sawtooth.sdk.protobuf"; 20 | option go_package = "client_peer"; 21 | 22 | message ClientPeersGetRequest{ 23 | } 24 | 25 | message ClientPeersGetResponse { 26 | enum Status { 27 | STATUS_UNSET = 0; 28 | OK = 1; 29 | ERROR = 2; 30 | } 31 | Status status = 1; 32 | repeated string peers = 2; 33 | } 34 | -------------------------------------------------------------------------------- /protos/client_receipt.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Intel Corporation 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // ----------------------------------------------------------------------------- 15 | 16 | syntax = "proto3"; 17 | 18 | option java_multiple_files = true; 19 | option java_package = "sawtooth.sdk.protobuf"; 20 | option go_package = "client_receipt_pb2"; 21 | 22 | import "transaction_receipt.proto"; 23 | 24 | // Fetches a specific txn by its id (header_signature) from the blockchain. 25 | message ClientReceiptGetRequest { 26 | repeated string transaction_ids = 1; 27 | } 28 | 29 | // A response that returns the txn receipt specified by a 30 | // ClientTransactionReceiptGetRequest. 31 | // 32 | // Statuses: 33 | // * OK - everything worked as expected, txn receipt has been fetched 34 | // * INTERNAL_ERROR - general error, such as protobuf failing to deserialize 35 | // * NO_RESOURCE - no receipt exists for the transaction id specified 36 | message ClientReceiptGetResponse { 37 | enum Status { 38 | STATUS_UNSET = 0; 39 | OK = 1; 40 | INTERNAL_ERROR = 2; 41 | NO_RESOURCE = 5; 42 | INVALID_ID = 8; 43 | } 44 | Status status = 1; 45 | repeated TransactionReceipt receipts = 2; 46 | } 47 | -------------------------------------------------------------------------------- /protos/client_status.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Intel Corporation 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // ----------------------------------------------------------------------------- 15 | 16 | syntax = "proto3"; 17 | 18 | option java_multiple_files = true; 19 | option java_package = "sawtooth.sdk.protobuf"; 20 | option go_package = "client_status"; 21 | 22 | // A request to get miscellaneous information about the validator 23 | message ClientStatusGetRequest{ 24 | } 25 | 26 | message ClientStatusGetResponse { 27 | // The status of the response message, not the validator's status 28 | enum Status { 29 | STATUS_UNSET = 0; 30 | OK = 1; 31 | ERROR = 2; 32 | } 33 | 34 | // Information about the validator's peers 35 | message Peer { 36 | // The peer's public network endpoint 37 | string endpoint = 1; 38 | } 39 | 40 | Status status = 1; 41 | repeated Peer peers = 2; 42 | // The validator's public network endpoint 43 | string endpoint = 3; 44 | } 45 | -------------------------------------------------------------------------------- /protos/client_transaction.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Intel Corporation 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // ----------------------------------------------------------------------------- 15 | 16 | syntax = "proto3"; 17 | 18 | option java_multiple_files = true; 19 | option java_package = "sawtooth.sdk.protobuf"; 20 | option go_package = "client_transaction_pb2"; 21 | 22 | import "transaction.proto"; 23 | import "client_list_control.proto"; 24 | 25 | 26 | // A request to return a list of txns from the validator. May include the id 27 | // of a particular block to be the `head` of the chain being requested. In that 28 | // case the list will include the txns from that block, and all txns 29 | // previous to that block on the chain. Filter with specific `transaction_ids`. 30 | message ClientTransactionListRequest { 31 | string head_id = 1; 32 | repeated string transaction_ids = 2; 33 | ClientPagingControls paging = 3; 34 | repeated ClientSortControls sorting = 4; 35 | } 36 | 37 | // A response that lists transactions from newest to oldest. 38 | // 39 | // Statuses: 40 | // * OK - everything worked as expected 41 | // * INTERNAL_ERROR - general error, such as protobuf failing to deserialize 42 | // * NOT_READY - the validator does not yet have a genesis block 43 | // * NO_ROOT - the head block specified was not found 44 | // * NO_RESOURCE - no txns were found with the parameters specified 45 | // * INVALID_PAGING - the paging controls were malformed or out of range 46 | // * INVALID_SORT - the sorting controls were malformed or invalid 47 | message ClientTransactionListResponse { 48 | enum Status { 49 | STATUS_UNSET = 0; 50 | OK = 1; 51 | INTERNAL_ERROR = 2; 52 | NOT_READY = 3; 53 | NO_ROOT = 4; 54 | NO_RESOURCE = 5; 55 | INVALID_PAGING = 6; 56 | INVALID_SORT = 7; 57 | INVALID_ID = 8; 58 | } 59 | Status status = 1; 60 | repeated Transaction transactions = 2; 61 | string head_id = 3; 62 | ClientPagingResponse paging = 4; 63 | } 64 | 65 | // Fetches a specific txn by its id (header_signature) from the blockchain. 66 | message ClientTransactionGetRequest { 67 | string transaction_id = 1; 68 | } 69 | 70 | // A response that returns the txn specified by a ClientTransactionGetRequest. 71 | // 72 | // Statuses: 73 | // * OK - everything worked as expected, txn has been fetched 74 | // * INTERNAL_ERROR - general error, such as protobuf failing to deserialize 75 | // * NO_RESOURCE - no txn with the specified id exists 76 | message ClientTransactionGetResponse { 77 | enum Status { 78 | STATUS_UNSET = 0; 79 | OK = 1; 80 | INTERNAL_ERROR = 2; 81 | NO_RESOURCE = 5; 82 | INVALID_ID = 8; 83 | } 84 | Status status = 1; 85 | Transaction transaction = 2; 86 | } 87 | -------------------------------------------------------------------------------- /protos/events.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Intel Corporation 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // ----------------------------------------------------------------------------- 15 | 16 | syntax = "proto3"; 17 | 18 | option java_multiple_files = true; 19 | option java_package = "sawtooth.sdk.protobuf"; 20 | option go_package = "events_pb2"; 21 | 22 | 23 | message Event { 24 | // Used to subscribe to events and servers as a hint for how to deserialize 25 | // event_data and what pairs to expect in attributes. 26 | string event_type = 1; 27 | 28 | // Transparent data defined by the event_type. 29 | message Attribute { 30 | string key = 1; 31 | string value = 2; 32 | } 33 | repeated Attribute attributes = 2; 34 | 35 | // Opaque data defined by the event_type. 36 | bytes data = 3; 37 | } 38 | 39 | message EventList { 40 | repeated Event events = 1; 41 | } 42 | 43 | message EventFilter { 44 | // EventFilter is used when subscribing to events to limit the events 45 | // received within a given event type. See 46 | // validator/server/events/subscription.py for further explanation. 47 | string key = 1; 48 | string match_string = 2; 49 | 50 | enum FilterType { 51 | FILTER_TYPE_UNSET = 0; 52 | SIMPLE_ANY = 1; 53 | SIMPLE_ALL = 2; 54 | REGEX_ANY = 3; 55 | REGEX_ALL = 4; 56 | } 57 | FilterType filter_type = 3; 58 | } 59 | 60 | message EventSubscription { 61 | // EventSubscription is used when subscribing to events to specify the type 62 | // of events being subscribed to, along with any additional filters. See 63 | // validator/server/events/subscription.py for further explanation. 64 | string event_type = 1; 65 | repeated EventFilter filters = 2; 66 | } 67 | -------------------------------------------------------------------------------- /protos/genesis.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Intel Corporation 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // ----------------------------------------------------------------------------- 15 | 16 | syntax = "proto3"; 17 | 18 | option java_multiple_files = true; 19 | option java_package = "sawtooth.sdk.protobuf"; 20 | option go_package = "genesis_pb2"; 21 | 22 | import "batch.proto"; 23 | 24 | message GenesisData { 25 | // The list of batches that will be applied during the genesis process 26 | repeated Batch batches = 1; 27 | } 28 | -------------------------------------------------------------------------------- /protos/identity.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Intel Corporation 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // ----------------------------------------------------------------------------- 15 | 16 | syntax = "proto3"; 17 | 18 | option java_multiple_files = true; 19 | option java_package = "sawtooth.identity.protobuf"; 20 | 21 | message Policy { 22 | 23 | enum EntryType { 24 | ENTRY_TYPE_UNSET = 0; 25 | PERMIT_KEY = 1; 26 | DENY_KEY = 2; 27 | } 28 | 29 | message Entry { 30 | // Whether this is a Permit_KEY or Deny_KEY entry 31 | EntryType type = 1; 32 | 33 | // This should be a public key or * to refer to all participants. 34 | string key = 2; 35 | } 36 | 37 | // name of the policy, this should be unique. 38 | string name = 1; 39 | 40 | // list of Entries 41 | // The entries will be processed in order from first to last. 42 | repeated Entry entries = 2; 43 | } 44 | 45 | // Policy will be stored in a Policy list to account for state collisions 46 | message PolicyList { 47 | repeated Policy policies = 1; 48 | } 49 | 50 | 51 | message Role { 52 | // Role name 53 | string name = 1; 54 | 55 | // Name of corresponding policy 56 | string policy_name = 2; 57 | } 58 | 59 | // Roles will be stored in a RoleList to account for state collisions 60 | message RoleList { 61 | repeated Role roles = 1; 62 | } 63 | -------------------------------------------------------------------------------- /protos/merkle.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Intel Corporation 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // ----------------------------------------------------------------------------- 15 | syntax = "proto3"; 16 | 17 | option java_multiple_files = true; 18 | option java_package = "sawtooth.sdk.protobuf"; 19 | option go_package = "merkle_pb2"; 20 | 21 | // An Entry in the change log for a given state root. 22 | message ChangeLogEntry { 23 | // A state root that succeed this root. 24 | message Successor { 25 | // A root hash of a merkle trie based of off this root. 26 | bytes successor = 1; 27 | 28 | // The keys (i.e. hashes) that were replaced (i.e. deleted) by this 29 | // successor. These may be deleted during pruning. 30 | repeated bytes deletions = 2; 31 | } 32 | 33 | // A root hash of a merkle trie this tree was based off. 34 | bytes parent = 1; 35 | 36 | // The hashes that were added for this root. These may be deleted during 37 | // pruning, if this root is being abandoned. 38 | repeated bytes additions = 2; 39 | 40 | // The list of successors. 41 | repeated Successor successors = 3; 42 | } 43 | -------------------------------------------------------------------------------- /protos/network.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2016, 2017 Intel Corporation 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // ----------------------------------------------------------------------------- 15 | 16 | syntax = "proto3"; 17 | option java_multiple_files = true; 18 | option java_package = "sawtooth.sdk.protobuf"; 19 | option go_package = "network_pb2"; 20 | 21 | // The disconnect message from a client to the server 22 | message DisconnectMessage { 23 | } 24 | 25 | // The registration request from a peer to the validator 26 | message PeerRegisterRequest { 27 | string endpoint = 1; 28 | // The current version of the network protocol that is being used by the 29 | // sender. This version is an increasing value. 30 | uint32 protocol_version = 2; 31 | } 32 | 33 | // The unregistration request from a peer to the validator 34 | message PeerUnregisterRequest { 35 | } 36 | 37 | message GetPeersRequest { 38 | } 39 | 40 | message GetPeersResponse { 41 | repeated string peer_endpoints = 1; 42 | } 43 | 44 | message PingRequest { 45 | } 46 | 47 | message PingResponse{ 48 | } 49 | 50 | message GossipMessage { 51 | enum ContentType{ 52 | CONTENT_TYPE_UNSET = 0; 53 | BLOCK = 1; 54 | BATCH = 2; 55 | CONSENSUS = 3; 56 | } 57 | bytes content = 1; 58 | ContentType content_type = 2; 59 | uint32 time_to_live = 3; 60 | } 61 | 62 | // A response sent from the validator to the peer acknowledging message 63 | // receipt 64 | message NetworkAcknowledgement { 65 | enum Status { 66 | STATUS_UNSET = 0; 67 | OK = 1; 68 | ERROR = 2; 69 | } 70 | 71 | Status status = 1; 72 | } 73 | 74 | message GossipBlockRequest { 75 | // The id of the block that is being requested 76 | string block_id = 1; 77 | 78 | // A random string that provides uniqueness for requests with 79 | // otherwise identical fields. 80 | string nonce = 2; 81 | uint32 time_to_live = 3; 82 | 83 | } 84 | 85 | message GossipBlockResponse { 86 | // The block 87 | bytes content = 1; 88 | } 89 | 90 | message GossipBatchResponse { 91 | //The batch 92 | bytes content = 1; 93 | } 94 | 95 | message GossipBatchByBatchIdRequest { 96 | // The id of the batch that is being requested 97 | string id = 1; 98 | 99 | // A random string that provides uniqueness for requests with 100 | // otherwise identical fields. 101 | string nonce = 2; 102 | uint32 time_to_live = 3; 103 | 104 | } 105 | 106 | message GossipBatchByTransactionIdRequest { 107 | // The id's of the transaction that are in the batches requested 108 | repeated string ids = 1; 109 | 110 | // A random string that provides uniqueness for requests with 111 | // otherwise identical fields. 112 | string nonce = 2; 113 | uint32 time_to_live = 3; 114 | 115 | } 116 | -------------------------------------------------------------------------------- /protos/setting.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Intel Corporation 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // ----------------------------------------------------------------------------- 15 | 16 | syntax = "proto3"; 17 | option java_multiple_files = true; 18 | option java_package = "sawtooth.sdk.protobuf"; 19 | option go_package = "setting_pb2"; 20 | 21 | 22 | // Setting Container for on-chain configuration key/value pairs 23 | message Setting { 24 | // Contains a setting entry (or entries, in the case of collisions). 25 | message Entry { 26 | string key = 1; 27 | string value = 2; 28 | } 29 | 30 | // List of setting entries - more than one implies a state key collision 31 | repeated Entry entries = 1; 32 | } 33 | -------------------------------------------------------------------------------- /protos/state_context.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Intel Corporation 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // ----------------------------------------------------------------------------- 15 | 16 | syntax = "proto3"; 17 | option java_multiple_files = true; 18 | option java_package = "sawtooth.sdk.protobuf"; 19 | option go_package = "state_context_pb2"; 20 | 21 | import "events.proto"; 22 | 23 | // An entry in the State 24 | message TpStateEntry { 25 | string address = 1; 26 | bytes data = 2; 27 | } 28 | 29 | // A request from a handler/tp for the values at a series of addresses 30 | message TpStateGetRequest { 31 | // The context id that references a context in the contextmanager 32 | string context_id = 1; 33 | repeated string addresses = 2; 34 | } 35 | 36 | // A response from the contextmanager/validator with a series of State entries 37 | message TpStateGetResponse { 38 | enum Status { 39 | STATUS_UNSET = 0; 40 | OK = 1; 41 | AUTHORIZATION_ERROR = 2; 42 | } 43 | 44 | repeated TpStateEntry entries = 1; 45 | Status status = 2; 46 | } 47 | 48 | // A request from the handler/tp to put entries in the state of a context 49 | message TpStateSetRequest { 50 | string context_id = 1; 51 | repeated TpStateEntry entries = 2; 52 | } 53 | 54 | // A response from the contextmanager/validator with the addresses that were set 55 | message TpStateSetResponse { 56 | enum Status { 57 | STATUS_UNSET = 0; 58 | OK = 1; 59 | AUTHORIZATION_ERROR = 2; 60 | } 61 | 62 | repeated string addresses = 1; 63 | Status status = 2; 64 | } 65 | 66 | // A request from the handler/tp to delete state entries at an collection of addresses 67 | message TpStateDeleteRequest { 68 | string context_id = 1; 69 | repeated string addresses = 2; 70 | } 71 | 72 | // A response form the contextmanager/validator with the addresses that were deleted 73 | message TpStateDeleteResponse { 74 | enum Status { 75 | STATUS_UNSET = 0; 76 | OK = 1; 77 | AUTHORIZATION_ERROR = 2; 78 | } 79 | 80 | repeated string addresses = 1; 81 | Status status = 2; 82 | } 83 | 84 | // The request from the transaction processor to the validator append data 85 | // to a transaction receipt 86 | message TpReceiptAddDataRequest { 87 | // The context id that references a context in the context manager 88 | string context_id = 1; 89 | bytes data = 3; 90 | } 91 | 92 | // The response from the validator to the transaction processor to verify that 93 | // data has been appended to a transaction receipt 94 | message TpReceiptAddDataResponse { 95 | enum Status { 96 | STATUS_UNSET = 0; 97 | OK = 1; 98 | ERROR = 2; 99 | } 100 | 101 | Status status = 2; 102 | } 103 | 104 | message TpEventAddRequest { 105 | string context_id = 1; 106 | Event event = 2; 107 | } 108 | 109 | message TpEventAddResponse { 110 | enum Status { 111 | STATUS_UNSET = 0; 112 | OK = 1; 113 | ERROR = 2; 114 | } 115 | Status status = 2; 116 | } 117 | -------------------------------------------------------------------------------- /protos/transaction.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Intel Corporation 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // ----------------------------------------------------------------------------- 15 | 16 | syntax = "proto3"; 17 | 18 | option java_multiple_files = true; 19 | option java_package = "sawtooth.sdk.protobuf"; 20 | option go_package = "transaction_pb2"; 21 | 22 | message TransactionHeader { 23 | // Public key for the client who added this transaction to a batch 24 | string batcher_public_key = 1; 25 | 26 | // A list of transaction signatures that describe the transactions that 27 | // must be processed before this transaction can be valid 28 | repeated string dependencies = 2; 29 | 30 | // The family name correlates to the transaction processor's family name 31 | // that this transaction can be processed on, for example 'intkey' 32 | string family_name = 3; 33 | 34 | // The family version correlates to the transaction processor's family 35 | // version that this transaction can be processed on, for example "1.0" 36 | string family_version = 4; 37 | 38 | // A list of addresses that are given to the context manager and control 39 | // what addresses the transaction processor is allowed to read from. 40 | repeated string inputs = 5; 41 | 42 | // A random string that provides uniqueness for transactions with 43 | // otherwise identical fields. 44 | string nonce = 6; 45 | 46 | // A list of addresses that are given to the context manager and control 47 | // what addresses the transaction processor is allowed to write to. 48 | repeated string outputs = 7; 49 | 50 | //The sha512 hash of the encoded payload 51 | string payload_sha512 = 9; 52 | 53 | // Public key for the client that signed the TransactionHeader 54 | string signer_public_key = 10; 55 | } 56 | 57 | message Transaction { 58 | // The serialized version of the TransactionHeader 59 | bytes header = 1; 60 | 61 | // The signature derived from signing the header 62 | string header_signature = 2; 63 | 64 | // The payload is the encoded family specific information of the 65 | // transaction. Example cbor({'Verb': verb, 'Name': name,'Value': value}) 66 | bytes payload = 3; 67 | } 68 | 69 | // A simple list of transactions that needs to be serialized before 70 | // it can be transmitted to a batcher. 71 | message TransactionList { 72 | repeated Transaction transactions = 1; 73 | } 74 | -------------------------------------------------------------------------------- /protos/transaction_receipt.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Intel Corporation 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // ----------------------------------------------------------------------------- 15 | 16 | syntax = "proto3"; 17 | 18 | option java_multiple_files = true; 19 | option java_package = "sawtooth.sdk.protobuf"; 20 | option go_package = "txn_receipt_pb2"; 21 | 22 | import "events.proto"; 23 | 24 | 25 | message TransactionReceipt { 26 | // State changes made by this transaction 27 | // StateChange is defined in protos/transaction_receipt.proto 28 | repeated StateChange state_changes = 1; 29 | // Events fired by this transaction 30 | repeated Event events = 2; 31 | // Transaction family defined data 32 | repeated bytes data = 3; 33 | 34 | string transaction_id = 4; 35 | } 36 | 37 | // StateChange objects have the type of SET, which is either an insert or 38 | // update, or DELETE. Items marked as a DELETE will have no byte value. 39 | message StateChange { 40 | enum Type { 41 | TYPE_UNSET = 0; 42 | SET = 1; 43 | DELETE = 2; 44 | } 45 | string address = 1; 46 | bytes value = 2; 47 | Type type = 3; 48 | } 49 | 50 | // A collection of state changes. 51 | message StateChangeList { 52 | repeated StateChange state_changes = 1; 53 | } 54 | -------------------------------------------------------------------------------- /sawtooth_processor_test/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | -------------------------------------------------------------------------------- /sawtooth_processor_test/message_types.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016, 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | from sawtooth_sdk.protobuf.processor_pb2 import TpRegisterRequest 17 | from sawtooth_sdk.protobuf.processor_pb2 import TpRegisterResponse 18 | from sawtooth_sdk.protobuf.processor_pb2 import TpProcessResponse 19 | from sawtooth_sdk.protobuf.processor_pb2 import TpProcessRequest 20 | 21 | from sawtooth_sdk.protobuf.state_context_pb2 import TpStateGetResponse 22 | from sawtooth_sdk.protobuf.state_context_pb2 import TpStateGetRequest 23 | from sawtooth_sdk.protobuf.state_context_pb2 import TpStateSetResponse 24 | from sawtooth_sdk.protobuf.state_context_pb2 import TpStateSetRequest 25 | from sawtooth_sdk.protobuf.state_context_pb2 import TpStateDeleteRequest 26 | from sawtooth_sdk.protobuf.state_context_pb2 import TpStateDeleteResponse 27 | from sawtooth_sdk.protobuf.state_context_pb2 import TpEventAddRequest 28 | from sawtooth_sdk.protobuf.state_context_pb2 import TpEventAddResponse 29 | from sawtooth_sdk.protobuf.validator_pb2 import Message 30 | 31 | 32 | _TYPE_TO_PROTO = { 33 | Message.TP_REGISTER_REQUEST: TpRegisterRequest, 34 | Message.TP_REGISTER_RESPONSE: TpRegisterResponse, 35 | Message.TP_PROCESS_RESPONSE: TpProcessResponse, 36 | Message.TP_PROCESS_REQUEST: TpProcessRequest, 37 | 38 | Message.TP_STATE_GET_REQUEST: TpStateGetRequest, 39 | Message.TP_STATE_GET_RESPONSE: TpStateGetResponse, 40 | Message.TP_STATE_SET_REQUEST: TpStateSetRequest, 41 | Message.TP_STATE_SET_RESPONSE: TpStateSetResponse, 42 | Message.TP_STATE_DELETE_REQUEST: TpStateDeleteRequest, 43 | Message.TP_STATE_DELETE_RESPONSE: TpStateDeleteResponse, 44 | Message.TP_EVENT_ADD_REQUEST: TpEventAddRequest, 45 | Message.TP_EVENT_ADD_RESPONSE: TpEventAddResponse, 46 | } 47 | 48 | _PROTO_TO_TYPE = { 49 | proto: type_ for type_, proto in _TYPE_TO_PROTO.items() 50 | } 51 | 52 | 53 | class UnknownMessageTypeException(Exception): 54 | pass 55 | 56 | 57 | def to_protobuf_class(message_type): 58 | if message_type in _TYPE_TO_PROTO: 59 | return _TYPE_TO_PROTO[message_type] 60 | 61 | raise UnknownMessageTypeException( 62 | "Unknown message type: {}".format(message_type)) 63 | 64 | 65 | def to_message_type(proto): 66 | proto_class = proto.__class__ 67 | 68 | if proto_class in _PROTO_TO_TYPE: 69 | return _PROTO_TO_TYPE[proto_class] 70 | 71 | raise UnknownMessageTypeException( 72 | "Unknown protobuf class: {}".format(proto_class)) 73 | -------------------------------------------------------------------------------- /sawtooth_processor_test/transaction_processor_test_case.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | import os 17 | import unittest 18 | 19 | from sawtooth_processor_test.mock_validator import MockValidator 20 | 21 | 22 | class TransactionProcessorTestCase(unittest.TestCase): 23 | @classmethod 24 | def setUpClass(cls): 25 | url = os.getenv('TEST_BIND', 'tcp://127.0.0.1:4004') 26 | 27 | cls.validator = MockValidator() 28 | 29 | cls.validator.listen(url) 30 | 31 | if not cls.validator.register_processor(): 32 | raise Exception('Failed to register processor') 33 | 34 | cls.factory = None 35 | 36 | @classmethod 37 | def tearDownClass(cls): 38 | try: 39 | cls.validator.close() 40 | except AttributeError: 41 | pass 42 | -------------------------------------------------------------------------------- /sawtooth_sdk/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | 17 | __all__ = [ 18 | 'messaging', 19 | 'processor' 20 | ] 21 | -------------------------------------------------------------------------------- /sawtooth_sdk/consensus/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ----------------------------------------------------------------------------- 15 | -------------------------------------------------------------------------------- /sawtooth_sdk/consensus/driver.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ----------------------------------------------------------------------------- 15 | 16 | import abc 17 | 18 | 19 | class Driver(metaclass=abc.ABCMeta): 20 | @abc.abstractmethod 21 | def __init__(self, engine): 22 | pass 23 | 24 | @abc.abstractmethod 25 | def start(self, endpoint): 26 | pass 27 | 28 | @abc.abstractmethod 29 | def stop(self): 30 | pass 31 | -------------------------------------------------------------------------------- /sawtooth_sdk/consensus/engine.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ----------------------------------------------------------------------------- 15 | 16 | import abc 17 | from collections import namedtuple 18 | 19 | 20 | StartupState = namedtuple( 21 | 'StartupInfo', 22 | ['chain_head', 'peers', 'local_peer_info']) 23 | 24 | 25 | PeerMessage = namedtuple( 26 | 'PeerMessage', 27 | ['header', 'header_bytes', 'header_signature', 'content']) 28 | 29 | 30 | class Engine(metaclass=abc.ABCMeta): 31 | @abc.abstractmethod 32 | def start(self, updates, service, startup_state): 33 | '''Called after the engine is initialized, when a connection to the 34 | validator has been established. Notifications from the 35 | validator are sent along UPDATES. SERVICE is used to send 36 | requests to the validator. 37 | 38 | Args: 39 | updates (Queue) 40 | service (Service) 41 | startup (StartupInfo) 42 | ''' 43 | 44 | @abc.abstractmethod 45 | def stop(self): 46 | '''Called before the engine is dropped in order to give the engine a 47 | chance to notify peers and clean up.''' 48 | 49 | @abc.abstractproperty 50 | def version(self): 51 | '''Get the version of this engine. 52 | 53 | Return: 54 | str 55 | ''' 56 | 57 | @abc.abstractproperty 58 | def name(self): 59 | '''Get the name of the engine, typically the algorithm being 60 | implemented. 61 | 62 | Return: 63 | str 64 | ''' 65 | 66 | def additional_protocols(self): 67 | '''Any additional protocol name/version pairs this engine supports. 68 | 69 | Return: 70 | List of (string, string) tuples 71 | ''' 72 | return [] 73 | -------------------------------------------------------------------------------- /sawtooth_sdk/consensus/exceptions.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ----------------------------------------------------------------------------- 15 | 16 | 17 | class InvalidState(Exception): 18 | pass 19 | 20 | 21 | class NoChainHead(Exception): 22 | pass 23 | 24 | 25 | class ReceiveError(Exception): 26 | pass 27 | 28 | 29 | class UnknownBlock(Exception): 30 | pass 31 | 32 | 33 | class UnknownPeer(Exception): 34 | pass 35 | 36 | 37 | class BlockNotReady(Exception): 38 | pass 39 | -------------------------------------------------------------------------------- /sawtooth_sdk/messaging/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | 17 | __all__ = [ 18 | 'exceptions', 19 | 'future', 20 | 'stream' 21 | ] 22 | -------------------------------------------------------------------------------- /sawtooth_sdk/messaging/exceptions.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | 17 | # ValidatorConnectionError is used internal to the sdk, and 18 | # any other use can cause undesirable or unexpected behavior. 19 | class ValidatorConnectionError(Exception): 20 | def __init__(self): 21 | super().__init__("the connection to the validator was lost") 22 | 23 | 24 | class WorkloadConfigurationError(Exception): 25 | def __init__(self): 26 | super().__init__("A workload object is not set.") 27 | 28 | 29 | # ValidatorVersionError is used internal to the sdk, and 30 | # any other use can cause undesirable or unexpected behavior. 31 | class ValidatorVersionError(Exception): 32 | def __init__(self): 33 | super().__init__("the SDK version doesn't match with that of " 34 | "validator") 35 | -------------------------------------------------------------------------------- /sawtooth_sdk/processor/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | '''The processor module defines: 17 | 18 | 1. A TransactionHandler interface to be 19 | used to create new transaction families. 20 | 21 | 2. A high-level, general purpose TransactionProcessor to which any 22 | number of handlers can be added. 23 | 24 | 3. A Context class used to abstract getting and setting addresses in 25 | global validator state. 26 | ''' 27 | 28 | __all__ = [ 29 | 'core', 30 | 'context', 31 | 'exceptions' 32 | ] 33 | -------------------------------------------------------------------------------- /sawtooth_sdk/processor/exceptions.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | 17 | class _TpResponseError(Exception): 18 | """Parent class for errors that will be parsed and sent to a validator. 19 | 20 | Args: 21 | message (str): Standard error message to be logged or sent back 22 | extended_data (bytes, optional): Byte-encoded data to be parsed later 23 | by the app developer. Opaque to the validator and Sawtooth. 24 | """ 25 | 26 | def __init__(self, message, extended_data=None): 27 | super().__init__(message) 28 | 29 | if extended_data is not None and not isinstance(extended_data, bytes): 30 | raise TypeError("extended_data must be byte-encoded") 31 | self.extended_data = extended_data 32 | 33 | 34 | class InvalidTransaction(_TpResponseError): 35 | """Raised for an Invalid Transaction.""" 36 | 37 | 38 | class InternalError(_TpResponseError): 39 | """Raised when an internal error occurs during transaction processing.""" 40 | 41 | 42 | class AuthorizationException(Exception): 43 | """Raised when a authorization error occurs.""" 44 | 45 | 46 | class LocalConfigurationError(Exception): 47 | """Raised when a log configuraiton error occurs.""" 48 | -------------------------------------------------------------------------------- /sawtooth_sdk/processor/handler.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | import abc 17 | 18 | 19 | class TransactionHandler(metaclass=abc.ABCMeta): 20 | """ 21 | TransactionHandler is the Abstract Base Class that defines the business 22 | logic for a new transaction family. 23 | 24 | The family_name, family_versions, and namespaces properties are 25 | used by the processor to route processing requests to the handler. 26 | """ 27 | 28 | @abc.abstractproperty 29 | def family_name(self): 30 | """ 31 | family_name should return the name of the transaction family that this 32 | handler can process, e.g. "intkey" 33 | """ 34 | 35 | @abc.abstractproperty 36 | def family_versions(self): 37 | """ 38 | family_versions should return a list of versions this transaction 39 | family handler can process, e.g. ["1.0"] 40 | """ 41 | 42 | @abc.abstractproperty 43 | def namespaces(self): 44 | """ 45 | namespaces should return a list containing all the handler's 46 | namespaces, e.g. ["abcdef"] 47 | """ 48 | 49 | @abc.abstractmethod 50 | def apply(self, transaction, context): 51 | """ 52 | Apply is the single method where all the business logic for a 53 | transaction family is defined. The method will be called by the 54 | transaction processor upon receiving a TpProcessRequest that the 55 | handler understands and will pass in the TpProcessRequest and an 56 | initialized instance of the Context type. 57 | """ 58 | -------------------------------------------------------------------------------- /sawtooth_sdk/processor/log.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | import logging 17 | import logging.config 18 | import os 19 | 20 | from colorlog import ColoredFormatter 21 | 22 | 23 | def create_console_handler(verbose_level): 24 | """ 25 | Set up the console logging for a transaction processor. 26 | Args: 27 | verbose_level (int): The log level that the console should print out 28 | """ 29 | clog = logging.StreamHandler() 30 | formatter = ColoredFormatter( 31 | "%(log_color)s[%(asctime)s.%(msecs)03d " 32 | "%(levelname)-8s %(module)s]%(reset)s " 33 | "%(white)s%(message)s", 34 | datefmt="%Y-%m-%d %H:%M:%S", 35 | reset=True, 36 | log_colors={ 37 | 'DEBUG': 'cyan', 38 | 'INFO': 'green', 39 | 'WARNING': 'yellow', 40 | 'ERROR': 'red', 41 | 'CRITICAL': 'red', 42 | }) 43 | 44 | clog.setFormatter(formatter) 45 | 46 | if verbose_level == 0: 47 | clog.setLevel(logging.WARN) 48 | elif verbose_level == 1: 49 | clog.setLevel(logging.INFO) 50 | else: 51 | clog.setLevel(logging.DEBUG) 52 | 53 | return clog 54 | 55 | 56 | def init_console_logging(verbose_level=2): 57 | """ 58 | Set up the console logging for a transaction processor. 59 | Args: 60 | verbose_level (int): The log level that the console should print out 61 | """ 62 | logger = logging.getLogger() 63 | logger.setLevel(logging.DEBUG) 64 | logger.addHandler(create_console_handler(verbose_level)) 65 | 66 | 67 | def log_configuration(log_config=None, log_dir=None, name=None): 68 | """ 69 | Sets up the loggers for a transaction processor. 70 | Args: 71 | log_config (dict): A dictinary of log config options 72 | log_dir (string): The log directory's path 73 | name (string): The name of the expected logging file 74 | """ 75 | if log_config is not None: 76 | logging.config.dictConfig(log_config) 77 | else: 78 | log_filename = os.path.join(log_dir, name) 79 | debug_handler = logging.FileHandler(log_filename + "-debug.log") 80 | debug_handler.setFormatter(logging.Formatter( 81 | '[%(asctime)s.%(msecs)03d [%(threadName)s] %(module)s' 82 | ' %(levelname)s] %(message)s', "%H:%M:%S")) 83 | debug_handler.setLevel(logging.DEBUG) 84 | 85 | error_handler = logging.FileHandler(log_filename + "-error.log") 86 | error_handler.setFormatter(logging.Formatter( 87 | '[%(asctime)s.%(msecs)03d [%(threadName)s] %(module)s' 88 | ' %(levelname)s] %(message)s', "%H:%M:%S")) 89 | error_handler.setLevel(logging.ERROR) 90 | 91 | logging.getLogger().addHandler(error_handler) 92 | logging.getLogger().addHandler(debug_handler) 93 | -------------------------------------------------------------------------------- /sawtooth_signing/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016, 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | from sawtooth_signing.core import NoSuchAlgorithmError 16 | from sawtooth_signing.core import ParseError 17 | from sawtooth_signing.core import SigningError 18 | 19 | from sawtooth_signing.secp256k1 import Secp256k1Context 20 | 21 | 22 | class Signer: 23 | """A convenient wrapper of Context and PrivateKey 24 | """ 25 | 26 | def __init__(self, context, private_key): 27 | """ 28 | """ 29 | self._context = context 30 | self._private_key = private_key 31 | self._public_key = None 32 | 33 | def sign(self, message): 34 | """Signs the given message 35 | 36 | Args: 37 | message (bytes): the message bytes 38 | 39 | Returns: 40 | The signature in a hex-encoded string 41 | 42 | Raises: 43 | SigningError: if any error occurs during the signing process 44 | """ 45 | return self._context.sign(message, self._private_key) 46 | 47 | def get_public_key(self): 48 | """Return the public key for this Signer instance. 49 | """ 50 | # Lazy-eval the public key 51 | if self._public_key is None: 52 | self._public_key = self._context.get_public_key(self._private_key) 53 | return self._public_key 54 | 55 | 56 | class CryptoFactory: 57 | """Factory for generating Signers. 58 | """ 59 | 60 | def __init__(self, context): 61 | self._context = context 62 | 63 | @property 64 | def context(self): 65 | """Return the context that backs this factory instance 66 | """ 67 | return self._context 68 | 69 | def new_signer(self, private_key): 70 | """Create a new signer for the given private key. 71 | 72 | Args: 73 | private_key (:obj:`PrivateKey`): a private key 74 | 75 | Returns: 76 | (:obj:`Signer`): a signer instance 77 | """ 78 | return Signer(self._context, private_key) 79 | 80 | 81 | def create_context(algorithm_name): 82 | """Returns an algorithm instance by name. 83 | 84 | Args: 85 | algorithm_name (str): the algorithm name 86 | 87 | Returns: 88 | (:obj:`Context`): a context instance for the given algorithm 89 | 90 | Raises: 91 | NoSuchAlgorithmError if the algorithm is unknown 92 | """ 93 | if algorithm_name == 'secp256k1': 94 | return Secp256k1Context() 95 | 96 | raise NoSuchAlgorithmError("no such algorithm: {}".format(algorithm_name)) 97 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | from __future__ import print_function 17 | 18 | import os 19 | import subprocess 20 | 21 | from setuptools import setup, find_packages 22 | 23 | 24 | conf_dir = "/etc/sawtooth" 25 | data_dir = "/var/lib/sawtooth" 26 | log_dir = "/var/log/sawtooth" 27 | 28 | data_files = [ 29 | (conf_dir, []), 30 | (os.path.join(conf_dir, "keys"), []), 31 | (data_dir, []), 32 | (log_dir, []), 33 | ] 34 | 35 | setup( 36 | name='sawtooth-sdk', 37 | version=subprocess.check_output( 38 | ['./bin/get_version']).decode('utf-8').strip(), 39 | description='Sawtooth Python SDK', 40 | author='Hyperledger Sawtooth', 41 | url='https://github.com/hyperledger/sawtooth-sdk-python', 42 | packages=find_packages(), 43 | data_files=data_files, 44 | install_requires=[ 45 | "colorlog", 46 | "protobuf", 47 | "pyzmq", 48 | "secp256k1", 49 | "toml", 50 | "PyYAML", 51 | ]) 52 | -------------------------------------------------------------------------------- /tests/python-sdk-tests.dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Cargill Incorporated 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | FROM ubuntu:bionic 17 | 18 | RUN apt-get update \ 19 | && apt-get install gnupg -y 20 | 21 | RUN echo "deb http://repo.sawtooth.me/ubuntu/nightly bionic universe" >> /etc/apt/sources.list \ 22 | && (apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 44FC67F19B2466EA \ 23 | || apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 44FC67F19B2466EA) \ 24 | && apt-get update 25 | 26 | RUN apt-get install -y -q \ 27 | git \ 28 | python3 \ 29 | python3-stdeb 30 | 31 | RUN apt-get install -y -q \ 32 | python3-grpcio \ 33 | python3-grpcio-tools \ 34 | python3-protobuf 35 | 36 | RUN apt-get install -y -q \ 37 | python3-cbor \ 38 | python3-colorlog \ 39 | python3-secp256k1 \ 40 | python3-toml \ 41 | python3-yaml \ 42 | python3-zmq 43 | 44 | RUN apt-get install -y -q \ 45 | python3-cov-core \ 46 | python3-nose2 \ 47 | python3-pip 48 | 49 | RUN pip3 install \ 50 | coverage --upgrade 51 | 52 | RUN mkdir -p /var/log/sawtooth 53 | 54 | ENV PATH=$PATH:/project/sawtooth-sdk-python/bin 55 | 56 | WORKDIR /project/sawtooth-sdk-python 57 | -------------------------------------------------------------------------------- /tests/sawtooth_integration/docker/integration-tests.dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Cargill Incorporated 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | FROM ubuntu:bionic 16 | 17 | RUN apt-get update \ 18 | && apt-get install gnupg -y 19 | 20 | RUN echo "deb [arch=amd64] http://repo.sawtooth.me/ubuntu/nightly bionic universe" >> /etc/apt/sources.list \ 21 | && (apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 44FC67F19B2466EA \ 22 | || apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 44FC67F19B2466EA) \ 23 | && apt-get update 24 | 25 | RUN apt-get install -y -q \ 26 | apt-transport-https \ 27 | curl \ 28 | python3-aiohttp \ 29 | python3-cbor \ 30 | python3-colorlog \ 31 | python3-cov-core \ 32 | python3-cryptography-vectors \ 33 | python3-cryptography \ 34 | python3-dev \ 35 | python3-lmdb \ 36 | python3-nose2 \ 37 | python3-pip \ 38 | python3-protobuf \ 39 | python3-pyformance \ 40 | python3-requests \ 41 | python3-sawtooth-cli \ 42 | python3-secp256k1 \ 43 | python3-toml \ 44 | python3-yaml \ 45 | python3-zmq \ 46 | software-properties-common 47 | 48 | RUN pip3 install \ 49 | coverage --upgrade 50 | 51 | RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - \ 52 | && add-apt-repository \ 53 | "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ 54 | $(lsb_release -cs) \ 55 | stable" 56 | 57 | RUN apt-get update && apt-get install -y -q \ 58 | docker-ce 59 | 60 | ENV PATH=$PATH:/project/sawtooth-sdk-python/bin 61 | 62 | WORKDIR /project/sawtooth-sdk-python 63 | -------------------------------------------------------------------------------- /tests/sawtooth_integration/docker/test_intkey_cli.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | version: "2.1" 17 | 18 | services: 19 | 20 | settings-tp: 21 | image: hyperledger/sawtooth-settings-tp:nightly 22 | expose: 23 | - 4004 24 | depends_on: 25 | - validator 26 | command: settings-tp -vv -C tcp://validator:4004 27 | stop_signal: SIGKILL 28 | 29 | intkey-tp-python: 30 | build: 31 | context: ../../.. 32 | dockerfile: ./sdk/examples/intkey_python/Dockerfile 33 | args: 34 | - http_proxy 35 | - https_proxy 36 | - no_proxy 37 | image: sawtooth-intkey-tp-python$INSTALL_TYPE:$ISOLATION_ID 38 | volumes: 39 | - $SAWTOOTH_SDK_PYTHON:/project/sawtooth-sdk-python 40 | expose: 41 | - 4004 42 | depends_on: 43 | - validator 44 | command: intkey-tp-python -vv -C tcp://validator:4004 45 | stop_signal: SIGKILL 46 | 47 | validator: 48 | image: hyperledger/sawtooth-validator:nightly 49 | expose: 50 | - 4004 51 | - 8800 52 | command: "bash -c \"\ 53 | sawadm keygen && \ 54 | sawset genesis \ 55 | -k /etc/sawtooth/keys/validator.priv \ 56 | -o config-genesis.batch && \ 57 | sawset proposal create \ 58 | -k /etc/sawtooth/keys/validator.priv \ 59 | sawtooth.consensus.algorithm.name=Devmode \ 60 | sawtooth.consensus.algorithm.version=0.1 \ 61 | -o config.batch && \ 62 | sawadm genesis \ 63 | config-genesis.batch config.batch && \ 64 | sawtooth-validator -v \ 65 | --endpoint tcp://validator:8800 \ 66 | --bind component:tcp://eth0:4004 \ 67 | --bind network:tcp://eth0:8800 \ 68 | --bind consensus:tcp://eth0:5005 \ 69 | \"" 70 | stop_signal: SIGKILL 71 | 72 | devmode: 73 | image: hyperledger/sawtooth-devmode-engine-rust:nightly 74 | command: devmode-engine-rust --connect tcp://validator:5005 -v 75 | stop_signal: SIGKILL 76 | 77 | rest-api: 78 | image: hyperledger/sawtooth-rest-api:nightly 79 | expose: 80 | - 4004 81 | - 8008 82 | depends_on: 83 | - validator 84 | command: sawtooth-rest-api -v --connect tcp://validator:4004 --bind rest-api:8008 85 | stop_signal: SIGKILL 86 | 87 | test-intkey-cli: 88 | build: 89 | context: ../../.. 90 | dockerfile: tests/sawtooth_integration/docker/integration-tests.dockerfile 91 | args: 92 | - http_proxy 93 | - https_proxy 94 | - no_proxy 95 | image: integration-tests:$ISOLATION_ID 96 | volumes: 97 | - $SAWTOOTH_SDK_PYTHON:/project/sawtooth-sdk-python 98 | expose: 99 | - 8008 100 | depends_on: 101 | - validator 102 | - rest-api 103 | command: nose2-3 104 | -c /project/sawtooth-sdk-python/tests/sawtooth_integration/nose2.cfg 105 | -v 106 | -s /project/sawtooth-sdk-python/tests/sawtooth_integration/tests 107 | test_intkey_cli.TestInkeyCli 108 | stop_signal: SIGKILL 109 | environment: 110 | PYTHONPATH: /project/sawtooth-sdk-python/tests:\ 111 | -------------------------------------------------------------------------------- /tests/sawtooth_integration/docker/test_systemd_services.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | version: "2.1" 17 | 18 | services: 19 | test-systemd-services: 20 | build: 21 | context: ../../.. 22 | dockerfile: ./tests/sawtooth_integration/docker/integration-tests.dockerfile 23 | args: 24 | - http_proxy 25 | - https_proxy 26 | - no_proxy 27 | image: integration-tests:$ISOLATION_ID 28 | volumes: 29 | - $SAWTOOTH_SDK_PYTHON:/project/sawtooth-sdk-python 30 | - /var/run/docker.sock:/var/run/docker.sock 31 | command: /project/sawtooth-sdk-python/tests/sawtooth_integration/tests/test_systemd.sh 32 | environment: 33 | ISOLATION_ID: ${ISOLATION_ID} 34 | -------------------------------------------------------------------------------- /tests/sawtooth_integration/nose2.cfg: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | [unittest] 16 | start-dir = tests 17 | code-directories = .. 18 | test-file-pattern = test*.py 19 | plugins = nose2.plugins.coverage 20 | 21 | [coverage] 22 | always-on = True 23 | -------------------------------------------------------------------------------- /tests/sawtooth_integration/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | -------------------------------------------------------------------------------- /tests/sawtooth_integration/tests/intkey_client.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | import logging 17 | import time 18 | from urllib.parse import urlparse, parse_qs 19 | 20 | from sawtooth_cli.rest_client import RestClient 21 | from sawtooth_cli.exceptions import CliException 22 | from sawtooth_cli.exceptions import RestClientException 23 | from sawtooth_intkey.intkey_message_factory import IntkeyMessageFactory 24 | 25 | LOGGER = logging.getLogger(__name__) 26 | 27 | 28 | class IntkeyClient(RestClient): 29 | def __init__(self, url, wait=30): 30 | super().__init__(url) 31 | self.url = url 32 | self.factory = IntkeyMessageFactory() 33 | self.wait = wait 34 | 35 | def send_txns(self, txns): 36 | batch = self.factory.create_batch(txns) 37 | 38 | attempts = 0 39 | response = None 40 | while True: 41 | try: 42 | response = self.send_batches(batch) 43 | id_query = urlparse(response['link']).query 44 | return parse_qs(id_query)['id'][0] 45 | except CliException: 46 | if attempts < 8: 47 | LOGGER.info('responding to back-pressure, retrying...') 48 | attempts += 1 49 | time.sleep(0.2 * (2 ** attempts)) 50 | else: 51 | raise 52 | 53 | def recent_block_signatures(self, tolerance): 54 | return self.list_block_signatures()[:tolerance] 55 | 56 | def list_block_signatures(self): 57 | return [block['header_signature'] for block in self.list_blocks()] 58 | 59 | def calculate_tolerance(self): 60 | length = len(list(self.list_blocks())) 61 | # the most recent nth of the chain, at least 2 blocks 62 | return max(2, length // 5) 63 | 64 | def poll_for_batches(self, batch_ids): 65 | """Poll timeout seconds for a batch status to become 66 | non-pending 67 | 68 | Args: 69 | batch_id (str): The id to get the status of 70 | """ 71 | time_waited = 0 72 | start_time = time.time() 73 | 74 | while time_waited < self.wait: 75 | 76 | res = self._get( 77 | '/batch_statuses', 78 | id=','.join(batch_ids), 79 | wait=(self.wait - time_waited)) 80 | 81 | if 'PENDING' not in [data['status'] for data in res['data']]: 82 | return 83 | 84 | time_waited = time.time() - start_time 85 | 86 | raise RestClientException( 87 | 'Request timed out after %d seconds' % self.wait) 88 | -------------------------------------------------------------------------------- /tests/sawtooth_integration/tests/test_intkey_cli.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | import unittest 17 | import logging 18 | import subprocess 19 | import shlex 20 | 21 | import cbor 22 | 23 | from sawtooth_integration.tests.integration_tools import wait_for_rest_apis 24 | from sawtooth_integration.tests.integration_tools import RestClient 25 | 26 | 27 | LOGGER = logging.getLogger(__name__) 28 | 29 | 30 | URL = 'http://rest-api:8008' 31 | WAIT = 300 32 | 33 | 34 | class IntkeyClient(RestClient): 35 | def __init__(self, url): 36 | super().__init__( 37 | url=url, 38 | namespace='1cf126') 39 | 40 | def get_keys(self): 41 | return { 42 | key: value 43 | for entry in self.get_data() 44 | for key, value in cbor.loads(entry).items() 45 | } 46 | 47 | 48 | class TestInkeyCli(unittest.TestCase): 49 | @classmethod 50 | def setUpClass(cls): 51 | wait_for_rest_apis([URL]) 52 | 53 | cls.client = IntkeyClient(url=URL) 54 | 55 | def test_intkey_cli(self): 56 | _send_command('sawtooth keygen') 57 | 58 | commands = ( 59 | 'set cat 5', # cat = 5 60 | 'inc cat 3', # cat = 8 61 | 'inc not-set 6', # invalid 62 | 'set dog 8', # dog = 8 63 | 'dec cat 4', # cat = 4 64 | 'dec dog 10', # invalid (can't go below 0) 65 | 'inc dog 100000000000', # invalid (can't go above 2**32) 66 | 'inc dog 3', # dog = 11 67 | ) 68 | 69 | for command in commands: 70 | _send_command( 71 | 'intkey {} --url {} --wait {}'.format( 72 | command, URL, WAIT)) 73 | 74 | display = ( 75 | 'show cat', 76 | 'show dog', 77 | 'show not-set', 78 | 'list' 79 | ) 80 | 81 | for command in display: 82 | # show not-set is expected to error 83 | try: 84 | _send_command( 85 | 'intkey {} --url {}'.format( 86 | command, URL)) 87 | except subprocess.CalledProcessError: 88 | continue 89 | 90 | self.assertEqual( 91 | self.client.get_keys(), 92 | { 93 | 'cat': 4, 94 | 'dog': 11 95 | }) 96 | 97 | 98 | def _send_command(command): 99 | return subprocess.run( 100 | shlex.split(command), check=True) 101 | -------------------------------------------------------------------------------- /tests/sawtooth_integration/tests/test_systemd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2017 Intel Corporation 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # ------------------------------------------------------------------------------ 16 | 17 | # A simple test to verify that the each systemd service is able to startup 18 | # without immediately crashing given the default arguments 19 | 20 | services=" 21 | intkey-tp-python 22 | xo-tp-python 23 | " 24 | 25 | if [ -z $ISOLATION_ID ] 26 | then 27 | ISOLATION_ID=latest 28 | fi 29 | 30 | for serv in $services 31 | do 32 | # 1. Create a docker container running systemd 33 | image=sawtooth-$serv:$ISOLATION_ID 34 | container=${ISOLATION_ID}_systemd_test_$serv 35 | service=sawtooth-$serv 36 | echo "Starting container '$container' from '$image'..." 37 | docker run -d --name $container --privileged --rm $image systemd 38 | sleep 1 # Give systemd a chance to start 39 | 40 | if [ $serv = "validator" ] 41 | then 42 | echo "Running keygen in $container..." 43 | docker exec $container sawadm keygen 44 | fi 45 | 46 | # 2. Start the systemd service in the container 47 | echo "Starting $service in $container..." 48 | docker exec $container systemctl start $service 49 | sleep 1 # Give the service a chance to fail 50 | 51 | # 3. Check if the service started successfully 52 | docker exec $container systemctl status $service 53 | exitcode=$? 54 | echo "Exit code was $exitcode" 55 | 56 | # 4. Cleanup the container 57 | docker kill $container 58 | 59 | if [ $exitcode -ne 0 ] 60 | then 61 | exit $exitcode 62 | fi 63 | done 64 | -------------------------------------------------------------------------------- /tests/sawtooth_integration/tests/test_workload.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | import unittest 17 | import time 18 | import logging 19 | import subprocess 20 | import shlex 21 | 22 | from sawtooth_cli.rest_client import RestClient 23 | from sawtooth_integration.tests.integration_tools import wait_for_rest_apis 24 | 25 | LOGGER = logging.getLogger(__name__) 26 | LOGGER.setLevel(logging.INFO) 27 | 28 | 29 | # the appropriateness of these parameters depends on 30 | # the rate at which blocks are published 31 | WORKLOAD_TIME = 5 32 | MINIMUM_BLOCK_COUNT = 3 33 | 34 | 35 | class TestWorkload(unittest.TestCase): 36 | @classmethod 37 | def setUpClass(cls): 38 | url = 'rest-api:8008' 39 | wait_for_rest_apis([url]) 40 | http = 'http://' + url 41 | cls.client = RestClient(http) 42 | cls.client.url = http 43 | 44 | def test_workload(self): 45 | workload_process = subprocess.Popen(shlex.split( 46 | 'intkey workload -u {}'.format( 47 | self.client.url))) 48 | 49 | # run workload for WORKLOAD_TIME seconds 50 | time.sleep(WORKLOAD_TIME) 51 | 52 | subprocess.run(shlex.split( 53 | 'sawtooth block list --url {}'.format(self.client.url)), 54 | check=True) 55 | 56 | blocks = self.client.list_blocks() 57 | 58 | # if workload is working, expect at least 59 | # MINIMUM_BLOCK_COUNT blocks to have been created 60 | self.assertGreaterEqual( 61 | len(list(blocks)), 62 | MINIMUM_BLOCK_COUNT, 63 | 'Not enough blocks; something is probably wrong with workload') 64 | 65 | workload_process.terminate() 66 | -------------------------------------------------------------------------------- /tests/signing-tests.dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Cargill Incorporated 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | FROM ubuntu:bionic 16 | 17 | RUN apt-get update \ 18 | && apt-get install gnupg -y 19 | 20 | RUN echo "deb http://repo.sawtooth.me/ubuntu/ci bionic universe" >> /etc/apt/sources.list \ 21 | && (apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 8AA7AF1F1091A5FD \ 22 | || apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 8AA7AF1F1091A5FD) \ 23 | && apt-get update \ 24 | && apt-get install -y -q \ 25 | git \ 26 | python3 \ 27 | python3-stdeb 28 | 29 | RUN apt-get install -y -q \ 30 | python3-grpcio \ 31 | python3-grpcio-tools \ 32 | python3-protobuf 33 | 34 | RUN apt-get install -y -q \ 35 | python3-secp256k1 36 | 37 | RUN apt-get install -y -q \ 38 | python3-cov-core \ 39 | python3-nose2 \ 40 | python3-pip 41 | 42 | RUN pip3 install \ 43 | coverage --upgrade 44 | 45 | ENV PATH=$PATH:/project/sawtooth-sdk-python/bin 46 | 47 | WORKDIR /project/sawtooth-sdk-python 48 | -------------------------------------------------------------------------------- /tests/unit_python_sdk.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | version: "2.1" 17 | 18 | services: 19 | 20 | unit-python-sdk: 21 | build: 22 | context: ../ 23 | dockerfile: tests/python-sdk-tests.dockerfile 24 | args: 25 | - http_proxy 26 | - https_proxy 27 | - no_proxy 28 | image: python-sdk-tests:$ISOLATION_ID 29 | volumes: 30 | - $SAWTOOTH_SDK_PYTHON:/project/sawtooth-sdk-python 31 | command: nose2-3 32 | -c /project/sawtooth-sdk-python/nose2.cfg 33 | -v 34 | -s /project/sawtooth-sdk-python/tests 35 | environment: 36 | PYTHONPATH: "/project/sawtooth-sdk-python" 37 | -------------------------------------------------------------------------------- /tests/unit_signing.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ------------------------------------------------------------------------------ 15 | 16 | version: "2.1" 17 | 18 | services: 19 | 20 | unit-signing: 21 | build: 22 | context: ../ 23 | dockerfile: tests/signing-tests.dockerfile 24 | args: 25 | - http_proxy 26 | - https_proxy 27 | - no_proxy 28 | image: signing-tests:$ISOLATION_ID 29 | volumes: 30 | - $SAWTOOTH_SDK_PYTHON:/project/sawtooth-sdk-python 31 | command: nose2-3 32 | -c /project/sawtooth-sdk-python/nose2.cfg 33 | -v 34 | -s /project/sawtooth-sdk-python/sawtooth_signing 35 | environment: 36 | PYTHONPATH: "/project/sawtooth-sdk-python/sawtooth_signing" 37 | --------------------------------------------------------------------------------