Skip to content
This repository has been archived by the owner on Mar 6, 2023. It is now read-only.

Migrate to gRPC + direct protobuf signing #21

Merged
merged 5 commits into from
Dec 14, 2021

Conversation

macong-cdc
Copy link
Collaborator

Sorry for this huge merge request, below is a summary:

  • Set up project with pyproject.toml and poetry (I am following pystarport project. However, there are still some files I am not sure whether to keep or remove, like .bumpversion.cfg, .coveragerc, .mypy.ini)
  • Use gRPC direct signing for msgSend method. This library works with chain-main version 3.2.0, which should fix Problem: chainlibpy is incompatible with 0.43/0.44 #18
  • Add a test case with mock gRPC server, currently there is only one test case for get_balance method. (Note: the entire gRPC server is mocked for testing purposes, if we need more tests like this style, I could add more later.)

@tomtau tomtau requested review from leejw51crypto and yihuang and removed request for tomtau December 6, 2021 03:59
Comment on lines 13 to 15
python -m grpc.tools.protoc --proto_path=$COSMOS/proto --proto_path=$COSMOS/third_party/proto --python_out=$OUTPUT $(find $COSMOS/proto/cosmos -iname "*.proto") --grpc_python_out=$OUTPUT --plugin=protoc-gen-grpc_python=$PLUGIN
# cosmos third-party
python -m grpc.tools.protoc --proto_path=$COSMOS/proto --proto_path=$COSMOS/third_party/proto --python_out=$OUTPUT $(find $COSMOS/third_party/proto -iname "*.proto") --grpc_python_out=$OUTPUT --plugin=protoc-gen-grpc_python=$PLUGIN
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The latest commit will let developer add path to .proto files needed in generate_protos.sh. So we only generate gRPC code that we need instead of everything.

Comment on lines 14 to 23
run: python3 -m pip install --user --upgrade poetry
- name: build
run: python3 setup.py sdist bdist_wheel
- name: install jfrog
run: curl -fL https://getcli.jfrog.io | sh
- name: upload to jfrog
run: |
./jfrog rt config --url "${{ secrets.ARTIFACTORY_URL }}" --user "${{ secrets.ARTIFACTORY_USER }}" --access-token "${{ secrets.ARTIFACTORY_PASSWORD }}" --interactive=false
./jfrog rt u --build-name=Crypto-Blockchain-PYPI --build-number=${{ github.run_id }} --flat=true "dist/*" "${{ secrets.ARTIFACTORY_NAME }}" No newline at end of file
run: poetry build
- name: release
uses: softprops/action-gh-release@v1
with:
files: |
dist/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Copy link
Contributor

Choose a reason for hiding this comment

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

before the security team use asked us to use jfrog to upload to pypi, peotry can do the same, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For this part, I copied this GitHub workflow from pystarport. I checked with Huang Yi earlier, he said we just need to run the upload workflow and release on GitHub, then security team will pick up from there.

Comment on lines 1 to 25
from .basic import (DEFAULT_BECH32_HRP_BASE, Coin, CommissionRates, Content,
Description, Input, Output, StdFee, SyncMode,
TimeoutHeight, VoteOptionAbstain, VoteOptionNo,
VoteOptionNoWithVeto, VoteOptionUnspecified, VoteOptionYes)
from .signdoc import StdSignDoc

__all__ = [
"message",
"DEFAULT_BECH32_HRP_BASE",
"Coin",
"TimeoutHeight",
"CommissionRates",
"Content",
"Description",
"Input",
"Output",
"StdFee",
"StdSignDoc",
"SyncMode",
"VoteOptionAbstain",
"VoteOptionNo",
"VoteOptionNoWithVeto",
"VoteOptionUnspecified",
"VoteOptionYes",
]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should keep the amino protocol, because later it will be used in the multisign method.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In the new commit I pushed, I recovered all files under chainlibpy/amino directory. Thank you for pointing this out :)

@leejw51crypto
Copy link

could you squash commits into 1 commit?

branches:
- master
tags:
- 'v*.*.*'

Choose a reason for hiding this comment

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

why not using master?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I guess, by doing such, we could control when to release by adding a tag, instead of whenever there is a MR being merged to master branch.

README.md Outdated Show resolved Hide resolved
@macong-cdc
Copy link
Collaborator Author

could you squash commits into 1 commit?

Squash into a single commit might reduce readability for this merge request, as the content of the merge request is quite huge, this MR is almost rewriting the entire library.
I could try to squash into 2 commits with 1 focusing on setup changes and the other one focusing on code migration to gRPC.

@leejw51crypto
Copy link

looks ok

Copy link

@leejw51crypto leejw51crypto left a comment

Choose a reason for hiding this comment

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

lgtm

pyproject.toml Outdated
@@ -1,5 +1,68 @@
[tool.poetry]
name = "chainlibpy"
version = "2.0.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

version need to be updated to 2.1.0 I think, because it support the grpc now.

@linfeng-crypto linfeng-crypto merged commit 30b1da0 into crypto-org-chain:master Dec 14, 2021
@macong-cdc macong-cdc deleted the grpc branch December 14, 2021 02:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problem: chainlibpy is incompatible with 0.43/0.44
4 participants