Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python #119

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -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
madninja marked this conversation as resolved.
Show resolved Hide resolved
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
madninja marked this conversation as resolved.
Show resolved Hide resolved
- name: Python artifact
uses: actions/upload-artifact@v2
with:
name: helium_proto
path: generated/helium
1 change: 1 addition & 0 deletions requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
betterproto[compiler]>=2.0.0b4,<3
38 changes: 38 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pip-tools>=6.5.1,<7
2 changes: 2 additions & 0 deletions src/blockchain_block.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
syntax = "proto3";

package helium;

import "blockchain_block_v1.proto";

message blockchain_block {
Expand Down
2 changes: 2 additions & 0 deletions src/blockchain_block_v1.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
syntax = "proto3";

package helium;

import "blockchain_txn.proto";

message blockchain_signature_v1 {
Expand Down
2 changes: 2 additions & 0 deletions src/blockchain_gossip_handler.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
syntax = "proto3";

package helium;

message blockchain_gossip_block {
bytes from = 1;
bytes block = 2;
Expand Down
2 changes: 2 additions & 0 deletions src/blockchain_snapshot_handler.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
syntax = "proto3";

package helium;

message blockchain_snapshot_req {
uint64 height = 1;
bytes hash = 2;
Expand Down
2 changes: 2 additions & 0 deletions src/blockchain_sync_handler.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
syntax = "proto3";

package helium;

message blockchain_sync_hash {
bytes hash = 1;
repeated uint64 heights = 2;
Expand Down
4 changes: 2 additions & 2 deletions src/blockchain_txn_poc_receipts_v1.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ syntax = "proto3";
package helium;

enum origin {
p2p = 0;
radio = 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don’t rename fields

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was done due to the following error:

radio.proto:3:9: "helium.radio" is already defined (as something other than a package) in file "blockchain_txn_poc_receipts_v1.proto".

This appears to be an issue with protobuf namespacing, I'm not sure why things that aren't protoc didn't care and I made this change based on a recommendation in an SO answer from one of protobuf's original authors about how to handle these conflicts. If there is an alternate method that wouldn't break the naming that'd be preferable, but I am unaware of what that would be.

Copy link
Member

@madninja madninja Feb 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that it'll break existing erlang and rust users of this message. Perhaps we're missing a protoc option here since Prost (rust) uses protoc under the hood and does not appear to have this issue

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will try to dig into those a little bit more to compare, thanks for the tip.

origin_p2p = 0;
origin_radio = 1;
}

message blockchain_poc_receipt_v1 {
Expand Down
1 change: 0 additions & 1 deletion src/service/gateway.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ syntax = "proto3";

package helium;

import "blockchain_state_channel_v1.proto";
madninja marked this conversation as resolved.
Show resolved Hide resolved
import "blockchain_txn_state_channel_close_v1.proto";
import "blockchain_txn_vars_v1.proto";

Expand Down