From 2b1a98768e5b04ffa9e81062f2b08a24192958bb Mon Sep 17 00:00:00 2001 From: joshua Date: Sun, 13 Feb 2022 12:17:21 -0500 Subject: [PATCH 1/2] Fix compilation with protoc Without package defined in all .proto files, output generation fails, e.g. joshua@cryptodevs[proto] protoc -I src --cpp_out=cpp src/*.proto blockchain_block_v1.proto:20:12: "blockchain_txn" is not defined. blockchain_block.proto: Import "blockchain_block_v1.proto" was not found or had errors. blockchain_block.proto:6:17: "blockchain_block_v1" is not defined. - With package defined, resolve conflict between enum and package namespace radio.proto:3:9: "helium.radio" is already defined (as something other than a package) in file "blockchain_txn_poc_receipts_v1.proto". - In src/service/gateway.proto, resolve warning on unused import --- src/blockchain_block.proto | 2 ++ src/blockchain_block_v1.proto | 2 ++ src/blockchain_gossip_handler.proto | 2 ++ src/blockchain_snapshot_handler.proto | 2 ++ src/blockchain_sync_handler.proto | 2 ++ src/blockchain_txn_poc_receipts_v1.proto | 4 ++-- src/service/gateway.proto | 1 - 7 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/blockchain_block.proto b/src/blockchain_block.proto index c280fd73..cb181727 100644 --- a/src/blockchain_block.proto +++ b/src/blockchain_block.proto @@ -1,5 +1,7 @@ syntax = "proto3"; +package helium; + import "blockchain_block_v1.proto"; message blockchain_block { diff --git a/src/blockchain_block_v1.proto b/src/blockchain_block_v1.proto index 2ab5005b..62c5b837 100644 --- a/src/blockchain_block_v1.proto +++ b/src/blockchain_block_v1.proto @@ -1,5 +1,7 @@ syntax = "proto3"; +package helium; + import "blockchain_txn.proto"; message blockchain_signature_v1 { diff --git a/src/blockchain_gossip_handler.proto b/src/blockchain_gossip_handler.proto index 344a5fb6..87bf2712 100644 --- a/src/blockchain_gossip_handler.proto +++ b/src/blockchain_gossip_handler.proto @@ -1,5 +1,7 @@ syntax = "proto3"; +package helium; + message blockchain_gossip_block { bytes from = 1; bytes block = 2; diff --git a/src/blockchain_snapshot_handler.proto b/src/blockchain_snapshot_handler.proto index 66cbfbcb..9483618a 100644 --- a/src/blockchain_snapshot_handler.proto +++ b/src/blockchain_snapshot_handler.proto @@ -1,5 +1,7 @@ syntax = "proto3"; +package helium; + message blockchain_snapshot_req { uint64 height = 1; bytes hash = 2; diff --git a/src/blockchain_sync_handler.proto b/src/blockchain_sync_handler.proto index 666056d6..cffe0500 100644 --- a/src/blockchain_sync_handler.proto +++ b/src/blockchain_sync_handler.proto @@ -1,5 +1,7 @@ syntax = "proto3"; +package helium; + message blockchain_sync_hash { bytes hash = 1; repeated uint64 heights = 2; diff --git a/src/blockchain_txn_poc_receipts_v1.proto b/src/blockchain_txn_poc_receipts_v1.proto index 2353a567..709ea1e2 100644 --- a/src/blockchain_txn_poc_receipts_v1.proto +++ b/src/blockchain_txn_poc_receipts_v1.proto @@ -2,8 +2,8 @@ syntax = "proto3"; package helium; enum origin { - p2p = 0; - radio = 1; + origin_p2p = 0; + origin_radio = 1; } message blockchain_poc_receipt_v1 { diff --git a/src/service/gateway.proto b/src/service/gateway.proto index 857a3fee..dd49e724 100644 --- a/src/service/gateway.proto +++ b/src/service/gateway.proto @@ -2,7 +2,6 @@ syntax = "proto3"; package helium; -import "blockchain_state_channel_v1.proto"; import "blockchain_txn_state_channel_close_v1.proto"; import "blockchain_txn_vars_v1.proto"; From 3669386366ffe2494eab42b4a1aa1d3522f972b0 Mon Sep 17 00:00:00 2001 From: joshua Date: Sun, 13 Feb 2022 13:08:31 -0500 Subject: [PATCH 2/2] Python build --- .github/workflows/python.yml | 33 +++++++++++++++++++++++++++++++ requirements.in | 1 + requirements.txt | 38 ++++++++++++++++++++++++++++++++++++ requirements_dev.txt | 1 + 4 files changed, 73 insertions(+) create mode 100644 .github/workflows/python.yml create mode 100644 requirements.in create mode 100644 requirements.txt create mode 100644 requirements_dev.txt diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml new file mode 100644 index 00000000..6cf80ac1 --- /dev/null +++ b/.github/workflows/python.yml @@ -0,0 +1,33 @@ +name: Python CI + +on: + push: + branches: [ master ] + tags: ['v*'] + pull_request: + branches: [ master ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.10 + uses: actions/setup-python@v2 + with: + python-version: "3.10" + - name: Install protoc + run: sudo apt install protobuf-compiler + - name: Install requirements + run: pip install -r requirements.txt + - name: Build python module + run: mkdir generated && protoc -I src --python_betterproto_out=generated/ src/*.proto src/service/*.proto + # Appears related to https://github.com/danielgtaylor/python-betterproto/issues/238 but we need the latest beta of + # betterproto to build src/service/*.proto + - name: Trim python module + run: sed -i '/from . import /d' generated/helium/__init__.py + - name: Python artifact + uses: actions/upload-artifact@v2 + with: + name: helium_proto + path: generated/helium diff --git a/requirements.in b/requirements.in new file mode 100644 index 00000000..f8f80252 --- /dev/null +++ b/requirements.in @@ -0,0 +1 @@ +betterproto[compiler]>=2.0.0b4,<3 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..583a3b25 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,38 @@ +# +# This file is autogenerated by pip-compile with python 3.10 +# To update, run: +# +# pip-compile +# +betterproto[compiler]==2.0.0b4 + # via -r requirements.in +black==22.1.0 + # via betterproto +click==8.0.3 + # via black +grpclib==0.4.2 + # via betterproto +h2==4.1.0 + # via grpclib +hpack==4.0.0 + # via h2 +hyperframe==6.0.1 + # via h2 +jinja2==2.11.3 + # via betterproto +markupsafe==2.0.1 + # via jinja2 +multidict==6.0.2 + # via grpclib +mypy-extensions==0.4.3 + # via black +pathspec==0.9.0 + # via black +platformdirs==2.5.0 + # via black +python-dateutil==2.8.2 + # via betterproto +six==1.16.0 + # via python-dateutil +tomli==2.0.1 + # via black diff --git a/requirements_dev.txt b/requirements_dev.txt new file mode 100644 index 00000000..a801cbb7 --- /dev/null +++ b/requirements_dev.txt @@ -0,0 +1 @@ +pip-tools>=6.5.1,<7