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

Hide channel id and endpoint from user and support https #210

Merged
merged 25 commits into from
Feb 15, 2019

Conversation

astroseger
Copy link
Collaborator

@astroseger astroseger commented Feb 14, 2019

This PR solves #201 and #208. It adds proper support for secure channels (https) and it significantly simplifies the life for users by hiding channel_id (and endpoints).

Example of workflow:

snet network ropsten

# open new channel only if you haven't done it already 
# It will not open new channel if you already have one!
snet channel open-init DappTesOrganization DappTesthttpsService 0.00001 +8days

# add funds if needed (for service which was opened for specific service)
snet channel extend-add-for-service DappTesOrganization DappTesthttpsService --amount 0.00001 --expiration +8days

# print list of initialized channels 
snet channel print-initialized

# make a call (you can use -y to remove price warning)
snet client call DappTesOrganization DappTesthttpsService mul '{"a":12,"b":7}'

# try claim timeout for ALL your channels (channels which have your as a sender)
snet channel claim-timeout-all

This PR does the following:

  • change directories struct in ~/.snet/mpe_client in order to make it more similar to @vforvalerio87 SDK. This new directories structure allows hiding channel_id from user.
    • Store compiled protobuf for service with <org_id> and <service_id> in ~/.snet/mpe_client/<mpe_address>_<registry_address>/<org_id>/<service_id>/service
    • Store initialized channels for this service in : ~/.snet/mpe_client/<mpe_address>_<registry_address>/<org_id>/<service_id>/channels
  • By default snet channel open-init will not open new channel if old channel for this service already exists. It will simply initialize existed channel.
  • snet client call has the following positional parameters: <org_id> <service_id> <method> <params>. User will need to manually specify channel_id only in case of multiply channels initialized for the same service (which, by default, is prevented in snet channel open-init).
  • make snet client call more faster by removing unnecessary blockchain call.
  • Remove price from list of obligatory parameter in snet client call. Instead, as was proposed by @arturgontijo, we have interactive confirmation. We have possibility to skip this confirmation by --yes/-y.
  • Change output of snet channel print-initialized to include org_id and service_id and remove unnecessary group_id
  • rename snet channel print-initialized-filter-group to snet channel print-initialized-filter-service because now it will print all initialized channels for whole service (not only for the specifc group). Change output to more informative similarly to snet channel print-initialized.
  • Add snet channel claim-timeout-all function which check ALL channels for the given identity and claim timeout for all expired channels.
  • Add snet channel extend-add-for-service function which add funds and extend expiration data for the channel which was opened for specific channel
  • (small change) In snet service update-metadata check that group_id or payment_address haven't been changed. We have possibility to force this change by --force
  • Add tests for all new functions and for some old ones (snet client call-lowlevel, snet client get-channel-state)

…l-state'. Also add tests for multiply endpoints in metadata (keeping tests for sinlge endpoint in metadata as well)
Copy link
Contributor

@arturgontijo arturgontijo left a comment

Choose a reason for hiding this comment

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

1 - Unused imports:

setup.py#L11			import glob

mpe_channel_command.py#L17	import json

mpe_client_command.py#L7	import os
				from snet_cli.mpe_service_metadata import load_mpe_service_metadata

utils_ipfs#L6			import sys

2 - Maybe we want to add minimal python version to:

setup.py#L44	python_requires='>=3.5'

3 - Whas about increment version (0.2.0 or even 0.1.10) at __init__.py?

4 - Typos (minor)
*** I'm not the best guy to propose it...feel free to ignore some of these suggestions.

arguments.py#L104	identies -> identities
arguments.py#L221	Informations -> Information
arguments.py#L373	currect -> current
arguments.py#L400	transfered -> transferred
arguments.py#L454	initilize -> initialize
arguments.py#L460	initilize -> initialize
arguments.py#L490	initilized -> initialized
arguments.py#L585	initilized -> initialized
arguments.py#L589	initilized -> initialized
arguments.py#L658	publising -> publishing

config.py#L159		get_all_identies_names() -> get_all_identities_names() # 4 Matches

mpe_channel_command.py#L109	canont -> can't
mpe_channel_command.py#L191	initilize -> initialize
mpe_channel_command.py#L233	initilized -> initialized
mpe_channel_command.py#L236	initilized -> initialized
mpe_channel_command.py#L240	_get_all_initilized_channels() -> _get_all_initialized_channels()
mpe_channel_command.py#L253	_get_initilized_channels_for_service() -> _get_initialized_channels_for_service()
mpe_channel_command.py#L272	initilized -> initialized
mpe_channel_command.py#L302	UNDIFINED -> UNDEFINED
mpe_channel_command.py#L382	_get_all_channels_filter_sender_recipeint_group -> _get_all_channels_filter_sender_recipient_group()

mpe_service_command.py#L121	opennned -> open

mpe_service_metadata.py#L65	unknow -> unknown

mpe_treasurer_command.py#L	incorect -> incorrect

utils_proto.py#L72		switch_to_json_payload_econding() -> switch_to_json_payload_encoding()

@arturgontijo
Copy link
Contributor

Wow...this one was awesome, @astroseger!

raise

def _init_or_update_service_from_metadata(self, metadata):
tmp_dir = tempfile.mkdtemp()
shutil.rmtree(tmp_dir)
Copy link
Member

Choose a reason for hiding this comment

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

We create and delete right away?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes... It is bad design. I will rewrite this function using tempfile.TemporaryDirectory pattern...

…m_metadata and _open_init_channel_from_metadata
@astroseger
Copy link
Collaborator Author

@raamb I've improved work with temporary directories. Could you approve :) ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants